diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 2b38f50aa..340ac0a34 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -7,6 +7,7 @@ class WebstreamController extends Zend_Controller_Action $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('new', 'json') ->addActionContext('save', 'json') + ->addActionContext('edit', 'json') ->initContext(); //TODO //$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); @@ -29,6 +30,20 @@ class WebstreamController extends Zend_Controller_Action */ } + public function editAction() + { + $request = $this->getRequest(); + + + $id = $request->getParam("id"); + if (is_null($id)) { + throw new Exception("Missing parameter 'id'"); + } + + $this->view->ws = new Application_Model_Webstream($id); + $this->view->html = $this->view->render('webstream/webstream.phtml'); + } + public function saveAction() { $request = $this->getRequest(); diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index 8ff6be973..6eba67789 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -4,34 +4,52 @@ class Application_Model_Webstream{ private $id; - public function __construct($id) + public function __construct($id=-1) { - $this->id = $id; + if ($id == -1) { + $this->webstream = new CcWebstream(); + + //We're not saving this object in the database, so -1 ID is OK. + $this->webstream->setDbId(-1); + $this->webstream->setDbName("Untitled Webstream"); + $this->webstream->setDbDescription(""); + $this->webstream->setDbUrl("http://"); + $this->webstream->setDbLength("00h 00m"); + $this->webstream->setDbName("Untitled Webstream"); + } else { + $this->id = $id; + $this->webstream = CcWebstreamQuery::create()->findPK($this->id); + } } - public static function getName() + public function getName() { - return "Default"; + return $this->webstream->getDbName(); } - public static function getId() + public function getId() { - return "id"; + return $this->webstream->getDbId(); } - public static function getLastModified($p_type) + public function getLastModified($p_type) { return "modified"; } - public static function getDefaultLength() + public function getDefaultLength() { - return "length"; + return $this->webstream->getDbLength(); } - public static function getDescription() + public function getDescription() { - return "desc"; + return $this->webstream->getDbDescription(); + } + + public function getUrl() + { + return $this->webstream->getDbUrl(); } public function getMetadata() @@ -41,11 +59,11 @@ class Application_Model_Webstream{ $username = $subjs->getDbLogin(); return array( - "name" => $webstream->getDbName(), - "length" => $webstream->getDbLength(), - "description" => $webstream->getDbDescription(), + "name" => $this->webstream->getDbName(), + "length" => $this->webstream->getDbLength(), + "description" => $this->webstream->getDbDescription(), "login"=> $username, - "url" => $webstream->getDbUrl(), + "url" => $this->webstream->getDbUrl(), ); } @@ -93,7 +111,8 @@ Array public static function analyzeFormData($request) { $valid = array("length" => array(true, ''), - "url" => array(true, '')); + "url" => array(true, ''), + "name" => array(true, '')); $length = trim($request->getParam("length")); $result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches); @@ -120,6 +139,19 @@ Array $valid['name'][1] = 'Webstream name cannot be empty'; } + $id = trim($request->getParam("id")); + + if (!is_null($id)) { + // user has performed a create stream action instead of edit + // stream action. Check if user has the rights to edit this stream. + + Logging::log("CREATE"); + } else { + Logging::log("EDIT"); + } + + + return $valid; } @@ -140,6 +172,7 @@ Array $length = trim($request->getParam("length")); $result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches); + if ($result == 1 && count($matches) == 3) { $hours = $matches[1]; $minutes = $matches[2]; @@ -150,9 +183,15 @@ Array //in the controller throw new Exception("Invalid date format: $length"); } + + $id = $request->getParam("id"); + + if (is_null($id)) { + $webstream = new CcWebstream(); + } else { + $webstream = CcWebstreamQuery::create()->findPK($id); + } - #TODO: These should be validated by a Zend Form. - $webstream = new CcWebstream(); $webstream->setDbName($request->getParam("name")); $webstream->setDbDescription($request->getParam("description")); $webstream->setDbUrl($request->getParam("url")); diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml index 4761f2ac9..6f5653cdc 100644 --- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml +++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml @@ -26,12 +26,12 @@
- +
- +
diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 3bad359a7..54f3ae353 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -611,12 +611,18 @@ var AIRTIME = (function(AIRTIME) { callback = function() { document.location.href = oItems.edit.url; }; - } - else { + } else if (data.ftype === "playlist" || data.ftype === "block") { callback = function() { - //TODO - AIRTIME.playlist.fnEdit(data.id, data.ftype); + var url = '/Playlist/edit'; + AIRTIME.playlist.fnEdit(data.id, data.ftype, url); }; + } else if (data.ftype === "stream") { + callback = function() { + var url = '/Webstream/edit'; + AIRTIME.playlist.fnEdit(data.id, data.ftype, url); + } + } else { + throw new Exception("Unknown type: " + data.ftype); } oItems.edit.callback = callback; } diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 4bb4d743d..9c6601f67 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -532,6 +532,7 @@ var AIRTIME = (function(AIRTIME){ //stream url //default_length //playlist name + var id = $pl.find("#ws_id").attr("value"); var description = $pl.find("#description").val(); var streamurl = $pl.find("#streamurl-element input").val(); var length = $pl.find("#streamlength-element input").val(); @@ -542,7 +543,7 @@ var AIRTIME = (function(AIRTIME){ var url = 'Webstream/save'; $.post(url, - {format: "json", description: description, url:streamurl, length: length, name: name}, + {format: "json", id:id, description: description, url:streamurl, length: length, name: name}, function(json){ if (json.analysis){ for (var s in json.analysis){ @@ -730,8 +731,7 @@ var AIRTIME = (function(AIRTIME){ }); }; - mod.fnEdit = function(id, type) { - var url = '/Playlist/edit'; + mod.fnEdit = function(id, type, url) { stopAudioPreview(); @@ -741,6 +741,7 @@ var AIRTIME = (function(AIRTIME){ openPlaylist(json); }); }; + mod.fnDelete = function(plid) { var url, id, lastMod; diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 5cbda60b0..ccc6a884f 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -8,7 +8,7 @@ exec 2>&1 if [ "$(id -u)" != "0" ]; then echo "Please run as root user." - exit 1 + exit 1 fi #Current dir