Index: trunk/extensions/GroupPermissionsManager/plugins/ExtendedPermissions.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | 'name' => 'Extended Permissions', |
17 | 17 | 'author' => 'Ryan Schmidt', |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:GroupPermissionsManager', |
19 | | - 'version' => '1.4', |
| 19 | + 'version' => '1.5', |
20 | 20 | 'description' => 'Extended permissions system', |
21 | 21 | 'descriptionmsg' => 'grouppermissions-desc2', |
22 | 22 | ); |
— | — | @@ -51,9 +51,9 @@ |
52 | 52 | //Extend the permissions system for finer-grained control without requiring hacks |
53 | 53 | //For allowing actions that the normal permissions system would prevent |
54 | 54 | function efGPManagerExtendedPermissionsGrant($title, $user, $action, &$result) { |
55 | | - global $wgRequest; |
| 55 | + global $wgRequest, $wgGroupPermissions; |
56 | 56 | $result = false; |
57 | | - if( $action == 'edit' && ($wgRequest->getVal('action') == 'edit' || $wgRequest->getVal('action') == 'submit') ) { |
| 57 | + if( $action == 'edit' || $action == 'create' ) { |
58 | 58 | if( !$title->exists() ) { |
59 | 59 | $protection = getTitleProtection($title); |
60 | 60 | if($protection) { |
— | — | @@ -63,11 +63,15 @@ |
64 | 64 | return true; |
65 | 65 | } |
66 | 66 | } |
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 |
68 | 68 | if( $title->isTalkPage() && $user->isAllowed('createtalk') ) { |
| 69 | + $wgGroupPermissions['*']['edit'] = true; |
| 70 | + $user->mRights = null; //force a reload of rights |
69 | 71 | $result = true; |
70 | 72 | return false; |
71 | 73 | } elseif( !$title->isTalkPage() && $user->isAllowed('createpage') ) { |
| 74 | + $wgGroupPermissions['*']['edit'] = true; |
| 75 | + $user->mRights = null; //force a reload of rights |
72 | 76 | $result = true; |
73 | 77 | return false; |
74 | 78 | } |
— | — | @@ -87,14 +91,25 @@ |
88 | 92 | $result = null; |
89 | 93 | return false; |
90 | 94 | } |
| 95 | + //ditto here w/ the GroupPermissions |
91 | 96 | if( $title->isTalkPage() && $user->isAllowed('edittalk') ) { |
| 97 | + $wgGroupPermissions['*']['edit'] = true; |
| 98 | + $user->mRights = null; //force a reload of rights |
92 | 99 | $result = true; |
93 | 100 | return false; |
94 | 101 | } elseif( !$title->isTalkPage() && $user->isAllowed('edit') ) { |
| 102 | + $wgGroupPermissions['*']['edit'] = true; |
| 103 | + $user->mRights = null; //force a reload of rights |
95 | 104 | $result = true; |
96 | 105 | return false; |
97 | 106 | } |
98 | 107 | } |
| 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 | + } |
99 | 114 | } |
100 | 115 | //hack for the UserCanRead method |
101 | 116 | $res = efGPManagerExtendedPermissionsRevoke($title, $user, $action, $result); |
— | — | @@ -177,6 +192,13 @@ |
178 | 193 | |
179 | 194 | //replace right-edit messages with right-edit-new wherever applicable |
180 | 195 | 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(); |
181 | 203 | if($key == 'right-edit') { |
182 | 204 | $key = 'right-edit-new'; |
183 | 205 | return false; //so it doesn't change load times TOO much |
Index: trunk/extensions/GroupPermissionsManager/plugins/CustomTabs.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | global $wgUser, $wgGPManagerShowEditTab; |
36 | | - wfLoadExtensionMessages('GroupPermissions'); |
| 36 | + loadGPMessages(); |
37 | 37 | $dt = array(); |
38 | 38 | $dto = array(); |
39 | 39 | foreach($ca as $tab => $stuff) { |
Index: trunk/extensions/GroupPermissionsManager/GroupPermissionsManager_body.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | $wgOut->permissionRequired( 'grouppermissions' ); |
31 | 31 | return; |
32 | 32 | } |
33 | | - wfLoadExtensionMessages('GroupPermissions'); |
| 33 | + loadGPMessages(); |
34 | 34 | $this->setHeaders(); |
35 | 35 | $wgOut->addWikiText( wfMsg( 'grouppermissions-header' ) ); |
36 | 36 | |
Index: trunk/extensions/GroupPermissionsManager/RemoveUnusedGroups.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | | - wfLoadExtensionMessages('GroupPermissions'); |
| 29 | + loadGPMessages(); |
30 | 30 | $this->setHeaders(); |
31 | 31 | $wgOut->addWikiText( wfMsg( 'grouppermissions-rug-header' ) ); |
32 | 32 | if($wgRequest->wasPosted() || !$wgGPManagerRUGconfirm) { |
Index: trunk/extensions/GroupPermissionsManager/GroupPermissionsManager.php |
— | — | @@ -189,3 +189,9 @@ |
190 | 190 | if($cvp[2] >= $nvp[2]) return true; |
191 | 191 | return false; |
192 | 192 | } |
| 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 @@ |
27 | 27 | $wgOut->permissionRequired( 'grouppermissions' ); |
28 | 28 | return; |
29 | 29 | } |
30 | | - wfLoadExtensionMessages('GroupPermissions'); |
| 30 | + loadGPMessages(); |
31 | 31 | $wgOut->addHTML('<noscript><strong>' . wfMsg('grouppermissions-needjs') . '</strong></noscript>'); |
32 | 32 | $this->setHeaders(); |
33 | 33 | $wgOut->addWikiText( wfMsg( 'grouppermissions-sp-header' ) ); |
Property changes on: trunk/extensions/GroupPermissionsManager |
___________________________________________________________________ |
Added: svn:ignore |
34 | 34 | + config |