Merged the model classes from /backend to their new home in /application/models.

Copied over the /backend/tests directory and modified the paths to their new
locations.

Moved the liquidsoap directory to be under the pypo directory.
This commit is contained in:
paul.baranowski 2010-12-07 17:29:28 -05:00
parent 184ee30775
commit dd8987cdbc
49 changed files with 3670 additions and 2639 deletions

View file

@ -26,22 +26,22 @@ class AccessRecur {
$ppa = new AccessRecur($ls, $sessid); $ppa = new AccessRecur($ls, $sessid);
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent); $r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$plRes = $r; $plRes = $r;
$r = StoredFile::RecallByGunid($plid); $r = StoredFile::RecallByGunid($plid);
if (is_null($r) || PEAR::isError($r)) { if (is_null($r) || PEAR::isError($r)) {
return $r; return $r;
} }
$ac = $r; $ac = $r;
$r = $ac->md->genPhpArray(); $r = $ac->md->genPhpArray();
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$pla = $r; $pla = $r;
$r = $ppa->processPlaylist($pla, $plRes['token']); $r = $ppa->processPlaylist($pla, $plRes['token']);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$plRes['content'] = $r; $plRes['content'] = $r;
return $plRes; return $plRes;
@ -58,14 +58,14 @@ class AccessRecur {
WHERE parent=x'{$token}'::bigint WHERE parent=x'{$token}'::bigint
"); ");
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$arr = $r; $arr = $r;
foreach ($arr as $i => $item) { foreach ($arr as $i => $item) {
extract($item); // token2, gunid extract($item); // token2, gunid
$r = BasicStor::GetType($gunid); $r = BasicStor::GetType($gunid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$ftype = $r; $ftype = $r;
# echo "$ftype/$token2\n"; # echo "$ftype/$token2\n";
@ -73,23 +73,23 @@ class AccessRecur {
case "audioclip": case "audioclip":
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2); $r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
# var_dump($r); # var_dump($r);
break; break;
case "playlist": case "playlist":
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2); $r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
# var_dump($r); # var_dump($r);
break; break;
default: default:
} }
} }
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE); $r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return $r; return $r;
} }
@ -103,11 +103,11 @@ class AccessRecur {
case "playlistElement": case "playlistElement":
$r = $this->processPlaylistElement($ple, $parent); $r = $this->processPlaylistElement($ple, $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
// $res = array_merge($res, $r); // $res = array_merge($res, $r);
$res[] = $r; $res[] = $r;
break; break;
default: default:
} }
} }
@ -119,7 +119,7 @@ class AccessRecur {
{ {
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent); $r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return $r; return $r;
} }
@ -132,48 +132,48 @@ class AccessRecur {
case "audioClip": case "audioClip":
$r = $this->processAudioClip($ac['attrs']['id'], $parent); $r = $this->processAudioClip($ac['attrs']['id'], $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return $r; return $r;
case "playlist": case "playlist":
// if(empty($ac['children'])){ // if(empty($ac['children'])){
$r = $this->accessPlaylist($this->ls, $this->sessid, $r = $this->accessPlaylist($this->ls, $this->sessid,
$ac['attrs']['id'], $parent); $ac['attrs']['id'], $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
if ($r->getCode() != GBERR_NOTF) { if ($r->getCode() != GBERR_NOTF) {
return $r; return $r;
} else { } else {
$r = $this->processPlaylist($ac, $parent); $r = $this->processPlaylist($ac, $parent);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$r = array( $r = array(
'content' => $r, 'content' => $r,
'url' => NULL, 'url' => NULL,
'token' => NULL, 'token' => NULL,
'chsum' => NULL, 'chsum' => NULL,
'size' => NULL, 'size' => NULL,
'warning' => 'inline playlist?', '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;
} }
*/ return $r;
break; /*
}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: default:
} }
} }

View file

@ -38,7 +38,7 @@ class Alib {
} }
$userid = Subjects::GetSubjId($login); $userid = Subjects::GetSubjId($login);
$sql = "INSERT INTO ".$CC_CONFIG['sessTable']." (sessid, userid, login, ts)" $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); $r = $CC_DBC->query($sql);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
@ -60,12 +60,12 @@ class Alib {
$ct = Alib::CheckAuthToken($sessid); $ct = Alib::CheckAuthToken($sessid);
if ($ct === FALSE) { if ($ct === FALSE) {
return PEAR::raiseError("Alib::logout: not logged ($sessid)", return PEAR::raiseError("Alib::logout: not logged ($sessid)",
ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN); ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
} elseif (PEAR::isError($ct)) { } elseif (PEAR::isError($ct)) {
return $ct; return $ct;
} else { } else {
$sql = "DELETE FROM ".$CC_CONFIG['sessTable'] $sql = "DELETE FROM ".$CC_CONFIG['sessTable']
." WHERE sessid='$sessid'"; ." WHERE sessid='$sessid'";
$r = $CC_DBC->query($sql); $r = $CC_DBC->query($sql);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
@ -85,7 +85,7 @@ class Alib {
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable'] $sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable']
." WHERE sessid='$sessid'"; ." WHERE sessid='$sessid'";
$c = $CC_DBC->getOne($sql); $c = $CC_DBC->getOne($sql);
return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE )); return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE ));
} //fn checkAuthToken } //fn checkAuthToken
@ -97,18 +97,18 @@ class Alib {
* @param string $sessid * @param string $sessid
* @return TRUE|PEAR_Error * @return TRUE|PEAR_Error
*/ */
// public function setAuthToken($sessid) // public function setAuthToken($sessid)
// { // {
// $r = $this->checkAuthToken($sessid); // $r = $this->checkAuthToken($sessid);
// if (PEAR::isError($r)) { // if (PEAR::isError($r)) {
// return $r; // return $r;
// } // }
// if (!$r) { // if (!$r) {
// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)"); // return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
// } // }
// //$this->sessid = $sessid; // //$this->sessid = $sessid;
// return TRUE; // return TRUE;
// } // fn setAuthToken // } // fn setAuthToken
/* -------------------------------------------------------- authorization */ /* -------------------------------------------------------- authorization */
@ -130,7 +130,7 @@ class Alib {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$permid = $CC_DBC->nextId($CC_CONFIG['permSequence']); $permid = $CC_DBC->nextId($CC_CONFIG['permSequence']);
$sql = "INSERT INTO ".$CC_CONFIG['permTable']." (permid, subj, action, obj, type)" $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); $r = $CC_DBC->query($sql);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return($r); return($r);
@ -213,85 +213,85 @@ class Alib {
*/ */
public static function CheckPerm($sid, $action, $oid=NULL) public static function CheckPerm($sid, $action, $oid=NULL)
{ {
return TRUE; return TRUE;
// global $CC_DBC; // global $CC_DBC;
// global $CC_CONFIG; // global $CC_CONFIG;
// if (!is_numeric($sid)) { // if (!is_numeric($sid)) {
// return FALSE; // return FALSE;
// } // }
//// if (is_null($oid) or $oid=='') { //// if (is_null($oid) or $oid=='') {
//// $oid = M2tree::GetRootNode(); //// $oid = M2tree::GetRootNode();
//// } //// }
//// if (PEAR::isError($oid)) { //// if (PEAR::isError($oid)) {
//// return $oid; //// return $oid;
//// } //// }
// if (!is_numeric($oid)) { // if (!is_numeric($oid)) {
// return FALSE; // return FALSE;
// } // }
// // query construction // // query construction
// // shortcuts: // // shortcuts:
// // p: permTable, // // p: permTable,
// // s: subjTable, m smembTable, // // s: subjTable, m smembTable,
// // t: treeTable ts: structTable, // // t: treeTable ts: structTable,
// // c: classTable, cm: cmembTable // // c: classTable, cm: cmembTable
// // main query elements: // // main query elements:
// $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj"; // $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
// $q_from = $CC_CONFIG['permTable']." p "; // $q_from = $CC_CONFIG['permTable']." p ";
// // joins for solving users/groups: // // joins for solving users/groups:
// $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj "; // $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_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
// $q_cond = "p.action in('_all', '$action') AND // $q_cond = "p.action in('_all', '$action') AND
// (s.id=$sid OR m.uid=$sid) "; // (s.id=$sid OR m.uid=$sid) ";
// // coalesce -1 for higher priority of nongroup rows: // // coalesce -1 for higher priority of nongroup rows:
// // action DESC order for lower priority of '_all': // // action DESC order for lower priority of '_all':
// $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC"; // $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
// $q_flds0 = $q_flds; // $q_flds0 = $q_flds;
// $q_from0 = $q_from; // $q_from0 = $q_from;
// $q_join0 = $q_join; // $q_join0 = $q_join;
// $q_cond0 = $q_cond; // $q_cond0 = $q_cond;
// $q_ordb0 = $q_ordb; // $q_ordb0 = $q_ordb;
// // joins for solving object tree: // // joins for solving object tree:
// $q_flds .= ", t.name, ts.level as tlevel"; // $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['treeTable']." t ON t.id=p.obj ";
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=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)"; // //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
// // action DESC order is hack for lower priority of '_all': // // 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"; // $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
// // query by tree: // // query by tree:
// $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb"; // $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
// $r1 = $CC_DBC->getAll($query1); // $r1 = $CC_DBC->getAll($query1);
// if (PEAR::isError($r1)) { // if (PEAR::isError($r1)) {
// return($r1); // return($r1);
// } // }
// // if there is row with type='A' on the top => permit // // if there is row with type='A' on the top => permit
// //$AllowedByTree = // //$AllowedByTree =
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A'); // // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
// //$DeniedByTree = // //$DeniedByTree =
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D'); // // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
// //
// if (!USE_ALIB_CLASSES) { // if (!USE_ALIB_CLASSES) {
// return $AllowedbyTree; // return $AllowedbyTree;
// } // }
// //
// // joins for solving object classes: // // joins for solving object classes:
// $q_flds = $q_flds0.", c.cname "; // $q_flds = $q_flds0.", c.cname ";
// $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj "; // $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_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_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
// $q_ordb = $q_ordb0; // $q_ordb = $q_ordb0;
// // query by class: // // query by class:
// $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb"; // $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
// $r2 = $CC_DBC->getAll($query2); // $r2 = $CC_DBC->getAll($query2);
// if (PEAR::isError($r2)) { // if (PEAR::isError($r2)) {
// return $r2; // return $r2;
// } // }
// $AllowedByClass = // $AllowedByClass =
// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A'); // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
// // not used now: // // not used now:
// // $DeniedByClass = // // $DeniedByClass =
// // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D'); // // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
// $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass)); // $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
// return $res; // return $res;
} // fn CheckPerm } // fn CheckPerm
@ -326,7 +326,7 @@ class Alib {
} }
if (is_null($uid)){ if (is_null($uid)){
return $CC_DBC->raiseError("Alib::removeSubj: Subj not found ($login)", 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); $r = Alib::RemovePerm(NULL, $uid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
@ -354,7 +354,7 @@ class Alib {
if (is_null($r)){ if (is_null($r)){
return PEAR::raiseError("Alib::GetSessLogin:". return PEAR::raiseError("Alib::GetSessLogin:".
" invalid session id ($sessid)", " invalid session id ($sessid)",
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN); ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
} }
return $r; return $r;
} // fn GetSessLogin } // fn GetSessLogin
@ -377,7 +377,7 @@ class Alib {
if (is_null($r)) { if (is_null($r)) {
return PEAR::raiseError("Alib::getSessUserId:". return PEAR::raiseError("Alib::getSessUserId:".
" invalid session id ($p_sessid)", " invalid session id ($p_sessid)",
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN); ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
} }
return $r; return $r;
} // fn getSessUserId } // fn getSessUserId
@ -394,7 +394,7 @@ class Alib {
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.login, p.* FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s" $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); return $CC_DBC->getAll($sql);
} // fn GetObjPerms } // fn GetObjPerms
@ -409,11 +409,11 @@ class Alib {
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT *" $sql = "SELECT *"
." FROM ".$CC_CONFIG['permTable'] ." FROM ".$CC_CONFIG['permTable']
." WHERE p.subj=$sid"; ." WHERE p.subj=$sid";
// $sql = "SELECT t.name, t.type as otype , p.*" // $sql = "SELECT t.name, t.type as otype , p.*"
// ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t" // ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
// ." WHERE t.id=p.obj AND p.subj=$sid"; // ." WHERE t.id=p.obj AND p.subj=$sid";
$a1 = $CC_DBC->getAll($sql); $a1 = $CC_DBC->getAll($sql);
return $a1; return $a1;
} // fn GetSubjPerms } // fn GetSubjPerms
@ -463,7 +463,7 @@ class Alib {
for ($c = 1; $c > 0; ){ for ($c = 1; $c > 0; ){
$sessid = md5(uniqid(rand())); $sessid = md5(uniqid(rand()));
$sql = "SELECT count(*) FROM ".$CC_CONFIG['sessTable'] $sql = "SELECT count(*) FROM ".$CC_CONFIG['sessTable']
." WHERE sessid='$sessid'"; ." WHERE sessid='$sessid'";
$c = $CC_DBC->getOne($sql); $c = $CC_DBC->getOne($sql);
if (PEAR::isError($c)) { if (PEAR::isError($c)) {
return $c; return $c;
@ -488,19 +488,19 @@ class Alib {
{ {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.login, p.action, p.type" $sql = "SELECT s.login, p.action, p.type"
." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s" ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
." WHERE s.id=p.subj" ." WHERE s.id=p.subj"
." ORDER BY p.permid"; ." ORDER BY p.permid";
$arr = $CC_DBC->getAll($sql); $arr = $CC_DBC->getAll($sql);
if (PEAR::isError($arr)) { if (PEAR::isError($arr)) {
return $arr; return $arr;
} }
$r = $ind.join(', ', array_map(create_function('$v', $r = $ind.join(', ', array_map(create_function('$v',
'return "{$v[\'login\']}/{$v[\'action\']}/{$v[\'type\']}";' 'return "{$v[\'login\']}/{$v[\'action\']}/{$v[\'type\']}";'
), ),
$arr $arr
))."\n"; ))."\n";
return $r; return $r;
} // fn dumpPerms } // fn dumpPerms
@ -532,16 +532,16 @@ class Alib {
$s =& $tdata['subjects']; $s =& $tdata['subjects'];
$CC_DBC->setErrorHandling(PEAR_ERROR_PRINT); $CC_DBC->setErrorHandling(PEAR_ERROR_PRINT);
$perms = array( $perms = array(
array($s['root'], '_all', $t['root'], 'A'), array($s['root'], '_all', $t['root'], 'A'),
array($s['test1'], '_all', $t['pa'], 'A'), array($s['test1'], '_all', $t['pa'], 'A'),
array($s['test1'], 'read', $t['s2b'], 'D'), array($s['test1'], 'read', $t['s2b'], 'D'),
array($s['test2'], 'addChilds', $t['pa'], 'D'), array($s['test2'], 'addChilds', $t['pa'], 'D'),
array($s['test2'], 'read', $t['i2'], 'A'), array($s['test2'], 'read', $t['i2'], 'A'),
array($s['test2'], 'edit', $t['s1a'], 'A'), array($s['test2'], 'edit', $t['s1a'], 'A'),
array($s['test1'], 'addChilds', $t['s2a'], 'D'), array($s['test1'], 'addChilds', $t['s2a'], 'D'),
array($s['test1'], 'addChilds', $t['s2c'], 'D'), array($s['test1'], 'addChilds', $t['s2c'], 'D'),
array($s['gr2'], 'addChilds', $t['i2'], 'A'), array($s['gr2'], 'addChilds', $t['i2'], 'A'),
array($s['test3'], '_all', $t['t1'], 'D'), array($s['test3'], '_all', $t['t1'], 'D'),
); );
if (USE_ALIB_CLASSES){ if (USE_ALIB_CLASSES){
$perms[] = array($s['test3'], 'read', $c['cl_sa'], 'D'); $perms[] = array($s['test3'], 'read', $c['cl_sa'], 'D');
@ -587,14 +587,14 @@ class Alib {
return $r; return $r;
} }
$test_dump = $r. $test_dump = $r.
(Alib::CheckPerm( (Alib::CheckPerm(
$tdata['subjects']['test1'], 'read', $tdata['subjects']['test1'], 'read',
$tdata['tree']['t1'] $tdata['tree']['t1']
)? 'yes':'no').", ". )? 'yes':'no').", ".
(Alib::CheckPerm( (Alib::CheckPerm(
$tdata['subjects']['test1'], 'addChilds', $tdata['subjects']['test1'], 'addChilds',
$tdata['tree']['i2'] $tdata['tree']['i2']
)? 'yes':'no')."\n" )? 'yes':'no')."\n"
; ;
Alib::RemovePerm($tdata['perms'][1]); Alib::RemovePerm($tdata['perms'][1]);
Alib::RemovePerm($tdata['perms'][3]); Alib::RemovePerm($tdata['perms'][3]);

View file

@ -132,7 +132,7 @@ class Backup
// get ids (and real filenames) which files match with criteria // get ids (and real filenames) which files match with criteria
$srch = $this->gb->localSearch($this->criteria,$this->sessid); $srch = $this->gb->localSearch($this->criteria,$this->sessid);
if (PEAR::isError($srch)) { if (PEAR::isError($srch)) {
return $srch; return $srch;
} }
$this->setIDs($srch); $this->setIDs($srch);
@ -167,7 +167,7 @@ class Backup
return array('token'=>$this->token); return array('token'=>$this->token);
} else { } else {
return false; return false;
} }
} }
@ -229,7 +229,7 @@ class Backup
unlink($this->statusFile); unlink($this->statusFile);
unlink($this->tmpFile); unlink($this->tmpFile);
if (is_file($this->tmpName)) { if (is_file($this->tmpName)) {
unlink($this->tmpName); unlink($this->tmpName);
} }
return !is_file($this->tmpFile); return !is_file($this->tmpFile);
} }
@ -288,42 +288,42 @@ class Backup
*/ */
private function setFilenames() private function setFilenames()
{ {
// if ($this->loglevel=='debug') { // if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n"); // $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
// } // }
// if (is_array($this->ids)) { // if (is_array($this->ids)) {
// foreach ($this->ids as $i => $item) { // foreach ($this->ids as $i => $item) {
// $gunid = $item['gunid']; // $gunid = $item['gunid'];
// // get a stored file object of this gunid // // get a stored file object of this gunid
// $sf = StoredFile::RecallByGunid($gunid); // $sf = StoredFile::RecallByGunid($gunid);
// if (is_null($sf) || PEAR::isError($sf)) { // if (is_null($sf) || PEAR::isError($sf)) {
// return $sf; // return $sf;
// } // }
// $lid = BasicStor::IdFromGunid($gunid); // $lid = BasicStor::IdFromGunid($gunid);
// if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) { // if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n"); // $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
// return PEAR::raiseError('Backup::setFilenames : Authorize ... error.'); // return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
// } // }
// // if the file is a playlist then it has only a meta file // // if the file is a playlist then it has only a meta file
// if (strtolower($sf->md->format) != 'playlist') { // if (strtolower($sf->md->format) != 'playlist') {
// $this->filenames[] = array( // $this->filenames[] = array(
// 'filename' => $sf->getRealFileName(), // 'filename' => $sf->getRealFileName(),
// 'format' => $sf->md->format // 'format' => $sf->md->format
// ); // );
// } // }
// $this->filenames[] = array( // $this->filenames[] = array(
// 'filename' => $sf->getRealMetadataFileName(), // 'filename' => $sf->getRealMetadataFileName(),
// 'format' => $sf->md->format // 'format' => $sf->md->format
// ); // );
// if ($this->loglevel=='debug') { // if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n"); // $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
// } // }
// } // }
// return $this->filenames; // return $this->filenames;
// } else { // } else {
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n"); // $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.'); // 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"); $this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n");
} }
$command = dirname(__FILe__)."/../bin/backup.sh" $command = dirname(__FILe__)."/../bin/backup.sh"
." {$this->tmpDir}" ." {$this->tmpDir}"
." {$this->tmpFile}" ." {$this->tmpFile}"
." {$this->statusFile}" ." {$this->statusFile}"
." >> {$this->logFile} &"; ." >> {$this->logFile} &";
$res = system("$command"); $res = system("$command");
sleep(2); sleep(2);
if ($this->loglevel=='debug') { if ($this->loglevel=='debug') {
@ -438,7 +438,7 @@ class Backup
{ {
$acc = BasicStor::bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE); $acc = BasicStor::bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
if (PEAR::isError($acc)) { if (PEAR::isError($acc)) {
return $acc; return $acc;
} }
$this->token = $acc['token']; $this->token = $acc['token'];
} }

File diff suppressed because it is too large Load diff

View file

@ -50,7 +50,7 @@ class LocStor extends BasicStor {
* {url:writable URL for HTTP PUT, token:access token} * {url:writable URL for HTTP PUT, token:access token}
*/ */
protected function storeAudioClipOpen($sessid, $gunid, $metadata, protected function storeAudioClipOpen($sessid, $gunid, $metadata,
$fname, $chsum, $ftype='audioclip') $fname, $chsum, $ftype='audioclip')
{ {
// Check the gunid format // Check the gunid format
if (!BasicStor::CheckGunid($gunid)) { if (!BasicStor::CheckGunid($gunid)) {
@ -79,7 +79,7 @@ class LocStor extends BasicStor {
if ($storedFile->isAccessed()) { if ($storedFile->isAccessed()) {
return PEAR::raiseError( return PEAR::raiseError(
'LocStor::storeAudioClipOpen: is accessed' 'LocStor::storeAudioClipOpen: is accessed'
); );
} }
$res = $storedFile->replace($oid, $storedFile->getName(), '', $metadata, 'string'); $res = $storedFile->replace($oid, $storedFile->getName(), '', $metadata, 'string');
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
@ -182,7 +182,7 @@ class LocStor extends BasicStor {
protected function storeWebstream($sessid, $gunid, $metadata, $fname, $url) protected function storeWebstream($sessid, $gunid, $metadata, $fname, $url)
{ {
$a = $this->storeAudioClipOpen( $a = $this->storeAudioClipOpen(
$sessid, $gunid, $metadata, $fname, md5(''), 'webstream'); $sessid, $gunid, $metadata, $fname, md5(''), 'webstream');
if (PEAR::isError($a)) { if (PEAR::isError($a)) {
return $a; return $a;
} }
@ -267,7 +267,7 @@ class LocStor extends BasicStor {
if (is_null($id) || !$ex) { if (is_null($id) || !$ex) {
return PEAR::raiseError( return PEAR::raiseError(
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)", "LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
GBERR_NOTF GBERR_NOTF
); );
} }
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
@ -304,8 +304,8 @@ class LocStor extends BasicStor {
*/ */
protected function downloadMetadataOpen($sessid, $gunid) protected function downloadMetadataOpen($sessid, $gunid)
{ {
// $res = $this->existsAudioClip($sessid, $gunid); // $res = $this->existsAudioClip($sessid, $gunid);
// if(PEAR::isError($res)) return $res; // if(PEAR::isError($res)) return $res;
$media = StoredFile::RecallByGunid($gunid) $media = StoredFile::RecallByGunid($gunid)
$id = $media->getGunid(); $id = $media->getGunid();
if (is_null($id)) { if (is_null($id)) {
@ -414,7 +414,7 @@ class LocStor extends BasicStor {
* </li> * </li>
* </ul> * </ul>
* @see BasicStor::localSearch * @see BasicStor::localSearch
*/ */
public function searchMetadata($sessid, $criteria) public function searchMetadata($sessid, $criteria)
{ {
if (($res = BasicStor::Authorize('read', $this->storId, $sessid)) !== TRUE) { if (($res = BasicStor::Authorize('read', $this->storId, $sessid)) !== TRUE) {
@ -592,7 +592,7 @@ class LocStor extends BasicStor {
if ($ex) { if ($ex) {
return PEAR::raiseError( return PEAR::raiseError(
'LocStor::createPlaylist: already exists' 'LocStor::createPlaylist: already exists'
); );
} }
$tmpFname = uniqid(''); $tmpFname = uniqid('');
if (($res = BasicStor::Authorize('write', null, $sessid)) !== TRUE) { if (($res = BasicStor::Authorize('write', null, $sessid)) !== TRUE) {
@ -608,7 +608,7 @@ class LocStor extends BasicStor {
$fname = "newFile.xml"; $fname = "newFile.xml";
} }
$storedFile->setName($fname); $storedFile->setName($fname);
$storedFile->setState('ready'); $storedFile->setState('ready');
$storedFile->setMime('application/smil'); $storedFile->setMime('application/smil');
return $storedFile->gunid; return $storedFile->gunid;
} }
@ -634,12 +634,12 @@ class LocStor extends BasicStor {
if (!$ex) { if (!$ex) {
return PEAR::raiseError( return PEAR::raiseError(
'LocStor::editPlaylist: playlist not exists' 'LocStor::editPlaylist: playlist not exists'
); );
} }
if ($this->isEdited($playlistId) !== FALSE) { if ($this->isEdited($playlistId) !== FALSE) {
return PEAR::raiseError( return PEAR::raiseError(
'LocStor::editPlaylist: playlist already edited' 'LocStor::editPlaylist: playlist already edited'
); );
} }
$storedFile =& StoredFile::RecallByGunid($playlistId); $storedFile =& StoredFile::RecallByGunid($playlistId);
if (is_null($storedFile) || PEAR::isError($storedFile)) { if (is_null($storedFile) || PEAR::isError($storedFile)) {
@ -753,7 +753,7 @@ class LocStor extends BasicStor {
} }
return PEAR::raiseError( return PEAR::raiseError(
'LocStor::deletePlaylist: playlist not exists', 'LocStor::deletePlaylist: playlist not exists',
GBERR_FILENEX GBERR_FILENEX
); );
} }
$storedFile =& StoredFile::RecallByGunid($playlistId); $storedFile =& StoredFile::RecallByGunid($playlistId);
@ -791,32 +791,32 @@ class LocStor extends BasicStor {
* } * }
*/ */
public function accessPlaylist($sessid, $playlistId, $recursive=FALSE, $parent='0') public function accessPlaylist($sessid, $playlistId, $recursive=FALSE, $parent='0')
// { // {
// if ($recursive) { // if ($recursive) {
// require_once("AccessRecur.php"); // require_once("AccessRecur.php");
// $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId); // $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
// if (PEAR::isError($r)) { // if (PEAR::isError($r)) {
// return $r; // return $r;
// } // }
// return $r; // return $r;
// } // }
// $ex = $this->existsPlaylist($sessid, $playlistId); // $ex = $this->existsPlaylist($sessid, $playlistId);
// if (PEAR::isError($ex)) { // if (PEAR::isError($ex)) {
// return $ex; // return $ex;
// } // }
// if (!$ex) { // if (!$ex) {
// return PEAR::raiseError( // return PEAR::raiseError(
// "LocStor::accessPlaylist: playlist not found ($playlistId)", // "LocStor::accessPlaylist: playlist not found ($playlistId)",
// GBERR_NOTF // GBERR_NOTF
// ); // );
// } // }
// $id = BasicStor::IdFromGunid($playlistId); // $id = BasicStor::IdFromGunid($playlistId);
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) { // if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
// return $res; // return $res;
// } // }
// $res = $this->bsOpenDownload($id, 'metadata', $parent); // $res = $this->bsOpenDownload($id, 'metadata', $parent);
// #unset($res['filename']); // #unset($res['filename']);
// return $res; // return $res;
} }
@ -983,7 +983,7 @@ class LocStor extends BasicStor {
if (!$ex) { if (!$ex) {
return PEAR::raiseError( return PEAR::raiseError(
'LocStor::playlistIsAvailable: playlist not exists' 'LocStor::playlistIsAvailable: playlist not exists'
); );
} }
$ie = $this->isEdited($playlistId); $ie = $this->isEdited($playlistId);
if ($ie === FALSE) { if ($ie === FALSE) {
@ -1159,7 +1159,7 @@ class LocStor extends BasicStor {
if ($token != '123456789abcdeff') { if ($token != '123456789abcdeff') {
return PEAR::raiseError( return PEAR::raiseError(
"LocStor::renderPlaylistToRSSClose: invalid token" "LocStor::renderPlaylistToRSSClose: invalid token"
); );
} }
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss"; $fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
unlink($fakeFile); unlink($fakeFile);
@ -1192,7 +1192,7 @@ class LocStor extends BasicStor {
if ($r === FALSE) { if ($r === FALSE) {
return PEAR::raiseError( return PEAR::raiseError(
"LocStor::createBackupOpen: false returned from Backup" "LocStor::createBackupOpen: false returned from Backup"
); );
} }
return $r; return $r;
} }
@ -1351,12 +1351,12 @@ class LocStor extends BasicStor {
* status: string - working | fault | success * status: string - working | fault | success
*/ */
protected function restoreBackupClose($token) { protected function restoreBackupClose($token) {
require_once('Restore.php'); require_once('Restore.php');
$rs = new Restore($this); $rs = new Restore($this);
if (PEAR::isError($rs)) { if (PEAR::isError($rs)) {
return $rs; return $rs;
} }
return $rs->closeRestore($token); return $rs->closeRestore($token);
} }
@ -1387,11 +1387,11 @@ class LocStor extends BasicStor {
{ {
$owner = Alib::GetSessUserId($sessid); $owner = Alib::GetSessUserId($sessid);
if (PEAR::isError($owner)) { if (PEAR::isError($owner)) {
return $owner; return $owner;
} }
$res = $this->bsOpenPut($chsum, NULL, $owner); $res = $this->bsOpenPut($chsum, NULL, $owner);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
return array('url'=>$res['url'], 'token'=>$res['token']); return array('url'=>$res['url'], 'token'=>$res['token']);
} }
@ -1412,7 +1412,7 @@ class LocStor extends BasicStor {
{ {
$res = $this->bsClosePut($token); $res = $this->bsClosePut($token);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
extract($res); // fname, owner extract($res); // fname, owner
switch ($trtype) { switch ($trtype) {
@ -1420,11 +1420,11 @@ class LocStor extends BasicStor {
$mdtoken = $pars['mdpdtoken']; $mdtoken = $pars['mdpdtoken'];
$res = $this->bsClosePut($mdtoken); $res = $this->bsClosePut($mdtoken);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
$mdfname = $res['fname']; $mdfname = $res['fname'];
if ($gunid == '') { if ($gunid == '') {
$gunid = NULL; $gunid = NULL;
} }
$values = array( $values = array(
"filename" => $pars['name'], "filename" => $pars['name'],
@ -1432,45 +1432,45 @@ class LocStor extends BasicStor {
"metadata" => $mdfname, "metadata" => $mdfname,
"gunid" => $pars['gunid'], "gunid" => $pars['gunid'],
"filetype" => "audioclip" "filetype" => "audioclip"
); );
$storedFile = StoredFile::Insert($values); $storedFile = StoredFile::Insert($values);
if (PEAR::isError($storedFile)) { if (PEAR::isError($storedFile)) {
return $storedFile; return $storedFile;
} }
$res = $storedFile->getId(); $res = $storedFile->getId();
@unlink($fname); @unlink($fname);
@unlink($mdfname); @unlink($mdfname);
break; break;
case "playlist": case "playlist":
if ($gunid == '') { if ($gunid == '') {
$gunid = NULL; $gunid = NULL;
} }
$values = array( $values = array(
"filename" => $pars['name'], "filename" => $pars['name'],
"metadata" => $fname, "metadata" => $fname,
"gunid" => $pars['gunid'], "gunid" => $pars['gunid'],
"filetype" => "playlist" "filetype" => "playlist"
); );
$storedFile = StoredFile::Insert($values); $storedFile = StoredFile::Insert($values);
if (PEAR::isError($storedFile)) { if (PEAR::isError($storedFile)) {
return $storedFile; return $storedFile;
} }
$res = $storedFile->getId(); $res = $storedFile->getId();
@unlink($fname); @unlink($fname);
break; break;
case "playlistPkg": case "playlistPkg":
$chsum = md5_file($fname); $chsum = md5_file($fname);
// importPlaylistOpen: // importPlaylistOpen:
$res = $this->bsOpenPut($chsum, NULL, $owner); $res = $this->bsOpenPut($chsum, NULL, $owner);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
$dest = $res['fname']; $dest = $res['fname'];
$token = $res['token']; $token = $res['token'];
copy($fname, $dest); copy($fname, $dest);
$r = $this->importPlaylistClose($token); $r = $this->importPlaylistClose($token);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
@unlink($fname); @unlink($fname);
return $r; return $r;
@ -1481,14 +1481,14 @@ class LocStor extends BasicStor {
@unlink($fname); @unlink($fname);
$results = $this->localSearch($criteria); $results = $this->localSearch($criteria);
if (PEAR::isError($results)) { if (PEAR::isError($results)) {
return $results; return $results;
} }
$realfile = tempnam($this->accessDir, 'searchjob_'); $realfile = tempnam($this->accessDir, 'searchjob_');
@chmod($realfile, 0660); @chmod($realfile, 0660);
$len = file_put_contents($realfile, serialize($results)); $len = file_put_contents($realfile, serialize($results));
$acc = BasicStor::bsAccess($realfile, '', NULL, 'download'); $acc = BasicStor::bsAccess($realfile, '', NULL, 'download');
if (PEAR::isError($acc)) { if (PEAR::isError($acc)) {
return $acc; return $acc;
} }
$url = BasicStor::GetUrlPart()."access/".basename($acc['fname']); $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
$chsum = md5_file($realfile); $chsum = md5_file($realfile);
@ -1523,227 +1523,227 @@ class LocStor extends BasicStor {
*/ */
function downloadOpen($sessid, $trtype, $pars=array()) function downloadOpen($sessid, $trtype, $pars=array())
{ {
// global $CC_CONFIG; // global $CC_CONFIG;
// switch ($trtype) { // switch ($trtype) {
// case "unknown": // case "unknown":
// case "audioclip": // case "audioclip":
// case "metadata": // case "metadata":
// case "playlist": // case "playlist":
// case "playlistPkg": // case "playlistPkg":
// if (!isset($pars['gunid'])) { // if (!isset($pars['gunid'])) {
// return PEAR::raiseError("Archive::downloadOpen: gunid not set"); // return PEAR::raiseError("Archive::downloadOpen: gunid not set");
// } // }
// break; // break;
// } // }
// $gunid = $pars['gunid']; // $gunid = $pars['gunid'];
// // resolve trtype by object type: // // resolve trtype by object type:
// if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) { // if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
// $media = StoredFile::RecallByGunid($gunid); // $media = StoredFile::RecallByGunid($gunid);
// $trtype2 = $media->getType(); // $trtype2 = $media->getType();
// if (PEAR::isError($trtype2)) { // if (PEAR::isError($trtype2)) {
// return $trtype2; // return $trtype2;
// } // }
// // required with content: // // required with content:
// $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ? // $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
// 'playlistPkg' : $trtype2); // 'playlistPkg' : $trtype2);
// //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid"); // //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
// } // }
// switch ($trtype) { // switch ($trtype) {
// case "audioclip": // case "audioclip":
// $res = $this->downloadRawAudioDataOpen($sessid, $gunid); // $res = $this->downloadRawAudioDataOpen($sessid, $gunid);
// break; // break;
// case "metadata": // case "metadata":
// $res = $this->downloadMetadataOpen($sessid, $gunid); // $res = $this->downloadMetadataOpen($sessid, $gunid);
// break; // break;
// case "playlist": // case "playlist":
// $res = $this->accessPlaylist($sessid, $gunid); // $res = $this->accessPlaylist($sessid, $gunid);
// break; // break;
// case "playlistPkg": // case "playlistPkg":
// $res = $this->bsExportPlaylistOpen($gunid); // $res = $this->bsExportPlaylistOpen($gunid);
// if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
// return $res; // return $res;
// } // }
// $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_'); // $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
// $plfpath = "$tmpn.lspl"; // $plfpath = "$tmpn.lspl";
// copy($res['fname'], $plfpath); // copy($res['fname'], $plfpath);
// $res = $this->bsExportPlaylistClose($res['token']); // $res = $this->bsExportPlaylistClose($res['token']);
// if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
// return $res; // return $res;
// } // }
// $fname = "transported_playlist.lspl"; // $fname = "transported_playlist.lspl";
// $id = BasicStor::IdFromGunid($gunid); // $id = BasicStor::IdFromGunid($gunid);
// $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download'); // $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
// if (PEAR::isError($acc)) { // if (PEAR::isError($acc)) {
// return $acc; // return $acc;
// } // }
// $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']); // $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
// $chsum = md5_file($plfpath); // $chsum = md5_file($plfpath);
// $size = filesize($plfpath); // $size = filesize($plfpath);
// $res = array( // $res = array(
// 'url'=>$url, 'token'=>$acc['token'], // 'url'=>$url, 'token'=>$acc['token'],
// 'chsum'=>$chsum, 'size'=>$size, // 'chsum'=>$chsum, 'size'=>$size,
// 'filename'=>$fname // 'filename'=>$fname
// ); // );
// break; // break;
// case "searchjob": // case "searchjob":
// $res = $pars; // $res = $pars;
// break; // break;
// case "file": // case "file":
// $res = array(); // $res = array();
// break; // break;
// default: // default:
// return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)"); // return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
// } // }
// if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
// return $res; // return $res;
// } // }
// switch ($trtype) { // switch ($trtype) {
// case "audioclip": // case "audioclip":
// case "metadata": // case "metadata":
// case "playlist": // case "playlist":
// case "playlistPkg": // case "playlistPkg":
// $f = StoredFile::RecallByGunid($gunid); // $f = StoredFile::RecallByGunid($gunid);
// $title = $f->getTitle(); // $title = $f->getTitle();
// break; // break;
// case "searchjob": // case "searchjob":
// $title = 'searchjob'; // $title = 'searchjob';
// break; // break;
// case "file": // case "file":
// $title = 'regular file'; // $title = 'regular file';
// break; // break;
// default: // default:
// } // }
// $res['title'] = $title; // $res['title'] = $title;
// $res['trtype'] = $trtype; // $res['trtype'] = $trtype;
// return $res; // return $res;
} }
/** /**
* Close download transport * Close download transport
* *
* @param string $token * @param string $token
* transport token * transport token
* @param string $trtype * @param string $trtype
* transport type * transport type
* @return array * @return array
* hasharray with: * hasharray with:
* url string: writable URL * url string: writable URL
* token string: PUT token * token string: PUT token
*/ */
function downloadClose($token, $trtype) function downloadClose($token, $trtype)
{ {
switch ($trtype) { switch ($trtype) {
case "audioclip": case "audioclip":
$res = $this->downloadRawAudioDataClose($token); $res = $this->downloadRawAudioDataClose($token);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $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);
} }
} return $res;
return $res; case "metadata":
case "searchjob": $res = $this->downloadMetadataClose($token);
$res = BasicStor::bsRelease($token, 'download'); return $res;
return $res; case "playlist":
case "file": $res = $this->releasePlaylist(NULL/*$sessid*/, $token);
return array(); return $res;
default: case "playlistPkg":
return PEAR::raiseError("Archive::downloadClose: NotImpl ($trtype)"); $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 * Prepare hub initiated transport
* *
* @param string $target * @param string $target
* hostname of transport target * hostname of transport target
* @param string $trtype * @param string $trtype
* transport type * transport type
* @param string $direction * @param string $direction
* 'up' | 'down' * 'up' | 'down'
* @param array $pars * @param array $pars
* transport parameters * transport parameters
* @return mixed * @return mixed
*/ */
function prepareHubInitiatedTransfer( function prepareHubInitiatedTransfer(
$target, $trtype='file', $direction='up',$pars=array()) $target, $trtype='file', $direction='up',$pars=array())
{ {
$tr = new Transport($this); $tr = new Transport($this);
$trec = TransportRecord::create($tr, $trtype, $direction, $trec = TransportRecord::create($tr, $trtype, $direction,
array_merge($pars, array('target'=>$target))); array_merge($pars, array('target'=>$target)));
if (PEAR::isError($trec)) { if (PEAR::isError($trec)) {
return $trec; return $trec;
}
return TRUE;
} }
return TRUE;
}
/** /**
* List hub initiated transports * List hub initiated transports
* *
* @param string $target * @param string $target
* hostname of transport target * hostname of transport target
* @param string $direction * @param string $direction
* 'up' | 'down' * 'up' | 'down'
* @param string $trtok * @param string $trtok
* transport token * transport token
* @return mixed * @return mixed
*/ */
function listHubInitiatedTransfers( function listHubInitiatedTransfers(
$target=NULL, $direction=NULL, $trtok=NULL) $target=NULL, $direction=NULL, $trtok=NULL)
{ {
$tr = new Transport($this); $tr = new Transport($this);
$res = $tr->getTransports($direction, $target, $trtok); $res = $tr->getTransports($direction, $target, $trtok);
return $res; 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;
} }
$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 } // class LocStor
?> ?>

View file

@ -44,19 +44,19 @@ class Prefs {
{ {
$subjid = GreenBox::GetSessUserId($sessid); $subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) { if (PEAR::isError($subjid)) {
return $subjid; return $subjid;
} }
if (is_null($subjid)) { if (is_null($subjid)) {
return PEAR::raiseError("Prefs::loadPref: invalid session id", return PEAR::raiseError("Prefs::loadPref: invalid session id",
GBERR_SESS); GBERR_SESS);
} }
$val = $this->readVal($subjid, $key); $val = $this->readVal($subjid, $key);
if (PEAR::isError($val)) { if (PEAR::isError($val)) {
return $val; return $val;
} }
if ($val === FALSE) { if ($val === FALSE) {
return PEAR::raiseError("Prefs::loadPref: invalid preference key", return PEAR::raiseError("Prefs::loadPref: invalid preference key",
GBERR_PREF); GBERR_PREF);
} }
return $val; return $val;
} }
@ -77,20 +77,19 @@ class Prefs {
{ {
$subjid = GreenBox::GetSessUserId($sessid); $subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) { if (PEAR::isError($subjid)) {
return $subjid; return $subjid;
} }
if (is_null($subjid)) { if (is_null($subjid)) {
return PEAR::raiseError("Prefs::savePref: invalid session id", return PEAR::raiseError("Prefs::savePref: invalid session id", GBERR_SESS);
GBERR_SESS);
} }
$r = $this->update($subjid, $key, $value); $r = $this->update($subjid, $key, $value);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
if ($r === FALSE) { if ($r === FALSE) {
$r = $this->insert($subjid, $key, $value); $r = $this->insert($subjid, $key, $value);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
} }
return TRUE; return TRUE;
@ -110,19 +109,17 @@ class Prefs {
{ {
$subjid = GreenBox::GetSessUserId($sessid); $subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) { if (PEAR::isError($subjid)) {
return $subjid; return $subjid;
} }
if (is_null($subjid)) { if (is_null($subjid)) {
return PEAR::raiseError("Prefs::delPref: invalid session id", return PEAR::raiseError("Prefs::delPref: invalid session id", GBERR_SESS);
GBERR_SESS);
} }
$r = $this->delete($subjid, $key); $r = $this->delete($subjid, $key);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
if ($r === FALSE) { if ($r === FALSE) {
return PEAR::raiseError("Prefs::delPref: invalid preference key", return PEAR::raiseError("Prefs::delPref: invalid preference key", GBERR_PREF);
GBERR_PREF);
} }
return TRUE; return TRUE;
} }
@ -146,7 +143,7 @@ class Prefs {
// if sessid is would be used here fix Transport::cronCallMethod ! // if sessid is would be used here fix Transport::cronCallMethod !
$subjid = Subjects::GetSubjId($group); $subjid = Subjects::GetSubjId($group);
if (PEAR::isError($subjid)) { if (PEAR::isError($subjid)) {
return $subjid; return $subjid;
} }
if (is_null($subjid)) { if (is_null($subjid)) {
return PEAR::raiseError( return PEAR::raiseError(
@ -154,7 +151,7 @@ class Prefs {
} }
$val = $this->readVal($subjid, $key); $val = $this->readVal($subjid, $key);
if (PEAR::isError($val)) { if (PEAR::isError($val)) {
return $val; return $val;
} }
if ($val === FALSE) { if ($val === FALSE) {
if ($returnErrorIfKeyNotExists) { if ($returnErrorIfKeyNotExists) {
@ -185,7 +182,7 @@ class Prefs {
{ {
$uid = GreenBox::GetSessUserId($sessid); $uid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($uid)) { if (PEAR::isError($uid)) {
return $uid; return $uid;
} }
if (is_null($uid)) { if (is_null($uid)) {
return PEAR::raiseError( return PEAR::raiseError(
@ -193,7 +190,7 @@ class Prefs {
} }
$gid = Subjects::GetSubjId($group); $gid = Subjects::GetSubjId($group);
if (PEAR::isError($gid)) { if (PEAR::isError($gid)) {
return $gid; return $gid;
} }
if (is_null($gid)) { if (is_null($gid)) {
return PEAR::raiseError( return PEAR::raiseError(
@ -201,7 +198,7 @@ class Prefs {
} }
$memb = Subjects::IsMemberOf($uid, $gid); $memb = Subjects::IsMemberOf($uid, $gid);
if (PEAR::isError($memb)) { if (PEAR::isError($memb)) {
return $memb; return $memb;
} }
if (!$memb) { if (!$memb) {
return PEAR::raiseError( return PEAR::raiseError(
@ -209,12 +206,12 @@ class Prefs {
} }
$r = $this->update($gid, $key, $value); $r = $this->update($gid, $key, $value);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
if ($r === FALSE) { if ($r === FALSE) {
$r = $this->insert($gid, $key, $value); $r = $this->insert($gid, $key, $value);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
} }
return TRUE; return TRUE;
@ -235,7 +232,7 @@ class Prefs {
{ {
$uid = GreenBox::GetSessUserId($sessid); $uid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($uid)) { if (PEAR::isError($uid)) {
return $uid; return $uid;
} }
if (is_null($uid)) { if (is_null($uid)) {
return PEAR::raiseError( return PEAR::raiseError(
@ -243,7 +240,7 @@ class Prefs {
} }
$gid = Subjects::GetSubjId($group); $gid = Subjects::GetSubjId($group);
if (PEAR::isError($gid)) { if (PEAR::isError($gid)) {
return $gid; return $gid;
} }
if (is_null($gid)) { if (is_null($gid)) {
return PEAR::raiseError( return PEAR::raiseError(
@ -251,7 +248,7 @@ class Prefs {
} }
$memb = Subjects::IsMemberOf($uid, $gid); $memb = Subjects::IsMemberOf($uid, $gid);
if (PEAR::isError($memb)) { if (PEAR::isError($memb)) {
return $memb; return $memb;
} }
if (!$memb) { if (!$memb) {
return PEAR::raiseError( return PEAR::raiseError(
@ -259,7 +256,7 @@ class Prefs {
} }
$r = $this->delete($gid, $key); $r = $this->delete($gid, $key);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
if ($r === FALSE) { if ($r === FALSE) {
return PEAR::raiseError( return PEAR::raiseError(
@ -287,7 +284,7 @@ class Prefs {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$id = $CC_DBC->nextId($CC_CONFIG['prefSequence']); $id = $CC_DBC->nextId($CC_CONFIG['prefSequence']);
if (PEAR::isError($id)) { if (PEAR::isError($id)) {
return $id; return $id;
} }
$r = $CC_DBC->query(" $r = $CC_DBC->query("
INSERT INTO ".$CC_CONFIG['prefTable']." INSERT INTO ".$CC_CONFIG['prefTable']."
@ -296,7 +293,7 @@ class Prefs {
($id, $subjid, '$keystr', '$valstr') ($id, $subjid, '$keystr', '$valstr')
"); ");
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return $id; return $id;
} }
@ -320,10 +317,10 @@ class Prefs {
WHERE subjid=$subjid AND keystr='$keystr' WHERE subjid=$subjid AND keystr='$keystr'
"); ");
if (PEAR::isError($val)) { if (PEAR::isError($val)) {
return $val; return $val;
} }
if (is_null($val)) { if (is_null($val)) {
return FALSE; return FALSE;
} }
return $val; return $val;
} }
@ -345,10 +342,10 @@ class Prefs {
WHERE subjid=$subjid WHERE subjid=$subjid
"); ");
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
if (is_null($res)) { if (is_null($res)) {
return FALSE; return FALSE;
} }
return $res; return $res;
} }
@ -374,10 +371,10 @@ class Prefs {
WHERE subjid=$subjid AND keystr='$keystr' WHERE subjid=$subjid AND keystr='$keystr'
"); ");
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
if ($CC_DBC->affectedRows() < 1) { if ($CC_DBC->affectedRows() < 1) {
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@ -400,10 +397,10 @@ class Prefs {
WHERE subjid=$subjid AND keystr='$keystr' WHERE subjid=$subjid AND keystr='$keystr'
"); ");
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
if ($CC_DBC->affectedRows() < 1) { if ($CC_DBC->affectedRows() < 1) {
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@ -422,7 +419,7 @@ class Prefs {
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ'; $testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
$r = savePref($sessid, $testKey, $testVal); $r = savePref($sessid, $testKey, $testVal);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$val = loadPref($sessid, $testKey); $val = loadPref($sessid, $testKey);
if ($val != $testVal) { if ($val != $testVal) {
@ -431,7 +428,7 @@ class Prefs {
} }
$r = savePref($sessid, $testKey, ''); $r = savePref($sessid, $testKey, '');
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$val = loadPref($sessid, $testKey); $val = loadPref($sessid, $testKey);
if ($val != $testVal) { if ($val != $testVal) {

View file

@ -35,12 +35,12 @@ class Renderer
// recall playlist: // recall playlist:
$pl = StoredFile::RecallByGunid($plid); $pl = StoredFile::RecallByGunid($plid);
if (is_null($pl) || PEAR::isError($pl)) { if (is_null($pl) || PEAR::isError($pl)) {
return $pl; return $pl;
} }
// smil export: // smil export:
$smil = $pl->outputToSmil(); $smil = $pl->outputToSmil();
if (PEAR::isError($smil)) { if (PEAR::isError($smil)) {
return $smil; return $smil;
} }
// temporary file for smil: // temporary file for smil:
$tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_'); $tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_');
@ -56,7 +56,7 @@ class Renderer
// open access to output file: /*gunid*/ /*parent*/ // open access to output file: /*gunid*/ /*parent*/
$acc = BasicStor::bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner); $acc = BasicStor::bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
if (PEAR::isError($acc)) { if (PEAR::isError($acc)) {
return $acc; return $acc;
} }
extract($acc); extract($acc);
$statf = Renderer::getStatusFile($gb, $token); $statf = Renderer::getStatusFile($gb, $token);
@ -70,7 +70,7 @@ class Renderer
if ($res === FALSE) { if ($res === FALSE) {
return PEAR::raiseError( return PEAR::raiseError(
'Renderer::rnRender2File: Error running renderer' 'Renderer::rnRender2File: Error running renderer'
); );
} }
return array('token'=>$token); return array('token'=>$token);
} }
@ -93,7 +93,7 @@ class Renderer
if (!file_exists($statf)) { if (!file_exists($statf)) {
return PEAR::raiseError( return PEAR::raiseError(
'Renderer::rnRender2FileCheck: Invalid token' 'Renderer::rnRender2FileCheck: Invalid token'
); );
} }
$status = trim(file_get_contents($statf)); $status = trim(file_get_contents($statf));
$url = Renderer::getUrl($gb, $token); $url = Renderer::getUrl($gb, $token);
@ -142,7 +142,7 @@ class Renderer
global $CC_CONFIG; global $CC_CONFIG;
$r = BasicStor::bsRelease($token, 'render'); $r = BasicStor::bsRelease($token, 'render');
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$realOgg = $r['realFname']; $realOgg = $r['realFname'];
$tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT); $tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT);
@ -171,7 +171,7 @@ class Renderer
{ {
$r = Renderer::rnRender2FileCheck($gb, $token); $r = Renderer::rnRender2FileCheck($gb, $token);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$status = $r['status']; $status = $r['status'];
$res = array('status' => $status, 'gunid'=>'NULL'); $res = array('status' => $status, 'gunid'=>'NULL');
@ -182,7 +182,7 @@ class Renderer
case "success": case "success":
$r = Renderer::rnRender2StorageCore($gb, $token); $r = Renderer::rnRender2StorageCore($gb, $token);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$res['gunid'] = $r['gunid']; $res['gunid'] = $r['gunid'];
break; break;
@ -205,36 +205,36 @@ class Renderer
*/ */
function rnRender2StorageCore(&$gb, $token) function rnRender2StorageCore(&$gb, $token)
{ {
// $r = BasicStor::bsRelease($token, 'render'); // $r = BasicStor::bsRelease($token, 'render');
// if (PEAR::isError($r)) { // if (PEAR::isError($r)) {
// return $r; // return $r;
// } // }
// $realOgg = $r['realFname']; // $realOgg = $r['realFname'];
// $owner = $r['owner']; // $owner = $r['owner'];
// $gunid = $r['gunid']; // $gunid = $r['gunid'];
// $fileName = 'rendered_playlist'; // $fileName = 'rendered_playlist';
// $id = BasicStor::IdFromGunid($gunid); // $id = BasicStor::IdFromGunid($gunid);
// if (PEAR::isError($id)) { // if (PEAR::isError($id)) {
// return $id; // return $id;
// } // }
// $mdata = ''; // $mdata = '';
// foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) { // foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
// $val = $gb->bsGetMetadataValue($id, $item); // $val = $gb->bsGetMetadataValue($id, $item);
// $mdata .= " <$item>$val</$item>\n"; // $mdata .= " <$item>$val</$item>\n";
// } // }
// $mdata = "<audioClip>\n <metadata>\n$mdata </metadata>\n</audioClip>\n"; // $mdata = "<audioClip>\n <metadata>\n$mdata </metadata>\n</audioClip>\n";
// //$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n"; // //$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
// $values = array( // $values = array(
// "filename" => $fileName, // "filename" => $fileName,
// "filepath" => $realOgg, // "filepath" => $realOgg,
// "metadata" => $mdata, // "metadata" => $mdata,
// "filetype" => "audioclip" // "filetype" => "audioclip"
// ); // );
// $storedFile = $gb->bsPutFile($values); // $storedFile = $gb->bsPutFile($values);
// if (PEAR::isError($storedFile)) { // if (PEAR::isError($storedFile)) {
// return $storedFile; // return $storedFile;
// } // }
// return array('gunid' => $storedFile->getGunid()); // return array('gunid' => $storedFile->getGunid());
} }

View file

@ -61,7 +61,7 @@ class Restore {
$this->token = null; $this->token = null;
$this->logFile = $CC_CONFIG['bufferDir'].'/'.$this->ACCESS_TYPE.'.log'; $this->logFile = $CC_CONFIG['bufferDir'].'/'.$this->ACCESS_TYPE.'.log';
if ($this->loglevel == 'debug') { if ($this->loglevel == 'debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n"); $this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
} }
} }
@ -131,9 +131,9 @@ class Restore {
} }
$r['status'] = $stat; $r['status'] = $stat;
if ($stat=='fault') { if ($stat=='fault') {
$r['faultString'] = $message; $r['faultString'] = $message;
} else { } else {
$r['faultString'] = ''; $r['faultString'] = '';
} }
return $r; return $r;
} else { } else {
@ -193,8 +193,8 @@ class Restore {
//simple check of archive format //simple check of archive format
if (is_dir($this->tmpDir.'audioClip/') && if (is_dir($this->tmpDir.'audioClip/') &&
is_dir($this->tmpDir.'meta-inf/') && is_dir($this->tmpDir.'meta-inf/') &&
is_dir($this->tmpDir.'playlist/')) { is_dir($this->tmpDir.'playlist/')) {
//search metafiles //search metafiles
$this->metafiles = $this->getMetaFiles(); $this->metafiles = $this->getMetaFiles();
#$this->addLogItem('metafiles:'.print_r($this->metafiles,true)); #$this->addLogItem('metafiles:'.print_r($this->metafiles,true));
@ -205,15 +205,15 @@ class Restore {
$this->addLogItem("-E- ".date("Ymd-H:i:s"). $this->addLogItem("-E- ".date("Ymd-H:i:s").
" startRestore - addFileToStorage \n". " startRestore - addFileToStorage \n".
"(".$put->getMessage()."/".$put->getUserInfo().")\n" "(".$put->getMessage()."/".$put->getUserInfo().")\n"
); );
file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo()); file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
return; return;
} }
} }
} else { } else {
$this->addLogItem("-E- ".date("Ymd-H:i:s")." startRestore - invalid archive format\n"); $this->addLogItem("-E- ".date("Ymd-H:i:s")." startRestore - invalid archive format\n");
file_put_contents($this->statusFile, 'fault|invalid archive format'); file_put_contents($this->statusFile, 'fault|invalid archive format');
return; return;
} }
file_put_contents($this->statusFile, 'success'); file_put_contents($this->statusFile, 'success');
// unlink($backupfile); // unlink($backupfile);
@ -238,13 +238,13 @@ class Restore {
$playlists = scandir($this->tmpDir.'playlist/'); $playlists = scandir($this->tmpDir.'playlist/');
for ($i = 0; $i < count($audioclips); $i++) { for ($i = 0; $i < count($audioclips); $i++) {
if (strpos($audioclips[$i],'xml')!==false) if (strpos($audioclips[$i],'xml')!==false)
$r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i], $r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
'type' => 'audioClip', 'type' => 'audioClip',
'id' => str_replace('.xml','',$audioclips[$i])); 'id' => str_replace('.xml','',$audioclips[$i]));
} }
for ($i = 0; $i < count($playlists); $i++) { for ($i = 0; $i < count($playlists); $i++) {
if (strpos($playlists[$i],'xml') !== false) if (strpos($playlists[$i],'xml') !== false)
$r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i], $r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i],
'type' => 'playlist', 'type' => 'playlist',
'id' => str_replace('.xml','',$playlists[$i])); 'id' => str_replace('.xml','',$playlists[$i]));
} }
@ -265,83 +265,83 @@ class Restore {
* @return mixed * @return mixed
* true if success or PEAR_error * true if success or PEAR_error
*/ */
// function addFileToStorage($file,$type,$gunid) // function addFileToStorage($file,$type,$gunid)
// { // {
// if ($this->loglevel=='debug') { // if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n"); // $this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n");
// } // }
// require_once("XmlParser.php"); // require_once("XmlParser.php");
// $tree = XmlParser::parse($file); // $tree = XmlParser::parse($file);
// $mediaFileLP = str_replace('.xml','',$file); // $mediaFileLP = str_replace('.xml','',$file);
// $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:''; // $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:'';
// $ex = $this->gb->existsFile($this->sessid,$gunid); // $ex = $this->gb->existsFile($this->sessid,$gunid);
// if (PEAR::isError($ex)) { // if (PEAR::isError($ex)) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s"). // $this->addLogItem("-E- ".date("Ymd-H:i:s").
// " addFileToStorage - existsFile($gunid) ". // " addFileToStorage - existsFile($gunid) ".
// "(".$ex->getMessage()."/".$ex->getUserInfo().")\n" // "(".$ex->getMessage()."/".$ex->getUserInfo().")\n"
// ); // );
// } // }
// if (!PEAR::isError($ex) && $ex) { // file is exists in storage server // if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
// //replace it // //replace it
// $id = BasicStor::IdFromGunid($gunid); // $id = BasicStor::IdFromGunid($gunid);
// $replace = $this->gb->replaceFile( // $replace = $this->gb->replaceFile(
// $id, # id int, virt.file's local id // $id, # id int, virt.file's local id
// $mediaFileLP, # mediaFileLP string, local path of media file // $mediaFileLP, # mediaFileLP string, local path of media file
// $file, # mdataFileLP string, local path of metadata file // $file, # mdataFileLP string, local path of metadata file
// $this->sessid); # sessid string, session id // $this->sessid); # sessid string, session id
// if (PEAR::isError($replace)) { // if (PEAR::isError($replace)) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s"). // $this->addLogItem("-E- ".date("Ymd-H:i:s").
// " addFileToStorage - replaceFile Error ". // " addFileToStorage - replaceFile Error ".
// "(".$replace->getMessage()."/".$replace->getUserInfo().")\n" // "(".$replace->getMessage()."/".$replace->getUserInfo().")\n"
// ); // );
// file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo()); // file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo());
// return $replace; // return $replace;
// } // }
// #$this->addLogItem("replace it \n"); // #$this->addLogItem("replace it \n");
// } else { // } else {
// // add as new // // add as new
// $name = $tree->children[0]->children[0]->content; // $name = $tree->children[0]->children[0]->content;
// if (empty($name)) { // if (empty($name)) {
// $name = $tree->attrs['title']->val; // $name = $tree->attrs['title']->val;
// } // }
// if (empty($name)) { // if (empty($name)) {
// $name = '???'; // $name = '???';
// } // }
// if ($this->loglevel=='debug') { // if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n". // $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
// "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n" // "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
// ); // );
// } // }
// $values = array( // $values = array(
// "filename" => $name, // "filename" => $name,
// "filepath" => $mediaFileLP, // "filepath" => $mediaFileLP,
// "metadata" => $file, // "metadata" => $file,
// "gunid" => $gunid, // "gunid" => $gunid,
// "filetype" => $type // "filetype" => $type
// ); // );
// $put = $this->gb->putFile($values, $this->sessid); // $put = $this->gb->putFile($values, $this->sessid);
// //$this->addLogItem("add as new \n"); // //$this->addLogItem("add as new \n");
// if (PEAR::isError($put)) { // if (PEAR::isError($put)) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s"). // $this->addLogItem("-E- ".date("Ymd-H:i:s").
// " addFileToStorage - putFile Error ". // " addFileToStorage - putFile Error ".
// "(".$put->getMessage()."/".$put->getUserInfo().")\n" // "(".$put->getMessage()."/".$put->getUserInfo().")\n"
// ."\n---\n".file_get_contents($file)."\n---\n" // ."\n---\n".file_get_contents($file)."\n---\n"
// ); // );
// file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo()); // file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
// //$this->addLogItem("Error Object: ".print_r($put,true)."\n"); // //$this->addLogItem("Error Object: ".print_r($put,true)."\n");
// return $put; // return $put;
// } // }
// } // }
// $ac = StoredFile::RecallByGunid($gunid); // $ac = StoredFile::RecallByGunid($gunid);
// if (is_null($ac) || PEAR::isError($ac)) { // if (is_null($ac) || PEAR::isError($ac)) {
// return $ac; // return $ac;
// } // }
// $res = $ac->setState('ready'); // $res = $ac->setState('ready');
// if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
// return $res; // return $res;
// } // }
// return true; // return true;
// } // }
/** /**

View file

@ -4,421 +4,556 @@ require_once("BasicStor.php");
class ScheduleGroup { class ScheduleGroup {
private $groupId; private $groupId;
public function __construct($p_groupId = null) { public function __construct($p_groupId = null) {
$this->groupId = $p_groupId; $this->groupId = $p_groupId;
} }
/** /**
* Convert a date to an ID by stripping out all characters * Return true if the schedule group exists in the DB.
* and padding with zeros. * @return boolean
* */
* @param string $p_dateStr public function exists() {
*/ global $CC_CONFIG, $CC_DBC;
public static function dateToId($p_dateStr) { $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG['scheduleTable']
$p_dateStr = str_replace(":", "", $p_dateStr); ." WHERE group_id=".$this->groupId;
$p_dateStr = str_replace(" ", "", $p_dateStr); $result = $CC_DBC->GetOne($sql);
$p_dateStr = str_replace(".", "", $p_dateStr);
$p_dateStr = str_replace("-", "", $p_dateStr);
$p_dateStr = substr($p_dateStr, 0, 17);
$p_dateStr = str_pad($p_dateStr, 17, "0");
return $p_dateStr;
}
/**
* Add the two times together, return the result.
*
* @param string $p_baseTime
* Specified as YYYY-MM-DD HH:MM:SS
*
* @param string $p_addTime
* Specified as HH:MM:SS.nnnnnn
*
* @return string
* The end time, to the nearest second.
*/
// protected function calculateEndTime($p_startTime, $p_trackTime) {
// $p_trackTime = substr($p_startTime, 0, );
// $start = new DateTime();
// $interval = new DateInterval()
//
// }
/**
* Add a music clip or playlist to the schedule.
*
* @param $p_datetime
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
* @param $p_audioFileId
* (optional, either this or $p_playlistId must be set) DB ID of the audio file
* @param $p_playlistId
* (optional, either this of $p_audioFileId must be set) DB ID of the playlist
* @param $p_options
* Does nothing at the moment.
*
* @return int|PEAR_Error
* Return PEAR_Error if the item could not be added.
* Error code 555 is a scheduling conflict.
*/
public function add($p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
global $CC_CONFIG, $CC_DBC;
if (!is_null($p_audioFileId)) {
// Schedule a single audio track
// Load existing track
$track = StoredFile::Recall($p_audioFileId);
if (is_null($track)) {
return new PEAR_Error("Could not find audio track.");
}
// Check if there are any conflicts with existing entries
$metadata = $track->getMetadata();
$length = trim($metadata["length"]);
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
return new PEAR_Error("Schedule conflict.", 555);
}
// Insert into the table
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$id = $this->dateToId($p_datetime);
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (id, playlist_id, starts, ends, clip_length, group_id, file_id)"
." VALUES ($id, 0, TIMESTAMP '$p_datetime', "
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
." '$length',"
." {$this->groupId}, $p_audioFileId)";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
var_dump($sql);
return $result;
}
return $this->groupId;
} elseif (!is_null($p_playlistId)){
// Schedule a whole playlist
// Load existing playlist
$playlist = Playlist::Recall($p_playlistId);
if (is_null($playlist)) {
return new PEAR_Error("Could not find playlist.");
}
// Check if there are any conflicts with existing entries
$length = trim($playlist->getLength());
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
return new PEAR_Error("Schedule conflict.", 555);
}
// Insert all items into the schedule
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$id = $this->dateToId($p_datetime);
$itemStartTime = $p_datetime;
$plItems = $playlist->getContents();
foreach ($plItems as $row) {
$trackLength = $row["cliplength"];
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (id, playlist_id, starts, ends, group_id, file_id,"
." clip_length, cue_in, cue_out, fade_in, fade_out)"
." VALUES ($id, $p_playlistId, TIMESTAMP '$itemStartTime', "
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
var_dump($sql); return $result;
return $result;
} }
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'"); return $result != "0";
$id = $this->dateToId($itemStartTime);
}
return $this->groupId;
} }
}
public function addAfter($p_groupId, $p_audioFileId) { /**
global $CC_CONFIG, $CC_DBC; * Convert a date to an ID by stripping out all characters
// Get the end time for the given entry * and padding with zeros.
$sql = "SELECT ends FROM ".$CC_CONFIG["scheduleTable"] *
." WHERE group_id=$p_groupId"; * @param string $p_dateStr
$startTime = $CC_DBC->GetOne($sql); */
return $this->add($startTime, $p_audioFileId); public static function dateToId($p_dateStr) {
} $p_dateStr = str_replace(":", "", $p_dateStr);
$p_dateStr = str_replace(" ", "", $p_dateStr);
public function update() { $p_dateStr = str_replace(".", "", $p_dateStr);
$p_dateStr = str_replace("-", "", $p_dateStr);
} $p_dateStr = substr($p_dateStr, 0, 17);
$p_dateStr = str_pad($p_dateStr, 17, "0");
/** return $p_dateStr;
* Remove the group from the schedule.
* Note: does not check if it is in the past, you can remove anything.
*
* @return boolean
* TRUE on success, false if there is no group ID defined.
*/
public function remove() {
global $CC_CONFIG, $CC_DBC;
if (is_null($this->groupId) || !is_numeric($this->groupId)) {
return false;
} }
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
." WHERE group_id = ".$this->groupId;
return $CC_DBC->query($sql); /**
} * Add the two times together, return the result.
*
* @param string $p_baseTime
* Specified as YYYY-MM-DD HH:MM:SS
*
* @param string $p_addTime
* Specified as HH:MM:SS.nnnnnn
*
* @return string
* The end time, to the nearest second.
*/
// protected function calculateEndTime($p_startTime, $p_trackTime) {
// $p_trackTime = substr($p_startTime, 0, );
// $start = new DateTime();
// $interval = new DateInterval()
//
// }
/** /**
* Return the number of items in this group. * Add a music clip or playlist to the schedule.
* @return string *
*/ * @param $p_datetime
public function count() { * In the format YYYY-MM-DD HH:MM:SS.mmmmmm
global $CC_CONFIG, $CC_DBC; * @param $p_audioFileId
$sql = "SELECT COUNT(*) FROM {$CC_CONFIG['scheduleTable']}" * (optional, either this or $p_playlistId must be set) DB ID of the audio file
." WHERE group_id={$this->groupId}"; * @param $p_playlistId
return $CC_DBC->GetOne($sql); * (optional, either this of $p_audioFileId must be set) DB ID of the playlist
} * @param $p_options
* Does nothing at the moment.
*
* @return int|PEAR_Error
* Return PEAR_Error if the item could not be added.
* Error code 555 is a scheduling conflict.
*/
public function add($p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
global $CC_CONFIG, $CC_DBC;
if (!is_null($p_audioFileId)) {
// Schedule a single audio track
/* // Load existing track
* Return the list of items in this group as a 2D array. $track = StoredFile::Recall($p_audioFileId);
* @return array if (is_null($track)) {
*/ return new PEAR_Error("Could not find audio track.");
public function getItems() { }
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT * FROM {$CC_CONFIG['scheduleTable']}"
." WHERE group_id={$this->groupId}";
return $CC_DBC->GetAll($sql);
}
public function reschedule($toDateTime) { // Check if there are any conflicts with existing entries
global $CC_CONFIG, $CC_DBC; $metadata = $track->getMetadata();
// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends=" $length = trim($metadata["length"]);
} if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
return new PEAR_Error("Schedule conflict.", 555);
}
// Insert into the table
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$id = $this->dateToId($p_datetime);
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (id, playlist_id, starts, ends, clip_length, group_id, file_id)"
." VALUES ($id, 0, TIMESTAMP '$p_datetime', "
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
." '$length',"
." {$this->groupId}, $p_audioFileId)";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
//var_dump($sql);
return $result;
}
return $this->groupId;
} elseif (!is_null($p_playlistId)){
// Schedule a whole playlist
// Load existing playlist
$playlist = Playlist::Recall($p_playlistId);
if (is_null($playlist)) {
return new PEAR_Error("Could not find playlist.");
}
// Check if there are any conflicts with existing entries
$length = trim($playlist->getLength());
//var_dump($length);
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
return new PEAR_Error("Schedule conflict.", 555);
}
// Insert all items into the schedule
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$id = $this->dateToId($p_datetime);
$itemStartTime = $p_datetime;
$plItems = $playlist->getContents();
//var_dump($plItems);
foreach ($plItems as $row) {
$trackLength = $row["cliplength"];
//var_dump($trackLength);
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (id, playlist_id, starts, ends, group_id, file_id,"
." clip_length, cue_in, cue_out, fade_in, fade_out)"
." VALUES ($id, $p_playlistId, TIMESTAMP '$itemStartTime', "
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
//var_dump($sql);
return $result;
}
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
$id = $this->dateToId($itemStartTime);
}
return $this->groupId;
}
}
public function addAfter($p_groupId, $p_audioFileId) {
global $CC_CONFIG, $CC_DBC;
// Get the end time for the given entry
$sql = "SELECT ends FROM ".$CC_CONFIG["scheduleTable"]
." WHERE group_id=$p_groupId";
$startTime = $CC_DBC->GetOne($sql);
return $this->add($startTime, $p_audioFileId);
}
public function update() {
}
/**
* Remove the group from the schedule.
* Note: does not check if it is in the past, you can remove anything.
*
* @return boolean
* TRUE on success, false if there is no group ID defined.
*/
public function remove() {
global $CC_CONFIG, $CC_DBC;
if (is_null($this->groupId) || !is_numeric($this->groupId)) {
return false;
}
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
." WHERE group_id = ".$this->groupId;
//echo $sql;
return $CC_DBC->query($sql);
}
/**
* Return the number of items in this group.
* @return string
*/
public function count() {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT COUNT(*) FROM {$CC_CONFIG['scheduleTable']}"
." WHERE group_id={$this->groupId}";
return $CC_DBC->GetOne($sql);
}
/*
* Return the list of items in this group as a 2D array.
* @return array
*/
public function getItems() {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT * FROM {$CC_CONFIG['scheduleTable']}"
." WHERE group_id={$this->groupId}";
return $CC_DBC->GetAll($sql);
}
public function reschedule($toDateTime) {
global $CC_CONFIG, $CC_DBC;
// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends="
}
public function notifyGroupStartPlay() {
global $CC_CONFIG, $CC_DBC;
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
." SET schedule_group_played=TRUE"
." WHERE group_id=".$this->groupId;
return $CC_DBC->query($sql);
}
public function notifyMediaItemStartPlay($p_fileId) {
global $CC_CONFIG, $CC_DBC;
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
." SET media_item_played=TRUE"
." WHERE group_id=".$this->groupId
." AND file_id=".pg_escape_string($p_fileId);
return $CC_DBC->query($sql);
}
} }
class Schedule { class Schedule {
function __construct() { function __construct() {
}
/**
* Return true if there is nothing in the schedule for the given times.
*
* @param string $p_datetime
* @param string $p_length
*
* @return boolean|PEAR_Error
*/
public static function isScheduleEmptyInRange($p_datetime, $p_length) {
global $CC_CONFIG, $CC_DBC;
if (empty($p_length)) {
return new PEAR_Error("Schedule::isSchedulerEmptyInRange: param p_length is empty.");
} }
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
." WHERE (starts >= '$p_datetime') "
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
//$_SESSION["debug"] = $sql;
$count = $CC_DBC->GetOne($sql);
return ($count == '0');
}
// public function onAddTrackToPlaylist($playlistId, $audioTrackId) { /**
// * Return true if there is nothing in the schedule for the given start time
// } * up to the length of time after that.
// *
// public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) { * @param string $p_datetime
// * In the format YYYY-MM-DD HH:MM:SS.mmmmmm
// } * @param string $p_length
* In the format HH:MM:SS.mmmmmm
/** * @return boolean|PEAR_Error
* Return TRUE if file is going to be played in the future. */
* public static function isScheduleEmptyInRange($p_datetime, $p_length) {
* @param string $p_fileId global $CC_CONFIG, $CC_DBC;
*/ if (empty($p_length)) {
public function IsFileScheduledInTheFuture($p_fileId) return new PEAR_Error("Schedule::isSchedulerEmptyInRange: param p_length is empty.");
{ }
global $CC_CONFIG, $CC_DBC; $sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"] ." WHERE (starts >= '$p_datetime') "
." WHERE file_id = {$p_fileId} AND starts > NOW()"; ." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
$count = $CC_DBC->GetOne($sql); //$_SESSION["debug"] = $sql;
if (is_numeric($count) && ($count != '0')) { //var_dump($sql);
return TRUE; $count = $CC_DBC->GetOne($sql);
} else { //var_dump($count);
return FALSE; return ($count == '0');
}
// public function onAddTrackToPlaylist($playlistId, $audioTrackId) {
//
// }
//
// public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) {
//
// }
/**
* Return TRUE if file is going to be played in the future.
*
* @param string $p_fileId
*/
public function IsFileScheduledInTheFuture($p_fileId)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
." WHERE file_id = {$p_fileId} AND starts > NOW()";
$count = $CC_DBC->GetOne($sql);
if (is_numeric($count) && ($count != '0')) {
return TRUE;
} else {
return FALSE;
}
} }
}
/** /**
* Returns array indexed numberically of: * Returns array indexed numberically of:
* "playlistId"/"playlist_id" (aliases to the same thing) * "playlistId"/"playlist_id" (aliases to the same thing)
* "start"/"starts" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn * "start"/"starts" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
* "end"/"ends" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn * "end"/"ends" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
* "group_id"/"id" (aliases to the same thing) * "group_id"/"id" (aliases to the same thing)
* "clip_length" (for playlists only, this is the length of the entire playlist) * "clip_length" (for audio clips this is the length of the audio clip,
* "name" (playlist only) * for playlists this is the length of the entire playlist)
* "creator" (playlist only) * "name" (playlist only)
* "file_id" (audioclip only) * "creator" (playlist only)
* "count" (number of items in the playlist, always 1 for audioclips. * "file_id" (audioclip only)
* Note that playlists with one item will also have count = 1. * "count" (number of items in the playlist, always 1 for audioclips.
* * Note that playlists with one item will also have count = 1.
* @param string $p_fromDateTime *
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn * @param string $p_fromDateTime
* @param string $p_toDateTime * In the format YYYY-MM-DD HH:MM:SS.nnnnnn
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn * @param string $p_toDateTime
* @param boolean $p_playlistsOnly * In the format YYYY-MM-DD HH:MM:SS.nnnnnn
* Retreive playlists as a single item. * @param boolean $p_playlistsOnly
* @return array * Retreive playlists as a single item.
* Returns empty array if nothing found * @return array
*/ * Returns empty array if nothing found
public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) { */
global $CC_CONFIG, $CC_DBC; public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) {
$rows = array(); global $CC_CONFIG, $CC_DBC;
if (!$p_playlistsOnly) { $rows = array();
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"] if (!$p_playlistsOnly) {
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') " ." WHERE (starts >= TIMESTAMP '$p_fromDateTime') "
." AND (ends <= TIMESTAMP '$p_toDateTime')"; ." AND (ends <= TIMESTAMP '$p_toDateTime')";
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
foreach ($rows as &$row) { foreach ($rows as &$row) {
$row["count"] = "1"; $row["count"] = "1";
$row["playlistId"] = $row["playlist_id"]; $row["playlistId"] = $row["playlist_id"];
$row["start"] = $row["starts"]; $row["start"] = $row["starts"];
$row["end"] = $row["ends"]; $row["end"] = $row["ends"];
$row["id"] = $row["group_id"]; $row["id"] = $row["group_id"];
} }
} else { } else {
$sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, " $sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, "
." SUM(clip_length) AS clip_length," ." SUM(clip_length) AS clip_length,"
." MIN(file_id) AS file_id, COUNT(*) as count," ." MIN(file_id) AS file_id, COUNT(*) as count,"
." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends" ." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends"
." FROM ".$CC_CONFIG["scheduleTable"] ." FROM ".$CC_CONFIG["scheduleTable"]
." LEFT JOIN ".$CC_CONFIG["playListTable"]." ON playlist_id = ".$CC_CONFIG["playListTable"].".id" ." LEFT JOIN ".$CC_CONFIG["playListTable"]." ON playlist_id = ".$CC_CONFIG["playListTable"].".id"
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')" ." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')"
." GROUP BY group_id" ." GROUP BY group_id"
." ORDER BY starts"; ." ORDER BY starts";
//var_dump($sql); //var_dump($sql);
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
if (!PEAR::isError($rows)) { if (!PEAR::isError($rows)) {
foreach ($rows as &$row) { foreach ($rows as &$row) {
$row["playlistId"] = $row["playlist_id"]; $row["playlistId"] = $row["playlist_id"];
$row["start"] = $row["starts"]; $row["start"] = $row["starts"];
$row["end"] = $row["ends"]; $row["end"] = $row["ends"];
$row["id"] = $row["group_id"]; $row["id"] = $row["group_id"];
}
}
} }
} return $rows;
} }
return $rows;
}
public function getSchedulerTime() { public function getSchedulerTime() {
} }
public function getCurrentlyPlaying() { public function getCurrentlyPlaying() {
} }
public function getNextItem($nextCount = 1) { public function getNextItem($nextCount = 1) {
} }
public function getStatus() { public function getStatus() {
} }
private static function CcTimeToPypoTime($p_time) { /**
$p_time = substr($p_time, 0, 19); * Convert a time string in the format "YYYY-MM-DD HH:mm:SS"
$p_time = str_replace(" ", "-", $p_time); * to "YYYY-MM-DD-HH-mm-SS".
$p_time = str_replace(":", "-", $p_time); *
return $p_time; * @param string $p_time
} * @return string
*/
private static function CcTimeToPypoTime($p_time)
{
$p_time = substr($p_time, 0, 19);
$p_time = str_replace(" ", "-", $p_time);
$p_time = str_replace(":", "-", $p_time);
return $p_time;
}
private static function PypoTimeToCcTime($p_time) { /**
$t = explode("-", $p_time); * Convert a time string in the format "YYYY-MM-DD-HH-mm-SS" to
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00"; * "YYYY-MM-DD HH:mm:SS".
} *
* @param string $p_time
* @return string
*/
private static function PypoTimeToCcTime($p_time)
{
$t = explode("-", $p_time);
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
}
/** /**
* Export the schedule in json formatted for pypo (the liquidsoap scheduler) * Converts a time value as a string (with format HH:MM:SS.mmmmmm) to
* * millisecs.
* @param string $range *
* In the format "YYYY-MM-DD HH:mm:ss" * @param string $p_time
* @param string $source * @return int
* In the format "YYYY-MM-DD HH:mm:ss" */
*/ private static function WallTimeToMillisecs($p_time)
public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime) {
{ $t = explode(":", $p_time);
global $CC_CONFIG, $CC_DBC; $millisecs = 0;
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime); if (strpos($t[2], ".")) {
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime); $secParts = explode(".", $t[2]);
$range_dt = array('start' => $range_start, 'end' => $range_end); $millisecs = $secParts[1];
//var_dump($range_dt); $millisecs = substr($millisecs, 0, 3);
$millisecs = intval($millisecs);
$seconds = intval($secParts[0]);
} else {
$seconds = intval($t[2]);
}
$ret = $millisecs + ($seconds * 1000) + ($t[1] * 60 * 1000) + ($t[0] * 60 * 60 * 1000);
return $ret;
}
// Scheduler wants everything in a playlist
$data = Schedule::GetItems($range_start, $range_end, true);
//echo "<pre>";var_dump($data);
$playlists = array();
if (is_array($data) && count($data) > 0) /**
{ * Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
foreach ($data as $dx) * Note: currently only supports calculating millisec differences.
{ *
// Is this the first item in the playlist? * @param string $p_time1
$start = $dx['start']; * @param string $p_time2
// chop off subseconds * @return double
$start = substr($start, 0, 19); */
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) /**
{ * Export the schedule in json formatted for pypo (the liquidsoap scheduler)
$scheduleGroup = new ScheduleGroup($playlist["schedule_id"]); *
$items = $scheduleGroup->getItems(); * @param string $range
$medias = array(); * In the format "YYYY-MM-DD HH:mm:ss"
$playlist['subtype'] = '1'; * @param string $source
foreach ($items as $item) * In the format "YYYY-MM-DD HH:mm:ss"
{ */
$storedFile = StoredFile::Recall($item["file_id"]); public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
$uri = $storedFile->getFileUrl(); {
$medias[] = array( 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 "<pre>";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"], 'id' => $storedFile->getGunid(), //$item["file_id"],
'uri' => $uri, 'uri' => $uri,
'fade_in' => $item["fade_in"], 'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]),
'fade_out' => $item["fade_out"], 'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]),
'fade_cross' => 0, 'fade_cross' => 0,
'cue_in' => $item["cue_in"], 'cue_in' => Schedule::WallTimeToMillisecs($item["cue_in"]),
'cue_out' => $item["cue_out"], 'cue_out' => $cueOut,
); 'export_source' => 'scheduler'
} );
$playlist['medias'] = $medias; }
} $playlist['medias'] = $medias;
}
$result = array(); $result = array();
$result['status'] = array('range' => $range_dt, 'version' => 0.2); $result['status'] = array('range' => $range_dt, 'version' => "0.2");
$result['playlists'] = $playlists; $result['playlists'] = $playlists;
$result['check'] = 1; $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();
}
}
} }

View file

@ -58,24 +58,24 @@ class SmilPlaylist {
} }
$lspl = SmilPlaylist::convert2lspl($gb, $path, $gunids, $parr); $lspl = SmilPlaylist::convert2lspl($gb, $path, $gunids, $parr);
if (PEAR::isError($lspl)) { if (PEAR::isError($lspl)) {
return $lspl; return $lspl;
} }
require_once("Playlist.php"); require_once("Playlist.php");
$pl =& Playlist::create($gb, $plid, "imported_SMIL"); $pl =& Playlist::create($gb, $plid, "imported_SMIL");
if (PEAR::isError($pl)) { if (PEAR::isError($pl)) {
return $pl; return $pl;
} }
$r = $pl->lock($gb, $subjid); $r = $pl->lock($gb, $subjid);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$r = $pl->setMetadata($lspl, 'string', 'playlist'); $r = $pl->setMetadata($lspl, 'string', 'playlist');
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$r = $pl->unlock($gb); $r = $pl->unlock($gb);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return $pl; return $pl;
} }
@ -99,7 +99,7 @@ class SmilPlaylist {
extract($parr); extract($parr);
$tree = SmilPlaylist::parse($data); $tree = SmilPlaylist::parse($data);
if (PEAR::isError($tree)) { if (PEAR::isError($tree)) {
return $tree; return $tree;
} }
if ($tree->name != 'smil') { if ($tree->name != 'smil') {
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected"); return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
@ -107,11 +107,11 @@ class SmilPlaylist {
if (isset($tree->children[1])) { if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf( return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag smil", "SmilPlaylist::parse: unexpected tag %s in tag smil",
$tree->children[1]->name $tree->children[1]->name
)); ));
} }
$res = SmilPlaylistBodyElement::convert2lspl( $res = SmilPlaylistBodyElement::convert2lspl(
$gb, $tree->children[0], &$gunids, $parr); $gb, $tree->children[0], &$gunids, $parr);
return $res; return $res;
} }
@ -136,13 +136,13 @@ class SmilPlaylistBodyElement {
if (isset($tree->children[1])) { if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf( return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag body", "SmilPlaylist::parse: unexpected tag %s in tag body",
$tree->children[1]->name $tree->children[1]->name
)); ));
} }
$res = SmilPlaylistParElement::convert2lspl( $res = SmilPlaylistParElement::convert2lspl(
$gb, $tree->children[0], &$gunids, $parr, $ind2); $gb, $tree->children[0], &$gunids, $parr, $ind2);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
$title = basename($rPath); $title = basename($rPath);
$playlength = '0'; $playlength = '0';
@ -165,7 +165,7 @@ class SmilPlaylistBodyElement {
*/ */
class SmilPlaylistParElement { class SmilPlaylistParElement {
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{ {
extract($parr); extract($parr);
if ($tree->name != 'par') { if ($tree->name != 'par') {
@ -176,7 +176,7 @@ class SmilPlaylistParElement {
$ch =& $tree->children[$i]; $ch =& $tree->children[$i];
$r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH); $r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$res .= $r; $res .= $r;
} }
@ -204,7 +204,7 @@ class SmilPlaylistAudioElement {
if (isset($tree->children[2])) { if (isset($tree->children[2])) {
return PEAR::raiseError(sprintf( return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag audio", "SmilPlaylist::parse: unexpected tag %s in tag audio",
$tree->children[2]->name $tree->children[2]->name
)); ));
} }
$res = ''; $fadeIn = 0; $fadeOut = 0; $res = ''; $fadeIn = 0; $fadeOut = 0;
@ -212,7 +212,7 @@ class SmilPlaylistAudioElement {
$ch =& $tree->children[$i]; $ch =& $tree->children[$i];
$r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2); $r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
switch ($r['type']) { switch ($r['type']) {
case "fadeIn": $fadeIn = $r['val']; break; case "fadeIn": $fadeIn = $r['val']; break;
@ -225,7 +225,7 @@ class SmilPlaylistAudioElement {
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut); $fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n"; $fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
} else { } else {
$fInfo = ''; $fInfo = '';
} }
$plElGunid = StoredFile::CreateGunid(); $plElGunid = StoredFile::CreateGunid();
$acGunid = $gunid; $acGunid = $gunid;
@ -238,19 +238,19 @@ class SmilPlaylistAudioElement {
case "m3u": case "m3u":
$type = 'playlist'; $type = 'playlist';
$acId = $gb->bsImportPlaylistRaw($gunid, $acId = $gb->bsImportPlaylistRaw($gunid,
$aPath, $uri, $ext, $gunids, $subjid); $aPath, $uri, $ext, $gunids, $subjid);
if (PEAR::isError($acId)) { if (PEAR::isError($acId)) {
return $r; return $r;
} }
//break; //break;
default: default:
$ac = StoredFile::RecallByGunid($gunid); $ac = StoredFile::RecallByGunid($gunid);
if (is_null($ac) || PEAR::isError($ac)) { if (is_null($ac) || PEAR::isError($ac)) {
return $ac; return $ac;
} }
$r = $ac->md->getMetadataElement('dcterms:extent'); $r = $ac->md->getMetadataElement('dcterms:extent');
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$playlength = $r[0]['value']; $playlength = $r[0]['value'];
} }
@ -263,7 +263,7 @@ class SmilPlaylistAudioElement {
$clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val); $clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val);
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n". $res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n".
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n". "$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
$fInfo. $fInfo.
"$ind</playlistElement>\n"; "$ind</playlistElement>\n";
return $res; return $res;
} }
@ -278,35 +278,35 @@ class SmilPlaylistAudioElement {
*/ */
class SmilPlaylistAnimateElement { class SmilPlaylistAnimateElement {
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='') public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{ {
extract($parr); extract($parr);
if ($tree->name != 'animate') { if ($tree->name != 'animate') {
return PEAR::raiseError("SmilPlaylist::parse: animate tag expected"); return PEAR::raiseError("SmilPlaylist::parse: animate tag expected");
} }
if ($tree->attrs['attributeName']->val == 'soundLevel' && if ($tree->attrs['attributeName']->val == 'soundLevel' &&
$tree->attrs['from']->val == '0%' && $tree->attrs['from']->val == '0%' &&
$tree->attrs['to']->val == '100%' && $tree->attrs['to']->val == '100%' &&
$tree->attrs['calcMode']->val == 'linear' && $tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' && $tree->attrs['fill']->val == 'freeze' &&
$tree->attrs['begin']->val == '0s' && $tree->attrs['begin']->val == '0s' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va) preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
) { ) {
return array('type'=>'fadeIn', 'val'=>intval($va[1])); return array('type'=>'fadeIn', 'val'=>intval($va[1]));
} }
if ($tree->attrs['attributeName']->val == 'soundLevel' && if ($tree->attrs['attributeName']->val == 'soundLevel' &&
$tree->attrs['from']->val == '100%' && $tree->attrs['from']->val == '100%' &&
$tree->attrs['to']->val == '0%' && $tree->attrs['to']->val == '0%' &&
$tree->attrs['calcMode']->val == 'linear' && $tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' && $tree->attrs['fill']->val == 'freeze' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) && preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd) preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
) { ) {
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1])); return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
} }
return PEAR::raiseError( return PEAR::raiseError(
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general" "SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
); );
} }
} // class SmilPlaylistAnimateElement } // class SmilPlaylistAnimateElement

File diff suppressed because it is too large Load diff

View file

@ -12,9 +12,9 @@ define('TR_LEAVE_CLOSED', TRUE);
*/ */
class TransportRecord class TransportRecord
{ {
/** /**
* @var DB * @var DB
*/ */
//public $dbc; //public $dbc;
/** /**
@ -72,12 +72,12 @@ class TransportRecord
$trec = new TransportRecord($tr); $trec = new TransportRecord($tr);
$trec->trtok = $trtok = $tr->_createTransportToken(); $trec->trtok = $trtok = $tr->_createTransportToken();
$trec->row = array_merge($defaults, $trec->row = array_merge($defaults,
array('trtype'=>$trtype, 'direction'=>$direction)); array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE; $trec->recalled = TRUE;
if (!isset($defaults['title'])) { if (!isset($defaults['title'])) {
$defaults['title'] = $trec->getTitle(); $defaults['title'] = $trec->getTitle();
if (PEAR::isError($defaults['title'])) { if (PEAR::isError($defaults['title'])) {
return $defaults['title']; return $defaults['title'];
} }
} }
$id = $CC_DBC->nextId($CC_CONFIG['transSequence']); $id = $CC_DBC->nextId($CC_CONFIG['transSequence']);
@ -96,7 +96,7 @@ class TransportRecord
"; ";
$res = $CC_DBC->query($query); $res = $CC_DBC->query($query);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
return $trec; return $trec;
} }
@ -126,7 +126,7 @@ class TransportRecord
WHERE trtok='$trtok' WHERE trtok='$trtok'
"); ");
if (PEAR::isError($row)) { if (PEAR::isError($row)) {
return $row; return $row;
} }
if (is_null($row)) { if (is_null($row)) {
return PEAR::raiseError("TransportRecord::recall:". return PEAR::raiseError("TransportRecord::recall:".
@ -170,16 +170,16 @@ class TransportRecord
UPDATE ".$CC_CONFIG['transTable']." UPDATE ".$CC_CONFIG['transTable']."
SET $set SET $set
WHERE trtok='{$this->trtok}'". WHERE trtok='{$this->trtok}'".
(is_null($oldState) ? '' : " AND state='$oldState'"). (is_null($oldState) ? '' : " AND state='$oldState'").
(is_null($lock) ? '' : " AND lock = '$slock'") (is_null($lock) ? '' : " AND lock = '$slock'")
); );
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
// return TRUE; // return TRUE;
$affRows = $CC_DBC->affectedRows(); $affRows = $CC_DBC->affectedRows();
if (PEAR::isError($affRows)) { if (PEAR::isError($affRows)) {
return $affRows; return $affRows;
} }
return ($affRows == 1); return ($affRows == 1);
} }
@ -217,7 +217,7 @@ class TransportRecord
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$pidsql = (is_null($pid) ? "NULL" : "$pid" ); $pidsql = (is_null($pid) ? "NULL" : "$pid" );
if ($this->dropped) { if ($this->dropped) {
return TRUE; return TRUE;
} }
$slock = ($lock ? 'Y' : 'N'); $slock = ($lock ? 'Y' : 'N');
$nlock = (!$lock); $nlock = (!$lock);
@ -228,11 +228,11 @@ class TransportRecord
WHERE trtok='{$this->trtok}' AND lock = '$snlock'" WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
); );
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$affRows = $CC_DBC->affectedRows(); $affRows = $CC_DBC->affectedRows();
if (PEAR::isError($affRows)) { if (PEAR::isError($affRows)) {
return $affRows; return $affRows;
} }
if ($affRows === 0) { if ($affRows === 0) {
$ltxt = ($lock ? 'lock' : 'unlock' ); $ltxt = ($lock ? 'lock' : 'unlock' );
@ -303,7 +303,7 @@ class TransportRecord
} }
$r = $this->setState('failed', array('errmsg'=>$msg)); $r = $this->setState('failed', array('errmsg'=>$msg));
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return TRUE; return TRUE;
} }
@ -326,7 +326,7 @@ class TransportRecord
if (TR_LEAVE_CLOSED) { if (TR_LEAVE_CLOSED) {
$r = $this->setState('closed'); $r = $this->setState('closed');
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
} else { } else {
$r = $CC_DBC->query(" $r = $CC_DBC->query("
@ -334,7 +334,7 @@ class TransportRecord
WHERE trtok='{$this->trtok}' WHERE trtok='{$this->trtok}'
"); ");
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$this->recalled = FALSE; $this->recalled = FALSE;
$this->dropped = TRUE; $this->dropped = TRUE;
@ -383,7 +383,7 @@ class TransportRecord
$defStr = 'unknown'; $defStr = 'unknown';
$trtype = $this->getTransportType(); //contains recall check $trtype = $this->getTransportType(); //contains recall check
if (PEAR::isError($trtype)) { if (PEAR::isError($trtype)) {
return $trtype; return $trtype;
} }
switch ($trtype) { switch ($trtype) {
case "audioclip": case "audioclip":
@ -396,9 +396,9 @@ class TransportRecord
} }
if (PEAR::isError($title)) { if (PEAR::isError($title)) {
if ($title->getCode() == GBERR_FOBJNEX) { if ($title->getCode() == GBERR_FOBJNEX) {
$title = $defStr; $title = $defStr;
} else { } else {
return $title; return $title;
} }
} }
break; break;
@ -407,10 +407,10 @@ class TransportRecord
break; break;
case "file": case "file":
$title = ( isset($this->row['localfile']) ? $title = ( isset($this->row['localfile']) ?
basename($this->row['localfile']) : 'regular file'); basename($this->row['localfile']) : 'regular file');
break; break;
default: default:
$title = $defStr; $title = $defStr;
} }
return $title; return $title;
} }

View file

@ -67,12 +67,12 @@ class Validator {
'webstream' => "webstreamFormat", 'webstream' => "webstreamFormat",
); );
if (!isset($formats[$format])) { if (!isset($formats[$format])) {
return $this->_err(VAL_FORMAT); return $this->_err(VAL_FORMAT);
} }
$formatName = $formats[$format]; $formatName = $formats[$format];
$formatFile = dirname(__FILE__)."/$formatName.php"; $formatFile = dirname(__FILE__)."/$formatName.php";
if (!file_exists($formatFile)) { if (!file_exists($formatFile)) {
return $this->_err(VAL_FORMAT); return $this->_err(VAL_FORMAT);
} }
require($formatFile); require($formatFile);
$this->formTree = $$formatName; $this->formTree = $$formatName;
@ -151,15 +151,15 @@ class Validator {
$dname = (($node->ns? $node->ns.":" : '').$node->name); $dname = (($node->ns? $node->ns.":" : '').$node->name);
$formTree =& $this->formTree; $formTree =& $this->formTree;
if (DEBUG) { if (DEBUG) {
echo"\nVAL::validateNode: 1 $dname/$fname\n"; echo"\nVAL::validateNode: 1 $dname/$fname\n";
} }
// check root node name: // check root node name:
if ($dname != $fname) { if ($dname != $fname) {
return $this->_err(VAL_ROOT, $fname); return $this->_err(VAL_ROOT, $fname);
} }
// check if this element is defined in format: // check if this element is defined in format:
if (!isset($formTree[$fname])) { if (!isset($formTree[$fname])) {
return $this->_err(VAL_NOTDEF, $fname); return $this->_err(VAL_NOTDEF, $fname);
} }
// check element content // check element content
if (isset($formTree[$fname]['regexp'])) { if (isset($formTree[$fname]['regexp'])) {
@ -171,12 +171,12 @@ class Validator {
// validate attributes: // validate attributes:
$ra = $this->validateAttributes($node, $fname); $ra = $this->validateAttributes($node, $fname);
if (PEAR::isError($ra)) { if (PEAR::isError($ra)) {
return $ra; return $ra;
} }
// validate children: // validate children:
$r = $this->validateChildren($node, $fname); $r = $this->validateChildren($node, $fname);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
return TRUE; return TRUE;
} }
@ -251,7 +251,7 @@ class Validator {
// call children recursive: // call children recursive:
$r = $this->validateNode($node->children[$i], $chname); $r = $this->validateNode($node->children[$i], $chname);
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
$childs[$chname] = TRUE; $childs[$chname] = TRUE;
} }
@ -269,13 +269,13 @@ class Validator {
foreach ($fchilds['oneof'] as $i => $ch) { foreach ($fchilds['oneof'] as $i => $ch) {
if (isset($childs[$ch])) { if (isset($childs[$ch])) {
if ($one) { if ($one) {
return $this->_err(VAL_UNEXPONEOF, "$ch in $fname"); return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
} }
$one = TRUE; $one = TRUE;
} }
} }
if (!$one) { if (!$one) {
return $this->_err(VAL_NOONEOF); return $this->_err(VAL_NOONEOF);
} }
} }
} }
@ -340,9 +340,9 @@ class Validator {
{ {
$formTree =& $this->formTree; $formTree =& $this->formTree;
$listed = ( $listed = (
isset($formTree[$fname][$nType][$reqType]) ? isset($formTree[$fname][$nType][$reqType]) ?
array_search($chname, $formTree[$fname][$nType][$reqType]) : array_search($chname, $formTree[$fname][$nType][$reqType]) :
FALSE FALSE
); );
return $listed; return $listed;
} }
@ -360,22 +360,22 @@ class Validator {
function _err($errno, $par='') function _err($errno, $par='')
{ {
$msg = array( $msg = array(
VAL_ROOT => 'Wrong root element', VAL_ROOT => 'Wrong root element',
VAL_NOREQE => 'Required element missing', VAL_NOREQE => 'Required element missing',
VAL_NOONEOF => 'One-of element missing', VAL_NOONEOF => 'One-of element missing',
VAL_UNKNOWNE => 'Unknown element', VAL_UNKNOWNE => 'Unknown element',
VAL_UNKNOWNA => 'Unknown attribute', VAL_UNKNOWNA => 'Unknown attribute',
VAL_NOTDEF => 'Not defined', VAL_NOTDEF => 'Not defined',
VAL_UNEXPONEOF => 'Unexpected second object from one-of set', VAL_UNEXPONEOF => 'Unexpected second object from one-of set',
VAL_FORMAT => 'Unknown format', VAL_FORMAT => 'Unknown format',
VAL_CONTENT => 'Invalid content', VAL_CONTENT => 'Invalid content',
VAL_NOREQA => 'Required attribute missing', VAL_NOREQA => 'Required attribute missing',
VAL_ATTRIB => 'Invalid attribute format', VAL_ATTRIB => 'Invalid attribute format',
VAL_PREDXML => 'Invalid predicate type', VAL_PREDXML => 'Invalid predicate type',
); );
return PEAR::raiseError( return PEAR::raiseError(
"Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})", "Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})",
$errno $errno
); );
} }

View file

@ -164,12 +164,12 @@ class XmlParser {
$res = xml_parse($xml_parser, $data, TRUE); $res = xml_parse($xml_parser, $data, TRUE);
if (!$res) { if (!$res) {
$this->err = array(TRUE, $this->err = array(TRUE,
sprintf("XML error: %s at line %d\n", sprintf("XML error: %s at line %d\n",
xml_error_string(xml_get_error_code($xml_parser)), xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser) xml_get_current_line_number($xml_parser)
) )
); );
// var_dump($data); // var_dump($data);
} }
xml_parser_free($xml_parser); xml_parser_free($xml_parser);
} }
@ -188,31 +188,31 @@ class XmlParser {
function &parse($data='', $loc='file') function &parse($data='', $loc='file')
{ {
switch ($loc) { switch ($loc) {
case "file": case "file":
if (!is_file($data)) { if (!is_file($data)) {
return PEAR::raiseError( return PEAR::raiseError(
"XmlParser::parse: file not found ($data)" "XmlParser::parse: file not found ($data)"
); );
} }
if (!is_readable($data)) { if (!is_readable($data)) {
return PEAR::raiseError( return PEAR::raiseError(
"XmlParser::parse: can't read file ($data)" "XmlParser::parse: can't read file ($data)"
); );
} }
$data = file_get_contents($data); $data = file_get_contents($data);
case "string": case "string":
$parser = new XmlParser($data); $parser = new XmlParser($data);
if ($parser->isError()) { if ($parser->isError()) {
return PEAR::raiseError( return PEAR::raiseError(
"XmlParser::parse: ".$parser->getError() "XmlParser::parse: ".$parser->getError()
); );
} }
$tree = $parser->getTree(); $tree = $parser->getTree();
break; break;
default: default:
return PEAR::raiseError( return PEAR::raiseError(
"XmlParser::parse: unsupported source location ($loc)" "XmlParser::parse: unsupported source location ($loc)"
); );
} }
return $tree; return $tree;
} }
@ -237,7 +237,7 @@ class XmlParser {
$atnm = $a['localPart']; $atnm = $a['localPart'];
unset($attrs[$atn]); unset($attrs[$atn]);
if ($atns == 'xmlns') { if ($atns == 'xmlns') {
$nSpaces[$atnm] = $atv; $nSpaces[$atnm] = $atv;
} else if ($atns == NULL && $atnm == 'xmlns') { } else if ($atns == NULL && $atnm == 'xmlns') {
$nSpaces[''] = $atv; $nSpaces[''] = $atv;
} else { } else {
@ -280,7 +280,7 @@ class XmlParser {
function characterData($parser, $data) { function characterData($parser, $data) {
$cnt = count($this->stack); $cnt = count($this->stack);
if (trim($data)!='') { 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) == ";"){ //if(substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";"){
// $this->stack[$cnt-1]->content .= trim($data); // $this->stack[$cnt-1]->content .= trim($data);
//}else{ //}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}"); $res .= XML_Util::replaceEntities("{$el->content}");
if ($haveCh) { if ($haveCh) {
$res .= "\n{$ind}"; $res .= "\n{$ind}";
} }
$res .= "</{$fullName}>"; $res .= "</{$fullName}>";
return $res; return $res;

View file

@ -47,6 +47,7 @@ class CcShowTableMap extends TableMap {
$this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null); $this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null); $this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('SHOW_ID', 'DbShowId', 'INTEGER', true, null, null);
// validators // validators
} // initialize() } // initialize()

View file

@ -35,7 +35,8 @@ class CcSubjsTableMap extends TableMap {
$this->setPhpName('CcSubjs'); $this->setPhpName('CcSubjs');
$this->setClassname('CcSubjs'); $this->setClassname('CcSubjs');
$this->setPackage('campcaster'); $this->setPackage('campcaster');
$this->setUseIdGenerator(false); $this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_subjs_id_seq');
// columns // columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, ''); $this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, '');

View file

@ -79,6 +79,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
*/ */
protected $description; 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 * Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction. * by another object which falls in this transaction.
@ -296,6 +302,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->description; return $this->description;
} }
/**
* Get the [show_id] column value.
*
* @return int
*/
public function getDbShowId()
{
return $this->show_id;
}
/** /**
* Set the value of [id] column. * Set the value of [id] column.
* *
@ -592,6 +608,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this; return $this;
} // setDbDescription() } // 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. * 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->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
$this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; $this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
$this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : 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->resetModified();
$this->setNew(false); $this->setNew(false);
@ -645,7 +682,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->ensureConsistency(); $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) { } catch (Exception $e) {
throw new PropelException("Error populating CcShow object", $e); throw new PropelException("Error populating CcShow object", $e);
@ -971,6 +1008,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
case 8: case 8:
return $this->getDbDescription(); return $this->getDbDescription();
break; break;
case 9:
return $this->getDbShowId();
break;
default: default:
return null; return null;
break; break;
@ -1003,6 +1043,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$keys[6] => $this->getDbRepeats(), $keys[6] => $this->getDbRepeats(),
$keys[7] => $this->getDbDay(), $keys[7] => $this->getDbDay(),
$keys[8] => $this->getDbDescription(), $keys[8] => $this->getDbDescription(),
$keys[9] => $this->getDbShowId(),
); );
return $result; return $result;
} }
@ -1061,6 +1102,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
case 8: case 8:
$this->setDbDescription($value); $this->setDbDescription($value);
break; break;
case 9:
$this->setDbShowId($value);
break;
} // switch() } // 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[6], $arr)) $this->setDbRepeats($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]); 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[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::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats);
if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day); 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::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcShowPeer::SHOW_ID)) $criteria->add(CcShowPeer::SHOW_ID, $this->show_id);
return $criteria; return $criteria;
} }
@ -1183,6 +1229,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$copyObj->setDbRepeats($this->repeats); $copyObj->setDbRepeats($this->repeats);
$copyObj->setDbDay($this->day); $copyObj->setDbDay($this->day);
$copyObj->setDbDescription($this->description); $copyObj->setDbDescription($this->description);
$copyObj->setDbShowId($this->show_id);
$copyObj->setNew(true); $copyObj->setNew(true);
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value $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->repeats = null;
$this->day = null; $this->day = null;
$this->description = null; $this->description = null;
$this->show_id = null;
$this->alreadyInSave = false; $this->alreadyInSave = false;
$this->alreadyInValidation = false; $this->alreadyInValidation = false;
$this->clearAllReferences(); $this->clearAllReferences();

View file

@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
const TM_CLASS = 'CcShowTableMap'; const TM_CLASS = 'CcShowTableMap';
/** The total number of columns. */ /** The total number of columns. */
const NUM_COLUMNS = 9; const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */ /** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0; const NUM_LAZY_LOAD_COLUMNS = 0;
@ -58,6 +58,9 @@ abstract class BaseCcShowPeer {
/** the column name for the DESCRIPTION field */ /** the column name for the DESCRIPTION field */
const DESCRIPTION = 'cc_show.DESCRIPTION'; 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. * 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 * 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' * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/ */
private static $fieldNames = array ( private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', ), 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', ), 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, ), 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', ), 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', ), 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, ) 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 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/ */
private static $fieldKeys = array ( 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_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, ), 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, ), 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, ), 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, ), 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, ) 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::REPEATS);
$criteria->addSelectColumn(CcShowPeer::DAY); $criteria->addSelectColumn(CcShowPeer::DAY);
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION); $criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
$criteria->addSelectColumn(CcShowPeer::SHOW_ID);
} else { } else {
$criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.NAME');
@ -185,6 +189,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn($alias . '.REPEATS'); $criteria->addSelectColumn($alias . '.REPEATS');
$criteria->addSelectColumn($alias . '.DAY'); $criteria->addSelectColumn($alias . '.DAY');
$criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.SHOW_ID');
} }
} }

View file

@ -15,6 +15,7 @@
* @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column * @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column
* @method CcShowQuery orderByDbDay($order = Criteria::ASC) Order by the day 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 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 groupByDbId() Group by the id column
* @method CcShowQuery groupByDbName() Group by the name column * @method CcShowQuery groupByDbName() Group by the name column
@ -25,6 +26,7 @@
* @method CcShowQuery groupByDbRepeats() Group by the repeats column * @method CcShowQuery groupByDbRepeats() Group by the repeats column
* @method CcShowQuery groupByDbDay() Group by the day column * @method CcShowQuery groupByDbDay() Group by the day column
* @method CcShowQuery groupByDbDescription() Group by the description 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 leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcShowQuery rightJoin($relation) Adds a RIGHT 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 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 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 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 findByDbId(int $id) Return CcShow objects filtered by the id column
* @method array findByDbName(string $name) Return CcShow objects filtered by the name 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 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 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 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 * @package propel.generator.campcaster.om
*/ */
@ -408,6 +412,37 @@ abstract class BaseCcShowQuery extends ModelCriteria
return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison); 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 * Exclude object from result
* *

View file

@ -699,13 +699,21 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
if (!$this->alreadyInSave) { if (!$this->alreadyInSave) {
$this->alreadyInSave = true; $this->alreadyInSave = true;
if ($this->isNew() ) {
$this->modifiedColumns[] = CcSubjsPeer::ID;
}
// If this object has been modified, then save it to the database. // If this object has been modified, then save it to the database.
if ($this->isModified()) { if ($this->isModified()) {
if ($this->isNew()) { if ($this->isNew()) {
$criteria = $this->buildCriteria(); $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); $pk = BasePeer::doInsert($criteria, $con);
$affectedRows = 1; $affectedRows = 1;
$this->setId($pk); //[IMV] update autoincrement primary key
$this->setNew(false); $this->setNew(false);
} else { } else {
$affectedRows = CcSubjsPeer::doUpdate($this, $con); $affectedRows = CcSubjsPeer::doUpdate($this, $con);
@ -1127,7 +1135,6 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
*/ */
public function copyInto($copyObj, $deepCopy = false) public function copyInto($copyObj, $deepCopy = false)
{ {
$copyObj->setId($this->id);
$copyObj->setLogin($this->login); $copyObj->setLogin($this->login);
$copyObj->setPass($this->pass); $copyObj->setPass($this->pass);
$copyObj->setType($this->type); $copyObj->setType($this->type);
@ -1180,6 +1187,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
$copyObj->setNew(true); $copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
} }
/** /**

View file

@ -529,6 +529,10 @@ abstract class BaseCcSubjsPeer {
$criteria = $values->buildCriteria(); // build Criteria from CcSubjs object $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 // Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME); $criteria->setDbName(self::DATABASE_NAME);

View file

@ -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 $*)

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,24 @@
<?php
$path = dirname(__FILE__).'/../../../library/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$WHITE_SCREEN_OF_DEATH = false;
require_once(dirname(__FILE__).'/../../configs/conf.php');
require_once('DB.php');
require_once('PHPUnit.php');
require_once 'StoredFileTests.php';
require_once 'SchedulerTests.php';
//require_once 'SchedulerExportTests.php';
require_once 'PlaylistTests.php';
//$suite = new PHPUnit_TestSuite("PlayListTests");
//$suite = new PHPUnit_TestSuite("SchedulerTests");
$suite = new PHPUnit_TestSuite("StoredFileTest");
$suite->addTestSuite("PlaylistTests");
$suite->addTestSuite("SchedulerTests");
//$suite->addTestSuite("SchedulerExportTests");
$result = PHPUnit::run($suite);
echo $result->toString();
?>

View file

@ -0,0 +1,181 @@
<?php
$path = dirname(__FILE__).'/../../library/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once(dirname(__FILE__).'/../../../library/propel/runtime/lib/Propel.php');
// Initialize Propel with the runtime configuration
Propel::init(__DIR__."/../../configs/propel-config.php");
// Add the generated 'classes' directory to the include path
set_include_path(dirname(__FILE__)."/../" . PATH_SEPARATOR . get_include_path());
require_once('DB.php');
require_once('PHPUnit.php');
require_once(dirname(__FILE__).'/../../configs/conf.php');
require_once(dirname(__FILE__).'/../GreenBox.php');
require_once(dirname(__FILE__).'/../Playlist.php');
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'America/Toronto';
date_default_timezone_set($tz);
//old database connection still needed to get a session instance.
$dsn = $CC_CONFIG['dsn'];
$CC_DBC = DB::connect($dsn, TRUE);
if (PEAR::isError($CC_DBC)) {
echo "ERROR: ".$CC_DBC->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;
}
}
}
?>

View file

@ -0,0 +1,42 @@
<?php
require_once(dirname(__FILE__)."/../Schedule.php");
class SchedulerExportTests extends PHPUnit_TestCase {
function setup() {
global $CC_CONFIG, $CC_DBC;
// Clear the files table
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
$CC_DBC->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");
}
}
?>

View file

@ -0,0 +1,128 @@
<?php
require_once(dirname(__FILE__)."/../Schedule.php");
class SchedulerTests extends PHPUnit_TestCase {
private $groupIdCreated;
private $storedFile;
private $storedFile2;
function setup() {
global $CC_CONFIG, $CC_DBC;
// Clear the files table
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
//$CC_DBC->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();
}
}
?>

View file

@ -0,0 +1,87 @@
<?php
require_once(dirname(__FILE__).'/../StoredFile.php');
$dsn = $CC_CONFIG['dsn'];
$CC_DBC = DB::connect($dsn, TRUE);
if (PEAR::isError($CC_DBC)) {
echo "ERROR: ".$CC_DBC->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;
}
}
}
?>

View file

@ -0,0 +1,25 @@
#!/usr/bin/php -q
<?php
header("Content-type: text/plain");
echo "TEST\n";
#$gunid = "5716b53127c3761f92fddde3412c7773";
$gunid = $argv[1];
echo "GUNID: $gunid\n";
require_once('../../conf.php');
require_once('DB.php');
require_once('../GreenBox.php');
$rmd = new StoredFile($gunid, '../stor/'.substr($gunid, 0, 3));
$r = $rmd->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";
?>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,4 @@
<?php
header ("location: ../");
exit;
?>

View file

@ -0,0 +1,22 @@
<?php
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
// Initialize Propel with the runtime configuration
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
// Add the generated 'classes' directory to the include path
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
$con = Propel::getConnection("campcaster");
$sql = "SELECT COUNT(*) FROM cc_schedule WHERE (starts >= '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());
?>

View file

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<playlist id="0e22c20310212a51">
<playlistElement id="0000000000000103" relativeOffset="00:00:00.000000" >
<audioClip id="0000000000010003"
playlength="00:00:11.500000"
title = "three"
uri="file:var/test10003.mp3"
/>
</playlistElement>
<playlistElement id="0000000000000104" relativeOffset="00:00:11.500000">
<playlist id="0000000000000001"
playlength="01:30:00.000000"
title="My First Playlist">
</playlist>
</playlistElement>
<metadata
xmlns="http://mdlf.org/campcaster/elements/1.0/"
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
>
<dc:title>embedded playlist</dc:title>
<dcterms:extent>01:30:11.500000</dcterms:extent>
</metadata>
</playlist>

View file

@ -0,0 +1,85 @@
<?php
require_once '../../conf.php';
require_once '../Playlist.php';
require_once '../StoredFile.php';
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
// Initialize Propel with the runtime configuration
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
// Add the generated 'classes' directory to the include path
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
$playlistName = "pypo_playlist_test";
$minutesFromNow = 1;
echo " ************************************************************** \n";
echo " This script schedules a playlist to play $minutesFromNow minute(s) from now.\n";
echo " This is a utility to help you debug the scheduler.\n";
echo " ************************************************************** \n";
echo "\n";
echo "Deleting playlists with the name '$playlistName'...";
// Delete any old playlists
$pl2 = Playlist::findPlaylistByName($playlistName);
foreach ($pl2 as $playlist) {
//var_dump($playlist);
$playlist->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";
?>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,143 @@
<?php
/*
header("Content-type: text/plain");
require_once('../../conf.php');
require_once('DB.php');
require_once('../GreenBox.php');
require_once('../LocStor.php');
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\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";
*/
?>

View file

@ -0,0 +1,62 @@
<?php
/*
header("Content-type: text/plain");
echo "\n#StorageServer storeWebstream test:\n";
require_once('../../conf.php');
require_once('DB.php');
require_once('../GreenBox.php');
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\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"
*/
?>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<audioClip>
<metadata
xmlns="http://mdlf.org/campcaster/elements/1.0/"
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
<dc:title>Webstream test 1</dc:title>
<dcterms:extent>01:30:00.000000</dcterms:extent>
<ls:url>http://localhost/y</ls:url>
</metadata>
</audioClip>

View file

@ -169,6 +169,7 @@ CREATE TABLE "cc_show"
"repeats" INT2 NOT NULL, "repeats" INT2 NOT NULL,
"day" INT2 NOT NULL, "day" INT2 NOT NULL,
"description" VARCHAR(512), "description" VARCHAR(512),
"show_id" INTEGER NOT NULL,
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
@ -331,7 +332,7 @@ DROP TABLE "cc_subjs" CASCADE;
CREATE TABLE "cc_subjs" CREATE TABLE "cc_subjs"
( (
"id" INTEGER NOT NULL, "id" serial NOT NULL,
"login" VARCHAR(255) default '' NOT NULL, "login" VARCHAR(255) default '' NOT NULL,
"pass" VARCHAR(255) default '' NOT NULL, "pass" VARCHAR(255) default '' NOT NULL,
"type" CHAR(1) default 'U' NOT NULL, "type" CHAR(1) default 'U' NOT NULL,