2013-02-26 16:20:02 +01:00
|
|
|
<?php
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
define('MAX_REBROADCAST_DATES', 10);
|
|
|
|
define('NO_REPEAT', -1);
|
|
|
|
define('REPEAT_WEEKLY', 0);
|
|
|
|
define('REPEAT_BI_WEEKLY', 1);
|
|
|
|
define('REPEAT_MONTHLY_MONTHLY', 2);
|
|
|
|
define('REPEAT_MONTHLY_WEEKLY', 3);
|
|
|
|
define('REPEAT_TRI_WEEKLY', 4);
|
|
|
|
define('REPEAT_QUAD_WEEKLY', 5);
|
2013-02-26 16:20:02 +01:00
|
|
|
|
|
|
|
class Application_Service_ShowService
|
|
|
|
{
|
2013-03-21 15:05:11 +01:00
|
|
|
private $ccShow;
|
2013-04-25 15:00:37 +02:00
|
|
|
private $isRecorded;
|
|
|
|
private $isRebroadcast;
|
|
|
|
private $repeatType;
|
|
|
|
private $isUpdate;
|
2013-10-07 20:16:20 +02:00
|
|
|
private $oldShowTimezone;
|
|
|
|
private $localShowStartHour;
|
|
|
|
private $localShowStartMin;
|
2013-10-07 21:53:33 +02:00
|
|
|
private $origCcShowDay;
|
2014-03-10 22:32:54 +01:00
|
|
|
private $origShowRepeatStatus;
|
2014-02-24 20:49:11 +01:00
|
|
|
private $instanceIdsForScheduleUpdates;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// keeps track of which show instances are new from either adding a new show
|
|
|
|
// day or changing the repeat type day during a show edit, or when a user moves
|
|
|
|
// forward in the calendar
|
2014-08-20 22:37:44 +02:00
|
|
|
private $newInstanceIdsCreated;
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public function __construct($showId = null, $showData = null, $isUpdate = false)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
|
|
|
if (!is_null($showId)) {
|
|
|
|
$this->ccShow = CcShowQuery::create()->findPk($showId);
|
|
|
|
}
|
2013-04-25 15:00:37 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if (isset($showData['add_show_repeats']) && $showData['add_show_repeats']) {
|
|
|
|
$this->repeatType = $showData['add_show_repeat_type'];
|
|
|
|
if ($showData['add_show_repeat_type'] == 2) {
|
|
|
|
$this->repeatType = $showData['add_show_monthly_repeat_type'];
|
2013-04-25 15:00:37 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->repeatType = -1;
|
|
|
|
}
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
$this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0;
|
|
|
|
$this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0;
|
|
|
|
$this->isUpdate = $isUpdate;
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->instanceIdsForScheduleUpdates = [];
|
|
|
|
$this->newInstanceIdsCreated = [];
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public function editRepeatingShowInstance($showData)
|
|
|
|
{
|
2013-04-01 20:42:35 +02:00
|
|
|
$service_user = new Application_Service_UserService();
|
|
|
|
$currentUser = $service_user->getCurrentUser();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$showData['add_show_duration'] = $this->formatShowDuration(
|
|
|
|
$showData['add_show_duration']
|
|
|
|
);
|
2013-04-01 20:42:35 +02:00
|
|
|
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$con->beginTransaction();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-04-01 20:42:35 +02:00
|
|
|
try {
|
|
|
|
if (!$currentUser->isAdminOrPM()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Permission denied');
|
2013-04-01 20:42:35 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$showId = $showData['add_show_id'];
|
2013-11-28 23:17:00 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// UPDATE SCHEDULE START TIME
|
2022-03-14 11:15:04 +01:00
|
|
|
// get the ccShow object to which this instance belongs
|
|
|
|
// so we can get the original start date and time
|
2013-11-28 23:17:00 +01:00
|
|
|
$this->ccShow = CcShowQuery::create()
|
2022-01-23 19:15:55 +01:00
|
|
|
->findPk($showId);
|
2013-04-01 20:42:35 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// DateTime in shows's local time
|
2021-10-11 16:10:47 +02:00
|
|
|
$newStartDateTime = new DateTime(
|
|
|
|
$showData['add_show_start_date'] . ' ' .
|
2022-07-07 20:01:15 +02:00
|
|
|
$showData['add_show_start_time'],
|
2021-10-11 16:10:47 +02:00
|
|
|
new DateTimeZone($showData['add_show_timezone'])
|
|
|
|
);
|
2013-04-01 20:42:35 +02:00
|
|
|
|
2013-04-30 19:58:03 +02:00
|
|
|
$ccShowInstanceOrig = CcShowInstancesQuery::create()
|
2022-01-23 19:15:55 +01:00
|
|
|
->findPk($showData['add_show_instance_id']);
|
2013-11-28 23:17:00 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// convert original start time into the show's local timezone
|
2013-11-28 23:17:00 +01:00
|
|
|
$origLocalStartDateTime = $ccShowInstanceOrig->getLocalStartDateTime();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$diff = $this->calculateShowStartDiff(
|
|
|
|
$newStartDateTime,
|
|
|
|
$origLocalStartDateTime
|
|
|
|
);
|
2013-04-01 20:42:35 +02:00
|
|
|
|
2013-11-28 23:17:00 +01:00
|
|
|
if ($diff != 0) {
|
2013-04-30 19:58:03 +02:00
|
|
|
Application_Service_SchedulerService::updateScheduleStartTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
[$showData['add_show_instance_id']],
|
|
|
|
$diff
|
|
|
|
);
|
2013-04-30 19:58:03 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
// UPDATE SCHEDULE START TIME ENDS
|
2013-04-01 20:42:35 +02:00
|
|
|
|
2013-11-28 23:17:00 +01:00
|
|
|
/*
|
|
|
|
* In the case where an instance is being edited for a second
|
|
|
|
* (or third, fourth, etc.) time we need to delete the old
|
|
|
|
* cc_show_day record
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2013-11-28 23:17:00 +01:00
|
|
|
* Since we don't store the cc_show_day ids we need to use the
|
|
|
|
* original start time from cc_show_instances, convert it to the show's
|
|
|
|
* local timezone, and find the record in cc_show_days
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2013-11-28 23:17:00 +01:00
|
|
|
* *** There is a flaw here: We have to assume the show timezone has
|
|
|
|
* *** not changed (make timezone readonly??)
|
|
|
|
*/
|
|
|
|
$origCcShowDay = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbRepeatType(-1)
|
2021-10-11 16:10:47 +02:00
|
|
|
->filterByDbFirstShow($origLocalStartDateTime->format('Y-m-d'))
|
|
|
|
->filterByDbStartTime($origLocalStartDateTime->format('H:i:s'))
|
2022-01-23 19:15:55 +01:00
|
|
|
->delete();
|
2013-11-28 23:17:00 +01:00
|
|
|
|
2013-12-02 19:13:41 +01:00
|
|
|
/*
|
|
|
|
* Set the new cc_show_day record
|
|
|
|
* Associates it with the current show_id and sets it to non-repeating
|
|
|
|
*/
|
|
|
|
$this->setCcShowDays($showData);
|
|
|
|
|
2013-11-28 23:17:00 +01:00
|
|
|
/*
|
|
|
|
* We need to find the new show day rule we just created by passing
|
|
|
|
* in the first show and start time in case multiple single
|
|
|
|
* instances have been edited out of the repeating sequence.
|
|
|
|
*/
|
|
|
|
$showDay = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbRepeatType(-1)
|
2021-10-11 16:10:47 +02:00
|
|
|
->filterByDbFirstShow($showData['add_show_start_date'])
|
|
|
|
->filterByDbStartTime($showData['add_show_start_time'] . ':00')
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
$ccShowInstance = $this->createNonRepeatingInstance(
|
|
|
|
$showDay,
|
|
|
|
$this->getPopulateShowUntilDateTIme()
|
|
|
|
);
|
2013-04-01 20:42:35 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// update cc_schedule with the new instance id
|
2013-04-30 21:54:04 +02:00
|
|
|
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
|
2013-11-28 23:17:00 +01:00
|
|
|
$selectCriteria = new Criteria();
|
2021-10-11 16:10:47 +02:00
|
|
|
$selectCriteria->add(CcSchedulePeer::INSTANCE_ID, $showData['add_show_instance_id']);
|
2013-11-28 23:17:00 +01:00
|
|
|
$updateCriteria = new Criteria();
|
|
|
|
$updateCriteria->add(CcSchedulePeer::INSTANCE_ID, $ccShowInstance->getDbId());
|
|
|
|
BasePeer::doUpdate($selectCriteria, $updateCriteria, $con);
|
|
|
|
|
2013-04-30 21:54:04 +02:00
|
|
|
$ccShowInstance->updateDbTimeFilled($con);
|
2013-12-02 19:13:41 +01:00
|
|
|
$ccShowInstance->updateScheduleStatus($con);
|
2014-09-19 19:02:38 +02:00
|
|
|
$ccShowInstance
|
2014-10-09 15:39:50 +02:00
|
|
|
->setDbDescription($showData['add_show_instance_description'])
|
2022-01-23 19:15:55 +01:00
|
|
|
->save();
|
2013-04-30 21:54:04 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// delete the edited instance from the repeating sequence
|
2014-09-19 19:02:38 +02:00
|
|
|
$ccShowInstanceOrig
|
2014-10-09 15:39:50 +02:00
|
|
|
->setDbModifiedInstance(true)
|
|
|
|
->setDbDescription($showData['add_show_instance_description'])
|
2022-01-23 19:15:55 +01:00
|
|
|
->save();
|
2013-04-01 20:42:35 +02:00
|
|
|
|
|
|
|
$con->commit();
|
|
|
|
Application_Model_RabbitMq::PushSchedule();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$con->rollback();
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::info('EXCEPTION: Show update failed.');
|
2013-04-01 20:42:35 +02:00
|
|
|
Logging::info($e->getMessage());
|
|
|
|
}
|
2013-03-27 21:25:39 +01:00
|
|
|
}
|
|
|
|
|
2013-10-07 20:16:20 +02:00
|
|
|
/**
|
|
|
|
* If a user is editing a show we need to store the original timezone and
|
|
|
|
* start time in case the show's timezone is changed and we are crossing
|
2021-10-11 16:10:47 +02:00
|
|
|
* over DST.
|
2013-10-07 20:16:20 +02:00
|
|
|
*/
|
|
|
|
private function storeOrigLocalShowInfo()
|
|
|
|
{
|
2013-12-02 13:19:31 +01:00
|
|
|
if ($this->ccShow->isRepeating()) {
|
2014-01-30 18:07:24 +01:00
|
|
|
$this->origCcShowDay = clone $this->ccShow->getFirstRepeatingCcShowDay();
|
2014-03-10 22:32:54 +01:00
|
|
|
$this->origShowRepeatStatus = true;
|
2013-12-02 13:19:31 +01:00
|
|
|
} else {
|
2014-01-30 18:07:24 +01:00
|
|
|
$this->origCcShowDay = clone $this->ccShow->getFirstCcShowDay();
|
2014-03-10 22:32:54 +01:00
|
|
|
$this->origShowRepeatStatus = false;
|
2013-12-02 13:19:31 +01:00
|
|
|
}
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2013-10-07 21:53:33 +02:00
|
|
|
$this->oldShowTimezone = $this->origCcShowDay->getDbTimezone();
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$origStartTime = explode(':', $this->origCcShowDay->getDbStartTime());
|
2013-10-07 20:16:20 +02:00
|
|
|
$this->localShowStartHour = $origStartTime[0];
|
|
|
|
$this->localShowStartMin = $origStartTime[1];
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
public function addUpdateShow($showData)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
2013-03-27 14:02:49 +01:00
|
|
|
$service_user = new Application_Service_UserService();
|
|
|
|
$currentUser = $service_user->getCurrentUser();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$showData['add_show_duration'] = $this->formatShowDuration(
|
|
|
|
$showData['add_show_duration']
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$con->beginTransaction();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
try {
|
2013-03-27 21:25:39 +01:00
|
|
|
if (!$currentUser->isAdminOrPM()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Permission denied');
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
2014-03-05 19:12:27 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// update ccShow
|
2013-04-25 15:00:37 +02:00
|
|
|
$this->setCcShow($showData);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$daysAdded = [];
|
2013-12-02 19:13:41 +01:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isUpdate) {
|
2014-10-09 15:39:50 +02:00
|
|
|
$showId = $this->ccShow->getDbId();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-10-09 15:39:50 +02:00
|
|
|
// Only delete the previous logo if a new one is being uploaded
|
2021-10-11 16:10:47 +02:00
|
|
|
if (array_key_exists('add_show_logo_name', $showData) && $showData['add_show_logo_name'] !== '') {
|
2015-02-04 21:09:27 +01:00
|
|
|
if (!Rest_ShowImageController::deleteShowImagesFromStor($showId)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Error deleting show images');
|
2014-10-09 15:39:50 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-02-25 23:16:14 +01:00
|
|
|
if (!$this->ccShow->getCcShowDayss()->isEmpty()) {
|
|
|
|
$this->storeOrigLocalShowInfo();
|
|
|
|
}
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2014-02-25 23:16:14 +01:00
|
|
|
$daysAdded = $this->delegateInstanceCleanup($showData);
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->deleteRebroadcastInstances();
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->deleteCcShowHosts();
|
2013-12-12 22:47:55 +01:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isRebroadcast) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// delete entry in cc_show_rebroadcast
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->deleteCcShowRebroadcasts();
|
|
|
|
}
|
2014-02-25 22:51:48 +01:00
|
|
|
|
|
|
|
$this->storeInstanceIds();
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// update ccShowDays
|
2013-04-25 15:00:37 +02:00
|
|
|
$this->setCcShowDays($showData);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// update ccShowRebroadcasts
|
2013-04-25 15:00:37 +02:00
|
|
|
$this->setCcShowRebroadcasts($showData);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// update ccShowHosts
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->setCcShowHosts($showData);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// create new ccShowInstances
|
2013-04-25 15:00:37 +02:00
|
|
|
$this->delegateInstanceCreation($daysAdded);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2013-10-07 21:53:33 +02:00
|
|
|
if ($this->isUpdate) {
|
2014-03-05 20:37:07 +01:00
|
|
|
/* If the show is repeating and the start date changes we need
|
|
|
|
* to ignore that difference when re-calculating schedule start times.
|
|
|
|
* Otherwise it might calculate a difference of a week, for example.
|
2014-02-25 23:22:17 +01:00
|
|
|
*/
|
2022-07-07 20:01:15 +02:00
|
|
|
if (
|
|
|
|
$this->ccShow->isRepeating()
|
|
|
|
&& $this->origCcShowDay->getLocalStartDateAndTime()->format('Y-m-d') != $showData['add_show_start_date']
|
|
|
|
) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$showData['add_show_start_date'] = $this->origCcShowDay->getLocalStartDateAndTime()->format('Y-m-d');
|
2014-03-05 20:37:07 +01:00
|
|
|
}
|
2014-02-25 23:22:17 +01:00
|
|
|
|
2015-05-11 20:57:20 +02:00
|
|
|
$this->adjustSchedule($showData);
|
2013-10-07 21:53:33 +02:00
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
$con->commit();
|
|
|
|
Application_Model_RabbitMq::PushSchedule();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$con->rollback();
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->isUpdate ? $action = 'update' : $action = 'creation';
|
|
|
|
Logging::info('EXCEPTION: Show ' . $action . ' failed.');
|
2013-03-21 15:05:11 +01:00
|
|
|
Logging::info($e->getMessage());
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2015-02-04 21:09:27 +01:00
|
|
|
// Added to pass along to the RESTful ShowImageController
|
2014-09-17 00:24:22 +02:00
|
|
|
return $this->ccShow->getDbId();
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2014-02-25 22:51:48 +01:00
|
|
|
/**
|
|
|
|
* Returns an array of instance ids that already exist
|
2021-10-11 16:10:47 +02:00
|
|
|
* We need this if a show is being updated so we can separate the
|
2014-02-25 22:51:48 +01:00
|
|
|
* instances that already exist and any new instances that
|
2021-10-11 16:10:47 +02:00
|
|
|
* get created (by adding a new repeat show day).
|
2014-02-25 22:51:48 +01:00
|
|
|
*/
|
|
|
|
private function storeInstanceIds()
|
|
|
|
{
|
2014-08-16 17:05:55 +02:00
|
|
|
$instances = $this->ccShow->getFutureCcShowInstancess();
|
2014-02-25 22:51:48 +01:00
|
|
|
foreach ($instances as $instance) {
|
|
|
|
$this->instanceIdsForScheduleUpdates[] = $instance->getDbId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
/**
|
2014-08-16 17:05:55 +02:00
|
|
|
* Adjusts the items in cc_schedule to reflect the
|
2021-10-11 16:10:47 +02:00
|
|
|
* new (if one) start and end time of the show getting updated.
|
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showData
|
2014-08-16 17:05:55 +02:00
|
|
|
*/
|
2013-10-07 21:53:33 +02:00
|
|
|
private function adjustSchedule($showData)
|
|
|
|
{
|
|
|
|
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
|
|
|
|
|
|
|
$this->updateScheduleStartEndTimes($showData);
|
|
|
|
|
2014-08-16 17:05:55 +02:00
|
|
|
$ccShowInstances = $this->ccShow->getFutureCcShowInstancess();
|
2013-10-07 21:53:33 +02:00
|
|
|
foreach ($ccShowInstances as $instance) {
|
|
|
|
$instance->updateScheduleStatus($con);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
/**
|
2013-09-06 12:35:31 +02:00
|
|
|
* Receives a cc_show id and determines whether to create a
|
2021-10-11 16:10:47 +02:00
|
|
|
* single show instance or repeating show instances.
|
|
|
|
*
|
|
|
|
* @param null|mixed $daysAdded
|
|
|
|
* @param null|mixed $end
|
|
|
|
* @param mixed $fillInstances
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
public function delegateInstanceCreation($daysAdded = null, $end = null, $fillInstances = false)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
|
|
|
$populateUntil = $this->getPopulateShowUntilDateTIme();
|
|
|
|
|
2013-03-25 21:28:53 +01:00
|
|
|
if (is_null($this->ccShow)) {
|
|
|
|
$ccShowDays = $this->getShowDaysInRange($populateUntil, $end);
|
|
|
|
} else {
|
2013-11-28 23:17:00 +01:00
|
|
|
if ($this->ccShow->isRepeating()) {
|
|
|
|
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
|
|
|
|
} else {
|
2022-03-14 11:15:04 +01:00
|
|
|
// $ccShowDays = $this->ccShow->getCcShowDayss();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-06-06 20:51:01 +02:00
|
|
|
/* Cannot use the above statement to get the cc_show_days
|
|
|
|
* object because it's getting the old object before the
|
|
|
|
* show was edited. clearInstancePool() didn't work.
|
|
|
|
*/
|
|
|
|
$ccShowDays = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($this->ccShow->getDbId())
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2013-11-28 23:17:00 +01:00
|
|
|
}
|
2013-03-25 21:28:53 +01:00
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2013-03-26 15:33:06 +01:00
|
|
|
if (!is_null($end)) {
|
|
|
|
$populateUntil = $end;
|
|
|
|
}
|
2013-03-28 19:25:40 +01:00
|
|
|
|
2013-06-19 07:17:32 +02:00
|
|
|
/* In case the user is moving forward in the calendar and there are
|
|
|
|
* linked shows in the schedule we need to keep track of each cc_show
|
|
|
|
* so we know which shows need to be filled with content
|
2013-09-06 12:35:31 +02:00
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
$ccShows = [];
|
2013-06-19 07:17:32 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
foreach ($ccShowDays as $day) {
|
2013-06-19 07:17:32 +02:00
|
|
|
$this->ccShow = $day->getCcShow();
|
2013-09-23 12:20:10 +02:00
|
|
|
$this->isRecorded = $this->ccShow->isRecorded();
|
|
|
|
$this->isRebroadcast = $this->ccShow->isRebroadcast();
|
2013-09-20 16:35:46 +02:00
|
|
|
|
2014-08-20 22:37:44 +02:00
|
|
|
$show_id = $day->getDbShowId();
|
|
|
|
if (!isset($ccShows[$show_id])) {
|
|
|
|
$ccShows[$show_id] = $day->getccShow();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// keep track of the new show instances getting created
|
|
|
|
// so we can fill their schedule after
|
2014-08-20 22:37:44 +02:00
|
|
|
if (!isset($this->newInstanceIdsCreated[$show_id])) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->newInstanceIdsCreated[$show_id] = [];
|
2013-06-19 07:17:32 +02:00
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
switch ($day->getDbRepeatType()) {
|
|
|
|
case NO_REPEAT:
|
2013-04-25 15:00:37 +02:00
|
|
|
$this->createNonRepeatingInstance($day, $populateUntil);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
case REPEAT_WEEKLY:
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->createWeeklyRepeatInstances(
|
|
|
|
$day,
|
|
|
|
$populateUntil,
|
|
|
|
REPEAT_WEEKLY,
|
|
|
|
new DateInterval('P7D'),
|
|
|
|
$daysAdded
|
|
|
|
);
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
case REPEAT_BI_WEEKLY:
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->createWeeklyRepeatInstances(
|
|
|
|
$day,
|
|
|
|
$populateUntil,
|
|
|
|
REPEAT_BI_WEEKLY,
|
|
|
|
new DateInterval('P14D'),
|
|
|
|
$daysAdded
|
|
|
|
);
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-09-03 02:25:22 +02:00
|
|
|
case REPEAT_TRI_WEEKLY:
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->createWeeklyRepeatInstances(
|
|
|
|
$day,
|
|
|
|
$populateUntil,
|
|
|
|
REPEAT_TRI_WEEKLY,
|
|
|
|
new DateInterval('P21D'),
|
|
|
|
$daysAdded
|
|
|
|
);
|
|
|
|
|
2013-09-03 02:25:22 +02:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-09-03 02:25:22 +02:00
|
|
|
case REPEAT_QUAD_WEEKLY:
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->createWeeklyRepeatInstances(
|
|
|
|
$day,
|
|
|
|
$populateUntil,
|
|
|
|
REPEAT_QUAD_WEEKLY,
|
|
|
|
new DateInterval('P28D'),
|
|
|
|
$daysAdded
|
|
|
|
);
|
|
|
|
|
2013-09-03 02:25:22 +02:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
case REPEAT_MONTHLY_MONTHLY:
|
2013-06-07 17:16:19 +02:00
|
|
|
$this->createMonthlyRepeatInstances($day, $populateUntil);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
case REPEAT_MONTHLY_WEEKLY:
|
2013-06-07 17:16:19 +02:00
|
|
|
$this->createMonthlyRepeatInstances($day, $populateUntil);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-04-25 15:00:37 +02:00
|
|
|
|
2013-06-19 07:17:32 +02:00
|
|
|
foreach ($ccShows as $ccShow) {
|
|
|
|
if (($this->isUpdate || $fillInstances) && $ccShow->isLinked()) {
|
2014-08-21 22:40:01 +02:00
|
|
|
Application_Service_SchedulerService::fillLinkedInstances(
|
2021-10-11 16:10:47 +02:00
|
|
|
$ccShow,
|
|
|
|
$this->newInstanceIdsCreated[$ccShow->getDbId()]
|
|
|
|
);
|
2013-06-19 07:17:32 +02:00
|
|
|
}
|
2013-05-02 17:40:56 +02:00
|
|
|
}
|
2013-05-10 20:17:54 +02:00
|
|
|
|
2014-08-15 21:32:52 +02:00
|
|
|
/*if (isset($this->linkedShowContent)) {
|
2013-05-10 20:17:54 +02:00
|
|
|
Application_Service_SchedulerService::fillPreservedLinkedShowContent(
|
|
|
|
$this->ccShow, $this->linkedShowContent);
|
2014-08-15 21:32:52 +02:00
|
|
|
}*/
|
2013-05-10 20:17:54 +02:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
return $this->ccShow;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2013-03-25 21:28:53 +01:00
|
|
|
private function getShowDaysInRange($start, $end)
|
|
|
|
{
|
2015-06-26 20:42:52 +02:00
|
|
|
$endTimeString = $end->format(DEFAULT_TIMESTAMP_FORMAT);
|
2013-03-25 21:28:53 +01:00
|
|
|
if (!is_null($start)) {
|
2015-06-26 20:42:52 +02:00
|
|
|
$startTimeString = $start->format(DEFAULT_TIMESTAMP_FORMAT);
|
2013-03-25 21:28:53 +01:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$today_timestamp = new DateTime('now', new DateTimeZone('UTC'));
|
2015-06-26 20:42:52 +02:00
|
|
|
$startTimeString = $today_timestamp->format(DEFAULT_TIMESTAMP_FORMAT);
|
2013-03-25 21:28:53 +01:00
|
|
|
}
|
|
|
|
|
2013-03-26 15:33:06 +01:00
|
|
|
$c = new Criteria();
|
|
|
|
$c->add(CcShowDaysPeer::FIRST_SHOW, $endTimeString, Criteria::LESS_THAN);
|
|
|
|
$c->addAnd(CcShowDaysPeer::LAST_SHOW, $startTimeString, Criteria::GREATER_THAN);
|
2013-05-01 21:20:55 +02:00
|
|
|
$c->addAnd(CcShowDaysPeer::REPEAT_TYPE, -1, Criteria::NOT_EQUAL);
|
2013-03-26 15:33:06 +01:00
|
|
|
$c->addOr(CcShowDaysPeer::LAST_SHOW, null, Criteria::ISNULL);
|
2013-03-25 21:28:53 +01:00
|
|
|
|
2013-03-26 15:33:06 +01:00
|
|
|
return CcShowDaysPeer::doSelect($c);
|
2013-03-25 21:28:53 +01:00
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
public static function formatShowDuration($duration)
|
|
|
|
{
|
|
|
|
$hPos = strpos($duration, 'h');
|
|
|
|
$mPos = strpos($duration, 'm');
|
|
|
|
|
|
|
|
$hValue = 0;
|
|
|
|
$mValue = 0;
|
|
|
|
|
|
|
|
if ($hPos !== false) {
|
|
|
|
$hValue = trim(substr($duration, 0, $hPos));
|
|
|
|
}
|
|
|
|
if ($mPos !== false) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$hPos = $hPos === false ? 0 : $hPos + 1;
|
|
|
|
$mValue = trim(substr($duration, $hPos, -1));
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
return $hValue . ':' . $mValue;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes all the cc_show_days entries for a specific show
|
|
|
|
* that is currently being edited. They will get recreated with
|
2021-10-11 16:10:47 +02:00
|
|
|
* the new show day specs.
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
|
|
|
private function deleteCcShowDays()
|
|
|
|
{
|
|
|
|
CcShowDaysQuery::create()->filterByDbShowId($this->ccShow->getDbId())->delete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function deleteRebroadcastInstances()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-03-21 15:05:11 +01:00
|
|
|
DELETE FROM cc_show_instances
|
|
|
|
WHERE starts > :timestamp::TIMESTAMP
|
|
|
|
AND show_id = :showId
|
|
|
|
AND rebroadcast = 1;
|
|
|
|
SQL;
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute($sql, [
|
2013-03-21 15:05:11 +01:00
|
|
|
':showId' => $this->ccShow->getDbId(),
|
2022-07-07 20:01:15 +02:00
|
|
|
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
|
|
|
|
], 'execute');
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2014-03-07 20:52:32 +01:00
|
|
|
private function deleteAllShowDays($showId)
|
|
|
|
{
|
|
|
|
CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
2022-01-23 19:15:55 +01:00
|
|
|
->delete();
|
2014-03-07 20:52:32 +01:00
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* TODO: This function is messy. Needs refactoring.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* When editing a show we may need to perform some actions to reflect the new specs:
|
|
|
|
* - Delete some show instances
|
|
|
|
* - Update duration
|
|
|
|
* - Update start and end time
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* @param $showData edit show form values in raw form
|
|
|
|
*/
|
2013-04-25 15:00:37 +02:00
|
|
|
private function delegateInstanceCleanup($showData)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
|
|
|
$showId = $this->ccShow->getDbId();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$daysAdded = [];
|
2013-04-01 20:42:35 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// CcShowDay object
|
2013-12-02 13:19:31 +01:00
|
|
|
if ($this->ccShow->isRepeating()) {
|
|
|
|
$currentShowDay = $this->ccShow->getFirstRepeatingCcShowDay();
|
2014-03-07 20:52:32 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// all cc_show_days
|
2014-03-07 20:52:32 +01:00
|
|
|
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
|
2013-12-02 13:19:31 +01:00
|
|
|
} else {
|
|
|
|
$currentShowDay = $this->ccShow->getFirstCcShowDay();
|
2014-03-07 20:52:32 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// all cc_show_days
|
2014-03-07 20:52:32 +01:00
|
|
|
$ccShowDays = $this->ccShow->getCcShowDayss();
|
2013-12-02 13:19:31 +01:00
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// new end date in the show's timezone (from the select box)
|
2013-03-21 15:05:11 +01:00
|
|
|
$endDateTime = $this->calculateEndDate($showData);
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// repeat option was toggled
|
2013-03-21 15:05:11 +01:00
|
|
|
if ($showData['add_show_repeats'] != $currentShowDay->isRepeating()) {
|
|
|
|
$this->deleteAllRepeatInstances($currentShowDay, $showId);
|
2014-03-07 20:52:32 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if (!$showData['add_show_repeats']) {
|
2014-03-10 22:41:57 +01:00
|
|
|
$this->deleteAllShowDays($showId);
|
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// if repeat option was checked we need to treat the current show day
|
|
|
|
// as a new show day so the repeat instances get created properly
|
|
|
|
// in createWeeklyRepeatInstances()
|
2013-04-01 20:42:35 +02:00
|
|
|
if ($showData['add_show_repeats']) {
|
|
|
|
array_push($daysAdded, $currentShowDay->getDbDay());
|
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($showData['add_show_repeats']) {
|
|
|
|
$localShowStart = $currentShowDay->getLocalStartDateAndTime();
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// if the start date changes, these are the repeat types
|
|
|
|
// that require show instance deletion
|
2022-07-07 20:01:15 +02:00
|
|
|
$deleteRepeatTypes = [
|
|
|
|
REPEAT_BI_WEEKLY, REPEAT_TRI_WEEKLY, REPEAT_QUAD_WEEKLY, REPEAT_MONTHLY_MONTHLY,
|
|
|
|
REPEAT_MONTHLY_WEEKLY,
|
|
|
|
];
|
|
|
|
|
|
|
|
if (
|
|
|
|
in_array($this->repeatType, $deleteRepeatTypes)
|
|
|
|
&& $showData['add_show_start_date'] != $localShowStart->format('Y-m-d')
|
|
|
|
) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// Start date has changed when repeat type is bi-weekly or monthly.
|
|
|
|
// This screws up the repeating positions of show instances, so
|
|
|
|
// we need to delete them (CC-2351)
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->deleteAllInstances($showId);
|
|
|
|
}
|
|
|
|
|
|
|
|
$currentRepeatType = $currentShowDay->getDbRepeatType();
|
2022-03-14 11:15:04 +01:00
|
|
|
// only delete instances if the show being edited was already repeating
|
|
|
|
// and the repeat type changed
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($currentRepeatType != -1 && $this->repeatType != $currentRepeatType) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->deleteAllInstances($showId);
|
2014-03-07 20:52:32 +01:00
|
|
|
$this->deleteAllShowDays($showId);
|
|
|
|
|
2023-12-18 19:02:03 +01:00
|
|
|
// when repeating by day of the month (1st, 2nd, etc.) we do not store the repeat week days
|
2013-12-02 19:13:41 +01:00
|
|
|
} elseif ($currentRepeatType != 2) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// repeat type is the same, check if the days of the week are the same
|
2013-03-21 15:05:11 +01:00
|
|
|
$repeatingDaysChanged = false;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDays = [];
|
2013-03-21 15:05:11 +01:00
|
|
|
foreach ($ccShowDays as $day) {
|
|
|
|
$showDays[] = $day->getDbDay();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($showData['add_show_day_check']) == count($showDays)) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// same number of days checked, lets see if they are the same numbers
|
2013-03-21 15:05:11 +01:00
|
|
|
$intersect = array_intersect($showData['add_show_day_check'], $showDays);
|
|
|
|
if (count($intersect) != count($showData['add_show_day_check'])) {
|
|
|
|
$repeatingDaysChanged = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$repeatingDaysChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($repeatingDaysChanged) {
|
|
|
|
$daysRemoved = array_diff($showDays, $showData['add_show_day_check']);
|
2021-10-11 16:10:47 +02:00
|
|
|
$newDays = array_diff($showData['add_show_day_check'], $showDays);
|
2013-04-01 20:42:35 +02:00
|
|
|
foreach ($newDays as $newDay) {
|
|
|
|
array_push($daysAdded, $newDay);
|
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
if (count($daysRemoved) > 0) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// delete repeating show instances for the repeating
|
|
|
|
// days that were removed
|
2014-08-15 21:32:52 +02:00
|
|
|
/*if ($this->ccShow->isLinked()) {
|
2013-05-10 20:17:54 +02:00
|
|
|
$this->preserveLinkedShowContent();
|
2014-08-15 21:32:52 +02:00
|
|
|
}*/
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->deleteRemovedShowDayInstances(
|
|
|
|
$daysRemoved,
|
|
|
|
$ccShowDays,
|
|
|
|
$showId
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
if (
|
|
|
|
$showData['add_show_start_date'] != $localShowStart->format('Y-m-d')
|
|
|
|
|| $showData['add_show_start_time'] != $localShowStart->format('H:i')
|
|
|
|
) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// start date has been pushed forward so we need to delete
|
|
|
|
// any instances of this show scheduled before the new start date
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($showData['add_show_start_date'] > $localShowStart->format('Y-m-d')) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->deleteInstancesBeforeDate($showData['add_show_start_date'], $showId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// get the endate from the past for this show.
|
|
|
|
// check if this is null if "no end"
|
2013-12-12 23:18:03 +01:00
|
|
|
$currentShowEndDateTime = $this->getRepeatingEndDate();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-03-04 17:29:49 +01:00
|
|
|
if ($endDateTime && $currentShowEndDateTime != $endDateTime) {
|
2014-10-09 15:39:50 +02:00
|
|
|
$endDate = clone $endDateTime;
|
2021-10-11 16:10:47 +02:00
|
|
|
$endDate->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// show's "No End" option was toggled
|
|
|
|
// or the end date comes earlier
|
2013-12-12 23:18:03 +01:00
|
|
|
if (is_null($currentShowEndDateTime) || ($endDateTime < $currentShowEndDateTime)) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// "No End" option was unchecked so we need to delete the
|
|
|
|
// repeat instances that are scheduled after the new end date
|
|
|
|
// OR
|
|
|
|
// end date was pushed back so we have to delete any
|
|
|
|
// instances of this show scheduled after the new end date
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->deleteInstancesFromDate($endDate->format('Y-m-d'), $showId);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-12 23:18:03 +01:00
|
|
|
}
|
2013-04-01 20:42:35 +02:00
|
|
|
|
|
|
|
return $daysAdded;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2014-08-15 21:32:52 +02:00
|
|
|
/*private function preserveLinkedShowContent()
|
2013-05-10 20:17:54 +02:00
|
|
|
{
|
2014-08-15 21:32:52 +02:00
|
|
|
// Get show content from any future linked instance. It doesn't
|
|
|
|
// matter which instance since content is the same in all.
|
|
|
|
//
|
2014-08-16 17:05:55 +02:00
|
|
|
$ccShowInstance = $this->ccShow->getFutureCcShowInstancess()->getFirst();
|
2013-05-10 20:17:54 +02:00
|
|
|
|
2014-03-07 20:52:32 +01:00
|
|
|
if (!$ccShowInstance) {
|
|
|
|
return;
|
|
|
|
}
|
2013-05-10 20:17:54 +02:00
|
|
|
$ccSchedules = CcScheduleQuery::create()
|
|
|
|
->filterByDbInstanceId($ccShowInstance->getDbId())
|
|
|
|
->find();
|
|
|
|
|
|
|
|
if (!$ccSchedules->isEmpty()) {
|
|
|
|
$this->linkedShowContent = $ccSchedules;
|
|
|
|
}
|
2014-08-15 21:32:52 +02:00
|
|
|
}*/
|
2013-05-10 20:17:54 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// returns a DateTime of the current show end date set to the timezone of the show.
|
2013-03-21 15:05:11 +01:00
|
|
|
public function getRepeatingEndDate()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-12-12 23:18:03 +01:00
|
|
|
SELECT last_show, timezone
|
2013-03-21 15:05:11 +01:00
|
|
|
FROM cc_show_days
|
|
|
|
WHERE show_id = :showId
|
|
|
|
ORDER BY last_show DESC
|
2013-12-12 23:18:03 +01:00
|
|
|
LIMIT 1
|
2013-03-21 15:05:11 +01:00
|
|
|
SQL;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$query = Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
|
|
|
['showId' => $this->ccShow->getDbId()],
|
|
|
|
'single'
|
|
|
|
);
|
|
|
|
|
2013-12-12 23:18:03 +01:00
|
|
|
$date = null;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
if ($query !== false && isset($query['last_show'])) {
|
2014-10-09 15:39:50 +02:00
|
|
|
$date = new DateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$query['last_show'],
|
|
|
|
new DateTimeZone($query['timezone'])
|
2014-10-09 15:39:50 +02:00
|
|
|
);
|
2013-12-12 23:18:03 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-12-12 23:18:03 +01:00
|
|
|
return $date;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function deleteInstancesFromDate($endDate, $showId)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-03-21 15:05:11 +01:00
|
|
|
DELETE FROM cc_show_instances
|
|
|
|
WHERE date(starts) >= :endDate::DATE
|
|
|
|
AND starts > :timestamp::TIMESTAMP
|
|
|
|
AND show_id = :showId
|
|
|
|
SQL;
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute($sql, [
|
2015-06-26 20:42:52 +02:00
|
|
|
':endDate' => $endDate, ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
|
2022-07-07 20:01:15 +02:00
|
|
|
':showId' => $showId,
|
|
|
|
], 'execute');
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function deleteInstancesBeforeDate($newStartDate, $showId)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-03-21 15:05:11 +01:00
|
|
|
DELETE
|
|
|
|
FROM cc_show_instances
|
|
|
|
WHERE date(starts) < :newStartDate::DATE
|
|
|
|
AND starts > :timestamp::TIMESTAMP
|
|
|
|
AND show_id = :showId
|
|
|
|
SQL;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute($sql, [
|
|
|
|
':newStartDate' => $newStartDate, ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
|
2022-07-07 20:01:15 +02:00
|
|
|
':showId' => $showId,
|
|
|
|
], 'execute');
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here ...
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2023-05-25 15:06:18 +02:00
|
|
|
* @param $daysRemoved array of days (days of the week) removed
|
2023-12-29 15:28:57 +01:00
|
|
|
* (days of the week are represented numerically
|
|
|
|
* 0=>sunday, 1=>monday, 2=>tuesday, etc.)
|
2023-05-25 15:06:18 +02:00
|
|
|
* @param $showDays array of ccShowDays objects
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showId
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
|
|
|
private function deleteRemovedShowDayInstances($daysRemoved, $showDays, $showId)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$daysRemovedUTC = [];
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// convert the start day of the week to UTC
|
2013-03-21 15:05:11 +01:00
|
|
|
foreach ($showDays as $showDay) {
|
|
|
|
if (in_array($showDay->getDbDay(), $daysRemoved)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->reload();
|
|
|
|
$startDay = $showDay->getUTCStartDateAndTime();
|
|
|
|
$daysRemovedUTC[] = $startDay->format('w');
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-27 21:25:39 +01:00
|
|
|
foreach ($daysRemoved as $day) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// delete the cc_show_day entries as well
|
2013-03-27 21:25:39 +01:00
|
|
|
CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbDay($day)
|
2022-01-23 19:15:55 +01:00
|
|
|
->delete();
|
2013-03-27 21:25:39 +01:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$uncheckedDays = pg_escape_string(implode(',', $daysRemovedUTC));
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
$sql = <<<SQL
|
|
|
|
DELETE
|
|
|
|
FROM cc_show_instances
|
2021-10-11 16:10:47 +02:00
|
|
|
WHERE EXTRACT(DOW FROM starts) IN ({$uncheckedDays})
|
2013-03-21 15:05:11 +01:00
|
|
|
AND starts > :timestamp::TIMESTAMP
|
|
|
|
AND show_id = :showId
|
|
|
|
SQL;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
|
|
|
[
|
2022-07-07 20:01:15 +02:00
|
|
|
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT), ':showId' => $showId,
|
|
|
|
],
|
2021-10-11 16:10:47 +02:00
|
|
|
'execute'
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public function deleteShow($instanceId, $singleInstance = false)
|
2013-04-03 17:46:46 +02:00
|
|
|
{
|
|
|
|
$service_user = new Application_Service_UserService();
|
|
|
|
$currentUser = $service_user->getCurrentUser();
|
|
|
|
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$con->beginTransaction();
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
try {
|
|
|
|
if (!$currentUser->isAdminOrPM()) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Permission denied');
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$ccShowInstance = CcShowInstancesQuery::create()
|
2022-01-23 19:15:55 +01:00
|
|
|
->findPk($instanceId);
|
2013-04-03 17:46:46 +02:00
|
|
|
if (!$ccShowInstance) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Could not find show instance');
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
2014-09-17 16:27:14 +02:00
|
|
|
// Delete show images
|
2013-04-03 17:46:46 +02:00
|
|
|
$showId = $ccShowInstance->getDbShowId();
|
2015-09-10 00:47:43 +02:00
|
|
|
if (!$singleInstance && !Rest_ShowImageController::deleteShowImagesFromStor($showId)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Error deleting show images');
|
2014-10-09 15:39:50 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
if ($singleInstance) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$ccShowInstances = [$ccShowInstance];
|
2013-04-03 17:46:46 +02:00
|
|
|
} else {
|
|
|
|
$ccShowInstances = CcShowInstancesQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbStarts($ccShowInstance->getDbStarts(), Criteria::GREATER_EQUAL)
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 20:42:52 +02:00
|
|
|
if (gmdate(DEFAULT_TIMESTAMP_FORMAT) <= $ccShowInstance->getDbEnds()) {
|
2014-01-13 17:41:44 +01:00
|
|
|
$this->deleteShowInstances($ccShowInstances, $showId);
|
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Cannot delete a show instance in the past');
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
2013-05-16 21:03:10 +02:00
|
|
|
Application_Model_StoredFile::updatePastFilesIsScheduled();
|
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
Application_Model_RabbitMq::PushSchedule();
|
|
|
|
|
|
|
|
$con->commit();
|
2014-01-13 17:41:44 +01:00
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
return $showId;
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$con->rollback();
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::info('Delete show instance failed');
|
2013-04-03 17:46:46 +02:00
|
|
|
Logging::info($e->getMessage());
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
public function deleteShowInstances($ccShowInstances, $showId)
|
|
|
|
{
|
|
|
|
foreach ($ccShowInstances as $ccShowInstance) {
|
|
|
|
$instanceId = $ccShowInstance->getDbId();
|
|
|
|
|
|
|
|
$ccShowInstance
|
|
|
|
->setDbModifiedInstance(true)
|
2022-01-23 19:15:55 +01:00
|
|
|
->save();
|
2013-04-03 17:46:46 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// delete the rebroadcasts of the removed recorded show
|
2013-04-03 17:46:46 +02:00
|
|
|
if ($ccShowInstance->isRecorded()) {
|
|
|
|
CcShowInstancesQuery::create()
|
|
|
|
->filterByDbOriginalShow($instanceId)
|
2022-01-23 19:15:55 +01:00
|
|
|
->delete();
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// delete all files scheduled in cc_schedules table
|
2013-04-03 17:46:46 +02:00
|
|
|
CcScheduleQuery::create()
|
|
|
|
->filterByDbInstanceId($instanceId)
|
2022-01-23 19:15:55 +01:00
|
|
|
->delete();
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->checkToDeleteCcShow($showId)) {
|
|
|
|
CcShowQuery::create()
|
|
|
|
->filterByDbId($showId)
|
2022-01-23 19:15:55 +01:00
|
|
|
->delete();
|
2023-12-18 19:02:03 +01:00
|
|
|
// There is only one cc_show_instance if the user selects 'Delete This Instance'
|
|
|
|
// There is more than one cc_show_instance if the user selects 'Delete This
|
|
|
|
// Instance and All Following'. We only need to set the last_show value
|
|
|
|
// when 'Delete This Instance and All Following' has been selected
|
2014-01-13 17:41:44 +01:00
|
|
|
} elseif (count($ccShowInstances) > 1) {
|
|
|
|
$this->setLastRepeatingShowDate($showId);
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-13 17:41:44 +01:00
|
|
|
private function setLastRepeatingShowDate($showId)
|
2013-04-03 17:46:46 +02:00
|
|
|
{
|
|
|
|
$ccShowInstances = CcShowInstancesQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbModifiedInstance(false)
|
|
|
|
->filterByDbRebroadcast(0)
|
2013-06-18 22:56:16 +02:00
|
|
|
->orderByDbStarts()
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2013-04-03 17:46:46 +02:00
|
|
|
|
2013-06-18 22:56:16 +02:00
|
|
|
/* We need to update the last_show in cc_show_days so the instances
|
|
|
|
* don't get recreated as the user moves forward in the calendar
|
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
$lastShowDays = [];
|
2013-12-04 16:05:32 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// get the show's timezone
|
2014-01-13 17:41:44 +01:00
|
|
|
$ccShow = CcShowQuery::create()->findPk($showId);
|
|
|
|
if ($ccShow->isRepeating()) {
|
|
|
|
$showTimezone = $ccShow->getFirstRepeatingCcShowDay()->getDbTimezone();
|
|
|
|
} else {
|
|
|
|
$showTimezone = $ccShow->getFirstCcShowDay()->getDbTimezone();
|
|
|
|
}
|
2013-12-04 16:05:32 +01:00
|
|
|
|
2014-01-13 17:41:44 +01:00
|
|
|
/* Creates an array where the key is the day of the week (monday,
|
|
|
|
* tuesday, etc.) and the value is the last show date for each
|
|
|
|
* day of the week. We will use this array to update the last_show
|
|
|
|
* for each cc_show_days entry of a cc_show
|
|
|
|
*/
|
|
|
|
foreach ($ccShowInstances as $instance) {
|
|
|
|
$instanceStartDT = $instance->getDbStarts(null);
|
|
|
|
$instanceStartDT->setTimezone(new DateTimeZone($showTimezone));
|
2021-10-11 16:10:47 +02:00
|
|
|
$lastShowDays[$instanceStartDT->format('w')] = $instanceStartDT;
|
2014-01-13 17:41:44 +01:00
|
|
|
}
|
2013-04-03 17:46:46 +02:00
|
|
|
|
2014-01-13 17:41:44 +01:00
|
|
|
foreach ($lastShowDays as $dayOfWeek => $lastShowStartDT) {
|
|
|
|
$ccShowDay = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbDay($dayOfWeek)
|
|
|
|
->filterByDbRepeatType(-1, Criteria::NOT_EQUAL)
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2014-01-13 17:41:44 +01:00
|
|
|
|
|
|
|
if (isset($ccShowDay)) {
|
|
|
|
$lastShowStartDT->setTimeZone(new DateTimeZone(
|
2021-10-11 16:10:47 +02:00
|
|
|
$ccShowDay->getDbTimezone()
|
|
|
|
));
|
2014-01-13 17:41:44 +01:00
|
|
|
$lastShowEndDT = Application_Service_CalendarService::addDeltas(
|
2021-10-11 16:10:47 +02:00
|
|
|
$lastShowStartDT,
|
|
|
|
1,
|
|
|
|
0
|
|
|
|
);
|
2014-01-13 17:41:44 +01:00
|
|
|
|
|
|
|
$ccShowDay
|
2021-10-11 16:10:47 +02:00
|
|
|
->setDbLastShow($lastShowEndDT->format('Y-m-d'))
|
2022-01-23 19:15:55 +01:00
|
|
|
->save();
|
2013-06-18 22:56:16 +02:00
|
|
|
}
|
2013-04-03 17:46:46 +02:00
|
|
|
}
|
|
|
|
|
2014-01-13 17:41:44 +01:00
|
|
|
// NOTE: Some cc_show_day records may not get updated because there may not be an instance
|
|
|
|
// left on one of the repeating days so we have to find the entries where the last_show is
|
|
|
|
// still null
|
|
|
|
$showDays = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbRepeatType(0, Criteria::GREATER_EQUAL)
|
|
|
|
->filterByDbLastShow(null)
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2014-01-13 17:41:44 +01:00
|
|
|
foreach ($showDays as $showDay) {
|
|
|
|
$showDay->setDbLastShow($showDay->getDbFirstShow())->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function checkToDeleteCcShow($showId)
|
|
|
|
{
|
|
|
|
// check if there are any non deleted show instances remaining.
|
|
|
|
$ccShowInstances = CcShowInstancesQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbModifiedInstance(false)
|
|
|
|
->filterByDbRebroadcast(0)
|
|
|
|
->orderByDbStarts()
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2014-01-13 17:41:44 +01:00
|
|
|
|
|
|
|
if ($ccShowInstances->isEmpty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-03 17:46:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
private function deleteAllInstances($showId)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-03-21 15:05:11 +01:00
|
|
|
DELETE
|
|
|
|
FROM cc_show_instances
|
|
|
|
WHERE starts > :timestamp::TIMESTAMP
|
|
|
|
AND show_id = :showId
|
|
|
|
SQL;
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
2022-07-07 20:01:15 +02:00
|
|
|
[
|
|
|
|
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
|
|
|
|
':showId' => $showId,
|
|
|
|
],
|
2021-10-11 16:10:47 +02:00
|
|
|
'execute'
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function deleteAllRepeatInstances($currentShowDay, $showId)
|
|
|
|
{
|
|
|
|
$firstShow = $currentShowDay->getUTCStartDateAndTime();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-03-21 15:05:11 +01:00
|
|
|
DELETE
|
|
|
|
FROM cc_show_instances
|
|
|
|
WHERE starts > :timestamp::TIMESTAMP
|
|
|
|
AND show_id = :showId
|
|
|
|
AND starts != :firstShow
|
|
|
|
SQL;
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
2022-07-07 20:01:15 +02:00
|
|
|
[
|
|
|
|
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
|
2021-10-11 16:10:47 +02:00
|
|
|
':showId' => $showId,
|
2022-07-07 20:01:15 +02:00
|
|
|
':firstShow' => $firstShow->format(DEFAULT_TIMESTAMP_FORMAT),
|
|
|
|
],
|
2021-10-11 16:10:47 +02:00
|
|
|
'execute'
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines what the show end date should be based on
|
2021-10-11 16:10:47 +02:00
|
|
|
* the form data.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* @param $showData add/edit show form data
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* @return DateTime object in user's local timezone
|
|
|
|
*/
|
|
|
|
private function calculateEndDate($showData)
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// if no end return null
|
2013-03-21 15:05:11 +01:00
|
|
|
if ($showData['add_show_no_end']) {
|
2013-12-12 23:18:03 +01:00
|
|
|
$endDate = null;
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
2022-03-14 11:15:04 +01:00
|
|
|
// if the show is repeating & ends, then return the end date
|
2013-12-12 23:18:03 +01:00
|
|
|
elseif ($showData['add_show_repeats']) {
|
|
|
|
$endDate = new DateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$showData['add_show_end_date'],
|
|
|
|
new DateTimeZone($showData['add_show_timezone'])
|
2013-12-12 23:18:03 +01:00
|
|
|
);
|
2021-10-11 16:10:47 +02:00
|
|
|
$endDate->add(new DateInterval('P1D'));
|
2013-12-12 23:18:03 +01:00
|
|
|
}
|
2022-03-14 11:15:04 +01:00
|
|
|
// the show doesn't repeat, so add one day to the start date.
|
2013-12-12 23:18:03 +01:00
|
|
|
else {
|
|
|
|
$endDate = new DateTime(
|
2014-10-09 15:39:50 +02:00
|
|
|
$showData['add_show_start_date'],
|
2021-10-11 16:10:47 +02:00
|
|
|
new DateTimeZone($showData['add_show_timezone'])
|
2013-12-12 23:18:03 +01:00
|
|
|
);
|
2021-10-11 16:10:47 +02:00
|
|
|
$endDate->add(new DateInterval('P1D'));
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $endDate;
|
|
|
|
}
|
|
|
|
|
2013-10-07 21:53:33 +02:00
|
|
|
private function updateScheduleStartEndTimes($showData)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
|
|
|
$showId = $this->ccShow->getDbId();
|
2022-03-14 11:15:04 +01:00
|
|
|
// DateTime in show's local time
|
2021-10-11 16:10:47 +02:00
|
|
|
$newStartDateTime = new DateTime(
|
|
|
|
$showData['add_show_start_date'] . ' ' .
|
2022-07-07 20:01:15 +02:00
|
|
|
$showData['add_show_start_time'],
|
2021-10-11 16:10:47 +02:00
|
|
|
new DateTimeZone($showData['add_show_timezone'])
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$diff = $this->calculateShowStartDiff(
|
|
|
|
$newStartDateTime,
|
|
|
|
$this->origCcShowDay->getLocalStartDateAndTime()
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2014-02-24 20:49:11 +01:00
|
|
|
Application_Service_SchedulerService::updateScheduleStartTime(
|
|
|
|
$this->instanceIdsForScheduleUpdates,
|
2021-10-11 16:10:47 +02:00
|
|
|
$diff
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the difference in seconds between a show's new and
|
2021-10-11 16:10:47 +02:00
|
|
|
* old start time.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* @param $newStartDateTime DateTime object
|
|
|
|
* @param $oldStartDateTime DateTime object
|
|
|
|
*/
|
|
|
|
private function calculateShowStartDiff($newStartDateTime, $oldStartDateTime)
|
|
|
|
{
|
|
|
|
return $newStartDateTime->getTimestamp() - $oldStartDateTime->getTimestamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Updates the start and end time for cc_show_instances.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param mixed $diff
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
|
|
|
private function updateInstanceStartEndTime($diff)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = <<<'SQL'
|
2013-03-21 15:05:11 +01:00
|
|
|
UPDATE cc_show_instances
|
|
|
|
SET starts = starts + :diff1::INTERVAL,
|
|
|
|
ends = ends + :diff2::INTERVAL
|
|
|
|
WHERE show_id = :showId
|
|
|
|
AND starts > :timestamp::TIMESTAMP
|
|
|
|
SQL;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
2022-07-07 20:01:15 +02:00
|
|
|
[
|
|
|
|
':diff1' => $diff, ':diff2' => $diff,
|
|
|
|
':showId' => $this->ccShow->getDbId(), ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
|
|
|
|
],
|
2021-10-11 16:10:47 +02:00
|
|
|
'execute'
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here ...
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* @param ccShowDays $showDay
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param DateTime $showStartDate user's local time
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $instanceId
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
|
|
|
private function createRebroadcastInstances($showDay, $showStartDate, $instanceId)
|
|
|
|
{
|
2015-06-26 20:42:52 +02:00
|
|
|
$currentUtcTimestamp = gmdate(DEFAULT_TIMESTAMP_FORMAT);
|
2013-03-21 15:05:11 +01:00
|
|
|
$showId = $this->ccShow->getDbId();
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id';
|
|
|
|
$rebroadcasts = Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
|
|
|
[':show_id' => $showId],
|
|
|
|
'all'
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
foreach ($rebroadcasts as $rebroadcast) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$days = explode(' ', $rebroadcast['day_offset']);
|
|
|
|
$time = explode(':', $rebroadcast['start_time']);
|
|
|
|
$offset = ['days' => $days[0], 'hours' => $time[0], 'mins' => $time[1]];
|
2013-03-21 15:05:11 +01:00
|
|
|
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$utcStartDateTime, $utcEndDateTime] = $this->createUTCStartEndDateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$showStartDate,
|
|
|
|
$showDay->getDbDuration(),
|
|
|
|
$offset
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2015-06-26 20:42:52 +02:00
|
|
|
if ($utcStartDateTime->format(DEFAULT_TIMESTAMP_FORMAT) > $currentUtcTimestamp) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$ccShowInstance = new CcShowInstances();
|
|
|
|
$ccShowInstance->setDbShowId($showId);
|
|
|
|
$ccShowInstance->setDbStarts($utcStartDateTime);
|
|
|
|
$ccShowInstance->setDbEnds($utcEndDateTime);
|
|
|
|
$ccShowInstance->setDbRecord(0);
|
|
|
|
$ccShowInstance->setDbRebroadcast(1);
|
|
|
|
$ccShowInstance->setDbOriginalShow($instanceId);
|
|
|
|
$ccShowInstance->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Sets a single cc_show_instance table row.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showDay
|
|
|
|
* @param mixed $populateUntil
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
2013-04-25 15:00:37 +02:00
|
|
|
private function createNonRepeatingInstance($showDay, $populateUntil)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// DateTime object
|
2013-03-21 15:05:11 +01:00
|
|
|
$start = $showDay->getLocalStartDateAndTime();
|
|
|
|
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$utcStartDateTime, $utcEndDateTime] = $this->createUTCStartEndDateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$start,
|
|
|
|
$showDay->getDbDuration()
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
if ($utcStartDateTime->getTimestamp() < $populateUntil->getTimestamp()) {
|
|
|
|
$ccShowInstance = new CcShowInstances();
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isUpdate) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// use original cc_show_day object to get the current cc_show_instance
|
2013-11-26 18:32:05 +01:00
|
|
|
$origStartDateTime = new DateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->origCcShowDay->getDbFirstShow() . ' ' . $this->origCcShowDay->getDbStartTime(),
|
2013-11-26 18:32:05 +01:00
|
|
|
new DateTimeZone($this->origCcShowDay->getDbTimezone())
|
|
|
|
);
|
2021-10-11 16:10:47 +02:00
|
|
|
$origStartDateTime->setTimezone(new DateTimeZone('UTC'));
|
2013-11-26 18:32:05 +01:00
|
|
|
$ccShowInstance = $this->getInstance($origStartDateTime);
|
2014-06-06 18:22:59 +02:00
|
|
|
if (!$ccShowInstance) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Could not find show instance with start time: ' . $origStartDateTime->format(DEFAULT_TIMESTAMP_FORMAT));
|
2014-06-06 18:22:59 +02:00
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
2013-05-01 21:20:55 +02:00
|
|
|
|
|
|
|
$ccShowInstance->setDbShowId($this->ccShow->getDbId());
|
2013-03-21 15:05:11 +01:00
|
|
|
$ccShowInstance->setDbStarts($utcStartDateTime);
|
|
|
|
$ccShowInstance->setDbEnds($utcEndDateTime);
|
|
|
|
$ccShowInstance->setDbRecord($showDay->getDbRecord());
|
|
|
|
$ccShowInstance->save();
|
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isRebroadcast) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId());
|
|
|
|
}
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-11-28 23:17:00 +01:00
|
|
|
return $ccShowInstance;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Sets multiple cc_show_instances table rows.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* @param unknown_type $showDay
|
|
|
|
* @param unknown_type $populateUntil
|
|
|
|
* @param unknown_type $repeatInterval
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param mixed $repeatType
|
|
|
|
* @param null|mixed $daysAdded
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
private function createWeeklyRepeatInstances(
|
|
|
|
$showDay,
|
|
|
|
$populateUntil,
|
|
|
|
$repeatType,
|
|
|
|
$repeatInterval,
|
|
|
|
$daysAdded = null
|
|
|
|
) {
|
|
|
|
$show_id = $showDay->getDbShowId();
|
2022-03-14 11:15:04 +01:00
|
|
|
$first_show = $showDay->getDbFirstShow(); // non-UTC
|
|
|
|
$last_show = $showDay->getDbLastShow(); // non-UTC
|
2021-10-11 16:10:47 +02:00
|
|
|
$duration = $showDay->getDbDuration();
|
|
|
|
$day = $showDay->getDbDay();
|
|
|
|
$record = $showDay->getDbRecord();
|
|
|
|
$timezone = $showDay->getDbTimezone();
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// DateTime local
|
2013-03-21 15:05:11 +01:00
|
|
|
$start = $this->getNextRepeatingPopulateStartDateTime($showDay);
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if (is_null($repeatInterval) && $repeatType == REPEAT_MONTHLY_WEEKLY) {
|
2015-01-20 17:32:15 +01:00
|
|
|
$repeatInterval = self::getMonthlyWeeklyRepeatInterval($start, $timezone);
|
2013-03-22 19:57:02 +01:00
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// DatePeriod in user's local time
|
2021-10-11 16:10:47 +02:00
|
|
|
$datePeriod = $this->getDatePeriod(
|
|
|
|
$start,
|
|
|
|
$timezone,
|
|
|
|
$last_show,
|
|
|
|
$repeatInterval,
|
|
|
|
$populateUntil
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2013-12-12 00:56:19 +01:00
|
|
|
if ($last_show) {
|
2014-10-09 15:39:50 +02:00
|
|
|
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
|
2021-10-11 16:10:47 +02:00
|
|
|
$utcLastShowDateTime->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
} else {
|
2014-10-09 15:39:50 +02:00
|
|
|
$utcLastShowDateTime = null;
|
2013-12-12 00:56:19 +01:00
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2013-06-05 22:16:57 +02:00
|
|
|
$previousDate = clone $start;
|
2013-08-01 21:38:34 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
foreach ($datePeriod as $date) {
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$utcStartDateTime, $utcEndDateTime] = $this->createUTCStartEndDateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$date,
|
|
|
|
$duration
|
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2022-07-07 20:01:15 +02:00
|
|
|
if (
|
|
|
|
$utcStartDateTime <= $populateUntil
|
|
|
|
&& (is_null($utcLastShowDateTime) || $utcStartDateTime < $utcLastShowDateTime)
|
|
|
|
) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$lastCreatedShow = clone $utcStartDateTime;
|
2013-03-21 15:05:11 +01:00
|
|
|
/* 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
|
|
|
|
*/
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isUpdate) {
|
2013-04-01 20:42:35 +02:00
|
|
|
if ($this->hasInstance($utcStartDateTime)) {
|
|
|
|
$ccShowInstance = $this->getInstance($utcStartDateTime);
|
|
|
|
$newInstance = false;
|
2013-04-26 19:43:30 +02:00
|
|
|
} else {
|
2013-04-01 20:42:35 +02:00
|
|
|
$newInstance = true;
|
|
|
|
$ccShowInstance = new CcShowInstances();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
} else {
|
2013-03-21 15:05:11 +01:00
|
|
|
$newInstance = true;
|
|
|
|
$ccShowInstance = new CcShowInstances();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When editing the start/end time of a repeating show, we don't want to
|
2013-12-16 21:27:51 +01:00
|
|
|
* change shows that are in the past so we check the end time.
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
2015-06-26 20:42:52 +02:00
|
|
|
if ($newInstance || $ccShowInstance->getDbEnds() > gmdate(DEFAULT_TIMESTAMP_FORMAT)) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$ccShowInstance->setDbShowId($show_id);
|
|
|
|
$ccShowInstance->setDbStarts($utcStartDateTime);
|
|
|
|
$ccShowInstance->setDbEnds($utcEndDateTime);
|
|
|
|
$ccShowInstance->setDbRecord($record);
|
|
|
|
$ccShowInstance->save();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-08-20 22:37:44 +02:00
|
|
|
if ($newInstance) {
|
|
|
|
array_push($this->newInstanceIdsCreated[$show_id], $ccShowInstance->getDbId());
|
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isRebroadcast) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->createRebroadcastInstances($showDay, $date, $ccShowInstance->getDbId());
|
|
|
|
}
|
|
|
|
}
|
2013-06-05 22:16:57 +02:00
|
|
|
$previousDate = clone $date;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
2013-04-25 15:00:37 +02:00
|
|
|
|
2013-07-29 21:10:24 +02:00
|
|
|
/* We need to set the next populate date for repeat shows so when a user
|
|
|
|
* moves forward in the calendar we know when to start generating new
|
|
|
|
* show instances.
|
|
|
|
* If $utcStartDateTime is not set then we know zero new shows were
|
|
|
|
* created and we shouldn't update the next populate date.
|
2013-04-25 15:00:37 +02:00
|
|
|
*/
|
2013-08-01 21:38:34 +02:00
|
|
|
if (isset($lastCreatedShow)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
/* Set UTC to local time before setting the next repeat date. If we don't
|
|
|
|
* the next repeat date might be scheduled for the following day
|
|
|
|
* THIS MUST BE IN THE TIMEZONE THE SHOW WAS CREATED IN */
|
2013-09-06 12:35:31 +02:00
|
|
|
$lastCreatedShow->setTimezone(new DateTimeZone($timezone));
|
2013-08-01 21:38:34 +02:00
|
|
|
$nextDate = $lastCreatedShow->add($repeatInterval);
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->setNextRepeatingShowDate($nextDate->format('Y-m-d'), $day, $show_id);
|
2013-07-29 21:10:24 +02:00
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2013-06-07 17:16:19 +02:00
|
|
|
private function createMonthlyRepeatInstances($showDay, $populateUntil)
|
2013-03-22 19:57:02 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$show_id = $showDay->getDbShowId();
|
2022-03-14 11:15:04 +01:00
|
|
|
$first_show = $showDay->getDbFirstShow(); // non-UTC
|
|
|
|
$last_show = $showDay->getDbLastShow(); // non-UTC
|
2021-10-11 16:10:47 +02:00
|
|
|
$duration = $showDay->getDbDuration();
|
|
|
|
$day = $showDay->getDbDay();
|
|
|
|
$record = $showDay->getDbRecord();
|
|
|
|
$timezone = $showDay->getDbTimezone();
|
2013-03-22 19:57:02 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// DateTime local
|
2013-03-22 19:57:02 +01:00
|
|
|
$start = $this->getNextRepeatingPopulateStartDateTime($showDay);
|
2013-03-25 21:28:53 +01:00
|
|
|
if (isset($last_show)) {
|
2013-03-22 19:57:02 +01:00
|
|
|
$end = new DateTime($last_show, new DateTimeZone($timezone));
|
|
|
|
} else {
|
|
|
|
$end = $populateUntil;
|
|
|
|
}
|
|
|
|
|
2013-06-07 17:16:19 +02:00
|
|
|
// We will only need this if the repeat type is MONTHLY_WEEKLY
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$weekNumberOfMonth, $dayOfWeek] =
|
2015-01-20 17:32:15 +01:00
|
|
|
self::getMonthlyWeeklyRepeatInterval(
|
2021-10-11 16:10:47 +02:00
|
|
|
new DateTime($first_show, new DateTimeZone($timezone))
|
|
|
|
);
|
2013-06-07 17:16:19 +02:00
|
|
|
|
|
|
|
$this->repeatType = $showDay->getDbRepeatType();
|
|
|
|
|
2014-10-09 15:39:50 +02:00
|
|
|
if ($last_show) {
|
|
|
|
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
|
2021-10-11 16:10:47 +02:00
|
|
|
$utcLastShowDateTime->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
} else {
|
2014-10-09 15:39:50 +02:00
|
|
|
$utcLastShowDateTime = null;
|
2013-12-12 00:56:19 +01:00
|
|
|
}
|
2013-03-22 19:57:02 +01:00
|
|
|
|
|
|
|
while ($start->getTimestamp() < $end->getTimestamp()) {
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$utcStartDateTime, $utcEndDateTime] = $this->createUTCStartEndDateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$start,
|
|
|
|
$duration
|
|
|
|
);
|
2013-03-22 19:57:02 +01:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2022-07-07 20:01:15 +02:00
|
|
|
if (
|
|
|
|
$utcStartDateTime->getTimestamp() <= $populateUntil->getTimestamp()
|
|
|
|
&& (is_null($utcLastShowDateTime)
|
|
|
|
|| $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())
|
|
|
|
) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$lastCreatedShow = clone $utcStartDateTime;
|
2013-03-22 19:57:02 +01:00
|
|
|
/* 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
|
|
|
|
*/
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isUpdate && $this->hasInstance($utcStartDateTime)) {
|
2013-03-22 19:57:02 +01:00
|
|
|
$ccShowInstance = $this->getInstance($utcStartDateTime);
|
|
|
|
$newInstance = false;
|
|
|
|
} else {
|
|
|
|
$newInstance = true;
|
|
|
|
$ccShowInstance = new CcShowInstances();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2015-06-26 20:42:52 +02:00
|
|
|
if ($newInstance || $ccShowInstance->getDbStarts() > gmdate(DEFAULT_TIMESTAMP_FORMAT)) {
|
2013-03-22 19:57:02 +01:00
|
|
|
$ccShowInstance->setDbShowId($show_id);
|
|
|
|
$ccShowInstance->setDbStarts($utcStartDateTime);
|
|
|
|
$ccShowInstance->setDbEnds($utcEndDateTime);
|
|
|
|
$ccShowInstance->setDbRecord($record);
|
|
|
|
$ccShowInstance->save();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-08-20 22:37:44 +02:00
|
|
|
if ($newInstance) {
|
|
|
|
array_push($this->newInstanceIdsCreated[$show_id], $ccShowInstance->getDbId());
|
|
|
|
}
|
2013-03-22 19:57:02 +01:00
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
if ($this->isRebroadcast) {
|
2013-05-29 18:34:00 +02:00
|
|
|
$this->createRebroadcastInstances($showDay, $start, $ccShowInstance->getDbId());
|
2013-03-22 19:57:02 +01:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 17:16:19 +02:00
|
|
|
if ($this->repeatType == REPEAT_MONTHLY_WEEKLY) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$monthlyWeeklyStart = new DateTime(
|
|
|
|
$utcStartDateTime->format('Y-m'),
|
|
|
|
new DateTimeZone('UTC')
|
|
|
|
);
|
|
|
|
$monthlyWeeklyStart->add(new DateInterval('P1M'));
|
2015-01-20 17:32:15 +01:00
|
|
|
$start = self::getNextMonthlyWeeklyRepeatDate(
|
2013-06-07 17:16:19 +02:00
|
|
|
$monthlyWeeklyStart,
|
|
|
|
$timezone,
|
|
|
|
$showDay->getDbStartTime(),
|
|
|
|
$weekNumberOfMonth,
|
2021-10-11 16:10:47 +02:00
|
|
|
$dayOfWeek
|
|
|
|
);
|
2013-06-07 17:16:19 +02:00
|
|
|
} else {
|
|
|
|
$start = $this->getNextMonthlyMonthlyRepeatDate(
|
2021-10-11 16:10:47 +02:00
|
|
|
$start,
|
|
|
|
$timezone,
|
|
|
|
$showDay->getDbStartTime()
|
|
|
|
);
|
2013-06-07 17:16:19 +02:00
|
|
|
}
|
2013-03-22 19:57:02 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->setNextRepeatingShowDate($start->format('Y-m-d'), $day, $show_id);
|
2013-03-22 19:57:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* i.e. last thursday of each month
|
2021-10-11 16:10:47 +02:00
|
|
|
* i.e. second monday of each month.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-22 19:57:02 +01:00
|
|
|
* @param string $showStart
|
|
|
|
*/
|
2015-01-20 17:32:15 +01:00
|
|
|
public static function getMonthlyWeeklyRepeatInterval($showStart)
|
2013-03-22 19:57:02 +01:00
|
|
|
{
|
2013-03-22 20:57:15 +01:00
|
|
|
$start = clone $showStart;
|
2021-10-11 16:10:47 +02:00
|
|
|
$dayOfMonth = $start->format('j');
|
|
|
|
$dayOfWeek = $start->format('l');
|
|
|
|
$yearAndMonth = $start->format('Y-m');
|
|
|
|
$firstDayOfWeek = strtotime($dayOfWeek . ' ' . $yearAndMonth);
|
2013-03-22 19:57:02 +01:00
|
|
|
// if $dayOfWeek is Friday, what number of the month does
|
|
|
|
// the first Friday fall on
|
2021-10-11 16:10:47 +02:00
|
|
|
$numberOfFirstDayOfWeek = date('j', $firstDayOfWeek);
|
2013-03-22 19:57:02 +01:00
|
|
|
|
|
|
|
$weekCount = 0;
|
|
|
|
while ($dayOfMonth >= $numberOfFirstDayOfWeek) {
|
2021-10-11 16:10:47 +02:00
|
|
|
++$weekCount;
|
2013-03-22 19:57:02 +01:00
|
|
|
$dayOfMonth -= 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($weekCount) {
|
|
|
|
case 1:
|
2021-10-11 16:10:47 +02:00
|
|
|
$weekNumberOfMonth = 'first';
|
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
case 2:
|
2021-10-11 16:10:47 +02:00
|
|
|
$weekNumberOfMonth = 'second';
|
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
case 3:
|
2021-10-11 16:10:47 +02:00
|
|
|
$weekNumberOfMonth = 'third';
|
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
case 4:
|
2021-10-11 16:10:47 +02:00
|
|
|
$weekNumberOfMonth = 'fourth';
|
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
break;
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
case 5:
|
2021-10-11 16:10:47 +02:00
|
|
|
$weekNumberOfMonth = 'fifth';
|
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:06:15 +02:00
|
|
|
/* return DateInterval::createFromDateString(
|
|
|
|
$weekNumberOfMonth." ".$dayOfWeek." of next month"); */
|
2021-10-11 16:10:47 +02:00
|
|
|
return [$weekNumberOfMonth, $dayOfWeek];
|
2013-03-22 19:57:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter description here ...
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2023-05-25 15:06:18 +02:00
|
|
|
* @param $start user's local time
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param mixed $timezone
|
|
|
|
* @param mixed $startTime
|
2013-03-22 19:57:02 +01:00
|
|
|
*/
|
2013-05-07 22:16:32 +02:00
|
|
|
private function getNextMonthlyMonthlyRepeatDate($start, $timezone, $startTime)
|
2013-03-21 21:31:05 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$dt = new DateTime($start->format('Y-m'), new DateTimeZone($timezone));
|
2013-06-07 13:06:15 +02:00
|
|
|
|
2013-06-07 17:16:19 +02:00
|
|
|
do {
|
2021-10-11 16:10:47 +02:00
|
|
|
$dt->add(new DateInterval('P1M'));
|
|
|
|
} while (!checkdate($dt->format('m'), $start->format('d'), $dt->format('Y')));
|
2013-03-22 19:57:02 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$dt->setDate($dt->format('Y'), $dt->format('m'), $start->format('d'));
|
2013-05-07 22:16:32 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$startTime = explode(':', $startTime);
|
|
|
|
$hours = isset($startTime[0]) ? $startTime[0] : '00';
|
|
|
|
$minutes = isset($startTime[1]) ? $startTime[1] : '00';
|
|
|
|
$seconds = isset($startTime[2]) ? $startTime[2] : '00';
|
2013-06-07 17:16:19 +02:00
|
|
|
$dt->setTime($hours, $minutes, $seconds);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-06-07 17:16:19 +02:00
|
|
|
return $dt;
|
|
|
|
}
|
|
|
|
|
2014-01-20 23:05:37 +01:00
|
|
|
/**
|
|
|
|
* Returns a DateTime object of when the next repeating show that repeats
|
2021-10-11 16:10:47 +02:00
|
|
|
* monthly, by day of the week (i.e. every fourth Tuesday) should be created.
|
|
|
|
*
|
2014-01-20 23:05:37 +01:00
|
|
|
* @param DateTime $start
|
2021-10-11 16:10:47 +02:00
|
|
|
* $start only has the year and month of the next show
|
|
|
|
* @param string $timezone
|
2014-01-20 23:05:37 +01:00
|
|
|
* @param string (i.e. '14:30' $startTime
|
|
|
|
* @param string (i.e. 'first', 'second') $weekNumberOfMonth
|
|
|
|
* @param string (i.e. 'Monday') $dayOfWeek
|
|
|
|
*/
|
2015-01-20 17:32:15 +01:00
|
|
|
public static function getNextMonthlyWeeklyRepeatDate(
|
2013-06-07 17:16:19 +02:00
|
|
|
$start,
|
|
|
|
$timezone,
|
|
|
|
$startTime,
|
|
|
|
$weekNumberOfMonth,
|
2021-10-11 16:10:47 +02:00
|
|
|
$dayOfWeek
|
|
|
|
) {
|
|
|
|
$dt = new DateTime($start->format('Y-m'), new DateTimeZone($timezone));
|
2013-06-07 17:16:19 +02:00
|
|
|
$tempDT = clone $dt;
|
|
|
|
$fifthWeekExists = false;
|
|
|
|
do {
|
2021-10-11 16:10:47 +02:00
|
|
|
$nextDT = date_create($weekNumberOfMonth . ' ' . $dayOfWeek .
|
|
|
|
' of ' . $tempDT->format('F') . ' ' . $tempDT->format('Y'));
|
2013-09-25 20:44:08 +02:00
|
|
|
$nextDT->setTimezone(new DateTimeZone($timezone));
|
2013-06-07 17:16:19 +02:00
|
|
|
|
|
|
|
/* We have to check if the next date is in the same month in case
|
|
|
|
* the repeat day is in the fifth week of the month.
|
|
|
|
* If it's not in the same month we know that a fifth week of
|
|
|
|
* the next month does not exist. So let's skip it.
|
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($tempDT->format('F') == $nextDT->format('F')) {
|
2013-06-07 17:16:19 +02:00
|
|
|
$fifthWeekExists = true;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$tempDT->add(new DateInterval('P1M'));
|
2013-06-07 17:16:19 +02:00
|
|
|
} while (!$fifthWeekExists);
|
|
|
|
|
|
|
|
$dt = $nextDT;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$startTime = explode(':', $startTime);
|
|
|
|
$hours = isset($startTime[0]) ? $startTime[0] : '00';
|
|
|
|
$minutes = isset($startTime[1]) ? $startTime[1] : '00';
|
|
|
|
$seconds = isset($startTime[2]) ? $startTime[2] : '00';
|
2013-05-07 22:16:32 +02:00
|
|
|
$dt->setTime($hours, $minutes, $seconds);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
return $dt;
|
2013-03-21 21:31:05 +01:00
|
|
|
}
|
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
private function getNextRepeatingPopulateStartDateTime($showDay)
|
|
|
|
{
|
|
|
|
$nextPopDate = $showDay->getDbNextPopDate();
|
|
|
|
$startTime = $showDay->getDbStartTime();
|
|
|
|
|
|
|
|
if (isset($nextPopDate)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
return new DateTime($nextPopDate . ' ' . $startTime, new DateTimeZone($showDay->getDbTimezone()));
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return new DateTime($showDay->getDbFirstShow() . ' ' . $startTime, new DateTimeZone($showDay->getDbTimezone()));
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a DatePeriod object in the user's local time
|
2021-10-11 16:10:47 +02:00
|
|
|
* It will get converted to UTC before the show instance gets created.
|
|
|
|
*
|
|
|
|
* @param mixed $start
|
|
|
|
* @param mixed $timezone
|
|
|
|
* @param mixed $lastShow
|
|
|
|
* @param mixed $repeatInterval
|
|
|
|
* @param mixed $populateUntil
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
|
|
|
private function getDatePeriod($start, $timezone, $lastShow, $repeatInterval, $populateUntil)
|
|
|
|
{
|
|
|
|
if (isset($lastShow)) {
|
|
|
|
$endDatePeriod = new DateTime($lastShow, new DateTimeZone($timezone));
|
|
|
|
} else {
|
|
|
|
$endDatePeriod = $populateUntil;
|
|
|
|
}
|
|
|
|
|
2013-03-22 19:57:02 +01:00
|
|
|
return new DatePeriod($start, $repeatInterval, $endDatePeriod);
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function hasInstance($starts)
|
|
|
|
{
|
|
|
|
return $this->getInstance($starts) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to retrieve the cc_show_instance belonging to a cc_show
|
|
|
|
* that starts at $starts. We have to pass in the start
|
2021-10-11 16:10:47 +02:00
|
|
|
* time in case the show is repeating.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-03-21 15:05:11 +01:00
|
|
|
* Returns the instance if one was found (one that is not a recording
|
|
|
|
* and modified instance is false (has not been deleted))
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
|
|
|
* @param mixed $starts
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
|
|
|
private function getInstance($starts)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$temp = clone $starts;
|
2013-10-07 20:16:20 +02:00
|
|
|
$temp->setTimezone(new DateTimeZone($this->oldShowTimezone));
|
|
|
|
$temp->setTime($this->localShowStartHour, $this->localShowStartMin);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
$temp->setTimezone(new DateTimeZone('UTC'));
|
2013-10-07 20:16:20 +02:00
|
|
|
|
2013-03-21 15:05:11 +01:00
|
|
|
$ccShowInstance = CcShowInstancesQuery::create()
|
2015-06-26 20:42:52 +02:00
|
|
|
->filterByDbStarts($temp->format(DEFAULT_TIMESTAMP_FORMAT), Criteria::EQUAL)
|
2013-03-21 15:05:11 +01:00
|
|
|
->filterByDbShowId($this->ccShow->getDbId(), Criteria::EQUAL)
|
2022-03-14 11:15:04 +01:00
|
|
|
// ->filterByDbModifiedInstance(false, Criteria::EQUAL)
|
2013-03-21 15:05:11 +01:00
|
|
|
->filterByDbRebroadcast(0, Criteria::EQUAL)
|
|
|
|
->limit(1)
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
if ($ccShowInstance->isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $ccShowInstance[0];
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
2013-02-26 23:41:35 +01:00
|
|
|
|
2013-03-27 21:25:39 +01:00
|
|
|
private function hasCcShowDay($repeatType, $day)
|
|
|
|
{
|
|
|
|
return $this->getCcShowDay($repeatType, $day) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getCcShowDay($repeatType, $day)
|
|
|
|
{
|
|
|
|
$ccShowDay = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($this->ccShow->getDbId())
|
|
|
|
->filterByDbDay($day)
|
|
|
|
->filterByDbRepeatType($repeatType)
|
|
|
|
->limit(1)
|
2022-01-23 19:15:55 +01:00
|
|
|
->find();
|
2013-03-27 21:25:39 +01:00
|
|
|
|
|
|
|
if ($ccShowDay->isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $ccShowDay[0];
|
2013-03-27 21:25:39 +01:00
|
|
|
}
|
|
|
|
|
2013-02-26 16:20:02 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Sets the fields for a cc_show table row.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showData
|
2013-02-26 16:20:02 +01:00
|
|
|
*/
|
2013-12-18 21:48:32 +01:00
|
|
|
public function setCcShow($showData)
|
2013-02-26 16:20:02 +01:00
|
|
|
{
|
2013-04-25 15:00:37 +02:00
|
|
|
if (!$this->isUpdate) {
|
2013-03-12 15:30:31 +01:00
|
|
|
$ccShow = new CcShow();
|
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$ccShow = CcShowQuery::create()->findPk($showData['add_show_id']);
|
2013-03-12 15:30:31 +01:00
|
|
|
}
|
|
|
|
|
2013-02-26 16:20:02 +01:00
|
|
|
$ccShow->setDbName($showData['add_show_name']);
|
|
|
|
$ccShow->setDbDescription($showData['add_show_description']);
|
|
|
|
$ccShow->setDbUrl($showData['add_show_url']);
|
|
|
|
$ccShow->setDbGenre($showData['add_show_genre']);
|
|
|
|
$ccShow->setDbColor($showData['add_show_color']);
|
|
|
|
$ccShow->setDbBackgroundColor($showData['add_show_background_color']);
|
|
|
|
$ccShow->setDbLiveStreamUsingAirtimeAuth($showData['cb_airtime_auth'] == 1);
|
|
|
|
$ccShow->setDbLiveStreamUsingCustomAuth($showData['cb_custom_auth'] == 1);
|
|
|
|
$ccShow->setDbLiveStreamUser($showData['custom_username']);
|
|
|
|
$ccShow->setDbLiveStreamPass($showData['custom_password']);
|
2017-02-13 15:35:09 +01:00
|
|
|
$ccShow->setDbHasAutoPlaylist($showData['add_show_has_autoplaylist'] == 1);
|
2017-03-31 06:00:19 +02:00
|
|
|
$ccShow->setDbAutoPlaylistRepeat($showData['add_show_autoplaylist_repeat'] == 1);
|
2017-02-13 15:35:09 +01:00
|
|
|
// added to prevent errors with insert due to a lack of data
|
2017-03-10 16:20:44 +01:00
|
|
|
if ($showData['add_show_autoplaylist_id'] != '') {
|
|
|
|
$ccShow->setDbAutoPlaylistId($showData['add_show_autoplaylist_id']);
|
2017-02-13 15:35:09 +01:00
|
|
|
}
|
2024-10-21 19:34:39 +02:00
|
|
|
|
|
|
|
$ccShow->setDbOverrideIntroPlaylist($showData['add_show_intro_playlist_id'] != 0);
|
2024-10-14 22:07:41 +02:00
|
|
|
if ($showData['add_show_intro_playlist_id'] != '') {
|
|
|
|
$ccShow->setDbIntroPlaylistId($showData['add_show_intro_playlist_id']);
|
|
|
|
}
|
2024-10-21 19:34:39 +02:00
|
|
|
|
|
|
|
$ccShow->setDbOverrideOutroPlaylist($showData['add_show_outro_playlist_id'] != 0);
|
2024-10-14 22:07:41 +02:00
|
|
|
if ($showData['add_show_outro_playlist_id'] != '') {
|
|
|
|
$ccShow->setDbOutroPlaylistId($showData['add_show_outro_playlist_id']);
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// Here a user has edited a show and linked it.
|
|
|
|
// We need to grab the existing show instances ids and fill their content
|
|
|
|
// with the content from the show instance that was clicked on to edit the show.
|
|
|
|
// We do this because linked show instances need to have the same content in each.
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($this->isUpdate && (!$ccShow->getDbLinked() && $showData['add_show_linked'])) {
|
2014-08-21 22:40:01 +02:00
|
|
|
$existingShowInstanceIds = $ccShow->getFutureInstanceIds(new Criteria());
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Service_SchedulerService::fillLinkedInstances($ccShow, $existingShowInstanceIds, $showData['add_show_instance_id']);
|
2013-04-26 19:43:30 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$ccShow->setDbLinked($showData['add_show_linked']);
|
2013-02-26 16:20:02 +01:00
|
|
|
|
|
|
|
$ccShow->save();
|
2013-03-21 15:05:11 +01:00
|
|
|
$this->ccShow = $ccShow;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Sets the fields for a cc_show_days table row.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showData
|
2013-03-21 15:05:11 +01:00
|
|
|
*/
|
2013-04-25 15:00:37 +02:00
|
|
|
private function setCcShowDays($showData)
|
2013-03-21 15:05:11 +01:00
|
|
|
{
|
|
|
|
$showId = $this->ccShow->getDbId();
|
|
|
|
|
2013-12-12 23:18:03 +01:00
|
|
|
$startDateTime = new DateTime(
|
2021-10-11 16:10:47 +02:00
|
|
|
$showData['add_show_start_date'] . ' ' . $showData['add_show_start_time'],
|
|
|
|
new DateTimeZone($showData['add_show_timezone'])
|
2013-12-12 23:18:03 +01:00
|
|
|
);
|
2013-03-21 15:05:11 +01:00
|
|
|
|
|
|
|
$endDateTime = $this->calculateEndDate($showData);
|
|
|
|
if (!is_null($endDateTime)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$endDate = $endDateTime->format('Y-m-d');
|
|
|
|
} else {
|
2014-10-09 15:39:50 +02:00
|
|
|
$endDate = null;
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// Our calculated start DOW must be used for non repeating since a day has not been selected.
|
|
|
|
// For all repeating shows, only the selected days of the week will be repeated on.
|
2021-10-11 16:10:47 +02:00
|
|
|
$startDow = $startDateTime->format('w');
|
2013-03-21 15:05:11 +01:00
|
|
|
if (!$showData['add_show_repeats']) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$showData['add_show_day_check'] = [$startDow];
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't set day for monthly repeat type, it's invalid
|
|
|
|
if ($showData['add_show_repeats'] && $showData['add_show_repeat_type'] == 2) {
|
2013-11-28 23:17:00 +01:00
|
|
|
if ($this->isUpdate) {
|
|
|
|
$showDay = CcShowDaysQuery::create()
|
|
|
|
->filterByDbShowId($showId)
|
2014-03-07 20:52:32 +01:00
|
|
|
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2014-03-07 20:52:32 +01:00
|
|
|
if (!$showDay) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// repeat type changed so we have to create a new show_day rule
|
2014-03-07 20:52:32 +01:00
|
|
|
$showDay = new CcShowDays();
|
|
|
|
}
|
2013-11-28 23:17:00 +01:00
|
|
|
} else {
|
|
|
|
$showDay = new CcShowDays();
|
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->setDbFirstShow($startDateTime->format('Y-m-d'));
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->setDbLastShow($endDate);
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->setDbStartTime($startDateTime->format('H:i:s'));
|
2013-09-24 22:23:45 +02:00
|
|
|
$showDay->setDbTimezone($showData['add_show_timezone']);
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->setDbDuration($showData['add_show_duration']);
|
2013-04-25 15:00:37 +02:00
|
|
|
$showDay->setDbRepeatType($this->repeatType);
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->setDbShowId($showId);
|
2013-04-25 15:00:37 +02:00
|
|
|
$showDay->setDbRecord($this->isRecorded);
|
2022-03-14 11:15:04 +01:00
|
|
|
// in case we are editing a show we need to set this to the first show
|
|
|
|
// so when editing, the date period iterator will start from the beginning
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->setDbNextPopDate($startDateTime->format('Y-m-d'));
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->save();
|
|
|
|
} else {
|
|
|
|
foreach ($showData['add_show_day_check'] as $day) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$daysAdd = 0;
|
2013-03-21 15:05:11 +01:00
|
|
|
$startDateTimeClone = clone $startDateTime;
|
|
|
|
if ($startDow !== $day) {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($startDow > $day) {
|
2013-03-21 15:05:11 +01:00
|
|
|
$daysAdd = 6 - $startDow + 1 + $day;
|
2021-10-11 16:10:47 +02:00
|
|
|
} else {
|
2013-03-21 15:05:11 +01:00
|
|
|
$daysAdd = $day - $startDow;
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
2013-03-21 15:05:11 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$startDateTimeClone->add(new DateInterval('P' . $daysAdd . 'D'));
|
2013-03-21 15:05:11 +01:00
|
|
|
}
|
|
|
|
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
2013-11-28 23:17:00 +01:00
|
|
|
if ($this->isUpdate) {
|
2022-07-07 20:01:15 +02:00
|
|
|
if (
|
|
|
|
$this->origCcShowDay->getDbRepeatType() == 2
|
|
|
|
|| $this->origCcShowDay->getDbRepeatType() == 3
|
|
|
|
) {
|
2014-03-07 20:52:32 +01:00
|
|
|
$day = null;
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif (!$this->origShowRepeatStatus) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// keep current show day to use for updating cc_show_day rule
|
2014-03-10 22:32:54 +01:00
|
|
|
$keepDay = $day;
|
|
|
|
$day = $this->origCcShowDay->getDbDay();
|
2014-03-07 20:52:32 +01:00
|
|
|
}
|
2014-03-10 22:41:57 +01:00
|
|
|
|
2014-03-07 20:52:32 +01:00
|
|
|
$showDay = CcShowDaysQuery::create()
|
2021-10-11 16:10:47 +02:00
|
|
|
->filterByDbShowId($showId)
|
|
|
|
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
|
|
|
|
->filterByDbDay($day)
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2014-03-07 20:52:32 +01:00
|
|
|
if (!$showDay) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// if no show day object was found it is because a new
|
|
|
|
// repeating day of the week was added OR the repeat
|
|
|
|
// type has changed
|
2014-03-07 20:52:32 +01:00
|
|
|
$showDay = new CcShowDays();
|
2013-11-28 23:17:00 +01:00
|
|
|
}
|
2014-03-10 22:32:54 +01:00
|
|
|
|
|
|
|
if (isset($keepDay)) {
|
|
|
|
$day = $keepDay;
|
|
|
|
}
|
2013-11-28 23:17:00 +01:00
|
|
|
} else {
|
|
|
|
$showDay = new CcShowDays();
|
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->setDbFirstShow($startDateTimeClone->format('Y-m-d'));
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->setDbLastShow($endDate);
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->setDbStartTime($startDateTimeClone->format('H:i'));
|
2013-09-25 20:44:08 +02:00
|
|
|
$showDay->setDbTimezone($showData['add_show_timezone']);
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->setDbDuration($showData['add_show_duration']);
|
|
|
|
$showDay->setDbDay($day);
|
2013-04-25 15:00:37 +02:00
|
|
|
$showDay->setDbRepeatType($this->repeatType);
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->setDbShowId($showId);
|
2013-04-25 15:00:37 +02:00
|
|
|
$showDay->setDbRecord($this->isRecorded);
|
2022-03-14 11:15:04 +01:00
|
|
|
// in case we are editing a show we need to set this to the first show
|
|
|
|
// so when editing, the date period iterator will start from the beginning
|
2021-10-11 16:10:47 +02:00
|
|
|
$showDay->setDbNextPopDate($startDateTimeClone->format('Y-m-d'));
|
2013-03-21 15:05:11 +01:00
|
|
|
$showDay->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-26 16:20:02 +01:00
|
|
|
}
|
|
|
|
|
2013-03-15 21:56:22 +01:00
|
|
|
/**
|
|
|
|
* Deletes all the cc_show_rebroadcast entries for a specific show
|
|
|
|
* that is currently being edited. They will get recreated with
|
2021-10-11 16:10:47 +02:00
|
|
|
* the new show specs.
|
2013-03-15 21:56:22 +01:00
|
|
|
*/
|
2013-03-21 15:05:11 +01:00
|
|
|
private function deleteCcShowRebroadcasts()
|
2013-03-15 21:56:22 +01:00
|
|
|
{
|
2013-03-21 15:05:11 +01:00
|
|
|
CcShowRebroadcastQuery::create()->filterByDbShowId($this->ccShow->getDbId())->delete();
|
2013-03-15 21:56:22 +01:00
|
|
|
}
|
|
|
|
|
2013-02-26 16:20:02 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Sets the fields for a cc_show_rebroadcast table row.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showData
|
2013-02-26 16:20:02 +01:00
|
|
|
*/
|
2013-04-25 15:00:37 +02:00
|
|
|
private function setCcShowRebroadcasts($showData)
|
2013-02-26 16:20:02 +01:00
|
|
|
{
|
2013-03-21 15:05:11 +01:00
|
|
|
$showId = $this->ccShow->getDbId();
|
|
|
|
|
2013-04-25 15:00:37 +02:00
|
|
|
if (($this->isRecorded && $showData['add_show_rebroadcast']) && ($this->repeatType != -1)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
for ($i = 1; $i <= MAX_REBROADCAST_DATES; ++$i) {
|
|
|
|
if ($showData['add_show_rebroadcast_date_' . $i]) {
|
2013-02-26 16:20:02 +01:00
|
|
|
$showRebroad = new CcShowRebroadcast();
|
2021-10-11 16:10:47 +02:00
|
|
|
$showRebroad->setDbDayOffset($showData['add_show_rebroadcast_date_' . $i]);
|
|
|
|
$showRebroad->setDbStartTime($showData['add_show_rebroadcast_time_' . $i]);
|
2013-02-26 16:20:02 +01:00
|
|
|
$showRebroad->setDbShowId($showId);
|
|
|
|
$showRebroad->save();
|
|
|
|
}
|
|
|
|
}
|
2013-04-25 15:00:37 +02:00
|
|
|
} elseif ($this->isRecorded && $showData['add_show_rebroadcast'] && ($this->repeatType == -1)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
for ($i = 1; $i <= MAX_REBROADCAST_DATES; ++$i) {
|
|
|
|
if ($showData['add_show_rebroadcast_date_absolute_' . $i]) {
|
|
|
|
$rebroadcastDate = new DateTime($showData["add_show_rebroadcast_date_absolute_{$i}"]);
|
2013-02-26 16:20:02 +01:00
|
|
|
$startDate = new DateTime($showData['add_show_start_date']);
|
|
|
|
$offsetDays = $startDate->diff($rebroadcastDate);
|
|
|
|
|
|
|
|
$showRebroad = new CcShowRebroadcast();
|
2021-10-11 16:10:47 +02:00
|
|
|
$showRebroad->setDbDayOffset($offsetDays->format('%a days'));
|
|
|
|
$showRebroad->setDbStartTime($showData['add_show_rebroadcast_time_absolute_' . $i]);
|
2013-02-26 16:20:02 +01:00
|
|
|
$showRebroad->setDbShowId($showId);
|
|
|
|
$showRebroad->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-15 21:56:22 +01:00
|
|
|
/**
|
|
|
|
* Deletes all the cc_show_hosts entries for a specific show
|
|
|
|
* that is currently being edited. They will get recreated with
|
2021-10-11 16:10:47 +02:00
|
|
|
* the new show specs.
|
2013-03-15 21:56:22 +01:00
|
|
|
*/
|
2013-03-21 15:05:11 +01:00
|
|
|
private function deleteCcShowHosts()
|
2013-03-15 21:56:22 +01:00
|
|
|
{
|
2013-03-21 15:05:11 +01:00
|
|
|
CcShowHostsQuery::create()->filterByDbShow($this->ccShow->getDbId())->delete();
|
2013-03-15 21:56:22 +01:00
|
|
|
}
|
|
|
|
|
2013-02-26 16:20:02 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Sets the fields for a cc_show_hosts table row.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $showData
|
2013-02-26 16:20:02 +01:00
|
|
|
*/
|
2013-03-21 15:05:11 +01:00
|
|
|
private function setCcShowHosts($showData)
|
2013-02-26 16:20:02 +01:00
|
|
|
{
|
|
|
|
if (is_array($showData['add_show_hosts'])) {
|
|
|
|
foreach ($showData['add_show_hosts'] as $host) {
|
|
|
|
$showHost = new CcShowHosts();
|
2013-03-21 15:05:11 +01:00
|
|
|
$showHost->setDbShow($this->ccShow->getDbId());
|
2013-02-26 16:20:02 +01:00
|
|
|
$showHost->setDbHost($host);
|
|
|
|
$showHost->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-02-26 19:21:39 +01:00
|
|
|
/**
|
|
|
|
* Gets the date and time shows (particularly repeating shows)
|
|
|
|
* can be populated until.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-02-26 19:21:39 +01:00
|
|
|
* @return DateTime object
|
|
|
|
*/
|
2013-03-25 21:28:53 +01:00
|
|
|
private static function getPopulateShowUntilDateTIme()
|
2013-02-26 19:21:39 +01:00
|
|
|
{
|
|
|
|
$populateUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
|
|
|
|
|
|
|
if (is_null($populateUntil)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$populateUntil = new DateTime('now', new DateTimeZone('UTC'));
|
2013-02-26 19:21:39 +01:00
|
|
|
Application_Model_Preference::SetShowsPopulatedUntil($populateUntil);
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2013-02-26 19:21:39 +01:00
|
|
|
return $populateUntil;
|
|
|
|
}
|
|
|
|
|
2013-02-26 23:41:35 +01:00
|
|
|
/**
|
|
|
|
* Enter description here ...
|
2021-10-11 16:10:47 +02:00
|
|
|
*
|
2013-03-21 21:31:05 +01:00
|
|
|
* @param DateTime $showStart user's local time
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param string $duration time interval (h)h:(m)m(:ss)
|
|
|
|
* @param array $offset (days, hours, mins) used for rebroadcast shows
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2013-02-26 23:41:35 +01:00
|
|
|
* @return array of 2 DateTime objects, start/end time of the show in UTC
|
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
private function createUTCStartEndDateTime($showStart, $duration, $offset = null)
|
2013-02-26 23:41:35 +01:00
|
|
|
{
|
2013-03-21 21:31:05 +01:00
|
|
|
$startDateTime = clone $showStart;
|
2013-09-25 20:44:08 +02:00
|
|
|
$timezone = $startDateTime->getTimezone();
|
2013-03-21 21:31:05 +01:00
|
|
|
|
2013-02-26 23:41:35 +01:00
|
|
|
if (isset($offset)) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// $offset["hours"] and $offset["mins"] represents the start time
|
|
|
|
// of a rebroadcast show
|
2021-10-11 16:10:47 +02:00
|
|
|
$startDateTime = new DateTime($startDateTime->format('Y-m-d') . ' ' .
|
|
|
|
$offset['hours'] . ':' . $offset['mins'], $timezone);
|
|
|
|
$startDateTime->add(new DateInterval("P{$offset['days']}D"));
|
2013-02-26 23:41:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$endDateTime = clone $startDateTime;
|
2021-10-11 16:10:47 +02:00
|
|
|
$duration = explode(':', $duration);
|
Feature: Support php7.4 (#1354)
* Run CI tests against php 7.4
* Sort composer dependencies
* Remove unused Aws S3 php library
* Pin simplepie dependency to ^1.5
* Pin getid3 dependency to ^1.9
* Pin composer semver to ^3.2
* Pin php-amqplib to ^2.12
* Drop sentry logging support
* Update composer dependencies
* Move propel regenerate to Makefile
* Regenerate propel files with v1.7.0
* Pin propel orm to ^1.7
* Regenerate propel files with v1.7.2
* fix: generator_version in airtime-conf-production.php
* Replace propel/propel1 with jooola/propel1
* Regenerate propel files with v1.7.3-dev
* Fix php7.4 compatibility
Using php-cs-fixer:
'@PhpCsFixer' => true,
'concat_space' => ['spacing' => 'one'],
'ordered_class_elements' => false,
'yoda_style' => false,
'@PHP74Migration' => true,
'assign_null_coalescing_to_coalesce_equal' => false,
'ternary_to_null_coalescing' => false,
'heredoc_indentation' => false,
'@PHP74Migration:risky' => true,
'declare_strict_types' => false,
'void_return' => false,
'use_arrow_functions' => false,
* Fix pre-commit
2021-10-17 17:19:53 +02:00
|
|
|
[$hours, $mins] = array_slice($duration, 0, 2);
|
2013-02-26 23:41:35 +01:00
|
|
|
$endDateTime->add(new DateInterval("PT{$hours}H{$mins}M"));
|
|
|
|
|
2013-12-11 20:45:16 +01:00
|
|
|
$startDateTime->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
return [$startDateTime, $endDateTime];
|
2013-02-26 23:41:35 +01:00
|
|
|
}
|
2013-03-08 18:17:55 +01:00
|
|
|
|
2013-03-08 22:08:43 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
2013-09-06 12:35:31 +02:00
|
|
|
*
|
2022-10-12 17:02:14 +02:00
|
|
|
* @param mixed $nextDate
|
|
|
|
* @param mixed $day
|
|
|
|
* @param mixed $showId
|
2013-03-08 22:08:43 +01:00
|
|
|
*/
|
2013-03-26 15:33:06 +01:00
|
|
|
private function setNextRepeatingShowDate($nextDate, $day, $showId)
|
2013-03-08 18:17:55 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$nextInfo = explode(' ', $nextDate);
|
2013-03-08 18:17:55 +01:00
|
|
|
|
|
|
|
$repeatInfo = CcShowDaysQuery::create()
|
2013-03-26 15:33:06 +01:00
|
|
|
->filterByDbShowId($showId)
|
2013-03-08 18:17:55 +01:00
|
|
|
->filterByDbDay($day)
|
2013-11-28 23:17:00 +01:00
|
|
|
->filterByDbRepeatType(-1, Criteria::NOT_EQUAL)
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2013-03-08 18:17:55 +01:00
|
|
|
|
|
|
|
$repeatInfo->setDbNextPopDate($nextInfo[0])
|
2022-01-23 19:15:55 +01:00
|
|
|
->save();
|
2013-03-08 18:17:55 +01:00
|
|
|
}
|
2013-06-19 07:17:32 +02:00
|
|
|
}
|