'reupload',
'reupload-shared',
'rollback',
- 'selenium',
'sendemail',
'siteadmin',
'suppressionlog',
*/
var $mNewtalk, $mDatePreference, $mBlockedby, $mHash, $mRights,
$mBlockreason, $mEffectiveGroups, $mImplicitGroups, $mFormerGroups, $mBlockedGlobally,
- $mLocked, $mHideName, $mOptions;
+ $mLocked, $mHideName, $mOptions, $mDisplayName;
/**
* @var WebRequest
/**
* Get the username corresponding to a given user ID
* @param $id Int User ID
- * @return String The corresponding username
+ * @return String|false The corresponding username
*/
- static function whoIs( $id ) {
+ public static function whoIs( $id ) {
$dbr = wfGetDB( DB_SLAVE );
return $dbr->selectField( 'user', 'user_name', array( 'user_id' => $id ), __METHOD__ );
}
* Get the real name of a user given their user ID
*
* @param $id Int User ID
- * @return String The corresponding user's real name
+ * @return String|false The corresponding user's real name
*/
public static function whoIsReal( $id ) {
$dbr = wfGetDB( DB_SLAVE );
$this->mEffectiveGroups = null;
$this->mImplicitGroups = null;
$this->mOptions = null;
+ $this->mDisplayName = null;
if ( $reloadFrom ) {
$this->mLoadedItems = array();
}
$defOpt['skin'] = $wgDefaultSkin;
+ // FIXME: Ideally we'd cache the results of this function so the hook is only run once,
+ // but that breaks the parser tests because they rely on being able to change $wgContLang
+ // mid-request and see that change reflected in the return value of this function.
+ // Which is insane and would never happen during normal MW operation, but is also not
+ // likely to get fixed unless and until we context-ify everything.
+ // See also https://www.mediawiki.org/wiki/Special:Code/MediaWiki/101488#c25275
wfRunHooks( 'UserGetDefaultOptions', array( &$defOpt ) );
return $defOpt;
$this->mRealName = $str;
}
+ /**
+ * Return the name of this user we should used to display in the user interface
+ * @return String The user's display name
+ */
+ public function getDisplayName() {
+ global $wgRealNameInInterface;
+ if ( is_null( $this->mDisplayName ) ) {
+ $displayName = null;
+
+ // Allow hooks to set a display name
+ wfRunHooks( 'UserDisplayName', array( $this, &$displayName ) );
+
+ if ( is_null( $displayName ) && $wgRealNameInInterface && $this->getRealName() ) {
+ // If $wgRealNameInInterface is true use the real name as the display name if it's set
+ $displayName = $this->getRealName();
+ }
+
+ if ( is_null( $displayName ) ) {
+ $displayName = $this->getName();
+ }
+
+ $this->mDisplayName = $displayName;
+ }
+ return $this->mDisplayName;
+ }
+
/**
* Get the user's current setting for a given option.
*
* @return Boolean: Whether the token matches
*/
public function matchEditToken( $val, $salt = '', $request = null ) {
- $sessionToken = $this->editToken( $salt, $request );
+ $sessionToken = $this->getEditToken( $salt, $request );
if ( $val != $sessionToken ) {
wfDebug( "User::matchEditToken: broken session data\n" );
}
* @return Boolean: Whether the token matches
*/
public function matchEditTokenNoSuffix( $val, $salt = '', $request = null ) {
- $sessionToken = $this->editToken( $salt, $request );
+ $sessionToken = $this->getEditToken( $salt, $request );
return substr( $sessionToken, 0, 32 ) == substr( $val, 0, 32 );
}
}
}
- $dbw->begin();
$dbw->delete( 'user_properties', array( 'up_user' => $this->getId() ), __METHOD__ );
$dbw->insert( 'user_properties', $insert_rows, __METHOD__ );
- $dbw->commit();
}
/**