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.");
             }
         }
     }
 }
Esempio n. 2
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 SourceConnectionStatus()
 {
     $status = array("live_dj" => Application_Model_Preference::GetSourceStatus("live_dj"), "master_dj" => Application_Model_Preference::GetSourceStatus("master_dj"));
     return $status;
 }