setquota.php 1006 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. OCP\JSON::callCheck();
  11. $username = isset($_POST["username"])?$_POST["username"]:'';
  12. //make sure the quota is in the expected format
  13. $quota=$_POST["quota"];
  14. if($quota!='none' and $quota!='default'){
  15. $quota= OC_Helper::computerFileSize($quota);
  16. if($quota==0){
  17. $quota='default';
  18. }else{
  19. $quota=OC_Helper::humanFileSize($quota);
  20. }
  21. }
  22. // Return Success story
  23. if($username){
  24. OC_Preferences::setValue($username,'files','quota',$quota);
  25. }else{//set the default quota when no username is specified
  26. if($quota=='default'){//'default' as default quota makes no sense
  27. $quota='none';
  28. }
  29. OC_Appconfig::setValue('files','default_quota',$quota);
  30. }
  31. OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));