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.");
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function updateSourceStatusAction()
 {
     $request = $this->getRequest();
     $sourcename = $request->getParam('sourcename');
     $status = $request->getParam('status');
     // on source disconnection sent msg to pypo to turn off the switch
     // Added AutoTransition option
     if ($status == "false" && Application_Model_Preference::GetAutoTransition()) {
         $data = array("sourcename" => $sourcename, "status" => "off");
         Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data);
         Application_Model_Preference::SetSourceSwitchStatus($sourcename, "off");
         Application_Model_LiveLog::SetEndTime($sourcename == 'scheduled_play' ? 'S' : 'L', new DateTime("now", new DateTimeZone('UTC')));
     } elseif ($status == "true" && Application_Model_Preference::GetAutoSwitch()) {
         $data = array("sourcename" => $sourcename, "status" => "on");
         Application_Model_RabbitMq::SendMessageToPypo("switch_source", $data);
         Application_Model_Preference::SetSourceSwitchStatus($sourcename, "on");
         Application_Model_LiveLog::SetNewLogTime($sourcename == 'scheduled_play' ? 'S' : 'L', new DateTime("now", new DateTimeZone('UTC')));
     }
     Application_Model_Preference::SetSourceStatus($sourcename, $status);
 }