0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(Fa';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("").append(M.responseText.replace(/
+ {/literal}
+
+ {*
+ {UIBROWSER->fileForm id=$editItem.id folderId=$editItem.folderId assign="dynform"}
+ {include file="sub/dynForm_plain.tpl}
+ {assign var="_uploadform" value=null}
+ *}
{/if}
@@ -26,8 +92,11 @@
{include file="file/metadataform.tpl"}
{/if}
+
+
{if $editItem.type == 'webstream'}
+
{UIBROWSER->webstreamForm id=$editItem.id folderId=$editItem.folderId assign="dynform"}
{include file="sub/dynForm_plain.tpl}
@@ -39,9 +108,10 @@
{/if}
- {if $editItem.type == 'playlist'}
+ {if $editItem.type == 'playlist'}
{include file="file/metadataform.tpl"}
{/if}
+
diff --git a/src/modules/htmlUI/var/templates/header.tpl b/src/modules/htmlUI/var/templates/header.tpl
index 65297a518..1b70316c2 100644
--- a/src/modules/htmlUI/var/templates/header.tpl
+++ b/src/modules/htmlUI/var/templates/header.tpl
@@ -8,11 +8,18 @@
{* *}
+
+
+
+
+
+
{include file="script/basics.js.tpl"}
{include file="script/contextmenu.js.tpl"}
{include file="script/collector.js.tpl"}
{include file="script/alttext.js.tpl"}
+
diff --git a/src/modules/htmlUI/var/ui_handler.class.php b/src/modules/htmlUI/var/ui_handler.class.php
index 006dbd926..092d57915 100644
--- a/src/modules/htmlUI/var/ui_handler.class.php
+++ b/src/modules/htmlUI/var/ui_handler.class.php
@@ -19,658 +19,813 @@ class uiHandler extends uiBase {
*/
public $redirUrl;
- /**
- * Initialize a new Browser Class
- * Call uiBase constructor
- *
- */
- public function __construct()
- {
- parent::__construct();
- } // constructor
+ /**
+ * Initialize a new Browser Class
+ * Call uiBase constructor
+ *
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ } // constructor
- // --- authentication ---
- /**
- * Login to the storageServer.
- * It set sessid to the cookie with name defined in ../conf.php
- *
- * @param array $formdata
- * The REQUEST array.
- */
- function login($formdata, $mask)
- {
- global $CC_CONFIG;
- //$this->_cleanArray($_SESSION);
+ // --- authentication ---
+ /**
+ * Login to the storageServer.
+ * It set sessid to the cookie with name defined in ../conf.php
+ *
+ * @param array $formdata
+ * The REQUEST array.
+ */
+ function login($formdata, $mask)
+ {
+ global $CC_CONFIG;
+ //$this->_cleanArray($_SESSION);
- if (!$this->_validateForm($formdata, $mask)) {
- $_SESSION['retransferFormData']['login'] = $formdata['login'];
- $_SESSION['retransferFormData']['langid'] = $formdata['langid'];
- $_SESSION['retransferFormData']['pass'] = "\n";
- $this->redirUrl = UI_BROWSER.'?popup[]=login';
- return FALSE;
- }
+ if (!$this->_validateForm($formdata, $mask)) {
+ $_SESSION['retransferFormData']['login'] = $formdata['login'];
+ $_SESSION['retransferFormData']['langid'] = $formdata['langid'];
+ $_SESSION['retransferFormData']['pass'] = "\n";
+ $this->redirUrl = UI_BROWSER.'?popup[]=login';
+ return FALSE;
+ }
- $sessid = Alib::Login($formdata['login'], $formdata['pass']);
+ $sessid = Alib::Login($formdata['login'], $formdata['pass']);
- if (!$sessid || PEAR::isError($sessid)){
- $this->_retMsg('Login failed.');
- $_SESSION['retransferFormData']['login'] = $formdata['login'];
- $_SESSION['retransferFormData']['langid'] = $formdata['langid'];
- $_SESSION['retransferFormData']['pass'] = "\n";
- $this->redirUrl = UI_BROWSER.'?popup[]=login';
- return FALSE;
- }
+ if (!$sessid || PEAR::isError($sessid)){
+ $this->_retMsg('Login failed.');
+ $_SESSION['retransferFormData']['login'] = $formdata['login'];
+ $_SESSION['retransferFormData']['langid'] = $formdata['langid'];
+ $_SESSION['retransferFormData']['pass'] = "\n";
+ $this->redirUrl = UI_BROWSER.'?popup[]=login';
+ return FALSE;
+ }
- #setcookie($CC_CONFIG['authCookieName'], $sessid);
- echo "";
- ob_flush();
+ #setcookie($CC_CONFIG['authCookieName'], $sessid);
+ echo "";
+ ob_flush();
- $id = M2tree::GetObjId($formdata['login'], $this->gb->storId);
+ $id = M2tree::GetObjId($formdata['login'], $this->gb->storId);
- if (PEAR::isError($id)) {
- $this->_retMsg('Access to home directory failed.');
- $_SESSION['retransferFormData']['login'] = $formdata['login'];
- $this->redirUrl = UI_BROWSER.'?popup[]=login';
- return FALSE;
- }
+ if (PEAR::isError($id)) {
+ $this->_retMsg('Access to home directory failed.');
+ $_SESSION['retransferFormData']['login'] = $formdata['login'];
+ $this->redirUrl = UI_BROWSER.'?popup[]=login';
+ return FALSE;
+ }
- $this->sessid = $sessid;
- $this->langid = $formdata['langid'];
- $this->redirUrl = UI_BROWSER.'?popup[]=_2SCHEDULER&popup[]=_close';
+ $this->sessid = $sessid;
+ $this->langid = $formdata['langid'];
+ $this->redirUrl = UI_BROWSER.'?popup[]=_2SCHEDULER&popup[]=_close';
- return TRUE;
- } // fn login
+ return TRUE;
+ } // fn login
- /**
- * Logut from storageServer, takes sessid from cookie
- *
- * @param boolean $trigger_login
- * trigger login popup after logout
- */
- function logout($trigger_login = FALSE)
- {
- global $CC_CONFIG;
- Alib::Logout($this->sessid);
- //setcookie($CC_CONFIG['authCookieName'], '');
- echo "";
- ob_clean();
- session_destroy();
+ /**
+ * Logut from storageServer, takes sessid from cookie
+ *
+ * @param boolean $trigger_login
+ * trigger login popup after logout
+ */
+ function logout($trigger_login = FALSE)
+ {
+ global $CC_CONFIG;
+ Alib::Logout($this->sessid);
+ //setcookie($CC_CONFIG['authCookieName'], '');
+ echo "";
+ ob_clean();
+ session_destroy();
- if ($trigger_login) {
- $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=login';
- } else {
- $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=_close';
- }
- } // fn logout
+ if ($trigger_login) {
+ $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=login';
+ } else {
+ $this->redirUrl = UI_BROWSER.'?popup[]=_clear_parent&popup[]=_close';
+ }
+ } // fn logout
+
+ function processFile($audio_file, $caller){
+
+ global $CC_CONFIG;
+
+ if ($this->testForAudioType($audio_file) === FALSE) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "uses an unsupported file type."}}');
+ }
+
+ $md5 = md5_file($audio_file);
+ $duplicate = StoredFile::RecallByMd5($md5);
+ if ($duplicate) {
+ $_SESSION['plupload'] = "is duplicate";
+ if (PEAR::isError($duplicate)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
+ }
+ else {
+ $duplicateName = $this->gb->getMetadataValue($duplicate->getId(), UI_MDATA_KEY_TITLE, $this->sessid);
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
+ }
+ }
+
+ $metadata = camp_get_audio_metadata($audio_file);
+
+ if (PEAR::isError($metadata)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $metadata->getMessage() + '}}');
+ }
+
+ // #2196 no id tag -> use the original filename
+ if (basename($audio_file) == $metadata['dc:title']) {
+ $metadata['dc:title'] = basename($audio_file);
+ $metadata['ls:filename'] = basename($audio_file);
+ }
+
+ // bsSetMetadataBatch doesnt like these values
+ unset($metadata['audio']);
+ unset($metadata['playtime_seconds']);
+
+ $values = array(
+ "filename" => basename($audio_file),
+ "filepath" => $audio_file,
+ "filetype" => "audioclip",
+ "mime" => $metadata["dc:format"],
+ "md5" => $md5
+ );
+ $storedFile = $this->gb->putFile(NULL, $values, $this->sessid);
+
+ if (PEAR::isError($storedFile)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $storedFile->getMessage() + '}}');
+ }
+
+ $result = $this->gb->bsSetMetadataBatch($storedFile->getId(), $metadata);
+
+ return $storedFile->getId();
+ }
+
+ function pluploadFile($data)
+ {
+ header('Content-type: text/plain; charset=UTF-8');
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Cache-Control: post-check=0, pre-check=0", false);
+ header("Pragma: no-cache");
+
+ // Settings
+ $targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
+ $cleanupTargetDir = false; // Remove old files
+ $maxFileAge = 60 * 60; // Temp file age in seconds
+
+ // 5 minutes execution time
+ @set_time_limit(5 * 60);
+
+ // Get parameters
+ $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
+ $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
+ $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
+
+ // Clean the fileName for security reasons
+ //$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
+
+ // Create target dir
+ if (!file_exists($targetDir)) {
+ @mkdir($targetDir);
+ }
+
+ // Remove old temp files
+ if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
+ while (($file = readdir($dir)) !== false) {
+ $filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
+
+ // Remove temp files if they are older than the max age
+ if (preg_match('/\\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
+ @unlink($filePath);
+ }
+
+ closedir($dir);
+ }
+ else {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
+ }
+
+ // Look for the content type header
+ if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
+ $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
+
+ if (isset($_SERVER["CONTENT_TYPE"]))
+ $contentType = $_SERVER["CONTENT_TYPE"];
+
+ if (strpos($contentType, "multipart") !== false) {
+ if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
+ // Open temp file
+ $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
+ if ($out) {
+ // Read binary input stream and append it to temp file
+ $in = fopen($_FILES['file']['tmp_name'], "rb");
+
+ if ($in) {
+ while ($buff = fread($in, 4096))
+ fwrite($out, $buff);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
+
+ fclose($out);
+ unlink($_FILES['file']['tmp_name']);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
+ } else {
+ // Open temp file
+ $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
+ if ($out) {
+ // Read binary input stream and append it to temp file
+ $in = fopen("php://input", "rb");
+
+ if ($in) {
+ while ($buff = fread($in, 4096))
+ fwrite($out, $buff);
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
+
+ fclose($out);
+ return $this->processFile($targetDir . DIRECTORY_SEPARATOR . $fileName);
+
+ } else
+ die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
+ }
+
+ // Return JSON-RPC response
+ die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
+ }
- // --- files ---
- /**
- * Provides file upload and store it to the storage
- *
- * @param array $formdata
- * submitted text and file
- */
- function uploadFile($formdata, $mask, $replace=NULL)
- {
- global $CC_CONFIG;
- if ($this->testForAudioType($formdata['mediafile']['name']) === FALSE) {
- if (UI_ERROR) {
- $this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']);
- }
- $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
- return FALSE;
- }
+ // --- files ---
+ /**
+ * Provides file upload and store it to the storage
+ *
+ * @param array $formdata
+ * submitted text and file
+ */
+ function uploadFile($formdata, $mask, $replace=NULL)
+ {
+ global $CC_CONFIG;
+ if ($this->testForAudioType($formdata['mediafile']['name']) === FALSE) {
+ if (UI_ERROR) {
+ $this->_retMsg('"$1" uses an unsupported file type.', $formdata['mediafile']['name']);
+ }
+ $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
+ return FALSE;
+ }
- $id = $formdata['id'];
- $folderId = $formdata['folderId'];
+ $id = $formdata['id'];
+ $folderId = $formdata['folderId'];
- if (Greenbox::getFileType($folderId) != 'Folder') {
- $this->_retMsg('The target is not a folder.');
- $this->redirUrl = UI_BROWSER."?act=fileList";
- return FALSE;
- }
+
- if (!$this->_validateForm($formdata, $mask)) {
- $this->redirUrl = UI_BROWSER."?act=editFile&id=".$id;
- return FALSE;
- }
+ if (Greenbox::getFileType($folderId) != 'Folder') {
+ $this->_retMsg('The target is not a folder: ' . $folderId . ' id: ' . $id);
- $md5 = md5_file($formdata['mediafile']['tmp_name']);
- $duplicate = StoredFile::RecallByMd5($md5);
- if ($duplicate) {
- if (PEAR::isError($duplicate)) {
- $this->_retMsg($duplicate->getMessage());
- $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
- return FALSE;
- } else {
- $duplicateName = $this->gb->getMetadataValue($duplicate->getId(), UI_MDATA_KEY_TITLE, $this->sessid);
- $this->_retMsg('An identical audioclip named "$1" already exists in the storage server.', $duplicateName);
- $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
- return FALSE;
- }
- }
+ $this->redirUrl = UI_BROWSER."?act=fileList";
+ return FALSE;
+ }
- $metadata = camp_get_audio_metadata($formdata['mediafile']['tmp_name']);
- if (PEAR::isError($metadata)) {
- $this->_retMsg($metadata->getMessage());
- $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
- return FALSE;
- }
- // #2196 no id tag -> use the original filename
- if (basename($formdata['mediafile']['tmp_name']) == $metadata['dc:title']) {
- $metadata['dc:title'] = $formdata['mediafile']['name'];
- $metadata['ls:filename'] = $formdata['mediafile']['name'];
- }
-
- // bsSetMetadataBatch doesnt like these values
- unset($metadata['audio']);
- unset($metadata['playtime_seconds']);
+ if (!$this->_validateForm($formdata, $mask)) {
+ $this->redirUrl = UI_BROWSER."?act=editFile&id=".$id;
+ return FALSE;
+ }
- $tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.campcaster");
- $ntmp = $CC_CONFIG['bufferDir'].'/'.$tmpgunid;
- move_uploaded_file($formdata['mediafile']['tmp_name'], $ntmp);
- chmod($ntmp, 0664);
+ $md5 = md5_file($formdata['mediafile']['tmp_name']);
+ $duplicate = StoredFile::RecallByMd5($md5);
+ if ($duplicate) {
+ if (PEAR::isError($duplicate)) {
+ $this->_retMsg($duplicate->getMessage());
+ $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
+ return FALSE;
+ } else {
+ $duplicateName = $this->gb->getMetadataValue($duplicate->getId(), UI_MDATA_KEY_TITLE, $this->sessid);
+ $this->_retMsg('An identical audioclip named "$1" already exists in the storage server.', $duplicateName);
+ $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
+ return FALSE;
+ }
+ }
- $values = array(
+ $metadata = camp_get_audio_metadata($formdata['mediafile']['tmp_name']);
+ if (PEAR::isError($metadata)) {
+ $this->_retMsg($metadata->getMessage());
+ $this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
+ return FALSE;
+ }
+ // #2196 no id tag -> use the original filename
+ if (basename($formdata['mediafile']['tmp_name']) == $metadata['dc:title']) {
+ $metadata['dc:title'] = $formdata['mediafile']['name'];
+ $metadata['ls:filename'] = $formdata['mediafile']['name'];
+ }
+
+ // bsSetMetadataBatch doesnt like these values
+ unset($metadata['audio']);
+ unset($metadata['playtime_seconds']);
+
+ $tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.campcaster");
+ $ntmp = $CC_CONFIG['bufferDir'].'/'.$tmpgunid;
+ move_uploaded_file($formdata['mediafile']['tmp_name'], $ntmp);
+ chmod($ntmp, 0664);
+
+ $values = array(
"filename" => $formdata['mediafile']['name'],
"filepath" => $ntmp,
"filetype" => "audioclip",
"mime" => $metadata["dc:format"],
"md5" => $md5
- );
- $storedFile = $this->gb->putFile($folderId, $values, $this->sessid);
- @unlink($ntmp);
+ );
+ $storedFile = $this->gb->putFile($folderId, $values, $this->sessid);
+ @unlink($ntmp);
- if (PEAR::isError($storedFile)) {
- $this->_retMsg($storedFile->getMessage());
- $this->redirUrl = UI_BROWSER."?act=editFile&id=".$id;
- return FALSE;
- }
+ if (PEAR::isError($storedFile)) {
+ $this->_retMsg($storedFile->getMessage());
+ $this->redirUrl = UI_BROWSER."?act=editFile&id=".$id;
+ return FALSE;
+ }
- $result = $this->gb->bsSetMetadataBatch($storedFile->getId(), $metadata);
+ $result = $this->gb->bsSetMetadataBatch($storedFile->getId(), $metadata);
- $this->redirUrl = UI_BROWSER."?act=addFileMData&id=".$storedFile->getId();
- $this->_retMsg('Audioclip has been uploaded successfully.');
- $this->_retMsg('Now please complete metadata about the clip.');
-
- return $storedFile->getId();
- } // fn uploadFile
+ $this->redirUrl = UI_BROWSER."?act=addFileMData&id=".$storedFile->getId();
+ $this->_retMsg('Audioclip has been uploaded successfully.');
+ $this->_retMsg('Now please complete metadata about the clip.');
+
+ return $storedFile->getId();
+ } // fn uploadFile
- function testForAudioType($filename)
- {
- global $CC_CONFIG;
- foreach ($CC_CONFIG['file_types'] as $t) {
- if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename)) {
- return TRUE;
- }
- }
- return FALSE;
- }
+ function testForAudioType($filename)
+ {
+ global $CC_CONFIG;
+ foreach ($CC_CONFIG['file_types'] as $t) {
+ if (preg_match('/'.str_replace('/', '\/', $t).'$/i', $filename)) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
- /**
- * @param unknown_type $id
- * @param unknown_type $langid
- * @return void
- */
- function translateMetadata($id, $langid=UI_DEFAULT_LANGID)
- {
- include(dirname(__FILE__).'/formmask/metadata.inc.php');
+ /**
+ * @param unknown_type $id
+ * @param unknown_type $langid
+ * @return void
+ */
+ function translateMetadata($id, $langid=UI_DEFAULT_LANGID)
+ {
+ include(dirname(__FILE__).'/formmask/metadata.inc.php');
- $ia = $this->gb->analyzeFile($id, $this->sessid);
- if (PEAR::isError($ia)) {
- $this->_retMsg($ia->getMessage());
- return;
- }
- // This is really confusing: the import script does not do it
- // this way. Which way is the right way?
- $this->setMetadataValue($id, UI_MDATA_KEY_DURATION, Playlist::secondsToPlaylistTime($ia['playtime_seconds']));
-// $this->setMetadataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
+ $ia = $this->gb->analyzeFile($id, $this->sessid);
+ if (PEAR::isError($ia)) {
+ $this->_retMsg($ia->getMessage());
+ return;
+ }
+ // This is really confusing: the import script does not do it
+ // this way. Which way is the right way?
+ $this->setMetadataValue($id, UI_MDATA_KEY_DURATION, Playlist::secondsToPlaylistTime($ia['playtime_seconds']));
+ // $this->setMetadataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
- // some data from raw audio
-// if (isset($ia['audio']['channels'])) {
-// $this->setMetadataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
-// }
-// if (isset($ia['audio']['sample_rate'])) {
-// $this->setMetadataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
-// }
-// if (isset($ia['audio']['bitrate'])) {
-// $this->setMetadataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
-// }
-// if (isset($ia['audio']['codec'])) {
-// $this->setMetadataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
-// }
+ // some data from raw audio
+ // if (isset($ia['audio']['channels'])) {
+ // $this->setMetadataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
+ // }
+ // if (isset($ia['audio']['sample_rate'])) {
+ // $this->setMetadataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
+ // }
+ // if (isset($ia['audio']['bitrate'])) {
+ // $this->setMetadataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
+ // }
+ // if (isset($ia['audio']['codec'])) {
+ // $this->setMetadataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
+ // }
- // from id3 Tags
- // loop main, music, talk
- foreach ($mask['pages'] as $key => $val) {
- // loop through elements
- foreach ($mask['pages'][$key] as $k => $v) {
- if (isset($v['element']) && isset($ia[$v['element']])) {
- $this->setMetadataValue($id, $v['element'], $ia[$v['element']], $langid);
- }
- }
- }
- }
+ // from id3 Tags
+ // loop main, music, talk
+ foreach ($mask['pages'] as $key => $val) {
+ // loop through elements
+ foreach ($mask['pages'][$key] as $k => $v) {
+ if (isset($v['element']) && isset($ia[$v['element']])) {
+ $this->setMetadataValue($id, $v['element'], $ia[$v['element']], $langid);
+ }
+ }
+ }
+ }
- /**
- * Provides file upload and store it to the storage
- *
- * @param array $formdata, submitted text and file
- * @param unknown $mask
- */
- function addWebstream($formdata, $mask)
- {
- $id = $formdata['id'];
- $folderId = $formdata['folderId'];
+ /**
+ * Provides file upload and store it to the storage
+ *
+ * @param array $formdata, submitted text and file
+ * @param unknown $mask
+ */
+ function addWebstream($formdata, $mask)
+ {
+ $id = $formdata['id'];
+ $folderId = $formdata['folderId'];
- if (Greenbox::getFileType($folderId) != 'Folder') {
- $this->_retMsg ('The target is not a folder.');
- $this->redirUrl = UI_BROWSER."?act=fileList";
- return FALSE;
- }
- if (!$this->_validateForm($formdata, $mask)) {
- $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
- return FALSE;
- }
+ if (Greenbox::getFileType($folderId) != 'Folder') {
+ $this->_retMsg ('The target is not a folder.');
+ $this->redirUrl = UI_BROWSER."?act=fileList";
+ return FALSE;
+ }
+ if (!$this->_validateForm($formdata, $mask)) {
+ $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
+ return FALSE;
+ }
- $r = $this->gb->storeWebstream($folderId, $formdata['title'], NULL, $this->sessid, NULL, $formdata['url']);
+ $r = $this->gb->storeWebstream($folderId, $formdata['title'], NULL, $this->sessid, NULL, $formdata['url']);
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
- return FALSE;
- }
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
+ return FALSE;
+ }
- $extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000';
+ $extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000';
- $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['title']);
- $this->setMetadataValue($r, UI_MDATA_KEY_DURATION, $extent);
- $this->setMetadataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM);
+ $this->setMetadataValue($r, UI_MDATA_KEY_TITLE, $formdata['title']);
+ $this->setMetadataValue($r, UI_MDATA_KEY_DURATION, $extent);
+ $this->setMetadataValue($r, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_STREAM);
- $this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r";
- $this->_retMsg('Webstream data has been saved.');
- $this->_retMsg('Now please complete metadata about the clip.');
+ $this->redirUrl = UI_BROWSER."?act=addWebstreamMData&id=$r";
+ $this->_retMsg('Webstream data has been saved.');
+ $this->_retMsg('Now please complete metadata about the clip.');
- return $r;
- } // fn addWebstream
+ return $r;
+ } // fn addWebstream
- function editWebstream($formdata, $mask)
- {
- $id = $formdata['id'];
- if (!$this->_validateForm($formdata, $mask)) {
- $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
- return FALSE;
- }
- $extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000';
+ function editWebstream($formdata, $mask)
+ {
+ $id = $formdata['id'];
+ if (!$this->_validateForm($formdata, $mask)) {
+ $this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
+ return FALSE;
+ }
+ $extent = sprintf('%02d', $formdata['length']['H']).':'.sprintf('%02d', $formdata['length']['i']).':'.sprintf('%02d', $formdata['length']['s']).'.000000';
- $this->setMetadataValue($id, UI_MDATA_KEY_TITLE, $formdata['title']);
- $this->setMetadataValue($id, UI_MDATA_KEY_URL, $formdata['url']);
- $this->setMetadataValue($id, UI_MDATA_KEY_DURATION, $extent);
+ $this->setMetadataValue($id, UI_MDATA_KEY_TITLE, $formdata['title']);
+ $this->setMetadataValue($id, UI_MDATA_KEY_URL, $formdata['url']);
+ $this->setMetadataValue($id, UI_MDATA_KEY_DURATION, $extent);
- $this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id'];
- $this->_retMsg('Webstream metadata has been updated.');
+ $this->redirUrl = UI_BROWSER.'?act=editItem&id='.$formdata['id'];
+ $this->_retMsg('Webstream metadata has been updated.');
- return TRUE;
- } // fn editWebstream
+ return TRUE;
+ } // fn editWebstream
- /**
- * Sava Meatadata from form.
- *
- * @param array $formdata
- */
- function editMetaData($formdata)
- {
- include(dirname(__FILE__).'/formmask/metadata.inc.php');
- $id = $formdata['id'];
- $curr_langid = $formdata['curr_langid'];
- $this->redirUrl = UI_BROWSER."?act=editItem&id=$id&curr_langid=".$formdata['target_langid'];
+ /**
+ * Sava Meatadata from form.
+ *
+ * @param array $formdata
+ */
+ function editMetaData($formdata)
+ {
+ include(dirname(__FILE__).'/formmask/metadata.inc.php');
+ $id = $formdata['id'];
+ $curr_langid = $formdata['curr_langid'];
+ $this->redirUrl = UI_BROWSER."?act=editItem&id=$id&curr_langid=".$formdata['target_langid'];
- foreach ($mask['pages'] as $key => $val) {
- foreach ($mask['pages'][$key] as $k => $v) {
- $formdata[$key.'___'.uiBase::formElementEncode($v['element'])] ? $mData[uiBase::formElementDecode($v['element'])] = $formdata[$key.'___'.uiBase::formElementEncode($v['element'])] : NULL;
- }
- }
+ foreach ($mask['pages'] as $key => $val) {
+ foreach ($mask['pages'][$key] as $k => $v) {
+ $formdata[$key.'___'.uiBase::formElementEncode($v['element'])] ? $mData[uiBase::formElementDecode($v['element'])] = $formdata[$key.'___'.uiBase::formElementEncode($v['element'])] : NULL;
+ }
+ }
- if (!count($mData)) {
- return;
- }
+ if (!count($mData)) {
+ return;
+ }
- foreach ($mData as $key => $val) {
- $r = $this->setMetadataValue($id, $key, $val, $curr_langid);
- if (PEAR::isError($r)) {
- $this->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
- }
- }
+ foreach ($mData as $key => $val) {
+ $r = $this->setMetadataValue($id, $key, $val, $curr_langid);
+ if (PEAR::isError($r)) {
+ $this->_retMsg('Unable to set "$1" to value "$2".', $key, $val);
+ }
+ }
- $this->_retMsg('Audioclip metadata has been updated.');
- } // fn editMetadata
+ $this->_retMsg('Audioclip metadata has been updated.');
+ } // fn editMetadata
- /**
- * Create new folder in the storage
- *
- * @param string $name
- * name for the new folder
- * @param int $id
- * local id to create folder in
- */
- function newFolder($name, $id)
- {
- $r = $this->gb->createFolder($id, $name, $this->sessid);
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- }
- $this->redirUrl = UI_BROWSER.'?act=fileList&id='.$this->id;
- } // fn newFolder
+ /**
+ * Create new folder in the storage
+ *
+ * @param string $name
+ * name for the new folder
+ * @param int $id
+ * local id to create folder in
+ */
+ function newFolder($name, $id)
+ {
+ $r = $this->gb->createFolder($id, $name, $this->sessid);
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ }
+ $this->redirUrl = UI_BROWSER.'?act=fileList&id='.$this->id;
+ } // fn newFolder
- /**
- * Change the name of file or folder
- *
- * @param string $newname
- * new name for the file or folder
- * @param int $id
- * destination folder id
- */
- function rename($newname, $id)
- {
- $r = $this->gb->renameFile($id, $newname, $this->sessid);
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- }
- $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
- } // fn rename
+ /**
+ * Change the name of file or folder
+ *
+ * @param string $newname
+ * new name for the file or folder
+ * @param int $id
+ * destination folder id
+ */
+ function rename($newname, $id)
+ {
+ $r = $this->gb->renameFile($id, $newname, $this->sessid);
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ }
+ $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
+ } // fn rename
- /**
- * Move file to another folder
- *
- * @todo format of destination path should be properly defined
- *
- * @param string $newPath
- * destination relative path
- * @param int $id
- * destination folder id
- */
- function move($newPath, $id)
- {
- $newPath = urldecode($newPath);
- $did = $this->gb->getObjIdFromRelPath($id, $newPath);
- $r = $this->gb->moveFile($id, $did, $this->sessid);
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
- } else {
- $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
- }
- } // fn move
+ /**
+ * Move file to another folder
+ *
+ * @todo format of destination path should be properly defined
+ *
+ * @param string $newPath
+ * destination relative path
+ * @param int $id
+ * destination folder id
+ */
+ function move($newPath, $id)
+ {
+ $newPath = urldecode($newPath);
+ $did = $this->gb->getObjIdFromRelPath($id, $newPath);
+ $r = $this->gb->moveFile($id, $did, $this->sessid);
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
+ } else {
+ $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
+ }
+ } // fn move
- /**
- * Copy file to another folder
- *
- * @todo format of destinantion path should be properly defined
- *
- * @param string $newPath
- * destination relative path
- * @param int $id
- * destination folder id
- */
- function copy($newPath, $id)
- {
- $newPath = urldecode($newPath);
- $did = $this->gb->getObjIdFromRelPath($id, $newPath);
- $r = $this->gb->copyFile($id, $did, $this->sessid);
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
- } else {
- $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
- }
- } // fn copy
+ /**
+ * Copy file to another folder
+ *
+ * @todo format of destinantion path should be properly defined
+ *
+ * @param string $newPath
+ * destination relative path
+ * @param int $id
+ * destination folder id
+ */
+ function copy($newPath, $id)
+ {
+ $newPath = urldecode($newPath);
+ $did = $this->gb->getObjIdFromRelPath($id, $newPath);
+ $r = $this->gb->copyFile($id, $did, $this->sessid);
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ $this->redirUrl = UI_BROWSER."?act=fileList&id=".$this->pid;
+ } else {
+ $this->redirUrl = UI_BROWSER."?act=fileList&id=".$did;
+ }
+ } // fn copy
- /**
- * Delete a stored file.
- *
- * @param mixed $id
- * either an int or an array of ints which are
- * IDs of files or folders to delete.
- * @param boolean $delOverride
- * this parameter is not used
- * @return boolean
- */
- function delete($id, $delOverride=FALSE)
- {
- $this->redirUrl = UI_BROWSER."?popup[]=_reload_parent&popup[]=_close";
+ /**
+ * Delete a stored file.
+ *
+ * @param mixed $id
+ * either an int or an array of ints which are
+ * IDs of files or folders to delete.
+ * @param boolean $delOverride
+ * this parameter is not used
+ * @return boolean
+ */
+ function delete($id, $delOverride=FALSE)
+ {
+ $this->redirUrl = UI_BROWSER."?popup[]=_reload_parent&popup[]=_close";
- if (is_array($id)) {
- $ids = $id;
- } else {
- $ids[] = $id;
- }
+ if (is_array($id)) {
+ $ids = $id;
+ } else {
+ $ids[] = $id;
+ }
- foreach ($ids as $id) {
- if (Greenbox::getFileType($id) == 'playlist') {
- $r = $this->gb->deletePlaylist($id, $this->sessid);
- } else {
- $r = $this->gb->deleteFile($id, $this->sessid);
- }
+ foreach ($ids as $id) {
+ if (Greenbox::getFileType($id) == 'playlist') {
+ $r = $this->gb->deletePlaylist($id, $this->sessid);
+ } else {
+ $r = $this->gb->deleteFile($id, $this->sessid);
+ }
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- return FALSE;
- }
- }
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ return FALSE;
+ }
+ }
- return TRUE;
- } // fn delete
+ return TRUE;
+ } // fn delete
- /**
- * Call access method and show access path.
- * Example only - not really useable.
- * @todo resource should be released by release method call
- *
- * @param int $id
- * local id of accessed file
- */
- function getFile($id)
- {
- $r = $this->gb->access($id, $this->sessid);
- if (PEAR::isError($r)) {
- $this->_retMsg($r->getMessage());
- } else {
- echo $r;
- }
- } // fn getFile
+ /**
+ * Call access method and show access path.
+ * Example only - not really useable.
+ * @todo resource should be released by release method call
+ *
+ * @param int $id
+ * local id of accessed file
+ */
+ function getFile($id)
+ {
+ $r = $this->gb->access($id, $this->sessid);
+ if (PEAR::isError($r)) {
+ $this->_retMsg($r->getMessage());
+ } else {
+ echo $r;
+ }
+ } // fn getFile
- /**
- * Show file's metadata as XML
- *
- * @param int $id
- * local id of stored file
- */
- function getMdata($id)
- {
- header("Content-type: text/xml");
- $r = $this->gb->getMetadata($id, $this->sessid);
- print_r($r);
- }
+ /**
+ * Show file's metadata as XML
+ *
+ * @param int $id
+ * local id of stored file
+ */
+ function getMdata($id)
+ {
+ header("Content-type: text/xml");
+ $r = $this->gb->getMetadata($id, $this->sessid);
+ print_r($r);
+ }
- // --- perms ---
- /**
- * Add new permission record
- *
- * @param int $subj
- * local user/group id
- * @param string $permAction
- * type of action from set predefined in conf.php
- * @param int $id
- * local id of file/object
- * @param char $allowDeny
- * 'A' or 'D'
- * @return boolean
- */
- function addPerm($subj, $permAction, $id, $allowDeny)
- {
- if (PEAR::isError(
- $this->gb->addPerm(
- $subj, $permAction, $id, $allowDeny, $this->sessid
- )
- )) {
- $this->_retMsg('Access denied.');
- return FALSE;
- }
- $this->redirUrl = UI_BROWSER.'?act=permissions&id='.$id;
- return TRUE;
- } // fn addPerm
+ // --- perms ---
+ /**
+ * Add new permission record
+ *
+ * @param int $subj
+ * local user/group id
+ * @param string $permAction
+ * type of action from set predefined in conf.php
+ * @param int $id
+ * local id of file/object
+ * @param char $allowDeny
+ * 'A' or 'D'
+ * @return boolean
+ */
+ function addPerm($subj, $permAction, $id, $allowDeny)
+ {
+ if (PEAR::isError(
+ $this->gb->addPerm(
+ $subj, $permAction, $id, $allowDeny, $this->sessid
+ )
+ )) {
+ $this->_retMsg('Access denied.');
+ return FALSE;
+ }
+ $this->redirUrl = UI_BROWSER.'?act=permissions&id='.$id;
+ return TRUE;
+ } // fn addPerm
- /**
- * Remove permission record
- *
- * @param int $permid
- * local id of permission record
- * @param int $oid
- * local id of object to handle
- */
- function removePerm($permid, $oid)
- {
- if (PEAR::isError($this->gb->removePerm($permid, NULL, NULL, $this->sessid))) {
- $this->_retMsg('Access denied.');
- return FALSE;
- }
- $this->redirUrl = UI_BROWSER.'?act=permissions&id='.$oid;
- return TRUE;
- } // fn removePerm
+ /**
+ * Remove permission record
+ *
+ * @param int $permid
+ * local id of permission record
+ * @param int $oid
+ * local id of object to handle
+ */
+ function removePerm($permid, $oid)
+ {
+ if (PEAR::isError($this->gb->removePerm($permid, NULL, NULL, $this->sessid))) {
+ $this->_retMsg('Access denied.');
+ return FALSE;
+ }
+ $this->redirUrl = UI_BROWSER.'?act=permissions&id='.$oid;
+ return TRUE;
+ } // fn removePerm
- /**
- * @param unknown_type $formdata
- * @param array $mask
- * @return boolean
- */
- function _validateForm($formdata, $mask)
- {
- $form = new HTML_QuickForm('validation', UI_STANDARD_FORM_METHOD, UI_HANDLER);
- uiBase::parseArrayToForm($form, $mask, 'server');
- if (!$form->validate()) {
- $_SESSION['retransferFormData'] = $_REQUEST;
- return FALSE;
- }
- // test for uploaded files bacause HTMLQuickForm::validate() ignores them
- if (is_array($form->_submitFiles)) {
- $was_error = FALSE;
- foreach ($form->_submitFiles as $key => $val) {
- if ($val['error']) {
+ /**
+ * @param unknown_type $formdata
+ * @param array $mask
+ * @return boolean
+ */
+ function _validateForm($formdata, $mask)
+ {
+ $form = new HTML_QuickForm('validation', UI_STANDARD_FORM_METHOD, UI_HANDLER);
+ uiBase::parseArrayToForm($form, $mask, 'server');
+ if (!$form->validate()) {
+ $_SESSION['retransferFormData'] = $_REQUEST;
+ return FALSE;
+ }
+ // test for uploaded files bacause HTMLQuickForm::validate() ignores them
+ if (is_array($form->_submitFiles)) {
+ $was_error = FALSE;
+ foreach ($form->_submitFiles as $key => $val) {
+ if ($val['error']) {
- switch ($val['error']) {
- case 1:
- $was_error = TRUE;
- $this->_retMsg('The uploaded filer is bigger than allowed in system settings. See "Help", chapter "Troubleshooting" for more information.');
- break;
- case 2:
- $was_error = TRUE;
- $this->_retMsg('The uploaded filer is bigger than allowed in system settings. See "Help", chapter "Troubleshooting" for more information.');
- break;
- case 3:
- $was_error = TRUE;
- $this->_retMsg('Upload of file "$1" was incomplete.', $mask[$key]['label']);
- break;
- case 4:
- if ($mask[$key]['required']) {
- $was_error = TRUE;
- $this->_retMsg('File "$1" has not been uploaded.', $mask[$key]['label']);
- }
- break;
- }
- }
- }
- if ($was_error) {
- $_SESSION['retransferFormData'] = array_merge($_REQUEST, $_FILES);
- #$this->_retMsg('Invalid or incomplete form data.');
- return FALSE;
- }
- }
- /*
- foreach($mask as $k) {
- if ($k['type']=='file' && $k['required']==TRUE) {
- if ($_FILES[$k['element']]['error']) {
- $_SESSION['retransferFormData'] = array_merge($_REQUEST, $_FILES);
- return FALSE;
- }
- }
- } */
- return TRUE;
- } // fn _validateForm
+ switch ($val['error']) {
+ case 1:
+ $was_error = TRUE;
+ $this->_retMsg('The uploaded filer is bigger than allowed in system settings. See "Help", chapter "Troubleshooting" for more information.');
+ break;
+ case 2:
+ $was_error = TRUE;
+ $this->_retMsg('The uploaded filer is bigger than allowed in system settings. See "Help", chapter "Troubleshooting" for more information.');
+ break;
+ case 3:
+ $was_error = TRUE;
+ $this->_retMsg('Upload of file "$1" was incomplete.', $mask[$key]['label']);
+ break;
+ case 4:
+ if ($mask[$key]['required']) {
+ $was_error = TRUE;
+ $this->_retMsg('File "$1" has not been uploaded.', $mask[$key]['label']);
+ }
+ break;
+ }
+ }
+ }
+ if ($was_error) {
+ $_SESSION['retransferFormData'] = array_merge($_REQUEST, $_FILES);
+ #$this->_retMsg('Invalid or incomplete form data.');
+ return FALSE;
+ }
+ }
+ /*
+ foreach($mask as $k) {
+ if ($k['type']=='file' && $k['required']==TRUE) {
+ if ($_FILES[$k['element']]['error']) {
+ $_SESSION['retransferFormData'] = array_merge($_REQUEST, $_FILES);
+ return FALSE;
+ }
+ }
+ } */
+ return TRUE;
+ } // fn _validateForm
- /**
- * @param array $formdata
- * @param array $mask
- * @return boolean
- */
- function changeStationPrefs($formdata, $mask)
- {
- $this->redirUrl = UI_BROWSER;
+ /**
+ * @param array $formdata
+ * @param array $mask
+ * @return boolean
+ */
+ function changeStationPrefs($formdata, $mask)
+ {
+ $this->redirUrl = UI_BROWSER;
- if ($this->_validateForm($formdata, $mask) == FALSE) {
- $this->_retMsg('Error while saving settings.');
- return FALSE;
- }
- foreach ($mask as $key => $val) {
- if (isset($val['isPref']) && $val['isPref']) {
- if (!empty($formdata[$val['element']])) {
- $result = $this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]);
- if (PEAR::isError($result))
- $this->_retMsg('Error while saving settings.');
- } else {
- $this->gb->delGroupPref($this->sessid, 'StationPrefs', $val['element']);
- }
- }
- if (isset($val['type'])
- && ($val['type'] == 'file')
- && ($val['element'] == "stationlogo")
- && !empty($formdata[$val['element']]['name'])) {
- $stationLogoPath = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', 'stationLogoPath');
- $filePath = $formdata[$val['element']]['tmp_name'];
- if (function_exists("getimagesize")) {
- $size = @getimagesize($filePath);
- if ($size === FALSE) {
- $this->_retMsg('Error while uploading logo: not an supported image format.');
- return FALSE;
- }
- if ( ($size[0] > 128) || ($size[1] > 128) ) {
- $this->_retMsg('Error uploading logo: the logo can be no larger than 128x128.');
- return FALSE;
- }
- }
- $success = @move_uploaded_file($filePath, $stationLogoPath);
- if (!$success) {
- $this->_retMsg('Error while uploading logo: could not move the file to the destination directory.');
- return FALSE;
- }
- }
- }
- $this->loadStationPrefs($mask, TRUE);
- if (UI_VERBOSE) {
- $this->_retMsg('Settings saved.');
- }
+ if ($this->_validateForm($formdata, $mask) == FALSE) {
+ $this->_retMsg('Error while saving settings.');
+ return FALSE;
+ }
+ foreach ($mask as $key => $val) {
+ if (isset($val['isPref']) && $val['isPref']) {
+ if (!empty($formdata[$val['element']])) {
+ $result = $this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]);
+ if (PEAR::isError($result))
+ $this->_retMsg('Error while saving settings.');
+ } else {
+ $this->gb->delGroupPref($this->sessid, 'StationPrefs', $val['element']);
+ }
+ }
+ if (isset($val['type'])
+ && ($val['type'] == 'file')
+ && ($val['element'] == "stationlogo")
+ && !empty($formdata[$val['element']]['name'])) {
+ $stationLogoPath = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', 'stationLogoPath');
+ $filePath = $formdata[$val['element']]['tmp_name'];
+ if (function_exists("getimagesize")) {
+ $size = @getimagesize($filePath);
+ if ($size === FALSE) {
+ $this->_retMsg('Error while uploading logo: not an supported image format.');
+ return FALSE;
+ }
+ if ( ($size[0] > 128) || ($size[1] > 128) ) {
+ $this->_retMsg('Error uploading logo: the logo can be no larger than 128x128.');
+ return FALSE;
+ }
+ }
+ $success = @move_uploaded_file($filePath, $stationLogoPath);
+ if (!$success) {
+ $this->_retMsg('Error while uploading logo: could not move the file to the destination directory.');
+ return FALSE;
+ }
+ }
+ }
+ $this->loadStationPrefs($mask, TRUE);
+ if (UI_VERBOSE) {
+ $this->_retMsg('Settings saved.');
+ }
- return TRUE;
- } // fn changeStationPrefs
+ return TRUE;
+ } // fn changeStationPrefs
} // class uiHandler
?>