diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-08-10 20:51:35 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-08-10 22:38:28 +0200 |
commit | f03874ac4994ac54816828a7e5d58570080c5bcf (patch) | |
tree | c57e9bb47514457005b6902c74ca64a6bc5cd766 /admin | |
parent | b54d790a873290e71654e94ac5072e87e6ba5427 (diff) | |
download | nextcloud-server-f03874ac4994ac54816828a7e5d58570080c5bcf.tar.gz nextcloud-server-f03874ac4994ac54816828a7e5d58570080c5bcf.zip |
work on user management
Diffstat (limited to 'admin')
-rw-r--r-- | admin/ajax/togglegroups.php | 4 | ||||
-rw-r--r-- | admin/apps.php | 13 | ||||
-rw-r--r-- | admin/css/users.css | 11 | ||||
-rw-r--r-- | admin/js/users.js | 110 | ||||
-rw-r--r-- | admin/templates/users.php | 54 | ||||
-rw-r--r-- | admin/users.php | 7 |
6 files changed, 89 insertions, 110 deletions
diff --git a/admin/ajax/togglegroups.php b/admin/ajax/togglegroups.php index 808e57dc9d6..1a0dc22be8e 100644 --- a/admin/ajax/togglegroups.php +++ b/admin/ajax/togglegroups.php @@ -19,6 +19,10 @@ $action = "add"; $username = $_POST["username"]; $group = $_POST["group"]; +if(!OC_Group::groupExists($group)){ + OC_Group::createGroup($group); +} + // Toggle group if( OC_Group::inGroup( $username, $group )){ $action = "remove"; diff --git a/admin/apps.php b/admin/apps.php index 83a48b65245..07e93728a39 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -33,11 +33,16 @@ OC_Util::addScript( "admin", "apps" ); $registeredApps=OC_App::getAllApps(); $apps=array(); + +$blacklist=array('files_imageviewer','files_textviewer');//we dont want to show configuration for these + foreach($registeredApps as $app){ - $info=OC_App::getAppInfo($app); - $active=(OC_Appconfig::getValue($app,'enabled','no')=='yes')?true:false; - $info['active']=$active; - $apps[]=$info; + if(array_search($app,$blacklist)===false){ + $info=OC_App::getAppInfo($app); + $active=(OC_Appconfig::getValue($app,'enabled','no')=='yes')?true:false; + $info['active']=$active; + $apps[]=$info; + } } $categories=OC_OCSClient::getCategories(); diff --git a/admin/css/users.css b/admin/css/users.css index 521217df4f4..27bd704c599 100644 --- a/admin/css/users.css +++ b/admin/css/users.css @@ -1,5 +1,6 @@ -form {display:inline} -td.remove>img,td.select>input{display:none;cursor:pointer} -td.select,td.remove{width:1em} -tr:hover>td.remove>img{display:inline} -li.selected{background-color:#ddd} +form { display:inline } +td.remove>img,td.select>input { display:none;cursor:pointer } +td.select,td.remove { width:1em } +tr:hover>td.remove>img { display:inline } +li.selected { background-color:#ddd } +#content>table { margin-top:6.5em } diff --git a/admin/js/users.js b/admin/js/users.js index 7e643fb60a2..7402255750f 100644 --- a/admin/js/users.js +++ b/admin/js/users.js @@ -1,5 +1,37 @@ $(document).ready(function(){ - $('select[multiple]').chosen(); + function applyMultiplySelect(element){ + var checked=[]; + var user=element.data('username') + 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('admin','ajax','togglegroups.php'), + { + username:user, + group:group + }, + function(){} + ); + } + }else{ + checkHandeler=false; + } + element.multiSelect({ + createText:'add group', + checked:checked, + oncheck:checkHandeler, + onuncheck:checkHandeler + }); + } + $('select[multiple]').each(function(index,element){ + applyMultiplySelect($(element)); + }); $('td.remove>img').live('click',function(event){ var uid=$(this).parent().parent().data('uid'); @@ -17,7 +49,7 @@ $(document).ready(function(){ event.preventDefault(); var username=$('#newusername').val(); var password=$('#newuserpassword').val(); - var groups=$('#newusergroups').val(); + var groups=$('#newusergroups').prev().children('div').data('settings').checked; $.post( OC.filePath('admin','ajax','createuser.php'), { @@ -29,72 +61,18 @@ $(document).ready(function(){ } ); - var tr=$('#rightcontent tr').first().clone(); + var tr=$('#content table tr').first().clone(); tr.attr('data-uid',username); tr.find('td.name').text(username); - tr.find('td.groups').text(groups.join(', ')); - $('#rightcontent tr').first().after(tr); - if(groups.indexOf($('#leftcontent li.selected').text().trim())!=-1){ - tr.find('td.select input').attr('checked','checked'); - } - }); - - $('#newgroup').submit(function(event){ - event.preventDefault(); - var name=$('#newgroupname').val(); - $.post( - OC.filePath('admin','ajax','creategroup.php'), - {groupname:name}, - function(result){ - - } - ); - $('#newusergroups').append('<option value="'+name+'">'+name+'</option>'); - $('select[multiple]').trigger("liszt:updated"); - var li=$('#leftcontent li').first().next().clone(); - li.text(name); - $('#leftcontent li').first().after(li); - }); - - $('#leftcontent li').live('click',function(event){ - $('#leftcontent li').removeClass('selected'); - $(this).addClass('selected'); - $('#rightcontent tr td.select input').show(); - $('#rightcontent tr td.select input').removeAttr('checked'); - var group=$(this).text().trim(); - var rows=$('#rightcontent tr').filter(function(i,tr){ - return ($(tr).children('td.groups').text().split(', ').indexOf(group)>-1); + var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">'); + select.data('username',username); + select.data('userGroups',groups.join(', ')); + tr.find('td.groups').empty(); + $.each($('#content table').data('groups').split(', '),function(i,group){ + select.append($('<option value="'+group+'">'+group+'</option>')); }); - rows.find('td.select input').attr('checked','checked'); - }); - $('#rightcontent tr td.select input').live('change',function(event){ - var group=$('#leftcontent li.selected').text().trim(); - var user=$(this).parent().parent().children('td.name').text().trim(); - if(group=='admin' && user==OC.currentUser){ - event.preventDefault(); - $(this).attr('checked','checked'); - return false; - } - if(group){ - $.post( - OC.filePath('admin','ajax','togglegroups.php'), - { - username:user, - group:group - }, - function(result){ - - } - ); - var groups=$(this).parent().parent().children('td.groups').text().trim().split(', '); - if(groups[0]=='') groups.pop(); - var index=groups.indexOf(group); - if(index==-1){ - groups.push(group); - }else{ - groups.splice(index,1); - } - $(this).parent().parent().children('td.groups').text(groups.join(', ')); - } + tr.find('td.groups').append(select); + applyMultiplySelect(select); + $('#content table tr').last().after(tr); }); }); diff --git a/admin/templates/users.php b/admin/templates/users.php index 00daf4c5263..63f512d4432 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -1,8 +1,4 @@ <div id="controls"> - <form id="newgroup"> - <input id="newgroupname" placeholder="<?php echo $l->t('Name')?>"></input> - <input type="submit" value="<?php echo $l->t('Create')?>"></input> - </form> <form id="newuser"> <input id="newusername" placeholder="<?php echo $l->t('Name')?>"></input> <input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>"></input> @@ -14,29 +10,29 @@ <input type="submit" value="<?php echo $l->t('Create')?>"></input> </form> </div> -<ul id="leftcontent"> - <?php foreach($_["groups"] as $group): ?> - <li data-gid="<?php echo $group["name"]; ?>"> - <?php echo $group["name"] ?> - </li> +<?php +$allGroups=array(); +foreach($_["groups"] as $group){ + $allGroups[]=$group['name']; +} +?> +<table data-groups="<?php echo implode(', ',$allGroups);?>"> + <?php foreach($_["users"] as $user): ?> + <tr data-uid="<?php echo $user["name"] ?>"> + <td class="select"><input type="checkbox"></input></td> + <td class="name"><?php echo $user["name"]; ?></td> + <td class="groups"> + <select data-username="<?php echo $user['name'] ;?>" data-user-groups="<?php echo $user['groups'] ;?>" data-placeholder="groups" title="<?php echo $l->t('Groups')?>" multiple="multiple"> + <?php foreach($_["groups"] as $group): ?> + <option value="<?php echo $group['name'];?>"><?php echo $group['name'];?></option> + <?php endforeach;?> + </select> + </td> + <td class="remove"> + <?php if($user['name']!=OC_User::getUser()):?> + <img alt="Remove" title="<?php echo $l->t('Remove')?>" class='svg' src='<?php echo image_path('core','actions/delete.svg') ?>'/> + <?php endif;?> + </td> + </tr> <?php endforeach; ?> -</ul> -<div id="rightcontent"> - <table> - <?php foreach($_["users"] as $user): ?> - <tr data-uid="<?php echo $user["name"] ?>"> - <td class="select"><input type="checkbox"></input></td> - <td class="name"><?php echo $user["name"]; ?></td> - <td class="groups"><?php if( $user["groups"] ){ echo $user["groups"]; }else{echo " ";} ?></td> - <td class="remove"> - <?php if($user['name']!=OC_User::getUser()):?> - <img alt="Remove" title="<?php echo $l->t('Remove')?>" class='svg' src='<?php echo image_path('core','actions/delete.svg') ?>'/> - <?php endif;?> - </td> - </tr> - <?php endforeach; ?> - </table> -</div> -<div id="#selecteduser"> - -</div> +</table> diff --git a/admin/users.php b/admin/users.php index 4a83510cb72..b120e10d437 100644 --- a/admin/users.php +++ b/admin/users.php @@ -38,12 +38,7 @@ $users = array(); $groups = array(); foreach( OC_User::getUsers() as $i ){ - // Do some more work here soon - $ingroups = array(); - foreach( OC_Group::getUserGroups( $i ) as $userGroup ){ - $ingroups[] = $userGroup; - } - $users[] = array( "name" => $i, "groups" => join( ", ", $ingroups )); + $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) )); } foreach( OC_Group::getGroups() as $i ){ |