diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index 0695f0def..a121bd7ec 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -25,6 +25,11 @@ class PluploadController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'css/plupload.queue.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']); + + $this->view->quotaLimitReached = false; + if (Application_Model_Preference::getDiskUsage() > Application_Model_Preference::getDiskQuota()) { + $this->view->quotaLimitReached = true; + } } public function recentUploadsAction() diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index ad8cada08..ffe09ba89 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -110,7 +110,7 @@ class Rest_MediaController extends Zend_Rest_Controller { return; } - + //If we do get an ID on a POST, then that doesn't make any sense //since POST is only for creating. if ($id = $this->_getParam('id', false)) { @@ -120,6 +120,13 @@ class Rest_MediaController extends Zend_Rest_Controller return; } + if (!$this->isEnoughDiskSpace()) { + $this->getResponse() + ->setHttpResponseCode(400) + ->appendBody("ERROR: Disk Quota limit reached."); + return; + } + $file = new CcFiles(); $whiteList = $this->removeBlacklistedFieldsFromRequestData($this->getRequest()->getPost()); @@ -423,5 +430,19 @@ class Rest_MediaController extends Zend_Rest_Controller return $response; } + /** + * + * Checks if there is enough disk space to upload the file in question + * We allow one file to exceed to the disk quota so it is possible for the + * disk usage to be greater than the disk usage value + */ + private function isEnoughDiskSpace() + { + if (Application_Model_Preference::getDiskUsage() < Application_Model_Preference::GetDiskQuota()) { + return true; + } + return false; + } + } diff --git a/airtime_mvc/application/views/scripts/plupload/index.phtml b/airtime_mvc/application/views/scripts/plupload/index.phtml index 4eec76438..bd25abe61 100644 --- a/airtime_mvc/application/views/scripts/plupload/index.phtml +++ b/airtime_mvc/application/views/scripts/plupload/index.phtml @@ -2,8 +2,15 @@ #plupload_files input[type="file"] { font-size: 200px !important; } - -