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>