From c23957811d31812cc9193eae0c83f6d7648b971b Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 8 Dec 2014 16:35:13 +0100 Subject: [PATCH] React on other statuscodes than 200 --- settings/controller/groupscontroller.php | 10 +-- settings/controller/userscontroller.php | 14 ++--- settings/js/users/groups.js | 27 ++++---- settings/js/users/users.js | 61 +++++++++---------- .../controller/groupscontrollertest.php | 8 +-- .../controller/userscontrollertest.php | 23 +++---- 6 files changed, 54 insertions(+), 89 deletions(-) diff --git a/settings/controller/groupscontroller.php b/settings/controller/groupscontroller.php index 8236d5507f..82e72821c3 100644 --- a/settings/controller/groupscontroller.php +++ b/settings/controller/groupscontroller.php @@ -82,10 +82,7 @@ class GroupsController extends Controller { if($this->groupManager->groupExists($id)) { return new DataResponse( array( - 'status' => 'error', - 'data' => array( - 'message' => (string)$this->l10n->t('Group already exists.') - ) + 'message' => (string)$this->l10n->t('Group already exists.') ), Http::STATUS_CONFLICT ); @@ -93,10 +90,7 @@ class GroupsController extends Controller { if($this->groupManager->createGroup($id)) { return new DataResponse( array( - 'status' => 'success', - 'data' => array( - 'groupname' => $id - ) + 'groupname' => $id ), Http::STATUS_CREATED ); diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php index aa16574221..5bd4b55510 100644 --- a/settings/controller/userscontroller.php +++ b/settings/controller/userscontroller.php @@ -161,10 +161,7 @@ class UsersController extends Controller { } catch (\Exception $exception) { return new DataResponse( array( - 'status' => 'error', - 'data' => array( - 'message' => (string)$this->l10n->t('Unable to create user.') - ) + 'message' => (string)$this->l10n->t('Unable to create user.') ), Http::STATUS_FORBIDDEN ); @@ -183,12 +180,9 @@ class UsersController extends Controller { return new DataResponse( array( - 'status' => 'success', - 'data' => array( - 'username' => $username, - 'groups' => $this->groupManager->getUserGroupIds($user), - 'storageLocation' => $user->getHome() - ) + 'username' => $username, + 'groups' => $this->groupManager->getUserGroupIds($user), + 'storageLocation' => $user->getHome() ), Http::STATUS_CREATED ); diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js index 40872785e3..c06bc5ff14 100644 --- a/settings/js/users/groups.js +++ b/settings/js/users/groups.js @@ -89,24 +89,19 @@ GroupList = { id: groupname }, function (result) { - if (result.status !== 'success') { - OC.dialogs.alert(result.data.message, - t('settings', 'Error creating group')); - } - else { - if (result.data.groupname) { - var addedGroup = result.data.groupname; - UserList.availableGroups = $.unique($.merge(UserList.availableGroups, [addedGroup])); - GroupList.addGroup(result.data.groupname); + if (result.groupname) { + var addedGroup = result.groupname; + UserList.availableGroups = $.unique($.merge(UserList.availableGroups, [addedGroup])); + GroupList.addGroup(result.groupname); - $('.groupsselect, .subadminsselect') - .append($('