2012-04-27 15:14:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SpecialNotifications extends SpecialPage {
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct('Notifications');
|
|
|
|
}
|
|
|
|
|
2012-07-26 17:23:18 +00:00
|
|
|
public function execute( $par ) {
|
2012-04-27 15:14:24 +00:00
|
|
|
$this->setHeaders();
|
|
|
|
|
2012-07-26 17:23:18 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
$out->setPageTitle( $this->msg( 'echo-specialpage' )->text() );
|
|
|
|
$out->addModules( array( 'ext.echo.special' ) );
|
2012-04-27 15:14:24 +00:00
|
|
|
|
2012-05-17 00:29:37 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
if ( $user->isAnon() ) {
|
2012-07-26 17:23:18 +00:00
|
|
|
$out->addWikiMsg( 'echo-anon' );
|
2012-04-27 15:14:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
$res = $dbr->select(
|
|
|
|
array( 'echo_notification', 'echo_event' ),
|
|
|
|
'*',
|
|
|
|
array(
|
2012-05-17 00:29:37 +00:00
|
|
|
'notification_user' => $user->getID(),
|
2012-04-27 15:14:24 +00:00
|
|
|
),
|
|
|
|
__METHOD__,
|
|
|
|
array(
|
|
|
|
'ORDER BY' => 'notification_timestamp DESC',
|
|
|
|
'LIMIT' => 50,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'echo_event' => array('left join', 'notification_event=event_id'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2012-07-26 17:23:18 +00:00
|
|
|
if ( !$res->numRows() ) {
|
|
|
|
$out->addWikiMsg( 'echo-none' );
|
2012-06-08 05:55:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-27 15:14:24 +00:00
|
|
|
$html = '';
|
|
|
|
foreach( $res as $row ) {
|
2012-06-06 07:04:28 +00:00
|
|
|
$event = EchoEvent::newFromRow( $row );
|
2012-06-01 10:57:09 +00:00
|
|
|
$class = 'mw-echo-notification';
|
2012-04-27 15:14:24 +00:00
|
|
|
|
2012-05-17 00:29:37 +00:00
|
|
|
$formatted = EchoNotificationController::formatNotification( $event, $user(), 'html' );
|
2012-04-27 15:14:24 +00:00
|
|
|
|
2012-06-01 10:57:09 +00:00
|
|
|
if ( $row->notification_read_timestamp === null ) {
|
|
|
|
$class .= ' mw-echo-unread';
|
|
|
|
}
|
|
|
|
|
2012-08-01 17:53:20 +00:00
|
|
|
$eventType = htmlspecialchars( $event->getType() );
|
2012-07-31 00:29:49 +00:00
|
|
|
$html .= "\t<li class=\"$class\" data-notification-type=\"$eventType\">$formatted</li>\n";
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$html = "<ul>\n$html\n</ul>\n";
|
|
|
|
|
2012-07-26 17:23:18 +00:00
|
|
|
$out->addHTML( $html );
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
2012-07-26 17:23:18 +00:00
|
|
|
}
|