CC-2336 Some Show Editing Features Seem to have been lost

This commit is contained in:
Naomi Aro 2011-05-30 18:12:57 -04:00
parent 1bca5208e7
commit f5e6082ee7
2 changed files with 32 additions and 9 deletions

View File

@ -18,6 +18,15 @@ class DateHelper
return date("Y-m-d H:i:s", $this->_timestamp);
}
/**
* Get date of object construction in the format
* YY:mm:dd
*/
function getDate()
{
return date("Y-m-d", $this->_timestamp);
}
/**
* Get time of object construction in the format
* HH:mm:ss

View File

@ -318,14 +318,19 @@ class Show {
* certain date.
*
* @param string $p_date
* The date which to delete after
* The date which to delete after, if null deletes from the current timestamp.
*/
public function removeAllInstancesFromDate($p_date){
public function removeAllInstancesFromDate($p_date=null){
global $CC_DBC;
$date = new DateHelper;
$timestamp = $date->getTimestamp();
if(is_null($p_date)) {
$date = new DateHelper;
$p_date = $date->getDate();
}
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances "
." WHERE date(starts) >= DATE '$p_date'"
@ -333,6 +338,13 @@ class Show {
." AND show_id = $showId";
$CC_DBC->query($sql);
/*
CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbStartTime($p_date, Criteria::GREATER_EQUAL)
->delete();
*/
}
/**
@ -546,10 +558,13 @@ class Show {
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType)
{
if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || $isRecorded){
//repeat option was toggled or show is recorded.
if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || ($isRecorded && !$p_data['add_show_repeats'])){
//repeat option was toggled.
$p_show->deleteAllInstances();
}
if($isRecorded && $p_data['add_show_repeats']) {
$p_show->removeAllInstancesFromDate();
}
if ($p_data['add_show_duration'] != $p_show->getDuration()){
//duration has changed
@ -741,11 +756,11 @@ class Show {
if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){
CcShowRebroadcastQuery::create()
->filterByDbShowId($data['add_show_id'])
->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL)
//->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL)
->delete();
}
//adding rows to cc_show_rebroadcast
if (($isRecorded && $data['add_show_rebroadcast']) && $repeatType != -1) {
if (($isRecorded && $data['add_show_rebroadcast']) && ($repeatType != -1)) {
for ($i=1; $i<=10; $i++) {
if ($data['add_show_rebroadcast_date_'.$i]) {
$showRebroad = new CcShowRebroadcast();
@ -864,13 +879,11 @@ class Show {
private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp)
{
global $CC_DBC;
$next_date = $first_show." ".$start_time;
if (strtotime($next_date) < strtotime($end_timestamp)) {
$start = $next_date;
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
$end = $CC_DBC->GetOne($sql);
@ -878,7 +891,8 @@ class Show {
if ($show->hasInstance()){
$ccShowInstance = $show->getInstance();
$newInstance = false;
} else {
}
else {
$ccShowInstance = new CcShowInstances();
$newInstance = true;
}