diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index e3001cffc..f0bb211c8 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -25,7 +25,8 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('preference')) ->add(new Zend_Acl_Resource('recorder')) ->add(new Zend_Acl_Resource('showbuilder')) - ->add(new Zend_Acl_Resource('auth')); + ->add(new Zend_Acl_Resource('auth')) + ->add(new Zend_Acl_Resource('usersettings')); /** Creating permissions */ $ccAcl->allow('G', 'index') @@ -34,11 +35,10 @@ $ccAcl->allow('G', 'index') ->allow('G', 'nowplaying') ->allow('G', 'api') ->allow('G', 'auth') - //->allow('G', 'plupload', array('upload-recorded')) ->allow('G', 'recorder') ->allow('G', 'schedule') ->allow('G', 'dashboard') - //->allow('H', 'plupload', array('plupload', 'upload', 'index')) + ->allow('H', 'usersettings') ->allow('H', 'plupload') ->allow('H', 'library') ->allow('H', 'search') diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index cfe93182e..bebedaa0c 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -1,6 +1,6 @@ addActionContext('status', 'json') ->addActionContext('register-component', 'json') ->addActionContext('update-liquidsoap-status', 'json') - ->addActionContext('library-init', 'json') ->addActionContext('live-chat', 'json') ->addActionContext('update-file-system-mount', 'json') ->addActionContext('handle-watched-dir-missing', 'json') @@ -64,7 +63,7 @@ class ApiController extends Zend_Controller_Action $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. @@ -72,16 +71,16 @@ class ApiController extends Zend_Controller_Action 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"), + "timestamp" => time(), + "timezoneOffset" => date("Z"), "timeScale" => Application_Model_Preference::GetCalendarTimeScale(), "timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(), "weekStartDay" => Application_Model_Preference::GetWeekStartDay() @@ -178,9 +177,9 @@ class ApiController extends Zend_Controller_Action * Retrieve the currently playing show as well as upcoming shows. * Number of shows returned and the time interval in which to * get the next shows can be configured as GET parameters. - * + * * TODO: in the future, make interval length a parameter instead of hardcode to 48 - * + * * Possible parameters: * type - Can have values of "endofday" or "interval". If set to "endofday", * the function will retrieve shows from now to end of day. @@ -199,19 +198,19 @@ class ApiController extends Zend_Controller_Action $date = new Application_Model_DateHelper; $utcTimeNow = $date->getUtcTimestamp(); $utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day - + $request = $this->getRequest(); $type = $request->getParam('type'); if($type == "endofday") { // make GetNextShows use end of day $utcTimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc(); } - + $limit = $request->getParam('limit'); if($limit == "" || !is_numeric($limit)) { $limit = "5"; } - + $result = array("env"=>APPLICATION_ENV, "schedulerTime"=>gmdate("Y-m-d H:i:s"), "currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow), @@ -219,7 +218,7 @@ class ApiController extends Zend_Controller_Action "timezone"=> date("T"), "timezoneOffset"=> date("Z"), "AIRTIME_API_VERSION"=>AIRTIME_API_VERSION); //used by caller to determine if the airtime they are running or widgets in use is out of date. - + //Convert from UTC to localtime for user. Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); @@ -233,7 +232,7 @@ class ApiController extends Zend_Controller_Action exit; } } - + public function weekInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi()){ @@ -244,7 +243,7 @@ class ApiController extends Zend_Controller_Action $date = new Application_Model_DateHelper; $dayStart = $date->getWeekStartDate(); $utcDayStart = Application_Model_DateHelper::ConvertToUtcDateTimeString($dayStart); - + $dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"); $result = array(); @@ -252,9 +251,9 @@ class ApiController extends Zend_Controller_Action $utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart); $shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd); $utcDayStart = $utcDayEnd; - + Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp")); - + $result[$dow[$i]] = $shows; } $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. @@ -373,8 +372,8 @@ 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 = Application_Model_Show::getShows(Application_Model_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()), + + $this->view->shows = Application_Model_Show::getShows(Application_Model_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()), Application_Model_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()), $excludeInstance=NULL, $onlyRecord=TRUE); @@ -405,7 +404,7 @@ class ApiController extends Zend_Controller_Action $upload_dir = ini_get("upload_tmp_dir"); $tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir); $tempFileName = basename($tempFilePath); - + $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; $result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName); if (isset($result)){ @@ -456,19 +455,19 @@ class ApiController extends Zend_Controller_Action } if (isset($show_name)) { - + $show_name = str_replace(" ", "-", $show_name); - + //2011-12-09-19-28-00-ofirrr-256kbps $filename = $file->getName(); - + //replace the showname in the filepath incase it has been edited since the show started recording //(some old bug) $filename_parts = explode("-", $filename); $new_name = array_slice($filename_parts, 0, 6); $new_name[] = $show_name; $new_name[] = $filename_parts[count($filename_parts)-1]; - + $tmpTitle = implode("-", $new_name); } else { @@ -533,7 +532,7 @@ class ApiController extends Zend_Controller_Action } $this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory(); - + $watchedDirs = Application_Model_MusicDir::getWatchedDirs(); $watchedDirsPath = array(); foreach($watchedDirs as $wd){ @@ -573,7 +572,7 @@ class ApiController extends Zend_Controller_Action $filepath = str_replace("//", "/", $filepath); $file = Application_Model_StoredFile::RecallByFilepath($filepath); - + if (is_null($file)) { $file = Application_Model_StoredFile::Insert($md); } @@ -737,10 +736,10 @@ class ApiController extends Zend_Controller_Action $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"])) @@ -752,10 +751,10 @@ class ApiController extends Zend_Controller_Action $this->view->msg = Application_Model_StreamSetting::getStreamSetting(); } - + public function statusAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $api_key = $request->getParam('api_key'); $getDiskInfo = $request->getParam('diskinfo') == "true"; @@ -767,7 +766,7 @@ class ApiController extends Zend_Controller_Action exit; } */ - + $status = array( "platform"=>Application_Model_Systemstatus::GetPlatformInfo(), "airtime_version"=>Application_Model_Preference::GetAirtimeVersion(), @@ -778,11 +777,11 @@ class ApiController extends Zend_Controller_Action "media_monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus() ) ); - + if ($getDiskInfo){ $status["partitions"] = Application_Model_Systemstatus::GetDiskInfo(); } - + $this->view->status = $status; } @@ -795,40 +794,21 @@ class ApiController extends Zend_Controller_Action Application_Model_ServiceRegister::Register($component, $remoteAddr); } - + public function updateLiquidsoapStatusAction(){ $request = $this->getRequest(); - + $msg = $request->getParam('msg'); $stream_id = $request->getParam('stream_id'); $boot_time = $request->getParam('boot_time'); - + Application_Model_StreamSetting::setLiquidsoapError($stream_id, $msg, $boot_time); } - - /** - * 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() - ); - } - + // handles addition/deletion of mount point which watched dirs reside public function updateFileSystemMountAction(){ global $CC_CONFIG; - + $request = $this->getRequest(); $api_key = $request->getParam('api_key'); if (!in_array($api_key, $CC_CONFIG["apiKey"])) @@ -841,16 +821,16 @@ class ApiController extends Zend_Controller_Action $params = $request->getParams(); $added_list = empty($params['added_dir'])?array():explode(',',$params['added_dir']); $removed_list = empty($params['removed_dir'])?array():explode(',',$params['removed_dir']); - + // get all watched dirs $watched_dirs = Application_Model_MusicDir::getWatchedDirs(null,null); - + foreach( $added_list as $ad){ foreach( $watched_dirs as $dir ){ $dirPath = $dir->getDirectory(); - + $ad .= '/'; - + // if mount path itself was watched if($dirPath == $ad){ Application_Model_MusicDir::addWatchedDir($dirPath, false); @@ -883,7 +863,7 @@ class ApiController extends Zend_Controller_Action // is new mount point within the watched dir? // pyinotify doesn't notify anyhing in this case, so we walk through all files within // this watched dir in DB and mark them deleted. - // In case of h) of use cases, due to pyinotify behaviour of noticing mounted dir, we need to + // In case of h) of use cases, due to pyinotify behaviour of noticing mounted dir, we need to // compare agaisnt all files in cc_files table else if(substr($rd, 0, strlen($dirPath)) === $dirPath ){ $watchDir = Application_Model_MusicDir::getDirByPath($rd); @@ -902,13 +882,13 @@ class ApiController extends Zend_Controller_Action } } } - + } - + // handles case where watched dir is missing public function handleWatchedDirMissingAction(){ global $CC_CONFIG; - + $request = $this->getRequest(); $api_key = $request->getParam('api_key'); if (!in_array($api_key, $CC_CONFIG["apiKey"])) @@ -917,7 +897,7 @@ class ApiController extends Zend_Controller_Action print 'You are not allowed to access this resource.'; exit; } - + $dir = base64_decode($request->getParam('dir')); Application_Model_MusicDir::removeWatchedDir($dir, false); } diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 1b2f9dfe4..0c838693d 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -47,7 +47,7 @@ class LibraryController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorderResize.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); @@ -79,6 +79,10 @@ class LibraryController extends Zend_Controller_Action $file = Application_Model_StoredFile::Recall($id); + if (isset($this->pl_sess->id) && $screen == "playlist") { + $menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "copy"); + } + $menu["edit"] = array("name"=> "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}"); if ($user->isAdmin()) { @@ -282,14 +286,4 @@ class LibraryController extends Zend_Controller_Action $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/NowplayingController.php b/airtime_mvc/application/controllers/NowplayingController.php index 1926d596c..bc02662bf 100644 --- a/airtime_mvc/application/controllers/NowplayingController.php +++ b/airtime_mvc/application/controllers/NowplayingController.php @@ -15,25 +15,25 @@ class NowplayingController extends Zend_Controller_Action public function indexAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - + $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + //nowplayingdatagrid.js requires this variable, so that datePicker widget can be offset to server time instead of client time $this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds"); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowview.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - + $refer_sses = new Zend_Session_Namespace('referrer'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); - + if ($request->isPost()) { $form = new Application_Form_RegisterAirtime(); - + $values = $request->getPost(); if ($values["Publicise"] != 1 && $form->isValid($values)){ Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); @@ -49,10 +49,10 @@ class NowplayingController extends Zend_Controller_Action Application_Model_Preference::SetEmail($values["Email"]); Application_Model_Preference::SetStationWebSite($values["StationWebSite"]); 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"]); @@ -75,10 +75,10 @@ class NowplayingController extends Zend_Controller_Action //popup if previous page was login if($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp() && !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){ - + $form = new Application_Form_RegisterAirtime(); - - + + $logo = Application_Model_Preference::GetStationLogo(); if($logo){ $this->view->logoImg = $logo; @@ -94,7 +94,7 @@ class NowplayingController extends Zend_Controller_Action $viewType = $this->_request->getParam('view'); $dateString = $this->_request->getParam('date'); $this->view->entries = Application_Model_Nowplaying::GetDataGridData($viewType, $dateString); - + } /* public function livestreamAction() @@ -107,16 +107,16 @@ class NowplayingController extends Zend_Controller_Action public function dayViewAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - + //nowplayingdatagrid.js requires this variable, so that datePicker widget can be offset to server time instead of client time $this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds"); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - + $this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/dayview.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); } @@ -127,7 +127,7 @@ class NowplayingController extends Zend_Controller_Action Application_Model_Preference::SetRemindMeDate(); die(); } - + public function donotshowregistrationpopupAction() { // unset session diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 64032d84a..b40de9d35 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -30,6 +30,12 @@ class PlaylistController extends Zend_Controller_Action if (isset($this->pl_sess->id)) { $pl = new Application_Model_Playlist($this->pl_sess->id); + + $modified = $this->_getParam('modified', null); + if ($pl->getLastModified("U") !== $modified) { + $this->createFullResponse($pl); + throw new PlaylistOutDatedException("You are viewing an older version of {$pl->getName()}"); + } } return $pl; } @@ -46,11 +52,14 @@ class PlaylistController extends Zend_Controller_Action private function createUpdateResponse($pl) { + $formatter = new LengthFormatter($pl->getLength()); + $this->view->length = $formatter->format(); + $this->view->pl = $pl; $this->view->html = $this->view->render('playlist/update.phtml'); $this->view->name = $pl->getName(); - $this->view->length = $pl->getLength(); $this->view->description = $pl->getDescription(); + $this->view->modified = $pl->getLastModified("U"); unset($this->view->pl); } @@ -58,6 +67,9 @@ class PlaylistController extends Zend_Controller_Action private function createFullResponse($pl = null) { if (isset($pl)) { + $formatter = new LengthFormatter($pl->getLength()); + $this->view->length = $formatter->format(); + $this->view->pl = $pl; $this->view->id = $pl->getId(); $this->view->html = $this->view->render('playlist/index.phtml'); @@ -68,10 +80,33 @@ class PlaylistController extends Zend_Controller_Action } } + private function playlistOutdated($pl, $e) + { + $this->view->error = $e->getMessage(); + } + + private function playlistNotFound() + { + $this->view->error = "Playlist not found"; + + Logging::log("Playlist not found"); + $this->changePlaylist(null); + $this->createFullResponse(null); + } + + private function playlistUnknownError($e) + { + $this->view->error = "Something went wrong."; + + Logging::log("{$e->getFile()}"); + Logging::log("{$e->getLine()}"); + Logging::log("{$e->getMessage()}"); + } + public function indexAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); @@ -81,18 +116,19 @@ class PlaylistController extends Zend_Controller_Action $this->_helper->viewRenderer->setResponseSegment('spl'); try { - $pl = $this->getPlaylist(); + if (isset($this->pl_sess->id)) { + $pl = new Application_Model_Playlist($this->pl_sess->id); + $this->view->pl = $pl; - if (isset($pl)) { - $this->view->pl = $pl; + $formatter = new LengthFormatter($pl->getLength()); + $this->view->length = $formatter->format(); } } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } } @@ -119,20 +155,15 @@ class PlaylistController extends Zend_Controller_Action } try { - $pl = $this->getPlaylist(); + $pl = new Application_Model_Playlist($id); + $this->createFullResponse($pl); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist {$id} not found"); - $this->changePlaylist(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); - $this->changePlaylist(null); + $this->playlistUnknownError($e); } - - $this->createFullResponse($pl); } public function deleteAction() @@ -150,23 +181,18 @@ class PlaylistController extends Zend_Controller_Action } else { Logging::log("Not deleting currently active playlist"); + $pl = new Application_Model_Playlist($this->pl_sess->id); } Application_Model_Playlist::DeletePlaylists($ids); - $pl = $this->getPlaylist(); + $this->createFullResponse($pl); } - catch(PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $pl = null; + catch (PlaylistNotFoundException $e) { + $this->playlistNotFound(); } - catch(Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + catch (Exception $e) { + $this->playlistUnknownError($e); } - - $this->createFullResponse($pl); } public function addItemsAction() @@ -176,24 +202,20 @@ class PlaylistController extends Zend_Controller_Action $afterItem = $this->_getParam('afterItem', null); $addType = $this->_getParam('type', 'after'); - Logging::log("type is ".$addType); - try { $pl = $this->getPlaylist(); $pl->addAudioClips($ids, $afterItem, $addType); + $this->createUpdateResponse($pl); + } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } - - $this->createUpdateResponse($pl); } public function moveItemsAction() @@ -201,46 +223,44 @@ class PlaylistController extends Zend_Controller_Action $ids = $this->_getParam('ids'); $ids = (!is_array($ids)) ? array($ids) : $ids; $afterItem = $this->_getParam('afterItem', null); + $modified = $this->_getParam('modified'); try { $pl = $this->getPlaylist(); $pl->moveAudioClips($ids, $afterItem); + $this->createUpdateResponse($pl); + } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } - - $this->createUpdateResponse($pl); } public function deleteItemsAction() { $ids = $this->_getParam('ids'); $ids = (!is_array($ids)) ? array($ids) : $ids; + $modified = $this->_getParam('modified'); try { $pl = $this->getPlaylist(); $pl->delAudioClips($ids); + $this->createUpdateResponse($pl); + } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } - - $this->createUpdateResponse($pl); } public function setCueAction() @@ -253,21 +273,22 @@ class PlaylistController extends Zend_Controller_Action $pl = $this->getPlaylist(); $response = $pl->changeClipLength($id, $cueIn, $cueOut); - $this->view->response = $response; - - if(!isset($response["error"])) { + if (!isset($response["error"])) { + $this->view->response = $response; $this->createUpdateResponse($pl); } + else { + $this->view->cue_error = $response["error"]; + } + } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } } @@ -281,21 +302,22 @@ class PlaylistController extends Zend_Controller_Action $pl = $this->getPlaylist(); $response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut); - $this->view->response = $response; - if (!isset($response["error"])) { $this->createUpdateResponse($pl); + $this->view->response = $response; + } + else { + $this->view->fade_error = $response["error"]; } } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); + } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } } @@ -309,15 +331,14 @@ class PlaylistController extends Zend_Controller_Action $fades = $pl->getFadeInfo($pl->getSize()-1); $this->view->fadeOut = $fades[1]; } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); + } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } } @@ -335,15 +356,14 @@ class PlaylistController extends Zend_Controller_Action $pl = $this->getPlaylist(); $pl->setPlaylistfades($fadeIn, $fadeOut); } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); + } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist not found"); - $this->changePlaylist(null); - $this->createFullResponse(null); + $this->playlistNotFound(); } catch (Exception $e) { - Logging::log("{$e->getFile()}"); - Logging::log("{$e->getLine()}"); - Logging::log("{$e->getMessage()}"); + $this->playlistUnknownError($e); } } @@ -351,33 +371,42 @@ class PlaylistController extends Zend_Controller_Action { $name = $this->_getParam('name', 'Unknown Playlist'); - $pl = $this->getPlaylist(); - if($pl === false){ - $this->view->playlist_error = true; - return false; + try { + $pl = $this->getPlaylist(); + $pl->setName($name); + $this->view->playlistName = $name; + $this->view->modified = $pl->getLastModified("U"); + } + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); + } + catch (PlaylistNotFoundException $e) { + $this->playlistNotFound(); + } + catch (Exception $e) { + $this->playlistUnknownError($e); } - $pl->setName($name); - - $this->view->playlistName = $name; } public function setPlaylistDescriptionAction() { - $description = $this->_getParam('description', false); - $pl = $this->getPlaylist(); - if($pl === false){ - $this->view->playlist_error = true; - return false; - } + $description = $this->_getParam('description', ""); - if($description != false) { + try { + $pl = $this->getPlaylist(); $pl->setDescription($description); + $this->view->description = $pl->getDescription(); + $this->view->modified = $pl->getLastModified("U"); } - else { - $description = $pl->getDescription(); + catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); + } + catch (PlaylistNotFoundException $e) { + $this->playlistNotFound(); + } + catch (Exception $e) { + $this->playlistUnknownError($e); } - - $this->view->playlistDescription = $description; } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index b297700b0..4d2018bba 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -20,7 +20,7 @@ class PreferenceController extends Zend_Controller_Action public function indexAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); @@ -59,7 +59,7 @@ class PreferenceController extends Zend_Controller_Action public function supportSettingAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); @@ -119,7 +119,7 @@ class PreferenceController extends Zend_Controller_Action public function directoryConfigAction() { global $CC_CONFIG; - + if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); @@ -136,7 +136,7 @@ class PreferenceController extends Zend_Controller_Action public function streamSettingAction() { global $CC_CONFIG; - + $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); @@ -206,10 +206,10 @@ class PreferenceController extends Zend_Controller_Action $values['output_sound_device'] = $form->getValue('output_sound_device'); } - + $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); $values['output_sound_device_type'] = $form->getValue('output_sound_device_type'); - $values['streamFormat'] = $form->getValue('streamFormat'); + $values['streamFormat'] = $form->getValue('streamFormat'); } if(!$error){ diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index e0b326e55..86678e8ba 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -15,12 +15,9 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('move-show', 'json') ->addActionContext('resize-show', 'json') ->addActionContext('delete-show', 'json') - ->addActionContext('schedule-show', 'json') - ->addActionContext('schedule-show-dialog', 'json') ->addActionContext('show-content-dialog', 'json') ->addActionContext('clear-show', 'json') ->addActionContext('get-current-playlist', 'json') - ->addActionContext('find-playlists', 'json') ->addActionContext('remove-group', 'json') ->addActionContext('edit-show', 'json') ->addActionContext('add-show', 'json') @@ -43,8 +40,6 @@ class ScheduleController extends Zend_Controller_Action $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); //full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time $this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds"); @@ -264,37 +259,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->items = $menu; } - public function scheduleShowAction() - { - $showInstanceId = $this->sched_sess->showInstanceId; - $search = $this->_getParam('search', null); - $plId = $this->_getParam('plId'); - - if($search == "") { - $search = null; - } - - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - try{ - $show = new Application_Model_ShowInstance($showInstanceId); - }catch(Exception $e){ - $this->view->show_error = true; - return false; - } - - if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) { - $show->scheduleShow(array($plId)); - } - - $this->view->showContent = $show->getShowContent(); - $this->view->timeFilled = $show->getTimeScheduled(); - $this->view->percentFilled = $show->getPercentScheduled(); - - $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); - unset($this->view->showContent); - } - public function clearShowAction() { $showInstanceId = $this->_getParam('id'); @@ -336,27 +300,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->entries = $range; } - public function findPlaylistsAction() - { - $post = $this->getRequest()->getPost(); - try{ - $show = new Application_Model_ShowInstance($this->sched_sess->showInstanceId); - }catch(Exception $e){ - $this->view->show_error = true; - return false; - } - - $playlists = $show->searchPlaylistsForShow($post); - foreach( $playlists['aaData'] as &$data){ - // calling two functions to format time to 1 decimal place - $sec = Application_Model_Playlist::playlistTimeToSeconds($data['length']); - $data['length'] = Application_Model_Playlist::secondsToPlaylistTime($sec); - } - - //for datatables - die(json_encode($playlists)); - } - public function removeGroupAction() { $showInstanceId = $this->sched_sess->showInstanceId; @@ -383,44 +326,6 @@ class ScheduleController extends Zend_Controller_Action unset($this->view->showContent); } - public function scheduleShowDialogAction() - { - $showInstanceId = $this->_getParam('id'); - $this->sched_sess->showInstanceId = $showInstanceId; - - try{ - $show = new Application_Model_ShowInstance($showInstanceId); - }catch(Exception $e){ - $this->view->show_error = true; - return false; - } - - $start_timestamp = $show->getShowInstanceStart(); - $end_timestamp = $show->getShowInstanceEnd(); - - $dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp))); - $dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp))); - - $this->view->showContent = $show->getShowContent(); - $this->view->timeFilled = $show->getTimeScheduled(); - $this->view->showName = $show->getName(); - $this->view->showLength = $show->getShowLength(); - $this->view->percentFilled = $show->getPercentScheduled(); - - $this->view->s_wday = $dateInfo_s['weekday']; - $this->view->s_month = $dateInfo_s['month']; - $this->view->s_day = $dateInfo_s['mday']; - $this->view->e_wday = $dateInfo_e['weekday']; - $this->view->e_month = $dateInfo_e['month']; - $this->view->e_day = $dateInfo_e['mday']; - $this->view->startTime = sprintf("%02d:%02d", $dateInfo_s['hours'], $dateInfo_s['minutes']); - $this->view->endTime = sprintf("%02d:%02d", $dateInfo_e['hours'], $dateInfo_e['minutes']); - - $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); - $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml'); - unset($this->view->showContent); - } - public function showContentDialogAction() { $showInstanceId = $this->_getParam('id'); diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index ba1d683f8..8f10ad4bd 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -83,8 +83,8 @@ class ShowbuilderController extends Zend_Controller_Action public function scheduleAddAction() { $request = $this->getRequest(); - $mediaItems = $request->getParam("mediaIds", null); - $scheduledIds = $request->getParam("schedIds", null); + $mediaItems = $request->getParam("mediaIds", array()); + $scheduledIds = $request->getParam("schedIds", array()); try { $scheduler = new Application_Model_Scheduler(); @@ -102,14 +102,12 @@ class ShowbuilderController extends Zend_Controller_Action Logging::log("{$e->getFile()}"); Logging::log("{$e->getLine()}"); } - - $this->view->data = $json; } public function scheduleRemoveAction() { $request = $this->getRequest(); - $items = $request->getParam("items", null); + $items = $request->getParam("items", array()); try { $scheduler = new Application_Model_Scheduler(); @@ -151,8 +149,6 @@ class ShowbuilderController extends Zend_Controller_Action Logging::log("{$e->getFile()}"); Logging::log("{$e->getLine()}"); } - - $this->view->data = $json; } public function scheduleReorderAction() { diff --git a/airtime_mvc/application/controllers/UsersettingsController.php b/airtime_mvc/application/controllers/UsersettingsController.php new file mode 100644 index 000000000..c088bfcdd --- /dev/null +++ b/airtime_mvc/application/controllers/UsersettingsController.php @@ -0,0 +1,49 @@ +_helper->getHelper('AjaxContext'); + $ajaxContext->addActionContext('get-library-datatable', 'json') + ->addActionContext('set-library-datatable', 'json') + ->addActionContext('get-timeline-datatable', 'json') + ->addActionContext('set-timeline-datatable', 'json') + ->initContext(); + } + + public function setLibraryDatatableAction() { + + $request = $this->getRequest(); + $settings = $request->getParam("settings"); + + $data = serialize($settings); + Application_Model_Preference::SetValue("library_datatable", $data, true); + } + + public function getLibraryDatatableAction() { + + $data = Application_Model_Preference::GetValue("library_datatable", true); + if ($data != "") { + $this->view->settings = unserialize($data); + } + } + + public function setTimelineDatatableAction() { + + $request = $this->getRequest(); + $settings = $request->getParam("settings"); + + $data = serialize($settings); + Application_Model_Preference::SetValue("timeline_datatable", $data, true); + } + + public function getTimelineDatatableAction() { + + $data = Application_Model_Preference::GetValue("timeline_datatable", true); + if ($data != "") { + $this->view->settings = unserialize($data); + } + } +} \ No newline at end of file diff --git a/airtime_mvc/application/layouts/scripts/builder.phtml b/airtime_mvc/application/layouts/scripts/builder.phtml index e9313cd03..3efba392c 100644 --- a/airtime_mvc/application/layouts/scripts/builder.phtml +++ b/airtime_mvc/application/layouts/scripts/builder.phtml @@ -22,7 +22,7 @@
layout()->library ?>
-
layout()->builder ?>
+
layout()->builder ?>
diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index b2982c1f4..69c0dc544 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -22,7 +22,7 @@
-
layout()->library ?>
+
layout()->library ?>
layout()->spl ?>
diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 441ed9a43..146c07593 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -1,5 +1,7 @@ pl->setDbName($p_newname); - $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $this->pl->save($this->con); } @@ -106,7 +108,7 @@ class Application_Model_Playlist { public function setDescription($p_description) { $this->pl->setDbDescription($p_description); - $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $this->pl->save($this->con); } @@ -123,7 +125,7 @@ class Application_Model_Playlist { public function setCreator($p_id) { $this->pl->setDbCreatorId($p_id); - $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $this->pl->save($this->con); } @@ -158,9 +160,15 @@ class Application_Model_Playlist { $clipSec = Application_Model_Playlist::playlistTimeToSeconds($files[$i]['cliplength']); - //$files[$i]['cliplength'] = Application_Model_Playlist::secondsToPlaylistTime($clipSec); $offset += $clipSec; - $files[$i]['offset'] = Application_Model_Playlist::secondsToPlaylistTime($offset); + $offset_cliplength = Application_Model_Playlist::secondsToPlaylistTime($offset); + + //format the length for UI. + $formatter = new LengthFormatter($files[$i]['cliplength']); + $files[$i]['cliplength'] = $formatter->format(); + + $formatter = new LengthFormatter($offset_cliplength); + $files[$i]['offset'] = $formatter->format(); $i++; } @@ -218,13 +226,18 @@ class Application_Model_Playlist { { $file = CcFilesQuery::create()->findPK($p_item, $this->con); - $entry = $this->plItem; - $entry["id"] = $file->getDbId(); - $entry["pos"] = $pos; - $entry["cliplength"] = $file->getDbLength(); - $entry["cueout"] = $file->getDbLength(); + if (isset($file) && $file->getDbFileExists()) { + $entry = $this->plItem; + $entry["id"] = $file->getDbId(); + $entry["pos"] = $pos; + $entry["cliplength"] = $file->getDbLength(); + $entry["cueout"] = $file->getDbLength(); - return $entry; + return $entry; + } + else { + throw new Exception("trying to add a file that does not exist."); + } } /* @@ -300,7 +313,7 @@ class Application_Model_Playlist { $pos = $pos + 1; } - $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $this->pl->save($this->con); $this->con->commit(); @@ -383,7 +396,7 @@ class Application_Model_Playlist { $this->pl = CcPlaylistQuery::create()->findPK($this->id); - $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $this->pl->save($this->con); } @@ -415,7 +428,7 @@ class Application_Model_Playlist { $contents[$i]->save($this->con); } - $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); $this->pl->save($this->con); $this->con->commit(); @@ -462,47 +475,52 @@ class Application_Model_Playlist { $fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn; $fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut; + $this->con->beginTransaction(); + $errArray= array(); - $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); - - $row = CcPlaylistcontentsQuery::create()->findPK($id); - - if (is_null($row)) { - $errArray["error"]="Playlist item does not exist."; - return $errArray; - } - - $clipLength = $row->getDbCliplength(); - - if(!is_null($fadeIn)) { - - $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)) { - //"Fade In can't be larger than overall playlength."; - $fadeIn = $clipLength; - } - $row->setDbFadein($fadeIn); - } - if(!is_null($fadeOut)){ - - $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)) { - //Fade Out can't be larger than overall playlength."; - $fadeOut = $clipLength; - } - $row->setDbFadeout($fadeOut); - } try { - $row->save(); + $row = CcPlaylistcontentsQuery::create()->findPK($id); + + if (is_null($row)) { + throw new Exception("Playlist item does not exist."); + } + + $clipLength = $row->getDbCliplength(); + + if (!is_null($fadeIn)) { + + $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)) { + //"Fade In can't be larger than overall playlength."; + $fadeIn = $clipLength; + } + $row->setDbFadein($fadeIn); + } + if (!is_null($fadeOut)){ + + $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)) { + //Fade Out can't be larger than overall playlength."; + $fadeOut = $clipLength; + } + $row->setDbFadeout($fadeOut); + } + + $row->save($this->con); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); + $this->pl->save($this->con); + + $this->con->commit(); } catch (Exception $e) { - Logging::log($e->getMessage()); + $this->con->rollback(); + throw $e; } - return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); + return array("fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut); } public function setPlaylistfades($fadein, $fadeout) { @@ -512,7 +530,7 @@ class Application_Model_Playlist { $row = CcPlaylistcontentsQuery::create() ->filterByDbPlaylistId($this->id) ->filterByDbPosition(0) - ->findOne(); + ->findOne($this->con); $this->changeFadeInfo($row->getDbId(), $fadein, null); } @@ -521,7 +539,7 @@ class Application_Model_Playlist { $row = CcPlaylistcontentsQuery::create() ->filterByDbPlaylistId($this->id) ->filterByDbPosition($this->getSize()-1) - ->findOne(); + ->findOne($this->con); $this->changeFadeInfo($row->getDbId(), null, $fadeout); } @@ -540,126 +558,135 @@ class Application_Model_Playlist { */ public function changeClipLength($id, $cueIn, $cueOut) { + $this->con->beginTransaction(); + $errArray= array(); - $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); - if (is_null($cueIn) && is_null($cueOut)) { - $errArray["error"]="Cue in and cue out are null."; - return $errArray; - } - - $row = CcPlaylistcontentsQuery::create() - ->joinWith(CcFilesPeer::OM_CLASS) - ->filterByPrimaryKey($id) - ->findOne(); - - if (is_null($row)) { - $errArray["error"]="Playlist item does not exist!."; - return $errArray; - } - - $oldCueIn = $row->getDBCuein(); - $oldCueOut = $row->getDbCueout(); - $fadeIn = $row->getDbFadein(); - $fadeOut = $row->getDbFadeout(); - - $file = $row->getCcFiles(); - $origLength = $file->getDbLength(); - - - if(!is_null($cueIn) && !is_null($cueOut)){ - - if($cueOut === ""){ - $cueOut = $origLength; - } - - $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)) { - $errArray["error"]= "Can't set cue in to be larger than cue out."; + try { + if (is_null($cueIn) && is_null($cueOut)) { + $errArray["error"] = "Cue in and cue out are null."; return $errArray; } - $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)){ - $errArray["error"] = "Can't set cue out to be greater than file length."; - return $errArray; + $row = CcPlaylistcontentsQuery::create() + ->joinWith(CcFilesPeer::OM_CLASS) + ->filterByPrimaryKey($id) + ->findOne($this->con); + + if (is_null($row)) { + throw new Exception("Playlist item does not exist."); } - $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'"; - $r = $con->query($sql); - $cliplength = $r->fetchColumn(0); + $oldCueIn = $row->getDBCuein(); + $oldCueOut = $row->getDbCueout(); + $fadeIn = $row->getDbFadein(); + $fadeOut = $row->getDbFadeout(); - $row->setDbCuein($cueIn); - $row->setDbCueout($cueOut); - $row->setDBCliplength($cliplength); + $file = $row->getCcFiles($this->con); + $origLength = $file->getDbLength(); - } - else if(!is_null($cueIn)) { + if (!is_null($cueIn) && !is_null($cueOut)){ - $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)) { - $errArray["error"] = "Can't set cue in to be larger than cue out."; - return $errArray; + if ($cueOut === ""){ + $cueOut = $origLength; + } + + $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)) { + $errArray["error"] = "Can't set cue in to be larger than cue out."; + return $errArray; + } + + $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)){ + $errArray["error"] = "Can't set cue out to be greater than file length."; + return $errArray; + } + + $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'"; + $r = $this->con->query($sql); + $cliplength = $r->fetchColumn(0); + + $row->setDbCuein($cueIn); + $row->setDbCueout($cueOut); + $row->setDBCliplength($cliplength); + + } + else if (!is_null($cueIn)) { + + $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)) { + $errArray["error"] = "Can't set cue in to be larger than cue out."; + return $errArray; + } + + $sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'"; + $r = $this->con->query($sql); + $cliplength = $r->fetchColumn(0); + + $row->setDbCuein($cueIn); + $row->setDBCliplength($cliplength); + } + else if (!is_null($cueOut)) { + + if ($cueOut === ""){ + $cueOut = $origLength; + } + + $sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)) { + $errArray["error"] = "Can't set cue out to be smaller than cue in."; + return $errArray; + } + + $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)){ + $errArray["error"] = "Can't set cue out to be greater than file length."; + return $errArray; + } + + $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'"; + $r = $this->con->query($sql); + $cliplength = $r->fetchColumn(0); + + $row->setDbCueout($cueOut); + $row->setDBCliplength($cliplength); } - $sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'"; - $r = $con->query($sql); - $cliplength = $r->fetchColumn(0); + $cliplength = $row->getDbCliplength(); - $row->setDbCuein($cueIn); - $row->setDBCliplength($cliplength); - } - else if(!is_null($cueOut)) { - - if($cueOut === ""){ - $cueOut = $origLength; + $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)){ + $fadeIn = $cliplength; + $row->setDbFadein($fadeIn); } - $sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)) { - $errArray["error"] ="Can't set cue out to be smaller than cue in."; - return $errArray; + $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'"; + $r = $this->con->query($sql); + if ($r->fetchColumn(0)){ + $fadeOut = $cliplength; + $row->setDbFadein($fadeOut); } - $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)){ - $errArray["error"] ="Can't set cue out to be greater than file length."; - return $errArray; - } + $row->save($this->con); + $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC"))); + $this->pl->save($this->con); - $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'"; - $r = $con->query($sql); - $cliplength = $r->fetchColumn(0); - - $row->setDbCueout($cueOut); - $row->setDBCliplength($cliplength); + $this->con->commit(); + } + catch (Exception $e) { + $this->con->rollback(); + throw $e; } - $cliplength = $row->getDbCliplength(); - - $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)){ - $fadeIn = $cliplength; - $row->setDbFadein($fadeIn); - } - - $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'"; - $r = $con->query($sql); - if($r->fetchColumn(0)){ - $fadeOut = $cliplength; - $row->setDbFadein($fadeOut); - } - - $row->save(); - - return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut, "length"=>$this->getLength(), - "fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); + return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getLength(), + "fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut); } public function getAllPLMetaData() diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 9f0dc8e19..bcad18d53 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -38,6 +38,7 @@ class Application_Model_Scheduler { $data = $this->fileInfo; $data["id"] = $id; $data["cliplength"] = $file->getDbLength(); + $data["cueout"] = $file->getDbLength(); $files[] = $data; } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index c46729e3e..ec4cdbcfe 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1396,7 +1396,7 @@ class Application_Model_Show { Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp); } - $sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, + $sql = "SELECT starts, ends, record, rebroadcast, instance_id, show_id, name, 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 @@ -1538,7 +1538,7 @@ class Application_Model_Show { $event["end"] = $endDateTime->format("Y-m-d H:i:s"); $event["endUnix"] = $endDateTime->format("U"); $event["allDay"] = false; - $event["description"] = $show["description"]; + //$event["description"] = $show["description"]; $event["showId"] = intval($show["show_id"]); $event["record"] = intval($show["record"]); $event["rebroadcast"] = intval($show["rebroadcast"]); diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 01dc84636..17e5c4605 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -1,5 +1,7 @@ false, "footer" => false, "empty" => false, - "checkbox" => false, + "allowed" => false, "id" => 0, "instance" => "", "starts" => "", @@ -37,26 +40,7 @@ class Application_Model_ShowBuilder { $this->timezone = date_default_timezone_get(); $this->user = Application_Model_User::GetCurrentUser(); $this->opts = $p_opts; - } - - /* - * @param DateInterval $p_interval - * - * @return string $runtime - */ - private function formatDuration($p_interval){ - - $hours = $p_interval->format("%h"); - $mins = $p_interval->format("%i"); - - if( $hours == 0) { - $runtime = $p_interval->format("%i:%S"); - } - else { - $runtime = $p_interval->format("%h:%I:%S"); - } - - return $runtime; + $this->epoch_now = time(); } private function formatTimeFilled($p_sec) { @@ -89,6 +73,7 @@ class Application_Model_ShowBuilder { private function makeFooterRow($p_item) { $row = $this->defaultRowArray; + $this->isAllowed($p_item, $row); $row["footer"] = true; $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); @@ -101,6 +86,39 @@ class Application_Model_ShowBuilder { return $row; } + private function isAllowed($p_item, &$row) { + + $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); + + //can only schedule the show if it hasn't started and you are allowed. + if ($this->epoch_now < $showStartDT->format('U') && $this->user->canSchedule($p_item["show_id"]) == true) { + $row["allowed"] = true; + } + } + + private function getItemStatus($p_item, &$row) { + + $showEndDT = new DateTime($p_item["si_ends"]); + $schedStartDT = new DateTime($p_item["sched_starts"]); + $schedEndDT = new DateTime($p_item["sched_ends"]); + + $showEndEpoch = intval($showEndDT->format("U")); + $schedStartEpoch = intval($schedStartDT->format("U")); + $schedEndEpoch = intval($schedEndDT->format("U")); + + if ($schedEndEpoch < $showEndEpoch) { + $status = 0; //item will playout in full + } + else if ($schedStartEpoch < $showEndEpoch && $schedEndEpoch > $showEndEpoch) { + $status = 1; //item is on boundry + } + else { + $status = 2; //item is overscheduled won't play. + } + + $row["status"] = $status; + } + private function getRowTimestamp($p_item, &$row) { if (is_null($p_item["si_last_scheduled"])) { @@ -116,7 +134,9 @@ class Application_Model_ShowBuilder { private function makeHeaderRow($p_item) { $row = $this->defaultRowArray; - $this->getRowTimestamp($p_item, &$row); + $this->isAllowed($p_item, $row); + Logging::log("making header for show id ".$p_item["show_id"]); + $this->getRowTimestamp($p_item, $row); $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); $showStartDT->setTimezone(new DateTimeZone($this->timezone)); @@ -137,15 +157,9 @@ class Application_Model_ShowBuilder { private function makeScheduledItemRow($p_item) { $row = $this->defaultRowArray; - $epoch_now = time(); - $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); - $this->getRowTimestamp($p_item, &$row); - - //can only schedule the show if it hasn't started and you are allowed. - if ($epoch_now < $showStartDT->format('U') && $this->user->canSchedule($p_item["show_id"]) == true) { - $row["checkbox"] = true; - } + $this->isAllowed($p_item, $row); + $this->getRowTimestamp($p_item, $row); if (isset($p_item["sched_starts"])) { @@ -154,13 +168,16 @@ class Application_Model_ShowBuilder { $schedEndDT = new DateTime($p_item["sched_ends"], new DateTimeZone("UTC")); $schedEndDT->setTimezone(new DateTimeZone($this->timezone)); - $runtime = $schedStartDT->diff($schedEndDT); + $this->getItemStatus($p_item, $row); $row["id"] = intval($p_item["sched_id"]); $row["instance"] = intval($p_item["si_id"]); $row["starts"] = $schedStartDT->format("H:i:s"); $row["ends"] = $schedEndDT->format("H:i:s"); - $row["runtime"] = $this->formatDuration($runtime); + + $formatter = new LengthFormatter($p_item['file_length']); + $row['runtime'] = $formatter->format(); + $row["title"] = $p_item["file_track_title"]; $row["creator"] = $p_item["file_artist_name"]; $row["album"] = $p_item["file_album_title"]; @@ -172,6 +189,8 @@ class Application_Model_ShowBuilder { $row["empty"] = true; $row["id"] = 0 ; $row["instance"] = intval($p_item["si_id"]); + + //return null; } return $row; @@ -219,7 +238,11 @@ class Application_Model_ShowBuilder { } //make a normal data row. - $display_items[] = $this->makeScheduledItemRow($item); + $row = $this->makeScheduledItemRow($item); + //don't display the empty rows. + if (isset($row)) { + $display_items[] = $row; + } } //make the last footer if there were any scheduled items. diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 984304c7b..37ad92b1a 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -1,5 +1,7 @@ _showInstance->getDbTimeFilled(); - if(is_null($time)) { + if (is_null($time)) { $time = "00:00:00"; } + else { + $formatter = new LengthFormatter($time); + $time = $formatter->format(); + } + return $time; } @@ -631,15 +638,11 @@ class Application_Model_ShowInstance { public function getShowLength() { - global $CC_DBC; + $start = $this->getShowInstanceStart(null); + $end = $this->getShowInstanceEnd(null); - $start_timestamp = $this->getShowInstanceStart(); - $end_timestamp = $this->getShowInstanceEnd(); - - $sql = "SELECT TIMESTAMP '{$end_timestamp}' - TIMESTAMP '{$start_timestamp}' "; - $length = $CC_DBC->GetOne($sql); - - return $length; + $interval = $start->diff($end); + return $interval->format("%h:%I:%S"); } public function searchPlaylistsForShow($datatables) @@ -657,47 +660,22 @@ class Application_Model_ShowInstance { WHERE s.instance_id = '{$this->_instanceId}' ORDER BY starts"; - return $CC_DBC->GetAll($sql); - } + Logging::log($sql); - public function getShowContent() - { - global $CC_DBC; + $results = $CC_DBC->GetAll($sql); - $res = $this->getShowListContent(); + foreach ($results as &$row) { - if(count($res) <= 0) { - return $res; + $dt = new DateTime($row["starts"], new DateTimeZone("UTC")); + $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); + $row["starts"] = $dt->format("Y-m-d H:i:s"); + + $formatter = new LengthFormatter($row["clip_length"]); + $row["clip_length"] = $formatter->format(); } - $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; + return $results; } public static function GetShowsInstancesIdsInRange($p_timeNow, $p_start, $p_end) diff --git a/airtime_mvc/application/models/SmilPlaylist.php b/airtime_mvc/application/models/SmilPlaylist.php deleted file mode 100644 index 52fc22d9e..000000000 --- a/airtime_mvc/application/models/SmilPlaylist.php +++ /dev/null @@ -1,312 +0,0 @@ -lock($gb, $subjid); - if (PEAR::isError($r)) { - return $r; - } - $r = $pl->setMetadata($lspl, 'string', 'playlist'); - if (PEAR::isError($r)) { - return $r; - } - $r = $pl->unlock($gb); - if (PEAR::isError($r)) { - return $r; - } - return $pl; - } - - - /** - * Import SMIL file to storage. - * - * @param GreenBox $gb - * @param string $data - * local path to SMIL file - * @param hasharray $gunids - * hash relation from filenames to gunids - * @param array $parr - * array of subjid, aPath, plid, rPath - * @return string - * XML of playlist in Airtime playlist format - */ - public static function convert2lspl(&$gb, $data, &$gunids, $parr) - { - extract($parr); - $tree = SmilPlaylist::parse($data); - if (PEAR::isError($tree)) { - return $tree; - } - if ($tree->name != 'smil') { - return PEAR::raiseError("SmilPlaylist::parse: smil tag expected"); - } - if (isset($tree->children[1])) { - return PEAR::raiseError(sprintf( - "SmilPlaylist::parse: unexpected tag %s in tag smil", - $tree->children[1]->name - )); - } - $res = SmilPlaylistBodyElement::convert2lspl( - $gb, $tree->children[0], &$gunids, $parr); - return $res; - } - -} // SmilPlaylist - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class SmilPlaylistBodyElement { - - public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') - { - extract($parr); - $ind2 = $ind.INDCH; - if ($tree->name != 'body') { - return PEAR::raiseError("SmilPlaylist::parse: body tag expected"); - } - if (isset($tree->children[1])) { - return PEAR::raiseError(sprintf( - "SmilPlaylist::parse: unexpected tag %s in tag body", - $tree->children[1]->name - )); - } - $res = SmilPlaylistParElement::convert2lspl( - $gb, $tree->children[0], &$gunids, $parr, $ind2); - if (PEAR::isError($res)) { - return $res; - } - $title = basename($rPath); - $playlength = '0'; - $res = "$ind\n". - "$ind\n". - "$ind2\n". - "$res". - "$ind\n"; - return $res; - } - -} // class SmilPlaylistBodyElement - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class SmilPlaylistParElement { - - public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') - { - extract($parr); - if ($tree->name != 'par') { - return PEAR::raiseError("SmilPlaylist::parse: par tag expected"); - } - $res = ''; - foreach ($tree->children as $i => $ch) { - $ch =& $tree->children[$i]; - $r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH); - if (PEAR::isError($r)) { - return $r; - } - $res .= $r; - } - return $res; - } -} - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class SmilPlaylistAudioElement { - public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') - { - extract($parr); - $uri = $tree->attrs['src']->val; - $gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL); - $ind2 = $ind.INDCH; - if ($tree->name != 'audio') { - return PEAR::raiseError("SmilPlaylist::parse: audio tag expected"); - } - if (isset($tree->children[2])) { - return PEAR::raiseError(sprintf( - "SmilPlaylist::parse: unexpected tag %s in tag audio", - $tree->children[2]->name - )); - } - $res = ''; $fadeIn = 0; $fadeOut = 0; - foreach ($tree->children as $i => $ch) { - $ch =& $tree->children[$i]; - $r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2); - if (PEAR::isError($r)) { - return $r; - } - switch ($r['type']) { - case "fadeIn": $fadeIn = $r['val']; break; - case "fadeOut": $fadeOut = $r['val']; break; - } - } - if ($fadeIn > 0 || $fadeOut > 0) { - $fiGunid = Application_Model_StoredFile::CreateGunid(); - $fadeIn = Application_Model_Playlist::secondsToPlaylistTime($fadeIn); - $fadeOut = Application_Model_Playlist::secondsToPlaylistTime($fadeOut); - $fInfo = "$ind2\n"; - } else { - $fInfo = ''; - } - $plElGunid = Application_Model_StoredFile::CreateGunid(); - $acGunid = $gunid; - $type = 'audioClip'; - if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) { - switch (strtolower($ext = $va[1])) { - case "lspl": - case "xml": - case "smil": - case "m3u": - $type = 'playlist'; - $acId = $gb->bsImportPlaylistRaw($gunid, - $aPath, $uri, $ext, $gunids, $subjid); - if (PEAR::isError($acId)) { - return $r; - } - //break; - default: - $ac = Application_Model_StoredFile::RecallByGunid($gunid); - if (is_null($ac) || PEAR::isError($ac)) { - return $ac; - } - $r = $ac->md->getMetadataElement('dcterms:extent'); - if (PEAR::isError($r)) { - return $r; - } - $playlength = $r[0]['value']; - } - } - - $title = basename($tree->attrs['src']->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. - "$ind\n"; - return $res; - } -} // class SmilPlaylistAudioElement - - -/** - * @package Airtime - * @subpackage StorageServer - * @copyright 2010 Sourcefabric O.P.S. - * @license http://www.gnu.org/licenses/gpl.txt - */ -class SmilPlaylistAnimateElement { - - public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') - { - extract($parr); - if ($tree->name != 'animate') { - return PEAR::raiseError("SmilPlaylist::parse: animate tag expected"); - } - if ($tree->attrs['attributeName']->val == 'soundLevel' && - $tree->attrs['from']->val == '0%' && - $tree->attrs['to']->val == '100%' && - $tree->attrs['calcMode']->val == 'linear' && - $tree->attrs['fill']->val == 'freeze' && - $tree->attrs['begin']->val == '0s' && - preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va) - ) { - return array('type'=>'fadeIn', 'val'=>intval($va[1])); - } - if ($tree->attrs['attributeName']->val == 'soundLevel' && - $tree->attrs['from']->val == '100%' && - $tree->attrs['to']->val == '0%' && - $tree->attrs['calcMode']->val == 'linear' && - $tree->attrs['fill']->val == 'freeze' && - preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) && - preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd) - ) { - return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1])); - } - return PEAR::raiseError( - "SmilPlaylistAnimateElement::convert2lspl: animate parameters too general" - ); - } -} // class SmilPlaylistAnimateElement - diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 175c2b918..f9cee1be5 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1,5 +1,9 @@ format("H"); - $min = $dt->format("i"); - $sec = $dt->format("s"); + $displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length", + "year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url", + "bit_rate", "sample_rate", "isrc_number", "encoded_by", "label", "copyright", "mime", "language" + ); - $time = "PT{$hours}H{$min}M{$sec}S"; + $plSelect = array(); + $fileSelect = array(); + foreach ($displayColumns as $key) { - $p_interval = new DateInterval($time); - - $hours = $p_interval->format("%h"); - $mins = $p_interval->format("%i"); - - if( $hours == 0) { - $runtime = $p_interval->format("%i:%S"); - } - else { - $runtime = $p_interval->format("%h:%I:%S"); - } - - return $runtime; - } - - public static function searchFilesForPlaylistBuilder($datatables) - { - global $CC_CONFIG; - - $displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number"); - - $plSelect = "SELECT "; - $fileSelect = "SELECT "; - foreach ($displayData as $key) { - - if ($key === "track_title") { - $plSelect .= "name AS ".$key.", "; - $fileSelect .= $key.", "; - } else if ($key === "ftype") { - $plSelect .= "'playlist' AS ".$key.", "; - $fileSelect .= $key.", "; - } else if ($key === "artist_name") { - $plSelect .= "login AS ".$key.", "; - $fileSelect .= $key.", "; - } else if ($key === "length") { - $plSelect .= $key.", "; - $fileSelect .= $key."::interval, "; - } else if ($key === "year") { - $plSelect .= "CAST(utime AS varchar) AS ".$key.", "; - $fileSelect .= $key.", "; - } else if ($key === "utime") { - $plSelect .= $key.", "; - $fileSelect .= $key.", "; - } else if ($key === "mtime") { - $plSelect .= $key.", "; - $fileSelect .= $key.", "; - } else if ($key === "track_number") { - $plSelect .= "NULL AS ".$key.", "; - $fileSelect .= $key.", "; - } else { - $plSelect .= "NULL AS ".$key.", "; - $fileSelect .= $key.", "; + if ($key === "id") { + $plSelect[] = "PL.id AS ".$key; + $fileSelect[] = $key; + } + else if ($key === "track_title") { + $plSelect[] = "name AS ".$key; + $fileSelect[] = $key; + } + else if ($key === "ftype") { + $plSelect[] = "'playlist'::varchar AS ".$key; + $fileSelect[] = $key; + } + else if ($key === "artist_name") { + $plSelect[] = "login AS ".$key; + $fileSelect[] = $key; + } + //same columns in each table. + else if(in_array($key, array("length", "utime", "mtime"))) { + $plSelect[] = $key; + $fileSelect[] = $key; + } + else if ($key === "year") { + $plSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; + $fileSelect[] = $key; + } + //need to cast certain data as ints for the union to search on. + else if (in_array($key, array("track_number"))){ + $plSelect[] = "NULL::int AS ".$key; + $fileSelect[] = $key; + } + else { + $plSelect[] = "NULL::text AS ".$key; + $fileSelect[] = $key; } } - $fromTable = " ((".$plSelect."PL.id - FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id)) - UNION - (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS"; + $plSelect = "SELECT ". join(",", $plSelect); + $fileSelect = "SELECT ". join(",", $fileSelect); - $results = Application_Model_StoredFile::searchFiles($fromTable, $datatables); + $type = intval($datatables["type"]); + + $plTable = "({$plSelect} FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))"; + $fileTable = "({$fileSelect} FROM cc_files AS FILES WHERE file_exists = 'TRUE')"; + $unionTable = "({$plTable} UNION {$fileTable} ) AS RESULTS"; + + //choose which table we need to select data from. + switch ($type) { + case 0: + $fromTable = $unionTable; + break; + case 1: + $fromTable = $fileTable." AS File"; //need an alias for the table if it's standalone. + break; + case 2: + $fromTable = $plTable." AS Playlist"; //need an alias for the table if it's standalone. + break; + default: + $fromTable = $unionTable; + } + + $results = Application_Model_StoredFile::searchFiles($displayColumns, $fromTable, $datatables); - foreach($results['aaData'] as &$row){ + foreach ($results['aaData'] as &$row) { $row['id'] = intval($row['id']); - //$length = new DateTime($row['length']); - //$row['length'] = self::formatDuration($length); + $formatter = new LengthFormatter($row['length']); + $row['length'] = $formatter->format(); + + if ($row['ftype'] === "audioclip") { + $formatter = new SamplerateFormatter($row['sample_rate']); + $row['sample_rate'] = $formatter->format(); + + $formatter = new BitrateFormatter($row['bit_rate']); + $row['bit_rate'] = $formatter->format(); + } // add checkbox row $row['checkbox'] = ""; - // a full timestamp is being returned for playlists' year column; - // split it and grab only the year info - $yearSplit = explode('-', $row['year']); - $row['year'] = $yearSplit[0]; - $type = substr($row['ftype'], 0, 2); $row['tr_id'] = "{$type}_{$row['id']}"; @@ -649,7 +654,7 @@ class Application_Model_StoredFile { //TODO url like this to work on both playlist/showbuilder screens. //datatable stuff really needs to be pulled out and generalized within the project //access to zend view methods to access url helpers is needed. - if($type == "au") { + if ($type == "au") { $row['image'] = ''; } else { @@ -660,55 +665,35 @@ class Application_Model_StoredFile { return $results; } - public static function searchPlaylistsForSchedule($datatables) - { - $fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id"; - //$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'"; - $datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'"; - - return Application_Model_StoredFile::searchFiles($fromTable, $datatables); - } - - public static function searchFiles($fromTable, $data) + public static function searchFiles($displayColumns, $fromTable, $data) { - global $CC_CONFIG, $CC_DBC; + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME); + $where = array(); - $columnsDisplayed = explode(",", $data["sColumns"]); - - if($data["sSearch"] !== "") + if ($data["sSearch"] !== "") { $searchTerms = explode(" ", $data["sSearch"]); - - $selectorCount = "SELECT COUNT(*)"; - foreach( $columnsDisplayed as $key=>$col){ - if($col == ''){ - unset($columnsDisplayed[$key]); - } } - //$selectorRows = "SELECT " . join(',', $columnsDisplayed ); - $selectorRows = "SELECT * "; + + $selectorCount = "SELECT COUNT(*) "; + $selectorRows = "SELECT ".join(",", $displayColumns)." "; $sql = $selectorCount." FROM ".$fromTable; - $totalRows = $CC_DBC->getOne($sql); + $sqlTotalRows = $sql; - // Where clause - if(isset($data["optWhere"])) { - $where[] = join(" AND ", $data["optWhere"]); - } - - if(isset($searchTerms)) { + if (isset($searchTerms)) { $searchCols = array(); - for($i=0; $i<$data["iColumns"]; $i++) { - if($data["bSearchable_".$i] == "true") { - $searchCols[] = $columnsDisplayed[$i]; + for ($i = 0; $i < $data["iColumns"]; $i++) { + if ($data["bSearchable_".$i] == "true") { + $searchCols[] = $data["mDataProp_{$i}"]; } } $outerCond = array(); - foreach($searchTerms as $term) { + foreach ($searchTerms as $term) { $innerCond = array(); - foreach($searchCols as $col) { + foreach ($searchCols as $col) { $escapedTerm = pg_escape_string($term); $innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'"; } @@ -720,31 +705,47 @@ class Application_Model_StoredFile { // Order By clause $orderby = array(); - for($i=0; $i<$data["iSortingCols"]; $i++){ - $orderby[] = $columnsDisplayed[$data["iSortCol_".$i]]." ".$data["sSortDir_".$i]; + for ($i = 0; $i < $data["iSortingCols"]; $i++){ + $num = $data["iSortCol_".$i]; + $orderby[] = $data["mDataProp_{$num}"]." ".$data["sSortDir_".$i]; } $orderby[] = "id"; $orderby = join("," , $orderby); // End Order By clause - if(isset($where)) { + if (count($where) > 0) { $where = join(" AND ", $where); $sql = $selectorCount." FROM ".$fromTable." WHERE ".$where; - $totalDisplayRows = $CC_DBC->getOne($sql); + $sqlTotalDisplayRows = $sql; + $sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"]; } else { $sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"]; } + try { + $r = $con->query($sqlTotalRows); + $totalRows = $r->fetchColumn(0); + + if (isset($sqlTotalDisplayRows)) { + $r = $con->query($sqlTotalDisplayRows); + $totalDisplayRows = $r->fetchColumn(0); + } + else { + $totalDisplayRows = $totalRows; + } + + $r = $con->query($sql); + $r->setFetchMode(PDO::FETCH_ASSOC); + $results = $r->fetchAll(); + } + catch (Exception $e) { + Logging::log($e->getMessage()); + } + //display sql executed in airtime log for testing - //Logging::log($sql); - - $results = $CC_DBC->getAll($sql); - - if(!isset($totalDisplayRows)) { - $totalDisplayRows = $totalRows; - } + Logging::log($sql); return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results); } diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 3e94e61ae..755a0fbe1 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -37,15 +37,16 @@ class Application_Model_User { public function canSchedule($p_showId) { $type = $this->getType(); + $result = false; if ( $type === UTYPE_ADMIN || $type === UTYPE_PROGRAM_MANAGER || CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0 ) { - return true; + $result = true; } - return false; + return $result; } public function isUserType($type, $showId=''){ @@ -240,6 +241,7 @@ class Application_Model_User { public static function getUsersDataTablesInfo($datatables_post) { + $displayColumns = array("id", "login", "first_name", "last_name", "type"); $fromTable = "cc_subjs"; // get current user @@ -250,7 +252,7 @@ class Application_Model_User { $username = $auth->getIdentity()->login; } - $res = Application_Model_StoredFile::searchFiles($fromTable, $datatables_post); + $res = Application_Model_StoredFile::searchFiles($displayColumns, $fromTable, $datatables_post); // mark record which is for the current user foreach($res['aaData'] as &$record){ diff --git a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php index bb4bb72ec..7426b39e4 100644 --- a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php @@ -57,7 +57,7 @@ class CcFilesTableMap extends TableMap { $this->addColumn('BIT_RATE', 'DbBitRate', 'VARCHAR', false, 32, null); $this->addColumn('SAMPLE_RATE', 'DbSampleRate', 'VARCHAR', false, 32, null); $this->addColumn('FORMAT', 'DbFormat', 'VARCHAR', false, 128, null); - $this->addColumn('LENGTH', 'DbLength', 'TIME', false, null, null); + $this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00'); $this->addColumn('ALBUM_TITLE', 'DbAlbumTitle', 'VARCHAR', false, 512, null); $this->addColumn('GENRE', 'DbGenre', 'VARCHAR', false, 64, null); $this->addColumn('COMMENTS', 'DbComments', 'LONGVARCHAR', false, null, null); diff --git a/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php b/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php index 12fa8d712..ebbe397c8 100644 --- a/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php @@ -39,17 +39,14 @@ class CcScheduleTableMap extends TableMap { $this->setPrimaryKeyMethodInfo('cc_schedule_id_seq'); // columns $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', false, null, null); $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); $this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null); - $this->addColumn('GROUP_ID', 'DbGroupId', 'INTEGER', false, null, null); $this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null); $this->addColumn('CLIP_LENGTH', 'DbClipLength', 'TIME', false, null, '00:00:00'); $this->addColumn('FADE_IN', 'DbFadeIn', 'TIME', false, null, '00:00:00'); $this->addColumn('FADE_OUT', 'DbFadeOut', 'TIME', false, null, '00:00:00'); $this->addColumn('CUE_IN', 'DbCueIn', 'TIME', false, null, '00:00:00'); $this->addColumn('CUE_OUT', 'DbCueOut', 'TIME', false, null, '00:00:00'); - $this->addColumn('SCHEDULE_GROUP_PLAYED', 'DbScheduleGroupPlayed', 'BOOLEAN', false, null, false); $this->addColumn('MEDIA_ITEM_PLAYED', 'DbMediaItemPlayed', 'BOOLEAN', false, null, false); $this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', true, null, null); // validators diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php index 15cde9a2b..6bdbd6b3d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php @@ -146,6 +146,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent /** * The value for the length field. + * Note: this column has a database default value of: '00:00:00' * @var string */ protected $length; @@ -456,6 +457,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent $this->filepath = ''; $this->state = 'empty'; $this->currentlyaccessing = 0; + $this->length = '00:00:00'; $this->file_exists = true; } @@ -729,36 +731,13 @@ abstract class BaseCcFiles extends BaseObject implements Persistent } /** - * Get the [optionally formatted] temporal [length] column value. + * Get the [length] column value. * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL - * @throws PropelException - if unable to parse/validate the date/time value. + * @return string */ - public function getDbLength($format = '%X') + public function getDbLength() { - if ($this->length === null) { - return null; - } - - - - try { - $dt = new DateTime($this->length); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->length, true), $x); - } - - if ($format === null) { - // Because propel.useDateTimeClass is TRUE, we return a DateTime object. - return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); - } + return $this->length; } /** @@ -1657,50 +1636,21 @@ abstract class BaseCcFiles extends BaseObject implements Persistent } // setDbFormat() /** - * Sets the value of [length] column to a normalized version of the date/time value specified. + * Set the value of [length] column. * - * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will - * be treated as NULL for temporal objects. + * @param string $v new value * @return CcFiles The current object (for fluent API support) */ public function setDbLength($v) { - // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now') - // -- which is unexpected, to say the least. - if ($v === null || $v === '') { - $dt = null; - } elseif ($v instanceof DateTime) { - $dt = $v; - } else { - // some string/numeric value passed; we normalize that so that we can - // validate it. - try { - if (is_numeric($v)) { // if it's a unix timestamp - $dt = new DateTime('@'.$v, new DateTimeZone('UTC')); - // We have to explicitly specify and then change the time zone because of a - // DateTime bug: http://bugs.php.net/bug.php?id=43003 - $dt->setTimeZone(new DateTimeZone(date_default_timezone_get())); - } else { - $dt = new DateTime($v); - } - } catch (Exception $x) { - throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x); - } + if ($v !== null) { + $v = (string) $v; } - if ( $this->length !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->length !== null && $tmpDt = new DateTime($this->length)) ? $tmpDt->format('H:i:s') : null; - $newNorm = ($dt !== null) ? $dt->format('H:i:s') : null; - - if ( ($currNorm !== $newNorm) // normalized values don't match - ) - { - $this->length = ($dt ? $dt->format('H:i:s') : null); - $this->modifiedColumns[] = CcFilesPeer::LENGTH; - } - } // if either are not null + if ($this->length !== $v || $this->isNew()) { + $this->length = $v; + $this->modifiedColumns[] = CcFilesPeer::LENGTH; + } return $this; } // setDbLength() @@ -2579,6 +2529,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent return false; } + if ($this->length !== '00:00:00') { + return false; + } + if ($this->file_exists !== true) { return false; } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php index 16aba102b..4921e9eb8 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php @@ -863,29 +863,20 @@ abstract class BaseCcFilesQuery extends ModelCriteria /** * Filter the query on the length column * - * @param string|array $dbLength The value to use as filter. - * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $dbLength 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 filterByDbLength($dbLength = null, $comparison = null) { - if (is_array($dbLength)) { - $useMinMax = false; - if (isset($dbLength['min'])) { - $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLength['max'])) { - $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { + if (null === $comparison) { + if (is_array($dbLength)) { $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLength)) { + $dbLength = str_replace('*', '%', $dbLength); + $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength, $comparison); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php b/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php index 26a91778d..751babc2d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php @@ -30,12 +30,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent */ protected $id; - /** - * The value for the playlist_id field. - * @var int - */ - protected $playlist_id; - /** * The value for the starts field. * @var string @@ -48,12 +42,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent */ protected $ends; - /** - * The value for the group_id field. - * @var int - */ - protected $group_id; - /** * The value for the file_id field. * @var int @@ -95,13 +83,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent */ protected $cue_out; - /** - * The value for the schedule_group_played field. - * Note: this column has a database default value of: false - * @var boolean - */ - protected $schedule_group_played; - /** * The value for the media_item_played field. * Note: this column has a database default value of: false @@ -155,7 +136,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $this->fade_out = '00:00:00'; $this->cue_in = '00:00:00'; $this->cue_out = '00:00:00'; - $this->schedule_group_played = false; $this->media_item_played = false; } @@ -179,16 +159,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent return $this->id; } - /** - * Get the [playlist_id] column value. - * - * @return int - */ - public function getDbPlaylistId() - { - return $this->playlist_id; - } - /** * Get the [optionally formatted] temporal [starts] column value. * @@ -255,16 +225,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent } } - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getDbGroupId() - { - return $this->group_id; - } - /** * Get the [file_id] column value. * @@ -440,16 +400,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent } } - /** - * Get the [schedule_group_played] column value. - * - * @return boolean - */ - public function getDbScheduleGroupPlayed() - { - return $this->schedule_group_played; - } - /** * Get the [media_item_played] column value. * @@ -490,26 +440,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent return $this; } // setDbId() - /** - * Set the value of [playlist_id] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbPlaylistId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->playlist_id !== $v) { - $this->playlist_id = $v; - $this->modifiedColumns[] = CcSchedulePeer::PLAYLIST_ID; - } - - return $this; - } // setDbPlaylistId() - /** * Sets the value of [starts] column to a normalized version of the date/time value specified. * @@ -608,26 +538,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent return $this; } // setDbEnds() - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbGroupId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = CcSchedulePeer::GROUP_ID; - } - - return $this; - } // setDbGroupId() - /** * Set the value of [file_id] column. * @@ -902,26 +812,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent return $this; } // setDbCueOut() - /** - * Set the value of [schedule_group_played] column. - * - * @param boolean $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbScheduleGroupPlayed($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->schedule_group_played !== $v || $this->isNew()) { - $this->schedule_group_played = $v; - $this->modifiedColumns[] = CcSchedulePeer::SCHEDULE_GROUP_PLAYED; - } - - return $this; - } // setDbScheduleGroupPlayed() - /** * Set the value of [media_item_played] column. * @@ -996,10 +886,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent return false; } - if ($this->schedule_group_played !== false) { - return false; - } - if ($this->media_item_played !== false) { return false; } @@ -1027,19 +913,16 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent try { $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->playlist_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->starts = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->ends = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->group_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->file_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->clip_length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->fade_in = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->fade_out = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->cue_in = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->cue_out = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->schedule_group_played = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; - $this->media_item_played = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; - $this->instance_id = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null; + $this->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->file_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->clip_length = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->fade_in = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->fade_out = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->cue_in = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->cue_out = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->media_item_played = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null; + $this->instance_id = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null; $this->resetModified(); $this->setNew(false); @@ -1048,7 +931,7 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 14; // 14 = CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 11; // 11 = CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcSchedule object", $e); @@ -1398,42 +1281,33 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent return $this->getDbId(); break; case 1: - return $this->getDbPlaylistId(); - break; - case 2: return $this->getDbStarts(); break; - case 3: + case 2: return $this->getDbEnds(); break; - case 4: - return $this->getDbGroupId(); - break; - case 5: + case 3: return $this->getDbFileId(); break; - case 6: + case 4: return $this->getDbClipLength(); break; - case 7: + case 5: return $this->getDbFadeIn(); break; - case 8: + case 6: return $this->getDbFadeOut(); break; - case 9: + case 7: return $this->getDbCueIn(); break; - case 10: + case 8: return $this->getDbCueOut(); break; - case 11: - return $this->getDbScheduleGroupPlayed(); - break; - case 12: + case 9: return $this->getDbMediaItemPlayed(); break; - case 13: + case 10: return $this->getDbInstanceId(); break; default: @@ -1461,19 +1335,16 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $keys = CcSchedulePeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbPlaylistId(), - $keys[2] => $this->getDbStarts(), - $keys[3] => $this->getDbEnds(), - $keys[4] => $this->getDbGroupId(), - $keys[5] => $this->getDbFileId(), - $keys[6] => $this->getDbClipLength(), - $keys[7] => $this->getDbFadeIn(), - $keys[8] => $this->getDbFadeOut(), - $keys[9] => $this->getDbCueIn(), - $keys[10] => $this->getDbCueOut(), - $keys[11] => $this->getDbScheduleGroupPlayed(), - $keys[12] => $this->getDbMediaItemPlayed(), - $keys[13] => $this->getDbInstanceId(), + $keys[1] => $this->getDbStarts(), + $keys[2] => $this->getDbEnds(), + $keys[3] => $this->getDbFileId(), + $keys[4] => $this->getDbClipLength(), + $keys[5] => $this->getDbFadeIn(), + $keys[6] => $this->getDbFadeOut(), + $keys[7] => $this->getDbCueIn(), + $keys[8] => $this->getDbCueOut(), + $keys[9] => $this->getDbMediaItemPlayed(), + $keys[10] => $this->getDbInstanceId(), ); if ($includeForeignObjects) { if (null !== $this->aCcShowInstances) { @@ -1517,42 +1388,33 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $this->setDbId($value); break; case 1: - $this->setDbPlaylistId($value); - break; - case 2: $this->setDbStarts($value); break; - case 3: + case 2: $this->setDbEnds($value); break; - case 4: - $this->setDbGroupId($value); - break; - case 5: + case 3: $this->setDbFileId($value); break; - case 6: + case 4: $this->setDbClipLength($value); break; - case 7: + case 5: $this->setDbFadeIn($value); break; - case 8: + case 6: $this->setDbFadeOut($value); break; - case 9: + case 7: $this->setDbCueIn($value); break; - case 10: + case 8: $this->setDbCueOut($value); break; - case 11: - $this->setDbScheduleGroupPlayed($value); - break; - case 12: + case 9: $this->setDbMediaItemPlayed($value); break; - case 13: + case 10: $this->setDbInstanceId($value); break; } // switch() @@ -1580,19 +1442,16 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $keys = CcSchedulePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbPlaylistId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbStarts($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbEnds($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbGroupId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbFileId($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbClipLength($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbFadeIn($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbFadeOut($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbCueIn($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbCueOut($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbScheduleGroupPlayed($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setDbMediaItemPlayed($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setDbInstanceId($arr[$keys[13]]); + if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbFileId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbClipLength($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbFadeIn($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbFadeOut($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbCueIn($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbCueOut($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbMediaItemPlayed($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbInstanceId($arr[$keys[10]]); } /** @@ -1605,17 +1464,14 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent $criteria = new Criteria(CcSchedulePeer::DATABASE_NAME); if ($this->isColumnModified(CcSchedulePeer::ID)) $criteria->add(CcSchedulePeer::ID, $this->id); - if ($this->isColumnModified(CcSchedulePeer::PLAYLIST_ID)) $criteria->add(CcSchedulePeer::PLAYLIST_ID, $this->playlist_id); if ($this->isColumnModified(CcSchedulePeer::STARTS)) $criteria->add(CcSchedulePeer::STARTS, $this->starts); if ($this->isColumnModified(CcSchedulePeer::ENDS)) $criteria->add(CcSchedulePeer::ENDS, $this->ends); - if ($this->isColumnModified(CcSchedulePeer::GROUP_ID)) $criteria->add(CcSchedulePeer::GROUP_ID, $this->group_id); if ($this->isColumnModified(CcSchedulePeer::FILE_ID)) $criteria->add(CcSchedulePeer::FILE_ID, $this->file_id); if ($this->isColumnModified(CcSchedulePeer::CLIP_LENGTH)) $criteria->add(CcSchedulePeer::CLIP_LENGTH, $this->clip_length); if ($this->isColumnModified(CcSchedulePeer::FADE_IN)) $criteria->add(CcSchedulePeer::FADE_IN, $this->fade_in); if ($this->isColumnModified(CcSchedulePeer::FADE_OUT)) $criteria->add(CcSchedulePeer::FADE_OUT, $this->fade_out); if ($this->isColumnModified(CcSchedulePeer::CUE_IN)) $criteria->add(CcSchedulePeer::CUE_IN, $this->cue_in); if ($this->isColumnModified(CcSchedulePeer::CUE_OUT)) $criteria->add(CcSchedulePeer::CUE_OUT, $this->cue_out); - if ($this->isColumnModified(CcSchedulePeer::SCHEDULE_GROUP_PLAYED)) $criteria->add(CcSchedulePeer::SCHEDULE_GROUP_PLAYED, $this->schedule_group_played); if ($this->isColumnModified(CcSchedulePeer::MEDIA_ITEM_PLAYED)) $criteria->add(CcSchedulePeer::MEDIA_ITEM_PLAYED, $this->media_item_played); if ($this->isColumnModified(CcSchedulePeer::INSTANCE_ID)) $criteria->add(CcSchedulePeer::INSTANCE_ID, $this->instance_id); @@ -1679,17 +1535,14 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent */ public function copyInto($copyObj, $deepCopy = false) { - $copyObj->setDbPlaylistId($this->playlist_id); $copyObj->setDbStarts($this->starts); $copyObj->setDbEnds($this->ends); - $copyObj->setDbGroupId($this->group_id); $copyObj->setDbFileId($this->file_id); $copyObj->setDbClipLength($this->clip_length); $copyObj->setDbFadeIn($this->fade_in); $copyObj->setDbFadeOut($this->fade_out); $copyObj->setDbCueIn($this->cue_in); $copyObj->setDbCueOut($this->cue_out); - $copyObj->setDbScheduleGroupPlayed($this->schedule_group_played); $copyObj->setDbMediaItemPlayed($this->media_item_played); $copyObj->setDbInstanceId($this->instance_id); @@ -1843,17 +1696,14 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent public function clear() { $this->id = null; - $this->playlist_id = null; $this->starts = null; $this->ends = null; - $this->group_id = null; $this->file_id = null; $this->clip_length = null; $this->fade_in = null; $this->fade_out = null; $this->cue_in = null; $this->cue_out = null; - $this->schedule_group_played = null; $this->media_item_played = null; $this->instance_id = null; $this->alreadyInSave = false; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php index b21b26990..e11d284a7 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php @@ -26,7 +26,7 @@ abstract class BaseCcSchedulePeer { const TM_CLASS = 'CcScheduleTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 14; + const NUM_COLUMNS = 11; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -34,18 +34,12 @@ abstract class BaseCcSchedulePeer { /** the column name for the ID field */ const ID = 'cc_schedule.ID'; - /** the column name for the PLAYLIST_ID field */ - const PLAYLIST_ID = 'cc_schedule.PLAYLIST_ID'; - /** the column name for the STARTS field */ const STARTS = 'cc_schedule.STARTS'; /** the column name for the ENDS field */ const ENDS = 'cc_schedule.ENDS'; - /** the column name for the GROUP_ID field */ - const GROUP_ID = 'cc_schedule.GROUP_ID'; - /** the column name for the FILE_ID field */ const FILE_ID = 'cc_schedule.FILE_ID'; @@ -64,9 +58,6 @@ abstract class BaseCcSchedulePeer { /** the column name for the CUE_OUT field */ const CUE_OUT = 'cc_schedule.CUE_OUT'; - /** the column name for the SCHEDULE_GROUP_PLAYED field */ - const SCHEDULE_GROUP_PLAYED = 'cc_schedule.SCHEDULE_GROUP_PLAYED'; - /** the column name for the MEDIA_ITEM_PLAYED field */ const MEDIA_ITEM_PLAYED = 'cc_schedule.MEDIA_ITEM_PLAYED'; @@ -89,12 +80,12 @@ abstract class BaseCcSchedulePeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbPlaylistId', 'DbStarts', 'DbEnds', 'DbGroupId', 'DbFileId', 'DbClipLength', 'DbFadeIn', 'DbFadeOut', 'DbCueIn', 'DbCueOut', 'DbScheduleGroupPlayed', 'DbMediaItemPlayed', 'DbInstanceId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbPlaylistId', 'dbStarts', 'dbEnds', 'dbGroupId', 'dbFileId', 'dbClipLength', 'dbFadeIn', 'dbFadeOut', 'dbCueIn', 'dbCueOut', 'dbScheduleGroupPlayed', 'dbMediaItemPlayed', 'dbInstanceId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::PLAYLIST_ID, self::STARTS, self::ENDS, self::GROUP_ID, self::FILE_ID, self::CLIP_LENGTH, self::FADE_IN, self::FADE_OUT, self::CUE_IN, self::CUE_OUT, self::SCHEDULE_GROUP_PLAYED, self::MEDIA_ITEM_PLAYED, self::INSTANCE_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'STARTS', 'ENDS', 'GROUP_ID', 'FILE_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', 'SCHEDULE_GROUP_PLAYED', 'MEDIA_ITEM_PLAYED', 'INSTANCE_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'starts', 'ends', 'group_id', 'file_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', 'schedule_group_played', 'media_item_played', 'instance_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbFileId', 'DbClipLength', 'DbFadeIn', 'DbFadeOut', 'DbCueIn', 'DbCueOut', 'DbMediaItemPlayed', 'DbInstanceId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbFileId', 'dbClipLength', 'dbFadeIn', 'dbFadeOut', 'dbCueIn', 'dbCueOut', 'dbMediaItemPlayed', 'dbInstanceId', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::FILE_ID, self::CLIP_LENGTH, self::FADE_IN, self::FADE_OUT, self::CUE_IN, self::CUE_OUT, self::MEDIA_ITEM_PLAYED, self::INSTANCE_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'FILE_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', 'MEDIA_ITEM_PLAYED', 'INSTANCE_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'file_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', 'media_item_played', 'instance_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -104,12 +95,12 @@ abstract class BaseCcSchedulePeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbPlaylistId' => 1, 'DbStarts' => 2, 'DbEnds' => 3, 'DbGroupId' => 4, 'DbFileId' => 5, 'DbClipLength' => 6, 'DbFadeIn' => 7, 'DbFadeOut' => 8, 'DbCueIn' => 9, 'DbCueOut' => 10, 'DbScheduleGroupPlayed' => 11, 'DbMediaItemPlayed' => 12, 'DbInstanceId' => 13, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbPlaylistId' => 1, 'dbStarts' => 2, 'dbEnds' => 3, 'dbGroupId' => 4, 'dbFileId' => 5, 'dbClipLength' => 6, 'dbFadeIn' => 7, 'dbFadeOut' => 8, 'dbCueIn' => 9, 'dbCueOut' => 10, 'dbScheduleGroupPlayed' => 11, 'dbMediaItemPlayed' => 12, 'dbInstanceId' => 13, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::PLAYLIST_ID => 1, self::STARTS => 2, self::ENDS => 3, self::GROUP_ID => 4, self::FILE_ID => 5, self::CLIP_LENGTH => 6, self::FADE_IN => 7, self::FADE_OUT => 8, self::CUE_IN => 9, self::CUE_OUT => 10, self::SCHEDULE_GROUP_PLAYED => 11, self::MEDIA_ITEM_PLAYED => 12, self::INSTANCE_ID => 13, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'STARTS' => 2, 'ENDS' => 3, 'GROUP_ID' => 4, 'FILE_ID' => 5, 'CLIP_LENGTH' => 6, 'FADE_IN' => 7, 'FADE_OUT' => 8, 'CUE_IN' => 9, 'CUE_OUT' => 10, 'SCHEDULE_GROUP_PLAYED' => 11, 'MEDIA_ITEM_PLAYED' => 12, 'INSTANCE_ID' => 13, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'starts' => 2, 'ends' => 3, 'group_id' => 4, 'file_id' => 5, 'clip_length' => 6, 'fade_in' => 7, 'fade_out' => 8, 'cue_in' => 9, 'cue_out' => 10, 'schedule_group_played' => 11, 'media_item_played' => 12, 'instance_id' => 13, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbFileId' => 3, 'DbClipLength' => 4, 'DbFadeIn' => 5, 'DbFadeOut' => 6, 'DbCueIn' => 7, 'DbCueOut' => 8, 'DbMediaItemPlayed' => 9, 'DbInstanceId' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbFileId' => 3, 'dbClipLength' => 4, 'dbFadeIn' => 5, 'dbFadeOut' => 6, 'dbCueIn' => 7, 'dbCueOut' => 8, 'dbMediaItemPlayed' => 9, 'dbInstanceId' => 10, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::FILE_ID => 3, self::CLIP_LENGTH => 4, self::FADE_IN => 5, self::FADE_OUT => 6, self::CUE_IN => 7, self::CUE_OUT => 8, self::MEDIA_ITEM_PLAYED => 9, self::INSTANCE_ID => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'FILE_ID' => 3, 'CLIP_LENGTH' => 4, 'FADE_IN' => 5, 'FADE_OUT' => 6, 'CUE_IN' => 7, 'CUE_OUT' => 8, 'MEDIA_ITEM_PLAYED' => 9, 'INSTANCE_ID' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'file_id' => 3, 'clip_length' => 4, 'fade_in' => 5, 'fade_out' => 6, 'cue_in' => 7, 'cue_out' => 8, 'media_item_played' => 9, 'instance_id' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -182,32 +173,26 @@ abstract class BaseCcSchedulePeer { { if (null === $alias) { $criteria->addSelectColumn(CcSchedulePeer::ID); - $criteria->addSelectColumn(CcSchedulePeer::PLAYLIST_ID); $criteria->addSelectColumn(CcSchedulePeer::STARTS); $criteria->addSelectColumn(CcSchedulePeer::ENDS); - $criteria->addSelectColumn(CcSchedulePeer::GROUP_ID); $criteria->addSelectColumn(CcSchedulePeer::FILE_ID); $criteria->addSelectColumn(CcSchedulePeer::CLIP_LENGTH); $criteria->addSelectColumn(CcSchedulePeer::FADE_IN); $criteria->addSelectColumn(CcSchedulePeer::FADE_OUT); $criteria->addSelectColumn(CcSchedulePeer::CUE_IN); $criteria->addSelectColumn(CcSchedulePeer::CUE_OUT); - $criteria->addSelectColumn(CcSchedulePeer::SCHEDULE_GROUP_PLAYED); $criteria->addSelectColumn(CcSchedulePeer::MEDIA_ITEM_PLAYED); $criteria->addSelectColumn(CcSchedulePeer::INSTANCE_ID); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PLAYLIST_ID'); $criteria->addSelectColumn($alias . '.STARTS'); $criteria->addSelectColumn($alias . '.ENDS'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); $criteria->addSelectColumn($alias . '.FILE_ID'); $criteria->addSelectColumn($alias . '.CLIP_LENGTH'); $criteria->addSelectColumn($alias . '.FADE_IN'); $criteria->addSelectColumn($alias . '.FADE_OUT'); $criteria->addSelectColumn($alias . '.CUE_IN'); $criteria->addSelectColumn($alias . '.CUE_OUT'); - $criteria->addSelectColumn($alias . '.SCHEDULE_GROUP_PLAYED'); $criteria->addSelectColumn($alias . '.MEDIA_ITEM_PLAYED'); $criteria->addSelectColumn($alias . '.INSTANCE_ID'); } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php index 11a030d84..4c661ad56 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php @@ -7,32 +7,26 @@ * * * @method CcScheduleQuery orderByDbId($order = Criteria::ASC) Order by the id column - * @method CcScheduleQuery orderByDbPlaylistId($order = Criteria::ASC) Order by the playlist_id column * @method CcScheduleQuery orderByDbStarts($order = Criteria::ASC) Order by the starts column * @method CcScheduleQuery orderByDbEnds($order = Criteria::ASC) Order by the ends column - * @method CcScheduleQuery orderByDbGroupId($order = Criteria::ASC) Order by the group_id column * @method CcScheduleQuery orderByDbFileId($order = Criteria::ASC) Order by the file_id column * @method CcScheduleQuery orderByDbClipLength($order = Criteria::ASC) Order by the clip_length column * @method CcScheduleQuery orderByDbFadeIn($order = Criteria::ASC) Order by the fade_in column * @method CcScheduleQuery orderByDbFadeOut($order = Criteria::ASC) Order by the fade_out column * @method CcScheduleQuery orderByDbCueIn($order = Criteria::ASC) Order by the cue_in column * @method CcScheduleQuery orderByDbCueOut($order = Criteria::ASC) Order by the cue_out column - * @method CcScheduleQuery orderByDbScheduleGroupPlayed($order = Criteria::ASC) Order by the schedule_group_played column * @method CcScheduleQuery orderByDbMediaItemPlayed($order = Criteria::ASC) Order by the media_item_played column * @method CcScheduleQuery orderByDbInstanceId($order = Criteria::ASC) Order by the instance_id column * * @method CcScheduleQuery groupByDbId() Group by the id column - * @method CcScheduleQuery groupByDbPlaylistId() Group by the playlist_id column * @method CcScheduleQuery groupByDbStarts() Group by the starts column * @method CcScheduleQuery groupByDbEnds() Group by the ends column - * @method CcScheduleQuery groupByDbGroupId() Group by the group_id column * @method CcScheduleQuery groupByDbFileId() Group by the file_id column * @method CcScheduleQuery groupByDbClipLength() Group by the clip_length column * @method CcScheduleQuery groupByDbFadeIn() Group by the fade_in column * @method CcScheduleQuery groupByDbFadeOut() Group by the fade_out column * @method CcScheduleQuery groupByDbCueIn() Group by the cue_in column * @method CcScheduleQuery groupByDbCueOut() Group by the cue_out column - * @method CcScheduleQuery groupByDbScheduleGroupPlayed() Group by the schedule_group_played column * @method CcScheduleQuery groupByDbMediaItemPlayed() Group by the media_item_played column * @method CcScheduleQuery groupByDbInstanceId() Group by the instance_id column * @@ -52,32 +46,26 @@ * @method CcSchedule findOneOrCreate(PropelPDO $con = null) Return the first CcSchedule matching the query, or a new CcSchedule object populated from the query conditions when no match is found * * @method CcSchedule findOneByDbId(int $id) Return the first CcSchedule filtered by the id column - * @method CcSchedule findOneByDbPlaylistId(int $playlist_id) Return the first CcSchedule filtered by the playlist_id column * @method CcSchedule findOneByDbStarts(string $starts) Return the first CcSchedule filtered by the starts column * @method CcSchedule findOneByDbEnds(string $ends) Return the first CcSchedule filtered by the ends column - * @method CcSchedule findOneByDbGroupId(int $group_id) Return the first CcSchedule filtered by the group_id column * @method CcSchedule findOneByDbFileId(int $file_id) Return the first CcSchedule filtered by the file_id column * @method CcSchedule findOneByDbClipLength(string $clip_length) Return the first CcSchedule filtered by the clip_length column * @method CcSchedule findOneByDbFadeIn(string $fade_in) Return the first CcSchedule filtered by the fade_in column * @method CcSchedule findOneByDbFadeOut(string $fade_out) Return the first CcSchedule filtered by the fade_out column * @method CcSchedule findOneByDbCueIn(string $cue_in) Return the first CcSchedule filtered by the cue_in column * @method CcSchedule findOneByDbCueOut(string $cue_out) Return the first CcSchedule filtered by the cue_out column - * @method CcSchedule findOneByDbScheduleGroupPlayed(boolean $schedule_group_played) Return the first CcSchedule filtered by the schedule_group_played column * @method CcSchedule findOneByDbMediaItemPlayed(boolean $media_item_played) Return the first CcSchedule filtered by the media_item_played column * @method CcSchedule findOneByDbInstanceId(int $instance_id) Return the first CcSchedule filtered by the instance_id column * * @method array findByDbId(int $id) Return CcSchedule objects filtered by the id column - * @method array findByDbPlaylistId(int $playlist_id) Return CcSchedule objects filtered by the playlist_id column * @method array findByDbStarts(string $starts) Return CcSchedule objects filtered by the starts column * @method array findByDbEnds(string $ends) Return CcSchedule objects filtered by the ends column - * @method array findByDbGroupId(int $group_id) Return CcSchedule objects filtered by the group_id column * @method array findByDbFileId(int $file_id) Return CcSchedule objects filtered by the file_id column * @method array findByDbClipLength(string $clip_length) Return CcSchedule objects filtered by the clip_length column * @method array findByDbFadeIn(string $fade_in) Return CcSchedule objects filtered by the fade_in column * @method array findByDbFadeOut(string $fade_out) Return CcSchedule objects filtered by the fade_out column * @method array findByDbCueIn(string $cue_in) Return CcSchedule objects filtered by the cue_in column * @method array findByDbCueOut(string $cue_out) Return CcSchedule objects filtered by the cue_out column - * @method array findByDbScheduleGroupPlayed(boolean $schedule_group_played) Return CcSchedule objects filtered by the schedule_group_played column * @method array findByDbMediaItemPlayed(boolean $media_item_played) Return CcSchedule objects filtered by the media_item_played column * @method array findByDbInstanceId(int $instance_id) Return CcSchedule objects filtered by the instance_id column * @@ -206,37 +194,6 @@ abstract class BaseCcScheduleQuery extends ModelCriteria return $this->addUsingAlias(CcSchedulePeer::ID, $dbId, $comparison); } - /** - * Filter the query on the playlist_id column - * - * @param int|array $dbPlaylistId 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 CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbPlaylistId($dbPlaylistId = null, $comparison = null) - { - if (is_array($dbPlaylistId)) { - $useMinMax = false; - if (isset($dbPlaylistId['min'])) { - $this->addUsingAlias(CcSchedulePeer::PLAYLIST_ID, $dbPlaylistId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbPlaylistId['max'])) { - $this->addUsingAlias(CcSchedulePeer::PLAYLIST_ID, $dbPlaylistId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::PLAYLIST_ID, $dbPlaylistId, $comparison); - } - /** * Filter the query on the starts column * @@ -299,37 +256,6 @@ abstract class BaseCcScheduleQuery extends ModelCriteria return $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds, $comparison); } - /** - * Filter the query on the group_id column - * - * @param int|array $dbGroupId 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 CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbGroupId($dbGroupId = null, $comparison = null) - { - if (is_array($dbGroupId)) { - $useMinMax = false; - if (isset($dbGroupId['min'])) { - $this->addUsingAlias(CcSchedulePeer::GROUP_ID, $dbGroupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbGroupId['max'])) { - $this->addUsingAlias(CcSchedulePeer::GROUP_ID, $dbGroupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::GROUP_ID, $dbGroupId, $comparison); - } - /** * Filter the query on the file_id column * @@ -516,23 +442,6 @@ abstract class BaseCcScheduleQuery extends ModelCriteria return $this->addUsingAlias(CcSchedulePeer::CUE_OUT, $dbCueOut, $comparison); } - /** - * Filter the query on the schedule_group_played column - * - * @param boolean|string $dbScheduleGroupPlayed The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbScheduleGroupPlayed($dbScheduleGroupPlayed = null, $comparison = null) - { - if (is_string($dbScheduleGroupPlayed)) { - $schedule_group_played = in_array(strtolower($dbScheduleGroupPlayed), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcSchedulePeer::SCHEDULE_GROUP_PLAYED, $dbScheduleGroupPlayed, $comparison); - } - /** * Filter the query on the media_item_played column * diff --git a/airtime_mvc/application/models/formatters/BitrateFormatter.php b/airtime_mvc/application/models/formatters/BitrateFormatter.php new file mode 100644 index 000000000..00828a672 --- /dev/null +++ b/airtime_mvc/application/models/formatters/BitrateFormatter.php @@ -0,0 +1,24 @@ +_bitrate = $bitrate; + } + + public function format() + { + $Kbps = bcdiv($this->_bitrate, 1000, 0); + + return "{$Kbps} Kbps"; + } +} \ No newline at end of file diff --git a/airtime_mvc/application/models/formatters/LengthFormatter.php b/airtime_mvc/application/models/formatters/LengthFormatter.php new file mode 100644 index 000000000..4551e4680 --- /dev/null +++ b/airtime_mvc/application/models/formatters/LengthFormatter.php @@ -0,0 +1,56 @@ + 24 hours) + */ + public function __construct($length) + { + $this->_length = $length; + } + + public function format() { + + $pieces = explode(":", $this->_length); + + $seconds = round($pieces[2], 1); + $seconds = number_format($seconds, 1); + list($seconds, $milliStr) = explode(".", $seconds); + + if (intval($pieces[0]) !== 0) { + $hours = ltrim($pieces[0], "0"); + } + + $minutes = $pieces[1]; + //length is less than 1 hour + if (!isset($hours)) { + + if (intval($minutes) !== 0) { + $minutes = ltrim($minutes, "0"); + } + //length is less than 1 minute + else { + unset($minutes); + } + } + + if (isset($hours) && isset($minutes) && isset($seconds)) { + $time = sprintf("%d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr); + } + else if (isset($minutes) && isset($seconds)) { + $time = sprintf("%d:%02d.%s", $minutes, $seconds, $milliStr); + } + else { + $time = sprintf("%d.%s", $seconds, $milliStr); + } + + return $time; + } + +} \ No newline at end of file diff --git a/airtime_mvc/application/models/formatters/SamplerateFormatter.php b/airtime_mvc/application/models/formatters/SamplerateFormatter.php new file mode 100644 index 000000000..aeabe8c2f --- /dev/null +++ b/airtime_mvc/application/models/formatters/SamplerateFormatter.php @@ -0,0 +1,24 @@ +_samplerate = $samplerate; + } + + public function format() + { + $kHz = bcdiv($this->_samplerate, 1000, 1); + + return "{$kHz} kHz"; + } +} \ No newline at end of file diff --git a/airtime_mvc/application/models/index.php b/airtime_mvc/application/models/index.php deleted file mode 100644 index ce253b51f..000000000 --- a/airtime_mvc/application/models/index.php +++ /dev/null @@ -1,3 +0,0 @@ - -
  • Search
  • - -
    - -
    -
    + +
    + diff --git a/airtime_mvc/application/views/scripts/playlist/index.phtml b/airtime_mvc/application/views/scripts/playlist/index.phtml index 75d1678d1..0dd86a2fd 100644 --- a/airtime_mvc/application/views/scripts/playlist/index.phtml +++ b/airtime_mvc/application/views/scripts/playlist/index.phtml @@ -14,7 +14,7 @@ pl->getName(); ?> -

    pl->getLength(); ?>

    +

    length; ?>

    diff --git a/airtime_mvc/application/views/scripts/schedule/find-playlists-partial.phtml b/airtime_mvc/application/views/scripts/schedule/find-playlists-partial.phtml deleted file mode 100644 index 6f79a662c..000000000 --- a/airtime_mvc/application/views/scripts/schedule/find-playlists-partial.phtml +++ /dev/null @@ -1,11 +0,0 @@ -
  • - name ?> - length ?> -
    - Creator: creator ?> - state === "edited") : ?> - Editing: login ?> - -
    -
    description ?>
    -
  • diff --git a/airtime_mvc/application/views/scripts/schedule/find-playlists.ajax.phtml b/airtime_mvc/application/views/scripts/schedule/find-playlists.ajax.phtml deleted file mode 100644 index 185ce5f98..000000000 --- a/airtime_mvc/application/views/scripts/schedule/find-playlists.ajax.phtml +++ /dev/null @@ -1,8 +0,0 @@ -playlists) > 0) { - echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); - } - else { - echo "No Playlists Fit Duration"; - } -?> diff --git a/airtime_mvc/application/views/scripts/schedule/find-playlists.phtml b/airtime_mvc/application/views/scripts/schedule/find-playlists.phtml deleted file mode 100644 index 185ce5f98..000000000 --- a/airtime_mvc/application/views/scripts/schedule/find-playlists.phtml +++ /dev/null @@ -1,8 +0,0 @@ -playlists) > 0) { - echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); - } - else { - echo "No Playlists Fit Duration"; - } -?> diff --git a/airtime_mvc/application/views/scripts/schedule/schedule-show-dialog.phtml b/airtime_mvc/application/views/scripts/schedule/schedule-show-dialog.phtml deleted file mode 100644 index 2085d67e9..000000000 --- a/airtime_mvc/application/views/scripts/schedule/schedule-show-dialog.phtml +++ /dev/null @@ -1,34 +0,0 @@ -
    -

    - showName; ?>: s_wday." ".$this->s_month." ".$this->s_day." ".$this->startTime. - " - ".$this->e_wday." ".$this->e_month." ".$this->e_day." ".$this->endTime; ?> -

    -
    -
    - - - - - - - - - - - - -
    IdDescriptionTitleCreatorLengthEditing
    -
    - -
    -

    Items In This Show:

    -
      -
      - timeFilled; ?> -
      - showLength; ?> -
      - -
      -
      -
      diff --git a/airtime_mvc/application/views/scripts/schedule/scheduled-content.phtml b/airtime_mvc/application/views/scripts/schedule/scheduled-content.phtml deleted file mode 100644 index c58492027..000000000 --- a/airtime_mvc/application/views/scripts/schedule/scheduled-content.phtml +++ /dev/null @@ -1,26 +0,0 @@ -showContent) > 0) : ?> - showContent as $pl) : ?> -
    • " > -

      - - -
      -
      -
      -

      - -
    • - - -
    • Nothing Scheduled
    • - - 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 a48a41399..103796adc 100644 --- a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml +++ b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml @@ -12,13 +12,11 @@ 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/build/schema.xml b/airtime_mvc/build/schema.xml index edc6b2b86..9c726d804 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -54,7 +54,7 @@ - + @@ -270,17 +270,14 @@ - - -