示例#1
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;
 }
 /**
  * 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;
 }
示例#3
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);
 }
 /**
  * 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;
     }
 }
示例#5
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;
 }
示例#6
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();
 }
示例#7
0
文件: Show.php 项目: nidzix/Airtime
 /**
  * Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show
  * is recorded, it may have multiple rebroadcast dates, and so this function will create
  * those as well.
  *
  * @param array $p_showRow
  *        A row from cc_show_days table
  * @param DateTime $p_populateUntilDateTime
  *        DateTime object in UTC time. "shows_populated_until" date YY-mm-dd in cc_pref
  * @param string $p_interval
  *        Period of time between repeating shows (in php DateInterval notation 'P7D')
  */
 private static function populateRepeatingShow($p_showDaysRow, $p_populateUntilDateTime, $p_interval)
 {
     $show_id = $p_showDaysRow["show_id"];
     $next_pop_date = $p_showDaysRow["next_pop_date"];
     $first_show = $p_showDaysRow["first_show"];
     //non-UTC
     $last_show = $p_showDaysRow["last_show"];
     //non-UTC
     $start_time = $p_showDaysRow["start_time"];
     //non-UTC
     $duration = $p_showDaysRow["duration"];
     $day = $p_showDaysRow["day"];
     $record = $p_showDaysRow["record"];
     $timezone = $p_showDaysRow["timezone"];
     $currentUtcTimestamp = gmdate("Y-m-d H:i:s");
     if (isset($next_pop_date)) {
         $start = $next_pop_date . " " . $start_time;
     } else {
         $start = $first_show . " " . $start_time;
     }
     $utcStartDateTime = Application_Common_DateHelper::ConvertToUtcDateTime($start, $timezone);
     //convert $last_show into a UTC DateTime object, or null if there is no last show.
     $utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
     $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
     $rebroadcasts = Application_Common_Database::prepareAndExecute($sql, array(':show_id' => $show_id), 'all');
     $show = new Application_Model_Show($show_id);
     while ($utcStartDateTime->getTimestamp() <= $p_populateUntilDateTime->getTimestamp() && (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())) {
         list($utcStartDateTime, $utcEndDateTime) = self::createUTCStartEndDateTime($start, $duration, $timezone);
         if ($show->hasInstanceOnDate($utcStartDateTime)) {
             $ccShowInstance = $show->getInstanceOnDate($utcStartDateTime);
             if ($ccShowInstance->getDbModifiedInstance()) {
                 //show instance on this date has been deleted.
                 list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone);
                 continue;
             }
             $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() > $currentUtcTimestamp) {
             $ccShowInstance->setDbShowId($show_id);
             $ccShowInstance->setDbStarts($utcStartDateTime);
             $ccShowInstance->setDbEnds($utcEndDateTime);
             $ccShowInstance->setDbRecord($record);
             $ccShowInstance->save();
         }
         $show_instance_id = $ccShowInstance->getDbId();
         $showInstance = new Application_Model_ShowInstance($show_instance_id);
         /* If we are updating a show then make sure that the scheduled content within
          * the show is updated to the correct time. */
         if (!$newInstance) {
             $showInstance->correctScheduleStartTimes();
         }
         $showInstance->deleteRebroadcasts();
         self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
         list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone);
     }
     Application_Model_Show::setNextPop($start, $show_id, $day);
 }
示例#8
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);
 }