Robert Vogel has submitted this change and it was merged.

Change subject: GroupManager: Used task API instead of AjaxExportList
......................................................................


GroupManager: Used task API instead of AjaxExportList

PatchSet2:

* fixed whitespace

Change-Id: Ie67f0b860c688540664faae28c5675500ab338a5
---
M GroupManager/GroupManager.class.php
M GroupManager/GroupManager.setup.php
M GroupManager/i18n/en.json
M GroupManager/i18n/qqq.json
A GroupManager/includes/api/BSApiTasksGroupManager.php
M GroupManager/resources/BS.GroupManager/Panel.js
M UserManager/resources/BS.UserManager/dialog/User.js
M UserManager/resources/BS.UserManager/dialog/UserGroups.js
M UserManager/resources/BS.UserManager/panel/Manager.js
9 files changed, 343 insertions(+), 333 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  Siebrand: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/GroupManager/GroupManager.class.php 
b/GroupManager/GroupManager.class.php
index d551397..d21127d 100644
--- a/GroupManager/GroupManager.class.php
+++ b/GroupManager/GroupManager.class.php
@@ -79,281 +79,10 @@
        }
 
        /**
-        * returns a json object which hold the data of all existing usergroups
-        * @param string $output the ajax output string
-        */
-       public static function getData() {
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-               global $wgGroupPermissions, $wgAdditionalGroups;
-
-               $oStoreParams = BsExtJSStoreParams::newFromRequest();
-               $iLimit     = $oStoreParams->getLimit();
-               $iStart     = $oStoreParams->getStart();
-               $sSort      = $oStoreParams->getSort( 'group_name' );
-               $sDirection = $oStoreParams->getDirection();
-
-               $aGroups = array();
-               foreach ( BsGroupHelper::getAvailableGroups() as $sGroup ) {
-                       $aGroups['groups'][] = array(
-                               'group_name' => $sGroup,
-                               'additional_group' => ( isset( 
$wgAdditionalGroups[$sGroup] ) )
-                       );
-               }
-
-               if ( $sDirection == 'DESC' ) {
-                       usort( $aGroups['groups'], function ($a, $b) { return 
strnatcasecmp($b["group_name"], $a["group_name"]); });
-               } else {
-                       usort( $aGroups['groups'], function ($a, $b) { return 
strnatcasecmp($a["group_name"], $b["group_name"]); });
-               }
-
-               $aGroups['totalCount'] = sizeof( $aGroups['groups'] );
-
-               // Apply limit and offset
-               $aGroups['groups'] = array_slice( $aGroups['groups'], $iStart, 
$iLimit );
-
-
-               return FormatJson::encode( $aGroups );
-       }
-
-       /**
-        * returns a json object which hold the data of all existing usergroups
-        * @param string $output the ajax output string
-        */
-       public static function getGroups() {
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-               global $wgGroupPermissions;
-
-               $aGroups = array();
-               foreach ( BsGroupHelper::getAvailableGroups() as $sGroup ) {
-                       if ( in_array( $sGroup, array( '*', 'user', 
'autoconfirmed', 'emailconfirmed' ) ) ) continue;
-                       if ( !wfMessage( 'group-' . $sGroup 
)->inContentLanguage()->isBlank() ) {
-                               $sDisplayName = wfMessage( 'group-' . $sGroup 
)->plain() . " (" . $sGroup . ")";
-                       } else {
-                               $sDisplayName = $sGroup;
-                       }
-
-                       $aGroups[] = array(
-                               'group' => $sGroup,
-                               'displayname' => $sDisplayName
-                       );
-               }
-
-               return FormatJson::encode( array( 'groups' => $aGroups ) );
-       }
-
-       /**
-        * adds an usergroup to the wiki
-        * @param string $output the ajax output string
-        */
-       public static function addGroup( $sGroup ) {
-               if ( wfReadOnly() ) {
-                       global $wgReadOnly;
-                       return FormatJson::encode( array(
-                               'success' => false,
-                               'message' => wfMessage( 'bs-readonly', 
$wgReadOnly )->plain()
-                               ) );
-               }
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-
-               // TODO SU (04.07.11 11:40): global sind leider hier noch 
nötig, da werte in den globals geändert werden müssen.
-               global $wgGroupPermissions, $wgAdditionalGroups;
-
-               $output = array(
-                       'success' => true,
-                       'message' => wfMessage( 'bs-groupmanager-grpadded' 
)->plain()
-               );
-
-               if ( array_key_exists( $sGroup, $wgAdditionalGroups ) ) {
-                       return FormatJson::encode( array(
-                                       'success' => false,
-                                       'msg' => wfMessage( 
'bs-groupmanager-grpexists' )->plain()
-                               )
-                       );
-               }
-
-               if ( !empty( $sGroup ) ) {
-                       if ( !isset( $wgGroupPermissions[ $sGroup ] ) ) {
-                               $wgAdditionalGroups[ $sGroup ] = true;
-                               $output = BsExtensionManager::getExtension( 
'GroupManager' )->saveData();
-                       }
-                       if( $output[ 'success' ] === true ) {
-                               // Create a log entry for the creation of the 
group
-                               $oTitle = SpecialPage::getTitleFor( 'WikiAdmin' 
);
-                               $oUser = RequestContext::getMain()->getUser();
-                               $oLogger = new ManualLogEntry( 
'bs-group-manager', 'create' );
-                               $oLogger->setPerformer( $oUser );
-                               $oLogger->setTarget( $oTitle );
-                               $oLogger->setParameters( array(
-                                               '4::group' => $sGroup
-                               ) );
-                               $oLogger->insert();
-                       }
-               }
-
-               return FormatJson::encode( $output );
-       }
-
-       /**
-        * changes the name of a given usergroup.
-        * @param string $output the ajax output string
-        */
-       public static function editGroup( $sNewGroup, $sGroup ) {
-               if ( wfReadOnly() ) {
-                       global $wgReadOnly;
-                       return FormatJson::encode( array(
-                                       'success' => false,
-                                       'message' => wfMessage( 'bs-readonly', 
$wgReadOnly )->plain()
-                               )
-                       );
-               }
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-
-               global $wgGroupPermissions, $wgAdditionalGroups, 
$wgNamespacePermissionLockdown;
-
-               $output = FormatJson::encode( array(
-                               'success' => true,
-                               'message' => wfMessage( 
'bs-groupmanager-grpedited' )->plain()
-                       )
-               );
-
-               if ( !empty( $sGroup ) && !empty( $sNewGroup ) ) {
-                       if ( !isset( $wgAdditionalGroups[$sGroup] ) ) {
-                               // If group is not in $wgAdditionalGroups, it's 
a system group and mustn't be renamed.
-                               return FormatJson::encode( array(
-                                               'success' => true,
-                                               'message' => wfMessage( 
'bs-groupmanager-grpedited' )->plain()
-                                       )
-                               );
-                       }
-                       // Copy the data of the old group to the group with the 
new name and then delete the old group
-                       $wgAdditionalGroups[$sGroup] = false;
-                       $wgAdditionalGroups[$sNewGroup] = true;
-
-                       $dbw = wfGetDB( DB_MASTER );
-                       $res = $dbw->update(
-                               'user_groups',
-                               array(
-                                       'ug_group' => $sNewGroup
-                               ),
-                               array(
-                                       'ug_group' => $sGroup
-                               )
-                       );
-
-                       if( $res === false ) {
-                               return FormatJson::encode( array(
-                                               'success' => false,
-                                               'message' => wfMessage( 
'bs-groupmanager-removegroup-message-unknown' )->plain()
-                                       )
-                               );
-                       }
-
-                       $result = BsExtensionManager::getExtension( 
'GroupManager' )->saveData();
-
-                       wfRunHooks( "BSGroupManagerGroupNameChanged", array( 
$sGroup, $sNewGroup, &$result ) );
-                       if ( $result['success'] === false ) {
-                               return FormatJson::encode( $result );
-                       }
-               }
-
-               // Create a log entry for the change of the group
-               $oTitle = SpecialPage::getTitleFor( 'WikiAdmin' );
-               $oUser = RequestContext::getMain()->getUser();
-               $oLogger = new ManualLogEntry( 'bs-group-manager', 'modify' );
-               $oLogger->setPerformer( $oUser );
-               $oLogger->setTarget( $oTitle );
-               $oLogger->setParameters( array(
-                               '4::group' => $sGroup,
-                               '5::newGroup' => $sNewGroup
-               ) );
-               $oLogger->insert();
-
-               return $output;
-       }
-
-       /**
-        * removes a usergroup
-        * @param string $output the ajax output string
-        */
-       public static function removeGroup( $sGroup ) {
-               if ( wfReadOnly() ) {
-                       global $wgReadOnly;
-                       return FormatJson::encode( array(
-                               'success' => false,
-                               'message' => wfMessage( 'bs-readonly', 
$wgReadOnly )->plain()
-                               ) );
-               }
-               if ( BsCore::checkAccessAdmission( 'wikiadmin' ) === false ) 
return true;
-               global $wgGroupPermissions, $wgAdditionalGroups, 
$wgNamespacePermissionLockdown;
-
-               $output = FormatJson::encode( array(
-                               'success' => true,
-                               'message' => wfMessage( 
'bs-groupmanager-grpremoved' )->plain()
-                       )
-               );
-
-               if ($sGroup) {
-                       if (!isset($wgAdditionalGroups[$sGroup])) {
-                               return FormatJson::encode( array(
-                                               'success' => false,
-                                               'message' => 
wfMessage('bs-groupmanager-msgnotremovable')->plain()
-                                       )
-                               );
-                       }
-
-                       $wgAdditionalGroups[$sGroup] = false;
-                       $dbw = wfGetDB( DB_MASTER );
-                       $res = $dbw->delete(
-                               'user_groups',
-                               array(
-                                       'ug_group' => $sGroup
-                               )
-                       );
-                       if( $res === false ) {
-                               return FormatJson::encode( array(
-                                               'success' => false,
-                                               'message' => wfMessage( 
'bs-groupmanager-removegroup-message-unknown' )->plain()
-                                       )
-                               );
-                       }
-
-                       $result = BsExtensionManager::getExtension( 
'GroupManager' )->saveData();
-
-                       wfRunHooks( "BSGroupManagerGroupDeleted", array( 
$sGroup, &$result ) );
-                       if ( $result['success'] === false ) {
-                               return FormatJson::encode( $result );
-                       }
-               }
-
-               // Create a log entry for the removal of the group
-               $oTitle = SpecialPage::getTitleFor( 'WikiAdmin' );
-               $oUser = RequestContext::getMain()->getUser();
-               $oLogger = new ManualLogEntry( 'bs-group-manager', 'remove' );
-               $oLogger->setPerformer( $oUser );
-               $oLogger->setTarget( $oTitle );
-               $oLogger->setParameters( array(
-                               '4::group' => $sGroup
-               ) );
-               $oLogger->insert();
-
-               return $output;
-       }
-
-       public static function removeGroups( $aGroups ){
-               $output = array();
-               if (is_array($aGroups) && count($aGroups) > 0){
-                       foreach($aGroups as $sGroup){
-                               $output [$sGroup] = 
FormatJson::decode(self::removeGroup($sGroup));
-                       }
-               }
-               return FormatJson::encode($output);
-       }
-
-       /**
         * saves all groupspecific data to a config file
         * @return array the json answer
         */
