diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..98a8f4524 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,41 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**LibreTime version:** +Version from the upgrade popup if you can reach it. + +**Installation method:** + - OS: [e.g. Ubuntu] + - OS Version [e.g. 16.04.5 LTS (Xenial Xerus)] + - Method: [e.g. `./install` script or packages] + - Details: [how did you call the install script, where did you get packages from] + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Client (please complete the following information if applicable):** + - OS: [e.g. Fedora] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..982a4dc0d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: feature-request +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index 7e6412ac8..719207802 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ VERSION airtime_mvc/tests/log/*.log .vagrant/ .DS_Store +.idea/ diff --git a/.travis.yml b/.travis.yml index 3a5967e19..dde29a3e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ dist: trusty language: php php: # the latest and greatest, has some issues that are excluded below in matrix.allow_failures +- 7.3 - 7.2 - 7.1 # the 7.0 build demonstrates that everything is basically ok for 7.0, users might want to wait for 7.1 to run it @@ -28,12 +29,15 @@ matrix: # there are some issues with phpunit as well as some deep in zf1 on 7.2 - env: PYTHON=false php: 7.2 + # there are some issues with phpunit as well as some deep in zf1 on 7.3 + - env: PYTHON=false + php: 7.3 exclude: - # by excluding all of python we make way to just runu python tests in one seperate instance + # by excluding all of python we make way to just run python tests in one seperate instance - env: PYTHON=true include: # using latest to run python on since it will last the longest - - php: 7.1 + - php: 7.3 env: PYTHON=true addons: apt: diff --git a/Vagrantfile b/Vagrantfile index f85987c79..0d5cae12a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,10 +9,9 @@ Vagrant.configure("2") do |config| config.vm.network "forwarded_port", guest: 8000, host:8000 # liquidsoap input harbors for instreaming (ie. /master) config.vm.network "forwarded_port", guest: 8001, host:8001 - config.vm.network "forwarded_port", guest: 8002, host:8002 + config.vm.network "forwarded_port", guest: 8002, host:8002 # mkdocs documentation config.vm.network "forwarded_port", guest: 8888, host:8888 - # make sure we are using nfs (doesn't work out of the box with debian) config.vm.synced_folder ".", "/vagrant", type: "nfs" @@ -40,31 +39,31 @@ Vagrant.configure("2") do |config| # define all the OS boxes we support config.vm.define "ubuntu-bionic" do |os| os.vm.box = "bento/ubuntu-18.04" - provision_libretime(os, "ubuntu.sh", installer_args) + provision_libretime(os, "debian.sh", installer_args) end config.vm.define "ubuntu-xenial" do |os| os.vm.box = "bento/ubuntu-16.04" - provision_libretime(os, "ubuntu.sh", installer_args) + provision_libretime(os, "debian.sh", installer_args) end config.vm.define "ubuntu-trusty" do |os| STDERR.puts 'WARNING: The "ubuntu-trusty" option is deprecated. Please migrate to "ubuntu-bionic".' STDERR.puts os.vm.box = "bento/ubuntu-14.04" - provision_libretime(os, "ubuntu.sh", installer_args) + provision_libretime(os, "debian.sh", installer_args) end config.vm.define "debian-jessie" do |os| os.vm.box = "bento/debian-8.7" provision_libretime(os, "debian.sh", installer_args) end config.vm.define "debian-stretch" do |os| - os.vm.box = "bento/debian-9.2" + os.vm.box = "bento/debian-9.6" provision_libretime(os, "debian.sh", installer_args) end - config.vm.define "debian-wheezy" do |os| - STDERR.puts 'WARNING: The "debian-wheezy" option is deprecated. Please migrate to "debian-stretch".' - STDERR.puts - os.vm.box = "bento/debian-7.11" - provision_libretime(os, "debian.sh", installer_args) + config.vm.define "debian-buster" do |os| + # TODO: Replace with generic/debian10 once it is released + os.vm.box = "fujimakishouten/debian-buster64" + # TODO: Remove the manual flags after buster is released + provision_libretime(os, "debian.sh", installer_args + "--distribution=debian --release=buster") end config.vm.define "centos" do |os| os.vm.box = 'centos/7' diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 37b2ca3af..dcb9ba090 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -43,29 +43,14 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->doctype('XHTML1_STRICT'); } - protected function _initZFDebug() + /** + * initialize front controller + * + * This is call ZFrontController to ensure it is executed last in the bootstrap process. + */ + protected function _initZFrontController() { - Zend_Controller_Front::getInstance()->throwExceptions(false); - - /* - if (APPLICATION_ENV == "development") { - $autoloader = Zend_Loader_Autoloader::getInstance(); - $autoloader->registerNamespace('ZFDebug'); - - $options = array( - 'plugins' => array('Variables', - 'Exception', - 'Memory', - 'Time') - ); - $debug = new ZFDebug_Controller_Plugin_Debug($options); - - $this->bootstrap('frontController'); - $frontController = $this->getResource('frontController'); - $frontController->registerPlugin($debug); - } - */ } protected function _initRouter() diff --git a/airtime_mvc/application/airtime-boot.php b/airtime_mvc/application/airtime-boot.php index 97c00678d..e425fe37e 100644 --- a/airtime_mvc/application/airtime-boot.php +++ b/airtime_mvc/application/airtime-boot.php @@ -64,10 +64,10 @@ set_include_path(APPLICATION_PATH . '/common/' . PATH_SEPARATOR . get_include_pa require_once 'autoload.php'; /** Zend_Application */ -require_once 'Zend/Application.php'; $application = new Zend_Application( APPLICATION_ENV, - CONFIG_PATH . 'application.ini' + CONFIG_PATH . 'application.ini', + true ); require_once(APPLICATION_PATH . "logging/Logging.php"); diff --git a/airtime_mvc/application/common/AutoPlaylistManager.php b/airtime_mvc/application/common/AutoPlaylistManager.php index 2d1304165..c87efc095 100644 --- a/airtime_mvc/application/common/AutoPlaylistManager.php +++ b/airtime_mvc/application/common/AutoPlaylistManager.php @@ -13,7 +13,6 @@ class AutoPlaylistManager { * @return bool true if $_AUTOPLAYLIST_POLL_INTERVAL_SECONDS has passed since the last check */ public static function hasAutoPlaylistPollIntervalPassed() { - Logging::info("Checking autoplaylist poll"); $lastPolled = Application_Model_Preference::getAutoPlaylistPollLock(); return empty($lastPolled) || (microtime(true) > $lastPolled + self::$_AUTOPLAYLIST_POLL_INTERVAL_SECONDS); } @@ -23,35 +22,58 @@ class AutoPlaylistManager { * */ public static function buildAutoPlaylist() { - Logging::info("Checking to run Auto Playlist"); $autoPlaylists = static::_upcomingAutoPlaylistShows(); foreach ($autoPlaylists as $autoplaylist) { // creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object $si = new Application_Model_ShowInstance($autoplaylist->getDbId()); $playlistid = $si->GetAutoPlaylistId(); - Logging::info("Scheduling $playlistid"); // call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object $sid = $si->getShowId(); $playlistrepeat = new Application_Model_Show($sid); + $introplaylistid = Application_Model_Preference::GetIntroPlaylist(); + $outroplaylistid = Application_Model_Preference::GetOutroPlaylist(); - if ($playlistrepeat->getAutoPlaylistRepeat()) { - $full = false; - while(!$full) { - $si = new Application_Model_ShowInstance($autoplaylist->getDbId()); + // we want to check and see if we need to repeat this process until the show is 100% scheduled + // so we create a while loop and break it immediately if repeat until full isn't enabled + // otherwise we continue to go through adding playlists, including the intro and outro if enabled + $full = false; + $repeatuntilfull = $playlistrepeat->getAutoPlaylistRepeat(); + $tempPercentScheduled = 0; + while(!$full) { + $si = new Application_Model_ShowInstance($autoplaylist->getDbId()); + // we do not want to try to schedule an empty playlist + if ($playlistid != null) { $si->addPlaylistToShow($playlistid, false); - $ps = $si->getPercentScheduled(); - //Logging::info("The total percent scheduled is % $ps"); - if ($ps > 100) { - $full = true; - } - } - } - else { - $si->addPlaylistToShow($playlistid, false); + $ps = $si->getPercentScheduled(); + if ($introplaylistid != null) { + //Logging::info('adding intro'); + $si->addPlaylistToShowStart($introplaylistid, false); + } + if ($outroplaylistid != null) { + //Logging::info('adding outro'); + $si->addPlaylistToShow($outroplaylistid, false); + //Logging::info("The total percent scheduled is % $ps"); + } + if ($ps > 100) { + $full = true; + } + elseif (!$repeatuntilfull) { + break; + } + // we want to avoid an infinite loop if all of the playlists are null + if ($playlistid == null && $introplaylistid == null && $outroplaylistid == null) { + break; + } + // another possible issue would be if the show isn't increasing in length each loop + // ie if all of the playlists being added are zero lengths this could cause an infinite loop + if ($tempPercentScheduled == $ps) { + break; + } + //now reset it to zero + $tempPercentScheduled = $ps; } $si->setAutoPlaylistBuilt(true); - } Application_Model_Preference::setAutoPlaylistPollLock(microtime(true)); } diff --git a/airtime_mvc/application/common/FileDataHelper.php b/airtime_mvc/application/common/FileDataHelper.php index 6ad391dbc..3cd9c83af 100644 --- a/airtime_mvc/application/common/FileDataHelper.php +++ b/airtime_mvc/application/common/FileDataHelper.php @@ -16,6 +16,7 @@ class FileDataHelper { "audio/mp4" => "m4a", "video/mp4" => "mp4", "audio/x-flac" => "flac", + "audio/flac" => "flac", "audio/wav" => "wav", "audio/x-wav" => "wav", "audio/mp2" => "mp2", diff --git a/airtime_mvc/application/common/PodcastManager.php b/airtime_mvc/application/common/PodcastManager.php index a090ff910..d29816a54 100644 --- a/airtime_mvc/application/common/PodcastManager.php +++ b/airtime_mvc/application/common/PodcastManager.php @@ -101,4 +101,4 @@ class PodcastManager { return (strtotime($a["pub_date"]) < strtotime($b["pub_date"])) ? 1 : -1; // Descending order } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index f7c81aafa..b211b323f 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -68,10 +68,9 @@ $pages[] = array( ); $pages[] = array( 'label' => _("Settings"), - 'resource' => 'preference', - 'action' => 'index', + 'action' => 'edit-user', 'module' => 'default', - 'controller' => 'preference', + 'controller' => 'user', 'class' => '', 'title' => 'Settings', 'pages' => array( @@ -84,8 +83,7 @@ $pages[] = array( array( 'label' => _('My Profile'), 'controller' => 'user', - 'action' => 'edit-user', - 'resource' => 'usersettings' + 'action' => 'edit-user' ), array( 'label' => _('Users'), diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index bee424f85..cd5027882 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -15,12 +15,12 @@ class ApiController extends Zend_Controller_Action } //Ignore API key and session authentication for these APIs: - $ignoreAuth = array("live-info", - "live-info-v2", - "week-info", - "station-metadata", + $ignoreAuth = array("live-info", + "live-info-v2", + "week-info", + "station-metadata", "station-logo", - "show-history-feed", + "show-history-feed", "item-history-feed", "shows", "show-tracks", @@ -178,6 +178,7 @@ class ApiController extends Zend_Controller_Action //Used by the SaaS monitoring public function onAirLightAction() { + $request = $this->getRequest(); $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); @@ -185,12 +186,16 @@ class ApiController extends Zend_Controller_Action $result["on_air_light"] = false; $result["on_air_light_expected_status"] = false; $result["station_down"] = false; + $result["master_stream"] = false; + $result["live_stream"] = false; + $result["master_stream_on_air"] = false; + $result["live_stream_on_air"] = false; $range = Application_Model_Schedule::GetPlayOrderRange(); - $isItemCurrentlyScheduled = !is_null($range["current"]) && count($range["currentShow"]) > 0 ? true : false; + $isItemCurrentlyScheduled = !is_null($range["tracks"]["current"]) && count($range["tracks"]["current"]) > 0 ? true : false; - $isCurrentItemPlaying = $range["current"]["media_item_played"] ? true : false; + $isCurrentItemPlaying = $range["tracks"]["current"]["media_item_played"] ? true : false; if ($isItemCurrentlyScheduled || Application_Model_Preference::GetSourceSwitchStatus("live_dj") == "on" || @@ -210,9 +215,28 @@ class ApiController extends Zend_Controller_Action $result["station_down"] = true; } + $live_dj_stream = Application_Model_Preference::GetSourceStatus("live_dj"); + $master_dj_stream = Application_Model_Preference::GetSourceStatus("master_dj"); + $live_dj_on_air = Application_Model_Preference::GetSourceSwitchStatus("live_dj"); + $master_dj_on_air = Application_Model_Preference::GetSourceSwitchStatus("master_dj"); + + if($live_dj_stream == true){ + $result["live_stream"] = true; + if ($live_dj_on_air == "on") { + $result["live_stream_on_air"] = true; + } + } + + if($master_dj_stream == true){ + $result["master_stream"] = true; + if ($master_dj_on_air == "on") { + $result["master_stream_on_air"] = true; + } + } + $this->returnJsonOrJsonp($request, $result); } - + /** * Retrieve the currently playing show as well as upcoming shows. * Number of shows returned and the time interval in which to @@ -234,18 +258,18 @@ class ApiController extends Zend_Controller_Action // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - + $request = $this->getRequest(); - + $utcTimeNow = gmdate(DEFAULT_TIMESTAMP_FORMAT); $utcTimeEnd = ""; // if empty, getNextShows will use interval instead of end of day - + // default to the station timezone $timezone = Application_Model_Preference::GetDefaultTimezone(); $userDefinedTimezone = strtolower($request->getParam('timezone')); $upcase = false; // only upcase the timezone abbreviations $this->updateTimezone($userDefinedTimezone, $timezone, $upcase); - + $type = $request->getParam('type'); $limit = $request->getParam('limit'); if ($limit == "" || !is_numeric($limit)) { @@ -255,12 +279,12 @@ class ApiController extends Zend_Controller_Action * we are using two entirely different codepaths for very similar functionality (type = endofday * vs type = interval). Needs to be fixed for 2.3 - MK */ if ($type == "endofday") { - + // make getNextShows use end of day $end = Application_Common_DateHelper::getTodayStationEndDateTime(); $end->setTimezone(new DateTimeZone("UTC")); $utcTimeEnd = $end->format(DEFAULT_TIMESTAMP_FORMAT); - + $result = array( "env" => APPLICATION_ENV, "schedulerTime" => $utcTimeNow, @@ -282,7 +306,7 @@ class ApiController extends Zend_Controller_Action array("starts", "ends", "start_timestamp","end_timestamp"), $timezone ); - + //Convert the UTC scheduler time ("now") to the user-defined timezone. $result["schedulerTime"] = Application_Common_DateHelper::UTCStringToTimezoneString($result["schedulerTime"], $timezone); $result["timezone"] = $upcase ? strtoupper($timezone) : $timezone; @@ -326,13 +350,13 @@ class ApiController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); - + // default to the station timezone $timezone = Application_Model_Preference::GetDefaultTimezone(); $userDefinedTimezone = strtolower($request->getParam('timezone')); $upcase = false; // only upcase the timezone abbreviations $this->updateTimezone($userDefinedTimezone, $timezone, $upcase); - + $daysToRetrieve = $request->getParam('days'); $showsToRetrieve = $request->getParam('shows'); if ($daysToRetrieve == "" || !is_numeric($daysToRetrieve)) { @@ -341,7 +365,7 @@ class ApiController extends Zend_Controller_Action if ($showsToRetrieve == "" || !is_numeric($showsToRetrieve)) { $showsToRetrieve = self::DEFAULT_SHOWS_TO_RETRIEVE; } - + // set the end time to the day's start n days from now. // days=1 will return shows until the end of the current day, // days=2 will return shows until the end of tomorrow, etc. @@ -350,7 +374,7 @@ class ApiController extends Zend_Controller_Action $utcTimeEnd = $end->format(DEFAULT_TIMESTAMP_FORMAT); $result = Application_Model_Schedule::GetPlayOrderRange($utcTimeEnd, $showsToRetrieve); - + // apply user-defined timezone, or default to station $this->applyLiveTimezoneAdjustments($result, $timezone, $upcase); @@ -359,7 +383,7 @@ class ApiController extends Zend_Controller_Action // convert image paths to point to api endpoints WidgetHelper::findAndConvertPaths($result); - + // used by caller to determine if the airtime they are running or widgets in use is out of date. $result["station"]["AIRTIME_API_VERSION"] = AIRTIME_API_VERSION; @@ -370,12 +394,12 @@ class ApiController extends Zend_Controller_Action exit; } } - + /** - * Check that the value for the timezone the user gave is valid. - * If it is, override the default (station) timezone. + * Check that the value for the timezone the user gave is valid. + * If it is, override the default (station) timezone. * If it's an abbreviation (pst, edt) we upcase the output. - * + * * @param string $userDefinedTimezone the requested timezone value * @param string $timezone the default timezone * @param boolean $upcase whether the timezone output should be upcased @@ -396,28 +420,28 @@ class ApiController extends Zend_Controller_Action $timezone = $userDefinedTimezone; } } - + /** - * If the user passed in a timezone parameter, adjust timezone-dependent + * If the user passed in a timezone parameter, adjust timezone-dependent * variables in the result to reflect the given timezone. - * + * * @param array $result reference to the object to send back to the user * @param string $timezone the user's timezone parameter value * @param boolean $upcase whether the timezone output should be upcased */ - private function applyLiveTimezoneAdjustments(&$result, $timezone, $upcase) + private function applyLiveTimezoneAdjustments(&$result, $timezone, $upcase) { Application_Common_DateHelper::convertTimestampsToTimezone( $result, array("starts", "ends", "start_timestamp","end_timestamp"), $timezone ); - + //Convert the UTC scheduler time ("now") to the user-defined timezone. $result["station"]["schedulerTime"] = Application_Common_DateHelper::UTCStringToTimezoneString($result["station"]["schedulerTime"], $timezone); $result["station"]["timezone"] = $upcase ? strtoupper($timezone) : $timezone; } - + public function weekInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) { @@ -438,11 +462,11 @@ class ApiController extends Zend_Controller_Action exit; } } - + /** * API endpoint to display the show logo */ - public function showLogoAction() + public function showLogoAction() { // Disable the view and the layout $this->view->layout()->disableLayout(); @@ -459,7 +483,7 @@ class ApiController extends Zend_Controller_Action if (empty($show)) { throw new ZendActionHttpException($this, 400, "ERROR: No show with ID $showId exists."); } - + $path = $show->getDbImagePath(); try { $mime_type = mime_content_type($path); @@ -488,9 +512,9 @@ class ApiController extends Zend_Controller_Action header('HTTP/1.0 401 Unauthorized'); print _('You are not allowed to access this resource. '); exit; - } + } } - + /** * API endpoint to provide station metadata */ @@ -500,18 +524,18 @@ class ApiController extends Zend_Controller_Action // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - + $CC_CONFIG = Config::getConfig(); $baseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['baseDir']); $path = 'http://'.$_SERVER['HTTP_HOST'].$baseDir."api/station-logo"; - + $result["name"] = Application_Model_Preference::GetStationName(); $result["logo"] = $path; $result["description"] = Application_Model_Preference::GetStationDescription(); $result["timezone"] = Application_Model_Preference::GetDefaultTimezone(); $result["locale"] = Application_Model_Preference::GetDefaultLocale(); $result["stream_data"] = Application_Model_StreamSetting::getEnabledStreamData(); - + // used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; @@ -526,27 +550,27 @@ class ApiController extends Zend_Controller_Action /** * API endpoint to display the current station logo */ - public function stationLogoAction() + public function stationLogoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi() || $this->checkAuth()) { // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - + $logo = Application_Model_Preference::GetStationLogo(); // if there's no logo, just die - redirects to a 404 if (!$logo || $logo === '') { return; } - + // we're passing this as an image instead of using it in a data uri, so decode it $blob = base64_decode($logo); - + // use finfo to get the mimetype from the decoded blob $f = finfo_open(); $mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE); finfo_close($f); - + header("Content-Type: " . $mime_type); echo $blob; } else { @@ -555,7 +579,7 @@ class ApiController extends Zend_Controller_Action exit; } } - + public function scheduleAction() { $this->view->layout()->disableLayout(); @@ -571,13 +595,13 @@ class ApiController extends Zend_Controller_Action public function notifyMediaItemStartPlayAction() { $media_id = $this->_getParam("media_id"); - + // We send a fake media id when playing on-demand ads; // in this case, simply return if ($media_id === '0' || $media_id === '-1') { return; } - + Logging::debug("Received notification of new media item start: $media_id"); Application_Model_Schedule::UpdateMediaPlayedStatus($media_id); @@ -619,7 +643,7 @@ class ApiController extends Zend_Controller_Action $this->_helper->json->sendJson(array("status"=>1, "message"=>"")); } - + public function recordedShowsAction() { $utcTimezone = new DateTimeZone("UTC"); @@ -637,7 +661,7 @@ class ApiController extends Zend_Controller_Action $this->view->server_timezone = Application_Model_Preference::GetDefaultTimezone(); $rows = Application_Model_Show::getCurrentShow(); - + if (count($rows) > 0) { $this->view->is_recording = ($rows[0]['record'] == 1); } @@ -664,7 +688,7 @@ class ApiController extends Zend_Controller_Action try { $show_inst = new Application_Model_ShowInstance($show_instance_id); $show_inst->setRecordedFile($file_id); - } + } catch (Exception $e) { //we've reached here probably because the show was //cancelled, and therefore the show instance does not exist @@ -717,7 +741,7 @@ class ApiController extends Zend_Controller_Action if ($md['is_record'] != 0) { $this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId()); } - + } elseif ($mode == "modify") { $filepath = $md['MDATA_KEY_FILEPATH']; $file = Application_Model_StoredFile::RecallByFilepath($filepath, $con); @@ -830,7 +854,7 @@ class ApiController extends Zend_Controller_Action } catch (Exception $e) { Logging::warn($e->getMessage()); Logging::warn(gettype($e)); - } + } // We tack on the 'key' back to every request in case the would like to associate // his requests with particular responses $response['key'] = $k; @@ -1085,7 +1109,7 @@ class ApiController extends Zend_Controller_Action } elseif ($djtype == "dj") { //check against show dj auth $showInfo = Application_Model_Show::getCurrentShow(); - + // there is current playing show if (isset($showInfo[0]['id'])) { $current_show_id = $showInfo[0]['id']; @@ -1139,12 +1163,12 @@ class ApiController extends Zend_Controller_Action $this->_helper->json->sendJson($rows); } - + public function getFilesWithoutSilanValueAction() { //connect to db and get get sql $rows = Application_Model_StoredFile::getAllFilesWithoutSilan(); - + $this->_helper->json->sendJson($rows); } @@ -1163,7 +1187,7 @@ class ApiController extends Zend_Controller_Action $this->_helper->json->sendJson(array()); } - + public function updateCueValuesBySilanAction() { $request = $this->getRequest(); @@ -1213,12 +1237,12 @@ class ApiController extends Zend_Controller_Action $data = $request->getParam("data"); $media_id = intval($request->getParam("media_id")); $data_arr = json_decode($data); - + //$media_id is -1 sometimes when a stream has stopped playing if (!is_null($media_id) && $media_id > 0) { if (isset($data_arr->title)) { - + $data_title = substr($data_arr->title, 0, 1024); $previous_metadata = CcWebstreamMetadataQuery::create() @@ -1235,20 +1259,20 @@ class ApiController extends Zend_Controller_Action } if ($do_insert) { - + $startDT = new DateTime("now", new DateTimeZone("UTC")); - + $webstream_metadata = new CcWebstreamMetadata(); $webstream_metadata->setDbInstanceId($media_id); $webstream_metadata->setDbStartTime($startDT); $webstream_metadata->setDbLiquidsoapData($data_title); $webstream_metadata->save(); - + $historyService = new Application_Service_HistoryService(); $historyService->insertWebstreamMetadata($media_id, $startDT, $data_arr); } } - } + } $this->view->response = $data; $this->view->media_id = $media_id; @@ -1271,11 +1295,11 @@ class ApiController extends Zend_Controller_Action Application_Model_ListenerStat::insertDataPoints($data); $this->view->data = $data; } - + public function updateStreamSettingTableAction() { $request = $this->getRequest(); $data = json_decode($request->getParam("data"), true); - + foreach ($data as $k=>$v) { Application_Model_StreamSetting::SetListenerStatError($k, $v); } @@ -1317,9 +1341,9 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $params = $request->getParams(); $userId = $request->getParam("user_id", null); - + list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); - + $historyService = new Application_Service_HistoryService(); $shows = $historyService->getShowList($startsDT, $endsDT, $userId); @@ -1343,8 +1367,8 @@ class ApiController extends Zend_Controller_Action $params = $request->getParams(); $showId = $request->getParam("show_id", null); $results = array(); - - if (empty($showId)) { + + if (empty($showId)) { $shows = CcShowQuery::create()->find(); foreach($shows as $show) { $results[] = $show->getShowInfo(); @@ -1361,19 +1385,19 @@ class ApiController extends Zend_Controller_Action Logging::info($e->getMessage()); } } - + /** * display show schedule for given show_id * * @return json array */ - public function showSchedulesAction() + public function showSchedulesAction() { try { $request = $this->getRequest(); $params = $request->getParams(); $showId = $request->getParam("show_id", null); - + list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); if ((!isset($showId)) || (!is_numeric($showId))) { @@ -1382,7 +1406,7 @@ class ApiController extends Zend_Controller_Action array("jsonrpc" => "2.0", "error" => array("code" => 400, "message" => "missing invalid type for required show_id parameter. use type int.".$showId)) ); } - + $shows = Application_Model_Show::getShows($startsDT, $endsDT, FALSE, $showId); // is this a valid show? @@ -1400,7 +1424,7 @@ class ApiController extends Zend_Controller_Action } } - + /** * displays track listing for given instance_id * @@ -1421,7 +1445,7 @@ class ApiController extends Zend_Controller_Action $showInstance = new Application_Model_ShowInstance($instanceId); $showInstanceContent = $showInstance->getShowListContent($prefTimezone); - + // is this a valid show instance with content? if (empty($showInstanceContent)) { $this->_helper->json->sendJson( diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 7ec84ddef..aefad2114 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -364,6 +364,7 @@ class LibraryController extends Zend_Controller_Action { $user = Application_Model_User::getCurrentUser(); $isAdminOrPM = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + $isAdmin = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN)); $request = $this->getRequest(); @@ -380,6 +381,10 @@ class LibraryController extends Zend_Controller_Action $form->removeActionButtons(); $this->view->permissionDenied = true; } + // only admins should be able to edit the owner of a file + if (!$isAdmin) { + $form->removeOwnerEdit(); + } if ($request->isPost()) { diff --git a/airtime_mvc/application/controllers/LocaleController.php b/airtime_mvc/application/controllers/LocaleController.php index c20142f99..01810176c 100644 --- a/airtime_mvc/application/controllers/LocaleController.php +++ b/airtime_mvc/application/controllers/LocaleController.php @@ -63,6 +63,16 @@ final class LocaleController extends Zend_Controller_Action //"Adding 1 Item" => _("Adding 1 Item"), //"Adding %s Items" => _("Adding %s Items"), //library/library.js + "Add" => _("Add"), + "New" => _("New"), + "Edit" => _("Edit"), + "Add to Schedule" => _("Add to Schedule"), + "Add to next show" => _("Add to next show"), + "Add to current show" => _("Add to current show"), + "Add after selected items" => _("Add after selected items"), + "Delete" => _("Delete"), + "Publish" => _("Publish"), + "Remove" => _("Remove"), "Edit Metadata" => _("Edit Metadata"), "Add to selected show" => _("Add to selected show"), "Select" => _("Select"), @@ -108,6 +118,10 @@ final class LocaleController extends Zend_Controller_Action "Are you sure you want to delete the selected item?" => _("Are you sure you want to delete the selected item?"), "Uploading in progress..." => _("Uploading in progress..."), "Retrieving data from the server..." => _("Retrieving data from the server..."), + //library/podcast.js + "Import" => _("Import"), + "Imported?" => _("Imported?"), + "View" => _("View"), // SOUNDCLOUD "Are you sure? SoundCloud stats and comments for this track will be permanently removed." => "Are you sure? SoundCloud stats and comments for this track will be permanently removed.", "Your track is being deleted from SoundCloud" => "Your track is being deleted from SoundCloud", @@ -314,6 +328,7 @@ final class LocaleController extends Zend_Controller_Action "Trim overbooked shows" => _("Trim overbooked shows"), "Remove selected scheduled items" => _("Remove selected scheduled items"), "Jump to the current playing track" => _("Jump to the current playing track"), + "Jump to Current" => _("Jump to Current"), "Cancel current show" => _("Cancel current show"), //already in schedule/schedule.js //"Cancel Current Show?" => _("Cancel Current Show?"), @@ -355,6 +370,7 @@ final class LocaleController extends Zend_Controller_Action "View listener stats" => _("View listener stats"), //dataTables/ColVis.js "Show / hide columns" => _("Show / hide columns"), + "Columns" => _("Columns"), //datatables.columnFilter.js "From {from} to {to}" => _("From {from} to {to}"), "kbps" => _("kbps"), diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index c12a00153..8065b637d 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -58,11 +58,7 @@ class LoginController extends Zend_Controller_Action //Open the session for writing, because we close it for writing by default in Bootstrap.php as an optimization. //session_start(); - // if the post contains recaptcha field, which means form had recaptcha field. - // Hence add the element for validation. - if (array_key_exists('recaptcha_response_field', $request->getPost())) { - $form->addRecaptcha(); - } + if ($form->isValid($request->getPost())) { //get the username and password from the form $username = $form->getValue('username'); @@ -276,10 +272,6 @@ class LoginController extends Zend_Controller_Action Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']); $form = new Application_Form_Login(); $this->view->error = true; - //Only show the captcha if you get your login wrong 4 times in a row. - if (Application_Model_Subjects::getLoginAttempts($username) > 3) { - $form->addRecaptcha(); - } return $form; } } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 4c63d73e5..685bfd480 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -64,7 +64,7 @@ class PlaylistController extends Zend_Controller_Action $this->view->obj = $obj; $this->view->contents = $obj->getContents(); - if ($formIsValid) { + if ($formIsValid && $obj instanceof Application_Model_Block) { $this->view->poolCount = $obj->getListofFilesMeetCriteria()['count']; } $this->view->showPoolCount = true; diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 6c9b0bfd9..5c1baf132 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -47,6 +47,8 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetDefaultFadeOut($values["stationDefaultFadeOut"]); Application_Model_Preference::SetPodcastAlbumOverride($values["podcastAlbumOverride"]); Application_Model_Preference::SetPodcastAutoSmartblock($values["podcastAutoSmartblock"]); + Application_Model_Preference::SetIntroPlaylist($values["introPlaylistSelect"]); + Application_Model_Preference::SetOutroPlaylist($values["outroPlaylistSelect"]); Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]); Application_Model_Preference::SetAllowedCorsUrls($values["allowedCorsUrls"]); Application_Model_Preference::SetDefaultLocale($values["locale"]); @@ -110,47 +112,6 @@ class PreferenceController extends Zend_Controller_Action $this->_helper->json->sendJson(array("url" => $url)); } - public function supportSettingAction() - { - $CC_CONFIG = Config::getConfig(); - - $request = $this->getRequest(); - - $baseUrl = Application_Common_OsPath::getBaseDir(); - - $this->view->headScript()->appendFile($baseUrl.'js/airtime/preferences/support-setting.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->statusMsg = ""; - - SessionHelper::reopenSessionForWriting(); - - $form = new Application_Form_SupportSettings(); - if ($request->isPost()) { - $values = $request->getPost(); - if ($form->isValid($values)) { - Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); - Application_Model_Preference::SetPhone($values["Phone"]); - Application_Model_Preference::SetEmail($values["Email"]); - Application_Model_Preference::SetStationWebSite($values["StationWebSite"]); - - Application_Model_Preference::SetStationCountry($values["Country"]); - Application_Model_Preference::SetStationCity($values["City"]); - Application_Model_Preference::SetStationDescription($values["Description"]); - if (isset($values["Privacy"])) { - Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]); - } - } - $this->view->statusMsg = "
"._("Support setting updated.")."
"; - } - - $privacyChecked = false; - if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) { - $privacyChecked = true; - } - $this->view->privacyChecked = $privacyChecked; - $this->view->section_title = _('Support Feedback'); - $this->view->form = $form; - } - public function directoryConfigAction() { } diff --git a/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7.1/downgrade.sql b/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7.1/downgrade.sql new file mode 100644 index 000000000..eec397f70 --- /dev/null +++ b/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7.1/downgrade.sql @@ -0,0 +1,3 @@ +ALTER TABLE podcast_episodes DROP COLUMN IF EXISTS episode_title; +ALTER TABLE podcast_episodes DROP COLUMN IF EXISTS episode_description; + diff --git a/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7.2/downgrade.sql b/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7.2/downgrade.sql new file mode 100644 index 000000000..915be5e56 --- /dev/null +++ b/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7.2/downgrade.sql @@ -0,0 +1 @@ +ALTER TABLE cc_blockcriteria DROP COLUMN IF EXISTS criteriagroup; diff --git a/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7/downgrade.sql b/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7/downgrade.sql new file mode 100644 index 000000000..1f562169c --- /dev/null +++ b/airtime_mvc/application/controllers/downgrade_sql/airtime_3.0.0-alpha.7/downgrade.sql @@ -0,0 +1 @@ +ALTER TABLE cc_block ALTER COLUMN type SET DEFAULT 'static'; diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7.1/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7.1/upgrade.sql new file mode 100644 index 000000000..2615a0f92 --- /dev/null +++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7.1/upgrade.sql @@ -0,0 +1,3 @@ +ALTER TABLE podcast_episodes ADD COLUMN episode_title VARCHAR(4096); +ALTER TABLE podcast_episodes ADD COLUMN episode_description VARCHAR(4096); + diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7.2/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7.2/upgrade.sql new file mode 100644 index 000000000..a274478bf --- /dev/null +++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7.2/upgrade.sql @@ -0,0 +1 @@ +ALTER TABLE cc_blockcriteria ADD COLUMN criteriagroup integer; diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7/upgrade.sql new file mode 100644 index 000000000..08b362d0e --- /dev/null +++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_3.0.0-alpha.7/upgrade.sql @@ -0,0 +1 @@ +ALTER TABLE cc_block ALTER COLUMN type SET DEFAULT 'dynamic'; diff --git a/airtime_mvc/application/forms/AddShowAutoPlaylist.php b/airtime_mvc/application/forms/AddShowAutoPlaylist.php index bb4cead12..c987480b2 100644 --- a/airtime_mvc/application/forms/AddShowAutoPlaylist.php +++ b/airtime_mvc/application/forms/AddShowAutoPlaylist.php @@ -15,7 +15,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm // Add autoplaylist checkbox element $this->addElement('checkbox', 'add_show_has_autoplaylist', array( - 'label' => _('Auto Schedule Playlist ?'), + 'label' => _('Add Autoloading Playlist ?'), 'required' => false, 'class' => 'input_text', 'decorators' => array('ViewHelper') @@ -29,7 +29,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm $this->addElement($autoPlaylistSelect); // Add autoplaylist checkbox element $this->addElement('checkbox', 'add_show_autoplaylist_repeat', array( - 'label' => _('Repeat AutoPlaylist Until Show is Full ?'), + 'label' => _('Repeat Playlist Until Show is Full ?'), 'required' => false, 'class' => 'input_text', 'decorators' => array('ViewHelper') diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php index 3faa209bd..e4e6768f9 100644 --- a/airtime_mvc/application/forms/EditAudioMD.php +++ b/airtime_mvc/application/forms/EditAudioMD.php @@ -48,6 +48,21 @@ class Application_Form_EditAudioMD extends Zend_Form )); $this->addElement($album_title); + + // Add album field + $user_options = array(); + $users = Application_Model_User::getNonGuestUsers(); + + foreach ($users as $host) { + $user_options[$host['index']] = $host['label']; + } + + $owner_id = new Zend_Form_Element_Select('owner_id'); + $owner_id->class = 'input_text'; + $owner_id->setLabel(_('Owner:')); + $owner_id->setMultiOptions($user_options); + $this->addelement($owner_id); + // Description field $description = new Zend_Form_Element_Textarea('description'); $description->class = 'input_text'; @@ -244,6 +259,9 @@ class Application_Form_EditAudioMD extends Zend_Form } } + public function removeOwnerEdit() { + $this->removeElement('owner_id'); + } public function removeActionButtons() { $this->removeElement('editmdsave'); diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 924264751..ea7ca4658 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -101,14 +101,29 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm )); + // add intro playlist select here + $introPlaylistSelect = new Zend_Form_Element_Select("introPlaylistSelect"); + $introPlaylistSelect->setLabel(_("Intro Autoloading Playlist")); + $introPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true)); + $introPlaylistSelect->setValue(Application_Model_Preference::GetIntroPlaylist()); + $this->addElement($introPlaylistSelect); + + $outroPlaylistSelect = new Zend_Form_Element_Select("outroPlaylistSelect"); + $outroPlaylistSelect->setLabel(_("Outro Autoloading Playlist")); + $outroPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true)); + $outroPlaylistSelect->setValue(Application_Model_Preference::GetOutroPlaylist()); + $this->addElement($outroPlaylistSelect); + + + $podcast_album_override = new Zend_Form_Element_Radio('podcastAlbumOverride'); - $podcast_album_override->setLabel(_('Podcast Album Override')); + $podcast_album_override->setLabel(_('Overwrite Podcast Episode Metatags')); $podcast_album_override->setMultiOptions(array( _("Disabled"), _("Enabled"), )); $podcast_album_override->setValue(Application_Model_Preference::GetPodcastAlbumOverride()); - $podcast_album_override->setDescription(_('Enabling this means that podcast tracks will always contain the podcast name in their album field.')); + $podcast_album_override->setDescription(_('Enabling this feature will cause podcast episode tracks to have their Artist, Title, and Album metatags set from podcast feed values. Note that enabling this feature is recommended in order to ensure reliable scheduling of episodes via smartblocks.')); $podcast_album_override->setSeparator(' '); //No
between radio buttons $podcast_album_override->addDecorator('HtmlTag', array('tag' => 'dd', 'id'=>"podcastAlbumOverride-element", @@ -117,14 +132,13 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $this->addElement($podcast_album_override); $podcast_auto_smartblock = new Zend_Form_Element_Radio('podcastAutoSmartblock'); - $podcast_auto_smartblock->setLabel(_('Podcast Automatic Smartblock and Playlist')); + $podcast_auto_smartblock->setLabel(_('Generate a smartblock and a playlist upon creation of a new podcast')); $podcast_auto_smartblock->setMultiOptions(array( _("Disabled"), _("Enabled"), )); $podcast_auto_smartblock->setValue(Application_Model_Preference::GetPodcastAutoSmartblock()); - $podcast_auto_smartblock->setDescription(_('Enabling this means that a smartblock and playlist matching the newest track of a - podcast will be created when a new podcast is added. This depends upon the Podcast Album Override to work.')); + $podcast_auto_smartblock->setDescription(_('If this option is enabled, a new smartblock and playlist matching the newest track of a podcast will be generated immediately upon creation of a new podcast. Note that the "Overwrite Podcast Episode Metatags" feature must also be enabled in order for smartblocks to reliably find episodes.')); $podcast_auto_smartblock->setSeparator(' '); //No
between radio buttons $podcast_auto_smartblock->addDecorator('HtmlTag', array('tag' => 'dd', 'id'=>"podcastAutoSmartblock-element", @@ -135,14 +149,14 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm //TODO add and insert Podcast Smartblock and Playlist autogenerate options $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); - $third_party_api->setLabel(_('Public Airtime API')); + $third_party_api->setLabel(_('Public LibreTime API')); $third_party_api->setDescription(_('Required for embeddable schedule widget.')); $third_party_api->setMultiOptions(array( _("Disabled"), _("Enabled"), )); $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); - $third_party_api->setDescription(_('Enabling this feature will allow Airtime to provide schedule data + $third_party_api->setDescription(_('Enabling this feature will allow LibreTime to provide schedule data to external widgets that can be embedded in your website.')); $third_party_api->setSeparator(' '); //No
between radio buttons //$third_party_api->addDecorator(new Zend_Form_Decorator_Label(array('tag' => 'dd', 'class' => 'radio-inline-list'))); diff --git a/airtime_mvc/application/forms/Login.php b/airtime_mvc/application/forms/Login.php index fd99e0537..d9713852a 100644 --- a/airtime_mvc/application/forms/Login.php +++ b/airtime_mvc/application/forms/Login.php @@ -71,10 +71,6 @@ class Application_Form_Login extends Zend_Form "locale" => Application_Model_Locale::getUserLocale() )); - if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) { - $this->addRecaptcha(); - } - // Add the submit button $this->addElement('submit', 'submit', array( 'ignore' => true, @@ -87,26 +83,6 @@ class Application_Form_Login extends Zend_Form } - public function addRecaptcha() - { - $pubKey = '6Ld4JsISAAAAAIxUKT4IjjOGi3DHqdoH2zk6WkYG'; - $privKey = '6Ld4JsISAAAAAJynYlXdrE4hfTReTSxYFe5szdyv'; - - $params= array('ssl' => true); - $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey, $params); - - $captcha = new Zend_Form_Element_Captcha('captcha', - array( - 'label' => _('Type the characters you see in the picture below.'), - 'captcha' => 'ReCaptcha', - 'captchaOptions' => array( - 'captcha' => 'ReCaptcha', - 'service' => $recaptcha - ) - ) - ); - $this->addElement($captcha); - } /** * tests if a string starts with a given string diff --git a/airtime_mvc/application/forms/SmartBlockCriteria.php b/airtime_mvc/application/forms/SmartBlockCriteria.php index b83a6e208..135414fc6 100644 --- a/airtime_mvc/application/forms/SmartBlockCriteria.php +++ b/airtime_mvc/application/forms/SmartBlockCriteria.php @@ -159,7 +159,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $this->limitOptions = array( "hours" => _("hours"), "minutes" => _("minutes"), - "items" => _("items") + "items" => _("items"), + "remaining" => _("time remaining in show") ); } return $this->limitOptions; @@ -223,7 +224,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm { // load type $out = CcBlockQuery::create()->findPk($p_blockId); - if ($out->getDbType() == "static") { + if ($out->getDbType() == "dynamic") { $blockType = 0; } else { $blockType = 1; @@ -233,14 +234,16 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $spType->setLabel(_('Type:')) ->setDecorators(array('viewHelper')) ->setMultiOptions(array( - 'static' => _('Static'), - 'dynamic' => _('Dynamic') + 'dynamic' => _('Dynamic'), + 'static' => _('Static') + )) ->setValue($blockType); $this->addElement($spType); $bl = new Application_Model_Block($p_blockId); - $storedCrit = $bl->getCriteria(); + $storedCrit = $bl->getCriteriaGrouped(); + Logging::info($storedCrit); //need to convert criteria to be displayed in the user's timezone if there's some timestamp type. self::convertTimestamps($storedCrit["crit"]); @@ -261,181 +264,183 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm if (isset($storedCrit["crit"])) { $criteriaKeys = array_keys($storedCrit["crit"]); } + //the way the everything is currently built it setups 25 smartblock criteria forms and then disables them + //but this creates 29 elements $numElements = count($this->getCriteriaOptions()); // loop through once for each potential criteria option ie album, composer, track + // criteria from different groups are separated already by the getCriteriaGrouped call for ($i = 0; $i < $numElements; $i++) { $criteriaType = ""; // if there is a criteria found then count the number of rows for this specific criteria ie > 1 track title + // need to refactor this to maintain separation based upon criteria grouping if (isset($criteriaKeys[$i])) { + //Logging::info($criteriaKeys[$i]); + Logging::info($storedCrit["crit"][$criteriaKeys[$i]]); $critCount = count($storedCrit["crit"][$criteriaKeys[$i]]); } else { $critCount = 1; } + // the challenge is that we need to increment the element for a new group + // within the same criteria but not the reference point i in the array + // and for these secondary groups they will have a differe$storedCrit["crit"][$criteriaKeys[$i]]nt j reference point + // store the number of items with the same key in the ModRowMap + $modRowMap[$i] = $critCount; - // store the number of items with the same key in the ModRowMap - $modRowMap[$i] = $critCount; - - /* Loop through all criteria with the same field - * Ex: all criteria for 'Album' - */ - for ($j = 0; $j < $critCount; $j++) { - /****************** CRITERIA ***********/ - // hide the criteria drop down select on any rows after the first - if ($j > 0) { - $invisible = ' sp-invisible'; - } else { - $invisible = ''; - } - - $criteria = new Zend_Form_Element_Select("sp_criteria_field_".$i."_".$j); - $criteria->setAttrib('class', 'input_select sp_input_select'.$invisible) - ->setValue('Select criteria') - ->setDecorators(array('viewHelper')) - ->setMultiOptions($this->getCriteriaOptions()); - // if this isn't the first criteria and there isn't an entry for it already disable it - if ($i != 0 && !isset($criteriaKeys[$i])) { - $criteria->setAttrib('disabled', 'disabled'); - } - // add the numbering to the form ie the i loop for each specific criteria and - // the j loop starts at 0 and grows for each item matching the same criteria - // look up the criteria type using the criteriaTypes function from above based upon the criteria value - if (isset($criteriaKeys[$i])) { - $criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]]; - $criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); - } - $this->addElement($criteria); - - - /****************** MODIFIER ***********/ - // every element has an optional modifier dropdown select - - $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_".$i."_".$j); - $criteriaModifers->setValue('Select modifier') - ->setAttrib('class', 'input_select sp_input_select') - ->setDecorators(array('viewHelper')); - if ($i != 0 && !isset($criteriaKeys[$i])) { - $criteriaModifers->setAttrib('disabled', 'disabled'); - } - // determine the modifier based upon criteria type which is looked up based upon an array - if (isset($criteriaKeys[$i])) { - if ($criteriaType == "s") { - $criteriaModifers->setMultiOptions($this->getStringCriteriaOptions()); - } - elseif ($criteriaType == "d") { - $criteriaModifers->setMultiOptions($this->getDateTimeCriteriaOptions()); - } - else { - $criteriaModifers->setMultiOptions($this->getNumericCriteriaOptions()); - } - $criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]); - } else { - $criteriaModifers->setMultiOptions(array('0' => _('Select modifier'))); - } - $this->addElement($criteriaModifers); - - /****************** VALUE ***********/ - /* The challenge here is that datetime */ - $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_".$i."_".$j); - $criteriaValue->setAttrib('class', 'input_text sp_input_text') - ->setDecorators(array('viewHelper')); - if ($i != 0 && !isset($criteriaKeys[$i])) { - $criteriaValue->setAttrib('disabled', 'disabled'); - } - if (isset($criteriaKeys[$i])) { - /* - * Need to parse relative dates in a special way to populate select box down below - */ - // this is used below to test whether the datetime select should be shown or hidden - $relativeDateTime = false; - $modifierTest = (string)$storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]; - if(isset($criteriaType) && $criteriaType == "d" && - preg_match('/before|after|between/', $modifierTest) == 1) { - // set relativeDatetime boolean to true so that the datetime select is displayed below - $relativeDateTime = true; - // the criteria value will be a number followed by time unit and ago so set input to number part - $criteriaValue->setValue(filter_var($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"], FILTER_SANITIZE_NUMBER_INT)); + /* Loop through all criteria with the same field + * Ex: all criteria for 'Album' + */ + for ($j = 0; $j < $critCount; $j++) { + /****************** CRITERIA ***********/ + // hide the criteria drop down select on any rows after the first + if ($j > 0) { + $invisible = ' sp-invisible'; } else { - $criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); + $invisible = ''; } - } - $this->addElement($criteriaValue); - - /****************** DATETIME SELECT *************/ - $criteriaDatetimeSelect = new Zend_Form_Element_Select("sp_criteria_datetime_select_".$i."_".$j); - $criteriaDatetimeSelect->setAttrib('class','input_select sp_input_select') - ->setDecorators(array('viewHelper')); - if (isset($criteriaKeys[$i]) && $relativeDateTime) { - $criteriaDatetimeSelect->setAttrib('enabled', 'enabled'); - } - else { - $criteriaDatetimeSelect->setAttrib('disabled', 'disabled'); - } - // check if the value is stored and it is a relative datetime field - if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]) - && isset($criteriaType) && $criteriaType == "d" && - preg_match('/before|after|between/', $modifierTest) == 1) { - // need to remove any leading numbers stored in the database - $dateTimeSelectValue = preg_replace('/[0-9]+/', '', $storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); - // need to strip white from front and ago from the end to match with the value of the time unit select dropdown - $dateTimeSelectValue = trim(preg_replace('/\W\w+\s*(\W*)$/', '$1', $dateTimeSelectValue)); - $criteriaDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); - $criteriaDatetimeSelect->setValue($dateTimeSelectValue); - $criteriaDatetimeSelect->setAttrib('enabled', 'enabled'); - } - else { - $criteriaDatetimeSelect->setMultiOptions(array('0' => _('Select unit of time'))); - $criteriaDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); - - } - - $this->addElement($criteriaDatetimeSelect); - - /****************** EXTRA ***********/ - $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_".$i."_".$j); - $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') - ->setDecorators(array('viewHelper')); - if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { - // need to check if this is a relative date time value - if(isset($criteriaType) && $criteriaType == "d" && $modifierTest == 'between') { - // the criteria value will be a number followed by time unit and ago so set input to number part - $criteriaExtra->setValue(filter_var($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"], FILTER_SANITIZE_NUMBER_INT)); + $criteria = new Zend_Form_Element_Select("sp_criteria_field_" . $i . "_" . $j); + $criteria->setAttrib('class', 'input_select sp_input_select' . $invisible) + ->setValue('Select criteria') + ->setDecorators(array('viewHelper')) + ->setMultiOptions($this->getCriteriaOptions()); + // if this isn't the first criteria and there isn't an entry for it already disable it + if ($i != 0 && !isset($criteriaKeys[$i])) { + $criteria->setAttrib('disabled', 'disabled'); } - else { - $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); + // add the numbering to the form ie the i loop for each specific criteria and + // the j loop starts at 0 and grows for each item matching the same criteria + // look up the criteria type using the criteriaTypes function from above based upon the criteria value + if (isset($criteriaKeys[$i])) { + $criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]]; + $criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); } - $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); - } else { - $criteriaExtra->setAttrib('disabled', 'disabled'); - } - $this->addElement($criteriaExtra); - /****************** DATETIME SELECT EXTRA **********/ + $this->addElement($criteria); - $criteriaExtraDatetimeSelect = new Zend_Form_Element_Select("sp_criteria_extra_datetime_select_".$i."_".$j); - $criteriaExtraDatetimeSelect->setAttrib('class','input_select sp_input_select') - ->setDecorators(array('viewHelper')); - if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]) - && $modifierTest == 'between') { - // need to remove the leading numbers stored in the database - $extraDateTimeSelectValue = preg_replace('/[0-9]+/', '', $storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); - // need to strip white from front and ago from the end to match with the value of the time unit select dropdown - $extraDateTimeSelectValue = trim(preg_replace('/\W\w+\s*(\W*)$/', '$1', $extraDateTimeSelectValue)); - $criteriaExtraDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); - // Logging::info('THIS IS-'.$extraDateTimeSelectValue.'-IT'); - $criteriaExtraDatetimeSelect->setValue($extraDateTimeSelectValue); - $criteriaExtraDatetimeSelect->setAttrib('enabled', 'enabled'); + /****************** MODIFIER ***********/ + // every element has an optional modifier dropdown select - } else { - $criteriaExtraDatetimeSelect->setMultiOptions(array('0' => _('Select unit of time'))); - $criteriaExtraDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); - $criteriaExtraDatetimeSelect->setAttrib('disabled', 'disabled'); - } - $this->addElement($criteriaExtraDatetimeSelect); - }//for + $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_" . $i . "_" . $j); + $criteriaModifers->setValue('Select modifier') + ->setAttrib('class', 'input_select sp_input_select') + ->setDecorators(array('viewHelper')); + if ($i != 0 && !isset($criteriaKeys[$i])) { + $criteriaModifers->setAttrib('disabled', 'disabled'); + } + // determine the modifier based upon criteria type which is looked up based upon an array + if (isset($criteriaKeys[$i])) { + if ($criteriaType == "s") { + $criteriaModifers->setMultiOptions($this->getStringCriteriaOptions()); + } elseif ($criteriaType == "d") { + $criteriaModifers->setMultiOptions($this->getDateTimeCriteriaOptions()); + } else { + $criteriaModifers->setMultiOptions($this->getNumericCriteriaOptions()); + } + $criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]); + } else { + $criteriaModifers->setMultiOptions(array('0' => _('Select modifier'))); + } + $this->addElement($criteriaModifers); + /****************** VALUE ***********/ + /* The challenge here is that datetime */ + $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_" . $i . "_" . $j); + $criteriaValue->setAttrib('class', 'input_text sp_input_text') + ->setDecorators(array('viewHelper')); + if ($i != 0 && !isset($criteriaKeys[$i])) { + $criteriaValue->setAttrib('disabled', 'disabled'); + } + if (isset($criteriaKeys[$i])) { + /* + * Need to parse relative dates in a special way to populate select box down below + */ + // this is used below to test whether the datetime select should be shown or hidden + $relativeDateTime = false; + $modifierTest = (string)$storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]; + if (isset($criteriaType) && $criteriaType == "d" && + preg_match('/before|after|between/', $modifierTest) == 1) { + // set relativeDatetime boolean to true so that the datetime select is displayed below + $relativeDateTime = true; + // the criteria value will be a number followed by time unit and ago so set input to number part + $criteriaValue->setValue(filter_var($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"], FILTER_SANITIZE_NUMBER_INT)); + } else { + $criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); + } + } + $this->addElement($criteriaValue); + + + /****************** DATETIME SELECT *************/ + $criteriaDatetimeSelect = new Zend_Form_Element_Select("sp_criteria_datetime_select_" . $i . "_" . $j); + $criteriaDatetimeSelect->setAttrib('class', 'input_select sp_input_select') + ->setDecorators(array('viewHelper')); + if (isset($criteriaKeys[$i]) && $relativeDateTime) { + $criteriaDatetimeSelect->setAttrib('enabled', 'enabled'); + } else { + $criteriaDatetimeSelect->setAttrib('disabled', 'disabled'); + } + // check if the value is stored and it is a relative datetime field + if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]) + && isset($criteriaType) && $criteriaType == "d" && + preg_match('/before|after|between/', $modifierTest) == 1) { + // need to remove any leading numbers stored in the database + $dateTimeSelectValue = preg_replace('/[0-9]+/', '', $storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); + // need to strip white from front and ago from the end to match with the value of the time unit select dropdown + $dateTimeSelectValue = trim(preg_replace('/\W\w+\s*(\W*)$/', '$1', $dateTimeSelectValue)); + $criteriaDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); + $criteriaDatetimeSelect->setValue($dateTimeSelectValue); + $criteriaDatetimeSelect->setAttrib('enabled', 'enabled'); + } else { + $criteriaDatetimeSelect->setMultiOptions(array('0' => _('Select unit of time'))); + $criteriaDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); + + } + + $this->addElement($criteriaDatetimeSelect); + + /****************** EXTRA ***********/ + $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_" . $i . "_" . $j); + $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text') + ->setDecorators(array('viewHelper')); + if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { + // need to check if this is a relative date time value + if (isset($criteriaType) && $criteriaType == "d" && $modifierTest == 'between') { + // the criteria value will be a number followed by time unit and ago so set input to number part + $criteriaExtra->setValue(filter_var($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"], FILTER_SANITIZE_NUMBER_INT)); + } else { + $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); + } + $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); + } else { + $criteriaExtra->setAttrib('disabled', 'disabled'); + } + $this->addElement($criteriaExtra); + /****************** DATETIME SELECT EXTRA **********/ + + $criteriaExtraDatetimeSelect = new Zend_Form_Element_Select("sp_criteria_extra_datetime_select_" . $i . "_" . $j); + $criteriaExtraDatetimeSelect->setAttrib('class', 'input_select sp_input_select') + ->setDecorators(array('viewHelper')); + + if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]) + && $modifierTest == 'between') { + // need to remove the leading numbers stored in the database + $extraDateTimeSelectValue = preg_replace('/[0-9]+/', '', $storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); + // need to strip white from front and ago from the end to match with the value of the time unit select dropdown + $extraDateTimeSelectValue = trim(preg_replace('/\W\w+\s*(\W*)$/', '$1', $extraDateTimeSelectValue)); + $criteriaExtraDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); + // Logging::info('THIS IS-'.$extraDateTimeSelectValue.'-IT'); + $criteriaExtraDatetimeSelect->setValue($extraDateTimeSelectValue); + $criteriaExtraDatetimeSelect->setAttrib('enabled', 'enabled'); + + } else { + $criteriaExtraDatetimeSelect->setMultiOptions(array('0' => _('Select unit of time'))); + $criteriaExtraDatetimeSelect->setMultiOptions($this->getTimePeriodCriteriaOptions()); + $criteriaExtraDatetimeSelect->setAttrib('disabled', 'disabled'); + } + $this->addElement($criteriaExtraDatetimeSelect); + }//for }//for $repeatTracks = new Zend_Form_Element_Checkbox('sp_repeat_tracks'); @@ -446,6 +451,14 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm } $this->addElement($repeatTracks); + $overflowTracks = new Zend_Form_Element_Checkbox('sp_overflow_tracks'); + $overflowTracks->setDecorators(array('viewHelper')) + ->setLabel(_('Allow last track to exceed time limit:')); + if (isset($storedCrit["overflow_tracks"])) { + $overflowTracks->setChecked($storedCrit["overflow_tracks"]["value"] == 1); + } + $this->addElement($overflowTracks); + $sort = new Zend_Form_Element_Select('sp_sort_options'); $sort->setAttrib('class', 'sp_input_select') ->setDecorators(array('viewHelper')) @@ -477,25 +490,16 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $limitValue->setValue(1); } - //getting block content candidate count that meets criteria - $bl = new Application_Model_Block($p_blockId); - if ($p_isValid) { - $files = $bl->getListofFilesMeetCriteria(); - $showPoolCount = true; - } else { - $files = null; - $showPoolCount = false; - } $generate = new Zend_Form_Element_Button('generate_button'); $generate->setAttrib('class', 'sp-button btn'); $generate->setAttrib('title', _('Generate playlist content and save criteria')); $generate->setIgnore(true); if ($blockType == 0) { - $generate->setLabel(_('Generate')); + $generate->setLabel(_('Preview')); } else { - $generate->setLabel(_('Preview')); + $generate->setLabel(_('Generate')); } $generate->setDecorators(array('viewHelper')); $this->addElement($generate); @@ -510,7 +514,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm $this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/smart-block-criteria.phtml', "openOption"=> $openSmartBlockOption, - 'criteriasLength' => count($this->getCriteriaOptions()), 'modRowMap' => $modRowMap)) + 'criteriasLength' => $numElements, 'modRowMap' => $modRowMap)) )); } /* @@ -523,7 +527,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm public function preValidation($params) { $data = Application_Model_Block::organizeSmartPlaylistCriteria($params['data']); - // add elelments that needs to be added + // add elements that needs to be added // set multioption for modifier according to criteria_field $modRowMap = array(); if (!isset($data['criteria'])) { diff --git a/airtime_mvc/application/forms/SupportSettings.php b/airtime_mvc/application/forms/SupportSettings.php deleted file mode 100644 index e582f407b..000000000 --- a/airtime_mvc/application/forms/SupportSettings.php +++ /dev/null @@ -1,150 +0,0 @@ -setDecorators(array( - array('ViewScript', array('viewScript' => 'form/support-setting.phtml')), - array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false))) - ); - - //Station name - $this->addElement('text', 'stationName', array( - 'class' => 'input_text', - 'label' => _('Station Name'), - 'required' => true, - 'filters' => array('StringTrim'), - 'validators' => array($notEmptyValidator), - 'value' => Application_Model_Preference::GetStationName(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Phone number - $this->addElement('text', 'Phone', array( - 'class' => 'input_text', - 'label' => _('Phone:'), - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetPhone(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - //Email - $this->addElement('text', 'Email', array( - 'class' => 'input_text', - 'label' => _('Email:'), - 'required' => false, - 'filters' => array('StringTrim'), - 'value' => Application_Model_Preference::GetEmail(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Station Web Site - $this->addElement('text', 'StationWebSite', array( - 'label' => _('Station Web Site:'), - 'required' => false, - 'class' => 'input_text', - 'value' => Application_Model_Preference::GetStationWebSite(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // county list dropdown - $this->addElement('select', 'Country', array( - 'label' => _('Country:'), - 'required' => false, - 'value' => Application_Model_Preference::GetStationCountry(), - 'multiOptions' => $country_list, - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Station city - $this->addElement('text', 'City', array( - 'label' => _('City:'), - 'required' => false, - 'class' => 'input_text', - 'value' => Application_Model_Preference::GetStationCity(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Station Description - $description = new Zend_Form_Element_Textarea('Description'); - $description->class = 'input_text_area'; - $description->setLabel(_('Station Description:')) - ->setRequired(false) - ->setValue(Application_Model_Preference::GetStationDescription()) - ->setDecorators(array('ViewHelper')) - ->setAttrib('ROWS','2') - ->setAttrib('COLS','58'); - $this->addElement($description); - - //enable support feedback - $this->addElement('checkbox', 'SupportFeedback', array( - 'label' => _('Send support feedback'), - 'required' => false, - 'value' => Application_Model_Preference::GetSupportFeedback(), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // checkbox for publicise - $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise"); - $checkboxPublicise->setLabel(sprintf(_('Promote my station on %s'), COMPANY_SITE)) - ->setRequired(false) - ->setDecorators(array('ViewHelper')) - ->setValue(Application_Model_Preference::GetPublicise()); - if (Application_Model_Preference::GetSupportFeedback() == '0') { - $checkboxPublicise->setAttrib("disabled", "disabled"); - } - $this->addElement($checkboxPublicise); - - // checkbox for privacy policy - $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy"); - $checkboxPrivacy->setLabel( - sprintf(_('By checking this box, I agree to %s\'s %sprivacy policy%s.'), - COMPANY_NAME, - $privacyPolicyAnchorOpen, - "")) - ->setDecorators(array('ViewHelper')); - $this->addElement($checkboxPrivacy); - - // submit button - $submit = new Zend_Form_Element_Submit("submit"); - $submit->class = 'btn right-floated'; - $submit->setIgnore(true) - ->setLabel(_("Save")) - ->setDecorators(array('ViewHelper')); - $this->addElement($submit); - } - - // overriding isValid function - public function isValid ($data) - { - $isValid = parent::isValid($data); - if (isset($data["Privacy"])) { - $checkPrivacy = $this->getElement('Privacy'); - if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") { - $checkPrivacy->addError(_("You have to agree to privacy policy.")); - $isValid = false; - } - } - - return $isValid; - } -} diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index 37bc92341..e08e925f1 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -361,10 +361,12 @@ SQL; { $result = CcBlockcriteriaQuery::create()->filterByDbBlockId($this->id) ->filterByDbCriteria('limit')->findOne(); - $modifier = $result->getDbModifier(); - $value = $result->getDbValue(); + if ($result) { + $modifier = $result->getDbModifier(); + $value = $result->getDbValue(); + return array($value, $modifier); + } - return array($value, $modifier); } // this function returns sum of all track length under this block. @@ -1158,7 +1160,7 @@ SQL; { $data = $this->organizeSmartPlaylistCriteria($p_criteria); // saving dynamic/static flag - $blockType = $data['etc']['sp_type'] == 0 ? 'static':'dynamic'; + $blockType = $data['etc']['sp_type'] == 0 ? 'dynamic':'static'; $this->saveType($blockType); $this->storeCriteriaIntoDb($data); @@ -1196,8 +1198,11 @@ SQL; if (isset($p_criteriaData['criteria'])) { $critKeys = array_keys($p_criteriaData['criteria']); for ($i = 0; $i < count($critKeys); $i++) { + // in order to maintain separation of different criteria to preserve AND statements for criteria + // that might contradict itself we group them based upon their original position on the form + $criteriaGroup = $i; foreach ($p_criteriaData['criteria'][$critKeys[$i]] as $d) { - // Logging::info($d); + Logging::info($d); $field = $d['sp_criteria_field']; $value = $d['sp_criteria_value']; $modifier = $d['sp_criteria_modifier']; @@ -1238,6 +1243,11 @@ SQL; $qry->setDbExtra($extra); } + // save the criteria group so separation via new modifiers AND can be preserved vs. lumping + // them all into a single or later on + if (isset($criteriaGroup)) { + $qry->setDbCriteriaGroup($criteriaGroup); + } $qry->save(); } } @@ -1262,13 +1272,22 @@ SQL; ->save(); - // insert repeate track option + // insert repeat track option $qry = new CcBlockcriteria(); $qry->setDbCriteria("repeat_tracks") ->setDbModifier("N/A") ->setDbValue($p_criteriaData['etc']['sp_repeat_tracks']) ->setDbBlockId($this->id) ->save(); + + // insert overflow track option + $qry = new CcBlockcriteria(); + $qry->setDbCriteria("overflow_tracks") + ->setDbModifier("N/A") + ->setDbValue($p_criteriaData['etc']['sp_overflow_tracks']) + ->setDbBlockId($this->id) + ->save(); + } /** @@ -1310,12 +1329,17 @@ SQL; } } - public function getListOfFilesUnderLimit() + /* + * + */ + + public function getListOfFilesUnderLimit($show = null) { - $info = $this->getListofFilesMeetCriteria(); + $info = $this->getListofFilesMeetCriteria($show); $files = $info['files']; $limit = $info['limit']; $repeat = $info['repeat_tracks']; + $overflow = $info['overflow_tracks']; $insertList = array(); $totalTime = 0; @@ -1332,17 +1356,27 @@ SQL; $id = $iterator->current()->getDbId(); $fileLength = $iterator->current()->getCueLength(); $length = Application_Common_DateHelper::calculateLengthInSeconds($fileLength); - // need to check to determine if the track will make the playlist exceed the totalTime before adding it - // this can be quite processor consuming so as a workaround I used the totalItems limit to prevent the - // algorithm from parsing too many items. - $projectedTime = $totalTime + $length; - if ($projectedTime > $limit['time']) { - $totalItems++; - } - else { + // if the block is setup to allow the overflow of tracks this will add the next track even if it becomes + // longer than the time limit + if ($overflow == 1) { $insertList[] = array('id' => $id, 'length' => $length); $totalTime += $length; $totalItems++; + } + // otherwise we need to check to determine if the track will make the playlist exceed the totalTime before + // adding it this could loop through a lot of tracks so I used the totalItems limit to prevent + // the algorithm from parsing too many items. + + else { + $projectedTime = $totalTime + $length; + if ($projectedTime > $limit['time']) { + $totalItems++; + } + else { + $insertList[] = array('id' => $id, 'length' => $length); + $totalTime += $length; + $totalItems++; + } } if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) { $isBlockFull = true; @@ -1355,14 +1389,30 @@ SQL; $sizeOfInsert = count($insertList); // if block is not full and repeat_track is check, fill up more + // additionally still don't overflow the limit while (!$isBlockFull && $repeat == 1 && $sizeOfInsert > 0) { Logging::debug("adding repeated tracks."); Logging::debug("total time = " . $totalTime); $randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert)); - $insertList[] = $insertList[$randomEleKey]; - $totalTime += $insertList[$randomEleKey]['length']; - $totalItems++; + // this will also allow the overflow of tracks so that time limited smart blocks will schedule until they + // are longer than the time limit rather than never scheduling past the time limit + if ($overflow == 1) { + $insertList[] = $insertList[$randomEleKey]; + $totalTime += $insertList[$randomEleKey]['length']; + $totalItems++; + } + else { + $projectedTime = $totalTime + $insertList[$randomEleKey]['length']; + if ($projectedTime > $limit['time']) { + $totalItems++; + } + else { + $insertList[] = $insertList[$randomEleKey]; + $totalTime += $insertList[$randomEleKey]['length']; + $totalItems++; + } + } if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) { break; @@ -1439,8 +1489,9 @@ SQL; foreach ($out as $crit) { $criteria = $crit->getDbCriteria(); $modifier = $crit->getDbModifier(); - $value = htmlspecialchars($crit->getDbValue()); + $value = $crit->getDbValue(); $extra = $crit->getDbExtra(); + $criteriagroup = $crit->getDbCriteriaGroup(); if ($criteria == "limit") { $storedCrit["limit"] = array( @@ -1449,6 +1500,8 @@ SQL; "display_modifier"=>_($modifier)); } else if($criteria == "repeat_tracks") { $storedCrit["repeat_tracks"] = array("value"=>$value); + } else if($criteria == "overflow_tracks") { + $storedCrit["overflow_tracks"] = array("value"=>$value); } else if($criteria == "sort") { $storedCrit["sort"] = array("value"=>$value); } else { @@ -1457,6 +1510,7 @@ SQL; "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, + "criteria_group"=>$criteriagroup, "display_name"=>$criteriaOptions[$criteria], "display_modifier"=>$modifierOptions[$modifier]); } @@ -1466,18 +1520,128 @@ SQL; } + /** + * Parses each row in the database for the criteria associated with this block and renders human readable labels. + * Returns it as an array with each criteria_name and modifier_name added based upon options array lookup. + * Maintains original separation of similar criteria that were separated by and statements + * + */ + + + public function getCriteriaGrouped() + { + $criteriaOptions = array( + 0 => _("Select criteria"), + "album_title" => _("Album"), + "bit_rate" => _("Bit Rate (Kbps)"), + "bpm" => _("BPM"), + "composer" => _("Composer"), + "conductor" => _("Conductor"), + "copyright" => _("Copyright"), + "cuein" => _("Cue In"), + "cueout" => _("Cue Out"), + "description" => _("Description"), + "artist_name" => _("Creator"), + "encoded_by" => _("Encoded By"), + "genre" => _("Genre"), + "isrc_number" => _("ISRC"), + "label" => _("Label"), + "language" => _("Language"), + "utime" => _("Upload Time"), + "mtime" => _("Last Modified"), + "lptime" => _("Last Played"), + "length" => _("Length"), + "mime" => _("Mime"), + "mood" => _("Mood"), + "owner_id" => _("Owner"), + "replay_gain" => _("Replay Gain"), + "sample_rate" => _("Sample Rate (kHz)"), + "track_title" => _("Title"), + "track_number" => _("Track Number"), + "utime" => _("Uploaded"), + "info_url" => _("Website"), + "year" => _("Year") + ); + + $modifierOptions = array( + "0" => _("Select modifier"), + "contains" => _("contains"), + "does not contain" => _("does not contain"), + "is" => _("is"), + "is not" => _("is not"), + "starts with" => _("starts with"), + "ends with" => _("ends with"), + "before" => _("before"), + "after" => _("after"), + "between" => _("between"), + "is" => _("is"), + "is not" => _("is not"), + "is greater than" => _("is greater than"), + "is less than" => _("is less than"), + "is in the range" => _("is in the range") + ); + + // Load criteria from db + $out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($this->id); + $storedCrit = array(); + + foreach ($out as $crit) { + Logging::info($crit); + $criteria = $crit->getDbCriteria(); + $modifier = $crit->getDbModifier(); + $value = $crit->getDbValue(); + $extra = $crit->getDbExtra(); + $criteriagroup = $crit->getDbCriteriaGroup(); + + if ($criteria == "limit") { + $storedCrit["limit"] = array( + "value"=>$value, + "modifier"=>$modifier, + "display_modifier"=>_($modifier)); + } else if($criteria == "repeat_tracks") { + $storedCrit["repeat_tracks"] = array("value"=>$value); + } else if($criteria == "overflow_tracks") { + $storedCrit["overflow_tracks"] = array("value"=>$value); + } else if($criteria == "sort") { + $storedCrit["sort"] = array("value"=>$value); + } else { + $storedCrit["crit"][$criteria . $criteriagroup][] = array( + "criteria"=>$criteria, + "value"=>$value, + "modifier"=>$modifier, + "extra"=>$extra, + "display_name"=>$criteriaOptions[$criteria], + "display_modifier"=>$modifierOptions[$modifier]); + } + } + + Logging::info($storedCrit); + return $storedCrit; + + } + + // this function return list of propel object - public function getListofFilesMeetCriteria() + public function getListofFilesMeetCriteria($show = null) { $storedCrit = $this->getCriteria(); $qry = CcFilesQuery::create(); $qry->useFkOwnerQuery("subj", "left join"); + //Logging::info($storedCrit); if (isset($storedCrit["crit"])) { foreach ($storedCrit["crit"] as $crit) { $i = 0; + $prevgroup = null; + $group = null; + // now we need to sort based upon extra which contains the and grouping from the form + usort($crit, function($a, $b) { + return $a['criteria_group'] - $b['criteria_group']; + }); + // we need to run the following loop separately for each criteria group inside of each array foreach ($crit as $criteria) { + $group = $criteria['criteria_group']; $spCriteria = $criteria['criteria']; $spCriteriaModifier = $criteria['modifier']; @@ -1494,9 +1658,9 @@ SQL; } elseif ($spCriteria == "bit_rate" || $spCriteria == 'sample_rate') { // multiply 1000 because we store only number value // e.g 192kps is stored as 192000 - $spCriteriaValue = $criteria['value']*1000; + $spCriteriaValue = $criteria['value'] * 1000; if (isset($criteria['extra'])) { - $spCriteriaExtra = $criteria['extra']*1000; + $spCriteriaExtra = $criteria['extra'] * 1000; } /* * If user is searching for an exact match of length we need to @@ -1520,7 +1684,6 @@ SQL; } else { $spCriteriaValue = ($criteria['value']); } - $spCriteriaExtra = $criteria['extra']; } @@ -1555,25 +1718,38 @@ SQL; // Logging::info($tdt); $spCriteriaValue = "$spCriteria >= '$fdt' AND $spCriteria <= '$tdt'"; } + // logging::info('before'); + // logging::info($spCriteriaModifier); $spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier]; + // logging::info('after'); + // logging::info($spCriteriaModifier); + try { if ($spCriteria == "owner_id") { $spCriteria = "subj.login"; } - if ($i > 0) { + Logging::info($i); + Logging::info($group); + Logging::info($prevgroup); + if ($i > 0 && $prevgroup == $group) { + Logging::info('adding or'); $qry->addOr($spCriteria, $spCriteriaValue, $spCriteriaModifier); } else { - $qry->add($spCriteria, $spCriteriaValue, $spCriteriaModifier); + Logging::info('adding and'); + $qry->addAnd($spCriteria, $spCriteriaValue, $spCriteriaModifier); } - + // only add this NOT LIKE null if you aren't also matching on another criteria + if ($i == 0) { if ($spCriteriaModifier == Criteria::NOT_ILIKE || $spCriteriaModifier == Criteria::NOT_EQUAL) { $qry->addOr($spCriteria, null, Criteria::ISNULL); } + } } catch (Exception $e) { Logging::info($e); } + $prevgroup = $group; $i++; } } @@ -1600,11 +1776,21 @@ SQL; // construct limit restriction $limits = array(); - if (isset($storedCrit['limit'])) { if ($storedCrit['limit']['modifier'] == "items") { $limits['time'] = 1440 * 60; $limits['items'] = $storedCrit['limit']['value']; + } elseif (($storedCrit['limit']['modifier'] == "remaining") ){ + // show will be null unless being called inside a show instance + if (!(is_null($show))) { + $showInstance = new Application_Model_ShowInstance($show); + $limits['time'] = $showInstance->getSecondsRemaining(); + $limits['items'] = null; + } + else { + $limits['time'] = 60 * 60; + $limits['items'] = null; + } } else { $limits['time'] = $storedCrit['limit']['modifier'] == "hours" ? intval(floatval($storedCrit['limit']['value']) * 60 * 60) : @@ -1614,20 +1800,30 @@ SQL; } $repeatTracks = 0; + $overflowTracks = 0; + if (isset($storedCrit['repeat_tracks'])) { $repeatTracks = $storedCrit['repeat_tracks']['value']; } - + + if (isset($storedCrit['overflow_tracks'])) { + $overflowTracks = $storedCrit['overflow_tracks']['value']; + } + + try { $out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); + Logging::info($qry->toString()); - return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "count"=>$out->count()); + return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "overflow_tracks"=> $overflowTracks, "count"=>$out->count()); } catch (Exception $e) { Logging::info($e); } + } public static function organizeSmartPlaylistCriteria($p_criteria) - { + { + Logging::info($p_criteria); $fieldNames = array('sp_criteria_field', 'sp_criteria_modifier', 'sp_criteria_value', 'sp_criteria_extra', 'sp_criteria_datetime_select', 'sp_criteria_extra_datetime_select'); $output = array(); foreach ($p_criteria as $ele) { @@ -1666,7 +1862,7 @@ SQL; $output['etc'][$ele['name']] = $ele['value']; } } - + Logging::info($output); return $output; } public static function getAllBlockFiles() diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 4dee92700..14dae59c4 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -387,6 +387,26 @@ class Application_Model_Preference return $val === '1' ? true : false; } + public static function GetIntroPlaylist() + { + return self::getValue("intro_playlist"); + } + + public static function GetOutroPlaylist() + { + return self::getValue("outro_playlist"); + } + + + public static function SetIntroPlaylist($playlist) + { + self::setValue("intro_playlist", $playlist); + } + + public static function SetOutroPlaylist($playlist) + { + self::setValue("outro_playlist", $playlist); + } public static function SetPhone($phone) { @@ -909,13 +929,13 @@ class Application_Model_Preference $versions[] = $item->get_title(); } $latest = $versions; - self::setValue('latest_version', json_encode($latest)); self::setValue('latest_version_nextcheck', strtotime('+1 week')); if (empty($latest)) { - return $config['airtime_version']; - } else { - return $latest; + return array($config['airtime_version']); } + + self::setValue('latest_version', json_encode($latest)); + return $latest; } public static function SetLatestVersion($version) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index e74fc1563..2386afc56 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -104,7 +104,7 @@ SQL; $utcNow = new DateTime("now", new DateTimeZone("UTC")); $shows = Application_Model_Show::getPrevCurrentNext($utcNow, $utcTimeEnd, $showsToRetrieve); - $currentShowID = count($shows['currentShow'])>0?$shows['currentShow']['instance_id']:null; + $currentShowID = (is_array($shows['currentShow'] && count($shows['currentShow'])>0))?$shows['currentShow']['instance_id']:null; $source = self::_getSource(); $results = Application_Model_Schedule::getPreviousCurrentNextMedia($utcNow, $currentShowID, self::_getSource()); diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index cf542dce5..3d8eb1185 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -207,13 +207,13 @@ final class Application_Model_Scheduler /* * @param $id * @param $type + * @param $show * * @return $files */ - private function retrieveMediaFiles($id, $type) + private function retrieveMediaFiles($id, $type, $show) { $files = array(); - if ($type === "audioclip") { $file = CcFilesQuery::create()->findPK($id, $this->con); @@ -278,7 +278,7 @@ final class Application_Model_Scheduler } else { $defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn(); $defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut(); - $dynamicFiles = $bl->getListOfFilesUnderLimit(); + $dynamicFiles = $bl->getListOfFilesUnderLimit($show); foreach ($dynamicFiles as $f) { $fileId = $f['id']; $file = CcFilesQuery::create()->findPk($fileId); @@ -337,7 +337,7 @@ final class Application_Model_Scheduler } else { $defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn(); $defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut(); - $dynamicFiles = $bl->getListOfFilesUnderLimit(); + $dynamicFiles = $bl->getListOfFilesUnderLimit($show); foreach ($dynamicFiles as $f) { $fileId = $f['id']; $file = CcFilesQuery::create()->findPk($fileId); @@ -788,11 +788,14 @@ final class Application_Model_Scheduler Logging::debug(floatval($pend) - floatval($pstart)); } + // passing $schedule["instance"] so that the instance being scheduled + // can be used to determine the remaining time + // in the case of a fill remaining time smart block if (is_null($filesToInsert)) { $filesToInsert = array(); foreach ($mediaItems as $media) { $filesToInsert = array_merge($filesToInsert, - $this->retrieveMediaFiles($media["id"], $media["type"])); + $this->retrieveMediaFiles($media["id"], $media["type"], $schedule["instance"])); } } @@ -855,8 +858,14 @@ final class Application_Model_Scheduler // default fades are in seconds // we need to convert to '00:00:00' format - $file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']); - $file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']); + // added a check to only run the conversion if they are in seconds format + // otherwise php > 7.1 throws errors + if (is_numeric($file['fadein'])) { + $file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']); + } + if (is_numeric($file['fadeout'])) { + $file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']); + } switch ($file["type"]) { case 0: diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 3dddf80c8..1cb7e8057 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -242,9 +242,30 @@ SQL; array(array("id" => $lastid, "instance" => $id, "timestamp" => $ts)), array(array("id" => $pl_id, "type" => "playlist")) ); + // doing this to update the database schedule so that subsequent adds will work. + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); + $this->_showInstance->updateScheduleStatus($con); } - + /** + * Add a playlist as the first item of the current show. + * + * @param int $plId + * Playlist ID. + */ + public function addPlaylistToShowStart($pl_id, $checkUserPerm = true) + { + $ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0; + $id = $this->_showInstance->getDbId(); + $scheduler = new Application_Model_Scheduler($checkUserPerm); + $scheduler->scheduleAfter( + array(array("id" => 0, "instance" => $id, "timestamp" => $ts)), + array(array("id" => $pl_id, "type" => "playlist")) + ); + // doing this to update the database schedule so that subsequent adds will work. + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); + $this->_showInstance->updateScheduleStatus($con); + } /** @@ -476,6 +497,12 @@ SQL; return intval($ends->format('U')) - intval($starts->format('U')); } + // should return the amount of seconds remaining to be scheduled in a show instance + public function getSecondsRemaining() + { + return ($this->getDurationSecs() - $this->getTimeScheduledSecs()); + } + public function getPercentScheduled() { $durationSeconds = $this->getDurationSecs(); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 819df76b4..25d692c12 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -172,39 +172,36 @@ class Application_Model_StoredFile $this->_file->$method(null); } } else { - $owner = $this->_file->getFkOwner(); - // if owner_id is already set we don't want to set it again. - if (!$owner) { // no owner detected, we try to assign one. - // if MDATA_OWNER_ID is not set then we default to the - // first admin user we find - if (!array_key_exists('owner_id', $p_md)) { - //$admins = Application_Model_User::getUsers(array('A')); - $admins = array_merge(Application_Model_User::getUsersOfType('A')->getData(), - Application_Model_User::getUsersOfType('S')->getData()); - if (count($admins) > 0) { // found admin => pick first one - $owner = $admins[0]; + // in order to edit the owner of a file we see if owner_id exists in the track form metadata otherwise + // we determine it via the algorithm below + if (!array_key_exists('owner_id', $p_md)) { + $owner = $this->_file->getFkOwner(); + // if owner_id is already set we don't want to set it again. + if (!$owner) { // no owner detected, we try to assign one. + // if MDATA_OWNER_ID is not set then we default to the + // first admin user we find + if (!array_key_exists('owner_id', $p_md)) { + //$admins = Application_Model_User::getUsers(array('A')); + $admins = array_merge(Application_Model_User::getUsersOfType('A')->getData(), + Application_Model_User::getUsersOfType('S')->getData()); + if (count($admins) > 0) { // found admin => pick first one + $owner = $admins[0]; + } + } // get the user by id and set it like that + else { + $user = CcSubjsQuery::create() + ->findPk($p_md['owner_id']); + if ($user) { + $owner = $user; + } + } + if ($owner) { + $this->_file->setDbOwnerId($owner->getDbId()); + } else { + Logging::info("Could not find suitable owner for file + '" . $p_md['filepath'] . "'"); } } - // get the user by id and set it like that - else { - $user = CcSubjsQuery::create() - ->findPk($p_md['owner_id']); - if ($user) { - $owner = $user; - } - } - if ($owner) { - $this->_file->setDbOwnerId( $owner->getDbId() ); - } else { - Logging::info("Could not find suitable owner for file - '".$p_md['filepath']."'"); - } - } - # We don't want to process owner_id in bulk because we already - # processed it in the code above. This is done because owner_id - # needs special handling - if (array_key_exists('owner_id', $p_md)) { - unset($p_md['owner_id']); } foreach ($p_md as $dbColumn => $mdValue) { // don't blank out name, defaults to original filename on first diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 0b105e125..6f39d01d6 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -325,6 +325,11 @@ class Application_Model_User return Application_Model_User::getUsers(array('H'), $search); } + public static function getNonGuestUsers($search=null) + { + return Application_Model_User::getUsers(array('H','A','S','P'), $search); + } + public static function getUsersDataTablesInfo($datatables) { diff --git a/airtime_mvc/application/models/airtime/ImportedPodcast.php.bak b/airtime_mvc/application/models/airtime/ImportedPodcast.php.bak deleted file mode 100644 index fa4804f38..000000000 --- a/airtime_mvc/application/models/airtime/ImportedPodcast.php.bak +++ /dev/null @@ -1,251 +0,0 @@ -get_title(); - $podcastArray["description"] = $rss->get_description(); - $podcastArray["link"] = $rss->get_link(); - $podcastArray["language"] = $rss->get_language(); - $podcastArray["copyright"] = $rss->get_copyright(); - $podcastArray["creator"] = $rss->get_author()->get_name(); - $podcastArray["category"] = $rss->get_categories(); - - $itunesChannel = "http://www.itunes.com/dtds/podcast-1.0.dtd"; - - $itunesSubtitle = $rss->get_channel_tags($itunesChannel, 'subtitle'); - $podcastArray["itunes_subtitle"] = isset($itunesSubtitle[0]["data"]) ? $itunesSubtitle[0]["data"] : ""; - - $itunesCategory = $rss->get_channel_tags($itunesChannel, 'category'); - $categoryArray = array(); - foreach ($itunesCategory as $c => $data) { - foreach ($data["attribs"] as $attrib) { - array_push($categoryArray, $attrib["text"]); - } - } - $podcastArray["itunes_category"] = implode(",", $categoryArray); - - $itunesAuthor = $rss->get_channel_tags($itunesChannel, 'author'); - $podcastArray["itunes_author"] = isset($itunesAuthor[0]["data"]) ? $itunesAuthor[0]["data"] : ""; - - $itunesSummary = $rss->get_channel_tags($itunesChannel, 'summary'); - $podcastArray["itunes_summary"] = isset($itunesSummary[0]["data"]) ? $itunesSummary[0]["data"] : ""; - - $itunesKeywords = $rss->get_channel_tags($itunesChannel, 'keywords'); - $podcastArray["itunes_keywords"] = isset($itunesKeywords[0]["data"]) ? $itunesKeywords[0]["data"] : ""; - - $itunesExplicit = $rss->get_channel_tags($itunesChannel, 'explicit'); - $podcastArray["itunes_explicit"] = isset($itunesExplicit[0]["data"]) ? $itunesExplicit[0]["data"] : ""; - - self::validatePodcastMetadata($podcastArray); - - try { - $podcast = new ImportedPodcast(); - $podcast->fromArray($podcastArray, BasePeer::TYPE_FIELDNAME); - $podcast->setDbOwner(self::getOwnerId()); - $podcast->setDbType(IMPORTED_PODCAST); - $podcast->save(); - - return self::_generatePodcastArray($podcast, $rss); - } catch(Exception $e) { - $podcast->delete(); - throw $e; - } - } - - /** - * Fetches a Podcast's rss feed and returns all its episodes with - * the Podcast object - * - * @param $podcastId - * - * @throws PodcastNotFoundException - * @throws InvalidPodcastException - * @return array - Podcast Array with a full list of episodes - */ - public static function getPodcastById($podcastId) - { - $podcast = PodcastQuery::create()->findPk($podcastId); - if (!$podcast) { - throw new PodcastNotFoundException(); - } - - $rss = Application_Service_PodcastService::getPodcastFeed($podcast->getDbUrl()); - if (!$rss) { - throw new InvalidPodcastException(); - } - - return self::_generatePodcastArray($podcast, $rss); - } - - /** - * Given a podcast object and a SimplePie feed object, - * generate a data array to pass back to the front-end - * - * @param Podcast $podcast Podcast model object - * @param SimplePie $rss SimplePie feed object - * - * @return array - */ - private static function _generatePodcastArray($podcast, $rss) { - $podcastArray = $podcast->toArray(BasePeer::TYPE_FIELDNAME); - - $podcastArray["episodes"] = array(); - foreach ($rss->get_items() as $item) { - /** @var SimplePie_Item $item */ - array_push($podcastArray["episodes"], array( - "guid" => $item->get_id(), - "title" => $item->get_title(), - "author" => $item->get_author()->get_name(), - "description" => $item->get_description(), - "pub_date" => $item->get_date("Y-m-d H:i:s"), - "link" => $item->get_link(), - "enclosure" => $item->get_enclosure() - )); - } - - return $podcastArray; - } - - /** - * Updates a Podcast object with the given metadata - * - * @param $podcastId - * @param $data - * @return array - * @throws Exception - * @throws PodcastNotFoundException - */ - public static function updateFromArray($podcastId, $data) - { - $podcast = PodcastQuery::create()->findPk($podcastId); - if (!$podcast) { - throw new PodcastNotFoundException(); - } - - self::removePrivateFields($data); - self::validatePodcastMetadata($data); - - $podcast->fromArray($data, BasePeer::TYPE_FIELDNAME); - $podcast->save(); - - return $podcast->toArray(BasePeer::TYPE_FIELDNAME); - } - - /** - * Deletes a Podcast and its podcast episodes - * - * @param $podcastId - * @throws Exception - * @throws PodcastNotFoundException - */ - public static function deleteById($podcastId) - { - $podcast = PodcastQuery::create()->findPk($podcastId); - if ($podcast) { - $podcast->delete(); - } else { - throw new PodcastNotFoundException(); - } - } - - /** - * Trims the podcast metadata to fit the table's column max size - * - * @param $podcastArray - */ - private static function validatePodcastMetadata(&$podcastArray) - { - $podcastTable = PodcastPeer::getTableMap(); - - foreach ($podcastArray as $key => &$value) { - try { - // Make sure column exists in table - $columnMaxSize = $podcastTable->getColumn($key)->getSize(); - } catch (PropelException $e) { - continue; - } - - if (strlen($value) > $columnMaxSize) { - $value = substr($value, 0, $podcastTable->getColumn($key)->getSize()); - } - } - } - - private static function removePrivateFields(&$data) - { - foreach (self::$privateFields as $key) { - unset($data[$key]); - } - } - - //TODO move this somewhere where it makes sense - private static function getOwnerId() - { - try { - if (Zend_Auth::getInstance()->hasIdentity()) { - $service_user = new Application_Service_UserService(); - return $service_user->getCurrentUser()->getDbId(); - } else { - $defaultOwner = CcSubjsQuery::create() - ->filterByDbType('A') - ->orderByDbId() - ->findOne(); - if (!$defaultOwner) { - // what to do if there is no admin user? - // should we handle this case? - return null; - } - return $defaultOwner->getDbId(); - } - } catch(Exception $e) { - Logging::info($e->getMessage()); - } - } -} diff --git a/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php b/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php index dfc5c95ff..72b72a09a 100644 --- a/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php @@ -46,7 +46,7 @@ class CcBlockTableMap extends TableMap $this->addForeignKey('creator_id', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'id', false, null, null); $this->addColumn('description', 'DbDescription', 'VARCHAR', false, 512, null); $this->addColumn('length', 'DbLength', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('type', 'DbType', 'VARCHAR', false, 7, 'static'); + $this->addColumn('type', 'DbType', 'VARCHAR', false, 7, 'dynamic'); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php b/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php index cf4a5e2ec..adf31fa13 100644 --- a/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php @@ -44,6 +44,7 @@ class CcBlockcriteriaTableMap extends TableMap $this->addColumn('modifier', 'DbModifier', 'VARCHAR', true, 16, null); $this->addColumn('value', 'DbValue', 'VARCHAR', true, 512, null); $this->addColumn('extra', 'DbExtra', 'VARCHAR', false, 512, null); + $this->addColumn('criteriagroup', 'DbCriteriaGroup', 'INTEGER', false, null, null); $this->addForeignKey('block_id', 'DbBlockId', 'INTEGER', 'cc_block', 'id', true, null, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/map/PodcastEpisodesTableMap.php b/airtime_mvc/application/models/airtime/map/PodcastEpisodesTableMap.php index ef3895069..978cf12a1 100644 --- a/airtime_mvc/application/models/airtime/map/PodcastEpisodesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/PodcastEpisodesTableMap.php @@ -45,6 +45,8 @@ class PodcastEpisodesTableMap extends TableMap $this->addColumn('publication_date', 'DbPublicationDate', 'TIMESTAMP', true, null, null); $this->addColumn('download_url', 'DbDownloadUrl', 'VARCHAR', true, 4096, null); $this->addColumn('episode_guid', 'DbEpisodeGuid', 'VARCHAR', true, 4096, null); + $this->addColumn('episode_title', 'DbEpisodeTitle', 'VARCHAR', true, 4096, null); + $this->addColumn('episode_description', 'DbEpisodeDescription', 'VARCHAR', true, 4096, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php index ec32bc9c8..0729979ab 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php @@ -55,7 +55,7 @@ abstract class BaseCcBlockcontents extends BaseObject implements Persistent /** * The value for the trackoffset field. - * Note: this column has a database default value of: 0 + * Note: this column has a database default value of: 0.0 * @var double */ protected $trackoffset; @@ -136,7 +136,7 @@ abstract class BaseCcBlockcontents extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->trackoffset = 0; + $this->trackoffset = 0.0; $this->cliplength = '00:00:00'; $this->cuein = '00:00:00'; $this->cueout = '00:00:00'; @@ -548,7 +548,7 @@ abstract class BaseCcBlockcontents extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->trackoffset !== 0) { + if ($this->trackoffset !== 0.0) { return false; } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php index 069a8f96e..a1b663a73 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php @@ -59,6 +59,12 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent */ protected $extra; + /** + * The value for the criteriagroup field. + * @var int + */ + protected $criteriagroup; + /** * The value for the block_id field. * @var int @@ -145,6 +151,17 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent return $this->extra; } + /** + * Get the [criteriagroup] column value. + * + * @return int + */ + public function getDbCriteriaGroup() + { + + return $this->criteriagroup; + } + /** * Get the [block_id] column value. * @@ -261,6 +278,27 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent return $this; } // setDbExtra() + /** + * Set the value of [criteriagroup] column. + * + * @param int $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbCriteriaGroup($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->criteriagroup !== $v) { + $this->criteriagroup = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::CRITERIAGROUP; + } + + + return $this; + } // setDbCriteriaGroup() + /** * Set the value of [block_id] column. * @@ -323,7 +361,8 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent $this->modifier = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->value = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->extra = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->block_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->criteriagroup = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->block_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; $this->resetModified(); $this->setNew(false); @@ -333,7 +372,7 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent } $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = CcBlockcriteriaPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 7; // 7 = CcBlockcriteriaPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating CcBlockcriteria object", $e); @@ -586,6 +625,9 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent if ($this->isColumnModified(CcBlockcriteriaPeer::EXTRA)) { $modifiedColumns[':p' . $index++] = '"extra"'; } + if ($this->isColumnModified(CcBlockcriteriaPeer::CRITERIAGROUP)) { + $modifiedColumns[':p' . $index++] = '"criteriagroup"'; + } if ($this->isColumnModified(CcBlockcriteriaPeer::BLOCK_ID)) { $modifiedColumns[':p' . $index++] = '"block_id"'; } @@ -615,6 +657,9 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent case '"extra"': $stmt->bindValue($identifier, $this->extra, PDO::PARAM_STR); break; + case '"criteriagroup"': + $stmt->bindValue($identifier, $this->criteriagroup, PDO::PARAM_INT); + break; case '"block_id"': $stmt->bindValue($identifier, $this->block_id, PDO::PARAM_INT); break; @@ -773,6 +818,9 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent return $this->getDbExtra(); break; case 5: + return $this->getDbCriteriaGroup(); + break; + case 6: return $this->getDbBlockId(); break; default: @@ -809,7 +857,8 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent $keys[2] => $this->getDbModifier(), $keys[3] => $this->getDbValue(), $keys[4] => $this->getDbExtra(), - $keys[5] => $this->getDbBlockId(), + $keys[5] => $this->getDbCriteriaGroup(), + $keys[6] => $this->getDbBlockId(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -870,6 +919,9 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent $this->setDbExtra($value); break; case 5: + $this->setDbCriteriaGroup($value); + break; + case 6: $this->setDbBlockId($value); break; } // switch() @@ -901,7 +953,8 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent if (array_key_exists($keys[2], $arr)) $this->setDbModifier($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setDbValue($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setDbExtra($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbBlockId($arr[$keys[5]]); + if (array_key_exists($keys[5], $arr)) $this->setDbCriteriaGroup($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbBlockId($arr[$keys[6]]); } /** @@ -918,6 +971,7 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent if ($this->isColumnModified(CcBlockcriteriaPeer::MODIFIER)) $criteria->add(CcBlockcriteriaPeer::MODIFIER, $this->modifier); if ($this->isColumnModified(CcBlockcriteriaPeer::VALUE)) $criteria->add(CcBlockcriteriaPeer::VALUE, $this->value); if ($this->isColumnModified(CcBlockcriteriaPeer::EXTRA)) $criteria->add(CcBlockcriteriaPeer::EXTRA, $this->extra); + if ($this->isColumnModified(CcBlockcriteriaPeer::CRITERIAGROUP)) $criteria->add(CcBlockcriteriaPeer::CRITERIAGROUP, $this->criteriagroup); if ($this->isColumnModified(CcBlockcriteriaPeer::BLOCK_ID)) $criteria->add(CcBlockcriteriaPeer::BLOCK_ID, $this->block_id); return $criteria; @@ -986,6 +1040,7 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent $copyObj->setDbModifier($this->getDbModifier()); $copyObj->setDbValue($this->getDbValue()); $copyObj->setDbExtra($this->getDbExtra()); + $copyObj->setDbCriteriaGroup($this->getDbCriteriaGroup()); $copyObj->setDbBlockId($this->getDbBlockId()); if ($deepCopy && !$this->startCopy) { @@ -1107,6 +1162,7 @@ abstract class BaseCcBlockcriteria extends BaseObject implements Persistent $this->modifier = null; $this->value = null; $this->extra = null; + $this->criteriagroup = null; $this->block_id = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php index 00024dfa6..27dd9ac29 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php @@ -24,13 +24,13 @@ abstract class BaseCcBlockcriteriaPeer const TM_CLASS = 'CcBlockcriteriaTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 7; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 7; /** the column name for the id field */ const ID = 'cc_blockcriteria.id'; @@ -47,6 +47,9 @@ abstract class BaseCcBlockcriteriaPeer /** the column name for the extra field */ const EXTRA = 'cc_blockcriteria.extra'; + /** the column name for the criteriagroup field */ + const CRITERIAGROUP = 'cc_blockcriteria.criteriagroup'; + /** the column name for the block_id field */ const BLOCK_ID = 'cc_blockcriteria.block_id'; @@ -69,12 +72,12 @@ abstract class BaseCcBlockcriteriaPeer * e.g. CcBlockcriteriaPeer::$fieldNames[CcBlockcriteriaPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbCriteria', 'DbModifier', 'DbValue', 'DbExtra', 'DbBlockId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCriteria', 'dbModifier', 'dbValue', 'dbExtra', 'dbBlockId', ), - BasePeer::TYPE_COLNAME => array (CcBlockcriteriaPeer::ID, CcBlockcriteriaPeer::CRITERIA, CcBlockcriteriaPeer::MODIFIER, CcBlockcriteriaPeer::VALUE, CcBlockcriteriaPeer::EXTRA, CcBlockcriteriaPeer::BLOCK_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CRITERIA', 'MODIFIER', 'VALUE', 'EXTRA', 'BLOCK_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'criteria', 'modifier', 'value', 'extra', 'block_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbCriteria', 'DbModifier', 'DbValue', 'DbExtra', 'DbCriteriaGroup', 'DbBlockId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCriteria', 'dbModifier', 'dbValue', 'dbExtra', 'dbCriteriaGroup', 'dbBlockId', ), + BasePeer::TYPE_COLNAME => array (CcBlockcriteriaPeer::ID, CcBlockcriteriaPeer::CRITERIA, CcBlockcriteriaPeer::MODIFIER, CcBlockcriteriaPeer::VALUE, CcBlockcriteriaPeer::EXTRA, CcBlockcriteriaPeer::CRITERIAGROUP, CcBlockcriteriaPeer::BLOCK_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CRITERIA', 'MODIFIER', 'VALUE', 'EXTRA', 'CRITERIAGROUP', 'BLOCK_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'criteria', 'modifier', 'value', 'extra', 'criteriagroup', 'block_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -84,12 +87,12 @@ abstract class BaseCcBlockcriteriaPeer * e.g. CcBlockcriteriaPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCriteria' => 1, 'DbModifier' => 2, 'DbValue' => 3, 'DbExtra' => 4, 'DbBlockId' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCriteria' => 1, 'dbModifier' => 2, 'dbValue' => 3, 'dbExtra' => 4, 'dbBlockId' => 5, ), - BasePeer::TYPE_COLNAME => array (CcBlockcriteriaPeer::ID => 0, CcBlockcriteriaPeer::CRITERIA => 1, CcBlockcriteriaPeer::MODIFIER => 2, CcBlockcriteriaPeer::VALUE => 3, CcBlockcriteriaPeer::EXTRA => 4, CcBlockcriteriaPeer::BLOCK_ID => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CRITERIA' => 1, 'MODIFIER' => 2, 'VALUE' => 3, 'EXTRA' => 4, 'BLOCK_ID' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'criteria' => 1, 'modifier' => 2, 'value' => 3, 'extra' => 4, 'block_id' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCriteria' => 1, 'DbModifier' => 2, 'DbValue' => 3, 'DbExtra' => 4, 'DbCriteriaGroup' => 5, 'DbBlockId' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCriteria' => 1, 'dbModifier' => 2, 'dbValue' => 3, 'dbExtra' => 4, 'dbCriteriaGroup' => 5, 'dbBlockId' => 6, ), + BasePeer::TYPE_COLNAME => array (CcBlockcriteriaPeer::ID => 0, CcBlockcriteriaPeer::CRITERIA => 1, CcBlockcriteriaPeer::MODIFIER => 2, CcBlockcriteriaPeer::VALUE => 3, CcBlockcriteriaPeer::EXTRA => 4, CcBlockcriteriaPeer::CRITERIAGROUP => 5, CcBlockcriteriaPeer::BLOCK_ID => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CRITERIA' => 1, 'MODIFIER' => 2, 'VALUE' => 3, 'EXTRA' => 4, 'CRITERIAGROUP' => 5, 'BLOCK_ID' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'criteria' => 1, 'modifier' => 2, 'value' => 3, 'extra' => 4, 'criteriagroup' => 5, 'block_id' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -168,6 +171,7 @@ abstract class BaseCcBlockcriteriaPeer $criteria->addSelectColumn(CcBlockcriteriaPeer::MODIFIER); $criteria->addSelectColumn(CcBlockcriteriaPeer::VALUE); $criteria->addSelectColumn(CcBlockcriteriaPeer::EXTRA); + $criteria->addSelectColumn(CcBlockcriteriaPeer::CRITERIAGROUP); $criteria->addSelectColumn(CcBlockcriteriaPeer::BLOCK_ID); } else { $criteria->addSelectColumn($alias . '.id'); @@ -175,6 +179,7 @@ abstract class BaseCcBlockcriteriaPeer $criteria->addSelectColumn($alias . '.modifier'); $criteria->addSelectColumn($alias . '.value'); $criteria->addSelectColumn($alias . '.extra'); + $criteria->addSelectColumn($alias . '.criteriagroup'); $criteria->addSelectColumn($alias . '.block_id'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php index c91212458..ebe48189b 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php @@ -11,6 +11,7 @@ * @method CcBlockcriteriaQuery orderByDbModifier($order = Criteria::ASC) Order by the modifier column * @method CcBlockcriteriaQuery orderByDbValue($order = Criteria::ASC) Order by the value column * @method CcBlockcriteriaQuery orderByDbExtra($order = Criteria::ASC) Order by the extra column + * @method CcBlockcriteriaQuery orderByDbCriteriaGroup($order = Criteria::ASC) Order by the criteriagroup column * @method CcBlockcriteriaQuery orderByDbBlockId($order = Criteria::ASC) Order by the block_id column * * @method CcBlockcriteriaQuery groupByDbId() Group by the id column @@ -18,6 +19,7 @@ * @method CcBlockcriteriaQuery groupByDbModifier() Group by the modifier column * @method CcBlockcriteriaQuery groupByDbValue() Group by the value column * @method CcBlockcriteriaQuery groupByDbExtra() Group by the extra column + * @method CcBlockcriteriaQuery groupByDbCriteriaGroup() Group by the criteriagroup column * @method CcBlockcriteriaQuery groupByDbBlockId() Group by the block_id column * * @method CcBlockcriteriaQuery leftJoin($relation) Adds a LEFT JOIN clause to the query @@ -35,6 +37,7 @@ * @method CcBlockcriteria findOneByDbModifier(string $modifier) Return the first CcBlockcriteria filtered by the modifier column * @method CcBlockcriteria findOneByDbValue(string $value) Return the first CcBlockcriteria filtered by the value column * @method CcBlockcriteria findOneByDbExtra(string $extra) Return the first CcBlockcriteria filtered by the extra column + * @method CcBlockcriteria findOneByDbCriteriaGroup(int $criteriagroup) Return the first CcBlockcriteria filtered by the criteriagroup column * @method CcBlockcriteria findOneByDbBlockId(int $block_id) Return the first CcBlockcriteria filtered by the block_id column * * @method array findByDbId(int $id) Return CcBlockcriteria objects filtered by the id column @@ -42,6 +45,7 @@ * @method array findByDbModifier(string $modifier) Return CcBlockcriteria objects filtered by the modifier column * @method array findByDbValue(string $value) Return CcBlockcriteria objects filtered by the value column * @method array findByDbExtra(string $extra) Return CcBlockcriteria objects filtered by the extra column + * @method array findByDbCriteriaGroup(int $criteriagroup) Return CcBlockcriteria objects filtered by the criteriagroup column * @method array findByDbBlockId(int $block_id) Return CcBlockcriteria objects filtered by the block_id column * * @package propel.generator.airtime.om @@ -150,7 +154,7 @@ abstract class BaseCcBlockcriteriaQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT "id", "criteria", "modifier", "value", "extra", "block_id" FROM "cc_blockcriteria" WHERE "id" = :p0'; + $sql = 'SELECT "id", "criteria", "modifier", "value", "extra", "criteriagroup", "block_id" FROM "cc_blockcriteria" WHERE "id" = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -397,6 +401,48 @@ abstract class BaseCcBlockcriteriaQuery extends ModelCriteria return $this->addUsingAlias(CcBlockcriteriaPeer::EXTRA, $dbExtra, $comparison); } + /** + * Filter the query on the criteriagroup column + * + * Example usage: + * + * $query->filterByDbCriteriaGroup(1234); // WHERE criteriagroup = 1234 + * $query->filterByDbCriteriaGroup(array(12, 34)); // WHERE criteriagroup IN (12, 34) + * $query->filterByDbCriteriaGroup(array('min' => 12)); // WHERE criteriagroup >= 12 + * $query->filterByDbCriteriaGroup(array('max' => 12)); // WHERE criteriagroup <= 12 + * + * + * @param mixed $dbCriteriaGroup The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbCriteriaGroup($dbCriteriaGroup = null, $comparison = null) + { + if (is_array($dbCriteriaGroup)) { + $useMinMax = false; + if (isset($dbCriteriaGroup['min'])) { + $this->addUsingAlias(CcBlockcriteriaPeer::CRITERIAGROUP, $dbCriteriaGroup['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCriteriaGroup['max'])) { + $this->addUsingAlias(CcBlockcriteriaPeer::CRITERIAGROUP, $dbCriteriaGroup['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcBlockcriteriaPeer::CRITERIAGROUP, $dbCriteriaGroup, $comparison); + } + /** * Filter the query on the block_id column * diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php index 1c634b382..b0552a756 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php @@ -74,7 +74,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent /** * The value for the trackoffset field. - * Note: this column has a database default value of: 0 + * Note: this column has a database default value of: 0.0 * @var double */ protected $trackoffset; @@ -161,7 +161,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent public function applyDefaultValues() { $this->type = 0; - $this->trackoffset = 0; + $this->trackoffset = 0.0; $this->cliplength = '00:00:00'; $this->cuein = '00:00:00'; $this->cueout = '00:00:00'; @@ -677,7 +677,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent return false; } - if ($this->trackoffset !== 0) { + if ($this->trackoffset !== 0.0) { return false; } diff --git a/airtime_mvc/application/models/airtime/om/BasePodcastEpisodes.php b/airtime_mvc/application/models/airtime/om/BasePodcastEpisodes.php index e39015230..23e331847 100644 --- a/airtime_mvc/application/models/airtime/om/BasePodcastEpisodes.php +++ b/airtime_mvc/application/models/airtime/om/BasePodcastEpisodes.php @@ -65,6 +65,18 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent */ protected $episode_guid; + /** + * The value for the episode_title field. + * @var string + */ + protected $episode_title; + + /** + * The value for the episode_description field. + * @var string + */ + protected $episode_description; + /** * @var CcFiles */ @@ -185,6 +197,28 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent return $this->episode_guid; } + /** + * Get the [episode_title] column value. + * + * @return string + */ + public function getDbEpisodeTitle() + { + + return $this->episode_title; + } + + /** + * Get the [episode_description] column value. + * + * @return string + */ + public function getDbEpisodeDescription() + { + + return $this->episode_description; + } + /** * Set the value of [id] column. * @@ -321,6 +355,48 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent return $this; } // setDbEpisodeGuid() + /** + * Set the value of [episode_title] column. + * + * @param string $v new value + * @return PodcastEpisodes The current object (for fluent API support) + */ + public function setDbEpisodeTitle($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->episode_title !== $v) { + $this->episode_title = $v; + $this->modifiedColumns[] = PodcastEpisodesPeer::EPISODE_TITLE; + } + + + return $this; + } // setDbEpisodeTitle() + + /** + * Set the value of [episode_description] column. + * + * @param string $v new value + * @return PodcastEpisodes The current object (for fluent API support) + */ + public function setDbEpisodeDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->episode_description !== $v) { + $this->episode_description = $v; + $this->modifiedColumns[] = PodcastEpisodesPeer::EPISODE_DESCRIPTION; + } + + + return $this; + } // setDbEpisodeDescription() + /** * Indicates whether the columns in this object are only set to default values. * @@ -359,6 +435,8 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent $this->publication_date = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->download_url = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->episode_guid = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->episode_title = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->episode_description = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->resetModified(); $this->setNew(false); @@ -368,7 +446,7 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent } $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = PodcastEpisodesPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = PodcastEpisodesPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating PodcastEpisodes object", $e); @@ -635,6 +713,12 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent if ($this->isColumnModified(PodcastEpisodesPeer::EPISODE_GUID)) { $modifiedColumns[':p' . $index++] = '"episode_guid"'; } + if ($this->isColumnModified(PodcastEpisodesPeer::EPISODE_TITLE)) { + $modifiedColumns[':p' . $index++] = '"episode_title"'; + } + if ($this->isColumnModified(PodcastEpisodesPeer::EPISODE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"episode_description"'; + } $sql = sprintf( 'INSERT INTO "podcast_episodes" (%s) VALUES (%s)', @@ -664,6 +748,12 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent case '"episode_guid"': $stmt->bindValue($identifier, $this->episode_guid, PDO::PARAM_STR); break; + case '"episode_title"': + $stmt->bindValue($identifier, $this->episode_title, PDO::PARAM_STR); + break; + case '"episode_description"': + $stmt->bindValue($identifier, $this->episode_description, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -827,6 +917,12 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent case 5: return $this->getDbEpisodeGuid(); break; + case 6: + return $this->getDbEpisodeTitle(); + break; + case 7: + return $this->getDbEpisodeDescription(); + break; default: return null; break; @@ -862,6 +958,8 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent $keys[3] => $this->getDbPublicationDate(), $keys[4] => $this->getDbDownloadUrl(), $keys[5] => $this->getDbEpisodeGuid(), + $keys[6] => $this->getDbEpisodeTitle(), + $keys[7] => $this->getDbEpisodeDescription(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -927,6 +1025,12 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent case 5: $this->setDbEpisodeGuid($value); break; + case 6: + $this->setDbEpisodeTitle($value); + break; + case 7: + $this->setDbEpisodeDescription($value); + break; } // switch() } @@ -957,6 +1061,8 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent if (array_key_exists($keys[3], $arr)) $this->setDbPublicationDate($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setDbDownloadUrl($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setDbEpisodeGuid($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbEpisodeTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbEpisodeDescription($arr[$keys[7]]); } /** @@ -974,6 +1080,8 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent if ($this->isColumnModified(PodcastEpisodesPeer::PUBLICATION_DATE)) $criteria->add(PodcastEpisodesPeer::PUBLICATION_DATE, $this->publication_date); if ($this->isColumnModified(PodcastEpisodesPeer::DOWNLOAD_URL)) $criteria->add(PodcastEpisodesPeer::DOWNLOAD_URL, $this->download_url); if ($this->isColumnModified(PodcastEpisodesPeer::EPISODE_GUID)) $criteria->add(PodcastEpisodesPeer::EPISODE_GUID, $this->episode_guid); + if ($this->isColumnModified(PodcastEpisodesPeer::EPISODE_TITLE)) $criteria->add(PodcastEpisodesPeer::EPISODE_TITLE, $this->episode_title); + if ($this->isColumnModified(PodcastEpisodesPeer::EPISODE_DESCRIPTION)) $criteria->add(PodcastEpisodesPeer::EPISODE_DESCRIPTION, $this->episode_description); return $criteria; } @@ -1042,6 +1150,8 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent $copyObj->setDbPublicationDate($this->getDbPublicationDate()); $copyObj->setDbDownloadUrl($this->getDbDownloadUrl()); $copyObj->setDbEpisodeGuid($this->getDbEpisodeGuid()); + $copyObj->setDbEpisodeTitle($this->getDbEpisodeTitle()); + $copyObj->setDbEpisodeDescription($this->getDbEpisodeDescription()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -1215,6 +1325,8 @@ abstract class BasePodcastEpisodes extends BaseObject implements Persistent $this->publication_date = null; $this->download_url = null; $this->episode_guid = null; + $this->episode_title = null; + $this->episode_description = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; diff --git a/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesPeer.php b/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesPeer.php index 3415c9345..91fcbeee2 100644 --- a/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesPeer.php @@ -24,13 +24,13 @@ abstract class BasePodcastEpisodesPeer const TM_CLASS = 'PodcastEpisodesTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 8; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 8; /** the column name for the id field */ const ID = 'podcast_episodes.id'; @@ -50,6 +50,12 @@ abstract class BasePodcastEpisodesPeer /** the column name for the episode_guid field */ const EPISODE_GUID = 'podcast_episodes.episode_guid'; + /** the column name for the episode_title field */ + const EPISODE_TITLE = 'podcast_episodes.episode_title'; + + /** the column name for the episode_description field */ + const EPISODE_DESCRIPTION = 'podcast_episodes.episode_description'; + /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -69,12 +75,12 @@ abstract class BasePodcastEpisodesPeer * e.g. PodcastEpisodesPeer::$fieldNames[PodcastEpisodesPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFileId', 'DbPodcastId', 'DbPublicationDate', 'DbDownloadUrl', 'DbEpisodeGuid', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFileId', 'dbPodcastId', 'dbPublicationDate', 'dbDownloadUrl', 'dbEpisodeGuid', ), - BasePeer::TYPE_COLNAME => array (PodcastEpisodesPeer::ID, PodcastEpisodesPeer::FILE_ID, PodcastEpisodesPeer::PODCAST_ID, PodcastEpisodesPeer::PUBLICATION_DATE, PodcastEpisodesPeer::DOWNLOAD_URL, PodcastEpisodesPeer::EPISODE_GUID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FILE_ID', 'PODCAST_ID', 'PUBLICATION_DATE', 'DOWNLOAD_URL', 'EPISODE_GUID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'file_id', 'podcast_id', 'publication_date', 'download_url', 'episode_guid', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFileId', 'DbPodcastId', 'DbPublicationDate', 'DbDownloadUrl', 'DbEpisodeGuid', 'DbEpisodeTitle', 'DbEpisodeDescription', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFileId', 'dbPodcastId', 'dbPublicationDate', 'dbDownloadUrl', 'dbEpisodeGuid', 'dbEpisodeTitle', 'dbEpisodeDescription', ), + BasePeer::TYPE_COLNAME => array (PodcastEpisodesPeer::ID, PodcastEpisodesPeer::FILE_ID, PodcastEpisodesPeer::PODCAST_ID, PodcastEpisodesPeer::PUBLICATION_DATE, PodcastEpisodesPeer::DOWNLOAD_URL, PodcastEpisodesPeer::EPISODE_GUID, PodcastEpisodesPeer::EPISODE_TITLE, PodcastEpisodesPeer::EPISODE_DESCRIPTION, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FILE_ID', 'PODCAST_ID', 'PUBLICATION_DATE', 'DOWNLOAD_URL', 'EPISODE_GUID', 'EPISODE_TITLE', 'EPISODE_DESCRIPTION', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'file_id', 'podcast_id', 'publication_date', 'download_url', 'episode_guid', 'episode_title', 'episode_description', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -84,12 +90,12 @@ abstract class BasePodcastEpisodesPeer * e.g. PodcastEpisodesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFileId' => 1, 'DbPodcastId' => 2, 'DbPublicationDate' => 3, 'DbDownloadUrl' => 4, 'DbEpisodeGuid' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFileId' => 1, 'dbPodcastId' => 2, 'dbPublicationDate' => 3, 'dbDownloadUrl' => 4, 'dbEpisodeGuid' => 5, ), - BasePeer::TYPE_COLNAME => array (PodcastEpisodesPeer::ID => 0, PodcastEpisodesPeer::FILE_ID => 1, PodcastEpisodesPeer::PODCAST_ID => 2, PodcastEpisodesPeer::PUBLICATION_DATE => 3, PodcastEpisodesPeer::DOWNLOAD_URL => 4, PodcastEpisodesPeer::EPISODE_GUID => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FILE_ID' => 1, 'PODCAST_ID' => 2, 'PUBLICATION_DATE' => 3, 'DOWNLOAD_URL' => 4, 'EPISODE_GUID' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'file_id' => 1, 'podcast_id' => 2, 'publication_date' => 3, 'download_url' => 4, 'episode_guid' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFileId' => 1, 'DbPodcastId' => 2, 'DbPublicationDate' => 3, 'DbDownloadUrl' => 4, 'DbEpisodeGuid' => 5, 'DbEpisodeTitle' => 6, 'DbEpisodeDescription' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFileId' => 1, 'dbPodcastId' => 2, 'dbPublicationDate' => 3, 'dbDownloadUrl' => 4, 'dbEpisodeGuid' => 5, 'dbEpisodeTitle' => 6, 'dbEpisodeDescription' => 7, ), + BasePeer::TYPE_COLNAME => array (PodcastEpisodesPeer::ID => 0, PodcastEpisodesPeer::FILE_ID => 1, PodcastEpisodesPeer::PODCAST_ID => 2, PodcastEpisodesPeer::PUBLICATION_DATE => 3, PodcastEpisodesPeer::DOWNLOAD_URL => 4, PodcastEpisodesPeer::EPISODE_GUID => 5, PodcastEpisodesPeer::EPISODE_TITLE => 6, PodcastEpisodesPeer::EPISODE_DESCRIPTION => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FILE_ID' => 1, 'PODCAST_ID' => 2, 'PUBLICATION_DATE' => 3, 'DOWNLOAD_URL' => 4, 'EPISODE_GUID' => 5, 'EPISODE_TITLE' => 6, 'EPISODE_DESCRIPTION' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'file_id' => 1, 'podcast_id' => 2, 'publication_date' => 3, 'download_url' => 4, 'episode_guid' => 5, 'episode_title' => 6, 'episode_description' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -169,6 +175,8 @@ abstract class BasePodcastEpisodesPeer $criteria->addSelectColumn(PodcastEpisodesPeer::PUBLICATION_DATE); $criteria->addSelectColumn(PodcastEpisodesPeer::DOWNLOAD_URL); $criteria->addSelectColumn(PodcastEpisodesPeer::EPISODE_GUID); + $criteria->addSelectColumn(PodcastEpisodesPeer::EPISODE_TITLE); + $criteria->addSelectColumn(PodcastEpisodesPeer::EPISODE_DESCRIPTION); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.file_id'); @@ -176,6 +184,8 @@ abstract class BasePodcastEpisodesPeer $criteria->addSelectColumn($alias . '.publication_date'); $criteria->addSelectColumn($alias . '.download_url'); $criteria->addSelectColumn($alias . '.episode_guid'); + $criteria->addSelectColumn($alias . '.episode_title'); + $criteria->addSelectColumn($alias . '.episode_description'); } } diff --git a/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesQuery.php b/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesQuery.php index fbf44a00f..f96d61b8d 100644 --- a/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BasePodcastEpisodesQuery.php @@ -12,6 +12,8 @@ * @method PodcastEpisodesQuery orderByDbPublicationDate($order = Criteria::ASC) Order by the publication_date column * @method PodcastEpisodesQuery orderByDbDownloadUrl($order = Criteria::ASC) Order by the download_url column * @method PodcastEpisodesQuery orderByDbEpisodeGuid($order = Criteria::ASC) Order by the episode_guid column + * @method PodcastEpisodesQuery orderByDbEpisodeTitle($order = Criteria::ASC) Order by the episode_title column + * @method PodcastEpisodesQuery orderByDbEpisodeDescription($order = Criteria::ASC) Order by the episode_description column * * @method PodcastEpisodesQuery groupByDbId() Group by the id column * @method PodcastEpisodesQuery groupByDbFileId() Group by the file_id column @@ -19,6 +21,8 @@ * @method PodcastEpisodesQuery groupByDbPublicationDate() Group by the publication_date column * @method PodcastEpisodesQuery groupByDbDownloadUrl() Group by the download_url column * @method PodcastEpisodesQuery groupByDbEpisodeGuid() Group by the episode_guid column + * @method PodcastEpisodesQuery groupByDbEpisodeTitle() Group by the episode_title column + * @method PodcastEpisodesQuery groupByDbEpisodeDescription() Group by the episode_description column * * @method PodcastEpisodesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method PodcastEpisodesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -40,6 +44,8 @@ * @method PodcastEpisodes findOneByDbPublicationDate(string $publication_date) Return the first PodcastEpisodes filtered by the publication_date column * @method PodcastEpisodes findOneByDbDownloadUrl(string $download_url) Return the first PodcastEpisodes filtered by the download_url column * @method PodcastEpisodes findOneByDbEpisodeGuid(string $episode_guid) Return the first PodcastEpisodes filtered by the episode_guid column + * @method PodcastEpisodes findOneByDbEpisodeTitle(string $episode_title) Return the first PodcastEpisodes filtered by the episode_title column + * @method PodcastEpisodes findOneByDbEpisodeDescription(string $episode_description) Return the first PodcastEpisodes filtered by the episode_description column * * @method array findByDbId(int $id) Return PodcastEpisodes objects filtered by the id column * @method array findByDbFileId(int $file_id) Return PodcastEpisodes objects filtered by the file_id column @@ -47,6 +53,8 @@ * @method array findByDbPublicationDate(string $publication_date) Return PodcastEpisodes objects filtered by the publication_date column * @method array findByDbDownloadUrl(string $download_url) Return PodcastEpisodes objects filtered by the download_url column * @method array findByDbEpisodeGuid(string $episode_guid) Return PodcastEpisodes objects filtered by the episode_guid column + * @method array findByDbEpisodeTitle(string $episode_title) Return PodcastEpisodes objects filtered by the episode_title column + * @method array findByDbEpisodeDescription(string $episode_description) Return PodcastEpisodes objects filtered by the episode_description column * * @package propel.generator.airtime.om */ @@ -154,7 +162,7 @@ abstract class BasePodcastEpisodesQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT "id", "file_id", "podcast_id", "publication_date", "download_url", "episode_guid" FROM "podcast_episodes" WHERE "id" = :p0'; + $sql = 'SELECT "id", "file_id", "podcast_id", "publication_date", "download_url", "episode_guid", "episode_title", "episode_description" FROM "podcast_episodes" WHERE "id" = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -474,6 +482,64 @@ abstract class BasePodcastEpisodesQuery extends ModelCriteria return $this->addUsingAlias(PodcastEpisodesPeer::EPISODE_GUID, $dbEpisodeGuid, $comparison); } + /** + * Filter the query on the episode_title column + * + * Example usage: + * + * $query->filterByDbEpisodeTitle('fooValue'); // WHERE episode_title = 'fooValue' + * $query->filterByDbEpisodeTitle('%fooValue%'); // WHERE episode_title LIKE '%fooValue%' + * + * + * @param string $dbEpisodeTitle 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 PodcastEpisodesQuery The current query, for fluid interface + */ + public function filterByDbEpisodeTitle($dbEpisodeTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbEpisodeTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbEpisodeTitle)) { + $dbEpisodeTitle = str_replace('*', '%', $dbEpisodeTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(PodcastEpisodesPeer::EPISODE_TITLE, $dbEpisodeTitle, $comparison); + } + + /** + * Filter the query on the episode_description column + * + * Example usage: + * + * $query->filterByDbEpisodeDescription('fooValue'); // WHERE episode_description = 'fooValue' + * $query->filterByDbEpisodeDescription('%fooValue%'); // WHERE episode_description LIKE '%fooValue%' + * + * + * @param string $dbEpisodeDescription 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 PodcastEpisodesQuery The current query, for fluid interface + */ + public function filterByDbEpisodeDescription($dbEpisodeDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbEpisodeDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbEpisodeDescription)) { + $dbEpisodeDescription = str_replace('*', '%', $dbEpisodeDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(PodcastEpisodesPeer::EPISODE_DESCRIPTION, $dbEpisodeDescription, $comparison); + } + /** * Filter the query by a related CcFiles object * diff --git a/airtime_mvc/application/modules/rest/Bootstrap.php b/airtime_mvc/application/modules/rest/Bootstrap.php index b8575a2cf..3ac5a1891 100644 --- a/airtime_mvc/application/modules/rest/Bootstrap.php +++ b/airtime_mvc/application/modules/rest/Bootstrap.php @@ -21,6 +21,17 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap ); $router->addRoute('podcast-bulk', $podcastBulkRoute); + + $smartblockPodcastRoute = new Zend_Controller_Router_Route( + 'rest/podcast/smartblock', + array( + 'controller' => 'podcast', + 'action' => 'smartblock', + 'module' => 'rest' + ) + ); + $router->addRoute('podcast-smartblock', $smartblockPodcastRoute); + $stationPodcastRoute = new Zend_Controller_Router_Route( 'rest/podcast/station', array( diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 79208f56c..8444e1841 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -130,7 +130,8 @@ class Rest_MediaController extends Zend_Rest_Controller try { // REST uploads are not from Zend_Form, hence we handle them using Zend_File_transfer directly - $upload = new Zend_File_Transfer(); + // we need to specify an explicit adapter since autodetection broke in php 7.2 + $upload = new Zend_File_Transfer('Zend_File_Transfer_Adapter_Http'); // this error should not really get hit, letting the user know if it does is nice for debugging // see: https://github.com/LibreTime/libretime/issues/3#issuecomment-281143417 if (!$upload->isValid('file')) { diff --git a/airtime_mvc/application/modules/rest/controllers/PodcastController.php b/airtime_mvc/application/modules/rest/controllers/PodcastController.php index f80b16c34..eb454cb94 100644 --- a/airtime_mvc/application/modules/rest/controllers/PodcastController.php +++ b/airtime_mvc/application/modules/rest/controllers/PodcastController.php @@ -191,6 +191,26 @@ class Rest_PodcastController extends Zend_Rest_Controller $this->_helper->json->sendJson($responseBody); } + + /** + * Endpoint for triggering the generation of a smartblock and playlist to match the podcast name + */ + + public function smartblockAction() { + + $title = $this->_getParam('title', []); + $id = $this->_getParam('id', []); + if (!$id) { + return; + } + $podcast = Application_Service_PodcastService::getPodcastById($id); + + // logging::info($podcast); + Application_Service_PodcastService::createPodcastSmartblockAndPlaylist($podcast, $title); + } + + + /** * @throws PodcastNotFoundException * diff --git a/airtime_mvc/application/services/PodcastEpisodeService.php b/airtime_mvc/application/services/PodcastEpisodeService.php index 124290ac2..c6b604563 100644 --- a/airtime_mvc/application/services/PodcastEpisodeService.php +++ b/airtime_mvc/application/services/PodcastEpisodeService.php @@ -46,7 +46,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir public function importEpisode($podcastId, $episode) { $e = $this->addPlaceholder($podcastId, $episode); $p = $e->getPodcast(); - $this->_download($e->getDbId(), $e->getDbDownloadUrl(), $p->getDbTitle(), $this->_getAlbumOverride($p)); + $this->_download($e->getDbId(), $e->getDbDownloadUrl(), $p->getDbTitle(), $this->_getAlbumOverride($p), $episode["title"]); return $e; } @@ -93,7 +93,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir // feed object, or whether it's passed in as json $enclosure = $episode["enclosure"]; $url = $enclosure instanceof SimplePie_Enclosure ? $enclosure->get_link() : $enclosure["link"]; - return $this->_buildEpisode($podcastId, $url, $episode["guid"], $episode["pub_date"]); + return $this->_buildEpisode($podcastId, $url, $episode["guid"], $episode["pub_date"], $episode["title"], $episode["description"]); } /** @@ -103,18 +103,22 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir * @param string $url the download URL for the episode * @param string $guid the unique id for the episode. Often the same as the download URL * @param string $publicationDate the publication date of the episode + * @param string $title the title of the episode + * @param string $description the description of the epsiode * * @return PodcastEpisodes the newly created PodcastEpisodes object * * @throws Exception * @throws PropelException */ - private function _buildEpisode($podcastId, $url, $guid, $publicationDate) { + private function _buildEpisode($podcastId, $url, $guid, $publicationDate, $title, $description) { $e = new PodcastEpisodes(); $e->setDbPodcastId($podcastId); $e->setDbDownloadUrl($url); $e->setDbEpisodeGuid($guid); $e->setDbPublicationDate($publicationDate); + $e->setDbEpisodeTitle($title); + $e->setDbEpisodeDescription($description); $e->save(); return $e; } @@ -128,7 +132,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir /** @var PodcastEpisodes $episode */ foreach($episodes as $episode) { $podcast = $episode->getPodcast(); - $this->_download($episode->getDbId(), $episode->getDbDownloadUrl(), $podcast->getDbTitle(), $this->_getAlbumOverride($podcast)); + $this->_download($episode->getDbId(), $episode->getDbDownloadUrl(), $podcast->getDbTitle(), $this->_getAlbumOverride($podcast), $episode->getDbEpisodeTitle()); } } @@ -158,7 +162,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir * @param string $title title of podcast to be downloaded - added as album to track metadata * @param boolean $album_override should we override the album name when downloading */ - private function _download($id, $url, $title, $album_override) { + private function _download($id, $url, $title, $album_override, $track_title = null) { $CC_CONFIG = Config::getConfig(); $stationUrl = Application_Common_HTTPHelper::getStationUrl(); $stationUrl .= substr($stationUrl, -1) == '/' ? '' : '/'; @@ -169,7 +173,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir 'api_key' => $CC_CONFIG["apiKey"][0], 'podcast_name' => $title, 'album_override' => $album_override, - ); + 'track_title' => $track_title); $task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data); // Get the created ThirdPartyTaskReference and set the episode ID so // we can remove the placeholder if the import ends up stuck in a pending state @@ -393,9 +397,47 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir foreach ($rss->get_items() as $item) { /** @var SimplePie_Item $item */ // If the enclosure is empty or has not URL, this isn't a podcast episode (there's no audio data) + // technically podcasts shouldn't have multiple enclosures but often CMS add non-audio files $enclosure = $item->get_enclosure(); $url = $enclosure instanceof SimplePie_Enclosure ? $enclosure->get_link() : $enclosure["link"]; - if (empty($url)) { continue; } + if (empty($url)) { + continue; + } + // next we check and see if the enclosure is not an audio file - this can happen from improperly + // formatted podcasts and we instead will search through the enclosures and see if there is an audio item + // then we pass that on, otherwise we just pass the first item since it is probably an audio file + elseif (!(substr($enclosure->get_type(), 0, 5) === 'audio')) { + // this is a rather hackish way of accessing the enclosures but get_enclosures() didnt detect multiple + // enclosures at certain points so we search through them and then manually create an enclosure object + // if we find an audio file in an enclosure and send it off + Logging::info('found a non audio'); + $testenclosures = $enclosures = $item->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'); + Logging::info($testenclosures); + // we need to check if this is an array otherwise sizeof will fail and stop this whole script + if (is_array($testenclosures)) { + $numenclosures = sizeof($testenclosures); + // now we loop through and look for a audio file and then stop the loop at the first one we find + for ($i = 0; $i < $numenclosures + 1; $i++) { + $enclosure_attribs = array_values($testenclosures[$i]['attribs'])[0]; + if (stripos($enclosure_attribs['type'], 'audio') !== false) { + $url = $enclosure_attribs['url']; + $enclosure = new SimplePie_Enclosure($enclosure_attribs['url'], $enclosure_attribs['type'], $length = $enclosure_attribs['length']); + break; + } + // if we didn't find an audio file we need to continue because there were no audio item enclosures + // so this should keep it from showing items without audio items on the episodes list + if ($i = $numenclosures) { + continue; + } + } + } + else { + continue; + } + } else { + $enclosure = $item->get_enclosure(); + } + //Logging::info($enclosure); $itemId = $item->get_id(); $ingested = in_array($itemId, $episodeIds) ? (empty($episodeFiles[$itemId]) ? -1 : 1) : 0; $file = $ingested > 0 && !empty($episodeFiles[$itemId]) ? @@ -415,12 +457,11 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir "author" => $this->_buildAuthorString($item), "description" => htmlspecialchars($item->get_description()), "pub_date" => $item->get_gmdate(), - "link" => $item->get_link(), - "enclosure" => $item->get_enclosure(), + "link" => $url, + "enclosure" => $enclosure, "file" => $file )); } - return $episodesArray; } diff --git a/airtime_mvc/application/services/PodcastService.php b/airtime_mvc/application/services/PodcastService.php index b9aecb389..8ea319772 100644 --- a/airtime_mvc/application/services/PodcastService.php +++ b/airtime_mvc/application/services/PodcastService.php @@ -162,49 +162,59 @@ class Application_Service_PodcastService /** * @param $podcast + * @param $title passed in directly from web UI input * This will automatically create a smartblock and playlist for this podcast. */ - public static function createPodcastSmartblockAndPlaylist($podcast) + public static function createPodcastSmartblockAndPlaylist($podcast, $title = null) { - $newBl = new Application_Model_Block(); - $newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); - $newBl->setName($podcast->getDbTitle()); - $newBl->setDescription('Auto-generated smartblock for podcast'); - $newBl->saveType('dynamic'); - // limit the smartblock to 1 item - $row = new CcBlockcriteria(); - $row->setDbCriteria('limit'); - $row->setDbModifier('items'); - $row->setDbValue(1); - $row->setDbBlockId($newBl->getId()); - $row->save(); - - // sort so that it is the newest item - $row = new CcBlockcriteria(); - $row->setDbCriteria('sort'); - $row->setDbModifier('N/A'); - $row->setDbValue('newest'); - $row->setDbBlockId($newBl->getId()); - $row->save(); - - // match the track by ensuring the album title matches the podcast - $row = new CcBlockcriteria(); - $row->setDbCriteria('album_title'); - $row->setDbModifier('is'); - $row->setDbValue($newBl->getName()); - $row->setDbBlockId($newBl->getId()); - $row->save(); - - $newPl = new Application_Model_Playlist(); - $newPl->setName($podcast->getDbTitle()); - $newPl->setCreator(Application_Model_User::getCurrentUser()->getId()); - $row = new CcPlaylistcontents(); - $row->setDbBlockId($newBl->getId()); - $row->setDbPlaylistId($newPl->getId()); - $row->setDbType(2); - $row->save(); + if (is_array($podcast)) { + $newpodcast = new Podcast(); + $newpodcast->fromArray($podcast, BasePeer::TYPE_FIELDNAME); + $podcast = $newpodcast; } + if ($title == null) { + $title = $podcast->getDbTitle(); + } + // Base class + $newBl = new Application_Model_Block(); + $newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); + $newBl->setName($title); + $newBl->setDescription('Auto-generated smartblock for podcast'); + $newBl->saveType('dynamic'); + // limit the smartblock to 1 item + $row = new CcBlockcriteria(); + $row->setDbCriteria('limit'); + $row->setDbModifier('items'); + $row->setDbValue(1); + $row->setDbBlockId($newBl->getId()); + $row->save(); + + // sort so that it is the newest item + $row = new CcBlockcriteria(); + $row->setDbCriteria('sort'); + $row->setDbModifier('N/A'); + $row->setDbValue('newest'); + $row->setDbBlockId($newBl->getId()); + $row->save(); + + // match the track by ensuring the album title matches the podcast + $row = new CcBlockcriteria(); + $row->setDbCriteria('album_title'); + $row->setDbModifier('is'); + $row->setDbValue($title); + $row->setDbBlockId($newBl->getId()); + $row->save(); + + $newPl = new Application_Model_Playlist(); + $newPl->setName($title); + $newPl->setCreator(Application_Model_User::getCurrentUser()->getId()); + $row = new CcPlaylistcontents(); + $row->setDbBlockId($newBl->getId()); + $row->setDbPlaylistId($newPl->getId()); + $row->setDbType(2); + $row->save(); + } public static function createStationPodcast() diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php index e305ca228..110584874 100644 --- a/airtime_mvc/application/upgrade/Upgrades.php +++ b/airtime_mvc/application/upgrade/Upgrades.php @@ -532,3 +532,60 @@ class AirtimeUpgrader300alpha6 extends AirtimeUpgrader return '3.0.0-alpha.6'; } } +/** + * Class AirtimeUpgrader300alpha7 + * + * GH-#636 - https://github.com/LibreTime/libretime/pull/636 - Change dynamic smartblock to be default smartblock type + */ + + +class AirtimeUpgrader300alpha7 extends AirtimeUpgrader +{ + protected function getSupportedSchemaVersions() { + return array( + '3.0.0-alpha.6' + ); + } + public function getNewVersion() { + return '3.0.0-alpha.7'; + } + +} +/** + * Class AirtimeUpgrader300alpha7-1 + * + * GH-#659 - https://github.com/LibreTime/libretime/pull/659/ - Add description and title to podcast episodes database table + */ + + +class AirtimeUpgrader300alpha7_1 extends AirtimeUpgrader +{ + protected function getSupportedSchemaVersions() { + return array( + '3.0.0-alpha.7' + ); + } + public function getNewVersion() { + return '3.0.0-alpha.7.1'; + } + +} +/** + * Class AirtimeUpgrader300alpha7-2 + * + * GH-#704 - https://github.com/LibreTime/libretime/pull/704/ - Add criteria group to smartblock table to enable database to store separately + */ + + + +class AirtimeUpgrader300alpha7_2 extends AirtimeUpgrader +{ + protected function getSupportedSchemaVersions() { + return array( + '3.0.0-alpha.7.1' + ); + } + public function getNewVersion() { + return '3.0.0-alpha.7.2'; + } +} diff --git a/airtime_mvc/application/views/scripts/embeddablewidgets/schedule.phtml b/airtime_mvc/application/views/scripts/embeddablewidgets/schedule.phtml index 94538187c..ffbfacb48 100644 --- a/airtime_mvc/application/views/scripts/embeddablewidgets/schedule.phtml +++ b/airtime_mvc/application/views/scripts/embeddablewidgets/schedule.phtml @@ -13,12 +13,12 @@
weekly_schedule_error_msg)) echo "style=display:none"; ?>>
- +
-

Copy this code and paste it into your website's HTML to embed the weekly schedule in your site. diff --git a/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml b/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml index 5d5eda5f6..a694866a8 100644 --- a/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml +++ b/airtime_mvc/application/views/scripts/form/add-show-autoplaylist.phtml @@ -7,9 +7,11 @@

element->getElement('add_show_has_autoplaylist') ?> +
+

More information"); ?>

 
element->getElement('submit') ?> diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index 8e9c63562..fcff6fb54 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -31,6 +31,10 @@ element->getElement('stationDefaultCrossfadeDuration')->render() ?> + element->getElement('introPlaylistSelect')->render() ?> + + element->getElement('outroPlaylistSelect')->render() ?> + element->getElement('podcastAlbumOverride')->render() ?> element->getElement('podcastAutoSmartblock')->render() ?> diff --git a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml index 3f46c828a..f2aabc598 100644 --- a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml +++ b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml @@ -1,72 +1,8 @@
-
- -
-
- element->getElement('sp_type')->getValue(); - foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?> - - - - - -
- -
- -
-
- element->getElement('sp_repeat_tracks')?> - element->getElement("sp_repeat_tracks")->hasErrors()) : ?> - element->getElement("sp_repeat_tracks")->getMessages() as $error): ?> - - - - - - -
- -
- -
-
- element->getElement('sp_sort_options') ?> - element->getElement("sp_sort_options")->hasErrors()) : ?> - element->getElement("sp_sort_options")->getMessages() as $error): ?> - - - - - -
- -
- -
-
- element->getElement('sp_limit_value')?> - element->getElement('sp_limit_options') ?> - element->getElement("sp_limit_value")->hasErrors()) : ?> - element->getElement("sp_limit_value")->getMessages() as $error): ?> - - - - - -
-
- - criteriasLength; $i++) { // modRowMap holds the number of modifier rows for each criteria element // i.e. if we have 'Album contains 1' and 'Album contains 2' the modRowMap @@ -90,40 +26,126 @@ $nextDisabled = $this->element->getElement("sp_criteria_field_".$nextIndex)->getAttrib('disabled') == 'disabled'?true:false; ?>
0) && */ $disabled) { - echo 'style=display:none'; - } ?> > + echo 'style="display:none"'; + }?> class="search-row-"> element->getElement("sp_criteria_field_".$i."_".$j) ?> element->getElement("sp_criteria_modifier_".$i."_".$j) /* @todo finish this */?> element->getElement("sp_criteria_value_".$i."_".$j) ?> element->getElement("sp_criteria_datetime_select_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>>element->getElement('sp_criteria_datetime_select_'.$i."_".$j) ?> - - + class='modifier_add_link' id='modifier_add_'> + + - + element->getElement("sp_criteria_extra_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>>element->getElement('sp_criteria_extra_'.$i."_".$j) ?> element->getElement("sp_criteria_extra_datetime_select_".$i."_".$j)->getAttrib("disabled") == "disabled"?'style="display:none;"':""?>>element->getElement('sp_criteria_extra_datetime_select_'.$i."_".$j) ?> - + - > + > - + element->getElement("sp_criteria_field_".$i."_".$j)->hasErrors()) : ?> - element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?> - - - - + element->getElement("sp_criteria_field_".$i."_".$j)->getMessages() as $error): ?> + + + +
+ +
+
+
+
+ +
+
+ element->getElement('sp_limit_value')?> + element->getElement('sp_limit_options') ?> + element->getElement("sp_limit_value")->hasErrors()) : ?> + element->getElement("sp_limit_value")->getMessages() as $error): ?> + + + + +
+
+
+
+
+ +
+
+ element->getElement('sp_type')->getValue(); + foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?> + + + + + +
+
+
+
+ +
+
+ element->getElement('sp_repeat_tracks')?> + element->getElement("sp_repeat_tracks")->hasErrors()) : ?> + element->getElement("sp_repeat_tracks")->getMessages() as $error): ?> + + + + + + +
+
+
+
+ +
+
+ element->getElement('sp_overflow_tracks')?> + element->getElement("sp_overflow_tracks")->hasErrors()) : ?> + element->getElement("sp_overflow_tracks")->getMessages() as $error): ?> + + + + + + +
+
+
+
+ +
+
+ element->getElement('sp_sort_options') ?> + element->getElement("sp_sort_options")->hasErrors()) : ?> + element->getElement("sp_sort_options")->getMessages() as $error): ?> + + + + + +
+
+
diff --git a/airtime_mvc/application/views/scripts/form/support-setting.phtml b/airtime_mvc/application/views/scripts/form/support-setting.phtml deleted file mode 100644 index 4f55061f9..000000000 --- a/airtime_mvc/application/views/scripts/form/support-setting.phtml +++ /dev/null @@ -1,147 +0,0 @@ -
-
-
-
- " - ."Click the box below and we'll make sure the features you use are constantly improving."), - PRODUCT_NAME)?> -
- - element->getElement('SupportFeedback')->hasErrors()) : ?> -
    - element->getElement('SupportFeedback')->getMessages() as $error): ?> -
  • - -
