2013-03-18 19:56:12 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Thanks extension
|
|
|
|
*
|
|
|
|
* This extension adds 'thank' links that allow users to thank other users for
|
|
|
|
* specific revisions. It relies on the Echo extension to send the actual thanks.
|
|
|
|
* For more info see http://mediawiki.org/wiki/Extension:Thanks
|
|
|
|
*
|
|
|
|
* 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 Ryan Kaldari
|
|
|
|
* @license MIT License
|
|
|
|
*/
|
|
|
|
|
|
|
|
$wgExtensionCredits['other'][] = array(
|
|
|
|
'path' => __FILE__,
|
|
|
|
'name' => 'Thanks',
|
|
|
|
'author' => array(
|
|
|
|
'Ryan Kaldari',
|
2014-02-26 02:12:47 +00:00
|
|
|
'Benjamin Chen',
|
|
|
|
'Wctaiwan',
|
2013-03-18 19:56:12 +00:00
|
|
|
),
|
2014-03-29 12:31:00 +00:00
|
|
|
'version' => '1.2.0',
|
2013-03-18 19:56:12 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Thanks',
|
|
|
|
'descriptionmsg' => 'thanks-desc',
|
2015-01-29 13:42:11 +00:00
|
|
|
'license-name' => 'MIT',
|
2013-03-18 19:56:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup */
|
|
|
|
|
|
|
|
$dir = __DIR__;
|
|
|
|
|
|
|
|
// Register files
|
|
|
|
$wgAutoloadClasses['ThanksHooks'] = $dir . '/Thanks.hooks.php';
|
|
|
|
$wgAutoloadClasses['EchoThanksFormatter'] = $dir . '/ThanksFormatter.php';
|
2014-02-26 02:12:47 +00:00
|
|
|
$wgAutoloadClasses['EchoFlowThanksFormatter'] = $dir . '/FlowThanksFormatter.php';
|
2013-03-18 19:56:12 +00:00
|
|
|
$wgAutoloadClasses['ApiThank'] = $dir . '/ApiThank.php';
|
2014-02-26 02:12:47 +00:00
|
|
|
$wgAutoloadClasses['ApiRevThank'] = $dir . '/ApiRevThank.php';
|
|
|
|
$wgAutoloadClasses['ApiFlowThank'] = $dir . '/ApiFlowThank.php';
|
2013-04-10 03:45:44 +00:00
|
|
|
$wgAutoloadClasses['ThanksLogFormatter'] = $dir . '/ThanksLogFormatter.php';
|
2013-10-24 01:13:43 +00:00
|
|
|
$wgAutoloadClasses['SpecialThanks'] = $dir . '/SpecialThanks.php';
|
2014-03-29 12:31:00 +00:00
|
|
|
$wgMessagesDirs['Thanks'] = __DIR__ . '/i18n';
|
2013-03-18 19:56:12 +00:00
|
|
|
$wgExtensionMessagesFiles['Thanks'] = $dir . '/Thanks.i18n.php';
|
2013-12-22 12:46:25 +00:00
|
|
|
$wgExtensionMessagesFiles['ThanksAlias'] = $dir . '/Thanks.alias.php';
|
|
|
|
|
2013-03-18 19:56:12 +00:00
|
|
|
// Register APIs
|
2014-02-26 02:12:47 +00:00
|
|
|
$wgAPIModules['thank'] = 'ApiRevThank';
|
2014-10-29 18:58:27 +00:00
|
|
|
/** @todo This should be conditional on Flow being installed on the wiki */
|
2014-02-26 02:12:47 +00:00
|
|
|
$wgAPIModules['flowthank'] = 'ApiFlowThank';
|
2013-03-18 19:56:12 +00:00
|
|
|
|
2013-10-24 01:13:43 +00:00
|
|
|
// Register special page
|
|
|
|
$wgSpecialPages['Thanks'] = 'SpecialThanks';
|
|
|
|
|
2013-03-18 19:56:12 +00:00
|
|
|
// Register hooks
|
|
|
|
$wgHooks['HistoryRevisionTools'][] = 'ThanksHooks::insertThankLink';
|
|
|
|
$wgHooks['DiffRevisionTools'][] = 'ThanksHooks::insertThankLink';
|
|
|
|
$wgHooks['PageHistoryBeforeList'][] = 'ThanksHooks::onPageHistoryBeforeList';
|
|
|
|
$wgHooks['DiffViewHeader'][] = 'ThanksHooks::onDiffViewHeader';
|
|
|
|
$wgHooks['BeforeCreateEchoEvent'][] = 'ThanksHooks::onBeforeCreateEchoEvent';
|
|
|
|
$wgHooks['EchoGetDefaultNotifiedUsers'][] = 'ThanksHooks::onEchoGetDefaultNotifiedUsers';
|
2013-04-26 23:36:24 +00:00
|
|
|
$wgHooks['AddNewAccount'][] = 'ThanksHooks::onAccountCreated';
|
2013-09-26 01:16:56 +00:00
|
|
|
$wgHooks['BeforeSpecialMobileDiffDisplay'][] = 'ThanksHooks::onBeforeSpecialMobileDiffDisplay';
|
2013-11-02 13:36:44 +00:00
|
|
|
$wgHooks['UnitTestsList'][] = 'ThanksHooks::registerUnitTests';
|
2013-11-13 02:46:18 +00:00
|
|
|
$wgHooks['GetLogTypesOnUser'][] = 'ThanksHooks::onGetLogTypesOnUser';
|
2014-07-14 19:08:43 +00:00
|
|
|
$wgHooks['BeforePageDisplay'][] = 'ThanksHooks::onBeforePageDisplay';
|
2015-01-15 00:14:12 +00:00
|
|
|
$wgHooks['ResourceLoaderTestModules'][] = 'ThanksHooks::onResourceLoaderTestModules';
|
2014-02-26 02:12:47 +00:00
|
|
|
|
2013-03-18 19:56:12 +00:00
|
|
|
// Register modules
|
|
|
|
$wgResourceModules['ext.thanks'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
'ext.thanks.thank.js',
|
|
|
|
),
|
2014-02-26 02:12:47 +00:00
|
|
|
'localBasePath' => $dir . '/modules',
|
|
|
|
'remoteExtPath' => 'Thanks/modules',
|
|
|
|
);
|
|
|
|
$wgResourceModules['ext.thanks.revthank'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
'ext.thanks.revthank.js',
|
|
|
|
),
|
2013-03-18 19:56:12 +00:00
|
|
|
'messages' => array(
|
|
|
|
'thanks-thanked',
|
|
|
|
'thanks-error-undefined',
|
|
|
|
'thanks-error-invalidrevision',
|
|
|
|
'thanks-error-ratelimited',
|
2014-08-06 13:46:53 +00:00
|
|
|
'thanks-confirmation2',
|
2013-06-08 05:06:46 +00:00
|
|
|
'ok',
|
|
|
|
'cancel',
|
2013-03-18 19:56:12 +00:00
|
|
|
),
|
|
|
|
'dependencies' => array(
|
|
|
|
'mediawiki.jqueryMsg',
|
|
|
|
'mediawiki.api',
|
|
|
|
'user.tokens',
|
2014-08-06 13:46:53 +00:00
|
|
|
'jquery.confirmable',
|
2014-02-26 02:12:47 +00:00
|
|
|
'ext.thanks',
|
2013-03-18 19:56:12 +00:00
|
|
|
),
|
|
|
|
'localBasePath' => $dir . '/modules',
|
|
|
|
'remoteExtPath' => 'Thanks/modules',
|
|
|
|
);
|
2013-09-26 01:16:56 +00:00
|
|
|
$wgResourceModules['ext.thanks.mobilediff'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
'ext.thanks.mobilediff.js',
|
|
|
|
),
|
|
|
|
'messages' => array(
|
|
|
|
'thanks-button-thank',
|
|
|
|
'thanks-button-thanked',
|
|
|
|
'thanks-error-invalidrevision',
|
|
|
|
'thanks-error-ratelimited',
|
|
|
|
'thanks-error-undefined',
|
|
|
|
'thanks-thanked-notice',
|
|
|
|
),
|
2014-02-26 02:12:47 +00:00
|
|
|
'dependencies' => array(
|
|
|
|
// Module name changed in MobileFrontend on 2014-02-25
|
|
|
|
'mobile.special.mobilediff.scripts',
|
2014-12-09 19:07:02 +00:00
|
|
|
'mobile.toast',
|
2014-02-26 02:12:47 +00:00
|
|
|
),
|
2013-09-26 01:16:56 +00:00
|
|
|
'targets' => array( 'desktop', 'mobile' ),
|
|
|
|
'localBasePath' => $dir . '/modules',
|
|
|
|
'remoteExtPath' => 'Thanks/modules',
|
|
|
|
);
|
2014-02-26 02:12:47 +00:00
|
|
|
$wgResourceModules['ext.thanks.flowthank'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
'ext.thanks.flowthank.js',
|
|
|
|
),
|
|
|
|
'messages' => array(
|
|
|
|
'thanks-button-thanked',
|
|
|
|
'thanks-error-undefined',
|
|
|
|
'thanks-error-ratelimited',
|
|
|
|
),
|
|
|
|
'dependencies' => array(
|
|
|
|
'mediawiki.jqueryMsg',
|
|
|
|
'mediawiki.api',
|
|
|
|
'user.tokens',
|
|
|
|
'ext.thanks',
|
|
|
|
),
|
|
|
|
'localBasePath' => $dir . '/modules',
|
|
|
|
'remoteExtPath' => 'Thanks/modules',
|
|
|
|
);
|
2013-03-18 19:56:12 +00:00
|
|
|
|
2013-04-10 03:45:44 +00:00
|
|
|
// Logging
|
|
|
|
$wgLogTypes[] = 'thanks';
|
|
|
|
$wgLogActionsHandlers['thanks/*'] = 'ThanksLogFormatter';
|
2013-07-26 21:42:06 +00:00
|
|
|
$wgFilterLogTypes['thanks'] = true;
|
2013-04-10 03:45:44 +00:00
|
|
|
|
2013-03-18 19:56:12 +00:00
|
|
|
/* Configuration */
|
|
|
|
|
|
|
|
// Enable sending thanks to bots
|
|
|
|
$wgThanksSendToBots = false;
|
|
|
|
|
2013-04-10 03:45:44 +00:00
|
|
|
// Whether or not thanks should be logged in Special:Log
|
|
|
|
$wgThanksLogging = true;
|
|
|
|
|
2013-06-08 05:06:46 +00:00
|
|
|
// Whether or not confirmation is required for sending thanks
|
|
|
|
$wgThanksConfirmationRequired = true;
|
|
|
|
|
2013-03-18 19:56:12 +00:00
|
|
|
// Set how many thanks can be sent per minute by a single user (default 10)
|
|
|
|
$wgRateLimits += array(
|
|
|
|
'thanks-notification' => array( 'user' => array( 10, 60 ) ),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Set default user options
|
|
|
|
$wgDefaultUserOptions['echo-subscriptions-web-edit-thank'] = true;
|
2013-04-26 23:36:24 +00:00
|
|
|
// This is overriden for new users in ThanksHooks::onAccountCreated
|
2013-04-25 18:00:08 +00:00
|
|
|
$wgDefaultUserOptions['echo-subscriptions-email-edit-thank'] = false;
|