(bug 14737) Allow the autoconfirmed timer to run from the first edit
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 3 Jan 2009 12:53:08 +0000 (12:53 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 3 Jan 2009 12:53:08 +0000 (12:53 +0000)
includes/Autopromote.php
includes/Defines.php
includes/User.php

index e4df133..c8a4c03 100644 (file)
@@ -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 );
index e9d8e15..8de6c5a 100644 (file)
@@ -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 );
index 2721dc5..17abe51 100644 (file)
@@ -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