CC-1805: Ability to edit a show

-All cases for "When" tab should be covered for editing shows.
This commit is contained in:
martin 2011-04-12 11:54:24 -04:00
parent 64124175c5
commit ea11e0114a
1 changed files with 276 additions and 253 deletions

View File

@ -138,6 +138,7 @@ class Show {
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances"
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
." AND starts > current_timestamp "
." AND show_id = $showId";
$CC_DBC->query($sql);
@ -251,6 +252,19 @@ class Show {
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances "
."WHERE date(starts) > DATE '$p_date' "
."AND starts > current_timestamp "
."AND show_id = $showId";
$CC_DBC->query($sql);
}
public function removeAllInstancesBeforeDate($p_date){
global $CC_DBC;
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances "
."WHERE date(starts) < DATE '$p_date' "
."AND starts > current_timestamp "
."AND show_id = $showId";
$CC_DBC->query($sql);
@ -288,12 +302,13 @@ class Show {
}
}
public function getAllInstanceIds(){
public function getAllFutureInstanceIds(){
global $CC_DBC;
$showId = $this->getId();
$sql = "SELECT id from cc_show_instances "
." WHERE show_id = $showId";
." WHERE show_id = $showId"
." AND starts > current_timestamp";
$rows = $CC_DBC->GetAll($sql);
@ -316,7 +331,8 @@ class Show {
$sql = "UPDATE cc_show_instances "
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
."WHERE show_id = $p_data[add_show_id]";
."WHERE show_id = $p_data[add_show_id] "
."AND starts > current_timestamp";
$CC_DBC->query($sql);
}
@ -344,10 +360,11 @@ class Show {
$sql = "UPDATE cc_show_instances "
."SET starts = starts + INTERVAL '$diff sec', "
."ends = ends + INTERVAL '$diff sec' "
."WHERE show_id = $p_data[add_show_id]";
."WHERE show_id = $p_data[add_show_id] "
."AND starts > current_timestamp";
$CC_DBC->query($sql);
$showInstanceIds = $this->getAllInstanceIds();
$showInstanceIds = $this->getAllFutureInstanceIds();
if (count($showInstanceIds) > 0 && $diff != 0){
$showIdsImploded = implode(",", $showInstanceIds);
$sql = "UPDATE cc_schedule "
@ -410,6 +427,12 @@ class Show {
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
//start date/time has changed
$newDate = strtotime($p_data['add_show_start_date']);
$oldDate = strtotime($p_show->getStartDate());
if ($newDate > $oldDate){
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
}
$p_show->updateStartDateTime($p_data, $p_endDate);
}
if ($p_data['add_show_duration'] != $p_show->getDuration()){