diff --git a/application/models/AccessRecur.php b/application/models/AccessRecur.php
index 6e0fd7931..ae78c8807 100644
--- a/application/models/AccessRecur.php
+++ b/application/models/AccessRecur.php
@@ -26,22 +26,22 @@ class AccessRecur {
$ppa = new AccessRecur($ls, $sessid);
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$plRes = $r;
$r = StoredFile::RecallByGunid($plid);
if (is_null($r) || PEAR::isError($r)) {
- return $r;
+ return $r;
}
$ac = $r;
$r = $ac->md->genPhpArray();
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$pla = $r;
$r = $ppa->processPlaylist($pla, $plRes['token']);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$plRes['content'] = $r;
return $plRes;
@@ -58,14 +58,14 @@ class AccessRecur {
WHERE parent=x'{$token}'::bigint
");
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$arr = $r;
foreach ($arr as $i => $item) {
extract($item); // token2, gunid
$r = BasicStor::GetType($gunid);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$ftype = $r;
# echo "$ftype/$token2\n";
@@ -73,23 +73,23 @@ class AccessRecur {
case "audioclip":
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
# var_dump($r);
- break;
+ break;
case "playlist":
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
# var_dump($r);
- break;
+ break;
default:
}
}
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return $r;
}
@@ -103,11 +103,11 @@ class AccessRecur {
case "playlistElement":
$r = $this->processPlaylistElement($ple, $parent);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
// $res = array_merge($res, $r);
$res[] = $r;
- break;
+ break;
default:
}
}
@@ -119,7 +119,7 @@ class AccessRecur {
{
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return $r;
}
@@ -132,48 +132,48 @@ class AccessRecur {
case "audioClip":
$r = $this->processAudioClip($ac['attrs']['id'], $parent);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return $r;
case "playlist":
-// if(empty($ac['children'])){
- $r = $this->accessPlaylist($this->ls, $this->sessid,
- $ac['attrs']['id'], $parent);
- if (PEAR::isError($r)) {
- if ($r->getCode() != GBERR_NOTF) {
- return $r;
- } else {
- $r = $this->processPlaylist($ac, $parent);
- if (PEAR::isError($r)) {
- return $r;
- }
- $r = array(
+ // if(empty($ac['children'])){
+ $r = $this->accessPlaylist($this->ls, $this->sessid,
+ $ac['attrs']['id'], $parent);
+ if (PEAR::isError($r)) {
+ if ($r->getCode() != GBERR_NOTF) {
+ return $r;
+ } else {
+ $r = $this->processPlaylist($ac, $parent);
+ if (PEAR::isError($r)) {
+ return $r;
+ }
+ $r = array(
'content' => $r,
'url' => NULL,
'token' => NULL,
'chsum' => NULL,
'size' => NULL,
'warning' => 'inline playlist?',
- );
- }
+ );
}
- return $r;
-/*
- }else{
- $r = $this->processPlaylist($ac, $parent);
- if(PEAR::isError($r)) return $r;
- $res = array(
- 'content' => $r,
- 'url' => NULL,
- 'token' => NULL,
- 'chsum' => NULL,
- 'size' => NULL,
- 'warning' => 'inline playlist',
- );
- return $res;
}
-*/
- break;
+ return $r;
+ /*
+ }else{
+ $r = $this->processPlaylist($ac, $parent);
+ if(PEAR::isError($r)) return $r;
+ $res = array(
+ 'content' => $r,
+ 'url' => NULL,
+ 'token' => NULL,
+ 'chsum' => NULL,
+ 'size' => NULL,
+ 'warning' => 'inline playlist',
+ );
+ return $res;
+ }
+ */
+ break;
default:
}
}
diff --git a/application/models/Alib.php b/application/models/Alib.php
index 8fa7c51a9..b9e16d6ca 100644
--- a/application/models/Alib.php
+++ b/application/models/Alib.php
@@ -38,7 +38,7 @@ class Alib {
}
$userid = Subjects::GetSubjId($login);
$sql = "INSERT INTO ".$CC_CONFIG['sessTable']." (sessid, userid, login, ts)"
- ." VALUES('$sessid', '$userid', '$login', now())";
+ ." VALUES('$sessid', '$userid', '$login', now())";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
@@ -60,12 +60,12 @@ class Alib {
$ct = Alib::CheckAuthToken($sessid);
if ($ct === FALSE) {
return PEAR::raiseError("Alib::logout: not logged ($sessid)",
- ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
+ ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
} elseif (PEAR::isError($ct)) {
return $ct;
} else {
$sql = "DELETE FROM ".$CC_CONFIG['sessTable']
- ." WHERE sessid='$sessid'";
+ ." WHERE sessid='$sessid'";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
@@ -85,7 +85,7 @@ class Alib {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable']
- ." WHERE sessid='$sessid'";
+ ." WHERE sessid='$sessid'";
$c = $CC_DBC->getOne($sql);
return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE ));
} //fn checkAuthToken
@@ -97,18 +97,18 @@ class Alib {
* @param string $sessid
* @return TRUE|PEAR_Error
*/
-// public function setAuthToken($sessid)
-// {
-// $r = $this->checkAuthToken($sessid);
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// if (!$r) {
-// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
-// }
-// //$this->sessid = $sessid;
-// return TRUE;
-// } // fn setAuthToken
+ // public function setAuthToken($sessid)
+ // {
+ // $r = $this->checkAuthToken($sessid);
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // if (!$r) {
+ // return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
+ // }
+ // //$this->sessid = $sessid;
+ // return TRUE;
+ // } // fn setAuthToken
/* -------------------------------------------------------- authorization */
@@ -130,7 +130,7 @@ class Alib {
global $CC_CONFIG, $CC_DBC;
$permid = $CC_DBC->nextId($CC_CONFIG['permSequence']);
$sql = "INSERT INTO ".$CC_CONFIG['permTable']." (permid, subj, action, obj, type)"
- ." VALUES ($permid, $sid, '$action', $oid, '$type')";
+ ." VALUES ($permid, $sid, '$action', $oid, '$type')";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return($r);
@@ -213,85 +213,85 @@ class Alib {
*/
public static function CheckPerm($sid, $action, $oid=NULL)
{
- return TRUE;
-// global $CC_DBC;
-// global $CC_CONFIG;
-// if (!is_numeric($sid)) {
-// return FALSE;
-// }
-//// if (is_null($oid) or $oid=='') {
-//// $oid = M2tree::GetRootNode();
-//// }
-//// if (PEAR::isError($oid)) {
-//// return $oid;
-//// }
-// if (!is_numeric($oid)) {
-// return FALSE;
-// }
-// // query construction
-// // shortcuts:
-// // p: permTable,
-// // s: subjTable, m smembTable,
-// // t: treeTable ts: structTable,
-// // c: classTable, cm: cmembTable
-// // main query elements:
-// $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
-// $q_from = $CC_CONFIG['permTable']." p ";
-// // joins for solving users/groups:
-// $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj ";
-// $q_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
-// $q_cond = "p.action in('_all', '$action') AND
-// (s.id=$sid OR m.uid=$sid) ";
-// // coalesce -1 for higher priority of nongroup rows:
-// // action DESC order for lower priority of '_all':
-// $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
-// $q_flds0 = $q_flds;
-// $q_from0 = $q_from;
-// $q_join0 = $q_join;
-// $q_cond0 = $q_cond;
-// $q_ordb0 = $q_ordb;
-// // joins for solving object tree:
-// $q_flds .= ", t.name, ts.level as tlevel";
-// //$q_join .= "LEFT JOIN ".$CC_CONFIG['treeTable']." t ON t.id=p.obj ";
-// //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=p.obj ";
-// //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
-// // action DESC order is hack for lower priority of '_all':
-// $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
-// // query by tree:
-// $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
-// $r1 = $CC_DBC->getAll($query1);
-// if (PEAR::isError($r1)) {
-// return($r1);
-// }
-// // if there is row with type='A' on the top => permit
-// //$AllowedByTree =
-// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
-// //$DeniedByTree =
-// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
-//
-// if (!USE_ALIB_CLASSES) {
-// return $AllowedbyTree;
-// }
-//
-// // joins for solving object classes:
-// $q_flds = $q_flds0.", c.cname ";
-// $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj ";
-// $q_join .= "LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON cm.cid=p.obj ";
-// $q_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
-// $q_ordb = $q_ordb0;
-// // query by class:
-// $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
-// $r2 = $CC_DBC->getAll($query2);
-// if (PEAR::isError($r2)) {
-// return $r2;
-// }
-// $AllowedByClass =
-// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
-// // not used now:
-// // $DeniedByClass =
-// // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
-// $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
-// return $res;
+ return TRUE;
+ // global $CC_DBC;
+ // global $CC_CONFIG;
+ // if (!is_numeric($sid)) {
+ // return FALSE;
+ // }
+ //// if (is_null($oid) or $oid=='') {
+ //// $oid = M2tree::GetRootNode();
+ //// }
+ //// if (PEAR::isError($oid)) {
+ //// return $oid;
+ //// }
+ // if (!is_numeric($oid)) {
+ // return FALSE;
+ // }
+ // // query construction
+ // // shortcuts:
+ // // p: permTable,
+ // // s: subjTable, m smembTable,
+ // // t: treeTable ts: structTable,
+ // // c: classTable, cm: cmembTable
+ // // main query elements:
+ // $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
+ // $q_from = $CC_CONFIG['permTable']." p ";
+ // // joins for solving users/groups:
+ // $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj ";
+ // $q_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
+ // $q_cond = "p.action in('_all', '$action') AND
+ // (s.id=$sid OR m.uid=$sid) ";
+ // // coalesce -1 for higher priority of nongroup rows:
+ // // action DESC order for lower priority of '_all':
+ // $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
+ // $q_flds0 = $q_flds;
+ // $q_from0 = $q_from;
+ // $q_join0 = $q_join;
+ // $q_cond0 = $q_cond;
+ // $q_ordb0 = $q_ordb;
+ // // joins for solving object tree:
+ // $q_flds .= ", t.name, ts.level as tlevel";
+ // //$q_join .= "LEFT JOIN ".$CC_CONFIG['treeTable']." t ON t.id=p.obj ";
+ // //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=p.obj ";
+ // //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
+ // // action DESC order is hack for lower priority of '_all':
+ // $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
+ // // query by tree:
+ // $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
+ // $r1 = $CC_DBC->getAll($query1);
+ // if (PEAR::isError($r1)) {
+ // return($r1);
+ // }
+ // // if there is row with type='A' on the top => permit
+ // //$AllowedByTree =
+ // // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
+ // //$DeniedByTree =
+ // // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
+ //
+ // if (!USE_ALIB_CLASSES) {
+ // return $AllowedbyTree;
+ // }
+ //
+ // // joins for solving object classes:
+ // $q_flds = $q_flds0.", c.cname ";
+ // $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj ";
+ // $q_join .= "LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON cm.cid=p.obj ";
+ // $q_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
+ // $q_ordb = $q_ordb0;
+ // // query by class:
+ // $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
+ // $r2 = $CC_DBC->getAll($query2);
+ // if (PEAR::isError($r2)) {
+ // return $r2;
+ // }
+ // $AllowedByClass =
+ // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
+ // // not used now:
+ // // $DeniedByClass =
+ // // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
+ // $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
+ // return $res;
} // fn CheckPerm
@@ -326,7 +326,7 @@ class Alib {
}
if (is_null($uid)){
return $CC_DBC->raiseError("Alib::removeSubj: Subj not found ($login)",
- ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
+ ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
$r = Alib::RemovePerm(NULL, $uid);
if (PEAR::isError($r)) {
@@ -354,7 +354,7 @@ class Alib {
if (is_null($r)){
return PEAR::raiseError("Alib::GetSessLogin:".
" invalid session id ($sessid)",
- ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
+ ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
return $r;
} // fn GetSessLogin
@@ -377,7 +377,7 @@ class Alib {
if (is_null($r)) {
return PEAR::raiseError("Alib::getSessUserId:".
" invalid session id ($p_sessid)",
- ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
+ ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
return $r;
} // fn getSessUserId
@@ -394,7 +394,7 @@ class Alib {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.login, p.* FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
- ." WHERE s.id=p.subj AND p.obj=$id";
+ ." WHERE s.id=p.subj AND p.obj=$id";
return $CC_DBC->getAll($sql);
} // fn GetObjPerms
@@ -409,11 +409,11 @@ class Alib {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT *"
- ." FROM ".$CC_CONFIG['permTable']
- ." WHERE p.subj=$sid";
-// $sql = "SELECT t.name, t.type as otype , p.*"
-// ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
-// ." WHERE t.id=p.obj AND p.subj=$sid";
+ ." FROM ".$CC_CONFIG['permTable']
+ ." WHERE p.subj=$sid";
+ // $sql = "SELECT t.name, t.type as otype , p.*"
+ // ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
+ // ." WHERE t.id=p.obj AND p.subj=$sid";
$a1 = $CC_DBC->getAll($sql);
return $a1;
} // fn GetSubjPerms
@@ -463,7 +463,7 @@ class Alib {
for ($c = 1; $c > 0; ){
$sessid = md5(uniqid(rand()));
$sql = "SELECT count(*) FROM ".$CC_CONFIG['sessTable']
- ." WHERE sessid='$sessid'";
+ ." WHERE sessid='$sessid'";
$c = $CC_DBC->getOne($sql);
if (PEAR::isError($c)) {
return $c;
@@ -488,19 +488,19 @@ class Alib {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.login, p.action, p.type"
- ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
- ." WHERE s.id=p.subj"
- ." ORDER BY p.permid";
+ ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
+ ." WHERE s.id=p.subj"
+ ." ORDER BY p.permid";
$arr = $CC_DBC->getAll($sql);
if (PEAR::isError($arr)) {
return $arr;
}
$r = $ind.join(', ', array_map(create_function('$v',
'return "{$v[\'login\']}/{$v[\'action\']}/{$v[\'type\']}";'
- ),
- $arr
- ))."\n";
- return $r;
+ ),
+ $arr
+ ))."\n";
+ return $r;
} // fn dumpPerms
@@ -532,16 +532,16 @@ class Alib {
$s =& $tdata['subjects'];
$CC_DBC->setErrorHandling(PEAR_ERROR_PRINT);
$perms = array(
- array($s['root'], '_all', $t['root'], 'A'),
- array($s['test1'], '_all', $t['pa'], 'A'),
- array($s['test1'], 'read', $t['s2b'], 'D'),
- array($s['test2'], 'addChilds', $t['pa'], 'D'),
- array($s['test2'], 'read', $t['i2'], 'A'),
- array($s['test2'], 'edit', $t['s1a'], 'A'),
- array($s['test1'], 'addChilds', $t['s2a'], 'D'),
- array($s['test1'], 'addChilds', $t['s2c'], 'D'),
- array($s['gr2'], 'addChilds', $t['i2'], 'A'),
- array($s['test3'], '_all', $t['t1'], 'D'),
+ array($s['root'], '_all', $t['root'], 'A'),
+ array($s['test1'], '_all', $t['pa'], 'A'),
+ array($s['test1'], 'read', $t['s2b'], 'D'),
+ array($s['test2'], 'addChilds', $t['pa'], 'D'),
+ array($s['test2'], 'read', $t['i2'], 'A'),
+ array($s['test2'], 'edit', $t['s1a'], 'A'),
+ array($s['test1'], 'addChilds', $t['s2a'], 'D'),
+ array($s['test1'], 'addChilds', $t['s2c'], 'D'),
+ array($s['gr2'], 'addChilds', $t['i2'], 'A'),
+ array($s['test3'], '_all', $t['t1'], 'D'),
);
if (USE_ALIB_CLASSES){
$perms[] = array($s['test3'], 'read', $c['cl_sa'], 'D');
@@ -587,14 +587,14 @@ class Alib {
return $r;
}
$test_dump = $r.
- (Alib::CheckPerm(
- $tdata['subjects']['test1'], 'read',
- $tdata['tree']['t1']
- )? 'yes':'no').", ".
- (Alib::CheckPerm(
- $tdata['subjects']['test1'], 'addChilds',
- $tdata['tree']['i2']
- )? 'yes':'no')."\n"
+ (Alib::CheckPerm(
+ $tdata['subjects']['test1'], 'read',
+ $tdata['tree']['t1']
+ )? 'yes':'no').", ".
+ (Alib::CheckPerm(
+ $tdata['subjects']['test1'], 'addChilds',
+ $tdata['tree']['i2']
+ )? 'yes':'no')."\n"
;
Alib::RemovePerm($tdata['perms'][1]);
Alib::RemovePerm($tdata['perms'][3]);
diff --git a/application/models/Backup.php b/application/models/Backup.php
index 211faa362..c05500264 100755
--- a/application/models/Backup.php
+++ b/application/models/Backup.php
@@ -132,7 +132,7 @@ class Backup
// get ids (and real filenames) which files match with criteria
$srch = $this->gb->localSearch($this->criteria,$this->sessid);
if (PEAR::isError($srch)) {
- return $srch;
+ return $srch;
}
$this->setIDs($srch);
@@ -167,7 +167,7 @@ class Backup
return array('token'=>$this->token);
} else {
- return false;
+ return false;
}
}
@@ -229,7 +229,7 @@ class Backup
unlink($this->statusFile);
unlink($this->tmpFile);
if (is_file($this->tmpName)) {
- unlink($this->tmpName);
+ unlink($this->tmpName);
}
return !is_file($this->tmpFile);
}
@@ -288,42 +288,42 @@ class Backup
*/
private function setFilenames()
{
-// if ($this->loglevel=='debug') {
-// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
-// }
-// if (is_array($this->ids)) {
-// foreach ($this->ids as $i => $item) {
-// $gunid = $item['gunid'];
-// // get a stored file object of this gunid
-// $sf = StoredFile::RecallByGunid($gunid);
-// if (is_null($sf) || PEAR::isError($sf)) {
-// return $sf;
-// }
-// $lid = BasicStor::IdFromGunid($gunid);
-// if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
-// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
-// return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
-// }
-// // if the file is a playlist then it has only a meta file
-// if (strtolower($sf->md->format) != 'playlist') {
-// $this->filenames[] = array(
-// 'filename' => $sf->getRealFileName(),
-// 'format' => $sf->md->format
-// );
-// }
-// $this->filenames[] = array(
-// 'filename' => $sf->getRealMetadataFileName(),
-// 'format' => $sf->md->format
-// );
-// if ($this->loglevel=='debug') {
-// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
-// }
-// }
-// return $this->filenames;
-// } else {
-// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
-// return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
-// }
+ // if ($this->loglevel=='debug') {
+ // $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
+ // }
+ // if (is_array($this->ids)) {
+ // foreach ($this->ids as $i => $item) {
+ // $gunid = $item['gunid'];
+ // // get a stored file object of this gunid
+ // $sf = StoredFile::RecallByGunid($gunid);
+ // if (is_null($sf) || PEAR::isError($sf)) {
+ // return $sf;
+ // }
+ // $lid = BasicStor::IdFromGunid($gunid);
+ // if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
+ // $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
+ // return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
+ // }
+ // // if the file is a playlist then it has only a meta file
+ // if (strtolower($sf->md->format) != 'playlist') {
+ // $this->filenames[] = array(
+ // 'filename' => $sf->getRealFileName(),
+ // 'format' => $sf->md->format
+ // );
+ // }
+ // $this->filenames[] = array(
+ // 'filename' => $sf->getRealMetadataFileName(),
+ // 'format' => $sf->md->format
+ // );
+ // if ($this->loglevel=='debug') {
+ // $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
+ // }
+ // }
+ // return $this->filenames;
+ // } else {
+ // $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
+ // return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
+ // }
}
@@ -337,10 +337,10 @@ class Backup
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n");
}
$command = dirname(__FILe__)."/../bin/backup.sh"
- ." {$this->tmpDir}"
- ." {$this->tmpFile}"
- ." {$this->statusFile}"
- ." >> {$this->logFile} &";
+ ." {$this->tmpDir}"
+ ." {$this->tmpFile}"
+ ." {$this->statusFile}"
+ ." >> {$this->logFile} &";
$res = system("$command");
sleep(2);
if ($this->loglevel=='debug') {
@@ -438,7 +438,7 @@ class Backup
{
$acc = BasicStor::bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
if (PEAR::isError($acc)) {
- return $acc;
+ return $acc;
}
$this->token = $acc['token'];
}
@@ -484,4 +484,4 @@ class Backup
}
} // classs Backup
-?>
+?>
diff --git a/application/models/BasicStor.php b/application/models/BasicStor.php
index 22cd01bbf..ed517eabd 100644
--- a/application/models/BasicStor.php
+++ b/application/models/BasicStor.php
@@ -139,11 +139,11 @@ class BasicStor {
* @return StoredFile|PEAR_Error
* The StoredFile that was created.
*/
-// public function bsPutFile($p_values, $p_copyMedia=TRUE)
-// {
-// $storedFile = StoredFile::Insert($p_values, $p_copyMedia);
-// return $storedFile;
-// }
+ // public function bsPutFile($p_values, $p_copyMedia=TRUE)
+ // {
+ // $storedFile = StoredFile::Insert($p_values, $p_copyMedia);
+ // return $storedFile;
+ // }
/**
@@ -154,28 +154,28 @@ class BasicStor {
* @param string $newName
* @return boolean|PEAR_Error
*/
-// public function bsRenameFile($id, $newName)
-// {
-// switch (BasicStor::GetObjType($id)) {
-// case "audioclip":
-// case "playlist":
-// case "webstream":
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// // catch nonerror exception:
-// //if($storedFile->getCode() != GBERR_FOBJNEX)
-// return $storedFile;
-// }
-// $res = $storedFile->setName($newName);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// break;
-// case "File":
-// default:
-// }
-// return TRUE;
-// }
+ // public function bsRenameFile($id, $newName)
+ // {
+ // switch (BasicStor::GetObjType($id)) {
+ // case "audioclip":
+ // case "playlist":
+ // case "webstream":
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // // catch nonerror exception:
+ // //if($storedFile->getCode() != GBERR_FOBJNEX)
+ // return $storedFile;
+ // }
+ // $res = $storedFile->setName($newName);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // break;
+ // case "File":
+ // default:
+ // }
+ // return TRUE;
+ // }
/**
@@ -192,27 +192,27 @@ class BasicStor {
* @return true|PEAR_Error
* @exception PEAR::error
*/
-// public function bsReplaceFile($id, $localFilePath, $metadataFilePath, $mdataLoc='file')
-// {
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// if (!empty($metadataFilePath) &&
-// ($mdataLoc!='file' || file_exists($metadataFilePath))) {
-// $r = $storedFile->setMetadata($metadataFilePath, $mdataLoc);
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// }
-// if (!empty($localFilePath) && file_exists($localFilePath)) {
-// $r = $storedFile->setRawMediaData($localFilePath);
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// }
-// return TRUE;
-// }
+ // public function bsReplaceFile($id, $localFilePath, $metadataFilePath, $mdataLoc='file')
+ // {
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // if (!empty($metadataFilePath) &&
+ // ($mdataLoc!='file' || file_exists($metadataFilePath))) {
+ // $r = $storedFile->setMetadata($metadataFilePath, $mdataLoc);
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // }
+ // if (!empty($localFilePath) && file_exists($localFilePath)) {
+ // $r = $storedFile->setRawMediaData($localFilePath);
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // }
+ // return TRUE;
+ // }
/**
@@ -224,64 +224,64 @@ class BasicStor {
* If true don't use trash
* @return true|PEAR_Error
*/
-// public function bsDeleteFile($id, $forced=FALSE)
-// {
-// global $CC_CONFIG;
-// // full delete:
-// if (!$CC_CONFIG['useTrash'] || $forced) {
-// $res = BasicStor::RemoveObj($id, $forced);
-// return $res;
-// }
-//
-// $storedFile = StoredFile::Recall($id);
-//
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// if ($storedFile->isAccessed()) {
-// return PEAR::raiseError(
-// 'Cannot delete an object that is currently accessed.'
-// );
-// }
-// // move to trash:
-// switch (BasicStor::GetObjType($id)) {
-//
-// case "audioclip":
-// $playLists = $storedFile->getPlaylists();
-// $item_gunid = $storedFile->getGunid();
-// if( $playLists != NULL) {
-//
-// foreach($playLists as $key=>$val) {
-// $playList_id = BasicStor::IdFromGunidBigInt($val["gunid"]);
-// $playList_titles[] = BasicStor::bsGetMetadataValue($playList_id, "dc:title");
-// }
-// return PEAR::raiseError(
-// 'Please remove this song from all playlists: ' . join(",", $playList_titles)
-// );
-// }
-// break;
-//
-// case "playlist":
-// if($storedFile->isScheduled()) {
-// return PEAR::raiseError(
-// 'Cannot delete an object that is scheduled to play.'
-// );
-// }
-// break;
-//
-// case "webstream":
-//
-// break;
-// default:
-// }
-//
-// $res = $storedFile->setState('deleted');
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-//
-// return TRUE;
-// }
+ // public function bsDeleteFile($id, $forced=FALSE)
+ // {
+ // global $CC_CONFIG;
+ // // full delete:
+ // if (!$CC_CONFIG['useTrash'] || $forced) {
+ // $res = BasicStor::RemoveObj($id, $forced);
+ // return $res;
+ // }
+ //
+ // $storedFile = StoredFile::Recall($id);
+ //
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // if ($storedFile->isAccessed()) {
+ // return PEAR::raiseError(
+ // 'Cannot delete an object that is currently accessed.'
+ // );
+ // }
+ // // move to trash:
+ // switch (BasicStor::GetObjType($id)) {
+ //
+ // case "audioclip":
+ // $playLists = $storedFile->getPlaylists();
+ // $item_gunid = $storedFile->getGunid();
+ // if( $playLists != NULL) {
+ //
+ // foreach($playLists as $key=>$val) {
+ // $playList_id = BasicStor::IdFromGunidBigInt($val["gunid"]);
+ // $playList_titles[] = BasicStor::bsGetMetadataValue($playList_id, "dc:title");
+ // }
+ // return PEAR::raiseError(
+ // 'Please remove this song from all playlists: ' . join(",", $playList_titles)
+ // );
+ // }
+ // break;
+ //
+ // case "playlist":
+ // if($storedFile->isScheduled()) {
+ // return PEAR::raiseError(
+ // 'Cannot delete an object that is scheduled to play.'
+ // );
+ // }
+ // break;
+ //
+ // case "webstream":
+ //
+ // break;
+ // default:
+ // }
+ //
+ // $res = $storedFile->setState('deleted');
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ //
+ // return TRUE;
+ // }
/* ----------------------------------------------------- put, access etc. */
@@ -329,7 +329,7 @@ class BasicStor {
* array with: seekable filehandle, access token
*/
public static function bsAccess($realFname, $ext, $gunid, $type='access',
- $parent='0', $owner=NULL)
+ $parent='0', $owner=NULL)
{
global $CC_CONFIG, $CC_DBC;
if (!is_null($gunid)) {
@@ -338,17 +338,17 @@ class BasicStor {
$token = StoredFile::CreateGunid();
if (!is_null($realFname)) {
$linkFname = $CC_CONFIG['accessDir']."/$token.$ext";
- //broken links are ignored by the player, do not worry about it here
-/* if (!is_file($realFname) && !is_link($realFname)) {
- return PEAR::raiseError(
- "BasicStor::bsAccess: real file not found ($realFname)",
- GBERR_FILEIO);
+ //broken links are ignored by the player, do not worry about it here
+ /* if (!is_file($realFname) && !is_link($realFname)) {
+ return PEAR::raiseError(
+ "BasicStor::bsAccess: real file not found ($realFname)",
+ GBERR_FILEIO);
}
-*/
+ */
if (! @symlink($realFname, $linkFname)) {
return PEAR::raiseError(
"BasicStor::bsAccess: symlink create failed ($linkFname)",
- GBERR_FILEIO);
+ GBERR_FILEIO);
}
} else {
$linkFname = NULL;
@@ -423,7 +423,7 @@ class BasicStor {
if(! @unlink($linkFname)){
return PEAR::raiseError(
"BasicStor::bsRelease: unlink failed ($linkFname)",
- GBERR_FILEIO);
+ GBERR_FILEIO);
}
}
$CC_DBC->query("BEGIN");
@@ -472,42 +472,42 @@ class BasicStor {
* array with strings:
* downloadable URL, download token, chsum, size, filename
*/
-// public function bsOpenDownload($id, $part='media')
-// {
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// $gunid = $storedFile->gunid;
-// switch ($part) {
-// case "media":
-// $realfile = $storedFile->getRealFileName();
-// $ext = $storedFile->getFileExtension();
-// $filename = $storedFile->getName();
-// break;
-// case "metadata":
-// $realfile = $storedFile->getRealMetadataFileName();
-// $ext = "xml";
-// $filename = $storedFile->getName();
-// break;
-// default:
-// return PEAR::raiseError(
-// "BasicStor::bsOpenDownload: unknown part ($part)"
-// );
-// }
-// $acc = BasicStor::bsAccess($realfile, $ext, $gunid, 'download');
-// if (PEAR::isError($acc)) {
-// return $acc;
-// }
-// $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
-// $chsum = md5_file($realfile);
-// $size = filesize($realfile);
-// return array(
-// 'url'=>$url, 'token'=>$acc['token'],
-// 'chsum'=>$chsum, 'size'=>$size,
-// 'filename'=>$filename
-// );
-// }
+ // public function bsOpenDownload($id, $part='media')
+ // {
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // $gunid = $storedFile->gunid;
+ // switch ($part) {
+ // case "media":
+ // $realfile = $storedFile->getRealFileName();
+ // $ext = $storedFile->getFileExtension();
+ // $filename = $storedFile->getName();
+ // break;
+ // case "metadata":
+ // $realfile = $storedFile->getRealMetadataFileName();
+ // $ext = "xml";
+ // $filename = $storedFile->getName();
+ // break;
+ // default:
+ // return PEAR::raiseError(
+ // "BasicStor::bsOpenDownload: unknown part ($part)"
+ // );
+ // }
+ // $acc = BasicStor::bsAccess($realfile, $ext, $gunid, 'download');
+ // if (PEAR::isError($acc)) {
+ // return $acc;
+ // }
+ // $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
+ // $chsum = md5_file($realfile);
+ // $size = filesize($realfile);
+ // return array(
+ // 'url'=>$url, 'token'=>$acc['token'],
+ // 'chsum'=>$chsum, 'size'=>$size,
+ // 'filename'=>$filename
+ // );
+ // }
/**
@@ -520,19 +520,19 @@ class BasicStor {
* @return string
* gunid
*/
-// public function bsCloseDownload($token, $part='media')
-// {
-// if (!BasicStor::bsCheckToken($token, 'download')) {
-// return PEAR::raiseError(
-// "BasicStor::bsCloseDownload: invalid token ($token)"
-// );
-// }
-// $r = BasicStor::bsRelease($token, 'download');
-// if (PEAR::isError($r)){
-// return $r;
-// }
-// return (is_null($r['gunid']) ? $r['realFname'] : $r['gunid']);
-// }
+ // public function bsCloseDownload($token, $part='media')
+ // {
+ // if (!BasicStor::bsCheckToken($token, 'download')) {
+ // return PEAR::raiseError(
+ // "BasicStor::bsCloseDownload: invalid token ($token)"
+ // );
+ // }
+ // $r = BasicStor::bsRelease($token, 'download');
+ // if (PEAR::isError($r)){
+ // return $r;
+ // }
+ // return (is_null($r['gunid']) ? $r['realFname'] : $r['gunid']);
+ // }
/**
@@ -551,35 +551,35 @@ class BasicStor {
* fname string: writable local filename
* token string: PUT token
*/
-// public function bsOpenPut($chsum, $gunid, $owner=NULL)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// if (!is_null($gunid)) {
-// $gunid = StoredFile::NormalizeGunid($gunid);
-// }
-// $escapedChsum = pg_escape_string($chsum);
-// $token = StoredFile::CreateGunid();
-// $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable']
-// ." WHERE token=x'$token'::bigint");
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// $gunidSql = (is_null($gunid) ? "NULL" : "x'{$gunid}'::bigint" );
-// $ownerSql = (is_null($owner) ? "NULL" : "$owner" );
-// $res = $CC_DBC->query("
-// INSERT INTO ".$CC_CONFIG['accessTable']."
-// (gunid, token, ext, chsum, type, owner, ts)
-// VALUES
-// ($gunidSql, x'$token'::bigint,
-// '', '$escapedChsum', 'put', $ownerSql, now())");
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// $fname = $CC_CONFIG['accessDir']."/$token";
-// touch($fname); // is it needed?
-// $url = BasicStor::GetUrlPart()."xmlrpc/put.php?token=$token";
-// return array('url'=>$url, 'fname'=>$fname, 'token'=>$token);
-// }
+ // public function bsOpenPut($chsum, $gunid, $owner=NULL)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // if (!is_null($gunid)) {
+ // $gunid = StoredFile::NormalizeGunid($gunid);
+ // }
+ // $escapedChsum = pg_escape_string($chsum);
+ // $token = StoredFile::CreateGunid();
+ // $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable']
+ // ." WHERE token=x'$token'::bigint");
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // $gunidSql = (is_null($gunid) ? "NULL" : "x'{$gunid}'::bigint" );
+ // $ownerSql = (is_null($owner) ? "NULL" : "$owner" );
+ // $res = $CC_DBC->query("
+ // INSERT INTO ".$CC_CONFIG['accessTable']."
+ // (gunid, token, ext, chsum, type, owner, ts)
+ // VALUES
+ // ($gunidSql, x'$token'::bigint,
+ // '', '$escapedChsum', 'put', $ownerSql, now())");
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // $fname = $CC_CONFIG['accessDir']."/$token";
+ // touch($fname); // is it needed?
+ // $url = BasicStor::GetUrlPart()."xmlrpc/put.php?token=$token";
+ // return array('url'=>$url, 'fname'=>$fname, 'token'=>$token);
+ // }
/**
@@ -593,58 +593,58 @@ class BasicStor {
* fname string, local path of the file having been put
* owner int, local subject id - owner of token
*/
-// public function bsClosePut($token)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $token = StoredFile::NormalizeGunid($token);
-//
-// if (!BasicStor::bsCheckToken($token, 'put')) {
-// return PEAR::raiseError(
-// "BasicStor::bsClosePut: invalid token ($token)",
-// GBERR_TOKEN);
-// }
-// $row = $CC_DBC->getRow(
-// "SELECT chsum, owner FROM ".$CC_CONFIG['accessTable']
-// ." WHERE token=x'{$token}'::bigint");
-// if (PEAR::isError($row)) {
-// return $row;
-// }
-// $fname = $CC_CONFIG['accessDir']."/$token";
-// $md5sum = md5_file($fname);
-//
-// $chsum = $row['chsum'];
-// $owner = $row['owner'];
-// $error = null;
-// if ( (trim($chsum) != '') && ($chsum != $md5sum) ) {
-// // Delete the file if the checksums do not match.
-// if (file_exists($fname)) {
-// @unlink($fname);
-// }
-// $error = new PEAR_Error(
-// "BasicStor::bsClosePut: md5sum does not match (token=$token)".
-// " [$chsum/$md5sum]",
-// GBERR_PUT);
-// } else {
-// // Remember the MD5 sum
-// $storedFile = StoredFile::RecallByToken($token);
-// if (!is_null($storedFile) && !PEAR::isError($storedFile)) {
-// $storedFile->setMd5($md5sum);
-// } else {
-//# $error = $storedFile;
-// }
-// }
-//
-// // Delete entry from access table.
-// $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable']
-// ." WHERE token=x'$token'::bigint");
-// if (PEAR::isError($error)) {
-// return $error;
-// } elseif (PEAR::isError($res)) {
-// return $res;
-// }
-//
-// return array('fname'=>$fname, 'owner'=>$owner);
-// }
+ // public function bsClosePut($token)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // $token = StoredFile::NormalizeGunid($token);
+ //
+ // if (!BasicStor::bsCheckToken($token, 'put')) {
+ // return PEAR::raiseError(
+ // "BasicStor::bsClosePut: invalid token ($token)",
+ // GBERR_TOKEN);
+ // }
+ // $row = $CC_DBC->getRow(
+ // "SELECT chsum, owner FROM ".$CC_CONFIG['accessTable']
+ // ." WHERE token=x'{$token}'::bigint");
+ // if (PEAR::isError($row)) {
+ // return $row;
+ // }
+ // $fname = $CC_CONFIG['accessDir']."/$token";
+ // $md5sum = md5_file($fname);
+ //
+ // $chsum = $row['chsum'];
+ // $owner = $row['owner'];
+ // $error = null;
+ // if ( (trim($chsum) != '') && ($chsum != $md5sum) ) {
+ // // Delete the file if the checksums do not match.
+ // if (file_exists($fname)) {
+ // @unlink($fname);
+ // }
+ // $error = new PEAR_Error(
+ // "BasicStor::bsClosePut: md5sum does not match (token=$token)".
+ // " [$chsum/$md5sum]",
+ // GBERR_PUT);
+ // } else {
+ // // Remember the MD5 sum
+ // $storedFile = StoredFile::RecallByToken($token);
+ // if (!is_null($storedFile) && !PEAR::isError($storedFile)) {
+ // $storedFile->setMd5($md5sum);
+ // } else {
+ //# $error = $storedFile;
+ // }
+ // }
+ //
+ // // Delete entry from access table.
+ // $res = $CC_DBC->query("DELETE FROM ".$CC_CONFIG['accessTable']
+ // ." WHERE token=x'$token'::bigint");
+ // if (PEAR::isError($error)) {
+ // return $error;
+ // } elseif (PEAR::isError($res)) {
+ // return $res;
+ // }
+ //
+ // return array('fname'=>$fname, 'owner'=>$owner);
+ // }
/**
@@ -660,31 +660,31 @@ class BasicStor {
* realsum: string - checksum of uploaded file
* )
*/
-// public function bsCheckPut($token)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// if (!BasicStor::bsCheckToken($token, 'put')) {
-// return PEAR::raiseError(
-// "BasicStor::bsCheckPut: invalid token ($token)"
-// );
-// }
-// $chsum = $CC_DBC->getOne("
-// SELECT chsum FROM ".$CC_CONFIG['accessTable']."
-// WHERE token=x'{$token}'::bigint
-// ");
-// if (PEAR::isError($chsum)) {
-// return $chsum;
-// }
-// $fname = $CC_CONFIG['accessDir']."/$token";
-// $md5sum = md5_file($fname);
-// $size = filesize($fname);
-// $status = ($chsum == $md5sum);
-// return array(
-// 'status'=>$status, 'size'=>$size,
-// 'expectedsum'=>$chsum,
-// 'realsum'=>$md5sum,
-// );
-// }
+ // public function bsCheckPut($token)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // if (!BasicStor::bsCheckToken($token, 'put')) {
+ // return PEAR::raiseError(
+ // "BasicStor::bsCheckPut: invalid token ($token)"
+ // );
+ // }
+ // $chsum = $CC_DBC->getOne("
+ // SELECT chsum FROM ".$CC_CONFIG['accessTable']."
+ // WHERE token=x'{$token}'::bigint
+ // ");
+ // if (PEAR::isError($chsum)) {
+ // return $chsum;
+ // }
+ // $fname = $CC_CONFIG['accessDir']."/$token";
+ // $md5sum = md5_file($fname);
+ // $size = filesize($fname);
+ // $status = ($chsum == $md5sum);
+ // return array(
+ // 'status'=>$status, 'size'=>$size,
+ // 'expectedsum'=>$chsum,
+ // 'realsum'=>$md5sum,
+ // );
+ // }
/**
@@ -693,14 +693,14 @@ class BasicStor {
* @return string
* URL
*/
-// public static function GetUrlPart()
-// {
-// global $CC_CONFIG;
-// $host = $CC_CONFIG['storageUrlHost'];
-// $port = $CC_CONFIG['storageUrlPort'];
-// $path = $CC_CONFIG['storageUrlPath'];
-// return "http://$host:$port$path/";
-// }
+ // public static function GetUrlPart()
+ // {
+ // global $CC_CONFIG;
+ // $host = $CC_CONFIG['storageUrlHost'];
+ // $port = $CC_CONFIG['storageUrlPort'];
+ // $path = $CC_CONFIG['storageUrlPath'];
+ // return "http://$host:$port$path/";
+ // }
/**
@@ -711,17 +711,17 @@ class BasicStor {
* @return array
* array of tokens
*/
-// public static function GetTokensByType($type)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $res = $CC_DBC->query(
-// "SELECT TO_HEX(token) AS token FROM ".$CC_CONFIG['accessTable']." WHERE type=?",
-// array($type));
-// while ($row = $res->fetchRow()) {
-// $r[] = $row['token'];
-// }
-// return $r;
-// }
+ // public static function GetTokensByType($type)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // $res = $CC_DBC->query(
+ // "SELECT TO_HEX(token) AS token FROM ".$CC_CONFIG['accessTable']." WHERE type=?",
+ // array($type));
+ // while ($row = $res->fetchRow()) {
+ // $r[] = $row['token'];
+ // }
+ // return $r;
+ // }
/* ----------------------------------------------------- metadata methods */
@@ -737,14 +737,14 @@ class BasicStor {
* 'file'|'string'
* @return boolean|PEAR_Error
*/
-// public function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
-// {
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// return $storedFile->setMetadata($mdata, $mdataLoc);
-// }
+ // public function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
+ // {
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // return $storedFile->setMetadata($mdata, $mdataLoc);
+ // }
/**
@@ -754,14 +754,14 @@ class BasicStor {
* Virtual file's local id
* @return string|PEAR_Error
*/
-// public function bsGetMetadata($id)
-// {
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// return $storedFile->getMetadata();
-// }
+ // public function bsGetMetadata($id)
+ // {
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // return $storedFile->getMetadata();
+ // }
/**
@@ -774,20 +774,20 @@ class BasicStor {
* null, id is then ignored
* @return string|PEAR_Error
*/
-// public function bsGetTitle($id, $gunid=NULL)
-// {
-// if (is_null($gunid)) {
-// $storedFile = StoredFile::Recall($id);
-// } else {
-// $storedFile = StoredFile::RecallByGunid($gunid);
-// }
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// $r = $storedFile->md["title"];
-// $title = (empty($r) ? 'unknown' : $r);
-// return $title;
-// }
+ // public function bsGetTitle($id, $gunid=NULL)
+ // {
+ // if (is_null($gunid)) {
+ // $storedFile = StoredFile::Recall($id);
+ // } else {
+ // $storedFile = StoredFile::RecallByGunid($gunid);
+ // }
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // $r = $storedFile->md["title"];
+ // $title = (empty($r) ? 'unknown' : $r);
+ // return $title;
+ // }
/**
@@ -804,27 +804,27 @@ class BasicStor {
* if an array is passed, an array is returned.
* @see Metadata::getMetadataValue
*/
-// public function bsGetMetadataValue($id, $category = null)
-// {
-// if (!is_numeric($id)) {
-// return null;
-// }
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// if (is_null($category)) {
-// return $storedFile->md;
-// } elseif (is_array($category)) {
-// $values = array();
-// foreach ($category as $tmpCat) {
-// $values[$tmpCat] = $storedFile->md[$tmpCat];
-// }
-// return $values;
-// } else {
-// return $storedFile->md[$category];
-// }
-// }
+ // public function bsGetMetadataValue($id, $category = null)
+ // {
+ // if (!is_numeric($id)) {
+ // return null;
+ // }
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // if (is_null($category)) {
+ // return $storedFile->md;
+ // } elseif (is_array($category)) {
+ // $values = array();
+ // foreach ($category as $tmpCat) {
+ // $values[$tmpCat] = $storedFile->md[$tmpCat];
+ // }
+ // return $values;
+ // } else {
+ // return $storedFile->md[$category];
+ // }
+ // }
/**
@@ -834,14 +834,14 @@ class BasicStor {
* @param string $p_category
* @return string|null
*/
-// public static function xmlCategoryToDbColumn($p_category)
-// {
-// global $g_metadata_xml_to_db_mapping;
-// if (array_key_exists($p_category, $g_metadata_xml_to_db_mapping)) {
-// return $g_metadata_xml_to_db_mapping[$p_category];
-// }
-// return null;
-// }
+ // public static function xmlCategoryToDbColumn($p_category)
+ // {
+ // global $g_metadata_xml_to_db_mapping;
+ // if (array_key_exists($p_category, $g_metadata_xml_to_db_mapping)) {
+ // return $g_metadata_xml_to_db_mapping[$p_category];
+ // }
+ // return null;
+ // }
/**
@@ -850,16 +850,16 @@ class BasicStor {
* @param string $p_dbColumn
* @return string|null
*/
-// public static function dbColumnToXmlCatagory($p_dbColumn)
-// {
-// global $g_metadata_xml_to_db_mapping;
-// $str = array_search($p_dbColumn, $g_metadata_xml_to_db_mapping);
-// // make return value consistent with xmlCategoryToDbColumn()
-// if ($str === FALSE) {
-// $str = null;
-// }
-// return $str;
-// }
+ // public static function dbColumnToXmlCatagory($p_dbColumn)
+ // {
+ // global $g_metadata_xml_to_db_mapping;
+ // $str = array_search($p_dbColumn, $g_metadata_xml_to_db_mapping);
+ // // make return value consistent with xmlCategoryToDbColumn()
+ // if ($str === FALSE) {
+ // $str = null;
+ // }
+ // return $str;
+ // }
/**
* Set metadata element value
@@ -872,33 +872,33 @@ class BasicStor {
* value to store, if NULL then delete record
* @return boolean
*/
-// public static function bsSetMetadataValue($p_id, $p_category, $p_value)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// if (!is_string($p_category) || is_array($p_value)) {
-// return FALSE;
-// }
-// if (is_a($p_id, "StoredFile")) {
-// $p_id = $p_id->getId();
-// }
-// if ($p_category == 'dcterms:extent') {
-// $p_value = BasicStor::NormalizeExtent($p_value);
-// }
-// $columnName = BasicStor::xmlCategoryToDbColumn($p_category); // Get column name
-//
-// if (!is_null($columnName)) {
-// $escapedValue = pg_escape_string($p_value);
-// $sql = "UPDATE ".$CC_CONFIG["filesTable"]
-// ." SET $columnName='$escapedValue'"
-// ." WHERE id=$p_id";
-// //var_dump($sql);
-// $res = $CC_DBC->query($sql);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// }
-// return TRUE;
-// }
+ // public static function bsSetMetadataValue($p_id, $p_category, $p_value)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // if (!is_string($p_category) || is_array($p_value)) {
+ // return FALSE;
+ // }
+ // if (is_a($p_id, "StoredFile")) {
+ // $p_id = $p_id->getId();
+ // }
+ // if ($p_category == 'dcterms:extent') {
+ // $p_value = BasicStor::NormalizeExtent($p_value);
+ // }
+ // $columnName = BasicStor::xmlCategoryToDbColumn($p_category); // Get column name
+ //
+ // if (!is_null($columnName)) {
+ // $escapedValue = pg_escape_string($p_value);
+ // $sql = "UPDATE ".$CC_CONFIG["filesTable"]
+ // ." SET $columnName='$escapedValue'"
+ // ." WHERE id=$p_id";
+ // //var_dump($sql);
+ // $res = $CC_DBC->query($sql);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // }
+ // return TRUE;
+ // }
/**
@@ -908,15 +908,15 @@ class BasicStor {
* value to normalize
* @return string
*/
-// private static function NormalizeExtent($v)
-// {
-// if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) {
-// $s = Playlist::playlistTimeToSeconds($v);
-// $t = Playlist::secondsToPlaylistTime($s);
-// return $t;
-// }
-// return $v;
-// }
+ // private static function NormalizeExtent($v)
+ // {
+ // if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) {
+ // $s = Playlist::playlistTimeToSeconds($v);
+ // $t = Playlist::secondsToPlaylistTime($s);
+ // return $t;
+ // }
+ // return $v;
+ // }
/**
@@ -929,60 +929,60 @@ class BasicStor {
* (e.g. 'dc:title'=>'New title')
* @return boolean
*/
-// public static function bsSetMetadataBatch($id, $values)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// if (!is_array($values)) {
-// $values = array($values);
-// }
-// if (count($values) == 0) {
-// return true;
-// }
-// if (is_a($id, "StoredFile")) {
-// $storedFile =& $id;
-// } else {
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// }
-// foreach ($values as $category => $oneValue) {
-// $columnName = BasicStor::xmlCategoryToDbColumn($category);
-// if (!is_null($columnName)) {
-// if ($category == 'dcterms:extent') {
-// $oneValue = BasicStor::NormalizeExtent($oneValue);
-// }
-// // Since track_number is an integer, you cannot set
-// // it to be the empty string, so we NULL it instead.
-// if ($columnName == 'track_number' && empty($oneValue)) {
-// $sqlPart = "$columnName = NULL";
-// } elseif (($columnName == 'length') && (strlen($oneValue) > 8)) {
-// // Postgres doesnt like it if you try to store really large hour
-// // values. TODO: We need to fix the underlying problem of getting the
-// // right values.
-// $parts = explode(':', $oneValue);
-// $hour = intval($parts[0]);
-// if ($hour > 24) {
-// continue;
-// } else {
-// $sqlPart = "$columnName = '$oneValue'";
-// }
-// } else {
-// $escapedValue = pg_escape_string($oneValue);
-// $sqlPart = "$columnName = '$escapedValue'";
-// }
-// $sqlValues[] = $sqlPart;
-// }
-// }
-// if (count($sqlValues)==0) {
-// return TRUE;
-// }
-// $sql = "UPDATE ".$CC_CONFIG["filesTable"]
-// ." SET ".join(",", $sqlValues)
-// ." WHERE id=$id";
-// $CC_DBC->query($sql);
-// return TRUE;
-// }
+ // public static function bsSetMetadataBatch($id, $values)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // if (!is_array($values)) {
+ // $values = array($values);
+ // }
+ // if (count($values) == 0) {
+ // return true;
+ // }
+ // if (is_a($id, "StoredFile")) {
+ // $storedFile =& $id;
+ // } else {
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // }
+ // foreach ($values as $category => $oneValue) {
+ // $columnName = BasicStor::xmlCategoryToDbColumn($category);
+ // if (!is_null($columnName)) {
+ // if ($category == 'dcterms:extent') {
+ // $oneValue = BasicStor::NormalizeExtent($oneValue);
+ // }
+ // // Since track_number is an integer, you cannot set
+ // // it to be the empty string, so we NULL it instead.
+ // if ($columnName == 'track_number' && empty($oneValue)) {
+ // $sqlPart = "$columnName = NULL";
+ // } elseif (($columnName == 'length') && (strlen($oneValue) > 8)) {
+ // // Postgres doesnt like it if you try to store really large hour
+ // // values. TODO: We need to fix the underlying problem of getting the
+ // // right values.
+ // $parts = explode(':', $oneValue);
+ // $hour = intval($parts[0]);
+ // if ($hour > 24) {
+ // continue;
+ // } else {
+ // $sqlPart = "$columnName = '$oneValue'";
+ // }
+ // } else {
+ // $escapedValue = pg_escape_string($oneValue);
+ // $sqlPart = "$columnName = '$escapedValue'";
+ // }
+ // $sqlValues[] = $sqlPart;
+ // }
+ // }
+ // if (count($sqlValues)==0) {
+ // return TRUE;
+ // }
+ // $sql = "UPDATE ".$CC_CONFIG["filesTable"]
+ // ." SET ".join(",", $sqlValues)
+ // ." WHERE id=$id";
+ // $CC_DBC->query($sql);
+ // return TRUE;
+ // }
/**
* Method returning array with where-parts of sql queries
@@ -998,35 +998,35 @@ class BasicStor {
$ops = array('full'=>"='%s'", 'partial'=>"ILIKE '%%%s%%'",
'prefix'=>"ILIKE '%s%%'", '<'=>"< '%s'", '='=>"= '%s'",
'>'=>"> '%s'", '<='=>"<= '%s'", '>='=>">= '%s'"
- );
- $whereArr = array();
- if (is_array($conditions)) {
- foreach ($conditions as $cond) {
- $columnName = StoredFile::xmlCategoryToDbColumn($cond['cat']);
- $op = strtolower($cond['op']);
- $value = $cond['val'];
- if (!empty($value)) {
- $splittedQn = XML_Util::splitQualifiedName($catQn);
- $catNs = $splittedQn['namespace'];
- $cat = $splittedQn['localPart'];
- $opVal = sprintf($ops[$op], pg_escape_string($value));
- // retype for timestamp value
- if ($cat == 'mtime') {
- switch ($op) {
- case 'partial':
- case 'prefix':
- break;
- default:
- $retype = "::timestamp with time zone";
- $opVal = "$retype $opVal$retype";
+ );
+ $whereArr = array();
+ if (is_array($conditions)) {
+ foreach ($conditions as $cond) {
+ $columnName = StoredFile::xmlCategoryToDbColumn($cond['cat']);
+ $op = strtolower($cond['op']);
+ $value = $cond['val'];
+ if (!empty($value)) {
+ $splittedQn = XML_Util::splitQualifiedName($catQn);
+ $catNs = $splittedQn['namespace'];
+ $cat = $splittedQn['localPart'];
+ $opVal = sprintf($ops[$op], pg_escape_string($value));
+ // retype for timestamp value
+ if ($cat == 'mtime') {
+ switch ($op) {
+ case 'partial':
+ case 'prefix':
+ break;
+ default:
+ $retype = "::timestamp with time zone";
+ $opVal = "$retype $opVal$retype";
+ }
}
+ $sqlCond = " {$columnName} {$opVal}\n";
+ $whereArr[] = $sqlCond;
}
- $sqlCond = " {$columnName} {$opVal}\n";
- $whereArr[] = $sqlCond;
}
}
- }
- return $whereArr;
+ return $whereArr;
}
/**
@@ -1104,8 +1104,8 @@ class BasicStor {
$orderByAllowedValues = array('dc:creator', 'dc:source', 'dc:title', 'dcterms:extent', "ls:track_num");
$orderByDefaults = array('dc:creator', 'dc:source', 'dc:title');
if ((!isset($criteria['orderby']))
- || (is_array($criteria['orderby']) && (count($criteria['orderby'])==0))) {
- // default ORDER BY
+ || (is_array($criteria['orderby']) && (count($criteria['orderby'])==0))) {
+ // default ORDER BY
// PaulB: track number removed because it doesnt work yet because
// if track_num is not an integer (e.g. bad metadata like "1/20",
// or if the field is blank) the SQL statement gives an error.
@@ -1148,7 +1148,7 @@ class BasicStor {
// Build WHERE clause
$whereClause = "";
if (!is_null($filetype)) {
- $whereClause .= "WHERE (ftype='$filetype')";
+ $whereClause .= "WHERE (ftype='$filetype')";
}
else {
$whereClause .= "WHERE (ftype is NOT NULL)";
@@ -1164,9 +1164,9 @@ class BasicStor {
// Final query
//"dcterms:extent" => "length",
- //"dc:title" => "track_title",
- //"dc:creator" => "artist_name",
- //dc:description
+ //"dc:title" => "track_title",
+ //"dc:creator" => "artist_name",
+ //dc:description
global $g_metadata_xml_to_db_mapping;
$plSelect = "SELECT ";
@@ -1207,17 +1207,17 @@ class BasicStor {
$sql .= $whereClause;
if ($orderby) {
- $sql .= " ORDER BY ".join(",", $orderBySql);
+ $sql .= " ORDER BY ".join(",", $orderBySql);
}
$_SESSION["debugsql"] = $sql;
$res = $CC_DBC->getAll($sql);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
if (!is_array($res)) {
- $res = array();
+ $res = array();
}
$count = count($res);
@@ -1266,83 +1266,83 @@ class BasicStor {
"dc:title" => "name",
"dc:creator" => "creator",
"dc:description" => "description"
- );
+ );
- $category = strtolower($category);
- $columnName = StoredFile::xmlCategoryToDbColumn($category);
- if (is_null($columnName)) {
- return new PEAR_Error(__FILE__.":".__LINE__." -- could not map XML category to DB column.");
- }
- $sql = "SELECT DISTINCT $columnName FROM ".$CC_CONFIG["filesTable"];
- $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
- ($offset != 0 ? " OFFSET $offset" : '' );
- $countRowsSql = "SELECT COUNT(DISTINCT $columnName) FROM ".$CC_CONFIG["filesTable"];
+ $category = strtolower($category);
+ $columnName = StoredFile::xmlCategoryToDbColumn($category);
+ if (is_null($columnName)) {
+ return new PEAR_Error(__FILE__.":".__LINE__." -- could not map XML category to DB column.");
+ }
+ $sql = "SELECT DISTINCT $columnName FROM ".$CC_CONFIG["filesTable"];
+ $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
+ ($offset != 0 ? " OFFSET $offset" : '' );
+ $countRowsSql = "SELECT COUNT(DISTINCT $columnName) FROM ".$CC_CONFIG["filesTable"];
- //$_SESSION["br"] = "in Browse Category: ".$category;
- $cnt = $CC_DBC->GetOne($countRowsSql);
- if (PEAR::isError($cnt)) {
- return $cnt;
- }
- $res = $CC_DBC->getCol($sql.$limitPart);
- if (PEAR::isError($res)) {
- return $res;
- }
- if (!is_array($res)) {
- $res = array();
- }
+ //$_SESSION["br"] = "in Browse Category: ".$category;
+ $cnt = $CC_DBC->GetOne($countRowsSql);
+ if (PEAR::isError($cnt)) {
+ return $cnt;
+ }
+ $res = $CC_DBC->getCol($sql.$limitPart);
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+ if (!is_array($res)) {
+ $res = array();
+ }
- if (array_key_exists($category, $pl_cat) && $category !== "dcterms:extent") {
- $columnName = $pl_cat[$category];
+ if (array_key_exists($category, $pl_cat) && $category !== "dcterms:extent") {
+ $columnName = $pl_cat[$category];
- $sql = "SELECT DISTINCT $columnName FROM ".$CC_CONFIG["playListTable"];
- $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
- ($offset != 0 ? " OFFSET $offset" : '' );
- $countRowsSql = "SELECT COUNT(DISTINCT $columnName) FROM ".$CC_CONFIG["playListTable"];
+ $sql = "SELECT DISTINCT $columnName FROM ".$CC_CONFIG["playListTable"];
+ $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
+ ($offset != 0 ? " OFFSET $offset" : '' );
+ $countRowsSql = "SELECT COUNT(DISTINCT $columnName) FROM ".$CC_CONFIG["playListTable"];
- $pl_cnt = $CC_DBC->GetOne($countRowsSql);
- if (PEAR::isError($cnt)) {
- return $cnt;
- }
- $pl_res = $CC_DBC->getCol($sql.$limitPart);
- if (PEAR::isError($res)) {
- return $pl_res;
- }
- if (!is_array($pl_res)) {
- $pl_res = array();
- }
+ $pl_cnt = $CC_DBC->GetOne($countRowsSql);
+ if (PEAR::isError($cnt)) {
+ return $cnt;
+ }
+ $pl_res = $CC_DBC->getCol($sql.$limitPart);
+ if (PEAR::isError($res)) {
+ return $pl_res;
+ }
+ if (!is_array($pl_res)) {
+ $pl_res = array();
+ }
- $res = array_merge($res, $pl_res);
- $res = array_slice($res, 0, $limit);
- $cnt = $cnt + $pl_cnt;
- }
- else if ($category === "dcterms:extent") {
- $columnName = $pl_cat[$category];
+ $res = array_merge($res, $pl_res);
+ $res = array_slice($res, 0, $limit);
+ $cnt = $cnt + $pl_cnt;
+ }
+ else if ($category === "dcterms:extent") {
+ $columnName = $pl_cat[$category];
- $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
- ($offset != 0 ? " OFFSET $offset" : '' );
+ $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).
+ ($offset != 0 ? " OFFSET $offset" : '' );
- $sql = "SELECT DISTINCT length AS $columnName FROM ".$CC_CONFIG["playListTimeView"];
+ $sql = "SELECT DISTINCT length AS $columnName FROM ".$CC_CONFIG["playListTimeView"];
- $countRowsSql = "SELECT COUNT(DISTINCT length) FROM ".$CC_CONFIG["playListTimeView"];
+ $countRowsSql = "SELECT COUNT(DISTINCT length) FROM ".$CC_CONFIG["playListTimeView"];
- $pl_cnt = $CC_DBC->GetOne($countRowsSql);
- if (PEAR::isError($cnt)) {
+ $pl_cnt = $CC_DBC->GetOne($countRowsSql);
+ if (PEAR::isError($cnt)) {
return $cnt;
- }
- $pl_res = $CC_DBC->getCol($sql.$limitPart);
- if (PEAR::isError($res)) {
+ }
+ $pl_res = $CC_DBC->getCol($sql.$limitPart);
+ if (PEAR::isError($res)) {
return $pl_res;
- }
- if (!is_array($pl_res)) {
+ }
+ if (!is_array($pl_res)) {
$pl_res = array();
- }
+ }
- $res = array_merge($res, $pl_res);
- $res = array_slice($res, 0, $limit);
- $cnt = $cnt + $pl_cnt;
- }
+ $res = array_merge($res, $pl_res);
+ $res = array_slice($res, 0, $limit);
+ $cnt = $cnt + $pl_cnt;
+ }
- return array('results'=>$res, 'cnt'=>$cnt);
+ return array('results'=>$res, 'cnt'=>$cnt);
}
@@ -1363,103 +1363,103 @@ class BasicStor {
* fname string: readable fname,
* token string: access token
*/
-// public function bsExportPlaylistOpen($plids, $type='lspl', $withContent=TRUE)
-// {
-// global $CC_CONFIG;
-// if (!is_array($plids)) {
-// $plids = array($plids);
-// }
-// $gunids = array();
-// foreach ($plids as $plid) {
-// $pl = StoredFile::RecallByGunid($plid);
-// if (is_null($pl) || PEAR::isError($pl)) {
-// return $pl;
-// }
-// if ($withContent) {
-// $gunidsX = $pl->export();
-// if (PEAR::isError($gunidsX)) {
-// return $gunidsX;
-// }
-// } else {
-// $gunidsX = array(array('gunid'=>$plid, 'type'=>'playlist'));
-// }
-// $gunids = array_merge($gunids, $gunidsX);
-// }
-// $plExts = array('lspl'=>"lspl", 'smil'=>"smil", 'm3u'=>"m3u");
-// $plExt = (isset($plExts[$type]) ? $plExts[$type] : "xml" );
-// $res = array();
-// $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plExport_');
-// $tmpf = "$tmpn.tar";
-// $tmpd = "$tmpn.dir";
-// mkdir($tmpd);
-// $tmpdp = "$tmpn.dir/playlist";
-// mkdir($tmpdp);
-// if ($withContent) {
-// $tmpdc = "$tmpn.dir/audioClip";
-// mkdir($tmpdc);
-// }
-// foreach ($gunids as $i => $it) {
-// $storedFile = StoredFile::RecallByGunid($it['gunid']);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-//// $MDfname = $storedFile->md->getFileName();
-// $MDfname = $storedFile->md["name"];
-// if (PEAR::isError($MDfname)) {
-// return $MDfname;
-// }
-// if (file_exists($MDfname)) {
-// switch ($it['type']) {
-// case "playlist":
-// $storedFile = $r = StoredFile::RecallByGunid($it['gunid']);
-// switch ($type) {
-// case "smil":
-// $string = $r = $storedFile->outputToSmil();
-// break;
-// case "m3u":
-// $string = $r = $storedFile->outputToM3u();
-// break;
-// default:
-//// $string = $r = $storedFile->md->genXmlDoc();
-// }
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $r = BasicStor::WriteStringToFile($string, "$tmpdp/{$it['gunid']}.$plExt");
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// break;
-// default:
-// copy($MDfname, "$tmpdc/{$it['gunid']}.xml"); break;
-// } // switch
-// } // if file_exists()
-// $RADfname = $storedFile->getRealFileName();
-// if (PEAR::isError($RADfname)) {
-// return $RADfname;
-// }
-// $RADext = $storedFile->getFileExtension();
-// if (PEAR::isError($RADext)) {
-// return $RADext;
-// }
-// if (file_exists($RADfname)) {
-// copy($RADfname, "$tmpdc/{$it['gunid']}.$RADext");
-// }
-// }
-// if (count($plids)==1) {
-// copy("$tmpdp/$plid.$plExt", "$tmpd/exportedPlaylist.$plExt");
-// }
-// $res = `cd $tmpd; tar cf $tmpf * --remove-files`;
-// @rmdir($tmpdc);
-// @rmdir($tmpdp);
-// @rmdir($tmpd);
-// unlink($tmpn);
-// $acc = BasicStor::bsAccess($tmpf, 'tar', NULL/*gunid*/, 'access');
-// if (PEAR::isError($acc)) {
-// return $acc;
-// }
-// return $acc;
-// }
+ // public function bsExportPlaylistOpen($plids, $type='lspl', $withContent=TRUE)
+ // {
+ // global $CC_CONFIG;
+ // if (!is_array($plids)) {
+ // $plids = array($plids);
+ // }
+ // $gunids = array();
+ // foreach ($plids as $plid) {
+ // $pl = StoredFile::RecallByGunid($plid);
+ // if (is_null($pl) || PEAR::isError($pl)) {
+ // return $pl;
+ // }
+ // if ($withContent) {
+ // $gunidsX = $pl->export();
+ // if (PEAR::isError($gunidsX)) {
+ // return $gunidsX;
+ // }
+ // } else {
+ // $gunidsX = array(array('gunid'=>$plid, 'type'=>'playlist'));
+ // }
+ // $gunids = array_merge($gunids, $gunidsX);
+ // }
+ // $plExts = array('lspl'=>"lspl", 'smil'=>"smil", 'm3u'=>"m3u");
+ // $plExt = (isset($plExts[$type]) ? $plExts[$type] : "xml" );
+ // $res = array();
+ // $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plExport_');
+ // $tmpf = "$tmpn.tar";
+ // $tmpd = "$tmpn.dir";
+ // mkdir($tmpd);
+ // $tmpdp = "$tmpn.dir/playlist";
+ // mkdir($tmpdp);
+ // if ($withContent) {
+ // $tmpdc = "$tmpn.dir/audioClip";
+ // mkdir($tmpdc);
+ // }
+ // foreach ($gunids as $i => $it) {
+ // $storedFile = StoredFile::RecallByGunid($it['gunid']);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ //// $MDfname = $storedFile->md->getFileName();
+ // $MDfname = $storedFile->md["name"];
+ // if (PEAR::isError($MDfname)) {
+ // return $MDfname;
+ // }
+ // if (file_exists($MDfname)) {
+ // switch ($it['type']) {
+ // case "playlist":
+ // $storedFile = $r = StoredFile::RecallByGunid($it['gunid']);
+ // switch ($type) {
+ // case "smil":
+ // $string = $r = $storedFile->outputToSmil();
+ // break;
+ // case "m3u":
+ // $string = $r = $storedFile->outputToM3u();
+ // break;
+ // default:
+ //// $string = $r = $storedFile->md->genXmlDoc();
+ // }
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // $r = BasicStor::WriteStringToFile($string, "$tmpdp/{$it['gunid']}.$plExt");
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // break;
+ // default:
+ // copy($MDfname, "$tmpdc/{$it['gunid']}.xml"); break;
+ // } // switch
+ // } // if file_exists()
+ // $RADfname = $storedFile->getRealFileName();
+ // if (PEAR::isError($RADfname)) {
+ // return $RADfname;
+ // }
+ // $RADext = $storedFile->getFileExtension();
+ // if (PEAR::isError($RADext)) {
+ // return $RADext;
+ // }
+ // if (file_exists($RADfname)) {
+ // copy($RADfname, "$tmpdc/{$it['gunid']}.$RADext");
+ // }
+ // }
+ // if (count($plids)==1) {
+ // copy("$tmpdp/$plid.$plExt", "$tmpd/exportedPlaylist.$plExt");
+ // }
+ // $res = `cd $tmpd; tar cf $tmpf * --remove-files`;
+ // @rmdir($tmpdc);
+ // @rmdir($tmpdp);
+ // @rmdir($tmpd);
+ // unlink($tmpn);
+ // $acc = BasicStor::bsAccess($tmpf, 'tar', NULL/*gunid*/, 'access');
+ // if (PEAR::isError($acc)) {
+ // return $acc;
+ // }
+ // return $acc;
+ // }
/**
@@ -1470,22 +1470,22 @@ class BasicStor {
* Access token obtained from bsExportPlaylistOpen method call.
* @return true/PEAR_Error
*/
-// public function bsExportPlaylistClose($token)
-// {
-// $r = BasicStor::bsRelease($token, 'access');
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $file = $r['realFname'];
-// if (file_exists($file)) {
-// if(! @unlink($file)){
-// return PEAR::raiseError(
-// "BasicStor::bsExportPlaylistClose: unlink failed ($file)",
-// GBERR_FILEIO);
-// }
-// }
-// return TRUE;
-// }
+ // public function bsExportPlaylistClose($token)
+ // {
+ // $r = BasicStor::bsRelease($token, 'access');
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // $file = $r['realFname'];
+ // if (file_exists($file)) {
+ // if(! @unlink($file)){
+ // return PEAR::raiseError(
+ // "BasicStor::bsExportPlaylistClose: unlink failed ($file)",
+ // GBERR_FILEIO);
+ // }
+ // }
+ // return TRUE;
+ // }
/**
@@ -1506,59 +1506,59 @@ class BasicStor {
* @return int
* Result file local id (or error object)
*/
-// public function bsImportPlaylistRaw($plid, $aPath, $rPath, $ext, &$gunids, $subjid)
-// {
-// $id = BasicStor::IdFromGunid($plid);
-// if (!is_null($id)) {
-// return $id;
-// }
-// $path = realpath("$aPath/$rPath");
-// if (FALSE === $path) {
-// return PEAR::raiseError(
-// "BasicStor::bsImportPlaylistRaw: file doesn't exist ($aPath/$rPath)"
-// );
-// }
-// switch ($ext) {
-// case "xml":
-// case "lspl":
-// $fname = $plid;
-// $values = array(
-// "filename" => $fname,
-// "metadata" => $path,
-// "gunid" => $plid,
-// "filetype" => "playlist"
-// );
-// $storedFile = StoredFile::Insert($values);
-// $res = $storedFile->getId();
-// break;
-// case "smil":
-// require_once("SmilPlaylist.php");
-// $res = SmilPlaylist::import($this, $aPath, $rPath, $gunids, $plid, $subjid);
-// if (PEAR::isError($res)) {
-// break;
-// }
-// $res = $res->getId();
-// break;
-// case "m3u":
-// require_once("M3uPlaylist.php");
-// $res = M3uPlaylist::import($this, $aPath, $rPath, $gunids, $plid, $subjid);
-// if (PEAR::isError($res)) {
-// break;
-// }
-// $res = $res->getId();
-// break;
-// default:
-// $res = PEAR::raiseError(
-// "BasicStor::importPlaylistRaw: unknown playlist format".
-// " (gunid:$plid, format:$ext)"
-// );
-// break;
-// }
-// if (!PEAR::isError($res)) {
-// $gunids[basename($rPath)] = $plid;
-// }
-// return $res;
-// }
+ // public function bsImportPlaylistRaw($plid, $aPath, $rPath, $ext, &$gunids, $subjid)
+ // {
+ // $id = BasicStor::IdFromGunid($plid);
+ // if (!is_null($id)) {
+ // return $id;
+ // }
+ // $path = realpath("$aPath/$rPath");
+ // if (FALSE === $path) {
+ // return PEAR::raiseError(
+ // "BasicStor::bsImportPlaylistRaw: file doesn't exist ($aPath/$rPath)"
+ // );
+ // }
+ // switch ($ext) {
+ // case "xml":
+ // case "lspl":
+ // $fname = $plid;
+ // $values = array(
+ // "filename" => $fname,
+ // "metadata" => $path,
+ // "gunid" => $plid,
+ // "filetype" => "playlist"
+ // );
+ // $storedFile = StoredFile::Insert($values);
+ // $res = $storedFile->getId();
+ // break;
+ // case "smil":
+ // require_once("SmilPlaylist.php");
+ // $res = SmilPlaylist::import($this, $aPath, $rPath, $gunids, $plid, $subjid);
+ // if (PEAR::isError($res)) {
+ // break;
+ // }
+ // $res = $res->getId();
+ // break;
+ // case "m3u":
+ // require_once("M3uPlaylist.php");
+ // $res = M3uPlaylist::import($this, $aPath, $rPath, $gunids, $plid, $subjid);
+ // if (PEAR::isError($res)) {
+ // break;
+ // }
+ // $res = $res->getId();
+ // break;
+ // default:
+ // $res = PEAR::raiseError(
+ // "BasicStor::importPlaylistRaw: unknown playlist format".
+ // " (gunid:$plid, format:$ext)"
+ // );
+ // break;
+ // }
+ // if (!PEAR::isError($res)) {
+ // $gunids[basename($rPath)] = $plid;
+ // }
+ // return $res;
+ // }
/**
@@ -1571,95 +1571,95 @@ class BasicStor {
* @return int
* Result file local id (or error object)
*/
-// public function bsImportPlaylist($fpath, $subjid)
-// {
-// global $CC_CONFIG;
-// // untar:
-// $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plImport_');
-// $tmpd = "$tmpn.dir";
-// $tmpdc = "$tmpd/audioClip";
-// $tmpdp = "$tmpd/playlist";
-// mkdir($tmpd);
-// $res = `cd $tmpd; tar xf $fpath`;
-// // clips:
-// $d = @dir($tmpdc);
-// $entries = array();
-// $gunids = array();
-// if ($d !== false) {
-// while (false !== ($entry = $d->read())) {
-// if (preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)) {
-// list(,$gunid, $ext) = $va;
-// switch ($ext) {
-// case"xml":
-// $entries[$gunid]['metadata'] = $entry;
-// break;
-// default:
-// $entries[$gunid]['rawMedia'] = $entry;
-// $entries[$gunid]['rawMediaExt'] = $ext;
-// $gunids[$entry] = $gunid;
-// break;
-// }
-// }
-// }
-// $d->close();
-// }
-// $res = TRUE;
-// foreach ($entries as $gunid => $it) {
-// $rawMedia = "$tmpdc/{$it['rawMedia']}";
-// if (!file_exists($rawMedia)) {
-// $rawMedia = NULL;
-// }
-// $metadata = "$tmpdc/{$it['metadata']}";
-// if (!file_exists($metadata)) {
-// $metadata = NULL;
-// }
-// $f = StoredFile::RecallByGunid($gunid);
-// if (!PEAR::isError($f)) {
-// $exists = $f->existsFile();
-// if ( $exists ) {
-// $res = $f->delete();
-// }
-// }
-// if (!PEAR::isError($res) ) {
-// $values = array(
-// "filename" => $gunid,
-// "filepath" => $rawMedia,
-// "metadata" => $metadata,
-// "gunid" => $gunid,
-// "filetype" => "audioclip"
-// );
-// $storedFile = StoredFile::Insert($values);
-// $res = $storedFile->getId();
-// }
-// @unlink("$tmpdc/{$it['rawMedia']}");
-// @unlink("$tmpdc/{$it['metadata']}");
-// if (PEAR::isError($res)) {
-// break;
-// }
-// }
-// // playlists:
-// $d = @dir($tmpdp);
-// if ($d !== false) {
-// while ((!PEAR::isError($res)) && false !== ($entry = $d->read())) {
-// if (preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)) {
-// list(,$gunid, $ext) = $va;
-// $res = $this->bsImportPlaylistRaw($gunid,
-// $tmpdp, $entry, $ext, $gunids, $subjid);
-// unlink("$tmpdp/$entry");
-// if (PEAR::isError($res)) {
-// break;
-// }
-// }
-// }
-// $d->close();
-// }
-// //@rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd);
-// @system("rm -rf $tmpdc");
-// @system("rm -rf $tmpdp");
-// @system("rm -rf $tmpd");
-// @unlink($tmpn);
-// return $res;
-// }
+ // public function bsImportPlaylist($fpath, $subjid)
+ // {
+ // global $CC_CONFIG;
+ // // untar:
+ // $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plImport_');
+ // $tmpd = "$tmpn.dir";
+ // $tmpdc = "$tmpd/audioClip";
+ // $tmpdp = "$tmpd/playlist";
+ // mkdir($tmpd);
+ // $res = `cd $tmpd; tar xf $fpath`;
+ // // clips:
+ // $d = @dir($tmpdc);
+ // $entries = array();
+ // $gunids = array();
+ // if ($d !== false) {
+ // while (false !== ($entry = $d->read())) {
+ // if (preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)) {
+ // list(,$gunid, $ext) = $va;
+ // switch ($ext) {
+ // case"xml":
+ // $entries[$gunid]['metadata'] = $entry;
+ // break;
+ // default:
+ // $entries[$gunid]['rawMedia'] = $entry;
+ // $entries[$gunid]['rawMediaExt'] = $ext;
+ // $gunids[$entry] = $gunid;
+ // break;
+ // }
+ // }
+ // }
+ // $d->close();
+ // }
+ // $res = TRUE;
+ // foreach ($entries as $gunid => $it) {
+ // $rawMedia = "$tmpdc/{$it['rawMedia']}";
+ // if (!file_exists($rawMedia)) {
+ // $rawMedia = NULL;
+ // }
+ // $metadata = "$tmpdc/{$it['metadata']}";
+ // if (!file_exists($metadata)) {
+ // $metadata = NULL;
+ // }
+ // $f = StoredFile::RecallByGunid($gunid);
+ // if (!PEAR::isError($f)) {
+ // $exists = $f->existsFile();
+ // if ( $exists ) {
+ // $res = $f->delete();
+ // }
+ // }
+ // if (!PEAR::isError($res) ) {
+ // $values = array(
+ // "filename" => $gunid,
+ // "filepath" => $rawMedia,
+ // "metadata" => $metadata,
+ // "gunid" => $gunid,
+ // "filetype" => "audioclip"
+ // );
+ // $storedFile = StoredFile::Insert($values);
+ // $res = $storedFile->getId();
+ // }
+ // @unlink("$tmpdc/{$it['rawMedia']}");
+ // @unlink("$tmpdc/{$it['metadata']}");
+ // if (PEAR::isError($res)) {
+ // break;
+ // }
+ // }
+ // // playlists:
+ // $d = @dir($tmpdp);
+ // if ($d !== false) {
+ // while ((!PEAR::isError($res)) && false !== ($entry = $d->read())) {
+ // if (preg_match("|^([0-9a-fA-F]{16})\.(.*)$|", $entry, $va)) {
+ // list(,$gunid, $ext) = $va;
+ // $res = $this->bsImportPlaylistRaw($gunid,
+ // $tmpdp, $entry, $ext, $gunids, $subjid);
+ // unlink("$tmpdp/$entry");
+ // if (PEAR::isError($res)) {
+ // break;
+ // }
+ // }
+ // }
+ // $d->close();
+ // }
+ // //@rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd);
+ // @system("rm -rf $tmpdc");
+ // @system("rm -rf $tmpdp");
+ // @system("rm -rf $tmpd");
+ // @unlink($tmpn);
+ // return $res;
+ // }
/* --------------------------------------------------------- info methods */
@@ -1671,15 +1671,15 @@ class BasicStor {
* Virtual file's local id
* @return array
*/
-// public function bsAnalyzeFile($id)
-// {
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// $ia = $storedFile->analyzeFile();
-// return $ia;
-// }
+ // public function bsAnalyzeFile($id)
+ // {
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // $ia = $storedFile->analyzeFile();
+ // return $ia;
+ // }
/**
@@ -1693,37 +1693,37 @@ class BasicStor {
* select file by gunid (id is then ignored)
* @return boolean
*/
-// public function bsExistsFile($id, $ftype=NULL, $byGunid=FALSE)
-// {
-// if ($byGunid) {
-// $storedFile = StoredFile::RecallByGunid($id);
-// } else {
-// $storedFile = StoredFile::Recall($id);
-// }
-// if (is_null($storedFile)) {
-// return $storedFile;
-// }
-// if (PEAR::isError($storedFile)) {
-// // catch some exceptions
-// switch ($storedFile->getCode()) {
-// case GBERR_FILENEX:
-// case GBERR_FOBJNEX:
-// return FALSE;
-// break;
-// default:
-// return $storedFile;
-// }
-// }
-// $realFtype = BasicStor::GetType($storedFile->gunid);
-// if (!is_null($ftype) && (
-// (strtolower($realFtype) != strtolower($ftype))
-// // webstreams are subset of audioclips
-// && !($realFtype == 'webstream' && $ftype == 'audioclip')
-// )) {
-// return FALSE;
-// }
-// return TRUE;
-// }
+ // public function bsExistsFile($id, $ftype=NULL, $byGunid=FALSE)
+ // {
+ // if ($byGunid) {
+ // $storedFile = StoredFile::RecallByGunid($id);
+ // } else {
+ // $storedFile = StoredFile::Recall($id);
+ // }
+ // if (is_null($storedFile)) {
+ // return $storedFile;
+ // }
+ // if (PEAR::isError($storedFile)) {
+ // // catch some exceptions
+ // switch ($storedFile->getCode()) {
+ // case GBERR_FILENEX:
+ // case GBERR_FOBJNEX:
+ // return FALSE;
+ // break;
+ // default:
+ // return $storedFile;
+ // }
+ // }
+ // $realFtype = BasicStor::GetType($storedFile->gunid);
+ // if (!is_null($ftype) && (
+ // (strtolower($realFtype) != strtolower($ftype))
+ // // webstreams are subset of audioclips
+ // && !($realFtype == 'webstream' && $ftype == 'audioclip')
+ // )) {
+ // return FALSE;
+ // }
+ // return TRUE;
+ // }
/* ---------------------------------------------------- redefined methods */
@@ -1734,25 +1734,25 @@ class BasicStor {
* Local object id
* @return string|PEAR_Error
*/
-// public static function GetObjType($p_id)
-// {
-// $type = "unknown";
-// $f = StoredFile::Recall($p_id);
-// return $f->getType();
+ // public static function GetObjType($p_id)
+ // {
+ // $type = "unknown";
+ // $f = StoredFile::Recall($p_id);
+ // return $f->getType();
-// $gunid = BasicStor::GunidFromId($oid);
-// if (PEAR::isError($gunid)) {
-// return $gunid;
-// }
-// $ftype = BasicStor::GetType($gunid);
-// if (PEAR::isError($ftype)) {
-// return $ftype;
-// }
-// if (!is_null($ftype)) {
-// $type = $ftype;
-// }
-// return $type;
-// }
+ // $gunid = BasicStor::GunidFromId($oid);
+ // if (PEAR::isError($gunid)) {
+ // return $gunid;
+ // }
+ // $ftype = BasicStor::GetType($gunid);
+ // if (PEAR::isError($ftype)) {
+ // return $ftype;
+ // }
+ // if (!is_null($ftype)) {
+ // $type = $ftype;
+ // }
+ // return $type;
+ // }
/**
@@ -1779,12 +1779,12 @@ class BasicStor {
if (PEAR::isError($res)) {
return $res;
}
-// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
- }
- return $uid;
+ // $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ }
+ return $uid;
}
@@ -1862,13 +1862,13 @@ class BasicStor {
$acts = array($acts);
}
$perm = true;
-// foreach ($acts as $i => $action) {
-// $res = Alib::CheckPerm($userid, $action, $pars[$i]);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// $perm = $perm && $res;
-// }
+ // foreach ($acts as $i => $action) {
+ // $res = Alib::CheckPerm($userid, $action, $pars[$i]);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // $perm = $perm && $res;
+ // }
if ($perm) {
return TRUE;
}
@@ -1886,14 +1886,14 @@ class BasicStor {
* @return int
* Local id
*/
-// public static function IdFromGunid($p_gunid)
-// {
-// global $CC_DBC;
-// global $CC_CONFIG;
-// return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid=x'$p_gunid'::bigint");
-// }
+ // public static function IdFromGunid($p_gunid)
+ // {
+ // global $CC_DBC;
+ // global $CC_CONFIG;
+ // return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid=x'$p_gunid'::bigint");
+ // }
- /**
+ /**
* Get local id from global id (big int).
*
* @param string $p_gunid
@@ -1901,12 +1901,12 @@ class BasicStor {
* @return int
* Local id
*/
-// public static function IdFromGunidBigInt($p_gunid)
-// {
-// global $CC_DBC;
-// global $CC_CONFIG;
-// return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid='$p_gunid'");
-// }
+ // public static function IdFromGunidBigInt($p_gunid)
+ // {
+ // global $CC_DBC;
+ // global $CC_CONFIG;
+ // return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid='$p_gunid'");
+ // }
/**
@@ -1917,25 +1917,25 @@ class BasicStor {
* @return string
* Global id
*/
-// public static function GunidFromId($p_id)
-// {
-// global $CC_CONFIG;
-// global $CC_DBC;
-// if (!is_numeric($p_id)) {
-// return NULL;
-// }
-// $gunid = $CC_DBC->getOne("
-// SELECT to_hex(gunid)as gunid FROM ".$CC_CONFIG['filesTable']."
-// WHERE id='$p_id'
-// ");
-// if (PEAR::isError($gunid)) {
-// return $gunid;
-// }
-// if (is_null($gunid)) {
-// return NULL;
-// }
-// return StoredFile::NormalizeGunid($gunid);
-// }
+ // public static function GunidFromId($p_id)
+ // {
+ // global $CC_CONFIG;
+ // global $CC_DBC;
+ // if (!is_numeric($p_id)) {
+ // return NULL;
+ // }
+ // $gunid = $CC_DBC->getOne("
+ // SELECT to_hex(gunid)as gunid FROM ".$CC_CONFIG['filesTable']."
+ // WHERE id='$p_id'
+ // ");
+ // if (PEAR::isError($gunid)) {
+ // return $gunid;
+ // }
+ // if (is_null($gunid)) {
+ // return NULL;
+ // }
+ // return StoredFile::NormalizeGunid($gunid);
+ // }
/**
@@ -1945,16 +1945,16 @@ class BasicStor {
* Global unique id of file
* @return string
*/
-// public static function GetType($p_gunid)
-// {
-// global $CC_CONFIG;
-// global $CC_DBC;
-// $ftype = $CC_DBC->getOne("
-// SELECT ftype FROM ".$CC_CONFIG['filesTable']."
-// WHERE gunid=x'$p_gunid'::bigint
-// ");
-// return $ftype;
-// }
+ // public static function GetType($p_gunid)
+ // {
+ // global $CC_CONFIG;
+ // global $CC_DBC;
+ // $ftype = $CC_DBC->getOne("
+ // SELECT ftype FROM ".$CC_CONFIG['filesTable']."
+ // WHERE gunid=x'$p_gunid'::bigint
+ // ");
+ // return $ftype;
+ // }
/**
@@ -1964,11 +1964,11 @@ class BasicStor {
* Global unique ID
* @return boolean
*/
-// protected static function CheckGunid($p_gunid)
-// {
-// $res = preg_match("|^([0-9a-fA-F]{16})?$|", $p_gunid);
-// return $res;
-// }
+ // protected static function CheckGunid($p_gunid)
+ // {
+ // $res = preg_match("|^([0-9a-fA-F]{16})?$|", $p_gunid);
+ // return $res;
+ // }
/**
* Set playlist edit flag
@@ -2038,24 +2038,24 @@ class BasicStor {
* @return int
* New object local id
*/
-// protected static function CopyObj($id, $newParid, $after=NULL)
-// {
-// switch (BasicStor::GetObjType($id)) {
-// case "audioclip":
-// case "playlist":
-// case "webstream":
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile) || PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// $ac2 = StoredFile::CopyOf($storedFile, $nid);
-// //$ac2->setName(M2tree::GetObjName($nid));
-// break;
-// case "File":
-// default:
-// }
-// return $nid;
-// }
+ // protected static function CopyObj($id, $newParid, $after=NULL)
+ // {
+ // switch (BasicStor::GetObjType($id)) {
+ // case "audioclip":
+ // case "playlist":
+ // case "webstream":
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile) || PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // $ac2 = StoredFile::CopyOf($storedFile, $nid);
+ // //$ac2->setName(M2tree::GetObjName($nid));
+ // break;
+ // case "File":
+ // default:
+ // }
+ // return $nid;
+ // }
/**
@@ -2068,50 +2068,50 @@ class BasicStor {
* Unconditional delete
* @return true|PEAR_Error
*/
-// public static function RemoveObj($id, $forced=FALSE)
-// {
-// $ot = BasicStor::GetObjType($id);
-// if (PEAR::isError($ot)) {
-// return $ot;
-// }
-// switch ($ot) {
-// case "audioclip":
-// case "playlist":
-// case "webstream":
-// $storedFile = StoredFile::Recall($id);
-// if (is_null($storedFile)) {
-// return TRUE;
-// }
-// if (PEAR::isError($storedFile)) {
-// return $storedFile;
-// }
-// if ($storedFile->isEdited() && !$forced) {
-// return PEAR::raiseError(
-// 'BasicStor::RemoveObj(): is edited'
-// );
-// }
-// if ($storedFile->isAccessed() && !$forced) {
-// return PEAR::raiseError(
-// 'BasicStor::RemoveObj(): is accessed'
-// );
-// }
-// $storedFile->delete();
-// break;
-// case "File":
-//// case "Folder":
-//// case "Replica":
-// break;
-// default:
-// return PEAR::raiseError(
-// "BasicStor::bsDeleteFile: unknown obj type ($ot)"
-// );
-// }
-// $res = Alib::RemoveObj($id);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// return TRUE;
-// }
+ // public static function RemoveObj($id, $forced=FALSE)
+ // {
+ // $ot = BasicStor::GetObjType($id);
+ // if (PEAR::isError($ot)) {
+ // return $ot;
+ // }
+ // switch ($ot) {
+ // case "audioclip":
+ // case "playlist":
+ // case "webstream":
+ // $storedFile = StoredFile::Recall($id);
+ // if (is_null($storedFile)) {
+ // return TRUE;
+ // }
+ // if (PEAR::isError($storedFile)) {
+ // return $storedFile;
+ // }
+ // if ($storedFile->isEdited() && !$forced) {
+ // return PEAR::raiseError(
+ // 'BasicStor::RemoveObj(): is edited'
+ // );
+ // }
+ // if ($storedFile->isAccessed() && !$forced) {
+ // return PEAR::raiseError(
+ // 'BasicStor::RemoveObj(): is accessed'
+ // );
+ // }
+ // $storedFile->delete();
+ // break;
+ // case "File":
+ //// case "Folder":
+ //// case "Replica":
+ // break;
+ // default:
+ // return PEAR::raiseError(
+ // "BasicStor::bsDeleteFile: unknown obj type ($ot)"
+ // );
+ // }
+ // $res = Alib::RemoveObj($id);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // return TRUE;
+ // }
/* ========================================================= misc methods */
@@ -2156,17 +2156,17 @@ class BasicStor {
*
* @return void
*/
-// private function deleteFiles()
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $ids = $CC_DBC->getAll("SELECT id FROM ".$CC_CONFIG['filesTable']);
-// if (is_array($ids)) {
-// foreach ($ids as $i => $item) {
-// $f = StoredFile::Recall($item['id']);
-// $f->delete();
-// }
-// }
-// }
+ // private function deleteFiles()
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // $ids = $CC_DBC->getAll("SELECT id FROM ".$CC_CONFIG['filesTable']);
+ // if (is_array($ids)) {
+ // foreach ($ids as $i => $item) {
+ // $f = StoredFile::Recall($item['id']);
+ // $f->delete();
+ // }
+ // }
+ // }
/**
@@ -2182,5 +2182,5 @@ class BasicStor {
fclose($fp);
}
-} // class BasicStor
-?>
\ No newline at end of file
+ } // class BasicStor
+ ?>
\ No newline at end of file
diff --git a/application/models/LocStor.php b/application/models/LocStor.php
index a5762b6ab..fa0956f3b 100644
--- a/application/models/LocStor.php
+++ b/application/models/LocStor.php
@@ -50,7 +50,7 @@ class LocStor extends BasicStor {
* {url:writable URL for HTTP PUT, token:access token}
*/
protected function storeAudioClipOpen($sessid, $gunid, $metadata,
- $fname, $chsum, $ftype='audioclip')
+ $fname, $chsum, $ftype='audioclip')
{
// Check the gunid format
if (!BasicStor::CheckGunid($gunid)) {
@@ -79,7 +79,7 @@ class LocStor extends BasicStor {
if ($storedFile->isAccessed()) {
return PEAR::raiseError(
'LocStor::storeAudioClipOpen: is accessed'
- );
+ );
}
$res = $storedFile->replace($oid, $storedFile->getName(), '', $metadata, 'string');
if (PEAR::isError($res)) {
@@ -182,7 +182,7 @@ class LocStor extends BasicStor {
protected function storeWebstream($sessid, $gunid, $metadata, $fname, $url)
{
$a = $this->storeAudioClipOpen(
- $sessid, $gunid, $metadata, $fname, md5(''), 'webstream');
+ $sessid, $gunid, $metadata, $fname, md5(''), 'webstream');
if (PEAR::isError($a)) {
return $a;
}
@@ -267,7 +267,7 @@ class LocStor extends BasicStor {
if (is_null($id) || !$ex) {
return PEAR::raiseError(
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
- GBERR_NOTF
+ GBERR_NOTF
);
}
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
@@ -304,8 +304,8 @@ class LocStor extends BasicStor {
*/
protected function downloadMetadataOpen($sessid, $gunid)
{
-// $res = $this->existsAudioClip($sessid, $gunid);
-// if(PEAR::isError($res)) return $res;
+ // $res = $this->existsAudioClip($sessid, $gunid);
+ // if(PEAR::isError($res)) return $res;
$media = StoredFile::RecallByGunid($gunid)
$id = $media->getGunid();
if (is_null($id)) {
@@ -414,7 +414,7 @@ class LocStor extends BasicStor {
*
*
* @see BasicStor::localSearch
- */
+ */
public function searchMetadata($sessid, $criteria)
{
if (($res = BasicStor::Authorize('read', $this->storId, $sessid)) !== TRUE) {
@@ -592,7 +592,7 @@ class LocStor extends BasicStor {
if ($ex) {
return PEAR::raiseError(
'LocStor::createPlaylist: already exists'
- );
+ );
}
$tmpFname = uniqid('');
if (($res = BasicStor::Authorize('write', null, $sessid)) !== TRUE) {
@@ -608,7 +608,7 @@ class LocStor extends BasicStor {
$fname = "newFile.xml";
}
$storedFile->setName($fname);
- $storedFile->setState('ready');
+ $storedFile->setState('ready');
$storedFile->setMime('application/smil');
return $storedFile->gunid;
}
@@ -634,12 +634,12 @@ class LocStor extends BasicStor {
if (!$ex) {
return PEAR::raiseError(
'LocStor::editPlaylist: playlist not exists'
- );
+ );
}
if ($this->isEdited($playlistId) !== FALSE) {
return PEAR::raiseError(
'LocStor::editPlaylist: playlist already edited'
- );
+ );
}
$storedFile =& StoredFile::RecallByGunid($playlistId);
if (is_null($storedFile) || PEAR::isError($storedFile)) {
@@ -753,7 +753,7 @@ class LocStor extends BasicStor {
}
return PEAR::raiseError(
'LocStor::deletePlaylist: playlist not exists',
- GBERR_FILENEX
+ GBERR_FILENEX
);
}
$storedFile =& StoredFile::RecallByGunid($playlistId);
@@ -791,32 +791,32 @@ class LocStor extends BasicStor {
* }
*/
public function accessPlaylist($sessid, $playlistId, $recursive=FALSE, $parent='0')
-// {
-// if ($recursive) {
-// require_once("AccessRecur.php");
-// $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// return $r;
-// }
-// $ex = $this->existsPlaylist($sessid, $playlistId);
-// if (PEAR::isError($ex)) {
-// return $ex;
-// }
-// if (!$ex) {
-// return PEAR::raiseError(
-// "LocStor::accessPlaylist: playlist not found ($playlistId)",
-// GBERR_NOTF
-// );
-// }
-// $id = BasicStor::IdFromGunid($playlistId);
-// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
-// return $res;
-// }
-// $res = $this->bsOpenDownload($id, 'metadata', $parent);
-// #unset($res['filename']);
-// return $res;
+ // {
+ // if ($recursive) {
+ // require_once("AccessRecur.php");
+ // $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
+ // return $r;
+ // }
+ // $ex = $this->existsPlaylist($sessid, $playlistId);
+ // if (PEAR::isError($ex)) {
+ // return $ex;
+ // }
+ // if (!$ex) {
+ // return PEAR::raiseError(
+ // "LocStor::accessPlaylist: playlist not found ($playlistId)",
+ // GBERR_NOTF
+ // );
+ // }
+ // $id = BasicStor::IdFromGunid($playlistId);
+ // if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
+ // return $res;
+ // }
+ // $res = $this->bsOpenDownload($id, 'metadata', $parent);
+ // #unset($res['filename']);
+ // return $res;
}
@@ -983,7 +983,7 @@ class LocStor extends BasicStor {
if (!$ex) {
return PEAR::raiseError(
'LocStor::playlistIsAvailable: playlist not exists'
- );
+ );
}
$ie = $this->isEdited($playlistId);
if ($ie === FALSE) {
@@ -1159,7 +1159,7 @@ class LocStor extends BasicStor {
if ($token != '123456789abcdeff') {
return PEAR::raiseError(
"LocStor::renderPlaylistToRSSClose: invalid token"
- );
+ );
}
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
unlink($fakeFile);
@@ -1192,7 +1192,7 @@ class LocStor extends BasicStor {
if ($r === FALSE) {
return PEAR::raiseError(
"LocStor::createBackupOpen: false returned from Backup"
- );
+ );
}
return $r;
}
@@ -1351,12 +1351,12 @@ class LocStor extends BasicStor {
* status: string - working | fault | success
*/
protected function restoreBackupClose($token) {
- require_once('Restore.php');
- $rs = new Restore($this);
- if (PEAR::isError($rs)) {
- return $rs;
- }
- return $rs->closeRestore($token);
+ require_once('Restore.php');
+ $rs = new Restore($this);
+ if (PEAR::isError($rs)) {
+ return $rs;
+ }
+ return $rs->closeRestore($token);
}
@@ -1387,11 +1387,11 @@ class LocStor extends BasicStor {
{
$owner = Alib::GetSessUserId($sessid);
if (PEAR::isError($owner)) {
- return $owner;
+ return $owner;
}
$res = $this->bsOpenPut($chsum, NULL, $owner);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
return array('url'=>$res['url'], 'token'=>$res['token']);
}
@@ -1412,7 +1412,7 @@ class LocStor extends BasicStor {
{
$res = $this->bsClosePut($token);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
extract($res); // fname, owner
switch ($trtype) {
@@ -1420,11 +1420,11 @@ class LocStor extends BasicStor {
$mdtoken = $pars['mdpdtoken'];
$res = $this->bsClosePut($mdtoken);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
$mdfname = $res['fname'];
if ($gunid == '') {
- $gunid = NULL;
+ $gunid = NULL;
}
$values = array(
"filename" => $pars['name'],
@@ -1432,45 +1432,45 @@ class LocStor extends BasicStor {
"metadata" => $mdfname,
"gunid" => $pars['gunid'],
"filetype" => "audioclip"
- );
- $storedFile = StoredFile::Insert($values);
- if (PEAR::isError($storedFile)) {
- return $storedFile;
- }
- $res = $storedFile->getId();
- @unlink($fname);
- @unlink($mdfname);
- break;
+ );
+ $storedFile = StoredFile::Insert($values);
+ if (PEAR::isError($storedFile)) {
+ return $storedFile;
+ }
+ $res = $storedFile->getId();
+ @unlink($fname);
+ @unlink($mdfname);
+ break;
case "playlist":
if ($gunid == '') {
- $gunid = NULL;
+ $gunid = NULL;
}
$values = array(
"filename" => $pars['name'],
"metadata" => $fname,
"gunid" => $pars['gunid'],
"filetype" => "playlist"
- );
- $storedFile = StoredFile::Insert($values);
- if (PEAR::isError($storedFile)) {
- return $storedFile;
- }
- $res = $storedFile->getId();
- @unlink($fname);
- break;
+ );
+ $storedFile = StoredFile::Insert($values);
+ if (PEAR::isError($storedFile)) {
+ return $storedFile;
+ }
+ $res = $storedFile->getId();
+ @unlink($fname);
+ break;
case "playlistPkg":
$chsum = md5_file($fname);
// importPlaylistOpen:
$res = $this->bsOpenPut($chsum, NULL, $owner);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
$dest = $res['fname'];
$token = $res['token'];
copy($fname, $dest);
$r = $this->importPlaylistClose($token);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
@unlink($fname);
return $r;
@@ -1481,14 +1481,14 @@ class LocStor extends BasicStor {
@unlink($fname);
$results = $this->localSearch($criteria);
if (PEAR::isError($results)) {
- return $results;
+ return $results;
}
$realfile = tempnam($this->accessDir, 'searchjob_');
@chmod($realfile, 0660);
$len = file_put_contents($realfile, serialize($results));
$acc = BasicStor::bsAccess($realfile, '', NULL, 'download');
if (PEAR::isError($acc)) {
- return $acc;
+ return $acc;
}
$url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
$chsum = md5_file($realfile);
@@ -1523,227 +1523,227 @@ class LocStor extends BasicStor {
*/
function downloadOpen($sessid, $trtype, $pars=array())
{
-// global $CC_CONFIG;
-// switch ($trtype) {
-// case "unknown":
-// case "audioclip":
-// case "metadata":
-// case "playlist":
-// case "playlistPkg":
-// if (!isset($pars['gunid'])) {
-// return PEAR::raiseError("Archive::downloadOpen: gunid not set");
-// }
-// break;
-// }
-// $gunid = $pars['gunid'];
-// // resolve trtype by object type:
-// if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
-// $media = StoredFile::RecallByGunid($gunid);
-// $trtype2 = $media->getType();
-// if (PEAR::isError($trtype2)) {
-// return $trtype2;
-// }
-// // required with content:
-// $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
-// 'playlistPkg' : $trtype2);
-// //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
-// }
-// switch ($trtype) {
-// case "audioclip":
-// $res = $this->downloadRawAudioDataOpen($sessid, $gunid);
-// break;
-// case "metadata":
-// $res = $this->downloadMetadataOpen($sessid, $gunid);
-// break;
-// case "playlist":
-// $res = $this->accessPlaylist($sessid, $gunid);
-// break;
-// case "playlistPkg":
-// $res = $this->bsExportPlaylistOpen($gunid);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
-// $plfpath = "$tmpn.lspl";
-// copy($res['fname'], $plfpath);
-// $res = $this->bsExportPlaylistClose($res['token']);
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// $fname = "transported_playlist.lspl";
-// $id = BasicStor::IdFromGunid($gunid);
-// $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
-// if (PEAR::isError($acc)) {
-// return $acc;
-// }
-// $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
-// $chsum = md5_file($plfpath);
-// $size = filesize($plfpath);
-// $res = array(
-// 'url'=>$url, 'token'=>$acc['token'],
-// 'chsum'=>$chsum, 'size'=>$size,
-// 'filename'=>$fname
-// );
-// break;
-// case "searchjob":
-// $res = $pars;
-// break;
-// case "file":
-// $res = array();
-// break;
-// default:
-// return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
-// }
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// switch ($trtype) {
-// case "audioclip":
-// case "metadata":
-// case "playlist":
-// case "playlistPkg":
-// $f = StoredFile::RecallByGunid($gunid);
-// $title = $f->getTitle();
-// break;
-// case "searchjob":
-// $title = 'searchjob';
-// break;
-// case "file":
-// $title = 'regular file';
-// break;
-// default:
-// }
-// $res['title'] = $title;
-// $res['trtype'] = $trtype;
-// return $res;
- }
+ // global $CC_CONFIG;
+ // switch ($trtype) {
+ // case "unknown":
+ // case "audioclip":
+ // case "metadata":
+ // case "playlist":
+ // case "playlistPkg":
+ // if (!isset($pars['gunid'])) {
+ // return PEAR::raiseError("Archive::downloadOpen: gunid not set");
+ // }
+ // break;
+ // }
+ // $gunid = $pars['gunid'];
+ // // resolve trtype by object type:
+ // if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
+ // $media = StoredFile::RecallByGunid($gunid);
+ // $trtype2 = $media->getType();
+ // if (PEAR::isError($trtype2)) {
+ // return $trtype2;
+ // }
+ // // required with content:
+ // $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
+ // 'playlistPkg' : $trtype2);
+ // //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
+ // }
+ // switch ($trtype) {
+ // case "audioclip":
+ // $res = $this->downloadRawAudioDataOpen($sessid, $gunid);
+ // break;
+ // case "metadata":
+ // $res = $this->downloadMetadataOpen($sessid, $gunid);
+ // break;
+ // case "playlist":
+ // $res = $this->accessPlaylist($sessid, $gunid);
+ // break;
+ // case "playlistPkg":
+ // $res = $this->bsExportPlaylistOpen($gunid);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
+ // $plfpath = "$tmpn.lspl";
+ // copy($res['fname'], $plfpath);
+ // $res = $this->bsExportPlaylistClose($res['token']);
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // $fname = "transported_playlist.lspl";
+ // $id = BasicStor::IdFromGunid($gunid);
+ // $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
+ // if (PEAR::isError($acc)) {
+ // return $acc;
+ // }
+ // $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
+ // $chsum = md5_file($plfpath);
+ // $size = filesize($plfpath);
+ // $res = array(
+ // 'url'=>$url, 'token'=>$acc['token'],
+ // 'chsum'=>$chsum, 'size'=>$size,
+ // 'filename'=>$fname
+ // );
+ // break;
+ // case "searchjob":
+ // $res = $pars;
+ // break;
+ // case "file":
+ // $res = array();
+ // break;
+ // default:
+ // return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
+ // }
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // switch ($trtype) {
+ // case "audioclip":
+ // case "metadata":
+ // case "playlist":
+ // case "playlistPkg":
+ // $f = StoredFile::RecallByGunid($gunid);
+ // $title = $f->getTitle();
+ // break;
+ // case "searchjob":
+ // $title = 'searchjob';
+ // break;
+ // case "file":
+ // $title = 'regular file';
+ // break;
+ // default:
+ // }
+ // $res['title'] = $title;
+ // $res['trtype'] = $trtype;
+ // return $res;
+ }
- /**
- * Close download transport
- *
- * @param string $token
- * transport token
- * @param string $trtype
- * transport type
- * @return array
- * hasharray with:
- * url string: writable URL
- * token string: PUT token
- */
- function downloadClose($token, $trtype)
- {
- switch ($trtype) {
- case "audioclip":
- $res = $this->downloadRawAudioDataClose($token);
- if (PEAR::isError($res)) {
- return $res;
- }
- return $res;
- case "metadata":
- $res = $this->downloadMetadataClose($token);
- return $res;
- case "playlist":
- $res = $this->releasePlaylist(NULL/*$sessid*/, $token);
- return $res;
- case "playlistPkg":
- $res = BasicStor::bsRelease($token, 'download');
- if (PEAR::isError($res)) {
- return $res;
- }
- $realFname = $r['realFname'];
- @unlink($realFname);
- if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) {
- list(,$tmpn) = $va;
- $tmpn = $CC_CONFIG['transDir']."/$tmpn";
- if (file_exists($tmpn)) {
- @unlink($tmpn);
+ /**
+ * Close download transport
+ *
+ * @param string $token
+ * transport token
+ * @param string $trtype
+ * transport type
+ * @return array
+ * hasharray with:
+ * url string: writable URL
+ * token string: PUT token
+ */
+ function downloadClose($token, $trtype)
+ {
+ switch ($trtype) {
+ case "audioclip":
+ $res = $this->downloadRawAudioDataClose($token);
+ if (PEAR::isError($res)) {
+ return $res;
}
- }
- return $res;
- case "searchjob":
- $res = BasicStor::bsRelease($token, 'download');
- return $res;
- case "file":
- return array();
- default:
- return PEAR::raiseError("Archive::downloadClose: NotImpl ($trtype)");
+ return $res;
+ case "metadata":
+ $res = $this->downloadMetadataClose($token);
+ return $res;
+ case "playlist":
+ $res = $this->releasePlaylist(NULL/*$sessid*/, $token);
+ return $res;
+ case "playlistPkg":
+ $res = BasicStor::bsRelease($token, 'download');
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+ $realFname = $r['realFname'];
+ @unlink($realFname);
+ if (preg_match("|(plExport_[^\.]+)\.lspl$|", $realFname, $va)) {
+ list(,$tmpn) = $va;
+ $tmpn = $CC_CONFIG['transDir']."/$tmpn";
+ if (file_exists($tmpn)) {
+ @unlink($tmpn);
+ }
+ }
+ return $res;
+ case "searchjob":
+ $res = BasicStor::bsRelease($token, 'download');
+ return $res;
+ case "file":
+ return array();
+ default:
+ return PEAR::raiseError("Archive::downloadClose: NotImpl ($trtype)");
+ }
}
- }
- /**
- * Prepare hub initiated transport
- *
- * @param string $target
- * hostname of transport target
- * @param string $trtype
- * transport type
- * @param string $direction
- * 'up' | 'down'
- * @param array $pars
- * transport parameters
- * @return mixed
- */
- function prepareHubInitiatedTransfer(
+ /**
+ * Prepare hub initiated transport
+ *
+ * @param string $target
+ * hostname of transport target
+ * @param string $trtype
+ * transport type
+ * @param string $direction
+ * 'up' | 'down'
+ * @param array $pars
+ * transport parameters
+ * @return mixed
+ */
+ function prepareHubInitiatedTransfer(
$target, $trtype='file', $direction='up',$pars=array())
- {
- $tr = new Transport($this);
- $trec = TransportRecord::create($tr, $trtype, $direction,
+ {
+ $tr = new Transport($this);
+ $trec = TransportRecord::create($tr, $trtype, $direction,
array_merge($pars, array('target'=>$target)));
- if (PEAR::isError($trec)) {
- return $trec;
+ if (PEAR::isError($trec)) {
+ return $trec;
+ }
+ return TRUE;
}
- return TRUE;
- }
- /**
- * List hub initiated transports
- *
- * @param string $target
- * hostname of transport target
- * @param string $direction
- * 'up' | 'down'
- * @param string $trtok
- * transport token
- * @return mixed
- */
- function listHubInitiatedTransfers(
+ /**
+ * List hub initiated transports
+ *
+ * @param string $target
+ * hostname of transport target
+ * @param string $direction
+ * 'up' | 'down'
+ * @param string $trtok
+ * transport token
+ * @return mixed
+ */
+ function listHubInitiatedTransfers(
$target=NULL, $direction=NULL, $trtok=NULL)
- {
- $tr = new Transport($this);
- $res = $tr->getTransports($direction, $target, $trtok);
- return $res;
- }
-
-
- /**
- * Set state of hub initiated transport
- *
- * @param string $target
- * hostname of transport target
- * @param string $trtok
- * transport token
- * @param string $state
- * transport state
- * @return TransportRecord|PEAR_Error
- */
- function setHubInitiatedTransfer($target, $trtok, $state)
- {
- $tr = new Transport($this);
- $trec = TransportRecord::recall($tr, $trtok);
- if (PEAR::isError($trec)) {
- return $trec;
+ {
+ $tr = new Transport($this);
+ $res = $tr->getTransports($direction, $target, $trtok);
+ return $res;
}
- $r = $trec->setState($state);
- if (PEAR::isError($r)) {
- return $r;
- }
- return $trec;
- }
- /* ==================================================== auxiliary methods */
+
+ /**
+ * Set state of hub initiated transport
+ *
+ * @param string $target
+ * hostname of transport target
+ * @param string $trtok
+ * transport token
+ * @param string $state
+ * transport state
+ * @return TransportRecord|PEAR_Error
+ */
+ function setHubInitiatedTransfer($target, $trtok, $state)
+ {
+ $tr = new Transport($this);
+ $trec = TransportRecord::recall($tr, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
+ }
+ $r = $trec->setState($state);
+ if (PEAR::isError($r)) {
+ return $r;
+ }
+ return $trec;
+ }
+
+ /* ==================================================== auxiliary methods */
} // class LocStor
?>
\ No newline at end of file
diff --git a/application/models/Prefs.php b/application/models/Prefs.php
index 49f0dc6c9..c51a75402 100644
--- a/application/models/Prefs.php
+++ b/application/models/Prefs.php
@@ -44,19 +44,19 @@ class Prefs {
{
$subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) {
- return $subjid;
+ return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::loadPref: invalid session id",
- GBERR_SESS);
+ GBERR_SESS);
}
$val = $this->readVal($subjid, $key);
if (PEAR::isError($val)) {
- return $val;
+ return $val;
}
if ($val === FALSE) {
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
- GBERR_PREF);
+ GBERR_PREF);
}
return $val;
}
@@ -77,20 +77,19 @@ class Prefs {
{
$subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) {
- return $subjid;
+ return $subjid;
}
if (is_null($subjid)) {
- return PEAR::raiseError("Prefs::savePref: invalid session id",
- GBERR_SESS);
+ return PEAR::raiseError("Prefs::savePref: invalid session id", GBERR_SESS);
}
$r = $this->update($subjid, $key, $value);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
if ($r === FALSE) {
$r = $this->insert($subjid, $key, $value);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
}
return TRUE;
@@ -110,19 +109,17 @@ class Prefs {
{
$subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) {
- return $subjid;
+ return $subjid;
}
if (is_null($subjid)) {
- return PEAR::raiseError("Prefs::delPref: invalid session id",
- GBERR_SESS);
+ return PEAR::raiseError("Prefs::delPref: invalid session id", GBERR_SESS);
}
$r = $this->delete($subjid, $key);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
if ($r === FALSE) {
- return PEAR::raiseError("Prefs::delPref: invalid preference key",
- GBERR_PREF);
+ return PEAR::raiseError("Prefs::delPref: invalid preference key", GBERR_PREF);
}
return TRUE;
}
@@ -146,7 +143,7 @@ class Prefs {
// if sessid is would be used here fix Transport::cronCallMethod !
$subjid = Subjects::GetSubjId($group);
if (PEAR::isError($subjid)) {
- return $subjid;
+ return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError(
@@ -154,7 +151,7 @@ class Prefs {
}
$val = $this->readVal($subjid, $key);
if (PEAR::isError($val)) {
- return $val;
+ return $val;
}
if ($val === FALSE) {
if ($returnErrorIfKeyNotExists) {
@@ -185,7 +182,7 @@ class Prefs {
{
$uid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($uid)) {
- return $uid;
+ return $uid;
}
if (is_null($uid)) {
return PEAR::raiseError(
@@ -193,7 +190,7 @@ class Prefs {
}
$gid = Subjects::GetSubjId($group);
if (PEAR::isError($gid)) {
- return $gid;
+ return $gid;
}
if (is_null($gid)) {
return PEAR::raiseError(
@@ -201,7 +198,7 @@ class Prefs {
}
$memb = Subjects::IsMemberOf($uid, $gid);
if (PEAR::isError($memb)) {
- return $memb;
+ return $memb;
}
if (!$memb) {
return PEAR::raiseError(
@@ -209,12 +206,12 @@ class Prefs {
}
$r = $this->update($gid, $key, $value);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
if ($r === FALSE) {
$r = $this->insert($gid, $key, $value);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
}
return TRUE;
@@ -235,7 +232,7 @@ class Prefs {
{
$uid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($uid)) {
- return $uid;
+ return $uid;
}
if (is_null($uid)) {
return PEAR::raiseError(
@@ -243,7 +240,7 @@ class Prefs {
}
$gid = Subjects::GetSubjId($group);
if (PEAR::isError($gid)) {
- return $gid;
+ return $gid;
}
if (is_null($gid)) {
return PEAR::raiseError(
@@ -251,7 +248,7 @@ class Prefs {
}
$memb = Subjects::IsMemberOf($uid, $gid);
if (PEAR::isError($memb)) {
- return $memb;
+ return $memb;
}
if (!$memb) {
return PEAR::raiseError(
@@ -259,7 +256,7 @@ class Prefs {
}
$r = $this->delete($gid, $key);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
if ($r === FALSE) {
return PEAR::raiseError(
@@ -287,7 +284,7 @@ class Prefs {
global $CC_CONFIG, $CC_DBC;
$id = $CC_DBC->nextId($CC_CONFIG['prefSequence']);
if (PEAR::isError($id)) {
- return $id;
+ return $id;
}
$r = $CC_DBC->query("
INSERT INTO ".$CC_CONFIG['prefTable']."
@@ -296,7 +293,7 @@ class Prefs {
($id, $subjid, '$keystr', '$valstr')
");
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return $id;
}
@@ -320,10 +317,10 @@ class Prefs {
WHERE subjid=$subjid AND keystr='$keystr'
");
if (PEAR::isError($val)) {
- return $val;
+ return $val;
}
if (is_null($val)) {
- return FALSE;
+ return FALSE;
}
return $val;
}
@@ -345,10 +342,10 @@ class Prefs {
WHERE subjid=$subjid
");
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
if (is_null($res)) {
- return FALSE;
+ return FALSE;
}
return $res;
}
@@ -374,10 +371,10 @@ class Prefs {
WHERE subjid=$subjid AND keystr='$keystr'
");
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
if ($CC_DBC->affectedRows() < 1) {
- return FALSE;
+ return FALSE;
}
return TRUE;
}
@@ -400,10 +397,10 @@ class Prefs {
WHERE subjid=$subjid AND keystr='$keystr'
");
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
if ($CC_DBC->affectedRows() < 1) {
- return FALSE;
+ return FALSE;
}
return TRUE;
}
@@ -422,7 +419,7 @@ class Prefs {
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
$r = savePref($sessid, $testKey, $testVal);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$val = loadPref($sessid, $testKey);
if ($val != $testVal) {
@@ -431,7 +428,7 @@ class Prefs {
}
$r = savePref($sessid, $testKey, '');
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$val = loadPref($sessid, $testKey);
if ($val != $testVal) {
diff --git a/application/models/Renderer.php b/application/models/Renderer.php
index 720d71397..81d636b70 100644
--- a/application/models/Renderer.php
+++ b/application/models/Renderer.php
@@ -35,12 +35,12 @@ class Renderer
// recall playlist:
$pl = StoredFile::RecallByGunid($plid);
if (is_null($pl) || PEAR::isError($pl)) {
- return $pl;
+ return $pl;
}
// smil export:
$smil = $pl->outputToSmil();
if (PEAR::isError($smil)) {
- return $smil;
+ return $smil;
}
// temporary file for smil:
$tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_');
@@ -56,7 +56,7 @@ class Renderer
// open access to output file: /*gunid*/ /*parent*/
$acc = BasicStor::bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
if (PEAR::isError($acc)) {
- return $acc;
+ return $acc;
}
extract($acc);
$statf = Renderer::getStatusFile($gb, $token);
@@ -70,7 +70,7 @@ class Renderer
if ($res === FALSE) {
return PEAR::raiseError(
'Renderer::rnRender2File: Error running renderer'
- );
+ );
}
return array('token'=>$token);
}
@@ -93,7 +93,7 @@ class Renderer
if (!file_exists($statf)) {
return PEAR::raiseError(
'Renderer::rnRender2FileCheck: Invalid token'
- );
+ );
}
$status = trim(file_get_contents($statf));
$url = Renderer::getUrl($gb, $token);
@@ -142,7 +142,7 @@ class Renderer
global $CC_CONFIG;
$r = BasicStor::bsRelease($token, 'render');
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$realOgg = $r['realFname'];
$tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT);
@@ -171,7 +171,7 @@ class Renderer
{
$r = Renderer::rnRender2FileCheck($gb, $token);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$status = $r['status'];
$res = array('status' => $status, 'gunid'=>'NULL');
@@ -182,7 +182,7 @@ class Renderer
case "success":
$r = Renderer::rnRender2StorageCore($gb, $token);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$res['gunid'] = $r['gunid'];
break;
@@ -205,36 +205,36 @@ class Renderer
*/
function rnRender2StorageCore(&$gb, $token)
{
-// $r = BasicStor::bsRelease($token, 'render');
-// if (PEAR::isError($r)) {
-// return $r;
-// }
-// $realOgg = $r['realFname'];
-// $owner = $r['owner'];
-// $gunid = $r['gunid'];
-// $fileName = 'rendered_playlist';
-// $id = BasicStor::IdFromGunid($gunid);
-// if (PEAR::isError($id)) {
-// return $id;
-// }
-// $mdata = '';
-// foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
-// $val = $gb->bsGetMetadataValue($id, $item);
-// $mdata .= " <$item>$val$item>\n";
-// }
-// $mdata = "
";var_dump($data);
- $playlists = array();
- if (is_array($data) && count($data) > 0)
- {
- foreach ($data as $dx)
- {
- // Is this the first item in the playlist?
- $start = $dx['start'];
- // chop off subseconds
- $start = substr($start, 0, 19);
+ /**
+ * Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
+ * Note: currently only supports calculating millisec differences.
+ *
+ * @param string $p_time1
+ * @param string $p_time2
+ * @return double
+ */
+ private static function TimeDiff($p_time1, $p_time2)
+ {
+ $parts1 = explode(".", $p_time1);
+ $parts2 = explode(".", $p_time2);
+ $diff = 0;
+ if ( (count($parts1) > 1) && (count($parts2) > 1) ) {
+ $millisec1 = substr($parts1[1], 0, 3);
+ $millisec1 = str_pad($millisec1, 3, "0");
+ $millisec1 = intval($millisec1);
+ $millisec2 = substr($parts2[1], 0, 3);
+ $millisec2 = str_pad($millisec2, 3, "0");
+ $millisec2 = intval($millisec2);
+ $diff = abs(millisec1 - millisec2)/1000;
+ }
+ return $diff;
+ }
- // Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
- $pkey = Schedule::CcTimeToPypoTime($start);
- $timestamp = strtotime($start);
- $playlists[$pkey]['source'] = "PLAYLIST";
- $playlists[$pkey]['x_ident'] = $dx["playlist_id"];
- $playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
- $playlists[$pkey]['timestamp'] = $timestamp;
- $playlists[$pkey]['duration'] = $dx['clip_length'];
- $playlists[$pkey]['played'] = '0';
- $playlists[$pkey]['schedule_id'] = $dx['group_id'];
- }
- }
- foreach ($playlists as &$playlist)
- {
- $scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
- $items = $scheduleGroup->getItems();
- $medias = array();
- $playlist['subtype'] = '1';
- foreach ($items as $item)
- {
- $storedFile = StoredFile::Recall($item["file_id"]);
- $uri = $storedFile->getFileUrl();
- $medias[] = array(
+ /**
+ * Export the schedule in json formatted for pypo (the liquidsoap scheduler)
+ *
+ * @param string $range
+ * In the format "YYYY-MM-DD HH:mm:ss"
+ * @param string $source
+ * In the format "YYYY-MM-DD HH:mm:ss"
+ */
+ public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
+ {
+ global $CC_CONFIG, $CC_DBC;
+ $range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
+ $range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
+ $range_dt = array('start' => $range_start, 'end' => $range_end);
+ //var_dump($range_dt);
+
+ // Scheduler wants everything in a playlist
+ $data = Schedule::GetItems($range_start, $range_end, true);
+ //echo "";var_dump($data);
+ $playlists = array();
+
+ if (is_array($data) && count($data) > 0)
+ {
+ foreach ($data as $dx)
+ {
+ // Is this the first item in the playlist?
+ $start = $dx['start'];
+ // chop off subseconds
+ $start = substr($start, 0, 19);
+
+ // Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
+ $pkey = Schedule::CcTimeToPypoTime($start);
+ $timestamp = strtotime($start);
+ $playlists[$pkey]['source'] = "PLAYLIST";
+ $playlists[$pkey]['x_ident'] = $dx["playlist_id"];
+ $playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
+ $playlists[$pkey]['timestamp'] = $timestamp;
+ $playlists[$pkey]['duration'] = $dx['clip_length'];
+ $playlists[$pkey]['played'] = '0';
+ $playlists[$pkey]['schedule_id'] = $dx['group_id'];
+ $playlists[$pkey]['user_id'] = 0;
+ $playlists[$pkey]['id'] = $dx["playlist_id"];
+ $playlists[$pkey]['start'] = Schedule::CcTimeToPypoTime($dx["start"]);
+ $playlists[$pkey]['end'] = Schedule::CcTimeToPypoTime($dx["end"]);
+ }
+ }
+
+ foreach ($playlists as &$playlist)
+ {
+ $scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
+ $items = $scheduleGroup->getItems();
+ $medias = array();
+ $playlist['subtype'] = '1';
+ foreach ($items as $item)
+ {
+ $storedFile = StoredFile::Recall($item["file_id"]);
+ $uri = $storedFile->getFileUrl();
+
+ // For pypo, a cueout of zero means no cueout
+ $cueOut = "0";
+ if (Schedule::TimeDiff($item["cue_out"], $item["clip_length"]) > 0.001) {
+ $cueOut = Schedule::WallTimeToMillisecs($item["cue_out"]);
+ }
+ $medias[] = array(
'id' => $storedFile->getGunid(), //$item["file_id"],
'uri' => $uri,
- 'fade_in' => $item["fade_in"],
- 'fade_out' => $item["fade_out"],
+ 'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]),
+ 'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]),
'fade_cross' => 0,
- 'cue_in' => $item["cue_in"],
- 'cue_out' => $item["cue_out"],
- );
- }
- $playlist['medias'] = $medias;
- }
+ 'cue_in' => Schedule::WallTimeToMillisecs($item["cue_in"]),
+ 'cue_out' => $cueOut,
+ 'export_source' => 'scheduler'
+ );
+ }
+ $playlist['medias'] = $medias;
+ }
- $result = array();
- $result['status'] = array('range' => $range_dt, 'version' => 0.2);
- $result['playlists'] = $playlists;
- $result['check'] = 1;
+ $result = array();
+ $result['status'] = array('range' => $range_dt, 'version' => "0.2");
+ $result['playlists'] = $playlists;
+ $result['check'] = 1;
- print json_encode($result);
- }
+ print json_encode($result);
+ }
+
+
+ /**
+ * Remove all items from the schedule in the given range.
+ *
+ * @param string $p_start
+ * In the format YYYY-MM-DD HH:MM:SS.nnnnnn
+ * @param string $p_end
+ * In the format YYYY-MM-DD HH:MM:SS.nnnnnn
+ */
+ public static function RemoveItemsInRange($p_start, $p_end)
+ {
+ $items = Schedule::GetItems($p_start, $p_end);
+ foreach ($items as $item) {
+ $scheduleGroup = new ScheduleGroup($item["group_id"]);
+ $scheduleGroup->remove();
+ }
+ }
}
diff --git a/application/models/SmilPlaylist.php b/application/models/SmilPlaylist.php
index dc4ca7f78..739667dc8 100644
--- a/application/models/SmilPlaylist.php
+++ b/application/models/SmilPlaylist.php
@@ -58,24 +58,24 @@ class SmilPlaylist {
}
$lspl = SmilPlaylist::convert2lspl($gb, $path, $gunids, $parr);
if (PEAR::isError($lspl)) {
- return $lspl;
+ return $lspl;
}
require_once("Playlist.php");
$pl =& Playlist::create($gb, $plid, "imported_SMIL");
if (PEAR::isError($pl)) {
- return $pl;
+ return $pl;
}
$r = $pl->lock($gb, $subjid);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$r = $pl->setMetadata($lspl, 'string', 'playlist');
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$r = $pl->unlock($gb);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return $pl;
}
@@ -99,7 +99,7 @@ class SmilPlaylist {
extract($parr);
$tree = SmilPlaylist::parse($data);
if (PEAR::isError($tree)) {
- return $tree;
+ return $tree;
}
if ($tree->name != 'smil') {
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
@@ -107,11 +107,11 @@ class SmilPlaylist {
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag smil",
- $tree->children[1]->name
+ $tree->children[1]->name
));
}
$res = SmilPlaylistBodyElement::convert2lspl(
- $gb, $tree->children[0], &$gunids, $parr);
+ $gb, $tree->children[0], &$gunids, $parr);
return $res;
}
@@ -136,13 +136,13 @@ class SmilPlaylistBodyElement {
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag body",
- $tree->children[1]->name
+ $tree->children[1]->name
));
}
$res = SmilPlaylistParElement::convert2lspl(
- $gb, $tree->children[0], &$gunids, $parr, $ind2);
+ $gb, $tree->children[0], &$gunids, $parr, $ind2);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
$title = basename($rPath);
$playlength = '0';
@@ -165,7 +165,7 @@ class SmilPlaylistBodyElement {
*/
class SmilPlaylistParElement {
- public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
+ public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
if ($tree->name != 'par') {
@@ -176,7 +176,7 @@ class SmilPlaylistParElement {
$ch =& $tree->children[$i];
$r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$res .= $r;
}
@@ -204,7 +204,7 @@ class SmilPlaylistAudioElement {
if (isset($tree->children[2])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag audio",
- $tree->children[2]->name
+ $tree->children[2]->name
));
}
$res = ''; $fadeIn = 0; $fadeOut = 0;
@@ -212,7 +212,7 @@ class SmilPlaylistAudioElement {
$ch =& $tree->children[$i];
$r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
switch ($r['type']) {
case "fadeIn": $fadeIn = $r['val']; break;
@@ -225,7 +225,7 @@ class SmilPlaylistAudioElement {
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
$fInfo = "$ind2\n";
} else {
- $fInfo = '';
+ $fInfo = '';
}
$plElGunid = StoredFile::CreateGunid();
$acGunid = $gunid;
@@ -238,19 +238,19 @@ class SmilPlaylistAudioElement {
case "m3u":
$type = 'playlist';
$acId = $gb->bsImportPlaylistRaw($gunid,
- $aPath, $uri, $ext, $gunids, $subjid);
+ $aPath, $uri, $ext, $gunids, $subjid);
if (PEAR::isError($acId)) {
- return $r;
+ return $r;
}
- //break;
+ //break;
default:
$ac = StoredFile::RecallByGunid($gunid);
if (is_null($ac) || PEAR::isError($ac)) {
- return $ac;
+ return $ac;
}
$r = $ac->md->getMetadataElement('dcterms:extent');
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$playlength = $r[0]['value'];
}
@@ -263,7 +263,7 @@ class SmilPlaylistAudioElement {
$clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val);
$res = "$ind\n".
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
- $fInfo.
+ $fInfo.
"$ind \n";
return $res;
}
@@ -278,35 +278,35 @@ class SmilPlaylistAudioElement {
*/
class SmilPlaylistAnimateElement {
- public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
- {
+ public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
+ {
extract($parr);
if ($tree->name != 'animate') {
return PEAR::raiseError("SmilPlaylist::parse: animate tag expected");
}
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
- $tree->attrs['from']->val == '0%' &&
- $tree->attrs['to']->val == '100%' &&
- $tree->attrs['calcMode']->val == 'linear' &&
- $tree->attrs['fill']->val == 'freeze' &&
- $tree->attrs['begin']->val == '0s' &&
- preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
+ $tree->attrs['from']->val == '0%' &&
+ $tree->attrs['to']->val == '100%' &&
+ $tree->attrs['calcMode']->val == 'linear' &&
+ $tree->attrs['fill']->val == 'freeze' &&
+ $tree->attrs['begin']->val == '0s' &&
+ preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
) {
return array('type'=>'fadeIn', 'val'=>intval($va[1]));
}
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
- $tree->attrs['from']->val == '100%' &&
- $tree->attrs['to']->val == '0%' &&
- $tree->attrs['calcMode']->val == 'linear' &&
- $tree->attrs['fill']->val == 'freeze' &&
- preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
- preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
+ $tree->attrs['from']->val == '100%' &&
+ $tree->attrs['to']->val == '0%' &&
+ $tree->attrs['calcMode']->val == 'linear' &&
+ $tree->attrs['fill']->val == 'freeze' &&
+ preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
+ preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
) {
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
}
return PEAR::raiseError(
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
- );
+ );
}
} // class SmilPlaylistAnimateElement
diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php
index 474445193..052885be6 100644
--- a/application/models/StoredFile.php
+++ b/application/models/StoredFile.php
@@ -1,26 +1,25 @@
"format",
"ls:bitrate" => "bit_rate",
- "ls:samplerate" => "sample_rate",
+ "ls:samplerate" => "sample_rate",
"dcterms:extent" => "length",
- "dc:title" => "track_title",
- "dc:description" => "comments",
- "dc:type" => "genre",
- "dc:creator" => "artist_name",
+ "dc:title" => "track_title",
+ "dc:description" => "comments",
+ "dc:type" => "genre",
+ "dc:creator" => "artist_name",
"dc:source" => "album_title",
- "ls:channels" => "channels",
- "ls:filename" => "name",
- "ls:year" => "year",
- "ls:url" => "url",
- "ls:track_num" => "track_number",
+ "ls:channels" => "channels",
+ "ls:filename" => "name",
+ "ls:year" => "year",
+ "ls:url" => "url",
+ "ls:track_num" => "track_number",
"ls:mood" => "mood",
"ls:bpm" => "bpm",
"ls:disc_num" => "disc_number",
@@ -148,118 +147,118 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
$getID3 = new getID3();
$infoFromFile = $getID3->analyze($p_filename);
if (PEAR::isError($infoFromFile)) {
- return $infoFromFile;
+ return $infoFromFile;
}
if (isset($infoFromFile['error'])) {
- return new PEAR_Error(array_pop($infoFromFile['error']));
+ return new PEAR_Error(array_pop($infoFromFile['error']));
}
if (!$infoFromFile['bitrate']) {
- return new PEAR_Error("File given is not an audio file.");
+ return new PEAR_Error("File given is not an audio file.");
}
if ($p_testonly) {
- print_r($infoFromFile);
+ print_r($infoFromFile);
}
- $titleKey = 'dc:title';
- $flds = array(
- 'dc:format' => array(
- array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE),
- ),
- 'ls:bitrate' => array(
- array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE),
- array('path'=>"['audio']['bitrate']", 'ignoreEnc'=>TRUE),
- ),
- 'ls:samplerate' => array(
- array('path'=>"['audio']['sample_rate']", 'ignoreEnc'=>TRUE),
- ),
- 'ls:encoder' => array(
- array('path'=>"['audio']['codec']", 'ignoreEnc'=>TRUE),
- ),
- 'dcterms:extent'=> array(
- array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE),
- ),
- 'ls:composer'=> array(
- array('path'=>"['id3v2']['comments']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
- array('path'=>"['id3v2']['TCOM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['id3v2']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
- array('path'=>"['ogg']['comments']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'dc:description'=> array(
- array('path'=>"['id3v1']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['comments']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
- array('path'=>"['id3v2']['COMM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['id3v2']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
- array('path'=>"['ogg']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'dc:type'=> array(
- array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
- array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'dc:title' => array(
- array('path'=>"['id3v2']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"),
- array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'dc:creator' => array(
- array('path'=>"['id3v2']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"),
- array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'dc:source' => array(
- array('path'=>"['id3v2']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['ogg']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'ls:encoded_by' => array(
- array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'ls:track_num' => array(
- array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
- array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
-// 'ls:genre' => array(
-// array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
-// array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
-// array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
-// array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
-// array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
-// ),
- 'ls:channels' => array(
- array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE),
- ),
- 'ls:year' => array(
- array('path'=>"['comments']['date']"),
- array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
- ),
- 'ls:filename' => array(
- array('path'=>"['filename']"),
- ),
- );
+ $titleKey = 'dc:title';
+ $flds = array(
+ 'dc:format' => array(
+ array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE),
+ ),
+ 'ls:bitrate' => array(
+ array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE),
+ array('path'=>"['audio']['bitrate']", 'ignoreEnc'=>TRUE),
+ ),
+ 'ls:samplerate' => array(
+ array('path'=>"['audio']['sample_rate']", 'ignoreEnc'=>TRUE),
+ ),
+ 'ls:encoder' => array(
+ array('path'=>"['audio']['codec']", 'ignoreEnc'=>TRUE),
+ ),
+ 'dcterms:extent'=> array(
+ array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE),
+ ),
+ 'ls:composer'=> array(
+ array('path'=>"['id3v2']['comments']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
+ array('path'=>"['id3v2']['TCOM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['id3v2']['composer']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
+ array('path'=>"['ogg']['comments']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['composer']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'dc:description'=> array(
+ array('path'=>"['id3v1']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['comments']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
+ array('path'=>"['id3v2']['COMM'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['id3v2']['comments']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
+ array('path'=>"['ogg']['comments']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['comment']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'dc:type'=> array(
+ array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
+ array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'dc:title' => array(
+ array('path'=>"['id3v2']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"),
+ array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'dc:creator' => array(
+ array('path'=>"['id3v2']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"),
+ array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'dc:source' => array(
+ array('path'=>"['id3v2']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['ogg']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'ls:encoded_by' => array(
+ array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'ls:track_num' => array(
+ array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ // 'ls:genre' => array(
+ // array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
+ // array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
+ // array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
+ // array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ // array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ // ),
+ 'ls:channels' => array(
+ array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE),
+ ),
+ 'ls:year' => array(
+ array('path'=>"['comments']['date']"),
+ array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
+ ),
+ 'ls:filename' => array(
+ array('path'=>"['filename']"),
+ ),
+ );
$mdata = array();
if (isset($infoFromFile['audio'])) {
- $mdata['audio'] = $infoFromFile['audio'];
+ $mdata['audio'] = $infoFromFile['audio'];
}
if (isset($infoFromFile['playtime_seconds'])) {
- $mdata['playtime_seconds'] = $infoFromFile['playtime_seconds'];
+ $mdata['playtime_seconds'] = $infoFromFile['playtime_seconds'];
}
$titleHaveSet = FALSE;
@@ -267,7 +266,7 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
foreach ($getid3keys as $getid3key) {
$path = $getid3key["path"];
$ignoreEnc = isset($getid3key["ignoreEnc"])?
- $getid3key["ignoreEnc"]:FALSE;
+ $getid3key["ignoreEnc"]:FALSE;
$dataPath = isset($getid3key["dataPath"])?$getid3key["dataPath"]:"";
$encPath = isset($getid3key["encPath"])?$getid3key["encPath"]:"";
$enc = "UTF-8";
@@ -283,7 +282,7 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
$encodedElement = "\$infoFromFile$path$encPath";
eval("\$encodedElementExists = isset($encodedElement);");
if ($encodedElementExists) {
- eval("\$enc = $encodedElement;");
+ eval("\$enc = $encodedElement;");
}
}
@@ -292,19 +291,19 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
$data = camp_parse_track_number($data);
}
camp_add_metadata($mdata, $key, $data, $enc);
- if ($key == $titleKey) {
- $titleHaveSet = TRUE;
- }
+ if ($key == $titleKey) {
+ $titleHaveSet = TRUE;
+ }
break;
}
}
}
if ($p_testonly) {
- var_dump($mdata);
+ var_dump($mdata);
}
if (!$titleHaveSet || trim($mdata[$titleKey]) == '') {
- camp_add_metadata($mdata, $titleKey, basename($p_filename));
+ camp_add_metadata($mdata, $titleKey, basename($p_filename));
}
return $mdata;
}
@@ -330,96 +329,96 @@ class StoredFile {
// *** Variables stored in the database ***
- /**
- * @var int
- */
- private $id;
+ /**
+ * @var int
+ */
+ private $id;
- /**
- * Unique ID for the file. This is stored in HEX format. It is
- * converted to a bigint whenever it is used in a database call.
- *
- * @var string
- */
- public $gunid;
+ /**
+ * Unique ID for the file. This is stored in HEX format. It is
+ * converted to a bigint whenever it is used in a database call.
+ *
+ * @var string
+ */
+ public $gunid;
- /**
- * The unique ID of the file as it is stored in the database.
- * This is for debugging purposes and may not always exist in this
- * class.
- *
- * @var string
- */
- //private $gunidBigint;
+ /**
+ * The unique ID of the file as it is stored in the database.
+ * This is for debugging purposes and may not always exist in this
+ * class.
+ *
+ * @var string
+ */
+ //private $gunidBigint;
- /**
- * @var string
- */
- private $name;
+ /**
+ * @var string
+ */
+ private $name;
- /**
- * @var string
- */
- private $mime;
+ /**
+ * @var string
+ */
+ private $mime;
- /**
- * Can be 'audioclip'...others might be coming, like webstream.
- *
- * @var string
- */
- private $ftype;
+ /**
+ * Can be 'audioclip'...others might be coming, like webstream.
+ *
+ * @var string
+ */
+ private $ftype;
- /**
- * Can be 'ready', 'edited', 'incomplete'.
- *
- * @var string
- */
- private $state;
+ /**
+ * Can be 'ready', 'edited', 'incomplete'.
+ *
+ * @var string
+ */
+ private $state;
- /**
- * @var int
- */
- private $currentlyaccessing;
+ /**
+ * @var int
+ */
+ private $currentlyaccessing;
- /**
- * @var int
- */
- private $editedby;
+ /**
+ * @var int
+ */
+ private $editedby;
- /**
- * @var timestamp
- */
- private $mtime;
+ /**
+ * @var timestamp
+ */
+ private $mtime;
- /**
- * @var string
- */
- private $md5;
+ /**
+ * @var string
+ */
+ private $md5;
- /**
- * @var string
- */
- private $filepath;
+ /**
+ * @var string
+ */
+ private $filepath;
- // *** Variables NOT stored in the database ***
+ // *** Variables NOT stored in the database ***
- /**
- * Directory where the file is located.
- *
- * @var string
- */
- private $resDir;
+ /**
+ * Directory where the file is located.
+ *
+ * @var string
+ */
+ private $resDir;
- /**
- * @var boolean
- */
- private $exists;
+ /**
+ * @var boolean
+ */
+ private $exists;
- /**
- * @var MetaData
- */
- public $md;
+ /**
+ * @var MetaData
+ */
+ public $md;
/* ========================================================== constructor */
/**
@@ -435,8 +434,8 @@ class StoredFile {
$this->gunid = StoredFile::generateGunid();
}
else {
- $this->loadMetadata();
- $this->exists = is_file($this->filepath) && is_readable($this->filepath);
+ $this->loadMetadata();
+ $this->exists = is_file($this->filepath) && is_readable($this->filepath);
}
}
@@ -444,7 +443,7 @@ class StoredFile {
* For testing only, do not use.
*/
public function __setGunid($p_guid) {
- $this->gunid = $p_guid;
+ $this->gunid = $p_guid;
}
/**
@@ -491,7 +490,7 @@ class StoredFile {
global $CC_CONFIG, $CC_DBC;
$escapedValue = pg_escape_string($this->gunid);
$sql = "SELECT * FROM ".$CC_CONFIG["filesTable"]
- ." WHERE gunid='$escapedValue'";
+ ." WHERE gunid='$escapedValue'";
//var_dump($sql);
$this->md = $CC_DBC->getRow($sql);
//var_dump($this->md);
@@ -530,8 +529,8 @@ class StoredFile {
$columnName = StoredFile::xmlCategoryToDbColumn($category);
if (!is_null($columnName)) {
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
- ." SET $columnName='$escapedValue'"
- ." WHERE gunid = '".$this->gunid."'";
+ ." SET $columnName='$escapedValue'"
+ ." WHERE gunid = '".$this->gunid."'";
$CC_DBC->query($sql);
}
}
@@ -546,8 +545,8 @@ class StoredFile {
foreach ($metadataColumns as $columnName) {
if (!is_null($columnName)) {
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
- ." SET $columnName=''"
- ." WHERE gunid = '".$this->gunid."'";
+ ." SET $columnName=''"
+ ." WHERE gunid = '".$this->gunid."'";
$CC_DBC->query($sql);
}
}
@@ -577,7 +576,7 @@ class StoredFile {
global $CC_CONFIG, $CC_DBC;
if (!isset($p_values["filepath"])) {
- return new PEAR_Error("StoredFile::Insert: filepath not set.");
+ return new PEAR_Error("StoredFile::Insert: filepath not set.");
}
if (!file_exists($p_values['filepath'])) {
return PEAR::raiseError("StoredFile::Insert: ".
@@ -591,16 +590,16 @@ class StoredFile {
// Get metadata
if (isset($p_values["metadata"])) {
- $metadata = $p_values['metadata'];
+ $metadata = $p_values['metadata'];
} else {
- $metadata = camp_get_audio_metadata($p_values["filepath"]);
+ $metadata = camp_get_audio_metadata($p_values["filepath"]);
}
$storedFile->name = isset($p_values['filename']) ? $p_values['filename'] : $p_values["filepath"];
- $storedFile->id = isset($p_values['id']) && is_integer($p_values['id'])?(int)$p_values['id']:null;
+ $storedFile->id = isset($p_values['id']) && is_integer($p_values['id'])?(int)$p_values['id']:null;
// NOTE: POSTGRES-SPECIFIC KEYWORD "DEFAULT" BEING USED, WOULD BE "NULL" IN MYSQL
- $sqlId = !is_null($storedFile->id)?"'".$storedFile->id."'":'DEFAULT';
- $storedFile->ftype = isset($p_values['filetype']) ? strtolower($p_values['filetype']) : "audioclip";
+ $sqlId = !is_null($storedFile->id)?"'".$storedFile->id."'":'DEFAULT';
+ $storedFile->ftype = isset($p_values['filetype']) ? strtolower($p_values['filetype']) : "audioclip";
$storedFile->mime = (isset($p_values["mime"]) ? $p_values["mime"] : NULL );
// $storedFile->filepath = $p_values['filepath'];
if (isset($p_values['md5'])) {
@@ -613,7 +612,7 @@ class StoredFile {
// Check for duplicates -- return duplicate
$duplicate = StoredFile::RecallByMd5($storedFile->md5);
if ($duplicate) {
- return $duplicate;
+ return $duplicate;
}
$storedFile->exists = FALSE;
@@ -622,11 +621,11 @@ class StoredFile {
$escapedName = pg_escape_string($storedFile->name);
$escapedFtype = pg_escape_string($storedFile->ftype);
$sql = "INSERT INTO ".$CC_CONFIG['filesTable']
- ."(id, name, gunid, mime, state, ftype, mtime, md5)"
- ."VALUES ({$sqlId}, '{$escapedName}', "
- ." '{$storedFile->gunid}',"
- ." '{$storedFile->mime}', 'incomplete', '$escapedFtype',"
- ." now(), '{$storedFile->md5}')";
+ ."(id, name, gunid, mime, state, ftype, mtime, md5)"
+ ."VALUES ({$sqlId}, '{$escapedName}', "
+ ." '{$storedFile->gunid}',"
+ ." '{$storedFile->mime}', 'incomplete', '$escapedFtype',"
+ ." now(), '{$storedFile->md5}')";
//$_SESSION["debug"] .= "sql: ".$sql."
";
//echo $sql."\n";
$res = $CC_DBC->query($sql);
@@ -636,9 +635,9 @@ class StoredFile {
}
if (!is_integer($storedFile->id)) {
- // NOTE: POSTGRES-SPECIFIC
- $sql = "SELECT currval('".$CC_CONFIG["filesSequence"]."_seq')";
- $storedFile->id = $CC_DBC->getOne($sql);
+ // NOTE: POSTGRES-SPECIFIC
+ $sql = "SELECT currval('".$CC_CONFIG["filesSequence"]."_seq')";
+ $storedFile->id = $CC_DBC->getOne($sql);
}
$storedFile->setMetadataBatch($metadata);
@@ -690,8 +689,8 @@ class StoredFile {
return null;
}
$sql = "SELECT *"
- ." FROM ".$CC_CONFIG['filesTable']
- ." WHERE $cond";
+ ." FROM ".$CC_CONFIG['filesTable']
+ ." WHERE $cond";
//echo $sql;
$row = $CC_DBC->getRow($sql);
if (PEAR::isError($row) || is_null($row)) {
@@ -753,8 +752,8 @@ class StoredFile {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT gunid"
- ." FROM ".$CC_CONFIG['accessTable']
- ." WHERE token=x'$p_token'::bigint";
+ ." FROM ".$CC_CONFIG['accessTable']
+ ." WHERE token=x'$p_token'::bigint";
$gunid = $CC_DBC->getOne($sql);
if (PEAR::isError($gunid)) {
return $gunid;
@@ -798,7 +797,7 @@ class StoredFile {
{
global $CC_CONFIG, $CC_DBC;
if ($this->exists) {
- return FALSE;
+ return FALSE;
}
// for files downloaded from remote instance:
if ($p_localFilePath == $this->filepath) {
@@ -825,8 +824,8 @@ class StoredFile {
$this->filepath = $dstFile;
$sqlPath = pg_escape_string($this->filepath);
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
- ." SET filepath='{$sqlPath}'"
- ." WHERE id={$this->id}";
+ ." SET filepath='{$sqlPath}'"
+ ." WHERE id={$this->id}";
//echo $sql."\n";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
@@ -837,6 +836,25 @@ class StoredFile {
}
+ /**
+ * Find and return the first exact match for the original file name
+ * that was used on import.
+ * @param string $p_name
+ */
+ public static function findByOriginalName($p_name)
+ {
+ global $CC_CONFIG, $CC_DBC;
+ $sql = "SELECT id FROM ".$CC_CONFIG["filesTable"]
+ ." WHERE name='".pg_escape_string($p_name)."'";
+ $id = $CC_DBC->getOne($sql);
+ if (is_numeric($id)) {
+ return StoredFile::Recall($id);
+ } else {
+ return NULL;
+ }
+ }
+
+
/**
* Delete and insert media file
*
@@ -853,9 +871,9 @@ class StoredFile {
}
if ($this->exists) {
- $r = $this->deleteFile();
+ $r = $this->deleteFile();
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
}
return $this->addFile($p_localFilePath);
@@ -885,19 +903,19 @@ class StoredFile {
{
global $CC_CONFIG;
if (!$this->exists) {
- return FALSE;
+ return FALSE;
}
if ($this->isAccessed()) {
- return PEAR::raiseError(
+ return PEAR::raiseError(
'Cannot delete a file that is currently accessed.'
- );
+ );
}
// Check if the file is scheduled to be played in the future
if (Schedule::IsFileScheduledInTheFuture($this->id)) {
- return PEAR::raiseError(
+ return PEAR::raiseError(
'Cannot delete a file that is scheduled in the future.'
- );
+ );
}
// Delete it from all playlists
@@ -913,12 +931,12 @@ class StoredFile {
} else {
return PEAR::raiseError(
"StoredFile::deleteFile: unlink failed ({$this->filepath})",
- GBERR_FILEIO
+ GBERR_FILEIO
);
}
} else {
- $this->exists = FALSE;
- return TRUE;
+ $this->exists = FALSE;
+ return TRUE;
}
}
@@ -934,7 +952,7 @@ class StoredFile {
public function analyzeFile()
{
if (!$this->exists) {
- return FALSE;
+ return FALSE;
}
$ia = camp_get_audio_metadata($this->filepath);
return $ia;
@@ -955,7 +973,7 @@ class StoredFile {
$values = array(
"id" => $p_nid,
"filename" => $p_src->name,
- "filepath" => $p_src->getRealFileName(),
+ "filepath" => $p_src->getRealFilePath(),
"filetype" => $p_src->getType()
);
$storedFile = StoredFile::Insert($values);
@@ -982,42 +1000,42 @@ class StoredFile {
* 'file'|'string'
* @return TRUE|PEAR_Error
*/
-// public function replace($p_oid, $p_name, $p_localFilePath='', $p_metadata='',
-// $p_mdataLoc='file')
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $CC_DBC->query("BEGIN");
-// $res = $this->setName($p_name);
-// if (PEAR::isError($res)) {
-// $CC_DBC->query("ROLLBACK");
-// return $res;
-// }
-// if ($p_localFilePath != '') {
-// $res = $this->setRawMediaData($p_localFilePath);
-// } else {
-// $res = $this->deleteFile();
-// }
-// if (PEAR::isError($res)) {
-// $CC_DBC->query("ROLLBACK");
-// return $res;
-// }
-// if ($p_metadata != '') {
-// $res = $this->setMetadata($p_metadata, $p_mdataLoc);
-// } else {
-//// $res = $this->md->delete();
-// $res = $this->clearMetadata();
-// }
-// if (PEAR::isError($res)) {
-// $CC_DBC->query("ROLLBACK");
-// return $res;
-// }
-// $res = $CC_DBC->query("COMMIT");
-// if (PEAR::isError($res)) {
-// $CC_DBC->query("ROLLBACK");
-// return $res;
-// }
-// return TRUE;
-// }
+ // public function replace($p_oid, $p_name, $p_localFilePath='', $p_metadata='',
+ // $p_mdataLoc='file')
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // $CC_DBC->query("BEGIN");
+ // $res = $this->setName($p_name);
+ // if (PEAR::isError($res)) {
+ // $CC_DBC->query("ROLLBACK");
+ // return $res;
+ // }
+ // if ($p_localFilePath != '') {
+ // $res = $this->setRawMediaData($p_localFilePath);
+ // } else {
+ // $res = $this->deleteFile();
+ // }
+ // if (PEAR::isError($res)) {
+ // $CC_DBC->query("ROLLBACK");
+ // return $res;
+ // }
+ // if ($p_metadata != '') {
+ // $res = $this->setMetadata($p_metadata, $p_mdataLoc);
+ // } else {
+ //// $res = $this->md->delete();
+ // $res = $this->clearMetadata();
+ // }
+ // if (PEAR::isError($res)) {
+ // $CC_DBC->query("ROLLBACK");
+ // return $res;
+ // }
+ // $res = $CC_DBC->query("COMMIT");
+ // if (PEAR::isError($res)) {
+ // $CC_DBC->query("ROLLBACK");
+ // return $res;
+ // }
+ // return TRUE;
+ // }
/**
@@ -1030,14 +1048,14 @@ class StoredFile {
*/
public function accessRawMediaData($p_parent='0')
{
- $realFname = $this->getRealFileName();
+ $realFname = $this->getRealFilePath();
$ext = $this->getFileExtension();
$res = BasicStor::bsAccess($realFname, $ext, $this->gunid, 'access', $p_parent);
if (PEAR::isError($res)) {
return $res;
}
$resultArray =
- array('url'=>"file://{$res['fname']}", 'token'=>$res['token']);
+ array('url'=>"file://{$res['fname']}", 'token'=>$res['token']);
return $resultArray;
}
@@ -1079,10 +1097,10 @@ class StoredFile {
return $res;
}
}
-// $r = $this->md->regenerateXmlFile();
-// if (PEAR::isError($r)) {
-// return $r;
-// }
+ // $r = $this->md->regenerateXmlFile();
+ // if (PEAR::isError($r)) {
+ // return $r;
+ // }
return TRUE;
}
@@ -1111,21 +1129,21 @@ class StoredFile {
* (NULL = no validation)
* @return boolean
*/
-// public function setMetadata($p_metadata, $p_mdataLoc='file', $p_format=NULL)
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $CC_DBC->query("BEGIN");
-// $res = $this->md->replace($p_metadata, $p_mdataLoc, $p_format);
-// if (PEAR::isError($res)) {
-// $CC_DBC->query("ROLLBACK");
-// return $res;
-// }
-// $res = $CC_DBC->query("COMMIT");
-// if (PEAR::isError($res)) {
-// return $res;
-// }
-// return TRUE;
-// }
+ // public function setMetadata($p_metadata, $p_mdataLoc='file', $p_format=NULL)
+ // {
+ // global $CC_CONFIG, $CC_DBC;
+ // $CC_DBC->query("BEGIN");
+ // $res = $this->md->replace($p_metadata, $p_mdataLoc, $p_format);
+ // if (PEAR::isError($res)) {
+ // $CC_DBC->query("ROLLBACK");
+ // return $res;
+ // }
+ // $res = $CC_DBC->query("COMMIT");
+ // if (PEAR::isError($res)) {
+ // return $res;
+ // }
+ // return TRUE;
+ // }
/**
* Set metadata element value
@@ -1138,27 +1156,27 @@ class StoredFile {
*/
public function setMetadataValue($p_category, $p_value)
{
- global $CC_CONFIG, $CC_DBC;
- if (!is_string($p_category) || is_array($p_value)) {
- return FALSE;
- }
- if ($p_category == 'dcterms:extent') {
- $p_value = StoredFile::NormalizeExtent($p_value);
- }
- $columnName = StoredFile::xmlCategoryToDbColumn($p_category); // Get column name
-
- if (!is_null($columnName)) {
- $escapedValue = pg_escape_string($p_value);
- $sql = "UPDATE ".$CC_CONFIG["filesTable"]
- ." SET $columnName='$escapedValue'"
- ." WHERE id={$this->id}";
- //var_dump($sql);
- $res = $CC_DBC->query($sql);
- if (PEAR::isError($res)) {
- return $res;
+ global $CC_CONFIG, $CC_DBC;
+ if (!is_string($p_category) || is_array($p_value)) {
+ return FALSE;
}
- }
- return TRUE;
+ if ($p_category == 'dcterms:extent') {
+ $p_value = StoredFile::NormalizeExtent($p_value);
+ }
+ $columnName = StoredFile::xmlCategoryToDbColumn($p_category); // Get column name
+
+ if (!is_null($columnName)) {
+ $escapedValue = pg_escape_string($p_value);
+ $sql = "UPDATE ".$CC_CONFIG["filesTable"]
+ ." SET $columnName='$escapedValue'"
+ ." WHERE id={$this->id}";
+ //var_dump($sql);
+ $res = $CC_DBC->query($sql);
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+ }
+ return TRUE;
}
@@ -1172,49 +1190,49 @@ class StoredFile {
*/
public function setMetadataBatch($values)
{
- global $CC_CONFIG, $CC_DBC;
- if (!is_array($values)) {
- $values = array($values);
- }
- if (count($values) == 0) {
- return true;
- }
- foreach ($values as $category => $oneValue) {
- $columnName = StoredFile::xmlCategoryToDbColumn($category);
- if (!is_null($columnName)) {
- if ($category == 'dcterms:extent') {
- $oneValue = StoredFile::NormalizeExtent($oneValue);
- }
- // Since track_number is an integer, you cannot set
- // it to be the empty string, so we NULL it instead.
- if ($columnName == 'track_number' && empty($oneValue)) {
- $sqlPart = "$columnName = NULL";
- } elseif (($columnName == 'length') && (strlen($oneValue) > 8)) {
- // Postgres doesnt like it if you try to store really large hour
- // values. TODO: We need to fix the underlying problem of getting the
- // right values.
- $parts = explode(':', $oneValue);
- $hour = intval($parts[0]);
- if ($hour > 24) {
- continue;
- } else {
- $sqlPart = "$columnName = '$oneValue'";
- }
- } else {
- $escapedValue = pg_escape_string($oneValue);
- $sqlPart = "$columnName = '$escapedValue'";
- }
- $sqlValues[] = $sqlPart;
+ global $CC_CONFIG, $CC_DBC;
+ if (!is_array($values)) {
+ $values = array($values);
}
- }
- if (count($sqlValues)==0) {
+ if (count($values) == 0) {
+ return true;
+ }
+ foreach ($values as $category => $oneValue) {
+ $columnName = StoredFile::xmlCategoryToDbColumn($category);
+ if (!is_null($columnName)) {
+ if ($category == 'dcterms:extent') {
+ $oneValue = StoredFile::NormalizeExtent($oneValue);
+ }
+ // Since track_number is an integer, you cannot set
+ // it to be the empty string, so we NULL it instead.
+ if ($columnName == 'track_number' && empty($oneValue)) {
+ $sqlPart = "$columnName = NULL";
+ } elseif (($columnName == 'length') && (strlen($oneValue) > 8)) {
+ // Postgres doesnt like it if you try to store really large hour
+ // values. TODO: We need to fix the underlying problem of getting the
+ // right values.
+ $parts = explode(':', $oneValue);
+ $hour = intval($parts[0]);
+ if ($hour > 24) {
+ continue;
+ } else {
+ $sqlPart = "$columnName = '$oneValue'";
+ }
+ } else {
+ $escapedValue = pg_escape_string($oneValue);
+ $sqlPart = "$columnName = '$escapedValue'";
+ }
+ $sqlValues[] = $sqlPart;
+ }
+ }
+ if (count($sqlValues)==0) {
+ return TRUE;
+ }
+ $sql = "UPDATE ".$CC_CONFIG["filesTable"]
+ ." SET ".join(",", $sqlValues)
+ ." WHERE id={$this->id}";
+ $CC_DBC->query($sql);
return TRUE;
- }
- $sql = "UPDATE ".$CC_CONFIG["filesTable"]
- ." SET ".join(",", $sqlValues)
- ." WHERE id={$this->id}";
- $CC_DBC->query($sql);
- return TRUE;
}
@@ -1236,11 +1254,11 @@ class StoredFile {
*/
public function getMetadataValue($p_name)
{
- if (isset($this->md[$p_name])){
- return $this->md[$p_name];
- } else {
- return "";
- }
+ if (isset($this->md[$p_name])){
+ return $this->md[$p_name];
+ } else {
+ return "";
+ }
}
/**
@@ -1254,8 +1272,8 @@ class StoredFile {
global $CC_CONFIG, $CC_DBC;
$escapedName = pg_escape_string($p_newname);
$sql = "UPDATE ".$CC_CONFIG['filesTable']
- ." SET name='$escapedName', mtime=now()"
- ." WHERE gunid='{$this->gunid}'";
+ ." SET name='$escapedName', mtime=now()"
+ ." WHERE gunid='{$this->gunid}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
@@ -1280,8 +1298,8 @@ class StoredFile {
$escapedState = pg_escape_string($p_state);
$eb = (!is_null($p_editedby) ? ", editedBy=$p_editedby" : '');
$sql = "UPDATE ".$CC_CONFIG['filesTable']
- ." SET state='$escapedState'$eb, mtime=now()"
- ." WHERE gunid='{$this->gunid}'";
+ ." SET state='$escapedState'$eb, mtime=now()"
+ ." WHERE gunid='{$this->gunid}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
@@ -1306,8 +1324,8 @@ class StoredFile {
}
$escapedMime = pg_escape_string($p_mime);
$sql = "UPDATE ".$CC_CONFIG['filesTable']
- ." SET mime='$escapedMime', mtime=now()"
- ." WHERE gunid='{$this->gunid}'";
+ ." SET mime='$escapedMime', mtime=now()"
+ ." WHERE gunid='{$this->gunid}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
@@ -1328,8 +1346,8 @@ class StoredFile {
global $CC_CONFIG, $CC_DBC;
$escapedMd5 = pg_escape_string($p_md5sum);
$sql = "UPDATE ".$CC_CONFIG['filesTable']
- ." SET md5='$escapedMd5', mtime=now()"
- ." WHERE gunid='{$this->gunid}'";
+ ." SET md5='$escapedMd5', mtime=now()"
+ ." WHERE gunid='{$this->gunid}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
@@ -1356,8 +1374,8 @@ class StoredFile {
}
}
$sql = "SELECT to_hex(token)as token, ext "
- ." FROM ".$CC_CONFIG['accessTable']
- ." WHERE gunid='{$this->gunid}'";
+ ." FROM ".$CC_CONFIG['accessTable']
+ ." WHERE gunid='{$this->gunid}'";
$tokens = $CC_DBC->getAll($sql);
if (is_array($tokens)) {
foreach ($tokens as $i => $item) {
@@ -1368,13 +1386,13 @@ class StoredFile {
}
}
$sql = "DELETE FROM ".$CC_CONFIG['accessTable']
- ." WHERE gunid='{$this->gunid}'";
+ ." WHERE gunid='{$this->gunid}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
}
$sql = "DELETE FROM ".$CC_CONFIG['filesTable']
- ." WHERE gunid='{$this->gunid}'";
+ ." WHERE gunid='{$this->gunid}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
@@ -1390,14 +1408,14 @@ class StoredFile {
public function getPlaylists() {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT playlist_id "
- ." FROM ".$CC_CONFIG['playistTable']
- ." WHERE file_id='{$this->id}'";
+ ." FROM ".$CC_CONFIG['playistTable']
+ ." WHERE file_id='{$this->id}'";
$ids = $CC_DBC->getAll($sql);
$playlists = array();
if (is_array($ids) && count($ids) > 0) {
- foreach ($ids as $id) {
- $playlists[] = Playlist::Recall($id);
- }
+ foreach ($ids as $id) {
+ $playlists[] = Playlist::Recall($id);
+ }
}
return $playlists;
}
@@ -1418,12 +1436,12 @@ class StoredFile {
return ($this->currentlyaccessing > 0);
}
$sql = "SELECT currentlyAccessing FROM ".$CC_CONFIG['filesTable']
- ." WHERE gunid='$p_gunid'";
+ ." WHERE gunid='$p_gunid'";
$ca = $CC_DBC->getOne($sql);
if (is_null($ca)) {
return PEAR::raiseError(
"StoredFile::isAccessed: invalid gunid ($p_gunid)",
- GBERR_FOBJNEX
+ GBERR_FOBJNEX
);
}
return ($ca > 0);
@@ -1465,7 +1483,7 @@ class StoredFile {
$p_playlistId = $this->gunid;
}
$sql = "SELECT editedBy FROM ".$CC_CONFIG['filesTable']
- ." WHERE gunid='$p_playlistId'";
+ ." WHERE gunid='$p_playlistId'";
$ca = $CC_DBC->getOne($sql);
if (PEAR::isError($ca)) {
return $ca;
@@ -1507,8 +1525,8 @@ class StoredFile {
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT gunid "
- ." FROM ".$CC_CONFIG['filesTable']
- ." WHERE gunid='{$this->gunid}'";
+ ." FROM ".$CC_CONFIG['filesTable']
+ ." WHERE gunid='{$this->gunid}'";
$indb = $CC_DBC->getRow($sql);
if (PEAR::isError($indb)) {
return $indb;
@@ -1529,15 +1547,15 @@ class StoredFile {
*/
public static function generateGunid()
{
- return md5(uniqid("", true));
+ return md5(uniqid("", true));
-// $ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
-// $initString = microtime().$ip.rand();
-// $hash = md5($initString);
-// // non-negative int8
-// $hsd = substr($hash, 0, 1);
-// $res = dechex(hexdec($hsd)>>1).substr($hash, 1, 15);
-// return StoredFile::NormalizeGunid($res);
+ // $ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
+ // $initString = microtime().$ip.rand();
+ // $hash = md5($initString);
+ // // non-negative int8
+ // $hsd = substr($hash, 0, 1);
+ // $res = dechex(hexdec($hsd)>>1).substr($hash, 1, 15);
+ // return StoredFile::NormalizeGunid($res);
}
@@ -1546,10 +1564,10 @@ class StoredFile {
*
* @return string
*/
-// public static function NormalizeGunid($p_gunid)
-// {
-// return str_pad($p_gunid, 16, "0", STR_PAD_LEFT);
-// }
+ // public static function NormalizeGunid($p_gunid)
+ // {
+ // return str_pad($p_gunid, 16, "0", STR_PAD_LEFT);
+ // }
/**
@@ -1600,10 +1618,10 @@ class StoredFile {
{
$a = $this->analyzeFile();
if (PEAR::isError($a)) {
- return $a;
+ return $a;
}
if (isset($a['dc:format'])) {
- return $a['dc:format'];
+ return $a['dc:format'];
}
return '';
}
@@ -1615,12 +1633,12 @@ class StoredFile {
*/
public function getTitle()
{
- return $this->md["title"];
+ return $this->md["title"];
}
public function getType()
{
- return $this->ftype;
+ return $this->ftype;
}
/**
@@ -1638,7 +1656,7 @@ class StoredFile {
return $this->state;
}
$sql = "SELECT state FROM ".$CC_CONFIG['filesTable']
- ." WHERE gunid='$p_gunid'";
+ ." WHERE gunid='$p_gunid'";
return $CC_DBC->getOne($sql);
}
@@ -1657,37 +1675,17 @@ class StoredFile {
return $this->name;
}
$sql = "SELECT name FROM ".$CC_CONFIG['filesTable']
- ." WHERE gunid='$p_gunid'";
+ ." WHERE gunid='$p_gunid'";
return $CC_DBC->getOne($sql);
}
- /**
- * Get and optionally create subdirectory in real filesystem for storing
- * raw media data.
- *
- * @return string
- */
-// private function _getResDir()
-// {
-// global $CC_CONFIG, $CC_DBC;
-// $resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3);
-// //$this->gb->debugLog("$resDir");
-// // see Transport::_getResDir too for resDir name create code
-// if (!is_dir($resDir)) {
-// mkdir($resDir, 02775);
-// chmod($resDir, 02775);
-// }
-// return $resDir;
-// }
-
-
/**
* Get real filename of raw media data
*
* @return string
*/
- public function getRealFileName()
+ public function getRealFilePath()
{
return $this->filepath;
}
@@ -1697,9 +1695,10 @@ class StoredFile {
*/
public function getFileUrl()
{
- global $CC_CONFIG;
- return "http://".$CC_CONFIG["storageUrlHost"]
- ."api/get_media.php?file_id={$this->gunid}";
+ global $CC_CONFIG;
+ return "http://".$CC_CONFIG["storageUrlHost"]
+ .$CC_CONFIG["apiPath"]."get_media.php?file="
+ .$this->gunid.".".$this->getFileExtension();
}
/**
@@ -1727,24 +1726,25 @@ class StoredFile {
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
}
+
public static function getFiles($query=NULL)
{
global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping;
-
+
$sql = "SELECT * FROM ".$CC_CONFIG['filesTable'];
if(!is_null($query)) {
$ob = " ORDER BY ".$g_metadata_xml_to_db_mapping[$query["category"]];
$sql = $sql . $ob . " " .$query["order"];
}
-
+
return $CC_DBC->getAll($sql);
}
public static function searchFiles($md)
{
global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping;
-
+
$match = array(
"0" => "ILIKE",
"1" => "=",
@@ -1754,7 +1754,7 @@ class StoredFile {
"5" => ">=",
"6" => "!=",
);
-
+
$sql = "SELECT * FROM ".$CC_CONFIG['filesTable'];
$cond = array();
@@ -1764,7 +1764,7 @@ class StoredFile {
$row_num = $t[1];
$string = $g_metadata_xml_to_db_mapping[$md[$key]["metadata_".$row_num]];
-
+
$string = $string ." ".$match[$md[$key]["match_".$row_num]];
if ($md[$key]["match_".$row_num] === "0")
@@ -1777,11 +1777,11 @@ class StoredFile {
}
$where = " WHERE ". join(" AND ", $cond);
- $sql = $sql . $where;
+ $sql = $sql . $where;
//echo $sql;
-
+
return $CC_DBC->getAll($sql);
}
-} // class StoredFile
-?>
+}
+?>
\ No newline at end of file
diff --git a/application/models/TransportRecord.php b/application/models/TransportRecord.php
index 9a491e7eb..6c804279c 100644
--- a/application/models/TransportRecord.php
+++ b/application/models/TransportRecord.php
@@ -12,9 +12,9 @@ define('TR_LEAVE_CLOSED', TRUE);
*/
class TransportRecord
{
- /**
- * @var DB
- */
+ /**
+ * @var DB
+ */
//public $dbc;
/**
@@ -72,12 +72,12 @@ class TransportRecord
$trec = new TransportRecord($tr);
$trec->trtok = $trtok = $tr->_createTransportToken();
$trec->row = array_merge($defaults,
- array('trtype'=>$trtype, 'direction'=>$direction));
+ array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE;
if (!isset($defaults['title'])) {
$defaults['title'] = $trec->getTitle();
if (PEAR::isError($defaults['title'])) {
- return $defaults['title'];
+ return $defaults['title'];
}
}
$id = $CC_DBC->nextId($CC_CONFIG['transSequence']);
@@ -96,7 +96,7 @@ class TransportRecord
";
$res = $CC_DBC->query($query);
if (PEAR::isError($res)) {
- return $res;
+ return $res;
}
return $trec;
}
@@ -126,7 +126,7 @@ class TransportRecord
WHERE trtok='$trtok'
");
if (PEAR::isError($row)) {
- return $row;
+ return $row;
}
if (is_null($row)) {
return PEAR::raiseError("TransportRecord::recall:".
@@ -170,16 +170,16 @@ class TransportRecord
UPDATE ".$CC_CONFIG['transTable']."
SET $set
WHERE trtok='{$this->trtok}'".
- (is_null($oldState) ? '' : " AND state='$oldState'").
- (is_null($lock) ? '' : " AND lock = '$slock'")
+ (is_null($oldState) ? '' : " AND state='$oldState'").
+ (is_null($lock) ? '' : " AND lock = '$slock'")
);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
// return TRUE;
$affRows = $CC_DBC->affectedRows();
if (PEAR::isError($affRows)) {
- return $affRows;
+ return $affRows;
}
return ($affRows == 1);
}
@@ -217,7 +217,7 @@ class TransportRecord
global $CC_CONFIG, $CC_DBC;
$pidsql = (is_null($pid) ? "NULL" : "$pid" );
if ($this->dropped) {
- return TRUE;
+ return TRUE;
}
$slock = ($lock ? 'Y' : 'N');
$nlock = (!$lock);
@@ -228,11 +228,11 @@ class TransportRecord
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$affRows = $CC_DBC->affectedRows();
if (PEAR::isError($affRows)) {
- return $affRows;
+ return $affRows;
}
if ($affRows === 0) {
$ltxt = ($lock ? 'lock' : 'unlock' );
@@ -303,7 +303,7 @@ class TransportRecord
}
$r = $this->setState('failed', array('errmsg'=>$msg));
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return TRUE;
}
@@ -326,7 +326,7 @@ class TransportRecord
if (TR_LEAVE_CLOSED) {
$r = $this->setState('closed');
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
} else {
$r = $CC_DBC->query("
@@ -334,7 +334,7 @@ class TransportRecord
WHERE trtok='{$this->trtok}'
");
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$this->recalled = FALSE;
$this->dropped = TRUE;
@@ -383,7 +383,7 @@ class TransportRecord
$defStr = 'unknown';
$trtype = $this->getTransportType(); //contains recall check
if (PEAR::isError($trtype)) {
- return $trtype;
+ return $trtype;
}
switch ($trtype) {
case "audioclip":
@@ -396,9 +396,9 @@ class TransportRecord
}
if (PEAR::isError($title)) {
if ($title->getCode() == GBERR_FOBJNEX) {
- $title = $defStr;
+ $title = $defStr;
} else {
- return $title;
+ return $title;
}
}
break;
@@ -407,10 +407,10 @@ class TransportRecord
break;
case "file":
$title = ( isset($this->row['localfile']) ?
- basename($this->row['localfile']) : 'regular file');
+ basename($this->row['localfile']) : 'regular file');
break;
default:
- $title = $defStr;
+ $title = $defStr;
}
return $title;
}
diff --git a/application/models/Validator.php b/application/models/Validator.php
index a53b9fdf4..d730aee10 100644
--- a/application/models/Validator.php
+++ b/application/models/Validator.php
@@ -67,12 +67,12 @@ class Validator {
'webstream' => "webstreamFormat",
);
if (!isset($formats[$format])) {
- return $this->_err(VAL_FORMAT);
+ return $this->_err(VAL_FORMAT);
}
$formatName = $formats[$format];
$formatFile = dirname(__FILE__)."/$formatName.php";
if (!file_exists($formatFile)) {
- return $this->_err(VAL_FORMAT);
+ return $this->_err(VAL_FORMAT);
}
require($formatFile);
$this->formTree = $$formatName;
@@ -151,15 +151,15 @@ class Validator {
$dname = (($node->ns? $node->ns.":" : '').$node->name);
$formTree =& $this->formTree;
if (DEBUG) {
- echo"\nVAL::validateNode: 1 $dname/$fname\n";
+ echo"\nVAL::validateNode: 1 $dname/$fname\n";
}
// check root node name:
if ($dname != $fname) {
- return $this->_err(VAL_ROOT, $fname);
+ return $this->_err(VAL_ROOT, $fname);
}
// check if this element is defined in format:
if (!isset($formTree[$fname])) {
- return $this->_err(VAL_NOTDEF, $fname);
+ return $this->_err(VAL_NOTDEF, $fname);
}
// check element content
if (isset($formTree[$fname]['regexp'])) {
@@ -171,12 +171,12 @@ class Validator {
// validate attributes:
$ra = $this->validateAttributes($node, $fname);
if (PEAR::isError($ra)) {
- return $ra;
+ return $ra;
}
// validate children:
$r = $this->validateChildren($node, $fname);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
return TRUE;
}
@@ -251,7 +251,7 @@ class Validator {
// call children recursive:
$r = $this->validateNode($node->children[$i], $chname);
if (PEAR::isError($r)) {
- return $r;
+ return $r;
}
$childs[$chname] = TRUE;
}
@@ -269,13 +269,13 @@ class Validator {
foreach ($fchilds['oneof'] as $i => $ch) {
if (isset($childs[$ch])) {
if ($one) {
- return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
+ return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
}
$one = TRUE;
}
}
if (!$one) {
- return $this->_err(VAL_NOONEOF);
+ return $this->_err(VAL_NOONEOF);
}
}
}
@@ -340,9 +340,9 @@ class Validator {
{
$formTree =& $this->formTree;
$listed = (
- isset($formTree[$fname][$nType][$reqType]) ?
- array_search($chname, $formTree[$fname][$nType][$reqType]) :
- FALSE
+ isset($formTree[$fname][$nType][$reqType]) ?
+ array_search($chname, $formTree[$fname][$nType][$reqType]) :
+ FALSE
);
return $listed;
}
@@ -360,22 +360,22 @@ class Validator {
function _err($errno, $par='')
{
$msg = array(
- VAL_ROOT => 'Wrong root element',
- VAL_NOREQE => 'Required element missing',
- VAL_NOONEOF => 'One-of element missing',
- VAL_UNKNOWNE => 'Unknown element',
- VAL_UNKNOWNA => 'Unknown attribute',
- VAL_NOTDEF => 'Not defined',
- VAL_UNEXPONEOF => 'Unexpected second object from one-of set',
- VAL_FORMAT => 'Unknown format',
- VAL_CONTENT => 'Invalid content',
- VAL_NOREQA => 'Required attribute missing',
- VAL_ATTRIB => 'Invalid attribute format',
- VAL_PREDXML => 'Invalid predicate type',
+ VAL_ROOT => 'Wrong root element',
+ VAL_NOREQE => 'Required element missing',
+ VAL_NOONEOF => 'One-of element missing',
+ VAL_UNKNOWNE => 'Unknown element',
+ VAL_UNKNOWNA => 'Unknown attribute',
+ VAL_NOTDEF => 'Not defined',
+ VAL_UNEXPONEOF => 'Unexpected second object from one-of set',
+ VAL_FORMAT => 'Unknown format',
+ VAL_CONTENT => 'Invalid content',
+ VAL_NOREQA => 'Required attribute missing',
+ VAL_ATTRIB => 'Invalid attribute format',
+ VAL_PREDXML => 'Invalid predicate type',
);
return PEAR::raiseError(
"Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})",
- $errno
+ $errno
);
}
diff --git a/application/models/XmlParser.php b/application/models/XmlParser.php
index 89d59e123..7d440460b 100644
--- a/application/models/XmlParser.php
+++ b/application/models/XmlParser.php
@@ -164,12 +164,12 @@ class XmlParser {
$res = xml_parse($xml_parser, $data, TRUE);
if (!$res) {
$this->err = array(TRUE,
- sprintf("XML error: %s at line %d\n",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)
- )
+ sprintf("XML error: %s at line %d\n",
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)
+ )
);
-// var_dump($data);
+ // var_dump($data);
}
xml_parser_free($xml_parser);
}
@@ -188,31 +188,31 @@ class XmlParser {
function &parse($data='', $loc='file')
{
switch ($loc) {
- case "file":
- if (!is_file($data)) {
- return PEAR::raiseError(
+ case "file":
+ if (!is_file($data)) {
+ return PEAR::raiseError(
"XmlParser::parse: file not found ($data)"
- );
- }
- if (!is_readable($data)) {
- return PEAR::raiseError(
+ );
+ }
+ if (!is_readable($data)) {
+ return PEAR::raiseError(
"XmlParser::parse: can't read file ($data)"
- );
- }
- $data = file_get_contents($data);
- case "string":
- $parser = new XmlParser($data);
- if ($parser->isError()) {
- return PEAR::raiseError(
+ );
+ }
+ $data = file_get_contents($data);
+ case "string":
+ $parser = new XmlParser($data);
+ if ($parser->isError()) {
+ return PEAR::raiseError(
"XmlParser::parse: ".$parser->getError()
- );
- }
- $tree = $parser->getTree();
- break;
- default:
- return PEAR::raiseError(
+ );
+ }
+ $tree = $parser->getTree();
+ break;
+ default:
+ return PEAR::raiseError(
"XmlParser::parse: unsupported source location ($loc)"
- );
+ );
}
return $tree;
}
@@ -237,7 +237,7 @@ class XmlParser {
$atnm = $a['localPart'];
unset($attrs[$atn]);
if ($atns == 'xmlns') {
- $nSpaces[$atnm] = $atv;
+ $nSpaces[$atnm] = $atv;
} else if ($atns == NULL && $atnm == 'xmlns') {
$nSpaces[''] = $atv;
} else {
@@ -280,7 +280,7 @@ class XmlParser {
function characterData($parser, $data) {
$cnt = count($this->stack);
if (trim($data)!='') {
- $this->stack[$cnt-1]->content .= $data;
+ $this->stack[$cnt-1]->content .= $data;
}
}
@@ -299,7 +299,7 @@ class XmlParser {
//if(substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";"){
// $this->stack[$cnt-1]->content .= trim($data);
//}else{
- $this->stack[$cnt-1]->content .= "*** $data ***";
+ $this->stack[$cnt-1]->content .= "*** $data ***";
//}
}
@@ -376,7 +376,7 @@ class XmlParser {
}
$res .= XML_Util::replaceEntities("{$el->content}");
if ($haveCh) {
- $res .= "\n{$ind}";
+ $res .= "\n{$ind}";
}
$res .= "{$fullName}>";
return $res;
diff --git a/application/models/campcaster/map/CcShowTableMap.php b/application/models/campcaster/map/CcShowTableMap.php
index 4d927e35b..cdf2751e3 100644
--- a/application/models/campcaster/map/CcShowTableMap.php
+++ b/application/models/campcaster/map/CcShowTableMap.php
@@ -47,6 +47,7 @@ class CcShowTableMap extends TableMap {
$this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
+ $this->addColumn('SHOW_ID', 'DbShowId', 'INTEGER', true, null, null);
// validators
} // initialize()
diff --git a/application/models/campcaster/map/CcSubjsTableMap.php b/application/models/campcaster/map/CcSubjsTableMap.php
index a32bb2710..80213c37d 100644
--- a/application/models/campcaster/map/CcSubjsTableMap.php
+++ b/application/models/campcaster/map/CcSubjsTableMap.php
@@ -35,7 +35,8 @@ class CcSubjsTableMap extends TableMap {
$this->setPhpName('CcSubjs');
$this->setClassname('CcSubjs');
$this->setPackage('campcaster');
- $this->setUseIdGenerator(false);
+ $this->setUseIdGenerator(true);
+ $this->setPrimaryKeyMethodInfo('cc_subjs_id_seq');
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, '');
diff --git a/application/models/campcaster/om/BaseCcShow.php b/application/models/campcaster/om/BaseCcShow.php
index d0df93fc4..c1136115b 100644
--- a/application/models/campcaster/om/BaseCcShow.php
+++ b/application/models/campcaster/om/BaseCcShow.php
@@ -79,6 +79,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
*/
protected $description;
+ /**
+ * The value for the show_id field.
+ * @var int
+ */
+ protected $show_id;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -296,6 +302,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->description;
}
+ /**
+ * Get the [show_id] column value.
+ *
+ * @return int
+ */
+ public function getDbShowId()
+ {
+ return $this->show_id;
+ }
+
/**
* Set the value of [id] column.
*
@@ -592,6 +608,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this;
} // setDbDescription()
+ /**
+ * Set the value of [show_id] column.
+ *
+ * @param int $v new value
+ * @return CcShow The current object (for fluent API support)
+ */
+ public function setDbShowId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->show_id !== $v) {
+ $this->show_id = $v;
+ $this->modifiedColumns[] = CcShowPeer::SHOW_ID;
+ }
+
+ return $this;
+ } // setDbShowId()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -637,6 +673,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
+ $this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
$this->resetModified();
$this->setNew(false);
@@ -645,7 +682,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 9; // 9 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
+ return $startcol + 10; // 10 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShow object", $e);
@@ -971,6 +1008,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
case 8:
return $this->getDbDescription();
break;
+ case 9:
+ return $this->getDbShowId();
+ break;
default:
return null;
break;
@@ -1003,6 +1043,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$keys[6] => $this->getDbRepeats(),
$keys[7] => $this->getDbDay(),
$keys[8] => $this->getDbDescription(),
+ $keys[9] => $this->getDbShowId(),
);
return $result;
}
@@ -1061,6 +1102,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
case 8:
$this->setDbDescription($value);
break;
+ case 9:
+ $this->setDbShowId($value);
+ break;
} // switch()
}
@@ -1094,6 +1138,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if (array_key_exists($keys[6], $arr)) $this->setDbRepeats($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbDescription($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]);
}
/**
@@ -1114,6 +1159,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats);
if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day);
if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CcShowPeer::SHOW_ID)) $criteria->add(CcShowPeer::SHOW_ID, $this->show_id);
return $criteria;
}
@@ -1183,6 +1229,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$copyObj->setDbRepeats($this->repeats);
$copyObj->setDbDay($this->day);
$copyObj->setDbDescription($this->description);
+ $copyObj->setDbShowId($this->show_id);
$copyObj->setNew(true);
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
@@ -1240,6 +1287,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->repeats = null;
$this->day = null;
$this->description = null;
+ $this->show_id = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
diff --git a/application/models/campcaster/om/BaseCcShowPeer.php b/application/models/campcaster/om/BaseCcShowPeer.php
index f407adde1..d950703aa 100644
--- a/application/models/campcaster/om/BaseCcShowPeer.php
+++ b/application/models/campcaster/om/BaseCcShowPeer.php
@@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
const TM_CLASS = 'CcShowTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 9;
+ const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -58,6 +58,9 @@ abstract class BaseCcShowPeer {
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'cc_show.DESCRIPTION';
+ /** the column name for the SHOW_ID field */
+ const SHOW_ID = 'cc_show.SHOW_ID';
+
/**
* An identiy map to hold any loaded instances of CcShow objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
@@ -74,12 +77,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', ),
- BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', ),
- BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', 'DbShowId', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', 'dbShowId', ),
+ BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, self::SHOW_ID, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', 'SHOW_ID', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', 'show_id', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -89,12 +92,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, ),
- BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, ),
- BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, 'DbShowId' => 9, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, 'dbShowId' => 9, ),
+ BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, self::SHOW_ID => 9, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, 'SHOW_ID' => 9, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, 'show_id' => 9, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -175,6 +178,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn(CcShowPeer::REPEATS);
$criteria->addSelectColumn(CcShowPeer::DAY);
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
+ $criteria->addSelectColumn(CcShowPeer::SHOW_ID);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
@@ -185,6 +189,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn($alias . '.REPEATS');
$criteria->addSelectColumn($alias . '.DAY');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.SHOW_ID');
}
}
diff --git a/application/models/campcaster/om/BaseCcShowQuery.php b/application/models/campcaster/om/BaseCcShowQuery.php
index 7dd2829e6..2cd8b335f 100644
--- a/application/models/campcaster/om/BaseCcShowQuery.php
+++ b/application/models/campcaster/om/BaseCcShowQuery.php
@@ -15,6 +15,7 @@
* @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column
* @method CcShowQuery orderByDbDay($order = Criteria::ASC) Order by the day column
* @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
+ * @method CcShowQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column
*
* @method CcShowQuery groupByDbId() Group by the id column
* @method CcShowQuery groupByDbName() Group by the name column
@@ -25,6 +26,7 @@
* @method CcShowQuery groupByDbRepeats() Group by the repeats column
* @method CcShowQuery groupByDbDay() Group by the day column
* @method CcShowQuery groupByDbDescription() Group by the description column
+ * @method CcShowQuery groupByDbShowId() Group by the show_id column
*
* @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -42,6 +44,7 @@
* @method CcShow findOneByDbRepeats(int $repeats) Return the first CcShow filtered by the repeats column
* @method CcShow findOneByDbDay(int $day) Return the first CcShow filtered by the day column
* @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column
+ * @method CcShow findOneByDbShowId(int $show_id) Return the first CcShow filtered by the show_id column
*
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column
@@ -52,6 +55,7 @@
* @method array findByDbRepeats(int $repeats) Return CcShow objects filtered by the repeats column
* @method array findByDbDay(int $day) Return CcShow objects filtered by the day column
* @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column
+ * @method array findByDbShowId(int $show_id) Return CcShow objects filtered by the show_id column
*
* @package propel.generator.campcaster.om
*/
@@ -408,6 +412,37 @@ abstract class BaseCcShowQuery extends ModelCriteria
return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison);
}
+ /**
+ * Filter the query on the show_id column
+ *
+ * @param int|array $dbShowId The value to use as filter.
+ * Accepts an associative array('min' => $minValue, 'max' => $maxValue)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CcShowQuery The current query, for fluid interface
+ */
+ public function filterByDbShowId($dbShowId = null, $comparison = null)
+ {
+ if (is_array($dbShowId)) {
+ $useMinMax = false;
+ if (isset($dbShowId['min'])) {
+ $this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbShowId['max'])) {
+ $this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+ return $this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId, $comparison);
+ }
+
/**
* Exclude object from result
*
diff --git a/application/models/campcaster/om/BaseCcSubjs.php b/application/models/campcaster/om/BaseCcSubjs.php
index 58796a099..b49c7b744 100644
--- a/application/models/campcaster/om/BaseCcSubjs.php
+++ b/application/models/campcaster/om/BaseCcSubjs.php
@@ -699,13 +699,21 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
+ if ($this->isNew() ) {
+ $this->modifiedColumns[] = CcSubjsPeer::ID;
+ }
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$criteria = $this->buildCriteria();
+ if ($criteria->keyContainsValue(CcSubjsPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
+ }
+
$pk = BasePeer::doInsert($criteria, $con);
$affectedRows = 1;
+ $this->setId($pk); //[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows = CcSubjsPeer::doUpdate($this, $con);
@@ -1127,7 +1135,6 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
*/
public function copyInto($copyObj, $deepCopy = false)
{
- $copyObj->setId($this->id);
$copyObj->setLogin($this->login);
$copyObj->setPass($this->pass);
$copyObj->setType($this->type);
@@ -1180,6 +1187,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
$copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
/**
diff --git a/application/models/campcaster/om/BaseCcSubjsPeer.php b/application/models/campcaster/om/BaseCcSubjsPeer.php
index f4bc75f9f..1ee269cc9 100644
--- a/application/models/campcaster/om/BaseCcSubjsPeer.php
+++ b/application/models/campcaster/om/BaseCcSubjsPeer.php
@@ -529,6 +529,10 @@ abstract class BaseCcSubjsPeer {
$criteria = $values->buildCriteria(); // build Criteria from CcSubjs object
}
+ if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
+ }
+
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
diff --git a/application/models/configure b/application/models/configure
deleted file mode 100755
index 26ccda218..000000000
--- a/application/models/configure
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-#-------------------------------------------------------------------------------
-# Copyright (c) 2010 Sourcefabric O.P.S.
-#
-# This file is part of the Campcaster project.
-# http://campcaster.campware.org/
-#
-# Campcaster is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Campcaster is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Campcaster; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#-------------------------------------------------------------------------------
-
-#-------------------------------------------------------------------------------
-# Run this script to configure the environment.
-#
-# This script in effect calls the real automake / autoconf configure script
-#-------------------------------------------------------------------------------
-
-# assume we're in $basedir
-reldir=`dirname $0`
-basedir=`cd $reldir; pwd;`
-test -z "$basedir" && basedir=.
-
-bindir=$basedir/bin
-tmpdir=$basedir/tmp
-
-
-autogen=$bindir/autogen.sh
-configure=$tmpdir/configure
-
-if [ ! -x $configure ]; then
- (cd $basedir && $autogen $*)
-fi
-
-(cd $tmpdir && $configure $*)
-
diff --git a/application/models/tests/0000000000010001 b/application/models/tests/0000000000010001
new file mode 100644
index 000000000..5fe526402
Binary files /dev/null and b/application/models/tests/0000000000010001 differ
diff --git a/application/models/tests/0000000000010002 b/application/models/tests/0000000000010002
new file mode 100644
index 000000000..1219a9056
Binary files /dev/null and b/application/models/tests/0000000000010002 differ
diff --git a/application/models/tests/AllTests.php b/application/models/tests/AllTests.php
new file mode 100644
index 000000000..9ca76645e
--- /dev/null
+++ b/application/models/tests/AllTests.php
@@ -0,0 +1,24 @@
+addTestSuite("PlaylistTests");
+$suite->addTestSuite("SchedulerTests");
+//$suite->addTestSuite("SchedulerExportTests");
+$result = PHPUnit::run($suite);
+
+echo $result->toString();
+
+?>
diff --git a/application/models/tests/PlaylistTests.php b/application/models/tests/PlaylistTests.php
new file mode 100644
index 000000000..27501a954
--- /dev/null
+++ b/application/models/tests/PlaylistTests.php
@@ -0,0 +1,181 @@
+getMessage()." ".$CC_DBC->getUserInfo()."\n";
+ exit(1);
+}
+$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
+
+class PlaylistTests extends PHPUnit_TestCase {
+
+ private $greenbox;
+ private $storedFile;
+ private $storedFile2;
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+ function setup() {
+ global $CC_CONFIG, $CC_DBC;
+ $this->greenbox = new GreenBox();
+
+ // Add a file
+ $values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
+ $this->storedFile = StoredFile::Insert($values, false);
+
+ // Add a file
+ $values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
+ $this->storedFile2 = StoredFile::Insert($values, false);
+
+ }
+
+ function testGBCreatePlaylist() {
+
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist UnitTest: create ".date("g:i a"));
+
+ if (!is_int($pl_id)) {
+ $this->fail("problems creating playlist.");
+ return;
+ }
+ }
+
+ function testGBLock() {
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist Metadata: lock ".date("g:i a"));
+
+ $sessid = Alib::Login('root', 'q');
+
+ $res = $this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
+
+ if($res !== TRUE) {
+ $this->fail("problems locking playlist for editing.");
+ return;
+ }
+ }
+
+ function testGBUnLock() {
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist UnitTest: unlock ".date("g:i a"));
+
+ $sessid = Alib::Login('root', 'q');
+
+ $this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
+ $res = $this->greenbox->releaseLockedPlaylist($pl_id, $sessid);
+
+ if($res !== TRUE) {
+ $this->fail("problems unlocking playlist.");
+ return;
+ }
+ }
+
+ function testGBSetPLMetaData() {
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist UnitTest: Set Metadata ".date("g:i a"));
+
+ $res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "Playlist Unit Test: Updated Title ".date("g:i a"));
+
+ if($res !== TRUE) {
+ $this->fail("problems setting playlist metadata.");
+ return;
+ }
+ }
+
+ function testGBGetPLMetaData() {
+ $pl = new Playlist();
+ $name = "Playlist UnitTest: GetMetadata ".date("g:i a");
+ $pl_id = $pl->create($name);
+
+ $res = $this->greenbox->getPLMetadataValue($pl_id, "dc:title");
+
+ if($res !== $name) {
+ $this->fail("problems getting playlist metadata.");
+ return;
+ }
+ }
+
+ function testAddAudioClip() {
+
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist Unit Test ". date("g:i a"));
+ $res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
+ if($res !== TRUE) {
+ $this->fail("problems adding audioclip to playlist.");
+ return;
+ }
+
+ $res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
+ if($res !== TRUE) {
+ $this->fail("problems adding audioclip 2 to playlist.");
+ return;
+ }
+ }
+
+ function testMoveAudioClip() {
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist Unit Test: Move ". date("g:i a"));
+
+ $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
+ $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
+
+ $res = $this->greenbox->moveAudioClipInPlaylist($pl_id, 0, 1);
+
+ if($res !== TRUE) {
+ $this->fail("problems moving audioclip in playlist.");
+ return;
+ }
+ }
+
+ function testDeleteAudioClip() {
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist UnitTest: Delete ".date("g:i a"));
+
+ $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
+ $res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0);
+
+ if($res !== TRUE) {
+ $this->fail("problems deleting audioclip from playlist.");
+ return;
+ }
+ }
+
+ function testFadeInfo() {
+ $pl = new Playlist();
+ $pl_id = $pl->create("Playlist Unit Test: Fade Info " . date("g:i a"));
+
+ $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
+
+ $res = $this->greenbox->changeFadeInfo($pl_id, 0, '00:00:01.14', null);
+
+ if(!is_array($res) && count($res) !== 2) {
+ $this->fail("problems setting fade in playlist.");
+ return;
+ }
+ }
+}
+
+?>
diff --git a/application/models/tests/SchedulerExportTests.php b/application/models/tests/SchedulerExportTests.php
new file mode 100644
index 000000000..6bdbd4ee2
--- /dev/null
+++ b/application/models/tests/SchedulerExportTests.php
@@ -0,0 +1,42 @@
+query($sql);
+
+ // Add a file
+ $values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
+ $this->storedFile = StoredFile::Insert($values, false);
+
+ // Add a file
+ $values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
+ $this->storedFile2 = StoredFile::Insert($values, false);
+
+ // Clear the schedule table
+ $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
+ $CC_DBC->query($sql);
+
+ // Create a playlist
+ $playlist = new Playlist();
+ $playlist->create("Scheduler Unit Test");
+ $result = $playlist->addAudioClip($this->storedFile->getId());
+ $result = $playlist->addAudioClip($this->storedFile2->getId());
+ $result = $playlist->addAudioClip($this->storedFile2->getId());
+
+ // Schedule it
+ $i = new ScheduleGroup();
+ $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
+ }
+
+ public function testExport() {
+ echo Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00");
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/application/models/tests/SchedulerTests.php b/application/models/tests/SchedulerTests.php
new file mode 100644
index 000000000..36c0084df
--- /dev/null
+++ b/application/models/tests/SchedulerTests.php
@@ -0,0 +1,128 @@
+query($sql);
+
+ // Add a file
+ $values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
+ $this->storedFile = StoredFile::Insert($values, false);
+
+ // Add a file
+ $values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
+ $this->storedFile2 = StoredFile::Insert($values, false);
+
+ // Clear the schedule table
+ //$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
+ //$CC_DBC->query($sql);
+ }
+
+ function testDateToId() {
+ $dateStr = "2006-04-02 10:20:08.123456";
+ $id = ScheduleGroup::dateToId($dateStr);
+ $expected = "20060402102008123";
+ if ($id != $expected) {
+ $this->fail("Did not convert date to ID correctly #1: $id != $expected");
+ }
+
+ $dateStr = "2006-04-02 10:20:08";
+ $id = ScheduleGroup::dateToId($dateStr);
+ $expected = "20060402102008000";
+ if ($id != $expected) {
+ $this->fail("Did not convert date to ID correctly #2: $id != $expected");
+ }
+ }
+
+ function testAddAndRemoveAudioFile() {
+ $i = new ScheduleGroup();
+ $this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
+ if (PEAR::isError($this->groupIdCreated)) {
+ $this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
+ }
+
+ $i = new ScheduleGroup($this->groupIdCreated);
+ $result = $i->remove();
+ if ($result != 1) {
+ $this->fail("Did not remove item.");
+ }
+ }
+
+ function testAddAndRemovePlaylist() {
+ // Create a playlist
+ $playlist = new Playlist();
+ $playlist->create("Scheduler Unit Test ".uniqid());
+ $result = $playlist->addAudioClip($this->storedFile->getId());
+ $result = $playlist->addAudioClip($this->storedFile2->getId());
+ $result = $playlist->addAudioClip($this->storedFile2->getId());
+
+ $i = new ScheduleGroup();
+ $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
+ if (PEAR::isError($this->groupIdCreated)) {
+ $this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
+ }
+ $group = new ScheduleGroup($this->groupIdCreated);
+ if ($group->count() != 3) {
+ $this->fail("Wrong number of items added.");
+ }
+ $items = $group->getItems();
+ if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
+ $this->fail("Wrong start time for 2nd item.");
+ }
+
+ $result = $group->remove();
+ if ($result != 1) {
+ $this->fail("Did not remove item.");
+ }
+
+ Playlist::Delete($playlist->getId());
+ }
+
+ function testIsScheduleEmptyInRange() {
+ $i = new ScheduleGroup();
+ $this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
+ if (PEAR::isError($this->groupIdCreated)) {
+ $this->fail($this->groupIdCreated->getMessage());
+ return;
+ }
+ if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
+ $this->fail("Reporting empty schedule when it isnt.");
+ return;
+ }
+ // echo "groupid: ".$this->groupIdCreated."\n";
+ $success = $i->remove();
+ if ($success === false) {
+ $this->fail("Failed to delete schedule group.");
+ return;
+ }
+ if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
+ $this->fail("Reporting booked schedule when it isnt.");
+ return;
+ }
+ }
+
+ function testGetItems() {
+ $i1 = new ScheduleGroup();
+ $groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId());
+ $i2 = new ScheduleGroup();
+ $i2->addAfter($groupId1, $this->storedFile->getId());
+ $items = Schedule::GetItems("2008-01-01", "2008-01-02");
+ if (count($items) != 2) {
+ $this->fail("Wrong number of items returned.");
+ return;
+ }
+ $i1->remove();
+ $i2->remove();
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/application/models/tests/StoredFileTests.php b/application/models/tests/StoredFileTests.php
new file mode 100644
index 000000000..e2ebcca08
--- /dev/null
+++ b/application/models/tests/StoredFileTests.php
@@ -0,0 +1,87 @@
+getMessage()." ".$CC_DBC->getUserInfo()."\n";
+ exit(1);
+}
+$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
+
+class StoredFileTest extends PHPUnit_TestCase {
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+ function setup() {
+ }
+
+ function testGetAudioMetadata() {
+ $filePath = dirname(__FILE__)."/ex1.mp3";
+ $metadata = camp_get_audio_metadata($filePath);
+ if (PEAR::isError($metadata)) {
+ $this->fail($metadata->getMessage());
+ return;
+ }
+ if (($metadata["dc:description"] != "Tmu sem tam videla ...")
+ || ($metadata["audio"]["dataformat"] != "mp3")
+ || ($metadata["dc:type"] != "Speech")) {
+ $str = " [dc:description] = " . $metadata["dc:description"] ."\n"
+ . " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
+ . " [dc:type] = ".$metadata["dc:type"]."\n";
+ $this->fail("Metadata has unexpected values:\n".$str);
+ }
+ //var_dump($metadata);
+ //$this->assertTrue(FALSE);
+ }
+
+ function testDeleteAndPutFile() {
+ $STORAGE_SERVER_PATH = dirname(__FILE__)."/../../";
+ $filePath = dirname(__FILE__)."/ex1.mp3";
+
+ // Delete any old data from previous tests
+ $md5 = md5_file($filePath);
+ $duplicate = StoredFile::RecallByMd5($md5);
+ if ($duplicate) {
+ $duplicate->delete();
+ }
+
+ // Test inserting a file by linking
+ $values = array("filepath" => $filePath,
+ "dc:description" => "Unit test ".time());
+ $storedFile = StoredFile::Insert($values, false);
+ if (PEAR::isError($storedFile)) {
+ $this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
+ return;
+ }
+ //var_dump($storedFile);
+ $id = $storedFile->getId();
+ if (!is_numeric($id)) {
+ $this->fail("StoredFile not created correctly. id = ".$id);
+ return;
+ }
+
+ // Test loading metadata
+ $f = new StoredFile();
+ $f->__setGunid($storedFile->getGunid());
+ $f->loadMetadata();
+ if (!is_array($md = $f->getMetadata())) {
+ $this->fail("Unable to load metadata.");
+ return;
+ }
+ //var_dump($md);
+
+ // Check if the length field has been set.
+ $f2 = StoredFile::RecallByGunid($storedFile->getGunid());
+ $m2 = $f2->getMetadata();
+ if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") {
+ $this->fail("Length not reporting correctly in metadata.");
+ return;
+ }
+
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/application/models/tests/analyze.php b/application/models/tests/analyze.php
new file mode 100755
index 000000000..c1435b9c8
--- /dev/null
+++ b/application/models/tests/analyze.php
@@ -0,0 +1,25 @@
+#!/usr/bin/php -q
+analyzeFile();
+
+echo "r=$r (".gettype($r).")\n";
+if (PEAR::isError($r)) {
+ echo "ERR: ".$r->getMessage()."\n".$r->getUserInfo()."\n";
+}
+if (is_array($r)) {
+ print_r($r);
+}
+echo"\n";
+?>
\ No newline at end of file
diff --git a/application/models/tests/ex1.mp3 b/application/models/tests/ex1.mp3
new file mode 100644
index 000000000..9d1f20156
Binary files /dev/null and b/application/models/tests/ex1.mp3 differ
diff --git a/application/models/tests/ex2.ogg b/application/models/tests/ex2.ogg
new file mode 100644
index 000000000..d018a4a11
Binary files /dev/null and b/application/models/tests/ex2.ogg differ
diff --git a/application/models/tests/ex2.wav b/application/models/tests/ex2.wav
new file mode 100644
index 000000000..8d1eddce9
Binary files /dev/null and b/application/models/tests/ex2.wav differ
diff --git a/application/models/tests/ex3.wav b/application/models/tests/ex3.wav
new file mode 100644
index 000000000..785f4edb3
Binary files /dev/null and b/application/models/tests/ex3.wav differ
diff --git a/application/models/tests/exportedPl_lspl.tar b/application/models/tests/exportedPl_lspl.tar
new file mode 100644
index 000000000..42cfb22dd
Binary files /dev/null and b/application/models/tests/exportedPl_lspl.tar differ
diff --git a/application/models/tests/index.php b/application/models/tests/index.php
new file mode 100644
index 000000000..125fdaf8e
--- /dev/null
+++ b/application/models/tests/index.php
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/application/models/tests/pdoTest.php b/application/models/tests/pdoTest.php
new file mode 100644
index 000000000..3aae4465b
--- /dev/null
+++ b/application/models/tests/pdoTest.php
@@ -0,0 +1,22 @@
+= '2010-01-01 00:00:00.000') "
+ ." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))";
+$rows1 = $con->query($sql);
+var_dump($rows1->fetchAll());
+
+$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents";
+$rows2 = $con->query($sql2);
+var_dump($rows2->fetchAll());
+
+$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'";
+$result3 = $con->query($sql3);
+var_dump($result3->fetchAll());
+
+?>
\ No newline at end of file
diff --git a/application/models/tests/plistEmbedded.xml b/application/models/tests/plistEmbedded.xml
new file mode 100644
index 000000000..db9b7ce03
--- /dev/null
+++ b/application/models/tests/plistEmbedded.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+ embedded playlist
+ 01:30:11.500000
+
+
+
diff --git a/application/models/tests/pypoTester.php b/application/models/tests/pypoTester.php
new file mode 100644
index 000000000..4443b14c1
--- /dev/null
+++ b/application/models/tests/pypoTester.php
@@ -0,0 +1,85 @@
+delete();
+}
+echo "done.\n";
+
+// Create a new playlist
+echo "Creating new playlist '$playlistName'...";
+$pl = new Playlist();
+$pl->create($playlistName);
+
+// Add a media clip
+$mediaFile = StoredFile::findByOriginalName("Manolo Camp - Morning Coffee.mp3");
+if (is_null($mediaFile)) {
+ echo "Adding test audio clip to the database.\n";
+ $v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Manolo Camp - Morning Coffee.mp3");
+ $mediaFile = StoredFile::Insert($v);
+ if (PEAR::isError($mediaFile)) {
+ var_dump($mediaFile);
+ exit();
+ }
+}
+$pl->addAudioClip($mediaFile->getId());
+$mediaFile = StoredFile::findByOriginalName("Peter Rudenko - Opening.mp3");
+if (is_null($mediaFile)) {
+ echo "Adding test audio clip to the database.\n";
+ $v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Peter Rudenko - Opening.mp3");
+ $mediaFile = StoredFile::Insert($v);
+ if (PEAR::isError($mediaFile)) {
+ var_dump($mediaFile);
+ exit();
+ }
+}
+$pl->addAudioClip($mediaFile->getId());
+echo "done.\n";
+
+//$pl2 = Playlist::findPlaylistByName("pypo_playlist_test");
+//var_dump($pl2);
+
+// Get current time
+// In the format YYYY-MM-DD HH:MM:SS.nnnnnn
+$startTime = date("Y-m-d H:i:s");
+$endTime = date("Y-m-d H:i:s", time()+(60*60));
+
+echo "Removing everything from the scheduler between $startTime and $endTime...";
+// Scheduler: remove any playlists for the next hour
+Schedule::RemoveItemsInRange($startTime, $endTime);
+// Check for succcess
+$scheduleClear = Schedule::isScheduleEmptyInRange($startTime, "01:00:00");
+if (!$scheduleClear) {
+ echo "\nERROR: Schedule could not be cleared.\n\n";
+ var_dump(Schedule::GetItems($startTime, $endTime));
+ exit;
+}
+echo "done.\n";
+
+// Schedule the playlist for two minutes from now
+echo "Scheduling new playlist...\n";
+$playTime = date("Y-m-d H:i:s", time()+(60*$minutesFromNow));
+$scheduleGroup = new ScheduleGroup();
+$scheduleGroup->add($playTime, null, $pl->getId());
+
+echo " SUCCESS: Playlist scheduled at $playTime\n\n";
+?>
\ No newline at end of file
diff --git a/application/models/tests/question.wav b/application/models/tests/question.wav
new file mode 100644
index 000000000..6c8b2a0cb
Binary files /dev/null and b/application/models/tests/question.wav differ
diff --git a/application/models/tests/silence.wav b/application/models/tests/silence.wav
new file mode 100644
index 000000000..547b4e492
Binary files /dev/null and b/application/models/tests/silence.wav differ
diff --git a/application/models/tests/test10001.mp3 b/application/models/tests/test10001.mp3
new file mode 100644
index 000000000..c5631e435
Binary files /dev/null and b/application/models/tests/test10001.mp3 differ
diff --git a/application/models/tests/test10002.mp3 b/application/models/tests/test10002.mp3
new file mode 100644
index 000000000..a7fe34c06
Binary files /dev/null and b/application/models/tests/test10002.mp3 differ
diff --git a/application/models/tests/test10003.mp3 b/application/models/tests/test10003.mp3
new file mode 100644
index 000000000..a98fa3730
Binary files /dev/null and b/application/models/tests/test10003.mp3 differ
diff --git a/application/models/tests/transTest.php b/application/models/tests/transTest.php
new file mode 100644
index 000000000..edf04354c
--- /dev/null
+++ b/application/models/tests/transTest.php
@@ -0,0 +1,143 @@
+\n");
+PEAR::setErrorHandling(PEAR_ERROR_RETURN);
+$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
+$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
+$gb = new GreenBox();
+$tr = new Transport($gb);
+$ls = new LocStor();
+@unlink($CC_CONFIG['transDir']."/activity.log");
+@unlink($CC_CONFIG['transDir']."/debug.log");
+$tr->_cleanUp();
+
+$gunid = 'a23456789abcdefb';
+$mediaFile = '../tests/ex1.mp3';
+$mdataFile = '../tests/mdata1.xml';
+
+// Test remote search
+$result = $tr->remoteSearch("");
+if (PEAR::isError($result)) {
+ echo $result->message."\n";
+} else {
+ var_dump($result);
+}
+
+// ========== STORE ==========
+
+echo"# Store: ";
+//$parid = $gb->_getHomeDirIdFromSess($sessid);
+$values = array(
+ "filename" => "xx1.mp3",
+ "filepath" => $mediaFile,
+ "metadata" => $mdataFile,
+ "gunid" => $gunid,
+ "filetype" => "audioclip"
+);
+$storedFile = StoredFile::Insert($values);
+if (PEAR::isError($storedFile)) {
+ if ($storedFile->getCode()!=GBERR_GUNID) {
+ echo "ERROR: ".$storedFile->getMessage()."\n";
+ exit(1);
+ }
+}
+$oid = $storedFile->getId();
+$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
+echo "$oid\n";
+
+// ========== DELETE FROM HUB ==========
+echo"# loginToArchive: ";
+$r = $tr->loginToArchive();
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
+echo "{$r['sessid']}\n";
+$asessid = $r['sessid'];
+echo"# deleteAudioClip on Hub: ";
+$r = $tr->xmlrpcCall(
+ 'archive.deleteAudioClip',
+ array(
+ 'sessid' => $asessid,
+ 'gunid' => $gunid,
+ 'forced' => TRUE,
+ )
+);
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; if($r->getCode()!=800+GBERR_FILENEX) exit(1); }
+else{ echo " {$r['status']}\n"; }
+echo"# logoutFromArchive: ";
+$r = $tr->logoutFromArchive($asessid);
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
+var_export($r); echo"\n";
+
+
+// ========== UPLOAD ==========
+echo "# UPLOAD test:\n";
+echo"# uploadAudioClip2Hub: ";
+$r = $gb->upload2Hub($gunid);
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
+var_export($r); echo"\n";
+$trtok = $r;
+
+echo"# logout: "; $r = Alib::Logout($sessid);
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
+echo "$r\n";
+#$trtok='280a6f1c18389620';
+
+for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
+ echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
+ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
+ $state = $r['state'];
+ echo "# state=$state, title={$r['title']}\n";
+}
+if($state=='failed') exit(1);
+
+// === DELETE LOCAL ===
+echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
+echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
+if (PEAR::isError($r)) {
+ echo "ERROR: ".$r->getMessage()."\n";
+ exit(1);
+}
+echo "$r\n";
+echo "# logout: "; $r = Alib::Logout($sessid);
+if (PEAR::isError($r)) {
+ echo "ERROR: ".$r->getMessage()."\n";
+ exit(1);
+}
+echo "$r\n";
+$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
+echo `$comm`;
+
+// === DOWNLOAD ===
+echo "# DOWNLOAD test:\n";
+echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
+
+echo"# downloadAudioClipFromHub: ";
+$r = $gb->downloadFromHub($sessid, $gunid);
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
+var_export($r); echo"\n";
+$trtok = $r;
+
+echo"# logout: "; $r = Alib::Logout($sessid);
+if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
+echo "$r\n";
+
+for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
+ echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
+ if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
+ $state = $r['state'];
+ echo "# state=$state, title={$r['title']}\n";
+}
+if($state=='failed') exit(1);
+
+$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
+
+if(file_exists("../trans/log")) echo `tail -n 25 ../trans/log`;
+echo "#Transport test: OK.\n\n";
+*/
+?>
\ No newline at end of file
diff --git a/application/models/tests/webstreamTest.php b/application/models/tests/webstreamTest.php
new file mode 100644
index 000000000..d8393867c
--- /dev/null
+++ b/application/models/tests/webstreamTest.php
@@ -0,0 +1,62 @@
+\n");
+PEAR::setErrorHandling(PEAR_ERROR_RETURN);
+$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
+$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
+$gb = new GreenBox();
+
+#$gunid = "123456789abcdee0";
+$gunid = "";
+#$mdataFileLP = '../tests/mdata1.xml';
+$mdataFileLP = NULL;
+
+echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
+$parid = $gb->_getHomeDirId($sessid);
+
+echo "# storeWebstream: ";
+$r = $gb->storeWebstream(
+ $parid, 'test stream', $mdataFileLP, $sessid, $gunid, 'http://localhost/y');
+if (PEAR::isError($r)) {
+ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
+ exit(1);
+}
+echo "";
+var_dump($r);
+//$id = BasicStor::IdFromGunid($gunid);
+$id = $r;
+
+echo "# getMdata: ";
+$r = $gb->getMetadata($id, $sessid);
+if (PEAR::isError($r)) {
+ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
+ exit(1);
+}
+echo "\n$r\n";
+
+echo "# deleteFile: ";
+$r = $gb->deleteFile($id, $sessid);
+if (PEAR::isError($r)) {
+ echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
+ exit(1);
+}
+echo "\n$r\n";
+
+echo "# logout: ";
+$r = Alib::Logout($sessid);
+if (PEAR::isError($r)) {
+ echo "ERROR: ".$r->getMessage()."\n";
+ exit(1);
+}
+echo "$r\n";
+
+echo "#storeWebstream test: OK.\n\n"
+*/
+?>
\ No newline at end of file
diff --git a/application/models/tests/wstream1.xml b/application/models/tests/wstream1.xml
new file mode 100644
index 000000000..57e228d8a
--- /dev/null
+++ b/application/models/tests/wstream1.xml
@@ -0,0 +1,14 @@
+
+
+
+ Webstream test 1
+ 01:30:00.000000
+ http://localhost/y
+
+
diff --git a/build/sql/schema.sql b/build/sql/schema.sql
index 8f997d217..265403546 100644
--- a/build/sql/schema.sql
+++ b/build/sql/schema.sql
@@ -169,6 +169,7 @@ CREATE TABLE "cc_show"
"repeats" INT2 NOT NULL,
"day" INT2 NOT NULL,
"description" VARCHAR(512),
+ "show_id" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
@@ -331,7 +332,7 @@ DROP TABLE "cc_subjs" CASCADE;
CREATE TABLE "cc_subjs"
(
- "id" INTEGER NOT NULL,
+ "id" serial NOT NULL,
"login" VARCHAR(255) default '' NOT NULL,
"pass" VARCHAR(255) default '' NOT NULL,
"type" CHAR(1) default 'U' NOT NULL,
diff --git a/3rd_party/liquidsoap/liquidsoap b/pypo/liquidsoap/liquidsoap
similarity index 100%
rename from 3rd_party/liquidsoap/liquidsoap
rename to pypo/liquidsoap/liquidsoap