aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--settings/ajax/setquota.php22
-rw-r--r--settings/js/users.js39
-rw-r--r--settings/templates/users.php4
-rw-r--r--settings/users.php2
4 files changed, 66 insertions, 1 deletions
diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php
new file mode 100644
index 00000000000..244a85e3d9c
--- /dev/null
+++ b/settings/ajax/setquota.php
@@ -0,0 +1,22 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+// We send json data
+header( "Content-Type: application/jsonrequest" );
+
+// Check if we are a user
+if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+$username = $_POST["username"];
+$quota= OC_Helper::computerFileSize($_POST["quota"]);
+
+// Return Success story
+OC_Preferences::setValue($username,'files','quota',$quota);
+echo json_encode( array( "status" => "success", "data" => array( "username" => $username ,'quota'=>$quota)));
+
+?>
diff --git a/settings/js/users.js b/settings/js/users.js
index bc1b8fc3ed0..3122f5614c7 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -75,6 +75,45 @@ $(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();
+ img
+ if(quota=='None'){
+ quota='';
+ }
+ 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){}
+ );
+ input.blur();
+ }else{
+ input.blur();
+ }
+ }
+ });
+ input.blur(function(){
+ var quota=$(this).parent().data('quota');
+ $(this).replaceWith($('<span>'+quota+'</span>'));
+ img.css('display','');
+ });
+ });
+ $('td.quota').live('click',function(event){
+ $(this).children('img').click();
+ });
$('#newuser').submit(function(event){
event.preventDefault();
diff --git a/settings/templates/users.php b/settings/templates/users.php
index 01e2adf4e97..9733c3e9a50 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -31,6 +31,10 @@ 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>
<td class="remove">
<?php if($user['name']!=OC_User::getUser()):?>
<img alt="Delete" title="<?php echo $l->t('Delete')?>" class="svg action" src="<?php echo image_path('core','actions/delete.svg') ?>" />
diff --git a/settings/users.php b/settings/users.php
index cd7d04a55e7..8bf64e16fff 100644
--- a/settings/users.php
+++ b/settings/users.php
@@ -38,7 +38,7 @@ $users = array();
$groups = array();
foreach( OC_User::getUsers() as $i ){
- $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ));
+ $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Helper::humanFileSize(OC_Preferences::getValue($i,'files','quota',0)));
}
foreach( OC_Group::getGroups() as $i ){