예제 #1
0
 public function passwordRestoreAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/login/password-restore.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $request = $this->getRequest();
     Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', 'en_CA'));
     if (!Application_Model_Preference::GetEnableSystemEmail()) {
         $this->_redirect('login');
     } else {
         //uses separate layout without a navigation.
         $this->_helper->layout->setLayout('login');
         $form = new Application_Form_PasswordRestore();
         $request = $this->getRequest();
         if ($request->isPost() && $form->isValid($request->getPost())) {
             if (is_null($form->username->getValue()) || $form->username->getValue() == '') {
                 $user = CcSubjsQuery::create()->filterByDbEmail($form->email->getValue())->findOne();
             } else {
                 $user = CcSubjsQuery::create()->filterByDbEmail($form->email->getValue())->filterByDbLogin($form->username->getValue())->findOne();
             }
             if (!empty($user)) {
                 $auth = new Application_Model_Auth();
                 $success = $auth->sendPasswordRestoreLink($user, $this->view);
                 if ($success) {
                     $this->_helper->redirector('password-restore-after', 'login');
                 } else {
                     $form->email->addError($this->view->translate(_("Email could not be sent. Check your mail server settings and ensure it has been configured properly.")));
                 }
             } else {
                 $form->email->addError($this->view->translate(_("Given email not found.")));
             }
         }
         $this->view->form = $form;
     }
 }
 public function configureTemplateAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/playouthistory/configuretemplate.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/history_styles.css?' . $CC_CONFIG['airtime_version']);
     try {
         $templateId = $this->_getParam('id');
         $historyService = new Application_Service_HistoryService();
         $template = $historyService->loadTemplate($templateId);
         $templateType = $template["type"];
         $supportedTypes = $historyService->getSupportedTemplateTypes();
         if (!in_array($templateType, $supportedTypes)) {
             throw new Exception("Error: {$templateType} is not supported.");
         }
         $getMandatoryFields = "mandatory" . ucfirst($templateType) . "Fields";
         $mandatoryFields = $historyService->{$getMandatoryFields}();
         $this->view->template_id = $templateId;
         $this->view->template_name = $template["name"];
         $this->view->template_fields = $template["fields"];
         $this->view->template_type = $templateType;
         $this->view->fileMD = $historyService->getFileMetadataTypes();
         $this->view->fields = $historyService->getFieldTypes();
         $this->view->required_fields = $mandatoryFields;
         $this->view->configured = $historyService->getConfiguredTemplateIds();
     } catch (Exception $e) {
         Logging::info("Error?");
         Logging::info($e);
         Logging::info($e->getMessage());
         $this->_forward('index', 'playouthistorytemplate');
     }
 }
 public function datatablesTranslationTableAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     header("Content-type: text/javascript");
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $locale = Application_Model_Preference::GetLocale();
     echo "var datatables_dict =" . file_get_contents(Application_Common_OsPath::join($_SERVER["DOCUMENT_ROOT"], $baseUrl, "js/datatables/i18n/", $locale . ".txt"));
 }
