mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-04 12:18:30 +00:00
56c4b95087
The workflow to format a notification is * Get EchoEvent, User, and Language * Get EchoEventFormatter implementation for notification type ** EchoEventFormatter returns structured data about each part of the notification (header, body, primary link, secondary link(s)) * Each output type will have a formatter class (e.g. EchoSpecialNotificationsFormatter, EchoPlainTextEmailFormatter) which takes a EchoEventPresentationModel and generates whatever it wants (HTML, plain-text email, etc). Included is an example conversion of the user-rights and mention formatters. The previous infrastructure will remain in place for backwards compatability until other extensions can be updated. Bug: T107823 Change-Id: I4397872a7ec062148dfcb066ddd8ab83f40486ac
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Formatter for 'user-rights' notifications
|
|
*/
|
|
class EchoUserRightsPresentationModel extends EchoEventPresentationModel {
|
|
|
|
public function getIconType() {
|
|
return 'site';
|
|
}
|
|
|
|
public function getHeaderMessage() {
|
|
$msg = parent::getHeaderMessage();
|
|
// @todo fix lego message
|
|
$msg->params( $this->getChangedGroups() );
|
|
|
|
return $msg;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
private function getChangedGroups() {
|
|
$list = array();
|
|
$extra = $this->event->getExtra();
|
|
foreach ( array( 'add', 'remove' ) as $action ) {
|
|
if ( isset( $extra[$action] ) && $extra[$action] ) {
|
|
|
|
// Get the localized group names, bug 55338
|
|
$groups = array();
|
|
foreach( $extra[$action] as $group ) {
|
|
$msg = $this->msg( 'group-' . $group );
|
|
$groups[] = $msg->isBlank() ? $group : $msg->text();
|
|
}
|
|
|
|
// Messages that can be used here:
|
|
// * notification-user-rights-add
|
|
// * notification-user-rights-remove
|
|
$list[] = $this->msg( 'notification-user-rights-' . $action )
|
|
->params( $this->language->commaList( $groups ), count( $groups ) )
|
|
->text();
|
|
}
|
|
}
|
|
|
|
return $this->language->semicolonList( $list );
|
|
}
|
|
|
|
public function getPrimaryLink() {
|
|
return array(
|
|
SpecialPage::getTitleFor( 'Listgrouprights' )->getLocalURL(),
|
|
$this->msg( 'echo-learn-more' )->text()
|
|
);
|
|
}
|
|
}
|