setquota.php 986 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright (c) 2012, Robin Appelman <icewind1991@gmail.com>
  4. * This file is licensed under the Affero General Public License version 3 or later.
  5. * See the COPYING-README file.
  6. */
  7. // Init owncloud
  8. require_once('../../lib/base.php');
  9. OC_JSON::checkAdminUser();
  10. $username = isset($_POST["username"])?$_POST["username"]:'';
  11. //make sure the quota is in the expected format
  12. $quota=$_POST["quota"];
  13. if($quota!='none' and $quota!='default'){
  14. $quota= OC_Helper::computerFileSize($quota);
  15. if($quota==0){
  16. $quota='default';
  17. }else{
  18. $quota=OC_Helper::humanFileSize($quota);
  19. }
  20. }
  21. // Return Success story
  22. if($username){
  23. OC_Preferences::setValue($username,'files','quota',$quota);
  24. }else{//set the default quota when no username is specified
  25. if($quota=='default'){//'default' as default quota makes no sense
  26. $quota='none';
  27. }
  28. OC_Appconfig::setValue('files','default_quota',$quota);
  29. }
  30. OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));
  31. ?>