-       protected function saveData() {
+       public static function saveData() {
                global $wgAdditionalGroups, $bsgConfigFiles;
 
                $sSaveContent = "<?php\n\$GLOBALS['wgAdditionalGroups'] = 
array();\n\n";
@@ -383,9 +112,9 @@
                        } else {
                                if ( $mValue !== false ) {
                                        $sSaveContent .= 
"\$GLOBALS['wgAdditionalGroups']['{$sGroup}'] = array();\n";
-                                       $this->checkI18N( $sGroup );
+                                       self::checkI18N( $sGroup );
                                } else {
-                                       $this->checkI18N( $sGroup, $mValue );
+                                       self::checkI18N( $sGroup, $mValue );
                                }
                        }
                }
@@ -407,7 +136,7 @@
                }
        }
 
-       public function checkI18N( $sGroup, $bValue = true ) {
+       public static function checkI18N( $sGroup, $bValue = true ) {
                $oTitle   = Title::newFromText( 'group-' . $sGroup, 
NS_MEDIAWIKI );
                $oArticle = null;
 
diff --git a/GroupManager/GroupManager.setup.php 
b/GroupManager/GroupManager.setup.php
index 8238cec..8f787e0 100644
--- a/GroupManager/GroupManager.setup.php
+++ b/GroupManager/GroupManager.setup.php
@@ -3,6 +3,7 @@
 BsExtensionManager::registerExtension( 'GroupManager', 
BsRUNLEVEL::FULL|BsRUNLEVEL::REMOTE, BsACTION::LOAD_SPECIALPAGE );
 
 $GLOBALS['wgAutoloadClasses']['GroupManager'] = __DIR__ . 
'/GroupManager.class.php';
+$wgAutoloadClasses['BSApiTasksGroupManager'] = __DIR__ . 
'/includes/api/BSApiTasksGroupManager.php';
 
 $wgMessagesDirs['GroupManager'] = __DIR__ . '/i18n';
 
@@ -27,12 +28,7 @@
        'remoteBasePath' => &$GLOBALS['wgScriptPath']
 );
 
-$wgAjaxExportList[] = 'GroupManager::getData';
-$wgAjaxExportList[] = 'GroupManager::getGroups';
-$wgAjaxExportList[] = 'GroupManager::addGroup';
-$wgAjaxExportList[] = 'GroupManager::editGroup';
-$wgAjaxExportList[] = 'GroupManager::removeGroup';
-$wgAjaxExportList[] = 'GroupManager::removeGroups';
+$wgAPIModules['bs-groupmanager'] = 'BSApiTasksGroupManager';
 
 $wgLogTypes[] = 'bs-group-manager';
 $wgFilterLogTypes['bs-group-manager'] = true;
diff --git a/GroupManager/i18n/en.json b/GroupManager/i18n/en.json
index 0b6bb53..157f0fc 100644
--- a/GroupManager/i18n/en.json
+++ b/GroupManager/i18n/en.json
@@ -6,6 +6,7 @@
        },
        "bs-groupmanager-desc": "Administration interface for adding, editing 
