diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php
index 37888c9ed..0c1911d55 100644
--- a/airtime_mvc/application/Bootstrap.php
+++ b/airtime_mvc/application/Bootstrap.php
@@ -28,6 +28,10 @@ require_once "SecurityHelper.php";
require_once "GoogleAnalytics.php";
require_once "Timezone.php";
require_once "Auth.php";
+require_once "interface/OAuth2.php";
+require_once "TaskManager.php";
+require_once __DIR__.'/services/CeleryService.php';
+require_once __DIR__.'/services/SoundcloudService.php';
require_once __DIR__.'/forms/helpers/ValidationTypes.php';
require_once __DIR__.'/forms/helpers/CustomDecorators.php';
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
@@ -123,11 +127,12 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendScript("var COMPANY_NAME = '" . COMPANY_NAME . "';");
}
- protected function _initUpgrade() {
+ protected function _initTasks() {
/* We need to wrap this here so that we aren't checking when we're running the unit test suite
*/
if (getenv("AIRTIME_UNIT_TEST") != 1) {
- UpgradeManager::checkIfUpgradeIsNeeded(); //This will do the upgrade too if it's needed...
+ //This will do the upgrade too if it's needed...
+ TaskManager::getInstance()->runTasks();
}
}
@@ -139,7 +144,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$baseUrl = Application_Common_OsPath::getBaseDir();
- $view->headLink(array('rel' => 'icon', 'href' => $baseUrl . 'favicon.ico', 'type' => 'image/x-icon'), 'PREPEND')
+ $view->headLink(array('rel' => 'icon',
+ 'href' => $baseUrl . 'favicon.ico?' . $CC_CONFIG['airtime_version'],
+ 'type' => 'image/x-icon'), 'PREPEND')
->appendStylesheet($baseUrl . 'css/bootstrap.css?' . $CC_CONFIG['airtime_version'])
->appendStylesheet($baseUrl . 'css/redmond/jquery-ui-1.8.8.custom.css?' . $CC_CONFIG['airtime_version'])
->appendStylesheet($baseUrl . 'css/pro_dropdown_3.css?' . $CC_CONFIG['airtime_version'])
diff --git a/airtime_mvc/application/common/TaskManager.php b/airtime_mvc/application/common/TaskManager.php
new file mode 100644
index 000000000..aa250f294
--- /dev/null
+++ b/airtime_mvc/application/common/TaskManager.php
@@ -0,0 +1,232 @@
+_isUserSessionRequest()) {
+ return;
+ }
+ $this->_con = Propel::getConnection(CcPrefPeer::DATABASE_NAME);
+ $this->_con->beginTransaction();
+ try {
+ $lock = $this->_getLock();
+ if ($lock && microtime(true) < $lock['valstr'] + self::TASK_INTERVAL_SECONDS) {
+ // Propel caches the database connection and uses it persistently, so if we don't
+ // use commit() here, we end up blocking other queries made within this request
+ $this->_con->commit();
+ return;
+ }
+ $this->_updateLock($lock);
+ $this->_con->commit();
+ } catch (Exception $e) {
+ // We get here if there are simultaneous requests trying to fetch the lock row
+ $this->_con->rollBack();
+ // Logging::info($e->getMessage()); // We actually get here a lot, so it's
+ // better to be silent here to avoid log bloat
+ return;
+ }
+ foreach ($this->_taskList as $task) {
+ $task = TaskFactory::getTask($task);
+ if ($task && $task->shouldBeRun()) {
+ $task->run();
+ }
+ }
+ }
+
+ /**
+ * Check if the current session is a user request
+ *
+ * @return bool true if there is a Zend_Auth object in the current session,
+ * otherwise false
+ */
+ private function _isUserSessionRequest() {
+ $auth = Zend_Auth::getInstance();
+ $data = $auth->getStorage()->read();
+ return !empty($data);
+ }
+
+ /**
+ * Get the task_manager_lock from cc_pref with a row-level lock for atomicity
+ *
+ * The lock is exclusive (prevent reads) and will only last for the duration
+ * of the transaction. We add NOWAIT so reads on the row during the transaction
+ * won't block
+ *
+ * @return array|bool an array containing the row values, or false on failure
+ */
+ private function _getLock() {
+ $sql = "SELECT * FROM cc_pref WHERE keystr='task_manager_lock' LIMIT 1 FOR UPDATE NOWAIT";
+ $st = $this->_con->prepare($sql);
+ $st->execute();
+ return $st->fetch();
+ }
+
+ /**
+ * Update and commit the new lock value, or insert it if it doesn't exist
+ *
+ * @param $lock array cc_pref lock row values
+ */
+ private function _updateLock($lock) {
+ $sql = empty($lock) ? "INSERT INTO cc_pref (keystr, valstr) VALUES ('task_manager_lock', :value)"
+ : "UPDATE cc_pref SET valstr=:value WHERE keystr='task_manager_lock'";
+ $st = $this->_con->prepare($sql);
+ $st->execute(array(":value" => microtime(true)));
+ }
+
+}
+
+/**
+ * Interface AirtimeTask Interface for task operations - also acts as task type ENUM
+ */
+interface AirtimeTask {
+
+ /**
+ * PHP doesn't have ENUMs so declare them as interface constants
+ * Task types - values don't really matter as long as they're unique
+ */
+
+ const UPGRADE = "upgrade";
+ const CELERY = "celery";
+
+ /**
+ * Check whether the task should be run
+ *
+ * @return bool true if the task needs to be run, otherwise false
+ */
+ public function shouldBeRun();
+
+ /**
+ * Run the task
+ *
+ * @return void
+ */
+ public function run();
+
+}
+
+/**
+ * Class TaskFactory Factory class to abstract task instantiation
+ */
+class TaskFactory {
+
+ /**
+ * Get an AirtimeTask based on a task type
+ *
+ * @param $task string the task type; uses AirtimeTask constants as an ENUM
+ *
+ * @return AirtimeTask|null return a task of the given type or null if no corresponding
+ * task exists or is implemented
+ */
+ public static function getTask($task) {
+ switch($task) {
+ case AirtimeTask::UPGRADE:
+ return new UpgradeTask();
+ case AirtimeTask::CELERY:
+ return new CeleryTask();
+ }
+ return null;
+ }
+
+}
+
+/**
+ * Class UpgradeTask
+ */
+class UpgradeTask implements AirtimeTask {
+
+ /**
+ * Check the current Airtime schema version to see if an upgrade should be run
+ *
+ * @return bool true if an upgrade is needed
+ */
+ public function shouldBeRun() {
+ return UpgradeManager::checkIfUpgradeIsNeeded();
+ }
+
+ /**
+ * Run all upgrades above the current schema version
+ */
+ public function run() {
+ UpgradeManager::doUpgrade();
+ }
+
+}
+
+/**
+ * Class CeleryTask
+ */
+class CeleryTask implements AirtimeTask {
+
+ /**
+ * Check the ThirdPartyTrackReferences table to see if there are any pending tasks
+ *
+ * @return bool true if there are pending tasks in ThirdPartyTrackReferences
+ */
+ public function shouldBeRun() {
+ return !CeleryService::isBrokerTaskQueueEmpty();
+ }
+
+ /**
+ * Poll the task queue for any completed Celery tasks
+ */
+ public function run() {
+ CeleryService::pollBrokerTaskQueue();
+ }
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/common/interface/OAuth2.php b/airtime_mvc/application/common/interface/OAuth2.php
new file mode 100644
index 000000000..28283c8e8
--- /dev/null
+++ b/airtime_mvc/application/common/interface/OAuth2.php
@@ -0,0 +1,31 @@
+add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('billing'))
->add(new Zend_Acl_Resource('thank-you'))
->add(new Zend_Acl_Resource('provisioning'))
+ ->add(new Zend_Acl_Resource('player'))
+ ->add(new Zend_Acl_Resource('soundcloud'))
->add(new Zend_Acl_Resource('embeddablewidgets'));
/** Creating permissions */
@@ -57,8 +59,9 @@ $ccAcl->allow('G', 'index')
->allow('G', 'provisioning')
->allow('G', 'downgrade')
->allow('G', 'rest:show-image', 'get')
- ->allow('H', 'rest:show-image')
->allow('G', 'rest:media', 'get')
+ ->allow('H', 'soundcloud')
+ ->allow('H', 'rest:show-image')
->allow('H', 'rest:media')
->allow('H', 'preference', 'is-import-in-progress')
->allow('H', 'usersettings')
@@ -71,6 +74,7 @@ $ccAcl->allow('G', 'index')
->allow('A', 'user')
->allow('A', 'systemstatus')
->allow('A', 'preference')
+ ->allow('A', 'player')
->allow('A', 'embeddablewidgets')
->allow('S', 'thank-you')
->allow('S', 'billing');
diff --git a/airtime_mvc/application/configs/airtime-conf.php b/airtime_mvc/application/configs/airtime-conf.php
index b23a37334..ad939b2ce 100644
--- a/airtime_mvc/application/configs/airtime-conf.php
+++ b/airtime_mvc/application/configs/airtime-conf.php
@@ -1,6 +1,6 @@
array (
diff --git a/airtime_mvc/application/configs/classmap-airtime-conf.php b/airtime_mvc/application/configs/classmap-airtime-conf.php
index 814429f76..671726a17 100644
--- a/airtime_mvc/application/configs/classmap-airtime-conf.php
+++ b/airtime_mvc/application/configs/classmap-airtime-conf.php
@@ -100,9 +100,15 @@ return array (
'BaseCcWebstreamMetadataQuery' => 'airtime/om/BaseCcWebstreamMetadataQuery.php',
'BaseCcWebstreamPeer' => 'airtime/om/BaseCcWebstreamPeer.php',
'BaseCcWebstreamQuery' => 'airtime/om/BaseCcWebstreamQuery.php',
+ 'BaseCeleryTasks' => 'airtime/om/BaseCeleryTasks.php',
+ 'BaseCeleryTasksPeer' => 'airtime/om/BaseCeleryTasksPeer.php',
+ 'BaseCeleryTasksQuery' => 'airtime/om/BaseCeleryTasksQuery.php',
'BaseCloudFile' => 'airtime/om/BaseCloudFile.php',
'BaseCloudFilePeer' => 'airtime/om/BaseCloudFilePeer.php',
'BaseCloudFileQuery' => 'airtime/om/BaseCloudFileQuery.php',
+ 'BaseThirdPartyTrackReferences' => 'airtime/om/BaseThirdPartyTrackReferences.php',
+ 'BaseThirdPartyTrackReferencesPeer' => 'airtime/om/BaseThirdPartyTrackReferencesPeer.php',
+ 'BaseThirdPartyTrackReferencesQuery' => 'airtime/om/BaseThirdPartyTrackReferencesQuery.php',
'CcBlock' => 'airtime/CcBlock.php',
'CcBlockPeer' => 'airtime/CcBlockPeer.php',
'CcBlockQuery' => 'airtime/CcBlockQuery.php',
@@ -235,8 +241,16 @@ return array (
'CcWebstreamPeer' => 'airtime/CcWebstreamPeer.php',
'CcWebstreamQuery' => 'airtime/CcWebstreamQuery.php',
'CcWebstreamTableMap' => 'airtime/map/CcWebstreamTableMap.php',
+ 'CeleryTasks' => 'airtime/CeleryTasks.php',
+ 'CeleryTasksPeer' => 'airtime/CeleryTasksPeer.php',
+ 'CeleryTasksQuery' => 'airtime/CeleryTasksQuery.php',
+ 'CeleryTasksTableMap' => 'airtime/map/CeleryTasksTableMap.php',
'CloudFile' => 'airtime/CloudFile.php',
'CloudFilePeer' => 'airtime/CloudFilePeer.php',
'CloudFileQuery' => 'airtime/CloudFileQuery.php',
'CloudFileTableMap' => 'airtime/map/CloudFileTableMap.php',
+ 'ThirdPartyTrackReferences' => 'airtime/ThirdPartyTrackReferences.php',
+ 'ThirdPartyTrackReferencesPeer' => 'airtime/ThirdPartyTrackReferencesPeer.php',
+ 'ThirdPartyTrackReferencesQuery' => 'airtime/ThirdPartyTrackReferencesQuery.php',
+ 'ThirdPartyTrackReferencesTableMap' => 'airtime/map/ThirdPartyTrackReferencesTableMap.php',
);
\ No newline at end of file
diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php
index 5b11c30c8..00af3e337 100644
--- a/airtime_mvc/application/configs/conf.php
+++ b/airtime_mvc/application/configs/conf.php
@@ -35,6 +35,8 @@ class Config {
$CC_CONFIG['baseDir'] = $values['general']['base_dir'];
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
$CC_CONFIG['basePort'] = $values['general']['base_port'];
+ $CC_CONFIG['stationId'] = $values['general']['station_id'];
+ $CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
if (isset($values['general']['dev_env'])) {
$CC_CONFIG['dev_env'] = $values['general']['dev_env'];
} else {
@@ -83,7 +85,18 @@ class Config {
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
-
+
+ $globalAirtimeConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/airtime.conf";
+ if (!file_exists($globalAirtimeConfig)) {
+ // If the dev env specific airtime.conf doesn't exist default
+ // to the production airtime.conf
+ $globalAirtimeConfig = "/etc/airtime-saas/production/airtime.conf";
+ }
+ $globalAirtimeConfigValues = parse_ini_file($globalAirtimeConfig, true);
+ $CC_CONFIG['soundcloud-client-id'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_id'];
+ $CC_CONFIG['soundcloud-client-secret'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_secret'];
+ $CC_CONFIG['soundcloud-redirect-uri'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_redirect_uri'];
+
if(isset($values['demo']['demo'])){
$CC_CONFIG['demo'] = $values['demo']['demo'];
}
diff --git a/airtime_mvc/application/configs/config-check.php b/airtime_mvc/application/configs/config-check.php
index 9cfb9927b..5ddf73295 100644
--- a/airtime_mvc/application/configs/config-check.php
+++ b/airtime_mvc/application/configs/config-check.php
@@ -7,17 +7,17 @@
* along with steps to fix them if they're not found or misconfigured.
*/
-$phpDependencies = checkPhpDependencies();
-$externalServices = checkExternalServices();
-$zend = $phpDependencies["zend"];
-$postgres = $phpDependencies["postgres"];
+$phpDependencies = checkPhpDependencies();
+$externalServices = checkExternalServices();
+$zend = $phpDependencies["zend"];
+$postgres = $phpDependencies["postgres"];
-$database = $externalServices["database"];
-$rabbitmq = $externalServices["rabbitmq"];
+$database = $externalServices["database"];
+$rabbitmq = $externalServices["rabbitmq"];
-$pypo = $externalServices["pypo"];
-$liquidsoap = $externalServices["liquidsoap"];
-$mediamonitor = $externalServices["media-monitor"];
+$pypo = $externalServices["pypo"];
+$liquidsoap = $externalServices["liquidsoap"];
+$analyzer = $externalServices["analyzer"];
$r1 = array_reduce($phpDependencies, "booleanReduce", true);
$r2 = array_reduce($externalServices, "booleanReduce", true);
@@ -174,28 +174,27 @@ $result = $r1 && $r2;
Make sure RabbitMQ is installed correctly, and that your settings in /etc/airtime/airtime.conf
are correct. Try using sudo rabbitmqctl list_users
and sudo rabbitmqctl list_vhosts
to see if the airtime user (or your custom RabbitMQ user) exists, then checking that
- sudo rabbitmqctl list_exchanges
contains entries for airtime-media-monitor, airtime-pypo,
- and airtime-uploads.
+ sudo rabbitmqctl list_exchanges
contains entries for airtime-pypo and airtime-uploads.
-
/etc/init
,
+ Check that the airtime_analyzer service is installed correctly in /etc/init.d
,
and ensure that it's running with
- initctl list | grep airtime-media-monitor
sudo service airtime-media-monitor start
+ initctl list | grep airtime_analyzer
sudo service airtime_analyzer start
@@ -212,7 +211,7 @@ $result = $r1 && $r2;
">
- Check that the airtime-playout service is installed correctly in /etc/init
,
+ Check that the airtime-playout service is installed correctly in /etc/init.d
,
and ensure that it's running with
initctl list | grep airtime-playout
sudo service airtime-playout restart
@@ -232,7 +231,7 @@ $result = $r1 && $r2;
">
- Check that the airtime-liquidsoap service is installed correctly in /etc/init
,
+ Check that the airtime-liquidsoap service is installed correctly in /etc/init.d
,
and ensure that it's running with
initctl list | grep airtime-liquidsoap
sudo service airtime-liquidsoap restart
diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php
index c6a51ef00..4360cd9e7 100644
--- a/airtime_mvc/application/configs/constants.php
+++ b/airtime_mvc/application/configs/constants.php
@@ -10,7 +10,6 @@ define('COMPANY_SUFFIX' , 'z.รบ.');
define('COMPANY_SITE' , 'Sourcefabric.org');
define('COMPANY_SITE_URL' , 'http://sourcefabric.org/');
-
define('HELP_URL' , 'http://help.sourcefabric.org/');
define('FAQ_URL' , 'https://sourcefabricberlin.zendesk.com/hc/en-us/sections/200994309-Airtime-FAQ');
define('WHOS_USING_URL' , 'http://sourcefabric.org/en/airtime/whosusing');
@@ -88,13 +87,6 @@ define('UI_PLAYLISTCONTROLLER_OBJ_SESSNAME', 'PLAYLISTCONTROLLER_OBJ');
/*define('UI_PLAYLIST_SESSNAME', 'PLAYLIST');
define('UI_BLOCK_SESSNAME', 'BLOCK');*/
-
-// Soundcloud contants
-define('SOUNDCLOUD_NOT_UPLOADED_YET' , -1);
-define('SOUNDCLOUD_PROGRESS' , -2);
-define('SOUNDCLOUD_ERROR' , -3);
-
-
//WHMCS integration
define("WHMCS_API_URL", "https://account.sourcefabric.com/includes/api.php");
define("SUBDOMAIN_WHMCS_CUSTOM_FIELD_NAME", "Choose your domain");
@@ -107,4 +99,16 @@ define('PROVISIONING_STATUS_SUSPENDED' , 'Suspended');
define('PROVISIONING_STATUS_ACTIVE' , 'Active');
//TuneIn integration
-define("TUNEIN_API_URL", "http://air.radiotime.com/Playing.ashx");
\ No newline at end of file
+define("TUNEIN_API_URL", "http://air.radiotime.com/Playing.ashx");
+
+// SoundCloud
+define('DEFAULT_SOUNDCLOUD_LICENSE_TYPE', 'all-rights-reserved');
+define('DEFAULT_SOUNDCLOUD_SHARING_TYPE', 'public');
+
+// Celery
+define('CELERY_PENDING_STATUS', 'PENDING');
+define('CELERY_SUCCESS_STATUS', 'SUCCESS');
+define('CELERY_FAILED_STATUS', 'FAILED');
+
+// Celery Services
+define('SOUNDCLOUD_SERVICE_NAME', 'soundcloud');
diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php
index 955d2e356..60b1e186b 100644
--- a/airtime_mvc/application/controllers/ApiController.php
+++ b/airtime_mvc/application/controllers/ApiController.php
@@ -648,11 +648,6 @@ class ApiController extends Zend_Controller_Action
// fields
$file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder");
$file->setMetadataValue('MDATA_KEY_TRACKNUMBER', $show_instance_id);
-
- if (!$showCanceled && Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud()) {
- $id = $file->getId();
- Application_Model_Soundcloud::uploadSoundcloud($id);
- }
}
public function mediaMonitorSetupAction()
diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php
index 00b8f84fe..2ad032973 100644
--- a/airtime_mvc/application/controllers/LibraryController.php
+++ b/airtime_mvc/application/controllers/LibraryController.php
@@ -265,29 +265,38 @@ class LibraryController extends Zend_Controller_Action
}
}
- //SOUNDCLOUD MENU OPTIONS
- if ($type === "audioclip" && Application_Model_Preference::GetUploadToSoundcloudOption()) {
+ // SOUNDCLOUD MENU OPTION
+ $ownerId = empty($obj) ? $file->getFileOwnerId() : $obj->getCreatorId();
+ if ($isAdminOrPM || $ownerId == $user->getId()) {
+ $soundcloudService = new SoundcloudService();
+ if ($type === "audioclip" && $soundcloudService->hasAccessToken()) {
- //create a menu separator
- $menu["sep1"] = "-----------";
+ //create a menu separator
+ $menu["sep1"] = "-----------";
- //create a sub menu for Soundcloud actions.
- $menu["soundcloud"] = array("name" => _("Soundcloud"), "icon" => "soundcloud", "items" => array());
+ //create a sub menu for Soundcloud actions.
+ $menu["soundcloud"] = array("name" => _("Soundcloud"), "icon" => "soundcloud", "items" => array());
- $scid = $file->getSoundCloudId();
-
- if ($scid > 0) {
- $url = $file->getSoundCloudLinkToFile();
- $menu["soundcloud"]["items"]["view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $url);
+ $serviceId = $soundcloudService->getServiceId($id);
+ if (!is_null($file) && $serviceId != 0) {
+ $menu["soundcloud"]["items"]["view"] = array("name" => _("View track"), "icon" => "soundcloud", "url" => $baseUrl . "soundcloud/view-on-sound-cloud/id/{$id}");
+ $menu["soundcloud"]["items"]["remove"] = array("name" => _("Remove track"), "icon" => "soundcloud", "url" => $baseUrl . "soundcloud/delete/id/{$id}");
+ } else {
+ // If a reference exists for this file ID, that means the user has uploaded the track
+ // but we haven't yet gotten a response from Celery, so disable the menu item
+ if ($soundcloudService->referenceExists($id)) {
+ $menu["soundcloud"]["items"]["upload"] = array(
+ "name" => _("Upload track"), "icon" => "soundcloud",
+ "url" => $baseUrl . "soundcloud/upload/id/{$id}", "disabled" => true
+ );
+ } else {
+ $menu["soundcloud"]["items"]["upload"] = array(
+ "name" => _("Upload track"), "icon" => "soundcloud",
+ "url" => $baseUrl . "soundcloud/upload/id/{$id}"
+ );
+ }
+ }
}
-
- if (!is_null($scid)) {
- $text = _("Re-upload to SoundCloud");
- } else {
- $text = _("Upload to SoundCloud");
- }
-
- $menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => $baseUrl."library/upload-file-soundcloud/id/{$id}");
}
if (empty($menu)) {
@@ -525,33 +534,4 @@ class LibraryController extends Zend_Controller_Action
Logging::info($e->getMessage());
}
}
-
- public function uploadFileSoundcloudAction()
- {
- $id = $this->_getParam('id');
- Application_Model_Soundcloud::uploadSoundcloud($id);
- // we should die with ui info
- $this->_helper->json->sendJson(null);
- }
-
- public function getUploadToSoundcloudStatusAction()
- {
- $id = $this->_getParam('id');
- $type = $this->_getParam('type');
-
- if ($type == "show") {
- $show_instance = new Application_Model_ShowInstance($id);
- $this->view->sc_id = $show_instance->getSoundCloudFileId();
- $file = $show_instance->getRecordedFile();
- $this->view->error_code = $file->getSoundCloudErrorCode();
- $this->view->error_msg = $file->getSoundCloudErrorMsg();
- } elseif ($type == "file") {
- $file = Application_Model_StoredFile::RecallById($id);
- $this->view->sc_id = $file->getSoundCloudId();
- $this->view->error_code = $file->getSoundCloudErrorCode();
- $this->view->error_msg = $file->getSoundCloudErrorMsg();
- } else {
- Logging::warn("Trying to upload unknown type: $type with id: $id");
- }
- }
}
diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php
index d705af955..5803d3223 100644
--- a/airtime_mvc/application/controllers/PreferenceController.php
+++ b/airtime_mvc/application/controllers/PreferenceController.php
@@ -62,14 +62,9 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::setTuneinPartnerKey($values["tunein_partner_key"]);
Application_Model_Preference::setTuneinPartnerId($values["tunein_partner_id"]);
- /*Application_Model_Preference::SetUploadToSoundcloudOption($values["UploadToSoundcloudOption"]);
- Application_Model_Preference::SetSoundCloudDownloadbleOption($values["SoundCloudDownloadbleOption"]);
- Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
- Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
- Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
- Application_Model_Preference::SetSoundCloudGenre($values["SoundCloudGenre"]);
- Application_Model_Preference::SetSoundCloudTrackType($values["SoundCloudTrackType"]);
- Application_Model_Preference::SetSoundCloudLicense($values["SoundCloudLicense"]);*/
+ // SoundCloud Preferences
+ Application_Model_Preference::setDefaultSoundCloudLicenseType($values["SoundCloudLicense"]);
+ Application_Model_Preference::setDefaultSoundCloudSharingType($values["SoundCloudSharing"]);
$this->view->statusMsg = "true
is returned; otherwise
+ * an aggregated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true
if all validations pass; array of ValidationFailed
objects otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aThirdPartyTrackReferences !== null) {
+ if (!$this->aThirdPartyTrackReferences->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aThirdPartyTrackReferences->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = CeleryTasksPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CeleryTasksPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getDbId();
+ break;
+ case 1:
+ return $this->getDbTaskId();
+ break;
+ case 2:
+ return $this->getDbTrackReference();
+ break;
+ case 3:
+ return $this->getDbName();
+ break;
+ case 4:
+ return $this->getDbDispatchTime();
+ break;
+ case 5:
+ return $this->getDbStatus();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CeleryTasks'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CeleryTasks'][$this->getPrimaryKey()] = true;
+ $keys = CeleryTasksPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getDbId(),
+ $keys[1] => $this->getDbTaskId(),
+ $keys[2] => $this->getDbTrackReference(),
+ $keys[3] => $this->getDbName(),
+ $keys[4] => $this->getDbDispatchTime(),
+ $keys[5] => $this->getDbStatus(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aThirdPartyTrackReferences) {
+ $result['ThirdPartyTrackReferences'] = $this->aThirdPartyTrackReferences->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CeleryTasksPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setDbId($value);
+ break;
+ case 1:
+ $this->setDbTaskId($value);
+ break;
+ case 2:
+ $this->setDbTrackReference($value);
+ break;
+ case 3:
+ $this->setDbName($value);
+ break;
+ case 4:
+ $this->setDbDispatchTime($value);
+ break;
+ case 5:
+ $this->setDbStatus($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CeleryTasksPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setDbTaskId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setDbTrackReference($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDbName($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDbDispatchTime($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setDbStatus($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CeleryTasksPeer::ID)) $criteria->add(CeleryTasksPeer::ID, $this->id);
+ if ($this->isColumnModified(CeleryTasksPeer::TASK_ID)) $criteria->add(CeleryTasksPeer::TASK_ID, $this->task_id);
+ if ($this->isColumnModified(CeleryTasksPeer::TRACK_REFERENCE)) $criteria->add(CeleryTasksPeer::TRACK_REFERENCE, $this->track_reference);
+ if ($this->isColumnModified(CeleryTasksPeer::NAME)) $criteria->add(CeleryTasksPeer::NAME, $this->name);
+ if ($this->isColumnModified(CeleryTasksPeer::DISPATCH_TIME)) $criteria->add(CeleryTasksPeer::DISPATCH_TIME, $this->dispatch_time);
+ if ($this->isColumnModified(CeleryTasksPeer::STATUS)) $criteria->add(CeleryTasksPeer::STATUS, $this->status);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getDbId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setDbId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getDbId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CeleryTasks (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setDbTaskId($this->getDbTaskId());
+ $copyObj->setDbTrackReference($this->getDbTrackReference());
+ $copyObj->setDbName($this->getDbName());
+ $copyObj->setDbDispatchTime($this->getDbDispatchTime());
+ $copyObj->setDbStatus($this->getDbStatus());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CeleryTasks Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CeleryTasksPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CeleryTasksPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a ThirdPartyTrackReferences object.
+ *
+ * @param ThirdPartyTrackReferences $v
+ * @return CeleryTasks The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setThirdPartyTrackReferences(ThirdPartyTrackReferences $v = null)
+ {
+ if ($v === null) {
+ $this->setDbTrackReference(NULL);
+ } else {
+ $this->setDbTrackReference($v->getDbId());
+ }
+
+ $this->aThirdPartyTrackReferences = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ThirdPartyTrackReferences object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCeleryTasks($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ThirdPartyTrackReferences object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @param $doQuery Executes a query to get the object if required
+ * @return ThirdPartyTrackReferences The associated ThirdPartyTrackReferences object.
+ * @throws PropelException
+ */
+ public function getThirdPartyTrackReferences(PropelPDO $con = null, $doQuery = true)
+ {
+ if ($this->aThirdPartyTrackReferences === null && ($this->track_reference !== null) && $doQuery) {
+ $this->aThirdPartyTrackReferences = ThirdPartyTrackReferencesQuery::create()->findPk($this->track_reference, $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->aThirdPartyTrackReferences->addCeleryTaskss($this);
+ */
+ }
+
+ return $this->aThirdPartyTrackReferences;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->task_id = null;
+ $this->track_reference = null;
+ $this->name = null;
+ $this->dispatch_time = null;
+ $this->status = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->alreadyInClearAllReferencesDeep = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep && !$this->alreadyInClearAllReferencesDeep) {
+ $this->alreadyInClearAllReferencesDeep = true;
+ if ($this->aThirdPartyTrackReferences instanceof Persistent) {
+ $this->aThirdPartyTrackReferences->clearAllReferences($deep);
+ }
+
+ $this->alreadyInClearAllReferencesDeep = false;
+ } // if ($deep)
+
+ $this->aThirdPartyTrackReferences = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CeleryTasksPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/airtime_mvc/application/models/airtime/om/BaseCeleryTasksPeer.php b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksPeer.php
new file mode 100644
index 000000000..b6dff77b4
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksPeer.php
@@ -0,0 +1,1019 @@
+ array ('DbId', 'DbTaskId', 'DbTrackReference', 'DbName', 'DbDispatchTime', 'DbStatus', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTaskId', 'dbTrackReference', 'dbName', 'dbDispatchTime', 'dbStatus', ),
+ BasePeer::TYPE_COLNAME => array (CeleryTasksPeer::ID, CeleryTasksPeer::TASK_ID, CeleryTasksPeer::TRACK_REFERENCE, CeleryTasksPeer::NAME, CeleryTasksPeer::DISPATCH_TIME, CeleryTasksPeer::STATUS, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TASK_ID', 'TRACK_REFERENCE', 'NAME', 'DISPATCH_TIME', 'STATUS', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'task_id', 'track_reference', 'name', 'dispatch_time', 'status', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CeleryTasksPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTaskId' => 1, 'DbTrackReference' => 2, 'DbName' => 3, 'DbDispatchTime' => 4, 'DbStatus' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTaskId' => 1, 'dbTrackReference' => 2, 'dbName' => 3, 'dbDispatchTime' => 4, 'dbStatus' => 5, ),
+ BasePeer::TYPE_COLNAME => array (CeleryTasksPeer::ID => 0, CeleryTasksPeer::TASK_ID => 1, CeleryTasksPeer::TRACK_REFERENCE => 2, CeleryTasksPeer::NAME => 3, CeleryTasksPeer::DISPATCH_TIME => 4, CeleryTasksPeer::STATUS => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TASK_ID' => 1, 'TRACK_REFERENCE' => 2, 'NAME' => 3, 'DISPATCH_TIME' => 4, 'STATUS' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'task_id' => 1, 'track_reference' => 2, 'name' => 3, 'dispatch_time' => 4, 'status' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CeleryTasksPeer::getFieldNames($toType);
+ $key = isset(CeleryTasksPeer::$fieldKeys[$fromType][$name]) ? CeleryTasksPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CeleryTasksPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CeleryTasksPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CeleryTasksPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CeleryTasksPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CeleryTasksPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CeleryTasksPeer::ID);
+ $criteria->addSelectColumn(CeleryTasksPeer::TASK_ID);
+ $criteria->addSelectColumn(CeleryTasksPeer::TRACK_REFERENCE);
+ $criteria->addSelectColumn(CeleryTasksPeer::NAME);
+ $criteria->addSelectColumn(CeleryTasksPeer::DISPATCH_TIME);
+ $criteria->addSelectColumn(CeleryTasksPeer::STATUS);
+ } else {
+ $criteria->addSelectColumn($alias . '.id');
+ $criteria->addSelectColumn($alias . '.task_id');
+ $criteria->addSelectColumn($alias . '.track_reference');
+ $criteria->addSelectColumn($alias . '.name');
+ $criteria->addSelectColumn($alias . '.dispatch_time');
+ $criteria->addSelectColumn($alias . '.status');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CeleryTasksPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+ /**
+ * Selects one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CeleryTasks
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CeleryTasksPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CeleryTasksPeer::populateObjects(CeleryTasksPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement directly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CeleryTasks $obj A CeleryTasks object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getDbId();
+ } // if key === null
+ CeleryTasksPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CeleryTasks object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CeleryTasks) {
+ $key = (string) $value->getDbId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CeleryTasks object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CeleryTasksPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CeleryTasks Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CeleryTasksPeer::$instances[$key])) {
+ return CeleryTasksPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool($and_clear_all_references = false)
+ {
+ if ($and_clear_all_references) {
+ foreach (CeleryTasksPeer::$instances as $instance) {
+ $instance->clearAllReferences(true);
+ }
+ }
+ CeleryTasksPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to celery_tasks
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CeleryTasksPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CeleryTasksPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CeleryTasksPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CeleryTasks object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CeleryTasksPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CeleryTasksPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CeleryTasksPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CeleryTasksPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related ThirdPartyTrackReferences 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 doCountJoinThirdPartyTrackReferences(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(CeleryTasksPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::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 CeleryTasks objects pre-filled with their ThirdPartyTrackReferences 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 CeleryTasks objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinThirdPartyTrackReferences(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(CeleryTasksPeer::DATABASE_NAME);
+ }
+
+ CeleryTasksPeer::addSelectColumns($criteria);
+ $startcol = CeleryTasksPeer::NUM_HYDRATE_COLUMNS;
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CeleryTasksPeer::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 = CeleryTasksPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CeleryTasksPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ThirdPartyTrackReferencesPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ThirdPartyTrackReferencesPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CeleryTasks) to $obj2 (ThirdPartyTrackReferences)
+ $obj2->addCeleryTasks($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(CeleryTasksPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::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 CeleryTasks 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 CeleryTasks 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(CeleryTasksPeer::DATABASE_NAME);
+ }
+
+ CeleryTasksPeer::addSelectColumns($criteria);
+ $startcol2 = CeleryTasksPeer::NUM_HYDRATE_COLUMNS;
+
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CeleryTasksPeer::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 = CeleryTasksPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CeleryTasksPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined ThirdPartyTrackReferences rows
+
+ $key2 = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ThirdPartyTrackReferencesPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ThirdPartyTrackReferencesPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CeleryTasks) to the collection in $obj2 (ThirdPartyTrackReferences)
+ $obj2->addCeleryTasks($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CeleryTasksPeer::DATABASE_NAME)->getTable(CeleryTasksPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCeleryTasksPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCeleryTasksPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new \CeleryTasksTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass($row = 0, $colnum = 0)
+ {
+ return CeleryTasksPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CeleryTasks or Criteria object.
+ *
+ * @param mixed $values Criteria or CeleryTasks object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CeleryTasks object
+ }
+
+ if ($criteria->containsKey(CeleryTasksPeer::ID) && $criteria->keyContainsValue(CeleryTasksPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CeleryTasksPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CeleryTasks or Criteria object.
+ *
+ * @param mixed $values Criteria or CeleryTasks object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CeleryTasksPeer::ID);
+ $value = $criteria->remove(CeleryTasksPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CeleryTasksPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CeleryTasksPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CeleryTasks object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the celery_tasks table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CeleryTasksPeer::TABLE_NAME, $con, CeleryTasksPeer::DATABASE_NAME);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CeleryTasksPeer::clearInstancePool();
+ CeleryTasksPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CeleryTasks or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CeleryTasks object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CeleryTasksPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof CeleryTasks) { // it's a model object
+ // invalidate the cache for this single object
+ CeleryTasksPeer::removeInstanceFromPool($values);
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CeleryTasksPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CeleryTasksPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CeleryTasks object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CeleryTasks $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CeleryTasksPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CeleryTasksPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CeleryTasksPeer::DATABASE_NAME, CeleryTasksPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CeleryTasks
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CeleryTasksPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, $pk);
+
+ $v = CeleryTasksPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CeleryTasks[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, $pks, Criteria::IN);
+ $objs = CeleryTasksPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCeleryTasksPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCeleryTasksPeer::buildTableMap();
+
diff --git a/airtime_mvc/application/models/airtime/om/BaseCeleryTasksQuery.php b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksQuery.php
new file mode 100644
index 000000000..9d25080d0
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksQuery.php
@@ -0,0 +1,550 @@
+mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CeleryTasks|CeleryTasks[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CeleryTasksPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Alias of findPk to use instance pooling
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CeleryTasks A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ public function findOneByDbId($key, $con = null)
+ {
+ return $this->findPk($key, $con);
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CeleryTasks A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT "id", "task_id", "track_reference", "name", "dispatch_time", "status" FROM "celery_tasks" WHERE "id" = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CeleryTasks();
+ $obj->hydrate($row);
+ CeleryTasksPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CeleryTasks|CeleryTasks[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CeleryTasks[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CeleryTasksPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CeleryTasksPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbId(1234); // WHERE id = 1234
+ * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12
+ * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12
+ *
+ *
+ * @param mixed $dbId 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 CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbId($dbId = null, $comparison = null)
+ {
+ if (is_array($dbId)) {
+ $useMinMax = false;
+ if (isset($dbId['min'])) {
+ $this->addUsingAlias(CeleryTasksPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbId['max'])) {
+ $this->addUsingAlias(CeleryTasksPeer::ID, $dbId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::ID, $dbId, $comparison);
+ }
+
+ /**
+ * Filter the query on the task_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbTaskId('fooValue'); // WHERE task_id = 'fooValue'
+ * $query->filterByDbTaskId('%fooValue%'); // WHERE task_id LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbTaskId The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbTaskId($dbTaskId = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbTaskId)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbTaskId)) {
+ $dbTaskId = str_replace('*', '%', $dbTaskId);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::TASK_ID, $dbTaskId, $comparison);
+ }
+
+ /**
+ * Filter the query on the track_reference column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbTrackReference(1234); // WHERE track_reference = 1234
+ * $query->filterByDbTrackReference(array(12, 34)); // WHERE track_reference IN (12, 34)
+ * $query->filterByDbTrackReference(array('min' => 12)); // WHERE track_reference >= 12
+ * $query->filterByDbTrackReference(array('max' => 12)); // WHERE track_reference <= 12
+ *
+ *
+ * @see filterByThirdPartyTrackReferences()
+ *
+ * @param mixed $dbTrackReference 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 CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbTrackReference($dbTrackReference = null, $comparison = null)
+ {
+ if (is_array($dbTrackReference)) {
+ $useMinMax = false;
+ if (isset($dbTrackReference['min'])) {
+ $this->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $dbTrackReference['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbTrackReference['max'])) {
+ $this->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $dbTrackReference['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $dbTrackReference, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbName The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbName($dbName = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbName)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbName)) {
+ $dbName = str_replace('*', '%', $dbName);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::NAME, $dbName, $comparison);
+ }
+
+ /**
+ * Filter the query on the dispatch_time column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbDispatchTime('2011-03-14'); // WHERE dispatch_time = '2011-03-14'
+ * $query->filterByDbDispatchTime('now'); // WHERE dispatch_time = '2011-03-14'
+ * $query->filterByDbDispatchTime(array('max' => 'yesterday')); // WHERE dispatch_time < '2011-03-13'
+ *
+ *
+ * @param mixed $dbDispatchTime The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbDispatchTime($dbDispatchTime = null, $comparison = null)
+ {
+ if (is_array($dbDispatchTime)) {
+ $useMinMax = false;
+ if (isset($dbDispatchTime['min'])) {
+ $this->addUsingAlias(CeleryTasksPeer::DISPATCH_TIME, $dbDispatchTime['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbDispatchTime['max'])) {
+ $this->addUsingAlias(CeleryTasksPeer::DISPATCH_TIME, $dbDispatchTime['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::DISPATCH_TIME, $dbDispatchTime, $comparison);
+ }
+
+ /**
+ * Filter the query on the status column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbStatus('fooValue'); // WHERE status = 'fooValue'
+ * $query->filterByDbStatus('%fooValue%'); // WHERE status LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbStatus The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbStatus($dbStatus = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbStatus)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbStatus)) {
+ $dbStatus = str_replace('*', '%', $dbStatus);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::STATUS, $dbStatus, $comparison);
+ }
+
+ /**
+ * Filter the query by a related ThirdPartyTrackReferences object
+ *
+ * @param ThirdPartyTrackReferences|PropelObjectCollection $thirdPartyTrackReferences The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByThirdPartyTrackReferences($thirdPartyTrackReferences, $comparison = null)
+ {
+ if ($thirdPartyTrackReferences instanceof ThirdPartyTrackReferences) {
+ return $this
+ ->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $thirdPartyTrackReferences->getDbId(), $comparison);
+ } elseif ($thirdPartyTrackReferences instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $thirdPartyTrackReferences->toKeyValue('PrimaryKey', 'DbId'), $comparison);
+ } else {
+ throw new PropelException('filterByThirdPartyTrackReferences() only accepts arguments of type ThirdPartyTrackReferences or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ThirdPartyTrackReferences relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function joinThirdPartyTrackReferences($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ThirdPartyTrackReferences');
+
+ // 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, 'ThirdPartyTrackReferences');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ThirdPartyTrackReferences relation ThirdPartyTrackReferences 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 ThirdPartyTrackReferencesQuery A secondary query class using the current class as primary query
+ */
+ public function useThirdPartyTrackReferencesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinThirdPartyTrackReferences($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ThirdPartyTrackReferences', 'ThirdPartyTrackReferencesQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CeleryTasks $celeryTasks Object to remove from the list of results
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function prune($celeryTasks = null)
+ {
+ if ($celeryTasks) {
+ $this->addUsingAlias(CeleryTasksPeer::ID, $celeryTasks->getDbId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php
new file mode 100644
index 000000000..a7860e1eb
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php
@@ -0,0 +1,1487 @@
+id;
+ }
+
+ /**
+ * Get the [service] column value.
+ *
+ * @return string
+ */
+ public function getDbService()
+ {
+
+ return $this->service;
+ }
+
+ /**
+ * Get the [foreign_id] column value.
+ *
+ * @return string
+ */
+ public function getDbForeignId()
+ {
+
+ return $this->foreign_id;
+ }
+
+ /**
+ * Get the [file_id] column value.
+ *
+ * @return int
+ */
+ public function getDbFileId()
+ {
+
+ return $this->file_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [upload_time] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getDbUploadTime($format = 'Y-m-d H:i:s')
+ {
+ if ($this->upload_time === null) {
+ return null;
+ }
+
+
+ try {
+ $dt = new DateTime($this->upload_time);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->upload_time, true), $x);
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ }
+
+ if (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ }
+
+ return $dt->format($format);
+
+ }
+
+ /**
+ * Get the [status] column value.
+ *
+ * @return string
+ */
+ public function getDbStatus()
+ {
+
+ return $this->status;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbId($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::ID;
+ }
+
+
+ return $this;
+ } // setDbId()
+
+ /**
+ * Set the value of [service] column.
+ *
+ * @param string $v new value
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbService($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->service !== $v) {
+ $this->service = $v;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::SERVICE;
+ }
+
+
+ return $this;
+ } // setDbService()
+
+ /**
+ * Set the value of [foreign_id] column.
+ *
+ * @param string $v new value
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbForeignId($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->foreign_id !== $v) {
+ $this->foreign_id = $v;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::FOREIGN_ID;
+ }
+
+
+ return $this;
+ } // setDbForeignId()
+
+ /**
+ * Set the value of [file_id] column.
+ *
+ * @param int $v new value
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbFileId($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->file_id !== $v) {
+ $this->file_id = $v;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::FILE_ID;
+ }
+
+ if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) {
+ $this->aCcFiles = null;
+ }
+
+
+ return $this;
+ } // setDbFileId()
+
+ /**
+ * Sets the value of [upload_time] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbUploadTime($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->upload_time !== null || $dt !== null) {
+ $currentDateAsString = ($this->upload_time !== null && $tmpDt = new DateTime($this->upload_time)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->upload_time = $newDateAsString;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::UPLOAD_TIME;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setDbUploadTime()
+
+ /**
+ * Set the value of [status] column.
+ *
+ * @param string $v new value
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbStatus($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->status !== $v) {
+ $this->status = $v;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::STATUS;
+ }
+
+
+ return $this;
+ } // setDbStatus()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which resultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
+ $this->service = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
+ $this->foreign_id = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->file_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->upload_time = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->status = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+ $this->postHydrate($row, $startcol, $rehydrate);
+
+ return $startcol + 6; // 6 = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating ThirdPartyTrackReferences object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) {
+ $this->aCcFiles = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = ThirdPartyTrackReferencesPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCcFiles = null;
+ $this->collCeleryTaskss = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ThirdPartyTrackReferencesQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCcFiles !== null) {
+ if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) {
+ $affectedRows += $this->aCcFiles->save($con);
+ }
+ $this->setCcFiles($this->aCcFiles);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->celeryTaskssScheduledForDeletion !== null) {
+ if (!$this->celeryTaskssScheduledForDeletion->isEmpty()) {
+ CeleryTasksQuery::create()
+ ->filterByPrimaryKeys($this->celeryTaskssScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->celeryTaskssScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCeleryTaskss !== null) {
+ foreach ($this->collCeleryTaskss as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ThirdPartyTrackReferencesPeer::ID . ')');
+ }
+ if (null === $this->id) {
+ try {
+ $stmt = $con->query("SELECT nextval('third_party_track_references_id_seq')");
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $this->id = $row[0];
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get sequence id.', $e);
+ }
+ }
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '"id"';
+ }
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::SERVICE)) {
+ $modifiedColumns[':p' . $index++] = '"service"';
+ }
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FOREIGN_ID)) {
+ $modifiedColumns[':p' . $index++] = '"foreign_id"';
+ }
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FILE_ID)) {
+ $modifiedColumns[':p' . $index++] = '"file_id"';
+ }
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::UPLOAD_TIME)) {
+ $modifiedColumns[':p' . $index++] = '"upload_time"';
+ }
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::STATUS)) {
+ $modifiedColumns[':p' . $index++] = '"status"';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO "third_party_track_references" (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '"id"':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '"service"':
+ $stmt->bindValue($identifier, $this->service, PDO::PARAM_STR);
+ break;
+ case '"foreign_id"':
+ $stmt->bindValue($identifier, $this->foreign_id, PDO::PARAM_STR);
+ break;
+ case '"file_id"':
+ $stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT);
+ break;
+ case '"upload_time"':
+ $stmt->bindValue($identifier, $this->upload_time, PDO::PARAM_STR);
+ break;
+ case '"status"':
+ $stmt->bindValue($identifier, $this->status, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ }
+
+ $this->validationFailures = $res;
+
+ return false;
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true
is returned; otherwise
+ * an aggregated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true
if all validations pass; array of ValidationFailed
objects otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCcFiles !== null) {
+ if (!$this->aCcFiles->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = ThirdPartyTrackReferencesPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ if ($this->collCeleryTaskss !== null) {
+ foreach ($this->collCeleryTaskss as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ThirdPartyTrackReferencesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getDbId();
+ break;
+ case 1:
+ return $this->getDbService();
+ break;
+ case 2:
+ return $this->getDbForeignId();
+ break;
+ case 3:
+ return $this->getDbFileId();
+ break;
+ case 4:
+ return $this->getDbUploadTime();
+ break;
+ case 5:
+ return $this->getDbStatus();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ThirdPartyTrackReferences'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ThirdPartyTrackReferences'][$this->getPrimaryKey()] = true;
+ $keys = ThirdPartyTrackReferencesPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getDbId(),
+ $keys[1] => $this->getDbService(),
+ $keys[2] => $this->getDbForeignId(),
+ $keys[3] => $this->getDbFileId(),
+ $keys[4] => $this->getDbUploadTime(),
+ $keys[5] => $this->getDbStatus(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCcFiles) {
+ $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collCeleryTaskss) {
+ $result['CeleryTaskss'] = $this->collCeleryTaskss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = ThirdPartyTrackReferencesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setDbId($value);
+ break;
+ case 1:
+ $this->setDbService($value);
+ break;
+ case 2:
+ $this->setDbForeignId($value);
+ break;
+ case 3:
+ $this->setDbFileId($value);
+ break;
+ case 4:
+ $this->setDbUploadTime($value);
+ break;
+ case 5:
+ $this->setDbStatus($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = ThirdPartyTrackReferencesPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setDbService($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setDbForeignId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDbFileId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDbUploadTime($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setDbStatus($arr[$keys[5]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::ID)) $criteria->add(ThirdPartyTrackReferencesPeer::ID, $this->id);
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::SERVICE)) $criteria->add(ThirdPartyTrackReferencesPeer::SERVICE, $this->service);
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FOREIGN_ID)) $criteria->add(ThirdPartyTrackReferencesPeer::FOREIGN_ID, $this->foreign_id);
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FILE_ID)) $criteria->add(ThirdPartyTrackReferencesPeer::FILE_ID, $this->file_id);
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::UPLOAD_TIME)) $criteria->add(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $this->upload_time);
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::STATUS)) $criteria->add(ThirdPartyTrackReferencesPeer::STATUS, $this->status);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ $criteria->add(ThirdPartyTrackReferencesPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return int
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getDbId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param int $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setDbId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getDbId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of ThirdPartyTrackReferences (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setDbService($this->getDbService());
+ $copyObj->setDbForeignId($this->getDbForeignId());
+ $copyObj->setDbFileId($this->getDbFileId());
+ $copyObj->setDbUploadTime($this->getDbUploadTime());
+ $copyObj->setDbStatus($this->getDbStatus());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ foreach ($this->getCeleryTaskss() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCeleryTasks($relObj->copy($deepCopy));
+ }
+ }
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return ThirdPartyTrackReferences Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return ThirdPartyTrackReferencesPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new ThirdPartyTrackReferencesPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a CcFiles object.
+ *
+ * @param CcFiles $v
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCcFiles(CcFiles $v = null)
+ {
+ if ($v === null) {
+ $this->setDbFileId(NULL);
+ } else {
+ $this->setDbFileId($v->getDbId());
+ }
+
+ $this->aCcFiles = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the CcFiles object, it will not be re-added.
+ if ($v !== null) {
+ $v->addThirdPartyTrackReferences($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated CcFiles object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @param $doQuery Executes a query to get the object if required
+ * @return CcFiles The associated CcFiles object.
+ * @throws PropelException
+ */
+ public function getCcFiles(PropelPDO $con = null, $doQuery = true)
+ {
+ if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) {
+ $this->aCcFiles = CcFilesQuery::create()->findPk($this->file_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCcFiles->addThirdPartyTrackReferencess($this);
+ */
+ }
+
+ return $this->aCcFiles;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CeleryTasks' == $relationName) {
+ $this->initCeleryTaskss();
+ }
+ }
+
+ /**
+ * Clears out the collCeleryTaskss 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 ThirdPartyTrackReferences The current object (for fluent API support)
+ * @see addCeleryTaskss()
+ */
+ public function clearCeleryTaskss()
+ {
+ $this->collCeleryTaskss = null; // important to set this to null since that means it is uninitialized
+ $this->collCeleryTaskssPartial = null;
+
+ return $this;
+ }
+
+ /**
+ * reset is the collCeleryTaskss collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCeleryTaskss($v = true)
+ {
+ $this->collCeleryTaskssPartial = $v;
+ }
+
+ /**
+ * Initializes the collCeleryTaskss collection.
+ *
+ * By default this just sets the collCeleryTaskss collection to an empty array (like clearcollCeleryTaskss());
+ * 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 initCeleryTaskss($overrideExisting = true)
+ {
+ if (null !== $this->collCeleryTaskss && !$overrideExisting) {
+ return;
+ }
+ $this->collCeleryTaskss = new PropelObjectCollection();
+ $this->collCeleryTaskss->setModel('CeleryTasks');
+ }
+
+ /**
+ * Gets an array of CeleryTasks 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 ThirdPartyTrackReferences 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|CeleryTasks[] List of CeleryTasks objects
+ * @throws PropelException
+ */
+ public function getCeleryTaskss($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collCeleryTaskssPartial && !$this->isNew();
+ if (null === $this->collCeleryTaskss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCeleryTaskss) {
+ // return empty collection
+ $this->initCeleryTaskss();
+ } else {
+ $collCeleryTaskss = CeleryTasksQuery::create(null, $criteria)
+ ->filterByThirdPartyTrackReferences($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCeleryTaskssPartial && count($collCeleryTaskss)) {
+ $this->initCeleryTaskss(false);
+
+ foreach ($collCeleryTaskss as $obj) {
+ if (false == $this->collCeleryTaskss->contains($obj)) {
+ $this->collCeleryTaskss->append($obj);
+ }
+ }
+
+ $this->collCeleryTaskssPartial = true;
+ }
+
+ $collCeleryTaskss->getInternalIterator()->rewind();
+
+ return $collCeleryTaskss;
+ }
+
+ if ($partial && $this->collCeleryTaskss) {
+ foreach ($this->collCeleryTaskss as $obj) {
+ if ($obj->isNew()) {
+ $collCeleryTaskss[] = $obj;
+ }
+ }
+ }
+
+ $this->collCeleryTaskss = $collCeleryTaskss;
+ $this->collCeleryTaskssPartial = false;
+ }
+ }
+
+ return $this->collCeleryTaskss;
+ }
+
+ /**
+ * Sets a collection of CeleryTasks 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 $celeryTaskss A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setCeleryTaskss(PropelCollection $celeryTaskss, PropelPDO $con = null)
+ {
+ $celeryTaskssToDelete = $this->getCeleryTaskss(new Criteria(), $con)->diff($celeryTaskss);
+
+
+ $this->celeryTaskssScheduledForDeletion = $celeryTaskssToDelete;
+
+ foreach ($celeryTaskssToDelete as $celeryTasksRemoved) {
+ $celeryTasksRemoved->setThirdPartyTrackReferences(null);
+ }
+
+ $this->collCeleryTaskss = null;
+ foreach ($celeryTaskss as $celeryTasks) {
+ $this->addCeleryTasks($celeryTasks);
+ }
+
+ $this->collCeleryTaskss = $celeryTaskss;
+ $this->collCeleryTaskssPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CeleryTasks objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CeleryTasks objects.
+ * @throws PropelException
+ */
+ public function countCeleryTaskss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCeleryTaskssPartial && !$this->isNew();
+ if (null === $this->collCeleryTaskss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCeleryTaskss) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCeleryTaskss());
+ }
+ $query = CeleryTasksQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByThirdPartyTrackReferences($this)
+ ->count($con);
+ }
+
+ return count($this->collCeleryTaskss);
+ }
+
+ /**
+ * Method called to associate a CeleryTasks object to this object
+ * through the CeleryTasks foreign key attribute.
+ *
+ * @param CeleryTasks $l CeleryTasks
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function addCeleryTasks(CeleryTasks $l)
+ {
+ if ($this->collCeleryTaskss === null) {
+ $this->initCeleryTaskss();
+ $this->collCeleryTaskssPartial = true;
+ }
+
+ if (!in_array($l, $this->collCeleryTaskss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCeleryTasks($l);
+
+ if ($this->celeryTaskssScheduledForDeletion and $this->celeryTaskssScheduledForDeletion->contains($l)) {
+ $this->celeryTaskssScheduledForDeletion->remove($this->celeryTaskssScheduledForDeletion->search($l));
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CeleryTasks $celeryTasks The celeryTasks object to add.
+ */
+ protected function doAddCeleryTasks($celeryTasks)
+ {
+ $this->collCeleryTaskss[]= $celeryTasks;
+ $celeryTasks->setThirdPartyTrackReferences($this);
+ }
+
+ /**
+ * @param CeleryTasks $celeryTasks The celeryTasks object to remove.
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function removeCeleryTasks($celeryTasks)
+ {
+ if ($this->getCeleryTaskss()->contains($celeryTasks)) {
+ $this->collCeleryTaskss->remove($this->collCeleryTaskss->search($celeryTasks));
+ if (null === $this->celeryTaskssScheduledForDeletion) {
+ $this->celeryTaskssScheduledForDeletion = clone $this->collCeleryTaskss;
+ $this->celeryTaskssScheduledForDeletion->clear();
+ }
+ $this->celeryTaskssScheduledForDeletion[]= clone $celeryTasks;
+ $celeryTasks->setThirdPartyTrackReferences(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->service = null;
+ $this->foreign_id = null;
+ $this->file_id = null;
+ $this->upload_time = null;
+ $this->status = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->alreadyInClearAllReferencesDeep = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep && !$this->alreadyInClearAllReferencesDeep) {
+ $this->alreadyInClearAllReferencesDeep = true;
+ if ($this->collCeleryTaskss) {
+ foreach ($this->collCeleryTaskss as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->aCcFiles instanceof Persistent) {
+ $this->aCcFiles->clearAllReferences($deep);
+ }
+
+ $this->alreadyInClearAllReferencesDeep = false;
+ } // if ($deep)
+
+ if ($this->collCeleryTaskss instanceof PropelCollection) {
+ $this->collCeleryTaskss->clearIterator();
+ }
+ $this->collCeleryTaskss = null;
+ $this->aCcFiles = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ThirdPartyTrackReferencesPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php
new file mode 100644
index 000000000..38c8ddbd9
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php
@@ -0,0 +1,1022 @@
+ array ('DbId', 'DbService', 'DbForeignId', 'DbFileId', 'DbUploadTime', 'DbStatus', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbService', 'dbForeignId', 'dbFileId', 'dbUploadTime', 'dbStatus', ),
+ BasePeer::TYPE_COLNAME => array (ThirdPartyTrackReferencesPeer::ID, ThirdPartyTrackReferencesPeer::SERVICE, ThirdPartyTrackReferencesPeer::FOREIGN_ID, ThirdPartyTrackReferencesPeer::FILE_ID, ThirdPartyTrackReferencesPeer::UPLOAD_TIME, ThirdPartyTrackReferencesPeer::STATUS, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'SERVICE', 'FOREIGN_ID', 'FILE_ID', 'UPLOAD_TIME', 'STATUS', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'service', 'foreign_id', 'file_id', 'upload_time', 'status', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. ThirdPartyTrackReferencesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbService' => 1, 'DbForeignId' => 2, 'DbFileId' => 3, 'DbUploadTime' => 4, 'DbStatus' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbService' => 1, 'dbForeignId' => 2, 'dbFileId' => 3, 'dbUploadTime' => 4, 'dbStatus' => 5, ),
+ BasePeer::TYPE_COLNAME => array (ThirdPartyTrackReferencesPeer::ID => 0, ThirdPartyTrackReferencesPeer::SERVICE => 1, ThirdPartyTrackReferencesPeer::FOREIGN_ID => 2, ThirdPartyTrackReferencesPeer::FILE_ID => 3, ThirdPartyTrackReferencesPeer::UPLOAD_TIME => 4, ThirdPartyTrackReferencesPeer::STATUS => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'SERVICE' => 1, 'FOREIGN_ID' => 2, 'FILE_ID' => 3, 'UPLOAD_TIME' => 4, 'STATUS' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'service' => 1, 'foreign_id' => 2, 'file_id' => 3, 'upload_time' => 4, 'status' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = ThirdPartyTrackReferencesPeer::getFieldNames($toType);
+ $key = isset(ThirdPartyTrackReferencesPeer::$fieldKeys[$fromType][$name]) ? ThirdPartyTrackReferencesPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ThirdPartyTrackReferencesPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, ThirdPartyTrackReferencesPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return ThirdPartyTrackReferencesPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. ThirdPartyTrackReferencesPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(ThirdPartyTrackReferencesPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::ID);
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::SERVICE);
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::FOREIGN_ID);
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::FILE_ID);
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::UPLOAD_TIME);
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::STATUS);
+ } else {
+ $criteria->addSelectColumn($alias . '.id');
+ $criteria->addSelectColumn($alias . '.service');
+ $criteria->addSelectColumn($alias . '.foreign_id');
+ $criteria->addSelectColumn($alias . '.file_id');
+ $criteria->addSelectColumn($alias . '.upload_time');
+ $criteria->addSelectColumn($alias . '.status');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ThirdPartyTrackReferencesPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+ /**
+ * Selects one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return ThirdPartyTrackReferences
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = ThirdPartyTrackReferencesPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return ThirdPartyTrackReferencesPeer::populateObjects(ThirdPartyTrackReferencesPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement directly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param ThirdPartyTrackReferences $obj A ThirdPartyTrackReferences object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getDbId();
+ } // if key === null
+ ThirdPartyTrackReferencesPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A ThirdPartyTrackReferences object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof ThirdPartyTrackReferences) {
+ $key = (string) $value->getDbId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ThirdPartyTrackReferences object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(ThirdPartyTrackReferencesPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return ThirdPartyTrackReferences Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(ThirdPartyTrackReferencesPeer::$instances[$key])) {
+ return ThirdPartyTrackReferencesPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool($and_clear_all_references = false)
+ {
+ if ($and_clear_all_references) {
+ foreach (ThirdPartyTrackReferencesPeer::$instances as $instance) {
+ $instance->clearAllReferences(true);
+ }
+ }
+ ThirdPartyTrackReferencesPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to third_party_track_references
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in CeleryTasksPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CeleryTasksPeer::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (int) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = ThirdPartyTrackReferencesPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = ThirdPartyTrackReferencesPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ThirdPartyTrackReferences object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = ThirdPartyTrackReferencesPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ThirdPartyTrackReferencesPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related CcFiles table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(ThirdPartyTrackReferencesPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of ThirdPartyTrackReferences objects pre-filled with their CcFiles objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of ThirdPartyTrackReferences objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ }
+
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ $startcol = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
+ CcFilesPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ThirdPartyTrackReferencesPeer::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 = ThirdPartyTrackReferencesPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = CcFilesPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CcFilesPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ CcFilesPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (ThirdPartyTrackReferences) to $obj2 (CcFiles)
+ $obj2->addThirdPartyTrackReferences($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(ThirdPartyTrackReferencesPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of ThirdPartyTrackReferences 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 ThirdPartyTrackReferences 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(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ }
+
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ $startcol2 = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
+
+ CcFilesPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = ThirdPartyTrackReferencesPeer::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 = ThirdPartyTrackReferencesPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined CcFiles rows
+
+ $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = CcFilesPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = CcFilesPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ CcFilesPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (ThirdPartyTrackReferences) to the collection in $obj2 (CcFiles)
+ $obj2->addThirdPartyTrackReferences($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(ThirdPartyTrackReferencesPeer::DATABASE_NAME)->getTable(ThirdPartyTrackReferencesPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseThirdPartyTrackReferencesPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new \ThirdPartyTrackReferencesTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass($row = 0, $colnum = 0)
+ {
+ return ThirdPartyTrackReferencesPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ThirdPartyTrackReferences or Criteria object.
+ *
+ * @param mixed $values Criteria or ThirdPartyTrackReferences object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from ThirdPartyTrackReferences object
+ }
+
+ if ($criteria->containsKey(ThirdPartyTrackReferencesPeer::ID) && $criteria->keyContainsValue(ThirdPartyTrackReferencesPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ThirdPartyTrackReferencesPeer::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a ThirdPartyTrackReferences or Criteria object.
+ *
+ * @param mixed $values Criteria or ThirdPartyTrackReferences object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(ThirdPartyTrackReferencesPeer::ID);
+ $value = $criteria->remove(ThirdPartyTrackReferencesPeer::ID);
+ if ($value) {
+ $selectCriteria->add(ThirdPartyTrackReferencesPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(ThirdPartyTrackReferencesPeer::TABLE_NAME);
+ }
+
+ } else { // $values is ThirdPartyTrackReferences object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the third_party_track_references table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(ThirdPartyTrackReferencesPeer::TABLE_NAME, $con, ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ThirdPartyTrackReferencesPeer::clearInstancePool();
+ ThirdPartyTrackReferencesPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ThirdPartyTrackReferences or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ThirdPartyTrackReferences object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ ThirdPartyTrackReferencesPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof ThirdPartyTrackReferences) { // it's a model object
+ // invalidate the cache for this single object
+ ThirdPartyTrackReferencesPeer::removeInstanceFromPool($values);
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ $criteria->add(ThirdPartyTrackReferencesPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ ThirdPartyTrackReferencesPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ ThirdPartyTrackReferencesPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given ThirdPartyTrackReferences object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param ThirdPartyTrackReferences $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(ThirdPartyTrackReferencesPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(ThirdPartyTrackReferencesPeer::DATABASE_NAME, ThirdPartyTrackReferencesPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param int $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return ThirdPartyTrackReferences
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = ThirdPartyTrackReferencesPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ $criteria->add(ThirdPartyTrackReferencesPeer::ID, $pk);
+
+ $v = ThirdPartyTrackReferencesPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return ThirdPartyTrackReferences[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(ThirdPartyTrackReferencesPeer::DATABASE_NAME);
+ $criteria->add(ThirdPartyTrackReferencesPeer::ID, $pks, Criteria::IN);
+ $objs = ThirdPartyTrackReferencesPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseThirdPartyTrackReferencesPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseThirdPartyTrackReferencesPeer::buildTableMap();
+
diff --git a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php
new file mode 100644
index 000000000..86f0a174d
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php
@@ -0,0 +1,628 @@
+mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return ThirdPartyTrackReferences|ThirdPartyTrackReferences[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ThirdPartyTrackReferencesPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Alias of findPk to use instance pooling
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ThirdPartyTrackReferences A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ public function findOneByDbId($key, $con = null)
+ {
+ return $this->findPk($key, $con);
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ThirdPartyTrackReferences A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT "id", "service", "foreign_id", "file_id", "upload_time", "status" FROM "third_party_track_references" WHERE "id" = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new ThirdPartyTrackReferences();
+ $obj->hydrate($row);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return ThirdPartyTrackReferences|ThirdPartyTrackReferences[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|ThirdPartyTrackReferences[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbId(1234); // WHERE id = 1234
+ * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12
+ * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12
+ *
+ *
+ * @param mixed $dbId 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 ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbId($dbId = null, $comparison = null)
+ {
+ if (is_array($dbId)) {
+ $useMinMax = false;
+ if (isset($dbId['min'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbId['max'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $dbId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $dbId, $comparison);
+ }
+
+ /**
+ * Filter the query on the service column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbService('fooValue'); // WHERE service = 'fooValue'
+ * $query->filterByDbService('%fooValue%'); // WHERE service LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbService The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbService($dbService = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbService)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbService)) {
+ $dbService = str_replace('*', '%', $dbService);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::SERVICE, $dbService, $comparison);
+ }
+
+ /**
+ * Filter the query on the foreign_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbForeignId('fooValue'); // WHERE foreign_id = 'fooValue'
+ * $query->filterByDbForeignId('%fooValue%'); // WHERE foreign_id LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbForeignId The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbForeignId($dbForeignId = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbForeignId)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbForeignId)) {
+ $dbForeignId = str_replace('*', '%', $dbForeignId);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::FOREIGN_ID, $dbForeignId, $comparison);
+ }
+
+ /**
+ * Filter the query on the file_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbFileId(1234); // WHERE file_id = 1234
+ * $query->filterByDbFileId(array(12, 34)); // WHERE file_id IN (12, 34)
+ * $query->filterByDbFileId(array('min' => 12)); // WHERE file_id >= 12
+ * $query->filterByDbFileId(array('max' => 12)); // WHERE file_id <= 12
+ *
+ *
+ * @see filterByCcFiles()
+ *
+ * @param mixed $dbFileId 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 ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbFileId($dbFileId = null, $comparison = null)
+ {
+ if (is_array($dbFileId)) {
+ $useMinMax = false;
+ if (isset($dbFileId['min'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbFileId['max'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $dbFileId, $comparison);
+ }
+
+ /**
+ * Filter the query on the upload_time column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbUploadTime('2011-03-14'); // WHERE upload_time = '2011-03-14'
+ * $query->filterByDbUploadTime('now'); // WHERE upload_time = '2011-03-14'
+ * $query->filterByDbUploadTime(array('max' => 'yesterday')); // WHERE upload_time < '2011-03-13'
+ *
+ *
+ * @param mixed $dbUploadTime The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * 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 ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbUploadTime($dbUploadTime = null, $comparison = null)
+ {
+ if (is_array($dbUploadTime)) {
+ $useMinMax = false;
+ if (isset($dbUploadTime['min'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $dbUploadTime['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbUploadTime['max'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $dbUploadTime['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $dbUploadTime, $comparison);
+ }
+
+ /**
+ * Filter the query on the status column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbStatus('fooValue'); // WHERE status = 'fooValue'
+ * $query->filterByDbStatus('%fooValue%'); // WHERE status LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbStatus The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbStatus($dbStatus = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbStatus)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbStatus)) {
+ $dbStatus = str_replace('*', '%', $dbStatus);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::STATUS, $dbStatus, $comparison);
+ }
+
+ /**
+ * Filter the query by a related CcFiles object
+ *
+ * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCcFiles($ccFiles, $comparison = null)
+ {
+ if ($ccFiles instanceof CcFiles) {
+ return $this
+ ->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $ccFiles->getDbId(), $comparison);
+ } elseif ($ccFiles instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison);
+ } else {
+ throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CcFiles relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function joinCcFiles($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CcFiles');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CcFiles');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CcFiles relation CcFiles object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcFilesQuery A secondary query class using the current class as primary query
+ */
+ public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCcFiles($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery');
+ }
+
+ /**
+ * Filter the query by a related CeleryTasks object
+ *
+ * @param CeleryTasks|PropelObjectCollection $celeryTasks the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCeleryTasks($celeryTasks, $comparison = null)
+ {
+ if ($celeryTasks instanceof CeleryTasks) {
+ return $this
+ ->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $celeryTasks->getDbTrackReference(), $comparison);
+ } elseif ($celeryTasks instanceof PropelObjectCollection) {
+ return $this
+ ->useCeleryTasksQuery()
+ ->filterByPrimaryKeys($celeryTasks->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCeleryTasks() only accepts arguments of type CeleryTasks or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CeleryTasks relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function joinCeleryTasks($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CeleryTasks');
+
+ // 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, 'CeleryTasks');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CeleryTasks relation CeleryTasks 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 CeleryTasksQuery A secondary query class using the current class as primary query
+ */
+ public function useCeleryTasksQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCeleryTasks($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CeleryTasks', 'CeleryTasksQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ThirdPartyTrackReferences $thirdPartyTrackReferences Object to remove from the list of results
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function prune($thirdPartyTrackReferences = null)
+ {
+ if ($thirdPartyTrackReferences) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $thirdPartyTrackReferences->getDbId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/airtime_mvc/application/services/CalendarService.php b/airtime_mvc/application/services/CalendarService.php
index abef0d292..e8de4c73f 100644
--- a/airtime_mvc/application/services/CalendarService.php
+++ b/airtime_mvc/application/services/CalendarService.php
@@ -55,23 +55,6 @@ class Application_Service_CalendarService
"icon" => "overview",
"url" => $baseUrl."library/edit-file-md/id/".$ccFile->getDbId());
}
-
- //recorded show can be uploaded to soundcloud
- if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
- $scid = $ccFile->getDbSoundcloudId();
-
- if ($scid > 0) {
- $menu["soundcloud_view"] = array(
- "name" => _("View on Soundcloud"),
- "icon" => "soundcloud",
- "url" => $ccFile->getDbSoundcloudLinkToFile());
- }
-
- $text = is_null($scid) ? _('Upload to SoundCloud') : _('Re-upload to SoundCloud');
- $menu["soundcloud_upload"] = array(
- "name"=> $text,
- "icon" => "soundcloud");
- }
} else {
$menu["content"] = array(
"name"=> _("Show Content"),
diff --git a/airtime_mvc/application/services/CeleryService.php b/airtime_mvc/application/services/CeleryService.php
new file mode 100644
index 000000000..8e9091290
--- /dev/null
+++ b/airtime_mvc/application/services/CeleryService.php
@@ -0,0 +1,211 @@
+PostTask($task, $data, true, $routingKey); // and routing key
+ return $result->getId();
+ }
+
+ /**
+ * Given a task name and identifier, check the Celery results queue for any
+ * corresponding messages
+ *
+ * @param $task CeleryTasks the Celery task object
+ *
+ * @return array the message response array
+ *
+ * @throws CeleryException when no message is found
+ * @throws CeleryTimeoutException when no message is found and more than
+ * $_CELERY_MESSAGE_TIMEOUT milliseconds have passed
+ */
+ private static function getAsyncResultMessage($task) {
+ $config = parse_ini_file(Application_Model_RabbitMq::getRmqConfigPath(), true);
+ $queue = self::$_CELERY_RESULTS_EXCHANGE . "." . $task;
+ $c = self::_setupCeleryExchange($config, self::$_CELERY_RESULTS_EXCHANGE, $queue);
+ $message = $c->getAsyncResultMessage($task->getDbName(), $task->getDbTaskId());
+
+ // If the message isn't ready yet (Celery hasn't finished the task),
+ // only throw an exception if the message has timed out.
+ if ($message == FALSE) {
+ if (self::_checkMessageTimeout($task)) {
+ // If the task times out, mark it as failed. We don't want to remove the
+ // track reference here in case it was a deletion that failed, for example.
+ $task->setDbStatus(CELERY_FAILED_STATUS)->save();
+ throw new CeleryTimeoutException("Celery task " . $task->getDbName()
+ . " with ID " . $task->getDbTaskId() . " timed out");
+ } else {
+ // The message hasn't timed out, but it's still false, which means it hasn't been
+ // sent back from Celery yet.
+ throw new CeleryException("Waiting on Celery task " . $task->getDbName()
+ . " with ID " . $task->getDbTaskId());
+ }
+ }
+ return $message;
+ }
+
+ /**
+ * Check to see if there are any pending tasks for this service
+ *
+ * @param string $taskName the name of the task to poll for
+ * @param string $serviceName the name of the service to poll for
+ *
+ * @return bool true if there are any pending tasks, otherwise false
+ */
+ public static function isBrokerTaskQueueEmpty($taskName="", $serviceName = "") {
+ $pendingTasks = self::_getPendingTasks($taskName, $serviceName);
+ return empty($pendingTasks);
+ }
+
+ /**
+ * Poll the message queue for this service to see if any tasks with the given name have completed
+ *
+ * If we find any completed tasks, adjust the ThirdPartyTrackReferences table accordingly
+ *
+ * If no task name is passed, we poll all tasks for this service
+ *
+ * @param string $taskName the name of the task to poll for
+ * @param string $serviceName the name of the service to poll for
+ */
+ public static function pollBrokerTaskQueue($taskName = "", $serviceName = "") {
+ $pendingTasks = self::_getPendingTasks($taskName, $serviceName);
+ foreach ($pendingTasks as $task) {
+ try {
+ $message = self::_getTaskMessage($task);
+ self::_processTaskMessage($task, $message);
+ } catch (CeleryTimeoutException $e) {
+ Logging::warn($e->getMessage());
+ } catch (Exception $e) {
+ // Because $message->result can be either an object or a string, sometimes
+ // we get a json_decode error and end up here
+ Logging::info($e->getMessage());
+ }
+ }
+ }
+
+ /**
+ * Return a collection of all pending CeleryTasks for this service or task
+ *
+ * @param string $taskName the name of the task to find
+ * @param string $serviceName the name of the service to find
+ *
+ * @return PropelCollection any pending CeleryTasks results for this service
+ * or task if taskName is provided
+ */
+ protected static function _getPendingTasks($taskName, $serviceName) {
+ $query = CeleryTasksQuery::create()
+ ->filterByDbStatus(CELERY_PENDING_STATUS)
+ ->filterByDbTaskId('', Criteria::NOT_EQUAL);
+ if (!empty($taskName)) {
+ $query->filterByDbName($taskName);
+ }
+ if (!empty($serviceName)) {
+ $query->useThirdPartyTrackReferencesQuery()
+ ->filterByDbService($serviceName)->endUse();
+ }
+ return $query->joinThirdPartyTrackReferences()
+ ->with('ThirdPartyTrackReferences')->find();
+ }
+
+ /**
+ * Get a Celery task message from the results queue
+ *
+ * @param $task CeleryTasks the Celery task object
+ *
+ * @return object the task message object
+ *
+ * @throws CeleryException when the result message for this task is still pending
+ * @throws CeleryTimeoutException when the result message for this task no longer exists
+ */
+ protected static function _getTaskMessage($task) {
+ $message = self::getAsyncResultMessage($task);
+ return json_decode($message['body']);
+ }
+
+ /**
+ * Process a message from the results queue
+ *
+ * @param $task CeleryTasks Celery task object
+ * @param $message mixed async message object from php-celery
+ */
+ protected static function _processTaskMessage($task, $message) {
+ $ref = $task->getThirdPartyTrackReferences(); // ThirdPartyTrackReferences join
+ $service = CeleryServiceFactory::getService($ref->getDbService());
+ if ($message->status == CELERY_SUCCESS_STATUS
+ && $task->getDbName() == $service->getCeleryDeleteTaskName()) {
+ $service->removeTrackReference($ref->getDbFileId());
+ } else {
+ $service->updateTrackReference($ref->getDbId(), json_decode($message->result), $message->status);
+ }
+ }
+
+ /**
+ * Check if a task message has been unreachable for more our timeout time
+ *
+ * @param $task CeleryTasks the Celery task object
+ *
+ * @return bool true if the dispatch time is empty or it's been more than our timeout time
+ * since the message was dispatched, otherwise false
+ */
+ protected static function _checkMessageTimeout($task) {
+ $utc = new DateTimeZone("UTC");
+ $dispatchTime = new DateTime($task->getDbDispatchTime(), $utc);
+ $now = new DateTime("now", $utc);
+ $timeoutSeconds = self::$_CELERY_MESSAGE_TIMEOUT / 1000; // Convert from milliseconds
+ $timeoutInterval = new DateInterval("PT" . $timeoutSeconds . "S");
+ return (empty($dispatchTime) || $dispatchTime->add($timeoutInterval) <= $now);
+ }
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/services/CeleryServiceFactory.php b/airtime_mvc/application/services/CeleryServiceFactory.php
new file mode 100644
index 000000000..defb6ce81
--- /dev/null
+++ b/airtime_mvc/application/services/CeleryServiceFactory.php
@@ -0,0 +1,20 @@
+ "license",
+ "getDefaultSoundCloudSharingType" => "sharing"
+ );
+
+ /**
+ * Initialize the service
+ */
+ public function __construct() {
+ $CC_CONFIG = Config::getConfig();
+ $clientId = $CC_CONFIG['soundcloud-client-id'];
+ $clientSecret = $CC_CONFIG['soundcloud-client-secret'];
+ $redirectUri = $CC_CONFIG['soundcloud-redirect-uri'];
+
+ $this->_client = new Soundcloud\Service($clientId, $clientSecret, $redirectUri);
+ $accessToken = Application_Model_Preference::getSoundCloudRequestToken();
+ if (!empty($accessToken)) {
+ $this->_accessToken = $accessToken;
+ $this->_client->setAccessToken($accessToken);
+ }
+ }
+
+ /**
+ * Build a parameter array for the track being uploaded to SoundCloud
+ *
+ * @param $file Application_Model_StoredFile the file being uploaded
+ *
+ * @return array the track array to send to SoundCloud
+ */
+ protected function _getUploadData($file) {
+ $file = $file->getPropelOrm();
+ $trackArray = $this->_serializeTrack($file);
+ foreach (self::$_SOUNDCLOUD_PREF_FUNCTIONS as $func => $param) {
+ $val = Application_Model_Preference::$func();
+ if (!empty($val)) {
+ $trackArray[$param] = $val;
+ }
+ }
+
+ return $trackArray;
+ }
+
+ /**
+ * Serialize Airtime file data to send to SoundCloud
+ *
+ * Ignores any null fields, as these will cause the upload to throw a 422
+ * Unprocessable Entity error
+ *
+ * TODO: Move this into a proper serializer
+ *
+ * @param $file CcFiles file object
+ *
+ * @return array the serialized data
+ */
+ protected function _serializeTrack($file) {
+ $fileData = array(
+ 'title' => $file->getDbTrackTitle(),
+ 'genre' => $file->getDbGenre(),
+ 'bpm' => $file->getDbBpm(),
+ 'release_year' => $file->getDbYear(),
+ );
+ $trackArray = array();
+ foreach ($fileData as $k => $v) {
+ if (!empty($v)) {
+ $trackArray[$k] = $v;
+ }
+ }
+ return $trackArray;
+ }
+
+ /**
+ * Update a ThirdPartyTrackReferences object for a completed upload
+ *
+ * TODO: should we have a database layer class to handle Propel operations?
+ *
+ * @param $trackId int ThirdPartyTrackReferences identifier
+ * @param $track object third-party service track object
+ * @param $status string Celery task status
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ public function updateTrackReference($trackId, $track, $status) {
+ parent::updateTrackReference($trackId, $track, $status);
+ $ref = ThirdPartyTrackReferencesQuery::create()
+ ->findOneByDbId($trackId);
+ if (is_null($ref)) {
+ $ref = new ThirdPartyTrackReferences();
+ }
+ $ref->setDbService(static::$_SERVICE_NAME);
+ // Only set the SoundCloud fields if the task was successful
+ if ($status == CELERY_SUCCESS_STATUS) {
+ $utc = new DateTimeZone("UTC");
+ $ref->setDbUploadTime(new DateTime("now", $utc));
+ // TODO: fetch any additional SoundCloud parameters we want to store
+ $ref->setDbForeignId($track->id); // SoundCloud identifier
+ }
+ // TODO: set SoundCloud upload status?
+ // $ref->setDbStatus($status);
+ $ref->save();
+ }
+
+ /**
+ * Given a CcFiles identifier for a file that's been uploaded to SoundCloud,
+ * return a link to the remote file
+ *
+ * @param int $fileId the local CcFiles identifier
+ *
+ * @return string the link to the remote file
+ *
+ * @throws Soundcloud\Exception\InvalidHttpResponseCodeException when SoundCloud returns a 4xx/5xx response
+ */
+ public function getLinkToFile($fileId) {
+ $serviceId = $this->getServiceId($fileId);
+ // If we don't find a record for the file we'll get 0 back for the id
+ if ($serviceId == 0) { return ''; }
+ try {
+ $track = json_decode($this->_client->get('tracks/' . $serviceId));
+ } catch (Soundcloud\Exception\InvalidHttpResponseCodeException $e) {
+ // If we end up here it means the track was removed from SoundCloud
+ // or the foreign id in our database is incorrect, so we should just
+ // get rid of the database record
+ Logging::warn("Error retrieving track data from SoundCloud: " . $e->getMessage());
+ $this->removeTrackReference($fileId);
+ throw $e; // Throw the exception up to the controller so we can redirect to a 404
+ }
+ return $track->permalink_url;
+ }
+
+ /**
+ * Check whether an access token exists for the SoundCloud client
+ *
+ * @return bool true if an access token exists, otherwise false
+ */
+ public function hasAccessToken() {
+ return !empty($this->_accessToken);
+ }
+
+ /**
+ * Get the SoundCloud authorization URL
+ *
+ * @return string the authorization URL
+ */
+ public function getAuthorizeUrl() {
+ // Pass the current URL in the state parameter in order to preserve it
+ // in the redirect. This allows us to create a singular script to redirect
+ // back to any station the request comes from.
+ $url = urlencode('http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST'].'/soundcloud/redirect');
+ return $this->_client->getAuthorizeUrl(array("state" => $url, "scope" => "non-expiring"));
+ }
+
+ /**
+ * Request a new access token from SoundCloud and store it in CcPref
+ *
+ * @param $code string exchange authorization code for access token
+ */
+ public function requestNewAccessToken($code) {
+ // Get a non-expiring access token
+ $response = $this->_client->accessToken($code);
+ $accessToken = $response['access_token'];
+ Application_Model_Preference::setSoundCloudRequestToken($accessToken);
+ $this->_accessToken = $accessToken;
+ }
+
+ /**
+ * Regenerate the SoundCloud client's access token
+ *
+ * @throws Soundcloud\Exception\InvalidHttpResponseCodeException
+ * thrown when attempting to regenerate a stale token
+ */
+ public function accessTokenRefresh() {
+ assert($this->hasAccessToken());
+ try {
+ $accessToken = $this->_accessToken;
+ $this->_client->accessTokenRefresh($accessToken);
+ } catch(Soundcloud\Exception\InvalidHttpResponseCodeException $e) {
+ // If we get here, then that means our token is stale, so remove it
+ // Because we're using non-expiring tokens, we shouldn't get here (!)
+ Application_Model_Preference::setSoundCloudRequestToken("");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/services/ThirdPartyCeleryService.php b/airtime_mvc/application/services/ThirdPartyCeleryService.php
new file mode 100644
index 000000000..5dbc1ebad
--- /dev/null
+++ b/airtime_mvc/application/services/ThirdPartyCeleryService.php
@@ -0,0 +1,131 @@
+ $this->_getUploadData($file),
+ 'token' => $this->_accessToken,
+ 'file_path' => $file->getFilePaths()[0]
+ );
+ try {
+ $brokerTaskId = CeleryService::sendCeleryMessage(static::$_CELERY_UPLOAD_TASK_NAME,
+ static::$_CELERY_EXCHANGE_NAME,
+ $data);
+ $this->_createTaskReference($fileId, $brokerTaskId, static::$_CELERY_UPLOAD_TASK_NAME);
+ } catch (Exception $e) {
+ Logging::info("Invalid request: " . $e->getMessage());
+ }
+ }
+
+ /**
+ * Delete the file with the given identifier from a third-party service
+ *
+ * @param int $fileId the local CcFiles identifier
+ *
+ * @throws ServiceNotFoundException when a $fileId with no corresponding
+ * service identifier is given
+ */
+ public function delete($fileId) {
+ $serviceId = $this->getServiceId($fileId);
+ if ($serviceId == 0) {
+ throw new ServiceNotFoundException("No service found for file with ID $fileId");
+ }
+ $data = array(
+ 'token' => $this->_accessToken,
+ 'track_id' => $serviceId
+ );
+ try {
+ $brokerTaskId = CeleryService::sendCeleryMessage(static::$_CELERY_DELETE_TASK_NAME,
+ static::$_CELERY_EXCHANGE_NAME,
+ $data);
+ $this->_createTaskReference($fileId, $brokerTaskId, static::$_CELERY_DELETE_TASK_NAME);
+ } catch (Exception $e) {
+ Logging::info("Invalid request: " . $e->getMessage());
+ }
+ }
+
+ /**
+ * Create a CeleryTasks object for a pending task
+ * TODO: should we have a database layer class to handle Propel operations?
+ *
+ * @param $fileId int CcFiles identifier
+ * @param $brokerTaskId int broker task identifier to so we can asynchronously
+ * receive completed task messages
+ * @param $taskName string broker task name
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ protected function _createTaskReference($fileId, $brokerTaskId, $taskName) {
+ $trackId = $this->createTrackReference($fileId);
+ $task = new CeleryTasks();
+ $task->setDbTaskId($brokerTaskId);
+ $task->setDbName($taskName);
+ $utc = new DateTimeZone("UTC");
+ $task->setDbDispatchTime(new DateTime("now", $utc));
+ $task->setDbStatus(CELERY_PENDING_STATUS);
+ $task->setDbTrackReference($trackId);
+ $task->save();
+ }
+
+ /**
+ * Update a CeleryTasks object for a completed upload
+ * TODO: should we have a database layer class to handle Propel operations?
+ *
+ * @param $trackId int ThirdPartyTrackReferences identifier
+ * @param $track object third-party service track object
+ * @param $status string Celery task status
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ public function updateTrackReference($trackId, $track, $status) {
+ $task = CeleryTasksQuery::create()
+ ->findOneByDbTrackReference($trackId);
+ $task->setDbStatus($status);
+ $task->save();
+ }
+
+ /**
+ * Field accessor for $_CELERY_DELETE_TASK_NAME
+ *
+ * @return string the Celery task name for deleting tracks from this service
+ */
+ public function getCeleryDeleteTaskName() {
+ return static::$_CELERY_DELETE_TASK_NAME;
+ }
+
+ /**
+ * Build a parameter array for the file being uploaded to a third party service
+ *
+ * @param $file Application_Model_StoredFile the file being uploaded
+ *
+ * @return array the track array to send to the third party service
+ */
+ abstract protected function _getUploadData($file);
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/services/ThirdPartyService.php b/airtime_mvc/application/services/ThirdPartyService.php
new file mode 100644
index 000000000..5af1eb0e4
--- /dev/null
+++ b/airtime_mvc/application/services/ThirdPartyService.php
@@ -0,0 +1,149 @@
+filterByDbService(static::$_SERVICE_NAME)
+ ->findOneByDbFileId($fileId);
+ if (is_null($ref)) {
+ $ref = new ThirdPartyTrackReferences();
+ }
+ $ref->setDbService(static::$_SERVICE_NAME);
+ // TODO: implement service-specific statuses?
+ // $ref->setDbStatus(CELERY_PENDING_STATUS);
+ $ref->setDbFileId($fileId);
+ $ref->save();
+ return $ref->getDbId();
+ }
+
+ /**
+ * Remove a ThirdPartyTrackReferences from the database.
+ * This is necessary if the track was removed from the service
+ * or the foreign id in our database is incorrect
+ *
+ * @param $fileId int cc_files identifier
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ public function removeTrackReference($fileId) {
+ $ref = ThirdPartyTrackReferencesQuery::create()
+ ->filterByDbService(static::$_SERVICE_NAME)
+ ->findOneByDbFileId($fileId);
+ $ref->delete();
+ }
+
+ /**
+ * Given a CcFiles identifier for a file that's been uploaded to a third-party service,
+ * return the third-party identifier for the remote file
+ *
+ * @param int $fileId the cc_files identifier
+ *
+ * @return string the service foreign identifier
+ */
+ public function getServiceId($fileId) {
+ $ref = ThirdPartyTrackReferencesQuery::create()
+ ->filterByDbService(static::$_SERVICE_NAME)
+ ->findOneByDbFileId($fileId); // There shouldn't be duplicates!
+ return empty($ref) ? '' : $ref->getDbForeignId();
+ }
+
+ /**
+ * Check if a reference exists for a given CcFiles identifier
+ *
+ * @param int $fileId the cc_files identifier
+ *
+ * @return string the service foreign identifier
+ */
+ public function referenceExists($fileId) {
+ $ref = ThirdPartyTrackReferencesQuery::create()
+ ->filterByDbService(static::$_SERVICE_NAME)
+ ->findOneByDbFileId($fileId); // There shouldn't be duplicates!
+ if (!empty($ref)) {
+ $task = CeleryTasksQuery::create()
+ ->findOneByDbTrackReference($ref->getDbId());
+ return $task->getDbStatus() != CELERY_FAILED_STATUS;
+ }
+ return false;
+ }
+
+ /**
+ * Given a CcFiles identifier for a file that's been uploaded to a third-party service,
+ * return a link to the remote file
+ *
+ * @param int $fileId the cc_files identifier
+ *
+ * @return string the link to the remote file
+ */
+ public function getLinkToFile($fileId) {
+ $serviceId = $this->getServiceId($fileId);
+ return empty($serviceId) ? '' : static::$_THIRD_PARTY_TRACK_URI . $serviceId;
+ }
+
+ /**
+ * Upload the file with the given identifier to a third-party service
+ *
+ * @param int $fileId the cc_files identifier
+ */
+ abstract function upload($fileId);
+
+ /**
+ * Delete the file with the given identifier from a third-party service
+ *
+ * @param int $fileId the cc_files identifier
+ *
+ * @throws ServiceNotFoundException when a $fileId with no corresponding
+ * service identifier is given
+ */
+ abstract function delete($fileId);
+
+ /**
+ * Update a ThirdPartyTrackReferences object for a completed task
+ *
+ * @param $trackId int ThirdPartyTrackReferences identifier
+ * @param $track object third-party service track object
+ * @param $status string Celery task status
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ abstract function updateTrackReference($trackId, $track, $status);
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php
index 812a36fb9..aa012eca6 100644
--- a/airtime_mvc/application/upgrade/Upgrades.php
+++ b/airtime_mvc/application/upgrade/Upgrades.php
@@ -1,69 +1,137 @@
runUpgrades($upgraders, (dirname(__DIR__) . "/controllers"));
+ */
}
/**
- * Run a given set of upgrades
- *
- * @param array $upgraders the upgrades to perform
- * @param string $dir the directory containing the upgrade sql
+ * Upgrade the Airtime schema version to match the highest supported version
+ *
* @return boolean whether or not an upgrade was performed
*/
- public function runUpgrades($upgraders, $dir) {
+ public static function doUpgrade()
+ {
+ // Get all upgrades dynamically (in declaration order!) so we don't have to add them explicitly each time
+ // TODO: explicitly sort classnames by ascending version suffix for safety
+ $upgraders = getUpgrades();
+ $dir = (dirname(__DIR__) . "/controllers");
$upgradePerformed = false;
-
- for($i = 0; $i < count($upgraders); $i++) {
- $upgrader = $upgraders[$i];
- if ($upgrader->checkIfUpgradeSupported()) {
- // pass the given directory to the upgrades, since __DIR__ returns parent dir of file, not executor
- $upgrader->upgrade($dir); // This will throw an exception if the upgrade fails.
- $upgradePerformed = true;
- $i = 0; // Start over, in case the upgrade handlers are not in ascending order.
- }
+
+ foreach ($upgraders as $upgrader) {
+ $upgradePerformed = self::_runUpgrade(new $upgrader($dir)) ? true : $upgradePerformed;
}
-
+
return $upgradePerformed;
}
+ /**
+ * Downgrade the Airtime schema version to match the given version
+ *
+ * @param string $toVersion the version we want to downgrade to
+ *
+ * @return boolean whether or not an upgrade was performed
+ */
+ public static function doDowngrade($toVersion)
+ {
+ $downgraders = array_reverse(getUpgrades()); // Reverse the array because we're downgrading
+ $dir = (dirname(__DIR__) . "/controllers");
+ $downgradePerformed = false;
+
+ foreach ($downgraders as $downgrader) {
+ /** @var AirtimeUpgrader $downgrader */
+ $downgrader = new $downgrader($dir);
+ if ($downgrader->getNewVersion() == $toVersion) {
+ break; // We've reached the version we wanted to downgrade to, so break
+ }
+ $downgradePerformed = self::_runDowngrade($downgrader) ? true : $downgradePerformed;
+ }
+
+ return $downgradePerformed;
+ }
+
+ /**
+ * Run the given upgrade
+ *
+ * @param $upgrader AirtimeUpgrader the upgrader class to be executed
+ *
+ * @return bool true if the upgrade was successful, otherwise false
+ */
+ private static function _runUpgrade(AirtimeUpgrader $upgrader) {
+ return $upgrader->checkIfUpgradeSupported() && $upgrader->upgrade();
+ }
+
+ /**
+ * Run the given downgrade
+ *
+ * @param $downgrader AirtimeUpgrader the upgrader class to be executed
+ * @param $supportedVersions array array of supported versions
+ *
+ * @return bool true if the downgrade was successful, otherwise false
+ */
+ private static function _runDowngrade(AirtimeUpgrader $downgrader) {
+ return $downgrader->checkIfDowngradeSupported() && $downgrader->downgrade();
+ }
+
}
abstract class AirtimeUpgrader
{
+ protected $_dir;
+
+ protected $username, $password, $host, $database;
+
+ /**
+ * @param $dir string directory housing upgrade files
+ */
+ public function __construct($dir) {
+ $this->_dir = $dir;
+ }
+
/** Schema versions that this upgrader class can upgrade from (an array of version strings). */
abstract protected function getSupportedSchemaVersions();
+
/** The schema version that this upgrader class will upgrade to. (returns a version string) */
abstract public function getNewVersion();
@@ -71,19 +139,26 @@ abstract class AirtimeUpgrader
{
return Application_Model_Preference::GetSchemaVersion();
}
-
- /**
+
+ /**
* This function checks to see if this class can perform an upgrade of your version of Airtime
* @return boolean True if we can upgrade your version of Airtime.
*/
public function checkIfUpgradeSupported()
- {
- if (!in_array(AirtimeUpgrader::getCurrentSchemaVersion(), $this->getSupportedSchemaVersions())) {
- return false;
- }
- return true;
+ {
+ return in_array(static::getCurrentSchemaVersion(), $this->getSupportedSchemaVersions());
}
-
+
+ /**
+ * This function checks to see if this class can perform a downgrade of your version of Airtime
+ *
+ * @return boolean True if we can downgrade your version of Airtime.
+ */
+ public function checkIfDowngradeSupported()
+ {
+ return static::getCurrentSchemaVersion() == $this->getNewVersion();
+ }
+
protected function toggleMaintenanceScreen($toggle)
{
if ($toggle)
@@ -105,9 +180,86 @@ abstract class AirtimeUpgrader
}*/
}
}
-
- /** Implement this for each new version of Airtime */
- abstract public function upgrade();
+
+ /**
+ * Implement this for each new version of Airtime
+ * This function abstracts out the core upgrade functionality,
+ * allowing child classes to overwrite _runUpgrade to reduce duplication
+ */
+ public function upgrade() {
+ Cache::clear();
+ assert($this->checkIfUpgradeSupported());
+
+ try {
+ // $this->toggleMaintenanceScreen(true);
+ Cache::clear();
+
+ $this->_getDbValues();
+ $this->_runUpgrade();
+
+ Application_Model_Preference::SetSchemaVersion($this->getNewVersion());
+ Cache::clear();
+
+ // $this->toggleMaintenanceScreen(false);
+ } catch(Exception $e) {
+ // $this->toggleMaintenanceScreen(false);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Implement this for each new version of Airtime
+ * This function abstracts out the core downgrade functionality,
+ * allowing child classes to overwrite _runDowngrade to reduce duplication
+ */
+ public function downgrade() {
+ Cache::clear();
+
+ try {
+ $this->_getDbValues();
+ $this->_runDowngrade();
+
+ $highestSupportedVersion = null;
+ foreach ($this->getSupportedSchemaVersions() as $v) {
+ // version_compare returns 1 (true) if the second parameter is lower
+ if (!$highestSupportedVersion || version_compare($v, $highestSupportedVersion)) {
+ $highestSupportedVersion = $v;
+ }
+ }
+
+ // Set the schema version to the highest supported version so we don't skip versions when downgrading
+ Application_Model_Preference::SetSchemaVersion($highestSupportedVersion);
+
+ Cache::clear();
+ } catch(Exception $e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ protected function _getDbValues() {
+ $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
+ $values = parse_ini_file($airtimeConf, true);
+
+ $this->username = $values['database']['dbuser'];
+ $this->password = $values['database']['dbpass'];
+ $this->host = $values['database']['host'];
+ $this->database = $values['database']['dbname'];
+ }
+
+ protected function _runUpgrade() {
+ passthru("export PGPASSWORD=".$this->password." && psql -h ".$this->host." -U ".$this->username." -q -f ".$this->_dir."/upgrade_sql/airtime_"
+ .$this->getNewVersion()."/upgrade.sql ".$this->database." 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
+ }
+
+ protected function _runDowngrade() {
+ passthru("export PGPASSWORD=".$this->password." && psql -h ".$this->host." -U ".$this->username." -q -f ".$this->_dir."/downgrade_sql/airtime_"
+ .$this->getNewVersion()."/downgrade.sql ".$this->database." 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
+ }
+
}
class AirtimeUpgrader253 extends AirtimeUpgrader
@@ -121,60 +273,17 @@ class AirtimeUpgrader253 extends AirtimeUpgrader
{
return '2.5.3';
}
-
- public function upgrade($dir = __DIR__)
- {
- Cache::clear();
- assert($this->checkIfUpgradeSupported());
-
- $con = Propel::getConnection();
- $con->beginTransaction();
- try {
-
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- //Begin upgrade
-
- //Update disk_usage value in cc_pref
- $musicDir = CcMusicDirsQuery::create()
- ->filterByType('stor')
- ->filterByExists(true)
- ->findOne();
- $storPath = $musicDir->getDirectory();
-
- //Update disk_usage value in cc_pref
- $storDir = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."srv/airtime/stor" : "/srv/airtime/stor";
- $diskUsage = shell_exec("du -sb $storDir | awk '{print $1}'");
-
- Application_Model_Preference::setDiskUsage($diskUsage);
-
- //clear out the cache
- Cache::clear();
-
- $con->commit();
-
- //update system_version in cc_pref and change some columns in cc_files
- $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
- $values = parse_ini_file($airtimeConf, true);
-
- $username = $values['database']['dbuser'];
- $password = $values['database']['dbpass'];
- $host = $values['database']['host'];
- $database = $values['database']['dbname'];
-
- passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_".$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
- Application_Model_Preference::SetSchemaVersion($this->getNewVersion());
- //clear out the cache
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
-
- } catch (Exception $e) {
- $con->rollback();
- $this->toggleMaintenanceScreen(false);
- }
+ protected function _runUpgrade()
+ {
+ //Update disk_usage value in cc_pref
+ $storDir = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."srv/airtime/stor" : "/srv/airtime/stor";
+ $diskUsage = shell_exec("du -sb $storDir | awk '{print $1}'");
+
+ Application_Model_Preference::setDiskUsage($diskUsage);
+
+ //update system_version in cc_pref and change some columns in cc_files
+ parent::_runUpgrade();
}
}
@@ -189,78 +298,49 @@ class AirtimeUpgrader254 extends AirtimeUpgrader
return '2.5.4';
}
- public function upgrade()
+ protected function _runUpgrade()
{
- Cache::clear();
-
- assert($this->checkIfUpgradeSupported());
-
- $newVersion = $this->getNewVersion();
-
- $con = Propel::getConnection();
- //$con->beginTransaction();
- try {
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- //Begin upgrade
-
- //First, ensure there are no superadmins already.
- $numberOfSuperAdmins = CcSubjsQuery::create()
+ //First, ensure there are no superadmins already.
+ $numberOfSuperAdmins = CcSubjsQuery::create()
->filterByDbType(UTYPE_SUPERADMIN)
->filterByDbLogin("sourcefabric_admin", Criteria::NOT_EQUAL) //Ignore sourcefabric_admin users
->count();
-
- //Only create a super admin if there isn't one already.
- if ($numberOfSuperAdmins == 0)
- {
- //Find the "admin" user and promote them to superadmin.
- $adminUser = CcSubjsQuery::create()
+
+ //Only create a super admin if there isn't one already.
+ if ($numberOfSuperAdmins == 0)
+ {
+ //Find the "admin" user and promote them to superadmin.
+ $adminUser = CcSubjsQuery::create()
->filterByDbLogin('admin')
->findOne();
- if (!$adminUser)
- {
- //TODO: Otherwise get the user with the lowest ID that is of type administrator:
- //
- $adminUser = CcSubjsQuery::create()
+ if (!$adminUser)
+ {
+ // Otherwise get the user with the lowest ID that is of type administrator:
+ $adminUser = CcSubjsQuery::create()
->filterByDbType(UTYPE_ADMIN)
->orderByDbId(Criteria::ASC)
->findOne();
-
- if (!$adminUser) {
- throw new Exception("Failed to find any users of type 'admin' ('A').");
- }
- }
-
- $adminUser = new Application_Model_User($adminUser->getDbId());
- $adminUser->setType(UTYPE_SUPERADMIN);
- $adminUser->save();
- Logging::info($_SERVER['HTTP_HOST'] . ': ' . $newVersion . " Upgrade: Promoted user " . $adminUser->getLogin() . " to be a Super Admin.");
-
- //Also try to promote the sourcefabric_admin user
- $sofabAdminUser = CcSubjsQuery::create()
- ->filterByDbLogin('sourcefabric_admin')
- ->findOne();
- if ($sofabAdminUser) {
- $sofabAdminUser = new Application_Model_User($sofabAdminUser->getDbId());
- $sofabAdminUser->setType(UTYPE_SUPERADMIN);
- $sofabAdminUser->save();
- Logging::info($_SERVER['HTTP_HOST'] . ': ' . $newVersion . " Upgrade: Promoted user " . $sofabAdminUser->getLogin() . " to be a Super Admin.");
+
+ if (!$adminUser) {
+ throw new Exception("Failed to find any users of type 'admin' ('A').");
}
}
-
- //$con->commit();
- Application_Model_Preference::SetSchemaVersion($newVersion);
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
-
- return true;
-
- } catch(Exception $e) {
- //$con->rollback();
- $this->toggleMaintenanceScreen(false);
- throw $e;
+
+ $adminUser = new Application_Model_User($adminUser->getDbId());
+ $adminUser->setType(UTYPE_SUPERADMIN);
+ $adminUser->save();
+ Logging::info($_SERVER['HTTP_HOST'] . ': ' . $this->getNewVersion() . " Upgrade: Promoted user " . $adminUser->getLogin() . " to be a Super Admin.");
+
+ //Also try to promote the sourcefabric_admin user
+ $sofabAdminUser = CcSubjsQuery::create()
+ ->filterByDbLogin('sourcefabric_admin')
+ ->findOne();
+ if ($sofabAdminUser) {
+ $sofabAdminUser = new Application_Model_User($sofabAdminUser->getDbId());
+ $sofabAdminUser->setType(UTYPE_SUPERADMIN);
+ $sofabAdminUser->save();
+ Logging::info($_SERVER['HTTP_HOST'] . ': ' . $this->getNewVersion() . " Upgrade: Promoted user " . $sofabAdminUser->getLogin() . " to be a Super Admin.");
+ }
}
}
}
@@ -275,40 +355,6 @@ class AirtimeUpgrader255 extends AirtimeUpgrader {
public function getNewVersion() {
return '2.5.5';
}
-
- public function upgrade($dir = __DIR__) {
- Cache::clear();
- assert($this->checkIfUpgradeSupported());
-
- $newVersion = $this->getNewVersion();
-
- try {
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- // Begin upgrade
- $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
- $values = parse_ini_file($airtimeConf, true);
-
- $username = $values['database']['dbuser'];
- $password = $values['database']['dbpass'];
- $host = $values['database']['host'];
- $database = $values['database']['dbname'];
-
- passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
- .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
-
- Application_Model_Preference::SetSchemaVersion($newVersion);
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
-
- return true;
- } catch(Exception $e) {
- $this->toggleMaintenanceScreen(false);
- throw $e;
- }
- }
}
class AirtimeUpgrader259 extends AirtimeUpgrader {
@@ -321,38 +367,6 @@ class AirtimeUpgrader259 extends AirtimeUpgrader {
public function getNewVersion() {
return '2.5.9';
}
-
- public function upgrade($dir = __DIR__) {
- Cache::clear();
- assert($this->checkIfUpgradeSupported());
-
- $newVersion = $this->getNewVersion();
-
- try {
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- // Begin upgrade
- $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
- $values = parse_ini_file($airtimeConf, true);
-
- $username = $values['database']['dbuser'];
- $password = $values['database']['dbpass'];
- $host = $values['database']['host'];
- $database = $values['database']['dbname'];
-
- passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
- .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
-
- Application_Model_Preference::SetSchemaVersion($newVersion);
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
- } catch(Exception $e) {
- $this->toggleMaintenanceScreen(false);
- throw $e;
- }
- }
}
class AirtimeUpgrader2510 extends AirtimeUpgrader
@@ -366,38 +380,6 @@ class AirtimeUpgrader2510 extends AirtimeUpgrader
public function getNewVersion() {
return '2.5.10';
}
-
- public function upgrade($dir = __DIR__) {
- Cache::clear();
- assert($this->checkIfUpgradeSupported());
-
- $newVersion = $this->getNewVersion();
-
- try {
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- // Begin upgrade
- $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
- $values = parse_ini_file($airtimeConf, true);
-
- $username = $values['database']['dbuser'];
- $password = $values['database']['dbpass'];
- $host = $values['database']['host'];
- $database = $values['database']['dbname'];
-
- passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
- .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
-
- Application_Model_Preference::SetSchemaVersion($newVersion);
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
- } catch(Exception $e) {
- $this->toggleMaintenanceScreen(false);
- throw $e;
- }
- }
}
class AirtimeUpgrader2511 extends AirtimeUpgrader
@@ -412,35 +394,13 @@ class AirtimeUpgrader2511 extends AirtimeUpgrader
return '2.5.11';
}
- public function upgrade($dir = __DIR__) {
- Cache::clear();
- assert($this->checkIfUpgradeSupported());
-
- $newVersion = $this->getNewVersion();
-
- try {
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- // Begin upgrade
- $queryResult = CcFilesQuery::create()
- ->select(array('disk_usage'))
- ->withColumn('SUM(CcFiles.filesize)', 'disk_usage')
- ->find();
- $disk_usage = $queryResult[0];
- Application_Model_Preference::setDiskUsage($disk_usage);
-
- Application_Model_Preference::SetSchemaVersion($newVersion);
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
- } catch(Exception $e) {
- $this->toggleMaintenanceScreen(false);
- throw $e;
- }
- }
- public function downgrade() {
-
+ protected function _runUpgrade() {
+ $queryResult = CcFilesQuery::create()
+ ->select(array('disk_usage'))
+ ->withColumn('SUM(CcFiles.filesize)', 'disk_usage')
+ ->find();
+ $disk_usage = $queryResult[0];
+ Application_Model_Preference::setDiskUsage($disk_usage);
}
}
@@ -456,39 +416,42 @@ class AirtimeUpgrader2512 extends AirtimeUpgrader
public function getNewVersion() {
return '2.5.12';
}
+}
- public function upgrade($dir = __DIR__) {
- Cache::clear();
- assert($this->checkIfUpgradeSupported());
-
- $newVersion = $this->getNewVersion();
-
- try {
- $this->toggleMaintenanceScreen(true);
- Cache::clear();
-
- // Begin upgrade
- $airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
- $values = parse_ini_file($airtimeConf, true);
-
- $username = $values['database']['dbuser'];
- $password = $values['database']['dbpass'];
- $host = $values['database']['host'];
- $database = $values['database']['dbname'];
-
- passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
- .$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v -E \"will create implicit sequence|will create implicit index\"");
-
- Application_Model_Preference::SetSchemaVersion($newVersion);
- Cache::clear();
-
- $this->toggleMaintenanceScreen(false);
- } catch(Exception $e) {
- $this->toggleMaintenanceScreen(false);
- throw $e;
- }
+/**
+ * Class AirtimeUpgrader2513 - Celery and SoundCloud upgrade
+ *
+ * Adds third_party_track_references and celery_tasks tables for third party service
+ * authentication and task architecture.
+ *
+ * sudo service airtime-playout start sudo service airtime-liquidsoap start -sudo service airtime-media-monitor start+sudo service airtime_analyzer start +sudo service airtime-celery start
Click "Done!" to bring up the Airtime configuration checklist; if your configuration is all green,
you're ready to get started with your personal Airtime station!
diff --git a/airtime_mvc/build/airtime-setup/load.php b/airtime_mvc/build/airtime-setup/load.php
index 722d6aec8..107b02b35 100644
--- a/airtime_mvc/build/airtime-setup/load.php
+++ b/airtime_mvc/build/airtime-setup/load.php
@@ -63,7 +63,7 @@ function checkDatabaseDependencies() {
function checkExternalServices() {
return array(
"database" => checkDatabaseConfiguration(),
- "media-monitor" => checkMediaMonitorService(),
+ "analyzer" => checkAnalyzerService(),
"pypo" => checkPlayoutService(),
"liquidsoap" => checkLiquidsoapService(),
"rabbitmq" => checkRMQConnection()
@@ -123,8 +123,8 @@ function checkRMQConnection() {
*
* @return boolean true if airtime-media-monitor is running
*/
-function checkMediaMonitorService() {
- exec("pgrep -f -u www-data airtime-media-monitor", $out, $status);
+function checkAnalyzerService() {
+ exec("pgrep -f -u www-data airtime_analyzer", $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}
diff --git a/airtime_mvc/build/build.properties b/airtime_mvc/build/build.properties
index ee5a5f8fa..556862bb1 100644
--- a/airtime_mvc/build/build.properties
+++ b/airtime_mvc/build/build.properties
@@ -1,6 +1,6 @@
#Note: project.home is automatically generated by the propel-install script.
#Any manual changes to this value will be overwritten.
-project.home = /home/sourcefabric/dev/Airtime-SaaS/Airtime/airtime_mvc
+project.home = /home/sourcefabric/dev/Airtime/airtime_mvc
project.build = ${project.home}/build
#Database driver
diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml
index ece788ea7..87f820cb6 100644
--- a/airtime_mvc/build/schema.xml
+++ b/airtime_mvc/build/schema.xml
@@ -531,4 +531,34 @@
try {
- $response = json_decode($soundcloud->get('me'), true);
-} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
- exit($e->getMessage());
-}
-
-### POST
-
-$comment = <<<EOH
-<comment>
- <body>Yeah!</body>
-</comment>
-EOH;
-
-try {
- $response = json_decode(
- $soundcloud->post(
- 'tracks/1/comments',
- $comment,
- array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml'))
- ),
- true
- );
-} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
- exit($e->getMessage());
-}
-
-### PUT
-
-$track = <<<EOH
-<track>
- <downloadable>true</downloadable>
-</track>
-EOH;
-
-try {
- $response = json_decode(
- $soundcloud->put(
- 'tracks/1',
- $track,
- array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml'))
- ),
- true
- );
-} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
- exit($e->getMessage());
-}
-
-### DELETE
-
-try {
- $response = json_decode($soundcloud->delete('tracks/1'), true);
-} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
- exit($e->getMessage());
-}
-
-### DOWNLOAD TRACK
-
-try {
- $track = $soundcloud->download(1337);
-} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
- exit($e->getMessage());
-}
-
-// do something clever with $track. Save to file perhaps?
-
-## Feedback and questions
-
-Found a bug or missing a feature? Don't hesitate to create a new issue here on GitHub. Or contact me [directly](https://github.com/mptre).
-
-Also make sure to check out the official [documentation](https://github.com/soundcloud/api/wiki/) and the join [Google Group](https://groups.google.com/group/soundcloudapi?pli=1) in order to stay updated.
-
-## License
-
-Copyright (c) 2011 Anton Lindqvist
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/airtime_mvc/library/soundcloud-api/Services/Soundcloud.php b/airtime_mvc/library/soundcloud-api/Services/Soundcloud.php
deleted file mode 100644
index 9eba8eade..000000000
--- a/airtime_mvc/library/soundcloud-api/Services/Soundcloud.php
+++ /dev/null
@@ -1,737 +0,0 @@
-
- * @copyright 2010 Anton Lindqvist