Merge branch '2.2.x' of dev.sourcefabric.org:airtime into 2.2.x
This commit is contained in:
commit
d3058ee5e8
7 changed files with 93 additions and 29 deletions
|
@ -784,7 +784,10 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
$scheduler = new Application_Model_Scheduler();
|
$scheduler = new Application_Model_Scheduler();
|
||||||
$scheduler->removeGaps($data['add_show_instance_id']);
|
$showInstances = CcShowInstancesQuery::create()->filterByDbShowId($data['add_show_id'])->find();
|
||||||
|
foreach ($showInstances as $si) {
|
||||||
|
$scheduler->removeGaps($si->getDbId());
|
||||||
|
}
|
||||||
$this->view->addNewShow = true;
|
$this->view->addNewShow = true;
|
||||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -163,7 +163,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
|
|
||||||
} elseif (!$formData["add_show_no_end"]) {
|
} elseif (!$formData["add_show_no_end"]) {
|
||||||
$popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"];
|
$popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"];
|
||||||
$populateUntilDateTime = new DateTime($popUntil, new DateTimeZone('UTC'));
|
$populateUntilDateTime = new DateTime($popUntil);
|
||||||
|
$populateUntilDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//get repeat interval
|
//get repeat interval
|
||||||
|
@ -198,21 +199,33 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
$repeatShowStart->add(new DateInterval("P".$daysAdd."D"));
|
$repeatShowStart->add(new DateInterval("P".$daysAdd."D"));
|
||||||
$repeatShowEnd->add(new DateInterval("P".$daysAdd."D"));
|
$repeatShowEnd->add(new DateInterval("P".$daysAdd."D"));
|
||||||
}
|
}
|
||||||
|
/* Here we are checking each repeating show by
|
||||||
|
* the show day.
|
||||||
|
* (i.e: every wednesday, then every thursday, etc.)
|
||||||
|
*/
|
||||||
while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) {
|
while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) {
|
||||||
//need to get each repeating show's instance id
|
if ($formData['add_show_id'] == -1) {
|
||||||
$qry = CcShowInstancesQuery::create()
|
//this is a new show
|
||||||
->filterByDbStarts($repeatShowStart->format('Y-m-d H:i:s'))
|
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||||
->filterByDbEnds($repeatShowEnd->format('Y-m-d H:i:s'))
|
$repeatShowStart, $repeatShowEnd);
|
||||||
->find();
|
|
||||||
$count = $qry->count();
|
/* If the repeating show is rebroadcasted we need to check
|
||||||
if ($count > 1) {
|
* the rebroadcast dates relative to the repeating show
|
||||||
$overlapping = true;
|
*/
|
||||||
} elseif ($count == 1) {
|
if (!$overlapping && $formData['add_show_rebroadcast']) {
|
||||||
$instanceId = $qry->getFirst()->getDbId();
|
$overlapping = self::checkRebroadcastDates(
|
||||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($repeatShowStart, $repeatShowEnd, $update, $instanceId);
|
$repeatShowStart, $formData, $hours, $minutes);
|
||||||
} else {
|
|
||||||
$overlapping = false;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||||
|
$repeatShowStart, $repeatShowEnd, $update, null, $formData["add_show_id"]);
|
||||||
|
|
||||||
|
if (!$overlapping && $formData['add_show_rebroadcast']) {
|
||||||
|
$overlapping = self::checkRebroadcastDates(
|
||||||
|
$repeatShowStart, $formData, $hours, $minutes, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($overlapping) {
|
if ($overlapping) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
|
||||||
|
@ -275,6 +288,39 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
return $valid;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkRebroadcastDates($repeatShowStart, $formData, $hours, $minutes, $showEdit=false) {
|
||||||
|
$overlapping = false;
|
||||||
|
for ($i = 1; $i <= 10; $i++) {
|
||||||
|
if (empty($formData["add_show_rebroadcast_date_".$i])) break;
|
||||||
|
$rebroadcastShowStart = clone $repeatShowStart;
|
||||||
|
/* formData is in local time so we need to set the
|
||||||
|
* show start back to local time
|
||||||
|
*/
|
||||||
|
$rebroadcastShowStart->setTimezone(new DateTimeZone(
|
||||||
|
Application_Model_Preference::GetTimezone()));
|
||||||
|
$rebroadcastWhenDays = explode(" ", $formData["add_show_rebroadcast_date_".$i]);
|
||||||
|
$rebroadcastWhenTime = explode(":", $formData["add_show_rebroadcast_time_".$i]);
|
||||||
|
$rebroadcastShowStart->add(new DateInterval("P".$rebroadcastWhenDays[0]."D"));
|
||||||
|
$rebroadcastShowStart->setTime($rebroadcastWhenTime[0], $rebroadcastWhenTime[1]);
|
||||||
|
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
|
||||||
|
|
||||||
|
$rebroadcastShowEnd = clone $rebroadcastShowStart;
|
||||||
|
$rebroadcastShowEnd->add(new DateInterval("PT".$hours."H".$minutes."M"));
|
||||||
|
|
||||||
|
if ($showEdit) {
|
||||||
|
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||||
|
$rebroadcastShowStart, $rebroadcastShowEnd, true, null, $formData['add_show_id']);
|
||||||
|
} else {
|
||||||
|
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||||
|
$rebroadcastShowStart, $rebroadcastShowEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($overlapping) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $overlapping;
|
||||||
|
}
|
||||||
|
|
||||||
public function disable()
|
public function disable()
|
||||||
{
|
{
|
||||||
$elements = $this->getElements();
|
$elements = $this->getElements();
|
||||||
|
|
|
@ -1157,14 +1157,21 @@ SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkOverlappingShows($show_start, $show_end,
|
public static function checkOverlappingShows($show_start, $show_end,
|
||||||
$update=false, $instanceId=null)
|
$update=false, $instanceId=null, $showId=null)
|
||||||
{
|
{
|
||||||
$overlapping = false;
|
$overlapping = false;
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
||||||
|
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
||||||
|
':show_end3' => $show_end->format('Y-m-d H:i:s')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/* If a show is being edited, exclude it from the query
|
/* If a show is being edited, exclude it from the query
|
||||||
* In both cases (new and edit) we only grab shows that
|
* In both cases (new and edit) we only grab shows that
|
||||||
* are scheduled 2 days prior
|
* are scheduled 2 days prior
|
||||||
*/
|
*/
|
||||||
//$se = $show_end->format('Y-m-d H:i:s');
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT id,
|
SELECT id,
|
||||||
|
@ -1175,15 +1182,21 @@ WHERE (ends <= :show_end1
|
||||||
OR starts <= :show_end2)
|
OR starts <= :show_end2)
|
||||||
AND date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
AND date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
||||||
AND modified_instance = FALSE
|
AND modified_instance = FALSE
|
||||||
|
SQL;
|
||||||
|
if (is_null($showId)) {
|
||||||
|
$sql .= <<<SQL
|
||||||
AND id != :instanceId
|
AND id != :instanceId
|
||||||
ORDER BY ends
|
ORDER BY ends
|
||||||
SQL;
|
SQL;
|
||||||
$rows = Application_Common_Database::prepareAndExecute($sql, array(
|
$params[':instanceId'] = $instanceId;
|
||||||
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
} else {
|
||||||
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
$sql .= <<<SQL
|
||||||
':show_end3' => $show_end->format('Y-m-d H:i:s'),
|
AND show_id != :showId
|
||||||
':instanceId' => $instanceId
|
ORDER BY ends
|
||||||
), 'all');
|
SQL;
|
||||||
|
$params[':showId'] = $showId;
|
||||||
|
}
|
||||||
|
$rows = Application_Common_Database::prepareAndExecute($sql, $params, 'all');
|
||||||
} else {
|
} else {
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT id,
|
SELECT id,
|
||||||
|
@ -1202,6 +1215,7 @@ SQL;
|
||||||
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
||||||
':show_end3' => $show_end->format('Y-m-d H:i:s')), 'all');
|
':show_end3' => $show_end->format('Y-m-d H:i:s')), 'all');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$start = new DateTime($row["starts"], new DateTimeZone('UTC'));
|
$start = new DateTime($row["starts"], new DateTimeZone('UTC'));
|
||||||
$end = new DateTime($row["ends"], new DateTimeZone('UTC'));
|
$end = new DateTime($row["ends"], new DateTimeZone('UTC'));
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<?php echo $this->element->getElement('sb_date_end'); ?>
|
<?php echo $this->element->getElement('sb_date_end'); ?>
|
||||||
<?php echo $this->element->getElement('sb_time_end'); ?>
|
<?php echo $this->element->getElement('sb_time_end'); ?>
|
||||||
|
|
||||||
<a id="sb_submit" class="btn btn-small" href="#" title="Find Shows">
|
<a id="sb_submit" class="btn btn-small" href="#" title="Display shows in the specified date and time range">
|
||||||
<i class="icon-white icon-search"></i> Find Shows</a>
|
<i class="icon-white icon-search"></i> Find Shows</a>
|
||||||
<div class="sb-advanced-options">
|
<div class="sb-advanced-options">
|
||||||
<fieldset class="padded display_field push-down-8 closed">
|
<fieldset class="padded display_field push-down-8 closed">
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<div id="show_builder" class="sb-content ui-widget ui-widget-content block-shadow omega-block padded">
|
<div id="show_builder" class="sb-content ui-widget ui-widget-content block-shadow omega-block padded">
|
||||||
<div class="sb-timerange">
|
<div class="sb-timerange">
|
||||||
<?php if(!$this->disableLib && !$this->showLib):?>
|
<?php if(!$this->disableLib && !$this->showLib):?>
|
||||||
<a id="sb_edit" class="btn btn-small" href="#" title="Open library to schedule files">
|
<a id="sb_edit" class="btn btn-small" href="#" title="Open library to add or remove content">
|
||||||
Schedule files
|
Add / Remove Content
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php echo $this->sb_form; ?>
|
<?php echo $this->sb_form; ?>
|
||||||
|
|
|
@ -815,9 +815,10 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
//playlist screen if this is the currently edited playlist.
|
//playlist screen if this is the currently edited playlist.
|
||||||
if ((data.ftype === "playlist" || data.ftype === "block") && screen === "playlist") {
|
if ((data.ftype === "playlist" || data.ftype === "block") && screen === "playlist") {
|
||||||
callback = function() {
|
callback = function() {
|
||||||
|
aMedia = [];
|
||||||
|
aMedia.push({"id": data.id, "type": data.ftype});
|
||||||
if (confirm('Are you sure you want to delete the selected item?')) {
|
if (confirm('Are you sure you want to delete the selected item?')) {
|
||||||
AIRTIME.playlist.fnDelete(data.id);
|
AIRTIME.library.fnDeleteItems(aMedia);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ AIRTIME = (function(AIRTIME) {
|
||||||
timeStartId = "#sb_time_start",
|
timeStartId = "#sb_time_start",
|
||||||
dateEndId = "#sb_date_end",
|
dateEndId = "#sb_date_end",
|
||||||
timeEndId = "#sb_time_end",
|
timeEndId = "#sb_time_end",
|
||||||
$toggleLib = $("<a id='sb_edit' class='btn btn-small' href='#' title='Open library to schedule files'>Schedule files</a>"),
|
$toggleLib = $("<a id='sb_edit' class='btn btn-small' href='#' title='Open library to add or remove content'>Add / Remove Content</a>"),
|
||||||
$libClose = $('<a />', {
|
$libClose = $('<a />', {
|
||||||
"class": "close-round",
|
"class": "close-round",
|
||||||
"href": "#",
|
"href": "#",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue