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',
135 'editusercssjs', #deprecated
147 'move-rootuserpages',
151 'override-export-depth',
174 'userrights-interwiki',
275 public function load() {
276 if ( $this->mLoadedItems ===
true ) {
282 $this->mLoadedItems =
true;
284 switch ( $this->mFrom ) {
309 throw new MWException(
"Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
320 if ( $this->mId == 0 ) {
326 $key =
wfMemcKey(
'user',
'id', $this->mId );
334 wfDebug(
"User: cache miss for user {$this->mId}\n" );
342 wfDebug(
"User: got user {$this->mId} from cache\n" );
344 foreach ( self::$mCacheVars
as $name ) {
345 $this->$name = $data[
$name];
349 $this->mLoadedItems =
true;
366 foreach ( self::$mCacheVars
as $name ) {
367 $data[
$name] = $this->$name;
370 $key =
wfMemcKey(
'user',
'id', $this->mId );
395 if ( $validate ===
true ) {
399 if (
$name ===
false ) {
406 $u->setItemLoaded(
'name' );
417 public static function newFromId( $id ) {
421 $u->setItemLoaded(
'id' );
437 $id =
$dbr->selectField(
'user',
'user_id',
array(
438 'user_email_token' => md5( $code ),
439 'user_email_token_expires > ' .
$dbr->addQuotes(
$dbr->timestamp() ),
441 if ( $id !==
false ) {
457 $user->mFrom =
'session';
458 $user->mRequest = $request;
476 public static function newFromRow( $row, $data =
null ) {
478 $user->loadFromRow( $row, $data );
489 public static function whoIs( $id ) {
499 public static function whoIsReal( $id ) {
510 if ( is_null( $nt ) ) {
515 if ( isset( self::$idCacheByName[
$name] ) ) {
516 return self::$idCacheByName[
$name];
520 $s =
$dbr->selectRow(
'user',
array(
'user_id' ),
array(
'user_name' => $nt->getText() ), __METHOD__ );
522 if (
$s ===
false ) {
530 if ( count( self::$idCacheByName ) > 1000 ) {
531 self::$idCacheByName =
array();
541 self::$idCacheByName =
array();
561 return preg_match(
'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/',
$name ) ||
IP::isIPv6(
$name );
580 || strpos(
$name,
'/' ) !==
false
581 || strlen(
$name ) > $wgMaxNameChars
584 ": '$name' invalid due to empty, IP, slash, length, or lowercase" );
591 if ( is_null( $parsed )
592 || $parsed->getNamespace()
593 || strcmp(
$name, $parsed->getPrefixedText() ) ) {
595 ": '$name' invalid due to ambiguous prefixes" );
601 $unicodeBlacklist =
'/[' .
602 '\x{0080}-\x{009f}' . # iso-8859-1 control chars
603 '\x{00a0}' . # non-breaking space
604 '\x{2000}-\x{200f}' . # various whitespace
605 '\x{2028}-\x{202f}' . # breaks and control chars
606 '\x{3000}' . # ideographic space
607 '\x{e000}-\x{f8ff}' . #
private use
609 if ( preg_match( $unicodeBlacklist,
$name ) ) {
611 ": '$name' invalid due to blacklisted characters" );
630 global $wgReservedUsernames;
632 if ( !self::isValidUserName(
$name ) ) {
636 static $reservedUsernames =
false;
637 if ( !$reservedUsernames ) {
638 $reservedUsernames = $wgReservedUsernames;
643 foreach ( $reservedUsernames
as $reserved ) {
644 if ( substr( $reserved, 0, 4 ) ==
'msg:' ) {
645 $reserved =
wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
647 if ( $reserved ==
$name ) {
667 global $wgInvalidUsernameCharacters;
672 if ( strlen(
$name ) > 235 ) {
674 ": '$name' invalid due to length" );
679 if ( $wgInvalidUsernameCharacters !==
'' ) {
680 if ( preg_match(
'/[' . preg_quote( $wgInvalidUsernameCharacters,
'/' ) .
']/',
$name ) ) {
682 ": '$name' invalid due to wgInvalidUsernameCharacters" );
717 foreach (
$result->getErrorsByType(
'warning' )
as $warning ) {
738 static $blockedLogins =
array(
739 'Useruser' =>
'Passpass',
'Useruser1' =>
'Passpass1', # r75589
740 'Apitestsysop' =>
'testpass',
'Apitestuser' =>
'testpass' # r75605
753 if ( strlen(
$password ) < $wgMinimalPasswordLength ) {
754 $status->error(
'passwordtooshort', $wgMinimalPasswordLength );
757 $status->error(
'password-name-match' );
760 $status->error(
'password-login-forbidden' );
769 } elseif (
$result ===
true ) {
795 global $wgPasswordExpirationDays;
800 if ( $wgPasswordExpirationDays ) {
803 time() + ( $wgPasswordExpirationDays * 24 * 3600 )
808 $this->mPasswordExpires = $newExpire;
821 global $wgPasswordExpireGrace;
826 if ( $expiration !==
null && $expUnix < $now ) {
827 $expired = ( $expUnix + $wgPasswordExpireGrace < $now ) ?
'hard' :
'soft';
894 # Reject names containing '#'; these will be cleaned up
895 # with title normalisation, but then it's too late to
897 if ( strpos(
$name,
'#' ) !==
false ) {
902 $t = ( $validate ===
'valid' ) ?
905 if ( is_null(
$t ) ) {
911 $name = $wgAuth->getCanonicalName(
$t->getText() );
913 switch ( $validate ) {
932 throw new MWException(
'Invalid parameter value for $validate in ' . __METHOD__ );
945 public static function edits( $uid ) {
948 return $user->getEditCount();
957 global $wgMinimalPasswordLength;
959 $length = max( 10, $wgMinimalPasswordLength );
961 $length = $length * 1.25;
980 $this->mName =
$name;
981 $this->mRealName =
'';
982 $this->mPassword = $this->mNewpassword =
'';
983 $this->mNewpassTime =
null;
985 $this->mOptionOverrides =
null;
986 $this->mOptionsLoaded =
false;
988 $loggedOut = $this->
getRequest()->getCookie(
'LoggedOut' );
989 if ( $loggedOut !==
null ) {
992 $this->mTouched =
'1'; # Allow any
pages to be cached
995 $this->mToken =
null;
996 $this->mEmailAuthenticated =
null;
997 $this->mEmailToken =
'';
998 $this->mEmailTokenExpires =
null;
999 $this->mPasswordExpires =
null;
1002 $this->mGroups =
array();
1022 return ( $this->mLoadedItems ===
true && $all ===
'all' ) ||
1023 ( isset( $this->mLoadedItems[$item] ) && $this->mLoadedItems[$item] ===
true );
1032 if ( is_array( $this->mLoadedItems ) ) {
1033 $this->mLoadedItems[$item] =
true;
1050 $cookieId = $request->getCookie(
'UserID' );
1051 $sessId = $request->getSessionData(
'wsUserID' );
1053 if ( $cookieId !==
null ) {
1054 $sId = intval( $cookieId );
1055 if ( $sessId !==
null && $cookieId != $sessId ) {
1056 wfDebugLog(
'loginSessions',
"Session user ID ($sessId) and
1057 cookie user ID ($sId) don't match!" );
1060 $request->setSessionData(
'wsUserID', $sId );
1061 } elseif ( $sessId !==
null && $sessId != 0 ) {
1067 if ( $request->getSessionData(
'wsUserName' ) !== null ) {
1068 $sName = $request->getSessionData(
'wsUserName' );
1069 } elseif ( $request->getCookie(
'UserName' ) !== null ) {
1070 $sName = $request->getCookie(
'UserName' );
1071 $request->setSessionData(
'wsUserName', $sName );
1077 if ( !$proposedUser->isLoggedIn() ) {
1082 global $wgBlockDisablesLogin;
1083 if ( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
1088 if ( $request->getSessionData(
'wsToken' ) ) {
1089 $passwordCorrect = ( $proposedUser->getToken(
false ) === $request->getSessionData(
'wsToken' ) );
1091 } elseif ( $request->getCookie(
'Token' ) ) {
1092 # Get the token from DB/cache and clean it up to remove garbage padding.
1093 # This deals with historical problems with bugs and the default column value.
1094 $token = rtrim( $proposedUser->getToken(
false ) );
1096 $passwordCorrect = strlen( $token ) && $this->
compareSecrets( $token, $request->getCookie(
'Token' ) );
1103 if ( ( $sName === $proposedUser->getName() ) && $passwordCorrect ) {
1105 $request->setSessionData(
'wsToken', $this->mToken );
1106 wfDebug(
"User: logged in from $from\n" );
1110 wfDebug(
"User: can't log in from $from, invalid credentials\n" );
1122 if ( strlen( $answer ) !== strlen(
$test ) ) {
1123 $passwordCorrect =
false;
1126 for ( $i = 0; $i < strlen( $answer ); $i++ ) {
1129 $passwordCorrect = (
$result == 0 );
1131 return $passwordCorrect;
1142 $this->mId = intval( $this->mId );
1145 if ( !$this->mId ) {
1151 $s =
$dbr->selectRow(
'user', self::selectFields(),
array(
'user_id' => $this->mId ), __METHOD__ );
1155 if (
$s !==
false ) {
1158 $this->mGroups =
null;
1178 public function loadFromRow( $row, $data =
null ) {
1181 $this->mGroups =
null;
1183 if ( isset( $row->user_name ) ) {
1184 $this->mName = $row->user_name;
1185 $this->mFrom =
'name';
1191 if ( isset( $row->user_real_name ) ) {
1192 $this->mRealName = $row->user_real_name;
1198 if ( isset( $row->user_id ) ) {
1199 $this->mId = intval( $row->user_id );
1200 $this->mFrom =
'id';
1206 if ( isset( $row->user_editcount ) ) {
1207 $this->mEditCount = $row->user_editcount;
1212 if ( isset( $row->user_password ) ) {
1213 $this->mPassword = $row->user_password;
1214 $this->mNewpassword = $row->user_newpassword;
1216 $this->mEmail = $row->user_email;
1218 $this->mToken = $row->user_token;
1219 if ( $this->mToken ==
'' ) {
1220 $this->mToken =
null;
1223 $this->mEmailToken = $row->user_email_token;
1232 $this->mLoadedItems =
true;
1235 if ( is_array( $data ) ) {
1236 if ( isset( $data[
'user_groups'] ) && is_array( $data[
'user_groups'] ) ) {
1237 $this->mGroups = $data[
'user_groups'];
1239 if ( isset( $data[
'user_properties'] ) && is_array( $data[
'user_properties'] ) ) {
1252 $user->loadGroups();
1253 $user->loadOptions();
1254 foreach ( self::$mCacheVars
as $var ) {
1255 $this->$var =
$user->$var;
1263 if ( is_null( $this->mGroups ) ) {
1265 $res =
$dbr->select(
'user_groups',
1266 array(
'ug_group' ),
1267 array(
'ug_user' => $this->mId ),
1269 $this->mGroups =
array();
1270 foreach (
$res as $row ) {
1271 $this->mGroups[] = $row->ug_group;
1291 global $wgAutopromoteOnceLogInRC, $wgAuth;
1293 $toPromote =
array();
1294 if ( $this->
getId() ) {
1296 if ( count( $toPromote ) ) {
1299 foreach ( $toPromote
as $group ) {
1303 $wgAuth->updateExternalDBGroups( $this, $toPromote );
1305 $newGroups = array_merge( $oldGroups, $toPromote );
1308 $logEntry->setPerformer( $this );
1310 $logEntry->setParameters(
array(
1311 '4::oldgroups' => $oldGroups,
1312 '5::newgroups' => $newGroups,
1314 $logid = $logEntry->insert();
1315 if ( $wgAutopromoteOnceLogInRC ) {
1316 $logEntry->publish( $logid );
1332 $this->mNewtalk = -1;
1333 $this->mDatePreference =
null;
1334 $this->mBlockedby = -1; # Unset
1335 $this->mHash =
false;
1336 $this->mRights =
null;
1337 $this->mEffectiveGroups =
null;
1338 $this->mImplicitGroups =
null;
1339 $this->mGroups =
null;
1340 $this->mOptions =
null;
1341 $this->mOptionsLoaded =
false;
1342 $this->mEditCount =
null;
1344 if ( $reloadFrom ) {
1345 $this->mLoadedItems =
array();
1346 $this->mFrom = $reloadFrom;
1357 global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions,
$wgContLang, $wgDefaultSkin;
1359 static $defOpt =
null;
1360 if ( !defined(
'MW_PHPUNIT_TEST' ) && $defOpt !==
null ) {
1367 $defOpt = $wgDefaultUserOptions;
1370 foreach ( LanguageConverter::$languagesWithVariants
as $langCode ) {
1371 $defOpt[$langCode ==
$wgContLang->getCode() ?
'variant' :
"variant-$langCode"] = $langCode;
1374 $defOpt[
'searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
1376 $defOpt[
'skin'] = $wgDefaultSkin;
1391 if ( isset( $defOpts[$opt] ) ) {
1392 return $defOpts[$opt];
1408 if ( -1 != $this->mBlockedby ) {
1413 wfDebug( __METHOD__ .
": checking...\n" );
1422 # We only need to worry about passing the IP address to the Block generator if the
1423 # user is not immune to autoblocks/hardblocks, and they are the current user so we
1424 # know which IP address they're actually coming from
1425 if ( !$this->
isAllowed(
'ipblock-exempt' ) && $this->getID() ==
$wgUser->getID() ) {
1435 if ( !$block instanceof
Block && $ip !==
null && !$this->
isAllowed(
'proxyunbannable' )
1436 && !in_array( $ip, $wgProxyWhitelist )
1439 if ( self::isLocallyBlockedProxy( $ip ) ) {
1442 $block->mReason =
wfMessage(
'proxyblockreason' )->text();
1443 $block->setTarget( $ip );
1447 $block->mReason =
wfMessage(
'sorbsreason' )->text();
1448 $block->setTarget( $ip );
1453 if ( !$block instanceof
Block
1454 && $wgApplyIpBlocksToXff
1456 && !$this->
isAllowed(
'proxyunbannable' )
1457 && !in_array( $ip, $wgProxyWhitelist )
1459 $xff = $this->
getRequest()->getHeader(
'X-Forwarded-For' );
1460 $xff = array_map(
'trim', explode(
',', $xff ) );
1461 $xff = array_diff( $xff,
array( $ip ) );
1464 if ( $block instanceof
Block ) {
1465 # Mangle the reason to alert the user that the block
1466 # originated from matching the X-Forwarded-For header.
1467 $block->mReason =
wfMessage(
'xffblockreason', $block->mReason )->text();
1471 if ( $block instanceof
Block ) {
1472 wfDebug( __METHOD__ .
": Found block.\n" );
1473 $this->mBlock = $block;
1474 $this->mBlockedby = $block->getByName();
1475 $this->mBlockreason = $block->mReason;
1476 $this->mHideName = $block->mHideName;
1477 $this->mAllowUsertalk = !$block->prevents(
'editownusertalk' );
1479 $this->mBlockedby =
'';
1480 $this->mHideName = 0;
1481 $this->mAllowUsertalk =
false;
1498 global $wgEnableSorbs, $wgEnableDnsBlacklist,
1499 $wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist;
1501 if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs ) {
1505 if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
1509 $urls = array_merge( $wgDnsBlacklistUrls, (
array)$wgSorbsUrl );
1527 $ipReversed = implode(
'.', array_reverse( explode(
'.', $ip ) ) );
1529 foreach ( (
array)$bases
as $base ) {
1532 if ( is_array( $base ) ) {
1533 if ( count( $base ) >= 2 ) {
1535 $host =
"{$base[1]}.$ipReversed.{$base[0]}";
1537 $host =
"$ipReversed.{$base[0]}";
1540 $host =
"$ipReversed.$base";
1544 $ipList = gethostbynamel( $host );
1547 wfDebugLog(
'dnsblacklist',
"Hostname $host is {$ipList[0]}, it's a proxy says $base!" );
1551 wfDebugLog(
'dnsblacklist',
"Requested $host, not found in $base." );
1570 if ( !$wgProxyList ) {
1575 if ( !is_array( $wgProxyList ) ) {
1577 $wgProxyList = array_map(
'trim',
file( $wgProxyList ) );
1580 if ( !is_array( $wgProxyList ) ) {
1582 } elseif ( array_search( $ip, $wgProxyList ) !==
false ) {
1584 } elseif ( array_key_exists( $ip, $wgProxyList ) ) {
1600 global $wgRateLimitsExcludedIPs;
1601 if ( in_array( $this->
getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
1607 return !$this->
isAllowed(
'noratelimit' );
1629 if ( !isset( $wgRateLimits[$action] ) ) {
1641 $limits = $wgRateLimits[$action];
1643 $id = $this->
getId();
1646 if ( isset( $limits[
'anon'] ) && $id == 0 ) {
1647 $keys[
wfMemcKey(
'limiter', $action,
'anon' )] = $limits[
'anon'];
1650 if ( isset( $limits[
'user'] ) && $id != 0 ) {
1651 $userLimit = $limits[
'user'];
1654 if ( isset( $limits[
'newbie'] ) && $id != 0 ) {
1655 $keys[
wfMemcKey(
'limiter', $action,
'user', $id )] = $limits[
'newbie'];
1657 if ( isset( $limits[
'ip'] ) ) {
1659 $keys[
"mediawiki:limiter:$action:ip:$ip"] = $limits[
'ip'];
1661 if ( isset( $limits[
'subnet'] ) ) {
1667 $subnet = $parts[0];
1668 } elseif ( preg_match(
'/^(\d+\.\d+\.\d+)\.\d+$/', $ip,
$matches ) ) {
1672 if ( $subnet !==
false ) {
1673 $keys[
"mediawiki:limiter:$action:subnet:$subnet"] = $limits[
'subnet'];
1680 if ( isset( $limits[$group] ) ) {
1681 if ( $userLimit ===
false || $limits[$group] > $userLimit ) {
1682 $userLimit = $limits[$group];
1687 if ( $userLimit !==
false ) {
1688 list( $max, $period ) = $userLimit;
1689 wfDebug( __METHOD__ .
": effective user limit: $max in {$period}s\n" );
1690 $keys[
wfMemcKey(
'limiter', $action,
'user', $id )] = $userLimit;
1696 $summary =
"(limit $max in {$period}s)";
1701 wfDebugLog(
'ratelimit', $this->
getName() .
" tripped! $key at $count $summary" );
1704 wfDebug( __METHOD__ .
": ok. $key at $count $summary\n" );
1707 wfDebug( __METHOD__ .
": adding record for $key $summary\n" );
1709 $wgMemc->add( $key, 0, intval( $period ) );
1727 public function isBlocked( $bFromSlave =
true ) {
1737 public function getBlock( $bFromSlave =
true ) {
1739 return $this->mBlock instanceof
Block ? $this->mBlock :
null;
1750 global $wgBlockAllowsUTEdit;
1753 $blocked = $this->
isBlocked( $bFromSlave );
1759 wfDebug( __METHOD__ .
": self-talk page, ignoring any blocks\n" );
1792 return ( $this->mBlock ? $this->mBlock->getId() :
false );
1804 if ( $this->mBlockedGlobally !==
null ) {
1814 wfRunHooks(
'UserIsBlockedGlobally',
array( &$this, $ip, &$blocked ) );
1815 $this->mBlockedGlobally = (bool)$blocked;
1825 if ( $this->mLocked !==
null ) {
1830 $authUser = $wgAuth->getUserInstance( $this );
1831 $this->mLocked = (bool)$authUser->isLocked();
1841 if ( $this->mHideName !==
null ) {
1845 if ( !$this->mHideName ) {
1848 $authUser = $wgAuth->getUserInstance( $this );
1849 $this->mHideName = (bool)$authUser->isHidden();
1858 public function getId() {
1859 if ( $this->mId ===
null && $this->mName !==
null &&
User::isIP( $this->mName ) ) {
1873 public function setId( $v ) {
1888 if ( $this->mName ===
false ) {
1909 public function setName( $str ) {
1911 $this->mName = $str;
1919 return str_replace(
' ',
'_', $this->
getName() );
1930 if ( $this->mNewtalk === -1 ) {
1931 $this->mNewtalk =
false; # reset talk
page status
1935 if ( !$this->mId ) {
1936 global $wgDisableAnonTalk;
1937 if ( $wgDisableAnonTalk ) {
1939 $this->mNewtalk =
false;
1943 $newtalk =
$wgMemc->get( $key );
1944 if ( strval( $newtalk ) !==
'' ) {
1945 $this->mNewtalk = (bool)$newtalk;
1950 $wgMemc->set( $key, (
int)$this->mNewtalk, 1800 );
1954 $this->mNewtalk = $this->
checkNewtalk(
'user_id', $this->mId );
1976 if ( !
wfRunHooks(
'UserRetrieveNewTalks',
array( &$this, &$talks ) ) ) {
1985 'MIN(user_last_timestamp)',
1998 $newMessageRevisionId =
null;
2000 if ( $newMessageLinks ) {
2004 if ( count( $newMessageLinks ) === 1
2005 && $newMessageLinks[0][
'wiki'] ===
wfWikiID()
2006 && $newMessageLinks[0][
'rev']
2008 $newMessageRevision = $newMessageLinks[0][
'rev'];
2009 $newMessageRevisionId = $newMessageRevision->getId();
2012 return $newMessageRevisionId;
2024 protected function checkNewtalk( $field, $id, $fromMaster =
false ) {
2025 if ( $fromMaster ) {
2030 $ok = $db->selectField(
'user_newtalk', $field,
2031 array( $field => $id ), __METHOD__ );
2032 return $ok !==
false;
2042 protected function updateNewtalk( $field, $id, $curRev =
null ) {
2044 $prevRev = $curRev ? $curRev->getPrevious() :
false;
2045 $ts = $prevRev ? $prevRev->getTimestamp() :
null;
2048 $dbw->insert(
'user_newtalk',
2049 array( $field => $id,
'user_last_timestamp' => $dbw->timestampOrNull( $ts ) ),
2052 if ( $dbw->affectedRows() ) {
2053 wfDebug( __METHOD__ .
": set on ($field, $id)\n" );
2056 wfDebug( __METHOD__ .
" already set ($field, $id)\n" );
2069 $dbw->delete(
'user_newtalk',
2070 array( $field => $id ),
2072 if ( $dbw->affectedRows() ) {
2073 wfDebug( __METHOD__ .
": killed on ($field, $id)\n" );
2076 wfDebug( __METHOD__ .
": already gone ($field, $id)\n" );
2086 public function setNewtalk( $val, $curRev =
null ) {
2092 $this->mNewtalk = $val;
2099 $id = $this->
getId();
2112 $key =
wfMemcKey(
'newtalk',
'ip', $id );
2113 $wgMemc->set( $key, $val ? 1 : 0, 1800 );
2126 global $wgClockSkewFudge;
2161 $method = __METHOD__;
2162 $dbw->onTransactionIdle(
function() use ( $dbw, $userid, $touched, $method ) {
2164 $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) );
2165 $needsPurge = $dbw->selectField(
'user',
'1',
2166 array(
'user_id' => $userid,
'user_touched < ' . $encTouched ) );
2167 if ( $needsPurge ) {
2168 $dbw->update(
'user',
2169 array(
'user_touched' => $dbw->timestamp( $touched ) ),
2170 array(
'user_id' => $userid,
'user_touched < ' . $encTouched ),
2217 if ( $str !==
null ) {
2218 if ( !$wgAuth->allowPasswordChange() ) {
2223 global $wgMinimalPasswordLength;
2225 if ( is_array( $valid ) ) {
2226 $message = array_shift( $valid );
2236 if ( !$wgAuth->setPassword( $this, $str ) ) {
2256 if ( $str ===
null ) {
2258 $this->mPassword =
'';
2262 $this->mNewpassword =
'';
2263 $this->mNewpassTime =
null;
2271 public function getToken( $forceCreation =
true ) {
2273 if ( !$this->mToken && $forceCreation ) {
2285 public function setToken( $token =
false ) {
2290 $this->mToken = $token;
2304 if ( $str ===
null ) {
2305 $this->mNewpassword =
'';
2306 $this->mNewpassTime =
null;
2321 global $wgPasswordReminderResendTime;
2323 if ( !$this->mNewpassTime || !$wgPasswordReminderResendTime ) {
2326 $expiry =
wfTimestamp(
TS_UNIX, $this->mNewpassTime ) + $wgPasswordReminderResendTime * 3600;
2327 return time() < $expiry;
2346 wfRunHooks(
'UserGetEmailAuthenticationTimestamp',
array( $this, &$this->mEmailAuthenticated ) );
2356 if ( $str == $this->mEmail ) {
2359 $this->mEmail = $str;
2372 global $wgEnableEmail, $wgEmailAuthentication;
2374 if ( !$wgEnableEmail ) {
2379 if ( $str === $oldaddr ) {
2385 if ( $str !==
'' && $wgEmailAuthentication ) {
2387 $type = $oldaddr !=
'' ?
'changed' :
'set';
2418 $this->mRealName = $str;
2431 public function getOption( $oname, $defaultOverride =
null, $ignoreHidden =
false ) {
2435 # We want 'disabled' preferences to always behave as the default value for
2436 # users, even if they have set the option explicitly in their settings (ie they
2437 # set it, and then it was disabled removing their ability to change it). But
2438 # we don't want to erase the preferences in the database in case the preference
2439 # is re-enabled again. So don't touch $mOptions, just override the returned value
2440 if ( !$ignoreHidden && in_array( $oname, $wgHiddenPrefs ) ) {
2444 if ( array_key_exists( $oname, $this->mOptions ) ) {
2445 return $this->mOptions[$oname];
2447 return $defaultOverride;
2461 # We want 'disabled' preferences to always behave as the default value for
2462 # users, even if they have set the option explicitly in their settings (ie they
2463 # set it, and then it was disabled removing their ability to change it). But
2464 # we don't want to erase the preferences in the database in case the preference
2465 # is re-enabled again. So don't touch $mOptions, just override the returned value
2466 foreach ( $wgHiddenPrefs
as $pref ) {
2468 if ( $default !==
null ) {
2484 return (
bool)$this->
getOption( $oname );
2495 public function getIntOption( $oname, $defaultOverride = 0 ) {
2498 $val = $defaultOverride;
2500 return intval( $val );
2509 public function setOption( $oname, $val ) {
2513 if ( is_null( $val ) ) {
2517 $this->mOptions[$oname] = $val;
2531 if ( in_array( $oname, $wgHiddenPrefs ) ) {
2554 if ( in_array( $oname, $wgHiddenPrefs ) ) {
2589 'registered-multiselect',
2590 'registered-checkmatrix',
2621 unset( $prefs[
$name] );
2626 $multiselectOptions =
array();
2627 foreach ( $prefs
as $name => $info ) {
2628 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
2629 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
2631 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
2634 $multiselectOptions[
"$prefix$value"] =
true;
2637 unset( $prefs[
$name] );
2640 $checkmatrixOptions =
array();
2641 foreach ( $prefs
as $name => $info ) {
2642 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
2643 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
2646 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
2649 foreach ( $rows
as $row ) {
2650 $checkmatrixOptions[
"$prefix-$column-$row"] =
true;
2654 unset( $prefs[
$name] );
2660 if ( isset( $prefs[$key] ) ) {
2661 $mapping[$key] =
'registered';
2662 } elseif ( isset( $multiselectOptions[$key] ) ) {
2663 $mapping[$key] =
'registered-multiselect';
2664 } elseif ( isset( $checkmatrixOptions[$key] ) ) {
2665 $mapping[$key] =
'registered-checkmatrix';
2666 } elseif ( isset( $specialOptions[$key] ) ) {
2667 $mapping[$key] =
'special';
2668 } elseif ( substr( $key, 0, 7 ) ===
'userjs-' ) {
2669 $mapping[$key] =
'userjs';
2671 $mapping[$key] =
'unused';
2693 $resetKinds =
array(
'registered',
'registered-multiselect',
'registered-checkmatrix',
'unused' ),
2699 if ( !is_array( $resetKinds ) ) {
2700 $resetKinds =
array( $resetKinds );
2703 if ( in_array(
'all', $resetKinds ) ) {
2706 if ( $context ===
null ) {
2711 $resetKinds = array_intersect( $resetKinds, self::listOptionKinds() );
2712 $newOptions =
array();
2716 foreach ( $this->mOptions
as $key =>
$value ) {
2717 if ( in_array( $optionKinds[$key], $resetKinds ) ) {
2722 $newOptions[$key] =
$value;
2727 $this->mOptions = $newOptions;
2728 $this->mOptionsLoaded =
true;
2737 if ( is_null( $this->mDatePreference ) ) {
2740 $map =
$wgLang->getDatePreferenceMigrationMap();
2741 if ( isset( $map[
$value] ) ) {
2744 $this->mDatePreference =
$value;
2757 if ( !$wgSecureLogin ) {
2777 if ( $threshold > $wgMaxArticleSize * 1024 ) {
2790 if ( is_null( $this->mRights ) ) {
2794 $this->mRights = array_values( array_unique( $this->mRights ) );
2818 if ( $recache || is_null( $this->mEffectiveGroups ) ) {
2820 $this->mEffectiveGroups = array_unique( array_merge(
2825 wfRunHooks(
'UserEffectiveGroups',
array( &$this, &$this->mEffectiveGroups ) );
2827 $this->mEffectiveGroups = array_values( array_unique( $this->mEffectiveGroups ) );
2841 if ( $recache || is_null( $this->mImplicitGroups ) ) {
2843 $this->mImplicitGroups =
array(
'*' );
2844 if ( $this->
getId() ) {
2845 $this->mImplicitGroups[] =
'user';
2847 $this->mImplicitGroups = array_unique( array_merge(
2848 $this->mImplicitGroups,
2855 $this->mEffectiveGroups =
null;
2872 if ( is_null( $this->mFormerGroups ) ) {
2874 $res =
$dbr->select(
'user_former_groups',
2875 array(
'ufg_group' ),
2876 array(
'ufg_user' => $this->mId ),
2878 $this->mFormerGroups =
array();
2879 foreach (
$res as $row ) {
2880 $this->mFormerGroups[] = $row->ufg_group;
2891 if ( !$this->
getId() ) {
2895 if ( !isset( $this->mEditCount ) ) {
2901 'user',
'user_editcount',
2902 array(
'user_id' => $this->mId ),
2910 $this->mEditCount =
$count;
2921 public function addGroup( $group ) {
2924 if ( $this->
getId() ) {
2925 $dbw->insert(
'user_groups',
2927 'ug_user' => $this->getID(),
2928 'ug_group' => $group,
2931 array(
'IGNORE' ) );
2935 $this->mGroups[] = $group;
2938 $this->mGroups = array_unique( $this->mGroups );
2943 $this->mRights =
null;
2957 $dbw->delete(
'user_groups',
2959 'ug_user' => $this->getID(),
2960 'ug_group' => $group,
2963 $dbw->insert(
'user_former_groups',
2965 'ufg_user' => $this->getID(),
2966 'ufg_group' => $group,
2969 array(
'IGNORE' ) );
2972 $this->mGroups = array_diff( $this->mGroups,
array( $group ) );
2977 $this->mRights =
null;
2987 return $this->getID() != 0;
2994 public function isAnon() {
3007 $permissions = func_get_args();
3008 foreach ( $permissions
as $permission ) {
3009 if ( $this->
isAllowed( $permission ) ) {
3022 $permissions = func_get_args();
3023 foreach ( $permissions
as $permission ) {
3024 if ( !$this->
isAllowed( $permission ) ) {
3036 public function isAllowed( $action =
'' ) {
3037 if ( $action ===
'' ) {
3041 if ( $action ===
'patrol' || $action ===
'autopatrol' ) {
3042 global $wgUseRCPatrol, $wgUseNPPatrol;
3043 if ( !$wgUseRCPatrol && !$wgUseNPPatrol ) {
3049 return in_array( $action, $this->
getRights(),
true );
3058 return $wgUseRCPatrol && $this->
isAllowedAny(
'patrol',
'patrolmarks' );
3066 global $wgUseRCPatrol, $wgUseNPPatrol;
3068 ( $wgUseRCPatrol || $wgUseNPPatrol )
3079 if ( $this->mRequest ) {
3108 $key = $checkRights .
':' .
$title->getNamespace() .
':' .
$title->getDBkey();
3110 if ( isset( $this->mWatchedItems[$key] ) ) {
3111 return $this->mWatchedItems[$key];
3114 if ( count( $this->mWatchedItems ) >= self::MAX_WATCHED_ITEMS_CACHE ) {
3115 $this->mWatchedItems =
array();
3119 return $this->mWatchedItems[$key];
3175 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3181 if ( !
wfRunHooks(
'UserClearNewTalkNotification',
array( &$this, $oldid ) ) ) {
3185 $nextid = $oldid ?
$title->getNextRevisionID( $oldid ) :
null;
3187 if ( !$oldid || !$nextid ) {
3233 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3242 $id = $this->
getId();
3245 $dbw->update(
'watchlist',
3246 array(
'wl_notificationtimestamp' =>
null ),
3247 array(
'wl_user' => $id ),
3294 public function setCookies( $request =
null, $secure =
null, $rememberMe =
false ) {
3295 if ( $request ===
null ) {
3300 if ( 0 == $this->mId ) {
3303 if ( !$this->mToken ) {
3312 'wsUserID' => $this->mId,
3313 'wsToken' => $this->mToken,
3314 'wsUserName' => $this->
getName()
3317 'UserID' => $this->mId,
3318 'UserName' => $this->
getName(),
3320 if ( $rememberMe ) {
3332 if (
$value ===
false ) {
3346 if ( $request->getCheck(
'wpStickHTTPS' ) || $this->
requiresHTTPS() ) {
3350 $rememberMe ? 0 :
null,
3352 array(
'prefix' =>
'' )
3360 public function logout() {
3373 $this->
getRequest()->setSessionData(
'wsUserID', 0 );
3380 $this->
setCookie(
'LoggedOut', time(), time() + 86400 );
3394 if ( 0 == $this->mId ) {
3399 if ( !$wgAuth->allowSetLocalPassword() ) {
3400 $this->mPassword =
'';
3404 $dbw->update(
'user',
3406 'user_name' => $this->mName,
3407 'user_password' => $this->mPassword,
3408 'user_newpassword' => $this->mNewpassword,
3409 'user_newpass_time' => $dbw->timestampOrNull( $this->mNewpassTime ),
3412 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
3413 'user_touched' => $dbw->timestamp( $this->mTouched ),
3414 'user_token' => strval( $this->mToken ),
3416 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
3417 'user_password_expires' => $dbw->timestampOrNull( $this->mPasswordExpires ),
3419 'user_id' => $this->mId
3441 $id =
$dbr->selectField(
'user',
'user_id',
array(
'user_name' =>
$s ), __METHOD__ );
3442 if ( $id ===
false ) {
3468 if ( isset(
$params[
'options'] ) ) {
3473 $seqVal = $dbw->nextSequenceValue(
'user_user_id_seq' );
3476 'user_id' => $seqVal,
3477 'user_name' =>
$name,
3478 'user_password' =>
$user->mPassword,
3479 'user_newpassword' =>
$user->mNewpassword,
3480 'user_newpass_time' => $dbw->timestampOrNull(
$user->mNewpassTime ),
3481 'user_email' =>
$user->mEmail,
3482 'user_email_authenticated' => $dbw->timestampOrNull(
$user->mEmailAuthenticated ),
3483 'user_real_name' =>
$user->mRealName,
3484 'user_token' => strval(
$user->mToken ),
3485 'user_registration' => $dbw->timestamp(
$user->mRegistration ),
3486 'user_editcount' => 0,
3487 'user_touched' => $dbw->timestamp( self::newTouchedTimestamp() ),
3490 $fields[
"user_$name"] =
$value;
3492 $dbw->insert(
'user', $fields, __METHOD__,
array(
'IGNORE' ) );
3493 if ( $dbw->affectedRows() ) {
3529 if ( !$this->mToken ) {
3536 $inWrite = $dbw->writesOrCallbacksPending();
3537 $seqVal = $dbw->nextSequenceValue(
'user_user_id_seq' );
3538 $dbw->insert(
'user',
3540 'user_id' => $seqVal,
3541 'user_name' => $this->mName,
3542 'user_password' => $this->mPassword,
3543 'user_newpassword' => $this->mNewpassword,
3544 'user_newpass_time' => $dbw->timestampOrNull( $this->mNewpassTime ),
3546 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
3548 'user_token' => strval( $this->mToken ),
3549 'user_registration' => $dbw->timestamp( $this->mRegistration ),
3550 'user_editcount' => 0,
3551 'user_touched' => $dbw->timestamp( $this->mTouched ),
3555 if ( !$dbw->affectedRows() ) {
3560 $dbw->commit( __METHOD__,
'flush' );
3562 $this->mId = $dbw->selectField(
'user',
'user_id',
3563 array(
'user_name' => $this->mName ), __METHOD__ );
3571 throw new MWException( __METHOD__ .
": hit a key conflict attempting " .
3572 "to insert user '{$this->mName}' row, but it was not present in select!" );
3576 $this->mId = $dbw->insertId();
3603 wfDebug( __METHOD__ .
"()\n" );
3605 if ( $this->mId == 0 ) {
3610 if ( !$userblock ) {
3614 return (
bool)$userblock->doAutoblock( $this->
getRequest()->getIP() );
3623 if ( $this->mBlock && $this->mBlock->prevents(
'createaccount' ) ) {
3627 # bug 13611: if the IP address the user is trying to create an account from is
3628 # blocked with createaccount disabled, prevent new account creation there even
3629 # when the user is logged in
3630 if ( $this->mBlockedFromCreateAccount ===
false && !$this->
isAllowed(
'ipblock-exempt' ) ) {
3633 return $this->mBlockedFromCreateAccount instanceof
Block && $this->mBlockedFromCreateAccount->
prevents(
'createaccount' )
3634 ? $this->mBlockedFromCreateAccount
3644 return $this->mBlock && $this->mBlock->prevents(
'sendemail' );
3671 return $title->getTalkPage();
3680 return !$this->
isAllowed(
'autoconfirmed' );
3689 global $wgAuth, $wgLegacyEncoding;
3696 if ( $wgAuth->authenticate( $this->getName(),
$password ) ) {
3698 } elseif ( $wgAuth->strict() ) {
3701 } elseif ( $wgAuth->strictUserAuth( $this->getName() ) ) {
3705 if ( self::comparePasswords( $this->mPassword,
$password, $this->mId ) ) {
3707 } elseif ( $wgLegacyEncoding ) {
3710 $cp1252Password = iconv(
'UTF-8',
'WINDOWS-1252//TRANSLIT',
$password );
3712 && self::comparePasswords( $this->mPassword, $cp1252Password, $this->mId )
3729 global $wgNewPasswordExpiry;
3732 if ( self::comparePasswords( $this->mNewpassword, $plaintext, $this->
getId() ) ) {
3733 if ( is_null( $this->mNewpassTime ) ) {
3737 return ( time() < $expiry );
3751 public function editToken( $salt =
'', $request =
null ) {
3768 public function getEditToken( $salt =
'', $request =
null ) {
3769 if ( $request ==
null ) {
3776 $token = $request->getSessionData(
'wsEditToken' );
3777 if ( $token ===
null ) {
3779 $request->setSessionData(
'wsEditToken', $token );
3781 if ( is_array( $salt ) ) {
3782 $salt = implode(
'|', $salt );
3809 public function matchEditToken( $val, $salt =
'', $request =
null ) {
3810 $sessionToken = $this->
getEditToken( $salt, $request );
3811 if ( $val != $sessionToken ) {
3812 wfDebug(
"User::matchEditToken: broken session data\n" );
3814 return $val == $sessionToken;
3827 $sessionToken = $this->
getEditToken( $salt, $request );
3828 return substr( $sessionToken, 0, 32 ) == substr( $val, 0, 32 );
3846 if (
$type ==
'created' ||
$type ===
false ) {
3847 $message =
'confirmemail_body';
3848 } elseif (
$type ===
true ) {
3849 $message =
'confirmemail_body_changed';
3852 $message =
'confirmemail_body_' .
$type;
3860 $wgLang->timeanddate( $expiration,
false ),
3862 $wgLang->date( $expiration,
false ),
3876 public function sendMail( $subject, $body,
$from =
null, $replyto =
null ) {
3877 if ( is_null(
$from ) ) {
3878 global $wgPasswordSender;
3900 global $wgUserEmailConfirmationTokenExpiry;
3902 $expires = $now + $wgUserEmailConfirmationTokenExpiry;
3906 $hash = md5( $token );
3907 $this->mEmailToken =
$hash;
3908 $this->mEmailTokenExpires = $expiration;
3918 return $this->
getTokenUrl(
'ConfirmEmail', $token );
3927 return $this->
getTokenUrl(
'InvalidateEmail', $token );
3947 return $title->getCanonicalURL();
3976 $this->mEmailToken =
null;
3977 $this->mEmailTokenExpires =
null;
3990 wfRunHooks(
'UserSetEmailAuthenticationTimestamp',
array( $this, &$this->mEmailAuthenticated ) );
3999 global $wgEnableEmail, $wgEnableUserEmail;
4000 if ( !$wgEnableEmail || !$wgEnableUserEmail || !$this->
isAllowed(
'sendemail' ) ) {
4028 global $wgEmailAuthentication;
4052 global $wgEmailAuthentication;
4053 return $wgEmailAuthentication &&
4055 $this->mEmailToken &&
4081 if ( $this->
getId() == 0 ) {
4085 $time =
$dbr->selectField(
'revision',
'rev_timestamp',
4088 array(
'ORDER BY' =>
'rev_timestamp ASC' )
4103 global $wgGroupPermissions, $wgRevokePermissions;
4106 foreach ( $groups
as $group ) {
4107 if ( isset( $wgGroupPermissions[$group] ) ) {
4108 $rights = array_merge( $rights,
4110 array_keys( array_filter( $wgGroupPermissions[$group] ) ) );
4114 foreach ( $groups
as $group ) {
4115 if ( isset( $wgRevokePermissions[$group] ) ) {
4116 $rights = array_diff( $rights,
4117 array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
4120 return array_unique( $rights );
4130 global $wgGroupPermissions;
4131 $allowedGroups =
array();
4132 foreach ( array_keys( $wgGroupPermissions )
as $group ) {
4133 if ( self::groupHasPermission( $group, $role ) ) {
4134 $allowedGroups[] = $group;
4137 return $allowedGroups;
4153 global $wgGroupPermissions, $wgRevokePermissions;
4154 return isset( $wgGroupPermissions[$group][$role] ) && $wgGroupPermissions[$group][$role]
4155 && !( isset( $wgRevokePermissions[$group][$role] ) && $wgRevokePermissions[$group][$role] );
4166 global $wgGroupPermissions, $wgRevokePermissions;
4171 if ( isset(
$cache[
$right] ) && !defined(
'MW_PHPUNIT_TEST' ) ) {
4175 if ( !isset( $wgGroupPermissions[
'*'][
$right] ) || !$wgGroupPermissions[
'*'][
$right] ) {
4181 foreach ( $wgRevokePermissions
as $rights ) {
4206 return $msg->isBlank() ? $group : $msg->text();
4216 public static function getGroupMember( $group, $username =
'#' ) {
4217 $msg =
wfMessage(
"group-$group-member", $username );
4218 return $msg->isBlank() ? $group : $msg->text();
4228 global $wgGroupPermissions, $wgRevokePermissions;
4230 array_merge( array_keys( $wgGroupPermissions ), array_keys( $wgRevokePermissions ) ),
4231 self::getImplicitGroups()
4240 if ( self::$mAllRights ===
false ) {
4241 global $wgAvailableRights;
4242 if ( count( $wgAvailableRights ) ) {
4243 self::$mAllRights = array_unique( array_merge( self::$mCoreRights, $wgAvailableRights ) );
4257 global $wgImplicitGroups;
4258 $groups = $wgImplicitGroups;
4259 wfRunHooks(
'UserGetImplicitGroups',
array( &$groups ) ); #deprecated, use $wgImplictGroups instead
4270 $msg =
wfMessage(
'grouppage-' . $group )->inContentLanguage();
4271 if ( $msg->exists() ) {
4273 if ( is_object(
$title ) ) {
4289 if ( $text ==
'' ) {
4309 if ( $text ==
'' ) {
4314 $page =
$title->getPrefixedText();
4315 return "[[$page|$text]]";
4331 global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
4334 if ( empty( $wgAddGroups[$group] ) ) {
4336 } elseif ( $wgAddGroups[$group] ===
true ) {
4339 } elseif ( is_array( $wgAddGroups[$group] ) ) {
4340 $groups[
'add'] = $wgAddGroups[$group];
4344 if ( empty( $wgRemoveGroups[$group] ) ) {
4345 } elseif ( $wgRemoveGroups[$group] ===
true ) {
4347 } elseif ( is_array( $wgRemoveGroups[$group] ) ) {
4348 $groups[
'remove'] = $wgRemoveGroups[$group];
4352 if ( empty( $wgGroupsAddToSelf[
'user'] ) || $wgGroupsAddToSelf[
'user'] !==
true ) {
4353 foreach ( $wgGroupsAddToSelf
as $key =>
$value ) {
4354 if ( is_int( $key ) ) {
4355 $wgGroupsAddToSelf[
'user'][] =
$value;
4360 if ( empty( $wgGroupsRemoveFromSelf[
'user'] ) || $wgGroupsRemoveFromSelf[
'user'] !==
true ) {
4361 foreach ( $wgGroupsRemoveFromSelf
as $key =>
$value ) {
4362 if ( is_int( $key ) ) {
4363 $wgGroupsRemoveFromSelf[
'user'][] =
$value;
4369 if ( empty( $wgGroupsAddToSelf[$group] ) ) {
4370 } elseif ( $wgGroupsAddToSelf[$group] ===
true ) {
4373 } elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) {
4374 $groups[
'add-self'] = $wgGroupsAddToSelf[$group];
4377 if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
4378 } elseif ( $wgGroupsRemoveFromSelf[$group] ===
true ) {
4380 } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
4381 $groups[
'remove-self'] = $wgGroupsRemoveFromSelf[$group];
4395 if ( $this->
isAllowed(
'userrights' ) ) {
4404 'add-self' =>
array(),
4405 'remove-self' =>
array()
4412 'remove' =>
array(),
4413 'add-self' =>
array(),
4414 'remove-self' =>
array()
4418 foreach ( $addergroups
as $addergroup ) {
4419 $groups = array_merge_recursive(
4422 $groups[
'add'] = array_unique( $groups[
'add'] );
4423 $groups[
'remove'] = array_unique( $groups[
'remove'] );
4424 $groups[
'add-self'] = array_unique( $groups[
'add-self'] );
4425 $groups[
'remove-self'] = array_unique( $groups[
'remove-self'] );
4435 if ( !$this->
isAnon() ) {
4439 array(
'user_editcount=user_editcount+1' ),
4445 if ( $dbw->affectedRows() == 0 ) {
4448 if (
$dbr !== $dbw ) {
4501 $key =
"right-$right";
4503 return $msg->isBlank() ?
$right : $msg->text();
4515 if ( $wgPasswordSalt ) {
4516 return md5( $userId .
'-' . md5(
$password ) );
4538 if ( $wgPasswordSalt ) {
4539 if ( $salt ===
false ) {
4542 return ':B:' . $salt .
':' . md5( $salt .
'-' . md5(
$password ) );
4566 if (
$type ==
':A:' ) {
4569 } elseif (
$type ==
':B:' ) {
4571 list( $salt, $realHash ) = explode(
':', substr(
$hash, 3 ), 2 );
4572 return md5( $salt .
'-' . md5(
$password ) ) === $realHash;
4602 if ( empty( $wgNewUserLog ) ) {
4606 if ( $action ===
true ) {
4607 $action =
'byemail';
4608 } elseif ( $action ===
false ) {
4609 if ( $this->
getName() == $wgUser->getName() ) {
4612 $action =
'create2';
4616 if ( $action ===
'create' || $action ===
'autocreate' ) {
4623 $logEntry->setPerformer( $performer );
4625 $logEntry->setComment( $reason );
4626 $logEntry->setParameters(
array(
4627 '4::userid' => $this->
getId(),
4629 $logid = $logEntry->insert();
4631 if ( $action !==
'autocreate' ) {
4632 $logEntry->publish( $logid );
4661 if ( $this->mOptionsLoaded ) {
4667 if ( !$this->
getId() ) {
4673 $this->mOptions[
'variant'] = $variant;
4674 $this->mOptions[
'language'] = $variant;
4675 $this->mOptionsLoaded =
true;
4680 if ( !is_null( $this->mOptionOverrides ) ) {
4681 wfDebug(
"User: loading options for user " . $this->
getId() .
" from override cache.\n" );
4682 foreach ( $this->mOptionOverrides
as $key =>
$value ) {
4683 $this->mOptions[$key] =
$value;
4686 if ( !is_array( $data ) ) {
4687 wfDebug(
"User: loading options for user " . $this->
getId() .
" from database.\n" );
4693 array(
'up_property',
'up_value' ),
4698 $this->mOptionOverrides =
array();
4700 foreach (
$res as $row ) {
4701 $data[$row->up_property] = $row->up_value;
4710 $this->mOptionsLoaded =
true;
4726 if ( !
wfRunHooks(
'UserSaveOptions',
array( $this, &$saveOptions ) ) ) {
4730 $userId = $this->
getId();
4731 $insert_rows =
array();
4732 foreach ( $saveOptions
as $key =>
$value ) {
4735 if ( ( is_null( $defaultOption ) &&
4739 $insert_rows[] =
array(
4740 'up_user' => $userId,
4741 'up_property' => $key,
4749 $res = $dbw->select(
'user_properties',
4750 array(
'up_property' ),
array(
'up_user' => $userId ), __METHOD__ );
4751 $priorKeys =
array();
4752 foreach (
$res as $row ) {
4753 $priorKeys[] = $row->up_property;
4755 if ( count( $priorKeys ) ) {
4763 $dbw->delete(
'user_properties',
4764 array(
'up_user' => $userId,
'up_property' => $priorKeys ), __METHOD__ );
4767 $dbw->insert(
'user_properties', $insert_rows, __METHOD__,
array(
'IGNORE' ) );
4794 global $wgMinimalPasswordLength;
4796 if ( $wgMinimalPasswordLength == 0 ) {
4800 # Note that the pattern requirement will always be satisfied if the
4801 # input is empty, so we need required in all cases.
4803 # @todo FIXME: Bug 23769: This needs to not claim the password is required
4804 # if e-mail confirmation is being used. Since HTML5 input validation
4805 # is b0rked anyway in some browsers, just return nothing. When it's
4806 # re-enabled, fix this code to not output required for e-mail
4808 #$ret = array( 'required' );
4811 # We can't actually do this right now, because Opera 9.6 will print out
4812 # the entered password visibly in its error message! When other
4813 # browsers add support for this attribute, or Opera fixes its support,
4814 # we can add support with a version check to avoid doing this on Opera
4815 # versions where it will be a problem. Reported to Opera as
4816 # DSK-262266, but they don't have a public bug tracker for us to follow.
4840 'user_newpass_time',
4844 'user_email_authenticated',
4846 'user_email_token_expires',
4847 'user_password_expires',
4848 'user_registration',
4863 $groups = array_map(
4864 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