2012-04-27 15:14:24 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* MediaWiki Extension: Echo
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @author Andrew Garrett
|
|
|
|
*/
|
|
|
|
|
|
|
|
# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
|
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
echo <<<EOT
|
|
|
|
To install this extension, put the following line in LocalSettings.php:
|
|
|
|
require_once( "$IP/extensions/Echo/Echo.php" );
|
|
|
|
EOT;
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extension credits that will show up on Special:Version
|
|
|
|
$wgExtensionCredits['specialpage'][] = array(
|
|
|
|
'path' => __FILE__,
|
|
|
|
'name' => 'Echo',
|
2012-07-17 00:04:16 +00:00
|
|
|
'url' => 'http://www.mediawiki.org/wiki/Echo_(Notifications)',
|
2012-04-27 15:14:24 +00:00
|
|
|
'author' => array(
|
|
|
|
'Andrew Garrett',
|
|
|
|
),
|
|
|
|
'descriptionmsg' => 'echo-desc',
|
|
|
|
);
|
|
|
|
|
|
|
|
$dir = dirname( __FILE__ ) . '/';
|
|
|
|
$wgExtensionMessagesFiles['Echo'] = $dir . 'Echo.i18n.php';
|
2012-10-23 22:37:22 +00:00
|
|
|
$wgExtensionMessagesFiles['EchoAliases'] = $dir . 'Echo.alias.php';
|
2012-04-27 15:14:24 +00:00
|
|
|
|
|
|
|
$wgAutoloadClasses['EchoHooks'] = "$dir/Hooks.php";
|
|
|
|
$wgAutoloadClasses['EchoSubscription'] = "$dir/model/Subscription.php";
|
|
|
|
$wgAutoloadClasses['EchoEvent'] = "$dir/model/Event.php";
|
|
|
|
$wgAutoloadClasses['EchoNotification'] = "$dir/model/Notification.php";
|
|
|
|
|
|
|
|
// Formatters
|
|
|
|
$wgAutoloadClasses['EchoNotificationFormatter'] = "$dir/formatters/NotificationFormatter.php";
|
|
|
|
$wgAutoloadClasses['EchoBasicFormatter'] = "$dir/formatters/BasicFormatter.php";
|
|
|
|
$wgAutoloadClasses['EchoEditFormatter'] = "$dir/formatters/EditFormatter.php";
|
2012-07-27 22:16:19 +00:00
|
|
|
$wgAutoloadClasses['EchoCommentFormatter'] = "$dir/formatters/CommentFormatter.php";
|
2012-04-27 15:14:24 +00:00
|
|
|
|
|
|
|
// Internal stuff
|
|
|
|
$wgAutoloadClasses['EchoNotifier'] = "$dir/Notifier.php";
|
|
|
|
$wgAutoloadClasses['EchoNotificationController'] = "$dir/controller/NotificationController.php";
|
2012-07-27 22:16:19 +00:00
|
|
|
$wgAutoloadClasses['EchoDiscussionParser'] = "$dir/includes/DiscussionParser.php";
|
2012-04-27 15:14:24 +00:00
|
|
|
|
2012-06-06 07:04:28 +00:00
|
|
|
// Job queue
|
|
|
|
$wgAutoloadClasses['EchoNotificationJob'] = "$dir/jobs/NotificationJob.php";
|
|
|
|
$wgJobClasses['EchoNotificationJob'] = 'EchoNotificationJob';
|
|
|
|
|
2012-04-27 15:14:24 +00:00
|
|
|
// API
|
|
|
|
$wgAutoloadClasses['ApiEchoNotifications'] = "$dir/api/ApiEchoNotifications.php";
|
|
|
|
$wgAPIMetaModules['notifications'] = 'ApiEchoNotifications';
|
|
|
|
|
|
|
|
// Special page
|
|
|
|
$wgAutoloadClasses['SpecialNotifications'] = "$dir/special/SpecialNotifications.php";
|
|
|
|
$wgSpecialPages['Notifications'] = 'SpecialNotifications';
|
|
|
|
|
|
|
|
// Housekeeping hooks
|
|
|
|
$wgHooks['LoadExtensionSchemaUpdates'][] = 'EchoHooks::getSchemaUpdates';
|
|
|
|
$wgHooks['GetPreferences'][] = 'EchoHooks::getPreferences';
|
2012-06-01 10:57:09 +00:00
|
|
|
$wgHooks['PersonalUrls'][] = 'EchoHooks::onPersonalUrls';
|
|
|
|
$wgHooks['BeforePageDisplay'][] = 'EchoHooks::beforePageDisplay';
|
2012-07-31 21:18:16 +00:00
|
|
|
$wgHooks['MakeGlobalVariablesScript'][] = 'EchoHooks::makeGlobalVariablesScript';
|
2012-07-31 00:29:49 +00:00
|
|
|
$wgHooks['UnitTestsList'][] = 'EchoHooks::getUnitTests';
|
2012-06-01 10:57:09 +00:00
|
|
|
|
|
|
|
$echoResourceTemplate = array(
|
|
|
|
'localBasePath' => "$dir/modules",
|
|
|
|
'remoteExtPath' => 'Echo/modules',
|
|
|
|
'group' => 'ext.echo',
|
|
|
|
);
|
2012-04-27 15:14:24 +00:00
|
|
|
|
|
|
|
$wgResourceModules += array(
|
2012-06-01 10:57:09 +00:00
|
|
|
'ext.echo.base' => $echoResourceTemplate + array(
|
|
|
|
'styles' => 'base/ext.echo.base.css',
|
2012-07-31 21:18:16 +00:00
|
|
|
'scripts' => 'base/ext.echo.base.js',
|
2012-06-01 10:57:09 +00:00
|
|
|
),
|
|
|
|
'ext.echo.overlay' => $echoResourceTemplate + array(
|
2012-07-31 21:18:16 +00:00
|
|
|
'scripts' => array(
|
|
|
|
'overlay/ext.echo.overlay.js',
|
|
|
|
),
|
2012-06-01 10:57:09 +00:00
|
|
|
'styles' => 'overlay/ext.echo.overlay.css',
|
2012-07-31 21:18:16 +00:00
|
|
|
'dependencies' => array(
|
|
|
|
'ext.echo.base',
|
|
|
|
'mediawiki.api',
|
|
|
|
'mediawiki.jqueryMsg',
|
2012-07-30 21:38:25 +00:00
|
|
|
'jquery.badge',
|
2012-07-31 00:29:49 +00:00
|
|
|
'ext.echo.icons',
|
2012-07-31 21:18:16 +00:00
|
|
|
),
|
2012-06-08 05:55:01 +00:00
|
|
|
'messages' => array(
|
|
|
|
'echo-link-new',
|
2012-07-30 21:38:25 +00:00
|
|
|
'echo-link',
|
2012-06-08 05:55:01 +00:00
|
|
|
'echo-overlay-title',
|
|
|
|
'echo-overlay-link',
|
|
|
|
'echo-none',
|
|
|
|
),
|
2012-06-01 10:57:09 +00:00
|
|
|
),
|
|
|
|
'ext.echo.special' => $echoResourceTemplate + array(
|
2012-07-31 00:29:49 +00:00
|
|
|
'dependencies' => array(
|
|
|
|
'ext.echo.base',
|
|
|
|
'ext.echo.icons',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'ext.echo.icons' => $echoResourceTemplate + array(
|
|
|
|
'styles' => 'icons/icons.css',
|
2012-04-27 15:14:24 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$wgDefaultUserOptions['echo-notify-watchlist'] = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This Echo hook can be used to define users who are by default interested in
|
|
|
|
* certain events.
|
|
|
|
* For example, it can be used to say that users are by default interested in
|
|
|
|
* their own user talk page being edited. In fact, that is what it is used for
|
|
|
|
* internally.
|
|
|
|
*/
|
2012-10-22 20:40:58 +00:00
|
|
|
$wgHooks['EchoGetDefaultNotifiedUsers'][] = 'EchoHooks::getDefaultNotifiedUsers';
|
|
|
|
$wgHooks['EchoGetNotificationTypes'][] = 'EchoHooks::getNotificationTypes';
|
2012-04-27 15:14:24 +00:00
|
|
|
|
|
|
|
// Hook appropriate events
|
|
|
|
$wgHooks['WatchArticleComplete'][] = 'EchoHooks::onWatch';
|
|
|
|
$wgHooks['UnwatchArticleComplete'][] = 'EchoHooks::onUnwatch';
|
|
|
|
$wgHooks['ArticleSaveComplete'][] = 'EchoHooks::onArticleSaved';
|
2012-08-31 23:35:16 +00:00
|
|
|
$wgHooks['AddNewAccount'][] = 'EchoHooks::onAccountCreated';
|
2012-07-18 19:39:33 +00:00
|
|
|
$wgHooks['ArticleRollbackComplete'][] = 'EchoHooks::onRollbackComplete';
|
2012-04-27 15:14:24 +00:00
|
|
|
|
2012-07-17 22:19:32 +00:00
|
|
|
// Disable ordinary email notifications
|
|
|
|
$wgHooks['AbortEmailNotification'][] = 'EchoHooks::abortEmailNotification';
|
2012-07-31 20:44:43 +00:00
|
|
|
// Disable the yellow bar of death
|
|
|
|
$wgHooks['ArticleEditUpdateNewTalk'][] = 'EchoHooks::abortNewtalkNotification';
|
2012-07-17 22:19:32 +00:00
|
|
|
|
2012-04-27 15:14:24 +00:00
|
|
|
// Configuration
|
|
|
|
|
2012-08-02 19:50:46 +00:00
|
|
|
$wgEchoDisableStandardEmail = true;
|
|
|
|
|
2012-08-31 23:35:16 +00:00
|
|
|
$wgEchoDefaultNotificationTypes = array( // Welcome events do not use subscription, and will only trigger notify, not email.
|
2012-04-27 15:14:24 +00:00
|
|
|
'all' => array(
|
|
|
|
'notify' => true,
|
2012-05-17 15:36:18 +00:00
|
|
|
'email' => true,
|
2012-04-27 15:14:24 +00:00
|
|
|
),
|
2012-07-18 19:39:33 +00:00
|
|
|
'reverted' => array(
|
|
|
|
'notify' => true,
|
|
|
|
'email' => false,
|
|
|
|
)
|
2012-04-27 15:14:24 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$wgEchoNotifiers = array(
|
2012-08-30 16:04:39 +00:00
|
|
|
'notify' => array( 'EchoNotifier', 'notifyWithNotification' ),
|
|
|
|
'email' => array( 'EchoNotifier', 'notifyWithEmail' ),
|
2012-04-27 15:14:24 +00:00
|
|
|
);
|
|
|
|
|
2012-08-01 18:20:21 +00:00
|
|
|
$wgEchoEnabledEvents = array(
|
|
|
|
'edit-user-talk',
|
|
|
|
'add-comment',
|
|
|
|
'add-talkpage-topic',
|
2012-08-31 23:35:16 +00:00
|
|
|
'welcome',
|
2012-07-18 19:39:33 +00:00
|
|
|
'reverted',
|
2012-08-01 18:20:21 +00:00
|
|
|
);
|
|
|
|
|
2012-07-18 19:39:33 +00:00
|
|
|
// Definitions of the notifications built into Echo
|
2012-04-27 15:14:24 +00:00
|
|
|
$wgEchoNotificationFormatters = array(
|
|
|
|
'edit-user-talk' => array(
|
|
|
|
'type' => 'edit',
|
2012-07-31 00:29:49 +00:00
|
|
|
'title-message' => 'notification-edit-talk-page',
|
2012-07-18 19:39:33 +00:00
|
|
|
'title-params' => array( 'agent', 'difflink', 'user', 'summary' ),
|
2012-05-17 15:36:18 +00:00
|
|
|
'email-subject-message' => 'notification-edit-talk-page-email-subject',
|
2012-09-16 17:46:02 +00:00
|
|
|
'email-subject-params' => array( 'agent' ),
|
2012-05-17 15:36:18 +00:00
|
|
|
'email-body-message' => 'notification-edit-talk-page-email-body',
|
2012-07-18 19:39:33 +00:00
|
|
|
'email-body-params' => array( 'agent', 'difflink', 'user', 'summary' ),
|
2012-08-01 18:35:30 +00:00
|
|
|
'icon' => 'chat',
|
2012-04-27 15:14:24 +00:00
|
|
|
),
|
|
|
|
'edit' => array(
|
|
|
|
'type' => 'edit',
|
2012-07-31 00:29:49 +00:00
|
|
|
'title-message' => 'notification-edit',
|
2012-07-18 19:39:33 +00:00
|
|
|
'title-params' => array( 'agent', 'title', 'difflink', 'user', 'summary' ),
|
2012-05-17 15:36:18 +00:00
|
|
|
'email-subject-message' => 'notification-edit-email-subject',
|
2012-09-16 17:46:02 +00:00
|
|
|
'email-subject-params' => array( 'agent', 'title' ),
|
2012-05-17 15:36:18 +00:00
|
|
|
'email-body-message' => 'notification-edit-email-body',
|
2012-07-18 19:39:33 +00:00
|
|
|
'email-body-params' => array( 'agent', 'title', 'difflink', 'user', 'summary' ),
|
2012-08-01 18:35:30 +00:00
|
|
|
'icon' => 'w',
|
2012-04-27 15:14:24 +00:00
|
|
|
),
|
2012-07-27 22:16:19 +00:00
|
|
|
'add-comment' => array(
|
|
|
|
'type' => 'comment',
|
2012-07-31 00:29:49 +00:00
|
|
|
'title-message' => 'notification-add-comment',
|
|
|
|
'title-message-yours' => 'notification-add-comment-yours',
|
2012-08-01 21:23:37 +00:00
|
|
|
'title-params' => array( 'agent', 'subject', 'title', 'content-page' ),
|
2012-07-31 00:29:49 +00:00
|
|
|
'content-message' => 'notification-talkpage-content',
|
2012-08-30 16:04:39 +00:00
|
|
|
'content-params' => array( 'commentText' ),
|
2012-08-01 18:35:30 +00:00
|
|
|
'icon' => 'chat',
|
2012-07-27 22:16:19 +00:00
|
|
|
),
|
|
|
|
'add-talkpage-topic' => array(
|
|
|
|
'type' => 'comment',
|
2012-07-31 00:29:49 +00:00
|
|
|
'title-message' => 'notification-add-talkpage-topic',
|
|
|
|
'title-message-yours' => 'notification-add-talkpage-topic-yours',
|
2012-08-01 21:23:37 +00:00
|
|
|
'title-params' => array( 'agent', 'subject', 'title', 'content-page' ),
|
2012-07-31 00:29:49 +00:00
|
|
|
'content-message' => 'notification-talkpage-content',
|
2012-08-30 16:04:39 +00:00
|
|
|
'content-params' => array( 'commentText' ),
|
2012-08-01 18:35:30 +00:00
|
|
|
'icon' => 'chat',
|
2012-07-27 22:16:19 +00:00
|
|
|
),
|
2012-08-31 23:35:16 +00:00
|
|
|
'welcome' => array(
|
|
|
|
'type' => 'welcome',
|
|
|
|
'title-message' => 'notification-new-user',
|
|
|
|
'title-params' => array( 'agent' ),
|
|
|
|
'content-message' => 'notification-new-user-content',
|
|
|
|
'content-params' => array( 'agent' ),
|
|
|
|
'icon' => 'w',
|
2012-07-18 19:39:33 +00:00
|
|
|
),
|
|
|
|
'reverted' => array(
|
|
|
|
'type' => 'edit',
|
|
|
|
'title-message' => 'notification-reverted',
|
|
|
|
'title-params' => array( 'agent', 'title', 'difflink', 'summary', 'number' ),
|
|
|
|
'email-subject-message' => 'notification-reverted-email-subject',
|
|
|
|
'email-subject-params' => array( 'agent', 'title', 'summary' ),
|
|
|
|
'email-body-message' => 'notification-reverted-email-body',
|
|
|
|
'email-body-params' => array( 'agent', 'title', 'difflink', 'user', 'summary' ),
|
|
|
|
'icon' => 'revert',
|
2012-08-31 23:35:16 +00:00
|
|
|
)
|
2012-06-08 05:33:25 +00:00
|
|
|
);
|