public function init() { $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences_soundcloud.phtml')))); //enable soundcloud uploads $this->addElement('checkbox', 'UseSoundCloud', array('label' => 'Upload Recorded Shows To SoundCloud', 'required' => false, 'value' => Application_Model_Preference::GetDoSoundCloudUpload(), 'decorators' => array('ViewHelper'))); //SoundCloud Username $this->addElement('text', 'SoundCloudUser', array('class' => 'input_text', 'label' => 'SoundCloud Email:', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetSoundCloudUser(), 'decorators' => array('ViewHelper'))); //SoundCloud Password $this->addElement('password', 'SoundCloudPassword', array('class' => 'input_text', 'label' => 'SoundCloud Password:'******'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetSoundCloudPassword(), 'decorators' => array('ViewHelper'))); // Add the description element $this->addElement('textarea', 'SoundCloudTags', array('label' => 'SoundCloud Tags: (separate tags with spaces)', 'required' => false, 'class' => 'input_text_area', 'value' => Application_Model_Preference::GetSoundCloudTags(), 'decorators' => array('ViewHelper'))); //SoundCloud default genre $this->addElement('text', 'SoundCloudGenre', array('class' => 'input_text', 'label' => 'Default Genre:', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetSoundCloudGenre(), 'decorators' => array('ViewHelper'))); $select = new Zend_Form_Element_Select('SoundCloudTrackType'); $select->setLabel('Default Track Type:'); $select->setAttrib('class', 'input_select'); $select->setMultiOptions(array("" => "", "original" => "Original", "remix" => "Remix", "live" => "Live", "recording" => "Recording", "spoken" => "Spoken", "podcast" => "Podcast", "demo" => "Demo", "in progress" => "Work in progress", "stem" => "Stem", "loop" => "Loop", "sound effect" => "Sound Effect", "sample" => "One Shot Sample", "other" => "Other")); $select->setRequired(false); $select->setValue(Application_Model_Preference::GetSoundCloudTrackType()); $select->setDecorators(array('ViewHelper')); $this->addElement($select); $select = new Zend_Form_Element_Select('SoundCloudLicense'); $select->setLabel('Default License:'); $select->setAttrib('class', 'input_select'); $select->setMultiOptions(array("" => "", "no-rights-reserved" => "The work is in the public domain", "all-rights-reserved" => "All rights are reserved", "cc-by" => "Creative Commons Attribution", "cc-by-nc" => "Creative Commons Attribution Noncommercial", "cc-by-nd" => "Creative Commons Attribution No Derivative Works", "cc-by-sa" => "Creative Commons Attribution Share Alike", "cc-by-nc-nd" => "Creative Commons Attribution Noncommercial Non Derivate Works", "cc-by-nc-sa" => "Creative Commons Attribution Noncommercial Share Alike")); $select->setRequired(false); $select->setValue(Application_Model_Preference::GetSoundCloudLicense()); $select->setDecorators(array('ViewHelper')); $this->addElement($select); }
public function makeContextMenuAction() { $id = $this->_getParam('id'); $today_timestamp = date("Y-m-d H:i:s"); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); $show = new ShowInstance($id); $params = '/format/json/id/#id#'; if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST), $show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) { $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog' . $params, 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content'); } } if (!$show->isRecorded()) { $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog' . $params, 'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content'); } if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp) && is_null($show->getSoundCloudFileId()) && $show->isRecorded() && Application_Model_Preference::GetDoSoundCloudUpload()) { $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['uploadToSoundCloud']({$id})"), 'title' => 'Upload to Soundcloud'); } if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) && strtotime($today_timestamp) < strtotime($show->getShowEnd()) && $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['confirmCancelShow']({$id})"), 'title' => 'Cancel Current Show'); } if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/' . $id, 'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); } } //returns format jjmenu is looking for. die(json_encode($menu)); }
public function uploadRecordedAction() { global $CC_CONFIG; $api_key = $this->_getParam('api_key'); if (!in_array($api_key, $CC_CONFIG["apiKey"])) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; exit; } //this file id is the recording for this show instance. $show_instance_id = $this->_getParam('showinstanceid'); $file_id = $this->_getParam('fileid'); $this->view->fileid = $file_id; $this->view->showinstanceid = $show_instance_id; $showCanceled = false; $file = StoredFile::Recall($file_id); //$show_instance = $this->_getParam('show_instance'); $show_name = null; try { $show_inst = new ShowInstance($show_instance_id); $show_inst->setRecordedFile($file_id); $show_name = $show_inst->getName(); $show_genre = $show_inst->getGenre(); $show_start_time = $show_inst->getShowStart(); } catch (Exception $e) { //we've reached here probably because the show was //cancelled, and therefore the show instance does not //exist anymore (ShowInstance constructor threw this error). //We've done all we can do (upload the file and put it in //the library), now lets just return. $showCanceled = true; } if (isset($show_name)) { $tmpTitle = "{$show_name}-{$show_start_time}"; $tmpTitle = str_replace(" ", "-", $tmpTitle); } else { $tmpTitle = $file->getName(); } $file->setMetadataValue('MDATA_KEY_TITLE', $tmpTitle); $file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder"); $file->setMetadataValue('MDATA_KEY_TRACKNUMBER', null); if (!$showCanceled && Application_Model_Preference::GetDoSoundCloudUpload()) { for ($i = 0; $i < $CC_CONFIG['soundcloud-connection-retries']; $i++) { $show = new Show($show_inst->getShowId()); $description = $show->getDescription(); $hosts = $show->getHosts(); $tags = array_merge($hosts, array($show_name)); try { $soundcloud = new ATSoundcloud(); $soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $tmpTitle, $description, $tags, $show_start_time, $show_genre); $show_inst->setSoundCloudFileId($soundcloud_id); break; } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { $code = $e->getHttpCode(); if (!in_array($code, array(0, 100))) { break; } } sleep($CC_CONFIG['soundcloud-connection-wait']); } } $this->view->id = $file_id; }