diff options
author | Owen Winkler <epithet@gmail.com> | 2013-08-15 06:19:40 -0400 |
---|---|---|
committer | Owen Winkler <epithet@gmail.com> | 2013-08-15 06:19:40 -0400 |
commit | cd7e57e8ec64ffef8faec750ebffbdc6138ec9a0 (patch) | |
tree | f567c89a4f75d9ebdf25dc9f6a508af3993460f1 /settings | |
parent | 75e9015b5445e957f2454373bed67dac1741b5cb (diff) | |
download | nextcloud-server-cd7e57e8ec64ffef8faec750ebffbdc6138ec9a0.tar.gz nextcloud-server-cd7e57e8ec64ffef8faec750ebffbdc6138ec9a0.zip |
Use JSON to send/receive group data.
Squashed commits from PR #4364 for master.
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/createuser.php | 2 | ||||
-rw-r--r-- | settings/js/users.js | 21 | ||||
-rw-r--r-- | settings/templates/users.php | 6 | ||||
-rw-r--r-- | settings/users.php | 15 |
4 files changed, 22 insertions, 22 deletions
diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index 205958f88d3..ccc2a5d402e 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -41,7 +41,7 @@ try { OC_JSON::success(array("data" => array( "username" => $username, - "groups" => implode( ", ", OC_Group::getUserGroups( $username ))))); + "groups" => OC_Group::getUserGroups( $username )))); } catch (Exception $exception) { OC_JSON::error(array("data" => array( "message" => $exception->getMessage()))); } diff --git a/settings/js/users.js b/settings/js/users.js index 6a8afc4ca36..948849fe539 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -89,10 +89,10 @@ var UserList = { tr.attr('data-displayName', displayname); tr.find('td.name').text(username); tr.find('td.displayName > span').text(displayname); - var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="' + t('settings', 'Groups') + '"></select>').attr('data-username', username).attr('data-user-groups', groups); + var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="' + t('settings', 'Groups') + '"></select>').attr('data-username', username).attr('data-user-groups', [groups]); tr.find('td.groups').empty(); if (tr.find('td.subadmins').length > 0) { - var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('settings', 'Group Admin') + '">').attr('data-username', username).attr('data-user-groups', groups).attr('data-subadmin', subadmin); + var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('settings', 'Group Admin') + '">').attr('data-username', username).attr('data-user-groups', [groups]).attr('data-subadmin', [subadmin]); tr.find('td.subadmins').empty(); } $.each(this.availableGroups, function (i, group) { @@ -227,7 +227,7 @@ var UserList = { var user = element.attr('data-username'); if ($(element).attr('class') === 'groupsselect') { if (element.data('userGroups')) { - checked = String(element.data('userGroups')).split(', '); + checked = element.data('userGroups'); } if (user) { var checkHandeler = function (group) { @@ -244,11 +244,10 @@ var UserList = { group: group }, function (response) { - if(response.status === 'success') { - if(UserList.availableGroups.indexOf(response.data.groupname) === -1 && response.data.action === 'add') { - UserList.availableGroups.push(response.data.groupname); - } - } else { + if(response.status === 'success' && UserList.availableGroups.indexOf(response.data.groupname) === -1 && response.data.action === 'add') { + UserList.availableGroups.push(response.data.groupname); + } + if(response.data.message) { OC.Notification.show(response.data.message); } } @@ -282,7 +281,7 @@ var UserList = { } if ($(element).attr('class') === 'subadminsselect') { if (element.data('subadmin')) { - checked = String(element.data('subadmin')).split(', '); + checked = element.data('subadmin'); } var checkHandeler = function (group) { if (group === 'admin') { @@ -321,7 +320,7 @@ var UserList = { $(document).ready(function () { UserList.doSort(); - UserList.availableGroups = $('#content table').attr('data-groups').split(', '); + UserList.availableGroups = $('#content table').data('groups'); $('tbody tr:last').bind('inview', function (event, isInView, visiblePartX, visiblePartY) { OC.Router.registerLoadedCallback(function () { UserList.update(); @@ -450,7 +449,7 @@ $(document).ready(function () { t('settings', 'Error creating user')); } else { if (result.data.groups) { - var addedGroups = result.data.groups.split(', '); + var addedGroups = result.data.groups; UserList.availableGroups = $.unique($.merge(UserList.availableGroups, addedGroups)); } if($('tr[data-uid="' + username + '"]').length === 0) { diff --git a/settings/templates/users.php b/settings/templates/users.php index 4ddef3ff1b5..22450fdf25f 100644 --- a/settings/templates/users.php +++ b/settings/templates/users.php @@ -78,7 +78,7 @@ $_['subadmingroups'] = array_flip($items); </div> </div> -<table class="hascontrols" data-groups="<?php p(implode(', ', $allGroups));?>"> +<table class="hascontrols" data-groups="<?php p(json_encode($allGroups));?>"> <thead> <tr> <th id='headerName'><?php p($l->t('Username'))?></th> @@ -108,7 +108,7 @@ $_['subadmingroups'] = array_flip($items); <td class="groups"><select class="groupsselect" data-username="<?php p($user['name']) ;?>" - data-user-groups="<?php p($user['groups']) ;?>" + data-user-groups="<?php p(json_encode($user['groups'])) ;?>" data-placeholder="groups" title="<?php p($l->t('Groups'))?>" multiple="multiple"> <?php foreach($_["groups"] as $group): ?> @@ -120,7 +120,7 @@ $_['subadmingroups'] = array_flip($items); <td class="subadmins"><select class="subadminsselect" data-username="<?php p($user['name']) ;?>" - data-subadmin="<?php p($user['subadmin']);?>" + data-subadmin="<?php p(json_encode($user['subadmin']));?>" data-placeholder="subadmins" title="<?php p($l->t('Group Admin'))?>" multiple="multiple"> <?php foreach($_["subadmingroups"] as $group): ?> diff --git a/settings/users.php b/settings/users.php index ba79ae93b28..213d1eecfda 100644 --- a/settings/users.php +++ b/settings/users.php @@ -54,15 +54,16 @@ foreach($accessibleusers as $uid => $displayName) { $name = $displayName; if ( $displayName !== $uid ) { $name = $name . ' ('.$uid.')'; - } - + } + $users[] = array( "name" => $uid, - "displayName" => $displayName, - "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($uid)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/), - 'quota'=>$quota, - 'isQuotaUserDefined'=>$isQuotaUserDefined, - 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($uid))); + "displayName" => $displayName, + "groups" => OC_Group::getUserGroups($uid), + 'quota' => $quota, + 'isQuotaUserDefined' => $isQuotaUserDefined, + 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid), + ); } foreach( $accessiblegroups as $i ) { |