mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
dff7e8072b
Bug: T126277 Depends-On: Ib9bb28a7a77602e3e729fd0bf13ab8259e15b006 Change-Id: I4941c4ba16ee95798767d858792090609b47b4e4
65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Formatter for 'user-rights' notifications
|
|
*/
|
|
class EchoUserRightsPresentationModel extends EchoEventPresentationModel {
|
|
|
|
public function getIconType() {
|
|
return 'user-rights';
|
|
}
|
|
|
|
public function getHeaderMessage() {
|
|
list( $formattedName, $genderName ) = $this->getAgentForOutput();
|
|
$add = $this->getLocalizedGroupNames( array_values( $this->event->getExtraParam( 'add', array() ) ) );
|
|
$remove = $this->getLocalizedGroupNames( array_values( $this->event->getExtraParam( 'remove', array() ) ) );
|
|
if ( $add && !$remove ) {
|
|
$msg = $this->msg( 'notification-header-user-rights-add-only' );
|
|
$msg->params( $genderName );
|
|
$msg->params( $this->language->commaList( $add ) );
|
|
$msg->params( count( $add ) );
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
return $msg;
|
|
} elseif ( !$add && $remove ) {
|
|
$msg = $this->msg( 'notification-header-user-rights-remove-only' );
|
|
$msg->params( $genderName );
|
|
$msg->params( $this->language->commaList( $remove ) );
|
|
$msg->params( count( $remove ) );
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
return $msg;
|
|
} else {
|
|
$msg = $this->msg( 'notification-header-user-rights-add-and-remove' );
|
|
$msg->params( $genderName );
|
|
$msg->params( $this->language->commaList( $add ) );
|
|
$msg->params( count( $add ) );
|
|
$msg->params( $this->language->commaList( $remove ) );
|
|
$msg->params( count( $remove ) );
|
|
$msg->params( $this->getViewingUserForGender() );
|
|
return $msg;
|
|
}
|
|
}
|
|
|
|
public function getBodyMessage() {
|
|
$reason = $this->event->getExtraParam( 'reason' );
|
|
return $reason ? $this->msg( 'notification-body-user-rights' )->params( $reason ) : false;
|
|
}
|
|
|
|
private function getLocalizedGroupNames( $names ) {
|
|
return array_map( function( $name ) {
|
|
$msg = $this->msg( 'group-' . $name );
|
|
return $msg->isBlank() ? $name : $msg->text();
|
|
}, $names );
|
|
}
|
|
|
|
public function getPrimaryLink() {
|
|
return array(
|
|
'url' => SpecialPage::getTitleFor( 'Listgrouprights' )->getLocalURL(),
|
|
'label' => $this->msg( 'echo-learn-more' )->text()
|
|
);
|
|
}
|
|
|
|
public function getSecondaryLinks() {
|
|
return array( $this->getAgentLink() );
|
|
}
|
|
}
|