예제 #4
0
 protected function _initHeadScript()
 {
     $CC_CONFIG = Config::getConfig();
     $view = $this->getResource('view');
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $view->headScript()->appendFile($baseUrl . 'js/libs/jquery-1.8.3.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/libs/jquery-ui-1.8.24.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/bootstrap/bootstrap.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/libs/underscore-min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/libs/jquery.stickyPanel.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/qtip/jquery.qtip.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/jplayer/jquery.jplayer.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/sprintf/sprintf-0.7-beta1.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/cookie/jquery.cookie.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/i18n/jquery.i18n.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'locale/general-translation-table?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'locale/datatables-translation-table?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendScript("\$.i18n.setDictionary(general_dict)");
     $view->headScript()->appendScript("var baseUrl='{$baseUrl}'");
     //These timezones are needed to adjust javascript Date objects on the client to make sense to the user's set timezone
     //or the server's set timezone.
     $serverTimeZone = new DateTimeZone(Application_Model_Preference::GetDefaultTimezone());
     $now = new DateTime("now", $serverTimeZone);
     $offset = $now->format("Z") * -1;
     $view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
     if (class_exists("Zend_Auth", false) && Zend_Auth::getInstance()->hasIdentity()) {
         $userTimeZone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
         $now = new DateTime("now", $userTimeZone);
         $offset = $now->format("Z") * -1;
         $view->headScript()->appendScript("var userTimezoneOffset = {$offset}; //in seconds");
     }
     //scripts for now playing bar
     $view->headScript()->appendFile($baseUrl . 'js/airtime/airtime_bootstrap.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/airtime/dashboard/helperfunctions.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/airtime/dashboard/dashboard.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/airtime/dashboard/versiontooltip.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/tipsy/jquery.tipsy.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/airtime/common/common.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $view->headScript()->appendFile($baseUrl . 'js/airtime/common/audioplaytest.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $user = Application_Model_User::getCurrentUser();
     if (!is_null($user)) {
         $userType = $user->getType();
     } else {
         $userType = "";
     }
     $view->headScript()->appendScript("var userType = '{$userType}';");
     if (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1) {
         $view->headScript()->appendFile($baseUrl . 'js/libs/google-analytics.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     }
     if (Application_Model_Preference::GetPlanLevel() != "disabled" && !($_SERVER['REQUEST_URI'] == $baseUrl . 'Dashboard/stream-player' || strncmp($_SERVER['REQUEST_URI'], $baseUrl . 'audiopreview/audio-preview', strlen($baseUrl . 'audiopreview/audio-preview')) == 0)) {
         $client_id = Application_Model_Preference::GetClientId();
         $view->headScript()->appendScript("var livechat_client_id = '{$client_id}';");
         $view->headScript()->appendFile($baseUrl . 'js/airtime/common/livechat.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     }
 }
 public function indexAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $locale = Application_Model_Preference::GetLocale();
     $this->view->headScript()->appendFile($baseUrl . 'js/plupload/plupload.full.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/plupload/jquery.plupload.queue.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/library/plupload.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/plupload/i18n/' . $locale . '.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/plupload.queue.css?' . $CC_CONFIG['airtime_version']);
 }
예제 #6
0
 public function init()
 {
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->setMethod('post');
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences.phtml'))));
     $general_pref = new Application_Form_GeneralPreferences();
     $this->addSubForm($general_pref, 'preferences_general');
     $email_pref = new Application_Form_EmailServerPreferences();
     $this->addSubForm($email_pref, 'preferences_email_server');
     $soundcloud_pref = new Application_Form_SoundcloudPreferences();
     $this->addSubForm($soundcloud_pref, 'preferences_soundcloud');
 }
 public function streamPlayerAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headLink()->appendStylesheet($baseUrl . 'js/jplayer/skin/jplayer.blue.monday.css?' . $CC_CONFIG['airtime_version']);
     $this->_helper->layout->setLayout('livestream');
     $logo = Application_Model_Preference::GetStationLogo();
     if ($logo) {
         $this->view->logo = "data:image/png;base64,{$logo}";
     } else {
         $this->view->logo = $baseUrl . "css/images/airtime_logo_jp.png";
     }
 }
예제 #8
0
 public function startForm($p_id)
 {
     $baseUrl = Application_Common_OsPath::getBaseDir();
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElement('hidden', 'file_id', array('value' => $p_id));
     // Add title field
     $this->addElement('text', 'track_title', array('label' => _('Title:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add artist field
     $this->addElement('text', 'artist_name', array('label' => _('Creator:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add album field
     $this->addElement('text', 'album_title', array('label' => _('Album:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add track number field
     $this->addElement('text', 'track_number', array('label' => _('Track:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add genre field
     $this->addElement('text', 'genre', array('label' => _('Genre:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add year field
     $year = new Zend_Form_Element_Text('year');
     $year->class = 'input_text';
     $year->setLabel(_('Year:'))->setFilters(array('StringTrim'))->setValidators(array(new Zend_Validate_StringLength(array('max' => 10)), Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM-DD"), Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM"), Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY")));
     $this->addElement($year);
     // Add label field
     $this->addElement('text', 'label', array('label' => _('Label:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add composer field
     $this->addElement('text', 'composer', array('label' => _('Composer:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add conductor field
     $this->addElement('text', 'conductor', array('label' => _('Conductor:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add mood field
     $this->addElement('text', 'mood', array('label' => _('Mood:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add bmp field
     $bpm = new Zend_Form_Element_Text('bpm');
     $bpm->class = 'input_text';
     $bpm->setLabel(_('BPM:'))->setFilters(array('StringTrim'))->setValidators(array(new Zend_Validate_StringLength(array('min' => 0, 'max' => 8)), new Zend_Validate_Digits()));
     $this->addElement($bpm);
     // Add copyright field
     $this->addElement('text', 'copyright', array('label' => _('Copyright:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add isrc number field
     $this->addElement('text', 'isrc_number', array('label' => _('ISRC Number:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add website field
     $this->addElement('text', 'info_url', array('label' => _('Website:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add language field
     $this->addElement('text', 'language', array('label' => _('Language:'), 'class' => 'input_text', 'filters' => array('StringTrim')));
     // Add the submit button
     $this->addElement('button', 'editmdsave', array('ignore' => true, 'class' => 'btn', 'label' => _('Save'), 'decorators' => array('ViewHelper')));
     // Add the submit button
     $this->addElement('button', 'editmdcancel', array('ignore' => true, 'class' => 'btn md-cancel', 'label' => _('Cancel'), 'decorators' => array('ViewHelper')));
     $this->addDisplayGroup(array('editmdsave', 'editmdcancel'), 'submitButtons', array('decorators' => array('FormElements', 'DtDdWrapper')));
 }
 public function indexAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendScript("var calendarPref = {};\n" . "calendarPref.weekStart = " . Application_Model_Preference::GetWeekStartDay() . ";\n" . "calendarPref.timestamp = " . time() . ";\n" . "calendarPref.timezoneOffset = " . Application_Common_DateHelper::getUserTimezoneOffset() . ";\n" . "calendarPref.timeScale = '" . Application_Model_Preference::GetCalendarTimeScale() . "';\n" . "calendarPref.timeInterval = " . Application_Model_Preference::GetCalendarTimeInterval() . ";\n" . "calendarPref.weekStartDay = " . Application_Model_Preference::GetWeekStartDay() . ";\n" . "var calendarEvents = null;");
     $this->view->headScript()->appendFile($baseUrl . 'js/contextmenu/jquery.contextMenu.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     //full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
     //this should be as a default, however with our new drop down timezone changing for shows, we should reset this offset then??
     $this->view->headScript()->appendScript("var timezoneOffset = " . Application_Common_DateHelper::getStationTimezoneOffset() . "; //in seconds");
     //set offset to ensure it loads last
     $this->view->headScript()->offsetSetFile(90, $baseUrl . 'js/airtime/schedule/full-calendar-functions.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/fullcalendar/fullcalendar.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/timepicker/jquery.ui.timepicker.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/colorpicker/js/colorpicker.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/schedule/add-show.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->offsetSetFile(100, $baseUrl . 'js/airtime/schedule/schedule.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']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/fullcalendar.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/colorpicker/css/colorpicker.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/add-show.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/jquery.contextMenu.css?' . $CC_CONFIG['airtime_version']);
     //Start Show builder JS/CSS requirements
     $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');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.ColVis.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.ColReorder.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.FixedColumns.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.columnFilter.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/library/events/library_showbuilder.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->headScript()->appendFile($baseUrl . 'js/airtime/showbuilder/builder.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->headLink()->appendStylesheet($baseUrl . 'css/showbuilder.css?' . $CC_CONFIG['airtime_version']);
     //End Show builder JS/CSS requirements
     $this->createShowFormAction(true);
     $user = Application_Model_User::getCurrentUser();
     if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
         $this->view->preloadShowForm = true;
     }
     $this->view->addNewShow = true;
 }
예제 #10
0
 public function init()
 {
     $this->setAction(Application_Common_OsPath::getBaseDir() . 'Showbuilder');
     $this->setMethod('post');
     $country_list = Application_Model_Preference::GetCountryList();
     $privacyChecked = false;
     if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) {
         $privacyChecked = true;
     }
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/register-dialog.phtml', 'privacyChecked' => $privacyChecked)), array('File', array('viewScript' => 'form/register-dialog.phtml', 'placement' => false))));
     // Station Name
     $stnName = new Zend_Form_Element_Text("stnName");
     $stnName->setLabel(_("Station Name"))->setRequired(true)->setValue(Application_Model_Preference::GetStationName())->setDecorators(array('ViewHelper'));
     $this->addElement($stnName);
     // Phone number
     $this->addElement('text', 'Phone', array('class' => 'input_text', 'label' => _('Phone:'), 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetPhone(), 'decorators' => array('ViewHelper')));
     //Email
     $this->addElement('text', 'Email', array('class' => 'input_text', 'label' => _('Email:'), 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetEmail(), 'decorators' => array('ViewHelper')));
     // Station Web Site
     $this->addElement('text', 'StationWebSite', array('label' => _('Station Web Site:'), 'required' => false, 'class' => 'input_text', 'value' => Application_Model_Preference::GetStationWebSite(), 'decorators' => array('ViewHelper')));
     // county list dropdown
     $this->addElement('select', 'Country', array('label' => _('Country:'), 'required' => false, 'value' => Application_Model_Preference::GetStationCountry(), 'multiOptions' => $country_list, 'decorators' => array('ViewHelper')));
     // Station city
     $this->addElement('text', 'City', array('label' => _('City:'), 'required' => false, 'class' => 'input_text', 'value' => Application_Model_Preference::GetStationCity(), 'decorators' => array('ViewHelper')));
     // Station Description
     $description = new Zend_Form_Element_Textarea('Description');
     $description->class = 'input_text_area';
     $description->setLabel(_('Station Description:'))->setRequired(false)->setValue(Application_Model_Preference::GetStationDescription())->setDecorators(array('ViewHelper'))->setAttrib('ROWS', '2')->setAttrib('COLS', '58');
     $this->addElement($description);
     // Station Logo
     $upload = new Zend_Form_Element_File('Logo');
     $upload->setLabel(_('Station Logo:'))->setRequired(false)->setDecorators(array('File'))->addValidator('Count', false, 1)->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addFilter('ImageSize');
     $this->addElement($upload);
     //enable support feedback
     $this->addElement('checkbox', 'SupportFeedback', array('label' => _('Send support feedback'), 'required' => false, 'value' => 1, 'decorators' => array('ViewHelper')));
     // checkbox for publicise
     $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
     $checkboxPublicise->setLabel(_('Promote my station on Sourcefabric.org'))->setRequired(false)->setDecorators(array('ViewHelper'))->setValue(Application_Model_Preference::GetPublicise());
     $this->addElement($checkboxPublicise);
     // text area for sending detail
     $this->addElement('textarea', 'SendInfo', array('class' => 'sending_textarea', 'required' => false, 'filters' => array('StringTrim'), 'readonly' => true, 'rows' => 5, 'cols' => 61, 'value' => Application_Model_Preference::GetSystemInfo(false, true), 'decorators' => array('ViewHelper')));
     // checkbox for privacy policy
     $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
     $checkboxPrivacy->setLabel(sprintf(_("By checking this box, I agree to Sourcefabric's %sprivacy policy%s."), "<a id='link_to_privacy' href='http://www.sourcefabric.org/en/about/policy/' onclick='window.open(this.href); return false;'>", "</a>"))->setDecorators(array('ViewHelper'));
     $this->addElement($checkboxPrivacy);
 }
 public function indexAction()
 {
     $CC_CONFIG = Config::getConfig();
     $request = $this->getRequest();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     //default time is the last 24 hours.
     $now = time();
     $from = $request->getParam("from", $now - 24 * 60 * 60);
     $to = $request->getParam("to", $now);
     $utcTimezone = new DateTimeZone("UTC");
     $displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
     $start = DateTime::createFromFormat("U", $from, $utcTimezone);
     $start->setTimezone($displayTimeZone);
     $end = DateTime::createFromFormat("U", $to, $utcTimezone);
     $end->setTimezone($displayTimeZone);
     $form = new Application_Form_DateRange();
     $form->populate(array('his_date_start' => $start->format("Y-m-d"), 'his_time_start' => $start->format("H:i"), 'his_date_end' => $end->format("Y-m-d"), 'his_time_end' => $end->format("H:i")));
     $this->view->date_form = $form;
     $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');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/timepicker/jquery.ui.timepicker.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/bootstrap-datetime/bootstrap-datetimepicker.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/playouthistory/historytable.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/bootstrap-datetimepicker.min.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/jquery.ui.timepicker.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/playouthistory.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/history_styles.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/jquery.contextMenu.css?' . $CC_CONFIG['airtime_version']);
     //set datatables columns for display of data.
     $historyService = new Application_Service_HistoryService();
     $columns = json_encode($historyService->getDatatablesLogSheetColumns());
     $script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify({$columns}) ); ";
     $columns = json_encode($historyService->getDatatablesFileSummaryColumns());
     $script .= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify({$columns}) );";
     $this->view->headScript()->appendScript($script);
     $user = Application_Model_User::getCurrentUser();
     $this->view->userType = $user->getType();
 }
 public function indexAction()
 {
     $CC_CONFIG = Config::getConfig();
     $request = $this->getRequest();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/flot/jquery.flot.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/flot/jquery.flot.crosshair.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/listenerstat/listenerstat.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/timepicker/jquery.ui.timepicker.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->headLink()->appendStylesheet($baseUrl . 'css/jquery.ui.timepicker.css?' . $CC_CONFIG['airtime_version']);
     //default time is the last 24 hours.
     $now = time();
     $from = $request->getParam("from", $now - 24 * 60 * 60);
     $to = $request->getParam("to", $now);
     $utcTimezone = new DateTimeZone("UTC");
     $displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
     $start = DateTime::createFromFormat("U", $from, $utcTimezone);
     $start->setTimezone($displayTimeZone);
     $end = DateTime::createFromFormat("U", $to, $utcTimezone);
     $end->setTimezone($displayTimeZone);
     $form = new Application_Form_DateRange();
     $form->populate(array('his_date_start' => $start->format("Y-m-d"), 'his_time_start' => $start->format("H:i"), 'his_date_end' => $end->format("Y-m-d"), 'his_time_end' => $end->format("H:i")));
     $errorStatus = Application_Model_StreamSetting::GetAllListenerStatErrors();
     Logging::info($errorStatus);
     $out = array();
     foreach ($errorStatus as $v) {
         $key = explode('_listener_stat_error', $v['keyname']);
         if ($v['value'] != 'OK') {
             $v['value'] = _("Please make sure admin user/password is correct on System->Streams page.");
         }
         $out[$key[0]] = $v['value'];
     }
     $this->view->errorStatus = $out;
     $this->view->date_form = $form;
 }
예제 #13
0
 public static function copyFileToStor($p_targetDir, $fileName, $tempname)
 {
     $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname;
     Logging::info('copyFileToStor: moving file ' . $audio_file);
     $storDir = Application_Model_MusicDir::getStorDir();
     $stor = $storDir->getDirectory();
     // check if "organize" dir exists and if not create one
     if (!file_exists($stor . "/organize")) {
         if (!mkdir($stor . "/organize", 0777)) {
             return array("code" => 109, "message" => "Failed to create 'organize' directory.");
         }
     }
     if (chmod($audio_file, 0644) === false) {
         Logging::info("Warning: couldn't change permissions of {$audio_file} to 0644");
     }
     // Check if we have enough space before copying
     if (!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
         $freeSpace = disk_free_space($stor);
         return array("code" => 107, "message" => "The file was not uploaded, there is\n                " . $freeSpace . "MB of disk space left and the file you are\n                uploading has a size of  " . $fileSize . "MB.");
     }
     // Check if liquidsoap can play this file
     if (!self::liquidsoapFilePlayabilityTest($audio_file)) {
         return array("code" => 110, "message" => "This file appears to be corrupted and will not\n                be added to media library.");
     }
     // Did all the checks for real, now trying to copy
     $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
     $user = Application_Model_User::getCurrentUser();
     if (is_null($user)) {
         $uid = Application_Model_User::getFirstAdminId();
     } else {
         $uid = $user->getId();
     }
     $id_file = "{$audio_stor}.identifier";
     if (file_put_contents($id_file, $uid) === false) {
         Logging::info("Could not write file to identify user: '******'");
         Logging::info("Id file path: '{$id_file}'");
         Logging::info("Defaulting to admin (no identification file was\n                written)");
     } else {
         Logging::info("Successfully written identification file for\n                uploaded '{$audio_stor}'");
     }
     Logging::info("copyFileToStor: moving file {$audio_file} to {$audio_stor}");
     // Martin K.: changed to rename: Much less load + quicker since this is
     // an atomic operation
     if (@rename($audio_file, $audio_stor) === false) {
         //something went wrong likely there wasn't enough space in .
         //the audio_stor to move the file too warn the user that   .
         //the file wasn't uploaded and they should check if there  .
         //is enough disk space                                     .
         unlink($audio_file);
         //remove the file after failed rename
         unlink($id_file);
         // Also remove the identifier file
         return array("code" => 108, "message" => "\n                The file was not uploaded, this error can occur if the computer\n                hard drive does not have enough disk space or the stor\n                directory does not have correct write permissions.");
     }
     // Now that we successfully added this file, we will add another tag
     // file that will identify the user that owns it
     return null;
 }
예제 #14
0
 /**
  *
  * Enter description here ...
  */
 public function makeContextMenu()
 {
     $menu = array();
     $now = time();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $isAdminOrPM = $this->currentUser->isAdminOrPM();
     $isHostOfShow = $this->currentUser->isHostOfShow($this->ccShow->getDbId());
     //DateTime objects in UTC
     $startDT = $this->ccShowInstance->getDbStarts(null);
     $endDT = $this->ccShowInstance->getDbEnds(null);
     //timestamps
     $start = $startDT->getTimestamp();
     $end = $endDT->getTimestamp();
     //show has ended
     if ($now > $end) {
         if ($this->ccShowInstance->isRecorded()) {
             $ccFile = $this->ccShowInstance->getCcFiles();
             if (!isset($ccFile)) {
                 $menu["error when recording"] = array("name" => _("Record file doesn't exist"), "icon" => "error");
             } else {
                 $menu["view_recorded"] = array("name" => _("View Recorded File Metadata"), "icon" => "overview", "url" => $baseUrl . "library/edit-file-md/id/" . $ccFile->getDbId());
             }
             //recorded show can be uploaded to soundcloud
             if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
                 $scid = $ccFile->getDbSoundcloudId();
                 if ($scid > 0) {
                     $menu["soundcloud_view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $ccFile->getDbSoundcloudLinkToFile());
                 }
                 $text = is_null($scid) ? _('Upload to SoundCloud') : _('Re-upload to SoundCloud');
                 $menu["soundcloud_upload"] = array("name" => $text, "icon" => "soundcloud");
             }
         } else {
             $menu["content"] = array("name" => _("Show Content"), "icon" => "overview", "url" => $baseUrl . "schedule/show-content-dialog");
         }
     } else {
         // Show content can be modified from the calendar if:
         // the user is admin or hosting the show,
         // the show is not recorded
         $currentShow = Application_Model_Show::getCurrentShow();
         $currentShowId = count($currentShow) == 1 ? $currentShow[0]["id"] : null;
         $showIsLinked = $this->ccShow->isLinked();
         if ($now < $end && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded()) {
             //if the show is not linked the user can add/remove content
             if (!$showIsLinked) {
                 $menu["schedule"] = array("name" => _("Add / Remove Content"), "icon" => "add-remove-content", "url" => $baseUrl . "showbuilder/builder-dialog/");
                 //if the show is linked and it's not currently playing the user can add/remove content
             } elseif ($showIsLinked && $currentShowId != $this->ccShow->getDbId()) {
                 $menu["schedule"] = array("name" => _("Add / Remove Content"), "icon" => "add-remove-content", "url" => $baseUrl . "showbuilder/builder-dialog/");
             }
         }
         if ($now < $start && ($isAdminOrPM || $isHostOfShow) && !$this->ccShowInstance->isRecorded()) {
             $menu["clear"] = array("name" => _("Remove All Content"), "icon" => "remove-all-content", "url" => $baseUrl . "schedule/clear-show");
         }
         //"Show Content" should be a menu item at all times except when
         //the show is recorded
         if (!$this->ccShowInstance->isRecorded()) {
             $menu["content"] = array("name" => _("Show Content"), "icon" => "overview", "url" => $baseUrl . "schedule/show-content-dialog");
         }
         //show is currently playing and user is admin
         if ($start <= $now && $now < $end && $isAdminOrPM) {
             if ($this->ccShowInstance->isRecorded()) {
                 $menu["cancel_recorded"] = array("name" => _("Cancel Current Show"), "icon" => "delete");
             } else {
                 $menu["cancel"] = array("name" => _("Cancel Current Show"), "icon" => "delete");
             }
         }
         $excludeIds = $this->ccShow->getEditedRepeatingInstanceIds();
         $isRepeating = $this->ccShow->isRepeating();
         $populateInstance = false;
         if ($isRepeating && in_array($this->ccShowInstance->getDbId(), $excludeIds)) {
             $populateInstance = true;
         }
         if (!$this->ccShowInstance->isRebroadcast() && $isAdminOrPM) {
             if ($isRepeating) {
                 if ($populateInstance) {
                     $menu["edit"] = array("name" => _("Edit This Instance"), "icon" => "edit", "url" => $baseUrl . "Schedule/populate-repeating-show-instance-form");
                 } else {
                     $menu["edit"] = array("name" => _("Edit"), "icon" => "edit", "items" => array());
                     $menu["edit"]["items"]["all"] = array("name" => _("Edit Show"), "icon" => "edit", "url" => $baseUrl . "Schedule/populate-show-form");
                     $menu["edit"]["items"]["instance"] = array("name" => _("Edit This Instance"), "icon" => "edit", "url" => $baseUrl . "Schedule/populate-repeating-show-instance-form");
                 }
             } else {
                 $menu["edit"] = array("name" => _("Edit Show"), "icon" => "edit", "_type" => "all", "url" => $baseUrl . "Schedule/populate-show-form");
             }
         }
         //show hasn't started yet and user is admin
         if ($now < $start && $isAdminOrPM) {
             //show is repeating so give user the option to delete all
             //repeating instances or just the one
             if ($isRepeating) {
                 $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "items" => array());
                 $menu["del"]["items"]["single"] = array("name" => _("Delete This Instance"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show-instance");
                 $menu["del"]["items"]["following"] = array("name" => _("Delete This Instance and All Following"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show");
             } elseif ($populateInstance) {
                 $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show-instance");
             } else {
                 $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "url" => $baseUrl . "schedule/delete-show");
             }
         }
     }
     return $menu;
 }
예제 #15
0
 public function dispatchMetadata($md, $mode)
 {
     $return_hash = array();
     Application_Model_Preference::SetImportTimestamp();
     $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
     $con->beginTransaction();
     try {
         // create also modifies the file if it exists
         if ($mode == "create") {
             $filepath = $md['MDATA_KEY_FILEPATH'];
             $filepath = Application_Common_OsPath::normpath($filepath);
             $file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
             if (is_null($file)) {
                 $file = Application_Model_StoredFile::Insert($md, $con);
             } else {
                 // If the file already exists we will update and make sure that
                 // it's marked as 'exists'.
                 $file->setFileExistsFlag(true);
                 $file->setFileHiddenFlag(false);
                 $file->setMetadata($md);
             }
             if ($md['is_record'] != 0) {
                 $this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId());
             }
         } elseif ($mode == "modify") {
             $filepath = $md['MDATA_KEY_FILEPATH'];
             $file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
             //File is not in database anymore.
             if (is_null($file)) {
                 $return_hash['error'] = _("File does not exist in Airtime.");
             } else {
                 //CC-5207 - restart media-monitor causes it to reevaluate all
                 //files in watched directories, and reset their cue-in/cue-out
                 //values. Since media-monitor has nothing to do with cue points
                 //let's unset it here. Note that on mode == "create", we still
                 //want media-monitor sending info about cue_out which by default
                 //will be equal to length of track until silan can take over.
                 unset($md['MDATA_KEY_CUE_IN']);
                 unset($md['MDATA_KEY_CUE_OUT']);
                 $file->setMetadata($md);
             }
         } elseif ($mode == "moved") {
             $file = Application_Model_StoredFile::RecallByFilepath($md['MDATA_KEY_ORIGINAL_PATH'], $con);
             if (is_null($file)) {
                 $return_hash['error'] = _('File does not exist in Airtime');
             } else {
                 $filepath = $md['MDATA_KEY_FILEPATH'];
                 //$filepath = str_replace("\\", "", $filepath);
                 $file->setFilePath($filepath);
             }
         } elseif ($mode == "delete") {
             $filepath = $md['MDATA_KEY_FILEPATH'];
             $filepath = str_replace("\\", "", $filepath);
             $file = Application_Model_StoredFile::RecallByFilepath($filepath, $con);
             if (is_null($file)) {
                 $return_hash['error'] = _("File doesn't exist in Airtime.");
                 Logging::warn("Attempt to delete file that doesn't exist.\n                        Path: '{$filepath}'");
             } else {
                 $file->deleteByMediaMonitor();
             }
         } elseif ($mode == "delete_dir") {
             $filepath = $md['MDATA_KEY_FILEPATH'];
             //$filepath = str_replace("\\", "", $filepath);
             $files = Application_Model_StoredFile::RecallByPartialFilepath($filepath, $con);
             foreach ($files as $file) {
                 $file->deleteByMediaMonitor();
             }
             $return_hash['success'] = 1;
         }
         if (!isset($return_hash['error'])) {
             $return_hash['fileid'] = is_null($file) ? '-1' : $file->getId();
         }
         $con->commit();
     } catch (Exception $e) {
         Logging::warn("rolling back");
         Logging::warn($e->getMessage());
         $con->rollback();
         $return_hash['error'] = $e->getMessage();
     }
     return $return_hash;
 }
예제 #16
0
 public function addUserAction()
 {
     $CC_CONFIG = Config::getConfig();
     $request = $this->getRequest();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $js_files = array('js/datatables/js/jquery.dataTables.js?', 'js/datatables/plugin/dataTables.pluginAPI.js?', 'js/airtime/user/user.js?');
     foreach ($js_files as $js) {
         $this->view->headScript()->appendFile($baseUrl . $js . $CC_CONFIG['airtime_version'], 'text/javascript');
     }
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/users.css?' . $CC_CONFIG['airtime_version']);
     $form = new Application_Form_AddUser();
     $this->view->successMessage = "";
     if ($request->isPost()) {
         $params = $request->getPost();
         $postData = explode('&', $params['data']);
         $formData = array();
         foreach ($postData as $k => $v) {
             $v = explode('=', $v);
             $formData[$v[0]] = urldecode($v[1]);
         }
         if ($form->isValid($formData)) {
             if ($form->validateLogin($formData)) {
                 $user = new Application_Model_User($formData['user_id']);
                 if (empty($formData['user_id'])) {
                     $user->setLogin($formData['login']);
                 }
                 $user->setFirstName($formData['first_name']);
                 $user->setLastName($formData['last_name']);
                 // We don't allow 6 x's as a password.
                 // The reason is because we that as a password placeholder
                 // on the client side.
                 if ($formData['password'] != "xxxxxx") {
                     $user->setPassword($formData['password']);
                 }
                 $user->setType($formData['type']);
                 $user->setEmail($formData['email']);
                 $user->setCellPhone($formData['cell_phone']);
                 $user->setSkype($formData['skype']);
                 $user->setJabber($formData['jabber']);
                 $user->save();
                 // Language and timezone settings are saved on a per-user basis
                 // By default, the default language, and timezone setting on
                 // preferences page is what gets assigned.
                 Application_Model_Preference::SetUserLocale();
                 Application_Model_Preference::SetUserTimezone();
                 $form->reset();
                 $this->view->form = $form;
                 if (strlen($formData['user_id']) == 0) {
                     $this->view->successMessage = "<div class='success'>" . _("User added successfully!") . "</div>";
                 } else {
                     $this->view->successMessage = "<div class='success'>" . _("User updated successfully!") . "</div>";
                 }
                 $this->_helper->json->sendJson(array("valid" => "true", "html" => $this->view->render('user/add-user.phtml')));
             } else {
                 $this->view->form = $form;
                 $this->_helper->json->sendJson(array("valid" => "false", "html" => $this->view->render('user/add-user.phtml')));
             }
         } else {
             $this->view->form = $form;
             $this->_helper->json->sendJson(array("valid" => "false", "html" => $this->view->render('user/add-user.phtml')));
         }
     }
     $this->view->form = $form;
 }
 public function contextMenuAction()
 {
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $id = $this->_getParam('id');
     $now = floatval(microtime(true));
     $request = $this->getRequest();
     $menu = array();
     $user = Application_Model_User::getCurrentUser();
     $item = CcScheduleQuery::create()->findPK($id);
     $instance = $item->getCcShowInstances();
     $menu["preview"] = array("name" => _("Preview"), "icon" => "play");
     //select the cursor
     $menu["selCurs"] = array("name" => _("Select cursor"), "icon" => "select-cursor");
     $menu["delCurs"] = array("name" => _("Remove cursor"), "icon" => "select-cursor");
     if ($now < floatval($item->getDbEnds("U.u")) && $user->canSchedule($instance->getDbShowId())) {
         //remove/truncate the item from the schedule
         $menu["del"] = array("name" => _("Delete"), "icon" => "delete", "url" => $baseUrl . "showbuilder/schedule-remove");
     }
     $this->view->items = $menu;
 }
 public function init()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/status/status.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
 }
예제 #19
0
파일: MusicDir.php 프로젝트: nidzix/Airtime
 /** There are 2 cases where this function can be called.
  * 1. When watched dir was removed
  * 2. When some dir was watched, but it was unmounted
  *
  *  In case of 1, $userAddedWatchedDir should be true
  *  In case of 2, $userAddedWatchedDir should be false
  *
  *  When $userAddedWatchedDir is true, it will set "Watched" flag to false
  *  otherwise, it will set "Exists" flag to true
  **/
 public static function removeWatchedDir($p_dir, $userAddedWatchedDir = true)
 {
     //make sure that $p_dir has a trailing "/"
     $real_path = Application_Common_OsPath::normpath($p_dir) . "/";
     if ($real_path != "/") {
         $p_dir = $real_path;
     }
     $dir = Application_Model_MusicDir::getDirByPath($p_dir);
     if (is_null($dir)) {
         return array("code" => 1, "error" => "'{$p_dir}' doesn't exist in the watched list.");
     } else {
         $dir->remove($userAddedWatchedDir);
         $data = array();
         $data["directory"] = $p_dir;
         Application_Model_RabbitMq::SendMessageToMediaMonitor("remove_watch", $data);
         return array("code" => 0);
     }
 }
예제 #20
0
 public function dispatchMetadata($md, $mode)
 {
     $return_hash = array();
     Application_Model_Preference::SetImportTimestamp();
     //Logging::info("--->Mode: $mode || file: {$md['MDATA_KEY_FILEPATH']} ");
     //Logging::info( $md );
     // create also modifies the file if it exists
     if ($mode == "create") {
         $filepath = $md['MDATA_KEY_FILEPATH'];
         $filepath = Application_Common_OsPath::normpath($filepath);
         $file = Application_Model_StoredFile::RecallByFilepath($filepath);
         if (is_null($file)) {
             $file = Application_Model_StoredFile::Insert($md);
         } else {
             // If the file already exists we will update and make sure that
             // it's marked as 'exists'.
             $file->setFileExistsFlag(true);
             $file->setMetadata($md);
         }
         if ($md['is_record'] != 0) {
             $this->uploadRecordedActionParam($md['MDATA_KEY_TRACKNUMBER'], $file->getId());
         }
     } elseif ($mode == "modify") {
         $filepath = $md['MDATA_KEY_FILEPATH'];
         $file = Application_Model_StoredFile::RecallByFilepath($filepath);
         //File is not in database anymore.
         if (is_null($file)) {
             $return_hash['error'] = "File does not exist in Airtime.";
             return $return_hash;
         } else {
             $file->setMetadata($md);
         }
     } elseif ($mode == "moved") {
         $file = Application_Model_StoredFile::RecallByFilepath($md['MDATA_KEY_ORIGINAL_PATH']);
         if (is_null($file)) {
             $return_hash['error'] = 'File does not exist in Airtime';
         } else {
             $filepath = $md['MDATA_KEY_FILEPATH'];
             //$filepath = str_replace("\\", "", $filepath);
             $file->setFilePath($filepath);
         }
     } elseif ($mode == "delete") {
         $filepath = $md['MDATA_KEY_FILEPATH'];
         $filepath = str_replace("\\", "", $filepath);
         $file = Application_Model_StoredFile::RecallByFilepath($filepath);
         if (is_null($file)) {
             $return_hash['error'] = "File doesn't exist in Airtime.";
             Logging::warn("Attempt to delete file that doesn't exist.\n                    Path: '{$filepath}'");
             return $return_hash;
         } else {
             $file->deleteByMediaMonitor();
         }
     } elseif ($mode == "delete_dir") {
         $filepath = $md['MDATA_KEY_FILEPATH'];
         //$filepath = str_replace("\\", "", $filepath);
         $files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
         foreach ($files as $file) {
             $file->deleteByMediaMonitor();
         }
         $return_hash['success'] = 1;
         return $return_hash;
     }
     $return_hash['fileid'] = is_null($file) ? '-1' : $file->getId();
     return $return_hash;
 }
 public function streamSettingAction()
 {
     $CC_CONFIG = Config::getConfig();
     $request = $this->getRequest();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/preferences/streamsetting.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     // get current settings
     $temp = Application_Model_StreamSetting::getStreamSetting();
     $setting = array();
     foreach ($temp as $t) {
         $setting[$t['keyname']] = $t['value'];
     }
     $name_map = array('ogg' => 'Ogg Vorbis', 'fdkaac' => 'AAC+', 'aac' => 'AAC', 'opus' => 'Opus', 'mp3' => 'MP3');
     // get predefined type and bitrate from pref table
     $temp_types = Application_Model_Preference::GetStreamType();
     $stream_types = array();
     foreach ($temp_types as $type) {
         $type = strtolower(trim($type));
         if (isset($name_map[$type])) {
             $name = $name_map[$type];
         } else {
             $name = $type;
         }
         $stream_types[$type] = $name;
     }
     $temp_bitrate = Application_Model_Preference::GetStreamBitrate();
     $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate());
     $stream_bitrates = array();
     foreach ($temp_bitrate as $type) {
         if (intval($type) <= $max_bitrate) {
             $stream_bitrates[trim($type)] = strtoupper(trim($type)) . " kbit/s";
         }
     }
     $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams());
     $form = new Application_Form_StreamSetting();
     $form->setSetting($setting);
     $form->startFrom();
     $live_stream_subform = new Application_Form_LiveStreamingPreferences();
     $form->addSubForm($live_stream_subform, "live_stream_subform");
     for ($i = 1; $i <= $num_of_stream; $i++) {
         $subform = new Application_Form_StreamSettingSubForm();
         $subform->setPrefix($i);
         $subform->setSetting($setting);
         $subform->setStreamTypes($stream_types);
         $subform->setStreamBitrates($stream_bitrates);
         $subform->startForm();
         $form->addSubForm($subform, "s" . $i . "_subform");
     }
     if ($request->isPost()) {
         $params = $request->getPost();
         /* Parse through post data and put in format
          * $form->isValid() is expecting it in
          */
         $postData = explode('&', $params['data']);
         $s1_data = array();
         $s2_data = array();
         $s3_data = array();
         $values = array();
         foreach ($postData as $k => $v) {
             $v = explode('=', urldecode($v));
             if (strpos($v[0], "s1_data") !== false) {
                 /* In this case $v[0] may be 's1_data[enable]' , for example.
                  * We only want the 'enable' part
                  */
                 preg_match('/\\[(.*)\\]/', $v[0], $matches);
                 $s1_data[$matches[1]] = $v[1];
             } elseif (strpos($v[0], "s2_data") !== false) {
                 preg_match('/\\[(.*)\\]/', $v[0], $matches);
                 $s2_data[$matches[1]] = $v[1];
             } elseif (strpos($v[0], "s3_data") !== false) {
                 preg_match('/\\[(.*)\\]/', $v[0], $matches);
                 $s3_data[$matches[1]] = $v[1];
             } else {
                 $values[$v[0]] = $v[1];
             }
         }
         $values["s1_data"] = $s1_data;
         $values["s2_data"] = $s2_data;
         $values["s3_data"] = $s3_data;
         $error = false;
         if ($form->isValid($values)) {
             $values['output_sound_device'] = $form->getValue('output_sound_device');
             $values['output_sound_device_type'] = $form->getValue('output_sound_device_type');
             $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
             $values['streamFormat'] = $form->getValue('streamFormat');
             Application_Model_StreamSetting::setStreamSetting($values);
             /* If the admin password values are empty then we should not
              * set the pseudo password ('xxxxxx') on the front-end
              */
             $s1_set_admin_pass = !empty($values["s1_data"]["admin_pass"]);
             $s2_set_admin_pass = !empty($values["s2_data"]["admin_pass"]);
             $s3_set_admin_pass = !empty($values["s3_data"]["admin_pass"]);
             // this goes into cc_pref table
             Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
             Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]);
             Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]);
             Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]);
             Application_Model_Preference::SetAutoTransition($values["auto_transition"]);
             Application_Model_Preference::SetAutoSwitch($values["auto_switch"]);
             // compare new values with current value
             $changeRGenabled = Application_Model_Preference::GetEnableReplayGain() != $values["enableReplayGain"];
             $changeRGmodifier = Application_Model_Preference::getReplayGainModifier() != $values["replayGainModifier"];
             if ($changeRGenabled || $changeRGmodifier) {
                 Application_Model_Preference::SetEnableReplayGain($values["enableReplayGain"]);
                 Application_Model_Preference::setReplayGainModifier($values["replayGainModifier"]);
                 $md = array('schedule' => Application_Model_Schedule::getSchedule());
                 Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md);
                 //Application_Model_RabbitMq::PushSchedule();
             }
             if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {
                 $master_connection_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $values["master_harbor_input_port"] . "/" . $values["master_harbor_input_mount_point"];
                 if (empty($values["master_harbor_input_port"]) || empty($values["master_harbor_input_mount_point"])) {
                     Application_Model_Preference::SetMasterDJSourceConnectionURL('N/A');
                 } else {
                     Application_Model_Preference::SetMasterDJSourceConnectionURL($master_connection_url);
                 }
             } else {
                 Application_Model_Preference::SetMasterDJSourceConnectionURL($values["master_dj_connection_url"]);
             }
             if (!Application_Model_Preference::GetLiveDjConnectionUrlOverride()) {
                 $live_connection_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $values["dj_harbor_input_port"] . "/" . $values["dj_harbor_input_mount_point"];
                 if (empty($values["dj_harbor_input_port"]) || empty($values["dj_harbor_input_mount_point"])) {
                     Application_Model_Preference::SetLiveDJSourceConnectionURL('N/A');
                 } else {
                     Application_Model_Preference::SetLiveDJSourceConnectionURL($live_connection_url);
                 }
             } else {
                 Application_Model_Preference::SetLiveDJSourceConnectionURL($values["live_dj_connection_url"]);
             }
             // extra info that goes into cc_stream_setting
             Application_Model_StreamSetting::setMasterLiveStreamPort($values["master_harbor_input_port"]);
             Application_Model_StreamSetting::setMasterLiveStreamMountPoint($values["master_harbor_input_mount_point"]);
             Application_Model_StreamSetting::setDjLiveStreamPort($values["dj_harbor_input_port"]);
             Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["dj_harbor_input_mount_point"]);
             Application_Model_StreamSetting::setOffAirMeta($values['offAirMeta']);
             // store stream update timestamp
             Application_Model_Preference::SetStreamUpdateTimestamp();
             $data = array();
             $info = Application_Model_StreamSetting::getStreamSetting();
             $data['setting'] = $info;
             for ($i = 1; $i <= $num_of_stream; $i++) {
                 Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
             }
             Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
             $live_stream_subform->updateVariables();
             $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
             $this->view->form = $form;
             $this->view->num_stream = $num_of_stream;
             $this->view->statusMsg = "<div class='success'>" . _("Stream Setting Updated.") . "</div>";
             $this->_helper->json->sendJson(array("valid" => "true", "html" => $this->view->render('preference/stream-setting.phtml'), "s1_set_admin_pass" => $s1_set_admin_pass, "s2_set_admin_pass" => $s2_set_admin_pass, "s3_set_admin_pass" => $s3_set_admin_pass));
         } else {
             $live_stream_subform->updateVariables();
             $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
             $this->view->form = $form;
             $this->view->num_stream = $num_of_stream;
             $this->_helper->json->sendJson(array("valid" => "false", "html" => $this->view->render('preference/stream-setting.phtml')));
         }
     }
     $live_stream_subform->updateVariables();
     $this->view->num_stream = $num_of_stream;
     $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
     $this->view->form = $form;
 }
 /**
  *Function will load and return the contents of the requested show.
  */
 public function getShowAction()
 {
     $baseUrl = Application_Common_OsPath::getBaseDir();
     // disable the view and the layout
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $showID = $this->_getParam('showID');
     if (!isset($showID)) {
         return;
     }
     $showInstance = new Application_Model_ShowInstance($showID);
     $result = array();
     $position = 0;
     foreach ($showInstance->getShowListContent() as $track) {
         $elementMap = array('element_title' => isset($track['track_title']) ? $track['track_title'] : "", 'element_artist' => isset($track['creator']) ? $track['creator'] : "", 'element_position' => $position, 'element_id' => ++$position, 'mime' => isset($track['mime']) ? $track['mime'] : "");
         $elementMap['type'] = $track['type'];
         if ($track['type'] == 0) {
             $mime = $track['mime'];
             if (strtolower($mime) === 'audio/mp3') {
                 $elementMap['element_mp3'] = $track['item_id'];
             } elseif (strtolower($mime) === 'audio/ogg') {
                 $elementMap['element_oga'] = $track['item_id'];
             } elseif (strtolower($mime) === 'audio/mp4') {
                 $elementMap['element_m4a'] = $track['item_id'];
             } elseif (strtolower($mime) === 'audio/wav') {
                 $elementMap['element_wav'] = $track['item_id'];
             } elseif (strtolower($mime) === 'audio/x-flac') {
                 $elementMap['element_flac'] = $track['item_id'];
             } else {
                 throw new Exception("Unknown file type: {$mime}");
             }
             $elementMap['uri'] = $baseUrl . "api/get-media/file/" . $track['item_id'];
         } else {
             $elementMap['uri'] = $track['filepath'];
         }
         $result[] = $elementMap;
     }
     $this->_helper->json($result);
 }
예제 #23
0
 public function getFileMetadataAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     try {
         if ($type == "audioclip") {
             $file = Application_Model_StoredFile::Recall($id);
             $this->view->type = $type;
             $md = $file->getMetadata();
             foreach ($md as $key => $value) {
                 if ($key == 'MDATA_KEY_DIRECTORY') {
                     $musicDir = Application_Model_MusicDir::getDirByPK($value);
                     $md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
                 }
             }
             $formatter = new SamplerateFormatter($md["MDATA_KEY_SAMPLERATE"]);
             $md["MDATA_KEY_SAMPLERATE"] = $formatter->format();
             $formatter = new BitrateFormatter($md["MDATA_KEY_BITRATE"]);
             $md["MDATA_KEY_BITRATE"] = $formatter->format();
             $formatter = new LengthFormatter($md["MDATA_KEY_DURATION"]);
             $md["MDATA_KEY_DURATION"] = $formatter->format();
             $this->view->md = $md;
         } elseif ($type == "playlist") {
             $file = new Application_Model_Playlist($id);
             $this->view->type = $type;
             $md = $file->getAllPLMetaData();
             $formatter = new LengthFormatter($md["dcterms:extent"]);
             $md["dcterms:extent"] = $formatter->format();
             $this->view->md = $md;
             $this->view->contents = $file->getContents();
         } elseif ($type == "block") {
             $block = new Application_Model_Block($id);
             $this->view->type = $type;
             $md = $block->getAllPLMetaData();
             $formatter = new LengthFormatter($md["dcterms:extent"]);
             $md["dcterms:extent"] = $formatter->format();
             $this->view->md = $md;
             if ($block->isStatic()) {
                 $this->view->blType = 'Static';
                 $this->view->contents = $block->getContents();
             } else {
                 $this->view->blType = 'Dynamic';
                 $this->view->contents = $block->getCriteria();
             }
             $this->view->block = $block;
         } elseif ($type == "stream") {
             $webstream = CcWebstreamQuery::create()->findPK($id);
             $ws = new Application_Model_Webstream($webstream);
             $md = $ws->getMetadata();
             $this->view->md = $md;
             $this->view->type = $type;
         }
     } catch (Exception $e) {
         Logging::info($e->getMessage());
     }
 }