- -
-
-
- " - . COMPANY_SITE - . ""; - echo sprintf(_("Click the box below to promote your station on %s."), $whosUsingAnchor) - ?> -
- - element->getElement('Publicise')->hasErrors()) : ?> -
    - element->getElement('Publicise')->getMessages() as $error): ?> -
  • - -
- -
-
-
-

-
-
;"> -
- -
-
- element->getElement('stationName') ?> - element->getElement('stationName')->hasErrors()) : ?> -
    - element->getElement('stationName')->getMessages() as $error): ?> -
  • - -
- -
-
- - -
-
- element->getElement('Phone') ?> - element->getElement('Phone')->hasErrors()) : ?> -
    - element->getElement('Phone')->getMessages() as $error): ?> -
  • - -
- -
-
- - - - -
-
- element->getElement('Email') ?> - element->getElement('Email')->hasErrors()) : ?> -
    - element->getElement('Email')->getMessages() as $error): ?> -
  • - -
- -
-
- -
-
- element->getElement('StationWebSite') ?> - element->getElement('StationWebSite')->hasErrors()) : ?> -
    - element->getElement('StationWebSite')->getMessages() as $error): ?> -
  • - -
- -
-
- -
-
- element->getElement('Country') ?> - element->getElement('Country')->hasErrors()) : ?> -
    - element->getElement('Country')->getMessages() as $error): ?> -
  • - -
