diff options
author | Morris Jobke <morris.jobke@gmail.com> | 2013-08-20 02:49:48 -0700 |
---|---|---|
committer | Morris Jobke <morris.jobke@gmail.com> | 2013-08-20 02:49:48 -0700 |
commit | de949b1caa4491a8016ed5e609fc781526fea54d (patch) | |
tree | b7e5aee0542b7fee87fbd3f335392edcd0807b25 /settings | |
parent | 884c6b5a82fb13c8f2b4fd029b5a16d41e5fc602 (diff) | |
parent | 9840363488cc22e5e71e33735a390d6751c956eb (diff) | |
download | nextcloud-server-de949b1caa4491a8016ed5e609fc781526fea54d.tar.gz nextcloud-server-de949b1caa4491a8016ed5e609fc781526fea54d.zip |
Merge pull request #4447 from owncloud/fix_4351_master
Use JSON to send/receive group data.
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/createuser.php | 2 | ||||
-rw-r--r-- | settings/js/users.js | 28 | ||||
-rw-r--r-- | settings/templates/users.php | 6 | ||||
-rw-r--r-- | settings/users.php | 15 |
4 files changed, 29 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..038ea369801 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -89,10 +89,15 @@ 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 +232,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 +249,12 @@ 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 +288,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 +327,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 +456,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 ) { |