コード例 #1
0
 public function __construct($instanceId = null)
 {
     if (!is_null($instanceId)) {
         $this->ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId);
         if (is_null($this->ccShowInstance)) {
             throw new Exception("Instance does not exist");
         }
         $this->ccShow = $this->ccShowInstance->getCcShow();
     }
     $service_user = new Application_Service_UserService();
     $this->currentUser = $service_user->getCurrentUser();
 }
コード例 #2
0
 public function __construct()
 {
     $this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
     //subtracting one because sometimes when we cancel a track, we set its end time
     //to epochNow and then send the new schedule to pypo. Sometimes the currently cancelled
     //track can still be included in the new schedule because it may have a few ms left to play.
     //subtracting 1 second from epochNow resolves this issue.
     $this->epochNow = microtime(true) - 1;
     $this->nowDT = DateTime::createFromFormat("U.u", $this->epochNow, new DateTimeZone("UTC"));
     if ($this->nowDT === false) {
         // DateTime::createFromFormat does not support millisecond string formatting in PHP 5.3.2 (Ubuntu 10.04).
         // In PHP 5.3.3 (Ubuntu 10.10), this has been fixed.
         $this->nowDT = DateTime::createFromFormat("U", time(), new DateTimeZone("UTC"));
     }
     $user_service = new Application_Service_UserService();
     $this->currentUser = $user_service->getCurrentUser();
 }
コード例 #3
0
 public function getFormAction()
 {
     $service_user = new Application_Service_UserService();
     $currentUser = $service_user->getCurrentUser();
     if ($currentUser->isAdminOrPM()) {
         $this->createShowFormAction(true);
         $this->view->addNewShow = true;
         $this->view->form = $this->view->render('schedule/add-show-form.phtml');
     }
 }
コード例 #4
0
 public function deleteShow($instanceId, $singleInstance = false)
 {
     $service_user = new Application_Service_UserService();
     $currentUser = $service_user->getCurrentUser();
     $con = Propel::getConnection();
     $con->beginTransaction();
     try {
         if (!$currentUser->isAdminOrPM()) {
             throw new Exception("Permission denied");
         }
         $ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId);
         if (!$ccShowInstance) {
             throw new Exception("Could not find show instance");
         }
         $showId = $ccShowInstance->getDbShowId();
         if ($singleInstance) {
             $ccShowInstances = CcShowInstancesQuery::create()->filterByDbShowId($showId)->filterByDbStarts($ccShowInstance->getDbStarts(), Criteria::GREATER_EQUAL)->filterByDbEnds($ccShowInstance->getDbEnds(), Criteria::LESS_EQUAL)->find();
         } else {
             $ccShowInstances = CcShowInstancesQuery::create()->filterByDbShowId($showId)->filterByDbStarts($ccShowInstance->getDbStarts(), Criteria::GREATER_EQUAL)->find();
         }
         if (gmdate("Y-m-d H:i:s") <= $ccShowInstance->getDbEnds()) {
             $this->deleteShowInstances($ccShowInstances, $ccShowInstance->getDbShowId());
         }
         Application_Model_StoredFile::updatePastFilesIsScheduled();
         Application_Model_RabbitMq::PushSchedule();
         $con->commit();
         return $showId;
     } catch (Exception $e) {
         $con->rollback();
         Logging::info("Delete show instance failed");
         Logging::info($e->getMessage());
         return false;
     }
 }