- -
-
- -
-
- element->getElement('City') ?> - element->getElement('City')->hasErrors()) : ?> -
    - element->getElement('City')->getMessages() as $error): ?> -
  • - -
- -
-
- -
-
- element->getElement('Description') ?> - element->getElement('Description')->hasErrors()) : ?> -
    - element->getElement('Description')->getMessages() as $error): ?> -
  • - -
- -
-
-
diff --git a/airtime_mvc/application/views/scripts/index/index.phtml b/airtime_mvc/application/views/scripts/index/index.phtml index 6ae9d4fb7..9420368f9 100644 --- a/airtime_mvc/application/views/scripts/index/index.phtml +++ b/airtime_mvc/application/views/scripts/index/index.phtml @@ -34,7 +34,7 @@
- +
diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index df94ff732..b3fd9f430 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -52,10 +52,12 @@
diff --git a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml index eb80e402c..47ce144bc 100644 --- a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml +++ b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml @@ -10,7 +10,7 @@ if (isset($this->obj)) {

"unsavedName)) echo $this->unsavedName; else echo $this->escape($this->obj->getName());?>"

-
+
@@ -25,17 +25,22 @@ if (isset($this->obj)) { else echo $this->escape($this->obj->getName()); ?>"> -
-
- -
form; ?> +
+
+
+
+ +
+
+
+
diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index 563e2899a..0901eb7b7 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -2,6 +2,23 @@ $items = $this->contents; $isSmartBlock = ($this->obj instanceof Application_Model_Block); $isPlaylist = ($this->obj instanceof Application_Model_Playlist); +if ($isSmartBlock && $this->showPoolCount) { ?> +
+ + poolCount; + echo ngettext(" track matches your search criteria.", " tracks match your search criteria.", $this->poolCount); + ?> + + poolCount > 0) { ?> + + + + +
+ obj->isStatic())) { @@ -148,4 +165,4 @@ if (($i < count($items) -1) && ($items[$i+1]['type'] == 0)) { } ?>
- + \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/podcast/podcast.phtml b/airtime_mvc/application/views/scripts/podcast/podcast.phtml index 1472bc78b..d008ade42 100644 --- a/airtime_mvc/application/views/scripts/podcast/podcast.phtml +++ b/airtime_mvc/application/views/scripts/podcast/podcast.phtml @@ -7,28 +7,33 @@