SAAS-777 - Changed deleteAllFilesAction to remove files and any current/future schedule items
This commit is contained in:
parent
3052e1f23b
commit
1fa45bfc48
|
@ -480,31 +480,42 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = Application_Model_User::getCurrentUser();
|
$this->deleteFutureScheduleItems();
|
||||||
$playlists = $blocks = $streams = [];
|
$this->deleteCloudFiles();
|
||||||
|
$this->deleteStoredFiles();
|
||||||
|
|
||||||
$allPlaylists = CcPlaylistQuery::create()->find();
|
$this->getResponse()
|
||||||
foreach ($allPlaylists as $p) {
|
->setHttpResponseCode(200)
|
||||||
$playlists[] = $p->getDbId();
|
->appendBody("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deleteFutureScheduleItems() {
|
||||||
|
$utcTimezone = new DateTimeZone("UTC");
|
||||||
|
$nowDateTime = new DateTime("now", $utcTimezone);
|
||||||
|
$scheduleItems = CcScheduleQuery::create()
|
||||||
|
->filterByDbEnds($nowDateTime->format("Y-m-d H:i:s"), Criteria::GREATER_THAN)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
// Delete all the schedule items
|
||||||
|
foreach ($scheduleItems as $i) {
|
||||||
|
// If this is the currently playing track, cancel the current show
|
||||||
|
if ($i->isCurrentItem()) {
|
||||||
|
$instanceId = $i->getDbInstanceId();
|
||||||
|
$instance = CcShowInstancesQuery::create()->findPk($instanceId);
|
||||||
|
$showId = $instance->getDbShowId();
|
||||||
|
|
||||||
|
// From ScheduleController
|
||||||
|
$scheduler = new Application_Model_Scheduler();
|
||||||
|
$scheduler->cancelShow($showId);
|
||||||
|
Application_Model_StoredFile::updatePastFilesIsScheduled();
|
||||||
|
}
|
||||||
|
|
||||||
|
$i->delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$allBlocks = CcBlockQuery::create()->find();
|
private function deleteCloudFiles() {
|
||||||
foreach ($allBlocks as $b) {
|
|
||||||
$blocks[] = $b->getDbId();
|
|
||||||
}
|
|
||||||
|
|
||||||
$allStreams = CcWebstreamQuery::create()->find();
|
|
||||||
foreach ($allStreams as $s) {
|
|
||||||
$streams[] = $s->getDbId();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete all playlists, blocks, and streams
|
|
||||||
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
|
|
||||||
Application_Model_Block::deleteBlocks($blocks, $user->getId());
|
|
||||||
Application_Model_Webstream::deleteStreams($streams, $user->getId());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Delete all the cloud files
|
|
||||||
$CC_CONFIG = Config::getConfig();
|
$CC_CONFIG = Config::getConfig();
|
||||||
|
|
||||||
foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) {
|
foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) {
|
||||||
|
@ -514,7 +525,9 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
Logging::info($e->getMessage());
|
Logging::info($e->getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deleteStoredFiles() {
|
||||||
// Delete all files from the database
|
// Delete all files from the database
|
||||||
$files = CcFilesQuery::create()->find();
|
$files = CcFilesQuery::create()->find();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
@ -523,10 +536,6 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
// every S3 file we delete.
|
// every S3 file we delete.
|
||||||
$storedFile->delete(true);
|
$storedFile->delete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getResponse()
|
|
||||||
->setHttpResponseCode(200)
|
|
||||||
->appendBody("OK");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue