From: Aaron Schulz Date: Sat, 3 Jan 2009 12:53:08 +0000 (+0000) Subject: (bug 14737) Allow the autoconfirmed timer to run from the first edit X-Git-Tag: 1.31.0-rc.0~43585 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=1f3f3146091d06fd7e20854c97df87b3d96f7db4;p=lhc%2Fweb%2Fwiklou.git (bug 14737) Allow the autoconfirmed timer to run from the first edit --- diff --git a/includes/Autopromote.php b/includes/Autopromote.php index e4df13316c..c8a4c03b27 100644 --- a/includes/Autopromote.php +++ b/includes/Autopromote.php @@ -106,6 +106,9 @@ class Autopromote { case APCOND_AGE: $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); return $age >= $cond[1]; + case APCOND_AGE_FROM_EDIT: + $age = time() - wfTimestampOrNull( TS_UNIX, $user->getFirstEditTimestamp() ); + return $age >= $cond[1]; case APCOND_INGROUPS: $groups = array_slice( $cond, 1 ); return count( array_intersect( $groups, $user->getGroups() ) ) == count( $groups ); diff --git a/includes/Defines.php b/includes/Defines.php index e9d8e15073..8de6c5a1a6 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -226,3 +226,4 @@ define( 'APCOND_EMAILCONFIRMED', 3 ); define( 'APCOND_INGROUPS', 4 ); define( 'APCOND_ISIP', 5 ); define( 'APCOND_IPINRANGE', 6 ); +define( 'APCOND_AGE_FROM_EDIT', 7 ); diff --git a/includes/User.php b/includes/User.php index 2721dc5a1e..17abe51550 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2989,10 +2989,28 @@ class User { * non-existent/anonymous user accounts. */ public function getRegistration() { - return $this->mId > 0 + return $this->getId() > 0 ? $this->mRegistration : false; } + + /** + * Get the timestamp of the first edit + * + * @return \types{\string,\bool} string Timestamp of first edit, or false for + * non-existent/anonymous user accounts. + */ + public function getFirstEditTimestamp() { + if( $this->getId() == 0 ) return false; // anons + $dbr = wfGetDB( DB_SLAVE ); + $time = $dbr->selectField( 'revision', 'rev_timestamp', + array( 'rev_user' => $this->getId() ), + __METHOD__, + array( 'ORDER BY' => 'rev_timestamp ASC' ) + ); + if( !$time ) return false; // no edits + return wfTimestamp( TS_MW, $time ); + } /** * Get the permissions associated with a given list of groups