r100561 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100560‎ | r100561 | r100562 >
Date:20:44, 23 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added 'generatepages' user right to view 'Generate pages' tab and page
Modified paths:
  • /trunk/extensions/PageSchemas/PS_Tabs.php (modified) (history)
  • /trunk/extensions/PageSchemas/PageSchemas.php (modified) (history)
  • /trunk/extensions/PageSchemas/specials/PS_GeneratePages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PS_Tabs.php
@@ -1,12 +1,13 @@
22 <?php
33
44 /**
5 - * @file PSTabs.php
 5+ * @file PS_Tabs.php
66 * @ingroup
77 *
8 - * @author ankit
 8+ * @author Ankit Garg
 9+ * @author Yaron Koren
910 */
10 - final class PSTabs {
 11+final class PSTabs {
1112
1213 public static function displayTabs( $obj, &$content_actions ) {
1314 global $wgUser;
@@ -28,7 +29,7 @@
2930 'href' => $title->getLocalURL( 'action=editschema' )
3031 );
3132
32 - if ( $isPSDefined ) {
 33+ if ( $isPSDefined && $wgUser->isAllowed( 'generatepages' ) ) {
3334 $content_actions['generatepages'] = array(
3435 'text' => wfMsg( 'generatepages' ),
3536 'class' => $wgRequest->getVal( 'action' ) == 'generatepages' ? 'selected' : '',
Index: trunk/extensions/PageSchemas/specials/PS_GeneratePages.php
@@ -10,12 +10,17 @@
1111
1212 class PSGeneratePages extends IncludableSpecialPage {
1313 function __construct() {
14 - parent::__construct( 'GeneratePages' );
 14+ parent::__construct( 'GeneratePages', 'generatepages' );
1515 }
1616
1717 function execute( $category ) {
18 - global $wgRequest, $wgOut, $wgPageSchemasHandlerClasses;
 18+ global $wgUser, $wgRequest, $wgOut, $wgPageSchemasHandlerClasses;
1919
 20+ if ( ! $wgUser->isAllowed( 'generatepages' ) ) {
 21+ $wgOut->permissionRequired( 'generatepages' );
 22+ return;
 23+ }
 24+
2025 $this->setHeaders();
2126 $param = $wgRequest->getText('param');
2227 if ( !empty( $param ) && !empty( $category ) ) {
Index: trunk/extensions/PageSchemas/PageSchemas.php
@@ -19,12 +19,14 @@
2020
2121 /* Configuration */
2222
 23+define( 'PAGE_SCHEMAS_VERSION', '0.2' );
 24+
2325 // Credits
2426 $wgExtensionCredits['parserhook'][] = array(
2527 'path' => __FILE__,
2628 'name' => 'Page Schemas',
2729 'author' => array( 'Ankit Garg', 'Yaron Koren' ),
28 - 'version' => '0.2',
 30+ 'version' => PAGE_SCHEMAS_VERSION,
2931 'url' => 'http://www.mediawiki.org/wiki/Extension:Page_Schemas',
3032 'descriptionmsg' => 'ps-desc',
3133 );
@@ -64,6 +66,10 @@
6567 $wgHooks['SkinTemplateTabs'][] = 'PSTabs::displayTabs';
6668 $wgHooks['SkinTemplateNavigation'][] = 'PSTabs::displayTabs2';
6769
 70+// User right for viewing the 'Generate pages' page
 71+$wgAvailableRights[] = 'generatepages';
 72+$wgGroupPermissions['sysop']['generatepages'] = true;
 73+
6874 // Register client-side modules
6975 $pageSchemasResourceTemplate = array(
7076 'localBasePath' => $dir,

Follow-up revisions

RevisionCommit summaryAuthorDate
r100582Add a message that explains the new user right introduced in r100561raymond06:50, 24 October 2011

Status & tagging log