and deleting user groups and their rights",
        "bs-groupmanager-grpexists": "The group already exists.",
+       "bs-groupmanager-grpempty": "The group name can not be empty.",
        "bs-groupmanager-grpadded": "The group has been added.",
        "bs-groupmanager-grpedited": "The group has been edited.",
        "bs-groupmanager-grpremoved": "The group has been removed.",
@@ -29,5 +30,6 @@
        "log-show-hide-bs-group-manager": "$1 group manager log",
        "logentry-bs-group-manager-create": "$1 {{GENDER:$2|has created}} the 
group $4",
        "logentry-bs-group-manager-modify": "$1 {{GENDER:$2|has renamed}} the 
group $4 to $5",
-       "logentry-bs-group-manager-remove": "$1 {{GENDER:$2|has removed}} the 
group $4"
+       "logentry-bs-group-manager-remove": "$1 {{GENDER:$2|has removed}} the 
group $4",
+       "apihelp-bs-groupmanager-description": "Provides the tasks for the 
extension GroupManager."
 }
diff --git a/GroupManager/i18n/qqq.json b/GroupManager/i18n/qqq.json
index 7211c7e..859acf7 100644
--- a/GroupManager/i18n/qqq.json
+++ b/GroupManager/i18n/qqq.json
@@ -8,6 +8,7 @@
        },
        "bs-groupmanager-desc": "Used in 
