2012-04-27 15:14:24 +00:00
|
|
|
<?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'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$html = '';
|
|
|
|
foreach( $res as $row ) {
|
|
|
|
$event = EchoEvent::loadFromRow( $row );
|
2012-06-01 10:57:09 +00:00
|
|
|
$class = 'mw-echo-notification';
|
2012-04-27 15:14:24 +00:00
|
|
|
|
|
|
|
$ts = $wgLang->timeanddate( $event->getTimestamp() );
|
|
|
|
$formatted = "<span class='mw-echo-timestamp'>$ts</span> ";
|
|
|
|
$formatted .= EchoNotificationController::formatNotification( $event, $wgUser, 'html' );
|
|
|
|
|
2012-06-01 10:57:09 +00:00
|
|
|
if ( $row->notification_read_timestamp === null ) {
|
|
|
|
$class .= ' mw-echo-unread';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= "\t<li class='$class'>$formatted</li>\n";
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$html = "<ul>\n$html\n</ul>\n";
|
|
|
|
|
|
|
|
$wgOut->addHTML( $html );
|
|
|
|
}
|
|
|
|
}
|