diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index c3fa239e9..7c808140c 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -27,10 +27,9 @@ class PluploadController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']); $this->view->quotaLimitReached = false; - // temporarily disabling disk quota until all file size values have been set - /*if (Application_Model_Systemstatus::isDiskOverQuota()) { + if (Application_Model_Systemstatus::isDiskOverQuota()) { $this->view->quotaLimitReached = true; - }*/ + } //Because uploads are done via AJAX (and we're not using Zend form for those), we manually add the CSRF //token in here. diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php index c9748467b..9af3dc1e9 100644 --- a/airtime_mvc/application/controllers/UpgradeController.php +++ b/airtime_mvc/application/controllers/UpgradeController.php @@ -19,6 +19,7 @@ class UpgradeController extends Zend_Controller_Action array_push($upgraders, new AirtimeUpgrader255()); array_push($upgraders, new AirtimeUpgrader259()); array_push($upgraders, new AirtimeUpgrader2510()); + array_push($upgraders, new AirtimeUpgrader2511()); $didWePerformAnUpgrade = false; try diff --git a/airtime_mvc/application/models/airtime/CcFiles.php b/airtime_mvc/application/models/airtime/CcFiles.php index 71e5f2ca6..029d21a15 100644 --- a/airtime_mvc/application/models/airtime/CcFiles.php +++ b/airtime_mvc/application/models/airtime/CcFiles.php @@ -78,11 +78,9 @@ class CcFiles extends BaseCcFiles { */ public static function createFromUpload($fileArray) { - /*temporarily disabling disk quota until all file sizes have ben set in the database. if (Application_Model_Systemstatus::isDiskOverQuota()) { throw new OverDiskQuotaException(); } - */ /* If full_path is set, the post request came from ftp. * Users are allowed to upload folders via ftp. If this is the case diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index acb0eeed7..6a2cccd63 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -14,15 +14,33 @@ class Rest_MediaController extends Zend_Rest_Controller public function indexAction() { + $totalFileCount = CcFilesQuery::create()->count(); + + // Check if offset and limit were sent with request. + // Default limit to zero and offset to $totalFileCount + $offset = $this->_getParam('offset', 0); + $limit = $this->_getParam('limit', $totalFileCount); + + $query = CcFilesQuery::create() + ->filterByDbHidden(false) + ->filterByDbFileExists(true) + ->filterByDbImportStatus(0) + ->setLimit($limit) + ->setOffset($offset) + ->orderByDbId(); + $queryCount = $query->count(); + $queryResult = $query->find(); + $files_array = array(); - foreach (CcFilesQuery::create()->find() as $file) + foreach ($queryResult as $file) { array_push($files_array, CcFiles::sanitizeResponse($file)); } - + $this->getResponse() - ->setHttpResponseCode(200) - ->appendBody(json_encode($files_array)); + ->setHttpResponseCode(200) + ->setHeader('X-TOTAL-COUNT', $queryCount) + ->appendBody(json_encode($files_array)); /** TODO: Use this simpler code instead after we upgrade to Propel 1.7 (Airtime 2.6.x branch): $this->getResponse() diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php index 74b9a6d4d..31c602437 100644 --- a/airtime_mvc/application/upgrade/Upgrades.php +++ b/airtime_mvc/application/upgrade/Upgrades.php @@ -341,3 +341,44 @@ class AirtimeUpgrader2510 extends AirtimeUpgrader } } } + +class AirtimeUpgrader2511 extends AirtimeUpgrader +{ + protected function getSupportedVersions() { + return array ( + '2.5.10' + ); + } + + public function getNewVersion() { + return '2.5.11'; + } + + public function upgrade($dir = __DIR__) { + Cache::clear(); + assert($this->checkIfUpgradeSupported()); + + $newVersion = $this->getNewVersion(); + + try { + $this->toggleMaintenanceScreen(true); + Cache::clear(); + + // Begin upgrade + $queryResult = CcFilesQuery::create() + ->select(array('disk_usage')) + ->withColumn('SUM(CcFiles.filesize)', 'disk_usage') + ->find(); + $disk_usage = $queryResult[0]; + Application_Model_Preference::setDiskUsage($disk_usage); + + Application_Model_Preference::SetAirtimeVersion($newVersion); + Cache::clear(); + + $this->toggleMaintenanceScreen(false); + } catch(Exception $e) { + $this->toggleMaintenanceScreen(false); + throw $e; + } + } +}