add option to set user quota
This commit is contained in:
parent
6173c0fbc2
commit
523b0966d2
|
@ -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)));
|
||||
|
||||
?>
|
|
@ -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();
|
||||
|
|
|
@ -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') ?>" />
|
||||
|
|
|
@ -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 ){
|
||||
|
|
Loading…
Reference in New Issue