mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-13 17:57:21 +00:00
7b47e5d09d
Add a title and a link to Special:Notifications to the notifications overlay. Also add a message to Special:Notifications and the overlay if a user has no notifications Change-Id: I28407d3ea82039b160170f51ab987418e14be2af
63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
class SpecialNotifications extends SpecialPage {
|
|
public function __construct() {
|
|
parent::__construct('Notifications');
|
|
}
|
|
|
|
public function execute($par) {
|
|
global $wgUser, $wgOut, $wgLang;
|
|
|
|
$this->setHeaders();
|
|
|
|
$wgOut->setPageTitle( wfMsg( 'echo-specialpage' ) );
|
|
$wgOut->addModules( array('ext.echo.special') );
|
|
|
|
if ( $wgUser->isAnon() ) {
|
|
$wgOut->addWikiMsg( 'echo-anon' );
|
|
return;
|
|
}
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
$res = $dbr->select(
|
|
array( 'echo_notification', 'echo_event' ),
|
|
'*',
|
|
array(
|
|
'notification_user' => $wgUser->getID(),
|
|
),
|
|
__METHOD__,
|
|
array(
|
|
'ORDER BY' => 'notification_timestamp DESC',
|
|
'LIMIT' => 50,
|
|
),
|
|
array(
|
|
'echo_event' => array('left join', 'notification_event=event_id'),
|
|
)
|
|
);
|
|
|
|
if ( ! $res->numRows() ) {
|
|
$wgOut->addWikiMsg('echo-none');
|
|
return;
|
|
}
|
|
|
|
$html = '';
|
|
foreach( $res as $row ) {
|
|
$event = EchoEvent::newFromRow( $row );
|
|
$class = 'mw-echo-notification';
|
|
|
|
$ts = $wgLang->timeanddate( $event->getTimestamp() );
|
|
$formatted = "<span class='mw-echo-timestamp'>$ts</span> ";
|
|
$formatted .= EchoNotificationController::formatNotification( $event, $wgUser, 'html' );
|
|
|
|
if ( $row->notification_read_timestamp === null ) {
|
|
$class .= ' mw-echo-unread';
|
|
}
|
|
|
|
$html .= "\t<li class='$class'>$formatted</li>\n";
|
|
}
|
|
|
|
$html = "<ul>\n$html\n</ul>\n";
|
|
|
|
$wgOut->addHTML( $html );
|
|
}
|
|
} |