diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php
index 64032d84a..65a9e38d8 100644
--- a/airtime_mvc/application/controllers/PlaylistController.php
+++ b/airtime_mvc/application/controllers/PlaylistController.php
@@ -30,6 +30,12 @@ class PlaylistController extends Zend_Controller_Action
if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id);
+
+ $modified = $this->_getParam('modified', null);
+ if ($pl->getLastModified("U") !== $modified) {
+ $this->createFullResponse($pl);
+ throw new PlaylistOutDatedException("You are viewing an older version of {$pl->getName()}");
+ }
}
return $pl;
}
@@ -51,6 +57,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
+ $this->view->modified = $pl->getLastModified("U");
unset($this->view->pl);
}
@@ -68,10 +75,33 @@ class PlaylistController extends Zend_Controller_Action
}
}
+ private function playlistOutdated($pl, $e)
+ {
+ $this->view->error = $e->getMessage();
+ }
+
+ private function playlistNotFound()
+ {
+ $this->view->error = "Playlist not found";
+
+ Logging::log("Playlist not found");
+ $this->changePlaylist(null);
+ $this->createFullResponse(null);
+ }
+
+ private function playlistUnknownError($e)
+ {
+ $this->view->error = "Something went wrong.";
+
+ Logging::log("{$e->getFile()}");
+ Logging::log("{$e->getLine()}");
+ Logging::log("{$e->getMessage()}");
+ }
+
public function indexAction()
{
global $CC_CONFIG;
-
+
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@@ -81,18 +111,16 @@ class PlaylistController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('spl');
try {
- $pl = $this->getPlaylist();
-
- if (isset($pl)) {
- $this->view->pl = $pl;
+ if (isset($this->pl_sess->id)) {
+ $pl = new Application_Model_Playlist($this->pl_sess->id);
+ $this->view->pl = $pl;
}
}
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
}
@@ -119,20 +147,15 @@ class PlaylistController extends Zend_Controller_Action
}
try {
- $pl = $this->getPlaylist();
+ $pl = new Application_Model_Playlist($id);
+ $this->createFullResponse($pl);
}
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist {$id} not found");
- $this->changePlaylist(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
- $this->changePlaylist(null);
+ $this->playlistUnknownError($e);
}
-
- $this->createFullResponse($pl);
}
public function deleteAction()
@@ -150,23 +173,18 @@ class PlaylistController extends Zend_Controller_Action
}
else {
Logging::log("Not deleting currently active playlist");
+ $pl = new Application_Model_Playlist($this->pl_sess->id);
}
Application_Model_Playlist::DeletePlaylists($ids);
- $pl = $this->getPlaylist();
+ $this->createFullResponse($pl);
}
- catch(PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $pl = null;
+ catch (PlaylistNotFoundException $e) {
+ $this->playlistNotFound();
}
- catch(Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ catch (Exception $e) {
+ $this->playlistUnknownError($e);
}
-
- $this->createFullResponse($pl);
}
public function addItemsAction()
@@ -176,24 +194,20 @@ class PlaylistController extends Zend_Controller_Action
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
- Logging::log("type is ".$addType);
-
try {
$pl = $this->getPlaylist();
$pl->addAudioClips($ids, $afterItem, $addType);
+ $this->createUpdateResponse($pl);
+ }
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
-
- $this->createUpdateResponse($pl);
}
public function moveItemsAction()
@@ -201,46 +215,44 @@ class PlaylistController extends Zend_Controller_Action
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
+ $modified = $this->_getParam('modified');
try {
$pl = $this->getPlaylist();
$pl->moveAudioClips($ids, $afterItem);
+ $this->createUpdateResponse($pl);
+ }
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
-
- $this->createUpdateResponse($pl);
}
public function deleteItemsAction()
{
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
+ $modified = $this->_getParam('modified');
try {
$pl = $this->getPlaylist();
$pl->delAudioClips($ids);
+ $this->createUpdateResponse($pl);
+ }
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
-
- $this->createUpdateResponse($pl);
}
public function setCueAction()
@@ -253,21 +265,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$response = $pl->changeClipLength($id, $cueIn, $cueOut);
- $this->view->response = $response;
-
- if(!isset($response["error"])) {
+ if (!isset($response["error"])) {
+ $this->view->response = $response;
$this->createUpdateResponse($pl);
}
+ else {
+ $this->view->cue_error = $response["error"];
+ }
+ }
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
}
@@ -281,21 +294,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut);
- $this->view->response = $response;
-
if (!isset($response["error"])) {
$this->createUpdateResponse($pl);
+ $this->view->response = $response;
+ }
+ else {
+ $this->view->fade_error = $response["error"];
}
}
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
+ }
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
}
@@ -309,15 +323,14 @@ class PlaylistController extends Zend_Controller_Action
$fades = $pl->getFadeInfo($pl->getSize()-1);
$this->view->fadeOut = $fades[1];
}
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
+ }
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
}
@@ -335,15 +348,14 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$pl->setPlaylistfades($fadeIn, $fadeOut);
}
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
+ }
catch (PlaylistNotFoundException $e) {
- Logging::log("Playlist not found");
- $this->changePlaylist(null);
- $this->createFullResponse(null);
+ $this->playlistNotFound();
}
catch (Exception $e) {
- Logging::log("{$e->getFile()}");
- Logging::log("{$e->getLine()}");
- Logging::log("{$e->getMessage()}");
+ $this->playlistUnknownError($e);
}
}
@@ -351,33 +363,42 @@ class PlaylistController extends Zend_Controller_Action
{
$name = $this->_getParam('name', 'Unknown Playlist');
- $pl = $this->getPlaylist();
- if($pl === false){
- $this->view->playlist_error = true;
- return false;
+ try {
+ $pl = $this->getPlaylist();
+ $pl->setName($name);
+ $this->view->playlistName = $name;
+ $this->view->modified = $pl->getLastModified("U");
+ }
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
+ }
+ catch (PlaylistNotFoundException $e) {
+ $this->playlistNotFound();
+ }
+ catch (Exception $e) {
+ $this->playlistUnknownError($e);
}
- $pl->setName($name);
-
- $this->view->playlistName = $name;
}
public function setPlaylistDescriptionAction()
{
- $description = $this->_getParam('description', false);
- $pl = $this->getPlaylist();
- if($pl === false){
- $this->view->playlist_error = true;
- return false;
- }
+ $description = $this->_getParam('description', "");
- if($description != false) {
+ try {
+ $pl = $this->getPlaylist();
$pl->setDescription($description);
+ $this->view->description = $pl->getDescription();
+ $this->view->modified = $pl->getLastModified("U");
}
- else {
- $description = $pl->getDescription();
+ catch (PlaylistOutDatedException $e) {
+ $this->playlistOutdated($pl, $e);
+ }
+ catch (PlaylistNotFoundException $e) {
+ $this->playlistNotFound();
+ }
+ catch (Exception $e) {
+ $this->playlistUnknownError($e);
}
-
- $this->view->playlistDescription = $description;
}
}
diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php
index 441ed9a43..ee264df57 100644
--- a/airtime_mvc/application/models/Playlist.php
+++ b/airtime_mvc/application/models/Playlist.php
@@ -89,7 +89,7 @@ class Application_Model_Playlist {
public function setName($p_newname)
{
$this->pl->setDbName($p_newname);
- $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@@ -106,7 +106,7 @@ class Application_Model_Playlist {
public function setDescription($p_description)
{
$this->pl->setDbDescription($p_description);
- $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@@ -123,7 +123,7 @@ class Application_Model_Playlist {
public function setCreator($p_id) {
$this->pl->setDbCreatorId($p_id);
- $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@@ -218,13 +218,18 @@ class Application_Model_Playlist {
{
$file = CcFilesQuery::create()->findPK($p_item, $this->con);
- $entry = $this->plItem;
- $entry["id"] = $file->getDbId();
- $entry["pos"] = $pos;
- $entry["cliplength"] = $file->getDbLength();
- $entry["cueout"] = $file->getDbLength();
+ if (isset($file) && $file->getDbFileExists()) {
+ $entry = $this->plItem;
+ $entry["id"] = $file->getDbId();
+ $entry["pos"] = $pos;
+ $entry["cliplength"] = $file->getDbLength();
+ $entry["cueout"] = $file->getDbLength();
- return $entry;
+ return $entry;
+ }
+ else {
+ throw new Exception("trying to add a file that does not exist.");
+ }
}
/*
@@ -300,7 +305,7 @@ class Application_Model_Playlist {
$pos = $pos + 1;
}
- $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
@@ -383,7 +388,7 @@ class Application_Model_Playlist {
$this->pl = CcPlaylistQuery::create()->findPK($this->id);
- $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
@@ -415,7 +420,7 @@ class Application_Model_Playlist {
$contents[$i]->save($this->con);
}
- $this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
@@ -462,47 +467,52 @@ class Application_Model_Playlist {
$fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn;
$fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut;
+ $this->con->beginTransaction();
+
$errArray= array();
- $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
-
- $row = CcPlaylistcontentsQuery::create()->findPK($id);
-
- if (is_null($row)) {
- $errArray["error"]="Playlist item does not exist.";
- return $errArray;
- }
-
- $clipLength = $row->getDbCliplength();
-
- if(!is_null($fadeIn)) {
-
- $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)) {
- //"Fade In can't be larger than overall playlength.";
- $fadeIn = $clipLength;
- }
- $row->setDbFadein($fadeIn);
- }
- if(!is_null($fadeOut)){
-
- $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)) {
- //Fade Out can't be larger than overall playlength.";
- $fadeOut = $clipLength;
- }
- $row->setDbFadeout($fadeOut);
- }
try {
- $row->save();
+ $row = CcPlaylistcontentsQuery::create()->findPK($id);
+
+ if (is_null($row)) {
+ throw new Exception("Playlist item does not exist.");
+ }
+
+ $clipLength = $row->getDbCliplength();
+
+ if (!is_null($fadeIn)) {
+
+ $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)) {
+ //"Fade In can't be larger than overall playlength.";
+ $fadeIn = $clipLength;
+ }
+ $row->setDbFadein($fadeIn);
+ }
+ if (!is_null($fadeOut)){
+
+ $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)) {
+ //Fade Out can't be larger than overall playlength.";
+ $fadeOut = $clipLength;
+ }
+ $row->setDbFadeout($fadeOut);
+ }
+
+ $row->save($this->con);
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
+ $this->pl->save($this->con);
+
+ $this->con->commit();
}
catch (Exception $e) {
- Logging::log($e->getMessage());
+ $this->con->rollback();
+ throw $e;
}
- return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
+ return array("fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
}
public function setPlaylistfades($fadein, $fadeout) {
@@ -512,7 +522,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition(0)
- ->findOne();
+ ->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), $fadein, null);
}
@@ -521,7 +531,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition($this->getSize()-1)
- ->findOne();
+ ->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), null, $fadeout);
}
@@ -540,126 +550,135 @@ class Application_Model_Playlist {
*/
public function changeClipLength($id, $cueIn, $cueOut)
{
+ $this->con->beginTransaction();
+
$errArray= array();
- $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
- if (is_null($cueIn) && is_null($cueOut)) {
- $errArray["error"]="Cue in and cue out are null.";
- return $errArray;
- }
-
- $row = CcPlaylistcontentsQuery::create()
- ->joinWith(CcFilesPeer::OM_CLASS)
- ->filterByPrimaryKey($id)
- ->findOne();
-
- if (is_null($row)) {
- $errArray["error"]="Playlist item does not exist!.";
- return $errArray;
- }
-
- $oldCueIn = $row->getDBCuein();
- $oldCueOut = $row->getDbCueout();
- $fadeIn = $row->getDbFadein();
- $fadeOut = $row->getDbFadeout();
-
- $file = $row->getCcFiles();
- $origLength = $file->getDbLength();
-
-
- if(!is_null($cueIn) && !is_null($cueOut)){
-
- if($cueOut === ""){
- $cueOut = $origLength;
- }
-
- $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)) {
- $errArray["error"]= "Can't set cue in to be larger than cue out.";
+ try {
+ if (is_null($cueIn) && is_null($cueOut)) {
+ $errArray["error"] = "Cue in and cue out are null.";
return $errArray;
}
- $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)){
- $errArray["error"] = "Can't set cue out to be greater than file length.";
- return $errArray;
+ $row = CcPlaylistcontentsQuery::create()
+ ->joinWith(CcFilesPeer::OM_CLASS)
+ ->filterByPrimaryKey($id)
+ ->findOne($this->con);
+
+ if (is_null($row)) {
+ throw new Exception("Playlist item does not exist.");
}
- $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
- $r = $con->query($sql);
- $cliplength = $r->fetchColumn(0);
+ $oldCueIn = $row->getDBCuein();
+ $oldCueOut = $row->getDbCueout();
+ $fadeIn = $row->getDbFadein();
+ $fadeOut = $row->getDbFadeout();
- $row->setDbCuein($cueIn);
- $row->setDbCueout($cueOut);
- $row->setDBCliplength($cliplength);
+ $file = $row->getCcFiles($this->con);
+ $origLength = $file->getDbLength();
- }
- else if(!is_null($cueIn)) {
+ if (!is_null($cueIn) && !is_null($cueOut)){
- $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)) {
- $errArray["error"] = "Can't set cue in to be larger than cue out.";
- return $errArray;
+ if ($cueOut === ""){
+ $cueOut = $origLength;
+ }
+
+ $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)) {
+ $errArray["error"] = "Can't set cue in to be larger than cue out.";
+ return $errArray;
+ }
+
+ $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)){
+ $errArray["error"] = "Can't set cue out to be greater than file length.";
+ return $errArray;
+ }
+
+ $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
+ $r = $this->con->query($sql);
+ $cliplength = $r->fetchColumn(0);
+
+ $row->setDbCuein($cueIn);
+ $row->setDbCueout($cueOut);
+ $row->setDBCliplength($cliplength);
+
+ }
+ else if (!is_null($cueIn)) {
+
+ $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)) {
+ $errArray["error"] = "Can't set cue in to be larger than cue out.";
+ return $errArray;
+ }
+
+ $sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
+ $r = $this->con->query($sql);
+ $cliplength = $r->fetchColumn(0);
+
+ $row->setDbCuein($cueIn);
+ $row->setDBCliplength($cliplength);
+ }
+ else if (!is_null($cueOut)) {
+
+ if ($cueOut === ""){
+ $cueOut = $origLength;
+ }
+
+ $sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)) {
+ $errArray["error"] = "Can't set cue out to be smaller than cue in.";
+ return $errArray;
+ }
+
+ $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)){
+ $errArray["error"] = "Can't set cue out to be greater than file length.";
+ return $errArray;
+ }
+
+ $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
+ $r = $this->con->query($sql);
+ $cliplength = $r->fetchColumn(0);
+
+ $row->setDbCueout($cueOut);
+ $row->setDBCliplength($cliplength);
}
- $sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
- $r = $con->query($sql);
- $cliplength = $r->fetchColumn(0);
+ $cliplength = $row->getDbCliplength();
- $row->setDbCuein($cueIn);
- $row->setDBCliplength($cliplength);
- }
- else if(!is_null($cueOut)) {
-
- if($cueOut === ""){
- $cueOut = $origLength;
+ $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)){
+ $fadeIn = $cliplength;
+ $row->setDbFadein($fadeIn);
}
- $sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)) {
- $errArray["error"] ="Can't set cue out to be smaller than cue in.";
- return $errArray;
+ $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
+ $r = $this->con->query($sql);
+ if ($r->fetchColumn(0)){
+ $fadeOut = $cliplength;
+ $row->setDbFadein($fadeOut);
}
- $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)){
- $errArray["error"] ="Can't set cue out to be greater than file length.";
- return $errArray;
- }
+ $row->save($this->con);
+ $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
+ $this->pl->save($this->con);
- $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
- $r = $con->query($sql);
- $cliplength = $r->fetchColumn(0);
-
- $row->setDbCueout($cueOut);
- $row->setDBCliplength($cliplength);
+ $this->con->commit();
+ }
+ catch (Exception $e) {
+ $this->con->rollback();
+ throw $e;
}
- $cliplength = $row->getDbCliplength();
-
- $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)){
- $fadeIn = $cliplength;
- $row->setDbFadein($fadeIn);
- }
-
- $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
- $r = $con->query($sql);
- if($r->fetchColumn(0)){
- $fadeOut = $cliplength;
- $row->setDbFadein($fadeOut);
- }
-
- $row->save();
-
- return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut, "length"=>$this->getLength(),
- "fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
+ return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getLength(),
+ "fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
}
public function getAllPLMetaData()
diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php
index 175c2b918..e1016baea 100644
--- a/airtime_mvc/application/models/StoredFile.php
+++ b/airtime_mvc/application/models/StoredFile.php
@@ -556,7 +556,7 @@ class Application_Model_StoredFile {
*
* @return string $runtime
*/
- private static function formatDuration($dt){
+ private static function formatDuration($dt) {
$hours = $dt->format("H");
$min = $dt->format("i");
@@ -569,7 +569,7 @@ class Application_Model_StoredFile {
$hours = $p_interval->format("%h");
$mins = $p_interval->format("%i");
- if( $hours == 0) {
+ if ( $hours == 0) {
$runtime = $p_interval->format("%i:%S");
}
else {
@@ -579,8 +579,7 @@ class Application_Model_StoredFile {
return $runtime;
}
- public static function searchFilesForPlaylistBuilder($datatables)
- {
+ public static function searchFilesForPlaylistBuilder($datatables) {
global $CC_CONFIG;
$displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number");
@@ -610,9 +609,6 @@ class Application_Model_StoredFile {
} else if ($key === "mtime") {
$plSelect .= $key.", ";
$fileSelect .= $key.", ";
- } else if ($key === "track_number") {
- $plSelect .= "NULL AS ".$key.", ";
- $fileSelect .= $key.", ";
} else {
$plSelect .= "NULL AS ".$key.", ";
$fileSelect .= $key.", ";
@@ -624,10 +620,10 @@ class Application_Model_StoredFile {
UNION
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
- $results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
+ $results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
- foreach($results['aaData'] as &$row){
+ foreach ($results['aaData'] as &$row) {
$row['id'] = intval($row['id']);
@@ -649,7 +645,7 @@ class Application_Model_StoredFile {
//TODO url like this to work on both playlist/showbuilder screens.
//datatable stuff really needs to be pulled out and generalized within the project
//access to zend view methods to access url helpers is needed.
- if($type == "au") {
+ if ($type == "au") {
$row['image'] = '';
}
else {
@@ -738,7 +734,7 @@ class Application_Model_StoredFile {
}
//display sql executed in airtime log for testing
- //Logging::log($sql);
+ Logging::log($sql);
$results = $CC_DBC->getAll($sql);
diff --git a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
index 58dc3d549..f48f70dd5 100644
--- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
+++ b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
@@ -19,7 +19,16 @@ var AIRTIME = (function(AIRTIME){
mod.fnDrawCallback = function() {
$('#library_display tr:not(:first)').draggable({
- helper: 'clone',
+ //helper: 'clone',
+ helper: function(){
+ var selected = $('#library_display input:checked').parents('tr');
+ if (selected.length === 0) {
+ selected = $(this);
+ }
+ var container = $('