http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100705
Revision: 100705
Author: yaron
Date: 2011-10-25 16:08:34 +0000 (Tue, 25 Oct 2011)
Log Message:
-----------
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
trunk/extensions/PageSchemas/specials/PS_EditSchema.php
Modified: trunk/extensions/PageSchemas/PS_Tabs.php
===================================================================
--- trunk/extensions/PageSchemas/PS_Tabs.php 2011-10-25 15:36:06 UTC (rev
100704)
+++ trunk/extensions/PageSchemas/PS_Tabs.php 2011-10-25 16:08:34 UTC (rev
100705)
@@ -21,13 +21,15 @@
$pageSchemaObj = new PSSchema( $category );
$isPSDefined = $pageSchemaObj->isPSDefined();
- global $wgRequest;
+ global $wgTitle, $wgRequest;
- $content_actions['editschema'] = array(
- 'text' => ( $isPSDefined ) ? wfMsg( 'editschema' ) :
wfMsg( 'createschema' ),
- 'class' => $wgRequest->getVal( 'action' ) ==
'editschema' ? 'selected' : '',
- 'href' => $title->getLocalURL( 'action=editschema' )
- );
+ if ( $wgUser->isAllowed( 'edit' ) && $wgTitle->userCan( 'edit'
) ) {
+ $content_actions['editschema'] = array(
+ 'text' => ( $isPSDefined ) ? wfMsg(
'editschema' ) : wfMsg( 'createschema' ),
+ 'class' => $wgRequest->getVal( 'action' ) ==
'editschema' ? 'selected' : '',
+ 'href' => $title->getLocalURL(
'action=editschema' )
+ );
+ }
if ( $isPSDefined && $wgUser->isAllowed( 'generatepages' ) ) {
$content_actions['generatepages'] = array(
Modified: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
===================================================================
--- trunk/extensions/PageSchemas/specials/PS_EditSchema.php 2011-10-25
15:36:06 UTC (rev 100704)
+++ trunk/extensions/PageSchemas/specials/PS_EditSchema.php 2011-10-25
16:08:34 UTC (rev 100705)
@@ -8,7 +8,7 @@
class PSEditSchema extends IncludableSpecialPage {
function __construct() {
- parent::__construct( 'EditSchema' );
+ parent::__construct( 'EditSchema', 'edit' );
}
/**
@@ -457,9 +457,16 @@
}
function execute( $category ) {
- global $wgRequest, $wgOut, $wgUser;
- global $wgSkin;
+ global $wgRequest, $wgOut, $wgUser, $wgTitle;
+ // Only display this page if user is allowed to edit the
+ // category page.
+ if ( !$wgUser->isAllowed( 'edit' ) || !$wgTitle->userCan(
'edit' ) ) {
+ $wgOut->permissionRequired( 'edit' );
+ return;
+ }
+
+
$this->setHeaders();
$text = '<p>' . wfMsg( 'ps-page-desc-edit-schema' ) . '</p>';
PageSchemas::addJavascriptAndCSS();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs