MediaWiki r34357 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r34356‎ | r34357 (on ViewVC)‎ | r34358 >
Date:06:42, 7 May 2008
Author:tstarling
Status:old
Tags:
Comment:
* Rename wfGetAvailableRights() to User::getAllRights()
* Reintroduce $wgAvailableRights so that the above function is not so terribly slow and broken
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Defines.php
===================================================================
--- trunk/phase3/includes/Defines.php	(revision 34356)
+++ trunk/phase3/includes/Defines.php	(revision 34357)
@@ -84,30 +84,6 @@
 define( 'MW_MATH_MATHML', 5 );
 /**#@-*/
 
-/**
- * User rights list
- * @deprecated
- */
-$wgAvailableRights = array(
-	'block',
-	'bot',
-	'createaccount',
-	'delete',
-	'edit',
-	'editinterface',
-	'import',
-	'importupload',
-	'move',
-	'patrol',
-	'protect',
-	'read',
-	'rollback',
-	'siteadmin',
-	'unwatchedpages',
-	'upload',
-	'userrights',
-);
-
 /**#@+
  * Cache type
  */
Index: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php	(revision 34356)
+++ trunk/phase3/includes/User.php	(revision 34357)
@@ -106,6 +106,52 @@
 	);
 
 	/**
+	 * Core rights
+	 * Each of these should have a corresponding message of the form "right-$right"
+	 */
+	static $mCoreRights = array(
+		'apihighlimits',
+		'autoconfirmed',
+		'autopatrol',
+		'bigdelete',
+		'block',
+		'blockemail',
+		'bot',
+		'browsearchive',
+		'createaccount',
+		'createpage',
+		'createtalk',
+		'delete',
+		'deletedhistory',
+		'edit',
+		'editinterface',
+		'editusercssjs',
+		'import',
+		'importupload',
+		'ipblock-exempt',
+		'markbotedits',
+		'minoredit',
+		'move',
+		'nominornewtalk',
+		'patrol',
+		'protect',
+		'proxyunbannable',
+		'purge',
+		'read',
+		'reupload',
+		'reupload-shared',
+		'rollback',
+		'suppressredirect',
+		'trackback',
+		'undelete',
+		'unwatchedpages',
+		'upload',
+		'upload_by_url',
+		'userrights',
+	);
+	static $mAllRights = false;
+
+	/**
 	 * The cache variable declarations
 	 */
 	var $mId, $mName, $mRealName, $mPassword, $mNewpassword, $mNewpassTime,
@@ -2717,6 +2763,22 @@
 	}
 
 	/**
+	 * Get a list of all available permissions
+	 */
+	static function getAllRights() {
+		if ( self::$mAllRights === false ) {
+			global $wgAvailableRights;
+			if ( count( $wgAvailableRights ) ) {
+				self::$mAllRights = array_unique( array_merge( self::$mCoreRights, $wgAvailableRights ) );
+			} else {
+				self::$mAllRights = self::$mCoreRights;
+			}
+			wfRunHooks( 'UserGetAllRights', array( &self::$mAllRights ) );
+		}
+		return self::$mAllRights;
+	}
+
+	/**
 	 * Get a list of implicit groups
 	 *
 	 * @return array
Index: trunk/phase3/includes/GlobalFunctions.php
===================================================================
--- trunk/phase3/includes/GlobalFunctions.php	(revision 34356)
+++ trunk/phase3/includes/GlobalFunctions.php	(revision 34357)
@@ -2608,23 +2608,3 @@
 
  	return md5( mt_rand( 0, 0x7fffffff ) . $salt );
 }
-
-/**
- * Generate a list of all available rights.
- * @todo Doesn't list any rights which aren't assigned to a group.
- */
-function wfGetAvailableRights() {
-	global $wgGroupPermissions;
-	
-	$rights = array();
-	
-	foreach( $wgGroupPermissions as $permissions ) {
-		$rights = array_merge( array_keys($permissions),$rights );
-	}
-	
-	$rights = array_unique($rights);
-	
-	wfRunHooks( 'GetAvailableRights', array( &$rights ) );
-	
-	return $rights;
-}
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 34356)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 34357)
@@ -1282,7 +1282,14 @@
  */
 $wgAddGroups = $wgRemoveGroups = array();
 
+
 /**
+ * A list of available rights, in addition to the ones defined by the core. 
+ * For extensions only.
+ */
+$wgAvailableRights = array();
+
+/**
  * Optional to restrict deletion of pages with higher revision counts
  * to users with the 'bigdelete' permission. (Default given to sysops.)
  */

Status & tagging log

  • 15:26, 12 September 2011 Meno25 (Talk | contribs) changed the status of r34357 [removed: ok added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox