public function switchSourceAction()
 {
     $sourcename = $this->_getParam('sourcename');
     $current_status = $this->_getParam('status');
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     $show = Application_Model_Show::getCurrentShow();
     $show_id = isset($show[0]['id']) ? $show[0]['id'] : 0;
     $source_connected = Application_Model_Preference::GetSourceStatus($sourcename);
     if ($user->canSchedule($show_id) && ($source_connected || $sourcename == 'scheduled_play' || $current_status == "on")) {
         $change_status_to = "on";
         if (strtolower($current_status) == "on") {
             $change_status_to = "off";
         }
         $data = array("sourcename" => $sourcename, "status" => $change_status_to);
         Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data);
         if (strtolower($current_status) == "on") {
             Application_Model_Preference::SetSourceSwitchStatus($sourcename, "off");
             $this->view->status = "OFF";
             //Log table updates
             Application_Model_LiveLog::SetEndTime($sourcename == 'scheduled_play' ? 'S' : 'L', new DateTime("now", new DateTimeZone('UTC')));
         } else {
             Application_Model_Preference::SetSourceSwitchStatus($sourcename, "on");
             $this->view->status = "ON";
             //Log table updates
             Application_Model_LiveLog::SetNewLogTime($sourcename == 'scheduled_play' ? 'S' : 'L', new DateTime("now", new DateTimeZone('UTC')));
         }
     } else {
         if ($source_connected) {
             $this->view->error = _("You don't have permission to switch source.");
         } else {
             if ($sourcename == 'scheduled_play') {
                 $this->view->error = _("You don't have permission to disconnect source.");
             } else {
                 $this->view->error = _("There is no source connected to this input.");
             }
         }
     }
 }
 /**
  *
  * Enter description here ...
  */
 public function makeContextMenu()
 {
     $menu = array();
     $now = time();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $isAdminOrPM = $this->currentUser->isAdminOrPM();
     $isHostOfShow = $this->currentUser->isHostOfShow($this->ccShow->getDbId());
     //DateTime objects in UTC
     $startDT = $this->ccShowInstance->getDbStarts(null);
     $endDT = $this->ccShowInstance->getDbEnds(null);
     //timestamps
     $start = $startDT->getTimestamp();
     $end = $endDT->getTimestamp();
     //show has ended
     if ($now > $end) {
         if ($this->ccShowInstance->isRecorded()) {
             $ccFile = $this->ccShowInstance->getCcFiles();
             if (!isset($ccFile)) {
                 $menu["error when recording"] = array("name" => _("Record file doesn't exist"), "icon" => "error");
             } else {
                 $menu["view_recorded"] = array("name" => _("View Recorded File Metadata"), "icon" => "overview", "url" => $baseUrl . "library/edit-file-md/id/" . $ccFile->getDbId());
             }
             //recorded show can be uploaded to soundcloud
             if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
                 $scid = $ccFile->getDbSoundcloudId();
                 if ($scid > 0) {
                     $menu["soundcloud_view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $ccFile->getDbSoundcloudLinkToFile());
                 }
                 $text = is_null($scid) ? _('Upload to SoundCloud') : _('Re-upload to SoundCloud');
                 $menu["soundcloud_upload"] = array("name" => $text, "icon" => "soundcloud");
             }
         } else {
             $menu["content"] = array("name" => _("Show Content"), "icon" => "overview", "url" => $baseUrl . "schedule/show-content-dialog");
         }
     } else {
         // Show content can be modified from the calendar if:
         // the user is admin or hosting the show,
         // the show is not recorded
         $currentShow = Application_Model_Show::getCurrentShow();
         $currentShowId = count($currentShow) == 1 ? $currentShow[0]["id"] : null;
         $showIsLinked = $this->ccShow->isLinked();
         if ($now < $end && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded()) {
             //if the show is not linked the user can add/remove content
             if (!$showIsLinked) {
                 $menu["schedule"] = array("name" => _("Add / Remove Content"), "icon" => "add-remove-content", "url" => $baseUrl . "showbuilder/builder-dialog/");
                 //if the show is linked and it's not currently playing the user can add/remove content
             } elseif ($showIsLinked && $currentShowId != $this->ccShow->getDbId()) {
                 $menu["schedule"] = array("name" => _("Add / Remove Content"), "icon" => "add-remove-content", "url" => $baseUrl . "showbuilder/builder-dialog/");
             }
         }
         if ($now < $start && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded()) {
             $menu["clear"] = array("name" => _("Remove All Content"), "icon" => "remove-all-content", "url" => $baseUrl . "schedule/clear-show");
         }
         //"Show Content" should be a menu item at all times except when
         //the show is recorded
         if (!$this->ccShowInstance->isRecorded()) {
             $menu["content"] = array("name" => _("Show Content"), "icon" => "overview", "url" => $baseUrl . "schedule/show-content-dialog");
         }
         //show is currently playing and user is admin
         if ($start <= $now && $now < $end && $isAdminOrPM) {
             if ($this->ccShowInstance->isRecorded()) {
                 $menu["cancel_recorded"] = array("name" => _("Cancel Current Show"), "icon" => "delete");
             } else {
                 $menu["cancel"] = array("name" => _("Cancel Current Show"), "icon" => "delete");
             }
         }
         $excludeIds = $this->ccShow->getEditedRepeatingInstanceIds();
         $isRepeating = $this->ccShow->isRepeating();
         $populateInstance = false;
         if ($isRepeating && in_array($this->ccShowInstance->getDbId(), $excludeIds)) {
             $populateInstance = true;
         }
         if (!$this->ccShowInstance->isRebroadcast() && $isAdminOrPM) {
             if ($isRepeating) {
                 if ($populateInstance) {
                     $menu["edit"] = array("name" => _("Edit This Instance"), "icon" => "edit", "url" => $baseUrl . "Schedule/populate-repeating-show-instance-form");
                 } else {
                     $menu["edit"] = array("name" => _("Edit"), "icon" => "edit", "items" => array());
                     $menu["edit"]["items"]["all"] = array("name" => _("Edit Show"), "icon" => "edit", "url" => $baseUrl . "Schedule/populate-show-form");
                     $menu["edit"]["items"]["instance"] = array("name" => _("Edit This Instance"), "icon" => "edit", "url" => $baseUrl . "Schedule/populate-repeating-show-instance-form");
                 }
             } else {
                 $menu["edit"] = array("name" => _("Edit Show"), "icon" => "edit", "_type" => "all", "url" => $baseUrl . "Schedule/populate-show-form");
             }
         }
         //show hasn't started yet and user is admin
         if ($now < $start && $isAdminOrPM) {
             //show is repeating so give user the option to delete all
             //repeating instances or just the one
             if ($isRepeating) {
                 $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "items" => array());
                 $menu["del"]["items"]["single"] = array("name" => _("Delete This Instance"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show-instance");
                 $menu["del"]["items"]["following"] = array("name" => _("Delete This Instance and All Following"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show");
             } elseif ($populateInstance) {
                 $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show-instance");
             } else {
                 $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show");
             }
         }
     }
     return $menu;
 }
示例#3
0
 public function getCurrentPlaylistAction()
 {
     $range = Application_Model_Schedule::GetPlayOrderRange();
     $show = Application_Model_Show::getCurrentShow();
     /* Convert all UTC times to localtime before sending back to user. */
     if (isset($range["previous"])) {
         $range["previous"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["previous"]["starts"]);
         $range["previous"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["previous"]["ends"]);
     }
     if (isset($range["current"])) {
         $range["current"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["current"]["starts"]);
         $range["current"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["current"]["ends"]);
     }
     if (isset($range["next"])) {
         $range["next"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["starts"]);
         $range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]);
     }
     Application_Model_Show::convertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
     Application_Model_Show::convertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
     $source_status = array();
     $switch_status = array();
     $live_dj = Application_Model_Preference::GetSourceStatus("live_dj");
     $master_dj = Application_Model_Preference::GetSourceStatus("master_dj");
     $scheduled_play_switch = Application_Model_Preference::GetSourceSwitchStatus("scheduled_play");
     $live_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("live_dj");
     $master_dj_switch = Application_Model_Preference::GetSourceSwitchStatus("master_dj");
     //might not be the correct place to implement this but for now let's just do it here
     $source_status['live_dj_source'] = $live_dj;
     $source_status['master_dj_source'] = $master_dj;
     $this->view->source_status = $source_status;
     $switch_status['live_dj_source'] = $live_dj_switch;
     $switch_status['master_dj_source'] = $master_dj_switch;
     $switch_status['scheduled_play'] = $scheduled_play_switch;
     $this->view->switch_status = $switch_status;
     $this->view->entries = $range;
     $this->view->show_name = isset($show[0]) ? $show[0]["name"] : "";
 }
 public function checkLiveStreamAuthAction()
 {
     $request = $this->getRequest();
     $username = $request->getParam('username');
     $password = $request->getParam('password');
     $djtype = $request->getParam('djtype');
     if ($djtype == 'master') {
         //check against master
         if ($username == Application_Model_Preference::GetLiveStreamMasterUsername() && $password == Application_Model_Preference::GetLiveStreamMasterPassword()) {
             $this->view->msg = true;
         } else {
             $this->view->msg = false;
         }
     } elseif ($djtype == "dj") {
         //check against show dj auth
         $showInfo = Application_Model_Show::getCurrentShow();
         // there is current playing show
         if (isset($showInfo[0]['id'])) {
             $current_show_id = $showInfo[0]['id'];
             $CcShow = CcShowQuery::create()->findPK($current_show_id);
             // get custom pass info from the show
             $custom_user = $CcShow->getDbLiveStreamUser();
             $custom_pass = $CcShow->getDbLiveStreamPass();
             // get hosts ids
             $show = new Application_Model_Show($current_show_id);
             $hosts_ids = $show->getHostsIds();
             // check against hosts auth
             if ($CcShow->getDbLiveStreamUsingAirtimeAuth()) {
                 foreach ($hosts_ids as $host) {
                     $h = new Application_Model_User($host['subjs_id']);
                     if ($username == $h->getLogin() && md5($password) == $h->getPassword()) {
                         $this->view->msg = true;
                         return;
                     }
                 }
             }
             // check against custom auth
             if ($CcShow->getDbLiveStreamUsingCustomAuth()) {
                 if ($username == $custom_user && $password == $custom_pass) {
                     $this->view->msg = true;
                 } else {
                     $this->view->msg = false;
                 }
             } else {
                 $this->view->msg = false;
             }
         } else {
             // no show is currently playing
             $this->view->msg = false;
         }
     }
 }