Exemplo n.º 1
0
 public function populateShowFormAction()
 {
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled' ? false : true;
     $showInstanceId = $this->_getParam('id');
     $this->view->action = "edit-show";
     try {
         $showInstance = new Application_Model_ShowInstance($showInstanceId);
     } catch (Exception $e) {
         $this->view->show_error = true;
         return false;
     }
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     $isDJ = $user->isHostOfShow($showInstance->getShowId());
     if (!($isAdminOrPM || $isDJ)) {
         return;
     }
     if ($isDJ) {
         $this->view->action = "dj-edit-show";
     }
     $formWhat = new Application_Form_AddShowWhat();
     $formWho = new Application_Form_AddShowWho();
     $formWhen = new Application_Form_AddShowWhen();
     $formRepeats = new Application_Form_AddShowRepeats();
     $formStyle = new Application_Form_AddShowStyle();
     $formLive = new Application_Form_AddShowLiveStream();
     $formWhat->removeDecorator('DtDdWrapper');
     $formWho->removeDecorator('DtDdWrapper');
     $formWhen->removeDecorator('DtDdWrapper');
     $formRepeats->removeDecorator('DtDdWrapper');
     $formStyle->removeDecorator('DtDdWrapper');
     $this->view->what = $formWhat;
     $this->view->when = $formWhen;
     $this->view->repeats = $formRepeats;
     $this->view->who = $formWho;
     $this->view->style = $formStyle;
     $this->view->live = $formLive;
     $this->view->addNewShow = false;
     $show = new Application_Model_Show($showInstance->getShowId());
     $formWhat->populate(array('add_show_id' => $show->getId(), 'add_show_instance_id' => $showInstanceId, 'add_show_name' => $show->getName(), 'add_show_url' => $show->getUrl(), 'add_show_genre' => $show->getGenre(), 'add_show_description' => $show->getDescription()));
     $startsDateTime = new DateTime($show->getStartDate() . " " . $show->getStartTime(), new DateTimeZone("UTC"));
     $endsDateTime = new DateTime($show->getEndDate() . " " . $show->getEndTime(), new DateTimeZone("UTC"));
     $startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
     $endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
     $formWhen->populate(array('add_show_start_date' => $startsDateTime->format("Y-m-d"), 'add_show_start_time' => $startsDateTime->format("H:i"), 'add_show_end_date_no_repeat' => $endsDateTime->format("Y-m-d"), 'add_show_end_time' => $endsDateTime->format("H:i"), 'add_show_duration' => $show->getDuration(true), 'add_show_repeats' => $show->isRepeating() ? 1 : 0));
     if ($show->isStartDateTimeInPast()) {
         // for a non-repeating show, we should never allow user to change the start time.
         // for the repeating show, we should allow because the form works as repeating template form
         if (!$showInstance->getShow()->isRepeating()) {
             $formWhen->disableStartDateAndTime();
         } else {
             $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
         }
     }
     //need to get the days of the week in the php timezone (for the front end).
     $days = array();
     $showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
     foreach ($showDays as $showDay) {
         $showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone()));
         $showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get()));
         array_push($days, $showStartDay->format('w'));
     }
     $displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone()));
     $displayedEndDate->sub(new DateInterval("P1D"));
     //end dates are stored non-inclusively.
     $displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
     $formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(), 'add_show_day_check' => $days, 'add_show_end_date' => $displayedEndDate->format("Y-m-d"), 'add_show_no_end' => $show->getRepeatingEndDate() == ''));
     $hosts = array();
     $showHosts = CcShowHostsQuery::create()->filterByDbShow($showInstance->getShowId())->find();
     foreach ($showHosts as $showHost) {
         array_push($hosts, $showHost->getDbHost());
     }
     $formWho->populate(array('add_show_hosts' => $hosts));
     $formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(), 'add_show_color' => $show->getColor()));
     $formLive->populate($show->getLiveStreamInfo());
     if (!$isSaas) {
         $formRecord = new Application_Form_AddShowRR();
         $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
         $formRebroadcast = new Application_Form_AddShowRebroadcastDates();
         $formRecord->removeDecorator('DtDdWrapper');
         $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
         $formRebroadcast->removeDecorator('DtDdWrapper');
         $this->view->rr = $formRecord;
         $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
         $this->view->rebroadcast = $formRebroadcast;
         $formRecord->populate(array('add_show_record' => $show->isRecorded(), 'add_show_rebroadcast' => $show->isRebroadcast()));
         $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
         $rebroadcastsRelative = $show->getRebroadcastsRelative();
         $rebroadcastFormValues = array();
         $i = 1;
         foreach ($rebroadcastsRelative as $rebroadcast) {
             $rebroadcastFormValues["add_show_rebroadcast_date_{$i}"] = $rebroadcast['day_offset'];
             $rebroadcastFormValues["add_show_rebroadcast_time_{$i}"] = Application_Common_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
             $i++;
         }
         $formRebroadcast->populate($rebroadcastFormValues);
         $rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
         $rebroadcastAbsoluteFormValues = array();
         $i = 1;
         foreach ($rebroadcastsAbsolute as $rebroadcast) {
             $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_{$i}"] = $rebroadcast['start_date'];
             $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_{$i}"] = $rebroadcast['start_time'];
             $i++;
         }
         $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
         if (!$isAdminOrPM) {
             $formRecord->disable();
             $formAbsoluteRebroadcast->disable();
             $formRebroadcast->disable();
         }
     }
     if (!$isAdminOrPM) {
         $formWhat->disable();
         $formWho->disable();
         $formWhen->disable();
         $formRepeats->disable();
         $formStyle->disable();
     }
     $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
     $this->view->entries = 5;
 }
