mediawiki-extensions-LoginN.../LoginNotifyPresentationModel.php
niharika29 b0d0086a4c Add a primary link to the notification
Bug: T163856
Change-Id: Ie8d51b4f0aecb857e8ab95ed15c4d776da7e495f
2017-04-27 22:00:48 +00:00

67 lines
1.6 KiB
PHP

<?php
class LoginNotifyPresentationModel extends EchoEventPresentationModel {
/**
* Show an user avatar.
*
* @return String Name of icon
*/
public function getIconType() {
return 'LoginNotify-user-avatar';
}
/**
* Link to help page on mediawiki
*
* @return array url to link to
*/
public function getPrimaryLink() {
return [
'url' => 'https://mediawiki.org/wiki/Help:Login_notifications'
];
}
/**
* Include the number of attempts in the message if needed
*
* @return Message
*/
public function getHeaderMessage() {
switch ( $this->event->getType() ) {
case 'login-fail-known':
$msg = $this->msg( 'notification-known-header-login-fail' );
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
break;
case 'login-fail-new':
if ( $this->isBundled() ) {
$msg = $this->msg( 'notification-new-bundled-header-login-fail' );
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
} else {
$msg = $this->msg( 'notification-new-unbundled-header-login-fail' );
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
}
break;
default:
$msg = $this->msg( 'notification-header-login-success' );
}
return $msg;
}
/**
* Get links to be used in the notification
*
* @return array Link to Special:ChangePassword
*/
public function getSecondaryLinks() {
$changePasswordLink = [
'url' => SpecialPage::getTitleFor( 'ChangePassword' )->getFullURL(),
'label' => $this->msg( 'changepassword' )->text(),
'description' => '',
'icon' => 'lock',
'prioritized' => true,
];
return [ $changePasswordLink ];
}
}