2016-03-28 08:26:48 +00:00
|
|
|
<?php
|
|
|
|
class LoginNotifyPresentationModel extends EchoEventPresentationModel {
|
|
|
|
|
|
|
|
/**
|
2017-03-17 20:26:31 +00:00
|
|
|
* Show an user avatar.
|
2016-03-28 08:26:48 +00:00
|
|
|
*
|
|
|
|
* @return String Name of icon
|
|
|
|
*/
|
|
|
|
public function getIconType() {
|
2017-03-17 20:26:31 +00:00
|
|
|
return 'LoginNotify-user-avatar';
|
2016-03-28 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Nothing really to link to
|
|
|
|
*
|
|
|
|
* @return boolean false to disable link
|
|
|
|
*/
|
|
|
|
public function getPrimaryLink() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include the number of attempts in the message
|
|
|
|
*
|
|
|
|
* @return Message
|
|
|
|
*/
|
|
|
|
public function getHeaderMessage() {
|
2017-04-07 21:48:57 +00:00
|
|
|
// Check if we got a bundled notification with a 'count' param
|
|
|
|
// 'count' param is set when we have a failed login attempt
|
2017-04-20 18:14:04 +00:00
|
|
|
$msg = '';
|
|
|
|
switch ( $this->event->getType() ) {
|
|
|
|
case 'login-fail-known':
|
|
|
|
if ( $this->event->getExtraParam( 'count', 0 ) > 0 ) {
|
|
|
|
$msg = $this->msg( 'notification-known-header-login-fail' );
|
|
|
|
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
|
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
$msg = $this->msg( 'notification-header-login-success' );
|
|
|
|
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'login-fail-new':
|
|
|
|
if ( $this->isBundled() && ( $this->event->getExtraParam( 'count', 0 ) > 0 ) ) {
|
|
|
|
$msg = $this->msg( 'notification-new-bundled-header-login-fail' );
|
|
|
|
$msg->params( $this->event->getExtraParam( 'count', 0 ) );
|
|
|
|
return $msg;
|
|
|
|
} elseif ( $this->event->getExtraParam( 'count', 0 ) > 0 ) {
|
|
|
|
$msg = $this->msg( 'notification-new-unbundled-header-login-fail' );
|
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
$msg = $this->msg( 'notification-header-login-success' );
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
break;
|
2017-04-07 21:48:57 +00:00
|
|
|
}
|
2017-04-20 18:14:04 +00:00
|
|
|
return $msg;
|
2016-03-28 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-17 20:26:31 +00:00
|
|
|
* Get links to be used in the notification
|
|
|
|
*
|
|
|
|
* @return array Link to Special:ChangePassword
|
2016-03-28 08:26:48 +00:00
|
|
|
*/
|
|
|
|
public function getSecondaryLinks() {
|
2017-03-17 20:26:31 +00:00
|
|
|
$changePasswordLink = [
|
|
|
|
'url' => SpecialPage::getTitleFor( 'ChangePassword' )->getFullURL(),
|
|
|
|
'label' => $this->msg( 'changepassword' )->text(),
|
|
|
|
'description' => '',
|
|
|
|
'icon' => 'lock',
|
|
|
|
'prioritized' => true,
|
|
|
|
];
|
|
|
|
|
|
|
|
return [ $changePasswordLink ];
|
2016-03-28 08:26:48 +00:00
|
|
|
}
|
|
|
|
}
|