Updated show edit functionality to accommodate uploading new show image
This commit is contained in:
parent
b2d81f370a
commit
f64b7d0813
|
@ -531,13 +531,24 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
list($data, $validateStartDate, $validateStartTime, $originalShowStartDateTime) =
|
||||
$service_showForm->preEditShowValidationCheck($data);
|
||||
|
||||
/*
|
||||
* hack to prevent validating the file upload field since it
|
||||
* isn't passed into $data
|
||||
*/
|
||||
$upload = $forms["style"]->getElement("upload");
|
||||
$forms["style"]->removeElement("upload");
|
||||
|
||||
|
||||
if ($service_showForm->validateShowForms($forms, $data, $validateStartDate,
|
||||
$originalShowStartDateTime, true, $data["add_show_instance_id"])) {
|
||||
|
||||
$service_show->addUpdateShow($data);
|
||||
|
||||
$this->view->addNewShow = true;
|
||||
// Get the show ID from the show service to pass as a parameter to the RESTful ShowController
|
||||
$this->view->showId = $service_show->addUpdateShow($data);
|
||||
|
||||
// re-add the upload element
|
||||
$forms["style"]->addElement($upload);
|
||||
|
||||
$this->view->addNewShow = true;
|
||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
} else {
|
||||
if (!$validateStartDate) {
|
||||
|
@ -547,6 +558,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->when->getElement('add_show_start_time')->setOptions(array('disabled' => true));
|
||||
}
|
||||
//$this->view->rr->getElement('add_show_record')->setOptions(array('disabled' => true));
|
||||
// re-add the upload element
|
||||
$forms["style"]->addElement($upload);
|
||||
|
||||
$this->view->addNewShow = false;
|
||||
$this->view->action = "edit-show";
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
|
|
|
@ -55,8 +55,6 @@ class Rest_ShowController extends Zend_Rest_Controller
|
|||
|
||||
public function uploadImageAction()
|
||||
{
|
||||
Logging::info("Uploading image: " . $_FILES["file"]);
|
||||
|
||||
if (!$this->restAuth->verifyAuth(true, true))
|
||||
{
|
||||
Logging::info("Authentication failed");
|
||||
|
@ -64,7 +62,6 @@ class Rest_ShowController extends Zend_Rest_Controller
|
|||
}
|
||||
|
||||
$showId = $this->getShowId();
|
||||
Logging::info("Show Id " . $showId);
|
||||
|
||||
if (!$showId) {
|
||||
Logging::info("No show id provided");
|
||||
|
@ -162,8 +159,7 @@ class Rest_ShowController extends Zend_Rest_Controller
|
|||
|
||||
// Did all the checks for real, now trying to copy
|
||||
$image_stor = Application_Common_OsPath::join($importedStorageDirectory, $newFileName);
|
||||
Logging::info($newFileName);
|
||||
Logging::info($image_stor);
|
||||
Logging::info("Adding image: " . $image_stor);
|
||||
Logging::info("copyFileToStor: moving file $image_file to $image_stor");
|
||||
|
||||
if (@rename($image_file, $image_stor) === false) {
|
||||
|
@ -181,14 +177,14 @@ class Rest_ShowController extends Zend_Rest_Controller
|
|||
return $image_stor;
|
||||
}
|
||||
|
||||
public static function deleteFileFromStor($showId) {
|
||||
public static function deleteFilesFromStor($showId) {
|
||||
$auth = new RestAuth();
|
||||
$ownerId = $auth->getOwnerId();
|
||||
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$importedStorageDirectory = $storDir->getDirectory() . "imported/" . $ownerId . "/show-images/" . $showId;
|
||||
|
||||
Logging::info($importedStorageDirectory);
|
||||
Logging::info("Deleting images from " . $importedStorageDirectory);
|
||||
|
||||
// to be safe in case image uploading functionality is extended later
|
||||
return Rest_ShowController::delTree($importedStorageDirectory);
|
||||
|
|
|
@ -198,7 +198,13 @@ class Application_Service_ShowService
|
|||
$daysAdded = array();
|
||||
|
||||
if ($this->isUpdate) {
|
||||
|
||||
|
||||
// Delete previous show images
|
||||
$showId = $this->ccShow->getDbId();
|
||||
if (!Rest_ShowController::deleteFilesFromStor($showId)) {
|
||||
throw new Exception("Error deleting show images");
|
||||
}
|
||||
|
||||
if (!$this->ccShow->getCcShowDayss()->isEmpty()) {
|
||||
$this->storeOrigLocalShowInfo();
|
||||
}
|
||||
|
@ -746,8 +752,9 @@ SQL;
|
|||
throw new Exception("Could not find show instance");
|
||||
}
|
||||
|
||||
// Delete show images
|
||||
$showId = $ccShowInstance->getDbShowId();
|
||||
if (!Rest_ShowController::deleteFileFromStor($showId)) {
|
||||
if (!Rest_ShowController::deleteFilesFromStor($showId)) {
|
||||
throw new Exception("Error deleting show images");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue