Пример #1
0
 /**
  * Filter the query by a related CcShowInstances object
  *
  * @param     CcShowInstances $ccShowInstances  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CcScheduleQuery The current query, for fluid interface
  */
 public function filterByCcShowInstances($ccShowInstances, $comparison = null)
 {
     return $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison);
 }
Пример #2
0
 /**
  * Declares an association between this object and a CcShowInstances object.
  *
  * @param      CcShowInstances $v
  * @return     CcShowInstances The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCcShowInstancesRelatedByDbOriginalShow(CcShowInstances $v = null)
 {
     if ($v === null) {
         $this->setDbOriginalShow(NULL);
     } else {
         $this->setDbOriginalShow($v->getDbId());
     }
     $this->aCcShowInstancesRelatedByDbOriginalShow = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the CcShowInstances object, it will not be re-added.
     if ($v !== null) {
         $v->addCcShowInstancesRelatedByDbId($this);
     }
     return $this;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      CcShowInstances $value A CcShowInstances object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(CcShowInstances $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getDbId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #4
0
 /**
  * Exclude object from result
  *
  * @param     CcShowInstances $ccShowInstances Object to remove from the list of results
  *
  * @return    CcShowInstancesQuery The current query, for fluid interface
  */
 public function prune($ccShowInstances = null)
 {
     if ($ccShowInstances) {
         $this->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Filter the query by a related CcShowInstances object
  *
  * @param     CcShowInstances $ccShowInstances  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CcFilesQuery The current query, for fluid interface
  */
 public function filterByCcShowInstances($ccShowInstances, $comparison = null)
 {
     return $this->addUsingAlias(CcFilesPeer::ID, $ccShowInstances->getDbRecordedFile(), $comparison);
 }
Пример #6
0
 /**
  * Declares an association between this object and a CcShowInstances object.
  *
  * @param      CcShowInstances $v
  * @return     CcSchedule The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCcShowInstances(CcShowInstances $v = null)
 {
     // aggregate_column_relation behavior
     if (null !== $this->aCcShowInstances && $v !== $this->aCcShowInstances) {
         $this->oldCcShowInstances = $this->aCcShowInstances;
     }
     if ($v === null) {
         $this->setDbInstanceId(NULL);
     } else {
         $this->setDbInstanceId($v->getDbId());
     }
     $this->aCcShowInstances = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the CcShowInstances object, it will not be re-added.
     if ($v !== null) {
         $v->addCcSchedule($this);
     }
     return $this;
 }
Пример #7
0
 private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp, $interval)
 {
     global $CC_DBC;
     if (isset($next_pop_date)) {
         $next_date = $next_pop_date . " " . $start_time;
     } else {
         $next_date = $first_show . " " . $start_time;
     }
     $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
     $rebroadcasts = $CC_DBC->GetAll($sql);
     $show = new Show($show_id);
     $date = new DateHelper();
     $currentTimestamp = $date->getTimestamp();
     while (strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
         $start = $next_date;
         $sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
         $end = $CC_DBC->GetOne($sql);
         if ($show->hasInstanceOnDate($start)) {
             $ccShowInstance = $show->getInstanceOnDate($start);
             $newInstance = false;
         } else {
             $ccShowInstance = new CcShowInstances();
             $newInstance = true;
         }
         /* When editing the start/end time of a repeating show, we don't want to
          * change shows that started in the past. So check the start time.
          */
         if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp) {
             $ccShowInstance->setDbShowId($show_id);
             $ccShowInstance->setDbStarts($start);
             $ccShowInstance->setDbEnds($end);
             $ccShowInstance->setDbRecord($record);
             $ccShowInstance->save();
         }
         $show_instance_id = $ccShowInstance->getDbId();
         $showInstance = new ShowInstance($show_instance_id);
         if (!$newInstance) {
             $showInstance->correctScheduleStartTimes();
         }
         foreach ($rebroadcasts as $rebroadcast) {
             $timeinfo = explode(" ", $next_date);
             $sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
             $rebroadcast_start_time = $CC_DBC->GetOne($sql);
             $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
             $rebroadcast_end_time = $CC_DBC->GetOne($sql);
             if ($rebroadcast_start_time > $currentTimestamp) {
                 $newRebroadcastInstance = new CcShowInstances();
                 $newRebroadcastInstance->setDbShowId($show_id);
                 $newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
                 $newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
                 $newRebroadcastInstance->setDbRecord(0);
                 $newRebroadcastInstance->setDbRebroadcast(1);
                 $newRebroadcastInstance->setDbOriginalShow($show_instance_id);
                 $newRebroadcastInstance->save();
             }
         }
         $sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
         $next_date = $CC_DBC->GetOne($sql);
     }
     Show::setNextPop($next_date, $show_id, $day);
     RabbitMq::PushSchedule();
 }
Пример #8
0
 private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_startTime, $p_duration, $p_timezone = null)
 {
     //Y-m-d
     //use only the date part of the show start time stamp for the offsets to work properly.
     $date = explode(" ", $p_startTime);
     $start_date = $date[0];
     foreach ($p_rebroadcasts as $rebroadcast) {
         $days = explode(" ", $rebroadcast["day_offset"]);
         $time = explode(":", $rebroadcast["start_time"]);
         $offset = array("days" => $days[0], "hours" => $time[0], "mins" => $time[1]);
         list($utcStartDateTime, $utcEndDateTime) = Application_Model_Show::createUTCStartEndDateTime($start_date, $p_duration, $p_timezone, $offset);
         if ($utcStartDateTime->format("Y-m-d H:i:s") > $p_currentUtcTimestamp) {
             $newRebroadcastInstance = new CcShowInstances();
             $newRebroadcastInstance->setDbShowId($p_showId);
             $newRebroadcastInstance->setDbStarts($utcStartDateTime);
             $newRebroadcastInstance->setDbEnds($utcEndDateTime);
             $newRebroadcastInstance->setDbRecord(0);
             $newRebroadcastInstance->setDbRebroadcast(1);
             $newRebroadcastInstance->setDbOriginalShow($p_showInstanceId);
             $newRebroadcastInstance->save();
         }
     }
 }
Пример #9
0
 private function createMonthlyRepeatInstances($showDay, $populateUntil)
 {
     $show_id = $showDay->getDbShowId();
     $first_show = $showDay->getDbFirstShow();
     //non-UTC
     $last_show = $showDay->getDbLastShow();
     //non-UTC
     $duration = $showDay->getDbDuration();
     $day = $showDay->getDbDay();
     $record = $showDay->getDbRecord();
     $timezone = $showDay->getDbTimezone();
     //DateTime local
     $start = $this->getNextRepeatingPopulateStartDateTime($showDay);
     if (isset($last_show)) {
         $end = new DateTime($last_show, new DateTimeZone($timezone));
     } else {
         $end = $populateUntil;
     }
     // We will only need this if the repeat type is MONTHLY_WEEKLY
     list($weekNumberOfMonth, $dayOfWeek) = $this->getMonthlyWeeklyRepeatInterval(new DateTime($first_show, new DateTimeZone($timezone)));
     $this->repeatType = $showDay->getDbRepeatType();
     if ($last_show) {
         $utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
         $utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
     } else {
         $utcLastShowDateTime = null;
     }
     while ($start->getTimestamp() < $end->getTimestamp()) {
         list($utcStartDateTime, $utcEndDateTime) = $this->createUTCStartEndDateTime($start, $duration);
         /*
          * Make sure start date is less than populate until date AND
          * last show date is null OR start date is less than last show date
          */
         if ($utcStartDateTime->getTimestamp() <= $populateUntil->getTimestamp() && (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())) {
             $lastCreatedShow = clone $utcStartDateTime;
             /* There may not always be an instance when editing a show
              * This will be the case when we are adding a new show day to
              * a repeating show
              */
             if ($this->isUpdate && $this->hasInstance($utcStartDateTime)) {
                 $ccShowInstance = $this->getInstance($utcStartDateTime);
                 $newInstance = false;
                 $updateScheduleStatus = true;
             } else {
                 $newInstance = true;
                 $ccShowInstance = new CcShowInstances();
                 $updateScheduleStatus = false;
             }
             /* When editing the start/end time of a repeating show, we don't want to
              * change shows that started in the past. So check the start time.
              */
             if ($newInstance || $ccShowInstance->getDbStarts() > gmdate("Y-m-d H:i:s")) {
                 $ccShowInstance->setDbShowId($show_id);
                 $ccShowInstance->setDbStarts($utcStartDateTime);
                 $ccShowInstance->setDbEnds($utcEndDateTime);
                 $ccShowInstance->setDbRecord($record);
                 $ccShowInstance->save();
             }
             if ($this->isRebroadcast) {
                 $this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId());
             }
         }
         if ($this->repeatType == REPEAT_MONTHLY_WEEKLY) {
             $monthlyWeeklyStart = new DateTime($utcStartDateTime->format("Y-m"), new DateTimeZone("UTC"));
             $monthlyWeeklyStart->add(new DateInterval("P1M"));
             $start = $this->getNextMonthlyWeeklyRepeatDate($monthlyWeeklyStart, $timezone, $showDay->getDbStartTime(), $weekNumberOfMonth, $dayOfWeek);
         } else {
             $start = $this->getNextMonthlyMonthlyRepeatDate($start, $timezone, $showDay->getDbStartTime());
         }
     }
     $this->setNextRepeatingShowDate($start->format("Y-m-d"), $day, $show_id);
 }