Ljonka has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344355 )

Change subject: Review: Move Hooks to extension.json, add edit on review 
handling
......................................................................

Review: Move Hooks to extension.json, add edit on review handling

- Hook Functions static
- global array with permission used on page editable review process
- add permission selection on bluespice preferences for review

Change-Id: I1ac10795fa2d112b83ca517c9a81531c802ad086
---
M Review/Review.class.php
M Review/extension.json
M Review/i18n/en.json
M Review/i18n/qqq.json
4 files changed, 94 insertions(+), 43 deletions(-)


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

diff --git a/Review/Review.class.php b/Review/Review.class.php
index 0d2e110..3a15e78 100644
--- a/Review/Review.class.php
+++ b/Review/Review.class.php
@@ -25,7 +25,8 @@
  * @author     Markus Glaser <[email protected]>
  * @author     Robert Vogel <[email protected]>
  * @author     Patric Wirth <[email protected]>
- * @version    2.23.1
+ * @author     Leonid Verhovskij <[email protected]>
+ * @version    2.27.1
  * @package    BlueSpice_Extensions
  * @subpackage Review
  * @copyright  Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
@@ -53,20 +54,9 @@
                BsConfig::registerVar( 'MW::Review::CheckOwner', true, 
BsConfig::LEVEL_PUBLIC | BsConfig::TYPE_BOOL, 'bs-review-pref-checkowner', 
'toggle' );
                BsConfig::registerVar( 'MW::Review::EmailNotifyOwner', true, 
BsConfig::LEVEL_USER | BsConfig::TYPE_BOOL, 'bs-review-pref-emailnotifyowner', 
'toggle' );
                BsConfig::registerVar( 'MW::Review::EmailNotifyReviewer', true, 
BsConfig::LEVEL_USER | BsConfig::TYPE_BOOL, 
'bs-review-pref-emailnotifyreviewer', 'toggle' );
-
-               $this->setHook( 'SkinTemplateNavigation' );
-               $this->setHook( 'userCan', 'checkReviewPermissions' );
-               $this->setHook( 'ArticleDeleteComplete' );
-               $this->setHook( 'BSFlaggedRevsConnectorCollectFlagInfo' );
-               $this->setHook( 'BSStateBarAddSortTopVars', 
'onStatebarAddSortTopVars' );
-               $this->setHook( 'BSStateBarAddSortBodyVars', 
'onStatebarAddSortBodyVars' );
-               $this->setHook( 'BSStateBarBeforeTopViewAdd', 
'onStateBarBeforeTopViewAdd' );
-               $this->setHook( 'BSStateBarBeforeBodyViewAdd', 
'onStateBarBeforeBodyViewAdd' );
-               $this->setHook( 'BSUserSidebarGlobalActionsWidgetGlobalActions' 
);
-               $this->setHook( 'BeforePageDisplay' );
-               $this->setHook( 'SkinTemplateOutputPageBeforeExec' );
-
-               $this->setHook( 'EchoGetDefaultNotifiedUsers' );
+               BsConfig::registerVar(
+                 'MW::Review::Permissions', $GLOBALS[ 
'bsgDefaultReviewAdditionalPermissions' ], BsConfig::LEVEL_PUBLIC | 
BsConfig::TYPE_ARRAY_STRING | BsConfig::USE_PLUGIN_FOR_PREFS, 
'bs-review-pref-permissions', 'multiselectex'
+               );
 
                $this->mCore->registerPermission( 'workflowview', array( 'user' 
), array( 'type' => 'global' ) );
                $this->mCore->registerPermission( 'workflowedit', array(), 
array( 'type' => 'global' ) );
@@ -426,11 +416,11 @@
         *
         * @return boolean Always true to keep hook running
         */
