Пример #1
0
 public function init()
 {
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences_soundcloud.phtml'))));
     //enable soundcloud uploads
     $this->addElement('checkbox', 'UseSoundCloud', array('label' => 'Automatically Upload Recorded Shows', 'required' => false, 'value' => Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud(), 'decorators' => array('ViewHelper')));
     //enable soundcloud uploads option
     $this->addElement('checkbox', 'UploadToSoundcloudOption', array('label' => 'Enable SoundCloud Upload', 'required' => false, 'value' => Application_Model_Preference::GetUploadToSoundcloudOption(), 'decorators' => array('ViewHelper')));
     //enable downloadable for soundcloud
     $this->addElement('checkbox', 'SoundCloudDownloadbleOption', array('label' => 'Automatically Mark Files "Downloadable" on SoundCloud', 'required' => false, 'value' => Application_Model_Preference::GetSoundCloudDownloadbleOption(), 'decorators' => array('ViewHelper')));
     //SoundCloud Username
     $this->addElement('text', 'SoundCloudUser', array('class' => 'input_text', 'label' => 'SoundCloud Email', 'filters' => array('StringTrim'), 'autocomplete' => 'off', 'value' => Application_Model_Preference::GetSoundCloudUser(), 'decorators' => array('ViewHelper'), 'allowEmpty' => false, 'validators' => array(new ConditionalNotEmpty(array('UploadToSoundcloudOption' => '1')))));
     //SoundCloud Password
     $this->addElement('password', 'SoundCloudPassword', array('class' => 'input_text', 'label' => 'SoundCloud Password', 'filters' => array('StringTrim'), 'autocomplete' => 'off', 'value' => Application_Model_Preference::GetSoundCloudPassword(), 'decorators' => array('ViewHelper'), 'allowEmpty' => false, 'validators' => array(new ConditionalNotEmpty(array('UploadToSoundcloudOption' => '1'))), 'renderPassword' => true));
     // 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);
 }
Пример #2
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;
 }
Пример #3
0
 public function uploadToSoundCloud()
 {
     global $CC_CONFIG;
     $file = $this->_file;
     if (is_null($file)) {
         return "File does not exist";
     }
     if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
         for ($i = 0; $i < $CC_CONFIG['soundcloud-connection-retries']; $i++) {
             $description = $file->getDbTrackTitle();
             $tag = array();
             $genre = $file->getDbGenre();
             $release = $file->getDbYear();
             try {
                 $soundcloud = new Application_Model_Soundcloud();
                 $soundcloud_res = $soundcloud->uploadTrack($this->getFilePath(), $this->getName(), $description, $tag, $release, $genre);
                 $this->setSoundCloudFileId($soundcloud_res['id']);
                 $this->setSoundCloudLinkToFile($soundcloud_res['permalink_url']);
                 $this->setSoundCloudUploadTime(new DateTime("now"), new DateTimeZone("UTC"));
                 break;
             } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                 $code = $e->getHttpCode();
                 $msg = $e->getHttpBody();
                 // TODO : Do not parse JSON by hand
                 $temp = explode('"error":', $msg);
                 $msg = trim($temp[1], '"}');
                 $this->setSoundCloudErrorCode($code);
                 $this->setSoundCloudErrorMsg($msg);
                 // setting sc id to -3 which indicates error
                 $this->setSoundCloudFileId(SOUNDCLOUD_ERROR);
                 if (!in_array($code, array(0, 100))) {
                     break;
                 }
             }
             sleep($CC_CONFIG['soundcloud-connection-wait']);
         }
     }
 }
