'import',
'importupload',
'ipblock-exempt',
+ 'managechangetags',
'markbotedits',
'mergehistory',
'minoredit',
if ( $this->mLoadedItems === true ) {
return;
}
- wfProfileIn( __METHOD__ );
// Set it now to avoid infinite recursion in accessors
$this->mLoadedItems = true;
Hooks::run( 'UserLoadAfterLoadFromSession', array( $this ) );
break;
default:
- wfProfileOut( __METHOD__ );
throw new MWException( "Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
}
- wfProfileOut( __METHOD__ );
}
/**
* @param string|bool $name
*/
public function loadDefaults( $name = false ) {
- wfProfileIn( __METHOD__ );
$passwordFactory = self::getPasswordFactory();
Hooks::run( 'UserLoadDefaults', array( $this, $name ) );
- wfProfileOut( __METHOD__ );
}
/**
return;
}
- wfProfileIn( __METHOD__ );
wfDebug( __METHOD__ . ": checking...\n" );
// Initialize data...
// Extensions
Hooks::run( 'GetBlockedStatus', array( &$this ) );
- wfProfileOut( __METHOD__ );
}
/**
* @return bool True if blacklisted.
*/
public function inDnsBlacklist( $ip, $bases ) {
- wfProfileIn( __METHOD__ );
$found = false;
// @todo FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170)
}
}
- wfProfileOut( __METHOD__ );
return $found;
}
if ( !$wgProxyList ) {
return false;
}
- wfProfileIn( __METHOD__ );
if ( !is_array( $wgProxyList ) ) {
// Load from the specified file
} else {
$ret = false;
}
- wfProfileOut( __METHOD__ );
return $ret;
}
}
global $wgMemc;
- wfProfileIn( __METHOD__ );
- wfProfileIn( __METHOD__ . '-' . $action );
$limits = $wgRateLimits[$action];
$keys = array();
}
}
- wfProfileOut( __METHOD__ . '-' . $action );
- wfProfileOut( __METHOD__ );
return $triggered;
}
*/
public function isBlockedFrom( $title, $bFromSlave = false ) {
global $wgBlockAllowsUTEdit;
- wfProfileIn( __METHOD__ );
$blocked = $this->isBlocked( $bFromSlave );
$allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false );
Hooks::run( 'UserIsBlockedFrom', array( $this, $title, &$blocked, &$allowUsertalk ) );
- wfProfileOut( __METHOD__ );
return $blocked;
}
*/
public function getEffectiveGroups( $recache = false ) {
if ( $recache || is_null( $this->mEffectiveGroups ) ) {
- wfProfileIn( __METHOD__ );
$this->mEffectiveGroups = array_unique( array_merge(
$this->getGroups(), // explicit groups
$this->getAutomaticGroups( $recache ) // implicit groups
Hooks::run( 'UserEffectiveGroups', array( &$this, &$this->mEffectiveGroups ) );
// Force reindexation of groups when a hook has unset one of them
$this->mEffectiveGroups = array_values( array_unique( $this->mEffectiveGroups ) );
- wfProfileOut( __METHOD__ );
}
return $this->mEffectiveGroups;
}
*/
public function getAutomaticGroups( $recache = false ) {
if ( $recache || is_null( $this->mImplicitGroups ) ) {
- wfProfileIn( __METHOD__ );
$this->mImplicitGroups = array( '*' );
if ( $this->getId() ) {
$this->mImplicitGroups[] = 'user';
// as getEffectiveGroups() depends on this function
$this->mEffectiveGroups = null;
}
- wfProfileOut( __METHOD__ );
}
return $this->mImplicitGroups;
}
if ( $this->mEditCount === null ) {
/* Populate the count, if it has not been populated yet */
- wfProfileIn( __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );
// check if the user_editcount field has been initialized
$count = $dbr->selectField(
$count = $this->initEditCount();
}
$this->mEditCount = $count;
- wfProfileOut( __METHOD__ );
}
return (int)$this->mEditCount;
}
* Add the user to the given group.
* This takes immediate effect.
* @param string $group Name of the group to add
+ * @return bool
*/
public function addGroup( $group ) {
- if ( Hooks::run( 'UserAddGroup', array( $this, &$group ) ) ) {
- $dbw = wfGetDB( DB_MASTER );
- if ( $this->getId() ) {
- $dbw->insert( 'user_groups',
- array(
- 'ug_user' => $this->getID(),
- 'ug_group' => $group,
- ),
- __METHOD__,
- array( 'IGNORE' ) );
- }
+ if ( !Hooks::run( 'UserAddGroup', array( $this, &$group ) ) ) {
+ return false;
}
+
+ $dbw = wfGetDB( DB_MASTER );
+ if ( $this->getId() ) {
+ $dbw->insert( 'user_groups',
+ array(
+ 'ug_user' => $this->getID(),
+ 'ug_group' => $group,
+ ),
+ __METHOD__,
+ array( 'IGNORE' ) );
+ }
+
$this->loadGroups();
$this->mGroups[] = $group;
// In case loadGroups was not called before, we now have the right twice.
$this->mRights = null;
$this->invalidateCache();
+
+ return true;
}
/**
* Remove the user from the given group.
* This takes immediate effect.
* @param string $group Name of the group to remove
+ * @return bool
*/
public function removeGroup( $group ) {
$this->load();
- if ( Hooks::run( 'UserRemoveGroup', array( $this, &$group ) ) ) {
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'user_groups',
- array(
- 'ug_user' => $this->getID(),
- 'ug_group' => $group,
- ), __METHOD__ );
- // Remember that the user was in this group
- $dbw->insert( 'user_former_groups',
- array(
- 'ufg_user' => $this->getID(),
- 'ufg_group' => $group,
- ),
- __METHOD__,
- array( 'IGNORE' ) );
+ if ( !Hooks::run( 'UserRemoveGroup', array( $this, &$group ) ) ) {
+ return false;
}
+
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->delete( 'user_groups',
+ array(
+ 'ug_user' => $this->getID(),
+ 'ug_group' => $group,
+ ), __METHOD__
+ );
+ // Remember that the user was in this group
+ $dbw->insert( 'user_former_groups',
+ array(
+ 'ufg_user' => $this->getID(),
+ 'ufg_group' => $group,
+ ),
+ __METHOD__,
+ array( 'IGNORE' )
+ );
+
$this->loadGroups();
$this->mGroups = array_diff( $this->mGroups, array( $group ) );
$this->mRights = null;
$this->invalidateCache();
+
+ return true;
}
/**
public function checkPassword( $password ) {
global $wgAuth, $wgLegacyEncoding;
- $section = new ProfileSection( __METHOD__ );
-
$this->loadPasswords();
// Certain authentication plugins do NOT want to save
if ( $title ) {
return Linker::link( $title, htmlspecialchars( $text ) );
} else {
- return $text;
+ return htmlspecialchars( $text );
}
}
if ( $action === true ) {
$action = 'byemail';
} elseif ( $action === false ) {
- if ( $this->getName() == $wgUser->getName() ) {
+ if ( $this->equals( $wgUser ) ) {
$action = 'create';
} else {
$action = 'create2';
return Status::newFatal( 'badaccess-group0' );
}
}
+
+ /**
+ * Checks if two user objects point to the same user.
+ *
+ * @since 1.25
+ * @param User $user
+ * @return bool
+ */
+ public function equals( User $user ) {
+ return $this->getName() === $user->getName();
+ }
}