예제 #1
0
 public function delete($rabbitmqPush = true)
 {
     // see if it was recording show
     $recording = $this->isRecorded();
     // get show id
     $showId = $this->getShowId();
     $show = $this->getShow();
     $current_timestamp = gmdate("Y-m-d H:i:s");
     if ($current_timestamp <= $this->getShowInstanceEnd()) {
         if ($show->isRepeating()) {
             CcShowInstancesQuery::create()->findPK($this->_instanceId)->setDbModifiedInstance(true)->save();
             if ($this->isRebroadcast()) {
                 return;
             }
             //delete the rebroadcasts of the removed recorded show.
             if ($recording) {
                 CcShowInstancesQuery::create()->filterByDbOriginalShow($this->_instanceId)->delete();
             }
             /* Automatically delete all files scheduled in cc_schedules table. */
             CcScheduleQuery::create()->filterByDbInstanceId($this->_instanceId)->delete();
             if ($this->checkToDeleteShow($showId)) {
                 CcShowQuery::create()->filterByDbId($showId)->delete();
             }
         } else {
             if ($this->isRebroadcast()) {
                 $this->_showInstance->delete();
             } else {
                 $show->delete();
             }
         }
     }
     if ($rabbitmqPush) {
         Application_Model_RabbitMq::PushSchedule();
     }
 }
예제 #2
0
 public function updateScheduleStatus(PropelPDO $con)
 {
     $this->updateDbTimeFilled($con);
     //scheduled track is in the show
     CcScheduleQuery::create()->filterByDbInstanceId($this->id)->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)->filterByDbEnds($this->ends, Criteria::LESS_EQUAL)->update(array('DbPlayoutStatus' => 1), $con);
     //scheduled track is a boundary track
     CcScheduleQuery::create()->filterByDbInstanceId($this->id)->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)->filterByDbStarts($this->ends, Criteria::LESS_THAN)->filterByDbEnds($this->ends, Criteria::GREATER_THAN)->update(array('DbPlayoutStatus' => 2), $con);
     //scheduled track is overbooked.
     CcScheduleQuery::create()->filterByDbInstanceId($this->id)->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)->filterByDbStarts($this->ends, Criteria::GREATER_THAN)->update(array('DbPlayoutStatus' => 0), $con);
     $this->setDbLastScheduled(gmdate("Y-m-d H:i:s"));
     $this->save($con);
 }
예제 #3
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this CcShowInstances is new, it will return
  * an empty collection; or if this CcShowInstances has previously
  * been saved, it will retrieve related CcSchedules from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in CcShowInstances.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      PropelPDO $con optional connection object
  * @param      string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return     PropelCollection|array CcSchedule[] List of CcSchedule objects
  */
 public function getCcSchedulesJoinCcWebstream($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = CcScheduleQuery::create(null, $criteria);
     $query->joinWith('CcWebstream', $join_behavior);
     return $this->getCcSchedules($query, $con);
 }
예제 #4
0
 /**
  * Returns a new CcScheduleQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    CcScheduleQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof CcScheduleQuery) {
         return $criteria;
     }
     $query = new CcScheduleQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
예제 #5
0
 public function cancelShow($p_id)
 {
     $this->con->beginTransaction();
     try {
         $instance = CcShowInstancesQuery::create()->findPK($p_id);
         if (!$instance->getDbRecord()) {
             $items = CcScheduleQuery::create()->filterByDbInstanceId($p_id)->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)->find($this->con);
             if (count($items) > 0) {
                 $remove = array();
                 $ts = $this->nowDT->format('U');
                 for ($i = 0; $i < count($items); $i++) {
                     $remove[$i]["instance"] = $p_id;
                     $remove[$i]["timestamp"] = $ts;
                     $remove[$i]["id"] = $items[$i]->getDbId();
                 }
                 $this->removeItems($remove, false);
             }
         } else {
             $rebroadcasts = $instance->getCcShowInstancessRelatedByDbId(null, $this->con);
             $rebroadcasts->delete($this->con);
         }
         $instance->setDbEnds($this->nowDT);
         $instance->save($this->con);
         $this->con->commit();
         if ($instance->getDbRecord()) {
             Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording");
         }
     } catch (Exception $e) {
         $this->con->rollback();
         throw $e;
     }
 }
예제 #6
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             CcScheduleQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
예제 #7
0
 public function contextMenuAction()
 {
     $id = $this->_getParam('id');
     $now = floatval(microtime(true));
     $request = $this->getRequest();
     $menu = array();
     $user = Application_Model_User::getCurrentUser();
     $item = CcScheduleQuery::create()->findPK($id);
     $instance = $item->getCcShowInstances();
     $menu["preview"] = array("name" => "Preview", "icon" => "play");
     //select the cursor
     $menu["selCurs"] = array("name" => "Select cursor", "icon" => "select-cursor");
     $menu["delCurs"] = array("name" => "Remove cursor", "icon" => "select-cursor");
     if ($now < floatval($item->getDbEnds("U.u")) && $user->canSchedule($instance->getDbShowId())) {
         //remove/truncate the item from the schedule
         $menu["del"] = array("name" => "Remove from show", "icon" => "delete", "url" => "/showbuilder/schedule-remove");
     }
     $this->view->items = $menu;
 }
 public function updateFutureIsScheduled($scheduleId, $status)
 {
     $sched = CcScheduleQuery::create()->findPk($scheduleId);
     $redraw = false;
     if (isset($sched)) {
         $fileId = $sched->getDbFileId();
         if (isset($fileId)) {
             $redraw = Application_Model_StoredFile::setIsScheduled($fileId, $status);
         }
     }
     return $redraw;
 }
예제 #9
0
파일: Schedule.php 프로젝트: nidzix/Airtime
 public static function GetStreamId($p_scheduleId)
 {
     $scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
     return $scheduledItem->getDbStreamId();
 }
예제 #10
0
 public function clearShow()
 {
     CcScheduleQuery::create()->filterByDbInstanceId($this->_instanceId)->delete();
     RabbitMq::PushSchedule();
     $this->updateScheduledTime();
 }
예제 #11
0
 public function deleteShowInstances($ccShowInstances, $showId)
 {
     foreach ($ccShowInstances as $ccShowInstance) {
         $instanceId = $ccShowInstance->getDbId();
         $ccShowInstance->setDbModifiedInstance(true)->save();
         //delete the rebroadcasts of the removed recorded show
         if ($ccShowInstance->isRecorded()) {
             CcShowInstancesQuery::create()->filterByDbOriginalShow($instanceId)->delete();
         }
         //delete all files scheduled in cc_schedules table
         CcScheduleQuery::create()->filterByDbInstanceId($instanceId)->delete();
     }
     if ($this->checkToDeleteCcShow($showId)) {
         CcShowQuery::create()->filterByDbId($showId)->delete();
     }
 }
예제 #12
0
 public function insertPlayedItem($schedId)
 {
     $this->con->beginTransaction();
     try {
         $item = CcScheduleQuery::create()->findPK($schedId, $this->con);
         //TODO figure out how to combine these all into 1 query.
         $showInstance = $item->getCcShowInstances($this->con);
         $show = $showInstance->getCcShow($this->con);
         $fileId = $item->getDbFileId();
         //don't add webstreams
         if (isset($fileId)) {
             $metadata = array();
             $metadata["showname"] = $show->getDbName();
             $instanceEnd = $showInstance->getDbEnds(null);
             $itemEnd = $item->getDbEnds(null);
             $recordStart = $item->getDbStarts(null);
             $recordEnd = $instanceEnd < $itemEnd ? $instanceEnd : $itemEnd;
             //first check if this is a duplicate
             // (caused by restarting liquidsoap)
             $prevRecord = CcPlayoutHistoryQuery::create()->filterByDbStarts($recordStart)->filterByDbEnds($recordEnd)->filterByDbFileId($fileId)->findOne($this->con);
             if (empty($prevRecord)) {
                 $history = new CcPlayoutHistory();
                 $history->setDbFileId($fileId);
                 $history->setDbStarts($recordStart);
                 $history->setDbEnds($recordEnd);
                 $history->setDbInstanceId($item->getDbInstanceId());
                 foreach ($metadata as $key => $val) {
                     $meta = new CcPlayoutHistoryMetaData();
                     $meta->setDbKey($key);
                     $meta->setDbValue($val);
                     $history->addCcPlayoutHistoryMetaData($meta);
                 }
                 $history->save($this->con);
                 $this->con->commit();
             }
         }
     } catch (Exception $e) {
         $this->con->rollback();
         throw $e;
     }
 }
예제 #13
0
 /**
  * 
  * This function resets the cc_schedule table's position numbers so that
  * tracks for each cc_show_instances start at position 1
  * 
  * The position numbers can become out of sync when the user deletes items
  * from linekd shows filled with dyanmic smart blocks, where each instance
  * has a different amount of scheduled items
  */
 public function correctSchedulePositions()
 {
     $schedule = CcScheduleQuery::create()->filterByDbInstanceId($this->id)->orderByDbStarts()->find();
     $pos = 0;
     foreach ($schedule as $item) {
         $item->setDbPosition($pos)->save();
         $pos++;
     }
 }
 /**
  * Get the associated CcSchedule object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     CcSchedule The associated CcSchedule object.
  * @throws     PropelException
  */
 public function getCcSchedule(PropelPDO $con = null)
 {
     if ($this->aCcSchedule === null && $this->instance_id !== null) {
         $this->aCcSchedule = CcScheduleQuery::create()->findPk($this->instance_id, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aCcSchedule->addCcWebstreamMetadatas($this);
         		 */
     }
     return $this->aCcSchedule;
 }