Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/97859


Change subject: API module: list=betafeatures
......................................................................

API module: list=betafeatures

Bug: 57622
Change-Id: I9829ae6c64138f746a594654211d7b080c03cbd3
---
A ApiListBetaFeatures.php
M BetaFeatures.php
2 files changed, 74 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures 
refs/changes/59/97859/1

diff --git a/ApiListBetaFeatures.php b/ApiListBetaFeatures.php
new file mode 100644
index 0000000..6b45d97
--- /dev/null
+++ b/ApiListBetaFeatures.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Query module to list all available BetaFeatures
+ *
+ * @ingroup API
+ * @file
+ * @author Kunal Mehta <[email protected]>
+ */
+class ApiQueryBetaFeatures extends ApiQueryBase {
+       public function __construct( $query, $moduleName ) {
+               parent::__construct( $query, $moduleName, 'bf' );
+       }
+
+       public function execute() {
+               wfProfileIn( __METHOD__ );
+               $params = $this->extractRequestParams();
+
+               $prefs = array();
+               $user = User::newFromName( 'MediaWiki default' ); // Is this 
not a bad idea?
+               wfRunHooks( 'GetBetaFeaturePreferences', array( $user, &$prefs 
) );
+
+               $counts = isset( $params['counts'] )
+                       ? BetaFeaturesHooks::getUserCounts( array_keys( $prefs 
) )
+                       : array();
+               foreach ( $prefs as $key => $info ) {
+                       $path = array( 'query', $this->getModuleName(), $key );
+                       $this->getResult()->addValue(
+                               $path,
+                               'name',
+                               $key
+                       );
+                       if ( isset( $counts[$key] ) ) {
+                               $this->getResult()->addValue(
+                                       $path,
+                                       'count',
+                                       $counts[$key]
+                               );
+                       }
+               }
+
+               wfProfileOut( __METHOD__ );
+       }
+
+       public function getAllowedParams() {
+               return array(
+                       'counts' => null,
+               );
+       }
+
+       public function getParamDescription() {
+               return array(
+                       'counts' => 'Whether to fetch how manu users have 
enabled a certain preference.',
+               );
+       }
+
+       public function getDescription() {
+               return 'Enumerate all Campaigns';
+       }
+
+
+       public function getExamples() {
+               return array(
+                       'api.php?action=query&list=betafeatures&count=' => 'Get 
all available betafeatures and show how many users have enabled them'
+               );
+       }
+
+       public function getHelpUrls() {
+               return 
'https://www.mediawiki.org/wiki/Extension:BetaFeatures/API';
+       }
+}
+
diff --git a/BetaFeatures.php b/BetaFeatures.php
index fdeee86..4bc963b 100644
--- a/BetaFeatures.php
+++ b/BetaFeatures.php
@@ -28,6 +28,9 @@
 $wgAutoloadClasses['HTMLHorizontalRuleField'] = __DIR__ . 
'/includes/HTMLHorizontalRuleField.php';
 $wgAutoloadClasses['BetaFeatures'] = __DIR__ . 
'/includes/BetaFeaturesUtil.php';
 $wgAutoloadClasses['UpdateBetaFeatureUserCountsJob'] = __DIR__ . 
'/includes/UpdateBetaFeatureUserCountsJob.php';
+$wgAutoloadClasses['ApiQueryBetaFeatures'] = __DIR__ . 
'/ApiListBetaFeatures.php';
+
+$wgAPIListModules['betafeatures'] = 'ApiQueryBetaFeatures';
 
 $wgExtensionMessagesFiles['BetaFeatures'] = __DIR__ . '/BetaFeatures.i18n.php';
 

-- 
To view, visit https://gerrit.wikimedia.org/r/97859
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9829ae6c64138f746a594654211d7b080c03cbd3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to