summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-25 16:36:58 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-25 16:36:58 +0100
commitea8f71a19c59e7138d4a504bacc0beb410fc77e8 (patch)
tree5c4da1ddafb6d81feb90d3a70e927e59dc0a5e0d /settings
parent814bc2fd2bef739938716ae840a4db0de502422a (diff)
parent8b93a9a237603185501d0e24e9c08705168fc553 (diff)
downloadnextcloud-server-ea8f71a19c59e7138d4a504bacc0beb410fc77e8.tar.gz
nextcloud-server-ea8f71a19c59e7138d4a504bacc0beb410fc77e8.zip
Merge branch 'master' into encryption
Diffstat (limited to 'settings')
-rw-r--r--settings/ajax/setquota.php22
-rw-r--r--settings/css/settings.css10
-rw-r--r--settings/js/users.js116
-rw-r--r--settings/templates/users.php40
-rw-r--r--settings/users.php11
5 files changed, 145 insertions, 54 deletions
diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php
index d4e3c58ac11..dc87625a05d 100644
--- a/settings/ajax/setquota.php
+++ b/settings/ajax/setquota.php
@@ -5,14 +5,28 @@ require_once('../../lib/base.php');
OC_JSON::checkAdminUser();
-$username = $_POST["username"];
+$username = isset($_POST["username"])?$_POST["username"]:'';
//make sure the quota is in the expected format
-$quota= OC_Helper::computerFileSize($_POST["quota"]);
-$quota=OC_Helper::humanFileSize($quota);
+$quota=$_POST["quota"];
+if($quota!='none' and $quota!='default'){
+ $quota= OC_Helper::computerFileSize($quota);
+ if($quota==0){
+ $quota='default';
+ }else{
+ $quota=OC_Helper::humanFileSize($quota);
+ }
+}
// Return Success story
-OC_Preferences::setValue($username,'files','quota',$quota);
+if($username){
+ OC_Preferences::setValue($username,'files','quota',$quota);
+}else{//set the default quota when no username is specified
+ if($quota=='default'){//'default' as default quota makes no sense
+ $quota='none';
+ }
+ OC_Appconfig::setValue('files','default_quota',$quota);
+}
OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));
?>
diff --git a/settings/css/settings.css b/settings/css/settings.css
index 8d89cee6ec0..7a5873bb4d2 100644
--- a/settings/css/settings.css
+++ b/settings/css/settings.css
@@ -26,9 +26,15 @@ tr:hover>td.password>span { margin:0; cursor:pointer; }
tr:hover>td.remove>img, tr:hover>td.password>img, tr:hover>td.quota>img { visibility:visible; cursor:pointer; }
tr:hover>td.remove>img { float:right; }
li.selected { background-color:#ddd; }
-#content>table:not(.nostyle) { margin-top:6.5em; }
+#content>table:not(.nostyle) { margin-top:3em; }
table:not(.nostyle) { width:100%; }
-
+#rightcontent { padding-left: 1em; }
+td.quota { position:relative }
+div.quota { float:right; display:block; position:absolute; right:25em; top:0; }
+select.quota { position:absolute; left:0; top:0; width:10em; }
+input.quota-other { display:none; position:absolute; left:0.1em; top:0.1em; width:7em; border:none; -webkit-box-shadow: none -mox-box-shadow:none ; box-shadow:none; }
+div.quota>span { position:absolute; right:0em; white-space:nowrap; top: 0.7em }
+select.quota.active { background: #fff; }
/* APPS */
li { color:#888; }
diff --git a/settings/js/users.js b/settings/js/users.js
index c9b1d855db0..eed93d3b303 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -5,6 +5,18 @@
*/
$(document).ready(function(){
+ function setQuota(uid,quota,ready){
+ $.post(
+ OC.filePath('settings','ajax','setquota.php'),
+ {username:uid,quota:quota},
+ function(result){
+ if(ready){
+ ready(result.data.quota);
+ }
+ }
+ );
+ }
+
function applyMultiplySelect(element){
var checked=[];
var user=element.data('username');
@@ -82,48 +94,66 @@ $(document).ready(function(){
$('td.password').live('click',function(event){
$(this).children('img').click();
});
-
- $('td.quota>img').live('click',function(event){
- event.stopPropagation();
- var img=$(this);
- var uid=img.parent().parent().data('uid');
- var input=$('<input>');
- var quota=img.parent().children('span').text();
- if(quota=='None'){
- quota='';
+
+ $('select.quota').live('change',function(){
+ var select=$(this);
+ var uid=$(this).parent().parent().data('uid');
+ var quota=$(this).val();
+ var other=$(this).next();
+ if(quota!='other'){
+ other.hide();
+ select.data('previous',quota);
+ setQuota(uid,quota);
+ }else{
+ other.show();
+ select.addClass('active');
+ other.focus();
}
- input.val(quota);
- img.css('display','none');
- img.parent().children('span').replaceWith(input);
- input.focus();
- input.keypress(function(event) {
- if(event.keyCode == 13) {
- $(this).parent().attr('data-quota',$(this).val());
- if($(this).val().length>0){
- $.post(
- OC.filePath('settings','ajax','setquota.php'),
- {username:uid,quota:$(this).val()},
- function(result){
- img.parent().children('span').text(result.data.quota)
- $(this).parent().attr('data-quota',result.data.quota);
- }
- );
- input.blur();
+ });
+ $('select.quota').each(function(i,select){
+ $(select).data('previous',$(select).val());
+ })
+
+ $('input.quota-other').live('change',function(){
+ var uid=$(this).parent().parent().data('uid');
+ var quota=$(this).val();
+ var select=$(this).prev();
+ var other=$(this);
+ if(quota){
+ setQuota(uid,quota,function(quota){
+ select.children().attr('selected',null);
+ var existingOption=select.children().filter(function(i,option){
+ return ($(option).val()==quota);
+ });
+ if(existingOption.length){
+ existingOption.attr('selected','selected');
}else{
- input.blur();
+ var option=$('<option/>');
+ option.attr('selected','selected').attr('value',quota).text(quota);
+ select.children().last().before(option);
}
- }
- });
- input.blur(function(){
- var quota=$(this).parent().attr('data-quota');
- $(this).replaceWith($('<span>'+quota+'</span>'));
- img.css('display','');
- });
- });
- $('td.quota').live('click',function(event){
- $(this).children('img').click();
+ select.val(quota);
+ select.removeClass('active');
+ other.val(null);
+ other.hide();
+ });
+ }else{
+ var previous=select.data('previous');
+ select.children().attr('selected',null);
+ select.children().each(function(i,option){
+ if($(option).val()==previous){
+ $(option).attr('selected','selected');
+ }
+ });
+ select.removeClass('active');
+ other.hide();
+ }
});
+ $('input.quota-other').live('blur',function(){
+ $(this).change();
+ })
+
$('#newuser').submit(function(event){
event.preventDefault();
var username=$('#newusername').val();
@@ -157,7 +187,13 @@ $(document).ready(function(){
select.data('username',username);
select.data('userGroups',groups.join(', '));
tr.find('td.groups').empty();
- $.each($('#content table').data('groups').split(', '),function(i,group){
+ var allGroups=$('#content table').data('groups').split(', ');
+ for(var i=0;i<groups.length;i++){
+ if(allGroups.indexOf(groups[i])==-1){
+ allGroups.push(groups[i]);
+ }
+ }
+ $.each(allGroups,function(i,group){
select.append($('<option value="'+group+'">'+group+'</option>'));
});
tr.find('td.groups').append(select);
@@ -166,5 +202,9 @@ $(document).ready(function(){
}
applyMultiplySelect(select);
$('#content table tbody').last().after(tr);
+
+ tr.find('select.quota option').attr('selected',null);
+ tr.find('select.quota option').first().attr('selected','selected');
+ tr.find('select.quota').data('previous','default');
});
});
diff --git a/settings/templates/users.php b/settings/templates/users.php
index bcc4d65fe43..a23a5bafe61 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -12,16 +12,30 @@ foreach($_["groups"] as $group) {
<div id="controls">
<form id="newuser">
- <th class="name"><input id="newusername" placeholder="<?php echo $l->t('Name')?>" /></th>
- <th class="password"><input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>" /></th>
- <th class="groups"><select id="newusergroups" data-placeholder="groups" title="<?php echo $l->t('Groups')?>" multiple="multiple">
+ <input id="newusername" placeholder="<?php echo $l->t('Name')?>" />
+ <input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>" />
+ <select id="newusergroups" 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></th>
- <th class="quota"></th>
- <th><input type="submit" value="<?php echo $l->t('Create')?>" /></th>
+ </select>
+ <input type="submit" value="<?php echo $l->t('Create')?>" />
</form>
+ <div class="quota">
+ <span><?php echo $l->t('Default Quota');?>:</span>
+ <select class='quota'>
+ <?php foreach($_['quota_preset'] as $preset):?>
+ <?php if($preset!='default'):?>
+ <option <?php if($_['default_quota']==$preset) echo 'selected="selected"';?> value='<?php echo $preset;?>'><?php echo $preset;?></option>
+ <?php endif;?>
+ <?php endforeach;?>
+ <?php if(array_search($_['default_quota'],$_['quota_preset'])===false):?>
+ <option selected="selected" value='<?php echo $_['default_quota'];?>'><?php echo $_['default_quota'];?></option>
+ <?php endif;?>
+ <option value='other'><?php echo $l->t('Other');?>...</option>
+ </select>
+ <input class='quota-other'></input>
+ </div>
</div>
<table data-groups="<?php echo implode(', ',$allGroups);?>">
@@ -49,9 +63,17 @@ foreach($_["groups"] as $group) {
<?php endforeach;?>
</select>
</td>
- <td class="quota" data-quota="<?php echo $user['quota']?>">
- <span><?php echo ($user['quota']>0)?$user['quota']:'None';?></span>
- <img class="svg action" src="<?php echo image_path('core','actions/rename.svg')?>" alt="set new password" title="set quota" />
+ <td class="quota">
+ <select class='quota'>
+ <?php foreach($_['quota_preset'] as $preset):?>
+ <option <?php if($user['quota']==$preset) echo 'selected="selected"';?> value='<?php echo $preset;?>'><?php echo $preset;?></option>
+ <?php endforeach;?>
+ <?php if(array_search($user['quota'],$_['quota_preset'])===false):?>
+ <option selected="selected" value='<?php echo $user['quota'];?>'><?php echo $user['quota'];?></option>
+ <?php endif;?>
+ <option value='other'><?php echo $l->t('Other');?>...</option>
+ </select>
+ <input class='quota-other'></input>
</td>
<td class="remove">
<?php if($user['name']!=OC_User::getUser()):?>
diff --git a/settings/users.php b/settings/users.php
index e5dcc049481..96515a90ce4 100644
--- a/settings/users.php
+++ b/settings/users.php
@@ -18,17 +18,26 @@ $users = array();
$groups = array();
foreach( OC_User::getUsers() as $i ){
- $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota',0));
+ $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota','default'));
}
foreach( OC_Group::getGroups() as $i ){
// Do some more work here soon
$groups[] = array( "name" => $i );
}
+$quotaPreset=OC_Appconfig::getValue('files','quota_preset','default,none,1 GB, 5 GB, 10 GB');
+$quotaPreset=explode(',',$quotaPreset);
+foreach($quotaPreset as &$preset){
+ $preset=trim($preset);
+}
+
+$defaultQuota=OC_Appconfig::getValue('files','default_quota','none');
$tmpl = new OC_Template( "settings", "users", "user" );
$tmpl->assign( "users", $users );
$tmpl->assign( "groups", $groups );
+$tmpl->assign( 'quota_preset', $quotaPreset);
+$tmpl->assign( 'default_quota', $defaultQuota);
$tmpl->printPage();
?>