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
 /**
  * Creates a single show instance. If the show is recorded, it may have multiple
  * rebroadcast dates, and so this function will create those as well.
  *
  * @param array $p_showRow
  *        A row from cc_show_days table
  * @param DateTime $p_populateUntilDateTime
  *        DateTime object in UTC time.
  */
 private static function populateNonRepeatingShow($p_showRow, $p_populateUntilDateTime)
 {
     $show_id = $p_showRow["show_id"];
     $first_show = $p_showRow["first_show"];
     //non-UTC
     $start_time = $p_showRow["start_time"];
     //non-UTC
     $duration = $p_showRow["duration"];
     $record = $p_showRow["record"];
     $timezone = $p_showRow["timezone"];
     $start = $first_show . " " . $start_time;
     //start & end UTC DateTimes for the show.
     list($utcStartDateTime, $utcEndDateTime) = Application_Model_Show::createUTCStartEndDateTime($start, $duration, $timezone);
     if ($utcStartDateTime->getTimestamp() < $p_populateUntilDateTime->getTimestamp()) {
         $currentUtcTimestamp = gmdate("Y-m-d H:i:s");
         $show = new Application_Model_Show($show_id);
         if ($show->hasInstance()) {
             $ccShowInstance = $show->getInstance();
             $newInstance = false;
         } else {
             $ccShowInstance = new CcShowInstances();
             $newInstance = true;
         }
         if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp) {
             $ccShowInstance->setDbShowId($show_id);
             $ccShowInstance->setDbStarts($utcStartDateTime);
             $ccShowInstance->setDbEnds($utcEndDateTime);
             $ccShowInstance->setDbRecord($record);
             $ccShowInstance->save();
         }
         $show_instance_id = $ccShowInstance->getDbId();
         $showInstance = new Application_Model_ShowInstance($show_instance_id);
         if (!$newInstance) {
             $showInstance->correctScheduleStartTimes();
         }
         $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
         $rebroadcasts = Application_Common_Database::prepareAndExecute($sql, array(':show_id' => $show_id), 'all');
         if ($showInstance->isRecorded()) {
             $showInstance->deleteRebroadcasts();
             self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
         }
     }
 }