-       public function onSkinTemplateNavigation( $oSkinTemplate, &$links ) {
-               if ( $this->getTitle()->exists() === false ) {
+       public static function onSkinTemplateNavigation( SkinTemplate 
$oSkinTemplate, &$links ) {
+               if ( $oSkinTemplate->getTitle()->exists() === false ) {
                        return true;
                }
-               if ( $this->getTitle()->userCan( 'workflowview' ) === false ) {
+               if ( $oSkinTemplate->getTitle()->userCan( 'workflowview' ) === 
false ) {
                        return true;
                }
 
@@ -674,10 +664,8 @@
         *
         * @return bool Allow other hooked methods to be executed. False if 
edit right is denied.
         */
-       public function checkReviewPermissions( $oTitle, $oUser, $sAction, 
&$bRight ) {
+       public static function checkReviewPermissions( $oTitle, $oUser, 
$sAction, &$bRight ) {
                $aActionsBlacklist = array( 'edit', 'delete', 'move', 
'protect', 'rollback' );
-               if ( !in_array( $sAction, $aActionsBlacklist ) )
-                       return true;
 
                $oRev = BsReviewProcess::newFromPid( $oTitle->getArticleID() );
                if ( !$oRev ) {
@@ -685,7 +673,7 @@
                }
 
 
-// Because of FlaggedRevs is it now allowed to edit when a workflow is 
finished...
+               // Because of FlaggedRevs is it now allowed to edit when a 
workflow is finished...
                $bResult = false;
                wfRunHooks( 'checkPageIsReviewable', array( $oTitle, &$bResult 
) );
 
@@ -717,7 +705,7 @@
         *
         * @return boolean
         */
-       public function onBSFlaggedRevsConnectorCollectFlagInfo( 
$oCurrentTitle, &$aFlagInfo ) {
+       public static function onBSFlaggedRevsConnectorCollectFlagInfo( 
$oCurrentTitle, &$aFlagInfo ) {
                $oRev = BsReviewProcess::newFromPid( 
$oCurrentTitle->getArticleID() );
                if ( $oRev instanceof BsReviewProcess && $oRev->isActive() ) {
                        $aFlagInfo[ 'user-can-review' ] = false;
@@ -965,7 +953,7 @@
 
                        $sIcon .= ".png";
 
-                       $aTopViews[ 'statebartopreview' ] = 
$this->makeStateBarTopReview( $sIcon );
+                       $aTopViews[ 'statebartopreview' ] = 
self::makeStateBarTopReview( $sIcon, $oTitle );
                }
 
                return true;
@@ -979,11 +967,10 @@
         *
         * @return \stdClass
         */
-       protected function makeJSDataObject( $oReview ) {
+       protected static function makeJSDataObject( $oReview, Title $oTitle ) {
                //Defaults
                $oData = new stdClass();
 
-               $oTitle = $this->getContext()->getTitle();
                if ( !is_null( $oTitle ) ) {
                        $oData->page_id = $oTitle->getArticleID();
                }
@@ -1136,10 +1123,10 @@
         *
         * @return ViewStateBarTopElement View that is part of StateBar.
         */
-       public function makeStateBarTopReview( $sIcon ) {
+       public static function makeStateBarTopReview( $sIcon, Title $oTitle ) {
                $oReviewView = new ViewStateBarTopElement();
 
-               if ( is_object( $this->getTitle() ) ) {
+               if ( is_object( $oTitle ) ) {
                        global $wgScriptPath;
                        $oReviewView->setKey( 'Review' );
                        $oReviewView->setIconSrc( $wgScriptPath . 
'/extensions/BlueSpiceExtensions/Review/resources/images/' . $sIcon );
@@ -1475,7 +1462,7 @@
         *
         * @return bool Allow other hooked methods to be executed. always true.
         */
-       public function onArticleDeleteComplete( &$article, &$user, $reason, 
$id ) {
+       public static function onArticleDeleteComplete( &$article, &$user, 
$reason, $id ) {
                BsReviewProcess::removeReviews( $id );
 
                return true;
@@ -1489,7 +1476,7 @@
         *
         * @return boolean
         */
-       public function onBeforePageDisplay( &$out, &$skin ) {
+       public static function onBeforePageDisplay( &$out, &$skin ) {
                $out->addModuleStyles( 'ext.bluespice.review.styles' );
 
                if ( $out->getTitle()->getNamespace() <= -1 )
@@ -1508,8 +1495,8 @@
                );
                $out->addJsConfigVars(
                        'bsReview',
-                       $this->makeJSDataObject( $oRev )
-               );
+                       self::makeJSDataObject( $oRev, $out->getTitle() )
+       );
 
                return true;
        }
@@ -1543,6 +1530,16 @@
                $aPrefs = array();
                wfRunHooks( 'BSReviewRunPreferencePlugin', array( 
&$sAdapterName, &$oVariable, &$aPrefs ) );
 
+               if ( $oVariable->getName() == "Permissions" ) {
+                       $aPermissions = array_diff(
+                         User::getAllRights(), WikiAdmin::get( 'ExcludeRights' 
)
+                       );
+                       return array(
+                               'type' => 'multiselectex',
+                               'options' => array_combine( $aPermissions, 
$aPermissions ),
+                       );
+               }
+
                return $aPrefs;
        }
 
@@ -1559,6 +1556,12 @@
                        "label" => "Review",
                        "mapping" => "Review::smwDataMapping"
                );
+
+               if( !isset( $GLOBALS['bsgDefaultReviewAdditionalPermissions'] ) 
) {
+                       $GLOBALS['bsgDefaultReviewAdditionalPermissions'] = 
array(
+                               'edit',
+                       );
+               }
        }
 
        /**
@@ -1595,4 +1598,35 @@
                );
                return true;
        }
+
+
+       /**
+        * Add edit right permission for current logged in user if review 
process
+        * add edit permission
+        * @param User $user
+        * @param type $rights
+        * @return boolean
+        */
+       public static function onUserGetRights( User $user, &$aRights ) {
+               if( !RequestContext::getMain()->hasTitle() ){
+                       return true;
+               }
+               $oTitle = RequestContext::getMain()->getTitle();
+               //permission handler
+               $oReviewProcess = BsReviewProcess::newFromPid( 
$oTitle->getArticleID() );
+               if( $oReviewProcess == null ){
+                       return true;
+               }
+
+               $aUser = $oReviewProcess->getNextUsers();
+               foreach ( $aUser as $mUser ) {
+                       if ( $mUser[ "id" ] == $user->getId() && 
$oReviewProcess->isEditable() ) {
+                               $bsConfigReview = BsConfig::get( 
"MW::Review::Permissions" );
+                               $aRights = array_merge( $aRights, 
$bsConfigReview );
+                       }
+               }
+
+               return true;
+       }
+
 }
diff --git a/Review/extension.json b/Review/extension.json
index 373fcb6..445dc66 100644
--- a/Review/extension.json
+++ b/Review/extension.json
@@ -1,8 +1,8 @@
 {
-        "name": "Review",
+    "name": "Review",
        "version": "2.27.0",
        "url": "https://help.bluespice.com/index.php/Review";,
-       "author": "Markus Glaser",
+       "author":[ "Markus Glaser", "Robert Vogel", "Patric Wirth", "Leonid 
Verhovskij"],
        "descriptionmsg": "bs-review-desc",
        "type": "bluespice",
        "bsgExtensions": {
@@ -92,7 +92,22 @@
        },
        "Hooks": {
                "LoadExtensionSchemaUpdates": "Review::getSchemaUpdates",
-               "BSUsageTrackerRegisterCollectors": 
"Review::onBSUsageTrackerRegisterCollectors"
+               "BSUsageTrackerRegisterCollectors": 
"Review::onBSUsageTrackerRegisterCollectors",
+               "UserAddGroup": "Review::onUserAddGroup",
+               "UserGetRights": "Review::onUserGetRights",
+               "UserCan":"Review::checkReviewPermissions",
+               "RevisionAjaxReviewBeforeParams": 
"Review::onRevisionAjaxReviewBeforeParams",
+               "SkinTemplateNavigation": "Review::onSkinTemplateNavigation",
+               "ArticleDeleteComplete":"Review::onArticleDeleteComplete",
+               
"BSFlaggedRevsConnectorCollectFlagInfo":"Review::onBSFlaggedRevsConnectorCollectFlagInfo",
+               "BSStateBarAddSortTopVars":"Review::onStatebarAddSortTopVars",
+               "BSStateBarAddSortBodyVars":"Review::onStatebarAddSortBodyVars",
+               
"BSStateBarBeforeTopViewAdd":"Review::onStateBarBeforeTopViewAdd",
+               
"BSStateBarBeforeBodyViewAdd":"Review::onStateBarBeforeBodyViewAdd",
+               
"BSUserSidebarGlobalActionsWidgetGlobalActions":"Review::onBSUserSidebarGlobalActionsWidgetGlobalActions",
+               "BeforePageDisplay":"Review::onBeforePageDisplay",
+               
"SkinTemplateOutputPageBeforeExec":"Review::onSkinTemplateOutputPageBeforeExec",
+               
"EchoGetDefaultNotifiedUsers":"Review::onEchoGetDefaultNotifiedUsers"
        },
        "callback": "Review::onRegistration",
        "manifest_version": 1
diff --git a/Review/i18n/en.json b/Review/i18n/en.json
index e7f7494..99fcb45 100644
--- a/Review/i18n/en.json
+++ b/Review/i18n/en.json
@@ -117,5 +117,6 @@
        "apihelp-bs-reviewpossiblereviewers-store-description": "Lists users 
that can be part of a review process. Allows sorting, filtering and pagination. 
Implements ExtJS Store parameters.",
        "apihelp-bs-reviewoverview-store-description": "Lists an overview of 
review processes. Allows sorting, filtering and pagination. Implements ExtJS 
Store parameters.",
        "apihelp-bs-review-tasks-description": "Allows manipulation of reviews",
-       "bs-usagetracker-review": "reviews"
+       "bs-usagetracker-review": "reviews",
+       "bs-review-pref-permissions": "Add additional permissions to assigned 
users"
 }
diff --git a/Review/i18n/qqq.json b/Review/i18n/qqq.json
index f63fa3d..ec59e09 100644
--- a/Review/i18n/qqq.json
+++ b/Review/i18n/qqq.json
@@ -118,11 +118,12 @@
        "notification-bs-review-finish-and-autoflag-subject": "Notification 
about reviewer finishes review and autoflags as stable - email 
subject\n\nParameters:\n* $1 - name of the user accepting a review\n* $2 - name 
of page\n* $3 - link to page (unused)",
        "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-reviewpossiblereviewers-store-param-articleid": "Describes 
the <var>articleId</var> parameter of the API module",
-       "apihelp-bs-reviewpossiblereviewers-store-description": "Describes the 
API endpoint that lists possible users that can do a review",
-       "apihelp-bs-reviewoverview-store-description": "Describes the API 
endpoint that lists an overview of Review",
-       "apihelp-bs-review-tasks-description": "Describes the API endpoint that 
allows manipulation of reviews",
-       "bs-usagetracker-review": "Name of the descriptor used in 
[[Special:UsageTracker|Special:UsageTracker]] output"
+       "apihelp-bs-reviewoverview-store-param-userid": "Describes the 
<var>userID</var> parameter of the API 
module\n{{doc-apihelp-param|bs-reviewoverview-store|userid}}",
+       "apihelp-bs-reviewpossiblereviewers-store-param-articleid": "Describes 
the <var>articleId</var> parameter of the API 
module\n{{doc-apihelp-param|bs-reviewpossiblereviewers-store|articleid}}",
+       "apihelp-bs-reviewpossiblereviewers-store-description": "Describes the 
API endpoint that lists possible users that can do a 
review\n{{doc-apihelp-description|bs-reviewpossiblereviewers-store}}",
+       "apihelp-bs-reviewoverview-store-description": "Describes the API 
endpoint that lists an overview of 
Review\n{{doc-apihelp-description|bs-reviewoverview-store}}",
+       "apihelp-bs-review-tasks-description": "Describes the API endpoint that 
allows manipulation of reviews\n{{doc-apihelp-description|bs-review-tasks}}",
+       "bs-usagetracker-review": "Name of the descriptor used in 
[[Special:UsageTracker|Special:UsageTracker]] output\n{{Identical|Review}}",
+       "apihelp-bs-reviewpossiblereviewers-store-description": "Describes the 
API endpoint that lists possible users that can do a 
review\n{{doc-apihelp-description|bs-reviewpossiblereviewers-store}}",
+       "bs-review-pref-permissions": "Option in 
[{{canonicalurl:Special:WikiAdmin|mode=Preferences}} 
Special:WikiAdmin?mode=Preferences], label of a multi select box for 
permissions that a user retrieves when part of a workflow"
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ac10795fa2d112b83ca517c9a81531c802ad086
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_27
Gerrit-Owner: Ljonka <[email protected]>

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

Reply via email to