r106212 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106211‎ | r106212 | r106213 >
Date:17:24, 14 December 2011
Author:cervidae
Status:ok
Tags:
Comment:
Replacing private function by variable to define grantable user groups
Modified paths:
  • /trunk/extensions/BatchUserRights/BatchUserRights.php (modified) (history)
  • /trunk/extensions/BatchUserRights/SpecialBatchUserRights.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BatchUserRights/BatchUserRights.php
@@ -17,7 +17,7 @@
1818 $wgExtensionCredits['specialpage'][] = array(
1919 'path' => __FILE__,
2020 'name' => 'BatchUserRights',
21 - 'version' => '1.1.1',
 21+ 'version' => '1.1.2',
2222 'author' => '[http://www.seancolombo.com Sean Colombo]',
2323 'descriptionmsg' => 'batchuserrights-desc',
2424 'url' => 'https://www.mediawiki.org/wiki/Extension:BatchUserRights',
@@ -28,9 +28,12 @@
2929 $wgAvailableRights[] = 'batchuserrights';
3030 $wgGroupPermissions['bureaucrat']['batchuserrights'] = true;
3131
 32+// User groups which can be added through Special:BatchUserRights
 33+$wgBatchUserRightsGrantableGroups = array();
 34+
3235 // Set up the new special page
3336 $dir = dirname( __FILE__ ) . '/';
3437 $wgExtensionMessagesFiles['BatchUserRights'] = $dir . 'BatchUserRights.i18n.php';
3538 $wgExtensionMessagesFiles['BatchUserRightsAliases'] = $dir . 'BatchUserRights.alias.php';
3639 $wgAutoloadClasses['SpecialBatchUserRights'] = $dir . 'SpecialBatchUserRights.php';
37 -$wgSpecialPages['BatchUserRights'] = 'SpecialBatchUserRights';
\ No newline at end of file
 40+$wgSpecialPages['BatchUserRights'] = 'SpecialBatchUserRights';
Index: trunk/extensions/BatchUserRights/SpecialBatchUserRights.php
@@ -8,13 +8,6 @@
99 class SpecialBatchUserRights extends SpecialPage {
1010 protected $isself = false;
1111
12 - // For added security, this array will be the only groups we'll allow to be batch-added to users.
13 - // FIXME: Don't use private function to define addable groups, switch to global variable
14 - private static $grantableUserGroups = array(
15 - 'beta',
16 - 'rollback',
17 - );
18 -
1912 /**
2013 * Constructor -- set up the new (restricted) special page
2114 */
@@ -38,7 +31,7 @@
3932 * @param $par Mixed: string if any subpage provided, else null
4033 */
4134 public function execute( $par ) {
42 - global $wgUser, $wgRequest, $wgOut;
 35+ global $wgUser, $wgRequest, $wgOut, $wgBatchUserRightsGrantableGroups;
4336
4437 // If the visitor doesn't have permissions to assign or remove
4538 // any groups, it's a bit silly to give them the user search prompt.
@@ -71,7 +64,7 @@
7265 $reason = $wgRequest->getVal( 'user-reason' );
7366 $tok = $wgRequest->getVal( 'wpEditToken' );
7467 if ( $wgUser->matchEditToken( $tok ) ) {
75 - $allgroups = self::$grantableUserGroups;
 68+ $allgroups = $wgBatchUserRightsGrantableGroups;
7669 $addgroup = array();
7770 foreach ( $allgroups as $group ) {
7871 // This batch form is only for adding user groups, we don't remove any.
@@ -350,9 +343,10 @@
351344 * @return string XHTML table element with checkboxes
352345 */
353346 private function groupCheckboxes() {
 347+ global $wgBatchUserRightsGrantableGroups;
354348 $usergroups = array(); // kinda a hack... this array holds "selected" groups... of which there shouldn't be any for this SpecialPage
355349
356 - $allgroups = self::$grantableUserGroups;
 350+ $allgroups = $wgBatchUserRightsGrantableGroups;
357351 $ret = '';
358352
359353 $column = 1;

Status & tagging log