r41570 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41569‎ | r41570 | r41571 >
Date:22:25, 2 October 2008
Author:skizzerz
Status:old
Tags:
Comment:
* bugfixes for ExtendedPermissions plugin and various other updates
Modified paths:
  • /trunk/extensions/GroupPermissionsManager (modified) (history)
  • /trunk/extensions/GroupPermissionsManager/GroupPermissionsManager.php (modified) (history)
  • /trunk/extensions/GroupPermissionsManager/GroupPermissionsManager_body.php (modified) (history)
  • /trunk/extensions/GroupPermissionsManager/RemoveUnusedGroups.php (modified) (history)
  • /trunk/extensions/GroupPermissionsManager/SortPermissions.php (modified) (history)
  • /trunk/extensions/GroupPermissionsManager/plugins/CustomTabs.php (modified) (history)
  • /trunk/extensions/GroupPermissionsManager/plugins/ExtendedPermissions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GroupPermissionsManager/plugins/ExtendedPermissions.php
@@ -15,7 +15,7 @@
1616 'name' => 'Extended Permissions',
1717 'author' => 'Ryan Schmidt',
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:GroupPermissionsManager',
19 - 'version' => '1.4',
 19+ 'version' => '1.5',
2020 'description' => 'Extended permissions system',
2121 'descriptionmsg' => 'grouppermissions-desc2',
2222 );
@@ -51,9 +51,9 @@
5252 //Extend the permissions system for finer-grained control without requiring hacks
5353 //For allowing actions that the normal permissions system would prevent
5454 function efGPManagerExtendedPermissionsGrant($title, $user, $action, &$result) {
55 - global $wgRequest;
 55+ global $wgRequest, $wgGroupPermissions;
5656 $result = false;
57 - if( $action == 'edit' && ($wgRequest->getVal('action') == 'edit' || $wgRequest->getVal('action') == 'submit') ) {
 57+ if( $action == 'edit' || $action == 'create' ) {
5858 if( !$title->exists() ) {
5959 $protection = getTitleProtection($title);
6060 if($protection) {
@@ -63,11 +63,15 @@
6464 return true;
6565 }
6666 }
67 - //otherwise don't pass it on to the normal permission system, because the edit right would then be checked
 67+ //need to explicitly set this right just for this instance because of a hard-coded check when saving a page
6868 if( $title->isTalkPage() && $user->isAllowed('createtalk') ) {
 69+ $wgGroupPermissions['*']['edit'] = true;
 70+ $user->mRights = null; //force a reload of rights
6971 $result = true;
7072 return false;
7173 } elseif( !$title->isTalkPage() && $user->isAllowed('createpage') ) {
 74+ $wgGroupPermissions['*']['edit'] = true;
 75+ $user->mRights = null; //force a reload of rights
7276 $result = true;
7377 return false;
7478 }
@@ -87,14 +91,25 @@
8892 $result = null;
8993 return false;
9094 }
 95+ //ditto here w/ the GroupPermissions
9196 if( $title->isTalkPage() && $user->isAllowed('edittalk') ) {
 97+ $wgGroupPermissions['*']['edit'] = true;
 98+ $user->mRights = null; //force a reload of rights
9299 $result = true;
93100 return false;
94101 } elseif( !$title->isTalkPage() && $user->isAllowed('edit') ) {
 102+ $wgGroupPermissions['*']['edit'] = true;
 103+ $user->mRights = null; //force a reload of rights
95104 $result = true;
96105 return false;
97106 }
98107 }
 108+ } elseif( $action == 'read' && ($wgRequest->getVal('action') == 'edit' || $wgRequest->getVal('action') == 'submit') ) {
 109+ # hack so anons can still view page source if they can't edit
 110+ if($user->isAllowed('viewsource')) {
 111+ $result = true;
 112+ return false;
 113+ }
99114 }
100115 //hack for the UserCanRead method
101116 $res = efGPManagerExtendedPermissionsRevoke($title, $user, $action, $result);
@@ -177,6 +192,13 @@
178193
179194 //replace right-edit messages with right-edit-new wherever applicable
180195 function efGPManagerReplaceEditMessage(&$key, &$useDB, &$langCode, $transform) {
 196+ # Dirty hack, prevents that issue on viewsource pages
 197+ global $wgRequest;
 198+ if($wgRequest->getVal('action') == 'edit' || $wgRequest->getVal('action') == 'sumbit') {
 199+ global $wgTitle;
 200+ if(!$wgTitle->userCan('edit')) return true;
 201+ }
 202+ loadGPMessages();
181203 if($key == 'right-edit') {
182204 $key = 'right-edit-new';
183205 return false; //so it doesn't change load times TOO much
Index: trunk/extensions/GroupPermissionsManager/plugins/CustomTabs.php
@@ -32,7 +32,7 @@
3333 return true;
3434 }
3535 global $wgUser, $wgGPManagerShowEditTab;
36 - wfLoadExtensionMessages('GroupPermissions');
 36+ loadGPMessages();
3737 $dt = array();
3838 $dto = array();
3939 foreach($ca as $tab => $stuff) {
Index: trunk/extensions/GroupPermissionsManager/GroupPermissionsManager_body.php
@@ -29,7 +29,7 @@
3030 $wgOut->permissionRequired( 'grouppermissions' );
3131 return;
3232 }
33 - wfLoadExtensionMessages('GroupPermissions');
 33+ loadGPMessages();
3434 $this->setHeaders();
3535 $wgOut->addWikiText( wfMsg( 'grouppermissions-header' ) );
3636
Index: trunk/extensions/GroupPermissionsManager/RemoveUnusedGroups.php
@@ -25,7 +25,7 @@
2626 return;
2727 }
2828
29 - wfLoadExtensionMessages('GroupPermissions');
 29+ loadGPMessages();
3030 $this->setHeaders();
3131 $wgOut->addWikiText( wfMsg( 'grouppermissions-rug-header' ) );
3232 if($wgRequest->wasPosted() || !$wgGPManagerRUGconfirm) {
Index: trunk/extensions/GroupPermissionsManager/GroupPermissionsManager.php
@@ -189,3 +189,9 @@
190190 if($cvp[2] >= $nvp[2]) return true;
191191 return false;
192192 }
 193+
 194+//shortcut to save some time in typing
 195+function loadGPMessages() {
 196+ wfLoadExtensionMessages('GroupPermissions');
 197+ return true;
 198+}
Index: trunk/extensions/GroupPermissionsManager/SortPermissions.php
@@ -26,7 +26,7 @@
2727 $wgOut->permissionRequired( 'grouppermissions' );
2828 return;
2929 }
30 - wfLoadExtensionMessages('GroupPermissions');
 30+ loadGPMessages();
3131 $wgOut->addHTML('<noscript><strong>' . wfMsg('grouppermissions-needjs') . '</strong></noscript>');
3232 $this->setHeaders();
3333 $wgOut->addWikiText( wfMsg( 'grouppermissions-sp-header' ) );
Property changes on: trunk/extensions/GroupPermissionsManager
___________________________________________________________________
Added: svn:ignore
3434 + config

Status & tagging log