Exemplo n.º 2
0
 private function checkToDeleteShow($showId)
 {
     //UTC DateTime object
     $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
     $showDays = CcShowDaysQuery::create()->filterByDbShowId($showId)->findOne();
     $showEnd = $showDays->getDbLastShow();
     //there will always be more shows populated.
     if (is_null($showEnd)) {
         return false;
     }
     $lastShowStartDateTime = new DateTime("{$showEnd} {$showDays->getDbStartTime()}", new DateTimeZone($showDays->getDbTimezone()));
     //end dates were non inclusive.
     $lastShowStartDateTime = self::addDeltas($lastShowStartDateTime, -1, 0);
     //there's still some shows left to be populated.
     if ($lastShowStartDateTime->getTimestamp() > $showsPopUntil->getTimestamp()) {
         return false;
     }
     // check if there are any non deleted show instances remaining.
     $showInstances = CcShowInstancesQuery::create()->filterByDbShowId($showId)->filterByDbModifiedInstance(false)->filterByDbRebroadcast(0)->find();
     if (is_null($showInstances)) {
         return true;
     } else {
         if (count($showInstances) === 1) {
             $showInstance = $showInstances[0];
             $showDaysOld = CcShowDaysQuery::create()->filterByDbShowId($showId)->find();
             $tz = $showDaysOld[0]->getDbTimezone();
             $startDate = new DateTime($showInstance->getDbStarts(), new DateTimeZone("UTC"));
             $startDate->setTimeZone(new DateTimeZone($tz));
             $endDate = self::addDeltas($startDate, 1, 0);
             //make a new rule for a non repeating show.
             $showDayNew = new CcShowDays();
             $showDayNew->setDbFirstShow($startDate->format("Y-m-d"));
             $showDayNew->setDbLastShow($endDate->format("Y-m-d"));
             $showDayNew->setDbStartTime($startDate->format("H:i:s"));
             $showDayNew->setDbTimezone($tz);
             $showDayNew->setDbDay($startDate->format('w'));
             $showDayNew->setDbDuration($showDaysOld[0]->getDbDuration());
             $showDayNew->setDbRepeatType(-1);
             $showDayNew->setDbShowId($showDaysOld[0]->getDbShowId());
             $showDayNew->setDbRecord($showDaysOld[0]->getDbRecord());
             $showDayNew->save();
             //delete the old rules for repeating shows
             $showDaysOld->delete();
             //remove the old repeating deleted instances.
             $showInstances = CcShowInstancesQuery::create()->filterByDbShowId($showId)->filterByDbModifiedInstance(true)->delete();
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public function editShowAction()
 {
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new User($userInfo->id);
     if (!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
         return;
     }
     $showInstanceId = $this->_getParam('id');
     $formWhat = new Application_Form_AddShowWhat();
     $formWho = new Application_Form_AddShowWho();
     $formWhen = new Application_Form_AddShowWhen();
     $formRepeats = new Application_Form_AddShowRepeats();
     $formStyle = new Application_Form_AddShowStyle();
     $formRecord = new Application_Form_AddShowRR();
     $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
     $formRebroadcast = new Application_Form_AddShowRebroadcastDates();
     $formWhat->removeDecorator('DtDdWrapper');
     $formWho->removeDecorator('DtDdWrapper');
     $formWhen->removeDecorator('DtDdWrapper');
     $formRepeats->removeDecorator('DtDdWrapper');
     $formStyle->removeDecorator('DtDdWrapper');
     $formRecord->removeDecorator('DtDdWrapper');
     $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
     $formRebroadcast->removeDecorator('DtDdWrapper');
     $this->view->what = $formWhat;
     $this->view->when = $formWhen;
     $this->view->repeats = $formRepeats;
     $this->view->who = $formWho;
     $this->view->style = $formStyle;
     $this->view->rr = $formRecord;
     $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
     $this->view->rebroadcast = $formRebroadcast;
     $this->view->addNewShow = false;
     $showInstance = new ShowInstance($showInstanceId);
     $show = new Show($showInstance->getShowId());
     $formWhat->populate(array('add_show_id' => $show->getId(), 'add_show_name' => $show->getName(), 'add_show_url' => $show->getUrl(), 'add_show_genre' => $show->getGenre(), 'add_show_description' => $show->getDescription()));
     $formWhen->populate(array('add_show_start_date' => $show->getStartDate(), 'add_show_start_time' => DateHelper::removeSecondsFromTime($show->getStartTime()), 'add_show_end_date_no_repeat' => $show->getEndDate(), 'add_show_end_time' => DateHelper::removeSecondsFromTime($show->getEndTime()), 'add_show_duration' => $show->getDuration(true), 'add_show_repeats' => $show->isRepeating() ? 1 : 0));
     if ($show->isStartDateTimeInPast()) {
         $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
     }
     $days = array();
     $showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
     foreach ($showDays as $showDay) {
         array_push($days, $showDay->getDbDay());
     }
     $displayedEndDate = new DateTime($show->getRepeatingEndDate());
     $displayedEndDate->sub(new DateInterval("P1D"));
     //end dates are stored non-inclusively.
     $displayedEndDate = $displayedEndDate->format("Y-m-d");
     $formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(), 'add_show_day_check' => $days, 'add_show_end_date' => $displayedEndDate, 'add_show_no_end' => $show->getRepeatingEndDate() == ''));
     $formRecord->populate(array('add_show_record' => $show->isRecorded(), 'add_show_rebroadcast' => $show->isRebroadcast()));
     $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true));
     $rebroadcastsRelative = $show->getRebroadcastsRelative();
     $rebroadcastFormValues = array();
     $i = 1;
     foreach ($rebroadcastsRelative as $rebroadcast) {
         $rebroadcastFormValues["add_show_rebroadcast_date_{$i}"] = $rebroadcast['day_offset'];
         $rebroadcastFormValues["add_show_rebroadcast_time_{$i}"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
         $i++;
     }
     $formRebroadcast->populate($rebroadcastFormValues);
     $rebroadcastsAbsolute = $show->getRebroadcastsAbsolute();
     $rebroadcastAbsoluteFormValues = array();
     $i = 1;
     foreach ($rebroadcastsAbsolute as $rebroadcast) {
         $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_{$i}"] = $rebroadcast['start_date'];
         $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_{$i}"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
         $i++;
     }
     $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
     $hosts = array();
     $showHosts = CcShowHostsQuery::create()->filterByDbShow($showInstance->getShowId())->find();
     foreach ($showHosts as $showHost) {
         array_push($hosts, $showHost->getDbHost());
     }
     $formWho->populate(array('add_show_hosts' => $hosts));
     $formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(), 'add_show_color' => $show->getColor()));
     $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
     $this->view->entries = 5;
 }
