diff --git a/LICENSE_3RD_PARTY b/LICENSE_3RD_PARTY index f935ac900..fff6fc84d 100644 --- a/LICENSE_3RD_PARTY +++ b/LICENSE_3RD_PARTY @@ -111,10 +111,6 @@ Non-linked code: * Server Browse - Web site: http://code.google.com/p/jq-serverbrowse/ - License: BSD 2-Clause - - * meioMask - - Web site: http://www.meiocodigo.com/ - - License: MIT ------------- Media-Monitor diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 953c53e7b..514fcf6d5 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -58,7 +58,8 @@ class ApiController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $api_key = $this->_getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -333,7 +334,8 @@ class ApiController extends Zend_Controller_Action $api_key = $this->_getParam('api_key'); - if(!in_array($api_key, $CC_CONFIG["apiKey"])) + if(!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource. '; @@ -355,7 +357,8 @@ class ApiController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $api_key = $this->_getParam('api_key'); - if(!in_array($api_key, $CC_CONFIG["apiKey"])) + if(!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -378,7 +381,8 @@ class ApiController extends Zend_Controller_Action global $CC_CONFIG; $api_key = $this->_getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -411,7 +415,8 @@ class ApiController extends Zend_Controller_Action global $CC_CONFIG; $api_key = $this->_getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -435,7 +440,8 @@ class ApiController extends Zend_Controller_Action global $CC_CONFIG; $api_key = $this->_getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -542,7 +548,8 @@ class ApiController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $api_key = $this->_getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -564,7 +571,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -667,7 +675,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -683,7 +692,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -711,7 +721,8 @@ class ApiController extends Zend_Controller_Action $api_key = $request->getParam('api_key'); $path = base64_decode($request->getParam('path')); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -728,7 +739,8 @@ class ApiController extends Zend_Controller_Action $api_key = $request->getParam('api_key'); $path = base64_decode($request->getParam('path')); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -745,7 +757,8 @@ class ApiController extends Zend_Controller_Action $api_key = $request->getParam('api_key'); $path = base64_decode($request->getParam('path')); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -760,7 +773,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -777,14 +791,13 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); $getDiskInfo = $request->getParam('diskinfo') == "true"; - /* - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; exit; } - */ $status = array( "platform"=>Application_Model_Systemstatus::GetPlatformInfo(), @@ -846,7 +859,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -926,7 +940,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -945,7 +960,8 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; @@ -979,7 +995,8 @@ class ApiController extends Zend_Controller_Action $password = $request->getParam('password'); $djtype = $request->getParam('djtype'); - if (!in_array($api_key, $CC_CONFIG["apiKey"])) + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && + is_null(Zend_Auth::getInstance()->getStorage()->read())) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 06b9486e3..ef5c3b475 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -142,7 +142,6 @@ class PreferenceController extends Zend_Controller_Action $baseUrl = $request->getBaseUrl(); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); // get current settings $temp = Application_Model_StreamSetting::getStreamSetting(); @@ -236,7 +235,7 @@ class PreferenceController extends Zend_Controller_Action $live_stream_subform->updateConnectionURLs(); } - $this->view->confirm_pypo_restart_text = "Updating settings will temporarily interrupt any currently playing shows. Click \'OK\' to continue."; + $this->view->confirm_pypo_restart_text = "If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings)."; $this->view->num_stream = $num_of_stream; $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); @@ -261,16 +260,18 @@ class PreferenceController extends Zend_Controller_Action else { $path = $path.'/'; - $handle = opendir($path); - while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != "..") { - //only show directories that aren't private. - if (is_dir($path.$file) && substr($file, 0, 1) != ".") { - $element = array(); - $element["name"] = $file; - $element["isFolder"] = true; - $element["isError"] = false; - $result[$file] = $element; + $handle = opendir($path); + if ($handle !== false){ + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") { + //only show directories that aren't private. + if (is_dir($path.$file) && substr($file, 0, 1) != ".") { + $element = array(); + $element["name"] = $file; + $element["isFolder"] = true; + $element["isError"] = false; + $result[$file] = $element; + } } } } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index ac023a68c..fad59eb3b 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -28,6 +28,8 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('content-context-menu', 'json') ->addActionContext('set-time-scale', 'json') ->addActionContext('set-time-interval', 'json') + ->addActionContext('edit-show-instance', 'json') + ->addActionContext('dj-edit-show', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -52,7 +54,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); @@ -88,6 +89,9 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); + if($user->isUserType(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)){ + $this->view->preloadShowForm = true; + } $this->view->headScript()->appendScript("var weekStart = ".Application_Model_Preference::GetWeekStartDay().";"); } @@ -429,6 +433,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->percentFilled = $show->getPercentScheduled(); $this->view->showContent = $show->getShowListContent(); $this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml'); + $this->view->showTitle = $show->getName(); unset($this->view->showContent); } @@ -444,6 +449,10 @@ class ScheduleController extends Zend_Controller_Action // repeating shows. It's value is either "instance","rebroadcast", or "all" $type = $this->_getParam('type'); + if ($type == "instance"){ + $this->view->action = "edit-show-instance"; + } + try{ $showInstance = new Application_Model_ShowInstance($showInstanceId); }catch(Exception $e){ @@ -457,6 +466,10 @@ class ScheduleController extends Zend_Controller_Action if(!($isAdminOrPM || $isDJ)) { return; } + + if($isDJ){ + $this->view->action = "dj-edit-show"; + } $formWhat = new Application_Form_AddShowWhat(); $formWho = new Application_Form_AddShowWho(); @@ -604,10 +617,50 @@ class ScheduleController extends Zend_Controller_Action } public function getFormAction(){ - Application_Model_Schedule::createNewFormSections($this->view); - $this->view->form = $this->view->render('schedule/add-show-form.phtml'); + if($user->isUserType(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)){ + Application_Model_Schedule::createNewFormSections($this->view); + $this->view->form = $this->view->render('schedule/add-show-form.phtml'); + } } + + public function editShowInstanceAction(){ + $js = $this->_getParam('data'); + $data = array(); + //need to convert from serialized jQuery array. + foreach($js as $j){ + $data[$j["name"]] = $j["value"]; + } + + + } + + public function djEditShowAction(){ + $js = $this->_getParam('data'); + $data = array(); + + //need to convert from serialized jQuery array. + foreach($js as $j){ + $data[$j["name"]] = $j["value"]; + } + + //update cc_show + $show = new Application_Model_Show($data["add_show_id"]); + $show->setAirtimeAuthFlag($data["cb_airtime_auth"]); + $show->setCustomAuthFlag($data["cb_custom_auth"]); + $show->setCustomUsername($data["custom_username"]); + $show->setCustomPassword($data["custom_password"]); + + $this->view->edit = true; + } + + //for 2.2 + /* + public function editShowAction(){ + + } + */ + public function addShowAction() { $js = $this->_getParam('data'); @@ -619,13 +672,6 @@ class ScheduleController extends Zend_Controller_Action } $show = new Application_Model_Show($data['add_show_id']); - - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - - $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - $isDJ = $user->isHost($show->getId()); - $startDateModified = true; if ($data['add_show_id'] != -1 && !array_key_exists('add_show_start_date', $data)){ //show is being updated and changing the start date was disabled, since the @@ -642,6 +688,11 @@ class ScheduleController extends Zend_Controller_Action if($data['add_show_day_check'] == "") { $data['add_show_day_check'] = null; } + + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + $user = new Application_Model_User($userInfo->id); + $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + $isDJ = $user->isHost($show->getId()); $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $record = false; @@ -785,7 +836,7 @@ class ScheduleController extends Zend_Controller_Action if (!$startDateModified){ $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); } - + $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } diff --git a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php index 8e1601819..b936960fc 100644 --- a/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowAbsoluteRebroadcastDates.php @@ -36,8 +36,7 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index e4b1b9d91..ad4c66c4d 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -8,7 +8,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm { $description1 = "This follows the same security pattern for the shows: if no users are explicitly set for the show, then anyone with a valid airtime login can connect to the stream, otherwise if there are users assigned to the show, then only those users can connect."; $cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth"); - $cb_airtime_auth->setLabel("Connect using Airtime username & password") + $cb_airtime_auth->setLabel("Use Airtime Authentication") ->setDescription($description1) ->setRequired(false) ->setDecorators(array('ViewHelper')); @@ -16,7 +16,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm $description2 = "Specifiy custom athentification which will work for only the show."; $cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth"); - $cb_custom_auth ->setLabel("Custom") + $cb_custom_auth ->setLabel("Use Custom Authentication") ->setDescription($description2) ->setRequired(false) ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/forms/AddShowRR.php b/airtime_mvc/application/forms/AddShowRR.php index 4c6e5b4b2..9f3778df1 100644 --- a/airtime_mvc/application/forms/AddShowRR.php +++ b/airtime_mvc/application/forms/AddShowRR.php @@ -24,8 +24,7 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowRebroadcastDates.php b/airtime_mvc/application/forms/AddShowRebroadcastDates.php index b4b352624..58afa7f0c 100644 --- a/airtime_mvc/application/forms/AddShowRebroadcastDates.php +++ b/airtime_mvc/application/forms/AddShowRebroadcastDates.php @@ -41,8 +41,7 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowRepeats.php b/airtime_mvc/application/forms/AddShowRepeats.php index d92662e0c..2315147fb 100644 --- a/airtime_mvc/application/forms/AddShowRepeats.php +++ b/airtime_mvc/application/forms/AddShowRepeats.php @@ -62,8 +62,7 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowStyle.php b/airtime_mvc/application/forms/AddShowStyle.php index 1e9b968ce..4f43159e5 100644 --- a/airtime_mvc/application/forms/AddShowStyle.php +++ b/airtime_mvc/application/forms/AddShowStyle.php @@ -40,8 +40,7 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowWhat.php b/airtime_mvc/application/forms/AddShowWhat.php index 54707c461..10ed22415 100644 --- a/airtime_mvc/application/forms/AddShowWhat.php +++ b/airtime_mvc/application/forms/AddShowWhat.php @@ -66,8 +66,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index cbae215cf..1493c4ace 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -119,8 +119,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } @@ -129,8 +128,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $element = $this->getElement('add_show_repeats'); if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/AddShowWho.php b/airtime_mvc/application/forms/AddShowWho.php index 7f0508c93..35b2aa52f 100644 --- a/airtime_mvc/application/forms/AddShowWho.php +++ b/airtime_mvc/application/forms/AddShowWho.php @@ -33,8 +33,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm { if ($element->getType() != 'Zend_Form_Element_Hidden') { - $element->setAttrib('readonly',true); - $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + $element->setAttrib('disabled','disabled'); } } } diff --git a/airtime_mvc/application/forms/EditAudioMD.php b/airtime_mvc/application/forms/EditAudioMD.php index a492f1ac5..7dbcdf961 100644 --- a/airtime_mvc/application/forms/EditAudioMD.php +++ b/airtime_mvc/application/forms/EditAudioMD.php @@ -87,7 +87,8 @@ class Application_Form_EditAudioMD extends Zend_Form $this->addElement('text', 'bpm', array( 'label' => 'BPM:', 'class' => 'input_text', - 'filters' => array('StringTrim') + 'filters' => array('StringTrim'), + 'validators' => array(array('StringLength', false, array(0, 8))) )); // Add copyright field diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 2b4ac8a61..e79a1d526 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -11,7 +11,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $defaultFade = Application_Model_Preference::GetDefaultFade(); if($defaultFade == ""){ - $defaultFade = '00.000000'; + $defaultFade = '0.500000'; } //Station name diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 1260781c4..161048bb8 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -21,6 +21,30 @@ class Application_Model_Show { $show->setDbName($name); Application_Model_RabbitMq::PushSchedule(); } + + public function setAirtimeAuthFlag($flag){ + $show = CcShowQuery::create()->findPK($this->_showId); + $show->setDbLiveStreamUsingAirtimeAuth($flag); + $show->save(); + } + + public function setCustomAuthFlag($flag){ + $show = CcShowQuery::create()->findPK($this->_showId); + $show->setDbLiveStreamUsingCustomAuth($flag); + $show->save(); + } + + public function setCustomUsername($username){ + $show = CcShowQuery::create()->findPK($this->_showId); + $show->setDbLiveStreamUser($username); + $show->save(); + } + + public function setCustomPassword($password){ + $show = CcShowQuery::create()->findPK($this->_showId); + $show->setDbLiveStreamPass($password); + $show->save(); + } public function getDescription() { diff --git a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml index e61593d78..be1c5d694 100644 --- a/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml +++ b/airtime_mvc/application/views/scripts/schedule/add-show-form.phtml @@ -1,7 +1,7 @@
Close - @@ -37,7 +37,7 @@ style; ?>
- diff --git a/airtime_mvc/application/views/scripts/schedule/index.phtml b/airtime_mvc/application/views/scripts/schedule/index.phtml index 9afe7b3c0..30d02f9c3 100644 --- a/airtime_mvc/application/views/scripts/schedule/index.phtml +++ b/airtime_mvc/application/views/scripts/schedule/index.phtml @@ -1,5 +1,7 @@
diff --git a/airtime_mvc/public/js/airtime/common/common.js b/airtime_mvc/public/js/airtime/common/common.js index 334b2a2de..81af8b06d 100644 --- a/airtime_mvc/public/js/airtime/common/common.js +++ b/airtime_mvc/public/js/airtime/common/common.js @@ -75,8 +75,9 @@ function open_show_preview(p_showID, p_showIndex) { } function openPreviewWindow(url) { + //$.post(baseUri+'Playlist/audio-preview-player', {fileName: fileName, cueIn: cueIn, cueOut: cueOut, fadeIn: fadeIn, fadeInFileName: fadeInFileName, fadeOut: fadeOut, fadeOutFileName: fadeOutFileName}) - _preview_window = window.open(url, 'Audio Player', 'width=450,height=800'); + _preview_window = window.open(url, 'Audio Player', 'width=450,height=100,scrollbars=yes'); //Set the play button to pause. //var elemID = "spl_"+elemIndexString; //$('#'+elemID+' div.list-item-container a span').attr("class", "ui-icon ui-icon-pause"); diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 747a7525b..422bb4a9f 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -235,18 +235,4 @@ $(document).ready(function() { showErrorSections() setInterval('checkLiquidsoapStatus()', 1000) - $.mask.rules = { - '@': /[^ &<>]/, - 'u': /[0-9a-zA-Z-_.:/]/, - 'd': /[0-9a-zA-Z-_.]/ - } - // add masking on the fields that don't allow special chars - - $.mask.masks = $.extend($.mask.masks,{ - regular_text:{ mask: '@', type:'repeat', 'maxLength': 256, selectCharsOnFocus: false, autoTab: false, fixedChars : '[(),:/]'}, - url:{ mask: 'u', type:'repeat', 'maxLength': 261, selectCharsOnFocus: false, autoTab: false, fixedChars : '[(),]'}, - domain:{ mask: 'd', type:'repeat', 'maxLength': 261, selectCharsOnFocus: false, autoTab: false, fixedChars : '[(),:/]'} - }) - $('input:text').setMask() - }); diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index cbb8a3f8e..44766ddd9 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -320,8 +320,10 @@ function setAddShowEvents() { message: null, applyPlatformOpacityRules: false }); + + var action = "/Schedule/"+String(addShowButton.attr("data-action")); - $.post("/Schedule/add-show", {format: "json", data: data, hosts: hosts, days: days}, function(json){ + $.post(action, {format: "json", data: data, hosts: hosts, days: days}, function(json){ //addShowButton.removeClass("disabled"); $('#schedule-add-show').unblock(); if(json.form) { @@ -334,6 +336,19 @@ function setAddShowEvents() { $("#add_show_end_date").val(end_date); $("#add_show_start_date").val(start_date); showErrorSections(); + }else if(json.edit){ + $("#schedule_calendar").removeAttr("style") + .fullCalendar('render'); + + $("#add-show-form").hide(); + $.get("/Schedule/get-form", {format:"json"}, function(json){ + $("#add-show-form") + .empty() + .append(json.form); + + setAddShowEvents(); + }); + makeAddShowButton(); } else { $("#add-show-form") diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index ef6cee5e1..976b69441 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -20,7 +20,6 @@ function scheduleRefetchEvents(json) { } function openAddShowForm() { - if($("#add-show-form").length == 1) { if( ($("#add-show-form").css('display')=='none')) { $("#add-show-form").show(); @@ -37,13 +36,6 @@ function openAddShowForm() { $add_show_name.select(); }); } - - $.mask.masks = $.extend($.mask.masks,{ - date:{ mask: '9999-19-39', selectCharsOnFocus: true, autoTab: false}, - time:{ mask: '29:69', selectCharsOnFocus: true, autoTab: false} - }); - - $('input:text').setMask(); } function makeAddShowButton(){ @@ -99,61 +91,65 @@ function pad(number, length) { return str; } -function dayClick(date, allDay, jsEvent, view) { - var now, today, selected, chosenDate, chosenTime; - - now = adjustDateToServerDate(new Date(), serverTimezoneOffset); +function dayClick(date, allDay, jsEvent, view){ + // The show from will be preloaded if the user is admin or program manager. + // Hence, if the user if DJ then it won't open anything. + if($.trim($("#add-show-form").html()) != ""){ + var now, today, selected, chosenDate, chosenTime; - if(view.name === "month") { - today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); - selected = new Date(date.getFullYear(), date.getMonth(), date.getDate()); - } - else { - today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes()); - selected = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()); - } - - if(selected >= today) { - var addShow = $('.add-button'); - - //remove the +show button if it exists. - if(addShow.length == 1){ - var span = $(addShow).parent(); - $(span).prev().remove(); - $(span).remove(); + now = adjustDateToServerDate(new Date(), serverTimezoneOffset); + + if(view.name === "month") { + today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); + selected = new Date(date.getFullYear(), date.getMonth(), date.getDate()); } - - // get current duration value on the form - var duration_string = $.trim($("#add_show_duration").val()); - var duration_info = duration_string.split(" "); - var duration_h = 0; - var duration_m = 0; - if(duration_info[0] != null){ - duration_h = parseInt(duration_info[0], 10); + else { + today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes()); + selected = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()); } - if(duration_info[1] != null){ - duration_m = parseInt(duration_info[1], 10); + + if(selected >= today) { + var addShow = $('.add-button'); + + //remove the +show button if it exists. + if(addShow.length == 1){ + var span = $(addShow).parent(); + $(span).prev().remove(); + $(span).remove(); + } + + // get current duration value on the form + var duration_string = $.trim($("#add_show_duration").val()); + var duration_info = duration_string.split(" "); + var duration_h = 0; + var duration_m = 0; + if(duration_info[0] != null){ + duration_h = parseInt(duration_info[0], 10); + } + if(duration_info[1] != null){ + duration_m = parseInt(duration_info[1], 10); + } + // duration in milisec + var duration = (duration_h * 60 * 60 * 1000) + (duration_m * 60 * 1000); + + // get start time value on the form + var startTime_string = $("#add_show_start_time").val(); + var startTime_info = startTime_string.split(':'); + var startTime = (parseInt(startTime_info[0],10) * 60 * 60 * 1000) + (parseInt(startTime_info[1], 10) * 60 * 1000); + + // calculate endDateTime + var endDateTime = new Date(selected.getTime() + startTime + duration); + + chosenDate = selected.getFullYear() + '-' + pad(selected.getMonth()+1,2) + '-' + pad(selected.getDate(),2); + var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2); + + $("#add_show_start_date").val(chosenDate); + $("#add_show_end_date_no_repeat").val(endDateFormat); + $("#add_show_end_date").val(endDateFormat); + $("#schedule-show-when").show(); + + openAddShowForm(); } - // duration in milisec - var duration = (duration_h * 60 * 60 * 1000) + (duration_m * 60 * 1000); - - // get start time value on the form - var startTime_string = $("#add_show_start_time").val(); - var startTime_info = startTime_string.split(':'); - var startTime = (parseInt(startTime_info[0],10) * 60 * 60 * 1000) + (parseInt(startTime_info[1], 10) * 60 * 1000); - - // calculate endDateTime - var endDateTime = new Date(selected.getTime() + startTime + duration); - - chosenDate = selected.getFullYear() + '-' + pad(selected.getMonth()+1,2) + '-' + pad(selected.getDate(),2); - var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2); - - $("#add_show_start_date").val(chosenDate); - $("#add_show_end_date_no_repeat").val(endDateFormat); - $("#add_show_end_date").val(endDateFormat); - $("#schedule-show-when").show(); - - openAddShowForm(); } } diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index f132d5c3a..b8ece01ef 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -176,7 +176,7 @@ function buildContentDialog (json){ dialog.dialog({ autoOpen: false, - title: 'Show Contents', + title: "Contents of Show \"" + json.showTitle + "\"", width: width, height: height, modal: true, @@ -422,4 +422,4 @@ $(document).ready(function() { }; } }); -}); \ No newline at end of file +}); diff --git a/airtime_mvc/public/js/jplayer/preview_jplayer.js b/airtime_mvc/public/js/jplayer/preview_jplayer.js index 5eacef33f..6d4975f25 100644 --- a/airtime_mvc/public/js/jplayer/preview_jplayer.js +++ b/airtime_mvc/public/js/jplayer/preview_jplayer.js @@ -20,7 +20,16 @@ $(document).ready(function(){ height: "0px", cssClass: "jp-video-270p" }, - wmode: "window" + playlistOptions: { + autoPlay: false, + loopOnPrevious: false, + shuffleOnLoop: true, + enableRemoveControls: false, + displayTime: 0, + addTime: 0, + removeTime: 0, + shuffleTime: 0 + } }); @@ -32,6 +41,8 @@ $(document).ready(function(){ var showID = $('.showID').text(); var showIndex = $('.showIndex').text(); + var numOfItems = 0; + if (playlistID != "" && playlistID !== ""){ playAllPlaylist(playlistID, playlistIndex); }else if (audioFileID != "") { @@ -87,6 +98,7 @@ function buildplaylist(p_url, p_playIndex) { var myPlaylist = new Array(); var media; var index; + var total = 0; for(index in data){ if (data[index]['element_mp3'] != undefined){ @@ -103,11 +115,17 @@ function buildplaylist(p_url, p_playIndex) { myPlaylist[index] = media; _idToPostionLookUp[data[index]['element_id']] = data[index]['element_position']; + total++; } _playlist_jplayer.setPlaylist(myPlaylist); _playlist_jplayer.option("autoPlay", true); play(p_playIndex); + + var height = Math.min(80 + (23 * total), 400); + window.innerWidth = 500; + window.innerHeight = height; + window.scrollbars = true; }); } @@ -146,4 +164,7 @@ function playOne(p_audioFileID) { //_playlist_jplayer.setPlaylist(playlist); --if I use this the player will call _init on the setPlaylist and on the ready _playlist_jplayer._initPlaylist(playlist); _playlist_jplayer.play(0); + + window.innerWidth = 490; + window.innerHeight = 105; } \ No newline at end of file diff --git a/airtime_mvc/public/js/meioMask/jquery.meio.mask.js b/airtime_mvc/public/js/meioMask/jquery.meio.mask.js deleted file mode 100644 index b57f73de7..000000000 --- a/airtime_mvc/public/js/meioMask/jquery.meio.mask.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){function d(b){var c=this;b=a.event.fix(b||window.e);b.type="paste";setTimeout(function(){a.event.handle.call(c,b)},1)}var b=window.orientation!=undefined,c=a.browser.opera||a.browser.mozilla&&parseFloat(a.browser.version.substr(0,3))<1.9?"input":"paste";a.event.special.paste={setup:function(){if(this.addEventListener)this.addEventListener(c,d,false);else if(this.attachEvent)this.attachEvent(c,d)},teardown:function(){if(this.removeEventListener)this.removeEventListener(c,d,false);else if(this.detachEvent)this.detachEvent(c,d)}};a.extend({mask:{rules:{z:/[a-z]/,Z:/[A-Z]/,a:/[a-zA-Z]/,"*":/[0-9a-zA-Z]/,"@":/[0-9a-zA-ZçÇáàãâéèêíìóòôõúùü]/},keyRepresentation:{8:"backspace",9:"tab",13:"enter",16:"shift",17:"control",18:"alt",27:"esc",33:"page up",34:"page down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",116:"f5",123:"f12",224:"command"},iphoneKeyRepresentation:{10:"go",127:"delete"},signals:{"+":"","-":"-"},options:{attr:"alt",mask:null,type:"fixed",maxLength:-1,defaultValue:"",signal:false,textAlign:true,selectCharsOnFocus:true,autoTab:true,setSize:false,fixedChars:"[(),.:/ -]",onInvalid:function(){},onValid:function(){},onOverflow:function(){}},masks:{phone:{mask:"(99) 9999-9999"},"phone-us":{mask:"(999) 999-9999"},cpf:{mask:"999.999.999-99"},cnpj:{mask:"99.999.999/9999-99"},date:{mask:"39/19/9999"},"date-us":{mask:"19/39/9999"},cep:{mask:"99999-999"},time:{mask:"29:59"},cc:{mask:"9999 9999 9999 9999"},integer:{mask:"999.999.999.999",type:"reverse"},decimal:{mask:"99,999.999.999.999",type:"reverse",defaultValue:"000"},"decimal-us":{mask:"99.999,999,999,999",type:"reverse",defaultValue:"000"},"signed-decimal":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"},"signed-decimal-us":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"}},init:function(){if(!this.hasInit){var c=this,d,e=b?this.iphoneKeyRepresentation:this.keyRepresentation;this.ignore=false;for(d=0;d<=9;d++)this.rules[d]=new RegExp("[0-"+d+"]");this.keyRep=e;this.ignoreKeys=[];a.each(e,function(a){c.ignoreKeys.push(parseInt(a))});this.hasInit=true}},set:function(b,c){var d=this,e=a(b),f="maxLength";c=c||{};this.init();return e.each(function(){if(c.attr)d.options.attr=c.attr;var b=a(this),e=a.extend({},d.options),g=b.attr(e.attr),h="";h=typeof c=="string"?c:g!=""?g:null;if(h)e.mask=h;if(d.masks[h])e=a.extend(e,d.masks[h]);if(typeof c=="object"&&c.constructor!=Array)e=a.extend(e,c);if(a.metadata)e=a.extend(e,b.metadata());if(e.mask!=null){if(b.data("mask"))d.unset(b);var i=e.defaultValue,j=e.type=="reverse",k=new RegExp(e.fixedChars,"g");if(e.maxLength==-1)e.maxLength=b.attr(f);e=a.extend({},e,{fixedCharsReg:new RegExp(e.fixedChars),fixedCharsRegG:k,maskArray:e.mask.split(""),maskNonFixedCharsArray:e.mask.replace(k,"").split("")});if((e.type=="fixed"||j)&&e.setSize&&!b.attr("size"))b.attr("size",e.mask.length);if(j&&e.textAlign)b.css("text-align","right");if(this.value!=""||i!=""){var l=d.string(this.value!=""?this.value:i,e);this.defaultValue=l;b.val(l)}if(e.type=="infinite")e.type="repeat";b.data("mask",e);b.removeAttr(f);b.bind("keydown.mask",{func:d._onKeyDown,thisObj:d},d._onMask).bind("keypress.mask",{func:d._onKeyPress,thisObj:d},d._onMask).bind("keyup.mask",{func:d._onKeyUp,thisObj:d},d._onMask).bind("paste.mask",{func:d._onPaste,thisObj:d},d._onMask).bind("focus.mask",d._onFocus).bind("blur.mask",d._onBlur).bind("change.mask",d._onChange)}})},unset:function(b){var c=a(b);return c.each(function(){var b=a(this);if(b.data("mask")){var c=b.data("mask").maxLength;if(c!=-1)b.attr("maxLength",c);b.unbind(".mask").removeData("mask")}})},string:function(b,c){this.init();var d={};if(typeof b!="string")b=String(b);switch(typeof c){case"string":if(this.masks[c])d=a.extend(d,this.masks[c]);else d.mask=c;break;case"object":d=c}if(!d.fixedChars)d.fixedChars=this.options.fixedChars;var e=new RegExp(d.fixedChars),f=new RegExp(d.fixedChars,"g");if(d.type=="reverse"&&d.defaultValue){if(typeof this.signals[d.defaultValue.charAt(0)]!="undefined"){var g=b.charAt(0);d.signal=typeof this.signals[g]!="undefined"?this.signals[g]:this.signals[d.defaultValue.charAt(0)];d.defaultValue=d.defaultValue.substring(1)}}return this.__maskArray(b.split(""),d.mask.replace(f,"").split(""),d.mask.split(""),d.type,d.maxLength,d.defaultValue,e,d.signal)},_onFocus:function(b){var c=a(this),d=c.data("mask");d.inputFocusValue=c.val();d.changed=false;if(d.selectCharsOnFocus)c.select()},_onBlur:function(b){var c=a(this),d=c.data("mask");if(d.inputFocusValue!=c.val()&&!d.changed)c.trigger("change")},_onChange:function(b){a(this).data("mask").changed=true},_onMask:function(b){var c=b.data.thisObj,d={};d._this=b.target;d.$this=a(d._this);if(d.$this.attr("readonly"))return true;d.data=d.$this.data("mask");d[d.data.type]=true;d.value=d.$this.val();d.nKey=c.__getKeyNumber(b);d.range=c.__getRange(d._this);d.valueArray=d.value.split("");return b.data.func.call(c,b,d)},_onKeyDown:function(c,d){this.ignore=a.inArray(d.nKey,this.ignoreKeys)>-1||c.ctrlKey||c.metaKey||c.altKey;if(this.ignore){var e=this.keyRep[d.nKey];d.data.onValid.call(d._this,e?e:"",d.nKey)}return b?this._keyPress(c,d):true},_onKeyUp:function(a,b){if(b.nKey==9||b.nKey==16)return true;if(b.data.type=="repeat"){this.__autoTab(b);return true}return this._onPaste(a,b)},_onPaste:function(b,c){if(c.reverse)this.__changeSignal(b.type,c);var d=this.__maskArray(c.valueArray,c.data.maskNonFixedCharsArray,c.data.maskArray,c.data.type,c.data.maxLength,c.data.defaultValue,c.data.fixedCharsReg,c.data.signal);c.$this.val(d);if(!c.reverse&&c.data.defaultValue.length&&c.range.start==c.range.end)this.__setRange(c._this,c.range.start,c.range.end);if((a.browser.msie||a.browser.safari)&&!c.reverse)this.__setRange(c._this,c.range.start,c.range.end);if(this.ignore)return true;this.__autoTab(c);return true},_onKeyPress:function(a,b){if(this.ignore)return true;if(b.reverse)this.__changeSignal(a.type,b);var c=String.fromCharCode(b.nKey),d=b.range.start,e=b.value,f=b.data.maskArray;if(b.reverse){var g=e.substr(0,d),h=e.substr(b.range.end,e.length);e=g+c+h;if(b.data.signal&&d-b.data.signal.length>0)d-=b.data.signal.length}var i=e.replace(b.data.fixedCharsRegG,"").split(""),j=this.__extraPositionsTill(d,f,b.data.fixedCharsReg);b.rsEp=d+j;if(b.repeat)b.rsEp=0;if(!this.rules[f[b.rsEp]]||b.data.maxLength!=-1&&i.length>=b.data.maxLength&&b.repeat){b.data.onOverflow.call(b._this,c,b.nKey);return false}else if(!this.rules[f[b.rsEp]].test(c)){b.data.onInvalid.call(b._this,c,b.nKey);return false}else b.data.onValid.call(b._this,c,b.nKey);var k=this.__maskArray(i,b.data.maskNonFixedCharsArray,f,b.data.type,b.data.maxLength,b.data.defaultValue,b.data.fixedCharsReg,b.data.signal,j);b.$this.val(k);return b.reverse?this._keyPressReverse(a,b):b.fixed?this._keyPressFixed(a,b):true},_keyPressFixed:function(a,b){if(b.range.start==b.range.end){if(b.rsEp==0&&b.value.length==0||b.rsEp=a.data.maskArray.length&&!a.repeat||a.data.maxLength!=-1&&a.valueArray.length>=a.data.maxLength&&a.repeat)){var b=this.__getNextInput(a._this,a.data.autoTab);if(b){a.$this.trigger("blur");b.focus().select()}}},__changeSignal:function(a,b){if(b.data.signal!==false){var c=a=="paste"?b.value.charAt(0):String.fromCharCode(b.nKey);if(this.signals&&typeof this.signals[c]!="undefined"){b.data.signal=this.signals[c]}}},__getKeyNumber:function(a){return a.charCode||a.keyCode||a.which},__maskArray:function(a,b,c,d,e,f,g,h,i){if(d=="reverse")a.reverse();a=this.__removeInvalidChars(a,b,d=="repeat"||d=="infinite");if(f)a=this.__applyDefaultValue.call(a,f);a=this.__applyMask(a,c,i,g);switch(d){case"reverse":a.reverse();return(h||"")+a.join("").substring(a.length-c.length);case"infinite":case"repeat":var j=a.join("");return e!=-1&&a.length>=e?j.substring(0,e):j;default:return a.join("").substring(0,c.length)}return""},__applyDefaultValue:function(a){var b=a.length,c=this.length,d;for(d=c-1;d>=0;d--){if(this[d]==a.charAt(0))this.pop();else break}for(d=0;d0||c.offsetHeight>0)&&c.nodeName!="FIELDSET"&&(b===true||typeof b=="string"&&a.is(b))},__setRange:function(a,b,c){if(typeof c=="undefined")c=b;if(a.setSelectionRange){a.setSelectionRange(b,c)}else{var d=a.createTextRange();d.collapse();d.moveStart("character",b);d.moveEnd("character",c-b);d.select()}},__getRange:function(b){if(!a.browser.msie)return{start:b.selectionStart,end:b.selectionEnd};var c={start:0,end:0},d=document.selection.createRange();c.start=0-d.duplicate().moveStart("character",-1e5);c.end=c.start+d.text.length;return c},unmaskedVal:function(b){return a(b).val().replace(a.mask.fixedCharsRegG,"")}}});a.fn.extend({setMask:function(b){return a.mask.set(this,b)},unsetMask:function(){return a.mask.unset(this)},unmaskedVal:function(){return a.mask.unmaskedVal(this[0])}})})(jQuery) \ No newline at end of file diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 57f912c1c..51c3d5f79 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -26,8 +26,7 @@ showhelp () { --pypo|-p Install only pypo and liquidsoap --show-recorder|-s Install only show-recorder --web|-w Install only files for web-server ---liquidsoap-keep-alive|-l Keep Liquidsoap alive when upgrading ---disable-auto-start-services|-d Disable auto-starting Airtime services" +--liquidsoap-keep-alive|-l Keep Liquidsoap alive when upgrading" } overwrite="f" @@ -39,9 +38,8 @@ pypo="f" showrecorder="f" web="f" liquidsoap_keep_alive="f" -disable_auto_start_services="f" -set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web,liquidsoap-keep-alive,disable-auto-start-services "hopnrmyswld" "$@") +set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web,liquidsoap-keep-alive "hopnrmyswl" "$@") while [ $# -gt 0 ] do case "$1" in @@ -55,7 +53,6 @@ do (-s|--show-recorder) showrecorder="t";; (-w|--web) web="t";; (-l|--liquidsoap-keep-alive) liquidsoap_keep_alive="t";; - (-d|--disable-auto-start-services) disable_auto_start_services="t";; (--) shift; break;; (-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;; @@ -125,14 +122,15 @@ fi #We don't want any of our python services running if we are doing an upgrade/reinstall. #They will be automatically restarted later on. +echo "* Temporarily stopping any previous running services" if [ -e /etc/init.d/airtime-media-monitor ]; then - /etc/init.d/airtime-media-monitor stop > /dev/null 2>&1 + invoke-rc.d airtime-media-monitor stop > /dev/null 2>&1 fi if [ -e /etc/init.d/airtime-playout ]; then - /etc/init.d/airtime-playout stop > /dev/null 2>&1 + invoke-rc.d airtime-playout stop > /dev/null 2>&1 fi if [ -e /etc/init.d/airtime-show-recorder ]; then - /etc/init.d/airtime-show-recorder stop > /dev/null 2>&1 + invoke-rc.d airtime-show-recorder stop > /dev/null 2>&1 fi @@ -147,7 +145,6 @@ export nodb export overwrite export preserve export liquidsoap_keep_alive -export disable_auto_start_services set +e test "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t" diff --git a/install_minimal/include/airtime-initialize.sh b/install_minimal/include/airtime-initialize.sh index 56be18066..8db2d825a 100755 --- a/install_minimal/include/airtime-initialize.sh +++ b/install_minimal/include/airtime-initialize.sh @@ -46,24 +46,19 @@ fi # so we can ensure they can register with monit to monitor them when they start. # If monit is already running, this step is still useful as we need monit to # reload its config files. -/etc/init.d/monit restart +invoke-rc.d monit restart #give monit some time to boot-up before issuing commands sleep 1 set +e -if [ "$disable_auto_start_services" = "f" ]; then - if [ "$mediamonitor" = "t" ]; then - monit monitor airtime-media-monitor - fi - if [ "$pypo" = "t" ]; then - monit monitor airtime-playout - monit monitor airtime-liquidsoap - fi -# if [ "$showrecorder" = "t" ]; then -# monit monitor airtime-show-recorder -# fi +if [ "$mediamonitor" = "t" ]; then + monit monitor airtime-media-monitor +fi +if [ "$pypo" = "t" ]; then + monit monitor airtime-playout + monit monitor airtime-liquidsoap fi monit monitor rabbitmq-server diff --git a/install_minimal/upgrades/airtime-2.1.0/MiscUpgrade.php b/install_minimal/upgrades/airtime-2.1.0/MiscUpgrade.php index 7a4a677bb..327f35f65 100644 --- a/install_minimal/upgrades/airtime-2.1.0/MiscUpgrade.php +++ b/install_minimal/upgrades/airtime-2.1.0/MiscUpgrade.php @@ -5,4 +5,14 @@ class AirtimeMiscUpgrade{ public static function start(){ } + + public static function adjustMonitCfgPermissions(){ + /* Make the read permission of Monit cfg files more strict */ + + chmod("/etc/monit/conf.d/monit-airtime-generic.cfg", 0600); + chmod("/etc/monit/conf.d/monit-airtime-liquidsoap.cfg", 0600); + chmod("/etc/monit/conf.d/monit-airtime-media-monitor.cfg", 0600); + chmod("/etc/monit/conf.d/monit-airtime-playout.cfg", 0600); + chmod("/etc/monit/conf.d/monit-airtime-rabbitmq-server.cfg", 0600); + } } diff --git a/python_apps/media-monitor/airtime-media-monitor b/python_apps/media-monitor/airtime-media-monitor index ac45bde13..a02f11735 100755 --- a/python_apps/media-monitor/airtime-media-monitor +++ b/python_apps/media-monitor/airtime-media-monitor @@ -15,6 +15,7 @@ cd ${media_monitor_path} exec 2>&1 export PYTHONPATH=${api_client_path} +export PATH=/usr/lib/airtime/pypo/bin/liquidsoap_bin/:$PATH # Note the -u when calling python! we need it to get unbuffered binary stdout and stderr exec python -u ${media_monitor_path}${media_monitor_script} > /var/log/airtime/media-monitor/py-interpreter.log 2>&1 diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py index d23651955..57e195a63 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py @@ -135,18 +135,17 @@ class AirtimeMediaMonitorBootstrap(): for file_path in deleted_files_set: self.logger.debug("deleted file") - full_file_path = "%s%s" % (dir, file_path) + full_file_path = os.path.join(dir, file_path) self.logger.debug(full_file_path) self.pe.handle_removed_file(False, full_file_path) for file_path in new_files_set: self.logger.debug("new file") - full_file_path = "%s%s" % (dir, file_path) + full_file_path = os.path.join(dir, file_path) self.logger.debug(full_file_path) if os.path.exists(full_file_path): - organized_filepath = self.pe.handle_created_file(False, full_file_path, os.path.basename(full_file_path)) - if organized_filepath is not None: - self.pe.handle_created_file(False, organized_filepath, os.path.basename(organized_filepath)) + self.pe.handle_created_file(False, full_file_path, os.path.basename(full_file_path)) + for file_path in modified_files_set: self.logger.debug("modified file") diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 3781ae1b8..a5c6055dc 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -137,15 +137,12 @@ class AirtimeProcessEvent(ProcessEvent): if self.mmc.is_parent_directory(pathname, self.config.organize_directory): #file was created in /srv/airtime/stor/organize. Need to process and move #to /srv/airtime/stor/imported - new_filepath = self.mmc.organize_new_file(pathname) - return new_filepath - else: - self.mmc.set_needed_file_permissions(pathname, dir) - if self.mmc.is_parent_directory(pathname, self.config.recorded_directory): - is_recorded = True - else : - is_recorded = False - self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded}) + pathname = self.mmc.organize_new_file(pathname) + name = os.path.basename(pathname) + + self.mmc.set_needed_file_permissions(pathname, dir) + is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory) + self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded}) else: #event is because of a created directory diff --git a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py index 8a250db47..ed226f011 100644 --- a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py +++ b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py @@ -3,6 +3,7 @@ import grp import pwd import logging import stat +import subprocess from subprocess import Popen, PIPE from airtimemetadata import AirtimeMetadata @@ -289,3 +290,16 @@ class MediaMonitorCommon: self.logger.warn("File %s, has invalid metadata", pathname) return filepath + +def test_file_playability(pathname): + """ + Test if the file can be played by Liquidsoap. Return "True" if Liquidsoap + can play it, or if Liquidsoap is not found. + """ + liquidsoap_found = subprocess.call("which liquidsoap", shell=True) + if liquidsoap_found == 0: + return_code = subprocess.call("liquidsoap -c 'output.dummy(single(\"%s\"))'" % pathname, shell=True) + else: + return_code = 0 + + return (return_code == 0) diff --git a/python_apps/media-monitor/airtimefilemonitor/workerprocess.py b/python_apps/media-monitor/airtimefilemonitor/workerprocess.py index 434c79907..65f751ab3 100644 --- a/python_apps/media-monitor/airtimefilemonitor/workerprocess.py +++ b/python_apps/media-monitor/airtimefilemonitor/workerprocess.py @@ -1,12 +1,20 @@ +from mediaconfig import AirtimeMediaConfig +import mediamonitorcommon + class MediaMonitorWorkerProcess: #this function is run in its own process, and continuously #checks the queue for any new file events. def process_file_events(self, queue, notifier): - while True: - event = queue.get() - notifier.logger.info("received event %s", event) - notifier.update_airtime(event) - - \ No newline at end of file + try: + event = queue.get() + if event['mode'] == AirtimeMediaConfig.MODE_CREATE: + filepath = event['filepath'] + if mediamonitorcommon.test_file_playability(filepath): + notifier.logger.info("received event %s", event) + notifier.update_airtime(event) + else: + notifier.logger.warn("Liquidsoap integrity check for file at %s failed. Not adding to media library.", filepath) + except Exception, e: + notifier.logger.error(e) diff --git a/python_apps/media-monitor/install/media-monitor-copy-files.py b/python_apps/media-monitor/install/media-monitor-copy-files.py index 1d62c42a2..d61491da3 100644 --- a/python_apps/media-monitor/install/media-monitor-copy-files.py +++ b/python_apps/media-monitor/install/media-monitor-copy-files.py @@ -50,8 +50,8 @@ try: #copy monit files shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/') subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True) - if os.environ["disable_auto_start_services"] == "f": - shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/') + + shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/') #create log dir create_dir(config['log_dir']) diff --git a/python_apps/media-monitor/install/media-monitor-initialize.py b/python_apps/media-monitor/install/media-monitor-initialize.py index 75ce015a4..017fdfe70 100644 --- a/python_apps/media-monitor/install/media-monitor-initialize.py +++ b/python_apps/media-monitor/install/media-monitor-initialize.py @@ -9,18 +9,18 @@ try: #create media-monitor dir under /var/tmp/airtime if not os.path.exists("/var/tmp/airtime/media-monitor"): os.makedirs("/var/tmp/airtime/media-monitor") - if os.environ["disable_auto_start_services"] == "f": - #update-rc.d init script - p = Popen("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True) - sts = os.waitpid(p.pid, 0)[1] - #Start media-monitor daemon - print "* Waiting for media-monitor processes to start..." - """ - p = Popen("/etc/init.d/airtime-media-monitor stop", shell=True) - sts = os.waitpid(p.pid, 0)[1] - """ - p = Popen("/etc/init.d/airtime-media-monitor start-no-monit", shell=True) - sts = os.waitpid(p.pid, 0)[1] + #update-rc.d init script + p = Popen("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True) + sts = os.waitpid(p.pid, 0)[1] + + #Start media-monitor daemon + print "* Waiting for media-monitor processes to start..." + """ + p = Popen("invoke-rc.d airtime-media-monitor stop", shell=True) + sts = os.waitpid(p.pid, 0)[1] + """ + p = Popen("invoke-rc.d airtime-media-monitor start-no-monit", shell=True) + sts = os.waitpid(p.pid, 0)[1] except Exception, e: print e diff --git a/python_apps/pypo/install/pypo-copy-files.py b/python_apps/pypo/install/pypo-copy-files.py index 19159d55f..1048621c2 100644 --- a/python_apps/pypo/install/pypo-copy-files.py +++ b/python_apps/pypo/install/pypo-copy-files.py @@ -51,9 +51,9 @@ try: shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/') subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True) shutil.copy('%s/../../monit/monit-airtime-rabbitmq-server.cfg'%current_script_dir, '/etc/monit/conf.d/') - if os.environ["disable_auto_start_services"] == "f": - shutil.copy('%s/../monit-airtime-liquidsoap.cfg'%current_script_dir, '/etc/monit/conf.d/') - shutil.copy('%s/../monit-airtime-playout.cfg'%current_script_dir, '/etc/monit/conf.d/') + + shutil.copy('%s/../monit-airtime-liquidsoap.cfg'%current_script_dir, '/etc/monit/conf.d/') + shutil.copy('%s/../monit-airtime-playout.cfg'%current_script_dir, '/etc/monit/conf.d/') #create pypo log dir create_dir(config['pypo_log_dir']) diff --git a/python_apps/pypo/install/pypo-initialize.py b/python_apps/pypo/install/pypo-initialize.py index b255e109c..10d9d9bcd 100644 --- a/python_apps/pypo/install/pypo-initialize.py +++ b/python_apps/pypo/install/pypo-initialize.py @@ -111,25 +111,18 @@ try: else: print "Unable to connect to the Airtime server." - if os.environ["disable_auto_start_services"] == "f": - #initialize init.d scripts - p = Popen("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True) - sts = os.waitpid(p.pid, 0)[1] + #initialize init.d scripts + p = Popen("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True) + sts = os.waitpid(p.pid, 0)[1] - #restart airtime-playout - print "* Waiting for pypo processes to start..." - """ - if os.environ["liquidsoap_keep_alive"] == "f": - print " * Restarting any previous Liquidsoap instances" - p = Popen("/etc/init.d/airtime-playout stop > /dev/null 2>&1", shell=True) - sts = os.waitpid(p.pid, 0)[1] - else: - print " * Keeping any previous Liquidsoap instances running" - p = Popen("/etc/init.d/airtime-playout pypo-stop > /dev/null 2>&1", shell=True) - sts = os.waitpid(p.pid, 0)[1] - """ - p = Popen("/etc/init.d/airtime-playout start-no-monit > /dev/null 2>&1", shell=True) - sts = os.waitpid(p.pid, 0)[1] + #clear out an previous pypo cache + print "* Clearing previous pypo cache" + p = Popen("rm -rf '/var/tmp/airtime/pypo/cache/scheduler/*' >/dev/null 2>&1", shell=True) + sts = os.waitpid(p.pid, 0)[1] + + print "* Waiting for pypo processes to start..." + p = Popen("invoke-rc.d airtime-playout start-no-monit > /dev/null 2>&1", shell=True) + sts = os.waitpid(p.pid, 0)[1] except Exception, e: print e diff --git a/python_apps/pypo/install/pypo-uninitialize.py b/python_apps/pypo/install/pypo-uninitialize.py index 864d94a3d..2329e88e7 100644 --- a/python_apps/pypo/install/pypo-uninitialize.py +++ b/python_apps/pypo/install/pypo-uninitialize.py @@ -10,7 +10,7 @@ try: #stop pypo and liquidsoap processes print "Waiting for pypo processes to stop...", if (os.path.exists('/etc/init.d/airtime-playout')): - p = Popen("/etc/init.d/airtime-playout stop", shell=True) + p = Popen("invoke-rc.d airtime-playout stop", shell=True) sts = os.waitpid(p.pid, 0)[1] print "OK" else: diff --git a/python_apps/pypo/install/pypo-uninstall.py b/python_apps/pypo/install/pypo-uninstall.py index 9b4429598..f3306d9c7 100644 --- a/python_apps/pypo/install/pypo-uninstall.py +++ b/python_apps/pypo/install/pypo-uninstall.py @@ -30,7 +30,7 @@ try: print 'Error loading config file: ', e sys.exit(1) - os.system("/etc/init.d/airtime-playout stop") + os.system("invoke-rc.d airtime-playout stop") os.system("rm -f /etc/init.d/airtime-playout") os.system("update-rc.d -f airtime-playout remove >/dev/null 2>&1") diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index af6efc5ca..396302754 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -183,9 +183,14 @@ class PypoPush(Thread): problem_at_iteration = None for queue_item in liquidsoap_queue_approx: if queue_item['start'] in media_schedule.keys(): - if queue_item['id'] == media_schedule[queue_item['start']]['id']: - #Everything OK for this iteration. - pass + media_item = media_schedule[queue_item['start']] + if queue_item['id'] == media_item['id']: + if queue_item['end'] == media_item['end']: + #Everything OK for this iteration. + pass + else: + problem_at_iteration = iteration + break else: #A different item has been scheduled at the same time! Need to remove #all tracks from the Liquidsoap queue starting at this point, and re-add @@ -204,7 +209,7 @@ class PypoPush(Thread): #The first item in the Liquidsoap queue (the one that is currently playing) #has changed or been removed from the schedule. We need to clear the entire #queue, and push the new schedule - self.logger.debug("Problem at iteration %s", problem_at_iteration) + self.logger.debug("Change in link %s of current chain", problem_at_iteration) self.remove_from_liquidsoap_queue(problem_at_iteration, liquidsoap_queue_approx) return problem_at_iteration