diff --git a/.gitignore b/.gitignore index 3f52a5722..5a4e08e87 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.pyc /files python_apps/pypo/liquidsoap_bin/liquidsoap +python_apps/pypo/liquidsoap/ build/build.properties diff --git a/CREDITS b/CREDITS index b6108f552..745ae324b 100644 --- a/CREDITS +++ b/CREDITS @@ -1,6 +1,21 @@ ======= CREDITS ======= +Version 1.9.4 +------------- +Same as previous version. + +Version 1.9.3 +------------- +Same as previous version. + +Version 1.9.2 +------------- +Same as previous version. + +Version 1.9.1 +------------- +Same as previous version. Version 1.9.0 ------------- diff --git a/LICENSE_3RD_PARTY b/LICENSE_3RD_PARTY index 1b6aebdc7..9bc1f8019 100644 --- a/LICENSE_3RD_PARTY +++ b/LICENSE_3RD_PARTY @@ -3,7 +3,10 @@ This application uses the following 3rd Party software: ---------------------- Common Non-linked Code ---------------------- - * Linux (Ubuntu & Debian) + * Linux + - What is it: Kernel + - Web site: https://github.com/torvalds/linux + - License: GPLv2 * RabbitMQ (works with version 1.7.2 and above) - What is it: Interprocess Message Passing with Queuing @@ -40,7 +43,7 @@ Linked code: * Phing - What is it: PHP project build system - Web site: http://phing.info/trac/ - - Note: Only used for development, not needed to run Airtime. + - Note: Only used for database installation and development, not needed to run Airtime. - License: LGPLv3 * PHP-AMQPLIB @@ -108,6 +111,10 @@ Non-linked code: * Server Browse - Web site: http://code.google.com/p/jq-serverbrowse/ - License: BSD 2-Clause + + * meioMask + - Web site: http://www.meiocodigo.com/ + - License: MIT ------------- Media-Monitor diff --git a/VERSION b/VERSION index df9515d6e..aa0e5423d 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ PRODUCT_ID=Airtime -PRODUCT_RELEASE=1.9.1 +PRODUCT_RELEASE=2.0.0-beta1 diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index c60840fb4..f3bf8f561 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -6,24 +6,12 @@ require_once __DIR__."/configs/ACL.php"; require_once 'propel/runtime/lib/Propel.php'; Propel::init(__DIR__."/configs/airtime-conf.php"); -//DateTime in PHP 5.3.0+ need a default timezone set. -$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC'; -date_default_timezone_set($tz); - require_once __DIR__."/logging/Logging.php"; require_once __DIR__."/configs/constants.php"; require_once __DIR__."/configs/conf.php"; require_once 'DB.php'; -require_once 'Soundcloud.php'; -require_once 'MusicDir.php'; -require_once 'Playlist.php'; -require_once 'StoredFile.php'; -require_once 'Schedule.php'; -require_once 'Shows.php'; -require_once 'Users.php'; -require_once 'RabbitMq.php'; -require_once 'DateHelper.php'; +require_once 'Preference.php'; require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; global $CC_CONFIG, $CC_DBC; @@ -31,49 +19,58 @@ $dsn = $CC_CONFIG['dsn']; $CC_DBC = DB::connect($dsn, FALSE); if (PEAR::isError($CC_DBC)) { - echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n"; - exit(1); + echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n"; + exit(1); } $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); + +//DateTime in PHP 5.3.0+ need a default timezone set. +date_default_timezone_set(Application_Model_Preference::GetTimezone()); + Logging::setLogPath('/var/log/airtime/zendphp.log'); Zend_Validate::setDefaultNamespaces("Zend"); $front = Zend_Controller_Front::getInstance(); -$front->registerPlugin(new RabbitMqPlugin()); +$front->registerPlugin(new RabbitMqPlugin()); + +/* The bootstrap class should only be used to initialize actions that return a view. + Actions that return JSON will not use the bootstrap class! */ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { - protected function _initDoctype() + protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML1_STRICT'); } - protected function _initHeadLink() - { - $view = $this->getResource('view'); + protected function _initHeadLink() + { + $view = $this->getResource('view'); $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); - $view->headLink()->appendStylesheet($baseUrl.'/css/redmond/jquery-ui-1.8.8.custom.css'); + $view->headLink()->appendStylesheet($baseUrl.'/css/redmond/jquery-ui-1.8.8.custom.css'); $view->headLink()->appendStylesheet($baseUrl.'/css/pro_dropdown_3.css'); - $view->headLink()->appendStylesheet($baseUrl.'/css/styles.css'); - } + $view->headLink()->appendStylesheet($baseUrl.'/css/styles.css'); + } - protected function _initHeadScript() - { - $view = $this->getResource('view'); + protected function _initHeadScript() + { + $view = $this->getResource('view'); $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-1.5.2.min.js','text/javascript'); - $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-ui-1.8.11.custom.min.js','text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/libs/jquery-ui-1.8.11.custom.min.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/libs/jquery.stickyPanel.js','text/javascript'); - $view->headScript()->appendFile($baseUrl.'/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/qtip/jquery.qtip2.min.js','text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/jplayer/jquery.jplayer.min.js'); + $view->headScript()->appendScript("var baseUrl='$baseUrl/'"); //scripts for now playing bar $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript'); - $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript'); } @@ -90,5 +87,26 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->headTitle(Application_Model_Preference::GetHeadTitle()); } + protected function _initZFDebug() + { + if (APPLICATION_ENV == "development"){ + global $CC_DBC; + + $autoloader = Zend_Loader_Autoloader::getInstance(); + $autoloader->registerNamespace('ZFDebug'); + + $options = array( + 'plugins' => array('Variables', + 'Exception', + 'Memory', + 'Time') + ); + $debug = new ZFDebug_Controller_Plugin_Debug($options); + + $this->bootstrap('frontController'); + $frontController = $this->getResource('frontController'); + $frontController->registerPlugin($debug); + } + } } diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index 5fa4b7a05..72187e4e9 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -19,6 +19,7 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('api')) ->add(new Zend_Acl_Resource('nowplaying')) + ->add(new Zend_Acl_Resource('systemstatus')) ->add(new Zend_Acl_Resource('search')) ->add(new Zend_Acl_Resource('dashboard')) ->add(new Zend_Acl_Resource('preference')) @@ -40,6 +41,7 @@ $ccAcl->allow('G', 'index') ->allow('H', 'search') ->allow('H', 'playlist') ->allow('A', 'user') + ->allow('A', 'systemstatus') ->allow('A', 'preference'); $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); diff --git a/airtime_mvc/application/configs/airtime-conf.php b/airtime_mvc/application/configs/airtime-conf.php index 1fe0ecb7e..74936f1ca 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 7dec19b57..ef3b99a4b 100644 --- a/airtime_mvc/application/configs/classmap-airtime-conf.php +++ b/airtime_mvc/application/configs/classmap-airtime-conf.php @@ -120,4 +120,25 @@ return array ( 'BaseCcCountryPeer' => 'airtime/om/BaseCcCountryPeer.php', 'BaseCcCountry' => 'airtime/om/BaseCcCountry.php', 'BaseCcCountryQuery' => 'airtime/om/BaseCcCountryQuery.php', + 'CcStreamSettingTableMap' => 'airtime/map/CcStreamSettingTableMap.php', + 'CcStreamSettingPeer' => 'airtime/CcStreamSettingPeer.php', + 'CcStreamSetting' => 'airtime/CcStreamSetting.php', + 'CcStreamSettingQuery' => 'airtime/CcStreamSettingQuery.php', + 'BaseCcStreamSettingPeer' => 'airtime/om/BaseCcStreamSettingPeer.php', + 'BaseCcStreamSetting' => 'airtime/om/BaseCcStreamSetting.php', + 'BaseCcStreamSettingQuery' => 'airtime/om/BaseCcStreamSettingQuery.php', + 'CcLoginAttemptsTableMap' => 'airtime/map/CcLoginAttemptsTableMap.php', + 'CcLoginAttemptsPeer' => 'airtime/CcLoginAttemptsPeer.php', + 'CcLoginAttempts' => 'airtime/CcLoginAttempts.php', + 'CcLoginAttemptsQuery' => 'airtime/CcLoginAttemptsQuery.php', + 'BaseCcLoginAttemptsPeer' => 'airtime/om/BaseCcLoginAttemptsPeer.php', + 'BaseCcLoginAttempts' => 'airtime/om/BaseCcLoginAttempts.php', + 'BaseCcLoginAttemptsQuery' => 'airtime/om/BaseCcLoginAttemptsQuery.php', + 'CcServiceRegisterTableMap' => 'airtime/map/CcServiceRegisterTableMap.php', + 'CcServiceRegisterPeer' => 'airtime/CcServiceRegisterPeer.php', + 'CcServiceRegister' => 'airtime/CcServiceRegister.php', + 'CcServiceRegisterQuery' => 'airtime/CcServiceRegisterQuery.php', + 'BaseCcServiceRegisterPeer' => 'airtime/om/BaseCcServiceRegisterPeer.php', + 'BaseCcServiceRegister' => 'airtime/om/BaseCcServiceRegister.php', + 'BaseCcServiceRegisterQuery' => 'airtime/om/BaseCcServiceRegisterQuery.php', ); \ No newline at end of file diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index 28db07932..50008e3f8 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -1,6 +1,5 @@ 'schedule' ), array( - 'label' => 'Configure', + 'label' => 'System', 'uri' => '#', 'resource' => 'preference', 'pages' => array( @@ -57,22 +57,55 @@ $pages = array( 'label' => 'Manage Media Folders', 'module' => 'default', 'controller' => 'Preference', - 'action' => 'directory-config' + 'action' => 'directory-config', + 'id' => 'manage_folder' + ), + array( + 'label' => 'Stream Settings', + 'module' => 'default', + 'controller' => 'Preference', + 'action' => 'stream-setting' ), array( 'label' => 'Support Settings', 'module' => 'default', 'controller' => 'Preference', 'action' => 'support-setting' + ), + array( + 'label' => 'Status', + 'module' => 'default', + 'controller' => 'systemstatus', + 'action' => 'index', + 'resource' => 'systemstatus' ) ) ), array( 'label' => 'Help', - 'module' => 'default', - 'controller' => 'dashboard', - 'action' => 'help', - 'resource' => 'dashboard' + 'uri' => '#', + 'resource' => 'dashboard', + 'pages' => array( + array( + 'label' => 'Getting Started', + 'module' => 'default', + 'controller' => 'dashboard', + 'action' => 'help', + 'resource' => 'dashboard' + ), + array( + 'label' => 'User Manual', + 'uri' => "http://en.flossmanuals.net/airtime/", + 'target' => "_blank" + ), + array( + 'label' => 'About', + 'module' => 'default', + 'controller' => 'dashboard', + 'action' => 'about', + 'resource' => 'dashboard' + ) + ) ) ); diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a02183492..1902ea905 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -9,6 +9,7 @@ class ApiController extends Zend_Controller_Action $context = $this->_helper->getHelper('contextSwitch'); $context->addActionContext('version', 'json') ->addActionContext('recorded-shows', 'json') + ->addActionContext('calendar-init', 'json') ->addActionContext('upload-file', 'json') ->addActionContext('upload-recorded', 'json') ->addActionContext('media-monitor-setup', 'json') @@ -19,6 +20,12 @@ class ApiController extends Zend_Controller_Action ->addActionContext('add-watched-dir', 'json') ->addActionContext('remove-watched-dir', 'json') ->addActionContext('set-storage-dir', 'json') + ->addActionContext('get-stream-setting', 'json') + ->addActionContext('status', 'json') + ->addActionContext('register-component', 'json') + ->addActionContext('update-liquidsoap-error', 'json') + ->addActionContext('update-liquidsoap-connection', 'json') + ->addActionContext('library-init', 'json') ->initContext(); } @@ -32,7 +39,7 @@ class ApiController extends Zend_Controller_Action * * First checks to ensure the correct API key was * supplied, then returns AIRTIME_VERSION as defined - * in application/conf.php + * in the database * * @return void * @@ -52,9 +59,32 @@ class ApiController extends Zend_Controller_Action print 'You are not allowed to access this resource.'; exit; } - $jsonStr = json_encode(array("version"=>AIRTIME_VERSION)); + $jsonStr = json_encode(array("version"=>Application_Model_Preference::GetAirtimeVersion())); echo $jsonStr; } + + /** + * Sets up and send init values used in the Calendar. + * This is only being used by schedule.js at the moment. + */ + public function calendarInitAction(){ + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + if(is_null(Zend_Auth::getInstance()->getStorage()->read())) { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + return; + } + + $this->view->calendarInit = array( + "timestamp" => time(), + "timezoneOffset" => date("Z"), + "timeScale" => Application_Model_Preference::GetCalendarTimeScale(), + "timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(), + "weekStartDay" => Application_Model_Preference::GetWeekStartDay() + ); + } /** * Allows remote client to download requested media file. @@ -87,7 +117,7 @@ class ApiController extends Zend_Controller_Action $filename = $this->_getParam("file"); $file_id = substr($filename, 0, strpos($filename, ".")); if (ctype_alnum($file_id) && strlen($file_id) == 32) { - $media = StoredFile::RecallByGunid($file_id); + $media = Application_Model_StoredFile::RecallByGunid($file_id); if ($media != null && !PEAR::isError($media)) { $filepath = $media->getFilePath(); if(is_file($filepath)){ @@ -112,6 +142,7 @@ class ApiController extends Zend_Controller_Action $file_base_name = substr($file_base_name, 1); header('Content-Disposition: attachment; filename="'.$file_base_name.'"'); } + $logger->info("Sending $filepath"); header("Content-Length: " . filesize($filepath)); // !! binary mode !! @@ -148,12 +179,13 @@ class ApiController extends Zend_Controller_Action $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timeNow = $date->getTimestamp(); + $result = array("env"=>APPLICATION_ENV, "schedulerTime"=>gmdate("Y-m-d H:i:s"), - "currentShow"=>Show_DAL::GetCurrentShow($timeNow), - "nextShow"=>Show_DAL::GetNextShows($timeNow, 5), + "currentShow"=>Application_Model_Show::GetCurrentShow($timeNow), + "nextShow"=>Application_Model_Show::GetNextShows($timeNow, 5), "timezone"=> date("T"), "timezoneOffset"=> date("Z")); @@ -178,7 +210,7 @@ class ApiController extends Zend_Controller_Action $result = array(); for ($i=0; $i<7; $i++){ - $result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i); + $result[$dow[$i]] = Application_Model_Show::GetShowsByDayOfWeek($i); } header("Content-type: text/javascript"); @@ -209,7 +241,7 @@ class ApiController extends Zend_Controller_Action PEAR::setErrorHandling(PEAR_ERROR_RETURN); - $result = Schedule::GetScheduledPlaylists(); + $result = Application_Model_Schedule::GetScheduledPlaylists(); echo json_encode($result); } @@ -231,7 +263,7 @@ class ApiController extends Zend_Controller_Action $schedule_group_id = $this->_getParam("schedule_id"); $media_id = $this->_getParam("media_id"); - $result = Schedule::UpdateMediaPlayedStatus($media_id); + $result = Application_Model_Schedule::UpdateMediaPlayedStatus($media_id); if (!PEAR::isError($result)) { echo json_encode(array("status"=>1, "message"=>"")); @@ -260,7 +292,7 @@ class ApiController extends Zend_Controller_Action $schedule_group_id = $this->_getParam("schedule_id"); if (is_numeric($schedule_group_id)) { - $sg = new ScheduleGroup($schedule_group_id); + $sg = new Application_Model_ScheduleGroup($schedule_group_id); if ($sg->exists()) { $result = $sg->notifyGroupStartPlay(); if (!PEAR::isError($result)) { @@ -296,12 +328,12 @@ class ApiController extends Zend_Controller_Action $now = new DateTime($today_timestamp); $end_timestamp = $now->add(new DateInterval("PT2H")); $end_timestamp = $end_timestamp->format("Y-m-d H:i:s"); - $this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE); + $this->view->shows = Application_Model_Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE); $this->view->is_recording = false; - $rows = Show_DAL::GetCurrentShow($today_timestamp); + $rows = Application_Model_Show::GetCurrentShow($today_timestamp); if (count($rows) > 0){ $this->view->is_recording = ($rows[0]['record'] == 1); } @@ -320,9 +352,9 @@ class ApiController extends Zend_Controller_Action } $upload_dir = ini_get("upload_tmp_dir"); - StoredFile::uploadFile($upload_dir); + Application_Model_StoredFile::uploadFile($upload_dir); $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; - StoredFile::copyFileToStor($upload_dir, $fileName); + Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName); } public function uploadRecordedAction() @@ -346,17 +378,17 @@ class ApiController extends Zend_Controller_Action $showCanceled = false; - $file = StoredFile::Recall($file_id); + $file = Application_Model_StoredFile::Recall($file_id); //$show_instance = $this->_getParam('show_instance'); $show_name = null; try { - $show_inst = new ShowInstance($show_instance_id); + $show_inst = new Application_Model_ShowInstance($show_instance_id); $show_inst->setRecordedFile($file_id); $show_name = $show_inst->getName(); $show_genre = $show_inst->getGenre(); - $show_start_time = $show_inst->getShowStart(); + $show_start_time = ConvertToLocalDateTimeString($show_inst->getShowStart()); } catch (Exception $e){ //we've reached here probably because the show was @@ -379,24 +411,31 @@ class ApiController extends Zend_Controller_Action $file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder"); $file->setMetadataValue('MDATA_KEY_TRACKNUMBER', null); - if (!$showCanceled && Application_Model_Preference::GetDoSoundCloudUpload()) + if (!$showCanceled && Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud()) { for ($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { - $show = new Show($show_inst->getShowId()); + $show = new Application_Model_Show($show_inst->getShowId()); $description = $show->getDescription(); $hosts = $show->getHosts(); $tags = array_merge($hosts, array($show_name)); try { - $soundcloud = new ATSoundcloud(); + $soundcloud = new Application_Model_Soundcloud(); $soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $tmpTitle, $description, $tags, $show_start_time, $show_genre); - $show_inst->setSoundCloudFileId($soundcloud_id); + $file->setSoundCloudFileId($soundcloud_id); break; } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { $code = $e->getHttpCode(); + $msg = $e->getHttpBody(); + $temp = explode('"error":',$msg); + $msg = trim($temp[1], '"}'); + $this->setSoundCloudErrorCode($code); + $this->setSoundCloudErrorMsg($msg); + // setting sc id to -3 which indicates error + $this->setSoundCloudFileId(SOUNDCLOUD_ERROR); if(!in_array($code, array(0, 100))) { break; } @@ -425,7 +464,14 @@ class ApiController extends Zend_Controller_Action exit; } - $this->view->stor = MusicDir::getStorDir()->getDirectory(); + $this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory(); + + $watchedDirs = Application_Model_MusicDir::getWatchedDirs(); + $watchedDirsPath = array(); + foreach($watchedDirs as $wd){ + $watchedDirsPath[] = $wd->getDirectory(); + } + $this->view->watched_dirs = $watchedDirsPath; } public function reloadMetadataAction() { @@ -458,10 +504,10 @@ class ApiController extends Zend_Controller_Action $filepath = $md['MDATA_KEY_FILEPATH']; $filepath = str_replace("\\", "", $filepath); - $file = StoredFile::RecallByFilepath($filepath); + $file = Application_Model_StoredFile::RecallByFilepath($filepath); if (is_null($file)) { - $file = StoredFile::Insert($md); + $file = Application_Model_StoredFile::Insert($md); } else { $this->view->error = "File already exists in Airtime."; @@ -471,7 +517,7 @@ class ApiController extends Zend_Controller_Action else if ($mode == "modify") { $filepath = $md['MDATA_KEY_FILEPATH']; $filepath = str_replace("\\", "", $filepath); - $file = StoredFile::RecallByFilepath($filepath); + $file = Application_Model_StoredFile::RecallByFilepath($filepath); //File is not in database anymore. if (is_null($file)) { @@ -485,7 +531,7 @@ class ApiController extends Zend_Controller_Action } else if ($mode == "moved") { $md5 = $md['MDATA_KEY_MD5']; - $file = StoredFile::RecallByMd5($md5); + $file = Application_Model_StoredFile::RecallByMd5($md5); if (is_null($file)) { $this->view->error = "File doesn't exist in Airtime."; @@ -501,7 +547,7 @@ class ApiController extends Zend_Controller_Action else if ($mode == "delete") { $filepath = $md['MDATA_KEY_FILEPATH']; $filepath = str_replace("\\", "", $filepath); - $file = StoredFile::RecallByFilepath($filepath); + $file = Application_Model_StoredFile::RecallByFilepath($filepath); if (is_null($file)) { $this->view->error = "File doesn't exist in Airtime."; @@ -511,6 +557,16 @@ class ApiController extends Zend_Controller_Action $file->delete(); } } + else if ($mode == "delete_dir") { + $filepath = $md['MDATA_KEY_FILEPATH']; + $filepath = str_replace("\\", "", $filepath); + $files = Application_Model_StoredFile::RecallByPartialFilepath($filepath); + + foreach($files as $file){ + $file->delete(); + } + return; + } $this->view->id = $file->getId(); } @@ -527,7 +583,7 @@ class ApiController extends Zend_Controller_Action } $dir_id = $request->getParam('dir_id'); - $this->view->files = StoredFile::listAllFiles($dir_id); + $this->view->files = Application_Model_StoredFile::listAllFiles($dir_id); } public function listAllWatchedDirsAction() { @@ -544,8 +600,8 @@ class ApiController extends Zend_Controller_Action $result = array(); - $arrWatchedDirs = MusicDir::getWatchedDirs(); - $storDir = MusicDir::getStorDir(); + $arrWatchedDirs = Application_Model_MusicDir::getWatchedDirs(); + $storDir = Application_Model_MusicDir::getStorDir(); $result[$storDir->getId()] = $storDir->getDirectory(); @@ -570,7 +626,7 @@ class ApiController extends Zend_Controller_Action exit; } - $this->view->msg = MusicDir::addWatchedDir($path); + $this->view->msg = Application_Model_MusicDir::addWatchedDir($path); } public function removeWatchedDirAction() { @@ -587,7 +643,7 @@ class ApiController extends Zend_Controller_Action exit; } - $this->view->msg = MusicDir::removeWatchedDir($path); + $this->view->msg = Application_Model_MusicDir::removeWatchedDir($path); } public function setStorageDirAction() { @@ -604,7 +660,97 @@ class ApiController extends Zend_Controller_Action exit; } - $this->view->msg = MusicDir::setStorDir($path); + $this->view->msg = Application_Model_MusicDir::setStorDir($path); + } + + public function getStreamSettingAction() { + global $CC_CONFIG; + + $request = $this->getRequest(); + $api_key = $request->getParam('api_key'); + if (!in_array($api_key, $CC_CONFIG["apiKey"])) + { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + exit; + } + + $this->view->msg = Application_Model_StreamSetting::getStreamSetting(); + } + + public function statusAction() { + global $CC_CONFIG; + + $request = $this->getRequest(); + $api_key = $request->getParam('api_key'); + /* + if (!in_array($api_key, $CC_CONFIG["apiKey"])) + { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + exit; + } + */ + + $status = array( + "platform"=>Application_Model_Systemstatus::GetPlatformInfo(), + "airtime_version"=>Application_Model_Preference::GetAirtimeVersion(), + "services"=>array( + "rabbitmq"=>Application_Model_Systemstatus::GetRabbitMqStatus(), + "pypo"=>Application_Model_Systemstatus::GetPypoStatus(), + "liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(), + "show_recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(), + "media_monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus() + ), + "partitions"=>Application_Model_Systemstatus::GetDiskInfo() + ); + + $this->view->status = $status; + } + + public function registerComponentAction(){ + $request = $this->getRequest(); + + $component = $request->getParam('component'); + $remoteAddr = $_SERVER['REMOTE_ADDR']; + Logging::log("Registered Component: ".$component."@".$remoteAddr); + + Application_Model_ServiceRegister::Register($component, $remoteAddr); + } + + public function updateLiquidsoapErrorAction(){ + $request = $this->getRequest(); + + $error_msg = $request->getParam('error_msg'); + $stream_id = $request->getParam('stream_id'); + Application_Model_StreamSetting::setLiquidsoapError($stream_id, $error_msg); + } + + public function updateLiquidsoapConnectionAction(){ + $request = $this->getRequest(); + + $stream_id = $request->getParam('stream_id'); + // setting error_msg as "" when there is no error_msg + Application_Model_StreamSetting::setLiquidsoapError($stream_id, "OK"); + } + + /** + * Sets up and send init values used in the Library. + * This is being used by library.js + */ + public function libraryInitAction(){ + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + if(is_null(Zend_Auth::getInstance()->getStorage()->read())) { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + return; + } + + $this->view->libraryInit = array( + "numEntries"=>Application_Model_Preference::GetLibraryNumEntries() + ); } } diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index 55652fc12..8b918137d 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -13,10 +13,30 @@ class DashboardController extends Zend_Controller_Action // action body } + public function streamPlayerAction() + { + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); + $this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.blue.monday.css'); + $this->_helper->layout->setLayout('bare'); + + $logo = Application_Model_Preference::GetStationLogo(); + if($logo){ + $this->view->logo = "data:image/png;base64,$logo"; + } else { + $this->view->logo = "$baseUrl/css/images/airtime_logo_jp.png"; + } + } + public function helpAction() { // action body } + public function aboutAction() + { + // action body + } + } diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 67efa7638..6aa4a5b43 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -13,6 +13,9 @@ class LibraryController extends Zend_Controller_Action ->addActionContext('delete', 'json') ->addActionContext('context-menu', 'json') ->addActionContext('get-file-meta-data', 'html') + ->addActionContext('upload-file-soundcloud', 'json') + ->addActionContext('get-upload-to-soundcloud-status', 'json') + ->addActionContext('set-num-entries', 'json') ->initContext(); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); @@ -25,7 +28,6 @@ class LibraryController extends Zend_Controller_Action $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js','text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jquery.jplayer.min.js'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js','text/javascript'); @@ -34,6 +36,8 @@ class LibraryController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css'); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css'); + $this->_helper->layout->setLayout('library'); $this->_helper->viewRenderer->setResponseSegment('library'); @@ -64,7 +68,7 @@ class LibraryController extends Zend_Controller_Action $paramsPop = str_replace('#type#', $type, $paramsPop); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); $pl_sess = $this->pl_sess; @@ -82,12 +86,29 @@ class LibraryController extends Zend_Controller_Action $id = $this->_getParam('id'); $file_id = $this->_getParam('id', null); - $file = StoredFile::Recall($file_id); + $file = Application_Model_StoredFile::Recall($file_id); - $url = $file->getRelativeFileUrl($baseUrl).'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); - + + if (Application_Model_Preference::GetUploadToSoundcloudOption()) { + $text = "Upload to Soundcloud"; + if(!is_null($file->getSoundCloudId())){ + $text = "Re-upload to Soundcloud"; + } + $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Library/upload-file-soundcloud/id/#id#', + 'callback'=>"window['addProgressIcon']('$file_id')"),'title' => $text); + + $scid = $file->getSoundCloudId(); + + if($scid > 0){ + $link_to_file = $file->getSoundCloudLinkToFile(); + $menu[] = array('action' => array('type' => 'fn', + 'callback' => "window['openFileOnSoundCloud']('$link_to_file')"), + 'title' => 'View on SoundCloud'); + } + } if ($user->isAdmin()) { $menu[] = array('action' => array('type' => 'fn', @@ -128,12 +149,12 @@ class LibraryController extends Zend_Controller_Action { $id = $this->_getParam('id'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if ($user->isAdmin()) { if (!is_null($id)) { - $file = StoredFile::Recall($id); + $file = Application_Model_StoredFile::Recall($id); if (PEAR::isError($file)) { $this->view->message = $file->getMessage(); @@ -153,7 +174,7 @@ class LibraryController extends Zend_Controller_Action else { $res = settype($res, "integer"); $data = array("filepath" => $file->getFilePath(), "delete" => $res); - RabbitMq::SendMessageToMediaMonitor("file_delete", $data); + Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data); } } @@ -164,12 +185,23 @@ class LibraryController extends Zend_Controller_Action public function contentsAction() { $post = $this->getRequest()->getPost(); - $datatables = StoredFile::searchFilesForPlaylistBuilder($post); + $datatables = Application_Model_StoredFile::searchFilesForPlaylistBuilder($post); //format clip lengh to 1 decimal foreach($datatables["aaData"] as &$data){ - $sec = Playlist::playlistTimeToSeconds($data[5]); - $data[5] = Playlist::secondsToPlaylistTime($sec); + if($data[6] == 'audioclip'){ + $file = Application_Model_StoredFile::Recall($data[0]); + $scid = $file->getSoundCloudId(); + if($scid == "-2"){ + $data[1] .= ''; + }else if($scid == "-3"){ + $data[1] .= ''; + }else if(!is_null($scid)){ + $data[1] .= ''; + } + } + $sec = Application_Model_Playlist::playlistTimeToSeconds($data[5]); + $data[5] = Application_Model_Playlist::secondsToPlaylistTime($sec); } die(json_encode($datatables)); @@ -179,9 +211,10 @@ class LibraryController extends Zend_Controller_Action { $request = $this->getRequest(); $form = new Application_Form_EditAudioMD(); - + $file_id = $this->_getParam('id', null); - $file = StoredFile::Recall($file_id); + $file = Application_Model_StoredFile::Recall($file_id); + $form->populate($file->getDbColMetadata()); if ($request->isPost()) { if ($form->isValid($request->getPost())) { @@ -190,14 +223,17 @@ class LibraryController extends Zend_Controller_Action $file->setDbColMetadata($formdata); $data = $file->getMetadata(); + + // set MDATA_KEY_FILEPATH + $data['MDATA_KEY_FILEPATH'] = $file->getFilePath(); + Logging::log($data['MDATA_KEY_FILEPATH']); + Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data); - RabbitMq::SendMessageToMediaMonitor("md_update", $data); $this->_helper->redirector('index'); } } - $form->populate($file->getDbColMetadata()); $this->view->form = $form; } @@ -207,16 +243,50 @@ class LibraryController extends Zend_Controller_Action $type = $this->_getParam('type'); if($type == "au") { - $file = StoredFile::Recall($id); + $file = Application_Model_StoredFile::Recall($id); $this->view->type = $type; $this->view->md = $file->getMetadata(); } else if($type == "pl") { - $file = Playlist::Recall($id); + $file = Application_Model_Playlist::Recall($id); $this->view->type = $type; $this->view->md = $file->getAllPLMetaData(); $this->view->contents = $file->getContents(); } } + + public function uploadFileSoundcloudAction(){ + $id = $this->_getParam('id'); + $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + // we should die with ui info + die(); + } + + 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(); + }else{ + $file = Application_Model_StoredFile::Recall($id); + $this->view->sc_id = $file->getSoundCloudId(); + $this->view->error_code = $file->getSoundCloudErrorCode(); + $this->view->error_msg = $file->getSoundCloudErrorMsg(); + } + } + + /** + * Stores the number of entries user chose to show in the Library + * to the pref db + */ + public function setNumEntriesAction() { + $request = $this->getRequest(); + $numEntries = $request->getParam('numEntries'); + Application_Model_Preference::SetLibraryNumEntries($numEntries); + } } diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index 107c50872..87ddc30a2 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -10,61 +10,80 @@ class LoginController extends Zend_Controller_Action public function indexAction() { - if(Zend_Auth::getInstance()->hasIdentity()) - { - $this->_redirect('Nowplaying'); - } - - //uses separate layout without a navigation. - $this->_helper->layout->setLayout('login'); - - $request = $this->getRequest(); + if(Zend_Auth::getInstance()->hasIdentity()) + { + $this->_redirect('Nowplaying'); + } + + //uses separate layout without a navigation. + $this->_helper->layout->setLayout('login'); + + $error = false; + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); + + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/login/login.js','text/javascript'); + $form = new Application_Form_Login(); - - $message = "Please enter your user name and password"; + + $message = "Please enter your user name and password"; if($request->isPost()) { + // if the post contains recaptcha field, which means form had recaptcha field. + // Hence add the element for validation. + if(array_key_exists('recaptcha_response_field', $request->getPost())){ + $form->addRecaptcha(); + } if($form->isValid($request->getPost())) { - - $authAdapter = $this->getAuthAdapter(); - //get the username and password from the form $username = $form->getValue('username'); $password = $form->getValue('password'); + if(Application_Model_Subjects::getLoginAttempts($username) >= 3 && $form->getElement('captcha') == NULL){ + $form->addRecaptcha(); + }else{ + $authAdapter = $this->getAuthAdapter(); - //pass to the adapter the submitted username and password - $authAdapter->setIdentity($username) - ->setCredential($password); - - $auth = Zend_Auth::getInstance(); - $result = $auth->authenticate($authAdapter); - - if($result->isValid()) - { - //all info about this user from the login table omit only the password - $userInfo = $authAdapter->getResultRowObject(null, 'password'); - - //the default storage is a session with namespace Zend_Auth - $authStorage = $auth->getStorage(); - $authStorage->write($userInfo); - - $tempSess = new Zend_Session_Namespace("referrer"); - $tempSess->referrer = 'login'; - - $this->_redirect('Nowplaying'); - } - else - { - $message = "Wrong username or password provided. Please try again."; + //pass to the adapter the submitted username and password + $authAdapter->setIdentity($username) + ->setCredential($password); + + $auth = Zend_Auth::getInstance(); + $result = $auth->authenticate($authAdapter); + if($result->isValid()) + { + //all info about this user from the login table omit only the password + $userInfo = $authAdapter->getResultRowObject(null, 'password'); + + //the default storage is a session with namespace Zend_Auth + $authStorage = $auth->getStorage(); + $authStorage->write($userInfo); + + Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']); + Application_Model_Subjects::resetLoginAttempts($username); + + $tempSess = new Zend_Session_Namespace("referrer"); + $tempSess->referrer = 'login'; + + $this->_redirect('Nowplaying'); + } + else + { + $message = "Wrong username or password provided. Please try again."; + Application_Model_Subjects::increaseLoginAttempts($username); + Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']); + $form = new Application_Form_Login(); + $error = true; + } } } } - + $this->view->message = $message; + $this->view->error = $error; $this->view->form = $form; - $this->view->airtimeVersion = AIRTIME_VERSION; + $this->view->airtimeVersion = Application_Model_Preference::GetAirtimeVersion(); $this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE; } diff --git a/airtime_mvc/application/controllers/NowplayingController.php b/airtime_mvc/application/controllers/NowplayingController.php index 257b354a2..4b9e0430f 100644 --- a/airtime_mvc/application/controllers/NowplayingController.php +++ b/airtime_mvc/application/controllers/NowplayingController.php @@ -23,14 +23,17 @@ class NowplayingController extends Zend_Controller_Action $refer_sses = new Zend_Session_Namespace('referrer'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if ($request->isPost()) { $form = new Application_Form_RegisterAirtime(); $values = $request->getPost(); - if ($values["Publicise"] != 1){ + if ($values["Publicise"] != 1 && $form->isValid($values)){ Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); + if(isset($values["Privacy"])){ + Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); + } // unset session Zend_Session::namespaceUnset('referrer'); } @@ -49,10 +52,12 @@ class NowplayingController extends Zend_Controller_Action Application_Model_Preference::SetStationDescription($values["Description"]); Application_Model_Preference::SetStationLogo($imagePath); Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); + if(isset($values["Privacy"])){ + Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); + } // unset session Zend_Session::namespaceUnset('referrer'); }else{ - var_dump($form->getMessages()); $logo = Application_Model_Preference::GetStationLogo(); if($logo){ $this->view->logoImg = $logo; @@ -85,12 +90,13 @@ class NowplayingController extends Zend_Controller_Action $this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString); } - +/* public function livestreamAction() { //use bare bones layout (no header bar or menu) $this->_helper->layout->setLayout('bare'); } +*/ public function dayViewAction() { diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index ec2cc345b..f6ca476ba 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -33,7 +33,7 @@ class PlaylistController extends Zend_Controller_Action if(isset($pl_sess->id)) { - $pl = Playlist::Recall($pl_sess->id); + $pl = Application_Model_Playlist::Recall($pl_sess->id); if($pl === FALSE) { unset($pl_sess->id); return; @@ -48,7 +48,7 @@ class PlaylistController extends Zend_Controller_Action if(isset($pl_sess->id)) { - $pl = Playlist::Recall($pl_sess->id); + $pl = Application_Model_Playlist::Recall($pl_sess->id); if($pl !== FALSE) { $this->closePlaylist($pl); } @@ -56,7 +56,7 @@ class PlaylistController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $pl = Playlist::Recall($pl_id); + $pl = Application_Model_Playlist::Recall($pl_id); if($pl === FALSE) { return FALSE; } @@ -92,7 +92,7 @@ class PlaylistController extends Zend_Controller_Action $pl_sess = $this->pl_sess; $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $pl = new Playlist(); + $pl = new Application_Model_Playlist(); $pl->create("Untitled Playlist"); $pl->setPLMetaData('dc:creator', $userInfo->login); @@ -285,11 +285,11 @@ class PlaylistController extends Zend_Controller_Action public function deleteAction() { $id = $this->_getParam('id', null); - $pl = Playlist::Recall($id); + $pl = Application_Model_Playlist::Recall($id); if ($pl !== FALSE) { - Playlist::Delete($id); + Application_Model_Playlist::Delete($id); $pl_sess = $this->pl_sess; @@ -305,7 +305,7 @@ class PlaylistController extends Zend_Controller_Action public function deleteActiveAction() { $pl = $this->getPlaylist(); - Playlist::Delete($pl->getId()); + Application_Model_Playlist::Delete($pl->getId()); $pl_sess = $this->pl_sess; unset($pl_sess->id); diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index 73d35196a..6003374f7 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -26,7 +26,7 @@ class PluploadController extends Zend_Controller_Action public function uploadAction() { $upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; - StoredFile::uploadFile($upload_dir); + Application_Model_StoredFile::uploadFile($upload_dir); die('{"jsonrpc" : "2.0"}'); } @@ -34,7 +34,7 @@ class PluploadController extends Zend_Controller_Action public function copyfileAction(){ $upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; $filename = $this->_getParam('name'); - StoredFile::copyFileToStor($upload_dir, $filename); + Application_Model_StoredFile::copyFileToStor($upload_dir, $filename); die('{"jsonrpc" : "2.0"}'); } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 7b7c62c65..414f3dae2 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -12,6 +12,8 @@ class PreferenceController extends Zend_Controller_Action ->addActionContext('reload-watch-directory', 'json') ->addActionContext('remove-watch-directory', 'json') ->addActionContext('is-import-in-progress', 'json') + ->addActionContext('change-stream-setting', 'json') + ->addActionContext('get-liquidsoap-status', 'json') ->initContext(); } @@ -33,8 +35,12 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]); Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]); Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]); + Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]); + Application_Model_Preference::SetWeekStartDay($values["preferences_general"]["weekStartDay"]); - Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]); + Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]); + Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]); + Application_Model_Preference::SetSoundCloudDownloadbleOption($values["preferences_soundcloud"]["SoundCloudDownloadbleOption"]); Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]); Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); @@ -60,24 +66,32 @@ class PreferenceController extends Zend_Controller_Action $form = new Application_Form_SupportSettings(); if ($request->isPost()) { - if ($form->isValid($request->getPost())) { - $values = $form->getValues(); + $values = $request->getPost(); + if ($form->isValid($values)) { + if ($values["Publicise"] != 1){ + Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); + if(isset($values["Privacy"])){ + Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); + } + }else{ + Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); + Application_Model_Preference::SetPhone($values["Phone"]); + Application_Model_Preference::SetEmail($values["Email"]); + Application_Model_Preference::SetStationWebSite($values["StationWebSite"]); + Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); + Application_Model_Preference::SetPublicise($values["Publicise"]); - Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); - Application_Model_Preference::SetPhone($values["Phone"]); - Application_Model_Preference::SetEmail($values["Email"]); - Application_Model_Preference::SetStationWebSite($values["StationWebSite"]); - Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); - Application_Model_Preference::SetPublicise($values["Publicise"]); - - $form->Logo->receive(); - $imagePath = $form->Logo->getFileName(); - - Application_Model_Preference::SetStationCountry($values["Country"]); - Application_Model_Preference::SetStationCity($values["City"]); - Application_Model_Preference::SetStationDescription($values["Description"]); - Application_Model_Preference::SetStationLogo($imagePath); + $form->Logo->receive(); + $imagePath = $form->Logo->getFileName(); + Application_Model_Preference::SetStationCountry($values["Country"]); + Application_Model_Preference::SetStationCity($values["City"]); + Application_Model_Preference::SetStationDescription($values["Description"]); + Application_Model_Preference::SetStationLogo($imagePath); + if(isset($values["Privacy"])){ + Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); + } + } $this->view->statusMsg = "
Support setting updated.
"; } } @@ -85,20 +99,106 @@ class PreferenceController extends Zend_Controller_Action if($logo){ $this->view->logoImg = $logo; } + $privacyChecked = false; + if(Application_Model_Preference::GetPrivacyPolicyCheck() == 1){ + $privacyChecked = true; + } + $this->view->privacyChecked = $privacyChecked; $this->view->form = $form; + //$form->render($this->view); } - + public function directoryConfigAction() + { + if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); + + $this->view->headScript()->appendFile($baseUrl.'/js/serverbrowse/serverbrowser.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/musicdirs.js','text/javascript'); + + $watched_dirs_pref = new Application_Form_WatchedDirPreferences(); + + $this->view->form = $watched_dirs_pref; + } + } + + public function streamSettingAction() { $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); - $this->view->headScript()->appendFile($baseUrl.'/js/serverbrowse/serverbrowser.js','text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/musicdirs.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js','text/javascript'); - $watched_dirs_pref = new Application_Form_WatchedDirPreferences(); + // get current settings + $temp = Application_Model_StreamSetting::getStreamSetting(); + $setting = array(); + foreach ($temp as $t){ + $setting[$t['keyname']] = $t['value']; + } - $this->view->form = $watched_dirs_pref; + // get predefined type and bitrate from pref table + $temp_types = Application_Model_Preference::GetStreamType(); + $stream_types = array(); + foreach ($temp_types as $type){ + if(trim($type) == "ogg"){ + $temp = "OGG/VORBIS"; + }else{ + $temp = strtoupper(trim($type)); + } + $stream_types[trim($type)] = $temp; + } + + $temp_bitrate = Application_Model_Preference::GetStreamBitrate(); + $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate()); + $stream_bitrates = array(); + foreach ($temp_bitrate as $type){ + if(intval($type) <= $max_bitrate){ + $stream_bitrates[trim($type)] = strtoupper(trim($type))." Kbit/s"; + } + } + + $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams()); + $form = new Application_Form_StreamSetting(); + $form->setSetting($setting); + $form->startFrom(); + for($i=1; $i<=$num_of_stream; $i++){ + $subform = new Application_Form_StreamSettingSubForm(); + $subform->setPrefix($i); + $subform->setSetting($setting); + $subform->setStreamTypes($stream_types); + $subform->setStreamBitrates($stream_bitrates); + $subform->startForm(); + $form->addSubForm($subform, "s".$i."_subform"); + } + if ($request->isPost()) { + $post_data = $request->getPost(); + $error = false; + $values = array(); + for($i=1; $i<=$num_of_stream; $i++){ + if(!$form->getSubForm("s".$i."_subform")->isValid($post_data["s".$i."_data"])){ + $error = true; + }else{ + // getValues returne array of size 1, so reorganized it + foreach($form->getSubForm("s".$i."_subform")->getValues() as $key => $d){ + $values[$key] = $d; + } + } + } + if($form->isValid($post_data['output_sound_device'])){ + $values['output_sound_device'] = $form->getValue('output_sound_device'); + } + if(!$error){ + Application_Model_StreamSetting::setStreamSetting($values); + $data = array(); + $data['setting'] = Application_Model_StreamSetting::getStreamSetting(); + Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); + $this->view->statusMsg = "
Stream Setting Updated.
"; + } + } + $this->view->num_stream = $num_of_stream; + $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); + $this->view->form = $form; } public function serverBrowseAction() @@ -144,7 +244,7 @@ class PreferenceController extends Zend_Controller_Action $element = $this->getRequest()->getParam("element"); $watched_dirs_form = new Application_Form_WatchedDirPreferences(); - $res = MusicDir::setStorDir($chosen); + $res = Application_Model_MusicDir::setStorDir($chosen); if($res['code'] != 0){ $watched_dirs_form->populate(array('storageFolder' => $chosen)); $watched_dirs_form->getElement($element)->setErrors(array($res['error'])); @@ -159,7 +259,7 @@ class PreferenceController extends Zend_Controller_Action $element = $this->getRequest()->getParam("element"); $watched_dirs_form = new Application_Form_WatchedDirPreferences(); - $res = MusicDir::addWatchedDir($chosen); + $res = Application_Model_MusicDir::addWatchedDir($chosen); if($res['code'] != 0){ $watched_dirs_form->populate(array('watchedFolder' => $chosen)); $watched_dirs_form->getElement($element)->setErrors(array($res['error'])); @@ -172,12 +272,12 @@ class PreferenceController extends Zend_Controller_Action { $chosen = $this->getRequest()->getParam("dir"); - $dir = MusicDir::removeWatchedDir($chosen); + $dir = Application_Model_MusicDir::removeWatchedDir($chosen); $watched_dirs_form = new Application_Form_WatchedDirPreferences(); $this->view->subform = $watched_dirs_form->render(); } - + public function isImportInProgressAction(){ $now = time(); $res = false; @@ -186,6 +286,20 @@ class PreferenceController extends Zend_Controller_Action } die(json_encode($res)); } + + public function getLiquidsoapStatusAction(){ + $out = array(); + $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams()); + for($i=1; $i<=$num_of_stream; $i++){ + $status = Application_Model_StreamSetting::getLiquidsoapError($i); + $status = $status == NULL?"Problem with Liquidsoap...":$status; + if(!Application_Model_StreamSetting::getStreamEnabled($i)){ + $status = "N/A"; + } + $out[] = array("id"=>$i, "status"=>$status); + } + die(json_encode($out)); + } } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 953cfee52..6e8e445fa 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -28,6 +28,8 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('get-form', 'json') ->addActionContext('upload-to-sound-cloud', 'json') ->addActionContext('content-context-menu', 'json') + ->addActionContext('set-time-scale', 'json') + ->addActionContext('set-time-interval', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -47,17 +49,19 @@ class ScheduleController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery-ui-timepicker.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/colorpicker/css/colorpicker.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css'); + $this->view->headLink()->appendStylesheet($baseUrl.'/css/qtip/jquery.qtip.min.css'); - Schedule::createNewFormSections($this->view); + Application_Model_Schedule::createNewFormSections($this->view); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); $this->view->isAdmin = $user->isAdmin(); $this->view->isProgramManager = $user->isUserType('P'); } @@ -68,31 +72,31 @@ class ScheduleController extends Zend_Controller_Action $end = $this->_getParam('end', null); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) $editable = true; else $editable = false; - $this->view->events = Show::getFullCalendarEvents($start, $end, $editable); + $this->view->events = Application_Model_Show::getFullCalendarEvents($start, $end, $editable); } public function moveShowAction() { $deltaDay = $this->_getParam('day'); - $deltaMin = $this->_getParam('min'); - $showInstanceId = $this->_getParam('showInstanceId'); + $deltaMin = $this->_getParam('min'); + $showInstanceId = $this->_getParam('showInstanceId'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - $show = new ShowInstance($showInstanceId); - $error = $show->moveShow($deltaDay, $deltaMin); + $showInstance = new Application_Model_ShowInstance($showInstanceId); + $error = $showInstance->moveShow($deltaDay, $deltaMin); } - if(isset($error)) - $this->view->error = $error; + if(isset($error)) + $this->view->error = $error; } @@ -103,10 +107,10 @@ class ScheduleController extends Zend_Controller_Action $showInstanceId = $this->_getParam('showInstanceId'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - $show = new ShowInstance($showInstanceId); + $show = new Application_Model_ShowInstance($showInstanceId); $error = $show->resizeShow($deltaDay, $deltaMin); } @@ -119,10 +123,10 @@ class ScheduleController extends Zend_Controller_Action $showInstanceId = $this->_getParam('id'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - $show = new ShowInstance($showInstanceId); + $show = new Application_Model_ShowInstance($showInstanceId); $show->deleteShow(); } } @@ -131,60 +135,30 @@ class ScheduleController extends Zend_Controller_Action { global $CC_CONFIG; $show_instance = $this->_getParam('id'); - $show_inst = new ShowInstance($show_instance); + $show_inst = new Application_Model_ShowInstance($show_instance); $file = $show_inst->getRecordedFile(); - - if(is_null($file)) { - $this->view->error = "Recorded file does not exist"; - return; - } - - $show_name = $show_inst->getName(); - $show_genre = $show_inst->getGenre(); - $show_start_time = $show_inst->getShowStart(); - - if(Application_Model_Preference::GetDoSoundCloudUpload()) - { - for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { - - $show = new Show($show_inst->getShowId()); - $description = $show->getDescription(); - $hosts = $show->getHosts(); - - $tags = array_merge($hosts, array($show_name)); - - try { - $soundcloud = new ATSoundcloud(); - $soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre); - $show_inst->setSoundCloudFileId($soundcloud_id); - $this->view->soundcloud_id = $soundcloud_id; - break; - } - catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { - $code = $e->getHttpCode(); - if(!in_array($code, array(0, 100))) { - break; - } - } - - sleep($CC_CONFIG['soundcloud-connection-wait']); - } - } + $id = $file->getId(); + $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + // we should die with ui info + die(); } public function makeContextMenuAction() { $id = $this->_getParam('id'); - $today_timestamp = date("Y-m-d H:i:s"); + $epochNow = time(); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); - $show = new ShowInstance($id); + $user = new Application_Model_User($userInfo->id); + $show = new Application_Model_ShowInstance($id); $params = '/format/json/id/#id#'; - - if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { + + $showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowStart()); + $showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowEnd()); + + if ($epochNow < $showStartDateHelper->getTimestamp()) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) { @@ -202,25 +176,30 @@ class ScheduleController extends Zend_Controller_Action 'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content'); } - if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp) - && is_null($show->getSoundCloudFileId()) + if ($showEndDateHelper->getTimestamp() <= $epochNow && $show->isRecorded() - && Application_Model_Preference::GetDoSoundCloudUpload()) { - $menu[] = array('action' => array('type' => 'fn', - 'callback' => "window['uploadToSoundCloud']($id)"), - 'title' => 'Upload to Soundcloud'); + && Application_Model_Preference::GetUploadToSoundcloudOption()) { + if(is_null($show->getSoundCloudFileId())){ + $menu[] = array('action' => array('type' => 'fn', + 'callback' => "window['uploadToSoundCloud']($id)"), + 'title' => 'Upload to Soundcloud'); + }else{ + $menu[] = array('action' => array('type' => 'fn', + 'callback' => "window['uploadToSoundCloud']($id)"), + 'title' => 'Re-upload to Soundcloud'); + } } - if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) && - strtotime($today_timestamp) < strtotime($show->getShowEnd()) && + if ($showStartDateHelper->getTimestamp() <= $epochNow && + $epochNow < $showEndDateHelper->getTimestamp() && $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['confirmCancelShow']($id)"), 'title' => 'Cancel Current Show'); } - if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { + if ($epochNow < $showStartDateHelper->getTimestamp()) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { @@ -248,8 +227,8 @@ class ScheduleController extends Zend_Controller_Action } $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); - $show = new ShowInstance($showInstanceId); + $user = new Application_Model_User($userInfo->id); + $show = new Application_Model_ShowInstance($showInstanceId); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) { $show->scheduleShow(array($plId)); @@ -267,8 +246,8 @@ class ScheduleController extends Zend_Controller_Action { $showInstanceId = $this->_getParam('id'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); - $show = new ShowInstance($showInstanceId); + $user = new Application_Model_User($userInfo->id); + $show = new Application_Model_ShowInstance($showInstanceId); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) $show->clearShow(); @@ -276,19 +255,19 @@ class ScheduleController extends Zend_Controller_Action public function getCurrentPlaylistAction() { - $this->view->entries = Schedule::GetPlayOrderRange(); + $this->view->entries = Application_Model_Schedule::GetPlayOrderRange(); } public function findPlaylistsAction() { $post = $this->getRequest()->getPost(); - $show = new ShowInstance($this->sched_sess->showInstanceId); + $show = new Application_Model_ShowInstance($this->sched_sess->showInstanceId); $playlists = $show->searchPlaylistsForShow($post); foreach( $playlists['aaData'] as &$data){ // calling two functions to format time to 1 decimal place - $sec = Playlist::playlistTimeToSeconds($data[4]); - $data[4] = Playlist::secondsToPlaylistTime($sec); + $sec = Application_Model_Playlist::playlistTimeToSeconds($data[4]); + $data[4] = Application_Model_Playlist::secondsToPlaylistTime($sec); } //for datatables @@ -302,8 +281,8 @@ class ScheduleController extends Zend_Controller_Action $search = $this->_getParam('search', null); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); - $show = new ShowInstance($showInstanceId); + $user = new Application_Model_User($userInfo->id); + $show = new Application_Model_ShowInstance($showInstanceId); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) { $show->removeGroupFromShow($group_id); @@ -321,12 +300,12 @@ class ScheduleController extends Zend_Controller_Action $showInstanceId = $this->_getParam('id'); $this->sched_sess->showInstanceId = $showInstanceId; - $show = new ShowInstance($showInstanceId); + $show = new Application_Model_ShowInstance($showInstanceId); $start_timestamp = $show->getShowStart(); $end_timestamp = $show->getShowEnd(); //check to make sure show doesn't overlap. - if(Show::getShows($start_timestamp, $end_timestamp, array($showInstanceId))) { + if(Application_Model_Show::getShows($start_timestamp, $end_timestamp, array($showInstanceId))) { $this->view->error = "cannot schedule an overlapping show."; return; } @@ -361,11 +340,11 @@ class ScheduleController extends Zend_Controller_Action public function showContentDialogAction() { $showInstanceId = $this->_getParam('id'); - $show = new ShowInstance($showInstanceId); + $show = new Application_Model_ShowInstance($showInstanceId); $originalShowId = $show->isRebroadcast(); if (!is_null($originalShowId)){ - $originalShow = new ShowInstance($originalShowId); + $originalShow = new Application_Model_ShowInstance($originalShowId); $originalShowName = $originalShow->getName(); $originalShowStart = $originalShow->getShowStart(); @@ -382,10 +361,12 @@ class ScheduleController extends Zend_Controller_Action public function editShowAction() { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if(!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { return; } + + $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $showInstanceId = $this->_getParam('id'); @@ -394,42 +375,39 @@ class ScheduleController extends Zend_Controller_Action $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); - $formRecord = new Application_Form_AddShowRR(); - $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); - $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); - $formRecord->removeDecorator('DtDdWrapper'); - $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); - $formRebroadcast->removeDecorator('DtDdWrapper'); $this->view->what = $formWhat; $this->view->when = $formWhen; $this->view->repeats = $formRepeats; $this->view->who = $formWho; $this->view->style = $formStyle; - $this->view->rr = $formRecord; - $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; - $this->view->rebroadcast = $formRebroadcast; $this->view->addNewShow = false; - $showInstance = new ShowInstance($showInstanceId); - $show = new Show($showInstance->getShowId()); + $showInstance = new Application_Model_ShowInstance($showInstanceId); + $show = new Application_Model_Show($showInstance->getShowId()); $formWhat->populate(array('add_show_id' => $show->getId(), 'add_show_name' => $show->getName(), 'add_show_url' => $show->getUrl(), 'add_show_genre' => $show->getGenre(), 'add_show_description' => $show->getDescription())); + + $startsDateTime = new DateTime($showInstance->getShowStart(), new DateTimeZone("UTC")); + $endsDateTime = new DateTime($showInstance->getShowEnd(), new DateTimeZone("UTC")); + + $startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); + $endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); - $formWhen->populate(array('add_show_start_date' => $show->getStartDate(), - 'add_show_start_time' => DateHelper::removeSecondsFromTime($show->getStartTime()), - 'add_show_end_date_no_repeat' => $show->getEndDate(), - 'add_show_end_time' => DateHelper::removeSecondsFromTime($show->getEndTime()), + $formWhen->populate(array('add_show_start_date' => $startsDateTime->format("Y-m-d"), + 'add_show_start_time' => $startsDateTime->format("H:i"), + 'add_show_end_date_no_repeat' => $endsDateTime->format("Y-m-d"), + 'add_show_end_time' => $endsDateTime->format("H:i"), 'add_show_duration' => $show->getDuration(true), 'add_show_repeats' => $show->isRepeating() ? 1 : 0)); @@ -443,58 +421,71 @@ class ScheduleController extends Zend_Controller_Action array_push($days, $showDay->getDbDay()); } - $displayedEndDate = new DateTime($show->getRepeatingEndDate()); + $displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone("UTC")); $displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively. - $displayedEndDate = $displayedEndDate->format("Y-m-d"); + $displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get())); $formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(), 'add_show_day_check' => $days, - 'add_show_end_date' => $displayedEndDate, + 'add_show_end_date' => $displayedEndDate->format("Y-m-d"), 'add_show_no_end' => ($show->getRepeatingEndDate() == ''))); - $formRecord->populate(array('add_show_record' => $show->isRecorded(), - 'add_show_rebroadcast' => $show->isRebroadcast())); - $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); - - - - $rebroadcastsRelative = $show->getRebroadcastsRelative(); - $rebroadcastFormValues = array(); - $i = 1; - foreach ($rebroadcastsRelative as $rebroadcast){ - $rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset']; - $rebroadcastFormValues["add_show_rebroadcast_time_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']); - $i++; - } - $formRebroadcast->populate($rebroadcastFormValues); - - $rebroadcastsAbsolute = $show->getRebroadcastsAbsolute(); - $rebroadcastAbsoluteFormValues = array(); - $i = 1; - foreach ($rebroadcastsAbsolute as $rebroadcast){ - $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date']; - $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']); - $i++; - } - $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); - $hosts = array(); $showHosts = CcShowHostsQuery::create()->filterByDbShow($showInstance->getShowId())->find(); foreach($showHosts as $showHost){ array_push($hosts, $showHost->getDbHost()); } $formWho->populate(array('add_show_hosts' => $hosts)); - - $formStyle->populate(array('add_show_background_color' => $show->getBackgroundColor(), 'add_show_color' => $show->getColor())); + + if(!$isSaas){ + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); + $formRebroadcast->removeDecorator('DtDdWrapper'); + + $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $this->view->rebroadcast = $formRebroadcast; + + $formRecord->populate(array('add_show_record' => $show->isRecorded(), + 'add_show_rebroadcast' => $show->isRebroadcast())); + + $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); + + + + $rebroadcastsRelative = $show->getRebroadcastsRelative(); + $rebroadcastFormValues = array(); + $i = 1; + foreach ($rebroadcastsRelative as $rebroadcast){ + $rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset']; + $rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']); + $i++; + } + $formRebroadcast->populate($rebroadcastFormValues); + + $rebroadcastsAbsolute = $show->getRebroadcastsAbsolute(); + $rebroadcastAbsoluteFormValues = array(); + $i = 1; + foreach ($rebroadcastsAbsolute as $rebroadcast){ + $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date']; + $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']); + $i++; + } + $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); + } $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->entries = 5; } public function getFormAction(){ - Schedule::createNewFormSections($this->view); + Application_Model_Schedule::createNewFormSections($this->view); $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } @@ -508,7 +499,7 @@ class ScheduleController extends Zend_Controller_Action $data[$j["name"]] = $j["value"]; } - $show = new Show($data['add_show_id']); + $show = new Application_Model_Show($data['add_show_id']); $startDateModified = true; if ($data['add_show_id'] != -1 && !array_key_exists('add_show_start_date', $data)){ @@ -524,24 +515,21 @@ class ScheduleController extends Zend_Controller_Action if($data['add_show_day_check'] == "") { $data['add_show_day_check'] = null; } - + + $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; + $record = false; + $formWhat = new Application_Form_AddShowWhat(); $formWho = new Application_Form_AddShowWho(); $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); - $formRecord = new Application_Form_AddShowRR(); - $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); - $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); - $formRecord->removeDecorator('DtDdWrapper'); - $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); - $formRebroadcast->removeDecorator('DtDdWrapper'); $what = $formWhat->isValid($data); $when = $formWhen->isValid($data); @@ -572,70 +560,96 @@ class ScheduleController extends Zend_Controller_Action $data["add_show_duration"] = $hValue.":".$mValue; + if(!$isSaas){ + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); + $formRebroadcast->removeDecorator('DtDdWrapper'); + + //If show is a new show (not updated), then get + //isRecorded from POST data. Otherwise get it from + //the database since the user is not allowed to + //update this option. + if ($data['add_show_id'] != -1){ + $data['add_show_record'] = $show->isRecorded(); + $record = $formRecord->isValid($data); + $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); + } else { + $record = $formRecord->isValid($data); + } + } + if($data["add_show_repeats"]) { $repeats = $formRepeats->isValid($data); if($repeats) { $repeats = $formRepeats->checkReliantFields($data); } - - $formAbsoluteRebroadcast->reset(); - //make it valid, results don't matter anyways. - $rebroadAb = 1; - - if ($data["add_show_rebroadcast"]) { - $rebroad = $formRebroadcast->isValid($data); - if($rebroad) { - $rebroad = $formRebroadcast->checkReliantFields($data); + if(!$isSaas){ + $formAbsoluteRebroadcast->reset(); + //make it valid, results don't matter anyways. + $rebroadAb = 1; + + if ($data["add_show_rebroadcast"]) { + $rebroad = $formRebroadcast->isValid($data); + if($rebroad) { + $rebroad = $formRebroadcast->checkReliantFields($data); + } + } + else { + $rebroad = 1; } - } - else { - $rebroad = 1; } } else { - $formRebroadcast->reset(); - //make it valid, results don't matter anyways. $repeats = 1; - $rebroad = 1; - - if ($data["add_show_rebroadcast"]) { - $rebroadAb = $formAbsoluteRebroadcast->isValid($data); - if($rebroadAb) { - $rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data); + if(!$isSaas){ + $formRebroadcast->reset(); + //make it valid, results don't matter anyways. + $rebroad = 1; + + if ($data["add_show_rebroadcast"]) { + $rebroadAb = $formAbsoluteRebroadcast->isValid($data); + if($rebroadAb) { + $rebroadAb = $formAbsoluteRebroadcast->checkReliantFields($data); + } + } + else { + $rebroadAb = 1; } - } - else { - $rebroadAb = 1; } } $who = $formWho->isValid($data); $style = $formStyle->isValid($data); - - //If show is a new show (not updated), then get - //isRecorded from POST data. Otherwise get it from - //the database since the user is not allowed to - //update this option. - $record = false; - if ($data['add_show_id'] != -1){ - $data['add_show_record'] = $show->isRecorded(); - $record = $formRecord->isValid($data); - $formRecord->getElement('add_show_record')->setOptions(array('disabled' => true)); - } else { - $record = $formRecord->isValid($data); - } - - if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) { - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - Show::create($data); + if ($what && $when && $repeats && $who && $style) { + if(!$isSaas){ + if($record && $rebroadAb && $rebroad){ + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + Application_Model_Show::create($data); + } + + //send back a new form for the user. + Application_Model_Schedule::createNewFormSections($this->view); + + $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); + } + }else{ + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + Application_Model_Show::create($data); + } + + //send back a new form for the user. + Application_Model_Schedule::createNewFormSections($this->view); + + $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } - - //send back a new form for the user. - Schedule::createNewFormSections($this->view); - - $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); } else { $this->view->what = $formWhat; @@ -643,9 +657,11 @@ class ScheduleController extends Zend_Controller_Action $this->view->repeats = $formRepeats; $this->view->who = $formWho; $this->view->style = $formStyle; - $this->view->rr = $formRecord; - $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; - $this->view->rebroadcast = $formRebroadcast; + if(!$isSaas){ + $this->view->rr = $formRecord; + $this->view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $this->view->rebroadcast = $formRebroadcast; + } $this->view->addNewShow = true; //the form still needs to be "update" since @@ -664,13 +680,13 @@ class ScheduleController extends Zend_Controller_Action public function cancelShowAction() { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $showInstanceId = $this->_getParam('id'); - $showInstance = new ShowInstance($showInstanceId); - $show = new Show($showInstance->getShowId()); + $showInstance = new Application_Model_ShowInstance($showInstanceId); + $show = new Application_Model_Show($showInstance->getShowId()); $show->cancelShow($showInstance->getShowStart()); } @@ -679,13 +695,15 @@ class ScheduleController extends Zend_Controller_Action public function cancelCurrentShowAction() { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new User($userInfo->id); + $user = new Application_Model_User($userInfo->id); if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $showInstanceId = $this->_getParam('id'); - $show = new ShowInstance($showInstanceId); + $show = new Application_Model_ShowInstance($showInstanceId); $show->clearShow(); $show->deleteShow(); + // send 'cancel-current-show' command to pypo + Application_Model_RabbitMq::SendMessageToPypo("cancel_current_show", array()); } } @@ -702,15 +720,32 @@ class ScheduleController extends Zend_Controller_Action $id = $this->_getParam('id'); $file_id = $this->_getParam('id', null); - $file = StoredFile::Recall($file_id); - - $url = $file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $file = Application_Model_StoredFile::Recall($file_id); + + $baseUrl = $this->getRequest()->getBaseUrl(); + $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); //returns format jjmenu is looking for. die(json_encode($menu)); } + + /** + * Sets the user specific preference for which time scale to use in Calendar. + * This is only being used by schedule.js at the moment. + */ + public function setTimeScaleAction() { + Application_Model_Preference::SetCalendarTimeScale($this->_getParam('timeScale')); + } + +/** + * Sets the user specific preference for which time interval to use in Calendar. + * This is only being used by schedule.js at the moment. + */ + public function setTimeIntervalAction() { + Application_Model_Preference::SetCalendarTimeInterval($this->_getParam('timeInterval')); + } } diff --git a/airtime_mvc/application/controllers/SystemstatusController.php b/airtime_mvc/application/controllers/SystemstatusController.php new file mode 100644 index 000000000..b4d1c2b3f --- /dev/null +++ b/airtime_mvc/application/controllers/SystemstatusController.php @@ -0,0 +1,62 @@ +getRequest(); + $baseUrl = $request->getBaseUrl(); + + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/status/status.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/sprintf/sprintf-0.7-beta1.js','text/javascript'); + } + + public function indexAction() + { + $services = array( + "pypo"=>Application_Model_Systemstatus::GetPypoStatus(), + "liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(), + "show-recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(), + "media-monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus(), + "rabbitmq-server"=>Application_Model_Systemstatus::GetRabbitMqStatus() + ); + + $partitions = Application_Model_Systemstatus::GetDiskInfo(); + + $this->view->status = new StdClass; + $this->view->status->services = $services; + $this->view->status->partitions = $partitions; + } + + public function getLogFileAction() + { + $log_files = array("pypo"=>"/var/log/airtime/pypo/pypo.log", + "liquidsoap"=>"/var/log/airtime/pypo-liquidsoap/ls_script.log", + "media-monitor"=>"/var/log/airtime/media-monitor/media-monitor.log", + "show-recorder"=>"/var/log/airtime/show-recorder/show-recorder.log", + "icecast2"=>"/var/log/icecast2/error.log"); + + $id = $this->_getParam('id'); + Logging::log($id); + + if (array_key_exists($id, $log_files)){ + $filepath = $log_files[$id]; + $filename = basename($filepath); + header("Content-Disposition: attachment; filename=$filename"); + header("Content-Length: " . filesize($filepath)); + // !! binary mode !! + $fp = fopen($filepath, 'rb'); + + //We can have multiple levels of output buffering. Need to + //keep looping until all have been disabled!!! + //http://www.php.net/manual/en/function.ob-end-flush.php + while (@ob_end_flush()); + + fpassthru($fp); + fclose($fp); + + //make sure to exit here so that no other output is sent. + exit; + } + } +} diff --git a/airtime_mvc/application/controllers/UserController.php b/airtime_mvc/application/controllers/UserController.php index 24d9d78d8..b84a0dede 100644 --- a/airtime_mvc/application/controllers/UserController.php +++ b/airtime_mvc/application/controllers/UserController.php @@ -34,7 +34,7 @@ class UserController extends Zend_Controller_Action $formdata = $form->getValues(); if ($form->validateLogin($formdata)){ - $user = new User($formdata['user_id']); + $user = new Application_Model_User($formdata['user_id']); $user->setFirstName($formdata['first_name']); $user->setLastName($formdata['last_name']); $user->setLogin($formdata['login']); @@ -63,13 +63,13 @@ class UserController extends Zend_Controller_Action public function getHostsAction() { $search = $this->_getParam('term'); - $this->view->hosts = User::getHosts($search); + $this->view->hosts = Application_Model_User::getHosts($search); } public function getUserDataTableInfoAction() { $post = $this->getRequest()->getPost(); - $users = User::getUsersDataTablesInfo($post); + $users = Application_Model_User::getUsersDataTablesInfo($post); die(json_encode($users)); } @@ -77,7 +77,7 @@ class UserController extends Zend_Controller_Action public function getUserDataAction() { $id = $this->_getParam('id'); - $this->view->entries = User::GetUserData($id); + $this->view->entries = Application_Model_User::GetUserData($id); } public function removeUserAction() @@ -89,7 +89,7 @@ class UserController extends Zend_Controller_Action $userId = $userInfo->id; if ($delId != $userId){ - $user = new User($delId); + $user = new Application_Model_User($delId); $this->view->entries = $user->delete(); } diff --git a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php index 3316f01b2..1c885528c 100644 --- a/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php +++ b/airtime_mvc/application/controllers/plugins/RabbitMqPlugin.php @@ -4,6 +4,10 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract { public function dispatchLoopShutdown() { - RabbitMq::PushScheduleFinal(); + if (Application_Model_RabbitMq::$doPush) { + $md = array('schedule' => Application_Model_Schedule::GetScheduledPlaylists()); + Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); + Application_Model_RabbitMq::SendMessageToShowRecorder("update_schedule"); + } } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/forms/AddShowRR.php b/airtime_mvc/application/forms/AddShowRR.php index 84b387b25..7eef2b438 100644 --- a/airtime_mvc/application/forms/AddShowRR.php +++ b/airtime_mvc/application/forms/AddShowRR.php @@ -7,7 +7,7 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm { // Add record element $this->addElement('checkbox', 'add_show_record', array( - 'label' => 'Record?', + 'label' => 'Record from Line In?', 'required' => false, )); diff --git a/airtime_mvc/application/forms/AddShowWhat.php b/airtime_mvc/application/forms/AddShowWhat.php index d3f241b25..d821b97a5 100644 --- a/airtime_mvc/application/forms/AddShowWhat.php +++ b/airtime_mvc/application/forms/AddShowWhat.php @@ -2,9 +2,12 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm { - public function init() { + // retrieves the length limit for each char field + // and store to assoc array + $maxLens = Application_Model_Show::GetMaxLengths(); + // Hidden element to indicate whether the show is new or // whether we are updating an existing show. $this->addElement('hidden', 'add_show_id', array( @@ -18,7 +21,8 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm 'required' => true, 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), - 'value' => 'Untitled Show' + 'value' => 'Untitled Show', + 'validators' => array(array('StringLength', false, array(0, $maxLens['name']))) )); // Add URL element @@ -27,7 +31,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm 'class' => 'input_text', 'required' => false, 'filters' => array('StringTrim'), - 'validators' => array('NotEmpty') + 'validators' => array('NotEmpty', array('StringLength', false, array(0, $maxLens['url']))) )); // Add genre element @@ -35,14 +39,16 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm 'label' => 'Genre:', 'class' => 'input_text', 'required' => false, - 'filters' => array('StringTrim') + 'filters' => array('StringTrim'), + 'validators' => array(array('StringLength', false, array(0, $maxLens['genre']))) )); // Add the description element $this->addElement('textarea', 'add_show_description', array( 'label' => 'Description:', 'required' => false, - 'class' => 'input_text_area' + 'class' => 'input_text_area', + 'validators' => array(array('StringLength', false, array(0, $maxLens['description']))) )); $descText = $this->getElement('add_show_description'); @@ -53,7 +59,5 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm )))); } - - } diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index e843727a3..df8d21e6e 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -5,6 +5,10 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm public function init() { + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/add-show-when.phtml')) + )); + // Add start date element $startDate = new Zend_Form_Element_Text('add_show_start_date'); $startDate->class = 'input_text'; @@ -15,11 +19,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm ->setValidators(array( 'NotEmpty', array('date', false, array('YYYY-MM-DD')))) - ->setDecorators(array( - array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)), - 'ViewHelper', - 'Description', - array('Label', array('tag' =>'dt')))); + ->setDecorators(array('ViewHelper')); + $startDate->setAttrib('alt', 'date'); $this->addElement($startDate); // Add start time element @@ -32,10 +33,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm 'NotEmpty', array('date', false, array('HH:mm')), array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')))) - ->setDecorators(array( - 'ViewHelper', - 'Errors', - array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true)))); + ->setDecorators(array('ViewHelper')); + $startTime->setAttrib('alt', 'time'); $this->addElement($startTime); // Add end date element @@ -48,11 +47,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm ->setValidators(array( 'NotEmpty', array('date', false, array('YYYY-MM-DD')))) - ->setDecorators(array( - array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)), - 'ViewHelper', - 'Description', - array('Label', array('tag' =>'dt')))); + ->setDecorators(array('ViewHelper')); + $endDate->setAttrib('alt', 'date'); $this->addElement($endDate); // Add end time element @@ -65,10 +61,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm 'NotEmpty', array('date', false, array('HH:mm')), array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')))) - ->setDecorators(array( - 'ViewHelper', - 'Errors', - array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true)))); + ->setDecorators(array('ViewHelper')); + $endTime->setAttrib('alt', 'time'); $this->addElement($endTime); // Add duration element @@ -76,30 +70,30 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm 'label' => 'Duration:', 'class' => 'input_text', 'value' => '01h00m', - 'readonly' => true + 'readonly' => true, + 'decorators' => array('ViewHelper') )); // Add repeats element $this->addElement('checkbox', 'add_show_repeats', array( 'label' => 'Repeats?', 'required' => false, + 'decorators' => array('ViewHelper') )); } public function checkReliantFields($formData, $startDateModified) { - $valid = true; - - $now_timestamp = date("Y-m-d H:i:s"); - $start_timestamp = $formData['add_show_start_date']." ".$formData['add_show_start_time']; - - $now_epoch = strtotime($now_timestamp); - $start_epoch = strtotime($start_timestamp); - + + $start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time']; + + //DateTime stores $start_time in the current timezone + $nowDateTime = new DateTime(); + $showStartDateTime = new DateTime($start_time); if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){ - if($start_epoch < $now_epoch) { + if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); $valid = false; } @@ -118,6 +112,5 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm return $valid; } - } diff --git a/airtime_mvc/application/forms/AddShowWho.php b/airtime_mvc/application/forms/AddShowWho.php index 76da90c28..360a5abea 100644 --- a/airtime_mvc/application/forms/AddShowWho.php +++ b/airtime_mvc/application/forms/AddShowWho.php @@ -13,7 +13,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm )); $options = array(); - $hosts = User::getHosts(); + $hosts = Application_Model_User::getHosts(); foreach ($hosts as $host) { $options[$host['value']] = $host['label']; diff --git a/airtime_mvc/application/forms/AddUser.php b/airtime_mvc/application/forms/AddUser.php index 4ff63dc12..43b76495c 100644 --- a/airtime_mvc/application/forms/AddUser.php +++ b/airtime_mvc/application/forms/AddUser.php @@ -34,7 +34,6 @@ class Application_Form_AddUser extends Zend_Form $firstName = new Zend_Form_Element_Text('first_name'); $firstName->setLabel('Firstname:'); $firstName->setAttrib('class', 'input_text'); - $firstName->setRequired(true); $firstName->addFilter('StringTrim'); $firstName->addValidator('NotEmpty'); $this->addElement($firstName); @@ -42,7 +41,6 @@ class Application_Form_AddUser extends Zend_Form $lastName = new Zend_Form_Element_Text('last_name'); $lastName->setLabel('Lastname:'); $lastName->setAttrib('class', 'input_text'); - $lastName->setRequired(true); $lastName->addFilter('StringTrim'); $lastName->addValidator('NotEmpty'); $this->addElement($lastName); diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php index 5e9b5969b..423ef1025 100644 --- a/airtime_mvc/application/forms/EditAudioMD.php +++ b/airtime_mvc/application/forms/EditAudioMD.php @@ -29,21 +29,15 @@ class Application_Form_EditAudioMD extends Zend_Form // Add title field $this->addElement('text', 'track_title', array( 'label' => 'Title:', - 'required' => true, 'class' => 'input_text', 'filters' => array('StringTrim'), - 'validators' => array( - 'NotEmpty', - ) )); // Add artist field $this->addElement('text', 'artist_name', array( 'label' => 'Artist:', - 'required' => true, 'class' => 'input_text', 'filters' => array('StringTrim'), - 'validators' => array('NotEmpty') )); // Add album field diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index b048f150f..61b79dbc8 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -57,9 +57,60 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); $third_party_api->setDecorators(array('ViewHelper')); $this->addElement($third_party_api); - + + /* Form Element for setting the Timezone */ + $timezone = new Zend_Form_Element_Select("timezone"); + $timezone->setLabel("Timezone"); + $timezone->setMultiOptions($this->getTimezones()); + $timezone->setValue(Application_Model_Preference::GetTimezone()); + $timezone->setDecorators(array('ViewHelper')); + $this->addElement($timezone); + + /* Form Element for setting which day is the start of the week */ + $week_start_day = new Zend_Form_Element_Select("weekStartDay"); + $week_start_day->setLabel("Week Starts On"); + $week_start_day->setMultiOptions($this->getWeekStartDays()); + $week_start_day->setValue(Application_Model_Preference::GetWeekStartDay()); + $week_start_day->setDecorators(array('ViewHelper')); + $this->addElement($week_start_day); } + + private function getTimezones(){ + $regions = array( + 'Africa' => DateTimeZone::AFRICA, + 'America' => DateTimeZone::AMERICA, + 'Antarctica' => DateTimeZone::ANTARCTICA, + 'Asia' => DateTimeZone::ASIA, + 'Atlantic' => DateTimeZone::ATLANTIC, + 'Europe' => DateTimeZone::EUROPE, + 'Indian' => DateTimeZone::INDIAN, + 'Pacific' => DateTimeZone::PACIFIC + ); + + $tzlist = array(); + + foreach ($regions as $name => $mask){ + $ids = DateTimeZone::listIdentifiers($mask); + foreach ($ids as $id){ + $tzlist[$id] = str_replace("_", " ", $id); + } + } + return $tzlist; + } + + private function getWeekStartDays() { + $days = array( + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday' + ); + return $days; + } } diff --git a/airtime_mvc/application/forms/Login.php b/airtime_mvc/application/forms/Login.php index 4a4cfbd4b..52323a666 100644 --- a/airtime_mvc/application/forms/Login.php +++ b/airtime_mvc/application/forms/Login.php @@ -29,15 +29,43 @@ class Application_Form_Login extends Zend_Form 'NotEmpty', ) )); - + + $recaptchaNeeded = false; + if(Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3){ + $recaptchaNeeded = true; + } + if($recaptchaNeeded){ + // recaptcha + $this->addRecaptcha(); + } + // Add the submit button $this->addElement('submit', 'submit', array( 'ignore' => true, 'label' => 'Login', - 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only' + 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center' )); } + + public function addRecaptcha(){ + $pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG'; + $privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv'; + + $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey); + + $captcha = new Zend_Form_Element_Captcha('captcha', + array( + 'label' => 'Type the characters you see in the picture below.', + 'captcha' => 'ReCaptcha', + 'captchaOptions' => array( + 'captcha' => 'ReCaptcha', + 'service' => $recaptcha + ) + ) + ); + $this->addElement($captcha); + } } diff --git a/airtime_mvc/application/forms/RegisterAirtime.php b/airtime_mvc/application/forms/RegisterAirtime.php index e31e67c3b..694224b9d 100644 --- a/airtime_mvc/application/forms/RegisterAirtime.php +++ b/airtime_mvc/application/forms/RegisterAirtime.php @@ -8,10 +8,15 @@ class Application_Form_RegisterAirtime extends Zend_Form $this->setAction('/Nowplaying'); $this->setMethod('post'); - $country_list = Application_Model_Preference::GetCountryList(); - + $country_list = Application_Model_Preference::GetCountryList(); + + $privacyChecked = false; + if(Application_Model_Preference::GetPrivacyPolicyCheck() == 1){ + $privacyChecked = true; + } + $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/register-dialog.phtml')), + array('ViewScript', array('viewScript' => 'form/register-dialog.phtml', 'privacyChecked'=>$privacyChecked)), array('File', array('viewScript' => 'form/register-dialog.phtml', 'placement' => false))) ); @@ -143,5 +148,22 @@ class Application_Form_RegisterAirtime extends Zend_Form ->setDecorators(array('ViewHelper')); $this->addElement($checkboxPrivacy); } + + // overriding isValid function + public function isValid ($data) + { + $isValid = parent::isValid($data); + if($data['Publicise'] != 1){ + $isValid = true; + } + if(isset($data["Privacy"])){ + $checkPrivacy = $this->getElement('Privacy'); + if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){ + $checkPrivacy->addError("You have to agree to privacy policy."); + $isValid = false; + } + } + return $isValid; + } } diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index 8639c675b..ad85b22b1 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -11,13 +11,33 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm //enable soundcloud uploads $this->addElement('checkbox', 'UseSoundCloud', array( - 'label' => 'Upload Recorded Shows To SoundCloud', + 'label' => 'Automatically Upload Recorded Shows', 'required' => false, - 'value' => Application_Model_Preference::GetDoSoundCloudUpload(), + 'value' => Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud(), 'decorators' => array( 'ViewHelper' ) - )); + )); + + //enable soundcloud uploads option + $this->addElement('checkbox', 'UploadToSoundcloudOption', array( + 'label' => 'Enable Soundcloud Upload', + 'required' => false, + 'value' => Application_Model_Preference::GetUploadToSoundcloudOption(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //enable downloadable for soundcloud + $this->addElement('checkbox', 'SoundCloudDownloadbleOption', array( + 'label' => 'Automatically Mark Files "Downloadable" on SoundCloud', + 'required' => false, + 'value' => Application_Model_Preference::GetSoundCloudDownloadbleOption(), + 'decorators' => array( + 'ViewHelper' + ) + )); //SoundCloud Username $this->addElement('text', 'SoundCloudUser', array( diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php new file mode 100644 index 000000000..cb7735cb5 --- /dev/null +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -0,0 +1,33 @@ +setting = $setting; + } + + public function startFrom() { + $setting = $this->setting; + $output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device'); + $output_sound_device->setLabel('Enabled') + ->setRequired(false) + ->setValue(($setting['output_sound_device'] == "true")?1:0) + ->setDecorators(array('ViewHelper')); + if (Application_Model_Preference::GetEnableStreamConf() == "false"){ + $output_sound_device->setAttrib("readonly", true); + } + $this->addElement($output_sound_device); + } + + public function isValid($data){ + $this->populate(array("output_sound_device"=>$data)); + return true; + } +} diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php new file mode 100644 index 000000000..70e28a7ba --- /dev/null +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -0,0 +1,188 @@ +prefix = $prefix; + } + + public function setSetting($setting){ + $this->setting = $setting; + } + + public function setStreamTypes($stream_types){ + $this->stream_types = $stream_types; + } + + public function setStreamBitrates($stream_bitrates){ + $this->stream_bitrates = $stream_bitrates; + } + + public function startForm(){ + $prefix = "s".$this->prefix; + $stream_number = $this->prefix; + $setting = $this->setting; + $stream_types = $this->stream_types; + $stream_bitrates = $this->stream_bitrates; + + $this->setIsArray(true); + $this->setElementsBelongTo($prefix."_data"); + + $disable_all = false; + if(Application_Model_Preference::GetEnableStreamConf() == "false"){ + $disable_all = true; + } + + $enable = new Zend_Form_Element_Checkbox('enable'); + $enable->setLabel('Enabled:') + ->setValue($setting[$prefix.'_output'] != 'disabled'?1:0) + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $enable->setAttrib("disabled", "disabled"); + } + $this->addElement($enable); + + $type = new Zend_Form_Element_Select('type'); + $type->setLabel("Stream Type:") + ->setMultiOptions($stream_types) + ->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0) + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $type->setAttrib("disabled", "disabled"); + } + $this->addElement($type); + + $bitrate = new Zend_Form_Element_Select('bitrate'); + $bitrate->setLabel("Bit Rate:") + ->setMultiOptions($stream_bitrates) + ->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0) + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $bitrate->setAttrib("disabled", "disabled"); + } + $this->addElement($type); + $this->addElement($bitrate); + + $output = new Zend_Form_Element_Select('output'); + $output->setLabel("Service Type:") + ->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"Shoutcast")) + ->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $output->setAttrib("disabled", "disabled"); + } + $this->addElement($output); + + $host = new Zend_Form_Element_Text('host'); + $host->setLabel("Server") + ->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $host->setAttrib("disabled", "disabled"); + } + $this->addElement($host); + + $port = new Zend_Form_Element_Text('port'); + $port->setLabel("Port") + ->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"") + ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) + ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $port->setAttrib("disabled", "disabled"); + } + $this->addElement($port); + + $pass = new Zend_Form_Element_Text('pass'); + $pass->setLabel("Password") + ->setValue(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $pass->setAttrib("disabled", "disabled"); + } + $this->addElement($pass); + + $genre = new Zend_Form_Element_Text('genre'); + $genre->setLabel("Genre") + ->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $genre->setAttrib("disabled", "disabled"); + } + $this->addElement($genre); + + $url = new Zend_Form_Element_Text('url'); + $url->setLabel("URL") + ->setValue(isset($setting[$prefix.'_url'])?$setting[$prefix.'_url']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $url->setAttrib("disabled", "disabled"); + } + $this->addElement($url); + + $description = new Zend_Form_Element_Text('description'); + $description->setLabel("Name/Description") + ->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $description->setAttrib("disabled", "disabled"); + } + $this->addElement($description); + + $mount = new Zend_Form_Element_Text('mount'); + $mount->setLabel("Mount Point") + ->setValue(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $mount->setAttrib("disabled", "disabled"); + } + $this->addElement($mount); + + $user = new Zend_Form_Element_Text('user'); + $user->setLabel("Username") + ->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"") + ->setDecorators(array('ViewHelper')); + if($disable_all){ + $user->setAttrib("disabled", "disabled"); + } + $this->addElement($user); + + $liquidsopa_error_msg = "Getting infomation from the server.."; + + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "liquidsoap_error_msg"=>$liquidsopa_error_msg)) + )); + } + + public function isValid ($data){ + $isValid = parent::isValid($data); + if($data['enable'] == 1){ + if($data['host'] == ''){ + $element = $this->getElement("host"); + $element->addError("Server cannot be empty."); + $isValid = false; + } + if($data['port'] == ''){ + $element = $this->getElement("port"); + $element->addError("Port cannot be empty."); + $isValid = false; + } + if($data['output'] == 'icecast'){ + if($data['mount'] == ''){ + $element = $this->getElement("mount"); + $element->addError("Mount cannot be empty with Icecast server."); + $isValid = false; + } + } + } + return $isValid; + } +} diff --git a/airtime_mvc/application/forms/SupportSettings.php b/airtime_mvc/application/forms/SupportSettings.php index ef6b9f2fa..605e85878 100644 --- a/airtime_mvc/application/forms/SupportSettings.php +++ b/airtime_mvc/application/forms/SupportSettings.php @@ -5,8 +5,8 @@ class Application_Form_SupportSettings extends Zend_Form public function init() { - $country_list = Application_Model_Preference::GetCountryList(); - + $country_list = Application_Model_Preference::GetCountryList(); + $this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/support-setting.phtml')), array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false))) @@ -105,6 +105,7 @@ class Application_Form_SupportSettings extends Zend_Form 'minheight' => 200, 'maxwidth' => 600, 'maxheight' => 600)); + $upload->setAttrib('accept', 'image/jpeg,image/gif,image/png,image/jpg'); $this->addElement($upload); //enable support feedback @@ -157,14 +158,19 @@ class Application_Form_SupportSettings extends Zend_Form $this->addElement($submit); } - // overwriting isValid function + // overriding isValid function public function isValid ($data) { $isValid = parent::isValid($data); - $checkPrivacy = $this->getElement('Privacy'); - if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){ - $checkPrivacy->addError("You have to agree to privacy policy."); - $isValid = false; + if($data['Publicise'] != 1){ + $isValid = true; + } + if(isset($data["Privacy"])){ + $checkPrivacy = $this->getElement('Privacy'); + if($data["SupportFeedback"] == "1" && $data["Privacy"] != "1"){ + $checkPrivacy->addError("You have to agree to privacy policy."); + $isValid = false; + } } return $isValid; } diff --git a/airtime_mvc/application/forms/WatchedDirPreferences.php b/airtime_mvc/application/forms/WatchedDirPreferences.php index 6e443b0bc..9e8021839 100644 --- a/airtime_mvc/application/forms/WatchedDirPreferences.php +++ b/airtime_mvc/application/forms/WatchedDirPreferences.php @@ -11,7 +11,7 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm $this->addElement('text', 'storageFolder', array( 'class' => 'input_text', - 'label' => 'Airtime\'s Storage Folder:', + 'label' => 'Import Folder:', 'required' => false, 'filters' => array('StringTrim'), 'value' => '', @@ -22,7 +22,7 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm $this->addElement('text', 'watchedFolder', array( 'class' => 'input_text', - 'label' => 'Choose a Folder to Watch:', + 'label' => 'Watched Folders:', 'required' => false, 'filters' => array('StringTrim'), 'value' => '', diff --git a/airtime_mvc/application/layouts/scripts/bare.phtml b/airtime_mvc/application/layouts/scripts/bare.phtml index d5070f175..6b37d41be 100644 --- a/airtime_mvc/application/layouts/scripts/bare.phtml +++ b/airtime_mvc/application/layouts/scripts/bare.phtml @@ -3,6 +3,8 @@ Livestream + headScript() ?> + headLink() ?>
layout()->content ?>
diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index cb71ad951..232fecd37 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -10,7 +10,7 @@
- partial('partialviews/header.phtml', array("user" => $this->loggedInAs())) ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> navigation()->menu()->setPartial($partial); ?> diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index cd55c2ec5..f84bd868c 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -10,7 +10,7 @@
- partial('partialviews/header.phtml', array("user" => $this->loggedInAs())) ?> + partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?> navigation()->menu()->setPartial($partial); ?> @@ -19,7 +19,8 @@
-
layout()->library ?>
+ +
layout()->library ?>
layout()->spl ?>
diff --git a/airtime_mvc/application/logging/Logging.php b/airtime_mvc/application/logging/Logging.php index 096dbd717..01ec88240 100644 --- a/airtime_mvc/application/logging/Logging.php +++ b/airtime_mvc/application/logging/Logging.php @@ -16,4 +16,9 @@ class Logging { public static function setLogPath($path){ self::$_path = $path; } + + public static function log($p_msg){ + $logger = self::getLogger(); + $logger->info($p_msg); + } } diff --git a/airtime_mvc/application/models/Dashboard.php b/airtime_mvc/application/models/Dashboard.php index dfdc97acd..fedadda44 100644 --- a/airtime_mvc/application/models/Dashboard.php +++ b/airtime_mvc/application/models/Dashboard.php @@ -9,8 +9,8 @@ class Application_Model_Dashboard //after the last item in the schedule table, then return the show's //name. Else return the last item from the schedule. - $showInstance = ShowInstance::GetLastShowInstance($p_timeNow); - $row = Schedule::GetLastScheduleItem($p_timeNow); + $showInstance = Application_Model_ShowInstance::GetLastShowInstance($p_timeNow); + $row = Application_Model_Schedule::GetLastScheduleItem($p_timeNow); if (is_null($showInstance)){ if (count($row) == 0){ @@ -53,10 +53,10 @@ class Application_Model_Dashboard //name. Else return the last item from the schedule. $row = array(); - $showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow); + $showInstance = Application_Model_ShowInstance::GetCurrentShowInstance($p_timeNow); if (!is_null($showInstance)){ $instanceId = $showInstance->getShowInstanceId(); - $row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId); + $row = Application_Model_Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId); } if (is_null($showInstance)){ if (count($row) == 0){ @@ -98,8 +98,8 @@ class Application_Model_Dashboard //after the last item in the schedule table, then return the show's //name. Else return the last item from the schedule. - $showInstance = ShowInstance::GetNextShowInstance($p_timeNow); - $row = Schedule::GetNextScheduleItem($p_timeNow); + $showInstance = Application_Model_ShowInstance::GetNextShowInstance($p_timeNow); + $row = Application_Model_Schedule::GetNextScheduleItem($p_timeNow); if (is_null($showInstance)){ if (count($row) == 0){ diff --git a/airtime_mvc/application/models/DateHelper.php b/airtime_mvc/application/models/DateHelper.php index bc7b21a86..1460012ec 100644 --- a/airtime_mvc/application/models/DateHelper.php +++ b/airtime_mvc/application/models/DateHelper.php @@ -1,12 +1,12 @@ _timestamp = date("U"); + $this->_dateTime = date("U"); } /** @@ -15,7 +15,19 @@ class DateHelper */ function getTimestamp() { - return date("Y-m-d H:i:s", $this->_timestamp); + return date("Y-m-d H:i:s", $this->_dateTime); + } + + /** + * Get time of object construction in the format + * YYYY-MM-DD HH:mm:ss + */ + function getUtcTimestamp() + { + $dateTime = new DateTime("@".$this->_dateTime); + $dateTime->setTimezone(new DateTimeZone("UTC")); + + return $dateTime->format("Y-m-d H:i:s"); } /** @@ -24,7 +36,7 @@ class DateHelper */ function getDate() { - return date("Y-m-d", $this->_timestamp); + return date("Y-m-d", $this->_dateTime); } /** @@ -33,7 +45,7 @@ class DateHelper */ function getTime() { - return date("H:i:s", $this->_timestamp); + return date("H:i:s", $this->_dateTime); } /** @@ -41,28 +53,30 @@ class DateHelper */ function setDate($dateString) { - $this->_timestamp = strtotime($dateString); + $this->_dateTime = strtotime($dateString); } /** - * - * Enter description here ... + * Find the epoch timestamp difference from "now" to the beginning of today. */ function getNowDayStartDiff() { - $dayStartTS = strtotime(date("Y-m-d", $this->_timestamp)); - return $this->_timestamp - $dayStartTS; + $dayStartTs = ((int)($this->_dateTime/86400))*86400; + return $this->_dateTime - $dayStartTs; } + /** + * Find the epoch timestamp difference from "now" to the end of today. + */ function getNowDayEndDiff() { - $dayEndTS = strtotime(date("Y-m-d", $this->_timestamp+(86400))); - return $dayEndTS - $this->_timestamp; + $dayEndTs = ((int)(($this->_dateTime+86400)/86400))*86400; + return $dayEndTs - $this->_dateTime; } function getEpochTime() { - return $this->_timestamp; + return $this->_dateTime; } public static function TimeDiff($time1, $time2) @@ -100,31 +114,31 @@ class DateHelper * format "hh:mm:ss". But when dealing with show times, we * do not care about the seconds. * - * @param int $p_timestamp + * @param int $p_dateTime * The value which to format. * @return int * The timestamp with the new format "hh:mm", or * the original input parameter, if it does not have * the correct format. */ - public static function removeSecondsFromTime($p_timestamp) + public static function removeSecondsFromTime($p_dateTime) { //Format is in hh:mm:ss. We want hh:mm - $timeExplode = explode(":", $p_timestamp); + $timeExplode = explode(":", $p_dateTime); if (count($timeExplode) == 3) return $timeExplode[0].":".$timeExplode[1]; else - return $p_timestamp; + return $p_dateTime; } - public static function getDateFromTimestamp($p_timestamp){ - $explode = explode(" ", $p_timestamp); + public static function getDateFromTimestamp($p_dateTime){ + $explode = explode(" ", $p_dateTime); return $explode[0]; } - public static function getTimeFromTimestamp($p_timestamp){ - $explode = explode(" ", $p_timestamp); + public static function getTimeFromTimestamp($p_dateTime){ + $explode = explode(" ", $p_dateTime); return $explode[1]; } @@ -157,5 +171,33 @@ class DateHelper return $totalSeconds; } + + public static function ConvertToUtcDateTime($p_dateString, $timezone){ + $dateTime = new DateTime($p_dateString, new DateTimeZone($timezone)); + $dateTime->setTimezone(new DateTimeZone("UTC")); + + return $dateTime; + } + + public static function ConvertToSpecificTimezoneDateTime($p_dateString, $timezone){ + $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); + $dateTime->setTimezone(new DateTimeZone($timezone)); + + return $dateTime; + } + + public static function ConvertToLocalDateTime($p_dateString){ + $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); + $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); + + return $dateTime; + } + + public static function ConvertToLocalDateTimeString($p_dateString, $format="Y-m-d H:i:s"){ + $dateTime = new DateTime($p_dateString, new DateTimeZone("UTC")); + $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); + + return $dateTime->format($format); + } } diff --git a/airtime_mvc/application/models/LoginAttempts.php b/airtime_mvc/application/models/LoginAttempts.php new file mode 100644 index 000000000..18b16df9b --- /dev/null +++ b/airtime_mvc/application/models/LoginAttempts.php @@ -0,0 +1,45 @@ +GetOne($sql); + if($res){ + $sql = "UPDATE cc_login_attempts SET attempts=attempts+1 WHERE ip='$ip'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + }else{ + $sql = "INSERT INTO cc_login_attempts (ip, attempts) values ('$ip', '1')"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + } + } + + public static function getAttempts($ip){ + global $CC_DBC; + $sql = "select attempts from cc_login_attempts WHERE ip='$ip'"; + $res = $CC_DBC->GetOne($sql); + return $res; + } + + public static function resetAttempts($ip){ + global $CC_DBC; + $sql = "select count(*) from cc_login_attempts WHERE ip='$ip'"; + $res = $CC_DBC->GetOne($sql); + if($res){ + $sql = "DELETE FROM cc_login_attempts WHERE ip='$ip'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + } + } +} \ No newline at end of file diff --git a/airtime_mvc/application/models/MusicDir.php b/airtime_mvc/application/models/MusicDir.php index d104ac268..8010b4c0f 100644 --- a/airtime_mvc/application/models/MusicDir.php +++ b/airtime_mvc/application/models/MusicDir.php @@ -2,7 +2,7 @@ class NestedDirectoryException extends Exception { } -class MusicDir { +class Application_Model_MusicDir { /** * @holds propel database object @@ -54,11 +54,11 @@ class MusicDir { $this->_dir->delete(); foreach ($show_instances as $show_instance_row) { - $temp_show = new ShowInstance($show_instance_row["instance_id"]); + $temp_show = new Application_Model_ShowInstance($show_instance_row["instance_id"]); $temp_show->updateScheduledTime(); } - RabbitMq::PushSchedule(); + Application_Model_RabbitMq::PushSchedule(); } /** @@ -184,7 +184,7 @@ class MusicDir { $data = array(); $data["directory"] = $p_path; - RabbitMq::SendMessageToMediaMonitor("new_watch", $data); + Application_Model_RabbitMq::SendMessageToMediaMonitor("new_watch", $data); } return $res; } @@ -193,7 +193,7 @@ class MusicDir { { $dir = CcMusicDirsQuery::create()->findPK($pk); - $mus_dir = new MusicDir($dir); + $mus_dir = new Application_Model_MusicDir($dir); return $mus_dir; } @@ -208,7 +208,7 @@ class MusicDir { return null; } else{ - $mus_dir = new MusicDir($dir); + $mus_dir = new Application_Model_MusicDir($dir); return $mus_dir; } } @@ -222,8 +222,7 @@ class MusicDir { ->find(); foreach($dirs as $dir) { - $tmp = new MusicDir($dir); - $result[] = $tmp; + $result[] = new Application_Model_MusicDir($dir); } return $result; @@ -235,7 +234,7 @@ class MusicDir { ->filterByType("stor") ->findOne(); - $mus_dir = new MusicDir($dir); + $mus_dir = new Application_Model_MusicDir($dir); return $mus_dir; } @@ -257,7 +256,7 @@ class MusicDir { $data = array(); $data["directory"] = $p_dir; $data["dir_id"] = $dirId; - RabbitMq::SendMessageToMediaMonitor("change_stor", $data); + Application_Model_RabbitMq::SendMessageToMediaMonitor("change_stor", $data); return array("code"=>0); }else{ return array("code"=>1, "error"=>"'$p_dir' is already set as the current storage dir or in the watched folders list."); @@ -273,7 +272,7 @@ class MusicDir { foreach($dirs as $dir) { $directory = $dir->getDirectory(); if (substr($p_filepath, 0, strlen($directory)) === $directory) { - $mus_dir = new MusicDir($dir); + $mus_dir = new Application_Model_MusicDir($dir); return $mus_dir; } } @@ -282,15 +281,19 @@ class MusicDir { } public static function removeWatchedDir($p_dir){ - $p_dir = realpath($p_dir)."/"; - $dir = MusicDir::getDirByPath($p_dir); + + $real_path = realpath($p_dir)."/"; + if($real_path != "/"){ + $p_dir = $real_path; + } + $dir = Application_Model_MusicDir::getDirByPath($p_dir); if($dir == NULL){ return array("code"=>1,"error"=>"'$p_dir' doesn't exist in the watched list."); }else{ $dir->remove(); $data = array(); $data["directory"] = $p_dir; - RabbitMq::SendMessageToMediaMonitor("remove_watch", $data); + Application_Model_RabbitMq::SendMessageToMediaMonitor("remove_watch", $data); return array("code"=>0); } } diff --git a/airtime_mvc/application/models/Nowplaying.php b/airtime_mvc/application/models/Nowplaying.php index eea8bbbb9..17c531fec 100644 --- a/airtime_mvc/application/models/Nowplaying.php +++ b/airtime_mvc/application/models/Nowplaying.php @@ -3,21 +3,31 @@ class Application_Model_Nowplaying { - public static function CreateHeaderRow($p_showName, $p_showStart, $p_showEnd){ + private static function CreateHeaderRow($p_showName, $p_showStart, $p_showEnd){ return array("h", "", $p_showStart, $p_showEnd, $p_showName, "", "", "", "", "", ""); } - public static function CreateDatatableRows($p_dbRows){ + private static function CreateDatatableRows($p_dbRows){ $dataTablesRows = array(); - $date = new DateHelper; - $timeNow = $date->getTimestamp(); + $epochNow = time(); foreach ($p_dbRows as $dbRow){ + + $showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']); + $showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']); + $itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']); + $itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']); + + $showStarts = $showStartDateTime->format("Y-m-d H:i:s"); + $showEnds = $showEndDateTime->format("Y-m-d H:i:s"); + $itemStarts = $itemStartDateTime->format("Y-m-d H:i:s"); + $itemEnds = $itemEndDateTime->format("Y-m-d H:i:s"); + $status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : ""; $type = "a"; - $type .= ($dbRow['item_ends'] > $timeNow && $dbRow['item_starts'] <= $timeNow) ? "c" : ""; + $type .= ($itemEndDateTime->getTimestamp() > $epochNow && $itemStartDateTime->getTimestamp() <= $epochNow) ? "c" : ""; // remove millisecond from the time format $itemStart = explode('.', $dbRow['item_starts']); @@ -25,36 +35,36 @@ class Application_Model_Nowplaying //format duration $duration = explode('.', $dbRow['clip_length']); - $formated = Application_Model_Nowplaying::FormatDuration($duration[0]); - $dataTablesRows[] = array($type, $dbRow['show_starts'], $itemStart[0], $itemEnd[0], - $formated, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'], + $formatted = self::FormatDuration($duration[0]); + $dataTablesRows[] = array($type, $showStarts, $itemStarts, $itemEnds, + $formatted, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'], $dbRow['playlist_name'], $dbRow['show_name'], $status); } return $dataTablesRows; } - public static function CreateGapRow($p_gapTime){ + private static function CreateGapRow($p_gapTime){ return array("g", "", "", "", $p_gapTime, "", "", "", "", "", ""); } - public static function CreateRecordingRow($p_showInstance){ + private static function CreateRecordingRow($p_showInstance){ return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", ""); } public static function GetDataGridData($viewType, $dateString){ if ($viewType == "now"){ - $date = new DateHelper; - $timeNow = $date->getTimestamp(); - + $dateTime = new DateTime("now", new DateTimeZone("UTC")); + $timeNow = $dateTime->format("Y-m-d H:i:s"); + $startCutoff = 60; $endCutoff = 86400; //60*60*24 - seconds in a day } else { - $date = new DateHelper; + $date = new Application_Model_DateHelper; $time = $date->getTime(); $date->setDate($dateString." ".$time); - $timeNow = $date->getTimestamp(); + $timeNow = $date->getUtcTimestamp(); $startCutoff = $date->getNowDayStartDiff(); $endCutoff = $date->getNowDayEndDiff(); @@ -62,33 +72,36 @@ class Application_Model_Nowplaying $data = array(); - $showIds = ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff); + $showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff); foreach ($showIds as $showId){ $instanceId = $showId['id']; - $si = new ShowInstance($instanceId); + $si = new Application_Model_ShowInstance($instanceId); $showId = $si->getShowId(); - $show = new Show($showId); + $show = new Application_Model_Show($showId); + + $showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowStart()); + $showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowEnd()); //append show header row - $data[] = Application_Model_Nowplaying::CreateHeaderRow($show->getName(), $si->getShowStart(), $si->getShowEnd()); + $data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s")); $scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff); - $dataTablesRows = Application_Model_Nowplaying::CreateDatatableRows($scheduledItems); + $dataTablesRows = self::CreateDatatableRows($scheduledItems); //append show audio item rows $data = array_merge($data, $dataTablesRows); //append show gap time row - $gapTime = Application_Model_Nowplaying::FormatDuration($si->getShowEndGapTime(), true); + $gapTime = self::FormatDuration($si->getShowEndGapTime(), true); if ($si->isRecorded()) - $data[] = Application_Model_Nowplaying::CreateRecordingRow($si); + $data[] = self::CreateRecordingRow($si); else if ($gapTime > 0) - $data[] = Application_Model_Nowplaying::CreateGapRow($gapTime); + $data[] = self::CreateGapRow($gapTime); } - return array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$data); + return array("currentShow"=>Application_Model_Show::GetCurrentShow($timeNow), "rows"=>$data); } public static function ShouldShowPopUp(){ @@ -102,7 +115,7 @@ class Application_Model_Nowplaying * default $time format should be in format of 00:00:00 * if $inSecond = true, then $time should be in seconds */ - public static function FormatDuration($time, $inSecond=false){ + private static function FormatDuration($time, $inSecond=false){ if($inSecond == false){ $duration = explode(':', $time); }else{ diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 6b8a2ffb6..09232a15e 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -9,7 +9,7 @@ define('INDCH', ' '); * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt */ -class Playlist { +class Application_Model_Playlist { // *** Variable stored in the database *** @@ -162,7 +162,7 @@ class Playlist { if($pl === NULL) return FALSE; - $storedPlaylist = new Playlist(); + $storedPlaylist = new Application_Model_Playlist(); $storedPlaylist->id = $id; $storedPlaylist->name = $pl->getDbName(); $storedPlaylist->state = $pl->getDbState(); @@ -187,7 +187,7 @@ class Playlist { return FALSE; $pl->setDbName($p_newname); - $pl->setDbMtime(new DateTime("now")); + $pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $pl->save(); $this->name = $p_newname; @@ -221,7 +221,7 @@ class Playlist { return FALSE; $pl->setDbDescription($p_description); - $pl->setDbMtime(new DateTime("now")); + $pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $pl->save(); //$this->name = $p_newname; @@ -254,7 +254,7 @@ class Playlist { return FALSE; $pl->setDbState($p_state); - $pl->setDbMtime(new DateTime("now")); + $pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $eb = (!is_null($p_editedby) ? $p_editedby : NULL); $pl->setDbEditedby($eb); @@ -405,10 +405,10 @@ class Playlist { foreach ($rows as $row) { $files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true); // display only upto 1 decimal place by calling secondsToPlaylistTime - $clipSec = Playlist::playlistTimeToSeconds($files[$i]['cliplength']); - $files[$i]['cliplength'] = Playlist::secondsToPlaylistTime($clipSec); + $clipSec = Application_Model_Playlist::playlistTimeToSeconds($files[$i]['cliplength']); + $files[$i]['cliplength'] = Application_Model_Playlist::secondsToPlaylistTime($clipSec); $offset += $clipSec; - $files[$i]['offset'] = Playlist::secondsToPlaylistTime($offset); + $files[$i]['offset'] = Application_Model_Playlist::secondsToPlaylistTime($offset); $i++; } @@ -424,8 +424,8 @@ class Playlist { return '00:00:00'; // calling two functions to format time to 1 decimal place - $sec = Playlist::playlistTimeToSeconds($res); - $res = Playlist::secondsToPlaylistTime($sec); + $sec = Application_Model_Playlist::playlistTimeToSeconds($res); + $res = Application_Model_Playlist::secondsToPlaylistTime($sec); return $res; } @@ -439,12 +439,11 @@ class Playlist { public function create($p_fname=NULL) { $this->name = !empty($p_fname) ? $p_fname : date("H:i:s"); - $this->mtime = new DateTime("now"); $pl = new CcPlaylist(); $pl->setDbName($this->name); $pl->setDbState("incomplete"); - $pl->setDbMtime($this->mtime); + $pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $pl->save(); $this->id = $pl->getDbId(); @@ -467,7 +466,7 @@ class Playlist { { if ($val && $this->isEdited() !== FALSE) { return PEAR::raiseError( - 'Playlist::lock: playlist already locked' + 'Application_Model_Playlist::lock: playlist already locked' ); } $r = $this->setEditFlag($subjid, $val); @@ -508,7 +507,7 @@ class Playlist { public function addAudioClip($p_mediaId, $p_position=NULL, $p_fadeIn=NULL, $p_fadeOut=NULL, $p_clipLength=NULL, $p_cuein=NULL, $p_cueout=NULL) { //get audio clip. - $media = StoredFile::Recall($p_mediaId); + $media = Application_Model_StoredFile::Recall($p_mediaId); if (is_null($media) || PEAR::isError($media)) { return $media; } @@ -1000,430 +999,3 @@ class Playlist { } } // class Playlist - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - * @todo Rename this class PlaylistTag - */ -class PlaylistTagExport -{ - public static function OutputToSmil(&$pl, $plt, $ind='') - { - $ind2 = $ind.INDCH; - $ind3 = $ind2.INDCH; - $ind4 = $ind3.INDCH; - $res = ""; - foreach ($plt['children'] as $ple) { - switch ($ple['elementname']) { - case "playlistElement": - $r = PlaylistElementExport::OutputToSmil($pl, $ple, $ind4); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $res .= $r; - } - break; - case "metadata": - $r = PlaylistMetadataExport::OutputToSmil($pl, $ple, $ind4); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $res .= $r; - } - break; - default: - } - } - $res = "$ind\n". - "$ind\n". - "$ind2\n". - "$ind3\n". - "$res". - "$ind3\n". - "$ind2\n". - "$ind\n"; - return $res; - } - - - public static function OutputToM3u(&$pl, $plt, $ind='') - { - $res = ""; - foreach ($plt['children'] as $ple) { - switch ($ple['elementname']) { - case"playlistElement": - $r = PlaylistElementExport::OutputToM3u($pl, $ple); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $res .= $r; - } - break; - } - } - $res = "#EXTM3U\n$res"; - return $res; - } - - - public static function OutputToRss(&$pl, $plt, $ind='') - { - $ind2 = $ind.INDCH; - $ind3 = $ind2.INDCH; - $res = ""; - foreach ($plt['children'] as $ple) { - switch ($ple['elementname']) { - case "playlistElement": - $r = PlaylistElementExport::OutputToRss($pl, $ple, $ind3); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $res .= $r; - } - break; - case "metadata": - $r = PlaylistMetadataExport::OutputToRss($pl, $ple, $ind3); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $res .= $r; - } - break; - default: - } - } - $res = "$ind\n". - "$ind\n". - "$ind2\n". - "$res". - "$ind2\n". - "$ind\n"; - return $res; - } -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - * @todo Rename this class "PlaylistElement" - */ -class PlaylistElementExport { - - public static function OutputToSmil(&$pl, $ple, $ind='') - { - $acOrPl = NULL; - $finfo = array('fi'=>0, 'fo'=>0); - $ind2 = $ind.INDCH; - $ind3 = $ind2.INDCH; - $anim = ''; - foreach ($ple['children'] as $ac) { - switch ($ac['elementname']) { - case "audioClip": - $r = PlaylistAudioClipExport::OutputToSmil($pl, $ac, $ind2); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $acOrPl = $r; - } - break; - case "playlist": - $gunid = $ac['attrs']['id']; - $pl2 = StoredFile::RecallByGunid($gunid); - if (is_null($pl2) || PEAR::isError($pl2)) { - return $pl2; - } - $r = $pl2->outputToSmil(FALSE); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $acOrPl = $r; - } - break; - case "fadeInfo": - $r = PlaylistFadeInfoExport::OutputToSmil($pl, $ac, $ind2); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $finfo = $r; - } - break; - default: - return PEAR::raiseError( - "PlaylistElementExport::OutputToSmil:". - " unknown tag {$ac['elementname']}" - ); - } - } - $beginS = Playlist::playlistTimeToSeconds($ple['attrs']['relativeOffset']); - $playlengthS = Playlist::playlistTimeToSeconds($acOrPl['playlength']); - $fadeOutS = Playlist::playlistTimeToSeconds($finfo['fo']); - $fiBeginS = 0; - $fiEndS = Playlist::playlistTimeToSeconds($finfo['fi']); - $foBeginS = ($playlengthS - $fadeOutS); - $foEndS = Playlist::playlistTimeToSeconds($acOrPl['playlength']); - foreach (array('fi','fo') as $ff) { - if (${$ff."EndS"} - ${$ff."BeginS"} > 0) { - $anim .= "{$ind2}\n" - ; - } - } - $src = $acOrPl['src']; - $str = "$ind" : " />"). - " ". - "\n"; - return $str; - } - - - public static function OutputToM3u(&$pl, $ple, $ind='') - { - $acOrPl = NULL; - foreach ($ple['children'] as $ac) { - switch ($ac['elementname']) { - case "audioClip": - $r = PlaylistAudioClipExport::OutputToM3u($pl, $ac); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $acOrPl = $r; - } - break; - case "playlist": - $gunid = $ac['attrs']['id']; - $pl2 = StoredFile::RecallByGunid($gunid); - if (is_null($pl2) || PEAR::isError($pl2)) { - return $pl2; - } - $r = $pl2->outputToM3u(FALSE); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $acOrPl = $r; - } - break; - } - } - if (is_null($acOrPl)) { - return ''; - } - $playlength = ceil(Playlist::playlistTimeToSeconds($acOrPl['playlength'])); - $title = $acOrPl['title']; - $uri = (isset($acOrPl['uri']) ? $acOrPl['uri'] : '???' ); - $res = "#EXTINF: $playlength, $title\n"; - $res .= "$uri\n"; - return $res; - } - - - public static function OutputToRss(&$pl, $ple, $ind='') - { - $acOrPl = NULL; - $ind2 = $ind.INDCH; - $anim = ''; - foreach ($ple['children'] as $ac) { - switch ($ac['elementname']) { - case "audioClip": - $r = PlaylistAudioClipExport::OutputToRss($pl, $ac, $ind2); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $acOrPl = $r; - } - break; - case "playlist": - $gunid = $ac['attrs']['id']; - $pl2 = StoredFile::RecallByGunid($gunid); - if (is_null($pl2) || PEAR::isError($pl2)) { - return $pl2; - } - $r = $pl2->outputToRss(FALSE); - if (PEAR::isError($r)) { - return $r; - } - if (!is_null($r)) { - $acOrPl = $r; - } - break; - case "fadeInfo": - break; - default: - return PEAR::raiseError( - "PlaylistElementExport::OutputToRss:". - " unknown tag {$ac['elementname']}" - ); - } - } - $title = (isset($acOrPl['title']) ? htmlspecialchars($acOrPl['title']) : '' ); - $desc = (isset($acOrPl['desc']) ? htmlspecialchars($acOrPl['desc']) : '' ); - $link = htmlspecialchars($acOrPl['src']); - $desc = ''; - $str = "$ind\n". - "$ind2$title\n". - "$ind2$desc\n". - "$ind2$link\n". - "$ind\n"; - return $str; - } -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - * @todo Rename this class to PlaylistAudioClip (notice the caps) - */ -class PlaylistAudioClipExport -{ - - public static function OutputToSmil(&$pl, $plac, $ind='') - { - $gunid = $plac['attrs']['id']; - $ac = StoredFile::RecallByGunid($gunid); - if (is_null($ac) || PEAR::isError($ac)) { - return $ac; - } - $RADext = $ac->getFileExtension(); - if (PEAR::isError($RADext)) { - return $RADext; - } - return array( - 'type' => 'audioclip', - 'gunid' => $gunid, - 'src' => AC_URL_RELPATH."$gunid.$RADext", - 'playlength' => $plac['attrs']['playlength'], - ); - } - - - public static function OutputToM3u(&$pl, $plac, $ind='') - { - $gunid = $plac['attrs']['id']; - $ac = StoredFile::RecallByGunid($gunid); - if (is_null($ac) || PEAR::isError($ac)) { - return $ac; - } - $RADext = $ac->getFileExtension(); - if (PEAR::isError($RADext)) { - return $RADext; - } - return array( - 'playlength' => $plac['attrs']['playlength'], - 'title' => $plac['attrs']['title'], - 'uri' => AC_URL_RELPATH."$gunid.$RADext", - ); - } - - - public static function OutputToRss(&$pl, $plac, $ind='') - { - $id = $plac['attrs']['id']; - $playlist = Playlist::Recall($id); - if (is_null($playlist) || PEAR::isError($playlist)) { - return $playlist; - } - $RADext = $playlist->getFileExtension(); - if (PEAR::isError($RADext)) { - return $RADext; - } - $title = $playlist->getName(); - $desc = $playlist->getPLMetaData("dc:description"); - return array( - 'type' => 'audioclip', - 'gunid' => $id, - 'src' => "http://XXX/YY/$id.$RADext", - 'playlength' => $plac['attrs']['playlength'], - 'title' => $title, - 'desc' => $desc, - ); - } -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - * @todo Rename this class "PlaylistFadeInfo" (notive the caps) - */ -class PlaylistFadeInfoExport -{ - - public static function OutputToSmil(&$pl, $plfi, $ind='') - { - $r = array( - 'fi'=>$plfi['attrs']['fadeIn'], - 'fo'=>$plfi['attrs']['fadeOut'], - ); - return $r; - } - - - public static function OutputToM3u(&$pl, $plfa, $ind='') - { - return ''; - } - - - public static function OutputToRss(&$pl, $plfa, $ind='') - { - return ''; - } - -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - * @todo Rename this class to PlaylistMetadata (notice the caps) - */ -class PlaylistMetadataExport -{ - public static function OutputToSmil(&$pl, $md, $ind='') - { - return NULL; - } - - - public static function OutputToM3u(&$pl, $md, $ind='') - { - return NULL; - } - - - public static function OutputToRss(&$pl, $md, $ind='') - { - return NULL; - } -} - diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 4d8b10cbe..337ba052b 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -3,7 +3,7 @@ class Application_Model_Preference { - public static function SetValue($key, $value){ + public static function SetValue($key, $value, $isUserValue = false){ global $CC_CONFIG, $CC_DBC; //called from a daemon process @@ -21,34 +21,58 @@ class Application_Model_Preference //Check if key already exists $sql = "SELECT COUNT(*) FROM cc_pref" ." WHERE keystr = '$key'"; + + //For user specific preference, check if id matches as well + if($isUserValue) { + $sql .= " AND subjid = '$id'"; + } + $result = $CC_DBC->GetOne($sql); - if ($result == 1 && is_null($id)){ - $sql = "UPDATE cc_pref" - ." SET subjid = NULL, valstr = '$value'" - ." WHERE keystr = '$key'"; - } - else if ($result == 1 && !is_null($id)){ - $sql = "UPDATE cc_pref" - ." SET subjid = $id, valstr = '$value'" - ." WHERE keystr = '$key'"; - } - else if(is_null($id)) { - $sql = "INSERT INTO cc_pref (keystr, valstr)" - ." VALUES ('$key', '$value')"; - } - else { - $sql = "INSERT INTO cc_pref (subjid, keystr, valstr)" - ." VALUES ($id, '$key', '$value')"; + if($result == 1) { + // result found + if(is_null($id) || !$isUserValue) { + // system pref + $sql = "UPDATE cc_pref" + ." SET subjid = NULL, valstr = '$value'" + ." WHERE keystr = '$key'"; + } else { + // user pref + $sql = "UPDATE cc_pref" + . " SET valstr = '$value'" + . " WHERE keystr = '$key' AND subjid = $id"; + } + } else { + // result not found + if(is_null($id) || !$isUserValue) { + // system pref + $sql = "INSERT INTO cc_pref (keystr, valstr)" + ." VALUES ('$key', '$value')"; + } else { + // user pref + $sql = "INSERT INTO cc_pref (subjid, keystr, valstr)" + ." VALUES ($id, '$key', '$value')"; + } } + return $CC_DBC->query($sql); } - public static function GetValue($key){ + public static function GetValue($key, $isUserValue = false){ global $CC_CONFIG, $CC_DBC; //Check if key already exists $sql = "SELECT COUNT(*) FROM cc_pref" ." WHERE keystr = '$key'"; + + //For user specific preference, check if id matches as well + if($isUserValue) { + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) { + $id = $auth->getIdentity()->id; + $sql .= " AND subjid = '$id'"; + } + } + $result = $CC_DBC->GetOne($sql); if ($result == 0) @@ -56,10 +80,15 @@ class Application_Model_Preference else { $sql = "SELECT valstr FROM cc_pref" ." WHERE keystr = '$key'"; + + //For user specific preference, check if id matches as well + if($isUserValue && $auth->hasIdentity()) { + $sql .= " AND subjid = '$id'"; + } + $result = $CC_DBC->GetOne($sql); return $result; } - } public static function GetHeadTitle(){ @@ -69,7 +98,7 @@ class Application_Model_Preference if (isset($defaultNamespace->title)) { $title = $defaultNamespace->title; } else { - $title = Application_Model_Preference::GetValue("station_name"); + $title = self::GetValue("station_name"); $defaultNamespace->title = $title; } if (strlen($title) > 0) @@ -79,109 +108,109 @@ class Application_Model_Preference } public static function SetHeadTitle($title, $view){ - Application_Model_Preference::SetValue("station_name", $title); + self::SetValue("station_name", $title); $defaultNamespace = new Zend_Session_Namespace('title_name'); $defaultNamespace->title = $title; - RabbitMq::PushSchedule(); + Application_Model_RabbitMq::PushSchedule(); //set session variable to new station name so that html title is updated. //should probably do this in a view helper to keep this controller as minimal as possible. $view->headTitle()->exchangeArray(array()); //clear headTitle ArrayObject - $view->headTitle(Application_Model_Preference::GetHeadTitle()); + $view->headTitle(self::GetHeadTitle()); } public static function SetShowsPopulatedUntil($timestamp) { - Application_Model_Preference::SetValue("shows_populated_until", $timestamp); + self::SetValue("shows_populated_until", $timestamp); } public static function GetShowsPopulatedUntil() { - return Application_Model_Preference::GetValue("shows_populated_until"); + return self::GetValue("shows_populated_until"); } public static function SetDefaultFade($fade) { - Application_Model_Preference::SetValue("default_fade", $fade); + self::SetValue("default_fade", $fade); } public static function GetDefaultFade() { - return Application_Model_Preference::GetValue("default_fade"); + return self::GetValue("default_fade"); } public static function SetStreamLabelFormat($type){ - Application_Model_Preference::SetValue("stream_label_format", $type); - RabbitMq::PushSchedule(); + self::SetValue("stream_label_format", $type); + Application_Model_RabbitMq::PushSchedule(); } public static function GetStreamLabelFormat(){ - return Application_Model_Preference::getValue("stream_label_format"); + return self::getValue("stream_label_format"); } public static function GetStationName(){ - return Application_Model_Preference::getValue("station_name"); + return self::getValue("station_name"); } - public static function SetDoSoundCloudUpload($upload) { - Application_Model_Preference::SetValue("soundcloud_upload", $upload); + public static function SetAutoUploadRecordedShowToSoundcloud($upload) { + self::SetValue("soundcloud_auto_upload_recorded_show", $upload); } - public static function GetDoSoundCloudUpload() { - return Application_Model_Preference::GetValue("soundcloud_upload"); + public static function GetAutoUploadRecordedShowToSoundcloud() { + return self::GetValue("soundcloud_auto_upload_recorded_show"); } public static function SetSoundCloudUser($user) { - Application_Model_Preference::SetValue("soundcloud_user", $user); + self::SetValue("soundcloud_user", $user); } public static function GetSoundCloudUser() { - return Application_Model_Preference::GetValue("soundcloud_user"); + return self::GetValue("soundcloud_user"); } public static function SetSoundCloudPassword($password) { if (strlen($password) > 0) - Application_Model_Preference::SetValue("soundcloud_password", $password); + self::SetValue("soundcloud_password", $password); } public static function GetSoundCloudPassword() { - return Application_Model_Preference::GetValue("soundcloud_password"); + return self::GetValue("soundcloud_password"); } public static function SetSoundCloudTags($tags) { - Application_Model_Preference::SetValue("soundcloud_tags", $tags); + self::SetValue("soundcloud_tags", $tags); } public static function GetSoundCloudTags() { - return Application_Model_Preference::GetValue("soundcloud_tags"); + return self::GetValue("soundcloud_tags"); } public static function SetSoundCloudGenre($genre) { - Application_Model_Preference::SetValue("soundcloud_genre", $genre); + self::SetValue("soundcloud_genre", $genre); } public static function GetSoundCloudGenre() { - return Application_Model_Preference::GetValue("soundcloud_genre"); + return self::GetValue("soundcloud_genre"); } public static function SetSoundCloudTrackType($track_type) { - Application_Model_Preference::SetValue("soundcloud_tracktype", $track_type); + self::SetValue("soundcloud_tracktype", $track_type); } public static function GetSoundCloudTrackType() { - return Application_Model_Preference::GetValue("soundcloud_tracktype"); + return self::GetValue("soundcloud_tracktype"); } public static function SetSoundCloudLicense($license) { - Application_Model_Preference::SetValue("soundcloud_license", $license); + self::SetValue("soundcloud_license", $license); } public static function GetSoundCloudLicense() { - return Application_Model_Preference::GetValue("soundcloud_license"); + return self::GetValue("soundcloud_license"); } public static function SetAllow3rdPartyApi($bool) { - Application_Model_Preference::SetValue("third_party_api", $bool); + self::SetValue("third_party_api", $bool); } public static function GetAllow3rdPartyApi() { - $val = Application_Model_Preference::GetValue("third_party_api"); + $val = self::GetValue("third_party_api"); if (strlen($val) == 0){ return "0"; } else { @@ -190,91 +219,101 @@ class Application_Model_Preference } public static function SetPhone($phone){ - Application_Model_Preference::SetValue("phone", $phone); + self::SetValue("phone", $phone); } public static function GetPhone(){ - return Application_Model_Preference::GetValue("phone"); + return self::GetValue("phone"); } public static function SetEmail($email){ - Application_Model_Preference::SetValue("email", $email); + self::SetValue("email", $email); } public static function GetEmail(){ - return Application_Model_Preference::GetValue("email"); + return self::GetValue("email"); } public static function SetStationWebSite($site){ - Application_Model_Preference::SetValue("station_website", $site); + self::SetValue("station_website", $site); } public static function GetStationWebSite(){ - return Application_Model_Preference::GetValue("station_website"); + return self::GetValue("station_website"); } public static function SetSupportFeedback($feedback){ - Application_Model_Preference::SetValue("support_feedback", $feedback); + self::SetValue("support_feedback", $feedback); } public static function GetSupportFeedback(){ - return Application_Model_Preference::GetValue("support_feedback"); + return self::GetValue("support_feedback"); } public static function SetPublicise($publicise){ - Application_Model_Preference::SetValue("publicise", $publicise); + self::SetValue("publicise", $publicise); } public static function GetPublicise(){ - return Application_Model_Preference::GetValue("publicise"); + return self::GetValue("publicise"); } public static function SetRegistered($registered){ - Application_Model_Preference::SetValue("registered", $registered); + self::SetValue("registered", $registered); } public static function GetRegistered(){ - return Application_Model_Preference::GetValue("registered"); + return self::GetValue("registered"); } public static function SetStationCountry($country){ - Application_Model_Preference::SetValue("country", $country); + self::SetValue("country", $country); } public static function GetStationCountry(){ - return Application_Model_Preference::GetValue("country"); + return self::GetValue("country"); } public static function SetStationCity($city){ - Application_Model_Preference::SetValue("city", $city); + self::SetValue("city", $city); } public static function GetStationCity(){ - return Application_Model_Preference::GetValue("city"); + return self::GetValue("city"); } public static function SetStationDescription($description){ - Application_Model_Preference::SetValue("description", $description); + self::SetValue("description", $description); } public static function GetStationDescription(){ - return Application_Model_Preference::GetValue("description"); + return self::GetValue("description"); + } + + public static function SetTimezone($timezone){ + self::SetValue("timezone", $timezone); + date_default_timezone_set($timezone); + $md = array("timezone" => $timezone); + } + + public static function GetTimezone(){ + return self::GetValue("timezone"); } public static function SetStationLogo($imagePath){ if(!empty($imagePath)){ $image = @file_get_contents($imagePath); $image = base64_encode($image); - Application_Model_Preference::SetValue("logoImage", $image); + self::SetValue("logoImage", $image); } } public static function GetStationLogo(){ - return Application_Model_Preference::GetValue("logoImage"); + return self::GetValue("logoImage"); } public static function GetUniqueId(){ - return Application_Model_Preference::GetValue("uniqueId"); + return self::GetValue("uniqueId"); } public static function GetCountryList(){ @@ -306,30 +345,30 @@ class Application_Model_Preference $outputArray = array(); - $outputArray['STATION_NAME'] = Application_Model_Preference::GetStationName(); - $outputArray['PHONE'] = Application_Model_Preference::GetPhone(); - $outputArray['EMAIL'] = Application_Model_Preference::GetEmail(); - $outputArray['STATION_WEB_SITE'] = Application_Model_Preference::GetStationWebSite(); - $outputArray['STATION_COUNTRY'] = Application_Model_Preference::GetStationCountry(); - $outputArray['STATION_CITY'] = Application_Model_Preference::GetStationCity(); - $outputArray['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription(); + $outputArray['STATION_NAME'] = self::GetStationName(); + $outputArray['PHONE'] = self::GetPhone(); + $outputArray['EMAIL'] = self::GetEmail(); + $outputArray['STATION_WEB_SITE'] = self::GetStationWebSite(); + $outputArray['STATION_COUNTRY'] = self::GetStationCountry(); + $outputArray['STATION_CITY'] = self::GetStationCity(); + $outputArray['STATION_DESCRIPTION'] = self::GetStationDescription(); // get web server info if(isset($systemInfoArray["AIRTIME_VERSION_URL"])){ $url = $systemInfoArray["AIRTIME_VERSION_URL"]; $index = strpos($url,'/api/'); $url = substr($url, 0, $index); - + $headerInfo = get_headers(trim($url),1); $outputArray['WEB_SERVER'] = $headerInfo['Server'][0]; } - - $outputArray['NUM_OF_USERS'] = User::getUserCount(); - $outputArray['NUM_OF_SONGS'] = StoredFile::getFileCount(); - $outputArray['NUM_OF_PLAYLISTS'] = Playlist::getPlaylistCount(); - $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Schedule::getSchduledPlaylistCount(); - $outputArray['NUM_OF_PAST_SHOWS'] = ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); - $outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId(); + + $outputArray['NUM_OF_USERS'] = Application_Model_User::getUserCount(); + $outputArray['NUM_OF_SONGS'] = Application_Model_StoredFile::getFileCount(); + $outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount(); + $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Application_Model_Schedule::getSchduledPlaylistCount(); + $outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); + $outputArray['UNIQUE_ID'] = self::GetUniqueId(); $outputArray = array_merge($systemInfoArray, $outputArray); @@ -340,8 +379,8 @@ class Application_Model_Preference } } if($returnArray){ - $outputArray['PROMOTE'] = Application_Model_Preference::GetPublicise(); - $outputArray['LOGOIMG'] = Application_Model_Preference::GetStationLogo(); + $outputArray['PROMOTE'] = self::GetPublicise(); + $outputArray['LOGOIMG'] = self::GetStationLogo(); return $outputArray; }else{ return $outputString; @@ -350,22 +389,168 @@ class Application_Model_Preference public static function SetRemindMeDate($now){ $weekAfter = mktime(0, 0, 0, date("m") , date("d")+7, date("Y")); - Application_Model_Preference::SetValue("remindme", $weekAfter); + self::SetValue("remindme", $weekAfter); } public static function GetRemindMeDate(){ - return Application_Model_Preference::GetValue("remindme"); + return self::GetValue("remindme"); } - + public static function SetImportTimestamp(){ $now = time(); - if(Application_Model_Preference::GetImportTimestamp()+5 < $now){ - Application_Model_Preference::SetValue("import_timestamp", $now); + if(self::GetImportTimestamp()+5 < $now){ + self::SetValue("import_timestamp", $now); } } - + public static function GetImportTimestamp(){ - return Application_Model_Preference::GetValue("import_timestamp"); + return self::GetValue("import_timestamp"); } + + public static function GetStreamType(){ + $st = self::GetValue("stream_type"); + return explode(',', $st); + } + + public static function GetStreamBitrate(){ + $sb = self::GetValue("stream_bitrate"); + return explode(',', $sb); + } + + public static function SetPrivacyPolicyCheck($flag){ + self::SetValue("privacy_policy", $flag); + } + + public static function GetPrivacyPolicyCheck(){ + return self::GetValue("privacy_policy"); + } + + public static function SetNumOfStreams($num){ + self::SetValue("num_of_streams", intval($num)); + } + + public static function GetNumOfStreams(){ + return self::GetValue("num_of_streams"); + } + + public static function SetMaxBitrate($bitrate){ + self::SetValue("max_bitrate", intval($bitrate)); + } + + public static function GetMaxBitrate(){ + return self::GetValue("max_bitrate"); + } + + public static function SetPlanLevel($plan){ + self::SetValue("plan_level", $plan); + } + + public static function GetPlanLevel(){ + return self::GetValue("plan_level"); + } + + public static function SetTrialEndingDate($date){ + self::SetValue("trial_end_date", $date); + } + + public static function GetTrialEndingDate(){ + return self::GetValue("trial_end_date"); + } + + public static function SetEnableStreamConf($bool){ + self::SetValue("enable_stream_conf", $bool); + } + + public static function GetEnableStreamConf(){ + if(self::GetValue("enable_stream_conf") == Null){ + return "true"; + } + return self::GetValue("enable_stream_conf"); + } + + public static function GetAirtimeVersion(){ + return self::GetValue("system_version"); + } + + public static function SetUploadToSoundcloudOption($upload) { + self::SetValue("soundcloud_upload_option", $upload); + } + + public static function GetUploadToSoundcloudOption() { + return self::GetValue("soundcloud_upload_option"); + } + + public static function SetSoundCloudDownloadbleOption($upload) { + self::SetValue("soundcloud_downloadable", $upload); + } + + public static function GetSoundCloudDownloadbleOption() { + return self::GetValue("soundcloud_downloadable"); + } + + public static function SetWeekStartDay($day) { + self::SetValue("week_start_day", $day); + } + + public static function GetWeekStartDay() { + $val = self::GetValue("week_start_day"); + if (strlen($val) == 0){ + return "0"; + } else { + return $val; + } + } + + /* User specific preferences start */ + + /** + * Sets the time scale preference (day/week/month) in Calendar. + * + * @param $timeScale new time scale + */ + public static function SetCalendarTimeScale($timeScale) { + return self::SetValue("calendar_time_scale", $timeScale, true /* user specific */); + } + + /** + * Retrieves the time scale preference for the current user. + */ + public static function GetCalendarTimeScale() { + return self::GetValue("calendar_time_scale", true /* user specific */); + } + + /** + * Sets the number of entries to show preference in library under Playlist Builder. + * + * @param $numEntries new number of entries to show + */ + public static function SetLibraryNumEntries($numEntries) { + return self::SetValue("library_num_entries", $numEntries, true /* user specific */); + } + + /** + * Retrieves the number of entries to show preference in library under Playlist Builder. + */ + public static function GetLibraryNumEntries() { + return self::GetValue("library_num_entries", true /* user specific */); + } + + /** + * Sets the time interval preference in Calendar. + * + * @param $timeInterval new time interval + */ + public static function SetCalendarTimeInterval($timeInterval) { + return self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */); + } + + /** + * Retrieves the time interval preference for the current user. + */ + public static function GetCalendarTimeInterval() { + return self::GetValue("calendar_time_interval", true /* user specific */); + } + + /* User specific preferences end */ } diff --git a/airtime_mvc/application/models/Prefs.php b/airtime_mvc/application/models/Prefs.php index f104bff59..bb90720e7 100644 --- a/airtime_mvc/application/models/Prefs.php +++ b/airtime_mvc/application/models/Prefs.php @@ -6,7 +6,7 @@ * @subpackage StorageServer * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt - * @see StoredFile + * @see Application_Model_StoredFile */ /* ================== Prefs ================== */ class Prefs { @@ -132,7 +132,7 @@ class Prefs { function loadGroupPref($group, $key, $returnErrorIfKeyNotExists = true) { // if sessid is would be used here fix Transport::cronCallMethod ! - $subjid = Subjects::GetSubjId($group); + $subjid = Application_Model_Subjects::GetSubjId($group); if (PEAR::isError($subjid)) { return $subjid; } @@ -179,7 +179,7 @@ class Prefs { return PEAR::raiseError( "Prefs::saveGroupPref: invalid session id", GBERR_SESS); } - $gid = Subjects::GetSubjId($group); + $gid = Application_Model_Subjects::GetSubjId($group); if (PEAR::isError($gid)) { return $gid; } @@ -187,7 +187,7 @@ class Prefs { return PEAR::raiseError( "Prefs::saveGroupPref: invalid group name", GBERR_SESS); } - $memb = Subjects::IsMemberOf($uid, $gid); + $memb = Application_Model_Subjects::IsMemberOf($uid, $gid); if (PEAR::isError($memb)) { return $memb; } @@ -229,7 +229,7 @@ class Prefs { return PEAR::raiseError( "Prefs::delGroupPref: invalid session id", GBERR_SESS); } - $gid = Subjects::GetSubjId($group); + $gid = Application_Model_Subjects::GetSubjId($group); if (PEAR::isError($gid)) { return $gid; } @@ -237,7 +237,7 @@ class Prefs { return PEAR::raiseError( "Prefs::delGroupPref: invalid group name", GBERR_SESS); } - $memb = Subjects::IsMemberOf($uid, $gid); + $memb = Application_Model_Subjects::IsMemberOf($uid, $gid); if (PEAR::isError($memb)) { return $memb; } diff --git a/airtime_mvc/application/models/RabbitMq.php b/airtime_mvc/application/models/RabbitMq.php index e50590622..bc5eaa1f7 100644 --- a/airtime_mvc/application/models/RabbitMq.php +++ b/airtime_mvc/application/models/RabbitMq.php @@ -1,45 +1,39 @@ channel(); - $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true); - $EXCHANGE = 'airtime-schedule'; - $channel->exchange_declare($EXCHANGE, 'direct', false, true); + $md["event_type"] = $event_type; - $data = json_encode(Schedule::GetScheduledPlaylists()); - $msg = new AMQPMessage($data, array('content_type' => 'text/plain')); + $conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"], + $CC_CONFIG["rabbitmq"]["port"], + $CC_CONFIG["rabbitmq"]["user"], + $CC_CONFIG["rabbitmq"]["password"]); + $channel = $conn->channel(); + $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true); - $channel->basic_publish($msg, $EXCHANGE); - $channel->close(); - $conn->close(); - - self::SendMessageToShowRecorder("update_schedule"); - } + $EXCHANGE = 'airtime-pypo'; + $channel->exchange_declare($EXCHANGE, 'direct', false, true); + + $data = json_encode($md); + $msg = new AMQPMessage($data, array('content_type' => 'text/plain')); + + $channel->basic_publish($msg, $EXCHANGE); + $channel->close(); + $conn->close(); } public static function SendMessageToMediaMonitor($event_type, $md) @@ -80,13 +74,13 @@ class RabbitMq $EXCHANGE = 'airtime-show-recorder'; $channel->exchange_declare($EXCHANGE, 'direct', false, true); - $today_timestamp = date("Y-m-d H:i:s"); - $now = new DateTime($today_timestamp); - $end_timestamp = $now->add(new DateInterval("PT2H")); - $end_timestamp = $end_timestamp->format("Y-m-d H:i:s"); + $now = new DateTime("@".time()); + $end_timestamp = new DateTime("@".(time() + 3600*2)); + $temp['event_type'] = $event_type; + $temp['server_timezone'] = Application_Model_Preference::GetTimezone(); if($event_type = "update_schedule"){ - $temp['shows'] = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE); + $temp['shows'] = Application_Model_Show::getShows($now->format("Y-m-d H:i:s"), $end_timestamp->format("Y-m-d H:i:s"), $excludeInstance=NULL, $onlyRecord=TRUE); } $data = json_encode($temp); $msg = new AMQPMessage($data, array('content_type' => 'text/plain')); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 33abd6d93..d5db0c091 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1,226 +1,6 @@ groupId = $p_groupId; - } - - /** - * Return true if the schedule group exists in the DB. - * @return boolean - */ - public function exists() { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG['scheduleTable'] - ." WHERE group_id=".$this->groupId; - $result = $CC_DBC->GetOne($sql); - if (PEAR::isError($result)) { - return $result; - } - return $result != "0"; - } - - /** - * Add a music clip or playlist to the schedule. - * - * @param int $p_showInstance - * ID of the show. - * @param $p_datetime - * In the format YYYY-MM-DD HH:MM:SS.mmmmmm - * @param $p_audioFileId - * (optional, either this or $p_playlistId must be set) DB ID of the audio file - * @param $p_playlistId - * (optional, either this of $p_audioFileId must be set) DB ID of the playlist - * @param $p_options - * Does nothing at the moment. - * - * @return int|PEAR_Error - * Return PEAR_Error if the item could not be added. - * Error code 555 is a scheduling conflict. - */ - public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) { - global $CC_CONFIG, $CC_DBC; - - if (!is_null($p_audioFileId)) { - // Schedule a single audio track - - // Load existing track - $track = StoredFile::Recall($p_audioFileId); - if (is_null($track)) { - return new PEAR_Error("Could not find audio track."); - } - - // Check if there are any conflicts with existing entries - $metadata = $track->getMetadata(); - $length = $metadata['MDATA_KEY_DURATION']; - if (empty($length)) { - return new PEAR_Error("Length is empty."); - } - // Insert into the table - $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); - - $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] - ." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)" - ." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', " - ." (TIMESTAMP '$p_datetime' + INTERVAL '$length')," - ." '$length'," - ." {$this->groupId}, $p_audioFileId, '$length')"; - $result = $CC_DBC->query($sql); - if (PEAR::isError($result)) { - //var_dump($sql); - return $result; - } - - } - elseif (!is_null($p_playlistId)){ - // Schedule a whole playlist - - // Load existing playlist - $playlist = Playlist::Recall($p_playlistId); - if (is_null($playlist)) { - return new PEAR_Error("Could not find playlist."); - } - - // Check if there are any conflicts with existing entries - $length = trim($playlist->getLength()); - //var_dump($length); - if (empty($length)) { - return new PEAR_Error("Length is empty."); - } - - // Insert all items into the schedule - $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); - $itemStartTime = $p_datetime; - - $plItems = $playlist->getContents(); - //var_dump($plItems); - foreach ($plItems as $row) { - $trackLength = $row["cliplength"]; - //var_dump($trackLength); - $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] - ." (instance_id, playlist_id, starts, ends, group_id, file_id," - ." clip_length, cue_in, cue_out, fade_in, fade_out)" - ." VALUES ($p_showInstance, $p_playlistId, TIMESTAMP '$itemStartTime', " - ." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength')," - ." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}'," - ." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')"; - $result = $CC_DBC->query($sql); - if (PEAR::isError($result)) { - //var_dump($sql); - return $result; - } - $itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'"); - } - } - - RabbitMq::PushSchedule(); - return $this->groupId; - } - - public function addFileAfter($show_instance, $p_groupId, $p_audioFileId) { - global $CC_CONFIG, $CC_DBC; - // Get the end time for the given entry - $sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"] - ." WHERE group_id=$p_groupId"; - $startTime = $CC_DBC->GetOne($sql); - return $this->add($show_instance, $startTime, $p_audioFileId); - } - - public function addPlaylistAfter($show_instance, $p_groupId, $p_playlistId) { - global $CC_CONFIG, $CC_DBC; - // Get the end time for the given entry - $sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"] - ." WHERE group_id=$p_groupId"; - - $startTime = $CC_DBC->GetOne($sql); - return $this->add($show_instance, $startTime, null, $p_playlistId); - } - - /** - * Remove the group from the schedule. - * Note: does not check if it is in the past, you can remove anything. - * - * @return boolean - * TRUE on success, false if there is no group ID defined. - */ - public function remove() { - global $CC_CONFIG, $CC_DBC; - if (is_null($this->groupId) || !is_numeric($this->groupId)) { - return false; - } - $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"] - ." WHERE group_id = ".$this->groupId; - //echo $sql; - $retVal = $CC_DBC->query($sql); - RabbitMq::PushSchedule(); - return $retVal; - } - - /** - * Return the number of items in this group. - * @return string - */ - public function count() { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT COUNT(*) FROM {$CC_CONFIG['scheduleTable']}" - ." WHERE group_id={$this->groupId}"; - return $CC_DBC->GetOne($sql); - } - - /* - * Return the list of items in this group as a 2D array. - * @return array - */ - public function getItems() { - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT " - ." st.id," - ." st.file_id," - ." st.cue_in," - ." st.cue_out," - ." st.clip_length," - ." st.fade_in," - ." st.fade_out," - ." st.starts," - ." st.ends" - ." FROM $CC_CONFIG[scheduleTable] as st" - ." LEFT JOIN $CC_CONFIG[showInstances] as si" - ." ON st.instance_id = si.id" - ." WHERE st.group_id=$this->groupId" - ." AND st.starts < si.ends" - ." ORDER BY st.starts"; - return $CC_DBC->GetAll($sql); - } - - public function notifyGroupStartPlay() { - global $CC_CONFIG, $CC_DBC; - $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] - ." SET schedule_group_played=TRUE" - ." WHERE group_id=".$this->groupId; - $retVal = $CC_DBC->query($sql); - return $retVal; - } - - public function notifyMediaItemStartPlay($p_fileId) { - global $CC_CONFIG, $CC_DBC; - $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] - ." SET media_item_played=TRUE" - ." WHERE group_id=".$this->groupId - ." AND file_id=".pg_escape_string($p_fileId); - $retVal = $CC_DBC->query($sql); - return $retVal; - } -} - -class Schedule { - - function __construct() { - - } +class Application_Model_Schedule { /** * Return true if there is nothing in the schedule for the given start time @@ -235,7 +15,7 @@ class Schedule { public static function isScheduleEmptyInRange($p_datetime, $p_length) { global $CC_CONFIG, $CC_DBC; if (empty($p_length)) { - return new PEAR_Error("Schedule::isSchedulerEmptyInRange: param p_length is empty."); + return new PEAR_Error("Application_Model_Schedule::isSchedulerEmptyInRange: param p_length is empty."); } $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"] ." WHERE (starts >= '$p_datetime') " @@ -307,9 +87,8 @@ class Schedule { $row["id"] = $row["group_id"]; } } else { - $sql = "SELECT MIN(st.name) AS name," - ." MIN(pt.creator) AS creator," - ." st.group_id, " + $sql = "SELECT MIN(pt.creator) AS creator," + ." st.group_id," ." SUM(st.clip_length) AS clip_length," ." MIN(st.file_id) AS file_id," ." COUNT(*) as count," @@ -326,6 +105,7 @@ class Schedule { ." ON st.instance_id = si.id" ." LEFT JOIN $CC_CONFIG[showTable] as sh" ." ON si.show_id = sh.id" + //The next line ensures we only get songs that haven't ended yet ." WHERE (st.ends >= TIMESTAMP '$p_currentDateTime')" ." AND (st.ends <= TIMESTAMP '$p_toDateTime')" //next line makes sure that we aren't returning items that @@ -363,18 +143,15 @@ class Schedule { global $CC_CONFIG; - $date = new DateHelper; - $timeNow = $date->getTimestamp(); + $date = new Application_Model_DateHelper; + $timeNow = $date->getUtcTimestamp(); return array("env"=>APPLICATION_ENV, - "schedulerTime"=>gmdate("Y-m-d H:i:s"), - //"previous"=>Schedule::GetScheduledItemData($timeNow, -1, $prev, "24 hours"), - //"current"=>Schedule::GetScheduledItemData($timeNow, 0), - //"next"=>Schedule::GetScheduledItemData($timeNow, 1, $next, "48 hours"), + "schedulerTime"=>$timeNow, "previous"=>Application_Model_Dashboard::GetPreviousItem($timeNow), "current"=>Application_Model_Dashboard::GetCurrentItem($timeNow), "next"=>Application_Model_Dashboard::GetNextItem($timeNow), - "currentShow"=>Show_DAL::GetCurrentShow($timeNow), - "nextShow"=>Show_DAL::GetNextShows($timeNow, 1), + "currentShow"=>Application_Model_Show::GetCurrentShow($timeNow), + "nextShow"=>Application_Model_Show::GetNextShows($timeNow, 1), "timezone"=> date("T"), "timezoneOffset"=> date("Z")); } @@ -660,21 +437,21 @@ class Schedule { global $CC_CONFIG, $CC_DBC; if (is_null($p_fromDateTime)) { - $t1 = new DateTime(); + $t1 = new DateTime("@".time()); $range_start = $t1->format("Y-m-d H:i:s"); } else { - $range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime); + $range_start = Application_Model_Schedule::PypoTimeToAirtimeTime($p_fromDateTime); } if (is_null($p_fromDateTime)) { - $t2 = new DateTime(); + $t2 = new DateTime("@".time()); $t2->add(new DateInterval("PT24H")); $range_end = $t2->format("Y-m-d H:i:s"); } else { - $range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime); + $range_end = Application_Model_Schedule::PypoTimeToAirtimeTime($p_toDateTime); } // Scheduler wants everything in a playlist - $data = Schedule::GetItems($range_start, $range_end, true); + $data = Application_Model_Schedule::GetItems($range_start, $range_end, true); $playlists = array(); if (is_array($data)){ @@ -685,50 +462,51 @@ class Schedule { $start = substr($start, 0, 19); //Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss" - $pkey = Schedule::AirtimeTimeToPypoTime($start); + $pkey = Application_Model_Schedule::AirtimeTimeToPypoTime($start); $timestamp = strtotime($start); $playlists[$pkey]['source'] = "PLAYLIST"; $playlists[$pkey]['x_ident'] = $dx['group_id']; - //$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive $playlists[$pkey]['timestamp'] = $timestamp; $playlists[$pkey]['duration'] = $dx['clip_length']; $playlists[$pkey]['played'] = '0'; $playlists[$pkey]['schedule_id'] = $dx['group_id']; $playlists[$pkey]['show_name'] = $dx['show_name']; - $playlists[$pkey]['show_start'] = Schedule::AirtimeTimeToPypoTime($dx['show_start']); - $playlists[$pkey]['show_end'] = Schedule::AirtimeTimeToPypoTime($dx['show_end']); + $playlists[$pkey]['show_start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx['show_start']); + $playlists[$pkey]['show_end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx['show_end']); $playlists[$pkey]['user_id'] = 0; $playlists[$pkey]['id'] = $dx['group_id']; - $playlists[$pkey]['start'] = Schedule::AirtimeTimeToPypoTime($dx["start"]); - $playlists[$pkey]['end'] = Schedule::AirtimeTimeToPypoTime($dx["end"]); + $playlists[$pkey]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx["start"]); + $playlists[$pkey]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($dx["end"]); } } + ksort($playlists); foreach ($playlists as &$playlist) { - $scheduleGroup = new ScheduleGroup($playlist["schedule_id"]); + $scheduleGroup = new Application_Model_ScheduleGroup($playlist["schedule_id"]); $items = $scheduleGroup->getItems(); $medias = array(); foreach ($items as $item) { - $storedFile = StoredFile::Recall($item["file_id"]); - $uri = $storedFile->getFileUrl(); + $storedFile = Application_Model_StoredFile::Recall($item["file_id"]); + $uri = $storedFile->getFileUrlUsingConfigAddress(); - $starts = Schedule::AirtimeTimeToPypoTime($item["starts"]); + $starts = Application_Model_Schedule::AirtimeTimeToPypoTime($item["starts"]); $medias[$starts] = array( 'row_id' => $item["id"], 'id' => $storedFile->getGunid(), 'uri' => $uri, - 'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]), - 'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]), + 'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]), + 'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]), 'fade_cross' => 0, - 'cue_in' => DateHelper::CalculateLengthInSeconds($item["cue_in"]), - 'cue_out' => DateHelper::CalculateLengthInSeconds($item["cue_out"]), + 'cue_in' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_in"]), + 'cue_out' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_out"]), 'export_source' => 'scheduler', 'start' => $starts, - 'end' => Schedule::AirtimeTimeToPypoTime($item["ends"]) + 'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["ends"]) ); } + ksort($medias); $playlist['medias'] = $medias; } @@ -740,7 +518,6 @@ class Schedule { $result['stream_metadata'] = array(); $result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat(); $result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName(); - $result['server_timezone'] = date('O'); return $result; } @@ -752,33 +529,25 @@ class Schedule { } public static function createNewFormSections($p_view){ + $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; + $formWhat = new Application_Form_AddShowWhat(); $formWho = new Application_Form_AddShowWho(); $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); $formStyle = new Application_Form_AddShowStyle(); - $formRecord = new Application_Form_AddShowRR(); - $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); - $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); $formRepeats->removeDecorator('DtDdWrapper'); $formStyle->removeDecorator('DtDdWrapper'); - $formRecord->removeDecorator('DtDdWrapper'); - $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); - $formRebroadcast->removeDecorator('DtDdWrapper'); $p_view->what = $formWhat; $p_view->when = $formWhen; $p_view->repeats = $formRepeats; $p_view->who = $formWho; $p_view->style = $formStyle; - $p_view->rr = $formRecord; - $p_view->absoluteRebroadcast = $formAbsoluteRebroadcast; - $p_view->rebroadcast = $formRebroadcast; - $p_view->addNewShow = true; $formWhat->populate(array('add_show_id' => '-1')); $formWhen->populate(array('add_show_start_date' => date("Y-m-d"), @@ -788,6 +557,21 @@ class Schedule { 'add_show_duration' => '1h')); $formRepeats->populate(array('add_show_end_date' => date("Y-m-d"))); + + if(!$isSaas){ + $formRecord = new Application_Form_AddShowRR(); + $formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates(); + $formRebroadcast = new Application_Form_AddShowRebroadcastDates(); + + $formRecord->removeDecorator('DtDdWrapper'); + $formAbsoluteRebroadcast->removeDecorator('DtDdWrapper'); + $formRebroadcast->removeDecorator('DtDdWrapper'); + + $p_view->rr = $formRecord; + $p_view->absoluteRebroadcast = $formAbsoluteRebroadcast; + $p_view->rebroadcast = $formRebroadcast; + } + $p_view->addNewShow = true; } } diff --git a/airtime_mvc/application/models/ScheduleGroup.php b/airtime_mvc/application/models/ScheduleGroup.php new file mode 100644 index 000000000..5d8b29b21 --- /dev/null +++ b/airtime_mvc/application/models/ScheduleGroup.php @@ -0,0 +1,216 @@ +groupId = $p_groupId; + } + + /** + * Return true if the schedule group exists in the DB. + * @return boolean + */ + public function exists() { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG['scheduleTable'] + ." WHERE group_id=".$this->groupId; + $result = $CC_DBC->GetOne($sql); + if (PEAR::isError($result)) { + return $result; + } + return $result != "0"; + } + + /** + * Add a music clip or playlist to the schedule. + * + * @param int $p_showInstance + * ID of the show. + * @param $p_datetime + * In the format YYYY-MM-DD HH:MM:SS.mmmmmm + * @param $p_audioFileId + * (optional, either this or $p_playlistId must be set) DB ID of the audio file + * @param $p_playlistId + * (optional, either this of $p_audioFileId must be set) DB ID of the playlist + * @param $p_options + * Does nothing at the moment. + * + * @return int|PEAR_Error + * Return PEAR_Error if the item could not be added. + * Error code 555 is a scheduling conflict. + */ + public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) { + global $CC_CONFIG, $CC_DBC; + + if (!is_null($p_audioFileId)) { + // Schedule a single audio track + + // Load existing track + $track = Application_Model_StoredFile::Recall($p_audioFileId); + if (is_null($track)) { + return new PEAR_Error("Could not find audio track."); + } + + // Check if there are any conflicts with existing entries + $metadata = $track->getMetadata(); + $length = $metadata['MDATA_KEY_DURATION']; + if (empty($length)) { + return new PEAR_Error("Length is empty."); + } + // Insert into the table + $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); + + $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] + ." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)" + ." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', " + ." (TIMESTAMP '$p_datetime' + INTERVAL '$length')," + ." '$length'," + ." {$this->groupId}, $p_audioFileId, '$length')"; + $result = $CC_DBC->query($sql); + if (PEAR::isError($result)) { + //var_dump($sql); + return $result; + } + + } + elseif (!is_null($p_playlistId)){ + // Schedule a whole playlist + + // Load existing playlist + $playlist = Application_Model_Playlist::Recall($p_playlistId); + if (is_null($playlist)) { + return new PEAR_Error("Could not find playlist."); + } + + // Check if there are any conflicts with existing entries + $length = trim($playlist->getLength()); + //var_dump($length); + if (empty($length)) { + return new PEAR_Error("Length is empty."); + } + + // Insert all items into the schedule + $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); + $itemStartTime = $p_datetime; + + $plItems = $playlist->getContents(); + //var_dump($plItems); + foreach ($plItems as $row) { + $trackLength = $row["cliplength"]; + //var_dump($trackLength); + $sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"] + ." (instance_id, playlist_id, starts, ends, group_id, file_id," + ." clip_length, cue_in, cue_out, fade_in, fade_out)" + ." VALUES ($p_showInstance, $p_playlistId, TIMESTAMP '$itemStartTime', " + ." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength')," + ." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}'," + ." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')"; + $result = $CC_DBC->query($sql); + if (PEAR::isError($result)) { + //var_dump($sql); + return $result; + } + $itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'"); + } + } + + Application_Model_RabbitMq::PushSchedule(); + return $this->groupId; + } + + public function addFileAfter($show_instance, $p_groupId, $p_audioFileId) { + global $CC_CONFIG, $CC_DBC; + // Get the end time for the given entry + $sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE group_id=$p_groupId"; + $startTime = $CC_DBC->GetOne($sql); + return $this->add($show_instance, $startTime, $p_audioFileId); + } + + public function addPlaylistAfter($show_instance, $p_groupId, $p_playlistId) { + global $CC_CONFIG, $CC_DBC; + // Get the end time for the given entry + $sql = "SELECT MAX(ends) FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE group_id=$p_groupId"; + + $startTime = $CC_DBC->GetOne($sql); + return $this->add($show_instance, $startTime, null, $p_playlistId); + } + + /** + * Remove the group from the schedule. + * Note: does not check if it is in the past, you can remove anything. + * + * @return boolean + * TRUE on success, false if there is no group ID defined. + */ + public function remove() { + global $CC_CONFIG, $CC_DBC; + if (is_null($this->groupId) || !is_numeric($this->groupId)) { + return false; + } + $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE group_id = ".$this->groupId; + //echo $sql; + $retVal = $CC_DBC->query($sql); + Application_Model_RabbitMq::PushSchedule(); + return $retVal; + } + + /** + * Return the number of items in this group. + * @return string + */ + public function count() { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT COUNT(*) FROM {$CC_CONFIG['scheduleTable']}" + ." WHERE group_id={$this->groupId}"; + return $CC_DBC->GetOne($sql); + } + + /* + * Return the list of items in this group as a 2D array. + * @return array + */ + public function getItems() { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT " + ." st.id," + ." st.file_id," + ." st.cue_in," + ." st.cue_out," + ." st.clip_length," + ." st.fade_in," + ." st.fade_out," + ." st.starts," + ." st.ends" + ." FROM $CC_CONFIG[scheduleTable] as st" + ." LEFT JOIN $CC_CONFIG[showInstances] as si" + ." ON st.instance_id = si.id" + ." WHERE st.group_id=$this->groupId" + ." AND st.starts < si.ends" + ." ORDER BY st.starts"; + return $CC_DBC->GetAll($sql); + } + + public function notifyGroupStartPlay() { + global $CC_CONFIG, $CC_DBC; + $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] + ." SET schedule_group_played=TRUE" + ." WHERE group_id=".$this->groupId; + $retVal = $CC_DBC->query($sql); + return $retVal; + } + + public function notifyMediaItemStartPlay($p_fileId) { + global $CC_CONFIG, $CC_DBC; + $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] + ." SET media_item_played=TRUE" + ." WHERE group_id=".$this->groupId + ." AND file_id=".pg_escape_string($p_fileId); + $retVal = $CC_DBC->query($sql); + return $retVal; + } +} diff --git a/airtime_mvc/application/models/ServiceRegister.php b/airtime_mvc/application/models/ServiceRegister.php new file mode 100644 index 000000000..47c647829 --- /dev/null +++ b/airtime_mvc/application/models/ServiceRegister.php @@ -0,0 +1,25 @@ +findOneByDbName($p_componentName); + + if ($component == NULL){ + $component = new CcServiceRegister(); + $component->setDbName($p_componentName); + } + + // Need to convert ipv6 to ipv4 since Monit server does not appear + // to allow access via an ipv6 address. + // http://[::1]:2812 does not respond. + // Bug: http://savannah.nongnu.org/bugs/?27608 + if ($p_ipAddress == "::1"){ + $p_ipAddress = "127.0.0.1"; + } + + $component->setDbIp($p_ipAddress); + $component->save(); + } + +} diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Show.php similarity index 56% rename from airtime_mvc/application/models/Shows.php rename to airtime_mvc/application/models/Show.php index 1311b837a..d60abe71d 100644 --- a/airtime_mvc/application/models/Shows.php +++ b/airtime_mvc/application/models/Show.php @@ -1,6 +1,6 @@ findPK($this->_showId); $show->setDbName($name); - RabbitMq::PushSchedule(); + Application_Model_RabbitMq::PushSchedule(); } public function getDescription() @@ -119,7 +119,7 @@ class Show { WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}"; $CC_DBC->query($sql); - RabbitMq::PushSchedule(); + Application_Model_RabbitMq::PushSchedule(); } /** @@ -137,7 +137,7 @@ class Show { $uncheckedDaysImploded = implode(",", $p_uncheckedDays); $showId = $this->getId(); - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $sql = "DELETE FROM cc_show_instances" @@ -302,7 +302,7 @@ class Show { public function deleteAllInstances(){ global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $showId = $this->getId(); @@ -321,7 +321,7 @@ class Show { public function deleteAllRebroadcasts(){ global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $showId = $this->getId(); @@ -343,11 +343,11 @@ class Show { public function removeAllInstancesFromDate($p_date=null){ global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); if(is_null($p_date)) { - $date = new DateHelper; + $date = new Application_Model_DateHelper; $p_date = $date->getDate(); } @@ -377,7 +377,7 @@ class Show { public function removeAllInstancesBeforeDate($p_date){ global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $showId = $this->getId(); @@ -434,7 +434,7 @@ class Show { } } - /** + /** * Get the end date of the current show. * Note that this is not the end date of repeated show * @@ -481,7 +481,7 @@ class Show { * true if the StartDate is in the past, false otherwise */ public function isStartDateTimeInPast(){ - $date = new DateHelper; + $date = new Application_Model_DateHelper; $current_timestamp = $date->getTimestamp(); return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime()); } @@ -495,7 +495,7 @@ class Show { public function getAllFutureInstanceIds(){ global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $showId = $this->getId(); @@ -517,7 +517,7 @@ class Show { global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $sql = "UPDATE cc_show_days " @@ -538,7 +538,7 @@ class Show { global $CC_DBC; - $date = new DateHelper; + $date = new Application_Model_DateHelper; $timestamp = $date->getTimestamp(); $sql = "UPDATE cc_show_days " @@ -577,10 +577,10 @@ class Show { public function getDuration($format=false){ $showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne(); if(!$format){ - return $showDay->getDbDuration(); + return $showDay->getDbDuration(); }else{ - $info = explode(':',$showDay->getDbDuration()); - return ($info[0] != 0 ? intval($info[0]).'h'.' ' : '').($info[1] != 0 ? intval($info[1]).'m' : ''); + $info = explode(':',$showDay->getDbDuration()); + return ($info[0] != 0 ? intval($info[0]).'h'.' ' : '').($info[1] != 0 ? intval($info[1]).'m' : ''); } } @@ -604,16 +604,18 @@ class Show { return $showInstances; } - public function hasInstanceOnDate($p_timestamp){ - return (!is_null($this->getInstanceOnDate($p_timestamp))); + public function hasInstanceOnDate($p_dateTime){ + return (!is_null($this->getInstanceOnDate($p_dateTeim))); } - public function getInstanceOnDate($p_timestamp){ + public function getInstanceOnDate($p_dateTime){ global $CC_DBC; + $timestamp = $p_dateTime->getTimestamp(); + $showId = $this->getId(); $sql = "SELECT id FROM cc_show_instances" - ." WHERE date(starts) = date(TIMESTAMP '$p_timestamp') " + ." WHERE date(starts) = date(TIMESTAMP '$timestamp') " ." AND show_id = $showId"; $row = $CC_DBC->GetOne($sql); @@ -724,27 +726,31 @@ class Show { */ public static function create($data) { - $con = Propel::getConnection(CcShowPeer::DATABASE_NAME); - $sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$data['add_show_start_date']} {$data['add_show_start_time']}')"; - $r = $con->query($sql); - $startDow = $r->fetchColumn(0); + $startDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']); + $utcStartDateTime = clone $startDateTime; + $utcStartDateTime->setTimezone(new DateTimeZone('UTC')); if ($data['add_show_no_end']) { $endDate = NULL; } else if ($data['add_show_repeats']) { - $sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' "; - $r = $con->query($sql); - $endDate = $r->fetchColumn(0); + $endDateTime = new DateTime($data['add_show_end_date']); + //$endDateTime->setTimezone(new DateTimeZone('UTC')); + $endDateTime->add(new DateInterval("P1D")); + $endDate = $endDateTime->format("Y-m-d"); } else { - $sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '1 day' "; - $r = $con->query($sql); - $endDate = $r->fetchColumn(0); + $endDateTime = new DateTime($data['add_show_start_date']); + //$endDateTime->setTimezone(new DateTimeZone('UTC')); + $endDateTime->add(new DateInterval("P1D")); + $endDate = $endDateTime->format("Y-m-d"); } - //only want the day of the week from the start date. + //What we are doing here is checking if the show repeats or if + //any repeating days have been checked. If not, then by default + //the "selected" DOW is the initial day. + $startDow = date("w", $utcStartDateTime->getTimestamp()); if (!$data['add_show_repeats']) { $data['add_show_day_check'] = array($startDow); } else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") { @@ -768,11 +774,11 @@ class Show { $ccShow->save(); $showId = $ccShow->getDbId(); - $show = new Show($showId); - $isRecorded = ($data['add_show_record']) ? 1 : 0; + $isRecorded = (isset($data['add_show_record']) && $data['add_show_record']) ? 1 : 0; if ($data['add_show_id'] != -1){ + $show = new Application_Model_Show($showId); $show->deletePossiblyInvalidInstances($data, $endDate, $isRecorded, $repeatType); } @@ -785,37 +791,33 @@ class Show { //don't set day for monthly repeat type, it's invalid. if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2){ $showDay = new CcShowDays(); - $showDay->setDbFirstShow($data['add_show_start_date']); + $showDay->setDbFirstShow($startDateTime->format("Y-m-d")); $showDay->setDbLastShow($endDate); - $showDay->setDbStartTime($data['add_show_start_time']); + $showDay->setDbStartTime($startDateTime->format("H:i:s")); + $showDay->setDbTimezone(date_default_timezone_get()); $showDay->setDbDuration($data['add_show_duration']); $showDay->setDbRepeatType($repeatType); $showDay->setDbShowId($showId); $showDay->setDbRecord($isRecorded); $showDay->save(); - } - else { + } else { foreach ($data['add_show_day_check'] as $day) { + $daysAdd=0; + $startDateTimeClone = clone $startDateTime; if ($startDow !== $day){ - if ($startDow > $day) $daysAdd = 6 - $startDow + 1 + $day; else $daysAdd = $day - $startDow; - - $sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' "; - $r = $con->query($sql); - $start = $r->fetchColumn(0); + + $startDateTimeClone->add(new DateInterval("P".$daysAdd."D")); } - else { - $start = $data['add_show_start_date']; - } - - if (strtotime($start) <= strtotime($endDate) || is_null($endDate)) { + if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) { $showDay = new CcShowDays(); - $showDay->setDbFirstShow($start); + $showDay->setDbFirstShow($startDateTimeClone->format("Y-m-d")); $showDay->setDbLastShow($endDate); - $showDay->setDbStartTime($data['add_show_start_time']); + $showDay->setDbStartTime($startDateTimeClone->format("H:i")); + $showDay->setDbTimezone(date_default_timezone_get()); $showDay->setDbDuration($data['add_show_duration']); $showDay->setDbDay($day); $showDay->setDbRepeatType($repeatType); @@ -826,15 +828,11 @@ class Show { } } - $date = new DateHelper(); - $currentTimestamp = $date->getTimestamp(); - //check if we are adding or updating a show, and if updating //erase all the show's future show_rebroadcast information first. if (($data['add_show_id'] != -1) && $data['add_show_rebroadcast']){ CcShowRebroadcastQuery::create() ->filterByDbShowId($data['add_show_id']) - //->filterByDbStartTime($currentTimestamp, Criteria::GREATER_EQUAL) ->delete(); } //adding rows to cc_show_rebroadcast @@ -852,6 +850,7 @@ class Show { else if ($isRecorded && $data['add_show_rebroadcast'] && ($repeatType == -1)){ for ($i=1; $i<=10; $i++) { if ($data['add_show_rebroadcast_date_absolute_'.$i]) { + $con = Propel::getConnection(CcShowPeer::DATABASE_NAME); $sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' "; $r = $con->query($sql); $offset_days = $r->fetchColumn(0); @@ -880,10 +879,250 @@ class Show { } } - Show::populateShowUntil($showId); - RabbitMq::PushSchedule(); + Application_Model_Show::populateShowUntil($showId); + Application_Model_RabbitMq::PushSchedule(); return $showId; } + + /** + * Generate repeating show instances for a single show up to the given date. + * If no date is given, use the one in the user's preferences, which is stored + * automatically by FullCalendar as the furthest date in the future the user + * has looked at. + * + * @param int $p_showId + * @param DateTime $p_dateTime + * DateTime object in UTC time. + */ + public static function populateShowUntil($p_showId, $p_dateTime = NULL) + { + global $CC_DBC; + if (is_null($p_endTimestamp)) { + $date = Application_Model_Preference::GetShowsPopulatedUntil(); + + if ($date == "") { + $p_dateTime = new DateTime("now", new DateTimeZone('UTC')); + Application_Model_Preference::SetShowsPopulatedUntil($p_dateTime->format("Y-m-d")); + } else { + $p_dateTime = new DateTime($date, new DateTimeZone('UTC')); + } + } + + $sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId"; + $res = $CC_DBC->GetAll($sql); + + foreach ($res as $showRow) { + Application_Model_Show::populateShow($showRow, $p_dateTime); + } + } + + /** + * We are going to use cc_show_days as a template, to generate Show Instances. This function + * is basically a dispatcher that looks at the show template, and sends it to the correct function + * so that Show Instance generation can begin. After the all show instances have been created, pushes + * the schedule to Pypo. + * + * @param array $p_showRow + * A row from cc_show_days table + * @param DateTime $p_dateTime + * DateTime object in UTC time. + */ + private static function populateShow($p_showRow, $p_dateTime) { + + if($p_showRow["repeat_type"] == -1) { + Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_dateTime); + } + else if($p_showRow["repeat_type"] == 0) { + Application_Model_Show::populateRepeatingShow($p_showRow, $p_dateTime, 'P7D'); + } + else if($p_showRow["repeat_type"] == 1) { + Application_Model_Show::populateRepeatingShow($p_showRow, $p_dateTime, 'P14D'); + } + else if($p_showRow["repeat_type"] == 2) { + Application_Model_Show::populateRepeatingShow($p_showRow, $p_dateTime, 'P1M'); + } + Application_Model_RabbitMq::PushSchedule(); + } + + /** + * Creates a single show instance. If the show is recorded, it may have multiple + * rebroadcast dates, and so this function will create those as well. + * + * @param array $p_showRow + * A row from cc_show_days table + * @param DateTime $p_dateTime + * DateTime object in UTC time. + */ + private static function populateNonRepeatingShow($p_showRow, $p_dateTime) + { + global $CC_DBC; + + $show_id = $p_showRow["show_id"]; + $first_show = $p_showRow["first_show"]; //non-UTC + $start_time = $p_showRow["start_time"]; //non-UTC + $duration = $p_showRow["duration"]; + $day = $p_showRow["day"]; + $record = $p_showRow["record"]; + $timezone = $p_showRow["timezone"]; + + $start = $first_show." ".$start_time; + $utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); + + if ($utcStartDateTime->getTimestamp() < $p_dateTime->getTimestamp()) { + + $utcStart = $utcStartDateTime->format("Y-m-d H:i:s"); + $sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'"; + $utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC")); + + $date = new Application_Model_DateHelper(); + $currentUtcTimestamp = $date->getUtcTimestamp(); + + $show = new Application_Model_Show($show_id); + if ($show->hasInstance()){ + $ccShowInstance = $show->getInstance(); + $newInstance = false; + } else { + $ccShowInstance = new CcShowInstances(); + $newInstance = true; + } + + if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ + $ccShowInstance->setDbShowId($show_id); + $ccShowInstance->setDbStarts($utcStartDateTime); + $ccShowInstance->setDbEnds($utcEndDateTime); + $ccShowInstance->setDbRecord($record); + $ccShowInstance->save(); + } + + $show_instance_id = $ccShowInstance->getDbId(); + $showInstance = new Application_Model_ShowInstance($show_instance_id); + + if (!$newInstance){ + $showInstance->correctScheduleStartTimes(); + } + + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; + Logging::log($sql); + $rebroadcasts = $CC_DBC->GetAll($sql); + + self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration); + } + } + + /** + * Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show + * is recorded, it may have multiple rebroadcast dates, and so this function will create + * those as well. + * + * @param array $p_showRow + * A row from cc_show_days table + * @param DateTime $p_dateTime + * DateTime object in UTC time. + * @param string $p_interval + * Period of time between repeating shows + */ + private static function populateRepeatingShow($p_showRow, $p_dateTime, $p_interval) + { + global $CC_DBC; + + $show_id = $p_showRow["show_id"]; + $next_pop_date = $p_showRow["next_pop_date"]; + $first_show = $p_showRow["first_show"]; //non-UTC + $last_show = $p_showRow["last_show"]; //non-UTC + $start_time = $p_showRow["start_time"]; //non-UTC + $duration = $p_showRow["duration"]; + $day = $p_showRow["day"]; + $record = $p_showRow["record"]; + $timezone = $p_showRow["timezone"]; + + + if(isset($next_pop_date)) { + $start = $next_pop_date." ".$start_time; + } else { + $start = $first_show." ".$start_time; + } + + $utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); + + $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; + $rebroadcasts = $CC_DBC->GetAll($sql); + $show = new Application_Model_Show($show_id); + + $date = new Application_Model_DateHelper(); + $currentUtcTimestamp = $date->getUtcTimestamp(); + + while($utcStartDateTime->getTimestamp() <= $p_dateTime->getTimestamp() && + ($utcStartDateTime->getTimestamp() < strtotime($last_show) || is_null($last_show))) { + + $utcStart = $utcStartDateTime->format("Y-m-d H:i:s"); + $sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'"; + $utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC")); + + if ($show->hasInstanceOnDate($utcStartDateTime)){ + $ccShowInstance = $show->getInstanceOnDate($utcStartDateTime); + $newInstance = false; + } else { + $ccShowInstance = new CcShowInstances(); + $newInstance = true; + } + + /* When editing the start/end time of a repeating show, we don't want to + * change shows that started in the past. So check the start time. + */ + if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ + $ccShowInstance->setDbShowId($show_id); + $ccShowInstance->setDbStarts($utcStartDateTime); + $ccShowInstance->setDbEnds($utcEndDateTime); + $ccShowInstance->setDbRecord($record); + $ccShowInstance->save(); + } + + $show_instance_id = $ccShowInstance->getDbId(); + $showInstance = new Application_Model_ShowInstance($show_instance_id); + + /* If we are updating a show then make sure that the scheduled content within + * the show is updated to the correct time. */ + if (!$newInstance){ + $showInstance->correctScheduleStartTimes(); + } + + self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration); + + $dt = new DateTime($start, new DateTimeZone($timezone)); + $dt->add(new DateInterval($p_interval)); + $start = $dt->format("Y-m-d H:i:s"); + + $dt->setTimezone(new DateTimeZone('UTC')); + $utcStartDateTime = $dt; + } + + Application_Model_Show::setNextPop($start, $show_id, $day); + } + + private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_utcStartDateTime, $p_duration){ + global $CC_DBC; + + foreach($p_rebroadcasts as $rebroadcast) { + $timeinfo = $p_utcStartDateTime->format("Y-m-d H:i:s"); + + $sql = "SELECT timestamp '{$timeinfo}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; + $rebroadcast_start_time = $CC_DBC->GetOne($sql); + + $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$p_duration}'"; + $rebroadcast_end_time = $CC_DBC->GetOne($sql); + + if ($rebroadcast_start_time > $p_currentUtcTimestamp){ + $newRebroadcastInstance = new CcShowInstances(); + $newRebroadcastInstance->setDbShowId($p_showId); + $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); + $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); + $newRebroadcastInstance->setDbRecord(0); + $newRebroadcastInstance->setDbRebroadcast(1); + $newRebroadcastInstance->setDbOriginalShow($p_showInstanceId); + $newRebroadcastInstance->save(); + } + } + } /** * Get all the show instances in the given time range. @@ -904,12 +1143,12 @@ class Show { //if application is requesting shows past our previous populated until date, generate shows up until this point. if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end_timestamp)) { - Show::populateAllShowsInRange($showsPopUntil, $end_timestamp); + Application_Model_Show::populateAllShowsInRange($showsPopUntil, $end_timestamp); Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp); } - $sql = "SELECT starts, ends, record, rebroadcast, soundcloud_id, instance_id, show_id, name, description, - color, background_color, cc_show_instances.id AS instance_id + $sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, description, + color, background_color, file_id, cc_show_instances.id AS instance_id FROM cc_show_instances LEFT JOIN cc_show ON cc_show.id = cc_show_instances.show_id"; @@ -953,209 +1192,6 @@ class Show { ->save(); } - //for a show with repeat_type == -1 - private static function populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp) - { - global $CC_DBC; - $next_date = $first_show." ".$start_time; - - if (strtotime($next_date) < strtotime($end_timestamp)) { - - $start = $next_date; - $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; - $end = $CC_DBC->GetOne($sql); - - $date = new DateHelper(); - $currentTimestamp = $date->getTimestamp(); - - $show = new Show($show_id); - if ($show->hasInstance()){ - $ccShowInstance = $show->getInstance(); - $newInstance = false; - } - else { - $ccShowInstance = new CcShowInstances(); - $newInstance = true; - } - - if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp){ - $ccShowInstance->setDbShowId($show_id); - $ccShowInstance->setDbStarts($start); - $ccShowInstance->setDbEnds($end); - $ccShowInstance->setDbRecord($record); - $ccShowInstance->save(); - } - - $show_instance_id = $ccShowInstance->getDbId(); - $showInstance = new ShowInstance($show_instance_id); - - if (!$newInstance){ - $showInstance->correctScheduleStartTimes(); - } - - $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; - $rebroadcasts = $CC_DBC->GetAll($sql); - - foreach($rebroadcasts as $rebroadcast) { - - $timeinfo = explode(" ", $start); - - $sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; - $rebroadcast_start_time = $CC_DBC->GetOne($sql); - - $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; - $rebroadcast_end_time = $CC_DBC->GetOne($sql); - - if ($rebroadcast_start_time > $currentTimestamp){ - $newRebroadcastInstance = new CcShowInstances(); - $newRebroadcastInstance->setDbShowId($show_id); - $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); - $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); - $newRebroadcastInstance->setDbRecord(0); - $newRebroadcastInstance->setDbRebroadcast(1); - $newRebroadcastInstance->setDbOriginalShow($show_instance_id); - $newRebroadcastInstance->save(); - } - } - } - RabbitMq::PushSchedule(); - } - - //for a show with repeat_type == 0,1,2 - private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, - $start_time, $duration, $day, $record, $end_timestamp, $interval) - { - global $CC_DBC; - - if(isset($next_pop_date)) { - $next_date = $next_pop_date." ".$start_time; - } - else { - $next_date = $first_show." ".$start_time; - } - - $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; - $rebroadcasts = $CC_DBC->GetAll($sql); - $show = new Show($show_id); - - $date = new DateHelper(); - $currentTimestamp = $date->getTimestamp(); - - while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) { - - $start = $next_date; - - $sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; - $end = $CC_DBC->GetOne($sql); - - if ($show->hasInstanceOnDate($start)){ - $ccShowInstance = $show->getInstanceOnDate($start); - $newInstance = false; - } else { - $ccShowInstance = new CcShowInstances(); - $newInstance = true; - } - - /* When editing the start/end time of a repeating show, we don't want to - * change shows that started in the past. So check the start time. - */ - if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp){ - $ccShowInstance->setDbShowId($show_id); - $ccShowInstance->setDbStarts($start); - $ccShowInstance->setDbEnds($end); - $ccShowInstance->setDbRecord($record); - $ccShowInstance->save(); - } - - $show_instance_id = $ccShowInstance->getDbId(); - $showInstance = new ShowInstance($show_instance_id); - - if (!$newInstance){ - $showInstance->correctScheduleStartTimes(); - } - - foreach($rebroadcasts as $rebroadcast) { - - $timeinfo = explode(" ", $next_date); - - $sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; - $rebroadcast_start_time = $CC_DBC->GetOne($sql); - - $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; - $rebroadcast_end_time = $CC_DBC->GetOne($sql); - - if ($rebroadcast_start_time > $currentTimestamp){ - $newRebroadcastInstance = new CcShowInstances(); - $newRebroadcastInstance->setDbShowId($show_id); - $newRebroadcastInstance->setDbStarts($rebroadcast_start_time); - $newRebroadcastInstance->setDbEnds($rebroadcast_end_time); - $newRebroadcastInstance->setDbRecord(0); - $newRebroadcastInstance->setDbRebroadcast(1); - $newRebroadcastInstance->setDbOriginalShow($show_instance_id); - $newRebroadcastInstance->save(); - } - } - - $sql = "SELECT timestamp '{$start}' + interval '{$interval}'"; - $next_date = $CC_DBC->GetOne($sql); - } - - Show::setNextPop($next_date, $show_id, $day); - RabbitMq::PushSchedule(); - } - - private static function populateShow($repeatType, $show_id, $next_pop_date, - $first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp) { - - if($repeatType == -1) { - Show::populateNonRepeatingShow($show_id, $first_show, $start_time, $duration, $day, $record, $end_timestamp); - } - else if($repeatType == 0) { - Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, - $start_time, $duration, $day, $record, $end_timestamp, '7 days'); - } - else if($repeatType == 1) { - Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, - $start_time, $duration, $day, $record, $end_timestamp, '14 days'); - } - else if($repeatType == 2) { - Show::populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, - $start_time, $duration, $day, $record, $end_timestamp, '1 month'); - } - } - - - /** - * Generate repeating show instances for a single show up to the given date. - * If no date is given, use the one in the user's preferences, which is stored - * automatically by FullCalendar as the furthest date in the future the user - * has looked at. - * - * @param int $p_showId - * @param string $p_date - * In the format "YYYY-MM-DD HH:mm:ss" - */ - public static function populateShowUntil($p_showId, $p_date = NULL) - { - global $CC_DBC; - if (is_null($p_date)) { - $p_date = Application_Model_Preference::GetShowsPopulatedUntil(); - - if ($p_date == "") { - $today_timestamp = date("Y-m-d"); - Application_Model_Preference::SetShowsPopulatedUntil($today_timestamp); - } - } - - $sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId"; - $res = $CC_DBC->GetAll($sql); - - foreach ($res as $row) { - Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"], - $row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_date); - } - } - /** * Generate all the repeating shows in the given range. * @@ -1183,8 +1219,7 @@ class Show { $res = $CC_DBC->GetAll($sql); foreach ($res as $row) { - Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"], - $row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_endTimestamp); + Application_Model_Show::populateShow($row, $p_endTimestamp); } } @@ -1205,24 +1240,24 @@ class Show { $interval = $start_range->diff($end_range); $days = $interval->format('%a'); - $shows = Show::getShows($start, $end); - + $shows = Application_Model_Show::getShows($start, $end); + $today_timestamp = date("Y-m-d H:i:s"); foreach ($shows as $show) { $options = array(); //only bother calculating percent for week or day view. if(intval($days) <= 7) { - $show_instance = new ShowInstance($show["instance_id"]); + $show_instance = new Application_Model_ShowInstance($show["instance_id"]); $options["percent"] = $show_instance->getPercentScheduled(); } if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) { $options["editable"] = true; - $events[] = Show::makeFullCalendarEvent($show, $options); + $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); } else { - $events[] = Show::makeFullCalendarEvent($show, $options); + $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options); } } @@ -1236,17 +1271,31 @@ class Show { if($show["rebroadcast"]) { $event["disableResizing"] = true; } + + $startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC")); + $startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); + + $endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC")); + $endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $event["id"] = $show["instance_id"]; $event["title"] = $show["name"]; - $event["start"] = $show["starts"]; - $event["end"] = $show["ends"]; + $event["start"] = $startDateTime->format("Y-m-d H:i:s"); + $event["end"] = $endDateTime->format("Y-m-d H:i:s"); $event["allDay"] = false; $event["description"] = $show["description"]; $event["showId"] = $show["show_id"]; $event["record"] = intval($show["record"]); $event["rebroadcast"] = intval($show["rebroadcast"]); - $event["soundcloud_id"] = (is_null($show["soundcloud_id"]) ? -1 : $show["soundcloud_id"]); + + // get soundcloud_id + if(!is_null($show["file_id"])){ + $file = Application_Model_StoredFile::Recall($show["file_id"]); + $soundcloud_id = $file->getSoundCloudId(); + }else{ + $soundcloud_id = null; + } + $event["soundcloud_id"] = (is_null($soundcloud_id) ? -1 : $soundcloud_id); //event colouring if($show["color"] != "") { @@ -1262,628 +1311,24 @@ class Show { return $event; } -} - -class ShowInstance { - - private $_instanceId; - private $_showInstance; - - public function __construct($instanceId) - { - $this->_instanceId = $instanceId; - $this->_showInstance = CcShowInstancesQuery::create()->findPK($instanceId); - - if (is_null($this->_showInstance)){ - throw new Exception(); - } - } - - public function getShowId() - { - return $this->_showInstance->getDbShowId(); - } - - public function getShowInstanceId() - { - return $this->_instanceId; - } - - public function isRebroadcast() - { - return $this->_showInstance->getDbOriginalShow(); - } - - public function isRecorded() - { - return $this->_showInstance->getDbRecord(); - } - - public function getName() - { - $show = CcShowQuery::create()->findPK($this->getShowId()); - return $show->getDbName(); - } - - public function getGenre() - { - $show = CcShowQuery::create()->findPK($this->getShowId()); - return $show->getDbGenre(); - } - - public function getShowStart() - { - return $this->_showInstance->getDbStarts(); - } - - public function getShowEnd() - { - return $this->_showInstance->getDbEnds(); - } - - public function getStartDate() - { - $showStart = $this->getShowStart(); - $showStartExplode = explode(" ", $showStart); - return $showStartExplode[0]; - } - - public function getStartTime() - { - $showStart = $this->getShowStart(); - $showStartExplode = explode(" ", $showStart); - - return $showStartExplode[1]; - } - - public function setSoundCloudFileId($p_soundcloud_id) - { - $this->_showInstance->setDbSoundCloudId($p_soundcloud_id) - ->save(); - } - - public function getSoundCloudFileId() - { - return $this->_showInstance->getDbSoundCloudId(); - } - - public function getRecordedFile() - { - $file_id = $this->_showInstance->getDbRecordedFile(); - - if(isset($file_id)) { - $file = StoredFile::Recall($file_id); - - if (PEAR::isError($file)) { - return null; - } - - if(file_exists($file->getFilePath())) { - return $file; - } - } - - return null; - } - - public function setShowStart($start) - { - $this->_showInstance->setDbStarts($start) - ->save(); - RabbitMq::PushSchedule(); - } - - public function setShowEnd($end) - { - $this->_showInstance->setDbEnds($end) - ->save(); - RabbitMq::PushSchedule(); - } - - public function updateScheduledTime() - { - $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); - $this->_showInstance->updateDbTimeFilled($con); - } - - public function correctScheduleStartTimes(){ - global $CC_DBC; - - $instance_id = $this->getShowInstanceId(); - $sql = "SELECT starts from cc_schedule" - ." WHERE instance_id = $instance_id" - ." ORDER BY starts" - ." LIMIT 1"; - - $scheduleStarts = $CC_DBC->GetOne($sql); - - if (!is_null($scheduleStarts)){ - $scheduleStartsEpoch = strtotime($scheduleStarts); - $showStartsEpoch = strtotime($this->getShowStart()); - - $diff = $showStartsEpoch - $scheduleStartsEpoch; - - if ($diff != 0){ - $sql = "UPDATE cc_schedule" - ." SET starts = starts + INTERVAL '$diff' second," - ." ends = ends + INTERVAL '$diff' second" - ." WHERE instance_id = $instance_id"; - - $CC_DBC->query($sql); - } - } - RabbitMq::PushSchedule(); - } - - public function moveShow($deltaDay, $deltaMin) - { - global $CC_DBC; - - $hours = $deltaMin/60; - if($hours > 0) - $hours = floor($hours); - else - $hours = ceil($hours); - - $mins = abs($deltaMin%60); - - $today_timestamp = date("Y-m-d H:i:s"); - $starts = $this->getShowStart(); - $ends = $this->getShowEnd(); - - if(strtotime($today_timestamp) > strtotime($starts)) { - return "can't move a past show"; - } - - $sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; - $new_starts = $CC_DBC->GetOne($sql); - - $sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; - $new_ends = $CC_DBC->GetOne($sql); - - if(strtotime($today_timestamp) > strtotime($new_starts)) { - return "can't move show into past"; - } - - $overlap = Show::getShows($new_starts, $new_ends, array($this->_instanceId)); - - if(count($overlap) > 0) { - return "Should not overlap shows"; - } - - $rebroadcast = $this->isRebroadcast(); - if($rebroadcast) { - $sql = "SELECT timestamp '{$new_starts}' < (SELECT starts FROM cc_show_instances WHERE id = {$rebroadcast})"; - $isBeforeRecordedOriginal = $CC_DBC->GetOne($sql); - - if($isBeforeRecordedOriginal === 't'){ - return "Cannot move a rebroadcast show before its original"; - } - } - - $this->setShowStart($new_starts); - $this->setShowEnd($new_ends); - $this->correctScheduleStartTimes(); - RabbitMq::PushSchedule(); - } - - public function resizeShow($deltaDay, $deltaMin) - { - global $CC_DBC; - - $hours = $deltaMin/60; - if($hours > 0) - $hours = floor($hours); - else - $hours = ceil($hours); - - $mins = abs($deltaMin%60); - - $today_timestamp = date("Y-m-d H:i:s"); - $starts = $this->getShowStart(); - $ends = $this->getShowEnd(); - - if(strtotime($today_timestamp) > strtotime($starts)) { - return "can't resize a past show"; - } - - $sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; - $new_ends = $CC_DBC->GetOne($sql); - - //only need to check overlap if show increased in size. - if(strtotime($new_ends) > strtotime($ends)) { - $overlap = Show::getShows($ends, $new_ends); - - if(count($overlap) > 0) { - return "Should not overlap shows"; - } - } - //with overbooking no longer need to check already scheduled content still fits. - - //must update length of all rebroadcast instances. - if($this->isRecorded()) { - $sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') - WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}"; - $CC_DBC->query($sql); - } - - $this->setShowEnd($new_ends); - RabbitMq::PushSchedule(); - } - - /** - * Get the group ID for this show. - * - */ - private function getLastGroupId() - { - global $CC_DBC; - $sql = "SELECT group_id FROM cc_schedule WHERE instance_id = '{$this->_instanceId}' ORDER BY ends DESC LIMIT 1"; - $res = $CC_DBC->GetOne($sql); - return $res; - } - - /** - * Add a playlist as the last item of the current show. - * - * @param int $plId - * Playlist ID. - */ - public function addPlaylistToShow($plId) - { - $sched = new ScheduleGroup(); - $lastGroupId = $this->getLastGroupId(); - - if (is_null($lastGroupId)) { - $groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId); - } - else { - $groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId); - } - RabbitMq::PushSchedule(); - $this->updateScheduledTime(); - } - - /** - * Add a media file as the last item in the show. - * - * @param int $file_id - */ - public function addFileToShow($file_id) - { - $sched = new ScheduleGroup(); - $lastGroupId = $this->getLastGroupId(); - - if (is_null($lastGroupId)) { - $groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id); - } - else { - $groupId = $sched->addFileAfter($this->_instanceId, $lastGroupId, $file_id); - } - RabbitMq::PushSchedule(); - $this->updateScheduledTime(); - } - - /** - * Add the given playlists to the show. - * - * @param array $plIds - * An array of playlist IDs. - */ - public function scheduleShow($plIds) - { - foreach ($plIds as $plId) { - $this->addPlaylistToShow($plId); - } - } - - public function removeGroupFromShow($group_id) - { - global $CC_DBC; - - $sql = "SELECT MAX(ends) as end_timestamp, (MAX(ends) - MIN(starts)) as length - FROM cc_schedule - WHERE group_id = '{$group_id}'"; - - $groupBoundry = $CC_DBC->GetRow($sql); - - $group = CcScheduleQuery::create() - ->filterByDbGroupId($group_id) - ->delete(); - - $sql = "UPDATE cc_schedule - SET starts = (starts - INTERVAL '{$groupBoundry["length"]}'), ends = (ends - INTERVAL '{$groupBoundry["length"]}') - WHERE starts >= '{$groupBoundry["end_timestamp"]}' AND instance_id = {$this->_instanceId}"; - - $CC_DBC->query($sql); - RabbitMq::PushSchedule(); - $this->updateScheduledTime(); - } - - public function clearShow() - { - CcScheduleQuery::create() - ->filterByDbInstanceId($this->_instanceId) - ->delete(); - RabbitMq::PushSchedule(); - $this->updateScheduledTime(); - } - - public function deleteShow() - { - // see if it was recording show - $recording = CcShowInstancesQuery::create() - ->findPK($this->_instanceId) - ->getDbRecord(); - CcShowInstancesQuery::create() - ->findPK($this->_instanceId) - ->delete(); - RabbitMq::PushSchedule(); - if($recording){ - RabbitMq::SendMessageToShowRecorder("cancel_recording"); - } - } - - public function setRecordedFile($file_id) - { - $showInstance = CcShowInstancesQuery::create() - ->findPK($this->_instanceId); - $showInstance->setDbRecordedFile($file_id) - ->save(); - - $rebroadcasts = CcShowInstancesQuery::create() - ->filterByDbOriginalShow($this->_instanceId) - ->find(); - - foreach ($rebroadcasts as $rebroadcast) { - - $rebroad = new ShowInstance($rebroadcast->getDbId()); - $rebroad->addFileToShow($file_id); - } - } - - public function getTimeScheduled() - { - $time = $this->_showInstance->getDbTimeFilled(); - - if(is_null($time)) { - $time = "00:00:00"; - } - return $time; - } - - public function getPercentScheduled() - { - $start_timestamp = $this->getShowStart(); - $end_timestamp = $this->getShowEnd(); - $time_filled = $this->getTimeScheduled(); - - $s_epoch = strtotime($start_timestamp); - $e_epoch = strtotime($end_timestamp); - $i_epoch = Schedule::WallTimeToMillisecs($time_filled) / 1000; - - $percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100); - - if ($percent > 100) - $percent = 100; - - return $percent; - } - - public function getShowLength() - { - global $CC_DBC; - - $start_timestamp = $this->getShowStart(); - $end_timestamp = $this->getShowEnd(); - - $sql = "SELECT TIMESTAMP '{$end_timestamp}' - TIMESTAMP '{$start_timestamp}' "; - $length = $CC_DBC->GetOne($sql); - - return $length; - } - - public function searchPlaylistsForShow($datatables) - { - return StoredFile::searchPlaylistsForSchedule($datatables); - } - - public function getShowListContent() - { - global $CC_DBC; - - $sql = "SELECT * - FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id - LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id ) - - WHERE s.instance_id = '{$this->_instanceId}' ORDER BY starts"; - - return $CC_DBC->GetAll($sql); - } - - public function getShowContent() - { - global $CC_DBC; - - $res = $this->getShowListContent(); - - if(count($res) <= 0) { - return $res; - } - - $items = array(); - $currGroupId = -1; - $pl_counter = -1; - $f_counter = -1; - foreach ($res as $row) { - if($currGroupId != $row["group_id"]){ - $currGroupId = $row["group_id"]; - $pl_counter = $pl_counter + 1; - $f_counter = -1; - - $items[$pl_counter]["pl_name"] = $row["name"]; - $items[$pl_counter]["pl_creator"] = $row["creator"]; - $items[$pl_counter]["pl_description"] = $row["description"]; - $items[$pl_counter]["pl_group"] = $row["group_id"]; - - $sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'"; - $length = $CC_DBC->GetOne($sql); - - $items[$pl_counter]["pl_length"] = $length; - } - $f_counter = $f_counter + 1; - - $items[$pl_counter]["pl_content"][$f_counter]["f_name"] = $row["track_title"]; - $items[$pl_counter]["pl_content"][$f_counter]["f_artist"] = $row["artist_name"]; - $items[$pl_counter]["pl_content"][$f_counter]["f_length"] = $row["length"]; - } - - return $items; - } - - public static function GetShowsInstancesIdsInRange($p_timeNow, $p_start, $p_end) - { - global $CC_DBC; - - $sql = "SELECT id FROM cc_show_instances AS si " - ."WHERE (" - ."(si.starts < TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' " - ."AND si.ends > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds') " - ."OR (si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' " - ."AND si.ends < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') " - ."OR (si.starts < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds' " - ."AND si.ends > TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') " - .") " - ." ORDER BY si.starts"; - - $rows = $CC_DBC->GetAll($sql); - return $rows; - } - - public function getScheduleItemsInRange($timeNow, $start, $end) - { - global $CC_DBC, $CC_CONFIG; - - $instanceId = $this->_instanceId; - - $sql = "SELECT" - ." si.starts as show_starts," - ." si.ends as show_ends," - ." si.rebroadcast as rebroadcast," - ." st.starts as item_starts," - ." st.ends as item_ends," - ." st.clip_length as clip_length," - ." ft.track_title as track_title," - ." ft.artist_name as artist_name," - ." ft.album_title as album_title," - ." s.name as show_name," - ." si.id as instance_id," - ." pt.name as playlist_name" - ." FROM $CC_CONFIG[showInstances] si" - ." LEFT JOIN $CC_CONFIG[scheduleTable] st" - ." ON st.instance_id = si.id" - ." LEFT JOIN $CC_CONFIG[playListTable] pt" - ." ON st.playlist_id = pt.id" - ." LEFT JOIN $CC_CONFIG[filesTable] ft" - ." ON st.file_id = ft.id" - ." LEFT JOIN $CC_CONFIG[showTable] s" - ." ON si.show_id = s.id" - ." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')" - ." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')" - ." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))" - ." AND (st.starts < si.ends)" - ." AND si.id = $instanceId" - ." ORDER BY si.starts, st.starts"; - - return $CC_DBC->GetAll($sql); - } - - public function getLastAudioItemEnd(){ - global $CC_DBC; - - $sql = "SELECT ends FROM cc_schedule " - ."WHERE instance_id = {$this->_instanceId} " - ."ORDER BY ends DESC " - ."LIMIT 1"; - - return $CC_DBC->GetOne($sql); - } - - public function getShowEndGapTime(){ - $showEnd = $this->getShowEnd(); - $lastItemEnd = $this->getLastAudioItemEnd(); - - if (is_null($lastItemEnd)){ - $lastItemEnd = $this->getShowStart(); - } - - - $diff = strtotime($showEnd) - strtotime($lastItemEnd); - - return ($diff < 0) ? 0 : $diff; - } - - public static function GetLastShowInstance($p_timeNow){ - global $CC_CONFIG, $CC_DBC; - - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.ends < TIMESTAMP '$p_timeNow'" - ." ORDER BY si.ends DESC" - ." LIMIT 1"; - - $id = $CC_DBC->GetOne($sql); - if (is_null($id)){ - return null; - } else { - return new ShowInstance($id); - } - } - - public static function GetCurrentShowInstance($p_timeNow){ - global $CC_CONFIG, $CC_DBC; - - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.starts <= TIMESTAMP '$p_timeNow'" - ." AND si.ends > TIMESTAMP '$p_timeNow'" - ." LIMIT 1"; - - $id = $CC_DBC->GetOne($sql); - if (is_null($id)){ - return null; - } else { - return new ShowInstance($id); - } - } - - public static function GetNextShowInstance($p_timeNow){ - global $CC_CONFIG, $CC_DBC; - - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.starts > TIMESTAMP '$p_timeNow'" - ." ORDER BY si.starts" - ." LIMIT 1"; - - $id = $CC_DBC->GetOne($sql); - if (is_null($id)){ - return null; - } else { - return new ShowInstance($id); - } + + public function setShowFirstShow($s_date){ + $showDay = CcShowDaysQuery::create() + ->filterByDbShowId($this->_showId) + ->findOne(); + + $showDay->setDbFirstShow($s_date) + ->save(); } - // returns number of show instances that ends later than $day - public static function GetShowInstanceCount($day){ - global $CC_CONFIG, $CC_DBC; - $sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'"; - return $CC_DBC->GetOne($sql); + public function setShowLastShow($e_date){ + $showDay = CcShowDaysQuery::create() + ->filterByDbShowId($this->_showId) + ->findOne(); + + $showDay->setDbLastShow($e_date) + ->save(); } -} - -/* Show Data Access Layer */ -class Show_DAL { public static function GetCurrentShow($timeNow) { @@ -1896,6 +1341,7 @@ class Show_DAL { ." AND si.ends > TIMESTAMP '$timeNow'"; $rows = $CC_DBC->GetAll($sql); + return $rows; } @@ -1937,4 +1383,19 @@ class Show_DAL { return $CC_DBC->GetAll($sql); } + + public static function GetMaxLengths() { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT column_name, character_maximum_length FROM information_schema.columns" + ." WHERE table_name = 'cc_show' AND character_maximum_length > 0"; + $result = $CC_DBC->GetAll($sql); + + // store result into assoc array + $assocArray = array(); + foreach($result as $row) { + $assocArray[$row['column_name']] = $row['character_maximum_length']; + } + + return $assocArray; + } } diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php new file mode 100644 index 000000000..7fed88a1a --- /dev/null +++ b/airtime_mvc/application/models/ShowInstance.php @@ -0,0 +1,638 @@ +_instanceId = $instanceId; + $this->_showInstance = CcShowInstancesQuery::create()->findPK($instanceId); + + if (is_null($this->_showInstance)){ + throw new Exception(); + } + } + + public function getShowId() + { + return $this->_showInstance->getDbShowId(); + } + + public function getShowInstanceId() + { + return $this->_instanceId; + } + + public function getShow(){ + return new Application_Model_Show($this->getShowId()); + } + + public function isRebroadcast() + { + return $this->_showInstance->getDbOriginalShow(); + } + + public function isRecorded() + { + return $this->_showInstance->getDbRecord(); + } + + public function getName() + { + $show = CcShowQuery::create()->findPK($this->getShowId()); + return $show->getDbName(); + } + + public function getGenre() + { + $show = CcShowQuery::create()->findPK($this->getShowId()); + return $show->getDbGenre(); + } + + public function getShowStart() + { + return $this->_showInstance->getDbStarts(); + } + + public function getShowEnd() + { + return $this->_showInstance->getDbEnds(); + } + + public function getStartDate() + { + $showStart = $this->getShowStart(); + $showStartExplode = explode(" ", $showStart); + return $showStartExplode[0]; + } + + public function getStartTime() + { + $showStart = $this->getShowStart(); + $showStartExplode = explode(" ", $showStart); + + return $showStartExplode[1]; + } + + public function setSoundCloudFileId($p_soundcloud_id) + { + $file = Application_Model_StoredFile::Recall($this->_showInstance->getDbRecordedFile()); + $file->setSoundCloudFileId($p_soundcloud_id); + } + + public function getSoundCloudFileId() + { + $file = Application_Model_StoredFile::Recall($this->_showInstance->getDbRecordedFile()); + return $file->getSoundCloudId(); + } + + public function getRecordedFile() + { + $file_id = $this->_showInstance->getDbRecordedFile(); + + if(isset($file_id)) { + $file = Application_Model_StoredFile::Recall($file_id); + + if (PEAR::isError($file)) { + return null; + } + + if(file_exists($file->getFilePath())) { + return $file; + } + } + + return null; + } + + public function setShowStart($start) + { + $this->_showInstance->setDbStarts($start) + ->save(); + Application_Model_RabbitMq::PushSchedule(); + } + + public function setShowEnd($end) + { + $this->_showInstance->setDbEnds($end) + ->save(); + Application_Model_RabbitMq::PushSchedule(); + } + + public function updateScheduledTime() + { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); + $this->_showInstance->updateDbTimeFilled($con); + } + + public function correctScheduleStartTimes(){ + global $CC_DBC; + + $instance_id = $this->getShowInstanceId(); + $sql = "SELECT starts from cc_schedule" + ." WHERE instance_id = $instance_id" + ." ORDER BY starts" + ." LIMIT 1"; + + $scheduleStarts = $CC_DBC->GetOne($sql); + + if (!is_null($scheduleStarts)){ + $scheduleStartsEpoch = strtotime($scheduleStarts); + $showStartsEpoch = strtotime($this->getShowStart()); + + $diff = $showStartsEpoch - $scheduleStartsEpoch; + + if ($diff != 0){ + $sql = "UPDATE cc_schedule" + ." SET starts = starts + INTERVAL '$diff' second," + ." ends = ends + INTERVAL '$diff' second" + ." WHERE instance_id = $instance_id"; + + $CC_DBC->query($sql); + } + } + Application_Model_RabbitMq::PushSchedule(); + } + + public function moveShow($deltaDay, $deltaMin) + { + global $CC_DBC; + + if ($this->getShow()->isRepeating()){ + return "Can't drag and drop repeating shows"; + } + + $hours = $deltaMin/60; + if($hours > 0) + $hours = floor($hours); + else + $hours = ceil($hours); + + $mins = abs($deltaMin%60); + + $today_timestamp = time(); + $starts = $this->getShowStart(); + $ends = $this->getShowEnd(); + + $startsDateTime = new DateTime($starts, new DateTimeZone("UTC")); + + if($today_timestamp > $startsDateTime->getTimestamp()) { + return "Can't move a past show"; + } + + $sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; + $new_starts = $CC_DBC->GetOne($sql); + + $sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; + $new_ends = $CC_DBC->GetOne($sql); + + $newStartsDateTime = new DateTime($new_starts, new DateTimeZone("UTC")); + if($today_timestamp > $newStartsDateTime->getTimestamp()) { + return "Can't move show into past"; + } + + $overlap = Application_Model_Show::getShows($new_starts, $new_ends, array($this->_instanceId)); + + if(count($overlap) > 0) { + return "Should not overlap shows"; + } + + $rebroadcast = $this->isRebroadcast(); + if($rebroadcast) { + $sql = "SELECT timestamp '{$new_starts}' < (SELECT starts FROM cc_show_instances WHERE id = {$rebroadcast})"; + $isBeforeRecordedOriginal = $CC_DBC->GetOne($sql); + + if($isBeforeRecordedOriginal === 't'){ + return "Cannot move a rebroadcast show before its original"; + } + } + + $this->setShowStart($new_starts); + $this->setShowEnd($new_ends); + $this->correctScheduleStartTimes(); + + $show = new Application_Model_Show($this->getShowId()); + if(!$show->isRepeating()){ + $show->setShowFirstShow($new_starts); + $show->setShowLastShow($new_ends); + } + + Application_Model_RabbitMq::PushSchedule(); + } + + public function resizeShow($deltaDay, $deltaMin) + { + global $CC_DBC; + + $hours = $deltaMin/60; + if($hours > 0) + $hours = floor($hours); + else + $hours = ceil($hours); + + $mins = abs($deltaMin%60); + + $today_timestamp = date("Y-m-d H:i:s"); + $starts = $this->getShowStart(); + $ends = $this->getShowEnd(); + + if(strtotime($today_timestamp) > strtotime($starts)) { + return "can't resize a past show"; + } + + $sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; + $new_ends = $CC_DBC->GetOne($sql); + + //only need to check overlap if show increased in size. + if(strtotime($new_ends) > strtotime($ends)) { + $overlap = Application_Model_Show::getShows($ends, $new_ends); + + if(count($overlap) > 0) { + return "Should not overlap shows"; + } + } + //with overbooking no longer need to check already scheduled content still fits. + + //must update length of all rebroadcast instances. + if($this->isRecorded()) { + $sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') + WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}"; + $CC_DBC->query($sql); + } + + $this->setShowEnd($new_ends); + Application_Model_RabbitMq::PushSchedule(); + } + + /** + * Get the group ID for this show. + * + */ + private function getLastGroupId() + { + global $CC_DBC; + $sql = "SELECT group_id FROM cc_schedule WHERE instance_id = '{$this->_instanceId}' ORDER BY ends DESC LIMIT 1"; + $res = $CC_DBC->GetOne($sql); + return $res; + } + + /** + * Add a playlist as the last item of the current show. + * + * @param int $plId + * Playlist ID. + */ + public function addPlaylistToShow($plId) + { + $sched = new Application_Model_ScheduleGroup(); + $lastGroupId = $this->getLastGroupId(); + + if (is_null($lastGroupId)) { + $groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId); + } + else { + $groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId); + } + Application_Model_RabbitMq::PushSchedule(); + $this->updateScheduledTime(); + } + + /** + * Add a media file as the last item in the show. + * + * @param int $file_id + */ + public function addFileToShow($file_id) + { + $sched = new Application_Model_ScheduleGroup(); + $lastGroupId = $this->getLastGroupId(); + + if (is_null($lastGroupId)) { + $groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id); + } + else { + $groupId = $sched->addFileAfter($this->_instanceId, $lastGroupId, $file_id); + } + Application_Model_RabbitMq::PushSchedule(); + $this->updateScheduledTime(); + } + + /** + * Add the given playlists to the show. + * + * @param array $plIds + * An array of playlist IDs. + */ + public function scheduleShow($plIds) + { + foreach ($plIds as $plId) { + $this->addPlaylistToShow($plId); + } + } + + public function removeGroupFromShow($group_id) + { + global $CC_DBC; + + $sql = "SELECT MAX(ends) as end_timestamp, (MAX(ends) - MIN(starts)) as length + FROM cc_schedule + WHERE group_id = '{$group_id}'"; + + $groupBoundry = $CC_DBC->GetRow($sql); + + $group = CcScheduleQuery::create() + ->filterByDbGroupId($group_id) + ->delete(); + + $sql = "UPDATE cc_schedule + SET starts = (starts - INTERVAL '{$groupBoundry["length"]}'), ends = (ends - INTERVAL '{$groupBoundry["length"]}') + WHERE starts >= '{$groupBoundry["end_timestamp"]}' AND instance_id = {$this->_instanceId}"; + + $CC_DBC->query($sql); + Application_Model_RabbitMq::PushSchedule(); + $this->updateScheduledTime(); + } + + public function clearShow() + { + CcScheduleQuery::create() + ->filterByDbInstanceId($this->_instanceId) + ->delete(); + Application_Model_RabbitMq::PushSchedule(); + $this->updateScheduledTime(); + } + + public function deleteShow() + { + // see if it was recording show + $recording = CcShowInstancesQuery::create() + ->findPK($this->_instanceId) + ->getDbRecord(); + CcShowInstancesQuery::create() + ->findPK($this->_instanceId) + ->delete(); + Application_Model_RabbitMq::PushSchedule(); + if($recording){ + Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording"); + } + } + + public function setRecordedFile($file_id) + { + $showInstance = CcShowInstancesQuery::create() + ->findPK($this->_instanceId); + $showInstance->setDbRecordedFile($file_id) + ->save(); + + $rebroadcasts = CcShowInstancesQuery::create() + ->filterByDbOriginalShow($this->_instanceId) + ->find(); + + foreach ($rebroadcasts as $rebroadcast) { + + $rebroad = new Application_Model_ShowInstance($rebroadcast->getDbId()); + $rebroad->addFileToShow($file_id); + } + } + + public function getTimeScheduled() + { + $time = $this->_showInstance->getDbTimeFilled(); + + if(is_null($time)) { + $time = "00:00:00"; + } + return $time; + } + + public function getPercentScheduled() + { + $start_timestamp = $this->getShowStart(); + $end_timestamp = $this->getShowEnd(); + $time_filled = $this->getTimeScheduled(); + + $s_epoch = strtotime($start_timestamp); + $e_epoch = strtotime($end_timestamp); + $i_epoch = Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000; + + $percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100); + + if ($percent > 100) + $percent = 100; + + return $percent; + } + + public function getShowLength() + { + global $CC_DBC; + + $start_timestamp = $this->getShowStart(); + $end_timestamp = $this->getShowEnd(); + + $sql = "SELECT TIMESTAMP '{$end_timestamp}' - TIMESTAMP '{$start_timestamp}' "; + $length = $CC_DBC->GetOne($sql); + + return $length; + } + + public function searchPlaylistsForShow($datatables) + { + return Application_Model_StoredFile::searchPlaylistsForSchedule($datatables); + } + + public function getShowListContent() + { + global $CC_DBC; + + $sql = "SELECT * + FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id + LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id ) + + WHERE s.instance_id = '{$this->_instanceId}' ORDER BY starts"; + + return $CC_DBC->GetAll($sql); + } + + public function getShowContent() + { + global $CC_DBC; + + $res = $this->getShowListContent(); + + if(count($res) <= 0) { + return $res; + } + + $items = array(); + $currGroupId = -1; + $pl_counter = -1; + $f_counter = -1; + foreach ($res as $row) { + if($currGroupId != $row["group_id"]){ + $currGroupId = $row["group_id"]; + $pl_counter = $pl_counter + 1; + $f_counter = -1; + + $items[$pl_counter]["pl_name"] = $row["name"]; + $items[$pl_counter]["pl_creator"] = $row["creator"]; + $items[$pl_counter]["pl_description"] = $row["description"]; + $items[$pl_counter]["pl_group"] = $row["group_id"]; + + $sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'"; + $length = $CC_DBC->GetOne($sql); + + $items[$pl_counter]["pl_length"] = $length; + } + $f_counter = $f_counter + 1; + + $items[$pl_counter]["pl_content"][$f_counter]["f_name"] = $row["track_title"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_artist"] = $row["artist_name"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_length"] = $row["length"]; + } + + return $items; + } + + public static function GetShowsInstancesIdsInRange($p_timeNow, $p_start, $p_end) + { + global $CC_DBC; + + $sql = "SELECT id FROM cc_show_instances AS si " + ."WHERE (" + ."(si.starts < TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' " + ."AND si.ends > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds') " + ."OR (si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' " + ."AND si.ends < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') " + ."OR (si.starts < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds' " + ."AND si.ends > TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') " + .") " + ." ORDER BY si.starts"; + + $rows = $CC_DBC->GetAll($sql); + return $rows; + } + + public function getScheduleItemsInRange($timeNow, $start, $end) + { + global $CC_DBC, $CC_CONFIG; + + $instanceId = $this->_instanceId; + + $sql = "SELECT" + ." si.starts as show_starts," + ." si.ends as show_ends," + ." si.rebroadcast as rebroadcast," + ." st.starts as item_starts," + ." st.ends as item_ends," + ." st.clip_length as clip_length," + ." ft.track_title as track_title," + ." ft.artist_name as artist_name," + ." ft.album_title as album_title," + ." s.name as show_name," + ." si.id as instance_id," + ." pt.name as playlist_name" + ." FROM $CC_CONFIG[showInstances] si" + ." LEFT JOIN $CC_CONFIG[scheduleTable] st" + ." ON st.instance_id = si.id" + ." LEFT JOIN $CC_CONFIG[playListTable] pt" + ." ON st.playlist_id = pt.id" + ." LEFT JOIN $CC_CONFIG[filesTable] ft" + ." ON st.file_id = ft.id" + ." LEFT JOIN $CC_CONFIG[showTable] s" + ." ON si.show_id = s.id" + ." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')" + ." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')" + ." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))" + ." AND (st.starts < si.ends)" + ." AND si.id = $instanceId" + ." ORDER BY si.starts, st.starts"; + + return $CC_DBC->GetAll($sql); + } + + public function getLastAudioItemEnd(){ + global $CC_DBC; + + $sql = "SELECT ends FROM cc_schedule " + ."WHERE instance_id = {$this->_instanceId} " + ."ORDER BY ends DESC " + ."LIMIT 1"; + + return $CC_DBC->GetOne($sql); + } + + public function getShowEndGapTime(){ + $showEnd = $this->getShowEnd(); + $lastItemEnd = $this->getLastAudioItemEnd(); + + if (is_null($lastItemEnd)){ + $lastItemEnd = $this->getShowStart(); + } + + + $diff = strtotime($showEnd) - strtotime($lastItemEnd); + + return ($diff < 0) ? 0 : $diff; + } + + public static function GetLastShowInstance($p_timeNow){ + global $CC_CONFIG, $CC_DBC; + + $sql = "SELECT si.id" + ." FROM $CC_CONFIG[showInstances] si" + ." WHERE si.ends < TIMESTAMP '$p_timeNow'" + ." ORDER BY si.ends DESC" + ." LIMIT 1"; + + $id = $CC_DBC->GetOne($sql); + if (is_null($id)){ + return null; + } else { + return new Application_Model_ShowInstance($id); + } + } + + public static function GetCurrentShowInstance($p_timeNow){ + global $CC_CONFIG, $CC_DBC; + + $sql = "SELECT si.id" + ." FROM $CC_CONFIG[showInstances] si" + ." WHERE si.starts <= TIMESTAMP '$p_timeNow'" + ." AND si.ends > TIMESTAMP '$p_timeNow'" + ." LIMIT 1"; + + $id = $CC_DBC->GetOne($sql); + if (is_null($id)){ + return null; + } else { + return new Application_Model_ShowInstance($id); + } + } + + public static function GetNextShowInstance($p_timeNow){ + global $CC_CONFIG, $CC_DBC; + + $sql = "SELECT si.id" + ." FROM $CC_CONFIG[showInstances] si" + ." WHERE si.starts > TIMESTAMP '$p_timeNow'" + ." ORDER BY si.starts" + ." LIMIT 1"; + + $id = $CC_DBC->GetOne($sql); + if (is_null($id)){ + return null; + } else { + return new Application_Model_ShowInstance($id); + } + } + + // returns number of show instances that ends later than $day + public static function GetShowInstanceCount($day){ + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'"; + return $CC_DBC->GetOne($sql); + } +} diff --git a/airtime_mvc/application/models/SmilPlaylist.php b/airtime_mvc/application/models/SmilPlaylist.php index a5c5fc735..52fc22d9e 100644 --- a/airtime_mvc/application/models/SmilPlaylist.php +++ b/airtime_mvc/application/models/SmilPlaylist.php @@ -61,7 +61,7 @@ class SmilPlaylist { return $lspl; } require_once("Playlist.php"); - $pl =& Playlist::create($gb, $plid, "imported_SMIL"); + $pl =& Application_Model_Playlist::create($gb, $plid, "imported_SMIL"); if (PEAR::isError($pl)) { return $pl; } @@ -220,14 +220,14 @@ class SmilPlaylistAudioElement { } } if ($fadeIn > 0 || $fadeOut > 0) { - $fiGunid = StoredFile::CreateGunid(); - $fadeIn = Playlist::secondsToPlaylistTime($fadeIn); - $fadeOut = Playlist::secondsToPlaylistTime($fadeOut); + $fiGunid = Application_Model_StoredFile::CreateGunid(); + $fadeIn = Application_Model_Playlist::secondsToPlaylistTime($fadeIn); + $fadeOut = Application_Model_Playlist::secondsToPlaylistTime($fadeOut); $fInfo = "$ind2\n"; } else { $fInfo = ''; } - $plElGunid = StoredFile::CreateGunid(); + $plElGunid = Application_Model_StoredFile::CreateGunid(); $acGunid = $gunid; $type = 'audioClip'; if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) { @@ -244,7 +244,7 @@ class SmilPlaylistAudioElement { } //break; default: - $ac = StoredFile::RecallByGunid($gunid); + $ac = Application_Model_StoredFile::RecallByGunid($gunid); if (is_null($ac) || PEAR::isError($ac)) { return $ac; } @@ -257,10 +257,10 @@ class SmilPlaylistAudioElement { } $title = basename($tree->attrs['src']->val); - $offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val); - $clipStart = Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val); - $clipEnd = Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val); - $clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val); + $offset = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['begin']->val); + $clipStart = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val); + $clipEnd = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val); + $clipLength = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val); $res = "$ind\n". "$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n". $fInfo. diff --git a/airtime_mvc/application/models/Soundcloud.php b/airtime_mvc/application/models/Soundcloud.php index 5e17049b6..d8286988f 100644 --- a/airtime_mvc/application/models/Soundcloud.php +++ b/airtime_mvc/application/models/Soundcloud.php @@ -1,8 +1,7 @@ _soundcloud->accessTokenResourceOwner($username, $password); return $token; @@ -40,13 +34,15 @@ class ATSoundcloud { $tags = Application_Model_Preference::GetSoundCloudTags(); } + $downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1'?true:false; + $track_data = array( 'track[sharing]' => 'private', 'track[title]' => $filename, 'track[asset_data]' => '@' . $filepath, 'track[tag_list]' => $tags, 'track[description]' => $description, - 'track[downloadable]' => true, + 'track[downloadable]' => $downloadable, ); @@ -81,13 +77,13 @@ class ATSoundcloud { if ($license != "") { $track_data['track[license]'] = $license; } - + $response = json_decode( $this->_soundcloud->post('tracks', $track_data), true ); - return $response["id"]; + return $response; } } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 922856feb..90cb2970e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1,7 +1,7 @@ 0) { foreach ($ids as $id) { - $playlists[] = Playlist::Recall($id); + $playlists[] = Application_Model_Playlist::Recall($id); } } return $playlists; @@ -310,7 +310,7 @@ class StoredFile { } } - Playlist::DeleteFileFromAllPlaylists($this->getId()); + Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId()); $this->_file->delete(); if (isset($res)) { @@ -338,7 +338,7 @@ class StoredFile { } // Check if the file is scheduled to be played in the future - if (Schedule::IsFileScheduledInTheFuture($this->getId())) { + if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) { return PEAR::raiseError('Cannot delete a file that is scheduled in the future.'); } @@ -395,10 +395,10 @@ class StoredFile { { $mime = $this->_file->getDbMime(); - if ($mime == "audio/vorbis") { + if ($mime == "audio/vorbis" || $mime == "application/ogg") { return "ogg"; } - else if ($mime == "audio/mp3") { + else if ($mime == "audio/mp3" || $mime == "audio/mpeg") { return "mp3"; } } @@ -410,7 +410,7 @@ class StoredFile { */ public function getFilePath() { - $music_dir = MusicDir::getDirByPK($this->_file->getDbDirectory()); + $music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory()); $filepath = $this->_file->getDbFilepath(); return $music_dir->getDirectory().$filepath; @@ -423,11 +423,11 @@ class StoredFile { */ public function setFilePath($p_filepath) { - $path_info = MusicDir::splitFilePath($p_filepath); + $path_info = Application_Model_MusicDir::splitFilePath($p_filepath); if (is_null($path_info)) { return -1; } - $musicDir = MusicDir::getDirByPath($path_info[0]); + $musicDir = Application_Model_MusicDir::getDirByPath($path_info[0]); $this->_file->setDbDirectory($musicDir->getId()); $this->_file->setDbFilepath($path_info[1]); @@ -435,12 +435,32 @@ class StoredFile { } /** - * Get the URL to access this file. + * Get the URL to access this file using the server name/address that + * this PHP script was invoked through. */ public function getFileUrl() { + $serverName = $_SERVER['SERVER_NAME']; + $serverPort = $_SERVER['SERVER_PORT']; + + return $this->constructGetFileUrl($serverName, $serverPort); + } + + /** + * Get the URL to access this file using the server name/address that + * is specified in the airtime.conf config file. + */ + public function getFileUrlUsingConfigAddress(){ global $CC_CONFIG; - return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); + + $serverName = $CC_CONFIG['baseUrl']; + $serverPort = $CC_CONFIG['basePort']; + + return $this->constructGetFileUrl($serverName, $serverPort); + } + + private function constructGetFileUrl($p_serverName, $p_serverPort){ + return "http://$p_serverName:$p_serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); } /** @@ -457,7 +477,7 @@ class StoredFile { $file = new CcFiles(); $file->setDbGunid(md5(uniqid("", true))); - $storedFile = new StoredFile(); + $storedFile = new Application_Model_StoredFile(); $storedFile->_file = $file; if(isset($md['MDATA_KEY_FILEPATH'])) { @@ -488,7 +508,7 @@ class StoredFile { * global unique id of file * @param string $p_md5sum * MD5 sum of the file - * @return StoredFile|NULL + * @return Application_Model_StoredFile|NULL * Return NULL if the object doesnt exist in the DB. */ public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null, $p_filepath=null) @@ -507,12 +527,12 @@ class StoredFile { ->findOne(); } else if (isset($p_filepath)) { - $path_info = MusicDir::splitFilePath($p_filepath); + $path_info = Application_Model_MusicDir::splitFilePath($p_filepath); if (is_null($path_info)) { return null; } - $music_dir = MusicDir::getDirByPath($path_info[0]); + $music_dir = Application_Model_MusicDir::getDirByPath($path_info[0]); $file = CcFilesQuery::create() ->filterByDbDirectory($music_dir->getId()) @@ -524,7 +544,7 @@ class StoredFile { } if (isset($file)) { - $storedFile = new StoredFile(); + $storedFile = new Application_Model_StoredFile(); $storedFile->_file = $file; return $storedFile; @@ -545,36 +565,57 @@ class StoredFile { * * @param string $p_gunid * global unique id of file - * @return StoredFile|NULL + * @return Application_Model_StoredFile|NULL */ public static function RecallByGunid($p_gunid) { - return StoredFile::Recall(null, $p_gunid); + return Application_Model_StoredFile::Recall(null, $p_gunid); } /** - * Fetch the StoredFile by looking up the MD5 value. + * Fetch the Application_Model_StoredFile by looking up the MD5 value. * * @param string $p_md5sum - * @return StoredFile|NULL + * @return Application_Model_StoredFile|NULL */ public static function RecallByMd5($p_md5sum) { - return StoredFile::Recall(null, null, $p_md5sum); + return Application_Model_StoredFile::Recall(null, null, $p_md5sum); } /** - * Fetch the StoredFile by looking up its filepath. + * Fetch the Application_Model_StoredFile by looking up its filepath. * * @param string $p_filepath path of file stored in Airtime. - * @return StoredFile|NULL + * @return Application_Model_StoredFile|NULL */ public static function RecallByFilepath($p_filepath) { - return StoredFile::Recall(null, null, null, $p_filepath); + return Application_Model_StoredFile::Recall(null, null, null, $p_filepath); } + + public static function RecallByPartialFilepath($partial_path){ + $path_info = Application_Model_MusicDir::splitFilePath($partial_path); + if (is_null($path_info)) { + return null; + } + $music_dir = Application_Model_MusicDir::getDirByPath($path_info[0]); + + $files = CcFilesQuery::create() + ->filterByDbDirectory($music_dir->getId()) + ->filterByDbFilepath("$path_info[1]%") + ->find(); + $res = array(); + foreach ($files as $file){ + $storedFile = new Application_Model_StoredFile(); + $storedFile->_file = $file; + $res[] = $storedFile; + } + return $res; + } + public static function searchFilesForPlaylistBuilder($datatables) { global $CC_CONFIG; @@ -614,7 +655,7 @@ class StoredFile { (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS"; - return StoredFile::searchFiles($fromTable, $datatables); + return Application_Model_StoredFile::searchFiles($fromTable, $datatables); } @@ -624,7 +665,7 @@ class StoredFile { //$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'"; $datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'"; - return StoredFile::searchFiles($fromTable, $datatables); + return Application_Model_StoredFile::searchFiles($fromTable, $datatables); } public static function searchFiles($fromTable, $data) @@ -728,7 +769,7 @@ class StoredFile { $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; - + Logging::log(__FILE__.":uploadFile(): filename=$fileName to $p_targetDir"); // Clean the fileName for security reasons //this needs fixing for songs not in ascii. //$fileName = preg_replace('/[^\w\._]+/', '', $fileName); @@ -799,7 +840,7 @@ class StoredFile { /*$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName; $md5 = md5_file($audio_file); - $duplicate = StoredFile::RecallByMd5($md5); + $duplicate = Application_Model_StoredFile::RecallByMd5($md5); if ($duplicate) { if (PEAR::isError($duplicate)) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}'); @@ -810,7 +851,7 @@ class StoredFile { } } - $storDir = MusicDir::getStorDir(); + $storDir = Application_Model_MusicDir::getStorDir(); $stor = $storDir->getDirectory(); $stor .= "/organize"; @@ -823,20 +864,20 @@ class StoredFile { public static function copyFileToStor($p_targetDir, $fileName){ $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName; - + Logging::log('copyFileToStor: moving file '.$audio_file); $md5 = md5_file($audio_file); - $duplicate = StoredFile::RecallByMd5($md5); + $duplicate = Application_Model_StoredFile::RecallByMd5($md5); if ($duplicate) { if (PEAR::isError($duplicate)) { die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}'); } if (file_exists($duplicate->getFilePath())) { $duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE'); - die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}'); + die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named \"' . $duplicateName . '\" already exists on the server."}}'); } } - $storDir = MusicDir::getStorDir(); + $storDir = Application_Model_MusicDir::getStorDir(); $stor = $storDir->getDirectory(); $stor .= "/organize"; @@ -844,6 +885,7 @@ class StoredFile { $audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName; $r = @copy($audio_file, $audio_stor); + //$r = @unlink($audio_file); } public static function getFileCount() @@ -875,5 +917,84 @@ class StoredFile { return $results; } + + public function setSoundCloudLinkToFile($link_to_file) + { + $this->_file->setDbSoundCloudLinkToFile($link_to_file) + ->save(); + } + + public function getSoundCloudLinkToFile(){ + return $this->_file->getDbSoundCloudLinkToFile(); + } + + public function setSoundCloudFileId($p_soundcloud_id) + { + $this->_file->setDbSoundCloudId($p_soundcloud_id) + ->save(); + } + + public function getSoundCloudId(){ + return $this->_file->getDbSoundCloudId(); + } + + public function setSoundCloudErrorCode($code){ + $this->_file->setDbSoundCloudErrorCode($code) + ->save(); + } + + public function getSoundCloudErrorCode(){ + return $this->_file->getDbSoundCloudErrorCode(); + } + + public function setSoundCloudErrorMsg($msg){ + $this->_file->setDbSoundCloudErrorMsg($msg) + ->save(); + } + + public function getSoundCloudErrorMsg(){ + return $this->_file->getDbSoundCloudErrorMsg(); + } + + public function uploadToSoundCloud() + { + global $CC_CONFIG; + + $file = $this->_file; + if(is_null($file)) { + return "File does not exist"; + } + if(Application_Model_Preference::GetUploadToSoundcloudOption()) + { + for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { + $description = $file->getDbTrackTitle(); + $tag = array(); + $genre = $file->getDbGenre(); + $release = $file->getDbYear(); + try { + $soundcloud = new Application_Model_Soundcloud(); + $soundcloud_res = $soundcloud->uploadTrack($this->getFilePath(), $this->getName(), $description, $tag, $release, $genre); + $this->setSoundCloudFileId($soundcloud_res['id']); + $this->setSoundCloudLinkToFile($soundcloud_res['permalink_url']); + break; + } + catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { + $code = $e->getHttpCode(); + $msg = $e->getHttpBody(); + $temp = explode('"error":',$msg); + $msg = trim($temp[1], '"}'); + $this->setSoundCloudErrorCode($code); + $this->setSoundCloudErrorMsg($msg); + // setting sc id to -3 which indicates error + $this->setSoundCloudFileId(SOUNDCLOUD_ERROR); + if(!in_array($code, array(0, 100))) { + break; + } + } + + sleep($CC_CONFIG['soundcloud-connection-wait']); + } + } + } } diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php new file mode 100644 index 000000000..5675de6c2 --- /dev/null +++ b/airtime_mvc/application/models/StreamSetting.php @@ -0,0 +1,124 @@ +getAll($sql); + $ids = array(); + + foreach ($rows as $row){ + $ids[] = substr($row["keyname"], 0, strpos($row["keyname"], "_")); + } + + //Logging::log(print_r($ids, true)); + + return $ids; + } + + /* Returns all information related to a specific stream. An example + * of a stream id is 's1' or 's2'. */ + public static function getStreamData($p_streamId){ + global $CC_DBC; + $sql = "SELECT * " + ."FROM cc_stream_setting " + ."WHERE keyname LIKE '${p_streamId}_%'"; + + $rows = $CC_DBC->getAll($sql); + $data = array(); + + foreach($rows as $row){ + $data[$row["keyname"]] = $row["value"]; + } + + return $data; + } + + public static function getStreamSetting(){ + global $CC_DBC; + $sql = "SELECT *" + ." FROM cc_stream_setting" + ." WHERE keyname not like '%_error'"; + + $rows = $CC_DBC->getAll($sql); + return $rows; + } + + public static function setStreamSetting($data){ + global $CC_DBC; + foreach($data as $key=>$d){ + if($key == "output_sound_device"){ + $v = $d == 1?"true":"false"; + $sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'"; + $CC_DBC->query($sql); + } + else{ + $temp = explode('_', $key); + $prefix = $temp[0]; + foreach($d as $k=>$v){ + $keyname = $prefix."_".$k; + if( $k == 'output'){ + if( $d["enable"] == 0){ + $v = 'disabled'; + } + } + $v = trim($v); + $sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'"; + $CC_DBC->query($sql); + } + } + } + } + + public static function setLiquidsoapError($stream_id, $msg){ + global $CC_DBC; + + $keyname = "s".$stream_id."_liquidsoap_error"; + $sql = "SELECT COUNT(*) FROM cc_stream_setting" + ." WHERE keyname = '$keyname'"; + $result = $CC_DBC->GetOne($sql); + if ($result == 1){ + $sql = "UPDATE cc_stream_setting" + ." SET value = '$msg'" + ." WHERE keyname = '$keyname'"; + }else{ + $sql = "INSERT INTO cc_stream_setting (keyname, value, type)" + ." VALUES ('$keyname', '$msg', 'string')"; + } + $res = $CC_DBC->query($sql); + } + + public static function getLiquidsoapError($stream_id){ + global $CC_DBC; + + $keyname = "s".$stream_id."_liquidsoap_error"; + $sql = "SELECT value FROM cc_stream_setting" + ." WHERE keyname = '$keyname'"; + $result = $CC_DBC->GetOne($sql); + + return $result; + } + + public static function getStreamEnabled($stream_id){ + global $CC_DBC; + + $keyname = "s".$stream_id."_output"; + $sql = "SELECT value FROM cc_stream_setting" + ." WHERE keyname = '$keyname'"; + $result = $CC_DBC->GetOne($sql); + + if($result == 'disabled'){ + $result = false; + }else{ + $result = true; + } + + return $result; + } +} diff --git a/airtime_mvc/application/models/Subjects.php b/airtime_mvc/application/models/Subjects.php index 3484484f9..7b2b15cd6 100644 --- a/airtime_mvc/application/models/Subjects.php +++ b/airtime_mvc/application/models/Subjects.php @@ -14,7 +14,7 @@ define('ALIBERR_BADSMEMB', 21); * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt */ -class Subjects { +class Application_Model_Subjects { /* ======================================================= public methods */ @@ -118,6 +118,38 @@ class Subjects { return (intval($res) > 0); } // fn isMemberOf + public static function increaseLoginAttempts($login){ + global $CC_CONFIG, $CC_DBC; + $sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = login_attempts+1" + ." WHERE login='$login'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + return (intval($res) > 0); + } + + public static function resetLoginAttempts($login){ + global $CC_CONFIG, $CC_DBC; + $sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'" + ." WHERE login='$login'"; + $res = $CC_DBC->query($sql); + if (PEAR::isError($res)) { + return $res; + } + return (intval($res) > 0); + } + + public static function getLoginAttempts($login){ + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'"; + $res = $CC_DBC->getOne($sql); + Logging::log($res); + if (PEAR::isError($res)) { + return $res; + } + return $res; + } } // class Subjects diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php new file mode 100644 index 000000000..ca522c991 --- /dev/null +++ b/airtime_mvc/application/models/Systemstatus.php @@ -0,0 +1,208 @@ +loadXML($result); + $docRoot = $xmlDoc->documentElement; + } + + return $docRoot; + } + + public static function ExtractServiceInformation($p_docRoot, $p_serviceName){ + + $starting = array( + "name"=>"", + "process_id"=>"STARTING...", + "uptime_seconds"=>"-1", + "status"=>true, + "memory_perc"=>"0%", + "memory_kb"=>"0", + "cpu_perc"=>"0%"); + + $notRunning = array( + "name"=>$p_serviceName, + "process_id"=>"FAILED", + "uptime_seconds"=>"-1", + "status"=>false, + "memory_perc"=>"0%", + "memory_kb"=>"0", + "cpu_perc"=>"0%" + ); + $data = $notRunning; + + + if (!is_null($p_docRoot)){ + foreach ($p_docRoot->getElementsByTagName("service") AS $item) + { + if ($item->getElementsByTagName("name")->item(0)->nodeValue == $p_serviceName){ + + $monitor = $item->getElementsByTagName("monitor"); + if ($monitor->length > 0){ + $status = $monitor->item(0)->nodeValue; + if ($status == "2"){ + $data = $starting; + } else if ($status == 0){ + $data = $notRunning; + } + } + + $process_id = $item->getElementsByTagName("name"); + if ($process_id->length > 0){ + $data["name"] = $process_id->item(0)->nodeValue; + } + + $process_id = $item->getElementsByTagName("pid"); + if ($process_id->length > 0){ + $data["process_id"] = $process_id->item(0)->nodeValue; + $data["status"] = true; + } + + $uptime = $item->getElementsByTagName("uptime"); + if ($uptime->length > 0){ + $data["uptime_seconds"] = $uptime->item(0)->nodeValue; + } + + $memory = $item->getElementsByTagName("memory"); + if ($memory->length > 0){ + $data["memory_perc"] = $memory->item(0)->getElementsByTagName("percenttotal")->item(0)->nodeValue."%"; + $data["memory_kb"] = $memory->item(0)->getElementsByTagName("kilobytetotal")->item(0)->nodeValue; + } + + $cpu = $item->getElementsByTagName("cpu"); + if ($cpu->length > 0){ + $data["cpu_perc"] = $cpu->item(0)->getElementsByTagName("percent")->item(0)->nodeValue."%"; + } + break; + } + } + } + return $data; + } + + public static function GetPlatformInfo(){ + $data = array("release"=>"UNKNOWN", + "machine"=>"UNKNOWN", + "memory"=>"UNKNOWN", + "swap"=>"UNKNOWN"); + + $docRoot = self::GetMonitStatus("localhost"); + if (!is_null($docRoot)){ + foreach ($docRoot->getElementsByTagName("platform") AS $item) + { + $data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue; + $data["machine"] = $item->getElementsByTagName("machine")->item(0)->nodeValue; + $data["memory"] = $item->getElementsByTagName("memory")->item(0)->nodeValue; + $data["swap"] = $item->getElementsByTagName("swap")->item(0)->nodeValue; + } + } + + return $data; + + } + + public static function GetPypoStatus(){ + + $component = CcServiceRegisterQuery::create()->findOneByDbName("pypo"); + $ip = $component->getDbIp(); + + $docRoot = self::GetMonitStatus($ip); + $data = self::ExtractServiceInformation($docRoot, "airtime-playout"); + + return $data; + } + + public static function GetLiquidsoapStatus(){ + + $component = CcServiceRegisterQuery::create()->findOneByDbName("pypo"); + $ip = $component->getDbIp(); + + $docRoot = self::GetMonitStatus($ip); + $data = self::ExtractServiceInformation($docRoot, "airtime-liquidsoap"); + + return $data; + } + + public static function GetShowRecorderStatus(){ + + $component = CcServiceRegisterQuery::create()->findOneByDbName("show-recorder"); + if (is_null($component)){ + return null; + } else { + $ip = $component->getDbIp(); + + $docRoot = self::GetMonitStatus($ip); + $data = self::ExtractServiceInformation($docRoot, "airtime-show-recorder"); + + return $data; + } + } + + public static function GetMediaMonitorStatus(){ + + $component = CcServiceRegisterQuery::create()->findOneByDbName("media-monitor"); + if (is_null($component)){ + return null; + } else { + $ip = $component->getDbIp(); + + $docRoot = self::GetMonitStatus($ip); + $data = self::ExtractServiceInformation($docRoot, "airtime-media-monitor"); + + return $data; + } + } + + public static function GetIcecastStatus(){ + $docRoot = self::GetMonitStatus("localhost"); + $data = self::ExtractServiceInformation($docRoot, "icecast2"); + + return $data; + } + + public static function GetRabbitMqStatus(){ + $docRoot = self::GetMonitStatus("localhost"); + $data = self::ExtractServiceInformation($docRoot, "rabbitmq-server"); + + return $data; + } + + public static function GetDiskInfo(){ + /* First lets get all the watched directories. Then we can group them + * into the same paritions by comparing the partition sizes. */ + $musicDirs = Application_Model_MusicDir::getWatchedDirs(); + $musicDirs[] = Application_Model_MusicDir::getStorDir(); + + + $partions = array(); + + foreach($musicDirs as $md){ + $totalSpace = disk_total_space($md->getDirectory()); + + if (!isset($partitions[$totalSpace])){ + $partitions[$totalSpace] = new StdClass; + $partitions[$totalSpace]->totalSpace = $totalSpace; + $partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory()); + } + + $partitions[$totalSpace]->dirs[] = $md->getDirectory(); + } + + return array_values($partitions); + } +} diff --git a/airtime_mvc/application/models/Users.php b/airtime_mvc/application/models/User.php similarity index 97% rename from airtime_mvc/application/models/Users.php rename to airtime_mvc/application/models/User.php index ef7b2e25d..6f0ec13c7 100644 --- a/airtime_mvc/application/models/Users.php +++ b/airtime_mvc/application/models/User.php @@ -5,7 +5,7 @@ define('UTYPE_ADMIN', 'A'); define('UTYPE_GUEST', 'G'); define('UTYPE_PROGRAM_MANAGER', 'P'); -class User { +class Application_Model_User { private $_userInstance; @@ -217,7 +217,7 @@ class User { } public static function getHosts($search=NULL) { - return User::getUsers(array('H'), $search); + return Application_Model_User::getUsers(array('H'), $search); } public static function getUsersDataTablesInfo($datatables_post) { @@ -232,7 +232,7 @@ class User { $username = $auth->getIdentity()->login; } - $res = StoredFile::searchFiles($fromTable, $datatables_post); + $res = Application_Model_StoredFile::searchFiles($fromTable, $datatables_post); // mark record which is for the current user foreach($res['aaData'] as &$record){ diff --git a/airtime_mvc/application/models/airtime/CcLoginAttempts.php b/airtime_mvc/application/models/airtime/CcLoginAttempts.php new file mode 100644 index 000000000..9350b8d56 --- /dev/null +++ b/airtime_mvc/application/models/airtime/CcLoginAttempts.php @@ -0,0 +1,18 @@ +addColumn('SUBJECT', 'DbSubject', 'VARCHAR', false, 512, null); $this->addColumn('CONTRIBUTOR', 'DbContributor', 'VARCHAR', false, 512, null); $this->addColumn('LANGUAGE', 'DbLanguage', 'VARCHAR', false, 512, null); + $this->addColumn('SOUNDCLOUD_ID', 'DbSoundcloudId', 'INTEGER', false, null, null); + $this->addColumn('SOUNDCLOUD_ERROR_CODE', 'DbSoundcloudErrorCode', 'INTEGER', false, null, null); + $this->addColumn('SOUNDCLOUD_ERROR_MSG', 'DbSoundcloudErrorMsg', 'VARCHAR', false, 512, null); + $this->addColumn('SOUNDCLOUD_LINK_TO_FILE', 'DbSoundcloudLinkToFile', 'VARCHAR', false, 512, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php b/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php new file mode 100644 index 000000000..32ce73743 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php @@ -0,0 +1,52 @@ +setName('cc_login_attempts'); + $this->setPhpName('CcLoginAttempts'); + $this->setClassname('CcLoginAttempts'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('IP', 'DbIP', 'VARCHAR', true, 32, null); + $this->addColumn('ATTEMPTS', 'DbAttempts', 'INTEGER', false, null, 0); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcLoginAttemptsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php b/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php new file mode 100644 index 000000000..f4eae5e60 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php @@ -0,0 +1,52 @@ +setName('cc_service_register'); + $this->setPhpName('CcServiceRegister'); + $this->setClassname('CcServiceRegister'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('NAME', 'DbName', 'VARCHAR', true, 32, null); + $this->addColumn('IP', 'DbIp', 'VARCHAR', true, 18, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcServiceRegisterTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php index 2e932e7eb..7d6b8a10e 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php @@ -42,6 +42,7 @@ class CcShowDaysTableMap extends TableMap { $this->addColumn('FIRST_SHOW', 'DbFirstShow', 'DATE', true, null, null); $this->addColumn('LAST_SHOW', 'DbLastShow', 'DATE', false, null, null); $this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null); + $this->addColumn('TIMEZONE', 'DbTimezone', 'VARCHAR', true, 255, null); $this->addColumn('DURATION', 'DbDuration', 'VARCHAR', true, 255, null); $this->addColumn('DAY', 'DbDay', 'TINYINT', false, null, null); $this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null); diff --git a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php index d2882172a..69efea1dd 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php @@ -46,7 +46,6 @@ class CcShowInstancesTableMap extends TableMap { $this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0); $this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null); $this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null); - $this->addColumn('SOUNDCLOUD_ID', 'DbSoundCloudId', 'INTEGER', false, null, null); $this->addColumn('TIME_FILLED', 'DbTimeFilled', 'TIME', false, null, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php b/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php new file mode 100644 index 000000000..d401ce096 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php @@ -0,0 +1,53 @@ +setName('cc_stream_setting'); + $this->setPhpName('CcStreamSetting'); + $this->setClassname('CcStreamSetting'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('KEYNAME', 'DbKeyName', 'VARCHAR', true, 64, null); + $this->addColumn('VALUE', 'DbValue', 'VARCHAR', false, 255, null); + $this->addColumn('TYPE', 'DbType', 'VARCHAR', true, 16, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + +} // CcStreamSettingTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php b/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php index 2d644a515..49e883968 100644 --- a/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php @@ -49,6 +49,7 @@ class CcSubjsTableMap extends TableMap { $this->addColumn('SKYPE_CONTACT', 'DbSkypeContact', 'VARCHAR', false, 255, null); $this->addColumn('JABBER_CONTACT', 'DbJabberContact', 'VARCHAR', false, 255, null); $this->addColumn('EMAIL', 'DbEmail', 'VARCHAR', false, 255, null); + $this->addColumn('LOGIN_ATTEMPTS', 'DbLoginAttempts', 'INTEGER', false, null, 0); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php index e30ff3fe1..0882018d1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php @@ -360,6 +360,30 @@ abstract class BaseCcFiles extends BaseObject implements Persistent */ protected $language; + /** + * The value for the soundcloud_id field. + * @var int + */ + protected $soundcloud_id; + + /** + * The value for the soundcloud_error_code field. + * @var int + */ + protected $soundcloud_error_code; + + /** + * The value for the soundcloud_error_msg field. + * @var string + */ + protected $soundcloud_error_msg; + + /** + * The value for the soundcloud_link_to_file field. + * @var string + */ + protected $soundcloud_link_to_file; + /** * @var CcSubjs */ @@ -1021,6 +1045,46 @@ abstract class BaseCcFiles extends BaseObject implements Persistent return $this->language; } + /** + * Get the [soundcloud_id] column value. + * + * @return int + */ + public function getDbSoundcloudId() + { + return $this->soundcloud_id; + } + + /** + * Get the [soundcloud_error_code] column value. + * + * @return int + */ + public function getDbSoundcloudErrorCode() + { + return $this->soundcloud_error_code; + } + + /** + * Get the [soundcloud_error_msg] column value. + * + * @return string + */ + public function getDbSoundcloudErrorMsg() + { + return $this->soundcloud_error_msg; + } + + /** + * Get the [soundcloud_link_to_file] column value. + * + * @return string + */ + public function getDbSoundcloudLinkToFile() + { + return $this->soundcloud_link_to_file; + } + /** * Set the value of [id] column. * @@ -2187,6 +2251,86 @@ abstract class BaseCcFiles extends BaseObject implements Persistent return $this; } // setDbLanguage() + /** + * Set the value of [soundcloud_id] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->soundcloud_id !== $v) { + $this->soundcloud_id = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ID; + } + + return $this; + } // setDbSoundcloudId() + + /** + * Set the value of [soundcloud_error_code] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudErrorCode($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->soundcloud_error_code !== $v) { + $this->soundcloud_error_code = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ERROR_CODE; + } + + return $this; + } // setDbSoundcloudErrorCode() + + /** + * Set the value of [soundcloud_error_msg] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudErrorMsg($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->soundcloud_error_msg !== $v) { + $this->soundcloud_error_msg = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ERROR_MSG; + } + + return $this; + } // setDbSoundcloudErrorMsg() + + /** + * Set the value of [soundcloud_link_to_file] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudLinkToFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->soundcloud_link_to_file !== $v) { + $this->soundcloud_link_to_file = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE; + } + + return $this; + } // setDbSoundcloudLinkToFile() + /** * Indicates whether the columns in this object are only set to default values. * @@ -2298,6 +2442,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->subject = ($row[$startcol + 52] !== null) ? (string) $row[$startcol + 52] : null; $this->contributor = ($row[$startcol + 53] !== null) ? (string) $row[$startcol + 53] : null; $this->language = ($row[$startcol + 54] !== null) ? (string) $row[$startcol + 54] : null; + $this->soundcloud_id = ($row[$startcol + 55] !== null) ? (int) $row[$startcol + 55] : null; + $this->soundcloud_error_code = ($row[$startcol + 56] !== null) ? (int) $row[$startcol + 56] : null; + $this->soundcloud_error_msg = ($row[$startcol + 57] !== null) ? (string) $row[$startcol + 57] : null; + $this->soundcloud_link_to_file = ($row[$startcol + 58] !== null) ? (string) $row[$startcol + 58] : null; $this->resetModified(); $this->setNew(false); @@ -2306,7 +2454,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 55; // 55 = CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 59; // 59 = CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcFiles object", $e); @@ -2869,6 +3017,18 @@ abstract class BaseCcFiles extends BaseObject implements Persistent case 54: return $this->getDbLanguage(); break; + case 55: + return $this->getDbSoundcloudId(); + break; + case 56: + return $this->getDbSoundcloudErrorCode(); + break; + case 57: + return $this->getDbSoundcloudErrorMsg(); + break; + case 58: + return $this->getDbSoundcloudLinkToFile(); + break; default: return null; break; @@ -2948,6 +3108,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $keys[52] => $this->getDbSubject(), $keys[53] => $this->getDbContributor(), $keys[54] => $this->getDbLanguage(), + $keys[55] => $this->getDbSoundcloudId(), + $keys[56] => $this->getDbSoundcloudErrorCode(), + $keys[57] => $this->getDbSoundcloudErrorMsg(), + $keys[58] => $this->getDbSoundcloudLinkToFile(), ); if ($includeForeignObjects) { if (null !== $this->aCcSubjs) { @@ -3152,6 +3316,18 @@ abstract class BaseCcFiles extends BaseObject implements Persistent case 54: $this->setDbLanguage($value); break; + case 55: + $this->setDbSoundcloudId($value); + break; + case 56: + $this->setDbSoundcloudErrorCode($value); + break; + case 57: + $this->setDbSoundcloudErrorMsg($value); + break; + case 58: + $this->setDbSoundcloudLinkToFile($value); + break; } // switch() } @@ -3231,6 +3407,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent if (array_key_exists($keys[52], $arr)) $this->setDbSubject($arr[$keys[52]]); if (array_key_exists($keys[53], $arr)) $this->setDbContributor($arr[$keys[53]]); if (array_key_exists($keys[54], $arr)) $this->setDbLanguage($arr[$keys[54]]); + if (array_key_exists($keys[55], $arr)) $this->setDbSoundcloudId($arr[$keys[55]]); + if (array_key_exists($keys[56], $arr)) $this->setDbSoundcloudErrorCode($arr[$keys[56]]); + if (array_key_exists($keys[57], $arr)) $this->setDbSoundcloudErrorMsg($arr[$keys[57]]); + if (array_key_exists($keys[58], $arr)) $this->setDbSoundcloudLinkToFile($arr[$keys[58]]); } /** @@ -3297,6 +3477,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent if ($this->isColumnModified(CcFilesPeer::SUBJECT)) $criteria->add(CcFilesPeer::SUBJECT, $this->subject); if ($this->isColumnModified(CcFilesPeer::CONTRIBUTOR)) $criteria->add(CcFilesPeer::CONTRIBUTOR, $this->contributor); if ($this->isColumnModified(CcFilesPeer::LANGUAGE)) $criteria->add(CcFilesPeer::LANGUAGE, $this->language); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ID)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ID, $this->soundcloud_id); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_CODE)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $this->soundcloud_error_code); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_MSG)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ERROR_MSG, $this->soundcloud_error_msg); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE)) $criteria->add(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, $this->soundcloud_link_to_file); return $criteria; } @@ -3412,6 +3596,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $copyObj->setDbSubject($this->subject); $copyObj->setDbContributor($this->contributor); $copyObj->setDbLanguage($this->language); + $copyObj->setDbSoundcloudId($this->soundcloud_id); + $copyObj->setDbSoundcloudErrorCode($this->soundcloud_error_code); + $copyObj->setDbSoundcloudErrorMsg($this->soundcloud_error_msg); + $copyObj->setDbSoundcloudLinkToFile($this->soundcloud_link_to_file); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -4066,6 +4254,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->subject = null; $this->contributor = null; $this->language = null; + $this->soundcloud_id = null; + $this->soundcloud_error_code = null; + $this->soundcloud_error_msg = null; + $this->soundcloud_link_to_file = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php index 319b237b7..e08728cfd 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcFilesPeer { const TM_CLASS = 'CcFilesTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 55; + const NUM_COLUMNS = 59; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -196,6 +196,18 @@ abstract class BaseCcFilesPeer { /** the column name for the LANGUAGE field */ const LANGUAGE = 'cc_files.LANGUAGE'; + /** the column name for the SOUNDCLOUD_ID field */ + const SOUNDCLOUD_ID = 'cc_files.SOUNDCLOUD_ID'; + + /** the column name for the SOUNDCLOUD_ERROR_CODE field */ + const SOUNDCLOUD_ERROR_CODE = 'cc_files.SOUNDCLOUD_ERROR_CODE'; + + /** the column name for the SOUNDCLOUD_ERROR_MSG field */ + const SOUNDCLOUD_ERROR_MSG = 'cc_files.SOUNDCLOUD_ERROR_MSG'; + + /** the column name for the SOUNDCLOUD_LINK_TO_FILE field */ + const SOUNDCLOUD_LINK_TO_FILE = 'cc_files.SOUNDCLOUD_LINK_TO_FILE'; + /** * An identiy map to hold any loaded instances of CcFiles objects. * This must be public so that other peer classes can access this when hydrating from JOIN @@ -212,12 +224,12 @@ abstract class BaseCcFilesPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbGunid', 'DbName', 'DbMime', 'DbFtype', 'DbDirectory', 'DbFilepath', 'DbState', 'DbCurrentlyaccessing', 'DbEditedby', 'DbMtime', 'DbMd5', 'DbTrackTitle', 'DbArtistName', 'DbBitRate', 'DbSampleRate', 'DbFormat', 'DbLength', 'DbAlbumTitle', 'DbGenre', 'DbComments', 'DbYear', 'DbTrackNumber', 'DbChannels', 'DbUrl', 'DbBpm', 'DbRating', 'DbEncodedBy', 'DbDiscNumber', 'DbMood', 'DbLabel', 'DbComposer', 'DbEncoder', 'DbChecksum', 'DbLyrics', 'DbOrchestra', 'DbConductor', 'DbLyricist', 'DbOriginalLyricist', 'DbRadioStationName', 'DbInfoUrl', 'DbArtistUrl', 'DbAudioSourceUrl', 'DbRadioStationUrl', 'DbBuyThisUrl', 'DbIsrcNumber', 'DbCatalogNumber', 'DbOriginalArtist', 'DbCopyright', 'DbReportDatetime', 'DbReportLocation', 'DbReportOrganization', 'DbSubject', 'DbContributor', 'DbLanguage', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbGunid', 'dbName', 'dbMime', 'dbFtype', 'dbDirectory', 'dbFilepath', 'dbState', 'dbCurrentlyaccessing', 'dbEditedby', 'dbMtime', 'dbMd5', 'dbTrackTitle', 'dbArtistName', 'dbBitRate', 'dbSampleRate', 'dbFormat', 'dbLength', 'dbAlbumTitle', 'dbGenre', 'dbComments', 'dbYear', 'dbTrackNumber', 'dbChannels', 'dbUrl', 'dbBpm', 'dbRating', 'dbEncodedBy', 'dbDiscNumber', 'dbMood', 'dbLabel', 'dbComposer', 'dbEncoder', 'dbChecksum', 'dbLyrics', 'dbOrchestra', 'dbConductor', 'dbLyricist', 'dbOriginalLyricist', 'dbRadioStationName', 'dbInfoUrl', 'dbArtistUrl', 'dbAudioSourceUrl', 'dbRadioStationUrl', 'dbBuyThisUrl', 'dbIsrcNumber', 'dbCatalogNumber', 'dbOriginalArtist', 'dbCopyright', 'dbReportDatetime', 'dbReportLocation', 'dbReportOrganization', 'dbSubject', 'dbContributor', 'dbLanguage', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::GUNID, self::NAME, self::MIME, self::FTYPE, self::DIRECTORY, self::FILEPATH, self::STATE, self::CURRENTLYACCESSING, self::EDITEDBY, self::MTIME, self::MD5, self::TRACK_TITLE, self::ARTIST_NAME, self::BIT_RATE, self::SAMPLE_RATE, self::FORMAT, self::LENGTH, self::ALBUM_TITLE, self::GENRE, self::COMMENTS, self::YEAR, self::TRACK_NUMBER, self::CHANNELS, self::URL, self::BPM, self::RATING, self::ENCODED_BY, self::DISC_NUMBER, self::MOOD, self::LABEL, self::COMPOSER, self::ENCODER, self::CHECKSUM, self::LYRICS, self::ORCHESTRA, self::CONDUCTOR, self::LYRICIST, self::ORIGINAL_LYRICIST, self::RADIO_STATION_NAME, self::INFO_URL, self::ARTIST_URL, self::AUDIO_SOURCE_URL, self::RADIO_STATION_URL, self::BUY_THIS_URL, self::ISRC_NUMBER, self::CATALOG_NUMBER, self::ORIGINAL_ARTIST, self::COPYRIGHT, self::REPORT_DATETIME, self::REPORT_LOCATION, self::REPORT_ORGANIZATION, self::SUBJECT, self::CONTRIBUTOR, self::LANGUAGE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GUNID', 'NAME', 'MIME', 'FTYPE', 'DIRECTORY', 'FILEPATH', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'MD5', 'TRACK_TITLE', 'ARTIST_NAME', 'BIT_RATE', 'SAMPLE_RATE', 'FORMAT', 'LENGTH', 'ALBUM_TITLE', 'GENRE', 'COMMENTS', 'YEAR', 'TRACK_NUMBER', 'CHANNELS', 'URL', 'BPM', 'RATING', 'ENCODED_BY', 'DISC_NUMBER', 'MOOD', 'LABEL', 'COMPOSER', 'ENCODER', 'CHECKSUM', 'LYRICS', 'ORCHESTRA', 'CONDUCTOR', 'LYRICIST', 'ORIGINAL_LYRICIST', 'RADIO_STATION_NAME', 'INFO_URL', 'ARTIST_URL', 'AUDIO_SOURCE_URL', 'RADIO_STATION_URL', 'BUY_THIS_URL', 'ISRC_NUMBER', 'CATALOG_NUMBER', 'ORIGINAL_ARTIST', 'COPYRIGHT', 'REPORT_DATETIME', 'REPORT_LOCATION', 'REPORT_ORGANIZATION', 'SUBJECT', 'CONTRIBUTOR', 'LANGUAGE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'gunid', 'name', 'mime', 'ftype', 'directory', 'filepath', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'md5', 'track_title', 'artist_name', 'bit_rate', 'sample_rate', 'format', 'length', 'album_title', 'genre', 'comments', 'year', 'track_number', 'channels', 'url', 'bpm', 'rating', 'encoded_by', 'disc_number', 'mood', 'label', 'composer', 'encoder', 'checksum', 'lyrics', 'orchestra', 'conductor', 'lyricist', 'original_lyricist', 'radio_station_name', 'info_url', 'artist_url', 'audio_source_url', 'radio_station_url', 'buy_this_url', 'isrc_number', 'catalog_number', 'original_artist', 'copyright', 'report_datetime', 'report_location', 'report_organization', 'subject', 'contributor', 'language', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbGunid', 'DbName', 'DbMime', 'DbFtype', 'DbDirectory', 'DbFilepath', 'DbState', 'DbCurrentlyaccessing', 'DbEditedby', 'DbMtime', 'DbMd5', 'DbTrackTitle', 'DbArtistName', 'DbBitRate', 'DbSampleRate', 'DbFormat', 'DbLength', 'DbAlbumTitle', 'DbGenre', 'DbComments', 'DbYear', 'DbTrackNumber', 'DbChannels', 'DbUrl', 'DbBpm', 'DbRating', 'DbEncodedBy', 'DbDiscNumber', 'DbMood', 'DbLabel', 'DbComposer', 'DbEncoder', 'DbChecksum', 'DbLyrics', 'DbOrchestra', 'DbConductor', 'DbLyricist', 'DbOriginalLyricist', 'DbRadioStationName', 'DbInfoUrl', 'DbArtistUrl', 'DbAudioSourceUrl', 'DbRadioStationUrl', 'DbBuyThisUrl', 'DbIsrcNumber', 'DbCatalogNumber', 'DbOriginalArtist', 'DbCopyright', 'DbReportDatetime', 'DbReportLocation', 'DbReportOrganization', 'DbSubject', 'DbContributor', 'DbLanguage', 'DbSoundcloudId', 'DbSoundcloudErrorCode', 'DbSoundcloudErrorMsg', 'DbSoundcloudLinkToFile', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbGunid', 'dbName', 'dbMime', 'dbFtype', 'dbDirectory', 'dbFilepath', 'dbState', 'dbCurrentlyaccessing', 'dbEditedby', 'dbMtime', 'dbMd5', 'dbTrackTitle', 'dbArtistName', 'dbBitRate', 'dbSampleRate', 'dbFormat', 'dbLength', 'dbAlbumTitle', 'dbGenre', 'dbComments', 'dbYear', 'dbTrackNumber', 'dbChannels', 'dbUrl', 'dbBpm', 'dbRating', 'dbEncodedBy', 'dbDiscNumber', 'dbMood', 'dbLabel', 'dbComposer', 'dbEncoder', 'dbChecksum', 'dbLyrics', 'dbOrchestra', 'dbConductor', 'dbLyricist', 'dbOriginalLyricist', 'dbRadioStationName', 'dbInfoUrl', 'dbArtistUrl', 'dbAudioSourceUrl', 'dbRadioStationUrl', 'dbBuyThisUrl', 'dbIsrcNumber', 'dbCatalogNumber', 'dbOriginalArtist', 'dbCopyright', 'dbReportDatetime', 'dbReportLocation', 'dbReportOrganization', 'dbSubject', 'dbContributor', 'dbLanguage', 'dbSoundcloudId', 'dbSoundcloudErrorCode', 'dbSoundcloudErrorMsg', 'dbSoundcloudLinkToFile', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::GUNID, self::NAME, self::MIME, self::FTYPE, self::DIRECTORY, self::FILEPATH, self::STATE, self::CURRENTLYACCESSING, self::EDITEDBY, self::MTIME, self::MD5, self::TRACK_TITLE, self::ARTIST_NAME, self::BIT_RATE, self::SAMPLE_RATE, self::FORMAT, self::LENGTH, self::ALBUM_TITLE, self::GENRE, self::COMMENTS, self::YEAR, self::TRACK_NUMBER, self::CHANNELS, self::URL, self::BPM, self::RATING, self::ENCODED_BY, self::DISC_NUMBER, self::MOOD, self::LABEL, self::COMPOSER, self::ENCODER, self::CHECKSUM, self::LYRICS, self::ORCHESTRA, self::CONDUCTOR, self::LYRICIST, self::ORIGINAL_LYRICIST, self::RADIO_STATION_NAME, self::INFO_URL, self::ARTIST_URL, self::AUDIO_SOURCE_URL, self::RADIO_STATION_URL, self::BUY_THIS_URL, self::ISRC_NUMBER, self::CATALOG_NUMBER, self::ORIGINAL_ARTIST, self::COPYRIGHT, self::REPORT_DATETIME, self::REPORT_LOCATION, self::REPORT_ORGANIZATION, self::SUBJECT, self::CONTRIBUTOR, self::LANGUAGE, self::SOUNDCLOUD_ID, self::SOUNDCLOUD_ERROR_CODE, self::SOUNDCLOUD_ERROR_MSG, self::SOUNDCLOUD_LINK_TO_FILE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GUNID', 'NAME', 'MIME', 'FTYPE', 'DIRECTORY', 'FILEPATH', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'MD5', 'TRACK_TITLE', 'ARTIST_NAME', 'BIT_RATE', 'SAMPLE_RATE', 'FORMAT', 'LENGTH', 'ALBUM_TITLE', 'GENRE', 'COMMENTS', 'YEAR', 'TRACK_NUMBER', 'CHANNELS', 'URL', 'BPM', 'RATING', 'ENCODED_BY', 'DISC_NUMBER', 'MOOD', 'LABEL', 'COMPOSER', 'ENCODER', 'CHECKSUM', 'LYRICS', 'ORCHESTRA', 'CONDUCTOR', 'LYRICIST', 'ORIGINAL_LYRICIST', 'RADIO_STATION_NAME', 'INFO_URL', 'ARTIST_URL', 'AUDIO_SOURCE_URL', 'RADIO_STATION_URL', 'BUY_THIS_URL', 'ISRC_NUMBER', 'CATALOG_NUMBER', 'ORIGINAL_ARTIST', 'COPYRIGHT', 'REPORT_DATETIME', 'REPORT_LOCATION', 'REPORT_ORGANIZATION', 'SUBJECT', 'CONTRIBUTOR', 'LANGUAGE', 'SOUNDCLOUD_ID', 'SOUNDCLOUD_ERROR_CODE', 'SOUNDCLOUD_ERROR_MSG', 'SOUNDCLOUD_LINK_TO_FILE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'gunid', 'name', 'mime', 'ftype', 'directory', 'filepath', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'md5', 'track_title', 'artist_name', 'bit_rate', 'sample_rate', 'format', 'length', 'album_title', 'genre', 'comments', 'year', 'track_number', 'channels', 'url', 'bpm', 'rating', 'encoded_by', 'disc_number', 'mood', 'label', 'composer', 'encoder', 'checksum', 'lyrics', 'orchestra', 'conductor', 'lyricist', 'original_lyricist', 'radio_station_name', 'info_url', 'artist_url', 'audio_source_url', 'radio_station_url', 'buy_this_url', 'isrc_number', 'catalog_number', 'original_artist', 'copyright', 'report_datetime', 'report_location', 'report_organization', 'subject', 'contributor', 'language', 'soundcloud_id', 'soundcloud_error_code', 'soundcloud_error_msg', 'soundcloud_link_to_file', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, ) ); /** @@ -227,12 +239,12 @@ abstract class BaseCcFilesPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbGunid' => 1, 'DbName' => 2, 'DbMime' => 3, 'DbFtype' => 4, 'DbDirectory' => 5, 'DbFilepath' => 6, 'DbState' => 7, 'DbCurrentlyaccessing' => 8, 'DbEditedby' => 9, 'DbMtime' => 10, 'DbMd5' => 11, 'DbTrackTitle' => 12, 'DbArtistName' => 13, 'DbBitRate' => 14, 'DbSampleRate' => 15, 'DbFormat' => 16, 'DbLength' => 17, 'DbAlbumTitle' => 18, 'DbGenre' => 19, 'DbComments' => 20, 'DbYear' => 21, 'DbTrackNumber' => 22, 'DbChannels' => 23, 'DbUrl' => 24, 'DbBpm' => 25, 'DbRating' => 26, 'DbEncodedBy' => 27, 'DbDiscNumber' => 28, 'DbMood' => 29, 'DbLabel' => 30, 'DbComposer' => 31, 'DbEncoder' => 32, 'DbChecksum' => 33, 'DbLyrics' => 34, 'DbOrchestra' => 35, 'DbConductor' => 36, 'DbLyricist' => 37, 'DbOriginalLyricist' => 38, 'DbRadioStationName' => 39, 'DbInfoUrl' => 40, 'DbArtistUrl' => 41, 'DbAudioSourceUrl' => 42, 'DbRadioStationUrl' => 43, 'DbBuyThisUrl' => 44, 'DbIsrcNumber' => 45, 'DbCatalogNumber' => 46, 'DbOriginalArtist' => 47, 'DbCopyright' => 48, 'DbReportDatetime' => 49, 'DbReportLocation' => 50, 'DbReportOrganization' => 51, 'DbSubject' => 52, 'DbContributor' => 53, 'DbLanguage' => 54, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbGunid' => 1, 'dbName' => 2, 'dbMime' => 3, 'dbFtype' => 4, 'dbDirectory' => 5, 'dbFilepath' => 6, 'dbState' => 7, 'dbCurrentlyaccessing' => 8, 'dbEditedby' => 9, 'dbMtime' => 10, 'dbMd5' => 11, 'dbTrackTitle' => 12, 'dbArtistName' => 13, 'dbBitRate' => 14, 'dbSampleRate' => 15, 'dbFormat' => 16, 'dbLength' => 17, 'dbAlbumTitle' => 18, 'dbGenre' => 19, 'dbComments' => 20, 'dbYear' => 21, 'dbTrackNumber' => 22, 'dbChannels' => 23, 'dbUrl' => 24, 'dbBpm' => 25, 'dbRating' => 26, 'dbEncodedBy' => 27, 'dbDiscNumber' => 28, 'dbMood' => 29, 'dbLabel' => 30, 'dbComposer' => 31, 'dbEncoder' => 32, 'dbChecksum' => 33, 'dbLyrics' => 34, 'dbOrchestra' => 35, 'dbConductor' => 36, 'dbLyricist' => 37, 'dbOriginalLyricist' => 38, 'dbRadioStationName' => 39, 'dbInfoUrl' => 40, 'dbArtistUrl' => 41, 'dbAudioSourceUrl' => 42, 'dbRadioStationUrl' => 43, 'dbBuyThisUrl' => 44, 'dbIsrcNumber' => 45, 'dbCatalogNumber' => 46, 'dbOriginalArtist' => 47, 'dbCopyright' => 48, 'dbReportDatetime' => 49, 'dbReportLocation' => 50, 'dbReportOrganization' => 51, 'dbSubject' => 52, 'dbContributor' => 53, 'dbLanguage' => 54, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::GUNID => 1, self::NAME => 2, self::MIME => 3, self::FTYPE => 4, self::DIRECTORY => 5, self::FILEPATH => 6, self::STATE => 7, self::CURRENTLYACCESSING => 8, self::EDITEDBY => 9, self::MTIME => 10, self::MD5 => 11, self::TRACK_TITLE => 12, self::ARTIST_NAME => 13, self::BIT_RATE => 14, self::SAMPLE_RATE => 15, self::FORMAT => 16, self::LENGTH => 17, self::ALBUM_TITLE => 18, self::GENRE => 19, self::COMMENTS => 20, self::YEAR => 21, self::TRACK_NUMBER => 22, self::CHANNELS => 23, self::URL => 24, self::BPM => 25, self::RATING => 26, self::ENCODED_BY => 27, self::DISC_NUMBER => 28, self::MOOD => 29, self::LABEL => 30, self::COMPOSER => 31, self::ENCODER => 32, self::CHECKSUM => 33, self::LYRICS => 34, self::ORCHESTRA => 35, self::CONDUCTOR => 36, self::LYRICIST => 37, self::ORIGINAL_LYRICIST => 38, self::RADIO_STATION_NAME => 39, self::INFO_URL => 40, self::ARTIST_URL => 41, self::AUDIO_SOURCE_URL => 42, self::RADIO_STATION_URL => 43, self::BUY_THIS_URL => 44, self::ISRC_NUMBER => 45, self::CATALOG_NUMBER => 46, self::ORIGINAL_ARTIST => 47, self::COPYRIGHT => 48, self::REPORT_DATETIME => 49, self::REPORT_LOCATION => 50, self::REPORT_ORGANIZATION => 51, self::SUBJECT => 52, self::CONTRIBUTOR => 53, self::LANGUAGE => 54, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GUNID' => 1, 'NAME' => 2, 'MIME' => 3, 'FTYPE' => 4, 'DIRECTORY' => 5, 'FILEPATH' => 6, 'STATE' => 7, 'CURRENTLYACCESSING' => 8, 'EDITEDBY' => 9, 'MTIME' => 10, 'MD5' => 11, 'TRACK_TITLE' => 12, 'ARTIST_NAME' => 13, 'BIT_RATE' => 14, 'SAMPLE_RATE' => 15, 'FORMAT' => 16, 'LENGTH' => 17, 'ALBUM_TITLE' => 18, 'GENRE' => 19, 'COMMENTS' => 20, 'YEAR' => 21, 'TRACK_NUMBER' => 22, 'CHANNELS' => 23, 'URL' => 24, 'BPM' => 25, 'RATING' => 26, 'ENCODED_BY' => 27, 'DISC_NUMBER' => 28, 'MOOD' => 29, 'LABEL' => 30, 'COMPOSER' => 31, 'ENCODER' => 32, 'CHECKSUM' => 33, 'LYRICS' => 34, 'ORCHESTRA' => 35, 'CONDUCTOR' => 36, 'LYRICIST' => 37, 'ORIGINAL_LYRICIST' => 38, 'RADIO_STATION_NAME' => 39, 'INFO_URL' => 40, 'ARTIST_URL' => 41, 'AUDIO_SOURCE_URL' => 42, 'RADIO_STATION_URL' => 43, 'BUY_THIS_URL' => 44, 'ISRC_NUMBER' => 45, 'CATALOG_NUMBER' => 46, 'ORIGINAL_ARTIST' => 47, 'COPYRIGHT' => 48, 'REPORT_DATETIME' => 49, 'REPORT_LOCATION' => 50, 'REPORT_ORGANIZATION' => 51, 'SUBJECT' => 52, 'CONTRIBUTOR' => 53, 'LANGUAGE' => 54, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'gunid' => 1, 'name' => 2, 'mime' => 3, 'ftype' => 4, 'directory' => 5, 'filepath' => 6, 'state' => 7, 'currentlyaccessing' => 8, 'editedby' => 9, 'mtime' => 10, 'md5' => 11, 'track_title' => 12, 'artist_name' => 13, 'bit_rate' => 14, 'sample_rate' => 15, 'format' => 16, 'length' => 17, 'album_title' => 18, 'genre' => 19, 'comments' => 20, 'year' => 21, 'track_number' => 22, 'channels' => 23, 'url' => 24, 'bpm' => 25, 'rating' => 26, 'encoded_by' => 27, 'disc_number' => 28, 'mood' => 29, 'label' => 30, 'composer' => 31, 'encoder' => 32, 'checksum' => 33, 'lyrics' => 34, 'orchestra' => 35, 'conductor' => 36, 'lyricist' => 37, 'original_lyricist' => 38, 'radio_station_name' => 39, 'info_url' => 40, 'artist_url' => 41, 'audio_source_url' => 42, 'radio_station_url' => 43, 'buy_this_url' => 44, 'isrc_number' => 45, 'catalog_number' => 46, 'original_artist' => 47, 'copyright' => 48, 'report_datetime' => 49, 'report_location' => 50, 'report_organization' => 51, 'subject' => 52, 'contributor' => 53, 'language' => 54, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbGunid' => 1, 'DbName' => 2, 'DbMime' => 3, 'DbFtype' => 4, 'DbDirectory' => 5, 'DbFilepath' => 6, 'DbState' => 7, 'DbCurrentlyaccessing' => 8, 'DbEditedby' => 9, 'DbMtime' => 10, 'DbMd5' => 11, 'DbTrackTitle' => 12, 'DbArtistName' => 13, 'DbBitRate' => 14, 'DbSampleRate' => 15, 'DbFormat' => 16, 'DbLength' => 17, 'DbAlbumTitle' => 18, 'DbGenre' => 19, 'DbComments' => 20, 'DbYear' => 21, 'DbTrackNumber' => 22, 'DbChannels' => 23, 'DbUrl' => 24, 'DbBpm' => 25, 'DbRating' => 26, 'DbEncodedBy' => 27, 'DbDiscNumber' => 28, 'DbMood' => 29, 'DbLabel' => 30, 'DbComposer' => 31, 'DbEncoder' => 32, 'DbChecksum' => 33, 'DbLyrics' => 34, 'DbOrchestra' => 35, 'DbConductor' => 36, 'DbLyricist' => 37, 'DbOriginalLyricist' => 38, 'DbRadioStationName' => 39, 'DbInfoUrl' => 40, 'DbArtistUrl' => 41, 'DbAudioSourceUrl' => 42, 'DbRadioStationUrl' => 43, 'DbBuyThisUrl' => 44, 'DbIsrcNumber' => 45, 'DbCatalogNumber' => 46, 'DbOriginalArtist' => 47, 'DbCopyright' => 48, 'DbReportDatetime' => 49, 'DbReportLocation' => 50, 'DbReportOrganization' => 51, 'DbSubject' => 52, 'DbContributor' => 53, 'DbLanguage' => 54, 'DbSoundcloudId' => 55, 'DbSoundcloudErrorCode' => 56, 'DbSoundcloudErrorMsg' => 57, 'DbSoundcloudLinkToFile' => 58, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbGunid' => 1, 'dbName' => 2, 'dbMime' => 3, 'dbFtype' => 4, 'dbDirectory' => 5, 'dbFilepath' => 6, 'dbState' => 7, 'dbCurrentlyaccessing' => 8, 'dbEditedby' => 9, 'dbMtime' => 10, 'dbMd5' => 11, 'dbTrackTitle' => 12, 'dbArtistName' => 13, 'dbBitRate' => 14, 'dbSampleRate' => 15, 'dbFormat' => 16, 'dbLength' => 17, 'dbAlbumTitle' => 18, 'dbGenre' => 19, 'dbComments' => 20, 'dbYear' => 21, 'dbTrackNumber' => 22, 'dbChannels' => 23, 'dbUrl' => 24, 'dbBpm' => 25, 'dbRating' => 26, 'dbEncodedBy' => 27, 'dbDiscNumber' => 28, 'dbMood' => 29, 'dbLabel' => 30, 'dbComposer' => 31, 'dbEncoder' => 32, 'dbChecksum' => 33, 'dbLyrics' => 34, 'dbOrchestra' => 35, 'dbConductor' => 36, 'dbLyricist' => 37, 'dbOriginalLyricist' => 38, 'dbRadioStationName' => 39, 'dbInfoUrl' => 40, 'dbArtistUrl' => 41, 'dbAudioSourceUrl' => 42, 'dbRadioStationUrl' => 43, 'dbBuyThisUrl' => 44, 'dbIsrcNumber' => 45, 'dbCatalogNumber' => 46, 'dbOriginalArtist' => 47, 'dbCopyright' => 48, 'dbReportDatetime' => 49, 'dbReportLocation' => 50, 'dbReportOrganization' => 51, 'dbSubject' => 52, 'dbContributor' => 53, 'dbLanguage' => 54, 'dbSoundcloudId' => 55, 'dbSoundcloudErrorCode' => 56, 'dbSoundcloudErrorMsg' => 57, 'dbSoundcloudLinkToFile' => 58, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::GUNID => 1, self::NAME => 2, self::MIME => 3, self::FTYPE => 4, self::DIRECTORY => 5, self::FILEPATH => 6, self::STATE => 7, self::CURRENTLYACCESSING => 8, self::EDITEDBY => 9, self::MTIME => 10, self::MD5 => 11, self::TRACK_TITLE => 12, self::ARTIST_NAME => 13, self::BIT_RATE => 14, self::SAMPLE_RATE => 15, self::FORMAT => 16, self::LENGTH => 17, self::ALBUM_TITLE => 18, self::GENRE => 19, self::COMMENTS => 20, self::YEAR => 21, self::TRACK_NUMBER => 22, self::CHANNELS => 23, self::URL => 24, self::BPM => 25, self::RATING => 26, self::ENCODED_BY => 27, self::DISC_NUMBER => 28, self::MOOD => 29, self::LABEL => 30, self::COMPOSER => 31, self::ENCODER => 32, self::CHECKSUM => 33, self::LYRICS => 34, self::ORCHESTRA => 35, self::CONDUCTOR => 36, self::LYRICIST => 37, self::ORIGINAL_LYRICIST => 38, self::RADIO_STATION_NAME => 39, self::INFO_URL => 40, self::ARTIST_URL => 41, self::AUDIO_SOURCE_URL => 42, self::RADIO_STATION_URL => 43, self::BUY_THIS_URL => 44, self::ISRC_NUMBER => 45, self::CATALOG_NUMBER => 46, self::ORIGINAL_ARTIST => 47, self::COPYRIGHT => 48, self::REPORT_DATETIME => 49, self::REPORT_LOCATION => 50, self::REPORT_ORGANIZATION => 51, self::SUBJECT => 52, self::CONTRIBUTOR => 53, self::LANGUAGE => 54, self::SOUNDCLOUD_ID => 55, self::SOUNDCLOUD_ERROR_CODE => 56, self::SOUNDCLOUD_ERROR_MSG => 57, self::SOUNDCLOUD_LINK_TO_FILE => 58, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GUNID' => 1, 'NAME' => 2, 'MIME' => 3, 'FTYPE' => 4, 'DIRECTORY' => 5, 'FILEPATH' => 6, 'STATE' => 7, 'CURRENTLYACCESSING' => 8, 'EDITEDBY' => 9, 'MTIME' => 10, 'MD5' => 11, 'TRACK_TITLE' => 12, 'ARTIST_NAME' => 13, 'BIT_RATE' => 14, 'SAMPLE_RATE' => 15, 'FORMAT' => 16, 'LENGTH' => 17, 'ALBUM_TITLE' => 18, 'GENRE' => 19, 'COMMENTS' => 20, 'YEAR' => 21, 'TRACK_NUMBER' => 22, 'CHANNELS' => 23, 'URL' => 24, 'BPM' => 25, 'RATING' => 26, 'ENCODED_BY' => 27, 'DISC_NUMBER' => 28, 'MOOD' => 29, 'LABEL' => 30, 'COMPOSER' => 31, 'ENCODER' => 32, 'CHECKSUM' => 33, 'LYRICS' => 34, 'ORCHESTRA' => 35, 'CONDUCTOR' => 36, 'LYRICIST' => 37, 'ORIGINAL_LYRICIST' => 38, 'RADIO_STATION_NAME' => 39, 'INFO_URL' => 40, 'ARTIST_URL' => 41, 'AUDIO_SOURCE_URL' => 42, 'RADIO_STATION_URL' => 43, 'BUY_THIS_URL' => 44, 'ISRC_NUMBER' => 45, 'CATALOG_NUMBER' => 46, 'ORIGINAL_ARTIST' => 47, 'COPYRIGHT' => 48, 'REPORT_DATETIME' => 49, 'REPORT_LOCATION' => 50, 'REPORT_ORGANIZATION' => 51, 'SUBJECT' => 52, 'CONTRIBUTOR' => 53, 'LANGUAGE' => 54, 'SOUNDCLOUD_ID' => 55, 'SOUNDCLOUD_ERROR_CODE' => 56, 'SOUNDCLOUD_ERROR_MSG' => 57, 'SOUNDCLOUD_LINK_TO_FILE' => 58, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'gunid' => 1, 'name' => 2, 'mime' => 3, 'ftype' => 4, 'directory' => 5, 'filepath' => 6, 'state' => 7, 'currentlyaccessing' => 8, 'editedby' => 9, 'mtime' => 10, 'md5' => 11, 'track_title' => 12, 'artist_name' => 13, 'bit_rate' => 14, 'sample_rate' => 15, 'format' => 16, 'length' => 17, 'album_title' => 18, 'genre' => 19, 'comments' => 20, 'year' => 21, 'track_number' => 22, 'channels' => 23, 'url' => 24, 'bpm' => 25, 'rating' => 26, 'encoded_by' => 27, 'disc_number' => 28, 'mood' => 29, 'label' => 30, 'composer' => 31, 'encoder' => 32, 'checksum' => 33, 'lyrics' => 34, 'orchestra' => 35, 'conductor' => 36, 'lyricist' => 37, 'original_lyricist' => 38, 'radio_station_name' => 39, 'info_url' => 40, 'artist_url' => 41, 'audio_source_url' => 42, 'radio_station_url' => 43, 'buy_this_url' => 44, 'isrc_number' => 45, 'catalog_number' => 46, 'original_artist' => 47, 'copyright' => 48, 'report_datetime' => 49, 'report_location' => 50, 'report_organization' => 51, 'subject' => 52, 'contributor' => 53, 'language' => 54, 'soundcloud_id' => 55, 'soundcloud_error_code' => 56, 'soundcloud_error_msg' => 57, 'soundcloud_link_to_file' => 58, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, ) ); /** @@ -359,6 +371,10 @@ abstract class BaseCcFilesPeer { $criteria->addSelectColumn(CcFilesPeer::SUBJECT); $criteria->addSelectColumn(CcFilesPeer::CONTRIBUTOR); $criteria->addSelectColumn(CcFilesPeer::LANGUAGE); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ID); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ERROR_CODE); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ERROR_MSG); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.GUNID'); @@ -415,6 +431,10 @@ abstract class BaseCcFilesPeer { $criteria->addSelectColumn($alias . '.SUBJECT'); $criteria->addSelectColumn($alias . '.CONTRIBUTOR'); $criteria->addSelectColumn($alias . '.LANGUAGE'); + $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ID'); + $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ERROR_CODE'); + $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ERROR_MSG'); + $criteria->addSelectColumn($alias . '.SOUNDCLOUD_LINK_TO_FILE'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php index 195f6a245..36c5f71ed 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php @@ -61,6 +61,10 @@ * @method CcFilesQuery orderByDbSubject($order = Criteria::ASC) Order by the subject column * @method CcFilesQuery orderByDbContributor($order = Criteria::ASC) Order by the contributor column * @method CcFilesQuery orderByDbLanguage($order = Criteria::ASC) Order by the language column + * @method CcFilesQuery orderByDbSoundcloudId($order = Criteria::ASC) Order by the soundcloud_id column + * @method CcFilesQuery orderByDbSoundcloudErrorCode($order = Criteria::ASC) Order by the soundcloud_error_code column + * @method CcFilesQuery orderByDbSoundcloudErrorMsg($order = Criteria::ASC) Order by the soundcloud_error_msg column + * @method CcFilesQuery orderByDbSoundcloudLinkToFile($order = Criteria::ASC) Order by the soundcloud_link_to_file column * * @method CcFilesQuery groupByDbId() Group by the id column * @method CcFilesQuery groupByDbGunid() Group by the gunid column @@ -117,6 +121,10 @@ * @method CcFilesQuery groupByDbSubject() Group by the subject column * @method CcFilesQuery groupByDbContributor() Group by the contributor column * @method CcFilesQuery groupByDbLanguage() Group by the language column + * @method CcFilesQuery groupByDbSoundcloudId() Group by the soundcloud_id column + * @method CcFilesQuery groupByDbSoundcloudErrorCode() Group by the soundcloud_error_code column + * @method CcFilesQuery groupByDbSoundcloudErrorMsg() Group by the soundcloud_error_msg column + * @method CcFilesQuery groupByDbSoundcloudLinkToFile() Group by the soundcloud_link_to_file column * * @method CcFilesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcFilesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -200,6 +208,10 @@ * @method CcFiles findOneByDbSubject(string $subject) Return the first CcFiles filtered by the subject column * @method CcFiles findOneByDbContributor(string $contributor) Return the first CcFiles filtered by the contributor column * @method CcFiles findOneByDbLanguage(string $language) Return the first CcFiles filtered by the language column + * @method CcFiles findOneByDbSoundcloudId(int $soundcloud_id) Return the first CcFiles filtered by the soundcloud_id column + * @method CcFiles findOneByDbSoundcloudErrorCode(int $soundcloud_error_code) Return the first CcFiles filtered by the soundcloud_error_code column + * @method CcFiles findOneByDbSoundcloudErrorMsg(string $soundcloud_error_msg) Return the first CcFiles filtered by the soundcloud_error_msg column + * @method CcFiles findOneByDbSoundcloudLinkToFile(string $soundcloud_link_to_file) Return the first CcFiles filtered by the soundcloud_link_to_file column * * @method array findByDbId(int $id) Return CcFiles objects filtered by the id column * @method array findByDbGunid(string $gunid) Return CcFiles objects filtered by the gunid column @@ -256,6 +268,10 @@ * @method array findByDbSubject(string $subject) Return CcFiles objects filtered by the subject column * @method array findByDbContributor(string $contributor) Return CcFiles objects filtered by the contributor column * @method array findByDbLanguage(string $language) Return CcFiles objects filtered by the language column + * @method array findByDbSoundcloudId(int $soundcloud_id) Return CcFiles objects filtered by the soundcloud_id column + * @method array findByDbSoundcloudErrorCode(int $soundcloud_error_code) Return CcFiles objects filtered by the soundcloud_error_code column + * @method array findByDbSoundcloudErrorMsg(string $soundcloud_error_msg) Return CcFiles objects filtered by the soundcloud_error_msg column + * @method array findByDbSoundcloudLinkToFile(string $soundcloud_link_to_file) Return CcFiles objects filtered by the soundcloud_link_to_file column * * @package propel.generator.airtime.om */ @@ -1633,6 +1649,112 @@ abstract class BaseCcFilesQuery extends ModelCriteria return $this->addUsingAlias(CcFilesPeer::LANGUAGE, $dbLanguage, $comparison); } + /** + * Filter the query on the soundcloud_id column + * + * @param int|array $dbSoundcloudId The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundcloudId($dbSoundcloudId = null, $comparison = null) + { + if (is_array($dbSoundcloudId)) { + $useMinMax = false; + if (isset($dbSoundcloudId['min'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSoundcloudId['max'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId, $comparison); + } + + /** + * Filter the query on the soundcloud_error_code column + * + * @param int|array $dbSoundcloudErrorCode The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundcloudErrorCode($dbSoundcloudErrorCode = null, $comparison = null) + { + if (is_array($dbSoundcloudErrorCode)) { + $useMinMax = false; + if (isset($dbSoundcloudErrorCode['min'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSoundcloudErrorCode['max'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode, $comparison); + } + + /** + * Filter the query on the soundcloud_error_msg column + * + * @param string $dbSoundcloudErrorMsg 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundcloudErrorMsg($dbSoundcloudErrorMsg = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbSoundcloudErrorMsg)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbSoundcloudErrorMsg)) { + $dbSoundcloudErrorMsg = str_replace('*', '%', $dbSoundcloudErrorMsg); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_MSG, $dbSoundcloudErrorMsg, $comparison); + } + + /** + * Filter the query on the soundcloud_link_to_file column + * + * @param string $dbSoundcloudLinkToFile 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 CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundcloudLinkToFile($dbSoundcloudLinkToFile = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbSoundcloudLinkToFile)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbSoundcloudLinkToFile)) { + $dbSoundcloudLinkToFile = str_replace('*', '%', $dbSoundcloudLinkToFile); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, $dbSoundcloudLinkToFile, $comparison); + } + /** * Filter the query by a related CcSubjs object * diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php new file mode 100644 index 000000000..b529e12d5 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php @@ -0,0 +1,735 @@ +attempts = 0; + } + + /** + * Initializes internal state of BaseCcLoginAttempts object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [ip] column value. + * + * @return string + */ + public function getDbIP() + { + return $this->ip; + } + + /** + * Get the [attempts] column value. + * + * @return int + */ + public function getDbAttempts() + { + return $this->attempts; + } + + /** + * Set the value of [ip] column. + * + * @param string $v new value + * @return CcLoginAttempts The current object (for fluent API support) + */ + public function setDbIP($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ip !== $v) { + $this->ip = $v; + $this->modifiedColumns[] = CcLoginAttemptsPeer::IP; + } + + return $this; + } // setDbIP() + + /** + * Set the value of [attempts] column. + * + * @param int $v new value + * @return CcLoginAttempts The current object (for fluent API support) + */ + public function setDbAttempts($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->attempts !== $v || $this->isNew()) { + $this->attempts = $v; + $this->modifiedColumns[] = CcLoginAttemptsPeer::ATTEMPTS; + } + + return $this; + } // setDbAttempts() + + /** + * 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() + { + if ($this->attempts !== 0) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false) + { + try { + + $this->ip = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->attempts = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 2; // 2 = CcLoginAttemptsPeer::NUM_COLUMNS - CcLoginAttemptsPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcLoginAttempts 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() + { + + } // 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(CcLoginAttemptsPeer::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 = CcLoginAttemptsPeer::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? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcLoginAttemptsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()) + ->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::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); + CcLoginAttemptsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(PropelPDO $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcLoginAttemptsPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcLoginAttemptsPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLoginAttemptsPeer::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->getDbIP(); + break; + case 1: + return $this->getDbAttempts(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcLoginAttemptsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbIP(), + $keys[1] => $this->getDbAttempts(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLoginAttemptsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setDbIP($value); + break; + case 1: + $this->setDbAttempts($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. + * The default key type is the column's phpname (e.g. 'AuthorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = CcLoginAttemptsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbIP($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbAttempts($arr[$keys[1]]); + } + + /** + * 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(CcLoginAttemptsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcLoginAttemptsPeer::IP)) $criteria->add(CcLoginAttemptsPeer::IP, $this->ip); + if ($this->isColumnModified(CcLoginAttemptsPeer::ATTEMPTS)) $criteria->add(CcLoginAttemptsPeer::ATTEMPTS, $this->attempts); + + 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(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, $this->ip); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbIP(); + } + + /** + * Generic method to set the primary key (ip column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbIP($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getDbIP(); + } + + /** + * 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 CcLoginAttempts (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + $copyObj->setDbIP($this->ip); + $copyObj->setDbAttempts($this->attempts); + + $copyObj->setNew(true); + } + + /** + * 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 CcLoginAttempts 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 CcLoginAttemptsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcLoginAttemptsPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->ip = null; + $this->attempts = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all collections of referencing foreign keys. + * + * This method is a user-space workaround for PHP's inability to garbage collect objects + * with circular references. This is currently necessary when using Propel in certain + * daemon or large-volumne/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all associated objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Catches calls to virtual methods + */ + public function __call($name, $params) + { + if (preg_match('/get(\w+)/', $name, $matches)) { + $virtualColumn = $matches[1]; + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + // no lcfirst in php<5.3... + $virtualColumn[0] = strtolower($virtualColumn[0]); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + throw new PropelException('Call to undefined method: ' . $name); + } + +} // BaseCcLoginAttempts diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php new file mode 100644 index 000000000..27b4cd90c --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php @@ -0,0 +1,735 @@ + array ('DbIP', 'DbAttempts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbIP', 'dbAttempts', ), + BasePeer::TYPE_COLNAME => array (self::IP, self::ATTEMPTS, ), + BasePeer::TYPE_RAW_COLNAME => array ('IP', 'ATTEMPTS', ), + BasePeer::TYPE_FIELDNAME => array ('ip', 'attempts', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbIP' => 0, 'DbAttempts' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbIP' => 0, 'dbAttempts' => 1, ), + BasePeer::TYPE_COLNAME => array (self::IP => 0, self::ATTEMPTS => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('IP' => 0, 'ATTEMPTS' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('ip' => 0, 'attempts' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + * @throws PropelException - if the specified name could not be found in the fieldname mappings. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. CcLoginAttemptsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::IP); + $criteria->addSelectColumn(CcLoginAttemptsPeer::ATTEMPTS); + } else { + $criteria->addSelectColumn($alias . '.IP'); + $criteria->addSelectColumn($alias . '.ATTEMPTS'); + } + } + + /** + * 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(CcLoginAttemptsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcLoginAttemptsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + // BasePeer returns a PDOStatement + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcLoginAttempts + * @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 = CcLoginAttemptsPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, PropelPDO $con = null) + { + return CcLoginAttemptsPeer::populateObjects(CcLoginAttemptsPeer::doSelectStmt($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. + * + * Use this method directly if you want to work with an executed statement durirectly (for example + * to perform your own object hydration). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con The connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return PDOStatement The executed PDOStatement object. + * @see BasePeer::doSelect() + */ + public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcLoginAttemptsPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a PDOStatement + return BasePeer::doSelect($criteria, $con); + } + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doSelect*() + * methods in your stub classes -- you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by doSelect*() + * and retrieveByPK*() calls. + * + * @param CcLoginAttempts $value A CcLoginAttempts object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcLoginAttempts $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbIP(); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A CcLoginAttempts object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcLoginAttempts) { + $key = (string) $value->getDbIP(); + } 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 CcLoginAttempts object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } // removeInstanceFromPool() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param string $key The key (@see getPrimaryKeyHash()) for this instance. + * @return CcLoginAttempts Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled. + * @see getPrimaryKeyHash() + */ + public static function getInstanceFromPool($key) + { + if (Propel::isInstancePoolingEnabled()) { + if (isset(self::$instances[$key])) { + return self::$instances[$key]; + } + } + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool() + { + self::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_login_attempts + * 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 (string) $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 = CcLoginAttemptsPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcLoginAttemptsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcLoginAttemptsPeer::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; + CcLoginAttemptsPeer::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 (CcLoginAttempts object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcLoginAttemptsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcLoginAttemptsPeer::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 + CcLoginAttemptsPeer::NUM_COLUMNS; + } else { + $cls = CcLoginAttemptsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcLoginAttemptsPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcLoginAttemptsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcLoginAttemptsPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcLoginAttemptsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CcLoginAttemptsPeer::CLASS_DEFAULT : CcLoginAttemptsPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcLoginAttempts or Criteria object. + * + * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcLoginAttempts object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a CcLoginAttempts or Criteria object. + * + * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcLoginAttemptsPeer::IP); + $value = $criteria->remove(CcLoginAttemptsPeer::IP); + if ($value) { + $selectCriteria->add(CcLoginAttemptsPeer::IP, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcLoginAttemptsPeer::TABLE_NAME); + } + + } else { // $values is CcLoginAttempts object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the cc_login_attempts table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::TABLE_NAME, $con, CcLoginAttemptsPeer::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). + CcLoginAttemptsPeer::clearInstancePool(); + CcLoginAttemptsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcLoginAttempts or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::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. + CcLoginAttemptsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcLoginAttempts) { // it's a model object + // invalidate the cache for this single object + CcLoginAttemptsPeer::removeInstanceFromPool($values); + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcLoginAttemptsPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + CcLoginAttemptsPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcLoginAttempts 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 CcLoginAttempts $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(CcLoginAttempts $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcLoginAttemptsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcLoginAttemptsPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcLoginAttemptsPeer::DATABASE_NAME, CcLoginAttemptsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcLoginAttempts + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcLoginAttemptsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, $pk); + + $v = CcLoginAttemptsPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param PropelPDO $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, $pks, Criteria::IN); + $objs = CcLoginAttemptsPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcLoginAttemptsPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcLoginAttemptsPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php new file mode 100644 index 000000000..930f32eda --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php @@ -0,0 +1,205 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + return $query; + } + + /** + * Find object by primary key + * Use instance pooling to avoid a database query if the object exists + * + * $obj = $c->findPk(12, $con); + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcLoginAttempts|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcLoginAttemptsPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { + // the object is alredy in the instance pool + return $obj; + } else { + // the object has not been requested yet, or the formatter is not an object formatter + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->getSelectStatement($con); + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param PropelPDO $con an optional connection object + * + * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + $criteria = $this->isKeepQuery() ? clone $this : $this; + return $this + ->filterByPrimaryKeys($keys) + ->find($con); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $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 CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $keys, Criteria::IN); + } + + /** + * Filter the query on the ip column + * + * @param string $dbIP 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 CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByDbIP($dbIP = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbIP)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbIP)) { + $dbIP = str_replace('*', '%', $dbIP); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $dbIP, $comparison); + } + + /** + * Filter the query on the attempts column + * + * @param int|array $dbAttempts The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByDbAttempts($dbAttempts = null, $comparison = null) + { + if (is_array($dbAttempts)) { + $useMinMax = false; + if (isset($dbAttempts['min'])) { + $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbAttempts['max'])) { + $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts, $comparison); + } + + /** + * Exclude object from result + * + * @param CcLoginAttempts $ccLoginAttempts Object to remove from the list of results + * + * @return CcLoginAttemptsQuery The current query, for fluid interface + */ + public function prune($ccLoginAttempts = null) + { + if ($ccLoginAttempts) { + $this->addUsingAlias(CcLoginAttemptsPeer::IP, $ccLoginAttempts->getDbIP(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcLoginAttemptsQuery diff --git a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php new file mode 100644 index 000000000..dbb3aa6a2 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php @@ -0,0 +1,708 @@ +name; + } + + /** + * Get the [ip] column value. + * + * @return string + */ + public function getDbIp() + { + return $this->ip; + } + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcServiceRegister The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcServiceRegisterPeer::NAME; + } + + return $this; + } // setDbName() + + /** + * Set the value of [ip] column. + * + * @param string $v new value + * @return CcServiceRegister The current object (for fluent API support) + */ + public function setDbIp($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ip !== $v) { + $this->ip = $v; + $this->modifiedColumns[] = CcServiceRegisterPeer::IP; + } + + return $this; + } // setDbIp() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false) + { + try { + + $this->name = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->ip = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 2; // 2 = CcServiceRegisterPeer::NUM_COLUMNS - CcServiceRegisterPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcServiceRegister 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() + { + + } // 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(CcServiceRegisterPeer::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 = CcServiceRegisterPeer::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? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcServiceRegisterQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()) + ->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::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); + CcServiceRegisterPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(PropelPDO $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcServiceRegisterPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcServiceRegisterPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcServiceRegisterPeer::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->getDbName(); + break; + case 1: + return $this->getDbIp(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcServiceRegisterPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbName(), + $keys[1] => $this->getDbIp(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcServiceRegisterPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setDbName($value); + break; + case 1: + $this->setDbIp($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. + * The default key type is the column's phpname (e.g. 'AuthorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = CcServiceRegisterPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbName($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbIp($arr[$keys[1]]); + } + + /** + * 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(CcServiceRegisterPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcServiceRegisterPeer::NAME)) $criteria->add(CcServiceRegisterPeer::NAME, $this->name); + if ($this->isColumnModified(CcServiceRegisterPeer::IP)) $criteria->add(CcServiceRegisterPeer::IP, $this->ip); + + 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(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, $this->name); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbName(); + } + + /** + * Generic method to set the primary key (name column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbName($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getDbName(); + } + + /** + * 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 CcServiceRegister (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + $copyObj->setDbName($this->name); + $copyObj->setDbIp($this->ip); + + $copyObj->setNew(true); + } + + /** + * 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 CcServiceRegister 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 CcServiceRegisterPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcServiceRegisterPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->name = null; + $this->ip = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all collections of referencing foreign keys. + * + * This method is a user-space workaround for PHP's inability to garbage collect objects + * with circular references. This is currently necessary when using Propel in certain + * daemon or large-volumne/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all associated objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Catches calls to virtual methods + */ + public function __call($name, $params) + { + if (preg_match('/get(\w+)/', $name, $matches)) { + $virtualColumn = $matches[1]; + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + // no lcfirst in php<5.3... + $virtualColumn[0] = strtolower($virtualColumn[0]); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + throw new PropelException('Call to undefined method: ' . $name); + } + +} // BaseCcServiceRegister diff --git a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php new file mode 100644 index 000000000..ab7d35634 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php @@ -0,0 +1,735 @@ + array ('DbName', 'DbIp', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbName', 'dbIp', ), + BasePeer::TYPE_COLNAME => array (self::NAME, self::IP, ), + BasePeer::TYPE_RAW_COLNAME => array ('NAME', 'IP', ), + BasePeer::TYPE_FIELDNAME => array ('name', 'ip', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbName' => 0, 'DbIp' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbName' => 0, 'dbIp' => 1, ), + BasePeer::TYPE_COLNAME => array (self::NAME => 0, self::IP => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('NAME' => 0, 'IP' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('name' => 0, 'ip' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + * @throws PropelException - if the specified name could not be found in the fieldname mappings. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. CcServiceRegisterPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcServiceRegisterPeer::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(CcServiceRegisterPeer::NAME); + $criteria->addSelectColumn(CcServiceRegisterPeer::IP); + } else { + $criteria->addSelectColumn($alias . '.NAME'); + $criteria->addSelectColumn($alias . '.IP'); + } + } + + /** + * 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(CcServiceRegisterPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcServiceRegisterPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + // BasePeer returns a PDOStatement + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcServiceRegister + * @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 = CcServiceRegisterPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, PropelPDO $con = null) + { + return CcServiceRegisterPeer::populateObjects(CcServiceRegisterPeer::doSelectStmt($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. + * + * Use this method directly if you want to work with an executed statement durirectly (for example + * to perform your own object hydration). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con The connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return PDOStatement The executed PDOStatement object. + * @see BasePeer::doSelect() + */ + public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcServiceRegisterPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a PDOStatement + return BasePeer::doSelect($criteria, $con); + } + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doSelect*() + * methods in your stub classes -- you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by doSelect*() + * and retrieveByPK*() calls. + * + * @param CcServiceRegister $value A CcServiceRegister object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcServiceRegister $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbName(); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A CcServiceRegister object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcServiceRegister) { + $key = (string) $value->getDbName(); + } 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 CcServiceRegister object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } // removeInstanceFromPool() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param string $key The key (@see getPrimaryKeyHash()) for this instance. + * @return CcServiceRegister Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled. + * @see getPrimaryKeyHash() + */ + public static function getInstanceFromPool($key) + { + if (Propel::isInstancePoolingEnabled()) { + if (isset(self::$instances[$key])) { + return self::$instances[$key]; + } + } + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool() + { + self::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_service_register + * 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 (string) $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 = CcServiceRegisterPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcServiceRegisterPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcServiceRegisterPeer::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; + CcServiceRegisterPeer::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 (CcServiceRegister object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcServiceRegisterPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcServiceRegisterPeer::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 + CcServiceRegisterPeer::NUM_COLUMNS; + } else { + $cls = CcServiceRegisterPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcServiceRegisterPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcServiceRegisterPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcServiceRegisterPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcServiceRegisterTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CcServiceRegisterPeer::CLASS_DEFAULT : CcServiceRegisterPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcServiceRegister or Criteria object. + * + * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcServiceRegister object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a CcServiceRegister or Criteria object. + * + * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcServiceRegisterPeer::NAME); + $value = $criteria->remove(CcServiceRegisterPeer::NAME); + if ($value) { + $selectCriteria->add(CcServiceRegisterPeer::NAME, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcServiceRegisterPeer::TABLE_NAME); + } + + } else { // $values is CcServiceRegister object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the cc_service_register table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::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(CcServiceRegisterPeer::TABLE_NAME, $con, CcServiceRegisterPeer::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). + CcServiceRegisterPeer::clearInstancePool(); + CcServiceRegisterPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcServiceRegister or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::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. + CcServiceRegisterPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcServiceRegister) { // it's a model object + // invalidate the cache for this single object + CcServiceRegisterPeer::removeInstanceFromPool($values); + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcServiceRegisterPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + CcServiceRegisterPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcServiceRegister 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 CcServiceRegister $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(CcServiceRegister $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcServiceRegisterPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcServiceRegisterPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcServiceRegisterPeer::DATABASE_NAME, CcServiceRegisterPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcServiceRegister + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcServiceRegisterPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, $pk); + + $v = CcServiceRegisterPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param PropelPDO $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, $pks, Criteria::IN); + $objs = CcServiceRegisterPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcServiceRegisterPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcServiceRegisterPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php new file mode 100644 index 000000000..a8df529a7 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php @@ -0,0 +1,196 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + return $query; + } + + /** + * Find object by primary key + * Use instance pooling to avoid a database query if the object exists + * + * $obj = $c->findPk(12, $con); + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcServiceRegister|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcServiceRegisterPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { + // the object is alredy in the instance pool + return $obj; + } else { + // the object has not been requested yet, or the formatter is not an object formatter + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->getSelectStatement($con); + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param PropelPDO $con an optional connection object + * + * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + $criteria = $this->isKeepQuery() ? clone $this : $this; + return $this + ->filterByPrimaryKeys($keys) + ->find($con); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcServiceRegisterQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcServiceRegisterPeer::NAME, $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 CcServiceRegisterQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcServiceRegisterPeer::NAME, $keys, Criteria::IN); + } + + /** + * Filter the query on the name column + * + * @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 CcServiceRegisterQuery 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(CcServiceRegisterPeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the ip column + * + * @param string $dbIp 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 CcServiceRegisterQuery The current query, for fluid interface + */ + public function filterByDbIp($dbIp = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbIp)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbIp)) { + $dbIp = str_replace('*', '%', $dbIp); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcServiceRegisterPeer::IP, $dbIp, $comparison); + } + + /** + * Exclude object from result + * + * @param CcServiceRegister $ccServiceRegister Object to remove from the list of results + * + * @return CcServiceRegisterQuery The current query, for fluid interface + */ + public function prune($ccServiceRegister = null) + { + if ($ccServiceRegister) { + $this->addUsingAlias(CcServiceRegisterPeer::NAME, $ccServiceRegister->getDbName(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcServiceRegisterQuery diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php b/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php index 3a2d48f37..be9f66086 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php @@ -48,6 +48,12 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent */ protected $start_time; + /** + * The value for the timezone field. + * @var string + */ + protected $timezone; + /** * The value for the duration field. * @var string @@ -234,6 +240,16 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent } } + /** + * Get the [timezone] column value. + * + * @return string + */ + public function getDbTimezone() + { + return $this->timezone; + } + /** * Get the [duration] column value. * @@ -484,6 +500,26 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent return $this; } // setDbStartTime() + /** + * Set the value of [timezone] column. + * + * @param string $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbTimezone($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->timezone !== $v) { + $this->timezone = $v; + $this->modifiedColumns[] = CcShowDaysPeer::TIMEZONE; + } + + return $this; + } // setDbTimezone() + /** * Set the value of [duration] column. * @@ -677,12 +713,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->first_show = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->last_show = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->start_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->duration = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->day = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->repeat_type = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->next_pop_date = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->show_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; - $this->record = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; + $this->timezone = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->duration = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->day = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->repeat_type = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->next_pop_date = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; + $this->record = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null; $this->resetModified(); $this->setNew(false); @@ -691,7 +728,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 10; // 10 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 11; // 11 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShowDays object", $e); @@ -1031,21 +1068,24 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent return $this->getDbStartTime(); break; case 4: - return $this->getDbDuration(); + return $this->getDbTimezone(); break; case 5: - return $this->getDbDay(); + return $this->getDbDuration(); break; case 6: - return $this->getDbRepeatType(); + return $this->getDbDay(); break; case 7: - return $this->getDbNextPopDate(); + return $this->getDbRepeatType(); break; case 8: - return $this->getDbShowId(); + return $this->getDbNextPopDate(); break; case 9: + return $this->getDbShowId(); + break; + case 10: return $this->getDbRecord(); break; default: @@ -1076,12 +1116,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $keys[1] => $this->getDbFirstShow(), $keys[2] => $this->getDbLastShow(), $keys[3] => $this->getDbStartTime(), - $keys[4] => $this->getDbDuration(), - $keys[5] => $this->getDbDay(), - $keys[6] => $this->getDbRepeatType(), - $keys[7] => $this->getDbNextPopDate(), - $keys[8] => $this->getDbShowId(), - $keys[9] => $this->getDbRecord(), + $keys[4] => $this->getDbTimezone(), + $keys[5] => $this->getDbDuration(), + $keys[6] => $this->getDbDay(), + $keys[7] => $this->getDbRepeatType(), + $keys[8] => $this->getDbNextPopDate(), + $keys[9] => $this->getDbShowId(), + $keys[10] => $this->getDbRecord(), ); if ($includeForeignObjects) { if (null !== $this->aCcShow) { @@ -1131,21 +1172,24 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->setDbStartTime($value); break; case 4: - $this->setDbDuration($value); + $this->setDbTimezone($value); break; case 5: - $this->setDbDay($value); + $this->setDbDuration($value); break; case 6: - $this->setDbRepeatType($value); + $this->setDbDay($value); break; case 7: - $this->setDbNextPopDate($value); + $this->setDbRepeatType($value); break; case 8: - $this->setDbShowId($value); + $this->setDbNextPopDate($value); break; case 9: + $this->setDbShowId($value); + break; + case 10: $this->setDbRecord($value); break; } // switch() @@ -1176,12 +1220,13 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent if (array_key_exists($keys[1], $arr)) $this->setDbFirstShow($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setDbLastShow($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setDbStartTime($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbDuration($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbDay($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbRepeatType($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbNextPopDate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbShowId($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbRecord($arr[$keys[9]]); + if (array_key_exists($keys[4], $arr)) $this->setDbTimezone($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbDuration($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbDay($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbRepeatType($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbNextPopDate($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbRecord($arr[$keys[10]]); } /** @@ -1197,6 +1242,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent if ($this->isColumnModified(CcShowDaysPeer::FIRST_SHOW)) $criteria->add(CcShowDaysPeer::FIRST_SHOW, $this->first_show); if ($this->isColumnModified(CcShowDaysPeer::LAST_SHOW)) $criteria->add(CcShowDaysPeer::LAST_SHOW, $this->last_show); if ($this->isColumnModified(CcShowDaysPeer::START_TIME)) $criteria->add(CcShowDaysPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcShowDaysPeer::TIMEZONE)) $criteria->add(CcShowDaysPeer::TIMEZONE, $this->timezone); if ($this->isColumnModified(CcShowDaysPeer::DURATION)) $criteria->add(CcShowDaysPeer::DURATION, $this->duration); if ($this->isColumnModified(CcShowDaysPeer::DAY)) $criteria->add(CcShowDaysPeer::DAY, $this->day); if ($this->isColumnModified(CcShowDaysPeer::REPEAT_TYPE)) $criteria->add(CcShowDaysPeer::REPEAT_TYPE, $this->repeat_type); @@ -1267,6 +1313,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $copyObj->setDbFirstShow($this->first_show); $copyObj->setDbLastShow($this->last_show); $copyObj->setDbStartTime($this->start_time); + $copyObj->setDbTimezone($this->timezone); $copyObj->setDbDuration($this->duration); $copyObj->setDbDay($this->day); $copyObj->setDbRepeatType($this->repeat_type); @@ -1374,6 +1421,7 @@ abstract class BaseCcShowDays extends BaseObject implements Persistent $this->first_show = null; $this->last_show = null; $this->start_time = null; + $this->timezone = null; $this->duration = null; $this->day = null; $this->repeat_type = null; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php index fadf97576..df6b9081d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowDaysPeer { const TM_CLASS = 'CcShowDaysTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 11; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -43,6 +43,9 @@ abstract class BaseCcShowDaysPeer { /** the column name for the START_TIME field */ const START_TIME = 'cc_show_days.START_TIME'; + /** the column name for the TIMEZONE field */ + const TIMEZONE = 'cc_show_days.TIMEZONE'; + /** the column name for the DURATION field */ const DURATION = 'cc_show_days.DURATION'; @@ -77,12 +80,12 @@ abstract class BaseCcShowDaysPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, self::RECORD, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbTimezone', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbTimezone', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::TIMEZONE, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, self::RECORD, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'TIMEZONE', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'timezone', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -92,12 +95,12 @@ abstract class BaseCcShowDaysPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbDuration' => 4, 'DbDay' => 5, 'DbRepeatType' => 6, 'DbNextPopDate' => 7, 'DbShowId' => 8, 'DbRecord' => 9, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbDuration' => 4, 'dbDay' => 5, 'dbRepeatType' => 6, 'dbNextPopDate' => 7, 'dbShowId' => 8, 'dbRecord' => 9, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::DURATION => 4, self::DAY => 5, self::REPEAT_TYPE => 6, self::NEXT_POP_DATE => 7, self::SHOW_ID => 8, self::RECORD => 9, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'DURATION' => 4, 'DAY' => 5, 'REPEAT_TYPE' => 6, 'NEXT_POP_DATE' => 7, 'SHOW_ID' => 8, 'RECORD' => 9, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'duration' => 4, 'day' => 5, 'repeat_type' => 6, 'next_pop_date' => 7, 'show_id' => 8, 'record' => 9, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbTimezone' => 4, 'DbDuration' => 5, 'DbDay' => 6, 'DbRepeatType' => 7, 'DbNextPopDate' => 8, 'DbShowId' => 9, 'DbRecord' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbTimezone' => 4, 'dbDuration' => 5, 'dbDay' => 6, 'dbRepeatType' => 7, 'dbNextPopDate' => 8, 'dbShowId' => 9, 'dbRecord' => 10, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::TIMEZONE => 4, self::DURATION => 5, self::DAY => 6, self::REPEAT_TYPE => 7, self::NEXT_POP_DATE => 8, self::SHOW_ID => 9, self::RECORD => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'TIMEZONE' => 4, 'DURATION' => 5, 'DAY' => 6, 'REPEAT_TYPE' => 7, 'NEXT_POP_DATE' => 8, 'SHOW_ID' => 9, 'RECORD' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'timezone' => 4, 'duration' => 5, 'day' => 6, 'repeat_type' => 7, 'next_pop_date' => 8, 'show_id' => 9, 'record' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -173,6 +176,7 @@ abstract class BaseCcShowDaysPeer { $criteria->addSelectColumn(CcShowDaysPeer::FIRST_SHOW); $criteria->addSelectColumn(CcShowDaysPeer::LAST_SHOW); $criteria->addSelectColumn(CcShowDaysPeer::START_TIME); + $criteria->addSelectColumn(CcShowDaysPeer::TIMEZONE); $criteria->addSelectColumn(CcShowDaysPeer::DURATION); $criteria->addSelectColumn(CcShowDaysPeer::DAY); $criteria->addSelectColumn(CcShowDaysPeer::REPEAT_TYPE); @@ -184,6 +188,7 @@ abstract class BaseCcShowDaysPeer { $criteria->addSelectColumn($alias . '.FIRST_SHOW'); $criteria->addSelectColumn($alias . '.LAST_SHOW'); $criteria->addSelectColumn($alias . '.START_TIME'); + $criteria->addSelectColumn($alias . '.TIMEZONE'); $criteria->addSelectColumn($alias . '.DURATION'); $criteria->addSelectColumn($alias . '.DAY'); $criteria->addSelectColumn($alias . '.REPEAT_TYPE'); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php index 9df957145..18653bd70 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php @@ -10,6 +10,7 @@ * @method CcShowDaysQuery orderByDbFirstShow($order = Criteria::ASC) Order by the first_show column * @method CcShowDaysQuery orderByDbLastShow($order = Criteria::ASC) Order by the last_show column * @method CcShowDaysQuery orderByDbStartTime($order = Criteria::ASC) Order by the start_time column + * @method CcShowDaysQuery orderByDbTimezone($order = Criteria::ASC) Order by the timezone column * @method CcShowDaysQuery orderByDbDuration($order = Criteria::ASC) Order by the duration column * @method CcShowDaysQuery orderByDbDay($order = Criteria::ASC) Order by the day column * @method CcShowDaysQuery orderByDbRepeatType($order = Criteria::ASC) Order by the repeat_type column @@ -21,6 +22,7 @@ * @method CcShowDaysQuery groupByDbFirstShow() Group by the first_show column * @method CcShowDaysQuery groupByDbLastShow() Group by the last_show column * @method CcShowDaysQuery groupByDbStartTime() Group by the start_time column + * @method CcShowDaysQuery groupByDbTimezone() Group by the timezone column * @method CcShowDaysQuery groupByDbDuration() Group by the duration column * @method CcShowDaysQuery groupByDbDay() Group by the day column * @method CcShowDaysQuery groupByDbRepeatType() Group by the repeat_type column @@ -43,6 +45,7 @@ * @method CcShowDays findOneByDbFirstShow(string $first_show) Return the first CcShowDays filtered by the first_show column * @method CcShowDays findOneByDbLastShow(string $last_show) Return the first CcShowDays filtered by the last_show column * @method CcShowDays findOneByDbStartTime(string $start_time) Return the first CcShowDays filtered by the start_time column + * @method CcShowDays findOneByDbTimezone(string $timezone) Return the first CcShowDays filtered by the timezone column * @method CcShowDays findOneByDbDuration(string $duration) Return the first CcShowDays filtered by the duration column * @method CcShowDays findOneByDbDay(int $day) Return the first CcShowDays filtered by the day column * @method CcShowDays findOneByDbRepeatType(int $repeat_type) Return the first CcShowDays filtered by the repeat_type column @@ -54,6 +57,7 @@ * @method array findByDbFirstShow(string $first_show) Return CcShowDays objects filtered by the first_show column * @method array findByDbLastShow(string $last_show) Return CcShowDays objects filtered by the last_show column * @method array findByDbStartTime(string $start_time) Return CcShowDays objects filtered by the start_time column + * @method array findByDbTimezone(string $timezone) Return CcShowDays objects filtered by the timezone column * @method array findByDbDuration(string $duration) Return CcShowDays objects filtered by the duration column * @method array findByDbDay(int $day) Return CcShowDays objects filtered by the day column * @method array findByDbRepeatType(int $repeat_type) Return CcShowDays objects filtered by the repeat_type column @@ -279,6 +283,28 @@ abstract class BaseCcShowDaysQuery extends ModelCriteria return $this->addUsingAlias(CcShowDaysPeer::START_TIME, $dbStartTime, $comparison); } + /** + * Filter the query on the timezone column + * + * @param string $dbTimezone 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 CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbTimezone($dbTimezone = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbTimezone)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbTimezone)) { + $dbTimezone = str_replace('*', '%', $dbTimezone); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcShowDaysPeer::TIMEZONE, $dbTimezone, $comparison); + } + /** * Filter the query on the duration column * diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php index 790a460cc..ebadd9600 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php @@ -74,12 +74,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent */ protected $file_id; - /** - * The value for the soundcloud_id field. - * @var int - */ - protected $soundcloud_id; - /** * The value for the time_filled field. * @var string @@ -273,16 +267,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this->file_id; } - /** - * Get the [soundcloud_id] column value. - * - * @return int - */ - public function getDbSoundCloudId() - { - return $this->soundcloud_id; - } - /** * Get the [optionally formatted] temporal [time_filled] column value. * @@ -546,26 +530,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this; } // setDbRecordedFile() - /** - * Set the value of [soundcloud_id] column. - * - * @param int $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbSoundCloudId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->soundcloud_id !== $v) { - $this->soundcloud_id = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::SOUNDCLOUD_ID; - } - - return $this; - } // setDbSoundCloudId() - /** * Sets the value of [time_filled] column to a normalized version of the date/time value specified. * @@ -663,8 +627,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->rebroadcast = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; $this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; $this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; - $this->soundcloud_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; - $this->time_filled = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; $this->resetModified(); $this->setNew(false); @@ -673,7 +636,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 10; // 10 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 9; // 9 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcShowInstances object", $e); @@ -1095,9 +1058,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent return $this->getDbRecordedFile(); break; case 8: - return $this->getDbSoundCloudId(); - break; - case 9: return $this->getDbTimeFilled(); break; default: @@ -1132,8 +1092,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $keys[5] => $this->getDbRebroadcast(), $keys[6] => $this->getDbOriginalShow(), $keys[7] => $this->getDbRecordedFile(), - $keys[8] => $this->getDbSoundCloudId(), - $keys[9] => $this->getDbTimeFilled(), + $keys[8] => $this->getDbTimeFilled(), ); if ($includeForeignObjects) { if (null !== $this->aCcShow) { @@ -1201,9 +1160,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->setDbRecordedFile($value); break; case 8: - $this->setDbSoundCloudId($value); - break; - case 9: $this->setDbTimeFilled($value); break; } // switch() @@ -1238,8 +1194,7 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if (array_key_exists($keys[5], $arr)) $this->setDbRebroadcast($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbSoundCloudId($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbTimeFilled($arr[$keys[9]]); + if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]); } /** @@ -1259,7 +1214,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) $criteria->add(CcShowInstancesPeer::REBROADCAST, $this->rebroadcast); if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id); if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id); - if ($this->isColumnModified(CcShowInstancesPeer::SOUNDCLOUD_ID)) $criteria->add(CcShowInstancesPeer::SOUNDCLOUD_ID, $this->soundcloud_id); if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled); return $criteria; @@ -1329,7 +1283,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $copyObj->setDbRebroadcast($this->rebroadcast); $copyObj->setDbOriginalShow($this->instance_id); $copyObj->setDbRecordedFile($this->file_id); - $copyObj->setDbSoundCloudId($this->soundcloud_id); $copyObj->setDbTimeFilled($this->time_filled); if ($deepCopy) { @@ -1847,7 +1800,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent $this->rebroadcast = null; $this->instance_id = null; $this->file_id = null; - $this->soundcloud_id = null; $this->time_filled = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php index d7dda7647..bbbfc3da9 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcShowInstancesPeer { const TM_CLASS = 'CcShowInstancesTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 9; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -55,9 +55,6 @@ abstract class BaseCcShowInstancesPeer { /** the column name for the FILE_ID field */ const FILE_ID = 'cc_show_instances.FILE_ID'; - /** the column name for the SOUNDCLOUD_ID field */ - const SOUNDCLOUD_ID = 'cc_show_instances.SOUNDCLOUD_ID'; - /** the column name for the TIME_FILLED field */ const TIME_FILLED = 'cc_show_instances.TIME_FILLED'; @@ -77,12 +74,12 @@ abstract class BaseCcShowInstancesPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbSoundCloudId', 'DbTimeFilled', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbSoundCloudId', 'dbTimeFilled', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::SOUNDCLOUD_ID, self::TIME_FILLED, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'SOUNDCLOUD_ID', 'TIME_FILLED', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'soundcloud_id', 'time_filled', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -92,12 +89,12 @@ abstract class BaseCcShowInstancesPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbSoundCloudId' => 8, 'DbTimeFilled' => 9, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbSoundCloudId' => 8, 'dbTimeFilled' => 9, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::SOUNDCLOUD_ID => 8, self::TIME_FILLED => 9, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'SOUNDCLOUD_ID' => 8, 'TIME_FILLED' => 9, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'soundcloud_id' => 8, 'time_filled' => 9, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -177,7 +174,6 @@ abstract class BaseCcShowInstancesPeer { $criteria->addSelectColumn(CcShowInstancesPeer::REBROADCAST); $criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID); $criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID); - $criteria->addSelectColumn(CcShowInstancesPeer::SOUNDCLOUD_ID); $criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED); } else { $criteria->addSelectColumn($alias . '.ID'); @@ -188,7 +184,6 @@ abstract class BaseCcShowInstancesPeer { $criteria->addSelectColumn($alias . '.REBROADCAST'); $criteria->addSelectColumn($alias . '.INSTANCE_ID'); $criteria->addSelectColumn($alias . '.FILE_ID'); - $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ID'); $criteria->addSelectColumn($alias . '.TIME_FILLED'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php index 3d49926a9..cdd85beed 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php @@ -14,7 +14,6 @@ * @method CcShowInstancesQuery orderByDbRebroadcast($order = Criteria::ASC) Order by the rebroadcast column * @method CcShowInstancesQuery orderByDbOriginalShow($order = Criteria::ASC) Order by the instance_id column * @method CcShowInstancesQuery orderByDbRecordedFile($order = Criteria::ASC) Order by the file_id column - * @method CcShowInstancesQuery orderByDbSoundCloudId($order = Criteria::ASC) Order by the soundcloud_id column * @method CcShowInstancesQuery orderByDbTimeFilled($order = Criteria::ASC) Order by the time_filled column * * @method CcShowInstancesQuery groupByDbId() Group by the id column @@ -25,7 +24,6 @@ * @method CcShowInstancesQuery groupByDbRebroadcast() Group by the rebroadcast column * @method CcShowInstancesQuery groupByDbOriginalShow() Group by the instance_id column * @method CcShowInstancesQuery groupByDbRecordedFile() Group by the file_id column - * @method CcShowInstancesQuery groupByDbSoundCloudId() Group by the soundcloud_id column * @method CcShowInstancesQuery groupByDbTimeFilled() Group by the time_filled column * * @method CcShowInstancesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query @@ -63,7 +61,6 @@ * @method CcShowInstances findOneByDbRebroadcast(int $rebroadcast) Return the first CcShowInstances filtered by the rebroadcast column * @method CcShowInstances findOneByDbOriginalShow(int $instance_id) Return the first CcShowInstances filtered by the instance_id column * @method CcShowInstances findOneByDbRecordedFile(int $file_id) Return the first CcShowInstances filtered by the file_id column - * @method CcShowInstances findOneByDbSoundCloudId(int $soundcloud_id) Return the first CcShowInstances filtered by the soundcloud_id column * @method CcShowInstances findOneByDbTimeFilled(string $time_filled) Return the first CcShowInstances filtered by the time_filled column * * @method array findByDbId(int $id) Return CcShowInstances objects filtered by the id column @@ -74,7 +71,6 @@ * @method array findByDbRebroadcast(int $rebroadcast) Return CcShowInstances objects filtered by the rebroadcast column * @method array findByDbOriginalShow(int $instance_id) Return CcShowInstances objects filtered by the instance_id column * @method array findByDbRecordedFile(int $file_id) Return CcShowInstances objects filtered by the file_id column - * @method array findByDbSoundCloudId(int $soundcloud_id) Return CcShowInstances objects filtered by the soundcloud_id column * @method array findByDbTimeFilled(string $time_filled) Return CcShowInstances objects filtered by the time_filled column * * @package propel.generator.airtime.om @@ -419,37 +415,6 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria return $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile, $comparison); } - /** - * Filter the query on the soundcloud_id column - * - * @param int|array $dbSoundCloudId The value to use as filter. - * Accepts an associative array('min' => $minValue, 'max' => $maxValue) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbSoundCloudId($dbSoundCloudId = null, $comparison = null) - { - if (is_array($dbSoundCloudId)) { - $useMinMax = false; - if (isset($dbSoundCloudId['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::SOUNDCLOUD_ID, $dbSoundCloudId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbSoundCloudId['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::SOUNDCLOUD_ID, $dbSoundCloudId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::SOUNDCLOUD_ID, $dbSoundCloudId, $comparison); - } - /** * Filter the query on the time_filled column * diff --git a/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php b/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php new file mode 100644 index 000000000..6dadc9b67 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php @@ -0,0 +1,756 @@ +keyname; + } + + /** + * Get the [value] column value. + * + * @return string + */ + public function getDbValue() + { + return $this->value; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getDbType() + { + return $this->type; + } + + /** + * Set the value of [keyname] column. + * + * @param string $v new value + * @return CcStreamSetting The current object (for fluent API support) + */ + public function setDbKeyName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->keyname !== $v) { + $this->keyname = $v; + $this->modifiedColumns[] = CcStreamSettingPeer::KEYNAME; + } + + return $this; + } // setDbKeyName() + + /** + * Set the value of [value] column. + * + * @param string $v new value + * @return CcStreamSetting The current object (for fluent API support) + */ + public function setDbValue($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CcStreamSettingPeer::VALUE; + } + + return $this; + } // setDbValue() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcStreamSetting The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcStreamSettingPeer::TYPE; + } + + return $this; + } // setDbType() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false) + { + try { + + $this->keyname = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->value = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 3; // 3 = CcStreamSettingPeer::NUM_COLUMNS - CcStreamSettingPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating CcStreamSetting 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() + { + + } // 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(CcStreamSettingPeer::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 = CcStreamSettingPeer::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? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $ret = $this->preDelete($con); + if ($ret) { + CcStreamSettingQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()) + ->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(PropelPDO $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::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); + CcStreamSettingPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param PropelPDO $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(PropelPDO $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $criteria = $this->buildCriteria(); + $pk = BasePeer::doInsert($criteria, $con); + $affectedRows = 1; + $this->setNew(false); + } else { + $affectedRows = CcStreamSettingPeer::doUpdate($this, $con); + } + + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcStreamSettingPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcStreamSettingPeer::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->getDbKeyName(); + break; + case 1: + return $this->getDbValue(); + break; + case 2: + return $this->getDbType(); + 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. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) + { + $keys = CcStreamSettingPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbKeyName(), + $keys[1] => $this->getDbValue(), + $keys[2] => $this->getDbType(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcStreamSettingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setDbKeyName($value); + break; + case 1: + $this->setDbValue($value); + break; + case 2: + $this->setDbType($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. + * The default key type is the column's phpname (e.g. 'AuthorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = CcStreamSettingPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbKeyName($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbValue($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbType($arr[$keys[2]]); + } + + /** + * 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(CcStreamSettingPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcStreamSettingPeer::KEYNAME)) $criteria->add(CcStreamSettingPeer::KEYNAME, $this->keyname); + if ($this->isColumnModified(CcStreamSettingPeer::VALUE)) $criteria->add(CcStreamSettingPeer::VALUE, $this->value); + if ($this->isColumnModified(CcStreamSettingPeer::TYPE)) $criteria->add(CcStreamSettingPeer::TYPE, $this->type); + + 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(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, $this->keyname); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbKeyName(); + } + + /** + * Generic method to set the primary key (keyname column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbKeyName($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + return null === $this->getDbKeyName(); + } + + /** + * 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 CcStreamSetting (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + $copyObj->setDbKeyName($this->keyname); + $copyObj->setDbValue($this->value); + $copyObj->setDbType($this->type); + + $copyObj->setNew(true); + } + + /** + * 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 CcStreamSetting 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 CcStreamSettingPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcStreamSettingPeer(); + } + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->keyname = null; + $this->value = null; + $this->type = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all collections of referencing foreign keys. + * + * This method is a user-space workaround for PHP's inability to garbage collect objects + * with circular references. This is currently necessary when using Propel in certain + * daemon or large-volumne/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all associated objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Catches calls to virtual methods + */ + public function __call($name, $params) + { + if (preg_match('/get(\w+)/', $name, $matches)) { + $virtualColumn = $matches[1]; + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + // no lcfirst in php<5.3... + $virtualColumn[0] = strtolower($virtualColumn[0]); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + throw new PropelException('Call to undefined method: ' . $name); + } + +} // BaseCcStreamSetting diff --git a/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php new file mode 100644 index 000000000..f5e680b20 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php @@ -0,0 +1,740 @@ + array ('DbKeyName', 'DbValue', 'DbType', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbKeyName', 'dbValue', 'dbType', ), + BasePeer::TYPE_COLNAME => array (self::KEYNAME, self::VALUE, self::TYPE, ), + BasePeer::TYPE_RAW_COLNAME => array ('KEYNAME', 'VALUE', 'TYPE', ), + BasePeer::TYPE_FIELDNAME => array ('keyname', 'value', 'type', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbKeyName' => 0, 'DbValue' => 1, 'DbType' => 2, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbKeyName' => 0, 'dbValue' => 1, 'dbType' => 2, ), + BasePeer::TYPE_COLNAME => array (self::KEYNAME => 0, self::VALUE => 1, self::TYPE => 2, ), + BasePeer::TYPE_RAW_COLNAME => array ('KEYNAME' => 0, 'VALUE' => 1, 'TYPE' => 2, ), + BasePeer::TYPE_FIELDNAME => array ('keyname' => 0, 'value' => 1, 'type' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + * @throws PropelException - if the specified name could not be found in the fieldname mappings. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. CcStreamSettingPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcStreamSettingPeer::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(CcStreamSettingPeer::KEYNAME); + $criteria->addSelectColumn(CcStreamSettingPeer::VALUE); + $criteria->addSelectColumn(CcStreamSettingPeer::TYPE); + } else { + $criteria->addSelectColumn($alias . '.KEYNAME'); + $criteria->addSelectColumn($alias . '.VALUE'); + $criteria->addSelectColumn($alias . '.TYPE'); + } + } + + /** + * 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(CcStreamSettingPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcStreamSettingPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + // BasePeer returns a PDOStatement + $stmt = BasePeer::doCount($criteria, $con); + + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $count = (int) $row[0]; + } else { + $count = 0; // no rows returned; we infer that means 0 matches. + } + $stmt->closeCursor(); + return $count; + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcStreamSetting + * @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 = CcStreamSettingPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, PropelPDO $con = null) + { + return CcStreamSettingPeer::populateObjects(CcStreamSettingPeer::doSelectStmt($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. + * + * Use this method directly if you want to work with an executed statement durirectly (for example + * to perform your own object hydration). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param PropelPDO $con The connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return PDOStatement The executed PDOStatement object. + * @see BasePeer::doSelect() + */ + public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcStreamSettingPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a PDOStatement + return BasePeer::doSelect($criteria, $con); + } + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doSelect*() + * methods in your stub classes -- you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by doSelect*() + * and retrieveByPK*() calls. + * + * @param CcStreamSetting $value A CcStreamSetting object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool(CcStreamSetting $obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbKeyName(); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A CcStreamSetting object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcStreamSetting) { + $key = (string) $value->getDbKeyName(); + } 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 CcStreamSetting object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } // removeInstanceFromPool() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param string $key The key (@see getPrimaryKeyHash()) for this instance. + * @return CcStreamSetting Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled. + * @see getPrimaryKeyHash() + */ + public static function getInstanceFromPool($key) + { + if (Propel::isInstancePoolingEnabled()) { + if (isset(self::$instances[$key])) { + return self::$instances[$key]; + } + } + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool() + { + self::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_stream_setting + * 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 (string) $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 = CcStreamSettingPeer::getOMClass(false); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcStreamSettingPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcStreamSettingPeer::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; + CcStreamSettingPeer::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 (CcStreamSetting object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcStreamSettingPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcStreamSettingPeer::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 + CcStreamSettingPeer::NUM_COLUMNS; + } else { + $cls = CcStreamSettingPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcStreamSettingPeer::addInstanceToPool($obj, $key); + } + return array($obj, $col); + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcStreamSettingPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcStreamSettingPeer::TABLE_NAME)) + { + $dbMap->addTableObject(new CcStreamSettingTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CcStreamSettingPeer::CLASS_DEFAULT : CcStreamSettingPeer::OM_CLASS; + } + + /** + * Method perform an INSERT on the database, given a CcStreamSetting or Criteria object. + * + * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcStreamSetting object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch(PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a CcStreamSetting or Criteria object. + * + * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcStreamSettingPeer::KEYNAME); + $value = $criteria->remove(CcStreamSettingPeer::KEYNAME); + if ($value) { + $selectCriteria->add(CcStreamSettingPeer::KEYNAME, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcStreamSettingPeer::TABLE_NAME); + } + + } else { // $values is CcStreamSetting object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the cc_stream_setting table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::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(CcStreamSettingPeer::TABLE_NAME, $con, CcStreamSettingPeer::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). + CcStreamSettingPeer::clearInstancePool(); + CcStreamSettingPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a CcStreamSetting or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::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. + CcStreamSettingPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcStreamSetting) { // it's a model object + // invalidate the cache for this single object + CcStreamSettingPeer::removeInstanceFromPool($values); + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcStreamSettingPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + CcStreamSettingPeer::clearRelatedInstancePool(); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcStreamSetting 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 CcStreamSetting $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(CcStreamSetting $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcStreamSettingPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcStreamSettingPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcStreamSettingPeer::DATABASE_NAME, CcStreamSettingPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcStreamSetting + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcStreamSettingPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, $pk); + + $v = CcStreamSettingPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param PropelPDO $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, $pks, Criteria::IN); + $objs = CcStreamSettingPeer::doSelect($criteria, $con); + } + return $objs; + } + +} // BaseCcStreamSettingPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseCcStreamSettingPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php new file mode 100644 index 000000000..666106d6f --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php @@ -0,0 +1,222 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + return $query; + } + + /** + * Find object by primary key + * Use instance pooling to avoid a database query if the object exists + * + * $obj = $c->findPk(12, $con); + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcStreamSetting|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ((null !== ($obj = CcStreamSettingPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) { + // the object is alredy in the instance pool + return $obj; + } else { + // the object has not been requested yet, or the formatter is not an object formatter + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->getSelectStatement($con); + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param PropelPDO $con an optional connection object + * + * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + $criteria = $this->isKeepQuery() ? clone $this : $this; + return $this + ->filterByPrimaryKeys($keys) + ->find($con); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $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 CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $keys, Criteria::IN); + } + + /** + * Filter the query on the keyname column + * + * @param string $dbKeyName 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 CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByDbKeyName($dbKeyName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbKeyName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbKeyName)) { + $dbKeyName = str_replace('*', '%', $dbKeyName); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $dbKeyName, $comparison); + } + + /** + * Filter the query on the value column + * + * @param string $dbValue 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 CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByDbValue($dbValue = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbValue)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbValue)) { + $dbValue = str_replace('*', '%', $dbValue); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcStreamSettingPeer::VALUE, $dbValue, $comparison); + } + + /** + * Filter the query on the type column + * + * @param string $dbType 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 CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbType)) { + $dbType = str_replace('*', '%', $dbType); + $comparison = Criteria::LIKE; + } + } + return $this->addUsingAlias(CcStreamSettingPeer::TYPE, $dbType, $comparison); + } + + /** + * Exclude object from result + * + * @param CcStreamSetting $ccStreamSetting Object to remove from the list of results + * + * @return CcStreamSettingQuery The current query, for fluid interface + */ + public function prune($ccStreamSetting = null) + { + if ($ccStreamSetting) { + $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $ccStreamSetting->getDbKeyName(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} // BaseCcStreamSettingQuery diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php index 1bef178f3..54a0468ce 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php @@ -95,6 +95,13 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent */ protected $email; + /** + * The value for the login_attempts field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $login_attempts; + /** * @var array CcAccess[] Collection to store aggregation of CcAccess objects. */ @@ -157,6 +164,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent $this->type = 'U'; $this->first_name = ''; $this->last_name = ''; + $this->login_attempts = 0; } /** @@ -325,6 +333,16 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent return $this->email; } + /** + * Get the [login_attempts] column value. + * + * @return int + */ + public function getDbLoginAttempts() + { + return $this->login_attempts; + } + /** * Set the value of [id] column. * @@ -603,6 +621,26 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent return $this; } // setDbEmail() + /** + * Set the value of [login_attempts] column. + * + * @param int $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbLoginAttempts($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->login_attempts !== $v || $this->isNew()) { + $this->login_attempts = $v; + $this->modifiedColumns[] = CcSubjsPeer::LOGIN_ATTEMPTS; + } + + return $this; + } // setDbLoginAttempts() + /** * Indicates whether the columns in this object are only set to default values. * @@ -633,6 +671,10 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent return false; } + if ($this->login_attempts !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -666,6 +708,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent $this->skype_contact = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; $this->jabber_contact = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; $this->email = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->login_attempts = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; $this->resetModified(); $this->setNew(false); @@ -674,7 +717,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 11; // 11 = CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 12; // 12 = CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcSubjs object", $e); @@ -1132,6 +1175,9 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent case 10: return $this->getDbEmail(); break; + case 11: + return $this->getDbLoginAttempts(); + break; default: return null; break; @@ -1166,6 +1212,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent $keys[8] => $this->getDbSkypeContact(), $keys[9] => $this->getDbJabberContact(), $keys[10] => $this->getDbEmail(), + $keys[11] => $this->getDbLoginAttempts(), ); return $result; } @@ -1230,6 +1277,9 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent case 10: $this->setDbEmail($value); break; + case 11: + $this->setDbLoginAttempts($value); + break; } // switch() } @@ -1265,6 +1315,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent if (array_key_exists($keys[8], $arr)) $this->setDbSkypeContact($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setDbJabberContact($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setDbEmail($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbLoginAttempts($arr[$keys[11]]); } /** @@ -1287,6 +1338,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent if ($this->isColumnModified(CcSubjsPeer::SKYPE_CONTACT)) $criteria->add(CcSubjsPeer::SKYPE_CONTACT, $this->skype_contact); if ($this->isColumnModified(CcSubjsPeer::JABBER_CONTACT)) $criteria->add(CcSubjsPeer::JABBER_CONTACT, $this->jabber_contact); if ($this->isColumnModified(CcSubjsPeer::EMAIL)) $criteria->add(CcSubjsPeer::EMAIL, $this->email); + if ($this->isColumnModified(CcSubjsPeer::LOGIN_ATTEMPTS)) $criteria->add(CcSubjsPeer::LOGIN_ATTEMPTS, $this->login_attempts); return $criteria; } @@ -1358,6 +1410,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent $copyObj->setDbSkypeContact($this->skype_contact); $copyObj->setDbJabberContact($this->jabber_contact); $copyObj->setDbEmail($this->email); + $copyObj->setDbLoginAttempts($this->login_attempts); if ($deepCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -2280,6 +2333,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent $this->skype_contact = null; $this->jabber_contact = null; $this->email = null; + $this->login_attempts = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php index 3743a4aab..79a9a7efa 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcSubjsPeer { const TM_CLASS = 'CcSubjsTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 11; + const NUM_COLUMNS = 12; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -64,6 +64,9 @@ abstract class BaseCcSubjsPeer { /** the column name for the EMAIL field */ const EMAIL = 'cc_subjs.EMAIL'; + /** the column name for the LOGIN_ATTEMPTS field */ + const LOGIN_ATTEMPTS = 'cc_subjs.LOGIN_ATTEMPTS'; + /** * An identiy map to hold any loaded instances of CcSubjs objects. * This must be public so that other peer classes can access this when hydrating from JOIN @@ -80,12 +83,12 @@ abstract class BaseCcSubjsPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbLogin', 'DbPass', 'DbType', 'DbFirstName', 'DbLastName', 'DbLastlogin', 'DbLastfail', 'DbSkypeContact', 'DbJabberContact', 'DbEmail', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLogin', 'dbPass', 'dbType', 'dbFirstName', 'dbLastName', 'dbLastlogin', 'dbLastfail', 'dbSkypeContact', 'dbJabberContact', 'dbEmail', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::LOGIN, self::PASS, self::TYPE, self::FIRST_NAME, self::LAST_NAME, self::LASTLOGIN, self::LASTFAIL, self::SKYPE_CONTACT, self::JABBER_CONTACT, self::EMAIL, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOGIN', 'PASS', 'TYPE', 'FIRST_NAME', 'LAST_NAME', 'LASTLOGIN', 'LASTFAIL', 'SKYPE_CONTACT', 'JABBER_CONTACT', 'EMAIL', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'pass', 'type', 'first_name', 'last_name', 'lastlogin', 'lastfail', 'skype_contact', 'jabber_contact', 'email', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbLogin', 'DbPass', 'DbType', 'DbFirstName', 'DbLastName', 'DbLastlogin', 'DbLastfail', 'DbSkypeContact', 'DbJabberContact', 'DbEmail', 'DbLoginAttempts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLogin', 'dbPass', 'dbType', 'dbFirstName', 'dbLastName', 'dbLastlogin', 'dbLastfail', 'dbSkypeContact', 'dbJabberContact', 'dbEmail', 'dbLoginAttempts', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::LOGIN, self::PASS, self::TYPE, self::FIRST_NAME, self::LAST_NAME, self::LASTLOGIN, self::LASTFAIL, self::SKYPE_CONTACT, self::JABBER_CONTACT, self::EMAIL, self::LOGIN_ATTEMPTS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOGIN', 'PASS', 'TYPE', 'FIRST_NAME', 'LAST_NAME', 'LASTLOGIN', 'LASTFAIL', 'SKYPE_CONTACT', 'JABBER_CONTACT', 'EMAIL', 'LOGIN_ATTEMPTS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'pass', 'type', 'first_name', 'last_name', 'lastlogin', 'lastfail', 'skype_contact', 'jabber_contact', 'email', 'login_attempts', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -95,12 +98,12 @@ abstract class BaseCcSubjsPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbLogin' => 1, 'DbPass' => 2, 'DbType' => 3, 'DbFirstName' => 4, 'DbLastName' => 5, 'DbLastlogin' => 6, 'DbLastfail' => 7, 'DbSkypeContact' => 8, 'DbJabberContact' => 9, 'DbEmail' => 10, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLogin' => 1, 'dbPass' => 2, 'dbType' => 3, 'dbFirstName' => 4, 'dbLastName' => 5, 'dbLastlogin' => 6, 'dbLastfail' => 7, 'dbSkypeContact' => 8, 'dbJabberContact' => 9, 'dbEmail' => 10, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOGIN => 1, self::PASS => 2, self::TYPE => 3, self::FIRST_NAME => 4, self::LAST_NAME => 5, self::LASTLOGIN => 6, self::LASTFAIL => 7, self::SKYPE_CONTACT => 8, self::JABBER_CONTACT => 9, self::EMAIL => 10, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOGIN' => 1, 'PASS' => 2, 'TYPE' => 3, 'FIRST_NAME' => 4, 'LAST_NAME' => 5, 'LASTLOGIN' => 6, 'LASTFAIL' => 7, 'SKYPE_CONTACT' => 8, 'JABBER_CONTACT' => 9, 'EMAIL' => 10, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'first_name' => 4, 'last_name' => 5, 'lastlogin' => 6, 'lastfail' => 7, 'skype_contact' => 8, 'jabber_contact' => 9, 'email' => 10, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbLogin' => 1, 'DbPass' => 2, 'DbType' => 3, 'DbFirstName' => 4, 'DbLastName' => 5, 'DbLastlogin' => 6, 'DbLastfail' => 7, 'DbSkypeContact' => 8, 'DbJabberContact' => 9, 'DbEmail' => 10, 'DbLoginAttempts' => 11, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLogin' => 1, 'dbPass' => 2, 'dbType' => 3, 'dbFirstName' => 4, 'dbLastName' => 5, 'dbLastlogin' => 6, 'dbLastfail' => 7, 'dbSkypeContact' => 8, 'dbJabberContact' => 9, 'dbEmail' => 10, 'dbLoginAttempts' => 11, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOGIN => 1, self::PASS => 2, self::TYPE => 3, self::FIRST_NAME => 4, self::LAST_NAME => 5, self::LASTLOGIN => 6, self::LASTFAIL => 7, self::SKYPE_CONTACT => 8, self::JABBER_CONTACT => 9, self::EMAIL => 10, self::LOGIN_ATTEMPTS => 11, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOGIN' => 1, 'PASS' => 2, 'TYPE' => 3, 'FIRST_NAME' => 4, 'LAST_NAME' => 5, 'LASTLOGIN' => 6, 'LASTFAIL' => 7, 'SKYPE_CONTACT' => 8, 'JABBER_CONTACT' => 9, 'EMAIL' => 10, 'LOGIN_ATTEMPTS' => 11, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'first_name' => 4, 'last_name' => 5, 'lastlogin' => 6, 'lastfail' => 7, 'skype_contact' => 8, 'jabber_contact' => 9, 'email' => 10, 'login_attempts' => 11, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -183,6 +186,7 @@ abstract class BaseCcSubjsPeer { $criteria->addSelectColumn(CcSubjsPeer::SKYPE_CONTACT); $criteria->addSelectColumn(CcSubjsPeer::JABBER_CONTACT); $criteria->addSelectColumn(CcSubjsPeer::EMAIL); + $criteria->addSelectColumn(CcSubjsPeer::LOGIN_ATTEMPTS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOGIN'); @@ -195,6 +199,7 @@ abstract class BaseCcSubjsPeer { $criteria->addSelectColumn($alias . '.SKYPE_CONTACT'); $criteria->addSelectColumn($alias . '.JABBER_CONTACT'); $criteria->addSelectColumn($alias . '.EMAIL'); + $criteria->addSelectColumn($alias . '.LOGIN_ATTEMPTS'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php index 857fbcdf4..9a0cffdd0 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php @@ -17,6 +17,7 @@ * @method CcSubjsQuery orderByDbSkypeContact($order = Criteria::ASC) Order by the skype_contact column * @method CcSubjsQuery orderByDbJabberContact($order = Criteria::ASC) Order by the jabber_contact column * @method CcSubjsQuery orderByDbEmail($order = Criteria::ASC) Order by the email column + * @method CcSubjsQuery orderByDbLoginAttempts($order = Criteria::ASC) Order by the login_attempts column * * @method CcSubjsQuery groupByDbId() Group by the id column * @method CcSubjsQuery groupByDbLogin() Group by the login column @@ -29,6 +30,7 @@ * @method CcSubjsQuery groupByDbSkypeContact() Group by the skype_contact column * @method CcSubjsQuery groupByDbJabberContact() Group by the jabber_contact column * @method CcSubjsQuery groupByDbEmail() Group by the email column + * @method CcSubjsQuery groupByDbLoginAttempts() Group by the login_attempts column * * @method CcSubjsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcSubjsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -76,6 +78,7 @@ * @method CcSubjs findOneByDbSkypeContact(string $skype_contact) Return the first CcSubjs filtered by the skype_contact column * @method CcSubjs findOneByDbJabberContact(string $jabber_contact) Return the first CcSubjs filtered by the jabber_contact column * @method CcSubjs findOneByDbEmail(string $email) Return the first CcSubjs filtered by the email column + * @method CcSubjs findOneByDbLoginAttempts(int $login_attempts) Return the first CcSubjs filtered by the login_attempts column * * @method array findByDbId(int $id) Return CcSubjs objects filtered by the id column * @method array findByDbLogin(string $login) Return CcSubjs objects filtered by the login column @@ -88,6 +91,7 @@ * @method array findByDbSkypeContact(string $skype_contact) Return CcSubjs objects filtered by the skype_contact column * @method array findByDbJabberContact(string $jabber_contact) Return CcSubjs objects filtered by the jabber_contact column * @method array findByDbEmail(string $email) Return CcSubjs objects filtered by the email column + * @method array findByDbLoginAttempts(int $login_attempts) Return CcSubjs objects filtered by the login_attempts column * * @package propel.generator.airtime.om */ @@ -452,6 +456,37 @@ abstract class BaseCcSubjsQuery extends ModelCriteria return $this->addUsingAlias(CcSubjsPeer::EMAIL, $dbEmail, $comparison); } + /** + * Filter the query on the login_attempts column + * + * @param int|array $dbLoginAttempts The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByDbLoginAttempts($dbLoginAttempts = null, $comparison = null) + { + if (is_array($dbLoginAttempts)) { + $useMinMax = false; + if (isset($dbLoginAttempts['min'])) { + $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLoginAttempts['max'])) { + $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts, $comparison); + } + /** * Filter the query by a related CcAccess object * diff --git a/airtime_mvc/application/models/cron/Cron.php b/airtime_mvc/application/models/cron/Cron.php deleted file mode 100755 index 300fbc701..000000000 --- a/airtime_mvc/application/models/cron/Cron.php +++ /dev/null @@ -1,214 +0,0 @@ - - * $cron = new Cron(); - * $access = $cron->openCrontab('write'); - * if ($access != 'write') { - * do { - * $access = $cron->forceWriteable(); - * } while ($access != 'write'); - * } - * $cron->addCronJob('*','*','*','*','*', - * 'ClassName', - * array('first','secound','third') - * ); - * $cron->closeCrontab(); - * - * @package Airtime - * @subpackage StorageServer.Cron - */ -class Cron { - /** - * @var Crontab - */ - public $ct; - - /** - * @var array This array created with getCommand() function - */ - private $params; - - /** - * @var string available values: read | write - */ - private $ctAccess = 'read'; - - private $lockfile; - private $cronfile; - private $paramdir; - private $cronUserName; - - /** - * Constructor - */ - function Cron() { - global $CC_CONFIG; - $this->lockfile = $CC_CONFIG['lockfile']; - $this->cronfile = $CC_CONFIG['cronfile']; - $this->paramdir = $CC_CONFIG['paramdir']; - $this->cronUserName = $CC_CONFIG['cronUserName']; - } - - - /* ==================================================== Cronjob functions */ - /** - * Add a cronjob to the crontab - * - * @access public - * @param string $m minute - * @param string $h hour - * @param string $dom day of month - * @param string $mo month - * @param string $dow day of week - * @param string $className name of class, which's execute() is called by croncall.php - * @param string $params the parameter(s) - * @return bool true if success else PEAR error. - */ - function addCronJob($m, $h, $dom, $mo, $dow, $className, $params) - { - if ($this->ctAccess == 'write') { - $this->ct->addCron($m, $h, $dom, $mo, $dow, - $this->getCommand($className, $params)); - return true; - } else { - return PEAR::raiseError('CronJob::addCronJob : '. - 'The crontab is not writable'); - } - } - - /** - * This function return with the active cronjobs - * - * @access public - * @return array array of cronjob struct - */ - function listCronJob() - { - return $this->ct->getByType(CRON_CMD); - } - - /** - * Remove a cronjob. - * - * @access public - * @param int $index index of the cronjobs' array. - * @return bool true if success else PEAR error. - */ - function removeCronJob($index) - { - if ($this->ctAccess == 'write') { - $this->crontab->delEntry($index); - return true; - } else { - return PEAR::raiseError('CronJob::removeCronJob : '. - 'The crontab is not writable'); - } - } - - /* ==================================================== Crontab functions */ - /** - * Open the crontab - * - * @access public - * @param string $access only for listing 'read', for add and delete 'write' - * @return string sucessed access - available values read | write - */ - function openCrontab($access = 'read') - { - $access = strtolower($access); - $this->ct = new Crontab($this->cronUserName); - if ($access == 'write' && - $this->isCrontabWritable() && - $this->lockCrontab()) { - $this->ctAccess = $access; - } else { - $this->ctAccess = 'read'; - } - return $this->ctAccess; - } - - /** - * Close the crontab - * - * @access public - * @return bool true if everything is ok, false is the lock file can't delete - */ - function closeCrontab() - { - if ($this->ctAccess == 'write') { - $this->ct->writeCrontab(); - } - return $this->ctAccess == 'write' ? $this->unlockCrontab() : true; - } - - /** - * Check the crontab is writable - * - * @access private - * @return bool - */ - function isCrontabWritable() - { - return !is_file($this->lockfile); - } - - /** - * Try to lock the crontab - * - * @access private - * @return bool true if the locking is success - */ - function lockCrontab() - { - return @touch($this->lockfile); - } - - /** - * Try to unlock the crontab - * - * @access private - * @return bool true if the unlocking is success - */ - function unlockCrontab() - { - return unlink($this->lockfile); - } - - /** - * If the crontab opened with read access. This function force set - * the access to write. - * - * @access public - * @return bool true if the setting is success - */ - function forceWriteable() - { - if ($this->isCrontabWritable() && $this->lockCrontab()) { - $this->ctAccess = 'write'; - return true; - } - return false; - } - - /* ======================================================= Misc functions */ - /** - * Get the shell command for the cronjob - * - * @param string $className name of the class what is called by croncall.php - * @param mixed $params with this parameter could be called the execute() of class - * @return string shell command - */ - function getCommand($className, $params) - { - $this->params = array ( - 'class' => $className, - 'params' => $params - ); - return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"'; - } -} - diff --git a/airtime_mvc/application/models/cron/CronJob.php b/airtime_mvc/application/models/cron/CronJob.php deleted file mode 100755 index a9e56adb0..000000000 --- a/airtime_mvc/application/models/cron/CronJob.php +++ /dev/null @@ -1,17 +0,0 @@ - "value" - * or a line can be a comment (string beginning with #) - * or it can be a special command (beginning with an @) - * @var array - */ - private $crontabs; - - /** - * The user for whom the crontab will be manipulated - * @var string - */ - private $user; - - /** - * Lists the type of line of each line in $crontabs. - * can be: any of the CRON_* constants. - * so $linetype[5] is the type of $crontabs[5]. - * @var string - */ - private $linetypes; - - // }}} - - /** - * Constructor - * - * Initialises $this->crontabs - * - * @param string $user the user for whom the crontab will be manipulated - */ - function Crontab($user) - { - $this->user = $user; - $this->readCrontab(); - } - - /** - * This reads the crontab of $this->user and parses it in $this->crontabs - * - */ - function readCrontab() - { - // return code is 0 or 1 if crontab was empty, elsewhere stop here - $cmd = "crontab -u {$this->user} -l"; - @exec("crontab -u {$this->user} -l", $crons, $return); - if ($return > 1) { - return PEAR::raiseError("*** Can't read crontab ***\n". - " Set crontab manually!\n"); - } - - foreach ($crons as $line) - { - $line = trim($line); // discarding all prepending spaces and tabs - - // empty lines.. - if (!$line) { - $this->crontabs[] = "empty line"; - $this->linetypes[] = CRON_EMPTY; - continue; - } - - // checking if this is a comment - if ($line[0] == "#") { - $this->crontabs[] = trim($line); - $this->linetypes[] = CRON_COMMENT; - continue; - } - - // Checking if this is an assignment - if (ereg("(.*)=(.*)", $line, $assign)) { - $this->crontabs[] = array ("name" => $assign[1], "value" => $assign[2]); - $this->linetypes[] = CRON_ASSIGN; - continue; - } - - // Checking if this is a special @-entry. check man 5 crontab for more info - if ($line[0] == '@') { - $this->crontabs[] = split("[ \t]", $line, 2); - $this->linetypes[] = CRON_SPECIAL; - continue; - } - - // It's a regular crontab-entry - $ct = split("[ \t]", $line, 6); - $this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5]); - } - } - - /** - * Writes the current crontab - */ - function writeCrontab() - { - global $DEBUG, $PATH; - - if (empty($this->linetypes)) { - return; - } - $filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron")); - $file = fopen($filename, "w"); - - foreach($this->linetypes as $i => $line) { - switch ($this->linetypes[$i]) { - case CRON_COMMENT: - $line = $this->crontabs[$i]; - break; - case CRON_ASSIGN: - $line = $this->crontabs[$i][name]." = ".$this->crontabs[$i][value]; - break; - case CRON_CMD: - $line = implode(" ", $this->crontabs[$i]); - break; - case CRON_SPECIAL: - $line = implode(" ", $this->crontabs[$i]); - break; - case CRON_EMPTY: - $line = "\n"; // an empty line in the crontab-file - break; - default: - unset($line); - echo "Something very weird is going on. This line ($i) has an unknown type.\n"; - break; - } - - // echo "line $i : $line\n"; - - if ($line) { - $r = @fwrite($file, $line."\n"); - if($r === FALSE) { - return PEAR::raiseError("*** Can't write crontab ***\n". - " Set crontab manually!\n"); - } - } - } - fclose($file); - - if ($DEBUG) { - echo "DEBUGMODE: not updating crontab. writing to $filename instead.\n"; - } else { - exec("crontab -u {$this->user} $filename", $returnar, $return); - if ($return != 0) { - echo "Error running crontab ($return). $filename not deleted\n"; - } else { - unlink($filename); - } - } - } - - - /** - * Add a item of type CRON_CMD to the end of $this->crontabs - * - * @param string $m - * minute - * @param string $h - * hour - * @param string $dom - * day of month - * @param string $mo - * month - * @param string $dow - * day of week - * @param string $cmd - * command - * - */ - function addCron($m, $h, $dom, $mo, $dow, $cmd) - { - $this->crontabs[] = array ("minute" => $m, "hour" => $h, "dayofmonth" => $dom, "month" => $mo, "dayofweek" => $dow, "command" => $cmd); - $this->linetypes[] = CRON_CMD; - } - - - /** - * Add a comment to the cron to the end of $this->crontabs - * - * @param string $comment - */ - function addComment($comment) - { - $this->crontabs[] = "# $comment\n"; - $this->linetypes[] = CRON_COMMENT; - } - - - /** - * Add a special command (check man 5 crontab for more information) - * - * @param string $sdate special date - * string meaning - * ------ ------- - * @reboot Run once, at startup. - * @yearly Run once a year, "0 0 1 1 *". - * @annually (same as @yearly) - * @monthly Run once a month, "0 0 1 * *". - * @weekly Run once a week, "0 0 * * 0". - * @daily Run once a day, "0 0 * * *". - * @midnight (same as @daily) - * @hourly Run once an hour, "0 * * * *". - * @param string $cmd command - */ - function addSpecial($sdate, $cmd) - { - $this->crontabs[] = array ("special" => $sdate, "command" => $cmd); - $this->linetypes[] = CRON_SPECIAL; - } - - - /** - * Add an assignment (name = value) - * - * @param string $name - * @param string $value - */ - function addAssign($name, $value) - { - $this->crontabs[] = array ("name" => $name, "value" => $value); - $this->linetypes[] = CRON_ASSIGN; - } - - - /** - * Delete a line from the arrays. - * - * @param int $index the index in $this->crontabs - */ - function delEntry($index) - { - unset ($this->crontabs[$index]); - unset ($this->linetypes[$index]); - } - - - /** - * Get all the lines of a certain type in an array - * - * @param string $type - */ - function getByType($type) - { - if ($type < CRON_COMMENT || $type > CRON_EMPTY) - { - trigger_error("Wrong type: $type", E_USER_WARNING); - return 0; - } - - $returnar = array (); - for ($i = 0; $i < count($this->linetypes); $i ++) - if ($this->linetypes[$i] == $type) - $returnar[] = $this->crontabs[$i]; - - return $returnar; - } -} - diff --git a/airtime_mvc/application/models/cron/croncall.php b/airtime_mvc/application/models/cron/croncall.php deleted file mode 100755 index 1c46966ae..000000000 --- a/airtime_mvc/application/models/cron/croncall.php +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/php -execute($p['params']); -exit(0); diff --git a/airtime_mvc/application/models/tests/SchedulerExportTests.php b/airtime_mvc/application/models/tests/SchedulerExportTests.php index 50b80e946..24a6813ba 100644 --- a/airtime_mvc/application/models/tests/SchedulerExportTests.php +++ b/airtime_mvc/application/models/tests/SchedulerExportTests.php @@ -12,30 +12,30 @@ class SchedulerExportTests extends PHPUnit_TestCase { // Add a file $values = array("filepath" => dirname(__FILE__)."/test10001.mp3"); - $this->storedFile = StoredFile::Insert($values, false); + $this->storedFile = Application_Model_StoredFile::Insert($values, false); // Add a file $values = array("filepath" => dirname(__FILE__)."/test10002.mp3"); - $this->storedFile2 = StoredFile::Insert($values, false); + $this->storedFile2 = Application_Model_StoredFile::Insert($values, false); // Clear the schedule table $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]; $CC_DBC->query($sql); // Create a playlist - $playlist = new Playlist(); + $playlist = new Application_Model_Playlist(); $playlist->create("Scheduler Unit Test"); $result = $playlist->addAudioClip($this->storedFile->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); // Schedule it - $i = new ScheduleGroup(); + $i = new Application_Model_ScheduleGroup(); $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId()); } public function testExport() { - echo Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00"); + echo Application_Model_Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00"); } } diff --git a/airtime_mvc/application/models/tests/SchedulerTests.php b/airtime_mvc/application/models/tests/SchedulerTests.php index 8f86b4ef9..e4094c313 100644 --- a/airtime_mvc/application/models/tests/SchedulerTests.php +++ b/airtime_mvc/application/models/tests/SchedulerTests.php @@ -16,11 +16,11 @@ class SchedulerTests extends PHPUnit_TestCase { // Add a file $values = array("filepath" => dirname(__FILE__)."/test10001.mp3"); - $this->storedFile = StoredFile::Insert($values, false); + $this->storedFile = Application_Model_StoredFile::Insert($values, false); // Add a file $values = array("filepath" => dirname(__FILE__)."/test10002.mp3"); - $this->storedFile2 = StoredFile::Insert($values, false); + $this->storedFile2 = Application_Model_StoredFile::Insert($values, false); // Clear the schedule table //$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]; @@ -29,14 +29,14 @@ class SchedulerTests extends PHPUnit_TestCase { function testDateToId() { $dateStr = "2006-04-02 10:20:08.123456"; - $id = ScheduleGroup::dateToId($dateStr); + $id = Application_Model_ScheduleGroup::dateToId($dateStr); $expected = "20060402102008123"; if ($id != $expected) { $this->fail("Did not convert date to ID correctly #1: $id != $expected"); } $dateStr = "2006-04-02 10:20:08"; - $id = ScheduleGroup::dateToId($dateStr); + $id = Application_Model_ScheduleGroup::dateToId($dateStr); $expected = "20060402102008000"; if ($id != $expected) { $this->fail("Did not convert date to ID correctly #2: $id != $expected"); @@ -44,13 +44,13 @@ class SchedulerTests extends PHPUnit_TestCase { } function testAddAndRemoveAudioFile() { - $i = new ScheduleGroup(); + $i = new Application_Model_ScheduleGroup(); $this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId()); if (PEAR::isError($this->groupIdCreated)) { $this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage()); } - $i = new ScheduleGroup($this->groupIdCreated); + $i = new Application_Model_ScheduleGroup($this->groupIdCreated); $result = $i->remove(); if ($result != 1) { $this->fail("Did not remove item."); @@ -59,18 +59,18 @@ class SchedulerTests extends PHPUnit_TestCase { function testAddAndRemovePlaylist() { // Create a playlist - $playlist = new Playlist(); + $playlist = new Application_Model_Playlist(); $playlist->create("Scheduler Unit Test ".uniqid()); $result = $playlist->addAudioClip($this->storedFile->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); - $i = new ScheduleGroup(); + $i = new Application_Model_ScheduleGroup(); $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId()); if (PEAR::isError($this->groupIdCreated)) { $this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage()); } - $group = new ScheduleGroup($this->groupIdCreated); + $group = new Application_Model_ScheduleGroup($this->groupIdCreated); if ($group->count() != 3) { $this->fail("Wrong number of items added."); } @@ -84,17 +84,17 @@ class SchedulerTests extends PHPUnit_TestCase { $this->fail("Did not remove item."); } - Playlist::Delete($playlist->getId()); + Application_Model_Playlist::Delete($playlist->getId()); } function testIsScheduleEmptyInRange() { - $i = new ScheduleGroup(); + $i = new Application_Model_ScheduleGroup(); $this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId()); if (PEAR::isError($this->groupIdCreated)) { $this->fail($this->groupIdCreated->getMessage()); return; } - if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) { + if (Application_Model_Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) { $this->fail("Reporting empty schedule when it isnt."); return; } @@ -104,7 +104,7 @@ class SchedulerTests extends PHPUnit_TestCase { $this->fail("Failed to delete schedule group."); return; } - if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) { + if (!Application_Model_Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) { $this->fail("Reporting booked schedule when it isnt."); return; } @@ -112,11 +112,11 @@ class SchedulerTests extends PHPUnit_TestCase { /* function testGetItems() { - $i1 = new ScheduleGroup(); + $i1 = new Application_Model_ScheduleGroup(); $groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId()); - $i2 = new ScheduleGroup(); + $i2 = new Application_Model_ScheduleGroup(); $i2->addAfter($groupId1, $this->storedFile->getId()); - $items = Schedule::GetItems("2008-01-01", "2008-01-02"); + $items = Application_Model_Schedule::GetItems("2008-01-01", "2008-01-02"); if (count($items) != 2) { $this->fail("Wrong number of items returned."); return; diff --git a/airtime_mvc/application/models/tests/StoredFileTests.php b/airtime_mvc/application/models/tests/StoredFileTests.php index 8ee3bea13..a1d0b68d2 100644 --- a/airtime_mvc/application/models/tests/StoredFileTests.php +++ b/airtime_mvc/application/models/tests/StoredFileTests.php @@ -43,7 +43,7 @@ class StoredFileTest extends PHPUnit_TestCase { // Delete any old data from previous tests $md5 = md5_file($filePath); - $duplicate = StoredFile::RecallByMd5($md5); + $duplicate = Application_Model_StoredFile::RecallByMd5($md5); if ($duplicate) { $duplicate->delete(); } @@ -51,7 +51,7 @@ class StoredFileTest extends PHPUnit_TestCase { // Test inserting a file by linking $values = array("filepath" => $filePath, "dc:description" => "Unit test ".time()); - $storedFile = StoredFile::Insert($values, false); + $storedFile = Application_Model_StoredFile::Insert($values, false); if (PEAR::isError($storedFile)) { $this->fail("Failed to create StoredFile: ".$storedFile->getMessage()); return; @@ -64,7 +64,7 @@ class StoredFileTest extends PHPUnit_TestCase { } // Test loading metadata - $f = new StoredFile(); + $f = new Application_Model_StoredFile(); $f->__setGunid($storedFile->getGunid()); $f->loadMetadata(); if (!is_array($md = $f->getMetadata())) { @@ -74,7 +74,7 @@ class StoredFileTest extends PHPUnit_TestCase { //var_dump($md); // Check if the length field has been set. - $f2 = StoredFile::RecallByGunid($storedFile->getGunid()); + $f2 = Application_Model_StoredFile::RecallByGunid($storedFile->getGunid()); $m2 = $f2->getMetadata(); if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") { $this->fail("Length not reporting correctly in metadata."); diff --git a/airtime_mvc/application/models/tests/populator.php b/airtime_mvc/application/models/tests/populator.php index 4a83e6ff0..6d70e1fbb 100644 --- a/airtime_mvc/application/models/tests/populator.php +++ b/airtime_mvc/application/models/tests/populator.php @@ -1,7 +1,7 @@ query($sql); /* // Create a playlist -$playlist = new Playlist(); +$playlist = new Application_Model_Playlist(); $playlist->create("Calendar Load test playlist ".uniqid()); // Add a file $values = array("filepath" => __DIR__."/test10001.mp3"); -$storedFile = StoredFile::Insert($values, false); +$storedFile = Application_Model_StoredFile::Insert($values, false); $result = $playlist->addAudioClip($storedFile->getId()); // Add a file $values = array("filepath" => __DIR__."/test10002.mp3"); -$storedFile2 = StoredFile::Insert($values, false); +$storedFile2 = Application_Model_StoredFile::Insert($values, false); $result = $playlist->addAudioClip($storedFile2->getId()); $result = $playlist->addAudioClip($storedFile2->getId()); @@ -62,13 +62,13 @@ function createTestShow($showNumber, $showTime, $duration = "1:00") $data['add_show_background_color'] = ""; $data['add_show_record'] = 0; $data['add_show_hosts'] =""; - $showId = Show::create($data); + $showId = Application_Model_Show::create($data); //echo "show created, ID: $showId\n"; // populating the show with a playlist - $instances = Show::getShows($showTime->format("Y-m-d H:i:s"), $showTime->format("Y-m-d H:i:s")); + $instances = Application_Model_Show::getShows($showTime->format("Y-m-d H:i:s"), $showTime->format("Y-m-d H:i:s")); $instance = array_pop($instances); - $show = new ShowInstance($instance["instance_id"]); + $show = new Application_Model_ShowInstance($instance["instance_id"]); //echo "Adding playlist to show instance ".$show->getShowInstanceId()."\n"; $show->scheduleShow(array(1)); //echo "done\n"; @@ -96,7 +96,11 @@ while ($showTime < $endDate) { } $showNumber = $showNumber + 1; } -RabbitMq::PushScheduleFinal(); + +if (Application_Model_RabbitMq::$doPush) { + $md = array('schedule' => Application_Model_Schedule::GetScheduledPlaylists()); + Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md); +} diff --git a/airtime_mvc/application/views/helpers/IsSaas.php b/airtime_mvc/application/views/helpers/IsSaas.php new file mode 100644 index 000000000..0e8bc0cee --- /dev/null +++ b/airtime_mvc/application/views/helpers/IsSaas.php @@ -0,0 +1,12 @@ +diff($datetime2); + if($interval->format('%R') == '-'){ + return "Trial expired."; + } + return $interval->format('%a days'); + } +} diff --git a/airtime_mvc/application/views/scripts/api/status.phtml b/airtime_mvc/application/views/scripts/api/status.phtml new file mode 100644 index 000000000..1cffa8b84 --- /dev/null +++ b/airtime_mvc/application/views/scripts/api/status.phtml @@ -0,0 +1,3 @@ + +

About

+

+Airtime , the open radio software for scheduling and remote station management.
+© 2011 Sourcefabric o.p.s 2011. Airtime is distributed under the GNU GPL v.3 +

+
+
+
+
+
+
+
+
+
diff --git a/airtime_mvc/application/views/scripts/dashboard/help.phtml b/airtime_mvc/application/views/scripts/dashboard/help.phtml index 23411f640..60d1de162 100644 --- a/airtime_mvc/application/views/scripts/dashboard/help.phtml +++ b/airtime_mvc/application/views/scripts/dashboard/help.phtml @@ -11,6 +11,6 @@
  • Select your playlist and drag and drop it to the "Items in this show" area.
  • Then you're good to go!
    -For more detailed help, read the user manual

    +For more detailed help, read the user manual.

    diff --git a/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml b/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml new file mode 100644 index 000000000..7b9d6a796 --- /dev/null +++ b/airtime_mvc/application/views/scripts/dashboard/stream-player.phtml @@ -0,0 +1,84 @@ +
    +

    Live stream

    + + + +
    + + +
    + +
    +
    +
    + +
    + +
    diff --git a/airtime_mvc/application/views/scripts/error/error.phtml b/airtime_mvc/application/views/scripts/error/error.phtml index feea0c563..e84196941 100644 --- a/airtime_mvc/application/views/scripts/error/error.phtml +++ b/airtime_mvc/application/views/scripts/error/error.phtml @@ -6,24 +6,12 @@ Zend Framework Default Application -

    An error occurred

    -

    message ?>

    - - - -

    Exception information:

    -

    - Message: exception->getMessage() ?> -

    - -

    Stack trace:

    -
    exception->getTraceAsString() ?>
    -  
    - -

    Request Parameters:

    -
    request->getParams(), 1) ?>
    -  
    - - +
    +

    Page not found!

    +

    Looks like the page you were looking for doesn't exist!

    +
    + Help +
    +
    diff --git a/airtime_mvc/application/views/scripts/form/add-show-when.phtml b/airtime_mvc/application/views/scripts/form/add-show-when.phtml new file mode 100644 index 000000000..6f3591ac6 --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/add-show-when.phtml @@ -0,0 +1,65 @@ +
    +
    +
    + +
    +
    + element->getElement('add_show_start_date') ?> + element->getElement('add_show_start_time') ?> +
    + element->getElement('add_show_start_date')->hasErrors() || $this->element->getElement('add_show_start_time')->hasErrors()){ ?> +
      + element->getElement('add_show_start_date')->getMessages() as $error): ?> +
    • + + element->getElement('add_show_start_time')->getMessages() as $error): ?> +
    • + +
    + +
    + +
    + +
    + element->getElement('add_show_end_date_no_repeat') ?> + element->getElement('add_show_end_time') ?> +
    + element->getElement('add_show_end_date_no_repeat')->hasErrors() || $this->element->getElement('add_show_end_time')->hasErrors()){ ?> +
      + element->getElement('add_show_end_date_no_repeat')->getMessages() as $error): ?> +
    • + + element->getElement('add_show_end_time')->getMessages() as $error): ?> +
    • + +
    + +
    + +
    +
    + element->getElement('add_show_duration') ?> +
    + element->getElement('add_show_duration')->hasErrors()){ ?> +
      + element->getElement('add_show_duration')->getMessages() as $error): ?> +
    • + +
    + +
    + element->getElement('add_show_repeats')->getLabel() ?> +
    +
    + element->getElement('add_show_repeats') ?> +
    +
    +
    + diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index b085f25f3..f8d7b23f7 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -72,6 +72,48 @@ - + +
    + +
    +
    + element->getElement('timezone') ?> + element->getElement('timezone')->hasErrors()) : ?> + + +
    + + +
    + +
    +
    + element->getElement('weekStartDay')->getValue(); + ?> + + + element->getElement('weekStartDay')->hasErrors()) : ?> + + +
    diff --git a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml index 3ee3ad54e..99456616a 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml @@ -1,6 +1,19 @@
    -
    +
    + + element->getElement('UploadToSoundcloudOption')->hasErrors()) : ?> +
      + element->getElement('UploadToSoundcloudOption')->getMessages() as $error): ?> +
    • + +
    + +
    +
    +
    + + element->getElement('SoundCloudDownloadbleOption')->hasErrors()) : ?> +
      + element->getElement('SoundCloudDownloadbleOption')->getMessages() as $error): ?> +
    • + +
    + +
    diff --git a/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml b/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml index 48da6eed6..f384eb752 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml @@ -16,7 +16,7 @@ -
    Current Storage Folder:getDirectory(); ?>
    +
    Current Import Folder:getDirectory(); ?>
    @@ -33,7 +33,7 @@ - + 0): ?> diff --git a/airtime_mvc/application/views/scripts/form/register-dialog.phtml b/airtime_mvc/application/views/scripts/form/register-dialog.phtml index 58a0d55b6..acb461be5 100644 --- a/airtime_mvc/application/views/scripts/form/register-dialog.phtml +++ b/airtime_mvc/application/views/scripts/form/register-dialog.phtml @@ -21,7 +21,7 @@
    Click the box below to advertise your station on - Sourcefabric.org. + Sourcefabric.org. In order to promote your station, "Send support feedback" must be enabled. This data will be collected in addition to the support feedback.
    @@ -140,7 +140,7 @@
    element->getView()->logoImg){?> -
    +
    element->getElement('Logo') ?> @@ -166,10 +166,14 @@

    - + privacyChecked){?> + + + Terms and Conditions +
    - \ No newline at end of file + diff --git a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml new file mode 100644 index 000000000..07f8bf9bc --- /dev/null +++ b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml @@ -0,0 +1,165 @@ + stream_number; + ?> +

    Stream stream_number?>

    +
    stream_number != '1'?'style="display: none;':''?> id="-config"> +
    +
    +
    + +
    +
    + liquidsoap_error_msg?> +
    +
    + +
    +
    + element->getElement('enable')?> +
    + +
    + +
    +
    + element->getElement('type')?> +
    + +
    + +
    +
    + element->getElement('bitrate')?> +
    +
    + +
    +
    + element->getElement('host')?> + element->getElement('host')->hasErrors()) : ?> +
      + element->getElement('host')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + +
    +
    + element->getElement('port')?> + element->getElement('port')->hasErrors()) : ?> +
      + element->getElement('port')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + +
    +
    + element->getElement('output')?> +
    + +
    + + + Additional Options + +
    +
    + +
    +
    + element->getElement('user')?> + element->getElement('user')->hasErrors()) : ?> +
      + element->getElement('user')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + +
    +
    + element->getElement('pass')?> + element->getElement('pass')->hasErrors()) : ?> +
      + element->getElement('pass')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + The following info will be displayed to listeners in their media player: +
    +
    + +
    +
    + element->getElement('description')?> + element->getElement('description')->hasErrors()) : ?> +
      + element->getElement('description')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + +
    +
    + element->getElement('url')?> + (Your radio station website) + element->getElement('url')->hasErrors()) : ?> +
      + element->getElement('url')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + +
    +
    + element->getElement('genre')?> + element->getElement('genre')->hasErrors()) : ?> +
      + element->getElement('genre')->getMessages() as $error): ?> +
    • + +
    + +
    +
    + +
    +
    + element->getElement('mount')?> + element->getElement('mount')->hasErrors()) : ?> +
      + element->getElement('mount')->getMessages() as $error): ?> +
    • + +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/form/support-setting.phtml b/airtime_mvc/application/views/scripts/form/support-setting.phtml index bb24b89ed..9794f8159 100644 --- a/airtime_mvc/application/views/scripts/form/support-setting.phtml +++ b/airtime_mvc/application/views/scripts/form/support-setting.phtml @@ -17,7 +17,7 @@
    Click the box below to advertise your station on - Sourcefabric.org. + Sourcefabric.org. In order to promote your station, "Send support feedback" must be enabled. This data will be collected in addition to the support feedback.
    element->getView()->logoImg){?> -
    +
    element->getElement('Logo') ?> @@ -159,16 +159,20 @@

    - - element->getElement('Privacy')->hasErrors()) : ?> - - + element->getView()->privacyChecked){?> + + element->getElement('Privacy')->hasErrors()) : ?> + + + + Terms and Conditions +
    - \ No newline at end of file + diff --git a/airtime_mvc/application/views/scripts/login/index.phtml b/airtime_mvc/application/views/scripts/login/index.phtml index 6a7476d10..ea6c24e41 100644 --- a/airtime_mvc/application/views/scripts/login/index.phtml +++ b/airtime_mvc/application/views/scripts/login/index.phtml @@ -1,11 +1,10 @@
    -
     
    -

    Login

    - - +
     
    +

    Login

    +
    diff --git a/airtime_mvc/application/views/scripts/menu.phtml b/airtime_mvc/application/views/scripts/menu.phtml index 9cf6c1aa5..0e6eb8dc1 100644 --- a/airtime_mvc/application/views/scripts/menu.phtml +++ b/airtime_mvc/application/views/scripts/menu.phtml @@ -1,3 +1,9 @@ + +
    + Listen +
    + is_trial){?> +
    + +
    +
    - - diff --git a/airtime_mvc/application/views/scripts/playlist/index.phtml b/airtime_mvc/application/views/scripts/playlist/index.phtml index 7987202c1..134cfa047 100644 --- a/airtime_mvc/application/views/scripts/playlist/index.phtml +++ b/airtime_mvc/application/views/scripts/playlist/index.phtml @@ -4,7 +4,6 @@ Playlist crossfade - pl)) : ?> diff --git a/airtime_mvc/application/views/scripts/plupload/index.phtml b/airtime_mvc/application/views/scripts/plupload/index.phtml index 92c98cc93..cf236b8d6 100644 --- a/airtime_mvc/application/views/scripts/plupload/index.phtml +++ b/airtime_mvc/application/views/scripts/plupload/index.phtml @@ -1,3 +1,8 @@ +
    diff --git a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml new file mode 100644 index 000000000..b86bbc855 --- /dev/null +++ b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml @@ -0,0 +1,35 @@ +
    +

    enable_stream_conf == "true"){?>style="float:left">Stream Settings

    + enable_stream_conf == "true"){?> +
    +
    + +
    +
    + +statusMsg;?> +
    + Hardware Audio Out +
    +
    + +
    +
    + form->getElement('output_sound_device') ?> +
    +
    +
    + num_stream;$i++){ + echo $this->form->getSubform("s".$i."_subform"); + } + ?> + enable_stream_conf == "true"){?> +
    + +
    + +
    +
    \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml index 8456fd6d1..b42b408d2 100644 --- a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml +++ b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml @@ -16,12 +16,14 @@ when; ?> repeats; ?> + isSaas()){?>

    Record & Rebroadcast

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

    Who

    who; ?> diff --git a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml index c830dd3da..8fb4346d0 100644 --- a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml +++ b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml @@ -12,11 +12,13 @@ showContent as $row): ?> " class=""> - + setTimezone(new DateTimeZone(date_default_timezone_get())); + echo $dt->format("Y-m-d H:i:s") ?> - + diff --git a/airtime_mvc/application/views/scripts/systemstatus/get-log-file.phtml b/airtime_mvc/application/views/scripts/systemstatus/get-log-file.phtml new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/airtime_mvc/application/views/scripts/systemstatus/get-log-file.phtml @@ -0,0 +1 @@ + diff --git a/airtime_mvc/application/views/scripts/systemstatus/index.phtml b/airtime_mvc/application/views/scripts/systemstatus/index.phtml new file mode 100644 index 000000000..d8fe2b940 --- /dev/null +++ b/airtime_mvc/application/views/scripts/systemstatus/index.phtml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + status->services as $key=>$value): ?> + " id=""> + + + + + + + + + + + +
    ServiceStatusUptimeCPUMemory
    Disk Space
    diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index 6895d3336..2cc0666bb 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -88,6 +88,10 @@ + + + + @@ -144,7 +148,6 @@ - @@ -166,6 +169,7 @@ + @@ -304,6 +308,7 @@ + @@ -315,4 +320,17 @@ + + + + +
    + + + +
    + + + +
    diff --git a/airtime_mvc/build/sql/defaultdata.sql b/airtime_mvc/build/sql/defaultdata.sql index 7b2070f70..4728d4ee6 100644 --- a/airtime_mvc/build/sql/defaultdata.sql +++ b/airtime_mvc/build/sql/defaultdata.sql @@ -1,5 +1,53 @@ INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin')); +-- added in 2.0.0 +INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_type', 'ogg, mp3'); +INSERT INTO cc_pref("keystr", "valstr") VALUES('stream_bitrate', '24, 32, 48, 64, 96, 128, 160, 192, 224, 256, 320'); +INSERT INTO cc_pref("keystr", "valstr") VALUES('num_of_streams', '3'); +INSERT INTO cc_pref("keystr", "valstr") VALUES('max_bitrate', '320'); +INSERT INTO cc_pref("keystr", "valstr") VALUES('plan_level', 'disabled'); + +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device', 'false', 'boolean'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('icecast_vorbis_metadata', 'false', 'boolean'); + +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_output', 'icecast', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_type', 'ogg', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_bitrate', '128', 'integer'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_host', '127.0.0.1', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_port', '8000', 'integer'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_user', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_pass', 'hackme', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_mount', 'airtime_128', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_url', 'http://airtime.sourcefabric.org', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_description', 'Airtime Radio! Stream #1', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_genre', 'genre', 'string'); + +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_output', 'disabled', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_type', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_bitrate', '', 'integer'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_host', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_port', '', 'integer'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_user', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_pass', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_mount', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_url', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_description', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_genre', '', 'string'); + +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_output', 'disabled', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_type', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_bitrate', '', 'integer'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_host', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_port', '', 'integer'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_user', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_pass', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_mount', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_url', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_description', '', 'string'); +INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_genre', '', 'string'); +-- end of added in 2.0.0 + + INSERT INTO cc_country (isocode, name) VALUES ('AFG', 'Afghanistan '); INSERT INTO cc_country (isocode, name) VALUES ('ALA', 'Ã…land Islands'); INSERT INTO cc_country (isocode, name) VALUES ('ALB', 'Albania '); diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index e8ae9c5c3..ae1770f48 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -114,6 +114,10 @@ CREATE TABLE "cc_files" "subject" VARCHAR(512), "contributor" VARCHAR(512), "language" VARCHAR(512), + "soundcloud_id" INTEGER, + "soundcloud_error_code" INTEGER, + "soundcloud_error_msg" VARCHAR(512), + "soundcloud_link_to_file" VARCHAR(512), PRIMARY KEY ("id"), CONSTRAINT "cc_files_gunid_idx" UNIQUE ("gunid") ); @@ -191,7 +195,6 @@ CREATE TABLE "cc_show_instances" "rebroadcast" INT2 default 0, "instance_id" INTEGER, "file_id" INTEGER, - "soundcloud_id" INTEGER, "time_filled" TIME, PRIMARY KEY ("id") ); @@ -213,6 +216,7 @@ CREATE TABLE "cc_show_days" "first_show" DATE NOT NULL, "last_show" DATE, "start_time" TIME NOT NULL, + "timezone" VARCHAR(255) NOT NULL, "duration" VARCHAR(255) NOT NULL, "day" INT2, "repeat_type" INT2 NOT NULL, @@ -434,6 +438,7 @@ CREATE TABLE "cc_subjs" "skype_contact" VARCHAR(255), "jabber_contact" VARCHAR(255), "email" VARCHAR(255), + "login_attempts" INTEGER default 0, PRIMARY KEY ("id"), CONSTRAINT "cc_subjs_id_idx" UNIQUE ("id"), CONSTRAINT "cc_subjs_login_idx" UNIQUE ("login") @@ -460,6 +465,61 @@ CREATE TABLE "cc_country" COMMENT ON TABLE "cc_country" IS ''; +SET search_path TO public; +----------------------------------------------------------------------------- +-- cc_stream_setting +----------------------------------------------------------------------------- + +DROP TABLE "cc_stream_setting" CASCADE; + + +CREATE TABLE "cc_stream_setting" +( + "keyname" VARCHAR(64) NOT NULL, + "value" VARCHAR(255), + "type" VARCHAR(16) NOT NULL, + PRIMARY KEY ("keyname") +); + +COMMENT ON TABLE "cc_stream_setting" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- cc_login_attempts +----------------------------------------------------------------------------- + +DROP TABLE "cc_login_attempts" CASCADE; + + +CREATE TABLE "cc_login_attempts" +( + "ip" VARCHAR(32) NOT NULL, + "attempts" INTEGER default 0, + PRIMARY KEY ("ip") +); + +COMMENT ON TABLE "cc_login_attempts" IS ''; + + +SET search_path TO public; +----------------------------------------------------------------------------- +-- cc_service_register +----------------------------------------------------------------------------- + +DROP TABLE "cc_service_register" CASCADE; + + +CREATE TABLE "cc_service_register" +( + "name" VARCHAR(32) NOT NULL, + "ip" VARCHAR(18) NOT NULL, + PRIMARY KEY ("name") +); + +COMMENT ON TABLE "cc_service_register" IS ''; + + SET search_path TO public; ALTER TABLE "cc_access" ADD CONSTRAINT "cc_access_owner_fkey" FOREIGN KEY ("owner") REFERENCES "cc_subjs" ("id"); diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug.php new file mode 100644 index 000000000..830701a81 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug.php @@ -0,0 +1,485 @@ + array( + 'Variables' => null, + 'Time' => null, + 'Memory' => null), + 'z-index' => 255, + 'jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', + 'image_path' => null + ); + + /** + * Standard plugins + * + * @var array + */ + public static $standardPlugins = array('Cache', 'Html', 'Database', 'Exception', 'File', 'Memory', 'Registry', 'Time', 'Variables'); + + /** + * Debug Bar Version Number + * for internal use only + * + * @var string + */ + protected $_version = '1.5.4'; + + /** + * Creates a new instance of the Debug Bar + * + * @param array|Zend_Config $options + * @throws Zend_Controller_Exception + * @return void + */ + + protected $_closingBracket = null; + + public function __construct($options = null) + { + if (isset($options)) { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } + + /* + * Verify that adapter parameters are in an array. + */ + if (!is_array($options)) { + throw new Zend_Exception('Debug parameters must be in an array or a Zend_Config object'); + } + + $this->setOptions($options); + } + + /** + * Creating ZF Version Tab always shown + */ + $version = new ZFDebug_Controller_Plugin_Debug_Plugin_Text(); + $version->setPanel($this->_getVersionPanel()) + ->setTab($this->_getVersionTab()) + ->setIdentifier('copyright') + ->setIconData('data:image/gif;base64,R0lGODlhEAAQAPcAAPb7/ef2+VepAGKzAIC8SavSiYS9Stvt0uTx4fX6+ur1632+QMLgrGOuApDIZO738drs0Ofz5t7v2MfjtPP6+t7v12SzAcvnyX2+PaPRhH2+Qmy3H3K5LPP6+cXkwIHAR2+4JHi7NePz8YC/Rc3ozfH49XK5KXq9OrzdpNzu1YrEUqrVkdzw5uTw4d/v2dDow5zOeO3279Hq0m+4JqrUhpnMbeHw3N3w6Mflwm22HmazBODy7tfu3un06r7gsuXy4sTisIzGXvH59ny9PdPr1rXZpMzlu36/Q5bLb+Pw3tDnxNHr1Lfbm+b199/x62q1Fp3NcdjszqTPh/L599vt04/GWmazCPb7/LHZnW63I3W6MXa7MmGuAt/y7Gq1E2m0Eb7cp9frzZLJaO/489bu3HW3N7rerN/v2q7WjIjEVuLx343FVrDXj9nt0cTjvW2zIoPBSNjv4OT09IXDUpvLeeHw3dPqyNLpxs/nwHe8OIvFWrPaoGe0C5zMb83mvHm8Oen06a3Xl9XqyoC/Qr/htWe0DofDU4nFWbPYk7ndqZ/PfYPBTMPhrqHRgoLBSujz55PKadHpxfX6+6LNeqPQfNXt2pPIYH2+O7vcoHi4OOf2+PL5+NTs2N3u1mi1E7XZl4zEVJjLaZHGauby5KTShmSzBO/38s/oz3i7MtbrzMHiuYTCT4fDTtXqye327uDv3JDHXu328JnMcu738LLanvD49ZTJYpPKauX19tvv44jBWo7GWpfKZ+Dv27XcpcrluXu8ONTs16zXleT08qfUjKzUlc7pzm63HaTRfZXKZuj06HG4KavViGe0EcDfqcjmxaDQgZrNdOHz77/ep4/HYL3esnW6LobCS3S5K57OctDp0JXKbez17N7x6cbkwLTZlbXXmLrcnrvdodHr06PQe8jkt5jIa93v13m8OI7CW3O6L3a7Nb7gs6nUjmu2GqjTgZjKaKLQeZnMc4LAReL08rTbopbLbuTx4KDOdtbry7DYmrvfrrPaoXK5K5zOegAAACH5BAEAAAAALAAAAAAQABAAAAhMAAEIHEiwoMGDCBMOlCKgoUMuHghInEiggEOHAC5eJNhQ4UAuAjwIJLCR4AEBDQS2uHiAYLGOHjNqlCmgYAONApQ0jBGzp8+fQH8GBAA7'); + $this->registerPlugin($version); + + /** + * Loading aready defined plugins + */ + $this->_loadPlugins(); + } + + /** + * Sets options of the Debug Bar + * + * @param array $options + * @return ZFDebug_Controller_Plugin_Debug + */ + public function setOptions(array $options = array()) + { + if (isset($options['jquery_path'])) { + $this->_options['jquery_path'] = $options['jquery_path']; + } + + if (isset($options['z-index'])) { + $this->_options['z-index'] = $options['z-index']; + } + + if (isset($options['image_path'])) { + $this->_options['image_path'] = $options['image_path']; + } + + if (isset($options['plugins'])) { + $this->_options['plugins'] = $options['plugins']; + } + return $this; + } + + /** + * Register a new plugin in the Debug Bar + * + * @param ZFDebug_Controller_Plugin_Debug_Plugin_Interface + * @return ZFDebug_Controller_Plugin_Debug + */ + public function registerPlugin(ZFDebug_Controller_Plugin_Debug_Plugin_Interface $plugin) + { + $this->_plugins[$plugin->getIdentifier()] = $plugin; + return $this; + } + + /** + * Unregister a plugin in the Debug Bar + * + * @param string $plugin + * @return ZFDebug_Controller_Plugin_Debug + */ + public function unregisterPlugin($plugin) + { + if (false !== strpos($plugin, '_')) { + foreach ($this->_plugins as $key => $_plugin) { + if ($plugin == get_class($_plugin)) { + unset($this->_plugins[$key]); + } + } + } else { + $plugin = strtolower($plugin); + if (isset($this->_plugins[$plugin])) { + unset($this->_plugins[$plugin]); + } + } + return $this; + } + + /** + * Get a registered plugin in the Debug Bar + * + * @param string $identifier + * @return ZFDebug_Controller_Plugin_Debug_Plugin_Interface + */ + public function getPlugin($identifier) + { + $identifier = strtolower($identifier); + if (isset($this->_plugins[$identifier])) { + return $this->_plugins[$identifier]; + } + return false; + } + + /** + * Defined by Zend_Controller_Plugin_Abstract + */ + public function dispatchLoopShutdown() + { + if ($this->getRequest()->isXmlHttpRequest()) { + return; + } + $disable = Zend_Controller_Front::getInstance()->getRequest()->getParam('ZFDEBUG_DISABLE'); + if (isset($disable)) { + return; + } + + $html = ''; + + /** + * Creating menu tab for all registered plugins + */ + foreach ($this->_plugins as $plugin) + { + $panel = $plugin->getPanel(); + if ($panel == '') { + continue; + } + + /* @var $plugin ZFDebug_Controller_Plugin_Debug_Plugin_Interface */ + $html .= '
    ' . $panel . '
    '; + } + + $html .= '
    '; + + /** + * Creating panel content for all registered plugins + */ + foreach ($this->_plugins as $plugin) + { + $tab = $plugin->getTab(); + if ($tab == '') { + continue; + } + + if (null !== $this->_options['image_path'] && file_exists($this->_options['image_path'] .'/'. $plugin->getIdentifier() .'.png')) { + $plugin_icon = $this->_options['image_path'] .'/'. $plugin->getIdentifier() .'.png'; + } else { + $plugin_icon = $plugin->getIconData(); + } + + /* @var $plugin ZFDebug_Controller_Plugin_Debug_Plugin_Interface */ + $html .= ''; + $html .= '' . $plugin->getIdentifier() . 'getClosingBracket() .' '; + $html .= $tab . ''; + } + + $html .= '«'; + + $html .= '
    '; + $this->_output($html); + } + + ### INTERNAL METHODS BELOW ### + + /** + * Load plugins set in config option + * + * @return void; + */ + protected function _loadPlugins() + { + foreach($this->_options['plugins'] as $plugin => $options) { + if (is_numeric($plugin)) { + # Plugin passed as array value instead of key + $plugin = $options; + $options = array(); + } + + // Register an instance + if (is_object($plugin) && in_array('ZFDebug_Controller_Plugin_Debug_Plugin_Interface', class_implements($plugin))) { + $this->registerPlugin($plugin); + continue; + } + + if (!is_string($plugin)) { + throw new Exception("Invalid plugin name", 1); + } + $plugin = ucfirst($plugin); + + // Register a classname + if (in_array($plugin, ZFDebug_Controller_Plugin_Debug::$standardPlugins)) { + // standard plugin + $pluginClass = 'ZFDebug_Controller_Plugin_Debug_Plugin_' . $plugin; + } else { + // we use a custom plugin + if (!preg_match('~^[\w]+$~D', $plugin)) { + throw new Zend_Exception("ZFDebug: Invalid plugin name [$plugin]"); + } + $pluginClass = $plugin; + } + + require_once str_replace('_', DIRECTORY_SEPARATOR, $pluginClass) . '.php'; + $object = new $pluginClass($options); + $this->registerPlugin($object); + } + } + + /** + * Return version tab + * + * @return string + */ + protected function _getVersionTab() + { + return ' ' . Zend_Version::VERSION . '/'.phpversion(); + } + + /** + * Returns version panel + * + * @return string + */ + protected function _getVersionPanel() + { + $panel = '

    ZFDebug v'.$this->_version.'

    ' . + '

    ©2008-2009 Joakim Nygård & Andreas Pankratz

    ' . + '

    The project is hosted at http://zfdebug.googlecode.com and released under the BSD License' . $this->getLinebreak() . + 'Includes images from the Silk Icon set by Mark James

    '. + '

    Disable ZFDebug temporarily by sending ZFDEBUG_DISABLE as a GET/POST parameter

    '; + // $panel .= '

    Zend Framework '.Zend_Version::VERSION.' / PHP '.phpversion().' with extensions:

    '; + // $extensions = get_loaded_extensions(); + // natcasesort($extensions); + // $panel .= implode('
    ', $extensions); + return $panel; + } + + /** + * Returns path to the specific icon + * + * @return string + */ + protected function _icon($kind) + { + switch ($kind) { + case 'database': + if (null === $this->_options['image_path']) + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC'; + + return $this->_options['image_path'] . '/database.png'; + break; + case 'exception': + if (null === $this->_options['image_path']) + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJPSURBVDjLpZPLS5RhFMYfv9QJlelTQZwRb2OKlKuINuHGLlBEBEOLxAu46oL0F0QQFdWizUCrWnjBaDHgThCMoiKkhUONTqmjmDp2GZ0UnWbmfc/ztrC+GbM2dXbv4ZzfeQ7vefKMMfifyP89IbevNNCYdkN2kawkCZKfSPZTOGTf6Y/m1uflKlC3LvsNTWArr9BT2LAf+W73dn5jHclIBFZyfYWU3or7T4K7AJmbl/yG7EtX1BQXNTVCYgtgbAEAYHlqYHlrsTEVQWr63RZFuqsfDAcdQPrGRR/JF5nKGm9xUxMyr0YBAEXXHgIANq/3ADQobD2J9fAkNiMTMSFb9z8ambMAQER3JC1XttkYGGZXoyZEGyTHRuBuPgBTUu7VSnUAgAUAWutOV2MjZGkehgYUA6O5A0AlkAyRnotiX3MLlFKduYCqAtuGXpyH0XQmOj+TIURt51OzURTYZdBKV2UBSsOIcRp/TVTT4ewK6idECAihtUKOArWcjq/B8tQ6UkUR31+OYXP4sTOdisivrkMyHodWejlXwcC38Fvs8dY5xaIId89VlJy7ACpCNCFCuOp8+BJ6A631gANQSg1mVmOxxGQYRW2nHMha4B5WA3chsv22T5/B13AIicWZmNZ6cMchTXUe81Okzz54pLi0uQWp+TmkZqMwxsBV74Or3od4OISPr0e3SHa3PX0f3HXKofNH/UIG9pZ5PeUth+CyS2EMkEqs4fPEOBJLsyske48/+xD8oxcAYPzs4QaS7RR2kbLTTOTQieczfzfTv8QPldGvTGoF6/8AAAAASUVORK5CYII='; + + return $this->_options['image_path'] . '/exception.png'; + break; + case 'error': + if (null === $this->_options['image_path']) + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIsSURBVDjLpVNLSJQBEP7+h6uu62vLVAJDW1KQTMrINQ1vPQzq1GOpa9EppGOHLh0kCEKL7JBEhVCHihAsESyJiE4FWShGRmauu7KYiv6Pma+DGoFrBQ7MzGFmPr5vmDFIYj1mr1WYfrHPovA9VVOqbC7e/1rS9ZlrAVDYHig5WB0oPtBI0TNrUiC5yhP9jeF4X8NPcWfopoY48XT39PjjXeF0vWkZqOjd7LJYrmGasHPCCJbHwhS9/F8M4s8baid764Xi0Ilfp5voorpJfn2wwx/r3l77TwZUvR+qajXVn8PnvocYfXYH6k2ioOaCpaIdf11ivDcayyiMVudsOYqFb60gARJYHG9DbqQFmSVNjaO3K2NpAeK90ZCqtgcrjkP9aUCXp0moetDFEeRXnYCKXhm+uTW0CkBFu4JlxzZkFlbASz4CQGQVBFeEwZm8geyiMuRVntzsL3oXV+YMkvjRsydC1U+lhwZsWXgHb+oWVAEzIwvzyVlk5igsi7DymmHlHsFQR50rjl+981Jy1Fw6Gu0ObTtnU+cgs28AKgDiy+Awpj5OACBAhZ/qh2HOo6i+NeA73jUAML4/qWux8mt6NjW1w599CS9xb0mSEqQBEDAtwqALUmBaG5FV3oYPnTHMjAwetlWksyByaukxQg2wQ9FlccaK/OXA3/uAEUDp3rNIDQ1ctSk6kHh1/jRFoaL4M4snEMeD73gQx4M4PsT1IZ5AfYH68tZY7zv/ApRMY9mnuVMvAAAAAElFTkSuQmCC'; + + return $this->_options['image_path'] . '/error.png'; + break; + default: + if (null === $this->_options['image_path']) + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHhSURBVDjLpZI9SJVxFMZ/r2YFflw/kcQsiJt5b1ije0tDtbQ3GtFQYwVNFbQ1ujRFa1MUJKQ4VhYqd7K4gopK3UIly+57nnMaXjHjqotnOfDnnOd/nt85SURwkDi02+ODqbsldxUlD0mvHw09ubSXQF1t8512nGJ/Uz/5lnxi0tB+E9QI3D//+EfVqhtppGxUNzCzmf0Ekojg4fS9cBeSoyzHQNuZxNyYXp5ZM5Mk1ZkZT688b6thIBenG/N4OB5B4InciYBCVyGnEBHO+/LH3SFKQuF4OEs/51ndXMXC8Ajqknrcg1O5PGa2h4CJUqVES0OO7sYevv2qoFBmJ/4gF4boaOrg6rPLYWaYiVfDo0my8w5uj12PQleB0vcp5I6HsHAUoqUhR29zH+5B4IxNTvDmxljy3x2YCYUwZVlbzXJh9UKeQY6t2m0Lt94Oh5loPdqK3EkjzZi4MM/Y9Db3MTv/mYWVxaqkw9IOATNR7B5ABHPrZQrtg9sb8XDKa1+QOwsri4zeHD9SAzE1wxBTXz9xtvMc5ZU5lirLSKIz18nJnhOZjb22YKkhd4odg5icpcoyL669TAAujlyIvmPHSWXY1ti1AmZ8mJ3ElP1ips1/YM3H300g+W+51nc95YPEX8fEbdA2ReVYAAAAAElFTkSuQmCC'; + + return $this->_options['image_path'] . '/unknown.png'; + break; + } + } + + /** + * Returns html header for the Debug Bar + * + * @return string + */ + protected function _headerOutput() { + $collapsed = isset($_COOKIE['ZFDebugCollapsed']) ? $_COOKIE['ZFDebugCollapsed'] : 0; + + return (' + + '); + } + + /** + * Appends Debug Bar html output to the original page + * + * @param string $html + * @return void + */ + protected function _output($html) + { + $response = $this->getResponse(); + $response->setBody(preg_replace('/(<\/head>)/i', $this->_headerOutput() . '$1', $response->getBody())); + $response->setBody(str_ireplace('', '
    '.$html.'
    ', $response->getBody())); + } + + public function getLinebreak() + { + return 'getClosingBracket(); + } + + public function getClosingBracket() + { + if (!$this->_closingBracket) { + if ($this->_isXhtml()) { + $this->_closingBracket = ' />'; + } else { + $this->_closingBracket = '>'; + } + } + + return $this->_closingBracket; + } + + protected function _isXhtml() + { + if ($view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view) { + $doctype = $view->doctype(); + return $doctype->isXhtml(); + } + return false; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin.php new file mode 100644 index 000000000..c5d408597 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin.php @@ -0,0 +1,92 @@ +getClosingBracket(); + } + + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHhSURBVDjLpZI9SJVxFMZ/r2YFflw/kcQsiJt5b1ije0tDtbQ3GtFQYwVNFbQ1ujRFa1MUJKQ4VhYqd7K4gopK3UIly+57nnMaXjHjqotnOfDnnOd/nt85SURwkDi02+ODqbsldxUlD0mvHw09ubSXQF1t8512nGJ/Uz/5lnxi0tB+E9QI3D//+EfVqhtppGxUNzCzmf0Ekojg4fS9cBeSoyzHQNuZxNyYXp5ZM5Mk1ZkZT688b6thIBenG/N4OB5B4InciYBCVyGnEBHO+/LH3SFKQuF4OEs/51ndXMXC8Ajqknrcg1O5PGa2h4CJUqVES0OO7sYevv2qoFBmJ/4gF4boaOrg6rPLYWaYiVfDo0my8w5uj12PQleB0vcp5I6HsHAUoqUhR29zH+5B4IxNTvDmxljy3x2YCYUwZVlbzXJh9UKeQY6t2m0Lt94Oh5loPdqK3EkjzZi4MM/Y9Db3MTv/mYWVxaqkw9IOATNR7B5ABHPrZQrtg9sb8XDKa1+QOwsri4zeHD9SAzE1wxBTXz9xtvMc5ZU5lirLSKIz18nJnhOZjb22YKkhd4odg5icpcoyL669TAAujlyIvmPHSWXY1ti1AmZ8mJ3ElP1ips1/YM3H300g+W+51nc95YPEX8fEbdA2ReVYAAAAAElFTkSuQmCC'; + } + + public function getClosingBracket() + { + if (!$this->_closingBracket) { + if ($this->_isXhtml()) { + $this->_closingBracket = ' />'; + } else { + $this->_closingBracket = '>'; + } + } + + return $this->_closingBracket; + } + + protected function _isXhtml() + { + $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view; + $doctype = $view->doctype(); + return $doctype->isXhtml(); + } + + /** + * Transforms data into readable format + * + * @param array $values + * @return string + */ + protected function _cleanData($values) + { + $linebreak = $this->getLinebreak(); + + if (is_array($values)) { + ksort($values); + } + $retVal = '
    '; + foreach ($values as $key => $value) + { + $key = htmlspecialchars($key); + if (is_numeric($value)) { + $retVal .= $key.' => '.$value.$linebreak; + } + else if (is_string($value)) { + $retVal .= $key.' => \''.htmlspecialchars($value).'\''.$linebreak; + } + else if (is_array($value)) + { + $retVal .= $key.' => '.self::_cleanData($value); + } + else if (is_object($value)) + { + $retVal .= $key.' => '.get_class($value).' Object()'.$linebreak; + } + else if (is_null($value)) + { + $retVal .= $key.' => NULL'.$linebreak; + } + } + return $retVal.'
    '; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php new file mode 100644 index 000000000..54ce22318 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php @@ -0,0 +1,129 @@ +_auth = Zend_Auth::getInstance(); + if (isset($options['user'])) { + $this->_user = $options['user']; + } + if (isset($options['role'])) { + $this->_role = $options['role']; + } + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJ3SURBVDjLpZNtSNNRFIcNKunF1rZWBMJqKaSiX9RP1dClsjldA42slW0q5oxZiuHrlqllLayoaJa2jbm1Lc3QUZpKFmmaTMsaRp+kMgjBheSmTL2//kqMBJlFHx44XM7vOfdyuH4A/P6HFQ9zo7cpa/mM6RvCrVDzaVDy6C5JJKv6rwSnIhlFd0R0Up/GwF2KWyl01CTSkM/dQoQRzAurCjRCGnRUUE2FaoSL0HExiYVzsQwcj6RNrSqo4W5Gh6Yc4+1qDDTkIy+GhYK4nTgdz0H2PrrHUJzs71NQn86enPn+CVN9GnzruoYR63mMPbkC59gQzDl7pt7rc9f7FNyUhPY6Bx9gwt4E9zszhWWpdg6ZcS8j3O7zCTuEpnXB+3MNZkUUZu0NmHE8XsL91oSWwiiEc3MeseLrN6woYCWa/Zl8ozyQ3w3Hl2lYy0SwlCUvsVi/Gv2JwITnYPDun2Hy6jYuEzAF1jUBCVYpO6kXo+NuGMeBAgcgfwNkvgBOPgUqXgKvP7rBFvRhE1crp8Vq1noFYSlacVyqGk0D86gbART9BDk9BFnPCNJbCY5aCFL1Cyhtp0RWAp74MsKSrkq9guHyvfMTtmLc1togpZoyqYmyNoITzVTYRJCiXYBIQ3CwFqi83o3JDhX6C0M8XsGIMoQ4OyuRlq1DdZcLkmbgGDX1iIEKNxAcbgTEOqC4ZRaJ6Ub86K7CYFEo8Qo+GBQlQyXBczLZpbloaQ9k1NUz/kD2myBBKxRZpa5hVcQslalatoUxizxAVVrN3CW21bFj9F858Q9dnIRmDyeuybM71uxmH9BNBB1q6zybV7H9s1Ue4PM3/gu/AEbfqfWy2twsAAAAAElFTkSuQmCC'; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + $username = 'Not Authed'; + $role = 'Unknown Role'; + + if(!$this->_auth->hasIdentity()) { + return 'Not authorized'; + } + $identity = $this->_auth->getIdentity(); + if (is_object($identity)) { + $username = $this->_auth->getIdentity()->{$this->_user}; + $role = $this->_auth->getIdentity()->{$this->_role}; + } + else { + $username = $this->_auth->getIdentity(); + $role = ''; + } + return $username . ' (' . $role . ')'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + return ''; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php new file mode 100644 index 000000000..b9a35536f --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php @@ -0,0 +1,132 @@ + $backend) { + if ($backend instanceof Zend_Cache_Backend_ExtendedInterface ) { + $this->_cacheBackends[$name] = $backend; + } + } + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAI/SURBVDjLjZPbS9NhHMYH+zNidtCSQrqwQtY5y2QtT2QGrTZf13TkoYFlzsWa/tzcoR3cSc2xYUlGJfzAaIRltY0N12H5I+jaOxG8De+evhtdOP1hu3hv3sPzPO/z4SsBIPnfuvG8cbBlWiEVO5OUItA0VS8oxi9EdhXo+6yV3V3UGHRvVXHNfNv6zRfNuBZVoiFcB/3LdnQ8U+Gk+bhPVKB3qUOuf6/muaQR/qwDkZ9BRFdCmMr5EPz6BN7lMYylLGgNNaKqt3K0SKDnQ7us690t3rNsxeyvaUz+8OJpzo/QNzd8WTtcaQ7WlBmPvxhx1V2Pg7oDziIBimwwf3qAGWESkVwQ7owNujk1ztvk+cg4NnAUTT4FrrjqUKHdF9jxBfXr1rgjaSk4OlMcLrnOrJ7latxbL1V2lgvlbG9MtMTrMw1r1PImtfyn1n5q47TlBLf90n5NmalMtUdKZoyQMkLKlIGLjMyYhFpmlz3nGEVmFJlRZNaf7pIaEndM24XIjCOzjX9mm2S2JsqdkMYIqbB1j5C6yWzVk7YRFTsGFu7l+4nveExIA9aMCcOJh6DIoMigyOh+o4UryRWQOtIjaJtoziM1FD0mpE4uZcTc72gBaUyYKEI6khgqINXO3saR7kM8IZUVCRDS0Ucf+xFbCReQhr97MZ51wpWxYnhpCD3zOrT4lTisr+AJqVx0Fiiyr4/vhP4VyyMFIUWNqRrV96vWKXKckBoIqWzXYcoPDrUslDJoopuEVEpIB0sR+AuErIiZ6OqMKAAAAABJRU5ErkJggg=='; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return 'Cache'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $panel = ''; + + # Support for APC + if (function_exists('apc_sma_info') && ini_get('apc.enabled')) { + $mem = apc_sma_info(); + $mem_size = $mem['num_seg']*$mem['seg_size']; + $mem_avail = $mem['avail_mem']; + $mem_used = $mem_size-$mem_avail; + + $cache = apc_cache_info(); + + $panel .= '

    APC '.phpversion('apc').' Enabled

    '; + $panel .= round($mem_avail/1024/1024, 1).'M available, '.round($mem_used/1024/1024, 1).'M used'.$this->getLinebreak() + . $cache['num_entries'].' Files cached ('.round($cache['mem_size']/1024/1024, 1).'M)'.$this->getLinebreak() + . $cache['num_hits'].' Hits ('.round($cache['num_hits'] * 100 / ($cache['num_hits']+$cache['num_misses']), 1).'%)'.$this->getLinebreak() + . $cache['expunges'].' Expunges (cache full count)'; + } + + foreach ($this->_cacheBackends as $name => $backend) { + $fillingPercentage = $backend->getFillingPercentage(); + $ids = $backend->getIds(); + + # Print full class name, backends might be custom + $panel .= '

    Cache '.$name.' ('.get_class($backend).')

    '; + $panel .= count($ids).' Entr'.(count($ids)>1?'ies':'y').''.$this->getLinebreak() + . 'Filling Percentage: '.$backend->getFillingPercentage().'%'.$this->getLinebreak(); + + $cacheSize = 0; + foreach ($ids as $id) + { + # Calculate valid cache size + $mem_pre = memory_get_usage(); + if ($cached = $backend->load($id)) { + $mem_post = memory_get_usage(); + $cacheSize += $mem_post-$mem_pre; + unset($cached); + } + } + $panel .= 'Valid Cache Size: '.round($cacheSize/1024, 1). 'K'; + } + return $panel; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php new file mode 100644 index 000000000..35d5d8d61 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php @@ -0,0 +1,170 @@ +_db[0] = Zend_Db_Table_Abstract::getDefaultAdapter(); + $this->_db[0]->getProfiler()->setEnabled(true); + } + } else if ($options['adapter'] instanceof Zend_Db_Adapter_Abstract ) { + $this->_db[0] = $options['adapter']; + $this->_db[0]->getProfiler()->setEnabled(true); + } else { + foreach ($options['adapter'] as $name => $adapter) { + if ($adapter instanceof Zend_Db_Adapter_Abstract) { + $adapter->getProfiler()->setEnabled(true); + $this->_db[$name] = $adapter; + } + } + } + + if (isset($options['explain'])) { + $this->_explain = (bool)$options['explain']; + } + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC'; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + if (!$this->_db) + return 'No adapter'; + + foreach ($this->_db as $adapter) { + $profiler = $adapter->getProfiler(); + $adapterInfo[] = $profiler->getTotalNumQueries().' in '.round($profiler->getTotalElapsedSecs()*1000, 2).' ms'; + } + $html = implode(' / ', $adapterInfo); + + return $html; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + if (!$this->_db) + return ''; + + $html = '

    Database queries

    '; + if (Zend_Db_Table_Abstract::getDefaultMetadataCache ()) { + $html .= 'Metadata cache is ENABLED'; + } else { + $html .= 'Metadata cache is DISABLED'; + } + + # For adding quotes to query params + function add_quotes(&$value, $key) { + $value = "'".$value."'"; + } + + foreach ($this->_db as $name => $adapter) { + if ($profiles = $adapter->getProfiler()->getQueryProfiles()) { + $adapter->getProfiler()->setEnabled(false); + $html .= '

    Adapter '.$name.'

      '; + foreach ($profiles as $profile) { + $params = $profile->getQueryParams(); + array_walk($params, 'add_quotes'); + $paramCount = count($params); + if ($paramCount) { + $html .= '
    1. '.htmlspecialchars(preg_replace(array_fill(0, $paramCount, '/\?/'), $params, $profile->getQuery(), 1)); + } else { + $html .= '
    2. '.htmlspecialchars($profile->getQuery()); + } + $html .= '

      Time: '.round($profile->getElapsedSecs()*1000, 2).' ms'.$this->getLinebreak(); + + $supportedAdapter = ($adapter instanceof Zend_Db_Adapter_Mysqli + || $adapter instanceof Zend_Db_Adapter_Pdo_Mysql); + + # Run explain if enabled, supported adapter and SELECT query + if ($this->_explain && $supportedAdapter && Zend_Db_Profiler::SELECT == $profile->getQueryType()) { + $explain = $adapter->fetchRow('EXPLAIN '.$profile->getQuery()); + $html .= 'Type: '.strtolower($explain['select_type']).', '.$explain['type'].$this->getLinebreak() + .'Possible Keys: '.$explain['possible_keys'].$this->getLinebreak() + .'Key Used: '.$explain['key'].$this->getLinebreak() + .'Rows: '.$explain['rows'].$this->getLinebreak() + .'Extra: '.$explain['Extra']; + } + + $html .= '

    3. '; + } + $html .= '
    '; + } + } + + return $html; + } + +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php new file mode 100644 index 000000000..986f5678f --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php @@ -0,0 +1,163 @@ +_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJPSURBVDjLpZPLS5RhFMYfv9QJlelTQZwRb2OKlKuINuHGLlBEBEOLxAu46oL0F0QQFdWizUCrWnjBaDHgThCMoiKkhUONTqmjmDp2GZ0UnWbmfc/ztrC+GbM2dXbv4ZzfeQ7vefKMMfifyP89IbevNNCYdkN2kawkCZKfSPZTOGTf6Y/m1uflKlC3LvsNTWArr9BT2LAf+W73dn5jHclIBFZyfYWU3or7T4K7AJmbl/yG7EtX1BQXNTVCYgtgbAEAYHlqYHlrsTEVQWr63RZFuqsfDAcdQPrGRR/JF5nKGm9xUxMyr0YBAEXXHgIANq/3ADQobD2J9fAkNiMTMSFb9z8ambMAQER3JC1XttkYGGZXoyZEGyTHRuBuPgBTUu7VSnUAgAUAWutOV2MjZGkehgYUA6O5A0AlkAyRnotiX3MLlFKduYCqAtuGXpyH0XQmOj+TIURt51OzURTYZdBKV2UBSsOIcRp/TVTT4ewK6idECAihtUKOArWcjq/B8tQ6UkUR31+OYXP4sTOdisivrkMyHodWejlXwcC38Fvs8dY5xaIId89VlJy7ACpCNCFCuOp8+BJ6A631gANQSg1mVmOxxGQYRW2nHMha4B5WA3chsv22T5/B13AIicWZmNZ6cMchTXUe81Okzz54pLi0uQWp+TmkZqMwxsBV74Or3od4OISPr0e3SHa3PX0f3HXKofNH/UIG9pZ5PeUth+CyS2EMkEqs4fPEOBJLsyske48/+xD8oxcAYPzs4QaS7RR2kbLTTOTQieczfzfTv8QPldGvTGoF6/8AAAAASUVORK5CYII='; + } + + /** + * Creates Error Plugin ans sets the Error Handler + * + * @return void + */ + public function __construct () + { + set_error_handler(array($this , 'errorHandler')); + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab () + { + $response = Zend_Controller_Front::getInstance()->getResponse(); + $errorCount = count(self::$errors); + if (! $response->isException() && ! $errorCount) + return ''; + $error = ''; + $exception = ''; + if ($errorCount) + $error = ($errorCount == 1 ? '1 Error' : $errorCount . ' Errors'); + $count = count($response->getException()); + //if ($this->_options['show_exceptions'] && $count) + if ($count) + $exception = ($count == 1) ? '1 Exception' : $count . ' Exceptions'; + $text = $exception . ($exception == '' || $error == '' ? '' : ' - ') . $error; + return $text; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel () + { + $response = Zend_Controller_Front::getInstance()->getResponse(); + $errorCount = count(self::$errors); + if (! $response->isException() && ! $errorCount) + return ''; + $html = ''; + + foreach ($response->getException() as $e) { + $html .= '

    ' . get_class($e) . ': ' . $e->getMessage() . '

    thrown in ' . $e->getFile() . ' on line ' . $e->getLine() . '

    '; + $html .= '

    Call Stack

      '; + foreach ($e->getTrace() as $t) { + $func = $t['function'] . '()'; + if (isset($t['class'])) + $func = $t['class'] . $t['type'] . $func; + if (! isset($t['file'])) + $t['file'] = 'unknown'; + if (! isset($t['line'])) + $t['line'] = 'n/a'; + $html .= '
    1. ' . $func . '
      in ' . str_replace($_SERVER['DOCUMENT_ROOT'], '', $t['file']) . ' on line ' . $t['line'] . '
    2. '; + } + $html .= '
    '; + } + + if ($errorCount) { + $html .= '

    Errors

      '; + foreach (self::$errors as $error) { + $html .= '
    1. ' . sprintf("%s: %s in %s on line %d", $error['type'], $error['message'], str_replace($_SERVER['DOCUMENT_ROOT'], '', $error['file']), $error['line']) . '
    2. '; + } + $html .= '
    '; + } + return $html; + } + + /** + * Debug Bar php error handler + * + * @param string $level + * @param string $message + * @param string $file + * @param string $line + * @return bool + */ + public static function errorHandler ($level, $message, $file, $line) + { + if (! ($level & error_reporting())) + return false; + switch ($level) { + case E_NOTICE: + case E_USER_NOTICE: + $type = 'Notice'; + break; + case E_WARNING: + case E_USER_WARNING: + $type = 'Warning'; + break; + case E_ERROR: + case E_USER_ERROR: + $type = 'Fatal Error'; + break; + default: + $type = 'Unknown, ' . $level; + break; + } + self::$errors[] = array('type' => $type , 'message' => $message , 'file' => $file , 'line' => $line); + if (ini_get('log_errors')) + error_log(sprintf("%s: %s in %s on line %d", $type, $message, $file, $line)); + return true; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php new file mode 100644 index 000000000..d112f61e0 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php @@ -0,0 +1,166 @@ +_basePath = realpath($options['base_path']); + is_array($options['library']) || $options['library'] = array($options['library']); + $this->_library = array_merge($options['library'], array('Zend', 'ZFDebug')); + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADPSURBVCjPdZFNCsIwEEZHPYdSz1DaHsMzuPM6RRcewSO4caPQ3sBDKCK02p+08DmZtGkKlQ+GhHm8MBmiFQUU2ng0B7khClTdQqdBiX1Ma1qMgbDlxh0XnJHiit2JNq5HgAo3KEx7BFAM/PMI0CDB2KNvh1gjHZBi8OR448GnAkeNDEDvKZDh2Xl4cBcwtcKXkZdYLJBYwCCFPDRpMEjNyKcDPC4RbXuPiWKkNABPOuNhItegz0pGFkD+y3p0s48DDB43dU7+eLWes3gdn5Y/LD9Y6skuWXcAAAAASUVORK5CYII='; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return count($this->_getIncludedFiles()) . ' Files'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $included = $this->_getIncludedFiles(); + $html = '

    File Information

    '; + $html .= count($included).' Files Included'.$this->getLinebreak(); + $size = 0; + foreach ($included as $file) { + $size += filesize($file); + } + $html .= 'Total Size: '. round($size/1024, 1).'K'.$this->getLinebreak(); + + $html .= 'Basepath: ' . $this->_basePath .$this->getLinebreak(); + + $libraryFiles = array(); + foreach ($this->_library as $key => $value) { + if ('' != $value) { + $libraryFiles[$key] = '

    ' . $value . ' Files

    '; + } + } + + $html .= '

    Application Files

    '; + foreach ($included as $file) { + $file = str_replace($this->_basePath, '', $file); + $filePaths = explode(DIRECTORY_SEPARATOR, $file); + $inUserLib = false; + foreach ($this->_library as $key => $library) + { + if('' != $library && in_array($library, $filePaths)) { + $libraryFiles[$key] .= $file . $this->getLinebreak(); + $inUserLib = TRUE; + } + } + if (!$inUserLib) { + $html .= $file .$this->getLinebreak(); + } + } + + $html .= implode('', $libraryFiles); + + return $html; + } + + /** + * Gets included files + * + * @return array + */ + protected function _getIncludedFiles() + { + if (null !== $this->_includedFiles) { + return $this->_includedFiles; + } + + $this->_includedFiles = get_included_files(); + sort($this->_includedFiles); + return $this->_includedFiles; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php new file mode 100644 index 000000000..01a7aca98 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php @@ -0,0 +1,101 @@ +_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEdSURBVDjLjZIxTgNBDEXfbDZIlIgmCKWgSpMGxEk4AHehgavQcJY0KRKJJiBQLkCR7PxvmiTsbrJoLY1sy/Ibe+an9XodtqkfSUd+Op0mTlgpidFodKpGRAAwn8/pstI2AHvfbi6KAkndgHZx31iP2/CTE3Q1A0ji6fUjsiFn8fJ4k44mSCmR0sl3QhJXF2fYwftXPl5hsVg0Xr0d2yZnIwWbqrlyOZlMDtc+v33H9eUQO7ACOZAC2Ye8qqIJqCfZRtnIIBnVQH8AdQOqylTZWPBwX+zGj93ZrXU7ZLlcxj5vArYi5/Iweh+BNQCbrVl8/uAMvjvvJbBU/++6rVarGI/HB0BbI4PBgNlsRtGlsL4CK7sAfQX2L6CPwH4BZf1E9tbX5ioAAAAASUVORK5CYII='; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return 'HTML'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $body = Zend_Controller_Front::getInstance()->getResponse()->getBody(); + $panel = '

    HTML Information

    '; + $panel .= $this->_isXhtml().' + '; + $panel .= ' Tags'.$this->getLinebreak() + . 'HTML Size: '.round(strlen($body)/1024, 2).'K'.$this->getLinebreak() + . ' Stylesheet Files'.$this->getLinebreak() + . ' Javascript Files'.$this->getLinebreak() + . ' Images'.$this->getLinebreak() + . '

    getClosingBracket().'getClosingBracket().'

    '; + return $panel; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php new file mode 100644 index 000000000..1110c3e47 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php @@ -0,0 +1,50 @@ + 0, + 'dispatchLoopStartup' => 0 + ); + + protected $_closingBracket = null; + + /** + * Creating time plugin + * @return void + */ + public function __construct() + { + Zend_Controller_Front::getInstance()->registerPlugin($this); + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGvSURBVDjLpZO7alZREEbXiSdqJJDKYJNCkPBXYq12prHwBezSCpaidnY+graCYO0DpLRTQcR3EFLl8p+9525xgkRIJJApB2bN+gZmqCouU+NZzVef9isyUYeIRD0RTz482xouBBBNHi5u4JlkgUfx+evhxQ2aJRrJ/oFjUWysXeG45cUBy+aoJ90Sj0LGFY6anw2o1y/mK2ZS5pQ50+2XiBbdCvPk+mpw2OM/Bo92IJMhgiGCox+JeNEksIC11eLwvAhlzuAO37+BG9y9x3FTuiWTzhH61QFvdg5AdAZIB3Mw50AKsaRJYlGsX0tymTzf2y1TR9WwbogYY3ZhxR26gBmocrxMuhZNE435FtmSx1tP8QgiHEvj45d3jNlONouAKrjjzWaDv4CkmmNu/Pz9CzVh++Yd2rIz5tTnwdZmAzNymXT9F5AtMFeaTogJYkJfdsaaGpyO4E62pJ0yUCtKQFxo0hAT1JU2CWNOJ5vvP4AIcKeao17c2ljFE8SKEkVdWWxu42GYK9KE4c3O20pzSpyyoCx4v/6ECkCTCqccKorNxR5uSXgQnmQkw2Xf+Q+0iqQ9Ap64TwAAAABJRU5ErkJggg=='; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + if (function_exists('memory_get_peak_usage')) { + return round(memory_get_peak_usage()/1024) . 'K of '.ini_get("memory_limit"); + } + return 'MemUsage n.a.'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $panel = '

    Memory Usage

    '; + $panel .= 'Dispatch: ' . round(($this->_memory['dispatchLoopShutdown']-$this->_memory['dispatchLoopStartup'])/1024,2) .'K'.$this->getLinebreak(); + if (isset($this->_memory['user']) && count($this->_memory['user'])) { + foreach ($this->_memory['user'] as $key => $value) { + $panel .= $key.': '.round($value/1024).'K'.$this->getLinebreak(); + } + } + return $panel; + } + + /** + * Sets a memory mark identified with $name + * + * @param string $name + */ + public function mark($name) { + if (!function_exists('memory_get_peak_usage')) { + return; + } + if (isset($this->_memory['user'][$name])) + $this->_memory['user'][$name] = memory_get_peak_usage()-$this->_memory['user'][$name]; + else + $this->_memory['user'][$name] = memory_get_peak_usage(); + } + + + /** + * Defined by Zend_Controller_Plugin_Abstract + * + * @param Zend_Controller_Request_Abstract + * @return void + */ + public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) + { + if (function_exists('memory_get_peak_usage')) { + $this->_memory['dispatchLoopStartup'] = memory_get_peak_usage(); + } + } + + /** + * Defined by Zend_Controller_Plugin_Abstract + * + * @param Zend_Controller_Request_Abstract + * @return void + */ + public function dispatchLoopShutdown() + { + if (function_exists('memory_get_peak_usage')) { + $this->_memory['dispatchLoopShutdown'] = memory_get_peak_usage(); + } + } + + public function getLinebreak() + { + return 'getClosingBracket(); + } + + public function getClosingBracket() + { + if (!$this->_closingBracket) { + if ($this->_isXhtml()) { + $this->_closingBracket = ' />'; + } else { + $this->_closingBracket = '>'; + } + } + + return $this->_closingBracket; + } + + protected function _isXhtml() + { + $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view; + $doctype = $view->doctype(); + return $doctype->isXhtml(); + } + +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Registry.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Registry.php new file mode 100644 index 000000000..690c0a85d --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Registry.php @@ -0,0 +1,90 @@ +_registry = Zend_Registry::getInstance(); + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAH2SURBVDjLjZNLTxNRGIaJv6ZNWeBwkZFLQtGAC4l/wKULV+7YILeSYukEUhJoSASVuCI0hpAYDSUQCJBSoAaC0wbBUi4aWphpO52Zlpa+nnOqCAptJ3k3M3me73LOlAAoyZfDqQdOEvyO89/vRcGZ5HeWmySFYdWHVOQN0vE58jrLJMFJ82hewVU4+bMfqdPxP9VBn+A4D88wP59PwFqmsH7UgeTJEMlsTuIyI5uRsDfCMcmtAtoyhVmOu5kkHZuFsiNA3XuEi+QCdhxluL0D/SvpoO+vhIksiItNiPqqyXgfIL403gjfoTsIL70gQBdim3VQvz2FFnwOxf8E8kYF0rIVYqcRM70Vgf/Pe/ohwsutOJdcpBpP4Mek+jPEfbWQVzkG+7tNcNsqt68tkcLZTIzM6YZ21IbolgHq9j1o+z04nKhHRnlH2p6A32LCvFD55fIYr960VHgSSqCFVDJBEeugh+zw2jnpc0/5rthuRMBaioWBqrVrFylXOUpankIi0AjJY0DC3wD9oA9rAnc2bat+n++2UkH8XHaTZfGQlg3QdlsIbIVX4KSPAv+60L+SO/PECmJiI1lYM9SQBR7b3einfn6kEMwEIZd5Q48sQQt1Qv/xFqt2Tp5x3B8sBmYC71h926az6njdUR6hMy8O17wqFqb5Bd2o/0SFzIZrAAAAAElFTkSuQmCC'; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return ' Registry (' . $this->_registry->count() . ')'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $html = '

    Registered Instances

    '; + $this->_registry->ksort(); + + $html .= $this->_cleanData($this->_registry); + return $html; + } + +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php new file mode 100644 index 000000000..86cabce20 --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php @@ -0,0 +1,150 @@ +setTab($tab); + } + if (isset($options['panel'])) { + $this->setPanel($panel); + } + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Sets identifier for this plugin + * + * @param string $name + * @return ZFDebug_Controller_Plugin_Debug_Plugin_Text Provides a fluent interface + */ + public function setIdentifier($name) + { + $this->_identifier = $name; + return $this; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return $this->_icondata; + } + + /** + * Sets icon data for this plugin + * + * @param string $data + * @return ZFDebug_Controller_Plugin_Debug_Plugin_Text Provides a fluent interface + */ + public function setIconData($data) + { + $this->_icondata = $data; + return $this; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return $this->_tab; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + return $this->_panel; + } + + /** + * Sets tab content + * + * @param string $tab + * @return ZFDebug_Controller_Plugin_Debug_Plugin_Text Provides a fluent interface + */ + public function setTab($tab) + { + $this->_tab = $tab; + return $this; + } + + /** + * Sets panel content + * + * @param string $panel + * @return ZFDebug_Controller_Plugin_Debug_Plugin_Text Provides a fluent interface + */ + public function setPanel($panel) + { + $this->_panel = $panel; + return $this; + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Time.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Time.php new file mode 100644 index 000000000..905d13ccf --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Time.php @@ -0,0 +1,249 @@ + 0, + 'dispatchLoopShutdown' => 0 + ); + + protected $_closingBracket = null; + + /** + * Creating time plugin + * @return void + */ + public function __construct() + { + Zend_Controller_Front::getInstance()->registerPlugin($this); + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAKrSURBVDjLpdPbT9IBAMXx/qR6qNbWUy89WS5rmVtutbZalwcNgyRLLMyuoomaZpRQCt5yNRELL0TkBSXUTBT5hZSXQPwBAvor/fZGazlb6+G8nIfP0znbgG3/kz+Knsbb+xxNV63DLxVLHzqV0vCrfMluzFmw1OW8ePEwf8+WgM1UXDnapVgLePr5Nj9DJBJGFEN8+TzKqL2RzkenV4yl5ws2BXob1WVeZxXhoB+PP0xzt0Bly0fKTePozV5GphYQPA46as+gU5/K+w2w6Ev2Ol/KpNCigM01R2uPgDcQIRSJEYys4JmNoO/y0tbnY9JlxnA9M15bfHZHCnjzVN4x7TLz6fMSJqsPgLAoMvV1niSQBGIbUP3Ki93t57XhItVXjulTQHf9hfk5/xgGyzQTgQjx7xvE4nG0j3UsiiLR1VVaLN3YpkTuNLgZGzRSq8wQUoD16flkOPSF28/cLCYkwqvrrAGXC1UYWtuRX1PR5RhgTJTI1Q4wKwzwWHk4kQI6a04nQ99mUOlczMYkFhPrBMQoN+7eQ35Nhc01SvA7OEMSFzTv8c/0UXc54xfQcj/bNzNmRmNy0zctMpeEQFSio/cdvqUICz9AiEPb+DLK2gE+2MrR5qXPpoAn6mxdr1GBwz1FiclDcAPCEkTXIboByz8guA75eg8WxxDtFZloZIdNKaDu5rnt9UVHE5POep6Zh7llmsQlLBNLSMTiEm5hGXXDJ6qb3zJiLaIiJy1Zpjy587ch1ahOKJ6XHGGiv5KeQSfFun4ulb/josZOYY0di/0tw9YCquX7KZVnFW46Ze2V4wU1ivRYe1UWI1Y1vgkDvo9PGLIoabp7kIrctJXSS8eKtjyTtuDErrK8jIYHuQf8VbK0RJUsLfEg94BfIztkLMvP3v3XN/5rfgIYvAvmgKE6GAAAAABJRU5ErkJggg=='; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return round($this->_timer['dispatchLoopShutdown'],2) .'/'.round($this->_timer['dispatchLoopShutdown']-$this->_timer['dispatchLoopStartup'],2). ' ms'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $html = '

    Custom Timers

    '; + $html .= 'Dispatch: ' . round(($this->_timer['dispatchLoopShutdown']-$this->_timer['dispatchLoopStartup']),2) .' ms'.$this->getLinebreak(); + if (isset($this->_timer['user']) && count($this->_timer['user'])) { + foreach ($this->_timer['user'] as $name => $time) { + $html .= ''.$name.': '. round($time,2).' ms'.$this->getLinebreak(); + } + } + + if (!Zend_Session::isStarted()){ + Zend_Session::start(); + } + + $request = Zend_Controller_Front::getInstance()->getRequest(); + $this_module = $request->getModuleName(); + $this_controller = $request->getControllerName(); + $this_action = $request->getActionName(); + + $timerNamespace = new Zend_Session_Namespace('ZFDebug_Time',false); + $timerNamespace->data[$this_module][$this_controller][$this_action][] = round($this->_timer['dispatchLoopShutdown'],2); + + $html .= '

    Overall Timers

    '; + + foreach ($timerNamespace->data as $module => $controller) + { + if ($module != $this_module) { + continue; + } + $html .= $module . $this->getLinebreak(); + $html .= '
    '; + foreach ($controller as $con => $action) + { + if ($con != $this_controller) { + continue; + } + $html .= ' ' . $con . $this->getLinebreak(); + $html .= '
    '; + foreach ($action as $key => $data) + { + if ($key != $this_action) { + continue; + } + $html .= ' ' . $key . $this->getLinebreak(); + $html .= '
    '; + $html .= ' Avg: ' . $this->_calcAvg($data) . ' ms / '.count($data).' requests'.$this->getLinebreak(); + $html .= ' Min: ' . round(min($data), 2) . ' ms'.$this->getLinebreak(); + $html .= ' Max: ' . round(max($data), 2) . ' ms'.$this->getLinebreak(); + $html .= '
    '; + } + $html .= '
    '; + } + $html .= '
    '; + } + $html .= $this->getLinebreak().'Reset timers by sending ZFDEBUG_RESET as a GET/POST parameter'; + + return $html; + } + + /** + * Sets a time mark identified with $name + * + * @param string $name + */ + public function mark($name) { + if (isset($this->_timer['user'][$name])) + $this->_timer['user'][$name] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000-$this->_timer['user'][$name]; + else + $this->_timer['user'][$name] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000; + } + + #public function routeStartup(Zend_Controller_Request_Abstract $request) { + # $this->timer['routeStartup'] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000; + #} + + #public function routeShutdown(Zend_Controller_Request_Abstract $request) { + # $this->timer['routeShutdown'] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000; + #} + + /** + * Defined by Zend_Controller_Plugin_Abstract + * + * @param Zend_Controller_Request_Abstract + * @return void + */ + public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) + { + $reset = Zend_Controller_Front::getInstance()->getRequest()->getParam('ZFDEBUG_RESET'); + if (isset($reset)) { + if (!Zend_Session::isStarted()) { + Zend_Session::start(); + } + $timerNamespace = new Zend_Session_Namespace('ZFDebug_Time',false); + $timerNamespace->unsetAll(); + } + + $this->_timer['dispatchLoopStartup'] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000; + } + + /** + * Defined by Zend_Controller_Plugin_Abstract + * + * @param Zend_Controller_Request_Abstract + * @return void + */ + public function dispatchLoopShutdown() + { + $this->_timer['dispatchLoopShutdown'] = (microtime(true)-$_SERVER['REQUEST_TIME'])*1000; + } + + /** + * Calculate average time from $array + * + * @param array $array + * @param int $precision + * @return float + */ + protected function _calcAvg(array $array, $precision=2) + { + if (!is_array($array)) { + return 'ERROR in method _calcAvg(): this is a not array'; + } + + foreach ($array as $value) + if (!is_numeric($value)) { + return 'ERROR in method _calcAvg(): the array contains one or more non-numeric values'; + } + + $cuantos=count($array); + return round(array_sum($array)/$cuantos,$precision); + } + + public function getLinebreak() + { + return 'getClosingBracket(); + } + + public function getClosingBracket() + { + if (!$this->_closingBracket) { + if ($this->_isXhtml()) { + $this->_closingBracket = ' />'; + } else { + $this->_closingBracket = '>'; + } + } + + return $this->_closingBracket; + } + + protected function _isXhtml() + { + $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view; + $doctype = $view->doctype(); + return $doctype->isXhtml(); + } +} \ No newline at end of file diff --git a/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php new file mode 100644 index 000000000..4890cbe8b --- /dev/null +++ b/airtime_mvc/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php @@ -0,0 +1,104 @@ +_identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFWSURBVBgZBcE/SFQBAAfg792dppJeEhjZn80MChpqdQ2iscmlscGi1nBPaGkviKKhONSpvSGHcCrBiDDjEhOC0I68sjvf+/V9RQCsLHRu7k0yvtN8MTMPICJieaLVS5IkafVeTkZEFLGy0JndO6vWNGVafPJVh2p8q/lqZl60DpIkaWcpa1nLYtpJkqR1EPVLz+pX4rj47FDbD2NKJ1U+6jTeTRdL/YuNrkLdhhuAZVP6ukqbh7V0TzmtadSEDZXKhhMG7ekZl24jGDLgtwEd6+jbdWAAEY0gKsPO+KPy01+jGgqlUjTK4ZroK/UVKoeOgJ5CpRyq5e2qjhF1laAS8c+Ymk1ZrVXXt2+9+fJBYUwDpZ4RR7Wtf9u9m2tF8Hwi9zJ3/tg5pW2FHVv7eZJHd75TBPD0QuYze7n4Zdv+ch7cfg8UAcDjq7mfwTycew1AEQAAAMB/0x+5JQ3zQMYAAAAASUVORK5CYII='; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + return ' Variables'; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + $this->_request = Zend_Controller_Front::getInstance()->getRequest(); + $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); + if ($viewRenderer->view && method_exists($viewRenderer->view, 'getVars')) { + $viewVars = $this->_cleanData($viewRenderer->view->getVars()); + } else { + $viewVars = "No 'getVars()' method in view class"; + } + $vars = ''; + if ($this->_request->isPost()) + { + $vars .= '

    $_POST

    ' + . '
    ' . $this->_cleanData($this->_request->getPost()) . '
    '; + } + + $vars .= '

    $_COOKIE

    ' + . '' + . '

    Request

    ' + . '
    ' . $this->_cleanData($this->_request->getParams()) . '
    ' + . '

    View vars

    ' + . '
    ' . $viewVars . '
    '; + return $vars; + } + +} \ No newline at end of file diff --git a/airtime_mvc/library/php-amqplib/demo/amqp_airtime_consumer.php b/airtime_mvc/library/php-amqplib/demo/amqp_airtime_consumer.php old mode 100644 new mode 100755 diff --git a/airtime_mvc/library/php-amqplib/demo/amqp_consumer.php b/airtime_mvc/library/php-amqplib/demo/amqp_consumer.php old mode 100644 new mode 100755 index c3d0e085d..188fbc844 --- a/airtime_mvc/library/php-amqplib/demo/amqp_consumer.php +++ b/airtime_mvc/library/php-amqplib/demo/amqp_consumer.php @@ -14,7 +14,7 @@ $PORT = 5672; $USER = 'guest'; $PASS = 'guest'; $VHOST = '/'; -$EXCHANGE = 'router'; +$EXCHANGE = 'airtime-schedule'; $QUEUE = 'msgs'; $CONSUMER_TAG = 'consumer'; @@ -23,7 +23,7 @@ $ch = $conn->channel(); $ch->access_request($VHOST, false, false, true, true); $ch->queue_declare($QUEUE); -$ch->exchange_declare($EXCHANGE, 'direct', false, false, false); +$ch->exchange_declare($EXCHANGE, 'direct', false, true); $ch->queue_bind($QUEUE, $EXCHANGE); function process_message($msg) { diff --git a/airtime_mvc/library/php-amqplib/demo/amqp_publisher.php b/airtime_mvc/library/php-amqplib/demo/amqp_publisher.php old mode 100644 new mode 100755 index 318ee5914..94dd3f917 --- a/airtime_mvc/library/php-amqplib/demo/amqp_publisher.php +++ b/airtime_mvc/library/php-amqplib/demo/amqp_publisher.php @@ -13,15 +13,17 @@ $PORT = 5672; $USER = 'guest'; $PASS = 'guest'; $VHOST = '/'; -$EXCHANGE = 'router'; +$EXCHANGE = 'airtime-schedule'; + $QUEUE = 'msgs'; $conn = new AMQPConnection($HOST, $PORT, $USER, $PASS); $ch = $conn->channel(); $ch->access_request($VHOST, false, false, true, true); -$ch->exchange_declare($EXCHANGE, 'direct', false, false, false); +$ch->exchange_declare($EXCHANGE, 'direct', false, true); -$msg_body = implode(' ', array_slice($argv, 1)); +$msg_body = json_encode(array("event_type"=>"get_status", "id"=>time())); +//$msg_body = '{"schedule":{"status":{"range":{"start":"2011-09-12 20:45:22","end":"2011-09-13 20:45:22"},"version":"1.1"},"playlists":[],"check":1,"stream_metadata":{"format":"","station_name":""}},"event_type":"update_schedule"}'; $msg = new AMQPMessage($msg_body, array('content_type' => 'text/plain')); $ch->basic_publish($msg, $EXCHANGE); @@ -29,4 +31,5 @@ $ch->basic_publish($msg, $EXCHANGE); echo "Sent message '".$msg_body."'\n"; $ch->close(); $conn->close(); + ?> diff --git a/airtime_mvc/library/propel/generator/bin/propel-gen.bat b/airtime_mvc/library/propel/generator/bin/propel-gen.bat deleted file mode 100755 index b6607f6b1..000000000 --- a/airtime_mvc/library/propel/generator/bin/propel-gen.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off - -rem ********************************************************************* -rem ** The Propel generator convenience script for Windows based systems -rem ** $Id$ -rem ********************************************************************* - -rem This script will do the following: -rem - check for PHING_COMMAND env, if found, use it. -rem - if not found detect php, if found use it, otherwise err and terminate -rem - check for PROPEL_GEN_HOME env, if found use it -rem - if not found error and leave - -if "%OS%"=="Windows_NT" @setlocal - -rem %~dp0 is expanded pathname of the current script under NT -set DEFAULT_PROPEL_GEN_HOME=%~dp0.. - -if "%PROPEL_GEN_HOME%" == "" set PROPEL_GEN_HOME=%DEFAULT_PROPEL_GEN_HOME% -set DEFAULT_PROPEL_GEN_HOME= - -if "%PHING_COMMAND%" == "" set PHING_COMMAND=phing.bat - -set nbArgs=0 -for %%x in (%*) do Set /A nbArgs+=1 -if %nbArgs% leq 1 ( - %PHING_COMMAND% -f "%PROPEL_GEN_HOME%\build.xml" -Dusing.propel-gen=true -Dproject.dir="%CD%" %* -) else ( - %PHING_COMMAND% -f "%PROPEL_GEN_HOME%\build.xml" -Dusing.propel-gen=true -Dproject.dir=%* -) - -if "%OS%"=="Windows_NT" @endlocal diff --git a/airtime_mvc/public/.htaccess b/airtime_mvc/public/.htaccess index 8a50c17ef..3dfbebfef 100644 --- a/airtime_mvc/public/.htaccess +++ b/airtime_mvc/public/.htaccess @@ -2,7 +2,6 @@ php_value post_max_size 500M php_value upload_max_filesize 500M php_value request_order "GPC" php_value session.gc_probability 0 -php_value date.timezone "America/Toronto" php_value phar.readonly Off RewriteEngine On diff --git a/airtime_mvc/public/css/add-show.css b/airtime_mvc/public/css/add-show.css index 96008facd..0dd479a3c 100644 --- a/airtime_mvc/public/css/add-show.css +++ b/airtime_mvc/public/css/add-show.css @@ -51,7 +51,7 @@ margin: 0; padding: 4px 0; text-align: left; - min-width:100px; + min-width:103px; clear:left; } #schedule-add-show dt.big { @@ -75,7 +75,7 @@ } label.wrapp-label input[type="checkbox"] { float:left; - margin:-1px 4px 0 0; + margin:-1px 2px 0 0; } #schedule-add-show fieldset:last-child { @@ -91,10 +91,10 @@ label.wrapp-label input[type="checkbox"] { #add_show_day_check-element.block-display label.wrapp-label { font-size:12px; float:left; - margin-right:5px; + margin-right:10px; } #add_show_name-element .input_text { - width:99%; + /*width:99%;*/ } #schedule-add-show-overlap { @@ -113,12 +113,13 @@ label.wrapp-label input[type="checkbox"] { } #add_show_start_time, #add_show_end_time { - width: 60px; + width: 54px; margin-left:10px; } #add_show_end_date_no_repeat, #add_show_start_date { - width: 95px; + width: 89px; + } #add_show_duration { diff --git a/airtime_mvc/public/css/images/404.png b/airtime_mvc/public/css/images/404.png new file mode 100644 index 000000000..c89f60ffb Binary files /dev/null and b/airtime_mvc/public/css/images/404.png differ diff --git a/airtime_mvc/public/css/images/accept.png b/airtime_mvc/public/css/images/accept.png new file mode 100644 index 000000000..b02cb4bcf Binary files /dev/null and b/airtime_mvc/public/css/images/accept.png differ diff --git a/airtime_mvc/public/css/images/airtime_logo_jp.png b/airtime_mvc/public/css/images/airtime_logo_jp.png new file mode 100644 index 000000000..0bc1ff866 Binary files /dev/null and b/airtime_mvc/public/css/images/airtime_logo_jp.png differ diff --git a/airtime_mvc/public/css/images/delete.png b/airtime_mvc/public/css/images/delete.png new file mode 100644 index 000000000..b622e16c1 Binary files /dev/null and b/airtime_mvc/public/css/images/delete.png differ diff --git a/airtime_mvc/public/css/images/icon_soundcloud_error2.png b/airtime_mvc/public/css/images/icon_soundcloud_error2.png new file mode 100644 index 000000000..4263e32bd Binary files /dev/null and b/airtime_mvc/public/css/images/icon_soundcloud_error2.png differ diff --git a/airtime_mvc/public/css/playlist_builder.css b/airtime_mvc/public/css/playlist_builder.css index 7aef3be75..2d02f4676 100644 --- a/airtime_mvc/public/css/playlist_builder.css +++ b/airtime_mvc/public/css/playlist_builder.css @@ -2,6 +2,7 @@ width: 40%; min-height: 475px; padding: 8px; + padding-bottom: 0px; font-size: 16px; } @@ -39,10 +40,11 @@ #spl_sortable { list-style: none; padding:0; - height: 300px; - overflow: auto; + padding-bottom:50px; width:100%; + min-height: 320px; margin-top:0; + margin-bottom:0; } #side_playlist li { diff --git a/airtime_mvc/public/css/qtip/jquery.qtip.min.css b/airtime_mvc/public/css/qtip/jquery.qtip.min.css new file mode 100644 index 000000000..6b0daf7c2 --- /dev/null +++ b/airtime_mvc/public/css/qtip/jquery.qtip.min.css @@ -0,0 +1 @@ +.ui-tooltip,.qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;z-index:15000;}.ui-tooltip-fluid{display:block;visibility:hidden;position:static!important;float:left!important;}.ui-tooltip-content{position:relative;padding:5px 9px;overflow:hidden;border-width:1px;border-style:solid;text-align:left;word-wrap:break-word;overflow:hidden;}.ui-tooltip-titlebar{position:relative;min-height:14px;padding:5px 35px 5px 10px;overflow:hidden;border-width:1px 1px 0;border-style:solid;font-weight:bold;}.ui-tooltip-titlebar+.ui-tooltip-content{border-top-width:0!important;}/*!Default close button class */ .ui-tooltip-titlebar .ui-state-default{position:absolute;right:4px;top:50%;margin-top:-9px;cursor:pointer;outline:medium none;border-width:1px;border-style:solid;}* html .ui-tooltip-titlebar .ui-state-default{top:16px;}.ui-tooltip-titlebar .ui-icon,.ui-tooltip-icon .ui-icon{display:block;text-indent:-1000em;}.ui-tooltip-icon,.ui-tooltip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;}.ui-tooltip-icon .ui-icon{width:18px;height:14px;text-align:center;text-indent:0;font:normal bold 10px/13px Tahoma,sans-serif;color:inherit;background:transparent none no-repeat -100em -100em;}/*!Default tooltip style */ .ui-tooltip-default .ui-tooltip-titlebar,.ui-tooltip-default .ui-tooltip-content{border-color:#F1D031;background-color:#FFFFA3;color:#555;}.ui-tooltip-default .ui-tooltip-titlebar{background-color:#FFEF93;}.ui-tooltip-default .ui-tooltip-icon{border-color:#CCC;background:#F1F1F1;color:#777;}.ui-tooltip-default .ui-tooltip-titlebar .ui-state-hover{border-color:#AAA;color:#111;}.ui-tooltip .ui-tooltip-tip{margin:0 auto;overflow:hidden;background:transparent!important;border:0 dashed transparent!important;z-index:10;}.ui-tooltip .ui-tooltip-tip,.ui-tooltip .ui-tooltip-tip *{position:absolute;line-height:.1px!important;font-size:.1px!important;color:#123456;background:transparent;border:0 dashed transparent;}.ui-tooltip .ui-tooltip-tip canvas{top:0;left:0;}#qtip-overlay{position:fixed;left:-10000em;top:-10000em;}#qtip-overlay.blurs{cursor:pointer;}#qtip-overlay div{position:absolute;left:0;top:0;width:100%;height:100%;background-color:black;opacity:.7;filter:alpha(opacity=70);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";}/*!Light tooltip style */ .ui-tooltip-light .ui-tooltip-titlebar,.ui-tooltip-light .ui-tooltip-content{border-color:#E2E2E2;color:#454545;}.ui-tooltip-light .ui-tooltip-content{background-color:white;}.ui-tooltip-light .ui-tooltip-titlebar{background-color:#f1f1f1;}/*!Dark tooltip style */ .ui-tooltip-dark .ui-tooltip-titlebar,.ui-tooltip-dark .ui-tooltip-content{border-color:#303030;color:#f3f3f3;}.ui-tooltip-dark .ui-tooltip-content{background-color:#505050;}.ui-tooltip-dark .ui-tooltip-titlebar{background-color:#404040;}.ui-tooltip-dark .ui-tooltip-icon{border-color:#444;}.ui-tooltip-dark .ui-tooltip-titlebar .ui-state-hover{border-color:#303030;}/*!Cream tooltip style */ .ui-tooltip-cream .ui-tooltip-titlebar,.ui-tooltip-cream .ui-tooltip-content{border-color:#F9E98E;color:#A27D35;}.ui-tooltip-cream .ui-tooltip-content{background-color:#FBF7AA;}.ui-tooltip-cream .ui-tooltip-titlebar{background-color:#F0DE7D;}.ui-tooltip-cream .ui-state-default .ui-tooltip-icon{background-position:-82px 0;}/*!Red tooltip style */ .ui-tooltip-red .ui-tooltip-titlebar,.ui-tooltip-red .ui-tooltip-content{border-color:#D95252;color:#912323;}.ui-tooltip-red .ui-tooltip-content{background-color:#F78B83;}.ui-tooltip-red .ui-tooltip-titlebar{background-color:#F06D65;}.ui-tooltip-red .ui-state-default .ui-tooltip-icon{background-position:-102px 0;}.ui-tooltip-red .ui-tooltip-icon{border-color:#D95252;}.ui-tooltip-red .ui-tooltip-titlebar .ui-state-hover{border-color:#D95252;}/*!Green tooltip style */ .ui-tooltip-green .ui-tooltip-titlebar,.ui-tooltip-green .ui-tooltip-content{border-color:#90D93F;color:#3F6219;}.ui-tooltip-green .ui-tooltip-content{background-color:#CAED9E;}.ui-tooltip-green .ui-tooltip-titlebar{background-color:#B0DE78;}.ui-tooltip-green .ui-state-default .ui-tooltip-icon{background-position:-42px 0;}/*!Blue tooltip style */ .ui-tooltip-blue .ui-tooltip-titlebar,.ui-tooltip-blue .ui-tooltip-content{border-color:#ADD9ED;color:#5E99BD;}.ui-tooltip-blue .ui-tooltip-content{background-color:#E5F6FE;}.ui-tooltip-blue .ui-tooltip-titlebar{background-color:#D0E9F5;}.ui-tooltip-blue .ui-state-default .ui-tooltip-icon{background-position:-2px 0;}/*!Add shadows to your tooltips in:FF3+,Chrome 2+,Opera 10.6+,IE6+,Safari 2+*/ .ui-tooltip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);}.ui-tooltip-shadow .ui-tooltip-titlebar,.ui-tooltip-shadow .ui-tooltip-content{filter:progid:DXImageTransform.Microsoft.Shadow(Color='gray',Direction=135,Strength=3);-ms-filter:"progid:DXImageTransform.Microsoft.Shadow(Color='gray',Direction=135,Strength=3)";_margin-bottom:-3px;.margin-bottom:-3px;}/*!Add rounded corners to your tooltips in:FF3+,Chrome 2+,Opera 10.6+,IE9+,Safari 2+*/ .ui-tooltip-rounded,.ui-tooltip-rounded .ui-tooltip-content,.ui-tooltip-tipsy,.ui-tooltip-tipsy .ui-tooltip-content,.ui-tooltip-youtube,.ui-tooltip-youtube .ui-tooltip-content{-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}.ui-tooltip-rounded .ui-tooltip-titlebar,.ui-tooltip-tipsy .ui-tooltip-titlebar,.ui-tooltip-youtube .ui-tooltip-titlebar{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0;}.ui-tooltip-rounded .ui-tooltip-titlebar+.ui-tooltip-content,.ui-tooltip-tipsy .ui-tooltip-titlebar+.ui-tooltip-content,.ui-tooltip-youtube .ui-tooltip-titlebar+.ui-tooltip-content{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px;}/*!Youtube tooltip style */ .ui-tooltip-youtube{-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;}.ui-tooltip-youtube .ui-tooltip-titlebar,.ui-tooltip-youtube .ui-tooltip-content{_margin-bottom:0;.margin-bottom:0;background:transparent;background:rgba(0,0,0,0.85);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000)";color:white;border-color:#CCC;}.ui-tooltip-youtube .ui-tooltip-icon{border-color:#222;}.ui-tooltip-youtube .ui-tooltip-titlebar .ui-state-hover{border-color:#303030;}.ui-tooltip-jtools{background:#232323;background:rgba(0,0,0,0.7);background-image:-moz-linear-gradient(top,#717171,#232323);background-image:-webkit-gradient(linear,left top,left bottom,from(#717171),to(#232323));border:2px solid #ddd;border:2px solid rgba(241,241,241,1);-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333;}.ui-tooltip-jtools .ui-tooltip-titlebar{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A)";}.ui-tooltip-jtools .ui-tooltip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323)";}.ui-tooltip-jtools .ui-tooltip-titlebar,.ui-tooltip-jtools .ui-tooltip-content{background:transparent;color:white;border:0 dashed transparent;}.ui-tooltip-jtools .ui-tooltip-icon{border-color:#555;}.ui-tooltip-jtools .ui-tooltip-titlebar .ui-state-hover{border-color:#333;}.ui-tooltip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,0.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,0.4);box-shadow:4px 4px 5px rgba(0,0,0,0.4);}.ui-tooltip-cluetip .ui-tooltip-titlebar{background-color:#87876A;color:white;border:0 dashed transparent;}.ui-tooltip-cluetip .ui-tooltip-content{background-color:#D9D9C2;color:#111;border:0 dashed transparent;}.ui-tooltip-cluetip .ui-tooltip-icon{border-color:#808064;}.ui-tooltip-cluetip .ui-tooltip-titlebar .ui-state-hover{border-color:#696952;color:#696952;}.ui-tooltip-tipsy{border:0;}.ui-tooltip-tipsy .ui-tooltip-titlebar,.ui-tooltip-tipsy .ui-tooltip-content{_margin-bottom:0;.margin-bottom:0;background:transparent;background:rgba(0,0,0,.87);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000)";color:white;border:0 transparent;font-size:11px;font-family:'Lucida Grande',sans-serif;font-weight:bold;line-height:16px;text-shadow:0 1px black;}.ui-tooltip-tipsy .ui-tooltip-titlebar{padding:6px 35px 0 10;}.ui-tooltip-tipsy .ui-tooltip-content{padding:6px 10;}.ui-tooltip-tipsy .ui-tooltip-icon{border-color:#222;text-shadow:none;}.ui-tooltip-tipsy .ui-tooltip-titlebar .ui-state-hover{border-color:#303030;}.ui-tooltip-tipped .ui-tooltip-titlebar,.ui-tooltip-tipped .ui-tooltip-content{border:3px solid #959FA9;filter:none;-ms-filter:none;}.ui-tooltip-tipped .ui-tooltip-titlebar{background:#3A79B8;background-image:-moz-linear-gradient(top,#3A79B8,#2E629D);background-image:-webkit-gradient(linear,left top,left bottom,from(#3A79B8),to(#2E629D));filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D)";color:white;font-weight:normal;font-family:serif;border-bottom-width:0;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;}.ui-tooltip-tipped .ui-tooltip-content{background-color:#F9F9F9;color:#454545;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;}.ui-tooltip-tipped .ui-tooltip-icon{border:2px solid #285589;background:#285589;}.ui-tooltip-tipped .ui-tooltip-icon .ui-icon{background-color:#FBFBFB;color:#555;}.ui-tooltip:not(.ie9haxors) div.ui-tooltip-content,.ui-tooltip:not(.ie9haxors) div.ui-tooltip-titlebar{filter:none;-ms-filter:none;} \ No newline at end of file diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 2c801123e..297cc30f3 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -1,1912 +1,2303 @@ -@charset "utf-8"; -/* CSS Document */ - -body { - font-size: 62.5%; - font-family:Arial, Helvetica, sans-serif; - background: #7f7f7f; - margin: 0; - padding: 0; -} -html, body { -height: 100%; -} - -#login-page { - background: #1f1f1f url(images/login_page_bg.png) no-repeat center 0; - margin: 0; - padding: 0; - height:100%; - text-align:center; -} - -h2 { - color: #000000; - font-size: 2.1em; - font-weight: normal; - margin: 0; - padding: 0 0 10px; -} -h3 { - font-size:1.7em; - font-weight:normal; - color:#000; - padding:0 0 10px 0; - margin:0; -} -a, a:focus { - outline:none; -} -label { - font-size:12px; -} -select { - font-size:12px; - font-family:Arial, Helvetica, sans-serif; - border:1px solid #9d9d9d; -} - -.logo { - position:absolute; - right:20px; - top:104px; - background:transparent url(images/airtime_logo.png) no-repeat 0 0; - height:35px; - width:66px; - z-index:1000; - display:block; -} - -/* Clearfix */ -.clearfix:after, li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;} -.clearfix, li { display: inline-block; } -* html .clearfix, * html li { height: 1%;} -.clearfix, li { display: block; } - - -/* Master Panel */ -#sticky { - position:fixed; - height:130px; - top:0; - left:0; -} - - -#master-panel { - background:#3d3d3d url(images/masterpanel_bg.png) repeat-x 0 0; - height:100px; - border:1px solid #000; - border-width: 1px 0; - overflow:hidden; - position:relative; -} - -.now-playing-block, .show-block, .on-air-block, .time-info-block, .personal-block, .listen-control-block { - height:100px; - float:left; - margin-right:10px; -} -.personal-block { - float:right; - margin-right:20px; - text-align:right; - min-width:110px; -} - -.personal-block ul { - margin:0; - padding:8px 0 0; -} -.personal-block li { - font-size:11px; - color:#bdbdbd; - list-style-type:none; - margin:0 0 2px 0; -} -.personal-block li.name { - color:#fff; - font-weight:normal; -} -.personal-block li a { - color:#fff; - text-decoration:underline; -} -.personal-block li a:hover { - color:#ff5d1a; -} -.now-playing-block { - width:30%; - padding-left:20px; -} -.show-block { - width:18%; -} -.text-row { - height:30px; - padding:0px 0 0; - font-size:12px; - text-wrap:none; - text-indent:2px; - overflow:hidden; - line-height:30px; -} -#master-panel .text-row { - color:#dfdfdf; -} -.text-row.next-song { - color:#d9d9d9; -} -.text-row strong { - font-weight:bold; - color:#969696; - padding-right:12px; -} -.text-row.rebroadcast, #master-panel .text-row.rebroadcast { - color:#969696; -} -.now-playing-info { - height:25px; - background:#3a3a3a url(images/playinfo_bg.png) repeat-x 0 0; - border: 1px solid #242424; - border-bottom-color:#727272; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - border-radius: 2px; - color:#fff; - font-size:15px; - line-height:22px; - text-indent:5px; - overflow:hidden; - margin-bottom:3px; -} -.time-elapsed { - color:#9b9b9b; - padding-right:6px; -} -.time-remaining { - color:#ff6f01; -} -.progressbar { - height:6px; - border:1px solid #242424; - border-width:1px 1px 0 1px; - background:#141414 url(images/progressbar_bg.png) repeat-x 0 0; -} -.progressbar .progress-song, .progressbar .progress-show, .progressbar .progress-show-error { - height:4px; - width:0%; - background:#f97202 url(images/progressbar_song.png) repeat-x 0 0; -} -.progressbar .progress-show { - background:#02cef9 url(images/progressbar_show.png) repeat-x 0 0; -} -.progressbar .progress-show-error { - background:#d40000 url(images/progressbar_show_error.png) repeat-x 0 0; -} -.now-playing-info .show-length { - color:#c4c4c4; - padding-left:6px; -} - -.on-air-block { - padding:0 12px 0 0; - background:url(images/masterpanel_spacer.png) no-repeat right 0; -} -.time-info-block { - padding:0 14px 0 2px; - background:url(images/masterpanel_spacer.png) no-repeat right 0; - min-width:105px; -} -.time-info-block ul { - margin:0; - padding:6px 0 0; -} -.time-info-block li { - list-style-type:none; - font-size:14px; - color:#bdbdbd; - margin:0 0 6px; -} -.time-info-block li.time { - font-size:26px; - color:#fff; - width:auto; - text-align:left; -} -.time-info-block li.time-zone { - font-size:17px; - margin-bottom:0; -} -.on-air-info { - height:26px; - border:1px solid #242424; - border-width:1px 1px 0 1px; - color:#fff; - min-width:85px; - font-size:16px; - line-height:100%; - font-weight:bold; - text-shadow: #242424 0px -1px; - text-align:center; - padding: 10px 0 0 0; - background-color:#464646; - margin-top:30px; -} -.on, .off { - background:#c21717 url(images/on-off-air.png) repeat-x 0 0; -} -.off { - background:#575050 url(images/on-off-air.png) repeat-x 0 -36px; - color:#a5a5a5; -} - -.listen-control-block a { - font-size:11px; - text-transform:uppercase; - padding:0; - border:1px solid #242424; - color:#fff; - text-decoration:none; - font-weight:bold; - margin-top:34px; - display:block; - -} -.listen-control-block a span { - background-color: #6e6e6e; - background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e)); - padding:5px 10px; - border:1px solid #a1a1a1; - border-width:1px 0; - border-bottom-color:#646464; - color:#dcdcdc; - text-shadow: #555555 0px -1px; - display:block; -} -.listen-control-block a:hover { - border:1px solid #000; -} -.listen-control-block a:hover span { - background-color: #292929; - background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); - border:1px solid #555555; - border-width:1px 0; - border-bottom-color:#1e1e1e; - color:#fff; - color:#0C0; - text-shadow: #000 0px -1px; - display:block; -} -.listen-control-block a:active span { - color:#fff; -} - -/* END Master Panel */ - - -.wrapper { - margin: 0 20px 0 20px; - padding:20px 0 0 0; -} - -.alpha-block { - padding:0; - float:left; - margin:0 16px 10px 0; -} -.omega-block { - padding:0; - float:left; - margin:0 0 10px 0; -} -.block-shadow { - -moz-box-shadow: 0 2px 2px rgba(0,0,0,.10); - -webkit-box-shadow: 0 2px 2px rgba(0,0,0,.10); - box-shadow: 0 2px 2px rgba(0,0,0,.10); -} -.clear { - clear: both; - display: block; - height: 0; - overflow: hidden; - visibility: hidden; - width: 0; -} -fieldset.plain { - border:none; - padding:0; - margin:0; -} -.frame { - padding:0; - border:1px solid #5b5b5b; - margin: 0 0 8px 0; -} -.padded { - padding:8px; -} -.padded-strong { - padding:10px; -} -.input_text, input[type="text"], input[type="password"] { - font-family:Arial, Helvetica, sans-serif; - border: 1px solid #5b5b5b; - font-size: 12px; - height: 23px; - margin: 0; - padding: 0; - text-indent: 3px; - width:auto; - background-color: #dddddd; - border: 1px solid #5b5b5b; - box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset; -} - -input[type="text"]:focus, input[type="password"]:focus, textarea:focus, .input_text_area:focus { - border: 1px solid #0088f1; -} -.auto-search { - background:#dddddd url(images/search_auto_bg.png) no-repeat 0 0; - text-indent:25px; -} -.input_text_area, textarea { - background-color: #dddddd; - border: 1px solid #5b5b5b; - box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset; - font-size: 13px; - text-indent: 3px; - margin:0; -} -.input_select, select { - background-color: #DDDDDD; - box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset; - border: 1px solid #5b5b5b; - font-family: Arial,Helvetica,sans-serif; - font-size: 12px; - height: 25px; - margin: 0; - padding: 2px 2px 2px 0; - vertical-align: top; -} -label { - font-size:13px; - color:#5b5b5b; - padding:0 16px 0 0; -} -#library_quick_search { - margin-bottom:16px; -} -#library_quick_search label { - -} -#library_quick_search input { - width:60%; -} -dl.inline-list { - float: left; - margin: 0; - padding: 0; - -} - -dl.inline-list dt { - clear: left; - float: left; - margin: 0; - padding: 0px 0; - font-weight: bold; - color:#333333; - font-size:12px; - font-weight:bold; - text-align:left; - min-width:70px; -} -dl.inline-list dd { - float: left; - margin: 0; - padding: 0px 0 4px 15px; - font-size:12px; -} -.left-floated { - float:left; - margin-left:0; - margin-right:10px; -} -.right-floated { - float:right; - margin-left:10px; - margin-right:0; - text-align:right; -} -/*----Data Table----*/ - -.datatable tr th.ui-state-default { - border: 1px solid #CCC; - border-width: 0 0 0 1px !important; -} -.datatable { - border-color: #5b5b5b; - border-style: solid; - border-width: 1px 1px 1px 1px; - width:100%; -} -.datatable tr td, .datatable tr th { - border-color: #b1b1b1; - border-style: solid; - border-width: 1px 0 0 1px; - font-size: 13px; - padding: 5px 5px; -} -.odd { - background-color: #d8d8d8; -} -.even { - background-color:#c7c7c7; -} -.datatable tr.even.selected td { - background-color: #abcfe2; -} -.datatable tr.odd.selected td { - background-color: #c5deeb; -} -.datatable tr.odd:hover td, .datatable tr.even:hover td { - background-color: #95d5f7 !important; -} - -.datatable tr td:first-child, .datatable tr th:first-child, .datatable tr th.ui-state-default:first-child { - border-left-width:0 !important; -} -.ui-widget-header + .datatable { - border-width: 0px 1px 1px 1px; -} -.datatable + .ui-widget-header { - border-width: 0px 1px 1px 1px; -} -.dataTables_scrollHeadInner > .datatable { - border-width: 0px 1px 0 1px; -} -.dataTables_scroll .datatable { - border-width: 0px 1px 0 1px; -} - -.DataTables_sort_wrapper .ui-icon { - display: block; - float: left; - margin: 0 3px 0 -2px; -} -.dataTables_length { - float:right; - margin:0 8px 0 0; - -} -.dataTables_length label { - padding:10px 6px 0 0; - font-size:12px; - color:#404040; - line-height:22px; -} -.dataTables_filter { - margin:8px 0 0 8px; -} -.dataTables_filter .auto-search { - width:60%; -} -.dataTables_processing { - font-size:11px; - font-weight:normal; - margin:2px 0 3px 8px; -} -#library_display_wrapper .ui-widget-header:first-child { - background:none; - border-width:0 0 1px 0; - color: #444444; - font-weight: bold; -} -#library_display_wrapper .ui-widget-header:first-child .dataTables_length { - margin:0; -} -#library_display_wrapper .ui-widget-header:first-child .dataTables_filter { - margin:0; -} - -.dataTables_info { - padding: 8px 0 0 8px; - font-size:12px; - color:#555555; - font-weight:normal; -} - -.dataTables_paginate { - padding: 8px 0 8px 8px; -} -.dataTables_paginate .ui-button { - font-size:12px; - font-weight:normal; - padding: 0.2em 1em; - margin-right:3px; -} -.dataTables_filter input { - background: url("images/search_auto_bg.png") no-repeat scroll 0 0 #DDDDDD; - text-indent: 25px; - width: 60%; - border: 1px solid #5B5B5B; - height: 23px; - margin: 0; - padding: 0; -} -.dataTables_length select { - background-color: #DDDDDD; - border: 1px solid #5B5B5B; - font-family: Arial,Helvetica,sans-serif; - font-size: 12px; - height: 25px; - margin: 0; - padding: 2px 2px 2px 0; - vertical-align: top; -} - -/*----END Data Table----*/ - -fieldset { - border: 1px solid #8f8f8f; - margin: 0; - padding: 0; -} -fieldset.plain { - border: none; - margin: 0; - padding: 0; -} -input[type="checkbox"] { - margin:0; - outline:none; - padding:0; - width:13px; - height:13px; -} -/*---//////////////////// LOGIN ////////////////////---*/ - -.login_box { - margin: 0 auto 0 auto; - text-align:center; - width:420px; - border:1px solid #181818; - border-width: 0 0 1px 0; - padding:0; - padding-top:60px; -} - -.login_box h2 { - background:#1f1f1f; - background: -moz-linear-gradient(center top , #2c2c2c 0pt, #1f1f1f 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #2c2c2c), color-stop(100%, #1f1f1f)); - border:1px solid #181818; - border-top-color:#4f4f4f; - margin:0; - padding:8px 0 8px 14px; - font-size:15px; - font-weight:bold; - color:#bebebe; - text-align:left; - -moz-box-shadow: 0 2px 2px rgba(0,0,0,.10); - -webkit-box-shadow: 0 2px 2px rgba(0,0,0,.10); - box-shadow: 0 2px 2px rgba(0,0,0,.10); -} -.login_box p { - margin:0; - padding:8px 0 16px 0; - font-size:12px; - color:#717171; - text-align:left; -} -.logobox { - height:120px; - text-align:center; - background:url(images/airtime_logo_big.png) no-repeat 50% 0; -} - -.login { - margin:2px 0 0 4px; - border:none; - background:none; - text-align:left; - -moz-box-shadow: none; - -webkit-box-shadow: none; - box-shadow: none; -} - -.login td { - border:none; - background-color:transparent; - color:#696969; -} - -.login h2 { - padding:7px 0 10px 0; -} - -.light { - color:#1683b0; -} -.alert { - color:#C00; -} - -.login-content { - background:url(images/login_content_bg.png) no-repeat 0 bottom; - padding:10px 10px 12px 14px; - text-align:left; -} -.login-content dl, .login-content dl.zend_form { - margin: 12px 0 0 0; - margin-bottom:8px; - margin:0; - padding:0; - width:100%; -} - -.login-content dd { - padding: 4px 0; - float: left; - font-size: 1.2em; - margin: 0; - padding: 4px 0 4px 15px; -} -.login-content dt { - clear: left; - color: #666666; - float: left; - font-size: 1.2em; - font-weight: bold; - margin: 0; - padding: 4px 0; - text-align: left; - min-width:90px; - clear:left; -} - -dt.block-display, dd.block-display { - display:block; - float:none; - margin-left:0; - padding-left:0; -} - -.login-content dt label { - padding-right:0; -} -.login-content dd .input_text { - padding-right:0; - width:280px; -} - -/*---//////////////////// END LOGIN ////////////////////---*/ - - -/*---//////////////////// FOOTER ////////////////////---*/ -.footer { - display:block; - height:40px; - clear:both; - color:#4b4b4b; - margin-top:12px; - font-size:11px; - line-height:140%; - text-align:center; - padding:10px 0 0 0; -} - -.footer a { - color:#ff5d1a; - text-decoration:none; -} -#login-page .footer { - color:#6d6d6d; -} -.footer a:hover { - color:#ff5d1a; - text-decoration:underline; -} -/*---//////////////////// END FOOTER ////////////////////---*/ - -.button-bar { - height: 28px; - margin-top:12px; -} -/*.sticky { - padding:0; - width:100%; - z-index:2000; - position:fixed; - top:0; - left:0; - margin-bottom:140px; -}*/ -.sticky { - padding:0; - width:100%; -} - -.floated-panel { - margin-top:0; - width:99.99%; - z-index:999; -} - - -/*---//////////////////// Schedule Show ////////////////////---*/ - - -#schedule_playlist_dialog .wrapp-two { - float: left; - width: 50%; - padding: 0; -} - -#schedule_playlist_dialog .wrapp-one { - margin-right:2%; - width: 48%; - float: left; -} - -#schedule_playlist_dialog div:first-child .ui-widget-header:first-child { - background: none repeat scroll 0 0 transparent; - border-width: 0 0 1px; - color: #444444; - font-weight: bold; -} - -#schedule_playlist_dialog div:first-child .ui-widget-header:first-child { - background: none repeat scroll 0 0 transparent; - border-width: 0 0 1px; - color: #444444; - font-weight: bold; -} -#schedule_playlist_dialog .ui-widget-header:first-child .dataTables_filter, -#schedule_playlist_dialog .ui-widget-header:first-child .dataTables_length { - margin: 0; -} - -.ui-dialog #schedule_playlist_dialog.ui-dialog-content { - padding:0; -} - - -#schedule_playlist_dialog > div { - background: none repeat scroll 0 0 transparent; - border: 1px solid #8f8f8f; - padding: 8px; - margin:8px 8px 0 8px; -} - - -#schedule_playlist_dialog > div h4 { - padding: 13px 0 12px 0; - margin: 0; - font-size:16px; - font-weight:normal; -} -#schedule_calendar { - width:98.5% -} -div.ui-datepicker { - /*font-size: 75%;*/ -} - - -#schedule_playlist_dialog ul { - list-style-type: none; - overflow: auto; - margin: 0 0 8px 0; - padding: 0; - height: 280px; - background:#9a9a9a; - width:100%; -} - -#schedule_playlist_chosen li { - float: left; - clear: left; - margin: 0; - width: 100%; - display:block; - margin-bottom:-1px; -} - -#schedule_playlist_chosen li > h3 { - font-size:15px; - padding: 7px 0 0 0; - margin: 0; - min-height:25px; - -} - -#schedule_playlist_chosen li > h3 > div { - float: left; - margin: 0 5px 2px 0; -} - -#schedule_playlist_chosen li > h3 > div > span.ui-icon { - margin-top: 0px; -} -#schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-triangle-1-e, -#schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-triangle-1-s { - float:left; - margin-right: 8px; -} -#schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-close { - float:right; - margin-right: 8px; -} -#schedule_playlist_chosen div.group_list { - border-width:0 1px 1px 1px; -} -/*#schedule_playlist_chosen li div{ - float: left; -} - -#schedule_playlist_chosen li > div{ - width: 475px; -} -*/ - -#schedule_playlist_chosen li > div > div{ - clear: left; - padding-top: 5px; - padding-left: 5px; -} -#schedule_playlist_chosen li > div:first-child { - border-bottom:1px solid #b1b1b1; -} -.sched_description { - clear: left; - font-size: 85%; - margin-left: 2em; -} - -.sh_pl_name { - min-width: 150px; -} - -.sh_pl_creator { - -} - -#schedule_playlist_chosen li > h3 > div.sh_pl_time { - float:right; - margin-right:22px; -} - -#schedule_playlist_chosen li > div > div > span { - float: right; - margin-right:46px; -} -#schedule_playlist_chosen li > div > div > span.sh_file_name { - display: inline-block; - float: left; - margin-right:0; -} - -.sh_file_artist, #schedule_playlist_chosen li > div > div.sh_file_artist { - font-size: 11px; - padding-top: 2px; - padding-bottom: 8px; - color:#5b5b5b; -} - -#schedule_playlist_chosen li > div > div.sched_description { - font-size: 12px; - padding-top: 5px; - padding-bottom: 7px; - border-bottom:1px solid #b1b1b1; - color:#5b5b5b; - margin:0; - background:#dddddd; -} -#show_time_info { - font-size:12px; - height:30px; -} - -#show_time_info > div, #show_time_info > span{ - float: left; -} - -#show_progressbar { - width: 46%; - height: 5px; - margin: 9px 9px 0 0; -} -#show_progressbar.ui-widget-content { - background: #646464 url(images/schedule-show_progressbar_bg.png) repeat-x 0 0; - border-color:#343434; - border-bottom-color:#cfcfcf; -} - -#show_progressbar .ui-progressbar-value { - background: #ff5d1a; - border-color:#343434; - border-width: 1px 0 0 1px; -} - -h2#scheduled_playlist_name { - font-size:21px; - font-weight:normal; - margin:0; - padding:8px 0 0px 12px; - color:#1c1c1c; -} - -h2#scheduled_playlist_name span { - color:#656565; -} - -.time { - width: 80px; - margin: 5px; - text-align: left; -} - -/* --- Add show Dialog --- */ - -#add_show_name { - -} - -#add_show_description { - width: 400px; - height: 200px; -} - -#fullcalendar_show_display { - width: 400px; -} - -.fc-agenda-body { - max-height:560px; -} - -#schedule_calendar .ui-progressbar { - width: 46%; - height: 5px; - margin: 9px 9px 0 0; -} - -#schedule_calendar .ui-progressbar.ui-widget-content { - background: #646464 url(images/schedule-show_progressbar_bg.png) repeat-x 0 0; - border-color:#343434; - border-bottom-color:#cfcfcf; -} -#schedule_calendar .ui-progressbar .ui-progressbar-value { - background: #ff5d1a; - border-color:#343434; - border-width: 1px 0 0 1px; -} -/*---//////////////////// Advenced Search ////////////////////---*/ - -.search_control { - padding:8px; - border:1pxp solid #8f8f8f; - background:#d8d8d8; - margin-bottom:8px; -} -.search_group { - padding:8px; - border:1pxp solid #8f8f8f; - margin-bottom:8px; -} -.search_group > fieldset { - padding:0; - border:none; - margin-top:8px; -} -.search_group > fieldset .input_text { - width:45%; -} -.search_group > fieldset .input_text, .search_group > fieldset .input_select { - margin-right:6px; -} -.search_group fieldset .ui-button-icon-only .ui-button-text, .search_group fieldset .ui-button-icons-only .ui-button-text { - padding: 3px 2px; - text-indent: -1e+7px; -} -.search_group fieldset .ui-button-icon-only { - width: 2.1em; -} - -.search_group fieldset .ui-button-icon-only .ui-icon { - left: 48%; - margin-top: -9px; - position: absolute; - top: 50%; -} - -/*---//////////////////// USERS ////////////////////---*/ - -.simple-formblock { - width: 30%; -} - -.simple-formblock dl, .simple-formblock dl.zend_form { - margin: 0; - padding: 0; - width: 100%; -} -.simple-formblock dt { - clear: left; - color: #666666; - float: left; - font-size: 1.2em; - font-weight: bold; - margin: 0; - min-width: 90px; - padding: 4px 0; - text-align: left; -} -.simple-formblock dd { - float: left; - font-size: 1.2em; - margin: 0; - padding: 4px 0 4px 15px; - width:60%; -} - -.simple-formblock.padded-strong { - padding:12px; -} - -.simple-formblock dd .input_text { - width: 100%; -} - -.simple-formblock h2 { - font-size:1.7em; - padding-bottom:16px; -} -.simple-formblock label { - padding:0; -} - -.ui-button-icon-only.crossfade-main-button, .ui-button-icons-only.crossfade-main-button { - padding-right: 8px; -} -.ui-button-icon-only.crossfade-main-button .ui-button-text, .ui-button-icons-only.crossfade-main-button .ui-button-text { - padding: 0; - text-indent: -1e+7px; - padding: 0.1em 1em; -} - -.ui-state-default .ui-icon.crossfade-main-icon { - background:url(images/crossfade_main.png) no-repeat 0 2px; - width:25px; -} - -.ui-button-icon-only.crossfade-main-button .ui-icon { - left: 44%; - margin-left: -8px; -} - -button, input { - margin-top:0; - margin-bottom:0; -} - -.user-management { - width:910px; - /*width:380px;*/ -} -.user-management-expanded { - width:910px; -} -.user-data { - float:left; - width:420px; - margin-left:10px; - /*display:none;*/ -} -.user-list-wrapper { - float:left; - width:480px; - /*margin-right:10px;*/ -} - -.user-management div.user-list-wrapper .ui-widget-header:first-child { - background: none repeat scroll 0 0 transparent; - border-width: 0 0 1px; - color: #444444; - font-weight: bold; -} -.user-list-wrapper .ui-widget-header:first-child .dataTables_filter { - margin:0; -} -.user-management h2 { - font-size: 1.7em; - padding-bottom: 12px; -} -.user-management .dataTables_filter input { - width: 99.6%; - margin-bottom:8px; -} -.user-data.simple-formblock dd { - width: 73%; -} - -.user-data fieldset { - margin-bottom:8px; -} -.user-data fieldset:last-child { - margin-bottom:0; -} - -.user-list-wrapper .button-holder { - padding:0; - text-align:right; - height:37px; -} -.user-list-wrapper .button-holder .ui-button { - margin:0; -} -.ui-widget-content .user-list-wrapper .ui-icon.ui-icon-closethick { - background-image:url(redmond/images/ui-icons_666666_256x240.png); - cursor:pointer; - float:right; - margin-right:5px; -} -.ui-widget-content .user-list-wrapper .ui-icon.ui-icon-closethick:hover { - background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png); -} - - -#ui-datepicker-div { z-index: 10 !important } - -.button-bar-top { - text-align:right; - height:38px; -} - -.toggle-button, .toggle-button-active { - border: 1px solid #505050; - background-color: #5e5e5e; - background: -moz-linear-gradient(top, #757575 0, #5e5e5e 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #757575), color-stop(100%, #5e5e5e)); - color: #ffffff; - margin:0; - font-size:12px; - padding:5px 12px; - text-decoration:none; - text-shadow: #343434 0px -1px; - border-width:1px 0 1px 1px; - cursor:pointer; -} -.toggle-button:hover { - background-color: #292929; - background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); - text-shadow: #000000 0px -1px; -} - -.toggle-button-active { - background-color: #c6c6c6; - background: -moz-linear-gradient(top, #767676 0, #c6c6c6 20%, #c6c6c6 35%, #a0a0a0 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #767676), color-stop(20%, #c6c6c6), color-stop(35%, #c6c6c6), color-stop(100%, #a0a0a0)); - color: #2e2e2e; - cursor:default; - text-shadow: #d8d8d8 0px 1px; -} -.end-button { - border-width:1px; -} - -.button-bar-top .toggle-button, .button-bar-top .toggle-button-active { - float:right; -} - -.button-bar-top .input_text { - height:25px; - margin-right:6px -} -.button-bar-top .input_text.hasDatepicker, .input_text.hasDatepicker { - background-image:url(images/input_with_calendar_bg.png); - background-repeat:no-repeat; - background-position:right 0; -} -.input_text.hasTimepicker { - background-image:url(images/input_with_time_bg.png); - background-repeat:no-repeat; - background-position:right 0; -} -ul.errors { - display:block; - clear:left; - padding:3px 0 0 0; - margin:0; -} - -.formrow-repeat ul.errors { - width:278px; -} - -ul.errors li { - color:#902d2d; - font-size:11px; - padding:2px 4px; - background:#c6b4b4; - margin-bottom:2px; - border:1px solid #c83f3f; -} - -div.success{ - color:#3B5323; - font-size:11px; - padding:2px 4px; - background:#93DB70; - margin-bottom:2px; - border:1px solid #488214; -} - -.collapsible-header { - border: 1px solid #8f8f8f; - background-color: #cccccc; - background: -moz-linear-gradient(top, #cccccc 0, #b9b9b9 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cccccc), color-stop(100%, #b9b9b9)); - font-size:13px; - color:#353535; - font-weight:bold; - padding:6px 0 6px 20px; - margin:8px 0 0 0; - cursor:pointer; - position:relative; -} -.collapsible-content { - margin-top:-1px; - display:none; -} -.collapsible-header .arrow-icon { - display:block; - background:url(images/arrows_collapse.png) no-repeat 0 0; - height:11px; - width:11px; - position:absolute; - left:5px; - top:8px; - -} -.collapsible-header.close .arrow-icon { - background-position: 0 -11px; - -} -#schedule-add-show .button-bar { - height: 28px; - margin: 0 0 8px 0; -} -#schedule-add-show .button-bar.bottom { - margin: 16px 0 0; -} -.schedule { - text-align:left; - height:38px; -} - -.add-button, .ui-widget-content a.add-button { - border: 1px solid #242424; - background-color: #353535; - background: -moz-linear-gradient(top, #494949 0, #353535 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #494949), color-stop(100%, #353535)); - color: #ffffff; - margin:0; - font-size:12px; - font-weight:bold; - padding:4px 12px 4px 22px; - text-decoration:none; - text-shadow: #000 0px -1px; - display:block; - float:left; - position:relative; -} -.add-button:hover, .ui-widget-content a.add-button:hover { - border: 1px solid #000000; - background-color: #353535; - background: -moz-linear-gradient(top, #353535 0, #000000 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #353535), color-stop(100%, #000000)); - color: #ffffff; -} -.add-button span { - position:absolute; - top:3px; - left:3px; - height:16px; - width:16px; - display:block; - background:url(redmond/images/ui-icons_ffffff_256x240.png) no-repeat; -} -.add-button:hover span { - background:url(redmond/images/ui-icons_ff5d1a_256x240.png) no-repeat; -} -.add-button span.add-icon { - background-position: -32px -128px; -} - -/*---//////////////////// NOW PLAYING COLORS ////////////////////---*/ -.playing-song, .datatable tr.playing-song:hover td { - background-color:#ff753c !important; -} -.playing-list { - background-color:#b0dcf2; -} -.odd.playing-list { - background-color:#bfe5f8; -} -.gap, .datatable tr.gap:hover td { - background-color:#da5454 !important; -} -.group, tr td.group { - background-color:#0aa2be; - color:#FFF; -} - - -/*---//////////////////// END NOW PLAYING COLORS ////////////////////---*/ -.icon-link, .ui-widget-content a.icon-link { - color: #646464; - position: relative; - text-decoration: none; - padding: 0 0 0 20px; -} -.icon-link .ui-icon { - background-image:url(redmond/images/ui-icons_666666_256x240.png); - background-repeat: no-repeat; - display: block; - height: 16px; - left: 0.2em; - margin: -3px 5px 0 0; - overflow: hidden; - position: absolute; - top: 2px; - width: 16px; -} -.icon-link:hover, .ui-widget-content a.icon-link:hover { - color: #444444; - text-decoration:underline; -} -.icon-link:hover .ui-icon { - background-image:url(redmond/images/ui-icons_454545_256x240.png); -} - -.button-bar .icon-link { - float:left; - margin:7px 0 0 1px; -} - -#show_content_dialog .datatable tr:first-child td { - border-top:none; -} - -#show_content_dialog .datatable { - margin-top:8px; -} -.simple-formblock.metadata, #side_playlist .simple-formblock.metadata { - border:none; - width:auto; - display:block; - padding: 2px; -} -#side_playlist .simple-formblock.metadata .input_text, #side_playlist .simple-formblock.metadata .input_text_area { - width:95%; -} -#side_playlist .simple-formblock.metadata.simple-formblock dd { - width:70%; -} -#side_playlist h3.plain { - float:none; - font-size:18px; - margin:2px 0 20px 0; -} - -.qtip { - font-size:11px; - line-height:160%; -} - -#schedule-show-who.scrolled { - margin-bottom: 0; - max-height:300px; - overflow:auto; -} -.text-content { - padding:20px 10px 40px 58px; - background: url(images/sf_arror.png) no-repeat 60% 0; - height:100%; -} -.text-content h2 { - font-size:2.4em; - color:#1f1f1f; -} -.text-content p { - font-size:1.6em; - line-height:140%; - color:#1f1f1f; - margin:0 0 1.4em 0; -} -.text-content a { - color:#f2f2f2; - text-decoration:none; -} -.text-content a:hover { - text-decoration:underline; -} - -.text-content ol { - margin:0 0 22px 25px; - padding:0; - list-style-position:outside; -} - -.text-content ol li { - margin:0 0 6px 0; - font-size:1.7em; - display:list-item; - color:#1f1f1f; -} -.gray-logo { - margin:5px 0 0 20px; -} -.formrow-repeat { - list-style-type:none; - margin:0; - padding:0; -} -.formrow-repeat li { - list-style-type:none; - margin:0 0 8px 0; - padding:0; - height:25px; - display:block; -} -/* -.formrow-repeat li .ui-button-icon-only { - width:1.8em; -} -.formrow-repeat li .ui-button-icon-only .ui-button-text, .formrow-repeat li .ui-button-icons-only .ui-button-text { - padding: 3px 3px 4px; -} - -.formrow-repeat li .ui-button-icon-only .ui-icon { - left: 48%; - margin-top: -9px; - position: absolute; - top: 50%; -} -.formrow-repeat li .ui-button .ui-button-text { - display: block; - line-height: 110%; -} -*/ - -#add_show_rebroadcast_relative .ui-button-icon-only, -#add_show_rebroadcast_absolute .ui-button-icon-only { - width: 1.8em; -} -#add_show_rebroadcast_relative .ui-button-icon-only .ui-button-text, -#add_show_rebroadcast_absolute .ui-button-icon-only .ui-button-text, -#add_show_rebroadcast_relative .ui-button-icons-only .ui-button-text, -#add_show_rebroadcast_absolute .ui-button-icons-only .ui-button-text, -#add_show_rebroadcast_relative .ui-button-text-icon-primary .ui-button-text, -#add_show_rebroadcast_absolute .ui-button-text-icon-primary .ui-button-text { - font-size:12px; -} - -#add_show_rebroadcast_relative .ui-button-icon-only .ui-icon, -#add_show_rebroadcast_absolute .ui-button-icon-only .ui-icon { - margin-top: -8px; - position: absolute; - top: 50%; -} -#add_show_rebroadcast_relative .ui-button-text-icon-primary .ui-icon, -#add_show_rebroadcast_absolute .ui-button-text-icon-primary .ui-icon { - left: 0.4em; -} -#add_show_rebroadcast_relative .ui-button .ui-button-text, -#add_show_rebroadcast_absolute .ui-button .ui-button-text { - display: block; - line-height: 14px; -} - -.formrow-repeat li .inline-text { - color: #666666; - padding: 0 6px 0 0; -} -.formrow-repeat li .input_text, .formrow-repeat li .input_select { - margin-right:6px; -} -.formrow-repeat li .hasDatepicker, .formrow-repeat li .input_select { - width:95px; -} -.formrow-repeat li .hasTimepicker { - width:60px; -} -.recording-show { - float: right; - background:url(images/record_icon.png) no-repeat 0 0; - width:23px; - height:23px; -} - -.datatable td .info-icon { - margin:-4px 3px -3px 0; - float:right; -} -.time-flow { - float:right; - margin-right:4px; -} -.small-icon { - display:block; - width:20px; - height:10px; - float:right; - margin-left:3px; - margin-top:2px; -} -.small-icon.recording { - background:url(images/icon_record.png) no-repeat 0 0; -} -.small-icon.rebroadcast { - background:url(images/icon_rebroadcast.png) no-repeat 0 0; -} -.small-icon.soundcloud { - background:url(images/icon_soundcloud.png) no-repeat 0 0; - width:21px; -} -.small-icon.progress { - background:url(images/upload-icon.gif) no-repeat; - background-color:black; - background-position:center; - border-radius:2px; - -webkit-border-radius:2px; - -moz-border-radius:2px; -} -.small-icon.alert { - background:url(images/icon_alert.png) no-repeat; - float:left; - width:13px; - margin-right:3px; - margin-left:1px; -} -.medium-icon { - display:block; - width:25px; - height:12px; - float:right; - margin-left:4px; -} -.medium-icon.recording { - background:url(images/icon_record_m.png) no-repeat 0 0; - width:20px; -} -.medium-icon.rebroadcast { - background:url(images/icon_rebroadcast_m.png) no-repeat 0 0; -} -.medium-icon.soundcloud { - background:url(images/icon_soundcloud_m.png) no-repeat 0 0; - width:21px; -} -.medium-icon.nowplaying, .medium-icon.finishedplaying { - background:url(images/icon_nowplaying_m.png) no-repeat 0 0; - width:12px; - height:9px; - float:left; - margin-left:6px; - margin-right:0; -} -.medium-icon.finishedplaying { - background:url(images/icon_finishedplaying_m.png) no-repeat 0 0; -} -.preferences, .manage-folders { - width: 500px; -} - -dt.block-display, dd.block-display { - display: block; - float: none; - margin-left: 0; - padding-left: 0; -} -.preferences dt.block-display, .preferences dd.block-display { - padding: 0 0 5px 0; -} -.preferences dd.block-display { - margin-bottom:4px; -} -.preferences dd.block-display:last-child { - margin-bottom:0; -} -.simple-formblock dd.block-display { - width: 100%; -} -.preferences input[type="radio"] { - margin:0; -} -.preferences label input[type="radio"] { - margin:0 1px 0 0; -} -.preferences label input[type="checkbox"] { - margin:0 5px 0 0; -} -dd.radio-inline-list, .preferences dd.radio-inline-list { - margin-bottom:6px; -} -.radio-inline-list label { - margin-right:12px; -} -.preferences.simple-formblock dd.block-display { - width: 100%; -} - -.preferences.simple-formblock dd.block-display select { - width: 100%; -} -.preferences dd.block-display .input_select { - width: 100%; -} -.preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text { - width: 99.5%; -} -.preferences dd#SoundCloudTags-element.block-display .input_text_area { - height: 120px; -} - -#show_time_info { - font-size:12px; - height:30px; -} -#show_time_warning { - background:#c83f3f url(images/icon_alert_ffffff.png) no-repeat 5px 4px; - border:1px solid #9d1010; - color:#fff; - padding: 2px 5px 2px 24px; - font-size: 12px; - line-height: 140%; -} - -/* HACK, to be removed after 1.7.0 */ -button.ui-button.md-cancel { - padding: .4em 1em; -} - -/*--//////////////////////// Changes/add-ons Jun 8th, 2011 ////////////////////////--*/ - -.dialogPopup.ui-dialog-content { - padding: 0.9em 1em; -} -.dialogPopup dl { - margin:0; - padding:0; - clear:both; - width:100%; -} -.dialogPopup dt { - clear: left; - padding: 0; - float:left; - width:35%; -} - -.dialogPopup dt.block-display { - float:none; - width:100%; - padding: 0 0 10px; -} - -.dialogPopup dt label { - font-weight: bold; - line-height:24px; -} -.dialogPopup dd { - padding: 0; - float:left; - width:65%; - margin:0 0 6px 0; -} -.dialogPopup dd.block-display { - float:none; - width:100%; - padding: 0 0 10px; - margin:0 0 8px 0; -} -.dialogPopup fieldset dt:last-child, .dialogPopup fieldset dd:last-child { - margin:0; -} - -.info-text { - font-size:12px; - color:#5b5b5b; - line-height:150%; - padding:0 0 6px; - margin:0; - -} -.dialogPopup label input[type="checkbox"] { - float:left; - margin-right:6px; -} - -.dialogPopup fieldset { - padding: 0; - clear:both; - border:none; -} -.dialogPopup fieldset dd input[type="text"], .dialogPopup fieldset dd textarea { - width:99.5%; - padding:0; -} -.dialogPopup fieldset dd select { - width:100%; -} - -fieldset.display_field { - /*background-color:#d5d5d5; - box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset;*/ - padding:10px; - border: 1px solid #8F8F8F; -} -label span { - font-weight:normal; -} - -.dialogPopup .display_field dt, .dialogPopup .display_field dd { - color: #353535; - float: left; - font-size: 12px; - margin: 0; - padding: 4px 0; - text-align: left; - width:auto; -} - -.dialogPopup .display_field dt { - clear: left; - font-weight:bold; - width:auto; - min-width:auto; - padding-right:8px; -} -#show_what_sending textarea { - background-color:transparent; - border:none; - box-shadow: none; - font-size: 12px; - text-indent: 0; - margin:0; - width:100%; - line-height:180%; - resize: none; -} -#show_what_sending textarea:focus { - border:none; -} -#show_what_sending dl { - overflow-x: hidden; -} - -#watched-folder-section dd.block-display input[type="text"] { - width: 65%; -} - -#watched-folder-section dd.block-display input[type="button"] { - border: 1px solid #5b5b5b; - background-color: #6e6e6e; - background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e)); - color: #ffffff; - font-family:Arial, Helvetica, sans-serif; - font-size:12px; - height:25px; - margin:0; - display:block; - margin-left:5px; - line-height:12px; - padding:0 10px 1px 10px; -} -#watched-folder-section dd.block-display input[type="button"]:hover { - border: 1px solid #242424; - background-color: #292929; - background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); - color: #ffffff; -} - -#watched-folder-section dd.block-display { - clear:both; - min-height:25px; - -} -#watched-folder-section dd.block-display.selected-item { - clear:both; - background:#9a9a9a; - margin:2px 0 5px 0; - width:84%; - padding:4px 8px 0; - position:relative; - min-height:22px; - border-radius: 4px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - font-size:13px; -} -#watched-folder-section dd.block-display.selected-item .ui-icon { - position:absolute; - top:4px; - right:5px; - cursor:pointer; -} -#watched-folder-section dd.block-display.selected-item .ui-icon:hover { - background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png) -} -#watched-folder-section dd.block-display input { - float:left; -} - -fieldset > legend { - color: #4F4F4F; - font-size: 12px; - line-height: 140%; -} -fieldset.closed, fieldset.display_field.closed { - border-width: 1px 0 0; - margin-bottom: -6px; - margin-left: 1px; -} - -fieldset.closed dl, fieldset.closed textarea, fieldset.closed div { - display:none; -} - -fieldset legend .ui-icon, .ui-widget-content fieldset legend .ui-icon { - background-image: url(redmond/images/ui-icons_454545_256x240.png); - float: left; -} - -input[type="checkbox"][disabled] { - opacity: 0.6; -} +@charset "utf-8"; +/* CSS Document */ -.play_small { - height:11px; - width: 15px; - display:inline-block; - background:url(images/play_pause_small.png) no-repeat 0 0; - margin:0 7px 0 0; - text-indent:-9999px; - overflow:hidden; - line-height:10px; -} -.play_small:hover, .play_small.paused { - background-position: 0 -11px; -} -.play_small.paused:hover { - background-position: 0 -22px; -} - -.play_small.playing { - background-position: -20px 0; -} -.play_small.playing:hover { - background-position: -20px -11px; -} - -.info-text-small { - color: #5B5B5B; - font-size: 11px; - line-height: 150%; - margin: 0; - padding: 0 0 6px; - font-style:italic; - font-weight:normal; -} -dd .info-text-small { - padding: 1px 0 2px; - display:inline-block; -} \ No newline at end of file +body { + font-size: 62.5%; + font-family:Arial, Helvetica, sans-serif; + background: #7f7f7f; + margin: 0; + padding: 0; +} +html, body { +height: 100%; +} + +#login-page { + background: #1f1f1f url(images/login_page_bg.png) no-repeat center 0; + margin: 0; + padding: 0; + height:100%; + text-align:center; +} + +h2 { + color: #000000; + font-size: 2.1em; + font-weight: normal; + margin: 0; + padding: 0 0 10px; +} +h3 { + font-size:1.7em; + font-weight:normal; + color:#000; + padding:0 0 10px 0; + margin:0; +} +a, a:focus { + outline:none; +} +label { + font-size:12px; +} +select { + font-size:12px; + font-family:Arial, Helvetica, sans-serif; + border:1px solid #9d9d9d; +} + +.logo { + position:absolute; + right:20px; + top:104px; + background:transparent url(images/airtime_logo.png) no-repeat 0 0; + height:35px; + width:66px; + z-index:1000; + display:block; +} + +/* Clearfix */ +.clearfix:after, li:after { content: "."; display: block; height: 0; clear: both; visibility: hidden;} +.clearfix, li { display: inline-block; } +* html .clearfix, * html li { height: 1%;} +.clearfix, li { display: block; } + + +/* Master Panel */ +#sticky { + position:fixed; + height:130px; + top:0; + left:0; +} + + +#master-panel { + background:#3d3d3d url(images/masterpanel_bg.png) repeat-x 0 0; + height:100px; + border:1px solid #000; + border-width: 1px 0; + overflow:hidden; + position:relative; +} + +.now-playing-block, .show-block, .on-air-block, .time-info-block, .personal-block, .listen-control-block, .trial-info-block { + height:100px; + float:left; + margin-right:10px; +} +.personal-block { + float:right; + margin-right:20px; + text-align:right; + min-width:110px; +} + +.personal-block ul { + margin:0; + padding:8px 0 0; +} +.personal-block li { + font-size:11px; + color:#bdbdbd; + list-style-type:none; + margin:0 0 2px 0; +} +.personal-block li.name { + color:#fff; + font-weight:normal; +} +.personal-block li a { + color:#fff; + text-decoration:underline; +} +.personal-block li a:hover { + color:#ff5d1a; +} +.now-playing-block { + width:30%; + padding-left:20px; +} +.show-block { + width:18%; +} +.text-row { + height:30px; + padding:0px 0 0; + font-size:12px; + text-wrap:none; + text-indent:2px; + overflow:hidden; + line-height:30px; +} +#master-panel .text-row { + color:#dfdfdf; +} +.text-row.next-song { + color:#d9d9d9; +} +.text-row strong { + font-weight:bold; + color:#969696; + padding-right:12px; +} +.text-row.rebroadcast, #master-panel .text-row.rebroadcast { + color:#969696; +} +.now-playing-info { + height:25px; + background:#3a3a3a url(images/playinfo_bg.png) repeat-x 0 0; + border: 1px solid #242424; + border-bottom-color:#727272; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + color:#fff; + font-size:15px; + line-height:22px; + text-indent:5px; + overflow:hidden; + margin-bottom:3px; +} +.time-elapsed { + color:#9b9b9b; + padding-right:6px; +} +.time-remaining { + color:#ff6f01; +} +.progressbar { + height:6px; + border:1px solid #242424; + border-width:1px 1px 0 1px; + background:#141414 url(images/progressbar_bg.png) repeat-x 0 0; +} +.progressbar .progress-song, .progressbar .progress-show, .progressbar .progress-show-error { + height:4px; + width:0%; + background:#f97202 url(images/progressbar_song.png) repeat-x 0 0; +} +.progressbar .progress-show { + background:#02cef9 url(images/progressbar_show.png) repeat-x 0 0; +} +.progressbar .progress-show-error { + background:#d40000 url(images/progressbar_show_error.png) repeat-x 0 0; +} +.now-playing-info .show-length { + color:#c4c4c4; + padding-left:6px; +} + +.on-air-block { + padding:0 12px 0 0; + background:url(images/masterpanel_spacer.png) no-repeat right 0; +} +.time-info-block { + padding:0 14px 0 2px; + background:url(images/masterpanel_spacer.png) no-repeat right 0; + min-width:105px; +} +.time-info-block ul { + margin:0; + padding:6px 0 0; +} +.time-info-block li { + list-style-type:none; + font-size:14px; + color:#bdbdbd; + margin:0 0 6px; +} +.time-info-block li.time { + font-size:26px; + color:#fff; + width:auto; + text-align:left; +} +.time-info-block li.time-zone { + font-size:17px; + margin-bottom:0; +} +.on-air-info { + height:26px; + border:1px solid #242424; + border-width:1px 1px 0 1px; + color:#fff; + min-width:85px; + font-size:16px; + line-height:100%; + font-weight:bold; + text-shadow: #242424 0px -1px; + text-align:center; + padding: 10px 0 0 0; + background-color:#464646; + margin-top:30px; +} +.on, .off { + background:#c21717 url(images/on-off-air.png) repeat-x 0 0; +} +.off { + background:#575050 url(images/on-off-air.png) repeat-x 0 -36px; + color:#a5a5a5; +} + +.listen-control-block a { + font-size:11px; + text-transform:uppercase; + padding:0; + border:1px solid #242424; + color:#fff; + text-decoration:none; + font-weight:bold; + margin-top:34px; + display:block; + +} +.listen-control-block a span { + background-color: #6e6e6e; + background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e)); + padding:5px 10px; + border:1px solid #a1a1a1; + border-width:1px 0; + border-bottom-color:#646464; + color:#dcdcdc; + text-shadow: #555555 0px -1px; + display:block; +} +.listen-control-block a:hover { + border:1px solid #000; +} +.listen-control-block a:hover span { + background-color: #292929; + background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); + border:1px solid #555555; + border-width:1px 0; + border-bottom-color:#1e1e1e; + color:#fff; + color:#0C0; + text-shadow: #000 0px -1px; + display:block; +} +.listen-control-block a:active span { + color:#fff; +} + +/* END Master Panel */ + + +.wrapper { + margin: 0 20px 0 20px; + padding:20px 0 0 0; +} + +.alpha-block { + padding:0; + float:left; + margin:0 16px 10px 0; +} +.omega-block { + padding:0; + float:left; + margin:0 0 10px 0; +} +.block-shadow { + -moz-box-shadow: 0 2px 2px rgba(0,0,0,.10); + -webkit-box-shadow: 0 2px 2px rgba(0,0,0,.10); + box-shadow: 0 2px 2px rgba(0,0,0,.10); +} +.clear { + clear: both; + display: block; + height: 0; + overflow: hidden; + visibility: hidden; + width: 0; +} +fieldset.plain { + border:none; + padding:0; + margin:0; +} +.frame { + padding:0; + border:1px solid #5b5b5b; + margin: 0 0 8px 0; +} +.padded { + padding:8px; +} +.padded-strong { + padding:10px; +} +.input_text, input[type="text"], input[type="password"] { + font-family:Arial, Helvetica, sans-serif; + border: 1px solid #5b5b5b; + font-size: 12px; + /*height: 23px;*/ + margin: 0; + padding: 4px 3px; + /*text-indent: 3px;*/ + width:auto; + background-color: #dddddd; + border: 1px solid #5b5b5b; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset; +} + +input[type="text"]:focus, input[type="password"]:focus, textarea:focus, .input_text_area:focus { + border: 1px solid #0088f1; +} +.auto-search { + background:#dddddd url(images/search_auto_bg.png) no-repeat 0 0; + text-indent:25px; +} +.input_text_area, textarea { + background-color: #dddddd; + border: 1px solid #5b5b5b; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset; + font-size: 13px; + text-indent: 3px; + margin:0; +} +.input_select, select { + background-color: #DDDDDD; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset; + border: 1px solid #5b5b5b; + font-family: Arial,Helvetica,sans-serif; + font-size: 12px; + height: 25px; + margin: 0; + padding: 2px 2px 2px 0; + vertical-align: top; +} +label { + font-size:13px; + color:#5b5b5b; + padding:0 16px 0 0; +} +#library_quick_search { + margin-bottom:16px; +} +#library_quick_search label { + +} +#library_quick_search input { + width:60%; +} +dl.inline-list { + float: left; + margin: 0; + padding: 0; + +} + +dl.inline-list dt { + clear: left; + float: left; + margin: 0; + padding: 0px 0; + font-weight: bold; + color:#333333; + font-size:12px; + font-weight:bold; + text-align:left; + min-width:70px; +} +dl.inline-list dd { + float: left; + margin: 0; + padding: 0px 0 4px 15px; + font-size:12px; +} +.left-floated { + float:left; + margin-left:0; + margin-right:10px; +} +.right-floated { + float:right; + margin-left:10px; + margin-right:0; + text-align:right; +} +/*----Data Table----*/ + +.datatable tr th.ui-state-default { + border: 1px solid #CCC; + border-width: 0 0 0 1px !important; +} +.datatable { + border-color: #5b5b5b; + border-style: solid; + border-width: 1px 1px 1px 1px; + width:100%; +} +.datatable tr td, .datatable tr th { + border-color: #b1b1b1; + border-style: solid; + border-width: 1px 0 0 1px; + font-size: 13px; + padding: 5px 5px; +} +.odd { + background-color: #d8d8d8; +} +.even { + background-color:#c7c7c7; +} +.datatable tr.even.selected td { + background-color: #abcfe2; +} +.datatable tr.odd.selected td { + background-color: #c5deeb; +} +.datatable tr.odd:hover td, .datatable tr.even:hover td { + background-color: #95d5f7 !important; +} + +.datatable tr td:first-child, .datatable tr th:first-child, .datatable tr th.ui-state-default:first-child { + border-left-width:0 !important; +} +.ui-widget-header + .datatable { + border-width: 0px 1px 1px 1px; +} +.datatable + .ui-widget-header { + border-width: 0px 1px 1px 1px; +} +.dataTables_scrollHeadInner > .datatable { + border-width: 0px 1px 0 1px; +} +.dataTables_scroll .datatable { + border-width: 0px 1px 0 1px; +} + +.DataTables_sort_wrapper .ui-icon { + display: block; + float: left; + margin: 0 3px 0 -2px; +} +.dataTables_length { + float:right; + margin:0 8px 0 0; + +} +.dataTables_length label { + padding:10px 6px 0 0; + font-size:12px; + color:#404040; + line-height:22px; +} +.dataTables_filter { + margin:8px 0 0 8px; +} +.dataTables_filter .auto-search { + width:60%; +} +.dataTables_processing { + font-size:11px; + font-weight:normal; + margin:2px 0 3px 8px; +} +#library_display_wrapper .ui-widget-header:first-child { + background:none; + border-width:0 0 1px 0; + color: #444444; + font-weight: bold; +} +#library_display_wrapper .ui-widget-header:first-child .dataTables_length { + margin:0; +} +#library_display_wrapper .ui-widget-header:first-child .dataTables_filter { + margin:0; +} + +.dataTables_info { + padding: 8px 0 0 8px; + font-size:12px; + color:#555555; + font-weight:normal; +} + +.dataTables_paginate { + padding: 8px 0 8px 8px; +} +.dataTables_paginate .ui-button { + font-size:12px; + font-weight:normal; + padding: 0.2em 1em; + margin-right:3px; +} +.dataTables_filter input { + background: url("images/search_auto_bg.png") no-repeat scroll 0 0 #DDDDDD; + width: 60%; + border: 1px solid #5B5B5B; + margin: 0; + padding: 4px 3px 4px 25px; +} +.dataTables_length select { + background-color: #DDDDDD; + border: 1px solid #5B5B5B; + font-family: Arial,Helvetica,sans-serif; + font-size: 12px; + height: 25px; + margin: 0; + padding: 2px 2px 2px 0; + vertical-align: top; +} + +/*----END Data Table----*/ + +fieldset { + border: 1px solid #8f8f8f; + margin: 0; + padding: 0; +} +fieldset.plain { + border: none; + margin: 0; + padding: 0; +} +input[type="checkbox"] { + margin:0; + outline:none; + padding:0; + width:13px; + height:13px; +} +/*---//////////////////// LOGIN ////////////////////---*/ + +.login_box { + margin: 0 auto 0 auto; + text-align:center; + width:420px; + border:1px solid #181818; + border-width: 0 0 1px 0; + padding:0; + padding-top:60px; +} + +.login_box h2 { + background:#1f1f1f; + background: -moz-linear-gradient(center top , #2c2c2c 0pt, #1f1f1f 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #2c2c2c), color-stop(100%, #1f1f1f)); + border:1px solid #181818; + border-top-color:#4f4f4f; + margin:0; + padding:8px 0 8px 14px; + font-size:15px; + font-weight:bold; + color:#bebebe; + text-align:left; + -moz-box-shadow: 0 2px 2px rgba(0,0,0,.10); + -webkit-box-shadow: 0 2px 2px rgba(0,0,0,.10); + box-shadow: 0 2px 2px rgba(0,0,0,.10); +} +.login_box p { + margin:0; + padding:8px 0 16px 0; + font-size:12px; + color:#717171; + text-align:left; +} +.logobox { + height:120px; + text-align:center; + background:url(images/airtime_logo_big.png) no-repeat 50% 0; +} + +.login { + margin:2px 0 0 4px; + border:none; + background:none; + text-align:left; + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +.login td { + border:none; + background-color:transparent; + color:#696969; +} + +.login h2 { + padding:7px 0 10px 0; +} + +.light { + color:#1683b0; +} +.alert { + color:#C00; +} + +.login-content { + background:url(images/login_content_bg.png) no-repeat 0 bottom; + padding:10px 10px 12px 14px; + text-align:left; +} +.login-content dl, .login-content dl.zend_form { + margin: 12px 0 0 0; + margin-bottom:8px; + margin:0; + padding:0; + width:100%; +} + +.login-content dd { + padding: 4px 0; + float: left; + font-size: 1.2em; + margin: 0; + padding: 4px 0 4px 15px; +} +.login-content dt { + clear: left; + color: #666666; + float: left; + font-size: 1.2em; + font-weight: bold; + margin: 0; + padding: 4px 0; + text-align: left; + min-width:90px; + clear:left; +} + +dt.block-display, dd.block-display { + display:block; + float:none; + margin-left:0; + padding-left:0; +} + +.login-content dt label { + padding-right:0; +} +.login-content dd .input_text { + padding-right:0; + width:280px; +} + +/*---//////////////////// END LOGIN ////////////////////---*/ + + +/*---//////////////////// FOOTER ////////////////////---*/ +.footer { + display:block; + height:40px; + clear:both; + color:#4b4b4b; + margin-top:12px; + font-size:11px; + line-height:140%; + text-align:center; + padding:10px 0 0 0; +} + +.footer a { + color:#ff5d1a; + text-decoration:none; +} +#login-page .footer { + color:#6d6d6d; +} +.footer a:hover { + color:#ff5d1a; + text-decoration:underline; +} +/*---//////////////////// END FOOTER ////////////////////---*/ + +.button-bar { + height: 28px; + margin-top:12px; +} +/*.sticky { + padding:0; + width:100%; + z-index:2000; + position:fixed; + top:0; + left:0; + margin-bottom:140px; +}*/ +.sticky { + padding:0; + width:100%; +} + +.floated-panel { + margin-top:0; + width:99.99%; + z-index:999; +} + + +/*---//////////////////// Schedule Show ////////////////////---*/ + + +#schedule_playlist_dialog .wrapp-two { + float: left; + width: 50%; + padding: 0; +} + +#schedule_playlist_dialog .wrapp-one { + margin-right:2%; + width: 48%; + float: left; +} + +#schedule_playlist_dialog div:first-child .ui-widget-header:first-child { + background: none repeat scroll 0 0 transparent; + border-width: 0 0 1px; + color: #444444; + font-weight: bold; +} + +#schedule_playlist_dialog div:first-child .ui-widget-header:first-child { + background: none repeat scroll 0 0 transparent; + border-width: 0 0 1px; + color: #444444; + font-weight: bold; +} +#schedule_playlist_dialog .ui-widget-header:first-child .dataTables_filter, +#schedule_playlist_dialog .ui-widget-header:first-child .dataTables_length { + margin: 0; +} + +.ui-dialog #schedule_playlist_dialog.ui-dialog-content { + padding:0; +} + + +#schedule_playlist_dialog > div { + background: none repeat scroll 0 0 transparent; + border: 1px solid #8f8f8f; + padding: 8px; + margin:8px 8px 0 8px; +} + + +#schedule_playlist_dialog > div h4 { + padding: 13px 0 12px 0; + margin: 0; + font-size:16px; + font-weight:normal; +} +#schedule_calendar { + width:98.5% +} +div.ui-datepicker { + /*font-size: 75%;*/ +} + + +#schedule_playlist_dialog ul { + list-style-type: none; + overflow: auto; + margin: 0 0 8px 0; + padding: 0; + height: 280px; + background:#9a9a9a; + width:100%; +} + +#schedule_playlist_chosen li { + float: left; + clear: left; + margin: 0; + width: 100%; + display:block; + margin-bottom:-1px; +} + +#schedule_playlist_chosen li > h3 { + font-size:15px; + padding: 7px 0 0 0; + margin: 0; + min-height:25px; + +} + +#schedule_playlist_chosen li > h3 > div { + float: left; + margin: 0 5px 2px 0; +} + +#schedule_playlist_chosen li > h3 > div > span.ui-icon { + margin-top: 0px; +} +#schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-triangle-1-e, +#schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-triangle-1-s { + float:left; + margin-right: 8px; +} +#schedule_playlist_chosen li > h3 > span.ui-icon.ui-icon-close { + float:right; + margin-right: 8px; +} +#schedule_playlist_chosen div.group_list { + border-width:0 1px 1px 1px; +} +/*#schedule_playlist_chosen li div{ + float: left; +} + +#schedule_playlist_chosen li > div{ + width: 475px; +} +*/ + +#schedule_playlist_chosen li > div > div{ + clear: left; + padding-top: 5px; + padding-left: 5px; +} +#schedule_playlist_chosen li > div:first-child { + border-bottom:1px solid #b1b1b1; +} +.sched_description { + clear: left; + font-size: 85%; + margin-left: 2em; +} + +.sh_pl_name { + min-width: 150px; +} + +.sh_pl_creator { + +} + +#schedule_playlist_chosen li > h3 > div.sh_pl_time { + float:right; + margin-right:22px; +} + +#schedule_playlist_chosen li > div > div > span { + float: right; + margin-right:46px; +} +#schedule_playlist_chosen li > div > div > span.sh_file_name { + display: inline-block; + float: left; + margin-right:0; +} + +.sh_file_artist, #schedule_playlist_chosen li > div > div.sh_file_artist { + font-size: 11px; + padding-top: 2px; + padding-bottom: 8px; + color:#5b5b5b; +} + +#schedule_playlist_chosen li > div > div.sched_description { + font-size: 12px; + padding-top: 5px; + padding-bottom: 7px; + border-bottom:1px solid #b1b1b1; + color:#5b5b5b; + margin:0; + background:#dddddd; +} +#show_time_info { + font-size:12px; + height:30px; +} + +#show_time_info > div, #show_time_info > span{ + float: left; +} + +#show_progressbar { + width: 46%; + height: 5px; + margin: 9px 9px 0 0; +} +#show_progressbar.ui-widget-content { + background: #646464 url(images/schedule-show_progressbar_bg.png) repeat-x 0 0; + border-color:#343434; + border-bottom-color:#cfcfcf; +} + +#show_progressbar .ui-progressbar-value { + background: #ff5d1a; + border-color:#343434; + border-width: 1px 0 0 1px; +} + +h2#scheduled_playlist_name { + font-size:21px; + font-weight:normal; + margin:0; + padding:8px 0 0px 12px; + color:#1c1c1c; +} + +h2#scheduled_playlist_name span { + color:#656565; +} + +.time { + width: 80px; + margin: 5px; + text-align: left; +} + +/* --- Add show Dialog --- */ + +#add_show_name { + +} + +#add_show_description { + width: 400px; + height: 200px; +} + +#fullcalendar_show_display { + width: 400px; +} + +.fc-agenda-body { + max-height:560px; +} + +#schedule_calendar .ui-progressbar { + width: 46%; + height: 5px; + margin: 9px 9px 0 0; +} + +#schedule_calendar .ui-progressbar.ui-widget-content { + background: #646464 url(images/schedule-show_progressbar_bg.png) repeat-x 0 0; + border-color:#343434; + border-bottom-color:#cfcfcf; +} +#schedule_calendar .ui-progressbar .ui-progressbar-value { + background: #ff5d1a; + border-color:#343434; + border-width: 1px 0 0 1px; +} +/*---//////////////////// Advenced Search ////////////////////---*/ + +.search_control { + padding:8px; + border:1pxp solid #8f8f8f; + background:#d8d8d8; + margin-bottom:8px; +} +.search_group { + padding:8px; + border:1pxp solid #8f8f8f; + margin-bottom:8px; +} +.search_group > fieldset { + padding:0; + border:none; + margin-top:8px; +} +.search_group > fieldset .input_text { + width:45%; +} +.search_group > fieldset .input_text, .search_group > fieldset .input_select { + margin-right:6px; +} +.search_group fieldset .ui-button-icon-only .ui-button-text, .search_group fieldset .ui-button-icons-only .ui-button-text { + padding: 3px 2px; + text-indent: -1e+7px; +} +.search_group fieldset .ui-button-icon-only { + width: 2.1em; +} + +.search_group fieldset .ui-button-icon-only .ui-icon { + left: 48%; + margin-top: -9px; + position: absolute; + top: 50%; +} + +/*---//////////////////// USERS ////////////////////---*/ + +.simple-formblock { + width: 30%; +} + +.simple-formblock dl, .simple-formblock dl.zend_form { + margin: 0; + padding: 0; + width: 100%; +} +.simple-formblock dt { + clear: left; + color: #666666; + float: left; + font-size: 1.2em; + font-weight: bold; + margin: 0; + min-width: 90px; + padding: 4px 0; + text-align: left; +} +.simple-formblock dd { + float: left; + font-size: 1.2em; + margin: 0; + padding: 4px 0 4px 15px; + width:60%; +} + +.simple-formblock dd.block-display { + width: 100%; +} + +.stream-setting-content dd.block-display { + /*width: 60%;*/ +} + +.simple-formblock.padded-strong { + padding:12px; +} + +.simple-formblock dd .input_text { + width: 97.8%; +} + +.simple-formblock h2 { + font-size:1.7em; + padding-bottom:16px; +} +.simple-formblock label { + padding:0; +} + +.ui-button-icon-only.crossfade-main-button, .ui-button-icons-only.crossfade-main-button { + padding-right: 8px; +} +.ui-button-icon-only.crossfade-main-button .ui-button-text, .ui-button-icons-only.crossfade-main-button .ui-button-text { + padding: 0; + text-indent: -1e+7px; + padding: 0.1em 1em; +} + +.ui-state-default .ui-icon.crossfade-main-icon { + background:url(images/crossfade_main.png) no-repeat 0 2px; + width:25px; +} + +.ui-button-icon-only.crossfade-main-button .ui-icon { + left: 44%; + margin-left: -8px; +} + +button, input { + margin-top:0; + margin-bottom:0; +} + +.user-management { + width:910px; + /*width:380px;*/ +} +.user-management-expanded { + width:910px; +} +.user-data { + float:left; + width:420px; + margin-left:10px; + /*display:none;*/ +} +.user-list-wrapper { + float:left; + width:480px; + /*margin-right:10px;*/ +} + +.user-management div.user-list-wrapper .ui-widget-header:first-child { + background: none repeat scroll 0 0 transparent; + border-width: 0 0 1px; + color: #444444; + font-weight: bold; +} +.user-list-wrapper .ui-widget-header:first-child .dataTables_filter { + margin:0; +} +.user-management h2 { + font-size: 1.7em; + padding-bottom: 12px; +} +.user-management .dataTables_filter input { + width: 93.8%; + margin-bottom:8px; +} +.user-data.simple-formblock dd { + width: 73%; +} + +.user-data fieldset { + margin-bottom:8px; +} +.user-data fieldset:last-child { + margin-bottom:0; +} + +.user-list-wrapper .button-holder { + padding:0; + text-align:right; + height:37px; +} +.user-list-wrapper .button-holder .ui-button { + margin:0; +} +.ui-widget-content .user-list-wrapper .ui-icon.ui-icon-closethick { + background-image:url(redmond/images/ui-icons_666666_256x240.png); + cursor:pointer; + float:right; + margin-right:5px; +} +.ui-widget-content .user-list-wrapper .ui-icon.ui-icon-closethick:hover { + background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png); +} + + +#ui-datepicker-div { z-index: 10 !important } + +.button-bar-top { + text-align:right; + height:38px; +} + +.toggle-button, .toggle-button-active { + border: 1px solid #505050; + background-color: #5e5e5e; + background: -moz-linear-gradient(top, #757575 0, #5e5e5e 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #757575), color-stop(100%, #5e5e5e)); + color: #ffffff; + margin:0; + font-size:12px; + padding:5px 12px; + text-decoration:none; + text-shadow: #343434 0px -1px; + border-width:1px 0 1px 1px; + cursor:pointer; +} +.toggle-button:hover { + background-color: #292929; + background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); + text-shadow: #000000 0px -1px; +} + +.toggle-button-active { + background-color: #c6c6c6; + background: -moz-linear-gradient(top, #767676 0, #c6c6c6 20%, #c6c6c6 35%, #a0a0a0 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #767676), color-stop(20%, #c6c6c6), color-stop(35%, #c6c6c6), color-stop(100%, #a0a0a0)); + color: #2e2e2e; + cursor:default; + text-shadow: #d8d8d8 0px 1px; +} +.end-button { + border-width:1px; +} + +.button-bar-top .toggle-button, .button-bar-top .toggle-button-active { + float:right; +} + +.button-bar-top .input_text { + height:25px; + margin-right:6px +} +.button-bar-top .input_text.hasDatepicker, .input_text.hasDatepicker { + background-image:url(images/input_with_calendar_bg.png); + background-repeat:no-repeat; + background-position:right 0; +} +.input_text.hasTimepicker { + background-image:url(images/input_with_time_bg.png); + background-repeat:no-repeat; + background-position:right 0; +} +ul.errors { + display:block; + clear:left; + padding:3px 0 0 0; + margin:0; +} + +.formrow-repeat ul.errors { + width:278px; +} + +ul.errors li { + color:#902d2d; + font-size:11px; + padding:2px 4px; + background:#c6b4b4; + margin-bottom:2px; + border:1px solid #c83f3f; +} + +div.success{ + color:#3B5323; + font-size:11px; + padding:2px 4px; + background:#93DB70; + margin-bottom:2px; + border:1px solid #488214; +} + +.collapsible-header, .collapsible-header-disabled { + border: 1px solid #8f8f8f; + background-color: #cccccc; + background: -moz-linear-gradient(top, #cccccc 0, #b9b9b9 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cccccc), color-stop(100%, #b9b9b9)); + font-size:13px; + color:#353535; + font-weight:bold; + padding:6px 0 6px 20px; + margin:8px 0 0 0; + cursor:pointer; + position:relative; +} +.collapsible-content { + margin-top:-1px; + display:none; +} +.collapsible-header .arrow-icon, .collapsible-header-disabled .arrow-icon { + display:block; + background:url(images/arrows_collapse.png) no-repeat 0 0; + height:11px; + width:11px; + position:absolute; + left:5px; + top:8px; + +} +.collapsible-header.close .arrow-icon, collapsible-header-disabled.close .arrow-icon { + background-position: 0 -11px; + +} +#schedule-add-show .button-bar { + height: 28px; + margin: 0 0 8px 0; +} +#schedule-add-show .button-bar.bottom { + margin: 16px 0 0; +} +.schedule { + text-align:left; + height:38px; +} + +.add-button, .ui-widget-content a.add-button { + border: 1px solid #242424; + background-color: #353535; + background: -moz-linear-gradient(top, #494949 0, #353535 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #494949), color-stop(100%, #353535)); + color: #ffffff; + margin:0; + font-size:12px; + font-weight:bold; + padding:4px 12px 4px 22px; + text-decoration:none; + text-shadow: #000 0px -1px; + display:block; + float:left; + position:relative; +} +.add-button:hover, .ui-widget-content a.add-button:hover { + border: 1px solid #000000; + background-color: #353535; + background: -moz-linear-gradient(top, #353535 0, #000000 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #353535), color-stop(100%, #000000)); + color: #ffffff; +} +.add-button span { + position:absolute; + top:3px; + left:3px; + height:16px; + width:16px; + display:block; + background:url(redmond/images/ui-icons_ffffff_256x240.png) no-repeat; +} +.add-button:hover span { + background:url(redmond/images/ui-icons_ff5d1a_256x240.png) no-repeat; +} +.add-button span.add-icon { + background-position: -32px -128px; +} + +/*---//////////////////// NOW PLAYING COLORS ////////////////////---*/ +.playing-song, .datatable tr.playing-song:hover td { + background-color:#ff753c !important; +} +.playing-list { + background-color:#b0dcf2; +} +.odd.playing-list { + background-color:#bfe5f8; +} +.gap, .datatable tr.gap:hover td { + background-color:#da5454 !important; +} +.group, tr td.group { + background-color:#0aa2be; + color:#FFF; +} + + +/*---//////////////////// END NOW PLAYING COLORS ////////////////////---*/ +.icon-link, .ui-widget-content a.icon-link { + color: #646464; + position: relative; + text-decoration: none; + padding: 0 0 0 20px; +} +.icon-link .ui-icon { + background-image:url(redmond/images/ui-icons_666666_256x240.png); + background-repeat: no-repeat; + display: block; + height: 16px; + left: 0.2em; + margin: -3px 5px 0 0; + overflow: hidden; + position: absolute; + top: 2px; + width: 16px; +} +.icon-link:hover, .ui-widget-content a.icon-link:hover { + color: #444444; + text-decoration:underline; +} +.icon-link:hover .ui-icon { + background-image:url(redmond/images/ui-icons_454545_256x240.png); +} + +.button-bar .icon-link { + float:left; + margin:7px 0 0 1px; +} + +#show_content_dialog .datatable tr:first-child td { + border-top:none; +} + +#show_content_dialog .datatable { + margin-top:8px; +} +.simple-formblock.metadata, #side_playlist .simple-formblock.metadata { + border:none; + width:auto; + display:block; + padding: 2px; +} +#side_playlist .simple-formblock.metadata .input_text, #side_playlist .simple-formblock.metadata .input_text_area { + width:95%; +} +#side_playlist .simple-formblock.metadata.simple-formblock dd { + width:70%; +} +#side_playlist h3.plain { + float:none; + font-size:18px; + margin:2px 0 20px 0; +} + +.qtip { + font-size:11px; + line-height:160%; +} + +#schedule-show-who.scrolled { + margin-bottom: 0; + max-height:300px; + overflow:auto; +} +.text-content { + padding:20px 10px 40px 58px; + background: url(images/sf_arror.png) no-repeat 60% 0; + min-height: 300px; +} +.text-content h2 { + font-size:2.4em; + color:#1f1f1f; +} +.text-content p { + font-size:1.6em; + line-height:140%; + color:#1f1f1f; + margin:0 0 1.4em 0; +} +.text-content a { + color:#f2f2f2; + text-decoration:none; +} +.text-content a:hover { + text-decoration:underline; +} + +.text-content ol { + margin:0 0 22px 25px; + padding:0; + list-style-position:outside; +} + +.text-content ol li { + margin:0 0 6px 0; + font-size:1.7em; + display:list-item; + color:#1f1f1f; +} +.gray-logo { + margin:5px 0 0 20px; +} +.formrow-repeat { + list-style-type:none; + margin:0; + padding:0; +} +.formrow-repeat li { + list-style-type:none; + margin:0 0 8px 0; + padding:0; + height:25px; + display:block; +} +/* +.formrow-repeat li .ui-button-icon-only { + width:1.8em; +} +.formrow-repeat li .ui-button-icon-only .ui-button-text, .formrow-repeat li .ui-button-icons-only .ui-button-text { + padding: 3px 3px 4px; +} + +.formrow-repeat li .ui-button-icon-only .ui-icon { + left: 48%; + margin-top: -9px; + position: absolute; + top: 50%; +} +.formrow-repeat li .ui-button .ui-button-text { + display: block; + line-height: 110%; +} +*/ + +#add_show_rebroadcast_relative .ui-button-icon-only, +#add_show_rebroadcast_absolute .ui-button-icon-only { + width: 1.8em; +} +#add_show_rebroadcast_relative .ui-button-icon-only .ui-button-text, +#add_show_rebroadcast_absolute .ui-button-icon-only .ui-button-text, +#add_show_rebroadcast_relative .ui-button-icons-only .ui-button-text, +#add_show_rebroadcast_absolute .ui-button-icons-only .ui-button-text, +#add_show_rebroadcast_relative .ui-button-text-icon-primary .ui-button-text, +#add_show_rebroadcast_absolute .ui-button-text-icon-primary .ui-button-text { + font-size:12px; +} + +#add_show_rebroadcast_relative .ui-button-icon-only .ui-icon, +#add_show_rebroadcast_absolute .ui-button-icon-only .ui-icon { + margin-top: -8px; + position: absolute; + top: 50%; +} +#add_show_rebroadcast_relative .ui-button-text-icon-primary .ui-icon, +#add_show_rebroadcast_absolute .ui-button-text-icon-primary .ui-icon { + left: 0.4em; +} +#add_show_rebroadcast_relative .ui-button .ui-button-text, +#add_show_rebroadcast_absolute .ui-button .ui-button-text { + display: block; + line-height: 14px; +} + +.formrow-repeat li .inline-text { + color: #666666; + padding: 0 6px 0 0; +} +.formrow-repeat li .input_text, .formrow-repeat li .input_select { + margin-right:6px; +} +.formrow-repeat li .hasDatepicker, .formrow-repeat li .input_select { + width:95px; +} +.formrow-repeat li .hasTimepicker { + width:60px; +} +.recording-show { + float: right; + background:url(images/record_icon.png) no-repeat 0 0; + width:23px; + height:23px; +} + +.datatable td .info-icon { + margin:-4px 3px -3px 0; + float:right; +} +.time-flow { + float:right; + margin-right:4px; +} +.small-icon { + display:block; + width:20px; + height:10px; + float:right; + margin-left:3px; + margin-top:2px; +} +.small-icon.recording { + background:url(images/icon_record.png) no-repeat 0 0; +} +.small-icon.rebroadcast { + background:url(images/icon_rebroadcast.png) no-repeat 0 0; +} +.small-icon.soundcloud { + background:url(images/icon_soundcloud.png) no-repeat 0 0; + width:21px; +} +.small-icon.sc-error { + background:url(images/icon_soundcloud_error2.png) no-repeat 0 0; + width:21px; +} +.small-icon.progress { + background:url(images/upload-icon.gif) no-repeat; + background-color:black; + background-position:center; + border-radius:2px; + -webkit-border-radius:2px; + -moz-border-radius:2px; +} +.small-icon.alert { + background:url(images/icon_alert.png) no-repeat; + float:left; + width:13px; + margin-right:3px; + margin-left:1px; +} +.medium-icon { + display:block; + width:25px; + height:12px; + float:right; + margin-left:4px; +} +.medium-icon.recording { + background:url(images/icon_record_m.png) no-repeat 0 0; + width:20px; +} +.medium-icon.rebroadcast { + background:url(images/icon_rebroadcast_m.png) no-repeat 0 0; +} +.medium-icon.soundcloud { + background:url(images/icon_soundcloud_m.png) no-repeat 0 0; + width:21px; +} +.medium-icon.nowplaying, .medium-icon.finishedplaying { + background:url(images/icon_nowplaying_m.png) no-repeat 0 0; + width:12px; + height:9px; + float:left; + margin-left:6px; + margin-right:0; +} +.medium-icon.finishedplaying { + background:url(images/icon_finishedplaying_m.png) no-repeat 0 0; +} +.preferences, .manage-folders, .stream-config { + width: 500px; +} + +dt.block-display, dd.block-display { + display: block; + float: none; + margin-left: 0; + padding-left: 0; +} +.preferences dt.block-display, .preferences dd.block-display { + padding: 0 0 5px 0; +} +.preferences dd.block-display, .stream-config dd.block-display { + margin-bottom:4px; +} +.preferences dd.block-display:last-child, .stream-config dd.block-display:last-child { + margin-bottom:0; + padding-bottom:0; +} +.preferences input[type="radio"], .stream-config input[type="radio"] { + margin:0; +} +.preferences label input[type="radio"], .stream-config label input[type="radio"] { + margin:0 1px 0 0; +} +.preferences label input[type="checkbox"], .stream-config label input[type="checkbox"] { + margin:0 5px 0 0; +} +dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio-inline-list { + margin-bottom:6px; +} +.radio-inline-list label { + margin-right:12px; +} +.preferences.simple-formblock dd.block-display { + width: 100%; +} + +.preferences.simple-formblock dd.block-display select, .stream-config.simple-formblock dd.block-display select { + width: 100%; +} +.preferences dd.block-display .input_select, .stream-config dd.block-display .input_select { + width: 100%; +} +.preferences dd.block-display .input_text_area, .preferences dd.block-display .input_text +.stream-config dd.block-display .input_text_area, .stream-config dd.block-display .input_text, +.stream-config dd.block-display input[type="text"], .stream-config dd.block-display input[type="password"] { + width: 98.5%; +} + +.preferences dd#SoundCloudTags-element.block-display .input_text_area { + height: 120px; +} + +#show_time_info { + font-size:12px; + height:30px; +} +#show_time_warning { + background:#c83f3f url(images/icon_alert_ffffff.png) no-repeat 5px 4px; + border:1px solid #9d1010; + color:#fff; + padding: 2px 5px 2px 24px; + font-size: 12px; + line-height: 140%; +} + +/* HACK, to be removed after 1.7.0 */ +button.ui-button.md-cancel { + padding: .4em 1em; +} + +/*--//////////////////////// Changes/add-ons Jun 8th, 2011 ////////////////////////--*/ + +.dialogPopup.ui-dialog-content { + padding: 0.9em 1em; +} +.dialogPopup dl { + margin:0; + padding:0; + clear:both; + width:100%; +} +.dialogPopup dt { + clear: left; + padding: 0; + float:left; + width:35%; +} + +.dialogPopup dt.block-display { + float:none; + width:100%; + padding: 0 0 10px; +} + +.dialogPopup dt label { + font-weight: bold; + line-height:24px; +} +.dialogPopup dd { + padding: 0; + float:left; + width:65%; + margin:0 0 6px 0; +} +.dialogPopup dd.block-display { + float:none; + width:100%; + padding: 0 0 10px; + margin:0 0 8px 0; +} +.dialogPopup fieldset dt:last-child, .dialogPopup fieldset dd:last-child { + margin:0; +} + +.info-text { + font-size:12px; + color:#5b5b5b; + line-height:150%; + padding:0 0 6px; + margin:0; + +} +.dialogPopup label input[type="checkbox"] { + float:left; + margin-right:6px; +} + +.dialogPopup fieldset { + padding: 0; + clear:both; + border:none; +} +.dialogPopup fieldset dd input[type="text"], .dialogPopup fieldset dd textarea { + width:99.5%; + padding:0; +} +.dialogPopup fieldset dd input[type="text"] { + height:23px; +} +.dialogPopup fieldset dd select { + width:100%; +} + +fieldset.display_field { + /*background-color:#d5d5d5; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2) inset;*/ + padding:10px; + border: 1px solid #8F8F8F; +} +label span { + font-weight:normal; +} + +.dialogPopup .display_field dt, .dialogPopup .display_field dd { + color: #353535; + float: left; + font-size: 12px; + margin: 0; + padding: 4px 0; + text-align: left; + width:auto; +} + +.dialogPopup .display_field dt { + clear: left; + font-weight:bold; + width:auto; + min-width:auto; + padding-right:8px; +} +#show_what_sending textarea { + background-color:transparent; + border:none; + box-shadow: none; + font-size: 12px; + text-indent: 0; + margin:0; + width:99%; + line-height:180%; + resize: none; +} +#show_what_sending textarea:focus { + border:none; +} +#show_what_sending dl { + overflow-x: hidden; +} + +#watched-folder-section dd.block-display input[type="text"] { + width: 63.6%; +} + +#watched-folder-section dd.block-display input[type="button"] { + border: 1px solid #5b5b5b; + background-color: #6e6e6e; + background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e)); + color: #ffffff; + font-family:Arial, Helvetica, sans-serif; + font-size:12px; + height:25px; + margin:0; + display:block; + margin-left:5px; + line-height:12px; + padding:0 10px 1px 10px; +} +#watched-folder-section dd.block-display input[type="button"]:hover { + border: 1px solid #242424; + background-color: #292929; + background: -moz-linear-gradient(top, #3b3b3b 0, #292929 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3b3b3b), color-stop(100%, #292929)); + color: #ffffff; +} + +#watched-folder-section dd.block-display { + clear:both; + min-height:25px; + +} +#watched-folder-section dd.block-display.selected-item { + clear:both; + background:#9a9a9a; + margin:2px 0 5px 0; + width:84%; + padding:4px 8px 0; + position:relative; + min-height:22px; + border-radius: 4px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + font-size:13px; +} +#watched-folder-section dd.block-display.selected-item .ui-icon { + position:absolute; + top:4px; + right:5px; + cursor:pointer; +} +#watched-folder-section dd.block-display.selected-item .ui-icon:hover { + background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png) +} +#watched-folder-section dd.block-display input { + float:left; +} + +fieldset > legend { + color: #4F4F4F; + font-size: 12px; + line-height: 140%; +} +fieldset.closed, fieldset.display_field.closed { + border-width: 1px 0 0; + margin-bottom: -6px; + margin-left: 1px; +} + +fieldset.closed dl, fieldset.closed textarea, fieldset.closed div { + display:none; +} + +fieldset legend .ui-icon, .ui-widget-content fieldset legend .ui-icon { + background-image: url(redmond/images/ui-icons_454545_256x240.png); + float: left; +} + +input[type="checkbox"][disabled] { + opacity: 0.6; +} + +.play_small { + height:11px; + width: 15px; + display:inline-block; + background:url(images/play_pause_small.png) no-repeat 0 0; + margin:0 7px 0 0; + text-indent:-9999px; + overflow:hidden; + line-height:10px; +} +.play_small:hover, .play_small.paused { + background-position: 0 -11px; +} +.play_small.paused:hover { + background-position: 0 -22px; +} + +.play_small.playing { + background-position: -20px 0; +} +.play_small.playing:hover { + background-position: -20px -11px; +} + +.info-text-small { + color: #5B5B5B; + font-size: 11px; + line-height: 150%; + margin: 0; + padding: 0 0 6px; + font-style:italic; + font-weight:normal; +} +dd .info-text-small { + padding: 1px 0 2px; + display:inline-block; +} + +.stream-config dt { + width:120px; + padding: 4px 0; +} +.stream-config dt.block-display { + width:auto; +} +.stream-config dd { + margin-bottom:0px; +} +.stream-config dd select { + width:160px; + line-height:140%; +} + +.stream-config dd input[type="text"] { + /*width:98.5%;*/ + min-width:152px; +} + +.stream-config dd input[id$=port] { + width:152px; +} + +dt.block-display.info-block { + width: auto; + font-size:12px; + padding:10px 0; +} +.top-margin { + margin-top:10px; + float: left; +} +.left-margin { + margin-left:20px; + float: left; +} +.stream-config dd.block-display textarea { + width: 99.5%; + height: 110px; +} + +.input-info { + font-size:12px; + padding:0 0 0 5px; +} + +.stream-config dd.block-display input[type="text"].with-info, .stream-config dd.block-display input[type="password"].with-info { + width: 83.6%; +} +.stream-config dd.block-display p { + font-size:13px; + margin:4px 0 4px 2px; +} + +.stream-config #output_setting { + width: 96%; +} + +.stream-config dt.block-display, .stream-config dd.block-display { + /*float: left;*/ +} +.collapsible-header-disabled { + cursor:default; + opacity:0.6; +} + +/*---//////////////////// ERROR PAGE ////////////////////---*/ + +.error-content { + background:url(images/404.png) no-repeat 0 0; + width:300px; + margin: 24px 15px; + padding: 0px 10px 0 420px; +} +.error-content h2 { + margin:0; + padding:0 0 10px 0; + font-size:36px; + font-weight:bold; + color:#3e3e3e; + text-align:left; + letter-spacing:-.3px; + text-shadow: rgba(248,248,248,.3) 0 1px 0, rgba(0,0,0,.8) 0 -1px 0; + rgba(51,51,51,.9) +} +.error-content p { + color: #272727; + font-size: 16px; + margin: 0; + padding:8px 2px; +} +.error-content .button-bar { + margin-top:47px; + padding-left:2px; +} +.error-content .toggle-button { + border: 1px solid #434343; + border-width:1px 1px 0px 1px; + background-color: #636363; + background: -moz-linear-gradient(top, #737373 0, #545454 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #737373), color-stop(100%, #545454)); + color: #1b1b1b; + font-size:15px; + font-weight:bold; + padding:5px 14px 6px 15px; + text-shadow: rgba(248,248,248,.24) 0 1px 0; + box-shadow: rgba(248,248,248,.3) 0px 1px 0px, rgba(0, 0, 0, 0.2) 0 2px 2px inset; + -moz-box-shadow: rgba(248,248,248,.3) 0px 1px 0px, rgba(0, 0, 0, 0.2) 0 2px 2px inset; + -webkit-box-shadow: rgba(248,248,248,.3) 0px 1px 0px, rgba(0, 0, 0, 0.2) 0 2px 2px inset; + margin: 0 5px 0 0; +} +.error-content .toggle-button:hover { + border: 1px solid #000; + border-width:1px 1px 0px 1px; + background-color: #353535; + background: -moz-linear-gradient(top, #393939 0, #000000 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #393939), color-stop(100%, #000000)); + color: #ff5d1a; + text-shadow:none; + box-shadow: rgba(248,248,248,.3) 0px 1px 0px, rgba(0, 0, 0, 0.6) 0 2px 2px inset; + -moz-box-shadow: rgba(248,248,248,.3) 0px 1px 0px, rgba(0, 0, 0, 0.6) 0 2px 2px inset; + -webkit-box-shadow: rgba(248,248,248,.3) 0px 1px 0px, rgba(0, 0, 0, 0.6) 0 2px 2px inset; +} + +/*---//////////////////// DEFAULT TABLE ////////////////////---*/ + +table { + border-color: #5b5b5b; + border-style: solid; + border-width: 0; +} +tbody tr th { + color: #000000; + background-color: #b1b1b1; + background: -moz-linear-gradient(top, #bebebe 0, #a2a2a2 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #bebebe), color-stop(100%, #a2a2a2)); + font-size: 13px; + padding: 5px 5px; + border-color: #b1b1b1; + border-style: solid; + border-width: 1px 0 0 1px; + border-top-color: #5b5b5b; + text-align:left; +} +thead tr th { + color: #FFFFFF; + font-size: 12px; + padding: 5px 5px; + border-color:#CCCCCC; + background-color: #6e6e6e; + background: -moz-linear-gradient(top, #868686 0, #6e6e6e 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #868686), color-stop(100%, #6e6e6e)); + border-style: solid; + border-width: 0 0 0 1px; +} +tr td { + border-color: #b1b1b1; + border-style: solid; + border-width: 0; + font-size: 12px; + padding: 5px 5px; +} +tfoot tr td, tfoot tr th { + color:#FFFFFF; + background-color: #6e6e6e; + background: -moz-linear-gradient(top, #6e6e6e 0, #868686 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #6e6e6e), color-stop(100%, #868686)); + font-size: 13px; + padding: 5px 5px; + border-color: #b1b1b1; + border-style: solid; + border-width: 1px 0 0 1px; +} +tfoot tr th { + font-weight:bold; + text-align:left; +} + + +/*---//////////////////// STATUS TABLE ////////////////////---*/ +.statustable { + background-color: #D8D8D8; + border-width: 2px 1px 1px; +} +.statustable tr td, .statustable tr th { + text-align:center; + vertical-align:text-top; + font-size:13px; +} +.statustable tr td { + border-width: 1px 0 0 1px; +} +.statustable tr td:first-child, .statustable tr th:first-child { + text-align:left; + border-left-width: 0 !important; +} +.checked-icon { + width:100%; + margin:0; + background: url("images/accept.png") no-repeat center center; + height:16px; + margin:0; + display:block; +} +.not-available-icon { + width:100%; + margin:0; + background: url("images/delete.png") no-repeat center center; + height:16px; + margin:0; + display:block; +} +.statustable ul { + margin:4px 0; + padding:0; +} +.statustable ul li { + background:#bbb; + margin:2px 0 6px 0; + padding:4px 8px 0; + position:relative; + min-height:22px; + border-radius: 4px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + font-size:13px; +} +.statustable .big { + width:120px; + height:10px; + background:#444444; + background: -moz-linear-gradient(top, #464646 0, #3e3e3e 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3e3e3e), color-stop(100%, #464646)); + border-bottom:1px solid #fff; + margin: 0 auto; + padding: 1px; + display:inline-block; +} +.diskspace { + background-color:#e76400; + background: -moz-linear-gradient(top, #ff6f01 0, #bc5200 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ff6f01), color-stop(100%, #bc5200)); + height:10px; +} +.statustable a { + color: #222; + text-decoration: underline; +} + +.statustable a:visited { + color: #666; + text-decoration: underline; +} +.statustable a:hover { + color: #e76400; + text-decoration: underline; +} +.strong { + font-weight:bold; +} + + +/*---//////////////////// PLUPLOAD ERROR ////////////////////---*/ + +#plupload_error{ + margin-top:10px; +} + +#plupload_error table { + color:red; + border:1px solid #c83f3f; + background:#c6b4b4; +} +#plupload_error table td { + color:#902d2d; + font-size:12px; + font-weight:bold; + padding:2px 4px; + margin-bottom:2px; + border:none; + margin:0; +} + +/*---//////////////////// TRIAL BOX HEADER ////////////////////---*/ + +.trial-box { + width:142px; + height:38px; + display:block; + position:absolute; + right:20px; + bottom:10px; + background-color:#222; + background-color:rgba(0, 0, 0, 0.7); + z-index:100; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + color:#FFF; + font-size:11px; + padding:7px; +} +.trial-box p { + padding:0 0 3px 0; + margin:0 0 5px 0; + float:left; +} +.trial-box-button a { + width:92px; + height:14px; + display:block; + padding: 1px 3px; + -moz-border-radius: 1px; + -webkit-border-radius: 1px; + border-radius: 1px; + text-transform:uppercase; + text-align:center; + font-family:Arial, Helvetica, sans-serif; + font-weight:bold; + text-decoration:none; + color:#FFFFFF; + background-color:#ff5d1a; + background: -moz-linear-gradient(top, #ff5d1a 0, #dd4202 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ff5d1a), color-stop(100%, #dd4202)); + box-shadow: rgba(248, 248, 248, 0.4) 0 1px 1px inset; + -moz-box-shadow: rgba(248, 248, 248, 0.4) 0 1px 1px inset; + -webkit-box-shadow: rgba(248, 248, 248, 0.4) 0 1px 1px inset; + float:left; +} +.trial-box-button a:hover { + background-color:#dd4202; + background: -moz-linear-gradient(top, #dd4202 0, #ff5d1a 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #dd4202), color-stop(100%, #ff5d1a)); + box-shadow: rgba(248, 248, 248, 0.4) 0 1px 1px inset; + -moz-box-shadow: rgba(248, 248, 248, 0.4) 0 1px 1px inset; + -webkit-box-shadow: rgba(248, 248, 248, 0.4) 0 1px 1px inset; +} +.trial-box-calendar { + float:right; + text-align:center; + font-weight:bold; +} +.trial-box-calendar-white { + font-size:18px; + color:#ff5d1a; + background:#FFF; + width:36px; + height:22px; + display:block; + -webkit-border-top-right-radius: 1px; + -moz-border-radius-topright: 1px; + -webkit-border-top-left-radius: 1px; + -moz-border-radius-topleft: 1px; +} +.trial-box-calendar-gray { + width:36px; + height:14px; + display:block; + color:#FFF; + font-size:11px; + padding:1px 0; + text-transform:uppercase; + background-color:#676767; + background: -moz-linear-gradient(top, #7f7f7f 0, #555555 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #7f7f7f), color-stop(100%, #555555)); + -webkit-border-bottom-right-radius: 1px; + -moz-border-radius-bottomright: 1px; + -webkit-border-bottom-left-radius: 1px; + -moz-border-radius-bottomleft: 1px; + box-shadow: rgba(0, 0, 0, 0.4) 0 2px 1px inset; + -moz-box-shadow: rgba(0, 0, 0, 0.4) 0 2px 2px inset; + -webkit-box-shadow: rgba(0, 0, 0, 0.4) 0 2px 2px inset; +} +#stream_url {font-size:12px; line-height: 170%;} +.stream-setting-content fieldset {border-width:0 1px 1px 1px;} \ No newline at end of file diff --git a/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js index 1b0747e1d..510c43fee 100644 --- a/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js +++ b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js @@ -11,6 +11,23 @@ function popup(mylink){ return false; } +function convertSecondsToDaysHoursMinutesSeconds(seconds){ + if (seconds < 0) + seconds = 0; + + seconds = parseInt(seconds, 10); + + var days = parseInt(seconds / 86400); + seconds -= days*86400; + + var hours = parseInt(seconds / 3600); + seconds -= hours*3600; + + var minutes = parseInt(seconds / 60); + seconds -= minutes*60; + + return {days:days, hours:hours, minutes:minutes, seconds:seconds}; +} /* Takes an input parameter of milliseconds and converts these into * the format HH:MM:SS */ @@ -141,6 +158,36 @@ function getFileExt(filename){ return filename.split('.').pop(); } +function audioStream(){ + + if ($("#jquery_jplayer_1").data("jPlayer") && $("#jquery_jplayer_1").data("jPlayer").status.paused != true){ + $('#jquery_jplayer_1').jPlayer('clearMedia'); + $('#jquery_jplayer_1').jPlayer('destroy'); + return; + } + + var uri = "http://localhost:8000/airtime_128.ogg"; + var ext = getFileExt(uri); + + var media; + var supplied; + if (ext == "ogg"){ + media = {oga:uri}; + supplied = "oga"; + } else { + media = {mp3:uri}; + supplied = "mp3"; + } + + $("#jquery_jplayer_1").jPlayer({ + ready: function () { + $(this).jPlayer("setMedia", media).jPlayer("play"); + }, + swfPath: "/js/jplayer", + supplied: supplied + }); +} + function audioPreview(filename, elemID){ var elems = $('.ui-icon.ui-icon-pause'); @@ -164,17 +211,52 @@ function audioPreview(filename, elemID){ supplied = "mp3"; } - //$('#jquery_jplayer_1').jPlayer('stop'); - $("#jquery_jplayer_1").jPlayer("destroy"); - $("#jquery_jplayer_1").jPlayer({ - ready: function () { - //alert(media); - $(this).jPlayer("setMedia", media).jPlayer("play"); - }, + $("#jquery_jplayer_1").jPlayer("destroy"); + $("#jquery_jplayer_1").jPlayer({ + ready: function () { + $(this).jPlayer("setMedia", media).jPlayer("play"); + }, swfPath: "/js/jplayer", - supplied: supplied - }); + supplied: supplied + }); - //$('#jquery_jplayer_1').jPlayer('setMedia', media).jPlayer('play'); $('#'+elemID+' div.list-item-container a span').attr("class", "ui-icon ui-icon-pause"); } + +function resizeImg(ele, targetWidth, targetHeight){ + var img = $(ele); + + var width = ele.width; + var height = ele.height; + + // resize img proportionaly + if( width > height && width > targetWidth){ + var ratio = targetWidth/width; + img.css("width", targetHeight+"px"); + var newHeight = height * ratio; + img.css("height", newHeight+"px"); + }else if( width < height && height > targetHeight){ + var ratio = targetHeight/height; + img.css("height", targetHeight+"px"); + var newWidth = width * ratio; + img.css("width", newWidth+"px"); + }else if( width == height && width > targetWidth){ + img.css("height", targetHeight+"px"); + img.css("width", targetWidth+"px" ); + } +} + +function resizeToMaxHeight(ele, targetHeight){ + var img = $(ele); + + var width = ele.width; + var height = ele.height; + + // resize img proportionaly + if( height > targetHeight){ + var ratio = targetHeight/height; + img.css("height", targetHeight+"px"); + var newWidth = width * ratio; + img.css("width", newWidth+"px"); + } +} diff --git a/airtime_mvc/public/js/airtime/dashboard/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js index 8b85621a7..9310958b3 100644 --- a/airtime_mvc/public/js/airtime/dashboard/playlist.js +++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js @@ -13,6 +13,8 @@ var currentElem; var serverUpdateInterval = 5000; var uiUpdateInterval = 200; +var timezoneOffset = 0; + //set to "development" if we are developing :). Useful to disable alerts //when entering production mode. var APPLICATION_ENV = ""; @@ -25,11 +27,11 @@ var nextShowPrepare = true; function secondsTimer(){ if (localRemoteTimeOffset !== null){ - var date = new Date(); + var date = new Date(); estimatedSchedulePosixTime = date.getTime() - localRemoteTimeOffset; - updateProgressBarValue(); + updateProgressBarValue(); updatePlaybar(); - } + } setTimeout(secondsTimer, uiUpdateInterval); } @@ -55,61 +57,61 @@ function nextShowStart(){ /* Called every "uiUpdateInterval" mseconds. */ function updateProgressBarValue(){ var showPercentDone = 0; - if (currentShow.length > 0){ - showPercentDone = (estimatedSchedulePosixTime - currentShow[0].showStartPosixTime)/currentShow[0].showLengthMs*100; - if (showPercentDone < 0 || showPercentDone > 100){ - showPercentDone = 0; - currentShow = new Array(); - currentSong = null; - } - } + if (currentShow.length > 0){ + showPercentDone = (estimatedSchedulePosixTime - currentShow[0].showStartPosixTime)/currentShow[0].showLengthMs*100; + if (showPercentDone < 0 || showPercentDone > 100){ + showPercentDone = 0; + currentShow = new Array(); + currentSong = null; + } + } $('#progress-show').attr("style", "width:"+showPercentDone+"%"); - var songPercentDone = 0; - if (currentSong !== null){ - songPercentDone = (estimatedSchedulePosixTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100; - if (songPercentDone < 0 || songPercentDone > 100){ - songPercentDone = 0; + var songPercentDone = 0; + if (currentSong !== null){ + songPercentDone = (estimatedSchedulePosixTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100; + if (songPercentDone < 0 || songPercentDone > 100){ + songPercentDone = 0; currentSong = null; - } else { + } else { if (currentSong.media_item_played == "t" && currentShow.length > 0) $('#on-air-info').attr("class", "on-air-info on"); else $('#on-air-info').attr("class", "on-air-info off"); $('#progress-show').attr("class", "progress-show"); - } - } else { - $('#on-air-info').attr("class", "on-air-info off"); + } + } else { + $('#on-air-info').attr("class", "on-air-info off"); $('#progress-show').attr("class", "progress-show-error"); } - $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); + $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); - //calculate how much time left to next song if there is any - if (nextSong !== null && nextSongPrepare){ - var diff = nextSong.songStartPosixTime - estimatedSchedulePosixTime; - if (diff < serverUpdateInterval){ + //calculate how much time left to next song if there is any + if (nextSong !== null && nextSongPrepare){ + var diff = nextSong.songStartPosixTime - estimatedSchedulePosixTime; + if (diff < serverUpdateInterval){ //sometimes the diff is negative (-100ms for example). Still looking //into why this could sometimes happen. if (diff < 0) diff=0; - nextSongPrepare = false; - setTimeout(newSongStart, diff); - } - } - - //calculate how much time left to next show if there is any - if (nextShow.length > 0 && nextShowPrepare){ - var diff = nextShow[0].showStartPosixTime - estimatedSchedulePosixTime; - if (diff < serverUpdateInterval){ + nextSongPrepare = false; + setTimeout(newSongStart, diff); + } + } + + //calculate how much time left to next show if there is any + if (nextShow.length > 0 && nextShowPrepare){ + var diff = nextShow[0].showStartPosixTime - estimatedSchedulePosixTime; + if (diff < serverUpdateInterval){ if (diff < 0) diff=0; - nextShowPrepare = false; - setTimeout(nextShowStart, diff); - } - } + nextShowPrepare = false; + setTimeout(nextShowStart, diff); + } + } } function updatePlaybar(){ @@ -157,7 +159,7 @@ function updatePlaybar(){ $('#playlist').text("Current Show:"); var recElem = $('.recording-show'); if (currentShow.length > 0){ - $('#playlist').text(currentShow[0].name); + $('#playlist').text(currentShow[0].name); (currentShow[0].record == "1") ? recElem.show(): recElem.hide(); } else { recElem.hide(); @@ -165,11 +167,11 @@ function updatePlaybar(){ $('#show-length').empty(); if (currentShow.length > 0){ - $('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime)); + $('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime + timezoneOffset) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime + timezoneOffset)); } /* Column 2 update */ - $('#time').text(convertDateToHHMMSS(estimatedSchedulePosixTime)); + $('#time').text(convertDateToHHMMSS(estimatedSchedulePosixTime + timezoneOffset)); } function calcAdditionalData(currentItem){ @@ -179,11 +181,11 @@ function calcAdditionalData(currentItem){ } function calcAdditionalShowData(show){ - if (show.length > 0){ - show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp); - show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp); - show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime; - } + if (show.length > 0){ + show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp); + show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp); + show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime; + } } function parseItems(obj){ @@ -209,7 +211,7 @@ function parseItems(obj){ calcAdditionalShowData(obj.nextShow); var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime); - schedulePosixTime += parseInt(obj.timezoneOffset)*1000; + timezoneOffset = parseInt(obj.timezoneOffset)*1000; var date = new Date(); localRemoteTimeOffset = date.getTime() - schedulePosixTime; } @@ -247,14 +249,23 @@ function setupQtip(){ } } +var stream_window = null; + function init() { //begin producer "thread" getScheduleFromServer(); - + //begin consumer "thread" secondsTimer(); setupQtip(); + + $('.listen-control-block').click(function() { + if (stream_window == null || stream_window.closed) + stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=216'); + stream_window.focus(); + return false; + }); } $(document).ready(function() { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 971bad119..dffc71432 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -31,6 +31,7 @@ function deleteAudioClip(json) { } deleteItem("au", json.id); + location.reload(true); } //callbacks called by jjmenu @@ -55,6 +56,10 @@ function confirmDeletePlaylist(params){ } } +function openFileOnSoundCloud(link){ + window.open(link) +} + function checkImportStatus(){ $.getJSON('/Preference/is-import-in-progress', function(data){ var div = $('#import_status'); @@ -111,47 +116,183 @@ function dtRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { // insert id on lenth field $('td:eq(4)', nRow).attr("id", "length"); - $('td:eq(5) img', nRow).qtip({ - - content: { - url: '/Library/get-file-meta-data', - type: 'post', - data: ({format: "html", id : id, type: type}), - title: { - text: aData[1] + ' MetaData', - button: 'Close' // Show a close link in the title - } - }, - - position: { - - adjust: { - screen: true // Keep the tooltip on-screen at all times - } - }, - - style: { - border: { - width: 0, - radius: 4 - }, - name: 'dark', // Use the default light style - width: 570 // Set the tooltip width - } - }); - return nRow; } function dtDrawCallback() { addLibraryItemEvents(); + addMetadataQtip(); } -$(document).ready(function() { +function addProgressIcon(id) { + if($("#au_"+id).find("td:eq(0)").find("span").length > 0){ + $("#au_"+id).find("td:eq(0)").find("span").removeClass(); + $("span[id="+id+"]").addClass("small-icon progress"); + }else{ + $("#au_"+id).find("td:eq(0)").append('') + } +} - $('.tabs').tabs(); +function checkSCUploadStatus(){ + var url = '/Library/get-upload-to-soundcloud-status/format/json'; + $("span[class*=progress]").each(function(){ + var id = $(this).attr("id"); + $.post(url, {format: "json", id: id, type:"file"}, function(json){ + if(json.sc_id > 0){ + $("span[id="+id+"]").removeClass("progress").addClass("soundcloud"); + }else if(json.sc_id == "-3"){ + $("span[id="+id+"]").removeClass("progress").addClass("sc-error"); + } + }); + }) +} - $('#library_display').dataTable( { +function addQtipToSCIcons(){ + $(".progress, .soundcloud, .sc-error").live('mouseover', function(){ + var id = $(this).attr("id"); + if($(this).hasClass("progress")){ + $(this).qtip({ + content: { + text: "Uploading in progress..." + }, + position:{ + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + show: { + ready: true // Needed to make it show on first mouseover event + } + }) + }else if($(this).hasClass("soundcloud")){ + $(this).qtip({ + content: { + text: "Retreiving data from the server...", + ajax: { + url: "/Library/get-upload-to-soundcloud-status", + type: "post", + data: ({format: "json", id : id, type: "file"}), + success: function(json, status){ + this.set('content.text', "The soundcloud id for this file is: "+json.sc_id) + } + } + }, + position:{ + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + show: { + ready: true // Needed to make it show on first mouseover event + } + }) + }else if($(this).hasClass("sc-error")){ + $(this).qtip({ + content: { + text: "Retreiving data from the server...", + ajax: { + url: "/Library/get-upload-to-soundcloud-status", + type: "post", + data: ({format: "json", id : id, type: "file"}), + success: function(json, status){ + this.set('content.text', "There was error while uploading to soundcloud.
    "+"Error code: "+json.error_code+ + "
    "+"Error msg: "+json.error_msg+"
    ") + } + } + }, + position:{ + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + show: { + ready: true // Needed to make it show on first mouseover event + } + }) + } + }); +} + +function addMetadataQtip(){ + var tableRow = $('#library_display tbody tr'); + tableRow.each(function(){ + var title = $(this).find('td:eq(0)').html() + var info = $(this).attr("id") + info = info.split("_"); + var id = info[1]; + var type = info[0]; + $(this).qtip({ + content: { + text: "Loading...", + title: { + text: title + }, + ajax: { + url: "/Library/get-file-meta-data", + type: "post", + data: ({format: "html", id : id, type: type}), + success: function(data, status){ + this.set('content.text', data) + } + } + }, + position: { + target: 'event', + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + style: { + width: 570, + classes: "ui-tooltip-dark" + }, + show: 'mousedown', + events: { + show: function(event, api) { + // Only show the tooltip if it was a right-click + if(event.originalEvent.button !== 2) { + event.preventDefault(); + } + } + } + }) + }) + + tableRow.bind('contextmenu', function(e){ + return false; + }) +} + +/** + * Use user preference for number of entries to show; + * defaults to 10 if preference was never set + */ +function getNumEntriesPreference(data) { + var numEntries = data.libraryInit.numEntries; + if(numEntries == '') { + numEntries = '10'; + } + return parseInt(numEntries); +} + +function createDataTable(data) { + var dTable = $('#library_display').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "/Library/contents/format/json", @@ -181,9 +322,32 @@ $(document).ready(function() { "bAutoWidth": false, "oLanguage": { "sSearch": "" - } - }).fnSetFilteringDelay(350); + }, + "iDisplayLength": getNumEntriesPreference(data) + }); + dTable.fnSetFilteringDelay(350); + + // Updates pref db when user changes the # of entries to show + $('select[name=library_display_length]').change(function() { + var url = '/Library/set-num-entries/format/json'; + $.post(url, {numEntries: $(this).val()}, + function(json){ + if(json.error) { + alert(json.error); + } + }); + }); +} + +$(document).ready(function() { + $('.tabs').tabs(); + + $.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable + , error:function(jqXHR, textStatus, errorThrown){}}); checkImportStatus() setInterval( "checkImportStatus()", 5000 ); + setInterval( "checkSCUploadStatus()", 5000 ); + + addQtipToSCIcons() }); diff --git a/airtime_mvc/public/js/airtime/library/plupload.js b/airtime_mvc/public/js/airtime/library/plupload.js index 76bdf532b..3fac56d6a 100644 --- a/airtime_mvc/public/js/airtime/library/plupload.js +++ b/airtime_mvc/public/js/airtime/library/plupload.js @@ -25,7 +25,7 @@ $(document).ready(function() { $("#plupload_error").find("table").append(row); }else{ - $.get('/Plupload/copyfile/format/json/name/'+file.name, function(json){ + $.get('/Plupload/copyfile/format/json/name/'+encodeURIComponent(file.name), function(json){ var jr = jQuery.parseJSON(json); if(jr.error !== undefined) { var row = $("") diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 4f22f29e9..d05321740 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -303,6 +303,9 @@ function addSPLItem(event, ui){ function deleteSPLItem(event){ event.stopPropagation(); + + // stop any preview playing + $('#jquery_jplayer_1').jPlayer('stop'); var url, pos; @@ -335,17 +338,6 @@ function noOpenPL(json) { .click(newSPL); } -function closeSPL() { - var url; - - // stop playing any preview - $('#jquery_jplayer_1').jPlayer('stop'); - - url = '/Playlist/close/format/json'; - - $.post(url, noOpenPL); -} - function createPlaylistMetaForm(json) { var submit, form; @@ -399,7 +391,7 @@ function newSPL() { function deleteSPL() { var url; - + // stop any preview playing $('#jquery_jplayer_1').jPlayer('stop'); @@ -456,10 +448,6 @@ function setUpSPL() { .button() .click(newSPL); - $("#spl_close") - .button() - .click(closeSPL); - $("#spl_crossfade").click(function(){ if($(this).hasClass("ui-state-active")) { diff --git a/airtime_mvc/public/js/airtime/login/login.js b/airtime_mvc/public/js/airtime/login/login.js new file mode 100644 index 000000000..478b1a978 --- /dev/null +++ b/airtime_mvc/public/js/airtime/login/login.js @@ -0,0 +1,6 @@ +$(window).load(function(){ + $("#username").focus() + + var captcha = $("#captcha-label").next() + captcha.css("padding-left", (((captcha.parents('div:eq(0)').width()-captcha.width())/2+"px"))); +}) \ No newline at end of file diff --git a/airtime_mvc/public/js/airtime/nowplaying/register.js b/airtime_mvc/public/js/airtime/nowplaying/register.js index 534378a7f..fe1e3b38f 100644 --- a/airtime_mvc/public/js/airtime/nowplaying/register.js +++ b/airtime_mvc/public/js/airtime/nowplaying/register.js @@ -36,7 +36,12 @@ $(document).ready(function(){ }); var button = $("#help_airtime"); - button.attr('disabled', 'disabled').addClass('ui-state-disabled'); + + if($("#link_to_terms_and_condition").length > 0 ){ + button.removeAttr('disabled').removeClass('ui-state-disabled'); + }else{ + button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); + } dialog.dialog('open'); @@ -57,7 +62,7 @@ $(document).ready(function(){ button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); }else{ pub.removeAttr("disabled"); - if(privacy.is(':checked')){ + if(privacy.length == 0 || privacy.is(':checked')){ button.removeAttr('disabled').removeClass('ui-state-disabled'); } } @@ -85,7 +90,7 @@ $(document).ready(function(){ } }); - if($("#SupportFeedback").is(':checked') && $("#Privacy").is(':checked')){ + if($("#SupportFeedback").is(':checked') && ($("#Privacy").length == 0 || $("#Privacy").is(':checked'))){ button.removeAttr('disabled').removeClass('ui-state-disabled'); }else{ button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); @@ -97,27 +102,25 @@ $(document).ready(function(){ }); }); -function resizeImg(ele){ - +function resizeImg(ele, targetWidth, targetHeight){ var img = $(ele); var width = ele.width; var height = ele.height; // resize img proportionaly - if( width > height && width > 430){ - var ratio = 430/width; - img.css("width", "430px"); + if( width > height && width > targetWidth){ + var ratio = targetWidth/width; + img.css("width", targetHeight+"px"); var newHeight = height * ratio; - img.css("height", newHeight ); - - }else if( width < height && height > 430){ - var ratio = 430/height; - img.css("height", "430px"); + img.css("height", newHeight); + }else if( width < height && height > targetHeight){ + var ratio = targetHeight/height; + img.css("height", targetHeight+"px"); var newWidth = width * ratio; - img.css("width", newWidth ); - }else if( width == height && width > 430){ - img.css("height", "430px"); - img.css("width", "430px" ); - } -} \ No newline at end of file + img.css("width", newWidth); + }else if( width == height && width > targetWidth){ + img.css("height", targetHeight+"px"); + img.css("width", targetWidth+"px" ); + } +} diff --git a/airtime_mvc/public/js/airtime/preferences/musicdirs.js b/airtime_mvc/public/js/airtime/preferences/musicdirs.js index a71e7aa31..796baec96 100644 --- a/airtime_mvc/public/js/airtime/preferences/musicdirs.js +++ b/airtime_mvc/public/js/airtime/preferences/musicdirs.js @@ -13,7 +13,7 @@ function setWatchedDirEvents() { //knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}], knownPaths: [], imageUrl: 'img/icons/', - systemImageUrl: 'img/browser/', + systemImageUrl: '/css/img/', handlerUrl: '/Preference/server-browse/format/json', title: 'Choose Storage Folder', basePath: '', @@ -69,6 +69,7 @@ function setWatchedDirEvents() { function(json) { $("#watched-folder-section").empty(); + $("#watched-folder-section").append("

    Manage Media Folders

    "); $("#watched-folder-section").append(json.subform); setWatchedDirEvents(); }); @@ -86,6 +87,7 @@ function setWatchedDirEvents() { function(json) { $("#watched-folder-section").empty(); + $("#watched-folder-section").append("

    Manage Media Folders

    "); $("#watched-folder-section").append(json.subform); setWatchedDirEvents(); }); diff --git a/airtime_mvc/public/js/airtime/preferences/preferences.js b/airtime_mvc/public/js/airtime/preferences/preferences.js index d1d2585be..eb6b7a935 100644 --- a/airtime_mvc/public/js/airtime/preferences/preferences.js +++ b/airtime_mvc/public/js/airtime/preferences/preferences.js @@ -1,6 +1,6 @@ function showErrorSections() { - if($("soundcloud-settings .errors").length > 0) { + if($("#soundcloud-settings .errors").length > 0) { $("#soundcloud-settings").show(); $(window).scrollTop($("soundcloud-settings .errors").position().top); } diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js new file mode 100644 index 000000000..a97df38ca --- /dev/null +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -0,0 +1,155 @@ +function showErrorSections() { + + $(".errors").each(function(i){ + if($(this).length > 0){ + $(window).scrollTop($(this).closest("div").position().top); + $(this).closest("fieldset").removeClass('closed'); + return false; + } + }); +} +function rebuildStreamURL(ele){ + var div = ele.closest("div") + host = div.find("input:[id$=-host]").val() + port = div.find("input:[id$=-port]").val() + mount = div.find("input:[id$=-mount]").val() + streamurl = "" + if(div.find("select:[id$=-output]").val()=="icecast"){ + streamurl = "http://"+host + if($.trim(port) != ""){ + streamurl += ":"+port + } + if($.trim(mount) != ""){ + streamurl += "/"+mount + } + }else{ + streamurl = "http://"+host+":"+port+"/" + } + div.find("#stream_url").html(streamurl) +} +function restrictOggBitrate(ele, on){ + var div = ele.closest("div") + if(on){ + div.find("select[id$=data-bitrate]").find("option[value='48']").attr('selected','selected'); + div.find("select[id$=data-bitrate]").find("option[value='24']").attr("disabled","disabled"); + div.find("select[id$=data-bitrate]").find("option[value='32']").attr("disabled","disabled"); + }else{ + div.find("select[id$=data-bitrate]").find("option[value='24']").attr("disabled",""); + div.find("select[id$=data-bitrate]").find("option[value='32']").attr("disabled",""); + } +} +function hideForShoutcast(ele){ + var div = ele.closest("div") + div.find("#outputMountpoint-label").hide() + div.find("#outputMountpoint-element").hide() + div.find("#outputUser-label").hide() + div.find("#outputUser-element").hide() + div.find("select[id$=data-type]").find("option[value='mp3']").attr('selected','selected'); + div.find("select[id$=data-type]").find("option[value='ogg']").attr("disabled","disabled"); + + restrictOggBitrate(ele, false) +} + +function validate(ele,evt) { + var theEvent = evt || window.event; + var key = theEvent.keyCode || theEvent.which; + if ((ele.val().length >= 5 || (key < 48 || key > 57)) && !(key == 8 || key == 9 || key == 13 || key == 37 || key == 39 || key == 46)) { + theEvent.returnValue = false; + if(theEvent.preventDefault) theEvent.preventDefault(); + } + } + + +function showForIcecast(ele){ + var div = ele.closest("div") + div.find("#outputMountpoint-label").show() + div.find("#outputMountpoint-element").show() + div.find("#outputUser-label").show() + div.find("#outputUser-element").show() + div.find("select[id$=data-type]").find("option[value='ogg']").attr("disabled",""); +} + +function checkLiquidsoapStatus(){ + var url = '/Preference/get-liquidsoap-status/format/json'; + var id = $(this).attr("id"); + $.post(url, function(json){ + var json_obj = jQuery.parseJSON(json); + for(var i=0;i height && width > 450){ - var ratio = 450/width; - img.css("width", "450px"); - var newHeight = height * ratio; - img.css("height", newHeight ); - - }else if( width < height && height > 450){ - var ratio = 450/height; - img.css("height", "450px"); - var newWidth = width * ratio; - img.css("width", newWidth ); - }else if( width == height && width > 450){ - img.css("height", "450px"); - img.css("width", "450px" ); - } - -} - $(document).ready(function() { var form = $("form"); @@ -52,7 +27,10 @@ $(document).ready(function() { if(!$("#SupportFeedback").is(':checked')){ promote.removeAttr("checked"); promote.attr("disabled", true); + }else{ + promote.removeAttr("disabled"); } + promote.live('click', function(){ if($(this).is(':checked')){ $("#public-info").show(); diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index 22f72f3f0..b20ba44d7 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -374,7 +374,10 @@ function setAddShowEvents() { function calculateDuration(endDateTime, startDateTime){ var duration; var durationSeconds = (endDateTime.getTime() - startDateTime.getTime())/1000; - if(durationSeconds != 0){ + if(isNaN(durationSeconds)){ + duration = '1h'; + } + else if(durationSeconds != 0){ var durationHour = parseInt(durationSeconds/3600, 10); var durationMin = parseInt((durationSeconds%3600)/60, 10); duration = (durationHour == 0 ? '' : durationHour+'h'+' ')+(durationMin == 0 ? '' : durationMin+'m'); @@ -416,10 +419,16 @@ function showErrorSections() { $("#schedule-record-rebroadcast").show(); $("#add_show_rebroadcast_relative").show(); } + $('input:text').setMask() } $(document).ready(function() { - + $.mask.masks = $.extend($.mask.masks,{ + date:{ mask: '9999-19-39'}, + time:{ mask: '29:69'} + }) + + $('input:text').setMask() //setAddShowEvents(); }); @@ -430,11 +439,24 @@ $(window).resize(function(){ var calendarWidth = 100-(($("#schedule-add-show").width() + (16 * 4))/windowWidth*100); var widthPercent = parseInt(calendarWidth)+"%"; $("#schedule_calendar").css("width", widthPercent); - $("#schedule_calendar").fullCalendar('render'); } + + // 200 px for top dashboard and 50 for padding on main content + // this calculation was copied from schedule.js line 326 + var mainHeight = document.documentElement.clientHeight - 200 - 50; + $('#schedule_calendar').fullCalendar('option', 'contentHeight', mainHeight) + $("#schedule_calendar").fullCalendar('render'); + }); $(window).load(function() { - + $.mask.masks = $.extend($.mask.masks,{ + date:{ mask: '9999-19-39'}, + time:{ mask: '29:69'} + }) + + $('input:text').setMask() + setAddShowEvents(); + }); diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index e0de9e0ac..c77f435bc 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -48,6 +48,17 @@ function removeAddShowButton(){ span.remove(); } +function pad(number, length) { + + var str = '' + number; + while (str.length < length) { + str = '0' + str; + } + + return str; + +} + function makeTimeStamp(date){ var sy, sm, sd, h, m, s, timestamp; sy = date.getFullYear(); @@ -57,14 +68,27 @@ function makeTimeStamp(date){ m = date.getMinutes(); s = date.getSeconds(); - timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s; + timestamp = sy+"-"+ pad(sm, 2) +"-"+ pad(sd, 2) +" "+ pad(h, 2) +":"+ pad(m, 2) +":"+ pad(s, 2); return timestamp; } +function adjustDateToServerDate(date, serverTimezoneOffset){ + //date object stores time in the browser's localtime. We need to artificially shift + //it to + var timezoneOffset = date.getTimezoneOffset()*60*1000; + + date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000); + + /* date object has been shifted to artificial UTC time. Now let's + * shift it to the server's timezone */ + + return date; +} + function dayClick(date, allDay, jsEvent, view) { var now, today, selected, chosenDate, chosenTime; - now = new Date(); + now = adjustDateToServerDate(new Date(), serverTimezoneOffset); if(view.name === "month") { today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); @@ -208,34 +232,53 @@ function eventRender(event, element, view) { } //add the record/rebroadcast icons if needed. - //record icon (only if not on soundcloud, will always be true for future events) if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 1 && event.soundcloud_id === -1) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } if(view.name === 'month' && event.record === 1 && event.soundcloud_id === -1) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } //rebroadcast icon if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.rebroadcast === 1) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } if(view.name === 'month' && event.rebroadcast === 1) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } //soundcloud icon - if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id !== -1 && event.record === 1) { + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id > 0 && event.record === 1) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } - if(view.name === 'month' && event.soundcloud_id !== -1 && event.record === 1) { + if(view.name === 'month' && event.soundcloud_id > 0 && event.record === 1) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } + + //progress icon + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id === -2 && event.record === 1) { + + $(element).find(".fc-event-time").before(''); + } + if(view.name === 'month' && event.soundcloud_id === -2 && event.record === 1) { + + $(element).find(".fc-event-title").after(''); + } + + //error icon + if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.soundcloud_id === -3 && event.record === 1) { + + $(element).find(".fc-event-time").before(''); + } + if(view.name === 'month' && event.soundcloud_id === -3 && event.record === 1) { + + $(element).find(".fc-event-title").after(''); + } } function eventAfterRender( event, element, view ) { @@ -245,6 +288,9 @@ function eventAfterRender( event, element, view ) { [{get:"/Schedule/make-context-menu/format/json/id/#id#"}], {id: event.id}, {xposition: "mouse", yposition: "mouse"}); + $(element).find(".small-icon").live('mouseover',function(){ + addQtipToSCIcons($(this)); + }) } function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { @@ -293,3 +339,97 @@ function getFullCalendarEvents(start, end, callback) { callback(json.events); }); } + +function checkSCUploadStatus(){ + var url = '/Library/get-upload-to-soundcloud-status/format/json'; + $("span[class*=progress]").each(function(){ + var id = $(this).attr("id"); + $.post(url, {format: "json", id: id, type:"show"}, function(json){ + if(json.sc_id > 0){ + $("span[id="+id+"]").removeClass("progress").addClass("soundcloud"); + }else if(json.sc_id == "-3"){ + $("span[id="+id+"]").removeClass("progress").addClass("sc-error"); + } + }); + }) +} + +function addQtipToSCIcons(ele){ + var id = $(ele).attr("id"); + if($(ele).hasClass("progress")){ + $(ele).qtip({ + content: { + text: "Uploading in progress..." + }, + position:{ + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + show: { + ready: true // Needed to make it show on first mouseover event + } + }) + }else if($(ele).hasClass("soundcloud")){ + $(ele).qtip({ + content: { + text: "Retreiving data from the server...", + ajax: { + url: "/Library/get-upload-to-soundcloud-status", + type: "post", + data: ({format: "json", id : id, type: "file"}), + success: function(json, status){ + this.set('content.text', "The soundcloud id for this file is: "+json.sc_id) + } + } + }, + position:{ + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + show: { + ready: true // Needed to make it show on first mouseover event + } + }) + }else if($(ele).hasClass("sc-error")){ + $(ele).qtip({ + content: { + text: "Retreiving data from the server...", + ajax: { + url: "/Library/get-upload-to-soundcloud-status", + type: "post", + data: ({format: "json", id : id, type: "show"}), + success: function(json, status){ + this.set('content.text', "There was error while uploading to soundcloud.
    "+"Error code: "+json.error_code+ + "
    "+"Error msg: "+json.error_msg+"
    ") + } + } + }, + position:{ + adjust: { + resize: true, + method: "flip flip" + }, + at: "right center", + my: "left top", + viewport: $(window) + }, + show: { + ready: true // Needed to make it show on first mouseover event + } + }) + } +} + +$(document).ready(function(){ + setInterval( "checkSCUploadStatus()", 5000 ); +}) diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index a821412d9..5c7ee99f0 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -4,6 +4,8 @@ * */ +var serverTimezoneOffset = 0; + function closeDialog(event, ui) { $("#schedule_calendar").fullCalendar( 'refetchEvents' ); $(this).remove(); @@ -178,20 +180,19 @@ function uploadToSoundCloud(show_instance_id){ var url = "/Schedule/upload-to-sound-cloud"; var span = $(window.triggerElement).find(".recording"); - - span.removeClass("recording") + + if(span.length == 0){ + span = $(window.triggerElement).find(".soundcloud"); + span.removeClass("soundcloud") + .addClass("progress") + }else{ + span.removeClass("recording") .addClass("progress"); + } $.post(url, {id: show_instance_id, format: "json"}, - function(data){ - if(data.error) { - span.removeClass("progress") - .addClass("recording"); - - alert(data.error); - return; - } + function(){ scheduleRefetchEvents(); }); @@ -292,18 +293,49 @@ function buildEditDialog(json){ } -$(window).load(function() { - var mainHeight = document.documentElement.clientHeight - 200 - 50; +/** + * Use user preference for time scale; defaults to month if preference was never set + */ +function getTimeScalePreference(data) { + var timeScale = data.calendarInit.timeScale; + if(timeScale == 'day') { + timeScale = 'agendaDay'; + } else if(timeScale == 'week') { + timeScale = 'agendaWeek'; + } else { + timeScale = 'month'; + } + return timeScale; +} +/** + * Use user preference for time interval; defaults to 30m if preference was never set + */ +function getTimeIntervalPreference(data) { + var timeInterval = data.calendarInit.timeInterval; + if(timeInterval == '') { + timeInterval = '30'; + } + return parseInt(timeInterval); +} + +function createFullCalendar(data){ + + serverTimezoneOffset = data.calendarInit.timezoneOffset; + + var mainHeight = document.documentElement.clientHeight - 200 - 50; + $('#schedule_calendar').fullCalendar({ header: { - left: 'prev, next, today', - center: 'title', - right: 'agendaDay, agendaWeek, month' - }, - defaultView: 'month', - editable: false, - allDaySlot: false, + left: 'prev, next, today', + center: 'title', + right: 'agendaDay, agendaWeek, month' + }, + defaultView: getTimeScalePreference(data), + slotMinutes: getTimeIntervalPreference(data), + firstDay: data.calendarInit.weekStartDay, + editable: false, + allDaySlot: false, axisFormat: 'H:mm', timeFormat: { agenda: 'H:mm{ - H:mm}', @@ -312,17 +344,44 @@ $(window).load(function() { contentHeight: mainHeight, theme: true, lazyFetching: false, + serverTimestamp: parseInt(data.calendarInit.timestamp, 10), + serverTimezoneOffset: parseInt(data.calendarInit.timezoneOffset, 10), - events: getFullCalendarEvents, + events: getFullCalendarEvents, - //callbacks (in full-calendar-functions.js) + //callbacks (in full-calendar-functions.js) viewDisplay: viewDisplay, - dayClick: dayClick, - eventRender: eventRender, - eventAfterRender: eventAfterRender, - eventDrop: eventDrop, - eventResize: eventResize + dayClick: dayClick, + eventRender: eventRender, + eventAfterRender: eventAfterRender, + eventDrop: eventDrop, + eventResize: eventResize + }); + + //Update time scale preference when day/week/month button is clicked + $(".fc-button-content").click(function() { + var url = '/Schedule/set-time-scale/format/json'; + $.post(url, {timeScale: $(this).text()}, + function(json){ + if(json.error) { + alert(json.error); + } + }); }); -}); + //Update time interval preference when dropdown is updated + $(".schedule_change_slots.input_select").change(function() { + var url = '/Schedule/set-time-interval/format/json'; + $.post(url, {timeInterval: $(this).val()}, + function(json){ + if(json.error) { + alert(json.error); + } + }); + }); +} +$(window).load(function() { + $.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:createFullCalendar + , error:function(jqXHR, textStatus, errorThrown){}}); +}); \ No newline at end of file diff --git a/airtime_mvc/public/js/airtime/status/status.js b/airtime_mvc/public/js/airtime/status/status.js new file mode 100644 index 000000000..c58809b90 --- /dev/null +++ b/airtime_mvc/public/js/airtime/status/status.js @@ -0,0 +1,66 @@ +function generatePartitions(partitions){ + + var rowTemplate = + ''+ + 'Disk #%s'+ + '
      '+ + '
    '+ + ''+ + '%sGB of %sGB'+ + ''+ + '
    '+ + '
    '+ + '
    '+ + '
    '+ + '
    %s%% in use
    '+ + ''+ + ''; + + $(".partition-info").remove(); + var lastElement = $('#partitions'); + for (var i=0; i'+partitions[i].dirs[j]+''); + } + lastElement = tr; + } + +} + +function success(data, textStatus, jqXHR){ + var services = data.status.services; + + for (var key in services){ + var s = services[key]; + var children = $("#"+s.name).children(); + $(children[0]).text(s.name); + $($(children[1]).children()[0]).attr("class", s.status ? "checked-icon": "not-available-icon"); + $(children[2]).text(sprintf('%(days)sd %(hours)sh %(minutes)sm %(seconds)ss', convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds))); + $(children[3]).text(s.cpu_perc); + $(children[4]).text(sprintf('%01.1fMB (%s)', parseInt(s.memory_kb)/1000, s.memory_perc)); + } + + generatePartitions(data.status.partitions); +} + +function updateStatus(){ + $.getJSON( "api/status/format/json", null, success); + +} + +$(document).ready(function() { + updateStatus(); + setInterval(updateStatus, 5000); +}); diff --git a/airtime_mvc/public/js/datatables/js/jquery.dataTables.js b/airtime_mvc/public/js/datatables/js/jquery.dataTables.js index 4ba698de5..a295d1706 100644 --- a/airtime_mvc/public/js/datatables/js/jquery.dataTables.js +++ b/airtime_mvc/public/js/datatables/js/jquery.dataTables.js @@ -1,6 +1,6 @@ /* * File: jquery.dataTables.js - * Version: 1.7.5 + * Version: 1.8.2 * Description: Paginate, search and sort HTML tables * Author: Allan Jardine (www.sprymedia.co.uk) * Created: 28/3/2008 @@ -9,7 +9,7 @@ * Project: Mtaala * Contact: allan.jardine@sprymedia.co.uk * - * Copyright 2008-2010 Allan Jardine, all rights reserved. + * Copyright 2008-2011 Allan Jardine, all rights reserved. * * This source file is free software, under either the GPL v2 license or a * BSD style license, as supplied with this software. @@ -22,11 +22,10 @@ */ /* - * When considering jsLint, we need to allow eval() as it it is used for reading cookies and - * building the dynamic multi-column sort functions. + * When considering jsLint, we need to allow eval() as it it is used for reading cookies */ /*jslint evil: true, undef: true, browser: true */ -/*globals $, jQuery,_fnExternApiFunc,_fnInitalise,_fnInitComplete,_fnLanguageProcess,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnGatherData,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap*/ +/*globals $, jQuery,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageProcess,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn*/ (function($, window, document) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -53,7 +52,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Section - DataTables extensible objects * - * The _oExt object is used to provide an area where user dfined plugins can be + * The _oExt object is used to provide an area where user defined plugins can be * added to DataTables. The following properties of the object are used: * oApi - Plug-in API functions * aTypes - Auto-detection of types @@ -68,7 +67,7 @@ * Notes: Allowed format is a.b.c.d.e where: * a:int, b:int, c:int, d:string(dev|beta), e:int. d and e are optional */ - _oExt.sVersion = "1.7.5"; + _oExt.sVersion = "1.8.2"; /* * Variable: sErrMode @@ -149,15 +148,15 @@ /* Full numbers paging buttons */ "sPageButton": "paginate_button", "sPageButtonActive": "paginate_active", - "sPageButtonStaticDisabled": "paginate_button", + "sPageButtonStaticDisabled": "paginate_button paginate_button_disabled", "sPageFirst": "first", "sPagePrevious": "previous", "sPageNext": "next", "sPageLast": "last", - /* Stripping classes */ - "sStripOdd": "odd", - "sStripEven": "even", + /* Striping classes */ + "sStripeOdd": "odd", + "sStripeEven": "even", /* Empty row */ "sRowEmpty": "dataTables_empty", @@ -184,6 +183,7 @@ "sSortJUIAscAllowed": "", "sSortJUIDescAllowed": "", "sSortJUIWrapper": "", + "sSortIcon": "", /* Scrolling */ "sScrollWrapper": "dataTables_scroll", @@ -220,9 +220,9 @@ "sPageNext": "next", "sPageLast": "last ui-corner-tr ui-corner-br", - /* Stripping classes */ - "sStripOdd": "odd", - "sStripEven": "even", + /* Striping classes */ + "sStripeOdd": "odd", + "sStripeEven": "even", /* Empty row */ "sRowEmpty": "dataTables_empty", @@ -250,6 +250,7 @@ "sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n", "sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s", "sSortJUIWrapper": "DataTables_sort_wrapper", + "sSortIcon": "DataTables_sort_icon", /* Scrolling */ "sScrollWrapper": "dataTables_scroll", @@ -272,15 +273,15 @@ /* * Variable: two_button * Purpose: Standard two button (forward/back) pagination - * Scope: jQuery.fn.dataTableExt.oPagination + * Scope: jQuery.fn.dataTableExt.oPagination */ "two_button": { /* * Function: oPagination.two_button.fnInit - * Purpose: Initalise dom elements required for pagination with forward/back buttons only + * Purpose: Initialise dom elements required for pagination with forward/back buttons only * Returns: - - * Inputs: object:oSettings - dataTables settings object - * node:nPaging - the DIV which contains this pagination control + * Inputs: object:oSettings - dataTables settings object + * node:nPaging - the DIV which contains this pagination control * function:fnCallbackDraw - draw function which must be called on update */ "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) @@ -318,7 +319,7 @@ nPaging.appendChild( nPrevious ); nPaging.appendChild( nNext ); - $(nPrevious).click( function() { + $(nPrevious).bind( 'click.DT', function() { if ( oSettings.oApi._fnPageChange( oSettings, "previous" ) ) { /* Only draw when the page has actually changed */ @@ -326,7 +327,7 @@ } } ); - $(nNext).click( function() { + $(nNext).bind( 'click.DT', function() { if ( oSettings.oApi._fnPageChange( oSettings, "next" ) ) { fnCallbackDraw( oSettings ); @@ -334,8 +335,8 @@ } ); /* Take the brutal approach to cancelling text selection */ - $(nPrevious).bind( 'selectstart', function () { return false; } ); - $(nNext).bind( 'selectstart', function () { return false; } ); + $(nPrevious).bind( 'selectstart.DT', function () { return false; } ); + $(nNext).bind( 'selectstart.DT', function () { return false; } ); /* ID the first elements only */ if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" ) @@ -350,7 +351,7 @@ * Function: oPagination.two_button.fnUpdate * Purpose: Update the two button pagination at the end of the draw * Returns: - - * Inputs: object:oSettings - dataTables settings object + * Inputs: object:oSettings - dataTables settings object * function:fnCallbackDraw - draw function to call on page change */ "fnUpdate": function ( oSettings, fnCallbackDraw ) @@ -382,22 +383,22 @@ /* * Variable: iFullNumbersShowPages * Purpose: Change the number of pages which can be seen - * Scope: jQuery.fn.dataTableExt.oPagination + * Scope: jQuery.fn.dataTableExt.oPagination */ "iFullNumbersShowPages": 5, /* * Variable: full_numbers * Purpose: Full numbers pagination - * Scope: jQuery.fn.dataTableExt.oPagination + * Scope: jQuery.fn.dataTableExt.oPagination */ "full_numbers": { /* * Function: oPagination.full_numbers.fnInit - * Purpose: Initalise dom elements required for pagination with a list of the pages + * Purpose: Initialise dom elements required for pagination with a list of the pages * Returns: - - * Inputs: object:oSettings - dataTables settings object - * node:nPaging - the DIV which contains this pagination control + * Inputs: object:oSettings - dataTables settings object + * node:nPaging - the DIV which contains this pagination control * function:fnCallbackDraw - draw function which must be called on update */ "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) @@ -425,28 +426,28 @@ nPaging.appendChild( nNext ); nPaging.appendChild( nLast ); - $(nFirst).click( function () { + $(nFirst).bind( 'click.DT', function () { if ( oSettings.oApi._fnPageChange( oSettings, "first" ) ) { fnCallbackDraw( oSettings ); } } ); - $(nPrevious).click( function() { + $(nPrevious).bind( 'click.DT', function() { if ( oSettings.oApi._fnPageChange( oSettings, "previous" ) ) { fnCallbackDraw( oSettings ); } } ); - $(nNext).click( function() { + $(nNext).bind( 'click.DT', function() { if ( oSettings.oApi._fnPageChange( oSettings, "next" ) ) { fnCallbackDraw( oSettings ); } } ); - $(nLast).click( function() { + $(nLast).bind( 'click.DT', function() { if ( oSettings.oApi._fnPageChange( oSettings, "last" ) ) { fnCallbackDraw( oSettings ); @@ -455,8 +456,8 @@ /* Take the brutal approach to cancelling text selection */ $('span', nPaging) - .bind( 'mousedown', function () { return false; } ) - .bind( 'selectstart', function () { return false; } ); + .bind( 'mousedown.DT', function () { return false; } ) + .bind( 'selectstart.DT', function () { return false; } ); /* ID the first elements only */ if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" ) @@ -473,7 +474,7 @@ * Function: oPagination.full_numbers.fnUpdate * Purpose: Update the list of page buttons shows * Returns: - - * Inputs: object:oSettings - dataTables settings object + * Inputs: object:oSettings - dataTables settings object * function:fnCallbackDraw - draw function to call on page change */ "fnUpdate": function ( oSettings, fnCallbackDraw ) @@ -535,12 +536,12 @@ /* Loop over each instance of the pager */ var an = oSettings.aanFeatures.p; var anButtons, anStatic, nPaginateList; - var fnClick = function() { + var fnClick = function(e) { /* Use the information in the element to jump to the required page */ var iTarget = (this.innerHTML * 1) - 1; oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength; fnCallbackDraw( oSettings ); - return false; + e.preventDefault(); }; var fnFalse = function () { return false; }; @@ -554,8 +555,8 @@ /* Build up the dynamic list forst - html and listeners */ var qjPaginateList = $('span:eq(2)', an[i]); qjPaginateList.html( sList ); - $('span', qjPaginateList).click( fnClick ).bind( 'mousedown', fnFalse ) - .bind( 'selectstart', fnFalse ); + $('span', qjPaginateList).bind( 'click.DT', fnClick ).bind( 'mousedown.DT', fnFalse ) + .bind( 'selectstart.DT', fnFalse ); /* Update the 'premanent botton's classes */ anButtons = an[i].getElementsByTagName('span'); @@ -605,6 +606,8 @@ */ "string-asc": function ( a, b ) { + if ( typeof a != 'string' ) { a = ''; } + if ( typeof b != 'string' ) { b = ''; } var x = a.toLowerCase(); var y = b.toLowerCase(); return ((x < y) ? -1 : ((x > y) ? 1 : 0)); @@ -612,6 +615,8 @@ "string-desc": function ( a, b ) { + if ( typeof a != 'string' ) { a = ''; } + if ( typeof b != 'string' ) { b = ''; } var x = a.toLowerCase(); var y = b.toLowerCase(); return ((x < y) ? 1 : ((x > y) ? -1 : 0)); @@ -646,7 +651,7 @@ if ( isNaN(x) || x==="" ) { - x = Date.parse( "01/01/1970 00:00:00" ); + x = Date.parse( "01/01/1970 00:00:00" ); } if ( isNaN(y) || y==="" ) { @@ -663,7 +668,7 @@ if ( isNaN(x) || x==="" ) { - x = Date.parse( "01/01/1970 00:00:00" ); + x = Date.parse( "01/01/1970 00:00:00" ); } if ( isNaN(y) || y==="" ) { @@ -711,15 +716,19 @@ * Function: - * Purpose: Check to see if a string is numeric * Returns: string:'numeric' or null - * Inputs: string:sText - string to check + * Inputs: mixed:sText - string to check */ function ( sData ) { /* Allow zero length strings as a number */ - if ( sData.length === 0 ) + if ( typeof sData == 'number' ) { return 'numeric'; } + else if ( typeof sData != 'string' ) + { + return null; + } var sValidFirstChars = "0123456789-"; var sValidChars = "0123456789."; @@ -765,7 +774,7 @@ function ( sData ) { var iParse = Date.parse(sData); - if ( (iParse !== null && !isNaN(iParse)) || sData.length === 0 ) + if ( (iParse !== null && !isNaN(iParse)) || (typeof sData == 'string' && sData.length === 0) ) { return 'date'; } @@ -780,7 +789,7 @@ */ function ( sData ) { - if ( sData.indexOf('<') != -1 && sData.indexOf('>') != -1 ) + if ( typeof sData == 'string' && sData.indexOf('<') != -1 && sData.indexOf('>') != -1 ) { return 'html'; } @@ -840,7 +849,7 @@ * Function: dataTable * Purpose: DataTables information * Returns: - - * Inputs: object:oInit - initalisation options for the table + * Inputs: object:oInit - initialisation options for the table */ $.fn.dataTable = function( oInit ) { @@ -914,7 +923,8 @@ "bProcessing": false, "bSortClasses": true, "bStateSave": false, - "bServerSide": false + "bServerSide": false, + "bDeferRender": false }; /* @@ -959,10 +969,12 @@ "sLengthMenu": "Show _MENU_ entries", "sZeroRecords": "No matching records found", "sEmptyTable": "No data available in table", + "sLoadingRecords": "Loading...", "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries", "sInfoEmpty": "Showing 0 to 0 of 0 entries", "sInfoFiltered": "(filtered from _MAX_ total entries)", "sInfoPostFix": "", + "sInfoThousands": ",", "sSearch": "Search:", "sUrl": "", "oPaginate": { @@ -1007,6 +1019,20 @@ * Scope: jQuery.dataTable.classSettings */ this.aoColumns = []; + + /* + * Variable: aoHeader + * Purpose: Store information about the table's header + * Scope: jQuery.dataTable.classSettings + */ + this.aoHeader = []; + + /* + * Variable: aoFooter + * Purpose: Store information about the table's footer + * Scope: jQuery.dataTable.classSettings + */ + this.aoFooter = []; /* * Variable: iNextId @@ -1059,22 +1085,22 @@ this.aaSortingFixed = null; /* - * Variable: asStripClasses + * Variable: asStripeClasses * Purpose: Classes to use for the striping of a table * Scope: jQuery.dataTable.classSettings */ - this.asStripClasses = []; + this.asStripeClasses = []; /* - * Variable: asDestoryStrips - * Purpose: If restoring a table - we should restore it's striping classes as well + * Variable: asDestroyStripes + * Purpose: If restoring a table - we should restore its striping classes as well * Scope: jQuery.dataTable.classSettings */ - this.asDestoryStrips = []; + this.asDestroyStripes = []; /* * Variable: sDestroyWidth - * Purpose: If restoring a table - we should restore it's width + * Purpose: If restoring a table - we should restore its width * Scope: jQuery.dataTable.classSettings */ this.sDestroyWidth = 0; @@ -1110,9 +1136,17 @@ */ this.aoDrawCallback = []; + /* + * Variable: fnPreDrawCallback + * Purpose: Callback function for just before the table is redrawn. A return of false + * will be used to cancel the draw. + * Scope: jQuery.dataTable.classSettings + */ + this.fnPreDrawCallback = null; + /* * Variable: fnInitComplete - * Purpose: Callback function for when the table has been initalised + * Purpose: Callback function for when the table has been initialised * Scope: jQuery.dataTable.classSettings */ this.fnInitComplete = null; @@ -1159,6 +1193,14 @@ */ this.nTableWrapper = null; + /* + * Variable: bDeferLoading + * Purpose: Indicate if when using server-side processing the loading of data + * should be deferred until the second draw + * Scope: jQuery.dataTable.classSettings + */ + this.bDeferLoading = false; + /* * Variable: bInitialised * Purpose: Indicate if all required information has been read in @@ -1262,6 +1304,15 @@ */ this.sAjaxSource = null; + /* + * Variable: sAjaxDataProp + * Purpose: Property from a given object from which to read the table data from. This can + * be an empty string (when not server-side processing), in which case it is + * assumed an an array is given directly. + * Scope: jQuery.dataTable.classSettings + */ + this.sAjaxDataProp = 'aaData'; + /* * Variable: bAjaxDataGet * Purpose: Note if draw should be blocked while getting data @@ -1269,16 +1320,27 @@ */ this.bAjaxDataGet = true; + /* + * Variable: jqXHR + * Purpose: The last jQuery XHR object that was used for server-side data gathering. + * This can be used for working with the XHR information in one of the callbacks + * Scope: jQuery.dataTable.classSettings + */ + this.jqXHR = null; + /* * Variable: fnServerData * Purpose: Function to get the server-side data - can be overruled by the developer * Scope: jQuery.dataTable.classSettings */ - this.fnServerData = function ( url, data, callback ) { - $.ajax( { + this.fnServerData = function ( url, data, callback, settings ) { + settings.jqXHR = $.ajax( { "url": url, "data": data, - "success": callback, + "success": function (json) { + $(settings.oInstance).trigger('xhr', settings); + callback( json ); + }, "dataType": "json", "cache": false, "error": function (xhr, error, thrown) { @@ -1290,6 +1352,17 @@ } ); }; + /* + * Variable: aoServerParams + * Purpose: Functions which are called prior to sending an Ajax request so extra parameters + * can easily be sent to the server + * Scope: jQuery.dataTable.classSettings + * Notes: Each array element is an object with the following parameters: + * function:fn - function to call + * string:sName - name callback - useful for knowing where it came from (plugin etc) + */ + this.aoServerParams = []; + /* * Variable: fnFormatNumber * Purpose: Format numbers for display @@ -1310,7 +1383,7 @@ { if ( i%3 === 0 && i !== 0 ) { - out = ','+out; + out = this.oLanguage.sInfoThousands+out; } out = a[iLen-i-1]+out; } @@ -1380,7 +1453,7 @@ this.bJUI = false; /* - * Variable: bJUI + * Variable: oClasses * Purpose: Should we add the markup needed for jQuery UI theming? * Scope: jQuery.dataTable.classSettings */ @@ -1394,12 +1467,28 @@ this.bFiltered = false; this.bSorted = false; + /* + * Variable: bSortCellsTop + * Purpose: Indicate that if multiple rows are in the header and there is more than one + * unique cell per column, if the top one (true) or bottom one (false) should + * be used for sorting / title by DataTables + * Scope: jQuery.dataTable.classSettings + */ + this.bSortCellsTop = false; + /* * Variable: oInit * Purpose: Initialisation object that is used for the table * Scope: jQuery.dataTable.classSettings */ this.oInit = null; + + /* + * Variable: aoDestroyCallback + * Purpose: Destroy callback functions + * Scope: jQuery.dataTable.classSettings + */ + this.aoDestroyCallback = []; } /* @@ -1680,10 +1769,10 @@ * Purpose: Open a display row (append a row after the row in question) * Returns: node:nNewRow - the row opened * Inputs: node:nTr - the table row to 'open' - * string:sHtml - the HTML to put into the row + * string|node|jQuery:mHtml - the HTML to put into the row * string:sClass - class to give the new TD cell */ - this.fnOpen = function( nTr, sHtml, sClass ) + this.fnOpen = function( nTr, mHtml, sClass ) { /* Find settings from table node */ var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] ); @@ -1696,8 +1785,16 @@ nNewRow.appendChild( nNewCell ); nNewCell.className = sClass; nNewCell.colSpan = _fnVisbleColumns( oSettings ); - nNewCell.innerHTML = sHtml; - + + if( typeof mHtml.jquery != 'undefined' || typeof mHtml == "object" ) + { + nNewCell.appendChild( mHtml ); + } + else + { + nNewCell.innerHTML = mHtml; + } + /* If the nTr isn't on the page at the moment - then we don't insert at the moment */ var nTrs = $('tr', oSettings.nTBody); if ( $.inArray(nTr, nTrs) != -1 ) @@ -1745,16 +1842,15 @@ * Function: fnGetData * Purpose: Return an array with the data which is used to make up the table * Returns: array array string: 2d data array ([row][column]) or array string: 1d data array - * or - * array string (if iRow specified) + * or string if both row and column are given * Inputs: mixed:mRow - optional - if not present, then the full 2D array for the table * if given then: - * int: - return 1D array for aoData entry of this index - * node(TR): - return 1D array for this TR element - * Inputs: int:iRow - optional - if present then the array returned will be the data for - * the row with the index 'iRow' + * int: - return data object for aoData entry of this index + * node(TR): - return data object for this TR element + * int:iCol - optional - the column that you want the data of. This will take into + * account mDataProp and return the value DataTables uses for this column */ - this.fnGetData = function( mRow ) + this.fnGetData = function( mRow, iCol ) { var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] ); @@ -1762,7 +1858,13 @@ { var iRow = (typeof mRow == 'object') ? _fnNodeToDataIndex(oSettings, mRow) : mRow; - return oSettings.aoData[iRow]._aData; + + if ( typeof iCol != 'undefined' ) + { + return _fnGetCellData( oSettings, iRow, iCol, '' ); + } + return (typeof oSettings.aoData[iRow] != 'undefined') ? + oSettings.aoData[iRow]._aData : null; } return _fnGetDataMaster( oSettings ); }; @@ -1782,7 +1884,7 @@ if ( typeof iRow != 'undefined' ) { - return oSettings.aoData[iRow].nTr; + return (typeof oSettings.aoData[iRow] != 'undefined') ? oSettings.aoData[iRow].nTr : null; } return _fnGetTrNodes( oSettings ); }; @@ -1792,34 +1894,28 @@ * Purpose: Get the array indexes of a particular cell from it's DOM element * Returns: int: - row index, or array[ int, int, int ]: - row index, column index (visible) * and column index including hidden columns - * Inputs: node:nNode - this can either be a TR or a TD in the table, the return is + * Inputs: node:nNode - this can either be a TR, TD or TH in the table's body, the return is * dependent on this input */ this.fnGetPosition = function( nNode ) { var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] ); - var i; + var sNodeName = nNode.nodeName.toUpperCase(); - if ( nNode.nodeName.toUpperCase() == "TR" ) + if ( sNodeName == "TR" ) { return _fnNodeToDataIndex(oSettings, nNode); } - else if ( nNode.nodeName.toUpperCase() == "TD" ) + else if ( sNodeName == "TD" || sNodeName == "TH" ) { var iDataIndex = _fnNodeToDataIndex(oSettings, nNode.parentNode); - var iCorrector = 0; - for ( var j=0 ; jtr', oSettings.nTHead)[0]; - var nTrFoot = $('>tr', oSettings.nTFoot)[0]; - var anTheadTh = []; - var anTfootTh = []; - for ( i=0 ; i= _fnVisbleColumns( oSettings ) ) + bAppend = (iInsert >= _fnVisbleColumns( oSettings )); + + /* Which coloumn should we be inserting before? */ + if ( !bAppend ) { - nTrHead.appendChild( anTheadTh[iCol] ); - anTrs = $('>tr', oSettings.nTHead); - for ( i=1, iLen=anTrs.length ; itr', oSettings.nTFoot); - for ( i=1, iLen=anTrs.length ; itr', oSettings.nTHead); - for ( i=1, iLen=anTrs.length ; itr', oSettings.nTFoot); - for ( i=1, iLen=anTrs.length ; itd:eq('+iBefore+')', - oSettings.aoData[i].nTr)[0] ); + oSettings.aoData[i].nTr.appendChild( + oSettings.aoData[i]._anHidden[iCol] + ); + } + else + { + oSettings.aoData[i].nTr.insertBefore( + oSettings.aoData[i]._anHidden[iCol], + _fnGetTdNodes( oSettings, i )[iBefore] ); + } } } - - oSettings.aoColumns[iCol].bVisible = true; } else { /* Remove a column from display */ - nTrHead.removeChild( anTheadTh[iCol] ); - for ( i=0, iLen=oSettings.aoColumns[iCol].anThExtra.length ; i