remove the groups specified in $wgAddGroups and $wgRemoveGroups for
any groups they are in.
* New permission userrights-interwiki for changing user rights on foreign wikis.
+* $wgImplictGroups for groups that are hidden from Special:Listusers, etc.
+* $wgAutopromote: automatically promote user flags when user matches
+ criterias
=== New features in 1.12 ===
* (bug 10735) Add a warning for non-descriptive filenames at Special:Upload
'AlphabeticPager' => 'includes/Pager.php',
'Article' => 'includes/Article.php',
'AuthPlugin' => 'includes/AuthPlugin.php',
+ 'Autopromote' => 'includes/Autopromote.php',
'BagOStuff' => 'includes/BagOStuff.php',
'HashBagOStuff' => 'includes/BagOStuff.php',
'SqlBagOStuff' => 'includes/BagOStuff.php',
--- /dev/null
+<?php
+
+/**
+ * This class checks if user can get extra rights
+ * because of conditions specified in $wgAutopromote
+ */
+class Autopromote {
+ public static function autopromoteUser( $user ) {
+ global $wgAutopromote;
+ $promote = array();
+ foreach( $wgAutopromote as $group => $cond ) {
+ if( self::recCheckCondition( $cond, $user ) )
+ $promote[] = $group;
+ }
+ return $promote;
+ }
+
+ //@private
+ static function recCheckCondition( $cond, $user ) {
+ $validOps = array( '&', '|', '^' );
+ if( is_array( $cond ) && count( $cond ) > 0 && in_array( $cond[0], $validOps ) ) {
+ if( $cond[0] == '&' ) {
+ foreach( array_slice( $cond, 1 ) as $subcond )
+ if( !self::recCheckCondition( $subcond, $user ) )
+ return false;
+ return true;
+ } elseif( $cond[0] == '|' ) {
+ foreach( array_slice( $cond, 1 ) as $subcond )
+ if( self::recCheckCondition( $subcond, $user ) )
+ return true;
+ return false;
+ } elseif( $cond[0] == '^' ) {
+ if( count( $cond ) < 3 )
+ return false;
+ return self::recCheckCondition( $cond[1], $user )
+ xor self::recCheckCondition( $cond[2], $user );
+ }
+ }
+ if( !is_array( $cond ) )
+ $cond = array( $cond );
+ return self::checkCondition( $cond, $user );
+ }
+
+ static function checkCondition( $cond, $user ) {
+ if( count( $cond ) < 1 )
+ return false;
+ switch( $cond[0] ) {
+ case APCOND_EMAILCONFIRMED:
+ if( User::isValidEmailAddr( $user->getEmail() ) ) {
+ global $wgEmailAuthentication;
+ if( $wgEmailAuthentication ) {
+ return boolval( $user->getEmailAuthenticationTimestamp() );
+ } else {
+ return true;
+ }
+ }
+ return false;
+ case APCOND_EDITCOUNT:
+ return $user->getEditCount() > $cond[1];
+ case APCOND_AGE:
+ $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
+ return $age >= $cond[1];
+ case APCOND_INGROUPS:
+ default:
+ $result = false;
+ wfRunHooks( 'AutopromoteCondition', array( $cond[0], array_slice( $cond, 1 ), &$result ) );
+ return $result;
+ }
+ }
+}
\ No newline at end of file
*/
# $wgGroupPermissions['developer']['siteadmin'] = true;
+
+/**
+ * Implicit groups, aren't shown on Special:Listusers or somewhere else
+ */
+$wgImplicitGroups = array( '*', 'user', 'autoconfirmed', 'emailconfirmed' );
+
/**
* Set of available actions that can be restricted via action=protect
* You probably shouldn't change this.
$wgAutoConfirmCount = 0;
//$wgAutoConfirmCount = 50;
+/**
+ * Automatically promote user flags to users that matchs some conditions
+ */
+$wgAutopromote = array(
+ 'autoconfirmed' => array( '&',
+ array( APCOND_EDITCOUNT, &$wgAutoConfirmCount ),
+ array( APCOND_AGE, &$wgAutoConfirmAge ),
+ ),
+ 'emailconfirmed' => APCOND_EMAILCONFIRMED,
+);
+
/**
* These settings can be used to give finer control over who can assign which
* groups at Special:Userrights. Example configuration:
# Flags for Parser::replaceLinkHolders
define( 'RLH_FOR_UPDATE', 1 );
+#Autopromote conditions
+define( 'APCOND_EDITCOUNT', 1 );
+define( 'APCOND_AGE', 2 );
+define( 'APCOND_EMAILCONFIRMED', 3 );
$this->mEffectiveGroups[] = '*';
if( $this->mId ) {
$this->mEffectiveGroups[] = 'user';
-
- global $wgAutoConfirmAge, $wgAutoConfirmCount;
- $accountAge = time() - wfTimestampOrNull( TS_UNIX, $this->mRegistration );
- if( $accountAge >= $wgAutoConfirmAge && $this->getEditCount() >= $wgAutoConfirmCount ) {
- $this->mEffectiveGroups[] = 'autoconfirmed';
- }
- # Implicit group for users whose email addresses are confirmed
- global $wgEmailAuthentication;
- if( self::isValidEmailAddr( $this->mEmail ) ) {
- if( $wgEmailAuthentication ) {
- if( $this->mEmailAuthenticated )
- $this->mEffectiveGroups[] = 'emailconfirmed';
- } else {
- $this->mEffectiveGroups[] = 'emailconfirmed';
- }
- }
+ $this->mEffectiveGroups = array_merge(
+ $this->mEffectiveGroups,
+ Autopromote::autopromoteUser( $this )
+ );
+
# Hook for additional groups
wfRunHooks( 'UserEffectiveGroups', array( &$this, &$this->mEffectiveGroups ) );
}
* @return array
*/
public static function getImplicitGroups() {
- static $groups = null;
- if( !is_array( $groups ) ) {
- $groups = array( '*', 'user', 'autoconfirmed', 'emailconfirmed' );
- wfRunHooks( 'UserGetImplicitGroups', array( &$groups ) );
- }
+ global $wgImplicitGroups;
+ $groups = $wgImplicitGroups;
+ wfRunHooks( 'UserGetImplicitGroups', array( &$groups ) ); #deprecated, use $wgImplictGroups instead
return $groups;
}