From 32a1a66378919a96e02c8fc1a18d75a02032c1ee Mon Sep 17 00:00:00 2001 From: Robb Ebright Date: Mon, 13 Feb 2017 09:35:09 -0500 Subject: [PATCH] Added AutoPlaylist Functionality to Show Scheduler enabling shows to have tracks added automatically. --- .../common/AutoPlaylistManager.php | 97 ++++++ .../application/common/TaskManager.php | 31 ++ .../application/configs/airtime-conf.php | 10 +- .../controllers/ScheduleController.php | 1 + .../upgrade_sql/airtime_2.5.17/upgrade.sql | 3 + .../application/forms/AddShowAutoPlaylist.php | 72 +++++ airtime_mvc/application/forms/AddShowWhat.php | 30 +- airtime_mvc/application/models/Preference.php | 9 + airtime_mvc/application/models/Show.php | 28 ++ .../application/models/ShowInstance.php | 34 ++- .../application/models/airtime/CcShow.php | 2 + .../models/airtime/map/CcPlaylistTableMap.php | 1 + .../airtime/map/CcShowInstancesTableMap.php | 1 + .../models/airtime/map/CcShowTableMap.php | 3 + .../models/airtime/om/BaseCcPlaylist.php | 286 ++++++++++++++++++ .../models/airtime/om/BaseCcPlaylistPeer.php | 3 + .../models/airtime/om/BaseCcPlaylistQuery.php | 78 +++++ .../models/airtime/om/BaseCcShow.php | 224 +++++++++++++- .../models/airtime/om/BaseCcShowInstances.php | 72 ++++- .../airtime/om/BaseCcShowInstancesPeer.php | 33 +- .../airtime/om/BaseCcShowInstancesQuery.php | 33 +- .../models/airtime/om/BaseCcShowPeer.php | 276 ++++++++++++++++- .../models/airtime/om/BaseCcShowQuery.php | 161 +++++++++- .../application/services/ShowFormService.php | 36 ++- .../application/services/ShowService.php | 5 + .../scripts/form/add-show-autoplaylist.phtml | 23 ++ .../views/scripts/form/add-show-block.phtml | 2 + .../scripts/schedule/add-show-form.phtml | 5 + .../public/js/airtime/schedule/add-show.js | 23 ++ 29 files changed, 1535 insertions(+), 47 deletions(-) create mode 100644 airtime_mvc/application/common/AutoPlaylistManager.php create mode 100644 airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.17/upgrade.sql create mode 100644 airtime_mvc/application/forms/AddShowAutoPlaylist.php create mode 100644 airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml diff --git a/airtime_mvc/application/common/AutoPlaylistManager.php b/airtime_mvc/application/common/AutoPlaylistManager.php new file mode 100644 index 000000000..0e71ae208 --- /dev/null +++ b/airtime_mvc/application/common/AutoPlaylistManager.php @@ -0,0 +1,97 @@ + $lastPolled + self::$_AUTOPLAYLIST_POLL_INTERVAL_SECONDS); + } + + + /* + * This function is copied from the TestUser class and is used to instantiate a user so that + * the Scheduler model can be utilized by buildAutoPlaylist. + * Not sure if this is the best strategy but it works. + */ + public static function loginUser() + { + $authAdapter = Application_Model_Auth::getAuthAdapter(); + + //pass to the adapter the submitted username and password + $authAdapter->setIdentity('admin') + ->setCredential('admin'); + + $auth = Zend_Auth::getInstance(); + $result = $auth->authenticate($authAdapter); + if ($result->isValid()) { + //all info about this user from the login table omit only the password + $userInfo = $authAdapter->getResultRowObject(null, 'password'); + + //the default storage is a session with namespace Zend_Auth + $authStorage = $auth->getStorage(); + $authStorage->write($userInfo); + } + } + + + /** + * Find all shows with autoplaylists who have yet to have their playlists built and added to the schedule + * + */ + public static function buildAutoPlaylist() { + // Starting a session so that the User can be created + Zend_Session::start(); + static::loginUser(); + Logging::info("Checking to run Auto Playlist"); + $autoPlaylists = static::_upcomingAutoPlaylistShows(); + foreach ($autoPlaylists as $autoplaylist) { + // creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object + $si = new Application_Model_ShowInstance($autoplaylist->getDbId()); + $playlistid = $si->GetAutoPlaylistId(); + Logging::info("Scheduling $playlistid"); + // call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object + $si->addPlaylistToShow($playlistid, false); + $si->setAutoPlaylistBuilt(true); + + } + Application_Model_Preference::setAutoPlaylistPollLock(microtime(true)); + Zend_Session::stop(); + } + + + /** + * Find all show instances starting in the next hour with autoplaylists not yet added to the schedule + * + * @return PropelObjectCollection collection of ShowInstance objects + * that have unbuilt autoplaylists + */ + protected static function _upcomingAutoPlaylistShows() { + //setting now so that past shows aren't referenced + $now = new DateTime("now", new DateTimeZone("UTC")); + // only build playlists for shows that start up to an hour from now + $future = clone $now; + $future->add(new DateInterval('PT1H')); + + return CcShowInstancesQuery::create() + ->filterByDbStarts($now,Criteria::GREATER_THAN) + ->filterByDbStarts($future,Criteria::LESS_THAN) + ->useCcShowQuery('a', 'left join') + ->filterByDbHasAutoPlaylist(true) + ->endUse() + ->filterByDbAutoPlaylistBuilt(false) + ->find(); + } + +} diff --git a/airtime_mvc/application/common/TaskManager.php b/airtime_mvc/application/common/TaskManager.php index 382f5ad19..6f961d7c5 100644 --- a/airtime_mvc/application/common/TaskManager.php +++ b/airtime_mvc/application/common/TaskManager.php @@ -222,6 +222,37 @@ class CeleryTask implements AirtimeTask { } +/** + * + * Class AutoPlaylistTask + * + * Checks for shows with an autoplaylist that needs to be filled in + * + */ +class AutoPlaylistTask implements AirtimeTask +{ + + /** + * Checks whether or not the autoplaylist polling interval has passed + * + * @return bool true if the autoplaylist polling interval has passed + */ + public function shouldBeRun() + { + return AutoPlaylistManager::hasAutoPlaylistPollIntervalPassed(); + } + + /** + * Schedule the autoplaylist for the shows + */ + public function run() + { + AutoPlaylistManager::buildAutoPlaylist(); + } +} + + + /** * Class PodcastTask * diff --git a/airtime_mvc/application/configs/airtime-conf.php b/airtime_mvc/application/configs/airtime-conf.php index ad939b2ce..dd8159a27 100644 --- a/airtime_mvc/application/configs/airtime-conf.php +++ b/airtime_mvc/application/configs/airtime-conf.php @@ -1,6 +1,6 @@ array ( @@ -22,6 +22,14 @@ $conf = array ( ), 'default' => 'airtime', ), + 'log' => + array ( + 'type' => 'file', + 'name' => './propel.log', + 'ident' => 'propel', + 'level' => '7', + 'conf' => '', + ), 'generator_version' => '1.7.0', ); $conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php'); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 84e88f045..33044b4ec 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -622,6 +622,7 @@ class ScheduleController extends Zend_Controller_Action } $this->view->what = $forms["what"]; + $this->view->autoplaylist = $forms["autoplaylist"]; $this->view->when = $forms["when"]; $this->view->repeats = $forms["repeats"]; $this->view->live = $forms["live"]; diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.17/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.17/upgrade.sql new file mode 100644 index 000000000..0ea1a39c4 --- /dev/null +++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.17/upgrade.sql @@ -0,0 +1,3 @@ +ALTER TABLE cc_show ADD COLUMN has_autoplaylist boolean default 'f' NOT NULL +ALTER TABLE cc_show ADD COLUMN autoplaylist_id integer DEFAULT NULL +ALTER TABLE cc_show_instances ADD COLUMN autoplaylist_built boolean default 'f' NOT NULL \ No newline at end of file diff --git a/airtime_mvc/application/forms/AddShowAutoPlaylist.php b/airtime_mvc/application/forms/AddShowAutoPlaylist.php new file mode 100644 index 000000000..d976983ba --- /dev/null +++ b/airtime_mvc/application/forms/AddShowAutoPlaylist.php @@ -0,0 +1,72 @@ +setDecorators(array( + array('ViewScript', array('viewScript' => 'form/add-show-autoplaylist.phtml')) + )); + + + + $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); + // retrieves the length limit for each char field + // and store to assoc array + $maxLens = Application_Model_Show::getMaxLengths(); + + // Add autoplaylist checkbox element + $this->addElement('checkbox', 'add_show_has_autoplaylist', array( + 'label' => _('Auto Schedule Playlist ?'), + 'required' => false, + 'class' => 'input_text', + 'decorators' => array('ViewHelper') + )); + + $autoPlaylistSelect = new Zend_Form_Element_Select("add_show_autoplaylist_id"); + $autoPlaylistSelect->setLabel(_("Select Playlist")); + $autoPlaylistSelect->setMultiOptions($this->getPlaylistNames()); + $autoPlaylistSelect->setValue(null); + $autoPlaylistSelect->setDecorators(array('ViewHelper')); + $this->addElement($autoPlaylistSelect); + } + + +private function getPlaylistNames() +{ + $playlistNames = array(NULL => _("None")); + + + $playlists = CcPlaylistQuery::create() + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find(); + + foreach ($playlists as $playlist) { + + $playlistNames[$playlist->getDbId()] = $playlist->getDbName(); + } + + return $playlistNames; +} + + + public function disable() + { + $elements = $this->getElements(); + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { + $element->setAttrib('disabled','disabled'); + } + } + } + + public function makeReadonly() + { + $elements = $this->getElements(); + foreach ($elements as $element) { + if ($element->getType() != 'Zend_Form_Element_Hidden') { + $element->setAttrib('readonly','readonly'); + } + } + } +} diff --git a/airtime_mvc/application/forms/AddShowWhat.php b/airtime_mvc/application/forms/AddShowWhat.php index 21d47d0fe..ce7353aaf 100644 --- a/airtime_mvc/application/forms/AddShowWhat.php +++ b/airtime_mvc/application/forms/AddShowWhat.php @@ -27,7 +27,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm 'class' => 'input_text', 'required' => true, 'filters' => array('StringTrim'), - 'value' => _('Untitled Show'), + 'value' => _('New Show'), 'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['name']))) )); @@ -39,7 +39,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm 'filters' => array('StringTrim'), 'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['url']))) )); - + // Add genre element $this->addElement('text', 'add_show_genre', array( 'label' => _('Genre:'), @@ -59,6 +59,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm $descText = $this->getElement('add_show_description'); + $descText->setDecorators(array(array('ViewScript', array( 'viewScript' => 'form/add-show-block.phtml', 'class' => 'block-display' @@ -73,15 +74,36 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm )); $instanceDesc = $this->getElement('add_show_instance_description'); - + $instanceDesc->setDecorators(array(array('ViewScript', array( 'viewScript' => 'form/add-show-block.phtml', 'class' => 'block-display' )))); $instanceDesc->setAttrib('disabled','disabled'); + } + + +private function getPlaylistNames() +{ + $playlistNames = array(NULL => _("None")); - /** + + $playlists = CcPlaylistQuery::create() + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find(); + + foreach ($playlists as $playlist) { + + $playlistNames[$playlist->getDbId()] = $playlist->getDbName(); + } + + return $playlistNames; +} + + + +/** * Enable the instance description when editing a show instance */ public function enableInstanceDesc() diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 3789f51de..444b58173 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1495,6 +1495,15 @@ class Application_Model_Preference { self::setValue("whats_new_dialog_viewed", $value, true); } + + public static function getAutoPlaylistPollLock() { + return self::getValue("autoplaylist_poll_lock"); + } + + public static function setAutoPlaylistPollLock($value) + { + self::setValue("autoplaylist_poll_lock", $value); + } public static function getPodcastPollLock() { return self::getValue("podcast_poll_lock"); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 504a53418..6881b9014 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -129,6 +129,34 @@ class Application_Model_Show return $this->_showId; } + + public function getHasAutoPlaylist() + { + $show = CcShowQuery::create()->findPK($this->_showId); + $hasAutoPlaylist = $show->getDbHasAutoPlaylist(); + return $hasAutoPlaylist; + } + + public function setHasAutoPlaylist($value) + { + $show = CcShowQuery::create()->findPK($this->_showId); + $show->setDbHasAutoPlaylist($value); + } + + public function getAutoPlaylistId() + { + $show = CcShowQuery::create()->findPK($this->_showId); + $autoPlaylistId = $show->getDbAutoPlaylistId(); + return $autoPlaylistId; + } + + public function setAutoPlaylistId($playlistid) + { + $show = CcShowQuery::create()->findPK($this->_showId); + $show->setDbAutoPlaylistId($playlistid); + } + + public function getHosts() { $sql = <<getDbGenre(); } + + public function hasAutoPlaylist() + { + $show = CcShowQuery::create()->findPK($this->getShowId()); + return $show->getDbHasAutoPlaylist(); + + } + + public function getAutoPlaylistId() + { + $show = CcShowQuery::create()->findPK($this->getShowId()); + return $show->getDbAutoPlaylistId(); + + } + /** * Return the start time of the Show (UTC time) * @return string in format DEFAULT_TIMESTAMP_FORMAT (PHP time notation) @@ -148,11 +163,22 @@ SQL; Application_Model_RabbitMq::PushSchedule(); } + public function setAutoPlaylistBuilt($bool) + { + $this->_showInstance->setDbAutoPlaylistBuilt($bool) + ->save(); + } + + public function updateScheduledTime() { $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); $this->_showInstance->updateDbTimeFilled($con); } + + + + public function isDeleted() { @@ -203,7 +229,7 @@ SQL; * @param int $plId * Playlist ID. */ - /*public function addPlaylistToShow($pl_id, $checkUserPerm = true) + public function addPlaylistToShow($pl_id, $checkUserPerm = true) { $ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0; $id = $this->_showInstance->getDbId(); @@ -213,7 +239,7 @@ SQL; array(array("id" => 0, "instance" => $id, "timestamp" => $ts)), array(array("id" => $pl_id, "type" => "playlist")) ); - }*/ + } /** * Add a media file as the last item in the show. @@ -239,12 +265,12 @@ SQL; * @param array $plIds * An array of playlist IDs. */ - /*public function scheduleShow($plIds) + public function scheduleShow($plIds) { foreach ($plIds as $plId) { $this->addPlaylistToShow($plId); } - }*/ + } public function clearShow() { diff --git a/airtime_mvc/application/models/airtime/CcShow.php b/airtime_mvc/application/models/airtime/CcShow.php index ee0c75454..a9e36ca19 100644 --- a/airtime_mvc/application/models/airtime/CcShow.php +++ b/airtime_mvc/application/models/airtime/CcShow.php @@ -319,6 +319,8 @@ class CcShow extends BaseCcShow { $info['color'] = $this->getDbColor(); $info['background_color'] = $this->getDbBackgroundColor(); $info['linked'] = $this->getDbLinked(); + $info['has_autoplaylist'] = $this->getDbHasAutoPlaylist(); + $info['autoplaylist_id'] = $this->getDbAutoPlaylistId(); return $info; } diff --git a/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php index e14663e13..d35f92e41 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php @@ -55,6 +55,7 @@ class CcPlaylistTableMap extends TableMap public function buildRelations() { $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcShow', 'CcShow', RelationMap::ONE_TO_MANY, array('id' => 'autoplaylist_id', ), 'SET NULL', null, 'CcShows'); $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null, 'CcPlaylistcontentss'); } // buildRelations() diff --git a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php index 0a52454dc..84930edec 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php @@ -52,6 +52,7 @@ class CcShowInstancesTableMap extends TableMap $this->addColumn('created', 'DbCreated', 'TIMESTAMP', true, null, null); $this->addColumn('last_scheduled', 'DbLastScheduled', 'TIMESTAMP', false, null, null); $this->addColumn('modified_instance', 'DbModifiedInstance', 'BOOLEAN', true, null, false); + $this->addColumn('autoplaylist_built', 'DbAutoPlaylistBuilt', 'BOOLEAN', true, null, false); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php index 73ba89fac..a393ee928 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php @@ -53,6 +53,8 @@ class CcShowTableMap extends TableMap $this->addColumn('linked', 'DbLinked', 'BOOLEAN', true, null, false); $this->addColumn('is_linkable', 'DbIsLinkable', 'BOOLEAN', true, null, true); $this->addColumn('image_path', 'DbImagePath', 'VARCHAR', false, 255, ''); + $this->addColumn('has_autoplaylist', 'DbHasAutoPlaylist', 'BOOLEAN', true, null, false); + $this->addForeignKey('autoplaylist_id', 'DbAutoPlaylistId', 'INTEGER', 'cc_playlist', 'id', false, null, null); // validators } // initialize() @@ -61,6 +63,7 @@ class CcShowTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('autoplaylist_id' => 'id', ), 'SET NULL', null); $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowInstancess'); $this->addRelation('CcShowDays', 'CcShowDays', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowDayss'); $this->addRelation('CcShowRebroadcast', 'CcShowRebroadcast', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowRebroadcasts'); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php index 29783a952..ee2e4269c 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php @@ -78,6 +78,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent */ protected $aCcSubjs; + /** + * @var PropelObjectCollection|CcShow[] Collection to store aggregation of CcShow objects. + */ + protected $collCcShows; + protected $collCcShowsPartial; + /** * @var PropelObjectCollection|CcPlaylistcontents[] Collection to store aggregation of CcPlaylistcontents objects. */ @@ -104,6 +110,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent */ protected $alreadyInClearAllReferencesDeep = false; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -534,6 +546,8 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? $this->aCcSubjs = null; + $this->collCcShows = null; + $this->collCcPlaylistcontentss = null; } // if (deep) @@ -680,6 +694,24 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent $this->resetModified(); } + if ($this->ccShowsScheduledForDeletion !== null) { + if (!$this->ccShowsScheduledForDeletion->isEmpty()) { + foreach ($this->ccShowsScheduledForDeletion as $ccShow) { + // need to save related object because we set the relation to null + $ccShow->save($con); + } + $this->ccShowsScheduledForDeletion = null; + } + } + + if ($this->collCcShows !== null) { + foreach ($this->collCcShows as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->ccPlaylistcontentssScheduledForDeletion !== null) { if (!$this->ccPlaylistcontentssScheduledForDeletion->isEmpty()) { CcPlaylistcontentsQuery::create() @@ -890,6 +922,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent } + if ($this->collCcShows !== null) { + foreach ($this->collCcShows 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)) { @@ -1000,6 +1040,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent if (null !== $this->aCcSubjs) { $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->collCcShows) { + $result['CcShows'] = $this->collCcShows->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCcPlaylistcontentss) { $result['CcPlaylistcontentss'] = $this->collCcPlaylistcontentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1184,6 +1227,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; + foreach ($this->getCcShows() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShow($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)); @@ -1303,11 +1352,239 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('CcShow' == $relationName) { + $this->initCcShows(); + } if ('CcPlaylistcontents' == $relationName) { $this->initCcPlaylistcontentss(); } } + /** + * Clears out the collCcShows 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 CcPlaylist The current object (for fluent API support) + * @see addCcShows() + */ + public function clearCcShows() + { + $this->collCcShows = null; // important to set this to null since that means it is uninitialized + $this->collCcShowsPartial = null; + + return $this; + } + + /** + * reset is the collCcShows collection loaded partially + * + * @return void + */ + public function resetPartialCcShows($v = true) + { + $this->collCcShowsPartial = $v; + } + + /** + * Initializes the collCcShows collection. + * + * By default this just sets the collCcShows collection to an empty array (like clearcollCcShows()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShows($overrideExisting = true) + { + if (null !== $this->collCcShows && !$overrideExisting) { + return; + } + $this->collCcShows = new PropelObjectCollection(); + $this->collCcShows->setModel('CcShow'); + } + + /** + * Gets an array of CcShow 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 CcPlaylist 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 PropelObjectCollection|CcShow[] List of CcShow objects + * @throws PropelException + */ + public function getCcShows($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowsPartial && !$this->isNew(); + if (null === $this->collCcShows || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShows) { + // return empty collection + $this->initCcShows(); + } else { + $collCcShows = CcShowQuery::create(null, $criteria) + ->filterByCcPlaylist($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowsPartial && count($collCcShows)) { + $this->initCcShows(false); + + foreach ($collCcShows as $obj) { + if (false == $this->collCcShows->contains($obj)) { + $this->collCcShows->append($obj); + } + } + + $this->collCcShowsPartial = true; + } + + $collCcShows->getInternalIterator()->rewind(); + + return $collCcShows; + } + + if ($partial && $this->collCcShows) { + foreach ($this->collCcShows as $obj) { + if ($obj->isNew()) { + $collCcShows[] = $obj; + } + } + } + + $this->collCcShows = $collCcShows; + $this->collCcShowsPartial = false; + } + } + + return $this->collCcShows; + } + + /** + * Sets a collection of CcShow objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShows A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcPlaylist The current object (for fluent API support) + */ + public function setCcShows(PropelCollection $ccShows, PropelPDO $con = null) + { + $ccShowsToDelete = $this->getCcShows(new Criteria(), $con)->diff($ccShows); + + + $this->ccShowsScheduledForDeletion = $ccShowsToDelete; + + foreach ($ccShowsToDelete as $ccShowRemoved) { + $ccShowRemoved->setCcPlaylist(null); + } + + $this->collCcShows = null; + foreach ($ccShows as $ccShow) { + $this->addCcShow($ccShow); + } + + $this->collCcShows = $ccShows; + $this->collCcShowsPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShow objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShow objects. + * @throws PropelException + */ + public function countCcShows(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowsPartial && !$this->isNew(); + if (null === $this->collCcShows || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShows) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShows()); + } + $query = CcShowQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcPlaylist($this) + ->count($con); + } + + return count($this->collCcShows); + } + + /** + * Method called to associate a CcShow object to this object + * through the CcShow foreign key attribute. + * + * @param CcShow $l CcShow + * @return CcPlaylist The current object (for fluent API support) + */ + public function addCcShow(CcShow $l) + { + if ($this->collCcShows === null) { + $this->initCcShows(); + $this->collCcShowsPartial = true; + } + + if (!in_array($l, $this->collCcShows->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShow($l); + + if ($this->ccShowsScheduledForDeletion and $this->ccShowsScheduledForDeletion->contains($l)) { + $this->ccShowsScheduledForDeletion->remove($this->ccShowsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShow $ccShow The ccShow object to add. + */ + protected function doAddCcShow($ccShow) + { + $this->collCcShows[]= $ccShow; + $ccShow->setCcPlaylist($this); + } + + /** + * @param CcShow $ccShow The ccShow object to remove. + * @return CcPlaylist The current object (for fluent API support) + */ + public function removeCcShow($ccShow) + { + if ($this->getCcShows()->contains($ccShow)) { + $this->collCcShows->remove($this->collCcShows->search($ccShow)); + if (null === $this->ccShowsScheduledForDeletion) { + $this->ccShowsScheduledForDeletion = clone $this->collCcShows; + $this->ccShowsScheduledForDeletion->clear(); + } + $this->ccShowsScheduledForDeletion[]= $ccShow; + $ccShow->setCcPlaylist(null); + } + + return $this; + } + /** * Clears out the collCcPlaylistcontentss collection * @@ -1618,6 +1895,11 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcShows) { + foreach ($this->collCcShows as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCcPlaylistcontentss) { foreach ($this->collCcPlaylistcontentss as $o) { $o->clearAllReferences($deep); @@ -1630,6 +1912,10 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) + if ($this->collCcShows instanceof PropelCollection) { + $this->collCcShows->clearIterator(); + } + $this->collCcShows = null; if ($this->collCcPlaylistcontentss instanceof PropelCollection) { $this->collCcPlaylistcontentss->clearIterator(); } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php index 11515ef0c..d1482249c 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php @@ -385,6 +385,9 @@ abstract class BaseCcPlaylistPeer */ public static function clearRelatedInstancePool() { + // Invalidate objects in CcShowPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowPeer::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/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php index 8e66d8f54..4735966f1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php @@ -30,6 +30,10 @@ * @method CcPlaylistQuery rightJoinCcSubjs($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcSubjs relation * @method CcPlaylistQuery innerJoinCcSubjs($relationAlias = null) Adds a INNER JOIN clause to the query using the CcSubjs relation * + * @method CcPlaylistQuery leftJoinCcShow($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcShow relation + * @method CcPlaylistQuery rightJoinCcShow($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcShow relation + * @method CcPlaylistQuery innerJoinCcShow($relationAlias = null) Adds a INNER JOIN clause to the query using the CcShow relation + * * @method CcPlaylistQuery leftJoinCcPlaylistcontents($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcPlaylistcontents relation * @method CcPlaylistQuery rightJoinCcPlaylistcontents($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcPlaylistcontents relation * @method CcPlaylistQuery innerJoinCcPlaylistcontents($relationAlias = null) Adds a INNER JOIN clause to the query using the CcPlaylistcontents relation @@ -582,6 +586,80 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); } + /** + * Filter the query by a related CcShow object + * + * @param CcShow|PropelObjectCollection $ccShow the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShow($ccShow, $comparison = null) + { + if ($ccShow instanceof CcShow) { + return $this + ->addUsingAlias(CcPlaylistPeer::ID, $ccShow->getDbAutoPlaylistId(), $comparison); + } elseif ($ccShow instanceof PropelObjectCollection) { + return $this + ->useCcShowQuery() + ->filterByPrimaryKeys($ccShow->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShow() only accepts arguments of type CcShow or PropelCollection'); + } + } + + /** + * 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 CcPlaylistQuery The current query, for fluid interface + */ + public function joinCcShow($relationAlias = null, $joinType = Criteria::LEFT_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 = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); + } + /** * Filter the query by a related CcPlaylistcontents object * diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShow.php b/airtime_mvc/application/models/airtime/om/BaseCcShow.php index 1bc274d1e..d358f85b1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShow.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShow.php @@ -121,6 +121,24 @@ abstract class BaseCcShow extends BaseObject implements Persistent */ protected $image_path; + /** + * The value for the has_autoplaylist field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $has_autoplaylist; + + /** + * The value for the autoplaylist_id field. + * @var int + */ + protected $autoplaylist_id; + + /** + * @var CcPlaylist + */ + protected $aCcPlaylist; + /** * @var PropelObjectCollection|CcShowInstances[] Collection to store aggregation of CcShowInstances objects. */ @@ -205,6 +223,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->linked = false; $this->is_linkable = true; $this->image_path = ''; + $this->has_autoplaylist = false; } /** @@ -371,6 +390,28 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this->image_path; } + /** + * Get the [has_autoplaylist] column value. + * + * @return boolean + */ + public function getDbHasAutoPlaylist() + { + + return $this->has_autoplaylist; + } + + /** + * Get the [autoplaylist_id] column value. + * + * @return int + */ + public function getDbAutoPlaylistId() + { + + return $this->autoplaylist_id; + } + /** * Set the value of [id] column. * @@ -697,6 +738,60 @@ abstract class BaseCcShow extends BaseObject implements Persistent return $this; } // setDbImagePath() + /** + * Sets the value of the [has_autoplaylist] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbHasAutoPlaylist($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->has_autoplaylist !== $v) { + $this->has_autoplaylist = $v; + $this->modifiedColumns[] = CcShowPeer::HAS_AUTOPLAYLIST; + } + + + return $this; + } // setDbHasAutoPlaylist() + + /** + * Set the value of [autoplaylist_id] column. + * + * @param int $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbAutoPlaylistId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->autoplaylist_id !== $v) { + $this->autoplaylist_id = $v; + $this->modifiedColumns[] = CcShowPeer::AUTOPLAYLIST_ID; + } + + if ($this->aCcPlaylist !== null && $this->aCcPlaylist->getDbId() !== $v) { + $this->aCcPlaylist = null; + } + + + return $this; + } // setDbAutoPlaylistId() + /** * Indicates whether the columns in this object are only set to default values. * @@ -739,6 +834,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent return false; } + if ($this->has_autoplaylist !== false) { + return false; + } + // otherwise, everything was equal, so return true return true; } // hasOnlyDefaultValues() @@ -775,6 +874,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->linked = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; $this->is_linkable = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; $this->image_path = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; + $this->has_autoplaylist = ($row[$startcol + 14] !== null) ? (boolean) $row[$startcol + 14] : null; + $this->autoplaylist_id = ($row[$startcol + 15] !== null) ? (int) $row[$startcol + 15] : null; $this->resetModified(); $this->setNew(false); @@ -784,7 +885,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent } $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 14; // 14 = CcShowPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 16; // 16 = CcShowPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating CcShow object", $e); @@ -807,6 +908,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent public function ensureConsistency() { + if ($this->aCcPlaylist !== null && $this->autoplaylist_id !== $this->aCcPlaylist->getDbId()) { + $this->aCcPlaylist = null; + } } // ensureConsistency /** @@ -846,6 +950,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? + $this->aCcPlaylist = null; $this->collCcShowInstancess = null; $this->collCcShowDayss = null; @@ -967,6 +1072,18 @@ abstract class BaseCcShow extends BaseObject implements Persistent 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcPlaylist !== null) { + if ($this->aCcPlaylist->isModified() || $this->aCcPlaylist->isNew()) { + $affectedRows += $this->aCcPlaylist->save($con); + } + $this->setCcPlaylist($this->aCcPlaylist); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1124,6 +1241,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent if ($this->isColumnModified(CcShowPeer::IMAGE_PATH)) { $modifiedColumns[':p' . $index++] = '"image_path"'; } + if ($this->isColumnModified(CcShowPeer::HAS_AUTOPLAYLIST)) { + $modifiedColumns[':p' . $index++] = '"has_autoplaylist"'; + } + if ($this->isColumnModified(CcShowPeer::AUTOPLAYLIST_ID)) { + $modifiedColumns[':p' . $index++] = '"autoplaylist_id"'; + } $sql = sprintf( 'INSERT INTO "cc_show" (%s) VALUES (%s)', @@ -1177,6 +1300,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent case '"image_path"': $stmt->bindValue($identifier, $this->image_path, PDO::PARAM_STR); break; + case '"has_autoplaylist"': + $stmt->bindValue($identifier, $this->has_autoplaylist, PDO::PARAM_BOOL); + break; + case '"autoplaylist_id"': + $stmt->bindValue($identifier, $this->autoplaylist_id, PDO::PARAM_INT); + break; } } $stmt->execute(); @@ -1264,6 +1393,18 @@ abstract class BaseCcShow extends BaseObject implements Persistent $failureMap = array(); + // We call the validate method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcPlaylist !== null) { + if (!$this->aCcPlaylist->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcPlaylist->getValidationFailures()); + } + } + + if (($retval = CcShowPeer::doValidate($this, $columns)) !== true) { $failureMap = array_merge($failureMap, $retval); } @@ -1378,6 +1519,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent case 13: return $this->getDbImagePath(); break; + case 14: + return $this->getDbHasAutoPlaylist(); + break; + case 15: + return $this->getDbAutoPlaylistId(); + break; default: return null; break; @@ -1421,6 +1568,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent $keys[11] => $this->getDbLinked(), $keys[12] => $this->getDbIsLinkable(), $keys[13] => $this->getDbImagePath(), + $keys[14] => $this->getDbHasAutoPlaylist(), + $keys[15] => $this->getDbAutoPlaylistId(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1428,6 +1577,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent } if ($includeForeignObjects) { + if (null !== $this->aCcPlaylist) { + $result['CcPlaylist'] = $this->aCcPlaylist->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } if (null !== $this->collCcShowInstancess) { $result['CcShowInstancess'] = $this->collCcShowInstancess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1516,6 +1668,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent case 13: $this->setDbImagePath($value); break; + case 14: + $this->setDbHasAutoPlaylist($value); + break; + case 15: + $this->setDbAutoPlaylistId($value); + break; } // switch() } @@ -1554,6 +1712,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent if (array_key_exists($keys[11], $arr)) $this->setDbLinked($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setDbIsLinkable($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setDbImagePath($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setDbHasAutoPlaylist($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setDbAutoPlaylistId($arr[$keys[15]]); } /** @@ -1579,6 +1739,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent if ($this->isColumnModified(CcShowPeer::LINKED)) $criteria->add(CcShowPeer::LINKED, $this->linked); if ($this->isColumnModified(CcShowPeer::IS_LINKABLE)) $criteria->add(CcShowPeer::IS_LINKABLE, $this->is_linkable); if ($this->isColumnModified(CcShowPeer::IMAGE_PATH)) $criteria->add(CcShowPeer::IMAGE_PATH, $this->image_path); + if ($this->isColumnModified(CcShowPeer::HAS_AUTOPLAYLIST)) $criteria->add(CcShowPeer::HAS_AUTOPLAYLIST, $this->has_autoplaylist); + if ($this->isColumnModified(CcShowPeer::AUTOPLAYLIST_ID)) $criteria->add(CcShowPeer::AUTOPLAYLIST_ID, $this->autoplaylist_id); return $criteria; } @@ -1655,6 +1817,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent $copyObj->setDbLinked($this->getDbLinked()); $copyObj->setDbIsLinkable($this->getDbIsLinkable()); $copyObj->setDbImagePath($this->getDbImagePath()); + $copyObj->setDbHasAutoPlaylist($this->getDbHasAutoPlaylist()); + $copyObj->setDbAutoPlaylistId($this->getDbAutoPlaylistId()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -1737,6 +1901,58 @@ abstract class BaseCcShow extends BaseObject implements Persistent return self::$peer; } + /** + * Declares an association between this object and a CcPlaylist object. + * + * @param CcPlaylist $v + * @return CcShow The current object (for fluent API support) + * @throws PropelException + */ + public function setCcPlaylist(CcPlaylist $v = null) + { + if ($v === null) { + $this->setDbAutoPlaylistId(NULL); + } else { + $this->setDbAutoPlaylistId($v->getDbId()); + } + + $this->aCcPlaylist = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcPlaylist object, it will not be re-added. + if ($v !== null) { + $v->addCcShow($this); + } + + + return $this; + } + + + /** + * Get the associated CcPlaylist object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcPlaylist The associated CcPlaylist object. + * @throws PropelException + */ + public function getCcPlaylist(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcPlaylist === null && ($this->autoplaylist_id !== null) && $doQuery) { + $this->aCcPlaylist = CcPlaylistQuery::create()->findPk($this->autoplaylist_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->aCcPlaylist->addCcShows($this); + */ + } + + return $this->aCcPlaylist; + } + /** * Initializes a collection based on the name of a relation. @@ -2756,6 +2972,8 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->linked = null; $this->is_linkable = null; $this->image_path = null; + $this->has_autoplaylist = null; + $this->autoplaylist_id = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; @@ -2799,6 +3017,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aCcPlaylist instanceof Persistent) { + $this->aCcPlaylist->clearAllReferences($deep); + } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) @@ -2819,6 +3040,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent $this->collCcShowHostss->clearIterator(); } $this->collCcShowHostss = null; + $this->aCcPlaylist = null; } /** diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php index a96bae447..ba63c6c89 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php @@ -112,6 +112,13 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent */ protected $modified_instance; + /** + * The value for the autoplaylist_built field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $autoplaylist_built; + /** * @var CcShow */ @@ -196,6 +203,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->rebroadcast = 0; $this->time_filled = '00:00:00'; $this->modified_instance = false; + $this->autoplaylist_built = false; } /** @@ -447,6 +455,17 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this->modified_instance; } + /** + * Get the [autoplaylist_built] column value. + * + * @return boolean + */ + public function getDbAutoPlaylistBuilt() + { + + return $this->autoplaylist_built; + } + /** * Set the value of [id] column. * @@ -748,6 +767,35 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this; } // setDbModifiedInstance() + /** + * Sets the value of the [autoplaylist_built] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbAutoPlaylistBuilt($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->autoplaylist_built !== $v) { + $this->autoplaylist_built = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::AUTOPLAYLIST_BUILT; + } + + + return $this; + } // setDbAutoPlaylistBuilt() + /** * Indicates whether the columns in this object are only set to default values. * @@ -778,6 +826,10 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return false; } + if ($this->autoplaylist_built !== false) { + return false; + } + // otherwise, everything was equal, so return true return true; } // hasOnlyDefaultValues() @@ -813,6 +865,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->created = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; $this->last_scheduled = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; $this->modified_instance = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; + $this->autoplaylist_built = ($row[$startcol + 13] !== null) ? (boolean) $row[$startcol + 13] : null; $this->resetModified(); $this->setNew(false); @@ -822,7 +875,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent } $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 13; // 13 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 14; // 14 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating CcShowInstances object", $e); @@ -1179,6 +1232,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) { $modifiedColumns[':p' . $index++] = '"modified_instance"'; } + if ($this->isColumnModified(CcShowInstancesPeer::AUTOPLAYLIST_BUILT)) { + $modifiedColumns[':p' . $index++] = '"autoplaylist_built"'; + } $sql = sprintf( 'INSERT INTO "cc_show_instances" (%s) VALUES (%s)', @@ -1229,6 +1285,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case '"modified_instance"': $stmt->bindValue($identifier, $this->modified_instance, PDO::PARAM_BOOL); break; + case '"autoplaylist_built"': + $stmt->bindValue($identifier, $this->autoplaylist_built, PDO::PARAM_BOOL); + break; } } $stmt->execute(); @@ -1443,6 +1502,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case 12: return $this->getDbModifiedInstance(); break; + case 13: + return $this->getDbAutoPlaylistBuilt(); + break; default: return null; break; @@ -1485,6 +1547,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $keys[10] => $this->getDbCreated(), $keys[11] => $this->getDbLastScheduled(), $keys[12] => $this->getDbModifiedInstance(), + $keys[13] => $this->getDbAutoPlaylistBuilt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1583,6 +1646,9 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent case 12: $this->setDbModifiedInstance($value); break; + case 13: + $this->setDbAutoPlaylistBuilt($value); + break; } // switch() } @@ -1620,6 +1686,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if (array_key_exists($keys[10], $arr)) $this->setDbCreated($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setDbLastScheduled($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setDbModifiedInstance($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setDbAutoPlaylistBuilt($arr[$keys[13]]); } /** @@ -1644,6 +1711,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) $criteria->add(CcShowInstancesPeer::CREATED, $this->created); if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled); if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance); + if ($this->isColumnModified(CcShowInstancesPeer::AUTOPLAYLIST_BUILT)) $criteria->add(CcShowInstancesPeer::AUTOPLAYLIST_BUILT, $this->autoplaylist_built); return $criteria; } @@ -1719,6 +1787,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $copyObj->setDbCreated($this->getDbCreated()); $copyObj->setDbLastScheduled($this->getDbLastScheduled()); $copyObj->setDbModifiedInstance($this->getDbModifiedInstance()); + $copyObj->setDbAutoPlaylistBuilt($this->getDbAutoPlaylistBuilt()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -2791,6 +2860,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->created = null; $this->last_scheduled = null; $this->modified_instance = null; + $this->autoplaylist_built = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php index ff2a4bfbc..7b25c5763 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php @@ -24,13 +24,13 @@ abstract class BaseCcShowInstancesPeer const TM_CLASS = 'CcShowInstancesTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 13; + const NUM_COLUMNS = 14; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 13; + const NUM_HYDRATE_COLUMNS = 14; /** the column name for the id field */ const ID = 'cc_show_instances.id'; @@ -71,6 +71,9 @@ abstract class BaseCcShowInstancesPeer /** the column name for the modified_instance field */ const MODIFIED_INSTANCE = 'cc_show_instances.modified_instance'; + /** the column name for the autoplaylist_built field */ + const AUTOPLAYLIST_BUILT = 'cc_show_instances.autoplaylist_built'; + /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -90,12 +93,12 @@ abstract class BaseCcShowInstancesPeer * e.g. CcShowInstancesPeer::$fieldNames[CcShowInstancesPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbDescription', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbCreated', 'DbLastScheduled', 'DbModifiedInstance', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbDescription', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbCreated', 'dbLastScheduled', 'dbModifiedInstance', ), - BasePeer::TYPE_COLNAME => array (CcShowInstancesPeer::ID, CcShowInstancesPeer::DESCRIPTION, CcShowInstancesPeer::STARTS, CcShowInstancesPeer::ENDS, CcShowInstancesPeer::SHOW_ID, CcShowInstancesPeer::RECORD, CcShowInstancesPeer::REBROADCAST, CcShowInstancesPeer::INSTANCE_ID, CcShowInstancesPeer::FILE_ID, CcShowInstancesPeer::TIME_FILLED, CcShowInstancesPeer::CREATED, CcShowInstancesPeer::LAST_SCHEDULED, CcShowInstancesPeer::MODIFIED_INSTANCE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DESCRIPTION', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'CREATED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'description', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'created', 'last_scheduled', 'modified_instance', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbDescription', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbCreated', 'DbLastScheduled', 'DbModifiedInstance', 'DbAutoPlaylistBuilt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbDescription', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbCreated', 'dbLastScheduled', 'dbModifiedInstance', 'dbAutoPlaylistBuilt', ), + BasePeer::TYPE_COLNAME => array (CcShowInstancesPeer::ID, CcShowInstancesPeer::DESCRIPTION, CcShowInstancesPeer::STARTS, CcShowInstancesPeer::ENDS, CcShowInstancesPeer::SHOW_ID, CcShowInstancesPeer::RECORD, CcShowInstancesPeer::REBROADCAST, CcShowInstancesPeer::INSTANCE_ID, CcShowInstancesPeer::FILE_ID, CcShowInstancesPeer::TIME_FILLED, CcShowInstancesPeer::CREATED, CcShowInstancesPeer::LAST_SCHEDULED, CcShowInstancesPeer::MODIFIED_INSTANCE, CcShowInstancesPeer::AUTOPLAYLIST_BUILT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DESCRIPTION', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'CREATED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', 'AUTOPLAYLIST_BUILT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'description', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'created', 'last_scheduled', 'modified_instance', 'autoplaylist_built', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -105,12 +108,12 @@ abstract class BaseCcShowInstancesPeer * e.g. CcShowInstancesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbDescription' => 1, 'DbStarts' => 2, 'DbEnds' => 3, 'DbShowId' => 4, 'DbRecord' => 5, 'DbRebroadcast' => 6, 'DbOriginalShow' => 7, 'DbRecordedFile' => 8, 'DbTimeFilled' => 9, 'DbCreated' => 10, 'DbLastScheduled' => 11, 'DbModifiedInstance' => 12, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbDescription' => 1, 'dbStarts' => 2, 'dbEnds' => 3, 'dbShowId' => 4, 'dbRecord' => 5, 'dbRebroadcast' => 6, 'dbOriginalShow' => 7, 'dbRecordedFile' => 8, 'dbTimeFilled' => 9, 'dbCreated' => 10, 'dbLastScheduled' => 11, 'dbModifiedInstance' => 12, ), - BasePeer::TYPE_COLNAME => array (CcShowInstancesPeer::ID => 0, CcShowInstancesPeer::DESCRIPTION => 1, CcShowInstancesPeer::STARTS => 2, CcShowInstancesPeer::ENDS => 3, CcShowInstancesPeer::SHOW_ID => 4, CcShowInstancesPeer::RECORD => 5, CcShowInstancesPeer::REBROADCAST => 6, CcShowInstancesPeer::INSTANCE_ID => 7, CcShowInstancesPeer::FILE_ID => 8, CcShowInstancesPeer::TIME_FILLED => 9, CcShowInstancesPeer::CREATED => 10, CcShowInstancesPeer::LAST_SCHEDULED => 11, CcShowInstancesPeer::MODIFIED_INSTANCE => 12, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DESCRIPTION' => 1, 'STARTS' => 2, 'ENDS' => 3, 'SHOW_ID' => 4, 'RECORD' => 5, 'REBROADCAST' => 6, 'INSTANCE_ID' => 7, 'FILE_ID' => 8, 'TIME_FILLED' => 9, 'CREATED' => 10, 'LAST_SCHEDULED' => 11, 'MODIFIED_INSTANCE' => 12, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'description' => 1, 'starts' => 2, 'ends' => 3, 'show_id' => 4, 'record' => 5, 'rebroadcast' => 6, 'instance_id' => 7, 'file_id' => 8, 'time_filled' => 9, 'created' => 10, 'last_scheduled' => 11, 'modified_instance' => 12, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbDescription' => 1, 'DbStarts' => 2, 'DbEnds' => 3, 'DbShowId' => 4, 'DbRecord' => 5, 'DbRebroadcast' => 6, 'DbOriginalShow' => 7, 'DbRecordedFile' => 8, 'DbTimeFilled' => 9, 'DbCreated' => 10, 'DbLastScheduled' => 11, 'DbModifiedInstance' => 12, 'DbAutoPlaylistBuilt' => 13, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbDescription' => 1, 'dbStarts' => 2, 'dbEnds' => 3, 'dbShowId' => 4, 'dbRecord' => 5, 'dbRebroadcast' => 6, 'dbOriginalShow' => 7, 'dbRecordedFile' => 8, 'dbTimeFilled' => 9, 'dbCreated' => 10, 'dbLastScheduled' => 11, 'dbModifiedInstance' => 12, 'dbAutoPlaylistBuilt' => 13, ), + BasePeer::TYPE_COLNAME => array (CcShowInstancesPeer::ID => 0, CcShowInstancesPeer::DESCRIPTION => 1, CcShowInstancesPeer::STARTS => 2, CcShowInstancesPeer::ENDS => 3, CcShowInstancesPeer::SHOW_ID => 4, CcShowInstancesPeer::RECORD => 5, CcShowInstancesPeer::REBROADCAST => 6, CcShowInstancesPeer::INSTANCE_ID => 7, CcShowInstancesPeer::FILE_ID => 8, CcShowInstancesPeer::TIME_FILLED => 9, CcShowInstancesPeer::CREATED => 10, CcShowInstancesPeer::LAST_SCHEDULED => 11, CcShowInstancesPeer::MODIFIED_INSTANCE => 12, CcShowInstancesPeer::AUTOPLAYLIST_BUILT => 13, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DESCRIPTION' => 1, 'STARTS' => 2, 'ENDS' => 3, 'SHOW_ID' => 4, 'RECORD' => 5, 'REBROADCAST' => 6, 'INSTANCE_ID' => 7, 'FILE_ID' => 8, 'TIME_FILLED' => 9, 'CREATED' => 10, 'LAST_SCHEDULED' => 11, 'MODIFIED_INSTANCE' => 12, 'AUTOPLAYLIST_BUILT' => 13, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'description' => 1, 'starts' => 2, 'ends' => 3, 'show_id' => 4, 'record' => 5, 'rebroadcast' => 6, 'instance_id' => 7, 'file_id' => 8, 'time_filled' => 9, 'created' => 10, 'last_scheduled' => 11, 'modified_instance' => 12, 'autoplaylist_built' => 13, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -197,6 +200,7 @@ abstract class BaseCcShowInstancesPeer $criteria->addSelectColumn(CcShowInstancesPeer::CREATED); $criteria->addSelectColumn(CcShowInstancesPeer::LAST_SCHEDULED); $criteria->addSelectColumn(CcShowInstancesPeer::MODIFIED_INSTANCE); + $criteria->addSelectColumn(CcShowInstancesPeer::AUTOPLAYLIST_BUILT); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.description'); @@ -211,6 +215,7 @@ abstract class BaseCcShowInstancesPeer $criteria->addSelectColumn($alias . '.created'); $criteria->addSelectColumn($alias . '.last_scheduled'); $criteria->addSelectColumn($alias . '.modified_instance'); + $criteria->addSelectColumn($alias . '.autoplaylist_built'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php index 871ecf84f..ffb0de76f 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php @@ -19,6 +19,7 @@ * @method CcShowInstancesQuery orderByDbCreated($order = Criteria::ASC) Order by the created column * @method CcShowInstancesQuery orderByDbLastScheduled($order = Criteria::ASC) Order by the last_scheduled column * @method CcShowInstancesQuery orderByDbModifiedInstance($order = Criteria::ASC) Order by the modified_instance column + * @method CcShowInstancesQuery orderByDbAutoPlaylistBuilt($order = Criteria::ASC) Order by the autoplaylist_built column * * @method CcShowInstancesQuery groupByDbId() Group by the id column * @method CcShowInstancesQuery groupByDbDescription() Group by the description column @@ -33,6 +34,7 @@ * @method CcShowInstancesQuery groupByDbCreated() Group by the created column * @method CcShowInstancesQuery groupByDbLastScheduled() Group by the last_scheduled column * @method CcShowInstancesQuery groupByDbModifiedInstance() Group by the modified_instance column + * @method CcShowInstancesQuery groupByDbAutoPlaylistBuilt() Group by the autoplaylist_built 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 @@ -77,6 +79,7 @@ * @method CcShowInstances findOneByDbCreated(string $created) Return the first CcShowInstances filtered by the created column * @method CcShowInstances findOneByDbLastScheduled(string $last_scheduled) Return the first CcShowInstances filtered by the last_scheduled column * @method CcShowInstances findOneByDbModifiedInstance(boolean $modified_instance) Return the first CcShowInstances filtered by the modified_instance column + * @method CcShowInstances findOneByDbAutoPlaylistBuilt(boolean $autoplaylist_built) Return the first CcShowInstances filtered by the autoplaylist_built column * * @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column * @method array findByDbDescription(string $description) Return CcShowInstances objects filtered by the description column @@ -91,6 +94,7 @@ * @method array findByDbCreated(string $created) Return CcShowInstances objects filtered by the created column * @method array findByDbLastScheduled(string $last_scheduled) Return CcShowInstances objects filtered by the last_scheduled column * @method array findByDbModifiedInstance(boolean $modified_instance) Return CcShowInstances objects filtered by the modified_instance column + * @method array findByDbAutoPlaylistBuilt(boolean $autoplaylist_built) Return CcShowInstances objects filtered by the autoplaylist_built column * * @package propel.generator.airtime.om */ @@ -198,7 +202,7 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT "id", "description", "starts", "ends", "show_id", "record", "rebroadcast", "instance_id", "file_id", "time_filled", "created", "last_scheduled", "modified_instance" FROM "cc_show_instances" WHERE "id" = :p0'; + $sql = 'SELECT "id", "description", "starts", "ends", "show_id", "record", "rebroadcast", "instance_id", "file_id", "time_filled", "created", "last_scheduled", "modified_instance", "autoplaylist_built" FROM "cc_show_instances" WHERE "id" = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -802,6 +806,33 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria return $this->addUsingAlias(CcShowInstancesPeer::MODIFIED_INSTANCE, $dbModifiedInstance, $comparison); } + /** + * Filter the query on the autoplaylist_built column + * + * Example usage: + * + * $query->filterByDbAutoPlaylistBuilt(true); // WHERE autoplaylist_built = true + * $query->filterByDbAutoPlaylistBuilt('yes'); // WHERE autoplaylist_built = true + * + * + * @param boolean|string $dbAutoPlaylistBuilt The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbAutoPlaylistBuilt($dbAutoPlaylistBuilt = null, $comparison = null) + { + if (is_string($dbAutoPlaylistBuilt)) { + $dbAutoPlaylistBuilt = in_array(strtolower($dbAutoPlaylistBuilt), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcShowInstancesPeer::AUTOPLAYLIST_BUILT, $dbAutoPlaylistBuilt, $comparison); + } + /** * Filter the query by a related CcShow object * diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php index cac274be4..caad50713 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php @@ -24,13 +24,13 @@ abstract class BaseCcShowPeer const TM_CLASS = 'CcShowTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 14; + const NUM_COLUMNS = 16; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 14; + const NUM_HYDRATE_COLUMNS = 16; /** the column name for the id field */ const ID = 'cc_show.id'; @@ -74,6 +74,12 @@ abstract class BaseCcShowPeer /** the column name for the image_path field */ const IMAGE_PATH = 'cc_show.image_path'; + /** the column name for the has_autoplaylist field */ + const HAS_AUTOPLAYLIST = 'cc_show.has_autoplaylist'; + + /** the column name for the autoplaylist_id field */ + const AUTOPLAYLIST_ID = 'cc_show.autoplaylist_id'; + /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -93,12 +99,12 @@ abstract class BaseCcShowPeer * e.g. CcShowPeer::$fieldNames[CcShowPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', 'DbLinked', 'DbIsLinkable', 'DbImagePath', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', 'dbLinked', 'dbIsLinkable', 'dbImagePath', ), - BasePeer::TYPE_COLNAME => array (CcShowPeer::ID, CcShowPeer::NAME, CcShowPeer::URL, CcShowPeer::GENRE, CcShowPeer::DESCRIPTION, CcShowPeer::COLOR, CcShowPeer::BACKGROUND_COLOR, CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, CcShowPeer::LIVE_STREAM_USER, CcShowPeer::LIVE_STREAM_PASS, CcShowPeer::LINKED, CcShowPeer::IS_LINKABLE, CcShowPeer::IMAGE_PATH, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', 'LINKED', 'IS_LINKABLE', 'IMAGE_PATH', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', 'linked', 'is_linkable', 'image_path', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', 'DbLinked', 'DbIsLinkable', 'DbImagePath', 'DbHasAutoPlaylist', 'DbAutoPlaylistId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', 'dbLinked', 'dbIsLinkable', 'dbImagePath', 'dbHasAutoPlaylist', 'dbAutoPlaylistId', ), + BasePeer::TYPE_COLNAME => array (CcShowPeer::ID, CcShowPeer::NAME, CcShowPeer::URL, CcShowPeer::GENRE, CcShowPeer::DESCRIPTION, CcShowPeer::COLOR, CcShowPeer::BACKGROUND_COLOR, CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, CcShowPeer::LIVE_STREAM_USER, CcShowPeer::LIVE_STREAM_PASS, CcShowPeer::LINKED, CcShowPeer::IS_LINKABLE, CcShowPeer::IMAGE_PATH, CcShowPeer::HAS_AUTOPLAYLIST, CcShowPeer::AUTOPLAYLIST_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', 'LINKED', 'IS_LINKABLE', 'IMAGE_PATH', 'HAS_AUTOPLAYLIST', 'AUTOPLAYLIST_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', 'linked', 'is_linkable', 'image_path', 'has_autoplaylist', 'autoplaylist_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) ); /** @@ -108,12 +114,12 @@ abstract class BaseCcShowPeer * e.g. CcShowPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, 'DbLinked' => 11, 'DbIsLinkable' => 12, 'DbImagePath' => 13, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, 'dbLinked' => 11, 'dbIsLinkable' => 12, 'dbImagePath' => 13, ), - BasePeer::TYPE_COLNAME => array (CcShowPeer::ID => 0, CcShowPeer::NAME => 1, CcShowPeer::URL => 2, CcShowPeer::GENRE => 3, CcShowPeer::DESCRIPTION => 4, CcShowPeer::COLOR => 5, CcShowPeer::BACKGROUND_COLOR => 6, CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH => 7, CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH => 8, CcShowPeer::LIVE_STREAM_USER => 9, CcShowPeer::LIVE_STREAM_PASS => 10, CcShowPeer::LINKED => 11, CcShowPeer::IS_LINKABLE => 12, CcShowPeer::IMAGE_PATH => 13, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, 'LINKED' => 11, 'IS_LINKABLE' => 12, 'IMAGE_PATH' => 13, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, 'linked' => 11, 'is_linkable' => 12, 'image_path' => 13, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, 'DbLinked' => 11, 'DbIsLinkable' => 12, 'DbImagePath' => 13, 'DbHasAutoPlaylist' => 14, 'DbAutoPlaylistId' => 15, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, 'dbLinked' => 11, 'dbIsLinkable' => 12, 'dbImagePath' => 13, 'dbHasAutoPlaylist' => 14, 'dbAutoPlaylistId' => 15, ), + BasePeer::TYPE_COLNAME => array (CcShowPeer::ID => 0, CcShowPeer::NAME => 1, CcShowPeer::URL => 2, CcShowPeer::GENRE => 3, CcShowPeer::DESCRIPTION => 4, CcShowPeer::COLOR => 5, CcShowPeer::BACKGROUND_COLOR => 6, CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH => 7, CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH => 8, CcShowPeer::LIVE_STREAM_USER => 9, CcShowPeer::LIVE_STREAM_PASS => 10, CcShowPeer::LINKED => 11, CcShowPeer::IS_LINKABLE => 12, CcShowPeer::IMAGE_PATH => 13, CcShowPeer::HAS_AUTOPLAYLIST => 14, CcShowPeer::AUTOPLAYLIST_ID => 15, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, 'LINKED' => 11, 'IS_LINKABLE' => 12, 'IMAGE_PATH' => 13, 'HAS_AUTOPLAYLIST' => 14, 'AUTOPLAYLIST_ID' => 15, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, 'linked' => 11, 'is_linkable' => 12, 'image_path' => 13, 'has_autoplaylist' => 14, 'autoplaylist_id' => 15, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) ); /** @@ -201,6 +207,8 @@ abstract class BaseCcShowPeer $criteria->addSelectColumn(CcShowPeer::LINKED); $criteria->addSelectColumn(CcShowPeer::IS_LINKABLE); $criteria->addSelectColumn(CcShowPeer::IMAGE_PATH); + $criteria->addSelectColumn(CcShowPeer::HAS_AUTOPLAYLIST); + $criteria->addSelectColumn(CcShowPeer::AUTOPLAYLIST_ID); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.name'); @@ -216,6 +224,8 @@ abstract class BaseCcShowPeer $criteria->addSelectColumn($alias . '.linked'); $criteria->addSelectColumn($alias . '.is_linkable'); $criteria->addSelectColumn($alias . '.image_path'); + $criteria->addSelectColumn($alias . '.has_autoplaylist'); + $criteria->addSelectColumn($alias . '.autoplaylist_id'); } } @@ -528,6 +538,244 @@ abstract class BaseCcShowPeer return array($obj, $col); } + + /** + * Returns the number of rows matching criteria, joining the related CcPlaylist 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 doCountJoinCcPlaylist(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(CcShowPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowPeer::AUTOPLAYLIST_ID, CcPlaylistPeer::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 CcShow objects pre-filled with their CcPlaylist 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 CcShow objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcPlaylist(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(CcShowPeer::DATABASE_NAME); + } + + CcShowPeer::addSelectColumns($criteria); + $startcol = CcShowPeer::NUM_HYDRATE_COLUMNS; + CcPlaylistPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowPeer::AUTOPLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowPeer::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 = CcShowPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcPlaylistPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcPlaylistPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcPlaylistPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShow) to $obj2 (CcPlaylist) + $obj2->addCcShow($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(CcShowPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowPeer::AUTOPLAYLIST_ID, CcPlaylistPeer::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 CcShow 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 CcShow 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(CcShowPeer::DATABASE_NAME); + } + + CcShowPeer::addSelectColumns($criteria); + $startcol2 = CcShowPeer::NUM_HYDRATE_COLUMNS; + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcPlaylistPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowPeer::AUTOPLAYLIST_ID, CcPlaylistPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowPeer::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 = CcShowPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcPlaylist rows + + $key2 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcPlaylistPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcPlaylistPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcPlaylistPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcShow) to the collection in $obj2 (CcPlaylist) + $obj2->addCcShow($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. diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php index 08002eecc..9be314d26 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php @@ -20,6 +20,8 @@ * @method CcShowQuery orderByDbLinked($order = Criteria::ASC) Order by the linked column * @method CcShowQuery orderByDbIsLinkable($order = Criteria::ASC) Order by the is_linkable column * @method CcShowQuery orderByDbImagePath($order = Criteria::ASC) Order by the image_path column + * @method CcShowQuery orderByDbHasAutoPlaylist($order = Criteria::ASC) Order by the has_autoplaylist column + * @method CcShowQuery orderByDbAutoPlaylistId($order = Criteria::ASC) Order by the autoplaylist_id column * * @method CcShowQuery groupByDbId() Group by the id column * @method CcShowQuery groupByDbName() Group by the name column @@ -35,11 +37,17 @@ * @method CcShowQuery groupByDbLinked() Group by the linked column * @method CcShowQuery groupByDbIsLinkable() Group by the is_linkable column * @method CcShowQuery groupByDbImagePath() Group by the image_path column + * @method CcShowQuery groupByDbHasAutoPlaylist() Group by the has_autoplaylist column + * @method CcShowQuery groupByDbAutoPlaylistId() Group by the autoplaylist_id column * * @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method CcShowQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method CcShowQuery leftJoinCcPlaylist($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcPlaylist relation + * @method CcShowQuery rightJoinCcPlaylist($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcPlaylist relation + * @method CcShowQuery innerJoinCcPlaylist($relationAlias = null) Adds a INNER JOIN clause to the query using the CcPlaylist relation + * * @method CcShowQuery leftJoinCcShowInstances($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcShowInstances relation * @method CcShowQuery rightJoinCcShowInstances($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcShowInstances relation * @method CcShowQuery innerJoinCcShowInstances($relationAlias = null) Adds a INNER JOIN clause to the query using the CcShowInstances relation @@ -72,6 +80,8 @@ * @method CcShow findOneByDbLinked(boolean $linked) Return the first CcShow filtered by the linked column * @method CcShow findOneByDbIsLinkable(boolean $is_linkable) Return the first CcShow filtered by the is_linkable column * @method CcShow findOneByDbImagePath(string $image_path) Return the first CcShow filtered by the image_path column + * @method CcShow findOneByDbHasAutoPlaylist(boolean $has_autoplaylist) Return the first CcShow filtered by the has_autoplaylist column + * @method CcShow findOneByDbAutoPlaylistId(int $autoplaylist_id) Return the first CcShow filtered by the autoplaylist_id column * * @method array findByDbId(int $id) Return CcShow objects filtered by the id column * @method array findByDbName(string $name) Return CcShow objects filtered by the name column @@ -87,6 +97,8 @@ * @method array findByDbLinked(boolean $linked) Return CcShow objects filtered by the linked column * @method array findByDbIsLinkable(boolean $is_linkable) Return CcShow objects filtered by the is_linkable column * @method array findByDbImagePath(string $image_path) Return CcShow objects filtered by the image_path column + * @method array findByDbHasAutoPlaylist(boolean $has_autoplaylist) Return CcShow objects filtered by the has_autoplaylist column + * @method array findByDbAutoPlaylistId(int $autoplaylist_id) Return CcShow objects filtered by the autoplaylist_id column * * @package propel.generator.airtime.om */ @@ -194,7 +206,7 @@ abstract class BaseCcShowQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT "id", "name", "url", "genre", "description", "color", "background_color", "live_stream_using_airtime_auth", "live_stream_using_custom_auth", "live_stream_user", "live_stream_pass", "linked", "is_linkable", "image_path" FROM "cc_show" WHERE "id" = :p0'; + $sql = 'SELECT "id", "name", "url", "genre", "description", "color", "background_color", "live_stream_using_airtime_auth", "live_stream_using_custom_auth", "live_stream_user", "live_stream_pass", "linked", "is_linkable", "image_path", "has_autoplaylist", "autoplaylist_id" FROM "cc_show" WHERE "id" = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -694,6 +706,153 @@ abstract class BaseCcShowQuery extends ModelCriteria return $this->addUsingAlias(CcShowPeer::IMAGE_PATH, $dbImagePath, $comparison); } + /** + * Filter the query on the has_autoplaylist column + * + * Example usage: + * + * $query->filterByDbHasAutoPlaylist(true); // WHERE has_autoplaylist = true + * $query->filterByDbHasAutoPlaylist('yes'); // WHERE has_autoplaylist = true + * + * + * @param boolean|string $dbHasAutoPlaylist The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbHasAutoPlaylist($dbHasAutoPlaylist = null, $comparison = null) + { + if (is_string($dbHasAutoPlaylist)) { + $dbHasAutoPlaylist = in_array(strtolower($dbHasAutoPlaylist), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcShowPeer::HAS_AUTOPLAYLIST, $dbHasAutoPlaylist, $comparison); + } + + /** + * Filter the query on the autoplaylist_id column + * + * Example usage: + * + * $query->filterByDbAutoPlaylistId(1234); // WHERE autoplaylist_id = 1234 + * $query->filterByDbAutoPlaylistId(array(12, 34)); // WHERE autoplaylist_id IN (12, 34) + * $query->filterByDbAutoPlaylistId(array('min' => 12)); // WHERE autoplaylist_id >= 12 + * $query->filterByDbAutoPlaylistId(array('max' => 12)); // WHERE autoplaylist_id <= 12 + * + * + * @see filterByCcPlaylist() + * + * @param mixed $dbAutoPlaylistId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbAutoPlaylistId($dbAutoPlaylistId = null, $comparison = null) + { + if (is_array($dbAutoPlaylistId)) { + $useMinMax = false; + if (isset($dbAutoPlaylistId['min'])) { + $this->addUsingAlias(CcShowPeer::AUTOPLAYLIST_ID, $dbAutoPlaylistId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbAutoPlaylistId['max'])) { + $this->addUsingAlias(CcShowPeer::AUTOPLAYLIST_ID, $dbAutoPlaylistId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowPeer::AUTOPLAYLIST_ID, $dbAutoPlaylistId, $comparison); + } + + /** + * Filter the query by a related CcPlaylist object + * + * @param CcPlaylist|PropelObjectCollection $ccPlaylist The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlaylist($ccPlaylist, $comparison = null) + { + if ($ccPlaylist instanceof CcPlaylist) { + return $this + ->addUsingAlias(CcShowPeer::AUTOPLAYLIST_ID, $ccPlaylist->getDbId(), $comparison); + } elseif ($ccPlaylist instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowPeer::AUTOPLAYLIST_ID, $ccPlaylist->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcPlaylist() only accepts arguments of type CcPlaylist or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlaylist 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 joinCcPlaylist($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlaylist'); + + // 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, 'CcPlaylist'); + } + + return $this; + } + + /** + * Use the CcPlaylist relation CcPlaylist 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 CcPlaylistQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', 'CcPlaylistQuery'); + } + /** * Filter the query by a related CcShowInstances object * diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 8b700cd3a..f5aab77a3 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -20,6 +20,7 @@ class Application_Service_ShowFormService public function createShowForms() { $formWhat = new Application_Form_AddShowWhat(); + $formAutoPlaylist = new Application_Form_AddShowAutoPlaylist(); $formWho = new Application_Form_AddShowWho(); $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); @@ -30,6 +31,7 @@ class Application_Service_ShowFormService $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formWhat->removeDecorator('DtDdWrapper'); + $formAutoPlaylist->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper'); @@ -41,6 +43,7 @@ class Application_Service_ShowFormService $forms = array(); $forms["what"] = $formWhat; + $forms["autoplaylist"] = $formAutoPlaylist; $forms["who"] = $formWho; $forms["when"] = $formWhen; $forms["repeats"] = $formRepeats; @@ -55,10 +58,10 @@ class Application_Service_ShowFormService /** * - * Popluates the what, when, and repeat forms + * Popluates the what, autoplaylist, when, and repeat forms * with default values */ - public function populateNewShowForms($formWhat, $formWhen, $formRepeats) + public function populateNewShowForms($formWhat, $formWhen, $formRepeats) { $formWhat->populate( array('add_show_id' => '-1', @@ -93,6 +96,7 @@ class Application_Service_ShowFormService */ $forms["what"]->makeReadonly(); $forms["what"]->enableInstanceDesc(); + $forms["autoplaylist"]->disable(); $forms["repeats"]->disable(); $forms["who"]->disable(); $forms["style"]->disable(); @@ -115,6 +119,7 @@ class Application_Service_ShowFormService { $this->populateFormWhat($forms["what"]); //local show start DT + $this->populateFormAutoPlaylist($forms["autoplaylist"]); $showStart = $this->populateFormWhen($forms["when"]); $this->populateFormRepeats($forms["repeats"], $showStart); $this->populateFormWho($forms["who"]); @@ -125,10 +130,11 @@ class Application_Service_ShowFormService $this->populateFormRebroadcastAbsolute($forms["abs_rebroadcast"]); } - private function populateFormWhat($form) + private function populateFormWhat($form) { $ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId); + $form->populate( array( 'add_show_instance_id' => $this->instanceId, @@ -137,10 +143,27 @@ class Application_Service_ShowFormService 'add_show_url' => $this->ccShow->getDbUrl(), 'add_show_genre' => $this->ccShow->getDbGenre(), 'add_show_description' => $this->ccShow->getDbDescription(), - 'add_show_instance_description' => $ccShowInstance->getDbDescription())); + 'add_show_instance_description' => $ccShowInstance->getDbDescription(), + )); + } + private function populateFormAutoPlaylist($form) + { + $ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId); + + if (!$this->ccShow->getDbAutoPlaylistId()) { +// $form->disableAutoPlaylist(); + } + + $form->populate( + array( + 'add_show_has_autoplaylist' => $this->ccShow->getDbHasAutoPlaylist() ? 1 : 0, + 'add_show_autoplaylist_id' => $this->ccShow->getDbAutoPlaylistId() + + )); } - private function populateFormWhen($form) + + private function populateFormWhen($form) { if ($this->ccShow->isRepeating()) { $ccShowDay = $this->ccShow->getFirstRepeatingCcShowDay(); @@ -503,6 +526,7 @@ class Application_Service_ShowFormService $originalStartDate=null, $editShow=false, $instanceId=null) { $what = $forms["what"]->isValid($formData); + $autoplaylist = $forms["autoplaylist"]->isValid($formData); $live = $forms["live"]->isValid($formData); $record = $forms["record"]->isValid($formData); $who = $forms["who"]->isValid($formData); @@ -556,7 +580,7 @@ class Application_Service_ShowFormService } } - return ($what && $live && $record && $who && $style && $when && + return ($what && $autoplaylist && $live && $record && $who && $style && $when && $repeats && $absRebroadcast && $rebroadcast); } diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 2be14fc32..f4b28027b 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -1540,6 +1540,11 @@ SQL; $ccShow->setDbLiveStreamUsingCustomAuth($showData['cb_custom_auth'] == 1); $ccShow->setDbLiveStreamUser($showData['custom_username']); $ccShow->setDbLiveStreamPass($showData['custom_password']); + $ccShow->setDbHasAutoPlaylist($showData['add_show_has_autoplaylist'] == 1); + // added to prevent errors with insert due to a lack of data + if ($showData['add_show_autoplaylist_id'] != '') { + $ccShow->setDbAutoPlaylistId($showData['add_show_autoplaylist_id']); + } //Here a user has edited a show and linked it. //We need to grab the existing show instances ids and fill their content diff --git a/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml b/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml new file mode 100644 index 000000000..2e2c45cdf --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml @@ -0,0 +1,23 @@ +
+
+
+ +
+
+ element->getElement('add_show_has_autoplaylist') ?> +
+ +
+
+ +
+
+ element->getElement('add_show_autoplaylist_id') ?> +
+
+
+ diff --git a/airtime_mvc/application/views/scripts/form/add-show-block.phtml b/airtime_mvc/application/views/scripts/form/add-show-block.phtml index 001e0fea6..1f80164d9 100644 --- a/airtime_mvc/application/views/scripts/form/add-show-block.phtml +++ b/airtime_mvc/application/views/scripts/form/add-show-block.phtml @@ -13,3 +13,5 @@ } ?> + + diff --git a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml index 1b0396f20..82cfcd9d5 100644 --- a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml +++ b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml @@ -11,6 +11,11 @@
what; ?>
+

+
+ autoplaylist; ?> +
+

fieldset:last").hide(); @@ -291,6 +298,22 @@ function setAddShowEvents(form) { var submitButton = $(".button-bar.bottom").find(".add-show-submit"); $("[id^=add_show_instance_description]").toggle(submitButton.attr("data-action") === "edit-repeating-show-instance"); + form.find("#add_show_has_autoplaylist").click(function(){ + $(this).blur(); + form.find("#add_show_playlist_dropdown").toggle(); + + var checkBoxSelected = false; + + //must switch rebroadcast displays + if(form.find("#add_show_has_autoplaylist").attr('checked')) { + form.find("#add_show_playlist_dropdown").show(); + } + else { + form.find("#add_show_playlist_downdown").hide(); + } + }); + + form.find("#add_show_repeats").click(function(){ $(this).blur(); form.find("#schedule-show-when > fieldset:last").toggle();