Implement access restriction for special page.

This commit is contained in:
Daniel Kraus
2014-06-03 16:50:57 +02:00
parent 6f25d469ed
commit 3e850f2781
2 changed files with 14 additions and 1 deletions

View File

@ -59,8 +59,12 @@
$wgAutoloadClasses['LinkTitles'] = dirname( __FILE__ ) . '/LinkTitles.body.php';
$wgAutoloadClasses['SpecialLinkTitles'] = dirname( __FILE__ ) . '/SpecialLinkTitles.php';
$wgExtensionFunctions[] = 'LinkTitles::setup';
// Settings for the batch-processing special page
$wgSpecialPages['LinkTitles'] = 'SpecialLinkTitles';
$wgSpecialPageGroups['LinkTitles'] = 'other';
$wgGroupPermissions['sysop']['linktitles-batch'] = true;
$wgAvailableRights[] = 'linktitles-batch';
// vim: ts=2:sw=2:noet

View File

@ -2,10 +2,19 @@
class SpecialLinkTitles extends SpecialPage {
function __construct() {
parent::__construct('LinkTitles');
// the second parameter in the following function call ensures that only
// users who have the 'linktitles-batch' right get to see this page (by
// default, this are all sysop users).
parent::__construct('LinkTitles', 'linktitles-batch');
}
function execute($par) {
// Prevent non-authorized users from executing the batch processing.
if ( !$this->userCanExecute( $this->getUser() ) ) {
$this->displayRestrictionError();
return;
}
$request = $this->getRequest();
$output = $this->getOutput();
$this->setHeaders();