diff --git a/.zfproject.xml b/.zfproject.xml index 9767ec927..cb27bbd9d 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -122,6 +122,9 @@ + + + diff --git a/application/configs/classmap-airtime-conf.php b/application/configs/classmap-airtime-conf.php index 3bde9f69f..a4f799421 100644 --- a/application/configs/classmap-airtime-conf.php +++ b/application/configs/classmap-airtime-conf.php @@ -50,6 +50,13 @@ return array ( 'BaseCcShowDaysPeer' => 'airtime/om/BaseCcShowDaysPeer.php', 'BaseCcShowDays' => 'airtime/om/BaseCcShowDays.php', 'BaseCcShowDaysQuery' => 'airtime/om/BaseCcShowDaysQuery.php', + 'CcShowRebroadcastTableMap' => 'airtime/map/CcShowRebroadcastTableMap.php', + 'CcShowRebroadcastPeer' => 'airtime/CcShowRebroadcastPeer.php', + 'CcShowRebroadcast' => 'airtime/CcShowRebroadcast.php', + 'CcShowRebroadcastQuery' => 'airtime/CcShowRebroadcastQuery.php', + 'BaseCcShowRebroadcastPeer' => 'airtime/om/BaseCcShowRebroadcastPeer.php', + 'BaseCcShowRebroadcast' => 'airtime/om/BaseCcShowRebroadcast.php', + 'BaseCcShowRebroadcastQuery' => 'airtime/om/BaseCcShowRebroadcastQuery.php', 'CcShowHostsTableMap' => 'airtime/map/CcShowHostsTableMap.php', 'CcShowHostsPeer' => 'airtime/CcShowHostsPeer.php', 'CcShowHosts' => 'airtime/CcShowHosts.php', diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index 2a3fe6117..aa4696f89 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -16,6 +16,16 @@ class ApiController extends Zend_Controller_Action // action body } + /** + * Returns Airtime version. i.e "1.7.0 alpha" + * + * First checks to ensure the correct API key was + * supplied, then returns AIRTIME_VERSION as defined + * in application/conf.php + * + * @return void + * + */ public function versionAction() { global $CC_CONFIG; @@ -35,7 +45,12 @@ class ApiController extends Zend_Controller_Action echo $jsonStr; } - + /** + * Allows remote client to download requested media file. + * + * @return void + * The given value increased by the increment amount. + */ public function getMediaAction() { global $CC_CONFIG; @@ -67,23 +82,9 @@ class ApiController extends Zend_Controller_Action // !! binary mode !! $fp = fopen($filepath, 'rb'); - $mtype = ''; - - /* - // magic_mime module installed? - if (function_exists('mime_content_type')) { - $mtype = mime_content_type($file_path); - } - // fileinfo module installed? - else if (function_exists('finfo_file')) { - $finfo = finfo_open(FILEINFO_MIME); // return mime type - $mtype = finfo_file($finfo, $file_path); - finfo_close($finfo); - } - - //header("Content-Type: $mtype"); - */ + // possibly use fileinfo module here in the future. + // http://www.php.net/manual/en/book.fileinfo.php $ext = pathinfo($filename, PATHINFO_EXTENSION); if ($ext == "ogg") header("Content-Type: audio/ogg"); @@ -92,17 +93,12 @@ class ApiController extends Zend_Controller_Action header("Content-Length: " . filesize($filepath)); - //header('Content-Disposition: attachment; filename="'.$media->getRealMetadataFileName().'"'); fpassthru($fp); + return; } - else { - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); - exit; - } - } else { - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); - exit; - } + } + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); + exit; } public function scheduleAction() diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index b0924ebb6..d3df6f232 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -34,7 +34,7 @@ class ScheduleController extends Zend_Controller_Action { $this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript'); $this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript'); - $this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript'); + $this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.js','text/javascript'); $this->view->headScript()->appendFile('/js/timepicker/jquery.ui.timepicker-0.0.6.js','text/javascript'); $this->view->headScript()->appendFile('/js/colorpicker/js/colorpicker.js','text/javascript'); $this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript'); @@ -48,22 +48,33 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet('/css/contextmenu.css'); $request = $this->getRequest(); + $formWhat = new Application_Form_AddShowWhat(); - $formWhat->removeDecorator('DtDdWrapper'); $formWho = new Application_Form_AddShowWho(); - $formWho->removeDecorator('DtDdWrapper'); $formWhen = new Application_Form_AddShowWhen(); - $formWhen->removeDecorator('DtDdWrapper'); $formRepeats = new Application_Form_AddShowRepeats(); - $formRepeats->removeDecorator('DtDdWrapper'); $formStyle = new Application_Form_AddShowStyle(); + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formWhat->removeDecorator('DtDdWrapper'); + $formWho->removeDecorator('DtDdWrapper'); + $formWhen->removeDecorator('DtDdWrapper'); + $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); + $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); + $formRebroadcast->removeDecorator('DtDdWrapper'); $this->view->what = $formWhat; - $this->view->when = $formWhen; - $this->view->repeats = $formRepeats; - $this->view->who = $formWho; - $this->view->style = $formStyle; + $this->view->when = $formWhen; + $this->view->repeats = $formRepeats; + $this->view->who = $formWho; + $this->view->style = $formStyle; + $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $this->view->rebroadcast = $formRebroadcast; $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); @@ -141,19 +152,27 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); - $show = new ShowInstance($id); $params = '/format/json/id/#id#'; if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { - if ($user->isHost($show->getShowId()) || $user->isAdmin()) { - $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params, 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add Content'); + + if (($user->isHost($show->getShowId()) || $user->isAdmin()) && !$show->isRecorded() && !$show->isRebroadcast()) { + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params, + 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add Content'); + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params, + 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content'); } - } - $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params, 'callback' => 'window["buildContentDialog"]'), - 'title' => 'Show Content'); - + + } + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog'.$params, + 'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content'); + + if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) && strtotime($today_timestamp) < strtotime($show->getShowEnd())) { $menu[] = array('action' => array('type' => 'fn', @@ -163,15 +182,15 @@ class ScheduleController extends Zend_Controller_Action } if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { + if ($user->isAdmin()) { - $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance'); - $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); - } - if ($user->isHost($show->getShowId()) || $user->isAdmin()) { - $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content'); + + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, + 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance'); + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params, + 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); } } - //returns format jjmenu is looking for. die(json_encode($menu)); @@ -328,19 +347,27 @@ class ScheduleController extends Zend_Controller_Action $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); + $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); + $formRebroadcast->removeDecorator('DtDdWrapper'); $this->view->what = $formWhat; $this->view->when = $formWhen; $this->view->repeats = $formRepeats; $this->view->who = $formWho; $this->view->style = $formStyle; - + $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $this->view->rebroadcast = $formRebroadcast; $what = $formWhat->isValid($data); $when = $formWhen->isValid($data); if($when) { diff --git a/application/forms/AddShowAbsoluteRebroadcastDates.php b/application/forms/AddShowAbsoluteRebroadcastDates.php new file mode 100644 index 000000000..322f8843d --- /dev/null +++ b/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -0,0 +1,37 @@ +addElement('text', 'add_show_rebroadcast_absolute_date_1', array( + 'label' => 'Rebroadcast Date:', + 'class' => 'input_text', + 'required' => true, + 'value' => date("Y-m-d"), + 'filters' => array('StringTrim'), + 'validators' => array( + 'NotEmpty', + array('date', false, array('YYYY-MM-DD')) + ) + )); + + // Add start time element + $this->addElement('text', 'add_show_rebroadcast_absolute_time_1', array( + 'label' => 'Rebroadcast Time:', + 'class' => 'input_text', + 'required' => true, + 'value' => '0:00', + 'filters' => array('StringTrim'), + 'validators' => array( + 'NotEmpty', + array('date', false, array('HH:mm')) + ) + )); + } + + +} + diff --git a/application/forms/AddShowRR.php b/application/forms/AddShowRR.php new file mode 100644 index 000000000..7ae1ec5b0 --- /dev/null +++ b/application/forms/AddShowRR.php @@ -0,0 +1,23 @@ +addElement('checkbox', 'add_show_record', array( + 'label' => 'Record', + 'required' => false, + )); + + // Add record element + $this->addElement('checkbox', 'add_show_rebroadcast', array( + 'label' => 'Rebroadcast', + 'required' => false, + )); + } + + +} + diff --git a/application/forms/AddShowRebroadcastDates.php b/application/forms/AddShowRebroadcastDates.php new file mode 100644 index 000000000..794917bc4 --- /dev/null +++ b/application/forms/AddShowRebroadcastDates.php @@ -0,0 +1,37 @@ +addElement('select', 'add_show_rebroadcast_date_1', array( + 'label' => 'Rebroadcast Day:', + 'required' => true, + 'class' => ' input_select', + 'multiOptions' => array( + "0 days" => "+0 days ", + "1 day" => "+1 day ", + "2 days" => "+2 days", + "3 days" => "+3 days" + ), + )); + + // Add start time element + $this->addElement('text', 'add_show_start_time_1', array( + 'label' => 'Rebroadcast Time:', + 'class' => 'input_text', + 'required' => true, + 'value' => '0:00', + 'filters' => array('StringTrim'), + 'validators' => array( + 'NotEmpty', + array('date', false, array('HH:mm')) + ) + )); + } + + +} + diff --git a/application/models/Shows.php b/application/models/Shows.php index 976bb253f..a1faadc07 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -117,8 +117,16 @@ class Show { $showId = $show->getDbId(); + if($data['add_show_record']){ + $isRecorded = 1; + } + else { + $isRecorded = 0; + } + //don't set day for monthly repeat type, it's invalid. if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) { + $showDay = new CcShowDays(); $showDay->setDbFirstShow($data['add_show_start_date']); $showDay->setDbLastShow($endDate); @@ -126,7 +134,9 @@ class Show { $showDay->setDbDuration($data['add_show_duration']); $showDay->setDbRepeatType($repeat_type); $showDay->setDbShowId($showId); + $showDay->setDbRecord($isRecorded); $showDay->save(); + } else { @@ -157,10 +167,42 @@ class Show { $showDay->setDbDay($day); $showDay->setDbRepeatType($repeat_type); $showDay->setDbShowId($showId); + $showDay->setDbRecord($isRecorded); $showDay->save(); } } } + + //adding rows to cc_show_rebroadcast + if($repeat_type != -1) { + + for($i=1; $i<=1; $i++) { + + $showRebroad = new CcShowRebroadcast(); + $showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]); + $showRebroad->setDbStartTime($data['add_show_start_time_'.$i]); + $showRebroad->setDbShowId($showId); + $showRebroad->save(); + } + } + else { + + for($i=1; $i<=1; $i++) { + + if($data['add_show_rebroadcast_absolute_date_'.$i]) { + + $sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' "; + $r = $con->query($sql); + $offset_days = $r->fetchColumn(0); + + $showRebroad = new CcShowRebroadcast(); + $showRebroad->setDbDayOffset($offset_days." days"); + $showRebroad->setDbStartTime($data['add_show_rebroadcast_absolute_time_'.$i]); + $showRebroad->setDbShowId($showId); + $showRebroad->save(); + } + } + } if(is_array($data['add_show_hosts'])) { //add selected hosts to cc_show_hosts table. @@ -178,7 +220,8 @@ class Show { public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE) { global $CC_DBC; - $sql = "SELECT starts, ends, show_id, name, description, color, background_color, cc_show_instances.id AS instance_id + $sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description, + color, background_color, cc_show_instances.id AS instance_id FROM cc_show_instances LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id"; @@ -210,8 +253,21 @@ class Show { return $CC_DBC->GetAll($sql); } - //for a show with repeat_type == -1 - private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $end_timestamp) { + private static function setNextPop($next_date, $show_id, $day) { + + $nextInfo = explode(" ", $next_date); + + $repeatInfo = CcShowDaysQuery::create() + ->filterByDbShowId($show_id) + ->filterByDbDay($day) + ->findOne(); + + $repeatInfo->setDbNextPopDate($nextInfo[0]) + ->save(); + } + + //for a show with repeat_type == -1 + private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp) { global $CC_DBC; $next_date = $first_show." ".$start_time; @@ -227,25 +283,39 @@ class Show { $newShow->setDbShowId($show_id); $newShow->setDbStarts($start); $newShow->setDbEnds($end); + $newShow->setDbRecord($record); $newShow->save(); + + $show_instance_id = $newShow->getDbId(); + + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; + $rebroadcasts = $CC_DBC->GetAll($sql); + + foreach($rebroadcasts as $rebroadcast) { + + $timeinfo = explode(" ", $start); + + $sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; + $rebroadcast_start_time = $CC_DBC->GetOne($sql); + + $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; + $rebroadcast_end_time = $CC_DBC->GetOne($sql); + + $newRebroadcastInstance = new CcShowInstances(); + $newRebroadcastInstance->setDbShowId($show_id); + $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); + $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); + $newRebroadcastInstance->setDbRecord(0); + $newRebroadcastInstance->setDbRebroadcast(1); + $newRebroadcastInstance->setDbOriginalShow($show_instance_id); + $newRebroadcastInstance->save(); + } } } - private static function setNextPop($next_date, $show_id, $day) { - - $nextInfo = explode(" ", $next_date); - - $repeatInfo = CcShowDaysQuery::create() - ->filterByDbShowId($show_id) - ->filterByDbDay($day) - ->findOne(); - - $repeatInfo->setDbNextPopDate($nextInfo[0]) - ->save(); - } - - //for a show with repeat_type == 0 - private static function populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) { + //for a show with repeat_type == 0,1,2 + private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, + $start_time, $duration, $day, $record, $end_timestamp, $interval) { global $CC_DBC; if(isset($next_pop_date)) { @@ -255,6 +325,9 @@ class Show { $next_date = $first_show." ".$start_time; } + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; + $rebroadcasts = $CC_DBC->GetAll($sql); + while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) { $start = $next_date; @@ -266,90 +339,55 @@ class Show { $newShow->setDbShowId($show_id); $newShow->setDbStarts($start); $newShow->setDbEnds($end); + $newShow->setDbRecord($record); $newShow->save(); - $sql = "SELECT timestamp '{$start}' + interval '7 days'"; + $show_instance_id = $newShow->getDbId(); + + foreach($rebroadcasts as $rebroadcast) { + + $timeinfo = explode(" ", $next_date); + + $sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; + $rebroadcast_start_time = $CC_DBC->GetOne($sql); + + $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; + $rebroadcast_end_time = $CC_DBC->GetOne($sql); + + $newRebroadcastInstance = new CcShowInstances(); + $newRebroadcastInstance->setDbShowId($show_id); + $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); + $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); + $newRebroadcastInstance->setDbRecord(0); + $newRebroadcastInstance->setDbRebroadcast(1); + $newRebroadcastInstance->setDbOriginalShow($show_instance_id); + $newRebroadcastInstance->save(); + } + + $sql = "SELECT timestamp '{$start}' + interval '{$interval}'"; $next_date = $CC_DBC->GetOne($sql); } Show::setNextPop($next_date, $show_id, $day); } - //for a show with repeat_type == 1 - private static function populateBiWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) { - global $CC_DBC; - - if(isset($next_pop_date)) { - $next_date = $next_pop_date." ".$start_time; - } - else { - $next_date = $first_show." ".$start_time; - } - - while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) { - - $start = $next_date; - - $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; - $end = $CC_DBC->GetOne($sql); - - $newShow = new CcShowInstances(); - $newShow->setDbShowId($show_id); - $newShow->setDbStarts($start); - $newShow->setDbEnds($end); - $newShow->save(); - - $sql = "SELECT timestamp '{$start}' + interval '14 days'"; - $next_date = $CC_DBC->GetOne($sql); - } - - Show::setNextPop($next_date, $show_id, $day); - } - - //for a show with repeat_type == 2 - private static function populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) { - global $CC_DBC; - - if(isset($next_pop_date)) { - $next_date = $next_pop_date." ".$start_time; - } - else { - $next_date = $first_show." ".$start_time; - } - - while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) { - - $start = $next_date; - - $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; - $end = $CC_DBC->GetOne($sql); - - $newShow = new CcShowInstances(); - $newShow->setDbShowId($show_id); - $newShow->setDbStarts($start); - $newShow->setDbEnds($end); - $newShow->save(); - - $sql = "SELECT timestamp '{$start}' + interval '1 month'"; - $next_date = $CC_DBC->GetOne($sql); - } - - Show::setNextPop($next_date, $show_id, $day); - } - - private static function populateShow($repeat_type, $show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) { + private static function populateShow($repeat_type, $show_id, $next_pop_date, + $first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp) { if($repeat_type == -1) { - Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $end_timestamp); + Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp); } else if($repeat_type == 0) { - Show::populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp); + Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, + $start_time, $duration, $day, $record, $end_timestamp, '7 days'); } else if($repeat_type == 1) { - Show::populateBiWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp); + Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, + $start_time, $duration, $day, $record, $end_timestamp, '14 days'); } else if($repeat_type == 2) { - Show::populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp); + Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, + $start_time, $duration, $day, $record, $end_timestamp, '1 month'); } } @@ -363,7 +401,7 @@ class Show { foreach($res as $row) { Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"], - $row["last_show"], $row["start_time"], $row["duration"], $row["day"], $showsPopUntil); + $row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $showsPopUntil); } } @@ -387,7 +425,7 @@ class Show { foreach($res as $row) { Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"], - $row["last_show"], $row["start_time"], $row["duration"], $row["day"], $end_timestamp); + $row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $end_timestamp); } } @@ -418,18 +456,28 @@ class Show { private static function makeFullCalendarEvent($show, $options=array()) { global $CC_DBC; + + $event = array(); - $event = array( - "id" => $show["instance_id"], - "title" => $show["name"], - "start" => $show["starts"], - "end" => $show["ends"], - "allDay" => false, - "description" => $show["description"], - "color" => $show["color"], - "backgroundColor" => $show["background_color"], - "showId" => $show["show_id"] - ); + if($show["rebroadcast"]) { + $title = "REBROADCAST ".$show["name"]; + $event["disableResizing"] = true; + } + else { + $title = $show["name"]; + } + + $event["id"] = $show["instance_id"]; + $event["title"] = $title; + $event["start"] = $show["starts"]; + $event["end"] = $show["ends"]; + $event["allDay"] = false; + $event["description"] = $show["description"]; + $event["color"] = $show["color"]; + $event["backgroundColor"] = $show["background_color"]; + $event["showId"] = $show["show_id"]; + $event["record"] = intval($show["record"]); + $event["rebroadcast"] = intval($show["rebroadcast"]); foreach($options as $key=>$value) { $event[$key] = $value; @@ -460,6 +508,16 @@ class ShowInstance { return $this->_instanceId; } + public function isRebroadcast() { + $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); + return $showInstance->getDbRebroadcast(); + } + + public function isRecorded() { + $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); + return $showInstance->getDbRecord(); + } + public function getName() { $show = CcShowQuery::create()->findPK($this->getShowId()); return $show->getDbName(); @@ -560,6 +618,13 @@ class ShowInstance { } } //with overbooking no longer need to check already scheduled content still fits. + + //must update length of all rebroadcast instances. + if($this->isRecorded()) { + $sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') + WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}"; + $CC_DBC->query($sql); + } $this->setShowEnd($new_ends); } diff --git a/application/models/airtime/CcShowRebroadcast.php b/application/models/airtime/CcShowRebroadcast.php new file mode 100644 index 000000000..216387959 --- /dev/null +++ b/application/models/airtime/CcShowRebroadcast.php @@ -0,0 +1,18 @@ +addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null); + $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); } // buildRelations() diff --git a/application/models/airtime/map/CcShowDaysTableMap.php b/application/models/airtime/map/CcShowDaysTableMap.php index ecd03ac15..333934c44 100644 --- a/application/models/airtime/map/CcShowDaysTableMap.php +++ b/application/models/airtime/map/CcShowDaysTableMap.php @@ -47,6 +47,7 @@ class CcShowDaysTableMap extends TableMap { $this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null); $this->addColumn('NEXT_POP_DATE', 'DbNextPopDate', 'DATE', false, null, null); $this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null); + $this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, null); // validators } // initialize() diff --git a/application/models/airtime/map/CcShowInstancesTableMap.php b/application/models/airtime/map/CcShowInstancesTableMap.php index f4fc54349..b826c19ce 100644 --- a/application/models/airtime/map/CcShowInstancesTableMap.php +++ b/application/models/airtime/map/CcShowInstancesTableMap.php @@ -42,6 +42,10 @@ class CcShowInstancesTableMap extends TableMap { $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); $this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null); $this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null); + $this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, 0); + $this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0); + $this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null); + $this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null); // validators } // initialize() @@ -51,6 +55,9 @@ class CcShowInstancesTableMap extends TableMap { public function buildRelations() { $this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcShowInstancesRelatedByDbOriginalShow', 'CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcShowInstancesRelatedByDbId', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null); $this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null); } // buildRelations() diff --git a/application/models/airtime/map/CcShowRebroadcastTableMap.php b/application/models/airtime/map/CcShowRebroadcastTableMap.php new file mode 100644 index 000000000..60a9ba980 --- /dev/null +++ b/application/models/airtime/map/CcShowRebroadcastTableMap.php @@ -0,0 +1,56 @@ +setName('cc_show_rebroadcast'); + $this->setPhpName('CcShowRebroadcast'); + $this->setClassname('CcShowRebroadcast'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_show_rebroadcast_id_seq'); + // columns + $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('DAY_OFFSET', 'DbDayOffset', 'VARCHAR', true, 255, null); + $this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null); + $this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); + } // buildRelations() + +} // CcShowRebroadcastTableMap diff --git a/application/models/airtime/map/CcShowTableMap.php b/application/models/airtime/map/CcShowTableMap.php index cdac72d46..c9db01d0b 100644 --- a/application/models/airtime/map/CcShowTableMap.php +++ b/application/models/airtime/map/CcShowTableMap.php @@ -53,6 +53,7 @@ class CcShowTableMap extends TableMap { { $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); $this->addRelation('CcShowDays', 'CcShowDays', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); + $this->addRelation('CcShowRebroadcast', 'CcShowRebroadcast', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); $this->addRelation('CcShowHosts', 'CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); } // buildRelations() diff --git a/application/models/airtime/om/BaseCcFiles.php b/application/models/airtime/om/BaseCcFiles.php index 68d3b0c58..024913755 100644 --- a/application/models/airtime/om/BaseCcFiles.php +++ b/application/models/airtime/om/BaseCcFiles.php @@ -359,6 +359,11 @@ abstract class BaseCcFiles extends BaseObject implements Persistent */ protected $aCcSubjs; + /** + * @var array CcShowInstances[] Collection to store aggregation of CcShowInstances objects. + */ + protected $collCcShowInstancess; + /** * @var array CcPlaylistcontents[] Collection to store aggregation of CcPlaylistcontents objects. */ @@ -2316,6 +2321,8 @@ abstract class BaseCcFiles extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? $this->aCcSubjs = null; + $this->collCcShowInstancess = null; + $this->collCcPlaylistcontentss = null; } // if (deep) @@ -2463,6 +2470,14 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } + if ($this->collCcShowInstancess !== null) { + foreach ($this->collCcShowInstancess as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->collCcPlaylistcontentss !== null) { foreach ($this->collCcPlaylistcontentss as $referrerFK) { if (!$referrerFK->isDeleted()) { @@ -2554,6 +2569,14 @@ abstract class BaseCcFiles extends BaseObject implements Persistent } + if ($this->collCcShowInstancess !== null) { + foreach ($this->collCcShowInstancess as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collCcPlaylistcontentss !== null) { foreach ($this->collCcPlaylistcontentss as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -3296,6 +3319,12 @@ abstract class BaseCcFiles extends BaseObject implements Persistent // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); + foreach ($this->getCcShowInstancess() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowInstances($relObj->copy($deepCopy)); + } + } + foreach ($this->getCcPlaylistcontentss() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCcPlaylistcontents($relObj->copy($deepCopy)); @@ -3396,6 +3425,165 @@ abstract class BaseCcFiles extends BaseObject implements Persistent return $this->aCcSubjs; } + /** + * Clears out the collCcShowInstancess collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCcShowInstancess() + */ + public function clearCcShowInstancess() + { + $this->collCcShowInstancess = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcShowInstancess collection. + * + * By default this just sets the collCcShowInstancess collection to an empty array (like clearcollCcShowInstancess()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initCcShowInstancess() + { + $this->collCcShowInstancess = new PropelObjectCollection(); + $this->collCcShowInstancess->setModel('CcShowInstances'); + } + + /** + * Gets an array of CcShowInstances objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this CcFiles is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + * @throws PropelException + */ + public function getCcShowInstancess($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcShowInstancess || null !== $criteria) { + if ($this->isNew() && null === $this->collCcShowInstancess) { + // return empty collection + $this->initCcShowInstancess(); + } else { + $collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + return $collCcShowInstancess; + } + $this->collCcShowInstancess = $collCcShowInstancess; + } + } + return $this->collCcShowInstancess; + } + + /** + * Returns the number of related CcShowInstances objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowInstances objects. + * @throws PropelException + */ + public function countCcShowInstancess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcShowInstancess || null !== $criteria) { + if ($this->isNew() && null === $this->collCcShowInstancess) { + return 0; + } else { + $query = CcShowInstancesQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcFiles($this) + ->count($con); + } + } else { + return count($this->collCcShowInstancess); + } + } + + /** + * Method called to associate a CcShowInstances object to this object + * through the CcShowInstances foreign key attribute. + * + * @param CcShowInstances $l CcShowInstances + * @return void + * @throws PropelException + */ + public function addCcShowInstances(CcShowInstances $l) + { + if ($this->collCcShowInstancess === null) { + $this->initCcShowInstancess(); + } + if (!$this->collCcShowInstancess->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcShowInstancess[]= $l; + $l->setCcFiles($this); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcFiles is new, it will return + * an empty collection; or if this CcFiles has previously + * been saved, it will retrieve related CcShowInstancess from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcFiles. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShow', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcFiles is new, it will return + * an empty collection; or if this CcFiles has previously + * been saved, it will retrieve related CcShowInstancess from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcFiles. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcShowInstancesRelatedByDbOriginalShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShowInstancesRelatedByDbOriginalShow', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + /** * Clears out the collCcPlaylistcontentss collection * @@ -3610,6 +3798,11 @@ abstract class BaseCcFiles extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collCcShowInstancess) { + foreach ((array) $this->collCcShowInstancess as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCcPlaylistcontentss) { foreach ((array) $this->collCcPlaylistcontentss as $o) { $o->clearAllReferences($deep); @@ -3617,6 +3810,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent } } // if ($deep) + $this->collCcShowInstancess = null; $this->collCcPlaylistcontentss = null; $this->aCcSubjs = null; } diff --git a/application/models/airtime/om/BaseCcFilesPeer.php b/application/models/airtime/om/BaseCcFilesPeer.php index 04fd0b423..db0de6078 100644 --- a/application/models/airtime/om/BaseCcFilesPeer.php +++ b/application/models/airtime/om/BaseCcFilesPeer.php @@ -603,6 +603,9 @@ abstract class BaseCcFilesPeer { */ public static function clearRelatedInstancePool() { + // Invalidate objects in CcShowInstancesPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowInstancesPeer::clearInstancePool(); // Invalidate objects in CcPlaylistcontentsPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CcPlaylistcontentsPeer::clearInstancePool(); diff --git a/application/models/airtime/om/BaseCcFilesQuery.php b/application/models/airtime/om/BaseCcFilesQuery.php index 279128d3b..c7dd35f3e 100644 --- a/application/models/airtime/om/BaseCcFilesQuery.php +++ b/application/models/airtime/om/BaseCcFilesQuery.php @@ -124,6 +124,10 @@ * @method CcFilesQuery rightJoinCcSubjs($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcSubjs relation * @method CcFilesQuery innerJoinCcSubjs($relationAlias = '') Adds a INNER JOIN clause to the query using the CcSubjs relation * + * @method CcFilesQuery leftJoinCcShowInstances($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowInstances relation + * @method CcFilesQuery rightJoinCcShowInstances($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowInstances relation + * @method CcFilesQuery innerJoinCcShowInstances($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowInstances relation + * * @method CcFilesQuery leftJoinCcPlaylistcontents($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcPlaylistcontents relation * @method CcFilesQuery rightJoinCcPlaylistcontents($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcontents relation * @method CcFilesQuery innerJoinCcPlaylistcontents($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcontents relation @@ -1650,6 +1654,70 @@ abstract class BaseCcFilesQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); } + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances $ccShowInstances the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByCcShowInstances($ccShowInstances, $comparison = null) + { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccShowInstances->getDbRecordedFile(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcShowInstances relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function joinCcShowInstances($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstances'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcShowInstances'); + } + + return $this; + } + + /** + * Use the CcShowInstances relation CcShowInstances object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstances($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery'); + } + /** * Filter the query by a related CcPlaylistcontents object * diff --git a/application/models/airtime/om/BaseCcShow.php b/application/models/airtime/om/BaseCcShow.php index 308766947..d6c57cac6 100644 --- a/application/models/airtime/om/BaseCcShow.php +++ b/application/models/airtime/om/BaseCcShow.php @@ -65,6 +65,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent */ protected $collCcShowDayss; + /** + * @var array CcShowRebroadcast[] Collection to store aggregation of CcShowRebroadcast objects. + */ + protected $collCcShowRebroadcasts; + /** * @var array CcShowHosts[] Collection to store aggregation of CcShowHosts objects. */ @@ -370,6 +375,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->collCcShowDayss = null; + $this->collCcShowRebroadcasts = null; + $this->collCcShowHostss = null; } // if (deep) @@ -521,6 +528,14 @@ abstract class BaseCcShow extends BaseObject implements Persistent } } + if ($this->collCcShowRebroadcasts !== null) { + foreach ($this->collCcShowRebroadcasts as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->collCcShowHostss !== null) { foreach ($this->collCcShowHostss as $referrerFK) { if (!$referrerFK->isDeleted()) { @@ -616,6 +631,14 @@ abstract class BaseCcShow extends BaseObject implements Persistent } } + if ($this->collCcShowRebroadcasts !== null) { + foreach ($this->collCcShowRebroadcasts as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collCcShowHostss !== null) { foreach ($this->collCcShowHostss as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -874,6 +897,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent } } + foreach ($this->getCcShowRebroadcasts() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowRebroadcast($relObj->copy($deepCopy)); + } + } + foreach ($this->getCcShowHostss() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCcShowHosts($relObj->copy($deepCopy)); @@ -1034,6 +1063,56 @@ abstract class BaseCcShow extends BaseObject implements Persistent } } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShow is new, it will return + * an empty collection; or if this CcShow has previously + * been saved, it will retrieve related CcShowInstancess from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcShow. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcShowInstancesRelatedByDbOriginalShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShowInstancesRelatedByDbOriginalShow', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShow is new, it will return + * an empty collection; or if this CcShow has previously + * been saved, it will retrieve related CcShowInstancess from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcShow. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + /** * Clears out the collCcShowDayss collection * @@ -1143,6 +1222,115 @@ abstract class BaseCcShow extends BaseObject implements Persistent } } + /** + * Clears out the collCcShowRebroadcasts collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCcShowRebroadcasts() + */ + public function clearCcShowRebroadcasts() + { + $this->collCcShowRebroadcasts = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcShowRebroadcasts collection. + * + * By default this just sets the collCcShowRebroadcasts collection to an empty array (like clearcollCcShowRebroadcasts()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initCcShowRebroadcasts() + { + $this->collCcShowRebroadcasts = new PropelObjectCollection(); + $this->collCcShowRebroadcasts->setModel('CcShowRebroadcast'); + } + + /** + * Gets an array of CcShowRebroadcast objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this CcShow is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelCollection|array CcShowRebroadcast[] List of CcShowRebroadcast objects + * @throws PropelException + */ + public function getCcShowRebroadcasts($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcShowRebroadcasts || null !== $criteria) { + if ($this->isNew() && null === $this->collCcShowRebroadcasts) { + // return empty collection + $this->initCcShowRebroadcasts(); + } else { + $collCcShowRebroadcasts = CcShowRebroadcastQuery::create(null, $criteria) + ->filterByCcShow($this) + ->find($con); + if (null !== $criteria) { + return $collCcShowRebroadcasts; + } + $this->collCcShowRebroadcasts = $collCcShowRebroadcasts; + } + } + return $this->collCcShowRebroadcasts; + } + + /** + * Returns the number of related CcShowRebroadcast objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowRebroadcast objects. + * @throws PropelException + */ + public function countCcShowRebroadcasts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcShowRebroadcasts || null !== $criteria) { + if ($this->isNew() && null === $this->collCcShowRebroadcasts) { + return 0; + } else { + $query = CcShowRebroadcastQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcShow($this) + ->count($con); + } + } else { + return count($this->collCcShowRebroadcasts); + } + } + + /** + * Method called to associate a CcShowRebroadcast object to this object + * through the CcShowRebroadcast foreign key attribute. + * + * @param CcShowRebroadcast $l CcShowRebroadcast + * @return void + * @throws PropelException + */ + public function addCcShowRebroadcast(CcShowRebroadcast $l) + { + if ($this->collCcShowRebroadcasts === null) { + $this->initCcShowRebroadcasts(); + } + if (!$this->collCcShowRebroadcasts->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcShowRebroadcasts[]= $l; + $l->setCcShow($this); + } + } + /** * Clears out the collCcShowHostss collection * @@ -1318,6 +1506,11 @@ abstract class BaseCcShow extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->collCcShowRebroadcasts) { + foreach ((array) $this->collCcShowRebroadcasts as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCcShowHostss) { foreach ((array) $this->collCcShowHostss as $o) { $o->clearAllReferences($deep); @@ -1327,6 +1520,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->collCcShowInstancess = null; $this->collCcShowDayss = null; + $this->collCcShowRebroadcasts = null; $this->collCcShowHostss = null; } diff --git a/application/models/airtime/om/BaseCcShowDays.php b/application/models/airtime/om/BaseCcShowDays.php index c45567ec9..248abdb94 100644 --- a/application/models/airtime/om/BaseCcShowDays.php +++ b/application/models/airtime/om/BaseCcShowDays.php @@ -78,6 +78,12 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent */ protected $show_id; + /** + * The value for the record field. + * @var int + */ + protected $record; + /** * @var CcShow */ @@ -279,6 +285,16 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent return $this->show_id; } + /** + * Get the [record] column value. + * + * @return int + */ + public function getDbRecord() + { + return $this->record; + } + /** * Set the value of [id] column. * @@ -579,6 +595,26 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent return $this; } // setDbShowId() + /** + * Set the value of [record] column. + * + * @param int $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbRecord($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->record !== $v) { + $this->record = $v; + $this->modifiedColumns[] = CcShowDaysPeer::RECORD; + } + + return $this; + } // setDbRecord() + /** * Indicates whether the columns in this object are only set to default values. * @@ -620,6 +656,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->repeat_type = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; $this->next_pop_date = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->show_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; + $this->record = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; $this->resetModified(); $this->setNew(false); @@ -628,7 +665,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 9; // 9 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 10; // 10 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShowDays object", $e); @@ -982,6 +1019,9 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent case 8: return $this->getDbShowId(); break; + case 9: + return $this->getDbRecord(); + break; default: return null; break; @@ -1015,6 +1055,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $keys[6] => $this->getDbRepeatType(), $keys[7] => $this->getDbNextPopDate(), $keys[8] => $this->getDbShowId(), + $keys[9] => $this->getDbRecord(), ); if ($includeForeignObjects) { if (null !== $this->aCcShow) { @@ -1078,6 +1119,9 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent case 8: $this->setDbShowId($value); break; + case 9: + $this->setDbRecord($value); + break; } // switch() } @@ -1111,6 +1155,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent if (array_key_exists($keys[6], $arr)) $this->setDbRepeatType($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setDbNextPopDate($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setDbShowId($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbRecord($arr[$keys[9]]); } /** @@ -1131,6 +1176,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent if ($this->isColumnModified(CcShowDaysPeer::REPEAT_TYPE)) $criteria->add(CcShowDaysPeer::REPEAT_TYPE, $this->repeat_type); if ($this->isColumnModified(CcShowDaysPeer::NEXT_POP_DATE)) $criteria->add(CcShowDaysPeer::NEXT_POP_DATE, $this->next_pop_date); if ($this->isColumnModified(CcShowDaysPeer::SHOW_ID)) $criteria->add(CcShowDaysPeer::SHOW_ID, $this->show_id); + if ($this->isColumnModified(CcShowDaysPeer::RECORD)) $criteria->add(CcShowDaysPeer::RECORD, $this->record); return $criteria; } @@ -1200,6 +1246,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $copyObj->setDbRepeatType($this->repeat_type); $copyObj->setDbNextPopDate($this->next_pop_date); $copyObj->setDbShowId($this->show_id); + $copyObj->setDbRecord($this->record); $copyObj->setNew(true); $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value @@ -1306,6 +1353,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->repeat_type = null; $this->next_pop_date = null; $this->show_id = null; + $this->record = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); diff --git a/application/models/airtime/om/BaseCcShowDaysPeer.php b/application/models/airtime/om/BaseCcShowDaysPeer.php index 669013b13..fadf97576 100644 --- a/application/models/airtime/om/BaseCcShowDaysPeer.php +++ b/application/models/airtime/om/BaseCcShowDaysPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowDaysPeer { const TM_CLASS = 'CcShowDaysTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 10; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -58,6 +58,9 @@ abstract class BaseCcShowDaysPeer { /** the column name for the SHOW_ID field */ const SHOW_ID = 'cc_show_days.SHOW_ID'; + /** the column name for the RECORD field */ + const RECORD = 'cc_show_days.RECORD'; + /** * An identiy map to hold any loaded instances of CcShowDays objects. * This must be public so that other peer classes can access this when hydrating from JOIN @@ -74,12 +77,12 @@ abstract class BaseCcShowDaysPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, self::RECORD, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -89,12 +92,12 @@ abstract class BaseCcShowDaysPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbDuration' => 4, 'DbDay' => 5, 'DbRepeatType' => 6, 'DbNextPopDate' => 7, 'DbShowId' => 8, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbDuration' => 4, 'dbDay' => 5, 'dbRepeatType' => 6, 'dbNextPopDate' => 7, 'dbShowId' => 8, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::DURATION => 4, self::DAY => 5, self::REPEAT_TYPE => 6, self::NEXT_POP_DATE => 7, self::SHOW_ID => 8, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'DURATION' => 4, 'DAY' => 5, 'REPEAT_TYPE' => 6, 'NEXT_POP_DATE' => 7, 'SHOW_ID' => 8, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'duration' => 4, 'day' => 5, 'repeat_type' => 6, 'next_pop_date' => 7, 'show_id' => 8, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbDuration' => 4, 'DbDay' => 5, 'DbRepeatType' => 6, 'DbNextPopDate' => 7, 'DbShowId' => 8, 'DbRecord' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbDuration' => 4, 'dbDay' => 5, 'dbRepeatType' => 6, 'dbNextPopDate' => 7, 'dbShowId' => 8, 'dbRecord' => 9, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::DURATION => 4, self::DAY => 5, self::REPEAT_TYPE => 6, self::NEXT_POP_DATE => 7, self::SHOW_ID => 8, self::RECORD => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'DURATION' => 4, 'DAY' => 5, 'REPEAT_TYPE' => 6, 'NEXT_POP_DATE' => 7, 'SHOW_ID' => 8, 'RECORD' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'duration' => 4, 'day' => 5, 'repeat_type' => 6, 'next_pop_date' => 7, 'show_id' => 8, 'record' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -175,6 +178,7 @@ abstract class BaseCcShowDaysPeer { $criteria->addSelectColumn(CcShowDaysPeer::REPEAT_TYPE); $criteria->addSelectColumn(CcShowDaysPeer::NEXT_POP_DATE); $criteria->addSelectColumn(CcShowDaysPeer::SHOW_ID); + $criteria->addSelectColumn(CcShowDaysPeer::RECORD); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.FIRST_SHOW'); @@ -185,6 +189,7 @@ abstract class BaseCcShowDaysPeer { $criteria->addSelectColumn($alias . '.REPEAT_TYPE'); $criteria->addSelectColumn($alias . '.NEXT_POP_DATE'); $criteria->addSelectColumn($alias . '.SHOW_ID'); + $criteria->addSelectColumn($alias . '.RECORD'); } } diff --git a/application/models/airtime/om/BaseCcShowDaysQuery.php b/application/models/airtime/om/BaseCcShowDaysQuery.php index a91994d5f..9df957145 100644 --- a/application/models/airtime/om/BaseCcShowDaysQuery.php +++ b/application/models/airtime/om/BaseCcShowDaysQuery.php @@ -15,6 +15,7 @@ * @method CcShowDaysQuery orderByDbRepeatType($order = Criteria::ASC) Order by the repeat_type column * @method CcShowDaysQuery orderByDbNextPopDate($order = Criteria::ASC) Order by the next_pop_date column * @method CcShowDaysQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column + * @method CcShowDaysQuery orderByDbRecord($order = Criteria::ASC) Order by the record column * * @method CcShowDaysQuery groupByDbId() Group by the id column * @method CcShowDaysQuery groupByDbFirstShow() Group by the first_show column @@ -25,6 +26,7 @@ * @method CcShowDaysQuery groupByDbRepeatType() Group by the repeat_type column * @method CcShowDaysQuery groupByDbNextPopDate() Group by the next_pop_date column * @method CcShowDaysQuery groupByDbShowId() Group by the show_id column + * @method CcShowDaysQuery groupByDbRecord() Group by the record column * * @method CcShowDaysQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcShowDaysQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -46,6 +48,7 @@ * @method CcShowDays findOneByDbRepeatType(int $repeat_type) Return the first CcShowDays filtered by the repeat_type column * @method CcShowDays findOneByDbNextPopDate(string $next_pop_date) Return the first CcShowDays filtered by the next_pop_date column * @method CcShowDays findOneByDbShowId(int $show_id) Return the first CcShowDays filtered by the show_id column + * @method CcShowDays findOneByDbRecord(int $record) Return the first CcShowDays filtered by the record column * * @method array findByDbId(int $id) Return CcShowDays objects filtered by the id column * @method array findByDbFirstShow(string $first_show) Return CcShowDays objects filtered by the first_show column @@ -56,6 +59,7 @@ * @method array findByDbRepeatType(int $repeat_type) Return CcShowDays objects filtered by the repeat_type column * @method array findByDbNextPopDate(string $next_pop_date) Return CcShowDays objects filtered by the next_pop_date column * @method array findByDbShowId(int $show_id) Return CcShowDays objects filtered by the show_id column + * @method array findByDbRecord(int $record) Return CcShowDays objects filtered by the record column * * @package propel.generator.airtime.om */ @@ -421,6 +425,37 @@ abstract class BaseCcShowDaysQuery extends ModelCriteria return $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId, $comparison); } + /** + * Filter the query on the record column + * + * @param int|array $dbRecord The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbRecord($dbRecord = null, $comparison = null) + { + if (is_array($dbRecord)) { + $useMinMax = false; + if (isset($dbRecord['min'])) { + $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRecord['max'])) { + $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord, $comparison); + } + /** * Filter the query by a related CcShow object * diff --git a/application/models/airtime/om/BaseCcShowInstances.php b/application/models/airtime/om/BaseCcShowInstances.php index ac28117c9..9a0578dd4 100644 --- a/application/models/airtime/om/BaseCcShowInstances.php +++ b/application/models/airtime/om/BaseCcShowInstances.php @@ -48,11 +48,52 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent */ protected $show_id; + /** + * The value for the record field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $record; + + /** + * The value for the rebroadcast field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $rebroadcast; + + /** + * The value for the instance_id field. + * @var int + */ + protected $instance_id; + + /** + * The value for the file_id field. + * @var int + */ + protected $file_id; + /** * @var CcShow */ protected $aCcShow; + /** + * @var CcShowInstances + */ + protected $aCcShowInstancesRelatedByDbOriginalShow; + + /** + * @var CcFiles + */ + protected $aCcFiles; + + /** + * @var array CcShowInstances[] Collection to store aggregation of CcShowInstances objects. + */ + protected $collCcShowInstancessRelatedByDbId; + /** * @var array CcSchedule[] Collection to store aggregation of CcSchedule objects. */ @@ -72,6 +113,28 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->record = 0; + $this->rebroadcast = 0; + } + + /** + * Initializes internal state of BaseCcShowInstances object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + /** * Get the [id] column value. * @@ -158,6 +221,46 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this->show_id; } + /** + * Get the [record] column value. + * + * @return int + */ + public function getDbRecord() + { + return $this->record; + } + + /** + * Get the [rebroadcast] column value. + * + * @return int + */ + public function getDbRebroadcast() + { + return $this->rebroadcast; + } + + /** + * Get the [instance_id] column value. + * + * @return int + */ + public function getDbOriginalShow() + { + return $this->instance_id; + } + + /** + * Get the [file_id] column value. + * + * @return int + */ + public function getDbRecordedFile() + { + return $this->file_id; + } + /** * Set the value of [id] column. * @@ -300,6 +403,94 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this; } // setDbShowId() + /** + * Set the value of [record] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbRecord($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->record !== $v || $this->isNew()) { + $this->record = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::RECORD; + } + + return $this; + } // setDbRecord() + + /** + * Set the value of [rebroadcast] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbRebroadcast($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->rebroadcast !== $v || $this->isNew()) { + $this->rebroadcast = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST; + } + + return $this; + } // setDbRebroadcast() + + /** + * Set the value of [instance_id] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbOriginalShow($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->instance_id !== $v) { + $this->instance_id = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::INSTANCE_ID; + } + + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId() !== $v) { + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + } + + return $this; + } // setDbOriginalShow() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbRecordedFile($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::FILE_ID; + } + + if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { + $this->aCcFiles = null; + } + + return $this; + } // setDbRecordedFile() + /** * Indicates whether the columns in this object are only set to default values. * @@ -310,6 +501,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { + if ($this->record !== 0) { + return false; + } + + if ($this->rebroadcast !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -336,6 +535,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->record = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->rebroadcast = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; $this->resetModified(); $this->setNew(false); @@ -344,7 +547,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 4; // 4 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 8; // 8 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShowInstances object", $e); @@ -370,6 +573,12 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($this->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { $this->aCcShow = null; } + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->instance_id !== $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId()) { + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + } + if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { + $this->aCcFiles = null; + } } // ensureConsistency /** @@ -410,6 +619,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? $this->aCcShow = null; + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + $this->aCcFiles = null; + $this->collCcShowInstancessRelatedByDbId = null; + $this->collCcSchedules = null; } // if (deep) @@ -534,6 +747,20 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->setCcShow($this->aCcShow); } + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) { + if ($this->aCcShowInstancesRelatedByDbOriginalShow->isModified() || $this->aCcShowInstancesRelatedByDbOriginalShow->isNew()) { + $affectedRows += $this->aCcShowInstancesRelatedByDbOriginalShow->save($con); + } + $this->setCcShowInstancesRelatedByDbOriginalShow($this->aCcShowInstancesRelatedByDbOriginalShow); + } + + if ($this->aCcFiles !== null) { + if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { + $affectedRows += $this->aCcFiles->save($con); + } + $this->setCcFiles($this->aCcFiles); + } + if ($this->isNew() ) { $this->modifiedColumns[] = CcShowInstancesPeer::ID; } @@ -557,6 +784,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } + if ($this->collCcShowInstancessRelatedByDbId !== null) { + foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->collCcSchedules !== null) { foreach ($this->collCcSchedules as $referrerFK) { if (!$referrerFK->isDeleted()) { @@ -642,12 +877,32 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent } } + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) { + if (!$this->aCcShowInstancesRelatedByDbOriginalShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShowInstancesRelatedByDbOriginalShow->getValidationFailures()); + } + } + + if ($this->aCcFiles !== null) { + if (!$this->aCcFiles->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); + } + } + if (($retval = CcShowInstancesPeer::doValidate($this, $columns)) !== true) { $failureMap = array_merge($failureMap, $retval); } + if ($this->collCcShowInstancessRelatedByDbId !== null) { + foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collCcSchedules !== null) { foreach ($this->collCcSchedules as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -701,6 +956,18 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case 3: return $this->getDbShowId(); break; + case 4: + return $this->getDbRecord(); + break; + case 5: + return $this->getDbRebroadcast(); + break; + case 6: + return $this->getDbOriginalShow(); + break; + case 7: + return $this->getDbRecordedFile(); + break; default: return null; break; @@ -729,11 +996,21 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $keys[1] => $this->getDbStarts(), $keys[2] => $this->getDbEnds(), $keys[3] => $this->getDbShowId(), + $keys[4] => $this->getDbRecord(), + $keys[5] => $this->getDbRebroadcast(), + $keys[6] => $this->getDbOriginalShow(), + $keys[7] => $this->getDbRecordedFile(), ); if ($includeForeignObjects) { if (null !== $this->aCcShow) { $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, true); } + if (null !== $this->aCcShowInstancesRelatedByDbOriginalShow) { + $result['CcShowInstancesRelatedByDbOriginalShow'] = $this->aCcShowInstancesRelatedByDbOriginalShow->toArray($keyType, $includeLazyLoadColumns, true); + } + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); + } } return $result; } @@ -777,6 +1054,18 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case 3: $this->setDbShowId($value); break; + case 4: + $this->setDbRecord($value); + break; + case 5: + $this->setDbRebroadcast($value); + break; + case 6: + $this->setDbOriginalShow($value); + break; + case 7: + $this->setDbRecordedFile($value); + break; } // switch() } @@ -805,6 +1094,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setDbShowId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbRecord($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbRebroadcast($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]); } /** @@ -820,6 +1113,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($this->isColumnModified(CcShowInstancesPeer::STARTS)) $criteria->add(CcShowInstancesPeer::STARTS, $this->starts); if ($this->isColumnModified(CcShowInstancesPeer::ENDS)) $criteria->add(CcShowInstancesPeer::ENDS, $this->ends); if ($this->isColumnModified(CcShowInstancesPeer::SHOW_ID)) $criteria->add(CcShowInstancesPeer::SHOW_ID, $this->show_id); + if ($this->isColumnModified(CcShowInstancesPeer::RECORD)) $criteria->add(CcShowInstancesPeer::RECORD, $this->record); + if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) $criteria->add(CcShowInstancesPeer::REBROADCAST, $this->rebroadcast); + if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id); + if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id); return $criteria; } @@ -884,12 +1181,22 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $copyObj->setDbStarts($this->starts); $copyObj->setDbEnds($this->ends); $copyObj->setDbShowId($this->show_id); + $copyObj->setDbRecord($this->record); + $copyObj->setDbRebroadcast($this->rebroadcast); + $copyObj->setDbOriginalShow($this->instance_id); + $copyObj->setDbRecordedFile($this->file_id); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); + foreach ($this->getCcShowInstancessRelatedByDbId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowInstancesRelatedByDbId($relObj->copy($deepCopy)); + } + } + foreach ($this->getCcSchedules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCcSchedule($relObj->copy($deepCopy)); @@ -990,6 +1297,263 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this->aCcShow; } + /** + * Declares an association between this object and a CcShowInstances object. + * + * @param CcShowInstances $v + * @return CcShowInstances The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShowInstancesRelatedByDbOriginalShow(CcShowInstances $v = null) + { + if ($v === null) { + $this->setDbOriginalShow(NULL); + } else { + $this->setDbOriginalShow($v->getDbId()); + } + + $this->aCcShowInstancesRelatedByDbOriginalShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShowInstances object, it will not be re-added. + if ($v !== null) { + $v->addCcShowInstancesRelatedByDbId($this); + } + + return $this; + } + + + /** + * Get the associated CcShowInstances object + * + * @param PropelPDO Optional Connection object. + * @return CcShowInstances The associated CcShowInstances object. + * @throws PropelException + */ + public function getCcShowInstancesRelatedByDbOriginalShow(PropelPDO $con = null) + { + if ($this->aCcShowInstancesRelatedByDbOriginalShow === null && ($this->instance_id !== null)) { + $this->aCcShowInstancesRelatedByDbOriginalShow = CcShowInstancesQuery::create()->findPk($this->instance_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCcShowInstancesRelatedByDbOriginalShow->addCcShowInstancessRelatedByDbId($this); + */ + } + return $this->aCcShowInstancesRelatedByDbOriginalShow; + } + + /** + * Declares an association between this object and a CcFiles object. + * + * @param CcFiles $v + * @return CcShowInstances The current object (for fluent API support) + * @throws PropelException + */ + public function setCcFiles(CcFiles $v = null) + { + if ($v === null) { + $this->setDbRecordedFile(NULL); + } else { + $this->setDbRecordedFile($v->getDbId()); + } + + $this->aCcFiles = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcFiles object, it will not be re-added. + if ($v !== null) { + $v->addCcShowInstances($this); + } + + return $this; + } + + + /** + * Get the associated CcFiles object + * + * @param PropelPDO Optional Connection object. + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null) + { + if ($this->aCcFiles === null && ($this->file_id !== null)) { + $this->aCcFiles = CcFilesQuery::create()->findPk($this->file_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCcFiles->addCcShowInstancess($this); + */ + } + return $this->aCcFiles; + } + + /** + * Clears out the collCcShowInstancessRelatedByDbId collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCcShowInstancessRelatedByDbId() + */ + public function clearCcShowInstancessRelatedByDbId() + { + $this->collCcShowInstancessRelatedByDbId = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Initializes the collCcShowInstancessRelatedByDbId collection. + * + * By default this just sets the collCcShowInstancessRelatedByDbId collection to an empty array (like clearcollCcShowInstancessRelatedByDbId()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initCcShowInstancessRelatedByDbId() + { + $this->collCcShowInstancessRelatedByDbId = new PropelObjectCollection(); + $this->collCcShowInstancessRelatedByDbId->setModel('CcShowInstances'); + } + + /** + * Gets an array of CcShowInstances objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this CcShowInstances is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + * @throws PropelException + */ + public function getCcShowInstancessRelatedByDbId($criteria = null, PropelPDO $con = null) + { + if(null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria) { + if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) { + // return empty collection + $this->initCcShowInstancessRelatedByDbId(); + } else { + $collCcShowInstancessRelatedByDbId = CcShowInstancesQuery::create(null, $criteria) + ->filterByCcShowInstancesRelatedByDbOriginalShow($this) + ->find($con); + if (null !== $criteria) { + return $collCcShowInstancessRelatedByDbId; + } + $this->collCcShowInstancessRelatedByDbId = $collCcShowInstancessRelatedByDbId; + } + } + return $this->collCcShowInstancessRelatedByDbId; + } + + /** + * Returns the number of related CcShowInstances objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowInstances objects. + * @throws PropelException + */ + public function countCcShowInstancessRelatedByDbId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + if(null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria) { + if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) { + return 0; + } else { + $query = CcShowInstancesQuery::create(null, $criteria); + if($distinct) { + $query->distinct(); + } + return $query + ->filterByCcShowInstancesRelatedByDbOriginalShow($this) + ->count($con); + } + } else { + return count($this->collCcShowInstancessRelatedByDbId); + } + } + + /** + * Method called to associate a CcShowInstances object to this object + * through the CcShowInstances foreign key attribute. + * + * @param CcShowInstances $l CcShowInstances + * @return void + * @throws PropelException + */ + public function addCcShowInstancesRelatedByDbId(CcShowInstances $l) + { + if ($this->collCcShowInstancessRelatedByDbId === null) { + $this->initCcShowInstancessRelatedByDbId(); + } + if (!$this->collCcShowInstancessRelatedByDbId->contains($l)) { // only add it if the **same** object is not already associated + $this->collCcShowInstancessRelatedByDbId[]= $l; + $l->setCcShowInstancesRelatedByDbOriginalShow($this); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcShowInstancessRelatedByDbId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcShowInstances. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessRelatedByDbIdJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShow', $join_behavior); + + return $this->getCcShowInstancessRelatedByDbId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcShowInstancessRelatedByDbId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in CcShowInstances. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessRelatedByDbIdJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcShowInstancessRelatedByDbId($query, $con); + } + /** * Clears out the collCcSchedules collection * @@ -1108,9 +1672,14 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->starts = null; $this->ends = null; $this->show_id = null; + $this->record = null; + $this->rebroadcast = null; + $this->instance_id = null; + $this->file_id = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); @@ -1128,6 +1697,11 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collCcShowInstancessRelatedByDbId) { + foreach ((array) $this->collCcShowInstancessRelatedByDbId as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCcSchedules) { foreach ((array) $this->collCcSchedules as $o) { $o->clearAllReferences($deep); @@ -1135,8 +1709,11 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent } } // if ($deep) + $this->collCcShowInstancessRelatedByDbId = null; $this->collCcSchedules = null; $this->aCcShow = null; + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + $this->aCcFiles = null; } /** diff --git a/application/models/airtime/om/BaseCcShowInstancesPeer.php b/application/models/airtime/om/BaseCcShowInstancesPeer.php index c94ac5e81..dcabfbd67 100644 --- a/application/models/airtime/om/BaseCcShowInstancesPeer.php +++ b/application/models/airtime/om/BaseCcShowInstancesPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer { const TM_CLASS = 'CcShowInstancesTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 8; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -43,6 +43,18 @@ abstract class BaseCcShowInstancesPeer { /** the column name for the SHOW_ID field */ const SHOW_ID = 'cc_show_instances.SHOW_ID'; + /** the column name for the RECORD field */ + const RECORD = 'cc_show_instances.RECORD'; + + /** the column name for the REBROADCAST field */ + const REBROADCAST = 'cc_show_instances.REBROADCAST'; + + /** the column name for the INSTANCE_ID field */ + const INSTANCE_ID = 'cc_show_instances.INSTANCE_ID'; + + /** the column name for the FILE_ID field */ + const FILE_ID = 'cc_show_instances.FILE_ID'; + /** * An identiy map to hold any loaded instances of CcShowInstances objects. * This must be public so that other peer classes can access this when hydrating from JOIN @@ -59,12 +71,12 @@ abstract class BaseCcShowInstancesPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -74,12 +86,12 @@ abstract class BaseCcShowInstancesPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -155,11 +167,19 @@ abstract class BaseCcShowInstancesPeer { $criteria->addSelectColumn(CcShowInstancesPeer::STARTS); $criteria->addSelectColumn(CcShowInstancesPeer::ENDS); $criteria->addSelectColumn(CcShowInstancesPeer::SHOW_ID); + $criteria->addSelectColumn(CcShowInstancesPeer::RECORD); + $criteria->addSelectColumn(CcShowInstancesPeer::REBROADCAST); + $criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID); + $criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.STARTS'); $criteria->addSelectColumn($alias . '.ENDS'); $criteria->addSelectColumn($alias . '.SHOW_ID'); + $criteria->addSelectColumn($alias . '.RECORD'); + $criteria->addSelectColumn($alias . '.REBROADCAST'); + $criteria->addSelectColumn($alias . '.INSTANCE_ID'); + $criteria->addSelectColumn($alias . '.FILE_ID'); } } @@ -353,6 +373,9 @@ abstract class BaseCcShowInstancesPeer { */ public static function clearRelatedInstancePool() { + // Invalidate objects in CcShowInstancesPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowInstancesPeer::clearInstancePool(); // Invalidate objects in CcSchedulePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CcSchedulePeer::clearInstancePool(); @@ -498,6 +521,56 @@ abstract class BaseCcShowInstancesPeer { } + /** + * Returns the number of rows matching criteria, joining the related CcFiles table + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return int Number of matching rows. + */ + public static function doCountJoinCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + + /** * Selects a collection of CcShowInstances objects pre-filled with their CcShow objects. * @param Criteria $criteria @@ -564,6 +637,72 @@ abstract class BaseCcShowInstancesPeer { } + /** + * Selects a collection of CcShowInstances objects pre-filled with their CcFiles objects. + * @param Criteria $criteria + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return array Array of CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); + CcFilesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::getInstanceFromPool($key1))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj1->hydrate($row, 0, true); // rehydrate + } else { + + $cls = CcShowInstancesPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowInstances) to $obj2 (CcFiles) + $obj2->addCcShowInstances($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + /** * Returns the number of rows matching criteria, joining all related tables * @@ -602,6 +741,8 @@ abstract class BaseCcShowInstancesPeer { $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { @@ -638,8 +779,13 @@ abstract class BaseCcShowInstancesPeer { CcShowPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); + CcFilesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + $stmt = BasePeer::doSelect($criteria, $con); $results = array(); @@ -675,6 +821,419 @@ abstract class BaseCcShowInstancesPeer { $obj2->addCcShowInstances($obj1); } // if joined row not null + // Add objects for joined CcFiles rows + + $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcFilesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcFilesPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj3 (CcFiles) + $obj3->addCcShowInstances($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow table + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptCcShow(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShowInstancesRelatedByDbOriginalShow table + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptCcShowInstancesRelatedByDbOriginalShow(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcFiles table + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return int Number of matching rows. + */ + public static function doCountJoinAllExceptCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + + + /** + * Selects a collection of CcShowInstances objects pre-filled with all related objects except CcShow. + * + * @param Criteria $criteria + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return array Array of CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShow(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + // $criteria->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::getInstanceFromPool($key1))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj1->hydrate($row, 0, true); // rehydrate + } else { + $cls = CcShowInstancesPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcFiles rows + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcFiles) + $obj2->addCcShowInstances($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Selects a collection of CcShowInstances objects pre-filled with all related objects except CcShowInstancesRelatedByDbOriginalShow. + * + * @param Criteria $criteria + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return array Array of CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShowInstancesRelatedByDbOriginalShow(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + // $criteria->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); + + CcFilesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::getInstanceFromPool($key1))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj1->hydrate($row, 0, true); // rehydrate + } else { + $cls = CcShowInstancesPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) + $obj2->addCcShowInstances($obj1); + + } // if joined row is not null + + // Add objects for joined CcFiles rows + + $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcFilesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcFilesPeer::getOMClass(false); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcFilesPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj3 (CcFiles) + $obj3->addCcShowInstances($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Selects a collection of CcShowInstances objects pre-filled with all related objects except CcFiles. + * + * @param Criteria $criteria + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return array Array of CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + // $criteria->getDbName() will return the same object if not set to another value + // so == check is okay and faster + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::getInstanceFromPool($key1))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj1->hydrate($row, 0, true); // rehydrate + } else { + $cls = CcShowInstancesPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) + $obj2->addCcShowInstances($obj1); + + } // if joined row is not null + $results[] = $obj1; } $stmt->closeCursor(); diff --git a/application/models/airtime/om/BaseCcShowInstancesQuery.php b/application/models/airtime/om/BaseCcShowInstancesQuery.php index 7442fe416..846f9d9dd 100644 --- a/application/models/airtime/om/BaseCcShowInstancesQuery.php +++ b/application/models/airtime/om/BaseCcShowInstancesQuery.php @@ -10,11 +10,19 @@ * @method CcShowInstancesQuery orderByDbStarts($order = Criteria::ASC) Order by the starts column * @method CcShowInstancesQuery orderByDbEnds($order = Criteria::ASC) Order by the ends column * @method CcShowInstancesQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column + * @method CcShowInstancesQuery orderByDbRecord($order = Criteria::ASC) Order by the record column + * @method CcShowInstancesQuery orderByDbRebroadcast($order = Criteria::ASC) Order by the rebroadcast column + * @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column + * @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column * * @method CcShowInstancesQuery groupByDbId() Group by the id column * @method CcShowInstancesQuery groupByDbStarts() Group by the starts column * @method CcShowInstancesQuery groupByDbEnds() Group by the ends column * @method CcShowInstancesQuery groupByDbShowId() Group by the show_id column + * @method CcShowInstancesQuery groupByDbRecord() Group by the record column + * @method CcShowInstancesQuery groupByDbRebroadcast() Group by the rebroadcast column + * @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column + * @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column * * @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcShowInstancesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -24,6 +32,18 @@ * @method CcShowInstancesQuery rightJoinCcShow($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShow relation * @method CcShowInstancesQuery innerJoinCcShow($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShow relation * + * @method CcShowInstancesQuery leftJoinCcShowInstancesRelatedByDbOriginalShow($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowInstancesRelatedByDbOriginalShow relation + * @method CcShowInstancesQuery rightJoinCcShowInstancesRelatedByDbOriginalShow($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowInstancesRelatedByDbOriginalShow relation + * @method CcShowInstancesQuery innerJoinCcShowInstancesRelatedByDbOriginalShow($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowInstancesRelatedByDbOriginalShow relation + * + * @method CcShowInstancesQuery leftJoinCcFiles($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcFiles relation + * @method CcShowInstancesQuery rightJoinCcFiles($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcFiles relation + * @method CcShowInstancesQuery innerJoinCcFiles($relationAlias = '') Adds a INNER JOIN clause to the query using the CcFiles relation + * + * @method CcShowInstancesQuery leftJoinCcShowInstancesRelatedByDbId($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowInstancesRelatedByDbId relation + * @method CcShowInstancesQuery rightJoinCcShowInstancesRelatedByDbId($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowInstancesRelatedByDbId relation + * @method CcShowInstancesQuery innerJoinCcShowInstancesRelatedByDbId($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowInstancesRelatedByDbId relation + * * @method CcShowInstancesQuery leftJoinCcSchedule($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcSchedule relation * @method CcShowInstancesQuery rightJoinCcSchedule($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcSchedule relation * @method CcShowInstancesQuery innerJoinCcSchedule($relationAlias = '') Adds a INNER JOIN clause to the query using the CcSchedule relation @@ -35,11 +55,19 @@ * @method CcShowInstances findOneByDbStarts(string $starts) Return the first CcShowInstances filtered by the starts column * @method CcShowInstances findOneByDbEnds(string $ends) Return the first CcShowInstances filtered by the ends column * @method CcShowInstances findOneByDbShowId(int $show_id) Return the first CcShowInstances filtered by the show_id column + * @method CcShowInstances findOneByDbRecord(int $record) Return the first CcShowInstances filtered by the record column + * @method CcShowInstances findOneByDbRebroadcast(int $rebroadcast) Return the first CcShowInstances filtered by the rebroadcast column + * @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column + * @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column * * @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column * @method array findByDbStarts(string $starts) Return CcShowInstances objects filtered by the starts column * @method array findByDbEnds(string $ends) Return CcShowInstances objects filtered by the ends column * @method array findByDbShowId(int $show_id) Return CcShowInstances objects filtered by the show_id column + * @method array findByDbRecord(int $record) Return CcShowInstances objects filtered by the record column + * @method array findByDbRebroadcast(int $rebroadcast) Return CcShowInstances objects filtered by the rebroadcast column + * @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column + * @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column * * @package propel.generator.airtime.om */ @@ -259,6 +287,130 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria return $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId, $comparison); } + /** + * Filter the query on the record column + * + * @param int|array $dbRecord The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbRecord($dbRecord = null, $comparison = null) + { + if (is_array($dbRecord)) { + $useMinMax = false; + if (isset($dbRecord['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRecord['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord, $comparison); + } + + /** + * Filter the query on the rebroadcast column + * + * @param int|array $dbRebroadcast The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbRebroadcast($dbRebroadcast = null, $comparison = null) + { + if (is_array($dbRebroadcast)) { + $useMinMax = false; + if (isset($dbRebroadcast['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRebroadcast['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast, $comparison); + } + + /** + * Filter the query on the instance_id column + * + * @param int|array $dbOriginalShow The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbOriginalShow($dbOriginalShow = null, $comparison = null) + { + if (is_array($dbOriginalShow)) { + $useMinMax = false; + if (isset($dbOriginalShow['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbOriginalShow['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow, $comparison); + } + + /** + * Filter the query on the file_id column + * + * @param int|array $dbRecordedFile The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbRecordedFile($dbRecordedFile = null, $comparison = null) + { + if (is_array($dbRecordedFile)) { + $useMinMax = false; + if (isset($dbRecordedFile['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRecordedFile['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile, $comparison); + } + /** * Filter the query by a related CcShow object * @@ -323,6 +475,198 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); } + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances $ccShowInstances the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByCcShowInstancesRelatedByDbOriginalShow($ccShowInstances, $comparison = null) + { + return $this + ->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcShowInstancesRelatedByDbOriginalShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcShowInstancesRelatedByDbOriginalShow($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstancesRelatedByDbOriginalShow'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcShowInstancesRelatedByDbOriginalShow'); + } + + return $this; + } + + /** + * Use the CcShowInstancesRelatedByDbOriginalShow relation CcShowInstances object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesRelatedByDbOriginalShowQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstancesRelatedByDbOriginalShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstancesRelatedByDbOriginalShow', 'CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles $ccFiles the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + return $this + ->addUsingAlias(CcShowInstancesPeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcFiles relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcFiles'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcFiles'); + } + + return $this; + } + + /** + * Use the CcFiles relation CcFiles object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery'); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances $ccShowInstances the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByCcShowInstancesRelatedByDbId($ccShowInstances, $comparison = null) + { + return $this + ->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbOriginalShow(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcShowInstancesRelatedByDbId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcShowInstancesRelatedByDbId($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstancesRelatedByDbId'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcShowInstancesRelatedByDbId'); + } + + return $this; + } + + /** + * Use the CcShowInstancesRelatedByDbId relation CcShowInstances object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesRelatedByDbIdQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstancesRelatedByDbId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstancesRelatedByDbId', 'CcShowInstancesQuery'); + } + /** * Filter the query by a related CcSchedule object * diff --git a/application/models/airtime/om/BaseCcShowPeer.php b/application/models/airtime/om/BaseCcShowPeer.php index f6479c699..e883cb5ec 100644 --- a/application/models/airtime/om/BaseCcShowPeer.php +++ b/application/models/airtime/om/BaseCcShowPeer.php @@ -364,6 +364,9 @@ abstract class BaseCcShowPeer { // Invalidate objects in CcShowDaysPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CcShowDaysPeer::clearInstancePool(); + // Invalidate objects in CcShowRebroadcastPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowRebroadcastPeer::clearInstancePool(); // Invalidate objects in CcShowHostsPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CcShowHostsPeer::clearInstancePool(); diff --git a/application/models/airtime/om/BaseCcShowQuery.php b/application/models/airtime/om/BaseCcShowQuery.php index 0b90dd5e5..ea2e416df 100644 --- a/application/models/airtime/om/BaseCcShowQuery.php +++ b/application/models/airtime/om/BaseCcShowQuery.php @@ -30,6 +30,10 @@ * @method CcShowQuery rightJoinCcShowDays($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowDays relation * @method CcShowQuery innerJoinCcShowDays($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowDays relation * + * @method CcShowQuery leftJoinCcShowRebroadcast($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowRebroadcast relation + * @method CcShowQuery rightJoinCcShowRebroadcast($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowRebroadcast relation + * @method CcShowQuery innerJoinCcShowRebroadcast($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowRebroadcast relation + * * @method CcShowQuery leftJoinCcShowHosts($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowHosts relation * @method CcShowQuery rightJoinCcShowHosts($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowHosts relation * @method CcShowQuery innerJoinCcShowHosts($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowHosts relation @@ -390,6 +394,70 @@ abstract class BaseCcShowQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CcShowDays', 'CcShowDaysQuery'); } + /** + * Filter the query by a related CcShowRebroadcast object + * + * @param CcShowRebroadcast $ccShowRebroadcast the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByCcShowRebroadcast($ccShowRebroadcast, $comparison = null) + { + return $this + ->addUsingAlias(CcShowPeer::ID, $ccShowRebroadcast->getDbShowId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcShowRebroadcast relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowQuery The current query, for fluid interface + */ + public function joinCcShowRebroadcast($relationAlias = '', $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowRebroadcast'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcShowRebroadcast'); + } + + return $this; + } + + /** + * Use the CcShowRebroadcast relation CcShowRebroadcast object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowRebroadcastQuery A secondary query class using the current class as primary query + */ + public function useCcShowRebroadcastQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowRebroadcast($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowRebroadcast', 'CcShowRebroadcastQuery'); + } + /** * Filter the query by a related CcShowHosts object * diff --git a/application/models/airtime/om/BaseCcShowRebroadcast.php b/application/models/airtime/om/BaseCcShowRebroadcast.php new file mode 100644 index 000000000..aabd37d79 --- /dev/null +++ b/application/models/airtime/om/BaseCcShowRebroadcast.php @@ -0,0 +1,957 @@ +id; + } + + /** + * Get the [day_offset] column value. + * + * @return string + */ + public function getDbDayOffset() + { + return $this->day_offset; + } + + /** + * Get the [optionally formatted] temporal [start_time] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getDbStartTime($format = '%X') + { + if ($this->start_time === null) { + return null; + } + + + + try { + $dt = new DateTime($this->start_time); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->start_time, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is TRUE, we return a DateTime object. + return $dt; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } else { + return $dt->format($format); + } + } + + /** + * Get the [show_id] column value. + * + * @return int + */ + public function getDbShowId() + { + return $this->show_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcShowRebroadcastPeer::ID; + } + + return $this; + } // setDbId() + + /** + * Set the value of [day_offset] column. + * + * @param string $v new value + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbDayOffset($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->day_offset !== $v) { + $this->day_offset = $v; + $this->modifiedColumns[] = CcShowRebroadcastPeer::DAY_OFFSET; + } + + return $this; + } // setDbDayOffset() + + /** + * Sets the value of [start_time] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will + * be treated as NULL for temporal objects. + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbStartTime($v) + { + // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') + // -- which is unexpected, to say the least. + if ($v === null || $v === '') { + $dt = null; + } elseif ($v instanceof DateTime) { + $dt = $v; + } else { + // some string/numeric value passed; we normalize that so that we can + // validate it. + try { + if (is_numeric($v)) { // if it's a unix timestamp + $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); + // We have to explicitly specify and then change the time zone because of a + // DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + $dt = new DateTime($v); + } + } catch (Exception $x) { + throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); + } + } + + if ( $this->start_time !== null || $dt !== null ) { + // (nested ifs are a little easier to read in this case) + + $currNorm = ($this->start_time !== null && $tmpDt = new DateTime($this->start_time)) ? $tmpDt->format('H:i:s') : null; + $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; + + if ( ($currNorm !== $newNorm) // normalized values don't match + ) + { + $this->start_time = ($dt ? $dt->format('H:i:s') : null); + $this->modifiedColumns[] = CcShowRebroadcastPeer::START_TIME; + } + } // if either are not null + + return $this; + } // setDbStartTime() + + /** + * Set the value of [show_id] column. + * + * @param int $v new value + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbShowId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->show_id !== $v) { + $this->show_id = $v; + $this->modifiedColumns[] = CcShowRebroadcastPeer::SHOW_ID; + } + + if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { + $this->aCcShow = null; + } + + return $this; + } // setDbShowId() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false) + { + try { + + $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; + $this->day_offset = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = CcShowRebroadcastPeer::NUM_COLUMNS - CcShowRebroadcastPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcShowRebroadcast object", $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + + if ($this->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { + $this->aCcShow = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param PropelPDO $con (optional) The PropelPDO connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $stmt = CcShowRebroadcastPeer::doSelectStmt($this->buildPkeyCriteria(), $con); + $row = $stmt->fetch(PDO::FETCH_NUM); + $stmt->closeCursor(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCcShow = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcShowRebroadcastQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()) + ->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CcShowRebroadcastPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(PropelPDO $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { + $affectedRows += $this->aCcShow->save($con); + } + $this->setCcShow($this->aCcShow); + } + + if ($this->isNew() ) { + $this->modifiedColumns[] = CcShowRebroadcastPeer::ID; + } + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + if ($criteria->keyContainsValue(CcShowRebroadcastPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowRebroadcastPeer::ID.')'); + } + + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows += 1; + $this->setDbId($pk); //[IMV] update autoincrement primary key + $this->setNew(false); + } else { + $affectedRows += CcShowRebroadcastPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + // We call the validate method on the following object(s) if they + // were passed to this object by their coresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if (!$this->aCcShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); + } + } + + + if (($retval = CcShowRebroadcastPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowRebroadcastPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $field = $this->getByPosition($pos); + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getDbId(); + break; + case 1: + return $this->getDbDayOffset(); + break; + case 2: + return $this->getDbStartTime(); + break; + case 3: + return $this->getDbShowId(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. + * Defaults to BasePeer::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $includeForeignObjects = false) + { + $keys = CcShowRebroadcastPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbDayOffset(), + $keys[2] => $this->getDbStartTime(), + $keys[3] => $this->getDbShowId(), + ); + if ($includeForeignObjects) { + if (null !== $this->aCcShow) { + $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, true); + } + } + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowRebroadcastPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setDbId($value); + break; + case 1: + $this->setDbDayOffset($value); + break; + case 2: + $this->setDbStartTime($value); + break; + case 3: + $this->setDbShowId($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. + * The default key type is the column's phpname (e.g. 'AuthorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = CcShowRebroadcastPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbDayOffset($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbShowId($arr[$keys[3]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcShowRebroadcastPeer::ID)) $criteria->add(CcShowRebroadcastPeer::ID, $this->id); + if ($this->isColumnModified(CcShowRebroadcastPeer::DAY_OFFSET)) $criteria->add(CcShowRebroadcastPeer::DAY_OFFSET, $this->day_offset); + if ($this->isColumnModified(CcShowRebroadcastPeer::START_TIME)) $criteria->add(CcShowRebroadcastPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcShowRebroadcastPeer::SHOW_ID)) $criteria->add(CcShowRebroadcastPeer::SHOW_ID, $this->show_id); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getDbId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getDbId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of CcShowRebroadcast (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + $copyObj->setDbDayOffset($this->day_offset); + $copyObj->setDbStartTime($this->start_time); + $copyObj->setDbShowId($this->show_id); + + $copyObj->setNew(true); + $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return CcShowRebroadcast Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return CcShowRebroadcastPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcShowRebroadcastPeer(); + } + return self::$peer; + } + + /** + * Declares an association between this object and a CcShow object. + * + * @param CcShow $v + * @return CcShowRebroadcast The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShow(CcShow $v = null) + { + if ($v === null) { + $this->setDbShowId(NULL); + } else { + $this->setDbShowId($v->getDbId()); + } + + $this->aCcShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShow object, it will not be re-added. + if ($v !== null) { + $v->addCcShowRebroadcast($this); + } + + return $this; + } + + + /** + * Get the associated CcShow object + * + * @param PropelPDO Optional Connection object. + * @return CcShow The associated CcShow object. + * @throws PropelException + */ + public function getCcShow(PropelPDO $con = null) + { + if ($this->aCcShow === null && ($this->show_id !== null)) { + $this->aCcShow = CcShowQuery::create()->findPk($this->show_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCcShow->addCcShowRebroadcasts($this); + */ + } + return $this->aCcShow; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->day_offset = null; + $this->start_time = null; + $this->show_id = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all collections of referencing foreign keys. + * + * This method is a user-space workaround for PHP's inability to garbage collect objects + * with circular references. This is currently necessary when using Propel in certain + * daemon or large-volumne/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all associated objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCcShow = null; + } + + /** + * Catches calls to virtual methods + */ + public function __call($name, $params) + { + if (preg_match('/get(\w+)/', $name, $matches)) { + $virtualColumn = $matches[1]; + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + // no lcfirst in php<5.3... + $virtualColumn[0] = strtolower($virtualColumn[0]); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + throw new PropelException('Call to undefined method: ' . $name); + } + +} // BaseCcShowRebroadcast diff --git a/application/models/airtime/om/BaseCcShowRebroadcastPeer.php b/application/models/airtime/om/BaseCcShowRebroadcastPeer.php new file mode 100644 index 000000000..ef0434c70 --- /dev/null +++ b/application/models/airtime/om/BaseCcShowRebroadcastPeer.php @@ -0,0 +1,983 @@ + array ('DbId', 'DbDayOffset', 'DbStartTime', 'DbShowId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbDayOffset', 'dbStartTime', 'dbShowId', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::DAY_OFFSET, self::START_TIME, self::SHOW_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DAY_OFFSET', 'START_TIME', 'SHOW_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'day_offset', 'start_time', 'show_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbDayOffset' => 1, 'DbStartTime' => 2, 'DbShowId' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbDayOffset' => 1, 'dbStartTime' => 2, 'dbShowId' => 3, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::DAY_OFFSET => 1, self::START_TIME => 2, self::SHOW_ID => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DAY_OFFSET' => 1, 'START_TIME' => 2, 'SHOW_ID' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'day_offset' => 1, 'start_time' => 2, 'show_id' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + * @throws PropelException - if the specified name could not be found in the fieldname mappings. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. CcShowRebroadcastPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcShowRebroadcastPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CcShowRebroadcastPeer::ID); + $criteria->addSelectColumn(CcShowRebroadcastPeer::DAY_OFFSET); + $criteria->addSelectColumn(CcShowRebroadcastPeer::START_TIME); + $criteria->addSelectColumn(CcShowRebroadcastPeer::SHOW_ID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.DAY_OFFSET'); + $criteria->addSelectColumn($alias . '.START_TIME'); + $criteria->addSelectColumn($alias . '.SHOW_ID'); + } + } + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) + { + // we may modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + // BasePeer returns a PDOStatement + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcShowRebroadcast + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = CcShowRebroadcastPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, PropelPDO $con = null) + { + return CcShowRebroadcastPeer::populateObjects(CcShowRebroadcastPeer::doSelectStmt($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. + * + * Use this method directly if you want to work with an executed statement durirectly (for example + * to perform your own object hydration). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con The connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return PDOStatement The executed PDOStatement object. + * @see BasePeer::doSelect() + */ + public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a PDOStatement + return BasePeer::doSelect($criteria, $con); + } + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doSelect*() + * methods in your stub classes -- you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by doSelect*() + * and retrieveByPK*() calls. + * + * @param CcShowRebroadcast $value A CcShowRebroadcast object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcShowRebroadcast $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A CcShowRebroadcast object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcShowRebroadcast) { + $key = (string) $value->getDbId(); + } elseif (is_scalar($value)) { + // assume we've been passed a primary key + $key = (string) $value; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcShowRebroadcast object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } // removeInstanceFromPool() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param string $key The key (@see getPrimaryKeyHash()) for this instance. + * @return CcShowRebroadcast Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled. + * @see getPrimaryKeyHash() + */ + public static function getInstanceFromPool($key) + { + if (Propel::isInstancePoolingEnabled()) { + if (isset(self::$instances[$key])) { + return self::$instances[$key]; + } + } + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool() + { + self::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_show_rebroadcast + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row PropelPDO resultset row. + * @param int $startcol The 0-based offset for reading from the resultset row. + * @return string A string version of PK or NULL if the components of primary key in result array are all null. + */ + public static function getPrimaryKeyHashFromRow($row, $startcol = 0) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[$startcol] === null) { + return null; + } + return (string) $row[$startcol]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row PropelPDO resultset row. + * @param int $startcol The 0-based offset for reading from the resultset row. + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $startcol = 0) + { + return (int) $row[$startcol]; + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(PDOStatement $stmt) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = CcShowRebroadcastPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CcShowRebroadcastPeer::addInstanceToPool($obj, $key); + } // if key exists + } + $stmt->closeCursor(); + return $results; + } + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row PropelPDO resultset row. + * @param int $startcol The 0-based offset for reading from the resultset row. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CcShowRebroadcast object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $startcol, true); // rehydrate + $col = $startcol + CcShowRebroadcastPeer::NUM_COLUMNS; + } else { + $cls = CcShowRebroadcastPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcShowRebroadcastPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + + /** + * Returns the number of rows matching criteria, joining the related CcShow table + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return int Number of matching rows. + */ + public static function doCountJoinCcShow(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + + + /** + * Selects a collection of CcShowRebroadcast objects pre-filled with their CcShow objects. + * @param Criteria $criteria + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return array Array of CcShowRebroadcast objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShow(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcShowRebroadcastPeer::addSelectColumns($criteria); + $startcol = (CcShowRebroadcastPeer::NUM_COLUMNS - CcShowRebroadcastPeer::NUM_LAZY_LOAD_COLUMNS); + CcShowPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowRebroadcastPeer::getInstanceFromPool($key1))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj1->hydrate($row, 0, true); // rehydrate + } else { + + $cls = CcShowRebroadcastPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowRebroadcastPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowRebroadcast) to $obj2 (CcShow) + $obj2->addCcShowRebroadcast($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining all related tables + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return int Number of matching rows. + */ + public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + + /** + * Selects a collection of CcShowRebroadcast objects pre-filled with all related objects. + * + * @param Criteria $criteria + * @param PropelPDO $con + * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN + * @return array Array of CcShowRebroadcast objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $criteria = clone $criteria; + + // Set the correct dbName if it has not been overridden + if ($criteria->getDbName() == Propel::getDefaultDB()) { + $criteria->setDbName(self::DATABASE_NAME); + } + + CcShowRebroadcastPeer::addSelectColumns($criteria); + $startcol2 = (CcShowRebroadcastPeer::NUM_COLUMNS - CcShowRebroadcastPeer::NUM_LAZY_LOAD_COLUMNS); + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowRebroadcastPeer::getInstanceFromPool($key1))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj1->hydrate($row, 0, true); // rehydrate + } else { + $cls = CcShowRebroadcastPeer::getOMClass(false); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowRebroadcastPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(false); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcShowRebroadcast) to the collection in $obj2 (CcShow) + $obj2->addCcShowRebroadcast($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + return $results; + } + + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcShowRebroadcastPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcShowRebroadcastPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcShowRebroadcastTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CcShowRebroadcastPeer::CLASS_DEFAULT : CcShowRebroadcastPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcShowRebroadcast or Criteria object. + * + * @param mixed $values Criteria or CcShowRebroadcast object containing data that is used to create the INSERT statement. + * @param PropelPDO $con the PropelPDO connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcShowRebroadcast object + } + + if ($criteria->containsKey(CcShowRebroadcastPeer::ID) && $criteria->keyContainsValue(CcShowRebroadcastPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowRebroadcastPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a CcShowRebroadcast or Criteria object. + * + * @param mixed $values Criteria or CcShowRebroadcast object containing data that is used to create the UPDATE statement. + * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcShowRebroadcastPeer::ID); + $value = $criteria->remove(CcShowRebroadcastPeer::ID); + if ($value) { + $selectCriteria->add(CcShowRebroadcastPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); + } + + } else { // $values is CcShowRebroadcast object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the cc_show_rebroadcast table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += BasePeer::doDeleteAll(CcShowRebroadcastPeer::TABLE_NAME, $con, CcShowRebroadcastPeer::DATABASE_NAME); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CcShowRebroadcastPeer::clearInstancePool(); + CcShowRebroadcastPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcShowRebroadcast or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcShowRebroadcast object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + // invalidate the cache for all objects of this type, since we have no + // way of knowing (without running a query) what objects should be invalidated + // from the cache based on this Criteria. + CcShowRebroadcastPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcShowRebroadcast) { // it's a model object + // invalidate the cache for this single object + CcShowRebroadcastPeer::removeInstanceFromPool($values); + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcShowRebroadcastPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + CcShowRebroadcastPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcShowRebroadcast object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param CcShowRebroadcast $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(CcShowRebroadcast $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcShowRebroadcastPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcShowRebroadcastPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcShowRebroadcastPeer::DATABASE_NAME, CcShowRebroadcastPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcShowRebroadcast + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, $pk); + + $v = CcShowRebroadcastPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param PropelPDO $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, $pks, Criteria::IN); + $objs = CcShowRebroadcastPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcShowRebroadcastPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcShowRebroadcastPeer::buildTableMap(); + diff --git a/application/models/airtime/om/BaseCcShowRebroadcastQuery.php b/application/models/airtime/om/BaseCcShowRebroadcastQuery.php new file mode 100644 index 000000000..d7fedf8e9 --- /dev/null +++ b/application/models/airtime/om/BaseCcShowRebroadcastQuery.php @@ -0,0 +1,329 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + return $query; + } + + /** + * Find object by primary key + * Use instance pooling to avoid a database query if the object exists + * + * $obj = $c->findPk(12, $con); + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcShowRebroadcast|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { + // the object is alredy in the instance pool + return $obj; + } else { + // the object has not been requested yet, or the formatter is not an object formatter + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->getSelectStatement($con); + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param PropelPDO $con an optional connection object + * + * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + $criteria = $this->isKeepQuery() ? clone $this : $this; + return $this + ->filterByPrimaryKeys($keys) + ->find($con); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * @param int|array $dbId The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId) && null === $comparison) { + $comparison = Criteria::IN; + } + return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the day_offset column + * + * @param string $dbDayOffset The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbDayOffset($dbDayOffset = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbDayOffset)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbDayOffset)) { + $dbDayOffset = str_replace('*', '%', $dbDayOffset); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowRebroadcastPeer::DAY_OFFSET, $dbDayOffset, $comparison); + } + + /** + * Filter the query on the start_time column + * + * @param string|array $dbStartTime The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbStartTime($dbStartTime = null, $comparison = null) + { + if (is_array($dbStartTime)) { + $useMinMax = false; + if (isset($dbStartTime['min'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStartTime['max'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime, $comparison); + } + + /** + * Filter the query on the show_id column + * + * @param int|array $dbShowId The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbShowId($dbShowId = null, $comparison = null) + { + if (is_array($dbShowId)) { + $useMinMax = false; + if (isset($dbShowId['min'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbShowId['max'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId, $comparison); + } + + /** + * Filter the query by a related CcShow object + * + * @param CcShow $ccShow the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByCcShow($ccShow, $comparison = null) + { + return $this + ->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $ccShow->getDbId(), $comparison); + } + + /** + * Adds a JOIN clause to the query using the CcShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function joinCcShow($relationAlias = '', $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShow'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcShow'); + } + + return $this; + } + + /** + * Use the CcShow relation CcShow object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowQuery A secondary query class using the current class as primary query + */ + public function useCcShowQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); + } + + /** + * Exclude object from result + * + * @param CcShowRebroadcast $ccShowRebroadcast Object to remove from the list of results + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function prune($ccShowRebroadcast = null) + { + if ($ccShowRebroadcast) { + $this->addUsingAlias(CcShowRebroadcastPeer::ID, $ccShowRebroadcast->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcShowRebroadcastQuery diff --git a/application/views/scripts/schedule/add-show-form.phtml b/application/views/scripts/schedule/add-show-form.phtml index 24a2323fc..2a111448b 100644 --- a/application/views/scripts/schedule/add-show-form.phtml +++ b/application/views/scripts/schedule/add-show-form.phtml @@ -6,20 +6,26 @@

What

- what ?> + what; ?>

When

- when ?> - repeats ?> + when; ?> + repeats; ?> +
+

Record & Rebroadcast

+
+ rr; ?> + absoluteRebroadcast; ?> + rebroadcast; ?>

Who

- who ?> + who; ?>

Style

- style ?> + style; ?>
diff --git a/build/schema.xml b/build/schema.xml index ea1512560..1e32c58fa 100644 --- a/build/schema.xml +++ b/build/schema.xml @@ -133,9 +133,19 @@ + + + + + + + + + + @@ -147,6 +157,16 @@ + + + + +
+ + + + + diff --git a/build/sql/schema.sql b/build/sql/schema.sql index 4627d2d23..9eb57a4e0 100644 --- a/build/sql/schema.sql +++ b/build/sql/schema.sql @@ -185,6 +185,10 @@ CREATE TABLE "cc_show_instances" "starts" TIMESTAMP NOT NULL, "ends" TIMESTAMP NOT NULL, "show_id" INTEGER NOT NULL, + "record" INT2 default 0, + "rebroadcast" INT2 default 0, + "instance_id" INTEGER, + "file_id" INTEGER, PRIMARY KEY ("id") ); @@ -210,12 +214,33 @@ CREATE TABLE "cc_show_days" "repeat_type" INT2 NOT NULL, "next_pop_date" DATE, "show_id" INTEGER NOT NULL, + "record" INT2, PRIMARY KEY ("id") ); COMMENT ON TABLE "cc_show_days" IS ''; +SET search_path TO public; +----------------------------------------------------------------------------- +-- cc_show_rebroadcast +----------------------------------------------------------------------------- + +DROP TABLE "cc_show_rebroadcast" CASCADE; + + +CREATE TABLE "cc_show_rebroadcast" +( + "id" serial NOT NULL, + "day_offset" VARCHAR(255) NOT NULL, + "start_time" TIME NOT NULL, + "show_id" INTEGER NOT NULL, + PRIMARY KEY ("id") +); + +COMMENT ON TABLE "cc_show_rebroadcast" IS ''; + + SET search_path TO public; ----------------------------------------------------------------------------- -- cc_show_hosts @@ -469,8 +494,14 @@ ALTER TABLE "cc_perms" ADD CONSTRAINT "cc_perms_subj_fkey" FOREIGN KEY ("subj") ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_original_show_instance_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE CASCADE; + +ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_recorded_file_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE; + ALTER TABLE "cc_show_days" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_rebroadcast" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; + ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_host_fkey" FOREIGN KEY ("subjs_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; diff --git a/build/sql/triggers.sql b/build/sql/triggers.sql index e354f644a..ea9993f9e 100644 --- a/build/sql/triggers.sql +++ b/build/sql/triggers.sql @@ -22,22 +22,3 @@ CREATE FUNCTION calculate_position() RETURNS trigger AS CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents FOR EACH ROW EXECUTE PROCEDURE calculate_position(); ----------------------------------------------------------------------------------- ---show_content() ----------------------------------------------------------------------------------- -DROP FUNCTION show_content() CASCADE; - -CREATE FUNCTION show_content() RETURNS trigger AS - ' - BEGIN - IF(TG_OP=''DELETE'') THEN - UPDATE cc_show_schedule SET position = (position - 1) - WHERE (instance_id = old.instance_id AND position > old.position); - END IF; - RETURN NULL; - END; - ' - LANGUAGE 'plpgsql'; - -CREATE TRIGGER show_content AFTER INSERT OR DELETE ON cc_show_schedule -FOR EACH ROW EXECUTE PROCEDURE show_content(); diff --git a/dev_tools/gen_doctrine_migration.php b/dev_tools/gen_doctrine_migration.php new file mode 100644 index 000000000..2e9791f30 --- /dev/null +++ b/dev_tools/gen_doctrine_migration.php @@ -0,0 +1,9 @@ + h3 > span.ui-icon.ui-icon-triangle-1-e, #schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-triangle-1-s { float:left; + margin-right: 8px; } #schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-close { @@ -1478,3 +1479,4 @@ ul.errors li { float:right; margin-right:4px; } + diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js index 87388f0fd..33df795b7 100644 --- a/public/js/airtime/schedule/full-calendar-functions.js +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -148,7 +148,8 @@ function viewDisplay( view ) { function eventRender(event, element, view) { - if(view.name === 'agendaDay' || view.name === 'agendaWeek') { + //only put progress bar on shows that aren't being recorded and are not a rebroadcast. + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0 && event.rebroadcast === 0) { var div = $('
'); div .height('5px') diff --git a/public/js/fullcalendar/fullcalendar.js b/public/js/fullcalendar/fullcalendar.js index cef3dd5e6..313c97839 100644 --- a/public/js/fullcalendar/fullcalendar.js +++ b/public/js/fullcalendar/fullcalendar.js @@ -2945,7 +2945,8 @@ function AgendaEventRenderer() { "" + htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) + "" + "" + htmlEscape(event.title) + "" + "" + - ((event.editable || event.editable === undefined && opt('editable')) && !opt('disableResizing') && $.fn.resizable ? + ((event.editable || event.editable === undefined && opt('editable')) && + (!event.disableResizing || event.disableResizing === undefined && !opt('disableResizing')) && $.fn.resizable ? "
=
" : '') + "
"; @@ -3178,7 +3179,7 @@ function AgendaEventRenderer() { function resizableSlotEvent(event, eventElement, timeElement) { - if (!opt('disableResizing') && eventElement.resizable) { + if ((!event.disableResizing || event.disableResizing === undefined && !opt('disableResizing')) && eventElement.resizable) { var slotDelta, prevSlotDelta; var slotHeight = getSlotHeight(); eventElement.resizable({ @@ -3641,7 +3642,8 @@ function DayEventRenderer() { :'') + "" + htmlEscape(event.title) + "" + "" + - (seg.isEnd && (event.editable || event.editable === undefined && opt('editable')) && !opt('disableResizing') ? + (seg.isEnd && (event.editable || event.editable === undefined && opt('editable')) && + (!event.disableResizing || event.disableResizing === undefined && !opt('disableResizing')) ? "
" : '') + ""; @@ -3831,7 +3833,7 @@ function DayEventRenderer() { function resizableDayEvent(event, element, seg) { - if (!opt('disableResizing') && seg.isEnd) { + if ((!event.disableResizing || event.disableResizing === undefined && !opt('disableResizing')) && seg.isEnd) { var rtl = opt('isRTL'); var direction = rtl ? 'w' : 'e'; var handle = element.find('div.ui-resizable-' + direction); @@ -4806,5 +4808,5 @@ function enableTextSelection(element) { */ - -})(jQuery); \ No newline at end of file + +})(jQuery);