CC-3174 Show Builder

experimenting
This commit is contained in:
Naomi Aro 2012-01-16 09:56:57 +01:00
parent 561b508162
commit 859213b760
12 changed files with 266 additions and 101 deletions

View file

@ -33,11 +33,11 @@ date_default_timezone_set(Application_Model_Preference::GetTimezone());
Zend_Validate::setDefaultNamespaces("Zend");
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new RabbitMqPlugin());
$front->registerPlugin(new RabbitMqPlugin());
Logging::debug($_SERVER['REQUEST_URI']);
/* The bootstrap class should only be used to initialize actions that return a view.
/* The bootstrap class should only be used to initialize actions that return a view.
Actions that return JSON will not use the bootstrap class! */
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
@ -77,7 +77,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript');
if (Application_Model_Preference::GetPlanLevel() != "disabled"
&& $_SERVER['REQUEST_URI'] != '/Dashboard/stream-player') {
$client_id = Application_Model_Preference::GetClientId();
@ -102,12 +102,12 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
if (APPLICATION_ENV == "development"){
global $CC_DBC;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array('Variables',
'plugins' => array('Variables',
'Exception',
'Memory',
'Time')
@ -119,12 +119,12 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$frontController->registerPlugin($debug);
}
}
protected function _initRouter()
{
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->addRoute(
'password-change',
new Zend_Controller_Router_Route('password-change/:user_id/:token', array(
@ -132,6 +132,16 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'controller' => 'auth',
'action' => 'password-change',
)));
/*
$router->addRoute(
'show-builder',
new Zend_Controller_Router_Route('show/builder/:show_instance_id/:user_id', array(
'module' => 'default',
'controller' => 'showbuilder',
'action' => 'index',
)));
*/
}
}

View file

@ -24,6 +24,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('dashboard'))
->add(new Zend_Acl_Resource('preference'))
->add(new Zend_Acl_Resource('recorder'))
->add(new Zend_Acl_Resource('showbuilder'))
->add(new Zend_Acl_Resource('auth'));
/** Creating permissions */
@ -42,6 +43,7 @@ $ccAcl->allow('G', 'index')
->allow('H', 'library')
->allow('H', 'search')
->allow('H', 'playlist')
->allow('H', 'showbuilder')
->allow('A', 'user')
->allow('A', 'systemstatus')
->allow('A', 'preference');

View file

@ -23,7 +23,15 @@ class LibraryController extends Zend_Controller_Action
$this->search_sess = new Zend_Session_Namespace("search");
}
public function indexAction()
public function indexAction() {
$this->_helper->layout->setLayout('library');
$this->_helper->actionStack('library', 'library');
$this->_helper->actionStack('index', 'playlist');
}
public function libraryAction()
{
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -43,7 +51,6 @@ class LibraryController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css');
$this->_helper->layout->setLayout('library');
$this->_helper->viewRenderer->setResponseSegment('library');
$form = new Application_Form_AdvancedSearch();
@ -53,8 +60,6 @@ class LibraryController extends Zend_Controller_Action
$this->search_sess->next_row[1] = 2;
$this->view->form = $form;
$this->view->md = $this->search_sess->md;
$this->_helper->actionStack('index', 'playlist');
}
public function contextMenuAction()
@ -183,7 +188,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->id = $id;
}
}
public function deleteGroupAction()
{
$ids = $this->_getParam('ids');
@ -217,7 +222,7 @@ class LibraryController extends Zend_Controller_Action
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
}
}
$this->view->ids = $ids;
}
}
@ -228,7 +233,7 @@ class LibraryController extends Zend_Controller_Action
$post = $this->getRequest()->getPost();
Logging::log(print_r($post, true));
$datatables = Application_Model_StoredFile::searchFilesForPlaylistBuilder($post);
//format clip lengh to 1 decimal
foreach($datatables["aaData"] as &$data){
if($data['ftype'] == 'audioclip'){

View file

@ -0,0 +1,60 @@
<?php
class ShowbuilderController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('schedule', 'json')
->initContext();
}
public function indexAction() {
$request = $this->getRequest();
$user_id = $request->getParam("uid", 0);
$show_instance_id = $request->getParam("sid", 0);
try {
$user = new Application_Model_User($user_id);
$show_instance = new Application_Model_ShowInstance($show_instance_id);
}
catch(Exception $e) {
$this->_helper->redirector('denied', 'error');
}
//user is allowed to schedule this show.
if ($user->isAdmin() || $user->isHost($show_instance->getShowId())) {
$this->_helper->layout->setLayout('builder');
$this->_helper->actionStack('library', 'library');
$this->_helper->actionStack('builder', 'showbuilder');
}
else {
$this->_helper->redirector('denied', 'error');
}
}
public function builderAction() {
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar_orig.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css');
$this->_helper->viewRenderer->setResponseSegment('builder');
}
public function eventFeedAction() {
}
public function scheduleAction() {
}
}

