Go to the documentation of this file.
27 define(
'USER_TOKEN_LENGTH', 32 );
33 define(
'MW_USER_VERSION', 9 );
39 define(
'EDIT_TOKEN_SUFFIX',
'+\\' );
90 'mEmailAuthenticated',
134 'editusercssjs', #deprecated
146 'move-rootuserpages',
150 'override-export-depth',
173 'userrights-interwiki',
274 public function load() {
275 if ( $this->mLoadedItems ===
true ) {
281 $this->mLoadedItems =
true;
283 switch ( $this->mFrom ) {
308 throw new MWException(
"Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
319 if ( $this->mId == 0 ) {
325 $key =
wfMemcKey(
'user',
'id', $this->mId );
333 wfDebug(
"User: cache miss for user {$this->mId}\n" );
341 wfDebug(
"User: got user {$this->mId} from cache\n" );
343 foreach ( self::$mCacheVars
as $name ) {
344 $this->$name = $data[
$name];
348 $this->mLoadedItems =
true;
365 foreach ( self::$mCacheVars
as $name ) {
366 $data[
$name] = $this->$name;
369 $key =
wfMemcKey(
'user',
'id', $this->mId );
394 if ( $validate ===
true ) {
398 if (
$name ===
false ) {
405 $u->setItemLoaded(
'name' );
416 public static function newFromId( $id ) {
420 $u->setItemLoaded(
'id' );
436 $id =
$dbr->selectField(
'user',
'user_id',
array(
437 'user_email_token' => md5( $code ),
438 'user_email_token_expires > ' .
$dbr->addQuotes(
$dbr->timestamp() ),
440 if ( $id !==
false ) {
456 $user->mFrom =
'session';
457 $user->mRequest = $request;
475 public static function newFromRow( $row, $data =
null ) {
477 $user->loadFromRow( $row, $data );
488 public static function whoIs( $id ) {
498 public static function whoIsReal( $id ) {
509 if ( is_null( $nt ) ) {
514 if ( isset( self::$idCacheByName[
$name] ) ) {
515 return self::$idCacheByName[
$name];
519 $s =
$dbr->selectRow(
'user',
array(
'user_id' ),
array(
'user_name' => $nt->getText() ), __METHOD__ );
521 if (
$s ===
false ) {
529 if ( count( self::$idCacheByName ) > 1000 ) {
530 self::$idCacheByName =
array();
540 self::$idCacheByName =
array();
560 return preg_match(
'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/',
$name ) ||
IP::isIPv6(
$name );
579 || strpos(
$name,
'/' ) !==
false
580 || strlen(
$name ) > $wgMaxNameChars
583 ": '$name' invalid due to empty, IP, slash, length, or lowercase" );
590 if ( is_null( $parsed )
591 || $parsed->getNamespace()
592 || strcmp(
$name, $parsed->getPrefixedText() ) ) {
594 ": '$name' invalid due to ambiguous prefixes" );
600 $unicodeBlacklist =
'/[' .
601 '\x{0080}-\x{009f}' . # iso-8859-1 control chars
602 '\x{00a0}' . # non-breaking space
603 '\x{2000}-\x{200f}' . # various whitespace
604 '\x{2028}-\x{202f}' . # breaks and control chars
605 '\x{3000}' . # ideographic space
606 '\x{e000}-\x{f8ff}' . #
private use
608 if ( preg_match( $unicodeBlacklist,
$name ) ) {
610 ": '$name' invalid due to blacklisted characters" );
629 global $wgReservedUsernames;
631 if ( !self::isValidUserName(
$name ) ) {
635 static $reservedUsernames =
false;
636 if ( !$reservedUsernames ) {
637 $reservedUsernames = $wgReservedUsernames;
642 foreach ( $reservedUsernames
as $reserved ) {
643 if ( substr( $reserved, 0, 4 ) ==
'msg:' ) {
644 $reserved =
wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
646 if ( $reserved ==
$name ) {
666 global $wgInvalidUsernameCharacters;
671 if ( strlen(
$name ) > 235 ) {
673 ": '$name' invalid due to length" );
678 if ( $wgInvalidUsernameCharacters !==
'' ) {
679 if ( preg_match(
'/[' . preg_quote( $wgInvalidUsernameCharacters,
'/' ) .
']/',
$name ) ) {
681 ": '$name' invalid due to wgInvalidUsernameCharacters" );
716 foreach (
$result->getErrorsByType(
'warning' )
as $warning ) {
737 static $blockedLogins =
array(
738 'Useruser' =>
'Passpass',
'Useruser1' =>
'Passpass1', # r75589
739 'Apitestsysop' =>
'testpass',
'Apitestuser' =>
'testpass' # r75605
752 if ( strlen(
$password ) < $wgMinimalPasswordLength ) {
753 $status->error(
'passwordtooshort', $wgMinimalPasswordLength );
756 $status->error(
'password-name-match' );
759 $status->error(
'password-login-forbidden' );
768 } elseif (
$result ===
true ) {
794 global $wgPasswordExpirationDays;
799 if ( $wgPasswordExpirationDays ) {
802 time() + ( $wgPasswordExpirationDays * 24 * 3600 )
807 $this->mPasswordExpires = $newExpire;
820 global $wgPasswordExpireGrace;
825 if ( $expiration !==
null && $expUnix < $now ) {
826 $expired = ( $expUnix + $wgPasswordExpireGrace < $now ) ?
'hard' :
'soft';
893 # Reject names containing '#'; these will be cleaned up
894 # with title normalisation, but then it's too late to
896 if ( strpos(
$name,
'#' ) !==
false ) {
901 $t = ( $validate ===
'valid' ) ?
904 if ( is_null(
$t ) ) {
910 $name = $wgAuth->getCanonicalName(
$t->getText() );
912 switch ( $validate ) {
931 throw new MWException(
'Invalid parameter value for $validate in ' . __METHOD__ );
944 public static function edits( $uid ) {
947 return $user->getEditCount();
956 global $wgMinimalPasswordLength;
958 $length = max( 10, $wgMinimalPasswordLength );
960 $length = $length * 1.25;
979 $this->mName =
$name;
980 $this->mRealName =
'';
981 $this->mPassword = $this->mNewpassword =
'';
982 $this->mNewpassTime =
null;
984 $this->mOptionOverrides =
null;
985 $this->mOptionsLoaded =
false;
987 $loggedOut = $this->
getRequest()->getCookie(
'LoggedOut' );
988 if ( $loggedOut !==
null ) {
991 $this->mTouched =
'1'; # Allow any
pages to be cached
994 $this->mToken =
null;
995 $this->mEmailAuthenticated =
null;
996 $this->mEmailToken =
'';
997 $this->mEmailTokenExpires =
null;
998 $this->mPasswordExpires =
null;
1001 $this->mGroups =
array();
1021 return ( $this->mLoadedItems ===
true && $all ===
'all' ) ||
1022 ( isset( $this->mLoadedItems[$item] ) && $this->mLoadedItems[$item] ===
true );
1031 if ( is_array( $this->mLoadedItems ) ) {
1032 $this->mLoadedItems[$item] =
true;
1049 $cookieId = $request->getCookie(
'UserID' );
1050 $sessId = $request->getSessionData(
'wsUserID' );
1052 if ( $cookieId !==
null ) {
1053 $sId = intval( $cookieId );
1054 if ( $sessId !==
null && $cookieId != $sessId ) {
1055 wfDebugLog(
'loginSessions',
"Session user ID ($sessId) and
1056 cookie user ID ($sId) don't match!" );
1059 $request->setSessionData(
'wsUserID', $sId );
1060 } elseif ( $sessId !==
null && $sessId != 0 ) {
1066 if ( $request->getSessionData(
'wsUserName' ) !== null ) {
1067 $sName = $request->getSessionData(
'wsUserName' );
1068 } elseif ( $request->getCookie(
'UserName' ) !== null ) {
1069 $sName = $request->getCookie(
'UserName' );
1070 $request->setSessionData(
'wsUserName', $sName );
1076 if ( !$proposedUser->isLoggedIn() ) {
1081 global $wgBlockDisablesLogin;
1082 if ( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
1087 if ( $request->getSessionData(
'wsToken' ) ) {
1088 $passwordCorrect = ( $proposedUser->getToken(
false ) === $request->getSessionData(
'wsToken' ) );
1090 } elseif ( $request->getCookie(
'Token' ) ) {
1091 # Get the token from DB/cache and clean it up to remove garbage padding.
1092 # This deals with historical problems with bugs and the default column value.
1093 $token = rtrim( $proposedUser->getToken(
false ) );
1095 $passwordCorrect = strlen( $token ) && $this->
compareSecrets( $token, $request->getCookie(
'Token' ) );
1102 if ( ( $sName === $proposedUser->getName() ) && $passwordCorrect ) {
1104 $request->setSessionData(
'wsToken', $this->mToken );
1105 wfDebug(
"User: logged in from $from\n" );
1109 wfDebug(
"User: can't log in from $from, invalid credentials\n" );
1121 if ( strlen( $answer ) !== strlen(
$test ) ) {
1122 $passwordCorrect =
false;
1125 for ( $i = 0; $i < strlen( $answer ); $i++ ) {
1128 $passwordCorrect = (
$result == 0 );
1130 return $passwordCorrect;
1141 $this->mId = intval( $this->mId );
1144 if ( !$this->mId ) {
1150 $s =
$dbr->selectRow(
'user', self::selectFields(),
array(
'user_id' => $this->mId ), __METHOD__ );
1154 if (
$s !==
false ) {
1157 $this->mGroups =
null;
1177 public function loadFromRow( $row, $data =
null ) {
1180 $this->mGroups =
null;
1182 if ( isset( $row->user_name ) ) {
1183 $this->mName = $row->user_name;
1184 $this->mFrom =
'name';
1190 if ( isset( $row->user_real_name ) ) {
1191 $this->mRealName = $row->user_real_name;
1197 if ( isset( $row->user_id ) ) {
1198 $this->mId = intval( $row->user_id );
1199 $this->mFrom =
'id';
1205 if ( isset( $row->user_editcount ) ) {
1206 $this->mEditCount = $row->user_editcount;
1211 if ( isset( $row->user_password ) ) {
1212 $this->mPassword = $row->user_password;
1213 $this->mNewpassword = $row->user_newpassword;
1215 $this->mEmail = $row->user_email;
1217 $this->mToken = $row->user_token;
1218 if ( $this->mToken ==
'' ) {
1219 $this->mToken =
null;
1222 $this->mEmailToken = $row->user_email_token;
1231 $this->mLoadedItems =
true;
1234 if ( is_array( $data ) ) {
1235 if ( isset( $data[
'user_groups'] ) && is_array( $data[
'user_groups'] ) ) {
1236 $this->mGroups = $data[
'user_groups'];
1238 if ( isset( $data[
'user_properties'] ) && is_array( $data[
'user_properties'] ) ) {
1251 $user->loadGroups();
1252 $user->loadOptions();
1253 foreach ( self::$mCacheVars
as $var ) {
1254 $this->$var =
$user->$var;
1262 if ( is_null( $this->mGroups ) ) {
1264 $res =
$dbr->select(
'user_groups',
1265 array(
'ug_group' ),
1266 array(
'ug_user' => $this->mId ),
1268 $this->mGroups =
array();
1269 foreach (
$res as $row ) {
1270 $this->mGroups[] = $row->ug_group;
1290 global $wgAutopromoteOnceLogInRC, $wgAuth;
1292 $toPromote =
array();
1293 if ( $this->
getId() ) {
1295 if ( count( $toPromote ) ) {
1298 foreach ( $toPromote
as $group ) {
1302 $wgAuth->updateExternalDBGroups( $this, $toPromote );
1304 $newGroups = array_merge( $oldGroups, $toPromote );
1307 $logEntry->setPerformer( $this );
1309 $logEntry->setParameters(
array(
1310 '4::oldgroups' => $oldGroups,
1311 '5::newgroups' => $newGroups,
1313 $logid = $logEntry->insert();
1314 if ( $wgAutopromoteOnceLogInRC ) {
1315 $logEntry->publish( $logid );
1331 $this->mNewtalk = -1;
1332 $this->mDatePreference =
null;
1333 $this->mBlockedby = -1; # Unset
1334 $this->mHash =
false;
1335 $this->mRights =
null;
1336 $this->mEffectiveGroups =
null;
1337 $this->mImplicitGroups =
null;
1338 $this->mGroups =
null;
1339 $this->mOptions =
null;
1340 $this->mOptionsLoaded =
false;
1341 $this->mEditCount =
null;
1343 if ( $reloadFrom ) {
1344 $this->mLoadedItems =
array();
1345 $this->mFrom = $reloadFrom;
1356 global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions,
$wgContLang, $wgDefaultSkin;
1358 static $defOpt =
null;
1359 if ( !defined(
'MW_PHPUNIT_TEST' ) && $defOpt !==
null ) {
1366 $defOpt = $wgDefaultUserOptions;
1369 foreach ( LanguageConverter::$languagesWithVariants
as $langCode ) {
1370 $defOpt[$langCode ==
$wgContLang->getCode() ?
'variant' :
"variant-$langCode"] = $langCode;
1373 $defOpt[
'searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
1375 $defOpt[
'skin'] = $wgDefaultSkin;
1390 if ( isset( $defOpts[$opt] ) ) {
1391 return $defOpts[$opt];
1407 if ( -1 != $this->mBlockedby ) {
1412 wfDebug( __METHOD__ .
": checking...\n" );
1421 # We only need to worry about passing the IP address to the Block generator if the
1422 # user is not immune to autoblocks/hardblocks, and they are the current user so we
1423 # know which IP address they're actually coming from
1424 if ( !$this->
isAllowed(
'ipblock-exempt' ) && $this->getID() ==
$wgUser->getID() ) {
1434 if ( !$block instanceof
Block && $ip !==
null && !$this->
isAllowed(
'proxyunbannable' )
1435 && !in_array( $ip, $wgProxyWhitelist )
1438 if ( self::isLocallyBlockedProxy( $ip ) ) {
1441 $block->mReason =
wfMessage(
'proxyblockreason' )->text();
1442 $block->setTarget( $ip );
1446 $block->mReason =
wfMessage(
'sorbsreason' )->text();
1447 $block->setTarget( $ip );
1452 if ( !$block instanceof
Block
1453 && $wgApplyIpBlocksToXff
1455 && !$this->
isAllowed(
'proxyunbannable' )
1456 && !in_array( $ip, $wgProxyWhitelist )
1458 $xff = $this->
getRequest()->getHeader(
'X-Forwarded-For' );
1459 $xff = array_map(
'trim', explode(
',', $xff ) );
1460 $xff = array_diff( $xff,
array( $ip ) );
1463 if ( $block instanceof
Block ) {
1464 # Mangle the reason to alert the user that the block
1465 # originated from matching the X-Forwarded-For header.
1466 $block->mReason =
wfMessage(
'xffblockreason', $block->mReason )->text();
1470 if ( $block instanceof
Block ) {
1471 wfDebug( __METHOD__ .
": Found block.\n" );
1472 $this->mBlock = $block;
1473 $this->mBlockedby = $block->getByName();
1474 $this->mBlockreason = $block->mReason;
1475 $this->mHideName = $block->mHideName;
1476 $this->mAllowUsertalk = !$block->prevents(
'editownusertalk' );
1478 $this->mBlockedby =
'';
1479 $this->mHideName = 0;
1480 $this->mAllowUsertalk =
false;
1497 global $wgEnableSorbs, $wgEnableDnsBlacklist,
1498 $wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist;
1500 if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs ) {
1504 if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
1508 $urls = array_merge( $wgDnsBlacklistUrls, (
array)$wgSorbsUrl );
1526 $ipReversed = implode(
'.', array_reverse( explode(
'.', $ip ) ) );
1528 foreach ( (
array)$bases
as $base ) {
1531 if ( is_array( $base ) ) {
1532 if ( count( $base ) >= 2 ) {
1534 $host =
"{$base[1]}.$ipReversed.{$base[0]}";
1536 $host =
"$ipReversed.{$base[0]}";
1539 $host =
"$ipReversed.$base";
1543 $ipList = gethostbynamel( $host );
1546 wfDebugLog(
'dnsblacklist',
"Hostname $host is {$ipList[0]}, it's a proxy says $base!" );
1550 wfDebugLog(
'dnsblacklist',
"Requested $host, not found in $base." );
1569 if ( !$wgProxyList ) {
1574 if ( !is_array( $wgProxyList ) ) {
1576 $wgProxyList = array_map(
'trim',
file( $wgProxyList ) );
1579 if ( !is_array( $wgProxyList ) ) {
1581 } elseif ( array_search( $ip, $wgProxyList ) !==
false ) {
1583 } elseif ( array_key_exists( $ip, $wgProxyList ) ) {
1599 global $wgRateLimitsExcludedIPs;
1600 if ( in_array( $this->
getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
1606 return !$this->
isAllowed(
'noratelimit' );
1628 if ( !isset( $wgRateLimits[$action] ) ) {
1640 $limits = $wgRateLimits[$action];
1642 $id = $this->
getId();
1645 if ( isset( $limits[
'anon'] ) && $id == 0 ) {
1646 $keys[
wfMemcKey(
'limiter', $action,
'anon' )] = $limits[
'anon'];
1649 if ( isset( $limits[
'user'] ) && $id != 0 ) {
1650 $userLimit = $limits[
'user'];
1653 if ( isset( $limits[
'newbie'] ) && $id != 0 ) {
1654 $keys[
wfMemcKey(
'limiter', $action,
'user', $id )] = $limits[
'newbie'];
1656 if ( isset( $limits[
'ip'] ) ) {
1658 $keys[
"mediawiki:limiter:$action:ip:$ip"] = $limits[
'ip'];
1660 if ( isset( $limits[
'subnet'] ) ) {
1666 $subnet = $parts[0];
1667 } elseif ( preg_match(
'/^(\d+\.\d+\.\d+)\.\d+$/', $ip,
$matches ) ) {
1671 if ( $subnet !==
false ) {
1672 $keys[
"mediawiki:limiter:$action:subnet:$subnet"] = $limits[
'subnet'];
1679 if ( isset( $limits[$group] ) ) {
1680 if ( $userLimit ===
false || $limits[$group] > $userLimit ) {
1681 $userLimit = $limits[$group];
1686 if ( $userLimit !==
false ) {
1687 list( $max, $period ) = $userLimit;
1688 wfDebug( __METHOD__ .
": effective user limit: $max in {$period}s\n" );
1689 $keys[
wfMemcKey(
'limiter', $action,
'user', $id )] = $userLimit;
1695 $summary =
"(limit $max in {$period}s)";
1700 wfDebugLog(
'ratelimit', $this->
getName() .
" tripped! $key at $count $summary" );
1703 wfDebug( __METHOD__ .
": ok. $key at $count $summary\n" );
1706 wfDebug( __METHOD__ .
": adding record for $key $summary\n" );
1708 $wgMemc->add( $key, 0, intval( $period ) );
1726 public function isBlocked( $bFromSlave =
true ) {
1736 public function getBlock( $bFromSlave =
true ) {
1738 return $this->mBlock instanceof
Block ? $this->mBlock :
null;
1749 global $wgBlockAllowsUTEdit;
1752 $blocked = $this->
isBlocked( $bFromSlave );
1758 wfDebug( __METHOD__ .
": self-talk page, ignoring any blocks\n" );
1791 return ( $this->mBlock ? $this->mBlock->getId() :
false );
1803 if ( $this->mBlockedGlobally !==
null ) {
1813 wfRunHooks(
'UserIsBlockedGlobally',
array( &$this, $ip, &$blocked ) );
1814 $this->mBlockedGlobally = (bool)$blocked;
1824 if ( $this->mLocked !==
null ) {
1829 $authUser = $wgAuth->getUserInstance( $this );
1830 $this->mLocked = (bool)$authUser->isLocked();
1840 if ( $this->mHideName !==
null ) {
1844 if ( !$this->mHideName ) {
1847 $authUser = $wgAuth->getUserInstance( $this );
1848 $this->mHideName = (bool)$authUser->isHidden();
1857 public function getId() {
1858 if ( $this->mId ===
null && $this->mName !==
null &&
User::isIP( $this->mName ) ) {
1872 public function setId( $v ) {
1887 if ( $this->mName ===
false ) {
1908 public function setName( $str ) {
1910 $this->mName = $str;
1918 return str_replace(
' ',
'_', $this->
getName() );
1929 if ( $this->mNewtalk === -1 ) {
1930 $this->mNewtalk =
false; # reset talk
page status
1934 if ( !$this->mId ) {
1935 global $wgDisableAnonTalk;
1936 if ( $wgDisableAnonTalk ) {
1938 $this->mNewtalk =
false;
1942 $newtalk =
$wgMemc->get( $key );
1943 if ( strval( $newtalk ) !==
'' ) {
1944 $this->mNewtalk = (bool)$newtalk;
1949 $wgMemc->set( $key, (
int)$this->mNewtalk, 1800 );
1953 $this->mNewtalk = $this->
checkNewtalk(
'user_id', $this->mId );
1975 if ( !
wfRunHooks(
'UserRetrieveNewTalks',
array( &$this, &$talks ) ) ) {
1984 'MIN(user_last_timestamp)',
1997 $newMessageRevisionId =
null;
1999 if ( $newMessageLinks ) {
2003 if ( count( $newMessageLinks ) === 1
2004 && $newMessageLinks[0][
'wiki'] ===
wfWikiID()
2005 && $newMessageLinks[0][
'rev']
2007 $newMessageRevision = $newMessageLinks[0][
'rev'];
2008 $newMessageRevisionId = $newMessageRevision->getId();
2011 return $newMessageRevisionId;
2023 protected function checkNewtalk( $field, $id, $fromMaster =
false ) {
2024 if ( $fromMaster ) {
2029 $ok = $db->selectField(
'user_newtalk', $field,
2030 array( $field => $id ), __METHOD__ );
2031 return $ok !==
false;
2041 protected function updateNewtalk( $field, $id, $curRev =
null ) {
2043 $prevRev = $curRev ? $curRev->getPrevious() :
false;
2044 $ts = $prevRev ? $prevRev->getTimestamp() :
null;
2047 $dbw->insert(
'user_newtalk',
2048 array( $field => $id,
'user_last_timestamp' => $dbw->timestampOrNull( $ts ) ),
2051 if ( $dbw->affectedRows() ) {
2052 wfDebug( __METHOD__ .
": set on ($field, $id)\n" );
2055 wfDebug( __METHOD__ .
" already set ($field, $id)\n" );
2068 $dbw->delete(
'user_newtalk',
2069 array( $field => $id ),
2071 if ( $dbw->affectedRows() ) {
2072 wfDebug( __METHOD__ .
": killed on ($field, $id)\n" );
2075 wfDebug( __METHOD__ .
": already gone ($field, $id)\n" );
2085 public function setNewtalk( $val, $curRev =
null ) {
2091 $this->mNewtalk = $val;
2098 $id = $this->
getId();
2111 $key =
wfMemcKey(
'newtalk',
'ip', $id );
2112 $wgMemc->set( $key, $val ? 1 : 0, 1800 );
2125 global $wgClockSkewFudge;
2160 $method = __METHOD__;
2161 $dbw->onTransactionIdle(
function() use ( $dbw, $userid, $touched, $method ) {
2163 $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) );
2164 $needsPurge = $dbw->selectField(
'user',
'1',
2165 array(
'user_id' => $userid,
'user_touched < ' . $encTouched ) );
2166 if ( $needsPurge ) {
2167 $dbw->update(
'user',
2168 array(
'user_touched' => $dbw->timestamp( $touched ) ),
2169 array(
'user_id' => $userid,
'user_touched < ' . $encTouched ),
2216 if ( $str !==
null ) {
2217 if ( !$wgAuth->allowPasswordChange() ) {
2222 global $wgMinimalPasswordLength;
2224 if ( is_array( $valid ) ) {
2225 $message = array_shift( $valid );
2235 if ( !$wgAuth->setPassword( $this, $str ) ) {
2255 if ( $str ===
null ) {
2257 $this->mPassword =
'';
2261 $this->mNewpassword =
'';
2262 $this->mNewpassTime =
null;
2270 public function getToken( $forceCreation =
true ) {
2272 if ( !$this->mToken && $forceCreation ) {
2284 public function setToken( $token =
false ) {
2289 $this->mToken = $token;
2303 if ( $str ===
null ) {
2304 $this->mNewpassword =
'';
2305 $this->mNewpassTime =
null;
2320 global $wgPasswordReminderResendTime;
2322 if ( !$this->mNewpassTime || !$wgPasswordReminderResendTime ) {
2325 $expiry =
wfTimestamp(
TS_UNIX, $this->mNewpassTime ) + $wgPasswordReminderResendTime * 3600;
2326 return time() < $expiry;
2345 wfRunHooks(
'UserGetEmailAuthenticationTimestamp',
array( $this, &$this->mEmailAuthenticated ) );
2355 if ( $str == $this->mEmail ) {
2358 $this->mEmail = $str;
2371 global $wgEnableEmail, $wgEmailAuthentication;
2373 if ( !$wgEnableEmail ) {
2378 if ( $str === $oldaddr ) {
2384 if ( $str !==
'' && $wgEmailAuthentication ) {
2386 $type = $oldaddr !=
'' ?
'changed' :
'set';
2417 $this->mRealName = $str;
2430 public function getOption( $oname, $defaultOverride =
null, $ignoreHidden =
false ) {
2434 # We want 'disabled' preferences to always behave as the default value for
2435 # users, even if they have set the option explicitly in their settings (ie they
2436 # set it, and then it was disabled removing their ability to change it). But
2437 # we don't want to erase the preferences in the database in case the preference
2438 # is re-enabled again. So don't touch $mOptions, just override the returned value
2439 if ( !$ignoreHidden && in_array( $oname, $wgHiddenPrefs ) ) {
2443 if ( array_key_exists( $oname, $this->mOptions ) ) {
2444 return $this->mOptions[$oname];
2446 return $defaultOverride;
2460 # We want 'disabled' preferences to always behave as the default value for
2461 # users, even if they have set the option explicitly in their settings (ie they
2462 # set it, and then it was disabled removing their ability to change it). But
2463 # we don't want to erase the preferences in the database in case the preference
2464 # is re-enabled again. So don't touch $mOptions, just override the returned value
2465 foreach ( $wgHiddenPrefs
as $pref ) {
2467 if ( $default !==
null ) {
2483 return (
bool)$this->
getOption( $oname );
2494 public function getIntOption( $oname, $defaultOverride = 0 ) {
2497 $val = $defaultOverride;
2499 return intval( $val );
2508 public function setOption( $oname, $val ) {
2512 if ( is_null( $val ) ) {
2516 $this->mOptions[$oname] = $val;
2530 if ( in_array( $oname, $wgHiddenPrefs ) ) {
2553 if ( in_array( $oname, $wgHiddenPrefs ) ) {
2588 'registered-multiselect',
2589 'registered-checkmatrix',
2620 unset( $prefs[
$name] );
2625 $multiselectOptions =
array();
2626 foreach ( $prefs
as $name => $info ) {
2627 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
2628 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
2630 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
2633 $multiselectOptions[
"$prefix$value"] =
true;
2636 unset( $prefs[
$name] );
2639 $checkmatrixOptions =
array();
2640 foreach ( $prefs
as $name => $info ) {
2641 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
2642 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
2645 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
2648 foreach ( $rows
as $row ) {
2649 $checkmatrixOptions[
"$prefix-$column-$row"] =
true;
2653 unset( $prefs[
$name] );
2659 if ( isset( $prefs[$key] ) ) {
2660 $mapping[$key] =
'registered';
2661 } elseif ( isset( $multiselectOptions[$key] ) ) {
2662 $mapping[$key] =
'registered-multiselect';
2663 } elseif ( isset( $checkmatrixOptions[$key] ) ) {
2664 $mapping[$key] =
'registered-checkmatrix';
2665 } elseif ( isset( $specialOptions[$key] ) ) {
2666 $mapping[$key] =
'special';
2667 } elseif ( substr( $key, 0, 7 ) ===
'userjs-' ) {
2668 $mapping[$key] =
'userjs';
2670 $mapping[$key] =
'unused';
2692 $resetKinds =
array(
'registered',
'registered-multiselect',
'registered-checkmatrix',
'unused' ),
2698 if ( !is_array( $resetKinds ) ) {
2699 $resetKinds =
array( $resetKinds );
2702 if ( in_array(
'all', $resetKinds ) ) {
2705 if ( $context ===
null ) {
2710 $resetKinds = array_intersect( $resetKinds, self::listOptionKinds() );
2711 $newOptions =
array();
2715 foreach ( $this->mOptions
as $key =>
$value ) {
2716 if ( in_array( $optionKinds[$key], $resetKinds ) ) {
2721 $newOptions[$key] =
$value;
2726 $this->mOptions = $newOptions;
2727 $this->mOptionsLoaded =
true;
2736 if ( is_null( $this->mDatePreference ) ) {
2739 $map =
$wgLang->getDatePreferenceMigrationMap();
2740 if ( isset( $map[
$value] ) ) {
2743 $this->mDatePreference =
$value;
2756 if ( !$wgSecureLogin ) {
2776 if ( $threshold > $wgMaxArticleSize * 1024 ) {
2789 if ( is_null( $this->mRights ) ) {
2793 $this->mRights = array_values( array_unique( $this->mRights ) );
2817 if ( $recache || is_null( $this->mEffectiveGroups ) ) {
2819 $this->mEffectiveGroups = array_unique( array_merge(
2824 wfRunHooks(
'UserEffectiveGroups',
array( &$this, &$this->mEffectiveGroups ) );
2826 $this->mEffectiveGroups = array_values( array_unique( $this->mEffectiveGroups ) );
2840 if ( $recache || is_null( $this->mImplicitGroups ) ) {
2842 $this->mImplicitGroups =
array(
'*' );
2843 if ( $this->
getId() ) {
2844 $this->mImplicitGroups[] =
'user';
2846 $this->mImplicitGroups = array_unique( array_merge(
2847 $this->mImplicitGroups,
2854 $this->mEffectiveGroups =
null;
2871 if ( is_null( $this->mFormerGroups ) ) {
2873 $res =
$dbr->select(
'user_former_groups',
2874 array(
'ufg_group' ),
2875 array(
'ufg_user' => $this->mId ),
2877 $this->mFormerGroups =
array();
2878 foreach (
$res as $row ) {
2879 $this->mFormerGroups[] = $row->ufg_group;
2890 if ( !$this->
getId() ) {
2894 if ( !isset( $this->mEditCount ) ) {
2900 'user',
'user_editcount',
2901 array(
'user_id' => $this->mId ),
2909 $this->mEditCount =
$count;
2920 public function addGroup( $group ) {
2923 if ( $this->
getId() ) {
2924 $dbw->insert(
'user_groups',
2926 'ug_user' => $this->getID(),
2927 'ug_group' => $group,
2930 array(
'IGNORE' ) );
2934 $this->mGroups[] = $group;
2937 $this->mGroups = array_unique( $this->mGroups );
2942 $this->mRights =
null;
2956 $dbw->delete(
'user_groups',
2958 'ug_user' => $this->getID(),
2959 'ug_group' => $group,
2962 $dbw->insert(
'user_former_groups',
2964 'ufg_user' => $this->getID(),
2965 'ufg_group' => $group,
2968 array(
'IGNORE' ) );
2971 $this->mGroups = array_diff( $this->mGroups,
array( $group ) );
2976 $this->mRights =
null;
2986 return $this->getID() != 0;
2993 public function isAnon() {
3006 $permissions = func_get_args();
3007 foreach ( $permissions
as $permission ) {
3008 if ( $this->
isAllowed( $permission ) ) {
3021 $permissions = func_get_args();
3022 foreach ( $permissions
as $permission ) {
3023 if ( !$this->
isAllowed( $permission ) ) {
3035 public function isAllowed( $action =
'' ) {
3036 if ( $action ===
'' ) {
3040 if ( $action ===
'patrol' || $action ===
'autopatrol' ) {
3041 global $wgUseRCPatrol, $wgUseNPPatrol;
3042 if ( !$wgUseRCPatrol && !$wgUseNPPatrol ) {
3048 return in_array( $action, $this->
getRights(),
true );
3057 return $wgUseRCPatrol && $this->
isAllowedAny(
'patrol',
'patrolmarks' );
3065 global $wgUseRCPatrol, $wgUseNPPatrol;
3067 ( $wgUseRCPatrol || $wgUseNPPatrol )
3078 if ( $this->mRequest ) {
3107 $key = $checkRights .
':' .
$title->getNamespace() .
':' .
$title->getDBkey();
3109 if ( isset( $this->mWatchedItems[$key] ) ) {
3110 return $this->mWatchedItems[$key];
3113 if ( count( $this->mWatchedItems ) >= self::MAX_WATCHED_ITEMS_CACHE ) {
3114 $this->mWatchedItems =
array();
3118 return $this->mWatchedItems[$key];
3174 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3180 if ( !
wfRunHooks(
'UserClearNewTalkNotification',
array( &$this, $oldid ) ) ) {
3184 $nextid = $oldid ?
$title->getNextRevisionID( $oldid ) :
null;
3186 if ( !$oldid || !$nextid ) {
3232 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3241 $id = $this->
getId();
3244 $dbw->update(
'watchlist',
3245 array(
'wl_notificationtimestamp' =>
null ),
3246 array(
'wl_user' => $id ),
3293 public function setCookies( $request =
null, $secure =
null, $rememberMe =
false ) {
3294 if ( $request ===
null ) {
3299 if ( 0 == $this->mId ) {
3302 if ( !$this->mToken ) {
3311 'wsUserID' => $this->mId,
3312 'wsToken' => $this->mToken,
3313 'wsUserName' => $this->
getName()
3316 'UserID' => $this->mId,
3317 'UserName' => $this->
getName(),
3319 if ( $rememberMe ) {
3331 if (
$value ===
false ) {
3345 if ( $request->getCheck(
'wpStickHTTPS' ) || $this->
requiresHTTPS() ) {
3349 $rememberMe ? 0 :
null,
3351 array(
'prefix' =>
'' )
3359 public function logout() {
3372 $this->
getRequest()->setSessionData(
'wsUserID', 0 );
3379 $this->
setCookie(
'LoggedOut', time(), time() + 86400 );
3393 if ( 0 == $this->mId ) {
3398 if ( !$wgAuth->allowSetLocalPassword() ) {
3399 $this->mPassword =
'';
3403 $dbw->update(
'user',
3405 'user_name' => $this->mName,
3406 'user_password' => $this->mPassword,
3407 'user_newpassword' => $this->mNewpassword,
3408 'user_newpass_time' => $dbw->timestampOrNull( $this->mNewpassTime ),
3411 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
3412 'user_touched' => $dbw->timestamp( $this->mTouched ),
3413 'user_token' => strval( $this->mToken ),
3415 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
3416 'user_password_expires' => $dbw->timestampOrNull( $this->mPasswordExpires ),
3418 'user_id' => $this->mId
3440 $id =
$dbr->selectField(
'user',
'user_id',
array(
'user_name' =>
$s ), __METHOD__ );
3441 if ( $id ===
false ) {
3467 if ( isset(
$params[
'options'] ) ) {
3472 $seqVal = $dbw->nextSequenceValue(
'user_user_id_seq' );
3475 'user_id' => $seqVal,
3476 'user_name' =>
$name,
3477 'user_password' =>
$user->mPassword,
3478 'user_newpassword' =>
$user->mNewpassword,
3479 'user_newpass_time' => $dbw->timestampOrNull(
$user->mNewpassTime ),
3480 'user_email' =>
$user->mEmail,
3481 'user_email_authenticated' => $dbw->timestampOrNull(
$user->mEmailAuthenticated ),
3482 'user_real_name' =>
$user->mRealName,
3483 'user_token' => strval(
$user->mToken ),
3484 'user_registration' => $dbw->timestamp(
$user->mRegistration ),
3485 'user_editcount' => 0,
3486 'user_touched' => $dbw->timestamp( self::newTouchedTimestamp() ),
3489 $fields[
"user_$name"] =
$value;
3491 $dbw->insert(
'user', $fields, __METHOD__,
array(
'IGNORE' ) );
3492 if ( $dbw->affectedRows() ) {
3528 if ( !$this->mToken ) {
3535 $inWrite = $dbw->writesOrCallbacksPending();
3536 $seqVal = $dbw->nextSequenceValue(
'user_user_id_seq' );
3537 $dbw->insert(
'user',
3539 'user_id' => $seqVal,
3540 'user_name' => $this->mName,
3541 'user_password' => $this->mPassword,
3542 'user_newpassword' => $this->mNewpassword,
3543 'user_newpass_time' => $dbw->timestampOrNull( $this->mNewpassTime ),
3545 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
3547 'user_token' => strval( $this->mToken ),
3548 'user_registration' => $dbw->timestamp( $this->mRegistration ),
3549 'user_editcount' => 0,
3550 'user_touched' => $dbw->timestamp( $this->mTouched ),
3554 if ( !$dbw->affectedRows() ) {
3559 $dbw->commit( __METHOD__,
'flush' );
3561 $this->mId = $dbw->selectField(
'user',
'user_id',
3562 array(
'user_name' => $this->mName ), __METHOD__ );
3570 throw new MWException( __METHOD__ .
": hit a key conflict attempting " .
3571 "to insert user '{$this->mName}' row, but it was not present in select!" );
3575 $this->mId = $dbw->insertId();
3602 wfDebug( __METHOD__ .
"()\n" );
3604 if ( $this->mId == 0 ) {
3609 if ( !$userblock ) {
3613 return (
bool)$userblock->doAutoblock( $this->
getRequest()->getIP() );
3622 if ( $this->mBlock && $this->mBlock->prevents(
'createaccount' ) ) {
3626 # bug 13611: if the IP address the user is trying to create an account from is
3627 # blocked with createaccount disabled, prevent new account creation there even
3628 # when the user is logged in
3629 if ( $this->mBlockedFromCreateAccount ===
false && !$this->
isAllowed(
'ipblock-exempt' ) ) {
3632 return $this->mBlockedFromCreateAccount instanceof
Block && $this->mBlockedFromCreateAccount->
prevents(
'createaccount' )
3633 ? $this->mBlockedFromCreateAccount
3643 return $this->mBlock && $this->mBlock->prevents(
'sendemail' );
3670 return $title->getTalkPage();
3679 return !$this->
isAllowed(
'autoconfirmed' );
3688 global $wgAuth, $wgLegacyEncoding;
3695 if ( $wgAuth->authenticate( $this->getName(),
$password ) ) {
3697 } elseif ( $wgAuth->strict() ) {
3700 } elseif ( $wgAuth->strictUserAuth( $this->getName() ) ) {
3704 if ( self::comparePasswords( $this->mPassword,
$password, $this->mId ) ) {
3706 } elseif ( $wgLegacyEncoding ) {
3709 $cp1252Password = iconv(
'UTF-8',
'WINDOWS-1252//TRANSLIT',
$password );
3711 && self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId )
3728 global $wgNewPasswordExpiry;
3731 if ( self::comparePasswords( $this->mNewpassword, $plaintext, $this->
getId() ) ) {
3732 if ( is_null( $this->mNewpassTime ) ) {
3736 return ( time() < $expiry );
3750 public function editToken( $salt =
'', $request =
null ) {
3767 public function getEditToken( $salt =
'', $request =
null ) {
3768 if ( $request ==
null ) {
3775 $token = $request->getSessionData(
'wsEditToken' );
3776 if ( $token ===
null ) {
3778 $request->setSessionData(
'wsEditToken', $token );
3780 if ( is_array( $salt ) ) {
3781 $salt = implode(
'|', $salt );
3808 public function matchEditToken( $val, $salt =
'', $request =
null ) {
3809 $sessionToken = $this->
getEditToken( $salt, $request );
3810 if ( $val != $sessionToken ) {
3811 wfDebug(
"User::matchEditToken: broken session data\n" );
3813 return $val == $sessionToken;
3826 $sessionToken = $this->
getEditToken( $salt, $request );
3827 return substr( $sessionToken, 0, 32 ) == substr( $val, 0, 32 );
3845 if (
$type ==
'created' ||
$type ===
false ) {
3846 $message =
'confirmemail_body';
3847 } elseif (
$type ===
true ) {
3848 $message =
'confirmemail_body_changed';
3851 $message =
'confirmemail_body_' .
$type;
3859 $wgLang->timeanddate( $expiration,
false ),
3861 $wgLang->date( $expiration,
false ),
3875 public function sendMail( $subject, $body,
$from =
null, $replyto =
null ) {
3876 if ( is_null(
$from ) ) {
3877 global $wgPasswordSender;
3899 global $wgUserEmailConfirmationTokenExpiry;
3901 $expires = $now + $wgUserEmailConfirmationTokenExpiry;
3905 $hash = md5( $token );
3906 $this->mEmailToken =
$hash;
3907 $this->mEmailTokenExpires = $expiration;
3917 return $this->
getTokenUrl(
'ConfirmEmail', $token );
3926 return $this->
getTokenUrl(
'InvalidateEmail', $token );
3946 return $title->getCanonicalURL();
3975 $this->mEmailToken =
null;
3976 $this->mEmailTokenExpires =
null;
3989 wfRunHooks(
'UserSetEmailAuthenticationTimestamp',
array( $this, &$this->mEmailAuthenticated ) );
3998 global $wgEnableEmail, $wgEnableUserEmail;
3999 if ( !$wgEnableEmail || !$wgEnableUserEmail || !$this->
isAllowed(
'sendemail' ) ) {
4027 global $wgEmailAuthentication;
4051 global $wgEmailAuthentication;
4052 return $wgEmailAuthentication &&
4054 $this->mEmailToken &&
4080 if ( $this->
getId() == 0 ) {
4084 $time =
$dbr->selectField(
'revision',
'rev_timestamp',
4087 array(
'ORDER BY' =>
'rev_timestamp ASC' )
4102 global $wgGroupPermissions, $wgRevokePermissions;
4105 foreach ( $groups
as $group ) {
4106 if ( isset( $wgGroupPermissions[$group] ) ) {
4107 $rights = array_merge( $rights,
4109 array_keys( array_filter( $wgGroupPermissions[$group] ) ) );
4113 foreach ( $groups
as $group ) {
4114 if ( isset( $wgRevokePermissions[$group] ) ) {
4115 $rights = array_diff( $rights,
4116 array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
4119 return array_unique( $rights );
4129 global $wgGroupPermissions;
4130 $allowedGroups =
array();
4131 foreach ( array_keys( $wgGroupPermissions )
as $group ) {
4132 if ( self::groupHasPermission( $group, $role ) ) {
4133 $allowedGroups[] = $group;
4136 return $allowedGroups;
4152 global $wgGroupPermissions, $wgRevokePermissions;
4153 return isset( $wgGroupPermissions[$group][$role] ) && $wgGroupPermissions[$group][$role]
4154 && !( isset( $wgRevokePermissions[$group][$role] ) && $wgRevokePermissions[$group][$role] );
4165 global $wgGroupPermissions, $wgRevokePermissions;
4170 if ( isset(
$cache[
$right] ) && !defined(
'MW_PHPUNIT_TEST' ) ) {
4174 if ( !isset( $wgGroupPermissions[
'*'][
$right] ) || !$wgGroupPermissions[
'*'][
$right] ) {
4180 foreach ( $wgRevokePermissions
as $rights ) {
4205 return $msg->isBlank() ? $group : $msg->text();
4215 public static function getGroupMember( $group, $username =
'#' ) {
4216 $msg =
wfMessage(
"group-$group-member", $username );
4217 return $msg->isBlank() ? $group : $msg->text();
4227 global $wgGroupPermissions, $wgRevokePermissions;
4229 array_merge( array_keys( $wgGroupPermissions ), array_keys( $wgRevokePermissions ) ),
4230 self::getImplicitGroups()
4239 if ( self::$mAllRights ===
false ) {
4240 global $wgAvailableRights;
4241 if ( count( $wgAvailableRights ) ) {
4242 self::$mAllRights = array_unique( array_merge( self::$mCoreRights, $wgAvailableRights ) );
4256 global $wgImplicitGroups;
4257 $groups = $wgImplicitGroups;
4258 wfRunHooks(
'UserGetImplicitGroups',
array( &$groups ) ); #deprecated, use $wgImplictGroups instead
4269 $msg =
wfMessage(
'grouppage-' . $group )->inContentLanguage();
4270 if ( $msg->exists() ) {
4272 if ( is_object(
$title ) ) {
4288 if ( $text ==
'' ) {
4308 if ( $text ==
'' ) {
4313 $page =
$title->getPrefixedText();
4314 return "[[$page|$text]]";
4330 global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
4333 if ( empty( $wgAddGroups[$group] ) ) {
4335 } elseif ( $wgAddGroups[$group] ===
true ) {
4338 } elseif ( is_array( $wgAddGroups[$group] ) ) {
4339 $groups[
'add'] = $wgAddGroups[$group];
4343 if ( empty( $wgRemoveGroups[$group] ) ) {
4344 } elseif ( $wgRemoveGroups[$group] ===
true ) {
4346 } elseif ( is_array( $wgRemoveGroups[$group] ) ) {
4347 $groups[
'remove'] = $wgRemoveGroups[$group];
4351 if ( empty( $wgGroupsAddToSelf[
'user'] ) || $wgGroupsAddToSelf[
'user'] !==
true ) {
4352 foreach ( $wgGroupsAddToSelf
as $key =>
$value ) {
4353 if ( is_int( $key ) ) {
4354 $wgGroupsAddToSelf[
'user'][] =
$value;
4359 if ( empty( $wgGroupsRemoveFromSelf[
'user'] ) || $wgGroupsRemoveFromSelf[
'user'] !==
true ) {
4360 foreach ( $wgGroupsRemoveFromSelf
as $key =>
$value ) {
4361 if ( is_int( $key ) ) {
4362 $wgGroupsRemoveFromSelf[
'user'][] =
$value;
4368 if ( empty( $wgGroupsAddToSelf[$group] ) ) {
4369 } elseif ( $wgGroupsAddToSelf[$group] ===
true ) {
4372 } elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) {
4373 $groups[
'add-self'] = $wgGroupsAddToSelf[$group];
4376 if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
4377 } elseif ( $wgGroupsRemoveFromSelf[$group] ===
true ) {
4379 } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
4380 $groups[
'remove-self'] = $wgGroupsRemoveFromSelf[$group];
4394 if ( $this->
isAllowed(
'userrights' ) ) {
4403 'add-self' =>
array(),
4404 'remove-self' =>
array()
4411 'remove' =>
array(),
4412 'add-self' =>
array(),
4413 'remove-self' =>
array()
4417 foreach ( $addergroups
as $addergroup ) {
4418 $groups = array_merge_recursive(
4421 $groups[
'add'] = array_unique( $groups[
'add'] );
4422 $groups[
'remove'] = array_unique( $groups[
'remove'] );
4423 $groups[
'add-self'] = array_unique( $groups[
'add-self'] );
4424 $groups[
'remove-self'] = array_unique( $groups[
'remove-self'] );
4434 if ( !$this->
isAnon() ) {
4438 array(
'user_editcount=user_editcount+1' ),
4444 if ( $dbw->affectedRows() == 0 ) {
4447 if (
$dbr !== $dbw ) {
4500 $key =
"right-$right";
4502 return $msg->isBlank() ?
$right : $msg->text();
4514 if ( $wgPasswordSalt ) {
4515 return md5( $userId .
'-' . md5(
$password ) );
4537 if ( $wgPasswordSalt ) {
4538 if ( $salt ===
false ) {
4541 return ':B:' . $salt .
':' . md5( $salt .
'-' . md5(
$password ) );
4565 if (
$type ==
':A:' ) {
4568 } elseif (
$type ==
':B:' ) {
4570 list( $salt, $realHash ) = explode(
':', substr(
$hash, 3 ), 2 );
4571 return md5( $salt .
'-' . md5(
$password ) ) === $realHash;
4601 if ( empty( $wgNewUserLog ) ) {
4605 if ( $action ===
true ) {
4606 $action =
'byemail';
4607 } elseif ( $action ===
false ) {
4608 if ( $this->
getName() == $wgUser->getName() ) {
4611 $action =
'create2';
4615 if ( $action ===
'create' || $action ===
'autocreate' ) {
4622 $logEntry->setPerformer( $performer );
4624 $logEntry->setComment( $reason );
4625 $logEntry->setParameters(
array(
4626 '4::userid' => $this->
getId(),
4628 $logid = $logEntry->insert();
4630 if ( $action !==
'autocreate' ) {
4631 $logEntry->publish( $logid );
4660 if ( $this->mOptionsLoaded ) {
4666 if ( !$this->
getId() ) {
4672 $this->mOptions[
'variant'] = $variant;
4673 $this->mOptions[
'language'] = $variant;
4674 $this->mOptionsLoaded =
true;
4679 if ( !is_null( $this->mOptionOverrides ) ) {
4680 wfDebug(
"User: loading options for user " . $this->
getId() .
" from override cache.\n" );
4681 foreach ( $this->mOptionOverrides
as $key =>
$value ) {
4682 $this->mOptions[$key] =
$value;
4685 if ( !is_array( $data ) ) {
4686 wfDebug(
"User: loading options for user " . $this->
getId() .
" from database.\n" );
4692 array(
'up_property',
'up_value' ),
4697 $this->mOptionOverrides =
array();
4699 foreach (
$res as $row ) {
4700 $data[$row->up_property] = $row->up_value;
4709 $this->mOptionsLoaded =
true;
4725 if ( !
wfRunHooks(
'UserSaveOptions',
array( $this, &$saveOptions ) ) ) {
4729 $userId = $this->
getId();
4730 $insert_rows =
array();
4731 foreach ( $saveOptions
as $key =>
$value ) {
4734 if ( ( is_null( $defaultOption ) &&
4738 $insert_rows[] =
array(
4739 'up_user' => $userId,
4740 'up_property' => $key,
4748 $res = $dbw->select(
'user_properties',
4749 array(
'up_property' ),
array(
'up_user' => $userId ), __METHOD__ );
4750 $priorKeys =
array();
4751 foreach (
$res as $row ) {
4752 $priorKeys[] = $row->up_property;
4754 if ( count( $priorKeys ) ) {
4762 $dbw->delete(
'user_properties',
4763 array(
'up_user' => $userId,
'up_property' => $priorKeys ), __METHOD__ );
4766 $dbw->insert(
'user_properties', $insert_rows, __METHOD__,
array(
'IGNORE' ) );
4793 global $wgMinimalPasswordLength;
4795 if ( $wgMinimalPasswordLength == 0 ) {
4799 # Note that the pattern requirement will always be satisfied if the
4800 # input is empty, so we need required in all cases.
4802 # @todo FIXME: Bug 23769: This needs to not claim the password is required
4803 # if e-mail confirmation is being used. Since HTML5 input validation
4804 # is b0rked anyway in some browsers, just return nothing. When it's
4805 # re-enabled, fix this code to not output required for e-mail
4807 #$ret = array( 'required' );
4810 # We can't actually do this right now, because Opera 9.6 will print out
4811 # the entered password visibly in its error message! When other
4812 # browsers add support for this attribute, or Opera fixes its support,
4813 # we can add support with a version check to avoid doing this on Opera
4814 # versions where it will be a problem. Reported to Opera as
4815 # DSK-262266, but they don't have a public bug tracker for us to follow.
4839 'user_newpass_time',
4843 'user_email_authenticated',
4845 'user_email_token_expires',
4846 'user_password_expires',
4847 'user_registration',
4862 $groups = array_map(
4863 array(
'User',
'makeGroupLinkWiki' ),
static getDefaultOption( $opt)
Get a given default option value.
addWatch( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Watch an article.
$mHash
Bool Whether the cache variables have been loaded.
$mBlockreason
Bool Whether the cache variables have been loaded.
prevents( $action, $x=null)
Get/set whether the Block prevents a given action.
load()
Load the user table data for this object from the source given by mFrom.
static passwordChangeInputAttribs()
Provide an array of HTML5 attributes to put on an input element intended for the user to enter a new ...
loadFromId()
Load user table data, given mId has already been set.
static getPreferences( $user, IContextSource $context)
updateNewtalk( $field, $id, $curRev=null)
Add or update the new messages flag.
$mEmailToken
Bool Whether the cache variables have been loaded.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getNewtalk()
Check if the user has new messages.
addGroup( $group)
Add the user to the given group.
static send( $to, $from, $subject, $body, $replyto=null, $contentType='text/plain;charset=UTF-8')
This function will perform a direct (authenticated) login to a SMTP Server to use for mail relaying i...
$mOptionsLoaded
Bool Whether the cache variables have been loaded.
inDnsBlacklist( $ip, $bases)
Whether the given IP is in a given DNS blacklist.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
see documentation in includes Linker php for Linker::makeImageLink & $time
static newFromId( $id)
Static factory method for creation from a given user ID.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
$mEditCount
Bool Whether the cache variables have been loaded.
confirmationTokenUrl( $token)
Return a URL the user can use to confirm their email address.
wfCanIPUseHTTPS( $ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
isValidPassword( $password)
Is the input a valid password for this user?
getId()
Get the user's ID.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
static makeGroupLinkWiki( $group, $text='')
Create a link to the group in Wikitext, if available; else return the group name.
isAnon()
Get whether the user is anonymous.
Block $mBlock
Bool Whether the cache variables have been loaded.
$mEffectiveGroups
Bool Whether the cache variables have been loaded.
getTokenUrl( $page, $token)
Internal function to format the e-mail validation/invalidation URLs.
const MAX_WATCHED_ITEMS_CACHE
Maximum items in $mWatchedItems.
static isLocallyBlockedProxy( $ip)
Check if an IP address is in the local proxy list.
resetTokenFromOption( $oname)
Reset a token stored in the preferences (like the watchlist one).
loadFromUserObject( $user)
Load the data for this user object from another user object.
static newFatalPermissionDeniedStatus( $permission)
Factory function for fatal permission-denied errors.
getPasswordExpireDate()
Get this user's password expiration date.
static isValidEmailAddr( $addr)
Does a string look like an e-mail address?
getEditCount()
Get the user's edit count.
spreadBlock()
If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from.
incEditCount()
Increment the user's edit-count field.
static newFromSession(WebRequest $request=null)
Create a new user object using data from session or cookies.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
getOptionKinds(IContextSource $context, $options=null)
Return an associative array mapping preferences keys to the kind of a preference they're used for.
static chooseBlock(array $blocks, array $ipChain)
From a list of multiple blocks, find the most exact and strongest Block.
getBlock( $bFromSlave=true)
Get the block affecting the user, or null if the user is not blocked.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
isEmailConfirmationPending()
Check whether there is an outstanding request for e-mail confirmation.
getBlockId()
If user is blocked, return the ID for the block.
getIntOption( $oname, $defaultOverride=0)
Get the user's current setting for a given option, as an integer value.
static searchableNamespaces()
Make a list of searchable namespaces and their canonical names.
__construct()
Lightweight constructor for an anonymous user.
editToken( $salt='', $request=null)
Alias for getEditToken.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getToken( $forceCreation=true)
Get the user's current token.
spreadAnyEditBlock()
If this user is logged-in and blocked, block any IP address they've successfully logged in from.
$mEmail
Bool Whether the cache variables have been loaded.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
getNewMessageRevisionId()
Get the revision ID for the last talk page revision viewed by the talk page owner.
loadDefaults( $name=false)
Set cached properties to default.
bool $mAllowUsertalk
Bool Whether the cache variables have been loaded.
wfProfileIn( $functionname)
Begin profiling of a function.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method this String will be used as the hash which may be added to this hook is run right before returning the options to the caller which means it s potentially called dozens or hundreds of times You may want to cache the results of non trivial operations in your hook function for this reason & $defaultOptions
$mNewtalk
Lazy-initialized variables, invalidated with clearInstanceCache.
loadOptions( $data=null)
Load the user options either from cache, the database or an array.
static makeGroupLinkHTML( $group, $text='')
Create a link to the group in HTML, if available; else return the group name.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
setNewpassword( $str, $throttle=true)
Set the password for a password reminder or new account email.
return false if a UserGetRights hook might remove the named right $right
static edits( $uid)
Count the number of edits of a user.
setEmailWithConfirmation( $str)
Set the user's e-mail address and a confirmation mail if needed.
static newGood( $value=null)
Factory function for good results.
getStubThreshold()
Get the user preferred stub threshold.
static validateEmail( $addr)
Does a string look like an e-mail address?
static comparePasswords( $hash, $password, $userId=false)
Compare a password hash with a plain-text password.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
wfReadOnly()
Check whether the wiki is in read-only mode.
Thrown by User::setPassword() on error.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
loadFromRow( $row, $data=null)
Initialize this object from a row from the user table.
setEmailAuthenticationTimestamp( $timestamp)
Set the e-mail authentication timestamp.
static isIPv6( $ip)
Given a string, determine if it as valid IP in IPv6 only.
clearCookie( $name, $secure=null, $params=array())
Clear a cookie on the user's client.
getUserPage()
Get this user's personal page title.
const USER_TOKEN_LENGTH
Global constants made accessible as class constants so that autoloader magic can be used.
getGroups()
Get the list of explicit group memberships this user has.
$mOptionOverrides
Bool Whether the cache variables have been loaded.
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
useNPPatrol()
Check whether to enable new pages patrol features for this user.
$mToken
Bool Whether the cache variables have been loaded.
getDatePreference()
Get the user's preferred date format.
setEmail( $str)
Set the user's e-mail address.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
static isValidUserName( $name)
Is the input a valid username?
sendConfirmationMail( $type='created')
Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's give...
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
getEmailAuthenticationTimestamp()
Get the timestamp of the user's e-mail authentication.
pingLimiter( $action='edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
$mFrom
String Initialization data source if mLoadedItems!==true.
initEditCount( $add=0)
Initialize user_editcount from data out of the revision table.
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
invalidateEmail()
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already co...
static newFromRow( $row, $data=null)
Create a new user object from a user row.
loadGroups()
Load the groups from the database if they aren't already loaded.
$mNewpassTime
Bool Whether the cache variables have been loaded.
compareSecrets( $answer, $test)
A comparison of two strings, not vulnerable to timing attacks.
deleteNewtalk( $field, $id)
Clear the new messages flag for the given user.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
static $mCacheVars
Array of Strings List of member variables which are saved to the shared cache (memcached).
The ContentHandler facility adds support for arbitrary content types on wiki pages
getRights()
Get the permissions this user has.
getRequest()
Get the WebRequest object to use with this object.
static getSaveBlacklist()
getAutomaticGroups( $recache=false)
Get the list of implicit group memberships this user has.
static generateToken()
Generate a looking random token for various uses.
setPassword( $str)
Set the password and reset the random token.
$mRights
Bool Whether the cache variables have been loaded.
$mNewpassword
Bool Whether the cache variables have been loaded.
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
isBlockedFrom( $title, $bFromSlave=false)
Check if user is blocked from editing a particular article.
resetOptions( $resetKinds=array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'), IContextSource $context=null)
Reset certain (or all) options to the site defaults.
Stores a single person's name and email address.
getEmail()
Get the user's e-mail address.
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an article
getTalkPage()
Get this user's talk page title.
$mName
Bool Whether the cache variables have been loaded.
matchEditToken( $val, $salt='', $request=null)
Check given value against the token value stored in the session.
$mBlockedby
Bool Whether the cache variables have been loaded.
addToDatabase()
Add this existing user object to the database.
clearSharedCache()
Clear user data from memcached.
invalidateCache()
Immediately touch the user data cache for this account.
setInternalPassword( $str)
Set the password and reset the random token unconditionally.
getWatchedItem( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Get a WatchedItem for this user and $title.
invalidationTokenUrl( $token)
Return a URL the user can use to invalidate their email address.
wfMemcKey()
Get a cache key.
isLocked()
Check if user account is locked.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static fromUserTitle( $user, $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Create a WatchedItem object with the given user and title.
checkPasswordValidity( $password)
Check if this is a valid password for this user.
$mOptions
Bool Whether the cache variables have been loaded.
confirmEmail()
Mark the e-mail address confirmed.
setItemLoaded( $item)
Set that an item has been loaded.
blockedFor()
If user is blocked, return the specified reason for the block.
$mImplicitGroups
Bool Whether the cache variables have been loaded.
getOptions()
Get all user's options.
setNewtalk( $val, $curRev=null)
Update the 'You have new messages!' status.
isWatched( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Check the watched status of an article.
Block $mBlockedFromCreateAccount
Bool Whether the cache variables have been loaded.
isAllowedToCreateAccount()
Get whether the user is allowed to create an account.
logout()
Log this user out.
confirmationToken(&$expiration)
Generate, store, and return a new e-mail confirmation code.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
static getImplicitGroups()
Get a list of implicit groups.
$mPasswordExpires
Bool Whether the cache variables have been loaded.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
isHidden()
Check if user account is hidden.
static randomPassword()
Return a random password.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
isBlockedFromEmailuser()
Get whether the user is blocked from using Special:Emailuser.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
static isIP( $name)
Does the string match an anonymous IPv4 address?
validateCache( $timestamp)
Validate the cache for this account.
getEffectiveGroups( $recache=false)
Get the list of implicit group memberships this user has.
isPingLimitable()
Is this user subject to rate limiting?
removeGroup( $group)
Remove the user from the given group.
static newFromConfirmationCode( $code)
Factory method to fetch whichever user has a given email confirmation code.
canReceiveEmail()
Is this user allowed to receive e-mails within limits of current site configuration?
isNewbie()
Determine whether the user is a newbie.
isAllowedAll()
Is the input a valid password for this user?
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
checkNewtalk( $field, $id, $fromMaster=false)
Internal uncached check for new messages.
clearInstanceCache( $reloadFrom=false)
Clear various cached data stored in this object.
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
return false to override stock group removal can be modified modifiable will be added to $_SESSION & $cookies
$mId
Bool Whether the cache variables have been loaded.
setName( $str)
Set the user name.
setCookie( $name, $value, $exp=0, $secure=null, $params=array())
Set a cookie on the user's client.
static createNew( $name, $params=array())
Add a user to the database, return the user object.
$mLoadedItems
Array with already loaded items or true if all items have been loaded.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method this String will be used as the hash which may be added to this hook is run right before returning the options to the caller which means it s potentially called dozens or hundreds of times You may want to cache the results of non trivial operations in your hook function for this reason change this to override email change this to override email authentication timestamp whether or not the user is blocked from that page & $allowUsertalk
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
processing should stop and the error should be shown to the user * false
clearNotification(&$title, $oldid=0)
Clear the user's notification timestamp for the given title.
saveSettings()
Save this user's settings into the database.
$mGroups
Bool Whether the cache variables have been loaded.
addNewUserLogEntry( $action=false, $reason='')
Add a newuser log entry for this user.
$mPassword
Bool Whether the cache variables have been loaded.
static getBlocksForIPList(array $ipChain, $isAnon, $fromMaster=false)
Get all blocks that match any IP from an array of IP addresses.
static $mCoreRights
Array of Strings Core rights.
getFirstEditTimestamp()
Get the timestamp of the first edit.
expirePassword( $ts=0)
Expire a user's password.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
setRealName( $str)
Set the user's real name.
getNewMessageLinks()
Return the data needed to construct links for new talk page message alerts.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getBlockedStatus( $bFromSlave=true)
Get blocking information.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
idForName()
If only this user's username is known, and it exists, return the user ID.
presenting them properly to the user as errors is done by the caller $title
getFormerGroups()
Returns the groups the user has belonged to.
loadFromDatabase()
Load user and user_group data from the database.
Allows to change the fields on the form that will be generated $name
static whoIs( $id)
Get the username corresponding to a given user ID.
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
static newTouchedTimestamp()
Generate a current or new-future timestamp to be stored in the user_touched field when we update thin...
loadFromSession()
Load user data from the session or login cookie.
isBlockedGlobally( $ip='')
Check if user is blocked on all wikis.
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
isDnsBlacklisted( $ip, $checkWhitelist=false)
Whether the given IP is in a DNS blacklist.
getTouched()
Get the user touched timestamp.
static parseRange( $range)
Given a string range in a number of formats, return the start and end of the range in hexadecimal.
$mRegistration
Bool Whether the cache variables have been loaded.
getRealName()
Get the user's real name.
static $idCacheByName
Bool Whether the cache variables have been loaded.
setBlocker( $user)
Set the user who implemented (or will implement) this block.
setCookies( $request=null, $secure=null, $rememberMe=false)
Set the default cookies for this session on the user's client.
static getGroupPermissions( $groups)
Get the permissions associated with a given list of groups.
static getGroupPage( $group)
Get the title of a page describing a particular group.
matchEditTokenNoSuffix( $val, $salt='', $request=null)
Check given value against the token value stored in the session, ignoring the suffix.
changeableGroups()
Returns an array of groups that this user can add and remove.
clearAllNotifications()
Resets all of the given user's page-change notification timestamps.
const CHECK_USER_RIGHTS
Constant to specify that user rights 'editmywatchlist' and 'viewmywatchlist' should be checked.
isPasswordReminderThrottled()
Has password reminder email been sent within the last $wgPasswordReminderResendTime hours?
static crypt( $password, $salt=false)
Make a new-style password hash.
checkPassword( $password)
Check to see if the given clear-text password is one of the accepted passwords.
static getAllGroups()
Return the set of defined explicit groups.
static getAllRights()
Get a list of all available permissions.
$mTouched
Bool Whether the cache variables have been loaded.
$mEmailAuthenticated
Bool Whether the cache variables have been loaded.
static getMain()
Static methods.
blockedBy()
If user is blocked, return the name of the user who placed the block.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static getGroupMember( $group, $username='#')
Get the localized descriptive name for a member of a group, if it exists.
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
Interface for objects which can provide a context on request.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method & $password
static changeableByGroup( $group)
Returns an array of the groups that a particular group can add/remove.
Array $mWatchedItems
Bool Whether the cache variables have been loaded.
static getGroupName( $group)
Get the localized descriptive name for a group, if it exists.
resetPasswordExpiration( $load=true)
Clear the password expiration for a user.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
setId( $v)
Set the user and reload all fields according to a given ID.
getRegistration()
Get the timestamp of account creation.
static sanitizeIP( $ip)
Convert an IP into a verbose, uppercase, normalized form.
static isEveryoneAllowed( $right)
Check if all users have the given permission.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
static idFromName( $name)
Get database id given a user name.
isAllowedAny()
Check if user is allowed to access a feature / make an action.
static getRightDescription( $right)
Get the description of a given right.
isLoggedIn()
Get whether the user is logged in.
checkTemporaryPassword( $plaintext)
Check if the given clear-text password matches the temporary password sent by e-mail for password res...
getTitleKey()
Get the user's name escaped by underscores.
saveToCache()
Save user data to the shared cache.
setToken( $token=false)
Set the random token (used for persistent authentication) Called from loadDefaults() among other plac...
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
wfBaseConvert( $input, $sourceBase, $destBase, $pad=1, $lowercase=true, $engine='auto')
Convert an arbitrarily-long digit string from one numeric base to another, optionally zero-padding to...
static resetIdByNameCache()
Reset the cache used in idFromName().
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
$mEmailTokenExpires
Bool Whether the cache variables have been loaded.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
isEmailConfirmed()
Is this user's e-mail address valid-looking and confirmed within limits of the current site configura...
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static unstub( $obj)
Unstubs an object, if it is a stub object.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled $incrBy
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
getPasswordExpired()
Check if the user's password is expired.
addAutopromoteOnceGroups( $event)
Add the user to the group if he/she meets given criteria.
sendMail( $subject, $body, $from=null, $replyto=null)
Send an e-mail to this user's account.
getTokenFromOption( $oname)
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and savin...
Class for creating log entries manually, for example to inject them into the database.
$mFormerGroups
Bool Whether the cache variables have been loaded.
getSkin()
Get the current skin, loading it if required.
$mBlockedGlobally
Bool Whether the cache variables have been loaded.
static selectFields()
Return the list of user fields that should be selected to create a new user object.
addNewUserLogEntryAutoCreate()
Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other a...
WebRequest $mRequest
Bool Whether the cache variables have been loaded.
getBoolOption( $oname)
Get the user's current setting for a given option, as a boolean value.
removeWatch( $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Stop watching an article.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
$mDatePreference
Bool Whether the cache variables have been loaded.
isBlocked( $bFromSlave=true)
Check if user is blocked.
$mRealName
Bool Whether the cache variables have been loaded.
isBlockedFromCreateAccount()
Get whether the user is explicitly blocked from account creation.
getEditToken( $salt='', $request=null)
Initialize (if necessary) and return a session token value which can be used in edit forms to show th...
requiresHTTPS()
Determine based on the wiki configuration and the user's options, whether this user must be over HTTP...
static $mAllRights
String Cached results of getAllRights()
isItemLoaded( $item, $all='all')
Return whether an item has been loaded.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
setOption( $oname, $val)
Set the given option for a user.
getPasswordValidity( $password)
Given unvalidated password input, return error message on failure.
static whoIsReal( $id)
Get the real name of a user given their user ID.
getName()
Get the user name, or the IP of an anonymous user.
doLogout()
Clear the user's cookies and session, and reset the instance cache.
canSendEmail()
Is this user allowed to send e-mails within limits of current site configuration?
static isCreatableName( $name)
Usernames which fail to pass this function will be blocked from new account registrations,...
$mHideName
Bool Whether the cache variables have been loaded.
static oldCrypt( $password, $userId)
Make an old-style password hash.
$mLocked
Bool Whether the cache variables have been loaded.
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
isAllowed( $action='')
Internal mechanics of testing a permission.
static newFatal( $message)
Factory function for fatal errors.
static listOptionKinds()
Return a list of the types of user options currently returned by User::getOptionKinds().
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk page