Ejemplo n.º 1
0
 public function makeContextMenuAction()
 {
     $id = $this->_getParam('id');
     $menu = array();
     $epochNow = time();
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     try {
         $instance = new Application_Model_ShowInstance($id);
     } catch (Exception $e) {
         $this->view->show_error = true;
         return false;
     }
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     $isDJ = $user->isHostOfShow($instance->getShowId());
     $showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
     $showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
     if ($instance->isRecorded() && $epochNow > $showEndLocalDT->getTimestamp()) {
         $file = $instance->getRecordedFile();
         $fileId = $file->getId();
         $menu["view_recorded"] = array("name" => "View Recorded File Metadata", "icon" => "overview", "url" => "/library/edit-file-md/id/" . $fileId);
     }
     if ($epochNow < $showStartLocalDT->getTimestamp()) {
         if (($isAdminOrPM || $isDJ) && !$instance->isRecorded() && !$instance->isRebroadcast()) {
             $menu["schedule"] = array("name" => "Add / Remove Content", "icon" => "add-remove-content", "url" => "/showbuilder/builder-dialog/");
             $menu["clear"] = array("name" => "Remove All Content", "icon" => "remove-all-content", "url" => "/schedule/clear-show");
         }
     }
     if (!$instance->isRecorded()) {
         $menu["content"] = array("name" => "Show Content", "icon" => "overview", "url" => "/schedule/show-content-dialog");
     }
     if ($showEndLocalDT->getTimestamp() <= $epochNow && $instance->isRecorded() && Application_Model_Preference::GetUploadToSoundcloudOption()) {
         $file = $instance->getRecordedFile();
         $fileId = $file->getId();
         $scid = $instance->getSoundCloudFileId();
         if ($scid > 0) {
             $url = $file->getSoundCloudLinkToFile();
             $menu["soundcloud_view"] = array("name" => "View on Soundcloud", "icon" => "soundcloud", "url" => $url);
         }
         $text = is_null($scid) ? 'Upload to SoundCloud' : 'Re-upload to SoundCloud';
         $menu["soundcloud_upload"] = array("name" => $text, "icon" => "soundcloud");
     }
     if ($showStartLocalDT->getTimestamp() <= $epochNow && $epochNow < $showEndLocalDT->getTimestamp() && $isAdminOrPM) {
         if ($instance->isRecorded()) {
             $menu["cancel_recorded"] = array("name" => "Cancel Current Show", "icon" => "delete");
         } else {
             if (!$instance->isRebroadcast()) {
                 $menu["edit"] = array("name" => "Edit Show", "icon" => "edit", "_type" => "all", "url" => "/Schedule/populate-show-form");
             }
             $menu["cancel"] = array("name" => "Cancel Current Show", "icon" => "delete");
         }
     }
     if ($epochNow < $showStartLocalDT->getTimestamp()) {
         if (!$instance->isRebroadcast() && $isAdminOrPM) {
             $menu["edit"] = array("name" => "Edit Show", "icon" => "edit", "_type" => "all", "url" => "/Schedule/populate-show-form");
         }
         if ($instance->getShow()->isRepeating() && $isAdminOrPM) {
             //create delete sub menu.
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "items" => array());
             $menu["del"]["items"]["single"] = array("name" => "Delete This Instance", "icon" => "delete", "url" => "/schedule/delete-show");
             $menu["del"]["items"]["following"] = array("name" => "Delete This Instance and All Following", "icon" => "delete", "url" => "/schedule/cancel-show");
         } elseif ($isAdminOrPM) {
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/schedule/delete-show");
         }
     }
     $this->view->items = $menu;
 }
Ejemplo n.º 2
0
 public function getUploadToSoundcloudStatusAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     if ($type == "show") {
         $show_instance = new Application_Model_ShowInstance($id);
         $this->view->sc_id = $show_instance->getSoundCloudFileId();
         $file = $show_instance->getRecordedFile();
         $this->view->error_code = $file->getSoundCloudErrorCode();
         $this->view->error_msg = $file->getSoundCloudErrorMsg();
     } elseif ($type == "file") {
         $file = Application_Model_StoredFile::Recall($id);
         $this->view->sc_id = $file->getSoundCloudId();
         $this->view->error_code = $file->getSoundCloudErrorCode();
         $this->view->error_msg = $file->getSoundCloudErrorMsg();
     } else {
         Logging::warn("Trying to upload unknown type: {$type} with id: {$id}");
     }
 }