Пример #4
0
 public function makeContextMenuAction()
 {
     $id = $this->_getParam('id');
     $menu = array();
     $epochNow = time();
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     try {
         $instance = new Application_Model_ShowInstance($id);
     } catch (Exception $e) {
         $this->view->show_error = true;
         return false;
     }
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     $isDJ = $user->isHostOfShow($instance->getShowId());
     $showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
     $showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
     if ($instance->isRecorded() && $epochNow > $showEndLocalDT->getTimestamp()) {
         $file = $instance->getRecordedFile();
         $fileId = $file->getId();
         $menu["view_recorded"] = array("name" => "View Recorded File Metadata", "icon" => "overview", "url" => "/library/edit-file-md/id/" . $fileId);
     }
     if ($epochNow < $showStartLocalDT->getTimestamp()) {
         if (($isAdminOrPM || $isDJ) && !$instance->isRecorded() && !$instance->isRebroadcast()) {
             $menu["schedule"] = array("name" => "Add / Remove Content", "icon" => "add-remove-content", "url" => "/showbuilder/builder-dialog/");
             $menu["clear"] = array("name" => "Remove All Content", "icon" => "remove-all-content", "url" => "/schedule/clear-show");
         }
     }
     if (!$instance->isRecorded()) {
         $menu["content"] = array("name" => "Show Content", "icon" => "overview", "url" => "/schedule/show-content-dialog");
     }
     if ($showEndLocalDT->getTimestamp() <= $epochNow && $instance->isRecorded() && Application_Model_Preference::GetUploadToSoundcloudOption()) {
         $file = $instance->getRecordedFile();
         $fileId = $file->getId();
         $scid = $instance->getSoundCloudFileId();
         if ($scid > 0) {
             $url = $file->getSoundCloudLinkToFile();
             $menu["soundcloud_view"] = array("name" => "View on Soundcloud", "icon" => "soundcloud", "url" => $url);
         }
         $text = is_null($scid) ? 'Upload to SoundCloud' : 'Re-upload to SoundCloud';
         $menu["soundcloud_upload"] = array("name" => $text, "icon" => "soundcloud");
     }
     if ($showStartLocalDT->getTimestamp() <= $epochNow && $epochNow < $showEndLocalDT->getTimestamp() && $isAdminOrPM) {
         if ($instance->isRecorded()) {
             $menu["cancel_recorded"] = array("name" => "Cancel Current Show", "icon" => "delete");
         } else {
             if (!$instance->isRebroadcast()) {
                 $menu["edit"] = array("name" => "Edit Show", "icon" => "edit", "_type" => "all", "url" => "/Schedule/populate-show-form");
             }
             $menu["cancel"] = array("name" => "Cancel Current Show", "icon" => "delete");
         }
     }
     if ($epochNow < $showStartLocalDT->getTimestamp()) {
         if (!$instance->isRebroadcast() && $isAdminOrPM) {
             $menu["edit"] = array("name" => "Edit Show", "icon" => "edit", "_type" => "all", "url" => "/Schedule/populate-show-form");
         }
         if ($instance->getShow()->isRepeating() && $isAdminOrPM) {
             //create delete sub menu.
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "items" => array());
             $menu["del"]["items"]["single"] = array("name" => "Delete This Instance", "icon" => "delete", "url" => "/schedule/delete-show");
             $menu["del"]["items"]["following"] = array("name" => "Delete This Instance and All Following", "icon" => "delete", "url" => "/schedule/cancel-show");
         } elseif ($isAdminOrPM) {
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/schedule/delete-show");
         }
     }
     $this->view->items = $menu;
 }
Пример #5
0
 private function makeHeaderRow($p_item)
 {
     $row = $this->defaultRowArray;
     //$this->isAllowed($p_item, $row);
     $this->getRowTimestamp($p_item, $row);
     $this->getItemColor($p_item, $row);
     $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
     $showStartDT->setTimezone(new DateTimeZone($this->timezone));
     $startsEpoch = floatval($showStartDT->format("U.u"));
     $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
     $showEndDT->setTimezone(new DateTimeZone($this->timezone));
     $endsEpoch = floatval($showEndDT->format("U.u"));
     //is a rebroadcast show
     if (intval($p_item["si_rebroadcast"]) === 1) {
         $row["rebroadcast"] = true;
         $parentInstance = CcShowInstancesQuery::create()->findPk($p_item["parent_show"]);
         $name = $parentInstance->getCcShow()->getDbName();
         $dt = $parentInstance->getDbStarts(null);
         $dt->setTimezone(new DateTimeZone($this->timezone));
         $time = $dt->format("Y-m-d H:i");
         $row["rebroadcast_title"] = sprintf(_("Rebroadcast of %s from %s"), $name, $time);
     } elseif (intval($p_item["si_record"]) === 1) {
         $row["record"] = true;
         // at the time of creating on show, the recorded file is not in the DB yet.
         // therefore, 'si_file_id' is null. So we need to check it.
         if (Application_Model_Preference::GetUploadToSoundcloudOption() && isset($p_item['si_file_id'])) {
             $file = Application_Model_StoredFile::RecallById($p_item['si_file_id']);
             if (isset($file)) {
                 $sid = $file->getSoundCloudId();
                 $row['soundcloud_id'] = $sid;
             }
         }
     }
     if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) {
         $row["currentShow"] = true;
         $this->currentShow = true;
     } else {
         $this->currentShow = false;
     }
     $this->isAllowed($p_item, $row);
     $row["header"] = true;
     $row["starts"] = $showStartDT->format("Y-m-d H:i");
     $row["startDate"] = $showStartDT->format("Y-m-d");
     $row["startTime"] = $showStartDT->format("H:i");
     $row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now;
     $row["ends"] = $showEndDT->format("Y-m-d H:i");
     $row["endDate"] = $showEndDT->format("Y-m-d");
     $row["endTime"] = $showEndDT->format("H:i");
     $row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u"));
     $row["title"] = htmlspecialchars($p_item["show_name"]);
     $row["instance"] = intval($p_item["si_id"]);
     $row["image"] = '';
     $this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
     $this->contentDT = $showStartDT;
     return $row;
 }