Exemplo n.º 4
0
 public function isRecorded()
 {
     $ccShowDay = CcShowDaysQuery::create()->filterByDbShowId($this->getDbId())->filterByDbRecord(1)->findOne();
     return !is_null($ccShowDay);
 }
Exemplo n.º 5
0
 /**
  * Returns the number of related CcShowDays objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related CcShowDays objects.
  * @throws     PropelException
  */
 public function countCcShowDayss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if (null === $this->collCcShowDayss || null !== $criteria) {
         if ($this->isNew() && null === $this->collCcShowDayss) {
             return 0;
         } else {
             $query = CcShowDaysQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByCcShow($this)->count($con);
         }
     } else {
         return count($this->collCcShowDayss);
     }
 }
Exemplo n.º 6
0
 private static function setNextPop($next_date, $show_id, $day)
 {
     $nextInfo = explode(" ", $next_date);
     $repeatInfo = CcShowDaysQuery::create()->filterByDbShowId($show_id)->filterByDbDay($day)->findOne();
     $repeatInfo->setDbNextPopDate($nextInfo[0])->save();
 }
Exemplo n.º 7
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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             CcShowDaysQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Exemplo n.º 8
0
 public function setShowLastShow($p_dt)
 {
     //clone object since we are modifying it and it was passed by reference.
     $dt = clone $p_dt;
     $dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
     //add one day since the Last Show date in CcShowDays is non-inclusive.
     $dt->add(new DateInterval("P1D"));
     $showDay = CcShowDaysQuery::create()->filterByDbShowId($this->_showId)->findOne();
     $showDay->setDbLastShow($dt)->save();
 }
Exemplo n.º 9
0
 /**
  *
  * Show instances for repeating shows only get created up
  * until what is visible on the calendar. We need to set the
  * date for when the next repeating show instance should be created
  * as the user browses the calendar further.
  *
  * @param $nextDate
  * @param $showId
  * @param $day
  */
 private function setNextRepeatingShowDate($nextDate, $day, $showId)
 {
     $nextInfo = explode(" ", $nextDate);
     $repeatInfo = CcShowDaysQuery::create()->filterByDbShowId($showId)->filterByDbDay($day)->filterByDbRepeatType(-1, Criteria::NOT_EQUAL)->findOne();
     $repeatInfo->setDbNextPopDate($nextInfo[0])->save();
 }