CC-1665: Scheduled stream rebroadcasting and recording

-more work to make webstreams behave like playlist creator
This commit is contained in:
Martin Konecny 2012-08-21 18:55:38 -04:00
parent 462542bf68
commit 9885374d34
5 changed files with 57 additions and 25 deletions

View File

@ -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());
}
}

View File

@ -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.

View File

@ -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();

View File

@ -4,8 +4,16 @@
<div id="side_playlist" class="pl-content ui-widget ui-widget-content block-shadow omega-block padded">
<?php if ($this->type == 'block') {
echo $this->render('playlist/smart-block.phtml');
} else {
echo $this->render('playlist/playlist.phtml');
} ?>
</div>
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}'");
}
?>
</div>

View File

@ -1,20 +1,20 @@
<button id="ws_new" class="ui-button ui-widget ui-state-default" role="button" aria-disabled="false">New</button>
<?php if (isset($this->ws)) : ?>
<?php if (isset($this->obj)) : ?>
<button id="ws_delete" class="ui-button ui-widget ui-state-default" <?php if ($this->action == "new"): ?>style="display:none;"<?php endif; ?> role="button" aria-disabled="false">Delete</button>
<?php endif; ?>
<?php if (isset($this->ws)) : ?>
<input id="obj_id" type="hidden" value="<?php echo $this->ws->getId(); ?>"></input>
<input id="obj_lastMod" type="hidden" value="<?php echo "1";//$this->ws->getLastModified('U'); ?>"></input>
<?php if (isset($this->obj)) : ?>
<input id="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>"></input>
<input id="obj_lastMod" type="hidden" value="<?php echo "1";//$this->obj->getLastModified('U'); ?>"></input>
<input id="obj_type" type="hidden" value="webstream"></input>
<div class="status" style="display:none;"></div>
<div class="playlist_title">
<div id="name-error" class="errors" style="display:none;"></div>
<h3 id="ws_name">
<a id="playlist_name_display" contenteditable="true"><?php echo $this->ws->getName(); ?></a>
<a id="playlist_name_display" contenteditable="true"><?php echo $this->obj->getName(); ?></a>
</h3>
<h4 id="ws_length"><?php echo $this->ws->getDefaultLength(); ?></h4>
<h4 id="ws_length"><?php echo $this->obj->getDefaultLength(); ?></h4>
</div>
<fieldset class="toggle" id="fieldset-metadate_change">
@ -22,18 +22,18 @@
<dl class="zend_form">
<dt id="description-label"><label for="description">Description</label></dt>
<dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->ws->getDescription(); ?></textarea>
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea>
</dd>
<dt id="submit-label" style="display: none;">&nbsp;</dt>
<div id="url-error" class="errors" style="display:none;"></div>
<dt id="streamurl-label"><label for="streamurl">Stream URL:</label></dt>
<dd id="streamurl-element">
<input type="text" value="<?php echo $this->ws->getUrl(); ?>" size="40"/>
<input type="text" value="<?php echo $this->obj->getUrl(); ?>" size="40"/>
</dd>
<div id="length-error" class="errors" style="display:none;"></div>
<dt id="streamlength-label"><label for="streamlength">Default Length:</label></dt>
<dd id="streamlength-element">
<input type="text" value="<?php echo $this->ws->getDefaultLength() ?>"/>
<input type="text" value="<?php echo $this->obj->getDefaultLength() ?>"/>
</dd>
<dd id="submit-element" class="buttons">
<input class="ui-button ui-state-default" type="submit" value="Save" id="webstream_save" name="submit">