Пример #6
0
 public function contextMenuAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     //playlist||timeline
     $screen = $this->_getParam('screen');
     $request = $this->getRequest();
     $baseUrl = $request->getBaseUrl();
     $menu = array();
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     //Open a jPlayer window and play the audio clip.
     $menu["play"] = array("name" => "Preview", "icon" => "play", "disabled" => false);
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
     if ($type === "audioclip") {
         $file = Application_Model_StoredFile::Recall($id);
         $menu["play"]["mime"] = $file->getPropelOrm()->getDbMime();
         if (isset($obj_sess->id) && $screen == "playlist") {
             // if the user is not admin or pm, check the creator and see if this person owns the playlist or Block
             if ($obj_sess->type == 'playlist') {
                 $obj = new Application_Model_Playlist($obj_sess->id);
             } elseif ($obj_sess->type == 'block') {
                 $obj = new Application_Model_Block($obj_sess->id);
             }
             if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
                 if ($obj_sess->type === "playlist") {
                     $menu["pl_add"] = array("name" => "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
                 } elseif ($obj_sess->type === "block") {
                     $menu["pl_add"] = array("name" => "Add to Smart Block", "icon" => "add-playlist", "icon" => "copy");
                 }
             }
         }
         if ($isAdminOrPM) {
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/library/delete");
             $menu["edit"] = array("name" => "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
         }
         $url = $file->getRelativeFileUrl($baseUrl) . '/download/true';
         $menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url);
     } elseif ($type === "playlist" || $type === "block") {
         if ($type === 'playlist') {
             $obj = new Application_Model_Playlist($id);
         } elseif ($type === 'block') {
             $obj = new Application_Model_Block($id);
             if (!$obj->isStatic()) {
                 unset($menu["play"]);
             }
             if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") {
                 if ($obj_sess->type === "playlist") {
                     $menu["pl_add"] = array("name" => "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
                 }
             }
         }
         if ($obj_sess->id !== $id && $screen == "playlist") {
             if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
                 $menu["edit"] = array("name" => "Edit", "icon" => "edit");
             }
         }
         if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/library/delete");
         }
     } elseif ($type == "stream") {
         $webstream = CcWebstreamQuery::create()->findPK($id);
         $obj = new Application_Model_Webstream($webstream);
         if (isset($obj_sess->id) && $screen == "playlist") {
             if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
                 if ($obj_sess->type === "playlist") {
                     $menu["pl_add"] = array("name" => "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
                 }
             }
         }
         if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
             if ($screen == "playlist") {
                 $menu["edit"] = array("name" => "Edit", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
             }
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/library/delete");
         }
     }
     //SOUNDCLOUD MENU OPTIONS
     if ($type === "audioclip" && Application_Model_Preference::GetUploadToSoundcloudOption()) {
         //create a menu separator
         $menu["sep1"] = "-----------";
         //create a sub menu for Soundcloud actions.
         $menu["soundcloud"] = array("name" => "Soundcloud", "icon" => "soundcloud", "items" => array());
         $scid = $file->getSoundCloudId();
         if ($scid > 0) {
             $url = $file->getSoundCloudLinkToFile();
             $menu["soundcloud"]["items"]["view"] = array("name" => "View on Soundcloud", "icon" => "soundcloud", "url" => $url);
         }
         if (!is_null($scid)) {
             $text = "Re-upload to SoundCloud";
         } else {
             $text = "Upload to SoundCloud";
         }
         $menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => "/library/upload-file-soundcloud/id/{$id}");
     }
     if (empty($menu)) {
         $menu["noaction"] = array("name" => "No action available");
     }
     $this->view->items = $menu;
 }