Autopromotion:
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Mon, 14 Jan 2008 18:52:55 +0000 (18:52 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Mon, 14 Jan 2008 18:52:55 +0000 (18:52 +0000)
* Add APCOND_INGROUPS
* Fix comment
* Don't use array_unique() since we have groups as *keys* of $wgAutopromote

RELEASE-NOTES
includes/Autopromote.php
includes/Defines.php
includes/User.php

index 6291317..f4ceed6 100644 (file)
@@ -132,6 +132,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 12536) User should be able to get MediaWiki version from any page
 * (bug 12622) A JavaScript constant to declare whether api.php is available
 * Add caching to the AJAX search
+* Added APCOND_INGROUPS
 
 
 === Bug fixes in 1.12 ===
index 76d6f2a..b509742 100644 (file)
@@ -18,7 +18,7 @@ class Autopromote {
                        if( self::recCheckCondition( $cond, $user ) )
                                $promote[] = $group;
                }
-               return array_unique( $promote );
+               return $promote;
        }
 
        /**
@@ -98,6 +98,9 @@ class Autopromote {
                        case APCOND_AGE:
                                $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
                                return $age >= $cond[1];
+                       case APCOND_INGROUPS:
+                               $groups = array_slice( $cond, 1 );
+                               return count( array_intersect( $groups, $user->getGroups() ) ) == count( $groups );
                        default:
                                $result = null;
                                wfRunHooks( 'AutopromoteCondition', array( $cond[0], array_slice( $cond, 1 ), $user, &$result ) );
index 69096be..1a62d45 100644 (file)
@@ -282,3 +282,4 @@ define( 'RLH_FOR_UPDATE', 1 );
 define( 'APCOND_EDITCOUNT', 1 );
 define( 'APCOND_AGE', 2 );
 define( 'APCOND_EMAILCONFIRMED', 3 );
+define( 'APCOND_INGROUPS', 4 );
\ No newline at end of file
index 6734c32..08bf83c 100644 (file)
@@ -1639,8 +1639,8 @@ class User {
 
        /**
         * Get the list of implicit group memberships this user has.
-        * This includes all explicit groups, plus 'user' if logged in
-        * and '*' for all accounts.
+        * This includes all explicit groups, plus 'user' if logged in,
+        * '*' for all accounts and autopromoted groups
         * @param boolean $recache Don't use the cache
         * @return array of strings
         */