diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index d95d2f4b3..50fe4cc59 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -62,6 +62,8 @@ class ApiController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $api_key = $this->_getParam('api_key'); + $downlaod = $this->_getParam('download'); + if(!in_array($api_key, $CC_CONFIG["apiKey"])) { header('HTTP/1.0 401 Unauthorized'); @@ -92,8 +94,9 @@ class ApiController extends Zend_Controller_Action header("Content-Type: audio/ogg"); else if ($ext == "mp3") header("Content-Type: audio/mpeg"); - - + if ($downlaod){ + header('Content-Disposition: attachment; filename="'.$media->getName().'"'); + } header("Content-Length: " . filesize($filepath)); fpassthru($fp); return; diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 467ebda77..cb21b4f61 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -50,6 +50,8 @@ class LibraryController extends Zend_Controller_Action public function contextMenuAction() { + global $CC_CONFIG; + $id = $this->_getParam('id'); $type = $this->_getParam('type'); @@ -70,6 +72,16 @@ class LibraryController extends Zend_Controller_Action $menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'), 'title' => 'Edit Metadata'); + // added for downlaod + $id = $this->_getParam('id'); + + $file_id = $this->_getParam('id', null); + $file = StoredFile::Recall($file_id); + + $url = 'api/get-media/file/'.$file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), + 'title' => 'Download'); + $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"), 'title' => 'Delete'); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 5a76b215c..53bd49f01 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -27,6 +27,7 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('cancel-show', 'json') ->addActionContext('get-form', 'json') ->addActionContext('upload-to-sound-cloud', 'json') + ->addActionContext('content-context-menu', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -703,6 +704,29 @@ class ScheduleController extends Zend_Controller_Action $show->deleteShow(); } } + + public function contentContextMenuAction(){ + global $CC_CONFIG; + + $id = $this->_getParam('id'); + + $params = '/format/json/id/#id#/'; + + $paramsPop = str_replace('#id#', $id, $params); + + // added for downlaod + $id = $this->_getParam('id'); + + $file_id = $this->_getParam('id', null); + $file = StoredFile::Recall($file_id); + + $url = 'api/get-media/file/'.$file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), + 'title' => 'Download'); + + //returns format jjmenu is looking for. + die(json_encode($menu)); + } } diff --git a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml index 4e5aac630..c830dd3da 100644 --- a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml +++ b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml @@ -11,7 +11,7 @@ showContent as $row): ?> - "> + " class=""> diff --git a/airtime_mvc/public/css/contextmenu.css b/airtime_mvc/public/css/contextmenu.css index 41a2f04a5..07af8909b 100644 --- a/airtime_mvc/public/css/contextmenu.css +++ b/airtime_mvc/public/css/contextmenu.css @@ -5,7 +5,7 @@ div.jjmenu { border-bottom:2px solid #5b5b5b; border-right:1px solid #5b5b5b; padding:0px; - z-index: 100; + z-index: 1011; font-size:11px; } diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index d1d513626..20c0321f8 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -197,6 +197,15 @@ function uploadToSoundCloud(show_instance_id){ } +//used by jjmenu +function getId() { + var tr_id = $(this.triggerElement).attr("id"); + tr_id = tr_id.split("_"); + + return tr_id[1]; +} +//end functions used by jjmenu + function buildContentDialog(json){ var dialog = $(json.dialog); @@ -213,6 +222,12 @@ function buildContentDialog(json){ }); dialog.dialog('open'); + + $('#show_content_dialog tbody tr') + .jjmenu("click", + [{get:"/Schedule/content-context-menu/format/json/id/#id#"}], + {id: getId}, + {xposition: "mouse", yposition: "mouse"}); } function buildScheduleDialog(json){