Add constant Linker::TOOL_LINKS_EMAIL to allow adding a "send e-mail" link from Linker::

Add "send e-mail" link in user tools for developer details (Special:Code/Project/author/authorname) in CodeReview.
This commit is contained in:
Siebrand Mazeland 2011-09-07 12:12:24 +00:00
parent e79af7c35f
commit 0c12790089
4 changed files with 22 additions and 1 deletions

View file

@ -12,6 +12,7 @@ class Linker {
* Flags for userToolLinks()
*/
const TOOL_LINKS_NOBLOCK = 1;
const TOOL_LINKS_EMAIL = 2;
/**
* Get the appropriate HTML attributes to add to the "a" element of an ex-
@ -932,7 +933,7 @@ class Linker {
* @param $userText String: user name or IP address
* @param $redContribsWhenNoEdits Boolean: should the contributions link be
* red if the user has no edits?
* @param $flags Integer: customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK)
* @param $flags Integer: customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK and Linker::TOOL_LINKS_EMAIL)
* @param $edits Integer: user edit count (optional, for performance)
* @return String: HTML fragment
*/
@ -942,6 +943,7 @@ class Linker {
global $wgUser, $wgDisableAnonTalk, $wgLang;
$talkable = !( $wgDisableAnonTalk && 0 == $userId );
$blockable = !$flags & self::TOOL_LINKS_NOBLOCK;
$addEmailLink = $flags & self::TOOL_LINKS_EMAIL;
$items = array();
if ( $talkable ) {
@ -964,6 +966,10 @@ class Linker {
$items[] = self::blockLink( $userId, $userText );
}
if ( $addEmailLink && $wgUser->canSendEmail() ) {
$items[] = self::emailLink( $userId, $userText );
}
if ( $items ) {
return ' <span class="mw-usertoollinks">(' . $wgLang->pipeList( $items ) . ')</span>';
} else {
@ -1006,6 +1012,18 @@ class Linker {
return $blockLink;
}
/**
* @param $userId Integer: userid
* @param $userText String: user name in database.
* @return String: HTML fragment with e-mail user link
* @private
*/
static function emailLink( $userId, $userText ) {
$emailPage = SpecialPage::getTitleFor( 'EmailUser', $userText );
$emailLink = self::link( $emailPage, wfMsgHtml( 'emaillink' ) );
return $emailLink;
}
/**
* Generate a user link if the current user is allowed to view it
* @param $rev Revision object.

View file

@ -3111,6 +3111,7 @@ See [[Special:BlockList|IP block list]] to review blocks.',
'unblocklink' => 'unblock',
'change-blocklink' => 'change block',
'contribslink' => 'contribs',
'emaillink' => 'send e-mail',
'autoblocker' => 'Autoblocked because your IP address has been recently used by "[[User:$1|$1]]".
The reason given for $1\'s block is: "$2"',
'blocklogpage' => 'Block log',

View file

@ -2794,6 +2794,7 @@ Usage:
'blocklink' => "Display name for a link that, when selected, leads to a form where a user can be blocked. Used in page history and recent changes pages. Example: \"''UserName (Talk | contribs | '''block''')''\".",
'change-blocklink' => 'Used to name the link on Special:Log',
'contribslink' => 'Short for "contributions". Used as display name for a link to user contributions on history pages, [[Special:RecentChanges]], [[Special:Watchlist]], etc.',
'emaillink' => 'Used as display name for a link to send an e-mail to a user in the user tool links. Example: "(Talk | contribs | block | send e-mail)".',
'blocklogpage' => "The page name of [[Special:Log/block]]. Also appears in the drop down menu of [[Special:Log]] pages and in the action links of Special:Contributions/''Username'' pages (e.g. \"For Somebody (talk | block log | logs)\").
{{Identical|Block log}}",

View file

@ -2128,6 +2128,7 @@ $wgMessageStructure = array(
'unblocklink',
'change-blocklink',
'contribslink',
'emaillink',
'autoblocker',
'blocklogpage',
'blocklog-showlog',