Display permissions specific to the API (such as writeapi and apihighlimits) on actio...
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 4 Aug 2008 14:26:20 +0000 (14:26 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 4 Aug 2008 14:26:20 +0000 (14:26 +0000)
RELEASE-NOTES
includes/api/ApiMain.php

index 0c1ec67..268e045 100644 (file)
@@ -67,6 +67,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   This means you can use API search on Wikipedia without explicitly adding
   &srwhat=text to the query.
 * Added iiprop=bitdepth to imageinfo and aiprop=bitdepth to allimages
+* API-specific permissions (such as 'writeapi' and 'apihighlimits' are now
+  listed on action=help
 
 
 === Languages updated in 1.14 ===
index 63e5377..d81dfc8 100644 (file)
@@ -99,6 +99,19 @@ class ApiMain extends ApiBase {
                'dbg' => 'ApiFormatDbg',
                'dbgfm' => 'ApiFormatDbg'
        );
+       
+       /**
+        * List of user roles that are specifically relevant to the API.
+        * array( 'right' => array ( 'msg'    => 'Some message with a $1',
+        *                           'params' => array ( $someVarToSubst ) ),
+        *                          );
+        */
+       private static $mRights = array( 'writeapi'             => array(       'msg' => 'Use of the write API' , 
+                                                                                                                               'params' => array() ),
+                                                                       'apihighlimits' => array(       'msg' => 'Use higher limits in API queries (Slow queries: $1 results; Fast queries: $2 results)',
+                                                                                                                               'params' => array ( ApiMain :: LIMIT_SML2, ApiMain :: LIMIT_BIG2 ) ),
+                                                                       );
+
 
        private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames;
        private $mResult, $mAction, $mShowVersions, $mEnableWrite, $mRequest, $mInternalMode, $mSquidMaxage;
@@ -525,6 +538,14 @@ class ApiMain extends ApiBase {
                        $msg .= "\n";
                }
 
+               $msg .= "\n$astriks Permissions $astriks\n\n";
+               foreach ( self :: $mRights as $right => $rightMsg ) {
+                       $groups = User::getGroupsWithPermission( $right );
+                       $msg .= "* " . $right . " *\n  " . wfMsgReplaceArgs( $rightMsg[ 'msg' ], $rightMsg[ 'params' ] ) . 
+                                               "\nGranted to:\n  " . str_replace( "*", "all", implode( ", ", $groups ) ) . "\n";
+
+               }
+
                $msg .= "\n$astriks Formats  $astriks\n\n";
                foreach( $this->mFormats as $formatName => $unused ) {
                        $module = $this->createPrinterByName($formatName);