summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-07-15 16:31:28 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-07-15 16:31:28 +0200
commite707e948577b927a28b86545d345e7b6c8606352 (patch)
treedf7f5a1705e1ee4815f28f0d864b97026a32f849 /settings/js
parent0cb9f5e159b1588550830dda4b21010a0412bae9 (diff)
downloadnextcloud-server-e707e948577b927a28b86545d345e7b6c8606352.tar.gz
nextcloud-server-e707e948577b927a28b86545d345e7b6c8606352.zip
subadmins can now add users
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/users.js89
1 files changed, 65 insertions, 24 deletions
diff --git a/settings/js/users.js b/settings/js/users.js
index dfa28e4c4cb..c86949db384 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -84,18 +84,56 @@ $(document).ready(function(){
}
function applyMultiplySelect(element){
+ console.log(element);
var checked=[];
var user=element.data('username');
- if(element.data('userGroups')){
- checked=element.data('userGroups').split(', ');
+ if($(element).attr('class') == 'groupsselect'){
+ if(element.data('userGroups')){
+ checked=element.data('userGroups').split(', ');
+ }
+ if(user){
+ var checkHandeler=function(group){
+ if(user==OC.currentUser && group=='admin'){
+ return false;
+ }
+ $.post(
+ OC.filePath('settings','ajax','togglegroups.php'),
+ {
+ username:user,
+ group:group
+ },
+ function(){}
+ );
+ };
+ }else{
+ checkHandeler=false;
+ }
+ var addGroup = function(group) {
+ $('select[multiple]').each(function(index, element) {
+ if ($(element).find('option[value="'+group +'"]').length == 0) {
+ $(element).append('<option value="'+group+'">'+group+'</option>');
+ }
+ })
+ };
+ element.multiSelect({
+ createCallback:addGroup,
+ createText:'add group',
+ checked:checked,
+ oncheck:checkHandeler,
+ onuncheck:checkHandeler,
+ minWidth: 100,
+ });
}
- if(user){
+ if($(element).attr('class') == 'subadminsselect'){
+ if(element.data('subadmin')){
+ checked=element.data('subadmin').split(', ');
+ }
var checkHandeler=function(group){
- if(user==OC.currentUser && group=='admin'){
+ if(group=='admin'){
return false;
}
$.post(
- OC.filePath('settings','ajax','togglegroups.php'),
+ OC.filePath('settings','ajax','togglesubadmins.php'),
{
username:user,
group:group
@@ -103,24 +141,25 @@ $(document).ready(function(){
function(){}
);
};
- }else{
- checkHandeler=false;
+
+ var addSubAdmin = function(group) {
+ console.log('addSubAdmin called');
+ console.log(group);
+ $('select[multiple]').each(function(index, element) {
+ if ($(element).find('option[value="'+group +'"]').length == 0) {
+ $(element).append('<option value="'+group+'">'+group+'</option>');
+ }
+ })
+ };
+ element.multiSelect({
+ createCallback:addSubAdmin,
+ createText:null,
+ checked:checked,
+ oncheck:checkHandeler,
+ onuncheck:checkHandeler,
+ minWidth: 100,
+ });
}
- var addGroup = function(group) {
- $('select[multiple]').each(function(index, element) {
- if ($(element).find('option[value="'+group +'"]').length == 0) {
- $(element).append('<option value="'+group+'">'+group+'</option>');
- }
- })
- };
- element.multiSelect({
- createCallback:addGroup,
- createText:'add group',
- checked:checked,
- oncheck:checkHandeler,
- onuncheck:checkHandeler,
- minWidth: 100,
- });
}
$('select[multiple]').each(function(index,element){
applyMultiplySelect($(element));
@@ -255,12 +294,14 @@ $(document).ready(function(){
OC.dialogs.alert(result.data.message, 'Error creating user');
}
else {
+ groups = result.data.groups;
+ console.log(groups);
var tr=$('#content table tbody tr').first().clone();
tr.attr('data-uid',username);
tr.find('td.name').text(username);
- var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">');
+ var select=$('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="Groups">');
select.data('username',username);
- select.data('userGroups',groups.join(', '));
+ select.data('userGroups',groups);
tr.find('td.groups').empty();
var allGroups=$('#content table').data('groups').split(', ');
for(var i=0;i<groups.length;i++){