r100705 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100704‎ | r100705 | r100706 >
Date:16:08, 25 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Changed "edit schema" tab and page to only be displayed if user can edit the category page
Modified paths:
  • /trunk/extensions/PageSchemas/PS_Tabs.php (modified) (history)
  • /trunk/extensions/PageSchemas/specials/PS_EditSchema.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PS_Tabs.php
@@ -21,13 +21,15 @@
2222 $pageSchemaObj = new PSSchema( $category );
2323 $isPSDefined = $pageSchemaObj->isPSDefined();
2424
25 - global $wgRequest;
 25+ global $wgTitle, $wgRequest;
2626
27 - $content_actions['editschema'] = array(
28 - 'text' => ( $isPSDefined ) ? wfMsg( 'editschema' ) : wfMsg( 'createschema' ),
29 - 'class' => $wgRequest->getVal( 'action' ) == 'editschema' ? 'selected' : '',
30 - 'href' => $title->getLocalURL( 'action=editschema' )
31 - );
 27+ if ( $wgUser->isAllowed( 'edit' ) && $wgTitle->userCan( 'edit' ) ) {
 28+ $content_actions['editschema'] = array(
 29+ 'text' => ( $isPSDefined ) ? wfMsg( 'editschema' ) : wfMsg( 'createschema' ),
 30+ 'class' => $wgRequest->getVal( 'action' ) == 'editschema' ? 'selected' : '',
 31+ 'href' => $title->getLocalURL( 'action=editschema' )
 32+ );
 33+ }
3234
3335 if ( $isPSDefined && $wgUser->isAllowed( 'generatepages' ) ) {
3436 $content_actions['generatepages'] = array(
Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
@@ -8,7 +8,7 @@
99
1010 class PSEditSchema extends IncludableSpecialPage {
1111 function __construct() {
12 - parent::__construct( 'EditSchema' );
 12+ parent::__construct( 'EditSchema', 'edit' );
1313 }
1414
1515 /**
@@ -457,9 +457,16 @@
458458 }
459459
460460 function execute( $category ) {
461 - global $wgRequest, $wgOut, $wgUser;
462 - global $wgSkin;
 461+ global $wgRequest, $wgOut, $wgUser, $wgTitle;
463462
 463+ // Only display this page if user is allowed to edit the
 464+ // category page.
 465+ if ( !$wgUser->isAllowed( 'edit' ) || !$wgTitle->userCan( 'edit' ) ) {
 466+ $wgOut->permissionRequired( 'edit' );
 467+ return;
 468+ }
 469+
 470+
464471 $this->setHeaders();
465472 $text = '<p>' . wfMsg( 'ps-page-desc-edit-schema' ) . '</p>';
466473 PageSchemas::addJavascriptAndCSS();

Follow-up revisions

RevisionCommit summaryAuthorDate
r102679Follow-up to r100705 - changed permission-checking to not be called on basic ...yaron20:09, 10 November 2011

Status & tagging log