CC-3102 : Show Editing, how it uses day of the week

This commit is contained in:
Naomi Aro 2011-11-25 16:07:03 +01:00
parent e9c25faa34
commit c21cbeb73b
1 changed files with 18 additions and 6 deletions

View File

@ -178,13 +178,27 @@ class Application_Model_Show {
* Sunday are removed. * Sunday are removed.
* *
* @param array p_uncheckedDays * @param array p_uncheckedDays
* An array specifying which days should be removed. * An array specifying which days should be removed. (in the local timezone)
*/ */
public function removeUncheckedDaysInstances($p_uncheckedDays) public function removeUncheckedDaysInstances($p_uncheckedDays)
{ {
global $CC_DBC; global $CC_DBC;
$uncheckedDaysImploded = implode(",", $p_uncheckedDays); //need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
$daysRemovedUTC = array();
$showDays = CcShowDaysQuery::create()
->filterByDbShowId($this->getId())
->find();
foreach($showDays as $showDay) {
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
$startDay = new DateTime("{$showDay->getDbFirstShow()} {$showDay->getDbStartTime()}", new DateTimeZone($showDay->getDbTimezone()));
$startDay->setTimezone(new DateTimeZone("UTC"));
$daysRemovedUTC[] = $startDay->format("w");
}
}
$uncheckedDaysImploded = implode(",", $daysRemovedUTC);
$showId = $this->getId(); $showId = $this->getId();
$timestamp = gmdate("Y-m-d H:i:s"); $timestamp = gmdate("Y-m-d H:i:s");
@ -194,9 +208,6 @@ class Application_Model_Show {
." AND starts > TIMESTAMP '$timestamp'" ." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId"; ." AND show_id = $showId";
Logging::log("sql for removing unchecked days");
Logging::log($sql);
$CC_DBC->query($sql); $CC_DBC->query($sql);
} }
@ -797,6 +808,7 @@ class Application_Model_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){
$this->removeUncheckedDaysInstances($daysRemoved); $this->removeUncheckedDaysInstances($daysRemoved);
} }
} }