View file

@ -0,0 +1,28 @@
<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo $this->headTitle() ?>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
</head>
<body>
<div id="Panel">
<div class="logo"></div>
<?php echo $this->versionNotify() ?>
<?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs(), "is_trial"=>$this->isTrial(), "trial_remain"=> $this->trialRemaining())) ?>
<?php $partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial); ?>
<?php echo $this->navigation()->menu() ?>
</div>
<div class="wrapper">
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
<div id="show_builder" class="ui-widget ui-widget-content block-shadow omega-block"><?php echo $this->layout()->builder ?></div>
</div>
</body>
</html>

View file

@ -11,11 +11,16 @@ class Application_Model_User {
public function __construct($userId)
{
if (strlen($userId)==0){
if (empty($userId)){
$this->_userInstance = $this->createUser();
} else {
}
else {
$this->_userInstance = CcSubjsQuery::create()->findPK($userId);
}
if (is_null($this->_userInstance)){
throw new Exception();
}
}
}
public function getId() {
@ -29,7 +34,7 @@ class Application_Model_User {
public function isAdmin() {
return $this->isUserType(UTYPE_ADMIN);
}
public function isUserType($type, $showId=''){
if(is_array($type)){
$result = false;
@ -62,99 +67,99 @@ class Application_Model_User {
}
}
}
public function setLogin($login){
$user = $this->_userInstance;
$user->setDbLogin($login);
$user->setDbLogin($login);
}
public function setPassword($password){
$user = $this->_userInstance;
$user->setDbPass(md5($password));
$user->setDbPass(md5($password));
}
public function setFirstName($firstName){
$user = $this->_userInstance;
$user->setDbFirstName($firstName);
$user->setDbFirstName($firstName);
}
public function setLastName($lastName){
$user = $this->_userInstance;
$user->setDbLastName($lastName);
$user->setDbLastName($lastName);
}
public function setType($type){
$user = $this->_userInstance;
$user->setDbType($type);
$user->setDbType($type);
}
public function setEmail($email){
$user = $this->_userInstance;
$user->setDbEmail($email);
$user->setDbEmail($email);
}
public function setSkype($skype){
$user = $this->_userInstance;
$user->setDbSkypeContact($skype);
$user->setDbSkypeContact($skype);
}
public function setJabber($jabber){
$user = $this->_userInstance;
$user->setDbJabberContact($jabber);
$user->setDbJabberContact($jabber);
}
public function getLogin(){
$user = $this->_userInstance;
return $user->getDbLogin();
}
return $user->getDbLogin();
}
public function getPassword(){
$user = $this->_userInstance;
return $user->getDbPass();
return $user->getDbPass();
}
public function getFirstName(){
$user = $this->_userInstance;
return $user->getDbFirstName();
return $user->getDbFirstName();
}
public function getLastName(){
$user = $this->_userInstance;
return $user->getDbLastName();
return $user->getDbLastName();
}
public function getType(){
$user = $this->_userInstance;
return $user->getDbType();
return $user->getDbType();
}
public function getEmail(){
$user = $this->_userInstance;
return $user->getDbEmail();
return $user->getDbEmail();
}
public function getSkype(){
$user = $this->_userInstance;
return $user->getDbSkypeContact();
return $user->getDbSkypeContact();
}
public function getJabber(){
$user = $this->_userInstance;
return $user->getDbJabberContact();
return $user->getDbJabberContact();
}
public function save(){
$this->_userInstance->save();
}
public function delete(){
if (!$this->_userInstance->isDeleted())
$this->_userInstance->delete();
}
private function createUser() {
$user = new CcSubjs();
$user = new CcSubjs();
return $user;
}
@ -165,7 +170,7 @@ class Application_Model_User {
$sql_gen = "SELECT login AS value, login AS label, id as index FROM cc_subjs ";
$sql = $sql_gen;
if(is_array($type)) {
for($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
@ -175,9 +180,9 @@ class Application_Model_User {
else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen ." WHERE (". $sql_type.") ";
if(!is_null($search)) {
$like = "login ILIKE '%{$search}%'";
@ -185,17 +190,17 @@ class Application_Model_User {
}
$sql = $sql ." ORDER BY login";
return $CC_DBC->GetAll($sql);
return $CC_DBC->GetAll($sql);
}
public static function getUserCount($type=NULL){
global $CC_DBC;
$sql;
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
if(!isset($type)){
$sql = $sql_gen;
}
@ -209,21 +214,21 @@ class Application_Model_User {
else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen ." WHERE (". $sql_type.") ";
}
return $CC_DBC->GetOne($sql);
}
public static function getHosts($search=NULL) {
return Application_Model_User::getUsers(array('H'), $search);
}
public static function getUsersDataTablesInfo($datatables_post) {
$fromTable = "cc_subjs";
// get current user
$username = "";
$auth = Zend_Auth::getInstance();
@ -231,29 +236,29 @@ class Application_Model_User {
if ($auth->hasIdentity()) {
$username = $auth->getIdentity()->login;
}
$res = Application_Model_StoredFile::searchFiles($fromTable, $datatables_post);
// mark record which is for the current user
foreach($res['aaData'] as &$record){
if($record[1] == $username){
$record[5] = "self";
}
}
return $res;
}
public static function getUserData($id){
global $CC_DBC;
$sql = "SELECT login, first_name, last_name, type, id, email, skype_contact, jabber_contact"
." FROM cc_subjs"
." WHERE id = $id";
return $CC_DBC->GetRow($sql);
}
public static function GetUserID($login){
$user = CcSubjsQuery::create()->findOneByDbLogin($login);
if (is_null($user)){

View file

@ -1,18 +0,0 @@
<ul>
<li><a href="#simpleSearch">Search</a></li>
<!--<li><a href="#advancedSearch">Advanced Search</a></li>-->
</ul>
<div id="simpleSearch">
<div id="import_status" style="visibility:hidden">File import in progress...</div>
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable">
</table>
</div>
<!--
<div id="advancedSearch">
<div id="search">
<?php //echo $this->form; ?>
</div>
<div><?php //echo var_dump($this->md); ?></div>
</div>
-->

View file

@ -0,0 +1,9 @@
<ul>
<li><a href="#simpleSearch">Search</a></li>
</ul>
<div id="simpleSearch">
<div id="import_status" style="visibility:hidden">File import in progress...</div>
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable">
</table>
</div>

View file

@ -0,0 +1 @@
<div style="width:800px" id="show_builder"></div>

View file

@ -73,7 +73,7 @@ function confirmDeletePlaylist(params){
}
function openFileOnSoundCloud(link){
window.open(link)
window.open(link);
}
function checkImportStatus(){
@ -84,7 +84,7 @@ function checkImportStatus(){
}else{
div.css('visibility', 'hidden');
}
})
});
}
function deletePlaylist(json) {
@ -152,7 +152,7 @@ function addProgressIcon(id) {
$("#au_"+id).find("td.library_title").find("span").removeClass();
$("span[id="+id+"]").addClass("small-icon progress");
}else{
$("#au_"+id).find("td.library_title").append('<span id="'+id+'" class="small-icon progress"></span>')
$("#au_"+id).find("td.library_title").append('<span id="'+id+'" class="small-icon progress"></span>');
}
}
@ -167,7 +167,7 @@ function checkSCUploadStatus(){
$("span[id="+id+"]").removeClass("progress").addClass("sc-error");
}
});
})
});
}
function addQtipToSCIcons(){
@ -190,7 +190,7 @@ function addQtipToSCIcons(){
show: {
ready: true // Needed to make it show on first mouseover event
}
})
});
}else if($(this).hasClass("soundcloud")){
$(this).qtip({
content: {
@ -200,7 +200,7 @@ function addQtipToSCIcons(){
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "The soundcloud id for this file is: "+json.sc_id)
this.set('content.text', "The soundcloud id for this file is: "+json.sc_id);
}
}
},
@ -216,7 +216,7 @@ function addQtipToSCIcons(){
show: {
ready: true // Needed to make it show on first mouseover event
}
})
});
}else if($(this).hasClass("sc-error")){
$(this).qtip({
content: {
@ -227,7 +227,7 @@ function addQtipToSCIcons(){
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "There was error while uploading to soundcloud.<br>"+"Error code: "+json.error_code+
"<br>"+"Error msg: "+json.error_msg+"<br>")
"<br>"+"Error msg: "+json.error_msg+"<br>");
}
}
},
@ -243,7 +243,7 @@ function addQtipToSCIcons(){
show: {
ready: true // Needed to make it show on first mouseover event
}
})
});
}
});
}
@ -251,8 +251,8 @@ function addQtipToSCIcons(){
function addMetadataQtip(){
var tableRow = $('#library_display tbody tr');
tableRow.each(function(){
var title = $(this).find('td.library_title').html()
var info = $(this).attr("id")
var title = $(this).find('td.library_title').html();
var info = $(this).attr("id");
info = info.split("_");
var id = info[1];
var type = info[0];
@ -267,7 +267,7 @@ function addMetadataQtip(){
type: "post",
data: ({format: "html", id : id, type: type}),
success: function(data, status){
this.set('content.text', data)
this.set('content.text', data);
}
}
},
@ -294,12 +294,12 @@ function addMetadataQtip(){
}
}
}
})
})
});
});
tableRow.bind('contextmenu', function(e){
return false;
})
});
}
/**
@ -570,5 +570,5 @@ $(document).ready(function() {
setInterval( "checkImportStatus()", 5000 );
setInterval( "checkSCUploadStatus()", 5000 );
addQtipToSCIcons()
addQtipToSCIcons();
});

View file

@ -0,0 +1,63 @@
function getFullCalendarEvents(start, end, callback) {
var url, unix_ts_start, unix_ts_end;
unix_ts_start = Math.round(start.getTime() / 1000),
unix_ts_end = Math.round(end.getTime() / 1000);
url = '/Schedule/event-feed';
var d = new Date();
$.get(url, {format: "json", start: unix_ts_start, end: unix_ts_end, cachep: d.getTime()}, function(json){
callback(json.events);
});
}
$(document).ready(function() {
$('#show_builder').fullCalendar({
header: {
left: '',
center: '',
right: ''
},
defaultView: 'agendaDay',
allDaySlot: false,
theme: true,
events: getFullCalendarEvents,
axisFormat: 'H:mm:ss',
slotMinutes: 1,
timeFormat: {
agenda: 'H:mm:ss{ - H:mm:ss}'
},
minTime: '17:00',
maxTime: '18:00',
droppable: true, // this allows things to be dropped onto the calendar !!!
drop: function(date, allDay) { // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
//var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
//var copiedEventObject = $.extend({}, originalEventObject);
var copiedEventObject = {};
// assign it the date that was reported
copiedEventObject.title = "test title";
copiedEventObject.start = date;
var end = new Date(date.getTime());
end.setMinutes(end.getMinutes() + 5);
end.setSeconds(end.getSeconds() + 5);
copiedEventObject.end = end;
copiedEventObject.allDay = allDay;
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('#show_builder').fullCalendar('renderEvent', copiedEventObject, true);
}
});
});