Pwirth has uploaded a new change for review.

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

Change subject: BSReview: Using own user store to filter by permission 
'workflowview'
......................................................................

BSReview: Using own user store to filter by permission 'workflowview'

=> requires: 297553

Change-Id: Ib894ba8ec30097f5d9022d2b8f378fba01738719
---
M Review/Review.setup.php
M Review/i18n/en.json
M Review/i18n/qqq.json
A Review/includes/api/BSApiReviewPossibleReviewersStore.php
M Review/resources/BS.Review/StepDialog.js
5 files changed, 103 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/55/297555/1

diff --git a/Review/Review.setup.php b/Review/Review.setup.php
index 56ebed6..f198aa8 100644
--- a/Review/Review.setup.php
+++ b/Review/Review.setup.php
@@ -62,6 +62,7 @@
 $wgAutoloadClasses['BsReviewProcess'] = __DIR__ . 
'/includes/ReviewProcess.class.php';
 $wgAutoloadClasses['BsReviewProcessStep'] = __DIR__ . 
'/includes/ReviewProcessStep.class.php';
 $wgAutoloadClasses['ReviewFormatter'] = __DIR__ . 
'/includes/ReviewFormatter.class.php';
+$wgAutoloadClasses['BSApiReviewPossibleReviewersStore'] = __DIR__ . 
'/includes/api/BSApiReviewPossibleReviewersStore.php';
 $wgAutoloadClasses['BSApiReviewOverviewStore'] = __DIR__ . 
'/includes/api/BSApiReviewOverviewStore.php';
 $wgAutoloadClasses['BSApiReviewTasks'] = __DIR__ . 
'/includes/api/BSApiReviewTasks.php';
 
@@ -69,6 +70,7 @@
 
 $wgSpecialPages['Review'] = 'SpecialReview';
 
+$wgAPIModules['bs-reviewpossiblereviewers-store'] = 
'BSApiReviewPossibleReviewersStore';
 $wgAPIModules['bs-reviewoverview-store'] = 'BSApiReviewOverviewStore';
 $wgAPIModules['bs-review-tasks'] = 'BSApiReviewTasks';
 
diff --git a/Review/i18n/en.json b/Review/i18n/en.json
index 4c7973e..a524c3f 100644
--- a/Review/i18n/en.json
+++ b/Review/i18n/en.json
@@ -112,5 +112,6 @@
        "notification-bs-review-finish-and-autoflag-body": "$1 {{GENDER:$1|has 
finished}} your review on \"$2\". The page got marked as stable automatically.",
        "apihelp-bs-reviewoverview-store": "Lists an overview of review 
processes",
        "apihelp-bs-reviewoverview-store-param-userid": "Filters the list 
review processes by user id<var>userID</var>",
-       "apihelp-bs-review-tasks": "Allows manipulation of reviews"
+       "apihelp-bs-review-tasks": "Allows manipulation of reviews",
+       "apihelp-bs-reviewpossiblereviewers-store-param-articleid": "Filters 
the list of users by permissions for <var>articleId</var>"
 }
diff --git a/Review/i18n/qqq.json b/Review/i18n/qqq.json
index e1926e8..5edbb65 100644
--- a/Review/i18n/qqq.json
+++ b/Review/i18n/qqq.json
@@ -119,5 +119,6 @@
        "notification-bs-review-finish-and-autoflag-body": "Notification about 
reviewer finishes review and autoflags as stable - email body\n\nParameters:\n* 
$1 - name of the user accepting a review\n* $2 - name of page\n* $3 - link to 
page (unused)",
        "apihelp-bs-reviewoverview-store": "Describes the API endpoint that 
lists an overview of Review",
        "apihelp-bs-reviewoverview-store-param-userid": "Describes the 
<var>userID</var> parameter of the API module",
-       "apihelp-bs-review-tasks": "Describes the API endpoint that allows 
manipulation of reviews"
+       "apihelp-bs-review-tasks": "Describes the API endpoint that allows 
manipulation of reviews",
+       "apihelp-bs-reviewpossiblereviewers-store-param-articleid": "Describes 
the <var>articleId</var> parameter of the API module"
 }
