diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index ec34f68f2..c47f5486d 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -20,31 +20,15 @@ class ShowbuilderController extends Zend_Controller_Action { $CC_CONFIG = Config::getConfig(); - + $request = $this->getRequest(); - + $baseUrl = Application_Common_OsPath::getBaseDir(); - + $user = Application_Model_User::GetCurrentUser(); $userType = $user->getType(); $this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );"); - $data = Application_Model_Preference::getCurrentLibraryTableSetting(); - if (!is_null($data)) { - $libraryTable = json_encode($data); - $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );"); - } else { - $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );"); - } - - $data = Application_Model_Preference::getTimelineDatatableSetting(); - if (!is_null($data)) { - $timelineTable = json_encode($data); - $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );"); - } else { - $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );"); - } - $this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); @@ -57,14 +41,12 @@ class ShowbuilderController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'css/media_library.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $refer_sses = new Zend_Session_Namespace('referrer'); if ($request->isPost()) { @@ -141,6 +123,28 @@ class ShowbuilderController extends Zend_Controller_Action $this->view->disableLib = $disableLib; $this->view->showLib = $showLib; + //only include library things on the page if the user can see it. + if (!$disableLib) { + $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + + $data = Application_Model_Preference::getCurrentLibraryTableSetting(); + if (!is_null($data)) { + $libraryTable = json_encode($data); + $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );"); + } else { + $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );"); + } + } + + $data = Application_Model_Preference::getTimelineDatatableSetting(); + if (!is_null($data)) { + $timelineTable = json_encode($data); + $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );"); + } else { + $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', '' );"); + } + //populate date range form for show builder. $now = time(); $from = $request->getParam("from", $now); @@ -270,8 +274,8 @@ class ShowbuilderController extends Zend_Controller_Action $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); - $opts = array("myShows" => $my_shows, - "showFilter" => $show_filter, + $opts = array("myShows" => $my_shows, + "showFilter" => $show_filter, "showInstanceFilter" => $show_instance_filter); $showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts); diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index e3b18b19f..4f03e6dfa 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -178,7 +178,12 @@ var AIRTIME = (function(AIRTIME){ }; mod.checkToolBarIcons = function() { - AIRTIME.library.checkAddButton(); + + //library may not be on the page. + if (AIRTIME.library !== undefined) { + AIRTIME.library.checkAddButton(); + } + mod.checkSelectButton(); mod.checkTrimButton(); mod.checkDeleteButton(); diff --git a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js index e411a4c1d..c2210a3ae 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js @@ -186,7 +186,11 @@ AIRTIME = (function(AIRTIME) { AIRTIME.showbuilder.fnServerData.start = oRange.start; AIRTIME.showbuilder.fnServerData.end = oRange.end; - AIRTIME.library.libraryInit(); + //the user might not have the library on the page (guest user) + if (AIRTIME.library !== undefined) { + AIRTIME.library.libraryInit(); + } + AIRTIME.showbuilder.builderDataTable(); setWidgetSize();