diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 0d7a34f7f..2cca81ac2 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -436,7 +436,7 @@ class PlaylistController extends Zend_Controller_Action try { $obj = $this->getPlaylist($type); - $obj->setName($name); + $obj->setName(trim($name)); $obj->setDescription($description); $this->view->description = $description; $this->view->playlistName = $name; diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index ffad27fea..a81c8d05d 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -163,7 +163,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } elseif (!$formData["add_show_no_end"]) { $popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"]; - $populateUntilDateTime = new DateTime($popUntil, new DateTimeZone('UTC')); + $populateUntilDateTime = new DateTime($popUntil); + $populateUntilDateTime->setTimezone(new DateTimeZone('UTC')); } //get repeat interval @@ -198,21 +199,20 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $repeatShowStart->add(new DateInterval("P".$daysAdd."D")); $repeatShowEnd->add(new DateInterval("P".$daysAdd."D")); } + /* Here we are checking each repeating show by + * the show day. + * (i.e: every wednesday, then every thursday, etc.) + */ while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) { - //need to get each repeating show's instance id - $qry = CcShowInstancesQuery::create() - ->filterByDbStarts($repeatShowStart->format('Y-m-d H:i:s')) - ->filterByDbEnds($repeatShowEnd->format('Y-m-d H:i:s')) - ->find(); - $count = $qry->count(); - if ($count > 1) { - $overlapping = true; - } elseif ($count == 1) { - $instanceId = $qry->getFirst()->getDbId(); - $overlapping = Application_Model_Schedule::checkOverlappingShows($repeatShowStart, $repeatShowEnd, $update, $instanceId); + if ($formData['add_show_id'] == -1) { + //this is a new show + $overlapping = Application_Model_Schedule::checkOverlappingShows( + $repeatShowStart, $repeatShowEnd); } else { - $overlapping = false; + $overlapping = Application_Model_Schedule::checkOverlappingShows( + $repeatShowStart, $repeatShowEnd, $update, null, $formData["add_show_id"]); } + if ($overlapping) { $valid = false; $this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows')); @@ -243,7 +243,9 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $minutes = "0"; $durationToAdd = "PT".$hours."H"; } - + + if (empty($formData["add_show_rebroadcast_date_absolute_".$i])) break; + $abs_rebroadcast_start = $formData["add_show_rebroadcast_date_absolute_".$i]." ". $formData["add_show_rebroadcast_time_absolute_".$i]; $rebroadcastShowStart = new DateTime($abs_rebroadcast_start); diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php index 39ec7af3b..ba7b1c4ef 100644 --- a/airtime_mvc/application/forms/EditAudioMD.php +++ b/airtime_mvc/application/forms/EditAudioMD.php @@ -125,7 +125,7 @@ class Application_Form_EditAudioMD extends Zend_Form // Add the submit button $this->addElement('submit', 'submit', array( 'ignore' => true, - 'class' => 'ui-button ui-state-default', + 'class' => 'btn', 'label' => 'Save', 'decorators' => array( 'ViewHelper' @@ -135,7 +135,7 @@ class Application_Form_EditAudioMD extends Zend_Form // Add the submit button $this->addElement('button', 'cancel', array( 'ignore' => true, - 'class' => 'ui-button ui-state-default ui-button-text-only md-cancel', + 'class' => 'btn md-cancel', 'label' => 'Cancel', 'onclick' => 'javascript:document.location.href = "/Library"', 'decorators' => array( diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index fa305a90a..4d62b8329 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -229,10 +229,17 @@ SQL; $formatter = new LengthFormatter($offset_cliplength); $row['offset'] = $formatter->format(); - //format the fades in format 00(.000000) + //format the fades in format 00(.0) $fades = $this->getFadeInfo($row['position']); $row['fadein'] = $fades[0]; $row['fadeout'] = $fades[1]; + + // format the cues in format 00:00:00(.0) + // we need to add the '.0' for cues and not fades + // because propel takes care of this for us + // (we use propel to fetch the fades) + $row['cuein'] = str_pad(substr($row['cuein'], 0, 10), 10, '.0'); + $row['cueout'] = str_pad(substr($row['cueout'], 0, 10), 10, '.0'); //format original length $formatter = new LengthFormatter($row['orig_length']); @@ -611,9 +618,10 @@ SQL; - #Propel returns values in form 00.000000 format which is for only seconds. - $fadeIn = $row->getDbFadein(); - $fadeOut = $row->getDbFadeout(); + //Propel returns values in form 00.000000 format which is for only seconds. + //We only want to display 1 decimal + $fadeIn = substr($row->getDbFadein(), 0, 4); + $fadeOut = substr($row->getDbFadeout(), 0, 4); return array($fadeIn, $fadeOut); } diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 232a52f04..c99fbb019 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -244,6 +244,13 @@ SQL; $fades = $this->getFadeInfo($row['position']); $row['fadein'] = $fades[0]; $row['fadeout'] = $fades[1]; + + // format the cues in format 00:00:00(.0) + // we need to add the '.0' for cues and not fades + // because propel takes care of this for us + // (we use propel to fetch the fades) + $row['cuein'] = str_pad(substr($row['cuein'], 0, 10), 10, '.0'); + $row['cueout'] = str_pad(substr($row['cueout'], 0, 10), 10, '.0'); //format original length $formatter = new LengthFormatter($row['orig_length']); @@ -585,9 +592,10 @@ SQL; if (!$row) { return NULL; } - #Propel returns values in form 00.000000 format which is for only seconds. - $fadeIn = $row->getDbFadein(); - $fadeOut = $row->getDbFadeout(); + //Propel returns values in form 00.000000 format which is for only seconds. + //We only want to display 1 decimal + $fadeIn = substr($row->getDbFadein(), 0, 4); + $fadeOut = substr($row->getDbFadeout(), 0, 4); return array($fadeIn, $fadeOut); } @@ -624,7 +632,7 @@ SQL; if (!is_null($fadeIn)) { - $sql = "SELECT INTERVAL :fadein > INTERVAL '{$clipLength}'"; + $sql = "SELECT :fadein::INTERVAL > INTERVAL '{$clipLength}'"; if (Application_Common_Database::prepareAndExecute($sql, array(':fadein'=>$fadeIn), 'column')) { //"Fade In can't be larger than overall playlength."; $fadeIn = $clipLength; @@ -633,7 +641,7 @@ SQL; } if (!is_null($fadeOut)) { - $sql = "SELECT INTERVAL :fadeout > INTERVAL '{$clipLength}'"; + $sql = "SELECT :fadeout::INTERVAL > INTERVAL '{$clipLength}'"; if (Application_Common_Database::prepareAndExecute($sql, array(':fadeout'=>$fadeOut), 'column')) { //Fade Out can't be larger than overall playlength."; $fadeOut = $clipLength; @@ -724,21 +732,21 @@ SQL; $cueOut = $origLength; } - $sql = "SELECT INTERVAL :cueIn > INTERVAL :cueOut"; + $sql = "SELECT :cueIn::INTERVAL > :cueOut::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':cueOut'=>$cueOut), 'column')) { $errArray["error"] = "Can't set cue in to be larger than cue out."; return $errArray; } - $sql = "SELECT INTERVAL :cueOut > INTERVAL :origLength"; + $sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) { $errArray["error"] = "Can't set cue out to be greater than file length."; return $errArray; } - $sql = "SELECT INTERVAL :cueOut - INTERVAL :cueIn"; + $sql = "SELECT :cueOut::INTERVAL - :cueIn::INTERVAL"; $cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':cueIn'=>$cueIn), 'column'); $row->setDbCuein($cueIn); @@ -747,15 +755,15 @@ SQL; } elseif (!is_null($cueIn)) { - $sql = "SELECT INTERVAL :cueIn > INTERVAL :oldCueOut"; + $sql = "SELECT :cueIn::INTERVAL > :oldCueOut::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut), 'column')) { $errArray["error"] = "Can't set cue in to be larger than cue out."; return $errArray; } - $sql = "SELECT INTERVAL :oldCueOut - INTERVAL :cueIn"; - $cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut, 'column')); + $sql = "SELECT :oldCueOut::INTERVAL - :cueIn::INTERVAL"; + $cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut), 'column'); $row->setDbCuein($cueIn); $row->setDBCliplength($cliplength); @@ -765,22 +773,22 @@ SQL; $cueOut = $origLength; } - $sql = "SELECT INTERVAL :cueOut < INTERVAL :oldCueIn"; - if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn, 'column'))) { + $sql = "SELECT :cueOut::INTERVAL < :oldCueIn::INTERVAL"; + if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn), 'column')) { $errArray["error"] = "Can't set cue out to be smaller than cue in."; return $errArray; } - $sql = "SELECT INTERVAL :cueOut > INTERVAL :origLength"; - if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength, 'column'))) { + $sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL"; + if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) { $errArray["error"] = "Can't set cue out to be greater than file length."; return $errArray; } - $sql = "SELECT INTERVAL :cueOut - INTERVAL :oldCueIn"; - $cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn, 'column')); + $sql = "SELECT :cueOut::INTERVAL - :oldCueIn::INTERVAL"; + $cliplength = Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn), 'column'); $row->setDbCueout($cueOut); $row->setDBCliplength($cliplength); @@ -788,14 +796,14 @@ SQL; $cliplength = $row->getDbCliplength(); - $sql = "SELECT INTERVAL :fadeIn > INTERVAL :cliplength"; - if (Application_Common_Database::prepareAndExecute($sql, array(':fadeIn'=>$fadeIn, ':cliplength'=>$cliplength, 'column'))) { + $sql = "SELECT :fadeIn::INTERVAL > :cliplength::INTERVAL"; + if (Application_Common_Database::prepareAndExecute($sql, array(':fadeIn'=>$fadeIn, ':cliplength'=>$cliplength), 'column')) { $fadeIn = $cliplength; $row->setDbFadein($fadeIn); } - $sql = "SELECT INTERVAL :fadeOut > INTERVAL :cliplength"; - if (Application_Common_Database::prepareAndExecute($sql, array(':fadeOut'=>$fadeOut, ':cliplength'=>$cliplength, 'column'))) { + $sql = "SELECT :fadeOut::INTERVAL > :cliplength::INTERVAL"; + if (Application_Common_Database::prepareAndExecute($sql, array(':fadeOut'=>$fadeOut, ':cliplength'=>$cliplength), 'column')) { $fadeOut = $cliplength; $row->setDbFadein($fadeOut); } diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index eff64b2ec..1102efaff 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1157,14 +1157,21 @@ SQL; } public static function checkOverlappingShows($show_start, $show_end, - $update=false, $instanceId=null) + $update=false, $instanceId=null, $showId=null) { $overlapping = false; + + $params = array( + ':show_end1' => $show_end->format('Y-m-d H:i:s'), + ':show_end2' => $show_end->format('Y-m-d H:i:s'), + ':show_end3' => $show_end->format('Y-m-d H:i:s') + ); + + /* If a show is being edited, exclude it from the query * In both cases (new and edit) we only grab shows that * are scheduled 2 days prior */ - //$se = $show_end->format('Y-m-d H:i:s'); if ($update) { $sql = <<= (date(:show_end3) - INTERVAL '2 days') AND modified_instance = FALSE +SQL; + if (is_null($showId)) { + $sql .= << $show_end->format('Y-m-d H:i:s'), - ':show_end2' => $show_end->format('Y-m-d H:i:s'), - ':show_end3' => $show_end->format('Y-m-d H:i:s'), - ':instanceId' => $instanceId - ), 'all'); + $params[':instanceId'] = $instanceId; + } else { + $sql .= << $show_end->format('Y-m-d H:i:s'), ':show_end3' => $show_end->format('Y-m-d H:i:s')), 'all'); } + foreach ($rows as $row) { $start = new DateTime($row["starts"], new DateTimeZone('UTC')); $end = new DateTime($row["ends"], new DateTimeZone('UTC')); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index d9467cfc1..bb58409fd 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -179,14 +179,19 @@ SQL; if ($deltaDay > 0) { return "Shows can have a max length of 24 hours."; } + + $utc = new DateTimeZone("UTC"); + + $nowDateTime = new DateTime("now", $utc); $showInstances = CcShowInstancesQuery::create() ->filterByDbShowId($this->_showId) ->find($con); - /* Check if the show being resized and any of its repeats * overlap - with other scheduled shows */ - $utc = new DateTimeZone("UTC"); + /* Check two things: + 1. If the show being resized and any of its repeats end in the past + 2. If the show being resized and any of its repeats overlap + with other scheduled shows */ foreach ($showInstances as $si) { $startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC")); @@ -201,6 +206,10 @@ SQL; $newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin); $newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin); + + if ($newEndsDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { + return "End date/time cannot be in the past"; + } //convert our new starts/ends to UTC. $newStartsDateTime->setTimezone($utc); @@ -1203,15 +1212,16 @@ SQL; //$con = Propel::getConnection(CcShowPeer::DATABASE_NAME); //$sql = "SELECT date '{$data['add_show_rebroadcast_date_absolute_'.$i]}' - date '{$data['add_show_start_date']}' "; $sql = << - $date["add_show_rebroadcast_date_absolute_$i"], + $data["add_show_rebroadcast_date_absolute_$i"], 'start' => - $date['add_show_start_date']), "column" ); + $data['add_show_start_date']), "column" ); //$r = $con->query($sql); //$offset_days = $r->fetchColumn(0); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index b405ef714..cd75da2d1 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -192,6 +192,7 @@ class Application_Model_StoredFile if ($dbColumn == "track_title" && (is_null($mdValue) || $mdValue == "")) { continue; } + # TODO : refactor string evals if (isset($this->_dbMD[$dbColumn])) { $propelColumn = $this->_dbMD[$dbColumn]; $method = "set$propelColumn"; @@ -756,10 +757,13 @@ SQL; $row['tr_id'] = "{$type}_{$row['id']}"; - //TODO url like this to work on both playlist/showbuilder screens. - //datatable stuff really needs to be pulled out and generalized within the project - //access to zend view methods to access url helpers is needed. + //TODO url like this to work on both playlist/showbuilder + //screens. datatable stuff really needs to be pulled out and + //generalized within the project access to zend view methods + //to access url helpers is needed. + // TODO : why is there inline html here? breaks abstraction and is + // ugly if ($type == "au") { $row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); $row['image'] = ''; diff --git a/airtime_mvc/application/views/scripts/form/showbuilder.phtml b/airtime_mvc/application/views/scripts/form/showbuilder.phtml index 877f28849..a0193b664 100644 --- a/airtime_mvc/application/views/scripts/form/showbuilder.phtml +++ b/airtime_mvc/application/views/scripts/form/showbuilder.phtml @@ -3,7 +3,7 @@ element->getElement('sb_date_end'); ?> element->getElement('sb_time_end'); ?> - + Find Shows
@@ -22,4 +22,4 @@
- \ No newline at end of file + 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 d6ac417b2..0f27248ca 100644 --- a/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml +++ b/airtime_mvc/application/views/scripts/form/smart-block-criteria.phtml @@ -4,10 +4,10 @@
-
+
element->getElement('generate_button') ?>
-
+
element->getElement('shuffle_button') ?>
diff --git a/airtime_mvc/application/views/scripts/form/support-setting.phtml b/airtime_mvc/application/views/scripts/form/support-setting.phtml index 46b93bb6c..f35a6eab1 100644 --- a/airtime_mvc/application/views/scripts/form/support-setting.phtml +++ b/airtime_mvc/application/views/scripts/form/support-setting.phtml @@ -3,9 +3,9 @@
- Help Airtime improve by letting us know how you are using it. This info - will be collected regularly in order to enhance your user experience.

- Click "Yes, help Airtime" and we'll make sure the features you use are + Help Airtime improve by letting Sourcefabric know how you are using it. This information + will be collected regularly in order to enhance your user experience.
+ Click the "Send support feedback" box and we'll make sure the features you use are constantly improving.
-
Click the box below to advertise your station on - Sourcefabric.org. - In order to promote your station, "Send support feedback" must be enabled. This data will be collected in addition to the support feedback.
+
Click the box below to promote your station on + Sourcefabric.org. +
-

Note: In order to promote your station, "Send support feedback" must be enabled

+
(In order to promote your station, "Send support feedback" must be enabled).

;">
@@ -179,7 +179,7 @@ - Terms and Conditions + Sourcefabric Privacy Policy
diff --git a/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml b/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml index 4a7baecad..ad65f2417 100644 --- a/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml +++ b/airtime_mvc/application/views/scripts/library/get-file-metadata.ajax.phtml @@ -37,8 +37,8 @@ type == "playlist") { ?>
o Web Stream
-o Dynamic Playlist
-o Static Playlist
+o Dynamic Smart Block
+o Static Smart Block
o Audio Track
@@ -47,7 +47,7 @@ type == "playlist") { ?>
Playlist Contents:
-
Static Playlist Contents:
+
Static Smart Block Contents:
contents as $row) : ?> @@ -86,7 +86,7 @@
blType == "Dynamic") { ?> -
Dynamic Playlist Criteria:
+
Dynamic Smart Block Criteria:
contents["crit"] as $criterias) : ?> diff --git a/airtime_mvc/application/views/scripts/login/password-restore.phtml b/airtime_mvc/application/views/scripts/login/password-restore.phtml index 63d265c65..bf65b2114 100644 --- a/airtime_mvc/application/views/scripts/login/password-restore.phtml +++ b/airtime_mvc/application/views/scripts/login/password-restore.phtml @@ -3,7 +3,7 @@

Reset password

- \ No newline at end of file + diff --git a/airtime_mvc/application/views/scripts/playlist/playlist.phtml b/airtime_mvc/application/views/scripts/playlist/playlist.phtml index 4ae48b038..6f962b97b 100644 --- a/airtime_mvc/application/views/scripts/playlist/playlist.phtml +++ b/airtime_mvc/application/views/scripts/playlist/playlist.phtml @@ -57,10 +57,10 @@ if (isset($this->obj)) {