X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FUser.php;h=fa20ebdaa6c6d2522fbf3c5786b11a97a99dc09e;hb=f45e512f92ab0f5dcd40e52e6b1cfb94311ef514;hp=5a117bdde11859fe442433a40014d02260d9d78e;hpb=29f51fdbdb3ae23aa147932d76394118664557a3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/User.php b/includes/User.php index 5a117bdde1..fa20ebdaa6 100644 --- a/includes/User.php +++ b/includes/User.php @@ -175,6 +175,7 @@ class User implements IDBAccessObject { 'userrights-interwiki', 'viewmyprivateinfo', 'viewmywatchlist', + 'viewsuppressed', 'writeapi', ); @@ -356,7 +357,7 @@ class User implements IDBAccessObject { /** * Load user table data, given mId has already been set. - * @return bool false if the ID does not exist, true otherwise + * @return bool False if the ID does not exist, true otherwise */ public function loadFromId() { global $wgMemc; @@ -368,7 +369,7 @@ class User implements IDBAccessObject { // Try cache $key = wfMemcKey( 'user', 'id', $this->mId ); $data = $wgMemc->get( $key ); - if ( !is_array( $data ) || $data['mVersion'] < MW_USER_VERSION ) { + if ( !is_array( $data ) || $data['mVersion'] != MW_USER_VERSION ) { // Object is expired, load from DB $data = false; } @@ -752,7 +753,7 @@ class User implements IDBAccessObject { * Given unvalidated password input, return error message on failure. * * @param string $password Desired password - * @return bool|string|array true on success, string or array of error message on failure + * @return bool|string|array True on success, string or array of error message on failure */ public function getPasswordValidity( $password ) { $result = $this->checkPasswordValidity( $password ); @@ -892,38 +893,6 @@ class User implements IDBAccessObject { return $this->mPasswordExpires; } - /** - * Does a string look like an e-mail address? - * - * This validates an email address using an HTML5 specification found at: - * http://www.whatwg.org/html/states-of-the-type-attribute.html#valid-e-mail-address - * Which as of 2011-01-24 says: - * - * A valid e-mail address is a string that matches the ABNF production - * 1*( atext / "." ) "@" ldh-str *( "." ldh-str ) where atext is defined - * in RFC 5322 section 3.2.3, and ldh-str is defined in RFC 1034 section - * 3.5. - * - * This function is an implementation of the specification as requested in - * bug 22449. - * - * Client-side forms will use the same standard validation rules via JS or - * HTML 5 validation; additional restrictions can be enforced server-side - * by extensions via the 'isValidEmailAddr' hook. - * - * Note that this validation doesn't 100% match RFC 2822, but is believed - * to be liberal enough for wide use. Some invalid addresses will still - * pass validation here. - * - * @param string $addr E-mail address - * @return bool - * @deprecated since 1.18 call Sanitizer::isValidEmail() directly - */ - public static function isValidEmailAddr( $addr ) { - wfDeprecated( __METHOD__, '1.18' ); - return Sanitizer::validateEmail( $addr ); - } - /** * Given unvalidated user input, return a canonical username, or false if * the username is invalid. @@ -1170,7 +1139,7 @@ class User implements IDBAccessObject { * Load user and user_group data from the database. * $this->mId must be set, this is how the user is identified. * - * @param integer $flags Supports User::READ_LOCKING + * @param int $flags Supports User::READ_LOCKING * @return bool True if the user exists, false if the user is anonymous */ public function loadFromDatabase( $flags = 0 ) { @@ -1416,7 +1385,7 @@ class User implements IDBAccessObject { foreach ( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) { $defOpt['searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] ); } - $defOpt['skin'] = $wgDefaultSkin; + $defOpt['skin'] = Skin::normalizeKey( $wgDefaultSkin ); wfRunHooks( 'UserGetDefaultOptions', array( &$defOpt ) ); @@ -1537,10 +1506,9 @@ class User implements IDBAccessObject { * @return bool True if blacklisted. */ public function isDnsBlacklisted( $ip, $checkWhitelist = false ) { - global $wgEnableSorbs, $wgEnableDnsBlacklist, - $wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist; + global $wgEnableDnsBlacklist, $wgDnsBlacklistUrls, $wgProxyWhitelist; - if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs ) { + if ( !$wgEnableDnsBlacklist ) { return false; } @@ -1548,8 +1516,7 @@ class User implements IDBAccessObject { return false; } - $urls = array_merge( $wgDnsBlacklistUrls, (array)$wgSorbsUrl ); - return $this->inDnsBlacklist( $ip, $urls ); + return $this->inDnsBlacklist( $ip, $wgDnsBlacklistUrls ); } /** @@ -2067,7 +2034,7 @@ class User implements IDBAccessObject { * @see getNewtalk() * @param string $field 'user_ip' for anonymous users, 'user_id' otherwise * @param string|int $id User's IP address for anonymous users, User ID otherwise - * @param bool $fromMaster true to fetch from the master, false for a slave + * @param bool $fromMaster True to fetch from the master, false for a slave * @return bool True if the user has new messages */ protected function checkNewtalk( $field, $id, $fromMaster = false ) { @@ -2209,7 +2176,7 @@ class User implements IDBAccessObject { $userid = $this->mId; $touched = $this->mTouched; $method = __METHOD__; - $dbw->onTransactionIdle( function() use ( $dbw, $userid, $touched, $method ) { + $dbw->onTransactionIdle( function () use ( $dbw, $userid, $touched, $method ) { // Prevent contention slams by checking user_touched first $encTouched = $dbw->addQuotes( $dbw->timestamp( $touched ) ); $needsPurge = $dbw->selectField( 'user', '1', @@ -2257,7 +2224,7 @@ class User implements IDBAccessObject { * a new password is set, for instance via e-mail. * * @param string $str New password to set - * @throws PasswordError on failure + * @throws PasswordError On failure * * @return bool */ @@ -2657,7 +2624,7 @@ class User implements IDBAccessObject { * @param IContextSource $context * @param array $options Assoc. array with options keys to check as keys. * Defaults to $this->mOptions. - * @return array the key => kind mapping data + * @return array The key => kind mapping data */ public function getOptionKinds( IContextSource $context, $options = null ) { $this->loadOptions(); @@ -2778,6 +2745,8 @@ class User implements IDBAccessObject { } } + wfRunHooks( 'UserResetAllOptions', array( $this, &$newOptions, $this->mOptions, $resetKinds ) ); + $this->mOptions = $newOptions; $this->mOptionsLoaded = true; } @@ -2939,7 +2908,7 @@ class User implements IDBAccessObject { /** * Get the user's edit count. - * @return int|null null for anonymous users + * @return int|null Null for anonymous users */ public function getEditCount() { if ( !$this->getId() ) { @@ -3748,8 +3717,8 @@ class User implements IDBAccessObject { /** * Check to see if the given clear-text password is one of the accepted passwords - * @param string $password user password. - * @return bool True if the given password is correct, otherwise False. + * @param string $password User password + * @return bool True if the given password is correct, otherwise False */ public function checkPassword( $password ) { global $wgAuth, $wgLegacyEncoding; @@ -3810,7 +3779,7 @@ class User implements IDBAccessObject { * Alias for getEditToken. * @deprecated since 1.19, use getEditToken instead. * - * @param string|array $salt of Strings Optional function-specific data for hashing + * @param string|array $salt Array of Strings Optional function-specific data for hashing * @param WebRequest|null $request WebRequest object to use or null to use $wgRequest * @return string The new edit token */ @@ -3827,7 +3796,7 @@ class User implements IDBAccessObject { * * @since 1.19 * - * @param string|array $salt of Strings Optional function-specific data for hashing + * @param string|array $salt Array of Strings Optional function-specific data for hashing * @param WebRequest|null $request WebRequest object to use or null to use $wgRequest * @return string The new edit token */ @@ -3888,7 +3857,7 @@ class User implements IDBAccessObject { * * @param string $val Input value to compare * @param string $salt Optional function-specific data for hashing - * @param WebRequest|null $request object to use or null to use $wgRequest + * @param WebRequest|null $request Object to use or null to use $wgRequest * @return bool Whether the token matches */ public function matchEditTokenNoSuffix( $val, $salt = '', $request = null ) { @@ -4394,7 +4363,7 @@ class User implements IDBAccessObject { * Returns an array of the groups that a particular group can add/remove. * * @param string $group The group to check for whether it can add/remove - * @return array array( 'add' => array( addablegroups ), + * @return array Array( 'add' => array( addablegroups ), * 'remove' => array( removablegroups ), * 'add-self' => array( addablegroups to self), * 'remove-self' => array( removable groups from self) ) @@ -4464,7 +4433,7 @@ class User implements IDBAccessObject { /** * Returns an array of groups that this user can add and remove - * @return array array( 'add' => array( addablegroups ), + * @return array Array( 'add' => array( addablegroups ), * 'remove' => array( removablegroups ), * 'add-self' => array( addablegroups to self), * 'remove-self' => array( removable groups from self) )