diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index cca59e7b5..a23f2f1a7 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -60,8 +60,9 @@ class LibraryController extends Zend_Controller_Action try { if (isset($this->obj_sess->id)) { + Logging::info($this->obj_sess->type); $objInfo = Application_Model_Library::getObjInfo($this->obj_sess->type); - Logging::log($this->obj_sess->id); + Logging::info($this->obj_sess->id); $obj = new $objInfo['className']($this->obj_sess->id); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -252,7 +253,7 @@ class LibraryController extends Zend_Controller_Action Application_Model_Webstream::deleteStreams($streams, $user->getId()); } catch (Exception $e) { //TODO: warn user that not all streams could be deleted. - Logging::log($e); + Logging::info($e); } foreach ($files as $id) { @@ -328,7 +329,7 @@ class LibraryController extends Zend_Controller_Action // set MDATA_KEY_FILEPATH $data['MDATA_KEY_FILEPATH'] = $file->getFilePath(); - Logging::log($data['MDATA_KEY_FILEPATH']); + Logging::info($data['MDATA_KEY_FILEPATH']); Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data); $this->_redirect('Library'); @@ -405,7 +406,7 @@ class LibraryController extends Zend_Controller_Action $this->view->type = $type; } } catch (Exception $e) { - Logging::log($e->getMessage()); + Logging::info($e->getMessage()); } } diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 9ff877b6c..5ab8213db 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -10,26 +10,37 @@ class WebstreamController extends Zend_Controller_Action ->addActionContext('edit', 'json') ->addActionContext('delete', 'json') ->initContext(); - //TODO - //$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); } public function newAction() { + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $webstream = new CcWebstream(); //we're not saving this primary key in the DB so it's OK - $webstream->setDbId(-1); + //$webstream->setDbId(-1); $webstream->setDbName("Untitled Webstream"); $webstream->setDbDescription(""); $webstream->setDbUrl("http://"); $webstream->setDbLength("00:00:00"); $webstream->setDbName("Untitled Webstream"); + $webstream->setDbCreatorId($userInfo->id); + $webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC'))); + $webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC'))); + $webstream->save(); + $type = "stream"; + $objInfo = Application_Model_Library::getObjInfo($type); + + $obj = new $objInfo['className']($webstream); + $obj->setName($webstream->getDbName()); + $obj->setMetadata('dc:creator', $userInfo->id); + + $type = "stream"; Application_Model_Library::changePlaylist($obj->getId(), $type); - $this->view->ws = new Application_Model_Webstream($webstream); + $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "new"; $this->view->html = $this->view->render('webstream/webstream.phtml'); } @@ -44,7 +55,7 @@ class WebstreamController extends Zend_Controller_Action } $webstream = CcWebstreamQuery::create()->findPK($id); - $this->view->ws = new Application_Model_Webstream($webstream); + $this->view->obj = new Application_Model_Webstream($webstream); $this->view->action = "edit"; $this->view->html = $this->view->render('webstream/webstream.phtml'); } @@ -64,7 +75,7 @@ class WebstreamController extends Zend_Controller_Action $webstream = CcWebstreamQuery::create()->findPK($id)->delete(); - $this->view->ws = null; + $this->view->obj = null; $this->view->action = "delete"; $this->view->html = $this->view->render('webstream/webstream.phtml'); @@ -73,11 +84,12 @@ class WebstreamController extends Zend_Controller_Action public function isAuthorized($id) { $hasPermission = false; + $user = Application_Model_User::getCurrentUser(); if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $hasPermission = true; } - if ($user->isUserType(UTYPE_HOST)) { + if (!$hasPermission) { if ($id != -1) { $webstream = CcWebstreamQuery::create()->findPK($id); //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index 7d7886e88..25279686e 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -6,7 +6,13 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable public function __construct($webstream) { + //TODO: hacky... + Logging::info("x ".$webstream); + if (is_int($webstream)) { + $this->webstream = CcWebstreamQuery::create()->findPK($webstream); + } else { $this->webstream = $webstream; + } } public function getOrm() @@ -41,6 +47,11 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable return ""; } + public function getLength() + { + return $this->getDefaultLength(); + } + public function getDescription() { return $this->webstream->getDbDescription(); diff --git a/airtime_mvc/application/views/scripts/library/index.phtml b/airtime_mvc/application/views/scripts/library/index.phtml index dd7c9f5f1..6f1d9dcbf 100644 --- a/airtime_mvc/application/views/scripts/library/index.phtml +++ b/airtime_mvc/application/views/scripts/library/index.phtml @@ -4,8 +4,16 @@
type == 'block') { - echo $this->render('playlist/smart-block.phtml'); - } else { - echo $this->render('playlist/playlist.phtml'); - } ?> -
\ No newline at end of file + echo $this->render('playlist/smart-block.phtml'); + } else if ($this->type == 'playlist') { + echo $this->render('playlist/playlist.phtml'); + } else if ($this->type == 'stream') { + echo $this->render('webstream/webstream.phtml'); + } else { + echo $this->render('webstream/webstream.phtml'); + //throw new Exception("Unrecognized type: '{$this->type}'"); + } + + +?> + diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml index 939cfffde..876ee841c 100644 --- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml +++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml @@ -1,20 +1,20 @@ -ws)) : ?> +obj)) : ?> -ws)) : ?> - - ws->getLastModified('U'); ?>"> +obj)) : ?> + + obj->getLastModified('U'); ?>">

- ws->getName(); ?> + obj->getName(); ?>

-

ws->getDefaultLength(); ?>

+

obj->getDefaultLength(); ?>

@@ -22,18 +22,18 @@
- +
- +
- +