2011-10-09 18:35:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* AJAX Poll extension for MediaWiki
|
|
|
|
* Created by Dariusz Siedlecki, based on the work by Eric David.
|
|
|
|
* Licensed under the GFDL.
|
|
|
|
*
|
|
|
|
* <poll>
|
|
|
|
* Question
|
|
|
|
* Answer 1
|
|
|
|
* Answer 2
|
2012-02-16 22:55:06 +00:00
|
|
|
* Answer ...
|
2011-10-09 18:35:17 +00:00
|
|
|
* Answer n
|
|
|
|
* </poll>
|
|
|
|
*
|
2013-06-04 20:01:09 +00:00
|
|
|
* to allow the viewing of the poll results even without having voted
|
|
|
|
* <poll show-results-before-voting>
|
|
|
|
* Question
|
|
|
|
* Answer 1
|
|
|
|
* Answer 2
|
|
|
|
* Answer ...
|
|
|
|
* Answer n
|
|
|
|
* </poll>
|
|
|
|
*
|
|
|
|
* If the first line after <poll> is "STATS",
|
|
|
|
* then some statistics about the wiki and its polls will be displayed.
|
|
|
|
* These statistics are not localizable and this whole feature will probably be
|
|
|
|
* removed (or at least refactored, but probably removed) in the future.
|
|
|
|
* <poll>
|
|
|
|
* STATS
|
|
|
|
* </poll>
|
|
|
|
*
|
2011-10-09 18:35:17 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @author Dariusz Siedlecki <datrio@gmail.com>
|
|
|
|
* @author Jack Phoenix <jack@countervandalism.net>
|
2012-02-16 06:27:52 +00:00
|
|
|
* @author Thomas Gries
|
2012-02-16 22:55:06 +00:00
|
|
|
* @maintainer Thomas Gries
|
2011-10-09 18:35:17 +00:00
|
|
|
* @link http://www.mediawiki.org/wiki/Extension:AJAX_Poll Documentation
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( !defined( 'MEDIAWIKI' ) ) {
|
|
|
|
die( "This is not a valid entry point.\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extension credits that will show up on Special:Version
|
|
|
|
$wgExtensionCredits['parserhook'][] = array(
|
2012-02-15 07:44:34 +00:00
|
|
|
'path' => __FILE__,
|
2011-10-09 18:35:17 +00:00
|
|
|
'name' => 'AJAX Poll',
|
2014-03-30 21:21:13 +00:00
|
|
|
'version' => '1.88.0 20140330',
|
2012-02-17 14:57:54 +00:00
|
|
|
'author' => array( 'Dariusz Siedlecki', 'Jack Phoenix', 'Thomas Gries' ),
|
|
|
|
'descriptionmsg' => 'ajaxpoll-desc',
|
2012-02-15 07:44:34 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:AJAX_Poll',
|
2011-10-09 18:35:17 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Internationalization + AJAX function
|
2012-03-13 22:31:46 +00:00
|
|
|
$dir = dirname( __FILE__ );
|
2014-03-30 21:21:13 +00:00
|
|
|
$wgMessagesDirs['AJAXPoll'] = __DIR__ . '/i18n';
|
2012-03-13 22:31:46 +00:00
|
|
|
$wgExtensionMessagesFiles['AJAXPoll'] = $dir . '/AJAXPoll.i18n.php';
|
|
|
|
$wgAutoloadClasses['AJAXPoll'] = $dir . '/AJAXPoll_body.php';
|
2012-02-19 17:24:15 +00:00
|
|
|
$wgAjaxExportList[] = 'AJAXPoll::submitVote';
|
2012-03-14 20:19:16 +00:00
|
|
|
$wgHooks['ParserFirstCallInit'][] = 'AJAXPoll::onParserInit';
|
|
|
|
$wgHooks['LoadExtensionSchemaUpdates'][] = 'AJAXPoll::onLoadExtensionSchemaUpdates';
|
2012-03-09 19:23:28 +00:00
|
|
|
|
2012-03-13 22:31:46 +00:00
|
|
|
$myResourceTemplate = array(
|
|
|
|
'localBasePath' => dirname( __FILE__ ) . "/resources",
|
|
|
|
'remoteExtPath' => 'AJAXPoll/resources',
|
|
|
|
'group' => 'ext.ajaxpoll',
|
|
|
|
);
|
|
|
|
$wgResourceModules['ext.ajaxpoll'] = $myResourceTemplate + array(
|
|
|
|
'scripts' => array(
|
|
|
|
'ajaxpoll.js',
|
|
|
|
),
|
|
|
|
'styles' => array(
|
|
|
|
'ajaxpoll.css',
|
|
|
|
),
|
|
|
|
'dependencies' => array(
|
2013-06-05 00:24:18 +00:00
|
|
|
),
|
|
|
|
'messages' => array(
|
|
|
|
'ajaxpoll-submitting',
|
2012-03-13 22:31:46 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2012-03-10 09:26:52 +00:00
|
|
|
# new user rights
|
|
|
|
$wgAvailableRights[] = 'ajaxpoll-vote';
|
2013-11-12 19:24:27 +00:00
|
|
|
$wgAvailableRights[] = 'ajaxpoll-view-results';
|
|
|
|
$wgAvailableRights[] = 'ajaxpoll-view-results-before-vote';
|
2012-03-10 09:26:52 +00:00
|
|
|
|
2013-05-26 10:03:15 +00:00
|
|
|
# The 'ajaxpoll-view-results-before-vote' group permission allows the specified
|
|
|
|
# group members to view poll results even without having voted
|
|
|
|
# but only if the high-level group permission 'ajaxpoll-vote' allows to view
|
|
|
|
# results in general.
|
|
|
|
#
|
|
|
|
# This 'ajaxpoll-view-results-before-vote' can be overwritten with the specific
|
|
|
|
# per-poll setting "show-results-before-voting" which takes precedence over the
|
|
|
|
# group permission.
|
|
|
|
#
|
|
|
|
# permission 'ajaxpoll-view-results' >>
|
|
|
|
# >> per-poll setting "show-results-before-voting" (if present)
|
|
|
|
# >> permission 'ajaxpoll-view-results-before-vote'
|
|
|
|
#
|
|
|
|
|
|
|
|
# anons
|
|
|
|
# default: anons cannot vote and will never see results
|
|
|
|
$wgGroupPermissions['*']['ajaxpoll-vote'] = false;
|
|
|
|
$wgGroupPermissions['*']['ajaxpoll-view-results'] = false;
|
|
|
|
$wgGroupPermissions['*']['ajaxpoll-view-results-before-vote'] = false;
|
|
|
|
|
|
|
|
# users
|
|
|
|
# default: users can vote and can see poll results - when they have voted
|
|
|
|
$wgGroupPermissions['user']['ajaxpoll-vote'] = true;
|
|
|
|
$wgGroupPermissions['user']['ajaxpoll-view-results'] = true;
|
2014-04-01 01:42:44 +00:00
|
|
|
|
|
|
|
# tracking category for Special:TrackingCategories
|
|
|
|
$wgTrackingCategories[] = 'ajaxpoll-tracking-category';
|