Index: trunk/phase3/includes/Defines.php |
— | — | @@ -226,3 +226,4 @@ |
227 | 227 | define( 'APCOND_INGROUPS', 4 ); |
228 | 228 | define( 'APCOND_ISIP', 5 ); |
229 | 229 | define( 'APCOND_IPINRANGE', 6 ); |
| 230 | +define( 'APCOND_AGE_FROM_EDIT', 7 ); |
Index: trunk/phase3/includes/User.php |
— | — | @@ -2989,10 +2989,28 @@ |
2990 | 2990 | * non-existent/anonymous user accounts. |
2991 | 2991 | */ |
2992 | 2992 | public function getRegistration() { |
2993 | | - return $this->mId > 0 |
| 2993 | + return $this->getId() > 0 |
2994 | 2994 | ? $this->mRegistration |
2995 | 2995 | : false; |
2996 | 2996 | } |
| 2997 | + |
| 2998 | + /** |
| 2999 | + * Get the timestamp of the first edit |
| 3000 | + * |
| 3001 | + * @return \types{\string,\bool} string Timestamp of first edit, or false for |
| 3002 | + * non-existent/anonymous user accounts. |
| 3003 | + */ |
| 3004 | + public function getFirstEditTimestamp() { |
| 3005 | + if( $this->getId() == 0 ) return false; // anons |
| 3006 | + $dbr = wfGetDB( DB_SLAVE ); |
| 3007 | + $time = $dbr->selectField( 'revision', 'rev_timestamp', |
| 3008 | + array( 'rev_user' => $this->getId() ), |
| 3009 | + __METHOD__, |
| 3010 | + array( 'ORDER BY' => 'rev_timestamp ASC' ) |
| 3011 | + ); |
| 3012 | + if( !$time ) return false; // no edits |
| 3013 | + return wfTimestamp( TS_MW, $time ); |
| 3014 | + } |
2997 | 3015 | |
2998 | 3016 | /** |
2999 | 3017 | * Get the permissions associated with a given list of groups |
Index: trunk/phase3/includes/Autopromote.php |
— | — | @@ -106,6 +106,9 @@ |
107 | 107 | case APCOND_AGE: |
108 | 108 | $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); |
109 | 109 | return $age >= $cond[1]; |
| 110 | + case APCOND_AGE_FROM_EDIT: |
| 111 | + $age = time() - wfTimestampOrNull( TS_UNIX, $user->getFirstEditTimestamp() ); |
| 112 | + return $age >= $cond[1]; |
110 | 113 | case APCOND_INGROUPS: |
111 | 114 | $groups = array_slice( $cond, 1 ); |
112 | 115 | return count( array_intersect( $groups, $user->getGroups() ) ) == count( $groups ); |