* 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-
* @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
*/
global $wgUser, $wgDisableAnonTalk, $wgLang;
$talkable = !( $wgDisableAnonTalk && 0 == $userId );
$blockable = !$flags & self::TOOL_LINKS_NOBLOCK;
+ $addEmailLink = $flags & self::TOOL_LINKS_EMAIL;
$items = array();
if ( $talkable ) {
$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 {
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.
'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',
'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}}",