cc-2362: upload to soundcloud with the wrong name after show rename.

-changed so that recorded shows are not deleted by default
-changed static method to non-static.
This commit is contained in:
martin 2011-06-06 12:01:37 -04:00
parent eee885f746
commit d591858528
1 changed files with 33 additions and 36 deletions

View File

@ -556,52 +556,49 @@ class Show {
return CcShowInstancesQuery::create()->findPk($row); return CcShowInstancesQuery::create()->findPk($row);
} }
public static function deletePossiblyInvalidInstances($p_data, $p_show, $p_endDate, $isRecorded, $repeatType) public function deletePossiblyInvalidInstances($p_data, $p_endDate, $isRecorded, $repeatType)
{ {
if (($p_data['add_show_repeats'] != $p_show->isRepeating()) || ($isRecorded && !$p_data['add_show_repeats'])){ if ($p_data['add_show_repeats'] != $this->isRepeating()){
//repeat option was toggled. //repeat option was toggled
$p_show->deleteAllInstances(); $this->deleteAllInstances();
}
if($isRecorded && $p_data['add_show_repeats']) {
$p_show->removeAllInstancesFromDate();
} }
if ($p_data['add_show_duration'] != $p_show->getDuration()){ if ($p_data['add_show_duration'] != $this->getDuration()){
//duration has changed //duration has changed
$p_show->updateDurationTime($p_data); $this->updateDurationTime($p_data);
} }
if ($p_data['add_show_repeats']){ if ($p_data['add_show_repeats']){
if (($repeatType == 1 || $repeatType == 2) && if (($repeatType == 1 || $repeatType == 2) &&
$p_data['add_show_start_date'] != $p_show->getStartDate()){ $p_data['add_show_start_date'] != $this->getStartDate()){
//start date has changed when repeat type is bi-weekly or monthly. //start date has changed when repeat type is bi-weekly or monthly.
//This screws up the repeating positions of show instances, so lets //This screws up the repeating positions of show instances, so lets
//just delete them for now. //just delete them for now. (CC-2351)
$p_show->deleteAllInstances(); $this->deleteAllInstances();
} }
if ($p_data['add_show_start_date'] != $p_show->getStartDate() if ($p_data['add_show_start_date'] != $this->getStartDate()
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){ || $p_data['add_show_start_time'] != $this->getStartTime()){
//start date/time has changed //start date/time has changed
$newDate = strtotime($p_data['add_show_start_date']); $newDate = strtotime($p_data['add_show_start_date']);
$oldDate = strtotime($p_show->getStartDate()); $oldDate = strtotime($this->getStartDate());
if ($newDate > $oldDate){ if ($newDate > $oldDate){
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']); $this->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
} }
$p_show->updateStartDateTime($p_data, $p_endDate); $this->updateStartDateTime($p_data, $p_endDate);
} }
if ($repeatType != $p_show->getRepeatType()){ if ($repeatType != $this->getRepeatType()){
//repeat type changed. //repeat type changed.
$p_show->deleteAllInstances(); $this->deleteAllInstances();
} else { } else {
//repeat type is the same, check if the days of the week are the same //repeat type is the same, check if the days of the week are the same
$repeatingDaysChanged = false; $repeatingDaysChanged = false;
$showDaysArray = $p_show->getShowDays(); $showDaysArray = $this->getShowDays();
if (count($p_data['add_show_day_check']) == count($showDaysArray)){ if (count($p_data['add_show_day_check']) == count($showDaysArray)){
//same number of days checked, lets see if they are the same numbers //same number of days checked, lets see if they are the same numbers
$intersect = array_intersect($p_data['add_show_day_check'], $showDaysArray); $intersect = array_intersect($p_data['add_show_day_check'], $showDaysArray);
@ -617,28 +614,28 @@ class Show {
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']); $daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
if (count($daysRemoved) > 0){ if (count($daysRemoved) > 0){
$p_show->removeUncheckedDaysInstances($daysRemoved); $this->removeUncheckedDaysInstances($daysRemoved);
} }
} }
} }
//Check if end date for the repeat option has changed. If so, need to take care //Check if end date for the repeat option has changed. If so, need to take care
//of deleting possible invalid Show Instances. //of deleting possible invalid Show Instances.
if ((strlen($p_show->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){ if ((strlen($this->getRepeatingEndDate()) == 0) == $p_data['add_show_no_end']){
//show "Never Ends" option was toggled. //show "Never Ends" option was toggled.
if ($p_data['add_show_no_end']){ if ($p_data['add_show_no_end']){
} }
else { else {
$p_show->removeAllInstancesFromDate($p_endDate); $this->removeAllInstancesFromDate($p_endDate);
} }
} }
if ($p_show->getRepeatingEndDate() != $p_data['add_show_end_date']){ if ($this->getRepeatingEndDate() != $p_data['add_show_end_date']){
//end date was changed. //end date was changed.
$newDate = strtotime($p_data['add_show_end_date']); $newDate = strtotime($p_data['add_show_end_date']);
$oldDate = strtotime($p_show->getRepeatingEndDate()); $oldDate = strtotime($this->getRepeatingEndDate());
if ($newDate < $oldDate){ if ($newDate < $oldDate){
$p_show->removeAllInstancesFromDate($p_endDate); $this->removeAllInstancesFromDate($p_endDate);
} }
} }
} }
@ -704,7 +701,7 @@ class Show {
$isRecorded = ($data['add_show_record']) ? 1 : 0; $isRecorded = ($data['add_show_record']) ? 1 : 0;
if ($data['add_show_id'] != -1){ if ($data['add_show_id'] != -1){
Show::deletePossiblyInvalidInstances($data, $show, $endDate, $isRecorded, $repeatType); $show->deletePossiblyInvalidInstances($data, $endDate, $isRecorded, $repeatType);
} }
//check if we are adding or updating a show, and if updating //check if we are adding or updating a show, and if updating