Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -2029,6 +2029,10 @@ |
2030 | 2030 | hashing method |
2031 | 2031 | &$hash: If the hook returns false, this String will be used as the hash |
2032 | 2032 | |
| 2033 | +'UserDisplayName': Called in User::getDisplayName() |
| 2034 | +$user: The user object to fetch the display name for |
| 2035 | +&$displayName: The display name. Will be null. Set to a name to override default name. |
| 2036 | + |
2033 | 2037 | 'UserEffectiveGroups': Called in User::getEffectiveGroups() |
2034 | 2038 | $user: User to get groups for |
2035 | 2039 | &$groups: Current effective groups |
Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -76,6 +76,8 @@ |
77 | 77 | * The default user signature now contains a talk link in addition to the user link. |
78 | 78 | * (bug 25306) Add link of old page title to MediaWiki:Delete_and_move_reason |
79 | 79 | * Added hook BitmapHandlerCheckImageArea |
| 80 | +* (experimental) $wgRealNameInInterface can be enabled to display a user's |
| 81 | + real name in some parts of the interface instead of a username. |
80 | 82 | |
81 | 83 | === Bug fixes in 1.19 === |
82 | 84 | * $wgUploadNavigationUrl should be used for file redlinks if |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -175,6 +175,7 @@ |
176 | 176 | $this->thisquery = wfArrayToCGI( $query ); |
177 | 177 | $this->loggedin = $user->isLoggedIn(); |
178 | 178 | $this->username = $user->getName(); |
| 179 | + $this->userdisplayname = $user->getDisplayName(); |
179 | 180 | |
180 | 181 | if ( $user->isLoggedIn() || $this->showIPinHeader() ) { |
181 | 182 | $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage ); |
— | — | @@ -305,6 +306,7 @@ |
306 | 307 | $tpl->set( 'capitalizeallnouns', $this->getLang()->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' ); |
307 | 308 | $tpl->set( 'showjumplinks', $user->getOption( 'showjumplinks' ) ); |
308 | 309 | $tpl->set( 'username', $user->isAnon() ? null : $this->username ); |
| 310 | + $tpl->set( 'userdisplayname', $user->isAnon() ? null : $this->userdisplayname ); |
309 | 311 | $tpl->setRef( 'userpage', $this->userpage ); |
310 | 312 | $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] ); |
311 | 313 | $tpl->set( 'userlang', $userlang ); |
— | — | @@ -558,7 +560,7 @@ |
559 | 561 | $returnto = wfArrayToCGI( $a ); |
560 | 562 | if( $this->loggedin ) { |
561 | 563 | $personal_urls['userpage'] = array( |
562 | | - 'text' => $this->username, |
| 564 | + 'text' => $this->userdisplayname, |
563 | 565 | 'href' => &$this->userpageUrlDetails['href'], |
564 | 566 | 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', |
565 | 567 | 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ) |
— | — | @@ -653,7 +655,7 @@ |
654 | 656 | if( $this->showIPinHeader() ) { |
655 | 657 | $href = &$this->userpageUrlDetails['href']; |
656 | 658 | $personal_urls['anonuserpage'] = array( |
657 | | - 'text' => $this->username, |
| 659 | + 'text' => $this->userdisplayname, |
658 | 660 | 'href' => $href, |
659 | 661 | 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', |
660 | 662 | 'active' => ( $pageurl == $href ) |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2244,6 +2244,12 @@ |
2245 | 2245 | $wgShowIPinHeader = true; |
2246 | 2246 | |
2247 | 2247 | /** |
| 2248 | + * Use a user's real name inside the user interface for display instead of the username |
| 2249 | + * (experimental) |
| 2250 | + */ |
| 2251 | +$wgRealNameInInterface = true; |
| 2252 | + |
| 2253 | +/** |
2248 | 2254 | * Site notice shown at the top of each page |
2249 | 2255 | * |
2250 | 2256 | * MediaWiki:Sitenotice page, which will override this. You can also |
Index: trunk/phase3/includes/User.php |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | */ |
201 | 201 | var $mNewtalk, $mDatePreference, $mBlockedby, $mHash, $mRights, |
202 | 202 | $mBlockreason, $mEffectiveGroups, $mImplicitGroups, $mFormerGroups, $mBlockedGlobally, |
203 | | - $mLocked, $mHideName, $mOptions; |
| 203 | + $mLocked, $mHideName, $mOptions, $mDisplayName; |
204 | 204 | |
205 | 205 | /** |
206 | 206 | * @var WebRequest |
— | — | @@ -1191,6 +1191,7 @@ |
1192 | 1192 | $this->mEffectiveGroups = null; |
1193 | 1193 | $this->mImplicitGroups = null; |
1194 | 1194 | $this->mOptions = null; |
| 1195 | + $this->mDisplayName = null; |
1195 | 1196 | |
1196 | 1197 | if ( $reloadFrom ) { |
1197 | 1198 | $this->mLoadedItems = array(); |
— | — | @@ -2136,6 +2137,32 @@ |
2137 | 2138 | } |
2138 | 2139 | |
2139 | 2140 | /** |
| 2141 | + * Return the name of this user we should used to display in the user interface |
| 2142 | + * @return String The user's display name |
| 2143 | + */ |
| 2144 | + public function getDisplayName() { |
| 2145 | + global $wgRealNameInInterface; |
| 2146 | + if ( is_null( $this->mDisplayName ) ) { |
| 2147 | + $displayName = null; |
| 2148 | + |
| 2149 | + // Allow hooks to set a display name |
| 2150 | + wfRunHooks( 'UserDisplayName', array( $this, &$displayName ) ); |
| 2151 | + |
| 2152 | + if ( is_null( $displayName ) && $wgRealNameInInterface && $this->getRealName() ) { |
| 2153 | + // If $wgRealNameInInterface is true use the real name as the display name if it's set |
| 2154 | + $displayName = $this->getRealName(); |
| 2155 | + } |
| 2156 | + |
| 2157 | + if ( is_null( $displayName ) ) { |
| 2158 | + $displayName = $this->getName(); |
| 2159 | + } |
| 2160 | + |
| 2161 | + $this->mDisplayName = $displayName; |
| 2162 | + } |
| 2163 | + return $this->mDisplayName; |
| 2164 | + } |
| 2165 | + |
| 2166 | + /** |
2140 | 2167 | * Get the user's current setting for a given option. |
2141 | 2168 | * |
2142 | 2169 | * @param $oname String The option to check |