[{{canonicalurl:Special:WikiAdmin|mode=ExtensionInfo}} 
Special:WikiAdmin?mode=ExtensionInfo], description of group manager extension",
        "bs-groupmanager-grpexists": "Error message that the group you want to 
create already exists.",
+       "bs-groupmanager-grpempty": "Error message that the group name param 
can not be empty.",
        "bs-groupmanager-grpadded": "Success message that the group has been 
added.",
        "bs-groupmanager-grpedited": "Success message that the group has been 
edited.",
        "bs-groupmanager-grpremoved": "Success message that the group has been 
removed.",
@@ -31,5 +32,6 @@
        "log-show-hide-bs-group-manager": "Used in [[Special:Log]]. 
Parameters:\n* $1 - link text; one of {{msg-mw|Show}} or 
{{msg-mw|Hide}}\n{{Related|Log-show-hide}}",
        "logentry-bs-group-manager-create": "Log message about the creation of 
a new group.\nParameters:\n* $4 - name of the group",
        "logentry-bs-group-manager-modify": "Log message about changes of the 
name of a group.\nParameters:\n* $4 - old name of the group\n* $5 - new name of 
the group",
-       "logentry-bs-group-manager-remove": "Log message about the removal of a 
group.\nParameters:\n* $4 - name of the group"
+       "logentry-bs-group-manager-remove": "Log message about the removal of a 
group.\nParameters:\n* $4 - name of the group",
+       "apihelp-bs-groupmanager-description": "Describes the API endpoint that 
provides tasks for the GroupManager extension"
 }
