mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
8da85396d6
This version is very rough. For an example set of Minimum Releasable Functionality, this version will notify users on changes to their watchlists or to their user talk pages. However, it is still missing a conversion script to turn watchlists into echo subscriptions. For now, notifications can be viewed through the new special page Special:Notifications, or through the API module provided. Change-Id: I5867226e3e6195fbed81f4b5803e2310f057ffc4
53 lines
1.2 KiB
PHP
53 lines
1.2 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'),
|
|
)
|
|
);
|
|
|
|
$html = '';
|
|
foreach( $res as $row ) {
|
|
$event = EchoEvent::loadFromRow( $row );
|
|
|
|
$ts = $wgLang->timeanddate( $event->getTimestamp() );
|
|
$formatted = "<span class='mw-echo-timestamp'>$ts</span> ";
|
|
$formatted .= EchoNotificationController::formatNotification( $event, $wgUser, 'html' );
|
|
|
|
$html .= "\t<li class='mw-echo-notification'>$formatted</li>\n";
|
|
}
|
|
|
|
$html = "<ul>\n$html\n</ul>\n";
|
|
|
|
$wgOut->addHTML( $html );
|
|
}
|
|
} |