diff --git a/Review/includes/api/BSApiReviewPossibleReviewersStore.php 
b/Review/includes/api/BSApiReviewPossibleReviewersStore.php
new file mode 100644
index 0000000..107f8ed
--- /dev/null
+++ b/Review/includes/api/BSApiReviewPossibleReviewersStore.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Provides the possible reviewers user store api for BlueSpice.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * This file is part of BlueSpice for MediaWiki
+ * For further information visit http://bluespice.com
+ *
+ * @author     Patric Wirth <[email protected]>
+ * @package    Bluespice_Extensions
+ * @copyright  Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or 
later
+ * @filesource
+ */
+
+/**
+ * Api base class for possible reviewers user store in BlueSpice
+ * @package BlueSpice_Extensions
+ */
+class BSApiReviewPossibleReviewersStore extends BSApiUserStore {
+       const PERMISSION = 'workflowview';
+       protected $oTitle = null;
+
+       public function getAllowedParams() {
+               return parent::getAllowedParams() + array(
+                       'articleId' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_REQUIRED => true,
+                               ApiBase::PARAM_DFLT => 0,
+                               ApiBase::PARAM_HELP_MSG =>
+                                       
'apihelp-bs-reviewpossiblereviewers-store-param-articleid',
+                       ),
+               );
+       }
+
+       protected function makeData($sQuery = '') {
+               $iArticleId = $this->getParameter( 'articleId' );
+               if( !$oTitle = Title::newFromId( $iArticleId ) ) {
+                       return array();
+               }
+               //TODO: Context could be used
+               $this->oTitle = $oTitle;
+               return parent::makeData($sQuery);
+       }
+
+       protected function makeResultRow( $row, $aGroups = array() ) {
+               $aResult = parent::makeResultRow( $row, $aGroups );
+               $oUser = User::newFromRow( $row );
+               error_log(var_export($this->oTitle->userCan( self::PERMISSION, 
$oUser ),1));
+               return $this->oTitle->userCan( self::PERMISSION, $oUser )
+                       ? $aResult
+                       : false
+               ;
+       }
+}
diff --git a/Review/resources/BS.Review/StepDialog.js 
b/Review/resources/BS.Review/StepDialog.js
index 543da9e..01bf8d4 100644
--- a/Review/resources/BS.Review/StepDialog.js
+++ b/Review/resources/BS.Review/StepDialog.js
@@ -1,13 +1,40 @@
 Ext.define( 'BS.Review.StepDialog', {
        extend: 'BS.Window',
+       requires: ['BS.model.User'],
        singleton: true,
        modal: true,
 
        afterInitComponent: function() {
+               this.strUsers = Ext.create( 'BS.store.BSApi', {
+                       apiAction: 'bs-reviewpossiblereviewers-store',
+                       proxy: {
+                               type: 'ajax',
+                               url: mw.util.wikiScript( 'api' ),
+                               reader: {
+                                       type: 'json',
+                                       root: 'results',
+                                       idProperty: 'user_id'
+                               },
+                               extraParams: {
+                                       articleId: mw.config.get( 
'wgArticleId', 0 )
+                               }
+                       },
+                       model: 'BS.model.User',
+                       //autoLoad: true //We need to load manually to have the 
store 
+                       //loading before rendering. This allows setting values 
at an early
+                       //time,
+                       sorters: [{
+                               property: 'display_name',
+                               direction: 'ASC'
+                       }],
+                       sortOnLoad: true,
+                       remoteSort: false
+               });
                this.setTitle( mw.message('bs-review-titleaddreviewer' 
).plain() );
                this.cbUsers = Ext.create( 'BS.form.UserCombo', {
-                       anyMatch: true
-               } );
+                       anyMatch: true,
+                       store: this.strUsers
+               });
                this.cbUsers.getStore().sort('display_name', 'asc');
 
                this.tfComment = Ext.create( 'Ext.form.TextField', {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib894ba8ec30097f5d9022d2b8f378fba01738719
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Pwirth <[email protected]>

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

Reply via email to