diff --git a/GroupManager/includes/api/BSApiTasksGroupManager.php 
b/GroupManager/includes/api/BSApiTasksGroupManager.php
new file mode 100644
index 0000000..14e229d
--- /dev/null
+++ b/GroupManager/includes/api/BSApiTasksGroupManager.php
@@ -0,0 +1,290 @@
+<?php
+/**
+ * Provides the group manager tasks 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://www.blue-spice.org
+ *
+ * @author     Patric Wirth <wi...@hallowelt.biz>
+ * @package    Bluespice_Extensions
+ * @copyright  Copyright (C) 2011 Hallo Welt! - Medienwerkstatt GmbH, All 
rights reserved.
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or 
later
+ */
+
+/**
+ * GroupManager Api class
+ * @package BlueSpice_Extensions
+ */
+class BSApiTasksGroupManager extends BSApiTasksBase {
+
+       /**
+        * Methods that can be called by task param
+        * @var array
+        */
+       protected $aTasks = array(
+               'addGroup',
+               'editGroup',
+               'removeGroup',
+               'removeGroups',
+       );
+
+       protected function task_addGroup( $oTaskData, $aParams ) {
+               // TODO SU (04.07.11 11:40): global sind leider hier noch 
nötig, da werte in den globals geändert werden müssen.
+               global $wgGroupPermissions, $wgAdditionalGroups;
+
+               $oReturn = $this->makeStandardReturn();
+
+               $sGroup = isset( $oTaskData->group )
+                       ? (string) $oTaskData->group
+                       : ''
+               ;
+               if( empty($sGroup) ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpempty'
+                       )->plain();
+                       return $oReturn;
+               }
+               if ( array_key_exists( $sGroup, $wgAdditionalGroups ) ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpexists'
+                       )->plain();
+                       return $oReturn;
+               }
+
+               if ( !isset( $wgGroupPermissions[ $sGroup ] ) ) {
+                       $wgAdditionalGroups[ $sGroup ] = true;
+                       $output = GroupManager::saveData();
+               }
+               if( $output[ 'success' ] === true ) {
+                       // Create a log entry for the creation of the group
+                       $oTitle = SpecialPage::getTitleFor( 'WikiAdmin' );
+                       $oUser = RequestContext::getMain()->getUser();
+                       $oLogger = new ManualLogEntry( 'bs-group-manager', 
'create' );
+                       $oLogger->setPerformer( $oUser );
+                       $oLogger->setTarget( $oTitle );
+                       $oLogger->setParameters( array(
+                                       '4::group' => $sGroup
+                       ) );
+                       $oLogger->insert();
+               }
+
+               $oReturn->success = true;
+               $oReturn->message = wfMessage( 'bs-groupmanager-grpadded' 
)->plain();
+               return $oReturn;
+       }
+
+       protected function task_editGroup( $oTaskData, $aParams ) {
+               global $wgAdditionalGroups;
+
+               $oReturn = $this->makeStandardReturn();
+               $sGroup = isset( $oTaskData->group )
+                       ? (string) $oTaskData->group
+                       : ''
+               ;
+               $sNewGroup = isset( $oTaskData->newGroup )
+                       ? (string) $oTaskData->newGroup
+                       : ''
+               ;
+               if( empty( $sGroup ) || empty( $sNewGroup ) || $sGroup == 
$sNewGroup ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpempty'
+                       )->plain();
+                       return $oReturn;
+               }
+               if( !isset( $wgAdditionalGroups[$sGroup] ) ) {
+                       // If group is not in $wgAdditionalGroups, it's a 
system group and mustn't be renamed.
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpedited'
+                       )->plain();
+                       return $oReturn;
+               }
+               // Copy the data of the old group to the group with the new 
name and then delete the old group
+               $wgAdditionalGroups[$sGroup] = false;
+               $wgAdditionalGroups[$sNewGroup] = true;
+
+               $dbw = wfGetDB( DB_MASTER );
+               $res = $dbw->update(
+                       'user_groups',
+                       array(
+                               'ug_group' => $sNewGroup
+                       ),
+                       array(
+                               'ug_group' => $sGroup
+                       )
+               );
+
+               if( $res === false ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-removegroup-message-unknown'
+                       )->plain();
+                       return $oReturn;
+               }
+
+               $oReturn->success = true;
+
+               $result = GroupManager::saveData();
+               //Backwards compatibility
+               $result = array_merge(
+                       (array) $oReturn,
+                       $result
+               );
+
+               wfRunHooks( "BSGroupManagerGroupNameChanged", array( $sGroup, 
$sNewGroup, &$result ) );
+
+               if ( $result['success'] === false ) {
+                       return (object) $result;
+               }
+               $result['message'] = wfMessage( 'bs-groupmanager-grpedited' 
)->plain();
+
+               // Create a log entry for the change of the group
+               $oTitle = SpecialPage::getTitleFor( 'WikiAdmin' );
+               $oUser = RequestContext::getMain()->getUser();
+               $oLogger = new ManualLogEntry( 'bs-group-manager', 'modify' );
+               $oLogger->setPerformer( $oUser );
+               $oLogger->setTarget( $oTitle );
+               $oLogger->setParameters( array(
+                               '4::group' => $sGroup,
+                               '5::newGroup' => $sNewGroup
+               ) );
+               $oLogger->insert();
+
+               return (object) $result;
+       }
+
+       protected function task_removeGroups( $oTaskData, $aParams ) {
+               $oReturn = $this->makeStandardReturn();
+               $aGroups = isset( $oTaskData->groups )
+                       ? $oTaskData->groups
+                       : array()
+               ;
+               if( !is_array($aGroups) || empty($aGroups) ){
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpempty'
+                       )->plain();
+                       return $oReturn;
+               }
+               $aFails = array();
+               foreach( $aGroups as $sGroup ){
+                       $oReturn->payload[$sGroup] = $this->task_removeGroup(
+                               (object) array( 'group' => $sGroup ),
+                               array()
+                       );
+                       $oReturn->payload_count++;
+                       if( isset($oReturn->payload[$sGroup]->success) ) {
+                               continue;
+                       }
+                       $aFails[] = $sGroup;
+               }
+
+               if( !empty($aFails) ) {
+                       $oReturn->success = false;
+                       $sErrorList = Xml::openElement( 'ul' );
+                       foreach( $aFails as $sGroup ) {
+                               $sErrorList .= Xml::element( 'li', array(), 
$sGroup );
+                       }
+                       $sErrorList .= Xml::closeElement( 'ul' );
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-removegroup-message-failure',
+                               count( $aFails ),
+                               $sErrorList
+                       )->parse();
+               } else {
+                       $oReturn->success = true;
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpremoved'
+                       )->plain();
+               }
+               return $oReturn;
+       }
+
+       protected function task_removeGroup( $oTaskData, $aParams ) {
+               global $wgAdditionalGroups;
+               $oReturn = $this->makeStandardReturn();
+
+               $sGroup = isset( $oTaskData->group )
+                       ? (string) $oTaskData->group
+                       : ''
+               ;
+               if( empty( $sGroup ) ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-grpempty'
+                       )->plain();
+                       return $oReturn;
+               }
+               if( !isset($wgAdditionalGroups[$sGroup]) ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-msgnotremovable'
+                       )->plain();
+                       return $oReturn;
+               }
+
+               $wgAdditionalGroups[$sGroup] = false;
+               $dbw = wfGetDB( DB_MASTER );
+               $res = $dbw->delete(
+                       'user_groups',
+                       array(
+                               'ug_group' => $sGroup
+                       )
+               );
+               if( $res === false ) {
+                       $oReturn->message = wfMessage(
+                               'bs-groupmanager-removegroup-message-unknown'
+                       )->plain();
+                       return $oReturn;
+               }
+
+               $result = GroupManager::saveData();
+               //Backwards compatibility
+               $result = array_merge(
+                       (array) $oReturn,
+                       $result
+               );
+
+               wfRunHooks( "BSGroupManagerGroupDeleted", array( $sGroup, 
&$result ) );
+               if( $result['success'] === false ) {
+                       return (object) $result;
+               }
+               $result['message'] = wfMessage( 'bs-groupmanager-grpremoved' 
)->plain();
+
+               // Create a log entry for the removal of the group
+               $oTitle = SpecialPage::getTitleFor( 'WikiAdmin' );
+               $oUser = RequestContext::getMain()->getUser();
+               $oLogger = new ManualLogEntry( 'bs-group-manager', 'remove' );
+               $oLogger->setPerformer( $oUser );
+               $oLogger->setTarget( $oTitle );
+               $oLogger->setParameters( array(
+                               '4::group' => $sGroup
+               ));
+               $oLogger->insert();
+
+               return (object) $result;
+       }
+
+       /**
+        * Returns an array of tasks and their required permissions
+        * array( 'taskname' => array('read', 'edit') )
+        * @return array
+        */
+       protected function getRequiredTaskPermissions() {
+               return array(
+                       'addGroup' => array( 'wikiadmin' ),
+                       'editGroup' => array( 'wikiadmin' ),
+                       'removeGroup' => array( 'wikiadmin' ),
+                       'removeGroups' => array( 'wikiadmin' ),
+               );
+       }
+}
\ No newline at end of file
diff --git a/GroupManager/resources/BS.GroupManager/Panel.js 
b/GroupManager/resources/BS.GroupManager/Panel.js
index 030b72f..2bcead3 100644
--- a/GroupManager/resources/BS.GroupManager/Panel.js
+++ b/GroupManager/resources/BS.GroupManager/Panel.js
@@ -16,23 +16,10 @@
 Ext.define( 'BS.GroupManager.Panel', {
        extend: 'BS.CRUDGridPanel',
        initComponent: function() {
-               this.strMain = Ext.create( 'Ext.data.JsonStore', {
-                       proxy: {
-                               type: 'ajax',
-                               url: bs.util.getAjaxDispatcherUrl( 
'GroupManager::getData' ),
-                               reader: {
-                                       type: 'json',
-                                       root: 'groups',
-                                       idProperty: 'group_name',
-                                       totalProperty: 'totalCount'
-                               }
-                       },
-                       autoLoad: true,
-                       fields: [ 'group_name', 'additional_group' ],
-                       sortInfo: {
-                               field: 'id',
-                               direction: 'ASC'
-                       }
+               this.strMain = Ext.create( 'BS.store.BSApi', {
+                       apiAction: 'bs-group-store',
+                       fields: ['group_name', 'additional_group'],
+                       submitValue: false
                });
 
                this.colGroupName = Ext.create( 'Ext.grid.column.Column', {
@@ -130,31 +117,40 @@
                }
 
                Ext.Ajax.request( {
-                       url: bs.util.getAjaxDispatcherUrl(
-                               'GroupManager::removeGroups',
-                               [ groupNames ]
-                       ),
+                       url: mw.util.wikiScript( 'api' ),
                        method: 'post',
                        scope: this,
+                       params: {
+                               action: 'bs-groupmanager',
+                               task: 'removeGroups',
+                               format: 'json',
+                               taskData: Ext.encode({
+                                       'groups': groupNames
+                               })
+                       },
                        success: function( response, opts ) {
                                var responseObj = Ext.decode( 
response.responseText );
-                               if ( Object.keys(responseObj).length === 
groupNames.length ) {
+                               if ( responseObj.success ) {
                                        this.renderMsgSuccess( responseObj );
                                } else {
-                                       var failureObj = {success: false, 
message: mw.message("bs-groupmanager-removeGroup-message-unknown").plain()};
-                                       this.renderMsgFailure( failureObj );
+                                       this.renderMsgFailure( responseObj );
                                }
                        }
                });
        },
        onDlgGroupAddOk: function( data, group ) {
                Ext.Ajax.request( {
-                       url: bs.util.getAjaxDispatcherUrl(
-                               'GroupManager::addGroup',
-                               [ group.group_name ]
-                       ),
+                       url: mw.util.wikiScript( 'api' ),
                        method: 'post',
                        scope: this,
+                       params: {
+                               action: 'bs-groupmanager',
+                               task: 'addGroup',
+                               format: 'json',
+                               taskData: Ext.encode({
+                                       'group': group.group_name
+                               })
+                       },
                        success: function( response, opts ) {
                                var responseObj = Ext.decode( 
response.responseText );
                                if ( responseObj.success === true ) {
@@ -169,15 +165,18 @@
        },
        onDlgUserEditOk: function( data, group ) {
                Ext.Ajax.request( {
-                       url: bs.util.getAjaxDispatcherUrl(
-                               'GroupManager::editGroup',
-                               [
-                                       group.group_name,
-                                       group.group_name_old
-                               ]
-                       ),
+                       url: mw.util.wikiScript( 'api' ),
                        method: 'post',
                        scope: this,
+                       params: {
+                               action: 'bs-groupmanager',
+                               task: 'editGroup',
+                               format: 'json',
+                               taskData: Ext.encode({
+                                       'group': group.group_name_old,
+                                       'newGroup': group.group_name
+                               })
+                       },
                        success: function( response, opts ) {
                                var responseObj = Ext.decode( 
response.responseText );
                                if ( responseObj.success === true ) {
diff --git a/UserManager/resources/BS.UserManager/dialog/User.js 
b/UserManager/resources/BS.UserManager/dialog/User.js
index 5b545b1..39826b2 100644
--- a/UserManager/resources/BS.UserManager/dialog/User.js
+++ b/UserManager/resources/BS.UserManager/dialog/User.js
@@ -62,7 +62,7 @@
                        labelWidth: 130,
                        labelAlign: 'right',
                        store: this.strGroups,
-                       valueField: 'group',
+                       valueField: 'group_name',
                        displayField: 'displayname',
                        maxHeight: 350
                } );
diff --git a/UserManager/resources/BS.UserManager/dialog/UserGroups.js 
b/UserManager/resources/BS.UserManager/dialog/UserGroups.js
index c82260d..2950cc0 100644
--- a/UserManager/resources/BS.UserManager/dialog/UserGroups.js
+++ b/UserManager/resources/BS.UserManager/dialog/UserGroups.js
@@ -27,7 +27,7 @@
                        labelWidth: 130,
                        labelAlign: 'right',
                        store: this.strGroups,
-                       valueField: 'group',
+                       valueField: 'group_name',
                        displayField: 'displayname',
                        maxHeight: 350
                } );
diff --git a/UserManager/resources/BS.UserManager/panel/Manager.js 
b/UserManager/resources/BS.UserManager/panel/Manager.js
index 242ff4f..390a0c0 100644
--- a/UserManager/resources/BS.UserManager/panel/Manager.js
+++ b/UserManager/resources/BS.UserManager/panel/Manager.js
@@ -38,24 +38,16 @@
                        }
                });
 
-               this.strGroups = Ext.create( 'Ext.data.JsonStore', {
-                       fields: [ 'group', 'displayname' ],
-                       proxy: {
-                               type: 'ajax',
-                               url: bs.util.getAjaxDispatcherUrl( 
'GroupManager::getGroups' ),
-                               reader: {
-                                       type: 'json',
-                                       root: 'groups',
-                                       idProperty: 'group'
-                               }
-                       },
-                       autoLoad: true
+               this.strGroups = Ext.create( 'BS.store.BSApi', {
+                       apiAction: 'bs-group-store',
+                       fields: ['group_name', 'additional_group', 
'displayname'],
+                       submitValue: false
                });
 
                this.strGroups.on( 'load', function( sender, records, 
successful, eOpts ){
                        for( var i = 0; i < records.length; i++ ) {
                                var record = records[i];
-                               record.set( 'id', record.get( 'group' ));
+                               record.set( 'id', record.get( 'group_name' ));
                                record.set( 'text', record.get( 'displayname' 
));
                        }
                }, this );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie67f0b860c688540664faae28c5675500ab338a5
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Pwirth <wi...@hallowelt.biz>
Gerrit-Reviewer: Dvogel hallowelt <daniel.vo...@hallowelt.com>
Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com>
Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to