2013-03-13 00:49:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Formatter for 'user-rights' notifications
|
|
|
|
*/
|
|
|
|
class EchoUserRightsFormatter extends EchoBasicFormatter {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $event EchoEvent
|
|
|
|
* @param $param string
|
|
|
|
* @param $message Message
|
|
|
|
* @param $user User
|
|
|
|
*/
|
|
|
|
protected function processParam( $event, $param, $message, $user ) {
|
|
|
|
$extra = $event->getExtra();
|
|
|
|
switch ( $param ) {
|
|
|
|
// List of user rights that are granted or revoked
|
|
|
|
case 'user-rights-list':
|
2015-08-13 17:56:23 +00:00
|
|
|
$lang = $this->getLanguage();
|
2013-03-13 00:49:19 +00:00
|
|
|
|
|
|
|
$list = array();
|
|
|
|
|
|
|
|
foreach ( array( 'add', 'remove' ) as $action ) {
|
2013-05-14 22:22:52 +00:00
|
|
|
if ( isset( $extra[$action] ) && $extra[$action] ) {
|
2013-10-24 17:18:14 +00:00
|
|
|
|
|
|
|
// Get the localized group names, bug 55338
|
|
|
|
$groups = array();
|
2015-10-01 13:48:52 +00:00
|
|
|
foreach ( $extra[$action] as $group ) {
|
2013-10-24 17:18:14 +00:00
|
|
|
$msg = $this->getMessage( 'group-' . $group );
|
|
|
|
$groups[] = $msg->isBlank() ? $group : $msg->escaped();
|
|
|
|
}
|
|
|
|
|
2013-03-13 00:49:19 +00:00
|
|
|
// Messages that can be used here:
|
|
|
|
// * notification-user-rights-add
|
|
|
|
// * notification-user-rights-remove
|
2013-08-27 00:55:45 +00:00
|
|
|
$list[] = $this->getMessage( 'notification-user-rights-' . $action )
|
2015-08-13 17:56:23 +00:00
|
|
|
->params( $lang->commaList( $groups ), count( $groups ) )
|
2013-03-13 00:49:19 +00:00
|
|
|
->escaped();
|
|
|
|
}
|
|
|
|
}
|
2015-08-13 17:56:23 +00:00
|
|
|
$message->params( $lang->semicolonList( $list ) );
|
2013-06-12 23:18:26 +00:00
|
|
|
break;
|
2013-03-13 00:49:19 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
parent::processParam( $event, $param, $message, $user );
|
2013-06-12 23:18:26 +00:00
|
|
|
break;
|
2013-03-13 00:49:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-12 23:18:26 +00:00
|
|
|
/**
|
|
|
|
* Helper function for getLink()
|
|
|
|
*
|
|
|
|
* @param EchoEvent $event
|
|
|
|
* @param User $user The user receiving the notification
|
|
|
|
* @param String $destination The destination type for the link
|
|
|
|
* @return Array including target and query parameters
|
|
|
|
*/
|
|
|
|
protected function getLinkParams( $event, $user, $destination ) {
|
|
|
|
$target = null;
|
|
|
|
$query = array();
|
|
|
|
// Set up link parameters based on the destination (or pass to parent)
|
|
|
|
switch ( $destination ) {
|
|
|
|
case 'user-rights-list':
|
2013-07-09 22:36:54 +00:00
|
|
|
$target = SpecialPage::getTitleFor( 'Listgrouprights' );
|
2013-06-12 23:18:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return parent::getLinkParams( $event, $user, $destination );
|
|
|
|
}
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2013-06-12 23:18:26 +00:00
|
|
|
return array( $target, $query );
|
|
|
|
}
|
2013-03-13 00:49:19 +00:00
|
|
|
}
|
2015-08-19 20:22:45 +00:00
|
|
|
|