diff --git a/application/configs/ACL.php b/application/configs/ACL.php index 26f1905b3..0bf2b6d43 100644 --- a/application/configs/ACL.php +++ b/application/configs/ACL.php @@ -14,7 +14,6 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('error')) ->add(new Zend_Acl_Resource('login')) ->add(new Zend_Acl_Resource('playlist')) - ->add(new Zend_Acl_Resource('sideplaylist')) ->add(new Zend_Acl_Resource('plupload')) ->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('api')) @@ -30,12 +29,14 @@ $ccAcl->allow('G', 'index') ->allow('G', 'error') ->allow('G', 'nowplaying') ->allow('G', 'api') + //->allow('G', 'plupload', array('upload-recorded')) ->allow('G', 'recorder') ->allow('G', 'schedule') ->allow('G', 'dashboard') + //->allow('H', 'plupload', array('plupload', 'upload', 'index')) + ->allow('H', 'plupload') ->allow('H', 'library') ->allow('H', 'search') - ->allow('H', 'plupload') ->allow('H', 'playlist') ->allow('A', 'user') ->allow('A', 'preference'); diff --git a/application/controllers/PluploadController.php b/application/controllers/PluploadController.php index 830590487..5870ab23a 100644 --- a/application/controllers/PluploadController.php +++ b/application/controllers/PluploadController.php @@ -5,22 +5,13 @@ class PluploadController extends Zend_Controller_Action public function init() { - if(!Zend_Auth::getInstance()->hasIdentity()) - { - $this->_redirect('login/index'); - } - $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('upload', 'json') + ->addActionContext('upload-recorded', 'json') ->initContext(); } - public function indexAction() - { - // action body - } - - public function uploadAction() + public function upload($targetDir) { // HTTP headers for no cache etc header('Content-type: text/plain; charset=UTF-8'); @@ -31,7 +22,7 @@ class PluploadController extends Zend_Controller_Action header("Pragma: no-cache"); // Settings - $targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; + //$targetDir = ini_get("upload_tmp_dir"); //. DIRECTORY_SEPARATOR . "plupload"; $cleanupTargetDir = false; // Remove old files $maxFileAge = 60 * 60; // Temp file age in seconds @@ -159,6 +150,23 @@ class PluploadController extends Zend_Controller_Action die('{"jsonrpc" : "2.0", "id" : '.$storedFile->getId().' }'); } + public function indexAction() + { + // action body + } + + public function uploadAction() + { + $upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; + $this->upload($upload_dir); + } + + public function uploadRecordedAction() + { + $upload_dir = ini_get("upload_tmp_dir"); + $this->upload($upload_dir); + } + public function pluploadAction() { $this->view->headScript()->appendFile('/js/plupload/plupload.full.min.js','text/javascript'); diff --git a/application/controllers/RecorderController.php b/application/controllers/RecorderController.php index 1f33beb93..1aafbef15 100644 --- a/application/controllers/RecorderController.php +++ b/application/controllers/RecorderController.php @@ -7,6 +7,7 @@ class RecorderController extends Zend_Controller_Action { $ajaxContext = $this->_helper->getHelper('contextSwitch'); $ajaxContext->addActionContext('get-show-schedule', 'json') + ->addActionContext('get-uploaded-file', 'json') ->initContext(); } @@ -17,15 +18,10 @@ class RecorderController extends Zend_Controller_Action public function getShowScheduleAction() { - //$from = $this->_getParam("from"); - //$to = $this->_getParam("to"); - $today_timestamp = date("Y-m-d H:i:s"); - $this->view->shows = Show::getShows($today_timestamp, null, $excludeInstance=NULL, $onlyRecord=TRUE); } - } diff --git a/application/controllers/plugins/Acl_plugin.php b/application/controllers/plugins/Acl_plugin.php index e3682ba11..a1a641ce4 100644 --- a/application/controllers/plugins/Acl_plugin.php +++ b/application/controllers/plugins/Acl_plugin.php @@ -110,7 +110,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract { $controller = strtolower($request->getControllerName()); - if ($controller == 'api' || $controller == 'recorder'){ + if ($controller == 'api' || $controller == 'recorder' || $controller == 'plupload' && $request->getActionName() == 'upload-recorded'){ $this->setRoleName("G"); } @@ -143,8 +143,9 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $this->setRoleName($userInfo->type); + Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl); Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName); - + $resourceName = ''; if ($request->getModuleName() != 'default') { diff --git a/python_apps/eggs/poster-0.8.0-py2.6.egg b/python_apps/eggs/poster-0.8.0-py2.6.egg new file mode 100644 index 000000000..7af5c8f5e Binary files /dev/null and b/python_apps/eggs/poster-0.8.0-py2.6.egg differ diff --git a/python_apps/show-recorder/config.cfg b/python_apps/show-recorder/config.cfg index 86cf8d194..274d9d786 100644 --- a/python_apps/show-recorder/config.cfg +++ b/python_apps/show-recorder/config.cfg @@ -1,8 +1,9 @@ # Hostname base_url = 'http://campcaster.dev/' -# URL to get the version number of the server API show_schedule_url = 'Recorder/get-show-schedule/format/json' +upload_file_url = 'Plupload/upload-recorded/format/json' + # base path to store recordered shows at base_recorded_files = '/home/naomi/Music/' diff --git a/python_apps/show-recorder/testrecordscript.py b/python_apps/show-recorder/testrecordscript.py index 43bed928a..0a387c5a2 100644 --- a/python_apps/show-recorder/testrecordscript.py +++ b/python_apps/show-recorder/testrecordscript.py @@ -107,12 +107,37 @@ def get_shows(): process_shows(shows) check_record() +def upload_file(): + + from poster.encode import multipart_encode + from poster.streaminghttp import register_openers + import urllib2 + + # Register the streaming http handlers with urllib2 + register_openers() + + # Start the multipart/form-data encoding of the file "DSC0001.jpg" + # "image1" is the name of the parameter, which is normally set + # via the "name" parameter of the HTML tag. + + # headers contains the necessary Content-Type and Content-Length + # datagen is a generator object that yields the encoded parameters + datagen, headers = multipart_encode({"file": open("/home/naomi/Music/testoutput.mp3", "rb"), 'name': 'crazy.mp3'}) + + url = config["base_url"] + config["upload_file_url"] + + req = urllib2.Request(url, datagen, headers) + response = urllib2.urlopen(req).read().strip() + print response + if __name__ == '__main__': - while True: - get_shows() - time.sleep(30) + # while True: + # get_shows() + # time.sleep(30) + + upload_file()