Merge branch 'master' of dev.sourcefabric.org:campcaster

Conflicts:
	.zfproject.xml
This commit is contained in:
naomiaro 2010-12-10 12:18:51 -05:00
commit def79d7679
189 changed files with 138 additions and 64033 deletions

View File

@ -56,6 +56,9 @@
<actionMethod actionName="moveShow"/>
<actionMethod actionName="resizeShow"/>
</controllerFile>
<controllerFile controllerName="Api">
<actionMethod actionName="index"/>
</controllerFile>
</controllersDirectory>
<formsDirectory>
<formFile formName="Login"/>
@ -174,6 +177,8 @@
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="resizeShow"/>
<viewControllerScriptsDirectory forControllerName="Api">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
@ -215,6 +220,7 @@
<testApplicationControllerFile filesystemName="SearchControllerTest.php"/>
<testApplicationControllerFile filesystemName="LoginControllerTest.php"/>
<testApplicationControllerFile filesystemName="ScheduleControllerTest.php"/>
<testApplicationControllerFile filesystemName="ApiControllerTest.php"/>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory>

View File

@ -15,6 +15,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('playlist'))
->add(new Zend_Acl_Resource('plupload'))
->add(new Zend_Acl_Resource('schedule'))
->add(new Zend_Acl_Resource('api'))
->add(new Zend_Acl_Resource('search'));
/** Creating permissions */
@ -23,11 +24,12 @@ $ccAcl->allow('guest', 'index')
->allow('guest', 'error')
->allow('guest', 'library')
->allow('guest', 'search')
->allow('guest', 'api')
->allow('host', 'plupload')
->allow('host', 'playlist')
->allow('host', 'schedule');
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);
$front = Zend_Controller_Front::getInstance();
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin($aclPlugin);

View File

@ -25,6 +25,8 @@ $CC_CONFIG = array(
'apiKey' => array('AAA'),
'apiPath' => "/api/",
'baseFilesDir' => __DIR__."/../../files",
// main directory for storing binary media files
'storageDir' => __DIR__.'/../../files/stor',
@ -162,4 +164,13 @@ set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
.PATH_SEPARATOR.$CC_CONFIG['zendPath']
.PATH_SEPARATOR.$old_include_path);
//$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);
?>

View File

@ -102,7 +102,14 @@ class Playlist {
}
/**
public static function findPlaylistByName($p_name)
{
$res = CcPlaylistQuery::create()->findByDbName($p_name);
return $res;
}
/**
* Fetch instance of Playlist object.<br>
*
* @param string $id
@ -414,7 +421,7 @@ class Playlist {
if (is_null($media) || PEAR::isError($media)) {
return $media;
}
$metadata = $media->getMetadata();
$length = $metadata["length"];
@ -425,7 +432,7 @@ class Playlist {
// insert at end of playlist.
if (is_null($p_position))
$p_position = $this->getNextPos();
// insert default values if parameter was empty
$p_cuein = !is_null($p_cuein) ? $p_cuein : '00:00:00.000000';
$p_cueout = !is_null($p_cueout) ? $p_cueout : $length;
@ -434,9 +441,9 @@ class Playlist {
$sql = "SELECT INTERVAL '{$p_cueout}' - INTERVAL '{$p_cuein}'";
$r = $con->query($sql);
$p_cliplength = $r->fetchColumn(0);
$res = $this->insertPlaylistElement($this->id, $p_mediaId, $p_position, $p_cliplength, $p_cuein, $p_cueout, $p_fadeIn, $p_fadeOut);
return TRUE;
}
@ -629,7 +636,7 @@ class Playlist {
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
}

View File

@ -401,6 +401,26 @@ class Schedule {
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
}
/**
* Return true if the input string is in the format YYYY-MM-DD-HH-mm
*
* @param string $p_time
* @return boolean
*/
public static function ValidPypoTimeFormat($p_time)
{
$t = explode("-", $p_time);
if (count($t) != 5) {
return false;
}
foreach ($t as $part) {
if (!is_numeric($part)) {
return false;
}
}
return true;
}
/**
* Converts a time value as a string (with format HH:MM:SS.mmmmmm) to
* millisecs.

View File

@ -1697,7 +1697,7 @@ class StoredFile {
{
global $CC_CONFIG;
return "http://".$CC_CONFIG["storageUrlHost"]
.$CC_CONFIG["apiPath"]."get_media.php?file="
.$CC_CONFIG["apiPath"]."getMedia/file/"
.$this->gunid.".".$this->getFileExtension();
}

View File

@ -1,12 +0,0 @@
DirectoryIndex index.php
Options +FollowSymLinks -Indexes
<IfModule mod_mime.c>
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc On
php_flag register_globals Off
</IfModule>
</IfModule>

View File

@ -1,184 +0,0 @@
<?
/**
* AccessRecur class
*
* Handles recursive accessPlaylist/releasePlaylist.
* Should be 'required_once' from LocStor.php only.
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class AccessRecur {
public $ls;
public $sessid;
public function __construct(&$ls, $sessid)
{
$this->ls =& $ls;
$this->sessid = $sessid;
}
public static function accessPlaylist(&$ls, $sessid, $plid, $parent='0')
{
$ppa = new AccessRecur($ls, $sessid);
$r = $ls->accessPlaylist($sessid, $plid, FALSE, $parent);
if (PEAR::isError($r)) {
return $r;
}
$plRes = $r;
$r = StoredFile::RecallByGunid($plid);
if (is_null($r) || PEAR::isError($r)) {
return $r;
}
$ac = $r;
$r = $ac->md->genPhpArray();
if (PEAR::isError($r)) {
return $r;
}
$pla = $r;
$r = $ppa->processPlaylist($pla, $plRes['token']);
if (PEAR::isError($r)) {
return $r;
}
$plRes['content'] = $r;
return $plRes;
}
public static function releasePlaylist(&$ls, $sessid, $token)
{
global $CC_CONFIG, $CC_DBC;
$ppa = new AccessRecur($ls, $sessid);
$r = $CC_DBC->getAll("
SELECT to_hex(token)as token2, to_hex(gunid)as gunid
FROM ".$CC_CONFIG['accessTable']."
WHERE parent=x'{$token}'::bigint
");
if (PEAR::isError($r)) {
return $r;
}
$arr = $r;
foreach ($arr as $i => $item) {
extract($item); // token2, gunid
$r = BasicStor::GetType($gunid);
if (PEAR::isError($r)) {
return $r;
}
$ftype = $r;
# echo "$ftype/$token2\n";
switch (strtolower($ftype)) {
case "audioclip":
$r = $ppa->ls->releaseRawAudioData($ppa->sessid, $token2);
if (PEAR::isError($r)) {
return $r;
}
# var_dump($r);
break;
case "playlist":
$r = $ppa->releasePlaylist($ppa->ls, $ppa->sessid, $token2);
if (PEAR::isError($r)) {
return $r;
}
# var_dump($r);
break;
default:
}
}
$r = $ppa->ls->releasePlaylist($ppa->sessid, $token, FALSE);
if (PEAR::isError($r)) {
return $r;
}
return $r;
}
private function processPlaylist($pla, $parent)
{
$res = array();
foreach ($pla['children'] as $ple) {
switch ($ple['elementname']) {
case "playlistElement":
$r = $this->processPlaylistElement($ple, $parent);
if (PEAR::isError($r)) {
return $r;
}
// $res = array_merge($res, $r);
$res[] = $r;
break;
default:
}
}
return $res;
}
private function processAudioClip($gunid, $parent)
{
$r = $this->ls->accessRawAudioData($this->sessid, $gunid, $parent);
if (PEAR::isError($r)) {
return $r;
}
return $r;
}
private function processPlaylistElement($ple, $parent='0')
{
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = $this->processAudioClip($ac['attrs']['id'], $parent);
if (PEAR::isError($r)) {
return $r;
}
return $r;
case "playlist":
// if(empty($ac['children'])){
$r = $this->accessPlaylist($this->ls, $this->sessid,
$ac['attrs']['id'], $parent);
if (PEAR::isError($r)) {
if ($r->getCode() != GBERR_NOTF) {
return $r;
} else {
$r = $this->processPlaylist($ac, $parent);
if (PEAR::isError($r)) {
return $r;
}
$r = array(
'content' => $r,
'url' => NULL,
'token' => NULL,
'chsum' => NULL,
'size' => NULL,
'warning' => 'inline playlist?',
);
}
}
return $r;
/*
}else{
$r = $this->processPlaylist($ac, $parent);
if(PEAR::isError($r)) return $r;
$res = array(
'content' => $r,
'url' => NULL,
'token' => NULL,
'chsum' => NULL,
'size' => NULL,
'warning' => 'inline playlist',
);
return $res;
}
*/
break;
default:
}
}
return array();
}
} // class AccessRecur
?>

View File

@ -1,622 +0,0 @@
<?php
require_once('Subjects.php');
define('USE_ALIB_CLASSES', TRUE);
define('ALIBERR_NOTLOGGED', 30);
define('ALIBERR_NOTEXISTS', 31);
/**
* Authentication/authorization class
*
* @package Campcaster
* @subpackage Alib
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Alib {
/* ======================================================= public methods */
/* ----------------------------------------------- session/authentication */
/**
* Authenticate and create session
*
* @param string $login
* @param string $pass
* @return boolean|sessionId|PEAR_Error
*/
public static function Login($login, $pass)
{
global $CC_CONFIG, $CC_DBC;
if (FALSE === Subjects::Authenticate($login, $pass)) {
Subjects::SetTimeStamp($login, TRUE);
return FALSE;
}
$sessid = Alib::_createSessid();
if (PEAR::isError($sessid)) {
return $sessid;
}
$userid = Subjects::GetSubjId($login);
$sql = "INSERT INTO ".$CC_CONFIG['sessTable']." (sessid, userid, login, ts)"
." VALUES('$sessid', '$userid', '$login', now())";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
Subjects::SetTimeStamp($login, FALSE);
return $sessid;
} // fn login
/**
* Logout and destroy session
*
* @param string $sessid
* @return true|PEAR_Error
*/
public static function Logout($sessid)
{
global $CC_CONFIG, $CC_DBC;
$ct = Alib::CheckAuthToken($sessid);
if ($ct === FALSE) {
return PEAR::raiseError("Alib::logout: not logged ($sessid)",
ALIBERR_NOTLOGGED, PEAR_ERROR_RETURN);
} elseif (PEAR::isError($ct)) {
return $ct;
} else {
$sql = "DELETE FROM ".$CC_CONFIG['sessTable']
." WHERE sessid='$sessid'";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
}
} // fn logout
/**
* Return true if the token is valid
*
* @param string $sessid
* @return boolean|PEAR_Error
*/
private static function CheckAuthToken($sessid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['sessTable']
." WHERE sessid='$sessid'";
$c = $CC_DBC->getOne($sql);
return ($c == 1 ? TRUE : (PEAR::isError($c) ? $c : FALSE ));
} //fn checkAuthToken
/**
* Set valid token in alib object
*
* @param string $sessid
* @return TRUE|PEAR_Error
*/
// public function setAuthToken($sessid)
// {
// $r = $this->checkAuthToken($sessid);
// if (PEAR::isError($r)) {
// return $r;
// }
// if (!$r) {
// return PEAR::raiseError("ALib::setAuthToken: invalid token ($sessid)");
// }
// //$this->sessid = $sessid;
// return TRUE;
// } // fn setAuthToken
/* -------------------------------------------------------- authorization */
/**
* Insert permission record
*
* @param int $sid
* local user/group id
* @param string $action
* @param int $oid
* local object id
* @param string $type
* 'A'|'D' (allow/deny)
* @return int
* local permission id
*/
public static function AddPerm($sid, $action, $oid, $type='A')
{
global $CC_CONFIG, $CC_DBC;
$permid = $CC_DBC->nextId($CC_CONFIG['permSequence']);
$sql = "INSERT INTO ".$CC_CONFIG['permTable']." (permid, subj, action, obj, type)"
." VALUES ($permid, $sid, '$action', $oid, '$type')";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return($r);
}
return $permid;
} // fn addPerm
/**
* Remove permission record
*
* @param int $permid
* local permission id
* @param int $subj
* local user/group id
* @param int $obj
* local object id
* @return boolean|PEAR_Error
*/
public static function RemovePerm($permid=NULL, $subj=NULL, $obj=NULL)
{
global $CC_CONFIG, $CC_DBC;
$ca = array();
if ($permid) {
$ca[] = "permid=$permid";
}
if ($subj) {
$ca[] = "subj=$subj";
}
if ($obj) {
$ca[] = "obj=$obj";
}
$cond = join(" AND ", $ca);
if (!$cond) {
return TRUE;
}
$sql = "DELETE FROM ".$CC_CONFIG['permTable']." WHERE $cond";
return $CC_DBC->query($sql);
} // fn removePerm
/**
* Return object related with permission record
*
* @param int $permid
* local permission id
* @return int
* local object id
*/
public static function GetPermOid($permid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT obj FROM ".$CC_CONFIG['permTable']." WHERE permid=$permid";
$res = $CC_DBC->getOne($sql);
return $res;
} // fn GetPermOid
/**
* Check if specified subject have permission to specified action
* on specified object
*
* Look for sequence of corresponding permissions and order it by
* relevence, then test the most relevant for result.
* High relevence have direct permission (directly for specified subject
* and object. Relevance order is done by level distance in the object
* tree, level distance in subjects (user/group system).
* Similar way is used for permissions related to object classes.
* But class-related permissions have lower priority then
* object-tree-related.
* Support for object classes can be disabled by USE_ALIB_CLASSES const.
*
* @param int $sid
* subject id (user or group id)
* @param string $action
* from set defined in config
* @param int $oid
* object id (default: root node)
* @return boolean|PEAR_Error
*/
public static function CheckPerm($sid, $action, $oid=NULL)
{
return TRUE;
// global $CC_DBC;
// global $CC_CONFIG;
// if (!is_numeric($sid)) {
// return FALSE;
// }
//// if (is_null($oid) or $oid=='') {
//// $oid = M2tree::GetRootNode();
//// }
//// if (PEAR::isError($oid)) {
//// return $oid;
//// }
// if (!is_numeric($oid)) {
// return FALSE;
// }
// // query construction
// // shortcuts:
// // p: permTable,
// // s: subjTable, m smembTable,
// // t: treeTable ts: structTable,
// // c: classTable, cm: cmembTable
// // main query elements:
// $q_flds = "m.level , p.subj, s.login, action, p.type, p.obj";
// $q_from = $CC_CONFIG['permTable']." p ";
// // joins for solving users/groups:
// $q_join = "LEFT JOIN ".$CC_CONFIG['subjTable']." s ON s.id=p.subj ";
// $q_join .= "LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=p.subj ";
// $q_cond = "p.action in('_all', '$action') AND
// (s.id=$sid OR m.uid=$sid) ";
// // coalesce -1 for higher priority of nongroup rows:
// // action DESC order for lower priority of '_all':
// $q_ordb = "ORDER BY coalesce(m.level,-1), action DESC, p.type DESC";
// $q_flds0 = $q_flds;
// $q_from0 = $q_from;
// $q_join0 = $q_join;
// $q_cond0 = $q_cond;
// $q_ordb0 = $q_ordb;
// // joins for solving object tree:
// $q_flds .= ", t.name, ts.level as tlevel";
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['treeTable']." t ON t.id=p.obj ";
// //$q_join .= "LEFT JOIN ".$CC_CONFIG['structTable']." ts ON ts.parid=p.obj ";
// //$q_cond .= " AND (t.id=$oid OR ts.objid=$oid)";
// // action DESC order is hack for lower priority of '_all':
// $q_ordb = "ORDER BY coalesce(ts.level,0), m.level, action DESC, p.type DESC";
// // query by tree:
// $query1 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
// $r1 = $CC_DBC->getAll($query1);
// if (PEAR::isError($r1)) {
// return($r1);
// }
// // if there is row with type='A' on the top => permit
// //$AllowedByTree =
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='A');
// //$DeniedByTree =
// // (is_array($r1) && count($r1)>0 && $r1[0]['type']=='D');
//
// if (!USE_ALIB_CLASSES) {
// return $AllowedbyTree;
// }
//
// // joins for solving object classes:
// $q_flds = $q_flds0.", c.cname ";
// $q_join = $q_join0."LEFT JOIN ".$CC_CONFIG['classTable']." c ON c.id=p.obj ";
// $q_join .= "LEFT JOIN ".$CC_CONFIG['cmembTable']." cm ON cm.cid=p.obj ";
// $q_cond = $q_cond0." AND (c.id=$oid OR cm.objid=$oid)";
// $q_ordb = $q_ordb0;
// // query by class:
// $query2 = "SELECT $q_flds FROM $q_from $q_join WHERE $q_cond $q_ordb";
// $r2 = $CC_DBC->getAll($query2);
// if (PEAR::isError($r2)) {
// return $r2;
// }
// $AllowedByClass =
// (is_array($r2) && count($r2)>0 && $r2[0]['type']=='A');
// // not used now:
// // $DeniedByClass =
// // (is_array($r2) && count($r2)>0 && $r2[0]['type']=='D');
// $res = ($AllowedByTree || (!$DeniedByTree && $AllowedByClass));
// return $res;
} // fn CheckPerm
/* ---------------------------------------------------------- object tree */
/**
* Remove all permissions on object and then remove object itself
*
* @param int $id
* @return void|PEAR_Error
*/
public static function RemoveObj($id)
{
$r = Alib::RemovePerm(NULL, NULL, $id);
return $r;
} // fn removeObj
/* --------------------------------------------------------- users/groups */
/**
* Remove all permissions of subject and then remove subject itself
*
* @param string $login
* @return void|PEAR_Error
*/
public static function RemoveSubj($login)
{
global $CC_CONFIG, $CC_DBC;
$uid = Subjects::GetSubjId($login);
if (PEAR::isError($uid)) {
return $uid;
}
if (is_null($uid)){
return $CC_DBC->raiseError("Alib::removeSubj: Subj not found ($login)",
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
$r = Alib::RemovePerm(NULL, $uid);
if (PEAR::isError($r)) {
return $r;
}
return Subjects::RemoveSubj($login, $uid);
} // fn RemoveSubj
/* ------------------------------------------------------------- sessions */
/**
* Get login from session id (token)
*
* @param string $sessid
* @return string|PEAR_Error
*/
public static function GetSessLogin($sessid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT login FROM ".$CC_CONFIG['sessTable']." WHERE sessid='$sessid'";
$r = $CC_DBC->getOne($sql);
if (PEAR::isError($r)) {
return $r;
}
if (is_null($r)){
return PEAR::raiseError("Alib::GetSessLogin:".
" invalid session id ($sessid)",
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
return $r;
} // fn GetSessLogin
/**
* Get user id from session id.
*
* @param string $p_sessid
* @return int|PEAR_Error
*/
public static function GetSessUserId($p_sessid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT userid FROM ".$CC_CONFIG['sessTable']." WHERE sessid='$p_sessid'";
$r = $CC_DBC->getOne($sql);
if (PEAR::isError($r)) {
return $r;
}
if (is_null($r)) {
return PEAR::raiseError("Alib::getSessUserId:".
" invalid session id ($p_sessid)",
ALIBERR_NOTEXISTS, PEAR_ERROR_RETURN);
}
return $r;
} // fn getSessUserId
/* --------------------------------------------------------- info methods */
/**
* Get all permissions on object.
*
* @param int $id
* @return array|null|PEAR_Error
*/
public static function GetObjPerms($id)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.login, p.* FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
." WHERE s.id=p.subj AND p.obj=$id";
return $CC_DBC->getAll($sql);
} // fn GetObjPerms
/**
* Get all permissions of subject.
*
* @param int $sid
* @return array
*/
public static function GetSubjPerms($sid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT *"
." FROM ".$CC_CONFIG['permTable']
." WHERE p.subj=$sid";
// $sql = "SELECT t.name, t.type as otype , p.*"
// ." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['treeTable']." t"
// ." WHERE t.id=p.obj AND p.subj=$sid";
$a1 = $CC_DBC->getAll($sql);
return $a1;
} // fn GetSubjPerms
/* ------------------------ info methods related to application structure */
/* (this part should be added/rewritten to allow defining/modifying/using
* application structure)
* (only very simple structure definition - in $CC_CONFIG - supported now)
*/
/**
* Get all actions
*
* @return array
*/
public static function GetAllActions()
{
global $CC_CONFIG;
return $CC_CONFIG['allActions'];
} // fn GetAllActions
/**
* Get all allowed actions on specified object type.
*
* @param string $type
* @return array
*/
public static function GetAllowedActions($type)
{
global $CC_CONFIG;
return $CC_CONFIG['allowedActions'][$type];
} // fn GetAllowedActions
/* ====================================================== private methods */
/**
* Create new session id. Return the new session ID.
*
* @return string
*/
private static function _createSessid()
{
global $CC_CONFIG, $CC_DBC;
for ($c = 1; $c > 0; ){
$sessid = md5(uniqid(rand()));
$sql = "SELECT count(*) FROM ".$CC_CONFIG['sessTable']
." WHERE sessid='$sessid'";
$c = $CC_DBC->getOne($sql);
if (PEAR::isError($c)) {
return $c;
}
}
return $sessid;
} // fn _createSessid
/* =============================================== test and debug methods */
/**
* Dump all permissions for debug
*
* @param string $indstr
* indentation string
* @param string $ind
* actual indentation
* @return string
*/
public static function DumpPerms($indstr=' ', $ind='')
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.login, p.action, p.type"
." FROM ".$CC_CONFIG['permTable']." p, ".$CC_CONFIG['subjTable']." s"
." WHERE s.id=p.subj"
." ORDER BY p.permid";
$arr = $CC_DBC->getAll($sql);
if (PEAR::isError($arr)) {
return $arr;
}
$r = $ind.join(', ', array_map(create_function('$v',
'return "{$v[\'login\']}/{$v[\'action\']}/{$v[\'type\']}";'
),
$arr
))."\n";
return $r;
} // fn dumpPerms
/**
* Delete everything form the permission table and session table.
*
* @return void
*/
public static function DeleteData()
{
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['permTable']);
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['sessTable']);
Subjects::DeleteData();
} // fn deleteData
/**
* Insert test permissions
*
* @return array
*/
public static function TestData()
{
global $CC_CONFIG, $CC_DBC;
$tdata = Subjects::TestData();
$t =& $tdata['tree'];
$c =& $tdata['classes'];
$s =& $tdata['subjects'];
$CC_DBC->setErrorHandling(PEAR_ERROR_PRINT);
$perms = array(
array($s['root'], '_all', $t['root'], 'A'),
array($s['test1'], '_all', $t['pa'], 'A'),
array($s['test1'], 'read', $t['s2b'], 'D'),
array($s['test2'], 'addChilds', $t['pa'], 'D'),
array($s['test2'], 'read', $t['i2'], 'A'),
array($s['test2'], 'edit', $t['s1a'], 'A'),
array($s['test1'], 'addChilds', $t['s2a'], 'D'),
array($s['test1'], 'addChilds', $t['s2c'], 'D'),
array($s['gr2'], 'addChilds', $t['i2'], 'A'),
array($s['test3'], '_all', $t['t1'], 'D'),
);
if (USE_ALIB_CLASSES){
$perms[] = array($s['test3'], 'read', $c['cl_sa'], 'D');
$perms[] = array($s['test4'], 'editPerms', $c['cl2'], 'A');
}
foreach ($perms as $p){
$o[] = $r = Alib::AddPerm($p[0], $p[1], $p[2], $p[3]);
if (PEAR::isError($r)) {
return $r;
}
}
$tdata['perms'] = $o;
return $tdata;
} // fn testData
/**
* Make basic test
*
* @return boolean|PEAR_Error
*/
public static function Test()
{
$p = Subjects::test();
if (PEAR::isError($p)) {
return $p;
}
Alib::DeleteData();
$tdata = Alib::TestData();
if (PEAR::isError($tdata)) {
return $tdata;
}
$test_correct = "root/_all/A, test1/_all/A, test1/read/D,".
" test2/addChilds/D, test2/read/A, test2/edit/A,".
" test1/addChilds/D, test1/addChilds/D, gr2/addChilds/A,".
" test3/_all/D";
if (USE_ALIB_CLASSES){
$test_correct .= ", test3/read/D, test4/editPerms/A";
}
$test_correct .= "\nno, yes\n";
$r = Alib::DumpPerms();
if (PEAR::isError($r)) {
return $r;
}
$test_dump = $r.
(Alib::CheckPerm(
$tdata['subjects']['test1'], 'read',
$tdata['tree']['t1']
)? 'yes':'no').", ".
(Alib::CheckPerm(
$tdata['subjects']['test1'], 'addChilds',
$tdata['tree']['i2']
)? 'yes':'no')."\n"
;
Alib::RemovePerm($tdata['perms'][1]);
Alib::RemovePerm($tdata['perms'][3]);
$test_correct .= "root/_all/A, test1/read/D,".
" test2/read/A, test2/edit/A,".
" test1/addChilds/D, test1/addChilds/D, gr2/addChilds/A,".
" test3/_all/D";
if (USE_ALIB_CLASSES) {
$test_correct .= ", test3/read/D, test4/editPerms/A";
}
$test_correct .= "\n";
$test_dump .= Alib::DumpPerms();
Alib::DeleteData();
if ($test_dump == $test_correct) {
$test_log .= "alib: OK\n";
return TRUE;
} else {
return PEAR::raiseError('Alib::test', 1, PEAR_ERROR_DIE, '%s'.
"<pre>\ncorrect:\n{$test_correct}\n".
"dump:\n{$test_dump}\n</pre>\n");
}
} // fn test
} // class Alib
?>

View File

@ -1,487 +0,0 @@
<?php
define('BACKUP_EXT', 'tar');
define('ACCESS_TYPE', 'backup');
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Backup
{
/**
* Name of logfile
* @var string
*/
private $logFile;
/**
* Session id
* @var string
*/
private $sessid;
/**
* struct - see search criteria
* @var array
*/
private $criteria;
/**
* @var string
*/
private $token;
/**
* name of statusfile
* @var string
*/
private $statusFile;
/**
* Affected gunids
* @var array
*/
private $ids;
/**
* Array of affected filenames
* @var array
*/
private $filenames = array();
/**
* Base tmp name
* @var string
*/
private $tmpName;
/**
* Name of temporary tarball file
* @var string
*/
private $tmpFile;
/**
* Name of temporary directory
* @var string
*/
private $tmpDir;
/**
* Name of temporary playlist directory
* @var string
*/
private $tmpDirPlaylist;
/**
* Name of temporary audioclip directory
* @var string
*/
private $tmpDirClip;
/**
* Name of temporary metafile directory
* @var string
*/
private $tmpDirMeta;
/**
* @var string
*/
private $loglevel = 'warn'; # 'debug';
/**
* @var GreenBox
*/
private $gb;
/**
* @param GreeenBox $gb
*/
public function __construct(&$gb)
{
global $CC_CONFIG;
$this->gb =& $gb;
$this->token = null;
$this->logFile = $CC_CONFIG['bufferDir'].'/'.ACCESS_TYPE.'.log';
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
}
/**
* Open a backup
* Create a backup file (tarball)
*
* @param string $sessid
* @param array $criteria
* struct - see search criteria
* @return array
* hasharray with field:
* token string: backup token
*/
public function openBackup($sessid, $criteria='')
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." openBackup - sessid:$sessid\n");
}
$this->sessid = $sessid;
$this->criteria = $criteria;
// get ids (and real filenames) which files match with criteria
$srch = $this->gb->localSearch($this->criteria,$this->sessid);
if (PEAR::isError($srch)) {
return $srch;
}
$this->setIDs($srch);
// get real filenames
if (is_array($this->ids)) {
$this->setFilenames();
$this->setEnviroment(true);
// write a status file
file_put_contents($this->statusFile, 'working');
// save the metafile to tmpdir
$hostname = trim(`hostname`);
$ctime = time();
$ctime_f = date("Ymd-H:i:s");
file_put_contents("{$this->tmpDirMeta}/storage.xml",
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"<storage\n".
" type=\"".ACCESS_TYPE."\"\n".
" version=\"1.0\"\n".
" ctime=\"$ctime\"\n".
" hostname=\"$hostname\"\n".
"/><!-- $ctime_f -->\n"
);
// copy all file to tmpdir
$this->copyAllFiles();
// do everything
$this->doIt();
return array('token'=>$this->token);
} else {
return false;
}
}
/**
* Check the status of backup.
*
* @param unknown $token
* @return array
* status : string - susccess | working | fault
* faultString: string - description of fault
* token : stirng - backup token
* url : string - access url
* tmpfile : string - access filename
*/
public function checkBackup($token)
{
global $CC_CONFIG;
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
}
$this->token = $token;
$this->setEnviroment();
$status = file_get_contents($this->statusFile);
if (strpos($status,'fault')!==false) {
list($status,$faultString) = explode('|',$status);
}
switch ($status) {
case 'success':
$r['url'] = BasicStor::GetUrlPart()."access/$token.".BACKUP_EXT;
$r['tmpfile'] = $CC_CONFIG['accessDir']."/$token.".BACKUP_EXT;
case 'working':
case 'fault':
$r['status'] = $status;
$r['faultString'] = $faultString;
$r['token'] = $token;
break;
}
return $r;
}
/**
* Close a backup
*
* @param unknown $token
* @return boolean
*/
public function closeBackup($token)
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." closeBackup - token:$token\n");
}
# post procedures
$this->token = $token;
$this->setEnviroment();
BasicStor::bsRelease($token, ACCESS_TYPE);
Backup::rRmDir($this->tmpDir);
unlink($this->statusFile);
unlink($this->tmpFile);
if (is_file($this->tmpName)) {
unlink($this->tmpName);
}
return !is_file($this->tmpFile);
}
/**
* list of unclosed backups
*
* @param string $stat
* if this parameter is not set, then return with all unclosed backups
* @return array of hasharray with field:
* status : string - susccess | working | fault
* token : stirng - backup token
* url : string - access url
*/
public function listBackups($stat='')
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." listBackups - stat:$stat\n");
}
// open temporary dir
$tokens = BasicStor::GetTokensByType(ACCESS_TYPE);
// echo '<XMP>tokens:'; print_r($tokens); echo '</XMP>';
foreach ($tokens as $token) {
$st = $this->checkBackup($token);
if ($stat=='' || $st['status']==$stat) {
$r[] = $st;
}
}
return $r;
}
/**
* Set the ids from searchResult
*
* @param array $searchResult : array of gunids
*/
private function setIDs($searchResult)
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setIDs\n");
}
if (is_array($searchResult['results'])) {
$this->ids = $searchResult['results'];
} else {
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setIDs - the parameter is not array!\n");
return PEAR::raiseError('The IDs variable isn\'t array.');
}
}
/**
* Set the filenames from ids.
*
*/
private function setFilenames()
{
// if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
// }
// if (is_array($this->ids)) {
// foreach ($this->ids as $i => $item) {
// $gunid = $item['gunid'];
// // get a stored file object of this gunid
// $sf = StoredFile::RecallByGunid($gunid);
// if (is_null($sf) || PEAR::isError($sf)) {
// return $sf;
// }
// $lid = BasicStor::IdFromGunid($gunid);
// if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
// return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
// }
// // if the file is a playlist then it has only a meta file
// if (strtolower($sf->md->format) != 'playlist') {
// $this->filenames[] = array(
// 'filename' => $sf->getRealFileName(),
// 'format' => $sf->md->format
// );
// }
// $this->filenames[] = array(
// 'filename' => $sf->getRealMetadataFileName(),
// 'format' => $sf->md->format
// );
// if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
// }
// }
// return $this->filenames;
// } else {
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
// return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
// }
}
/**
* Create the tarball - call the shell script
*
*/
private function doIt()
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt\n");
}
$command = dirname(__FILe__)."/../bin/backup.sh"
." {$this->tmpDir}"
." {$this->tmpFile}"
." {$this->statusFile}"
." >> {$this->logFile} &";
$res = system("$command");
sleep(2);
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." doIt - command:$command\n");
}
}
/**
* Copy the real files into the tmp dirs to tar they.
*
*/
private function copyAllFiles()
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." copyAllFiles\n");
}
//echo '<XMP>this->filenames:'; print_r($this->filenames); echo '</XMP>';
if (is_array($this->filenames)) {
foreach ($this->filenames as $v) {
# get the filename from full path
$fn = substr($v['filename'],strrpos($v['filename'],'/'));
switch (strtolower($v['format'])) {
case 'playlist':
# if playlist then copy to the playlist dir
copy($v['filename'],$this->tmpDirPlaylist.$fn);
break;
case 'audioclip':
# if audioclip then copy to the audioclip dir
copy($v['filename'],$this->tmpDirClip.$fn);
break;
}
}
}
}
/**
* Figure out the enviroment to the backup
*
*/
private function setEnviroment($createDir=false)
{
global $CC_CONFIG;
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment - createDirs:$createDir\n");
}
// create temporary directories
if (is_null($this->token) && $createDir) {
$this->tmpName = tempnam($CC_CONFIG['bufferDir'], ACCESS_TYPE.'_');
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
$this->tmpDir = $this->tmpName.'.dir';
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
$this->tmpDirClip = $this->tmpDir. '/audioClip';
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
touch($this->tmpFile);
mkdir($this->tmpDir);
mkdir($this->tmpDirPlaylist);
mkdir($this->tmpDirClip);
mkdir($this->tmpDirMeta);
$this->genToken();
} else {
$symlink = $CC_CONFIG['accessDir'].'/'.$this->token.'.'.BACKUP_EXT;
if (is_link($symlink) && is_file(readlink($symlink))) {
$this->tmpName = str_replace('.tar','',readlink($symlink));
$this->tmpFile = $this->tmpName.'.'.BACKUP_EXT;
$this->tmpDir = $this->tmpName.'.dir';
$this->tmpDirPlaylist = $this->tmpDir. '/playlist';
$this->tmpDirClip = $this->tmpDir. '/audioClip';
$this->tmpDirMeta = $this->tmpDir. '/meta-inf';
} else {
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setEnviroment - Corrupt symbolic link.\n");
return false;
}
}
$this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.'.BACKUP_EXT.'.status';
if ($this->loglevel=='debug') {
$this->addLogItem("this->tmpName: $this->tmpName\n");
$this->addLogItem("this->tmpFile: $this->tmpFile\n");
$this->addLogItem("this->tmpDir: $this->tmpDir\n");
$this->addLogItem("this->tmpDirPlaylist: $this->tmpDirPlaylist\n");
$this->addLogItem("this->tmpDirClip: $this->tmpDirClip\n");
$this->addLogItem("this->tmpDirMeta: $this->tmpDirMeta\n");
$this->addLogItem("this->token: $this->token\n");
$this->addLogItem("this->statusFile: $this->statusFile\n");
}
}
/**
* Generate a new token.
* @return void
*/
private function genToken()
{
$acc = BasicStor::bsAccess($this->tmpFile, BACKUP_EXT, null, ACCESS_TYPE);
if (PEAR::isError($acc)) {
return $acc;
}
$this->token = $acc['token'];
}
/**
* Add a line to the logfile.
*
* @param string $item
* the new row of log file
*/
private function addLogItem($item)
{
$f = fopen($this->logFile,'a');
fwrite($f,$item);
fclose($f);
}
/**
* Delete a directory recursive
*
* @param string $dirname
* path of dir.
*/
private static function rRmDir($dirname)
{
if (is_dir($dirname)) {
$dir_handle = opendir($dirname);
}
while ($file = readdir($dir_handle)) {
if ( ($file != ".") && ($file != "..") ) {
if (!is_dir($dirname."/".$file)) {
unlink ($dirname."/".$file);
} else {
Backup::rRmDir($dirname."/".$file);
}
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
} // classs Backup
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,352 +0,0 @@
<?
define('INDCH', ' ');
/**
* M3uPlaylist class
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class M3uPlaylist {
/**
* Parse M3U file or string
*
* @param string $data
* local path to M3U file or M3U string
* @param string $loc
* location: 'file'|'string'
* @return array
* reference, parse result tree (or PEAR::error)
*/
function &parse($data='', $loc='file')
{
switch ($loc) {
case "file":
if (!is_file($data)) {
return PEAR::raiseError(
"M3uPlaylist::parse: file not found ($data)"
);
}
if (!is_readable($data)) {
return PEAR::raiseError(
"M3uPlaylist::parse: can't read file ($data)"
);
}
$data = file_get_contents($data);
case "string":
$arr = preg_split("|\n#EXTINF: |", $data);
if ($arr[0] != '#EXTM3U') {
return PEAR::raiseError(
"M3uPlaylist::parse: invalid M3U header"
);
}
array_shift($arr);
break;
default:
return PEAR::raiseError(
"M3uPlaylist::parse: unsupported data location ($loc)"
);
}
return $arr;
}
/**
* Import M3U file to storage
*
* @param GreenBox $gb
* @param string $aPath
* absolute path part of imported file (e.g. /home/user/campcaster)
* @param string $rPath
* relative path/filename part of imported file
* (e.g. playlists/playlist_1.smil)
* @param array $gunids
* hash relation from filenames to gunids
* @param string $plid
* playlist gunid
* @param int $subjid
* local subject (user) id (id of user doing the import)
* @return Playlist
*/
function import(&$gb, $aPath, $rPath, &$gunids, $plid, $subjid=NULL)
{
// $path = realpath("$aPath/$rPath");
// if (FALSE === $path) {
// return PEAR::raiseError(
// "M3uPlaylist::import: file doesn't exist ($aPath/$rPath)"
// );
// }
// $arr = M3uPlaylist::parse($path);
// if (PEAR::isError($arr)) {
// return $arr;
// }
// require_once("Playlist.php");
// $pl =& Playlist::create($gb, $plid, "imported_M3U");
// if (PEAR::isError($pl)) {
// return $pl;
// }
// $r = $pl->lock($gb, $subjid);
// if (PEAR::isError($r)) {
// return $r;
// }
// foreach ($arr as $i => $it) {
// list($md, $uri) = preg_split("|\n|", $it);
// list($length, $title) = preg_split("|, *|", $md);
// // $gunid = StoredFile::CreateGunid();
// $gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
// $acId = BasicStor::IdFromGunid($gunid);
// if (PEAR::isError($acId)) {
// return $acId;
// }
// $length = Playlist::secondsToPlaylistTime($length);
// $offset = '???';
// if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
// switch (strtolower($ext = $va[1])) {
// case "lspl":
// case "xml":
// case "smil":
// case "m3u":
// $acId = $gb->bsImportPlaylistRaw($gunid,
// $aPath, $uri, $ext, $gunids, $subjid);
// if (PEAR::isError($acId)) {
// break;
// }
// //no break!
// default:
// if (is_null($gunid)) {
// return PEAR::raiseError(
// "M3uPlaylist::import: no gunid");
// }
// $r = $pl->addAudioClip($acId);
// if (PEAR::isError($r)) {
// return $r;
// }
// }
// }
// }
// $r = $pl->unlock($gb);
// if (PEAR::isError($r)) {
// return $r;
// }
// return $pl;
}
/**
* Import M3U file to storage
*
* @param GreenBox $gb
* @param string $data
* local path to M3U file
* @return string
* XML playlist in Campcaster playlist format
*/
function convert2lspl(&$gb, $data)
{
$arr = M3uPlaylist::parse($data);
if (PEAR::isError($arr)) {
return $arr;
}
$ind = '';
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$res = '';
foreach ($arr as $i => $it) {
list($md, $uri) = preg_split("|\n|", $it);
list($length, $title) = preg_split("|, *|", $md);
$gunid = StoredFile::CreateGunid();
$gunid2 = StoredFile::CreateGunid();
$length = Playlist::secondsToPlaylistTime($length);
$offset = '???';
$clipStart = '???';
$clipEnd = '???';
$clipLength = '???';
$uri_h = preg_replace("|--|", "&#2d;&#2d;", htmlspecialchars("$uri"));
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
switch (strtolower($ext = $va[1])) {
case "lspl":
case "xml":
case "smil":
case "m3u":
$acOrPl = "$ind3<playlist id=\"$gunid2\" ".
"playlength=\"$length\" title=\"$title\"/> ".
"<!-- $uri_h -->\n";
break;
default:
$acOrPl = "$ind3<audioClip id=\"$gunid2\" ".
"playlength=\"$length\" title=\"$title\"/> ".
"<!-- $uri_h -->\n";
break;
}
}
$res .= "$ind2<playlistElement id=\"$gunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n".
$acOrPl.
"$ind2</playlistElement>\n";
}
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"$ind<playlist id=\"$gunid\" playlength=\"$playlength\" title=\"\">\n".
"$ind2<metadata/>\n".
"$res".
"$ind</playlist>\n";
return $res;
}
} // class M3uPlaylist
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class M3uPlaylistBodyElement {
function convert2lspl(&$tree, $ind='')
{
$ind2 = $ind.INDCH;
if ($tree->name != 'body') {
return PEAR::raiseError("M3uPlaylist::parse: body tag expected");
}
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"M3uPlaylist::parse: unexpected tag %s in tag body",
$tree->children[1]->name
));
}
$res = M3uPlaylistParElement::convert2lspl($tree->children[0], $ind2);
if (PEAR::isError($res)) {
return $res;
}
$gunid = StoredFile::CreateGunid();
$playlength = '???'; // ***
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"$ind<playlist id=\"$gunid\" playlength=\"$playlength\" title=\"\">\n".
"$ind2<metadata/>\n".
"$res".
"$ind</playlist>\n";
return $res;
}
}
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class M3uPlaylistParElement {
function convert2lspl(&$tree, $ind='')
{
if ($tree->name != 'par') {
return PEAR::raiseError("M3uPlaylist::parse: par tag expected");
}
$res = '';
foreach ($tree->children as $i => $ch) {
$ch =& $tree->children[$i];
$r = M3uPlaylistAudioElement::convert2lspl($ch, $ind.INDCH);
if (PEAR::isError($r)) {
return $r;
}
$res .= $r;
}
return $res;
}
}
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class M3uPlaylistAudioElement {
function convert2lspl(&$tree, $ind='')
{
$ind2 = $ind.INDCH;
if ($tree->name != 'audio') {
return PEAR::raiseError("M3uPlaylist::parse: audio tag expected");
}
if (isset($tree->children[2])) {
return PEAR::raiseError(sprintf(
"M3uPlaylist::parse: unexpected tag %s in tag audio",
$tree->children[2]->name
));
}
$res = ''; $fadeIn = 0; $fadeOut = 0;
foreach ($tree->children as $i => $ch) {
$ch =& $tree->children[$i];
$r = M3uPlaylistAnimateElement::convert2lspl($ch, $ind2);
if (PEAR::isError($r)) {
return $r;
}
switch ($r['type']) {
case "fadeIn":
$fadeIn = $r['val'];
break;
case "fadeOut":
$fadeOut = $r['val'];
break;
}
}
if ($fadeIn > 0 || $fadeOut > 0) {
$fadeIn = Playlist::secondsToPlaylistTime($fadeIn);
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
$fInfo = "$ind2<fadeInfo fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
} else {
$fInfo = '';
}
$plElGunid = StoredFile::CreateGunid();
$aGunid = StoredFile::CreateGunid();
$title = basename($tree->attrs['src']->val);
$offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val);
$playlength = '???'; # ***
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\">\n".
"$ind2<audioClip id=\"$aGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
$fInfo.
"$ind</playlistElement>\n";
return $res;
}
} // class M3uPlaylistAudioElement
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class M3uPlaylistAnimateElement {
function convert2lspl(&$tree, $ind='') {
if ($tree->name != 'animate') {
return PEAR::raiseError("M3uPlaylist::parse: animate tag expected");
}
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
$tree->attrs['from']->val == '0%' &&
$tree->attrs['to']->val == '100%' &&
$tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' &&
$tree->attrs['begin']->val == '0s' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
) {
return array('type'=>'fadeIn', 'val'=>$va[1]);
}
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
$tree->attrs['from']->val == '100%' &&
$tree->attrs['to']->val == '0%' &&
$tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
) {
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
}
return PEAR::raiseError(
"M3uPlaylistAnimateElement::convert2lspl: animate parameters too general"
);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,442 +0,0 @@
<?php
require_once("GreenBox.php");
/**
* Preference storage class.
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @see StoredFile
*/
/* ================== Prefs ================== */
class Prefs {
public $gb;
/**
* Constructor
*
* @param GreenBox $gb
* GreenBox object reference
*/
public function __construct(&$gb)
{
$this->gb =& $gb;
}
/* ======================================================= public methods */
/* ----------------------------------------------------- user preferences */
/**
* Read preference record by session id
*
* @param string $sessid
* session id
* @param string $key
* preference key
* @return string
* preference value
*/
function loadPref($sessid, $key)
{
$subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::loadPref: invalid session id",
GBERR_SESS);
}
$val = $this->readVal($subjid, $key);
if (PEAR::isError($val)) {
return $val;
}
if ($val === FALSE) {
return PEAR::raiseError("Prefs::loadPref: invalid preference key",
GBERR_PREF);
}
return $val;
}
/**
* Save preference record by session id
*
* @param string $sessid
* session id
* @param string $key
* preference key
* @param string $value
* preference value
* @return boolean
*/
function savePref($sessid, $key, $value)
{
$subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::savePref: invalid session id", GBERR_SESS);
}
$r = $this->update($subjid, $key, $value);
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
$r = $this->insert($subjid, $key, $value);
if (PEAR::isError($r)) {
return $r;
}
}
return TRUE;
}
/**
* Delete preference record by session id
*
* @param string $sessid
* session id
* @param string $key
* preference key
* @return boolean
*/
function delPref($sessid, $key)
{
$subjid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError("Prefs::delPref: invalid session id", GBERR_SESS);
}
$r = $this->delete($subjid, $key);
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
return PEAR::raiseError("Prefs::delPref: invalid preference key", GBERR_PREF);
}
return TRUE;
}
/* ---------------------------------------------------- group preferences */
/**
* Read group preference record
*
* @param string $group
* group name
* @param string $key
* preference key
* @param boolean $returnErrorIfKeyNotExists
* If set to true and the key doesnt exist, return a PEAR error.
* @return string
* preference value
*/
function loadGroupPref($group, $key, $returnErrorIfKeyNotExists = true)
{
// if sessid is would be used here fix Transport::cronCallMethod !
$subjid = Subjects::GetSubjId($group);
if (PEAR::isError($subjid)) {
return $subjid;
}
if (is_null($subjid)) {
return PEAR::raiseError(
"Prefs::loadGroupPref: invalid group name", ALIBERR_NOTGR);
}
$val = $this->readVal($subjid, $key);
if (PEAR::isError($val)) {
return $val;
}
if ($val === FALSE) {
if ($returnErrorIfKeyNotExists) {
return PEAR::raiseError(
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF);
} else {
return '';
}
}
return $val;
}
/**
* Save group preference record
*
* @param string $sessid
* session id
* @param string $group
* group name
* @param string $key
* preference key
* @param string $value
* preference value
* @return boolean
*/
function saveGroupPref($sessid, $group, $key, $value)
{
$uid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($uid)) {
return $uid;
}
if (is_null($uid)) {
return PEAR::raiseError(
"Prefs::saveGroupPref: invalid session id", GBERR_SESS);
}
$gid = Subjects::GetSubjId($group);
if (PEAR::isError($gid)) {
return $gid;
}
if (is_null($gid)) {
return PEAR::raiseError(
"Prefs::saveGroupPref: invalid group name", GBERR_SESS);
}
$memb = Subjects::IsMemberOf($uid, $gid);
if (PEAR::isError($memb)) {
return $memb;
}
if (!$memb) {
return PEAR::raiseError(
"Prefs::saveGroupPref: access denied", GBERR_DENY);
}
$r = $this->update($gid, $key, $value);
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
$r = $this->insert($gid, $key, $value);
if (PEAR::isError($r)) {
return $r;
}
}
return TRUE;
}
/**
* Delete group preference record
*
* @param string $sessid
* session id
* @param string $group
* group name
* @param string $key
* preference key
* @return boolean
*/
function delGroupPref($sessid, $group, $key)
{
$uid = GreenBox::GetSessUserId($sessid);
if (PEAR::isError($uid)) {
return $uid;
}
if (is_null($uid)) {
return PEAR::raiseError(
"Prefs::delGroupPref: invalid session id", GBERR_SESS);
}
$gid = Subjects::GetSubjId($group);
if (PEAR::isError($gid)) {
return $gid;
}
if (is_null($gid)) {
return PEAR::raiseError(
"Prefs::delGroupPref: invalid group name", GBERR_SESS);
}
$memb = Subjects::IsMemberOf($uid, $gid);
if (PEAR::isError($memb)) {
return $memb;
}
if (!$memb) {
return PEAR::raiseError(
"Prefs::delGroupPref: access denied", GBERR_DENY);
}
$r = $this->delete($gid, $key);
if (PEAR::isError($r)) {
return $r;
}
if ($r === FALSE) {
return PEAR::raiseError(
"Prefs::delGroupPref: invalid preference key", GBERR_PREF);
}
return TRUE;
}
/* ==================================================== low level methods */
/**
* Insert of new preference record
*
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @param string $valstr
* preference value
* @return int
* local user id
*/
public static function Insert($subjid, $keystr, $valstr='')
{
global $CC_CONFIG, $CC_DBC;
$id = $CC_DBC->nextId($CC_CONFIG['prefSequence']);
if (PEAR::isError($id)) {
return $id;
}
$r = $CC_DBC->query("
INSERT INTO ".$CC_CONFIG['prefTable']."
(id, subjid, keystr, valstr)
VALUES
($id, $subjid, '$keystr', '$valstr')
");
if (PEAR::isError($r)) {
return $r;
}
return $id;
}
/**
* Read value of preference record
*
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @return string
* preference value
*/
function readVal($subjid, $keystr)
{
global $CC_CONFIG, $CC_DBC;
$val = $CC_DBC->getOne("
SELECT valstr FROM ".$CC_CONFIG['prefTable']."
WHERE subjid=$subjid AND keystr='$keystr'
");
if (PEAR::isError($val)) {
return $val;
}
if (is_null($val)) {
return FALSE;
}
return $val;
}
/**
* Read all keys of subject's preferences
*
* @param int $subjid
* local user/group id
* @return array
* preference keys
*/
function readKeys($subjid)
{
global $CC_CONFIG, $CC_DBC;
$res = $CC_DBC->getAll("
SELECT keystr FROM ".$CC_CONFIG['prefTable']."
WHERE subjid=$subjid
");
if (PEAR::isError($res)) {
return $res;
}
if (is_null($res)) {
return FALSE;
}
return $res;
}
/**
* Update value of preference record
*
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @param string $newvalstr
* new preference value
* @return boolean
*/
function update($subjid, $keystr, $newvalstr='')
{
global $CC_CONFIG, $CC_DBC;
$r = $CC_DBC->query("
UPDATE ".$CC_CONFIG['prefTable']." SET
valstr='$newvalstr'
WHERE subjid=$subjid AND keystr='$keystr'
");
if (PEAR::isError($r)) {
return $r;
}
if ($CC_DBC->affectedRows() < 1) {
return FALSE;
}
return TRUE;
}
/**
* Delete preference record
*
* @param int $subjid
* local user/group id
* @param string $keystr
* preference key
* @return boolean
*/
function delete($subjid, $keystr)
{
global $CC_CONFIG, $CC_DBC;
$r = $CC_DBC->query("
DELETE FROM ".$CC_CONFIG['prefTable']."
WHERE subjid=$subjid AND keystr='$keystr'
");
if (PEAR::isError($r)) {
return $r;
}
if ($CC_DBC->affectedRows() < 1) {
return FALSE;
}
return TRUE;
}
/* ==================================================== auxiliary methods */
/**
* Test method
*
*/
function test()
{
global $CC_CONFIG;
$sessid = Alib::Login('root', $CC_CONFIG['tmpRootPass']);
$testkey = 'testKey';
$testVal = 'abcDef 0123 ěščřžýáíé ĚŠČŘŽÝÁÍÉ';
$r = savePref($sessid, $testKey, $testVal);
if (PEAR::isError($r)) {
return $r;
}
$val = loadPref($sessid, $testKey);
if ($val != $testVal) {
echo "ERROR: preference storage test failed.\n ($testVal / $val)\n";
return FALSE;
}
$r = savePref($sessid, $testKey, '');
if (PEAR::isError($r)) {
return $r;
}
$val = loadPref($sessid, $testKey);
if ($val != $testVal) {
echo "ERROR: preference storage test failed.\n ('' / '$val')\n";
return FALSE;
}
return TRUE;
}
} // class Prefs
?>

View File

@ -1,290 +0,0 @@
<?php
define('RENDER_EXT', 'ogg');
require_once("Playlist.php");
/**
* Renderer caller class
*
* Playlist to file rendering - PHP layer, caller to the renderer executable
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @see LocStor
*/
class Renderer
{
/**
* Render playlist to ogg file (open handle)
*
* @param GreenBox $gb
* greenbox object reference
* @param string $plid
* playlist gunid
* @param int $owner
* local subject id, owner of token
* @return array
* token: string - render token
*/
function rnRender2FileOpen(&$gb, $plid, $owner=NULL)
{
global $CC_CONFIG;
// recall playlist:
$pl = StoredFile::RecallByGunid($plid);
if (is_null($pl) || PEAR::isError($pl)) {
return $pl;
}
// smil export:
$smil = $pl->outputToSmil();
if (PEAR::isError($smil)) {
return $smil;
}
// temporary file for smil:
$tmpn = tempnam($CC_CONFIG['bufferDir'], 'plRender_');
$smilf = "$tmpn.smil";
file_put_contents($smilf, $smil);
$url = "file://$smilf";
// output file:
$outf = "$tmpn.".RENDER_EXT;
touch($outf);
// logging:
$logf = $CC_CONFIG['bufferDir']."/renderer.log";
file_put_contents($logf, "--- ".date("Ymd-H:i:s")."\n", FILE_APPEND);
// open access to output file: /*gunid*/ /*parent*/
$acc = BasicStor::bsAccess($outf, RENDER_EXT, $plid, 'render', 0, $owner);
if (PEAR::isError($acc)) {
return $acc;
}
extract($acc);
$statf = Renderer::getStatusFile($gb, $token);
file_put_contents($statf, "working");
// command:
$stServDir = dirname(__FILE__)."/..";
$renderExe = "$stServDir/bin/renderer.sh";
$command = "$renderExe -p $url -o $outf -s $statf >> $logf &";
file_put_contents($logf, "$command\n", FILE_APPEND);
$res = system($command);
if ($res === FALSE) {
return PEAR::raiseError(
'Renderer::rnRender2File: Error running renderer'
);
}
return array('token'=>$token);
}
/**
* Render playlist to ogg file (check results)
*
* @param GreenBox $gb
* GreenBox object reference
* @param string $token
* render token
* @return array
* status : string - success | working | fault
* url : string - readable url
*/
function rnRender2FileCheck(&$gb, $token)
{
$statf = Renderer::getStatusFile($gb, $token);
if (!file_exists($statf)) {
return PEAR::raiseError(
'Renderer::rnRender2FileCheck: Invalid token'
);
}
$status = trim(file_get_contents($statf));
$url = Renderer::getUrl($gb, $token);
$tmpfile= Renderer::getLocalFile($gb, $token);
return array('status'=>$status, 'url'=>$url, 'tmpfile'=>$tmpfile);
}
/**
* Render playlist to ogg file (list results)
*
* @param GreenBox $gb
* greenbox object reference
* @param string $stat
* status (optional) if this parameter is not set, then return with all unclosed backups
* @return array
* array of hasharray:
* status : string - success | working | fault
* url : string - readable url
*/
function rnRender2FileList(&$gb,$stat='') {
// open temporary dir
$tokens = BasicStor::GetTokensByType('render');
foreach ($tokens as $token) {
$st = Renderer::rnRender2FileCheck($gb, $token);
if ( ($stat=='') || ($st['status']==$stat) ) {
$r[] = $st;
}
}
return $r;
}
/**
* Render playlist to ogg file (close handle)
*
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return mixed
* TRUE or PEAR_Error
*/
function rnRender2FileClose(&$gb, $token)
{
global $CC_CONFIG;
$r = BasicStor::bsRelease($token, 'render');
if (PEAR::isError($r)) {
return $r;
}
$realOgg = $r['realFname'];
$tmpn = $CC_CONFIG['bufferDir']."/".basename($realOgg, '.'.RENDER_EXT);
$smilf = "$tmpn.smil";
$statf = Renderer::getStatusFile($gb, $token);
@unlink($statf);
@unlink($realOgg);
@unlink($smilf);
@unlink($tmpn);
return TRUE;
}
/**
* Render playlist to storage as audioClip (check results)
*
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
* status : string - success | working | fault
* gunid: string - global unique id of result file
*/
function rnRender2StorageCheck(&$gb, $token)
{
$r = Renderer::rnRender2FileCheck($gb, $token);
if (PEAR::isError($r)) {
return $r;
}
$status = $r['status'];
$res = array('status' => $status, 'gunid'=>'NULL');
switch ($status) {
case "fault":
$res['faultString'] = "Error runing renderer";
break;
case "success":
$r = Renderer::rnRender2StorageCore($gb, $token);
if (PEAR::isError($r)) {
return $r;
}
$res['gunid'] = $r['gunid'];
break;
default:
break;
}
return $res;
}
/**
* Render playlist to storage as audioClip (core method)
*
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array:
* gunid: string - global unique id of result file
*/
function rnRender2StorageCore(&$gb, $token)
{
// $r = BasicStor::bsRelease($token, 'render');
// if (PEAR::isError($r)) {
// return $r;
// }
// $realOgg = $r['realFname'];
// $owner = $r['owner'];
// $gunid = $r['gunid'];
// $fileName = 'rendered_playlist';
// $id = BasicStor::IdFromGunid($gunid);
// if (PEAR::isError($id)) {
// return $id;
// }
// $mdata = '';
// foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
// $val = $gb->bsGetMetadataValue($id, $item);
// $mdata .= " <$item>$val</$item>\n";
// }
// $mdata = "<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";
// $values = array(
// "filename" => $fileName,
// "filepath" => $realOgg,
// "metadata" => $mdata,
// "filetype" => "audioclip"
// );
// $storedFile = $gb->bsPutFile($values);
// if (PEAR::isError($storedFile)) {
// return $storedFile;
// }
// return array('gunid' => $storedFile->getGunid());
}
/**
* Return local filepath of rendered file
*
* @param Greenbox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
*/
function getLocalFile(&$gb, $token)
{
global $CC_CONFIG;
$token = StoredFile::NormalizeGunid($token);
return $CC_CONFIG['accessDir']."/$token.".RENDER_EXT;
}
/**
* Return filepath of render status file
*
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
*/
function getStatusFile(&$gb, $token)
{
return Renderer::getLocalFile($gb, $token).".status";
}
/**
* Return remote accessible URL for rendered file
*
* @param GreenBox $gb
* greenbox object reference
* @param string $token
* render token
* @return array
*/
function getUrl(&$gb, $token)
{
$token = StoredFile::NormalizeGunid($token);
return BasicStor::GetUrlPart()."access/$token.".RENDER_EXT;
}
} // class Renderer
?>

View File

@ -1,436 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Restore {
/**
* Name of logfile
* @var string
*/
private $logFile;
/**
* session id
* @var string
*/
private $sessid;
/**
* @var string
*/
private $token;
/**
* Name of statusfile
* @var string
*/
private $statusFile;
/**
* Name of temporary directory, to here extract the backup tarball
* @var string
*/
private $tmpDir;
/**
* @var string
*/
// private $loglevel = 'warn';
public $loglevel = 'warn';
// public $loglevel = 'debug';
/**
* @var GreenBox
*/
private $gb;
private $ACCESS_TYPE = 'restore';
/**
* @param GreenBox $gb
* greenbox object reference
*/
public function __construct(&$gb)
{
global $CC_CONFIG;
$this->gb =& $gb;
$this->token = null;
$this->logFile = $CC_CONFIG['bufferDir'].'/'.$this->ACCESS_TYPE.'.log';
if ($this->loglevel == 'debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." construct\n");
}
}
/**
* Call asyncronously the restore procedure. Restore from backup.
*
* @param string $sessid
* session id
* @param string $backup_file
* path of the backup file
* @return array
* hasharray with field:
* token string: backup token
*/
function openRestore($sessid, $backup_file)
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I-".date("Ymd-H:i:s")." doRestore - sessid:$sessid\n");
}
$this->sessid = $sessid;
// generate token
$this->token = StoredFile::CreateGunid();
// status file -> working
$this->setEnviroment();
file_put_contents($this->statusFile, 'working');
//call the restore script in background
$command = dirname(__FILE__).'/../bin/restore.php';
$runLog = "/dev/null";
$params = "{$backup_file} {$this->statusFile} {$this->token} {$sessid}>> $runLog &";
$ret = system("$command $params", $st);
if ($this->loglevel=='debug') {
$this->addLogItem("-I-".date("Ymd-H:i:s")." restore.php call: $st/$ret\n");
}
return array('token'=>$this->token);
}
/**
* Check the status of restore
*
* @param string $token
* @return array
* hasharray with field:
* status : string - susccess | working | fault
* faultString : string - description of fault
* token : stirng - backup token
* url : string - access url
* tmpfile : string - access filename
*/
function checkRestore($token)
{
if ($this->loglevel == 'debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
}
$this->token = $token;
$this->setEnviroment();
if (is_file($this->statusFile)) {
$r = array();
$stat = file_get_contents($this->statusFile);
if (strpos($stat,'fault|') !== false) {
list($stat,$message) = explode('|',$stat);
}
$r['status'] = $stat;
if ($stat=='fault') {
$r['faultString'] = $message;
} else {
$r['faultString'] = '';
}
return $r;
} else {
return PEAR::raiseError('Restore::checkRestore: invalid token!');
}
}
/**
* Check the status of restore.
*
* @param string $token
* @return array
* hasharray with field:
* status : boolean - is success
*/
function closeRestore($token)
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." checkBackup - token:$token\n");
}
$this->token = $token;
$this->setEnviroment();
$this->rRmDir($this->tmpDir);
unlink($this->statusFile);
return array("status" => !is_file($this->statusFile));
}
/**
* Do restore in background
*
* this function is called from the asyncron commandline script
* ../bin/restore.php
*
* @param string $backupfile
* path of backupfile
* @param string $token
* restore token
* @param string $sessid
* session id
*/
function startRestore($backupfile, $token, $sessid)
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." startRestore - bufile:$backupfile | token:$token\n");
}
$this->token = $token;
$this->sessid = $sessid;
$this->setEnviroment();
// extract tarball
$command = 'tar -xf '.$backupfile .' --directory '.$this->tmpDir;
$res = system($command);
//$this->addLogItem('command: '.$command."\n");
//$this->addLogItem('res: '.$res."\n");
//simple check of archive format
if (is_dir($this->tmpDir.'audioClip/') &&
is_dir($this->tmpDir.'meta-inf/') &&
is_dir($this->tmpDir.'playlist/')) {
//search metafiles
$this->metafiles = $this->getMetaFiles();
#$this->addLogItem('metafiles:'.print_r($this->metafiles,true));
//add to storage server
foreach ($this->metafiles as $info) {
$r = $this->addFileToStorage($info['file'],$info['type'],$info['id']);
if (PEAR::isError($r)) {
$this->addLogItem("-E- ".date("Ymd-H:i:s").
" startRestore - addFileToStorage \n".
"(".$put->getMessage()."/".$put->getUserInfo().")\n"
);
file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
return;
}
}
} else {
$this->addLogItem("-E- ".date("Ymd-H:i:s")." startRestore - invalid archive format\n");
file_put_contents($this->statusFile, 'fault|invalid archive format');
return;
}
file_put_contents($this->statusFile, 'success');
// unlink($backupfile);
}
/**
* Get the metafiles.
*
* @return array
* array of hasharray with field:
* file : string - metafile path
* type : stirng - audioClip | playlist
* id : string - the backuped gunid
*/
function getMetaFiles()
{
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." getMetaFiles - tmpDir:{$this->tmpDir}\n");
}
$audioclips = scandir($this->tmpDir.'audioClip/');
$playlists = scandir($this->tmpDir.'playlist/');
for ($i = 0; $i < count($audioclips); $i++) {
if (strpos($audioclips[$i],'xml')!==false)
$r[] = array('file' => $this->tmpDir.'audioClip/'.$audioclips[$i],
'type' => 'audioClip',
'id' => str_replace('.xml','',$audioclips[$i]));
}
for ($i = 0; $i < count($playlists); $i++) {
if (strpos($playlists[$i],'xml') !== false)
$r[] = array('file' => $this->tmpDir.'playlist/'.$playlists[$i],
'type' => 'playlist',
'id' => str_replace('.xml','',$playlists[$i]));
}
return $r;
}
/**
* Add the file to the storage server.
*
* @param string $file
* path of metafile
* @param string $type
* restore token
* @param string $sessid
* session id
*
* @return mixed
* true if success or PEAR_error
*/
// function addFileToStorage($file,$type,$gunid)
// {
// if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n");
// }
// require_once("XmlParser.php");
// $tree = XmlParser::parse($file);
// $mediaFileLP = str_replace('.xml','',$file);
// $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:'';
// $ex = $this->gb->existsFile($this->sessid,$gunid);
// if (PEAR::isError($ex)) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
// " addFileToStorage - existsFile($gunid) ".
// "(".$ex->getMessage()."/".$ex->getUserInfo().")\n"
// );
// }
// if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
// //replace it
// $id = BasicStor::IdFromGunid($gunid);
// $replace = $this->gb->replaceFile(
// $id, # id int, virt.file's local id
// $mediaFileLP, # mediaFileLP string, local path of media file
// $file, # mdataFileLP string, local path of metadata file
// $this->sessid); # sessid string, session id
// if (PEAR::isError($replace)) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
// " addFileToStorage - replaceFile Error ".
// "(".$replace->getMessage()."/".$replace->getUserInfo().")\n"
// );
// file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo());
// return $replace;
// }
// #$this->addLogItem("replace it \n");
// } else {
// // add as new
// $name = $tree->children[0]->children[0]->content;
// if (empty($name)) {
// $name = $tree->attrs['title']->val;
// }
// if (empty($name)) {
// $name = '???';
// }
// if ($this->loglevel=='debug') {
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
// "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
// );
// }
// $values = array(
// "filename" => $name,
// "filepath" => $mediaFileLP,
// "metadata" => $file,
// "gunid" => $gunid,
// "filetype" => $type
// );
// $put = $this->gb->putFile($values, $this->sessid);
// //$this->addLogItem("add as new \n");
// if (PEAR::isError($put)) {
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
// " addFileToStorage - putFile Error ".
// "(".$put->getMessage()."/".$put->getUserInfo().")\n"
// ."\n---\n".file_get_contents($file)."\n---\n"
// );
// file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
// //$this->addLogItem("Error Object: ".print_r($put,true)."\n");
// return $put;
// }
// }
// $ac = StoredFile::RecallByGunid($gunid);
// if (is_null($ac) || PEAR::isError($ac)) {
// return $ac;
// }
// $res = $ac->setState('ready');
// if (PEAR::isError($res)) {
// return $res;
// }
// return true;
// }
/**
* Figure out the environment to the backup.
*
*/
function setEnviroment()
{
global $CC_CONFIG;
if ($this->loglevel=='debug') {
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setEnviroment\n");
}
$this->statusFile = $CC_CONFIG['accessDir'].'/'.$this->token.'.status';
$this->tmpDir = '/tmp/ls_restore/'.$this->token.'/';
$this->rMkDir($this->tmpDir);
}
/**
* Add a line to the logfile.
*
* @param string $item
* the new row of log file
*/
function addLogItem($item)
{
$f = fopen ($this->logFile,'a');
flock($f,LOCK_SH);
fwrite($f,$item);
flock($f,LOCK_UN);
fclose($f);
//echo file_get_contents($this->logFile)."<BR><BR>\n\n";
}
/**
* Delete a directory recursive
*
* @param string $dirname
* path of dir
*
* @return boolean
* is success
*/
function rRmDir($dirname)
{
if (is_dir($dirname)) {
$dir_handle = opendir($dirname);
}
while ($file = readdir($dir_handle)) {
if ($file!="." && $file!="..") {
if (!is_dir($dirname."/".$file)) {
unlink ($dirname."/".$file);
} else {
Restore::rRmDir($dirname."/".$file);
}
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
/**
* Create a directory recursive
*
* @param string $dirname
* path of dir.
* @param int $mode
* octal - rights of dir.
* @param boolean $recursive
* do it recursive.
*
* @return boolean
*/
function rMkDir($dirname, $mode=0777, $recursive=true)
{
if (is_null($dirname) || $dirname === "" ) {
return false;
}
if (is_dir($dirname) || $dirname === "/" ) {
return true;
}
if ($this->rMkDir(dirname($dirname), $mode, $recursive)) {
return mkdir($dirname, $mode);
}
return false;
}
} // class Restore
?>

View File

@ -1,560 +0,0 @@
<?php
require_once("StoredFile.php");
require_once("BasicStor.php");
class ScheduleGroup {
private $groupId;
public function __construct($p_groupId = null) {
$this->groupId = $p_groupId;
}
/**
* Return true if the schedule group exists in the DB.
* @return boolean
*/
public function exists() {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG['scheduleTable']
." WHERE group_id=".$this->groupId;
$result = $CC_DBC->GetOne($sql);
if (PEAR::isError($result)) {
return $result;
}
return $result != "0";
}
/**
* Convert a date to an ID by stripping out all characters
* and padding with zeros.
*
* @param string $p_dateStr
*/
public static function dateToId($p_dateStr) {
$p_dateStr = str_replace(":", "", $p_dateStr);
$p_dateStr = str_replace(" ", "", $p_dateStr);
$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());
//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 {
function __construct() {
}
/**
* Return true if there is nothing in the schedule for the given start time
* up to the length of time after that.
*
* @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
*/
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;
//var_dump($sql);
$count = $CC_DBC->GetOne($sql);
//var_dump($count);
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:
* "playlistId"/"playlist_id" (aliases to the same thing)
* "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
* "group_id"/"id" (aliases to the same thing)
* "clip_length" (for audio clips this is the length of the audio clip,
* for playlists this is the length of the entire playlist)
* "name" (playlist only)
* "creator" (playlist only)
* "file_id" (audioclip only)
* "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_toDateTime
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
* @param boolean $p_playlistsOnly
* Retreive playlists as a single item.
* @return array
* Returns empty array if nothing found
*/
public static function GetItems($p_fromDateTime, $p_toDateTime, $p_playlistsOnly = true) {
global $CC_CONFIG, $CC_DBC;
$rows = array();
if (!$p_playlistsOnly) {
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') "
." AND (ends <= TIMESTAMP '$p_toDateTime')";
$rows = $CC_DBC->GetAll($sql);
foreach ($rows as &$row) {
$row["count"] = "1";
$row["playlistId"] = $row["playlist_id"];
$row["start"] = $row["starts"];
$row["end"] = $row["ends"];
$row["id"] = $row["group_id"];
}
} else {
$sql = "SELECT MIN(name) AS name, MIN(creator) AS creator, group_id, "
." SUM(clip_length) AS clip_length,"
." MIN(file_id) AS file_id, COUNT(*) as count,"
." MIN(playlist_id) AS playlist_id, MIN(starts) AS starts, MAX(ends) AS ends"
." FROM ".$CC_CONFIG["scheduleTable"]
." LEFT JOIN ".$CC_CONFIG["playListTable"]." ON playlist_id = ".$CC_CONFIG["playListTable"].".id"
." WHERE (starts >= TIMESTAMP '$p_fromDateTime') AND (ends <= TIMESTAMP '$p_toDateTime')"
." GROUP BY group_id"
." ORDER BY starts";
//var_dump($sql);
$rows = $CC_DBC->GetAll($sql);
if (!PEAR::isError($rows)) {
foreach ($rows as &$row) {
$row["playlistId"] = $row["playlist_id"];
$row["start"] = $row["starts"];
$row["end"] = $row["ends"];
$row["id"] = $row["group_id"];
}
}
}
return $rows;
}
public function getSchedulerTime() {
}
public function getCurrentlyPlaying() {
}
public function getNextItem($nextCount = 1) {
}
public function getStatus() {
}
/**
* Convert a time string in the format "YYYY-MM-DD HH:mm:SS"
* to "YYYY-MM-DD-HH-mm-SS".
*
* @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;
}
/**
* Convert a time string in the format "YYYY-MM-DD-HH-mm-SS" to
* "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";
}
/**
* Converts a time value as a string (with format HH:MM:SS.mmmmmm) to
* millisecs.
*
* @param string $p_time
* @return int
*/
private static function WallTimeToMillisecs($p_time)
{
$t = explode(":", $p_time);
$millisecs = 0;
if (strpos($t[2], ".")) {
$secParts = explode(".", $t[2]);
$millisecs = $secParts[1];
$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;
}
/**
* Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
* Note: currently only supports calculating millisec differences.
*
* @param string $p_time1
* @param string $p_time2
* @return double
*/
private static function TimeDiff($p_time1, $p_time2)
{
$parts1 = explode(".", $p_time1);
$parts2 = explode(".", $p_time2);
$diff = 0;
if ( (count($parts1) > 1) && (count($parts2) > 1) ) {
$millisec1 = substr($parts1[1], 0, 3);
$millisec1 = str_pad($millisec1, 3, "0");
$millisec1 = intval($millisec1);
$millisec2 = substr($parts2[1], 0, 3);
$millisec2 = str_pad($millisec2, 3, "0");
$millisec2 = intval($millisec2);
$diff = abs(millisec1 - millisec2)/1000;
}
return $diff;
}
/**
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
*
* @param string $range
* In the format "YYYY-MM-DD HH:mm:ss"
* @param string $source
* In the format "YYYY-MM-DD HH:mm:ss"
*/
public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
{
global $CC_CONFIG, $CC_DBC;
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
$range_dt = array('start' => $range_start, 'end' => $range_end);
//var_dump($range_dt);
// Scheduler wants everything in a playlist
$data = Schedule::GetItems($range_start, $range_end, true);
//echo "<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"],
'uri' => $uri,
'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]),
'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]),
'fade_cross' => 0,
'cue_in' => Schedule::WallTimeToMillisecs($item["cue_in"]),
'cue_out' => $cueOut,
'export_source' => 'scheduler'
);
}
$playlist['medias'] = $medias;
}
$result = array();
$result['status'] = array('range' => $range_dt, 'version' => "0.2");
$result['playlists'] = $playlists;
$result['check'] = 1;
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

@ -1,313 +0,0 @@
<?
define('INDCH', ' ');
require_once("XmlParser.php");
/**
* SmilPlaylist class
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class SmilPlaylist {
/**
* Parse SMIL file or string
*
* @param string $data
* local path to SMIL file or SMIL string
* @param string $loc
* location: 'file'|'string'
* @return array
* reference, parse result tree (or PEAR::error)
*/
private static function &parse($data='', $loc='file')
{
return XmlParser::parse($data, $loc);
}
/**
* Import SMIL file to storage
*
* @param GreenBox $gb
* reference to GreenBox object
* @param string $aPath
* absolute path part of imported file (e.g. /home/user/campcaster)
* @param string $rPath
* relative path/filename part of imported file
* (e.g. playlists/playlist_1.smil)
* @param array $gunids
* hash relation from filenames to gunids
* @param string $plid
* playlist gunid
* @param int $subjid
* local subject (user) id (id of user doing the import)
* @return Playlist
*/
public static function &import(&$gb, $aPath, $rPath, &$gunids, $plid, $subjid=NULL)
{
$parr = compact('subjid', 'aPath', 'plid', 'rPath');
$path = realpath("$aPath/$rPath");
if (FALSE === $path) {
return PEAR::raiseError(
"SmilPlaylist::import: file doesn't exist ($aPath/$rPath)"
);
}
$lspl = SmilPlaylist::convert2lspl($gb, $path, $gunids, $parr);
if (PEAR::isError($lspl)) {
return $lspl;
}
require_once("Playlist.php");
$pl =& Playlist::create($gb, $plid, "imported_SMIL");
if (PEAR::isError($pl)) {
return $pl;
}
$r = $pl->lock($gb, $subjid);
if (PEAR::isError($r)) {
return $r;
}
$r = $pl->setMetadata($lspl, 'string', 'playlist');
if (PEAR::isError($r)) {
return $r;
}
$r = $pl->unlock($gb);
if (PEAR::isError($r)) {
return $r;
}
return $pl;
}
/**
* Import SMIL file to storage.
*
* @param GreenBox $gb
* @param string $data
* local path to SMIL file
* @param hasharray $gunids
* hash relation from filenames to gunids
* @param array $parr
* array of subjid, aPath, plid, rPath
* @return string
* XML of playlist in Campcaster playlist format
*/
public static function convert2lspl(&$gb, $data, &$gunids, $parr)
{
extract($parr);
$tree = SmilPlaylist::parse($data);
if (PEAR::isError($tree)) {
return $tree;
}
if ($tree->name != 'smil') {
return PEAR::raiseError("SmilPlaylist::parse: smil tag expected");
}
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag smil",
$tree->children[1]->name
));
}
$res = SmilPlaylistBodyElement::convert2lspl(
$gb, $tree->children[0], &$gunids, $parr);
return $res;
}
} // SmilPlaylist
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class SmilPlaylistBodyElement {
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
$ind2 = $ind.INDCH;
if ($tree->name != 'body') {
return PEAR::raiseError("SmilPlaylist::parse: body tag expected");
}
if (isset($tree->children[1])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag body",
$tree->children[1]->name
));
}
$res = SmilPlaylistParElement::convert2lspl(
$gb, $tree->children[0], &$gunids, $parr, $ind2);
if (PEAR::isError($res)) {
return $res;
}
$title = basename($rPath);
$playlength = '0';
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"$ind<playlist id=\"$plid\" playlength=\"$playlength\" title=\"$title\">\n".
"$ind2<metadata/>\n".
"$res".
"$ind</playlist>\n";
return $res;
}
} // class SmilPlaylistBodyElement
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class SmilPlaylistParElement {
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
if ($tree->name != 'par') {
return PEAR::raiseError("SmilPlaylist::parse: par tag expected");
}
$res = '';
foreach ($tree->children as $i => $ch) {
$ch =& $tree->children[$i];
$r = SmilPlaylistAudioElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind.INDCH);
if (PEAR::isError($r)) {
return $r;
}
$res .= $r;
}
return $res;
}
}
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class SmilPlaylistAudioElement {
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
$uri = $tree->attrs['src']->val;
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
$ind2 = $ind.INDCH;
if ($tree->name != 'audio') {
return PEAR::raiseError("SmilPlaylist::parse: audio tag expected");
}
if (isset($tree->children[2])) {
return PEAR::raiseError(sprintf(
"SmilPlaylist::parse: unexpected tag %s in tag audio",
$tree->children[2]->name
));
}
$res = ''; $fadeIn = 0; $fadeOut = 0;
foreach ($tree->children as $i => $ch) {
$ch =& $tree->children[$i];
$r = SmilPlaylistAnimateElement::convert2lspl($gb, $ch, &$gunids, $parr, $ind2);
if (PEAR::isError($r)) {
return $r;
}
switch ($r['type']) {
case "fadeIn": $fadeIn = $r['val']; break;
case "fadeOut": $fadeOut = $r['val']; break;
}
}
if ($fadeIn > 0 || $fadeOut > 0) {
$fiGunid = StoredFile::CreateGunid();
$fadeIn = Playlist::secondsToPlaylistTime($fadeIn);
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut);
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
} else {
$fInfo = '';
}
$plElGunid = StoredFile::CreateGunid();
$acGunid = $gunid;
$type = 'audioClip';
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
switch (strtolower($ext = $va[1])) {
case "lspl":
case "xml":
case "smil":
case "m3u":
$type = 'playlist';
$acId = $gb->bsImportPlaylistRaw($gunid,
$aPath, $uri, $ext, $gunids, $subjid);
if (PEAR::isError($acId)) {
return $r;
}
//break;
default:
$ac = StoredFile::RecallByGunid($gunid);
if (is_null($ac) || PEAR::isError($ac)) {
return $ac;
}
$r = $ac->md->getMetadataElement('dcterms:extent');
if (PEAR::isError($r)) {
return $r;
}
$playlength = $r[0]['value'];
}
}
$title = basename($tree->attrs['src']->val);
$offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val);
$clipStart = Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val);
$clipEnd = Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val);
$clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val);
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n".
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
$fInfo.
"$ind</playlistElement>\n";
return $res;
}
} // class SmilPlaylistAudioElement
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class SmilPlaylistAnimateElement {
public static function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
{
extract($parr);
if ($tree->name != 'animate') {
return PEAR::raiseError("SmilPlaylist::parse: animate tag expected");
}
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
$tree->attrs['from']->val == '0%' &&
$tree->attrs['to']->val == '100%' &&
$tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' &&
$tree->attrs['begin']->val == '0s' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $va)
) {
return array('type'=>'fadeIn', 'val'=>intval($va[1]));
}
if ($tree->attrs['attributeName']->val == 'soundLevel' &&
$tree->attrs['from']->val == '100%' &&
$tree->attrs['to']->val == '0%' &&
$tree->attrs['calcMode']->val == 'linear' &&
$tree->attrs['fill']->val == 'freeze' &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['begin']->val, $vaBegin) &&
preg_match("|^([0-9.]+)s$|", $tree->attrs['end']->val, $vaEnd)
) {
return array('type'=>'fadeOut', 'val'=>($vaEnd[1] - $vaBegin[1]));
}
return PEAR::raiseError(
"SmilPlaylistAnimateElement::convert2lspl: animate parameters too general"
);
}
} // class SmilPlaylistAnimateElement
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,683 +0,0 @@
<?php
define('ALIBERR_NOTGR', 20);
define('ALIBERR_BADSMEMB', 21);
/**
* Subj class
*
* users + groups
* with "linearized recursive membership" ;)
* (allow adding users to groups or groups to groups)
*
* @package Campcaster
* @subpackage Alib
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @see ObjClasses
* @see Alib
*/
class Subjects {
/* ======================================================= public methods */
/**
* Add new subject (a.k.a. "user")
*
* @param string $p_login
* @param string $p_pass
* @param string $p_realname
* @param boolean $p_passenc
* password already encrypted if true
* @return int|PEAR_Error
*/
public static function AddSubj($p_login, $p_pass=NULL, $p_realname='', $p_passenc=FALSE)
{
global $CC_CONFIG, $CC_DBC;
if (!$p_login) {
return $CC_DBC->raiseError("Subjects::AddSubj: empty login");
}
$id = $CC_DBC->nextId($CC_CONFIG['subjSequence']);
if (PEAR::isError($id)) {
return $id;
}
if (!is_null($p_pass) && !$p_passenc) {
$p_pass = md5($p_pass);
}
$sql = "INSERT INTO ".$CC_CONFIG['subjTable']." (id, login, pass, type, realname)"
." VALUES ($id, '$p_login', ".
(is_null($p_pass) ? "'!', 'G'" : "'$p_pass', 'U'").",
'$p_realname')";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
return $id;
}
/**
* Remove subject by uid or by login
*
* @param string $login
* @param int $uid
* @return boolean|PEAR_Error
*/
public static function RemoveSubj($login, $uid=NULL)
{
global $CC_CONFIG, $CC_DBC;
if (is_null($uid)) {
$uid = Subjects::GetSubjId($login);
}
if (PEAR::isError($uid)) {
return $uid;
}
$sql = "DELETE FROM ".$CC_CONFIG['smembTable']
." WHERE (uid='$uid' OR gid='$uid') AND mid is null";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
$sql2 = "DELETE FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login'";
$r = $CC_DBC->query($sql2);
if (PEAR::isError($r)) {
return $r;
}
return Subjects::_rebuildRels();
} // fn removeSubj
/**
* Check login and password
*
* @param string $login
* @param string $pass
* optional
* @return boolean|int|PEAR_Error
*/
public static function Authenticate($login, $pass='')
{
global $CC_CONFIG, $CC_DBC;
$cpass = md5($pass);
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login' AND pass='$cpass' AND type='U'";
$id = $CC_DBC->getOne($sql);
if (PEAR::isError($id)) {
return $id;
}
return (is_null($id) ? FALSE : $id);
} // fn authenticate
/**
* Set lastlogin or lastfail timestamp
*
* @param string $login
* @param boolean $failed
* true=> set lastfail, false=> set lastlogin
* @return boolean|int|PEAR_Error
*/
public static function SetTimeStamp($login, $failed=FALSE)
{
global $CC_CONFIG, $CC_DBC;
$fld = ($failed ? 'lastfail' : 'lastlogin');
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET $fld=now()"
." WHERE login='$login'";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
} // fn setTimeStamp
/**
* Change user password
*
* @param string $login
* @param string $oldpass
* old password (optional for 'superuser mode')
* @param string $pass
* optional
* @param boolean $passenc
* optional, password already encrypted if true
* @return boolean|PEAR_Error
*/
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
{
global $CC_CONFIG, $CC_DBC;
if (!$passenc) {
$cpass = md5($pass);
} else {
$cpass = $pass;
}
if (!is_null($oldpass)) {
$oldcpass = md5($oldpass);
$oldpCond = "AND pass='$oldcpass'";
} else {
$oldpCond = '';
}
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'"
." WHERE login='$login' $oldpCond AND type='U'";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
} // fn passwd
/* --------------------------------------------------------------- groups */
/**
* Add {login} and direct/indirect members to {gname} and to groups,
* where {gname} is [in]direct member
*
* @param string $login
* @param string $gname
* @return int|PEAR_Error
*/
public static function AddSubjectToGroup($login, $gname)
{
$uid = Subjects::GetSubjId($login);
if (PEAR::isError($uid)) {
return $uid;
}
$gid = Subjects::GetSubjId($gname);
if (PEAR::isError($gid)) {
return $gid;
}
$isgr = Subjects::IsGroup($gid);
if (PEAR::isError($isgr)) {
return $isgr;
}
if (!$isgr) {
return PEAR::raiseError("Subjects::addSubj2Gr: Not a group ($gname)", ALIBERR_NOTGR);
}
// add subject and all [in]direct members to group $gname:
$mid = Subjects::_plainAddSubjectToGroup($uid, $gid);
if (PEAR::isError($mid)) {
return $mid;
}
// add it to all groups where $gname is [in]direct member:
$marr = Subjects::_listRMemb($gid);
if (PEAR::isError($marr)) {
return $marr;
}
foreach ($marr as $k => $v) {
$r = Subjects::_plainAddSubjectToGroup(
$uid, $v['gid'], intval($v['level'])+1, $v['id']);
if (PEAR::isError($r)) {
return $r;
}
}
return $mid;
} // fn addSubj2Gr
/**
* Remove subject from group
*
* @param string $login
* @param string $gname
* @return boolean|PEAR_Error
*/
public static function RemoveSubjectFromGroup($login, $gname)
{
global $CC_CONFIG, $CC_DBC;
$uid = Subjects::GetSubjId($login);
if (PEAR::isError($uid)) {
return $uid;
}
$gid = Subjects::GetSubjId($gname);
if (PEAR::isError($gid)) {
return $gid;
}
$sql = "SELECT id FROM ".$CC_CONFIG['smembTable']
." WHERE uid='$uid' AND gid='$gid' AND mid is null";
$mid = $CC_DBC->getOne($sql);
if (is_null($mid)) {
return FALSE;
}
if (PEAR::isError($mid)) {
return $mid;
}
// remove it:
$r = Subjects::_removeMemb($mid);
if (PEAR::isError($r)) {
return $r;
}
// and rebuild indirect memberships:
$r = Subjects::_rebuildRels();
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
} // fn removeSubjFromGr
/* --------------------------------------------------------- info methods */
/**
* Get subject id from login
*
* @param string $login
* @return int|PEAR_Error
*/
public static function GetSubjId($login)
{
global $CC_CONFIG;
global $CC_DBC;
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login'";
return $CC_DBC->getOne($sql);
} // fn getSubjId
/**
* Get subject name (login) from id
*
* @param int $id
* @param string $fld
* @return string|PEAR_Error
*/
public static function GetSubjName($id, $fld='login')
{
global $CC_CONFIG;
global $CC_DBC;
$sql = "SELECT $fld FROM ".$CC_CONFIG['subjTable']
." WHERE id='$id'";
return $CC_DBC->getOne($sql);
} // fn getSubjName
/**
* Get one subject from the table.
*
* @param string $p_fieldValue
* @param string $p_fieldName
* @return array
*/
public static function GetSubject($p_fieldValue, $p_fieldName='login')
{
global $CC_CONFIG, $CC_DBC;
if (!in_array($p_fieldName, array("login", "id"))) {
return null;
}
$escapedValue = pg_escape_string($p_fieldValue);
$sql = "SELECT * FROM ".$CC_CONFIG['subjTable']
." WHERE $p_fieldName='$escapedValue'";
$row = $CC_DBC->GetRow($sql);
return $row;
}
/**
* Get all subjects
*
* @param string $flds
* @return array|PEAR_Error
*/
public static function GetSubjects($flds='id, login')
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT $flds FROM ".$CC_CONFIG['subjTable'];
return $CC_DBC->getAll($sql);
} // fn getSubjects
/**
* Get subjects with count of direct members
*
* @return array|PEAR_Error
*/
public static function GetSubjectsWCnt()
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(m.uid)as cnt, s.id, s.login, s.type"
." FROM ".$CC_CONFIG['subjTable']." s"
." LEFT JOIN ".$CC_CONFIG['smembTable']." m ON m.gid=s.id"
." WHERE m.mid is null"
." GROUP BY s.id, s.login, s.type"
." ORDER BY s.id";
return $CC_DBC->getAll($sql);
} // fn getSubjectsWCnt
/**
* Return true if subject is a group
*
* @param int $gid
* @return boolean|PEAR_Error
*/
public static function IsGroup($gid)
{
global $CC_CONFIG, $CC_DBC;
if (empty($gid)) {
return FALSE;
}
$sql = "SELECT type FROM ".$CC_CONFIG['subjTable']
." WHERE id='$gid'";
$r = $CC_DBC->getOne($sql);
if (PEAR::isError($r)) {
return $r;
}
return ($r === 'G');
} // fn isGroup
/**
* List direct members of group
*
* @param int $gid
* @return array|PEAR_Error
*/
public static function ListGroup($gid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT s.id, s.login, s.type"
." FROM ".$CC_CONFIG['smembTable']." m, ".$CC_CONFIG['subjTable']." s"
." WHERE m.uid=s.id AND m.mid is null AND m.gid='$gid'";
return $CC_DBC->getAll($sql);
} // fn listGroup
/**
* Return true if uid is [id]direct member of gid
*
* @param int $uid
* local user id
* @param int $gid
* local group id
* @return boolean
*/
public static function IsMemberOf($uid, $gid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(*)as cnt"
." FROM ".$CC_CONFIG['smembTable']
." WHERE uid='$uid' AND gid='$gid'";
$res = $CC_DBC->getOne($sql);
if (PEAR::isError($res)) {
return $res;
}
return (intval($res) > 0);
} // fn isMemberOf
/* ==================================================== "private" methods */
/**
* Create membership record
*
* @param int $uid
* @param int $gid
* @param int $level
* @param int $mid
* @return int|PEAR_Error
*/
private static function _addMemb($uid, $gid, $level=0, $mid='null')
{
global $CC_CONFIG, $CC_DBC;
if ($uid == $gid) {
return PEAR::raiseError("Subjects::_addMemb: uid==gid ($uid)", ALIBERR_BADSMEMB);
}
$sql = "SELECT id, level, mid FROM ".$CC_CONFIG['smembTable']
." WHERE uid='$uid' AND gid='$gid' ORDER BY level ASC";
$a = $CC_DBC->getAll($sql);
if (PEAR::isError($a)) {
return $a;
}
if (count($a) > 0) {
$a0 = $a[0];
$id = $a0['id'];
if ($level < intval($a0['level'])){
$sql2 = "UPDATE ".$CC_CONFIG['smembTable']
." SET level='$level', mid=$mid WHERE id='{$a0['id']}'";
$r = $CC_DBC->query($sql2);
if (PEAR::isError($r)) {
return $r;
}
}
} else {
$id = $CC_DBC->nextId($CC_CONFIG['smembSequence']);
if (PEAR::isError($id)) {
return $id;
}
$sql3 = "INSERT INTO ".$CC_CONFIG['smembTable']." (id, uid, gid, level, mid)"
." VALUES ($id, $uid, $gid, $level, $mid)";
$r = $CC_DBC->query($sql3);
if (PEAR::isError($r)) {
return $r;
}
}
return $id;
} // fn _addMemb
/**
* Remove membership record
*
* @param int $mid
* @return null|PEAR_Error
*/
private static function _removeMemb($mid)
{
global $CC_CONFIG, $CC_DBC;
$sql = "DELETE FROM ".$CC_CONFIG['smembTable']
." WHERE id='$mid'";
return $CC_DBC->query($sql);
} // fn _removeMemb
/**
* List [in]direct members of group
*
* @param int $gid
* @param int $uid
* @return array|PEAR_Error
*/
private static function _listMemb($gid, $uid=NULL)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT id, uid, level FROM ".$CC_CONFIG['smembTable']
." WHERE gid='$gid'".(is_null($uid) ? '' : " AND uid='$uid'");
return $CC_DBC->getAll($sql);
} // fn _listMemb
/**
* List groups where uid is [in]direct member
*
* @param int $gid
* @param int $uid
* @return array|PEAR_Error
*/
private static function _listRMemb($uid, $gid=NULL)
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT id, gid, level FROM ".$CC_CONFIG['smembTable']
." WHERE uid='$uid'".(is_null($gid) ? '' : " AND gid='$gid'");
return $CC_DBC->getAll($sql);
} // fn listRMemb
/**
* Add uid and its [in]direct members to gid
*
* @param int $uid
* @param int $gid
* @param int $level
* @param int $rmid
* @return int|PEAR_Error
*/
private static function _plainAddSubjectToGroup($uid, $gid, $level=0, $rmid='null')
{
$mid = Subjects::_addMemb($uid, $gid, $level, $rmid);
if (PEAR::isError($mid)) {
return $mid;
}
$marr = Subjects::_listMemb($uid);
if (PEAR::isError($marr)) {
return $marr;
}
foreach ($marr as $k => $v) {
$r = Subjects::_addMemb(
$v['uid'], $gid, intval($v['level'])+$level+1, $mid
);
if (PEAR::isError($r)) {
return $r;
}
}
return $mid;
}
/**
* Rebuild indirect membership records<br>
* it's probably more complicated to do removing without rebuild ...
*
* @return true|PEAR_Error
*/
private static function _rebuildRels()
{
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("BEGIN");
$r = $CC_DBC->query("LOCK TABLE ".$CC_CONFIG['smembTable']);
if (PEAR::isError($r)) {
return $r;
}
$sql = "DELETE FROM ".$CC_CONFIG['smembTable']
." WHERE mid is not null";
$r = $CC_DBC->query($sql);
if (PEAR::isError($r)) {
return $r;
}
$arr = $CC_DBC->getAll("SELECT uid, gid FROM ".$CC_CONFIG['smembTable']);
// WHERE mid is null
if (PEAR::isError($arr)) {
return $arr;
}
foreach ($arr as $it) {
$marr = Subjects::_listRMemb($it['gid']);
if (PEAR::isError($marr)) {
return $marr;
}
foreach ($marr as $k => $v) {
$r = Subjects::_plainAddSubjectToGroup(
$it['uid'], $v['gid'], intval($v['level'])+1, $v['id']
);
if (PEAR::isError($r)) {
return $r;
}
}
}
$r = $CC_DBC->query("COMMIT");
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
} // fn _rebuildRels
/* =============================================== test and debug methods */
/**
* Dump subjects for debug
*
* @param string $indstr
* indentation string
* @param string $ind
* actual indentation
* @return string
*/
public static function DumpSubjects($indstr=' ', $ind='')
{
$r = $ind.join(', ', array_map(
create_function('$v', 'return "{$v[\'login\']}({$v[\'cnt\']})";'),
Subjects::GetSubjectsWCnt()
))."\n";
return $r;
} // fn dumpSubjects
/**
* Delete all subjects and membership records
*
* @return void
*/
public static function DeleteData()
{
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['subjTable']);
$CC_DBC->query("DELETE FROM ".$CC_CONFIG['smembTable']);
//ObjClasses::DeleteData();
} // fn deleteData
/**
* Insert test data
*
* @return array
*/
public function TestData()
{
// $tdata = ObjClasses::TestData();
// $o['root'] = Subjects::AddSubj('root', 'q');
// $o['test1'] = Subjects::AddSubj('test1', 'a');
// $o['test2'] = Subjects::AddSubj('test2', 'a');
// $o['test3'] = Subjects::AddSubj('test3', 'a');
// $o['test4'] = Subjects::AddSubj('test4', 'a');
// $o['test5'] = Subjects::AddSubj('test5', 'a');
// $o['gr1'] = Subjects::AddSubj('gr1');
// $o['gr2'] = Subjects::AddSubj('gr2');
// $o['gr3'] = Subjects::AddSubj('gr3');
// $o['gr4'] = Subjects::AddSubj('gr4');
// Subjects::AddSubjectToGroup('test1', 'gr1');
// Subjects::AddSubjectToGroup('test2', 'gr2');
// Subjects::AddSubjectToGroup('test3', 'gr3');
// Subjects::AddSubjectToGroup('test4', 'gr4');
// Subjects::AddSubjectToGroup('test5', 'gr1');
// Subjects::AddSubjectToGroup('gr4', 'gr3');
// Subjects::AddSubjectToGroup('gr3', 'gr2');
// $tdata['subjects'] = $o;
// return $tdata;
} // fn TestData
/**
* Make basic test
*
*/
public static function Test()
{
// $p = ObjClasses::Test();
// if (PEAR::isError($p)) {
// return $p;
// }
// Subjects::DeleteData();
// Subjects::TestData();
// $test_correct = "root(0), test1(0), test2(0), test3(0),".
// " test4(0), test5(0), gr1(2), gr2(2), gr3(2), gr4(1)\n";
// $test_dump = Subjects::DumpSubjects();
// Subjects::RemoveSubj('test1');
// Subjects::RemoveSubj('test3');
// Subjects::RemoveSubjectFromGroup('test5', 'gr1');
// Subjects::RemoveSubjectFromGroup('gr3', 'gr2');
// $test_correct .= "root(0), test2(0), test4(0), test5(0),".
// " gr1(0), gr2(1), gr3(1), gr4(1)\n";
// $test_dump .= Subjects::DumpSubjects();
// Subjects::DeleteData();
// if ($test_dump == $test_correct) {
// $test_log .= "subj: OK\n";
// return TRUE;
// } else {
// return PEAR::raiseError(
// 'Subjects::test:', 1, PEAR_ERROR_DIE, '%s'.
// "<pre>\ncorrect:\n{$test_correct}\n".
// "dump:\n{$test_dump}\n</pre>\n");
// }
} // fn test
} // class Subjects
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,419 +0,0 @@
<?php
define('TR_LEAVE_CLOSED', TRUE);
/**
* Auxiliary class for transport records
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class TransportRecord
{
/**
* @var DB
*/
//public $dbc;
/**
* @var GreenBox
*/
private $gb;
/**
* @var array
*/
//private $config;
/**
* @var Transport
*/
private $tr;
/**
* @var boolean
*/
private $recalled = FALSE;
/**
* @var boolean
*/
private $dropped = FALSE;
/**
* @param Transport $tr
* @return TransportRecord
*/
public function __construct(&$tr)
{
$this->tr =& $tr;
$this->gb =& $tr->gb;
}
/**
* Factory method
*
* @param Transport $tr
* @param string $trtype
* transport type (see Transport::install)
* @param string $direction
* 'up' | 'down'
* @param array $defaults
* default parameters (optional, internal use)
* @return TransportRecord
*/
function create(&$tr, $trtype, $direction='up', $defaults=array())
{
global $CC_DBC, $CC_CONFIG;
$trec = new TransportRecord($tr);
$trec->trtok = $trtok = $tr->_createTransportToken();
$trec->row = array_merge($defaults,
array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE;
if (!isset($defaults['title'])) {
$defaults['title'] = $trec->getTitle();
if (PEAR::isError($defaults['title'])) {
return $defaults['title'];
}
}
$id = $CC_DBC->nextId($CC_CONFIG['transSequence']);
$names = "id, trtok, direction, state, trtype, start, ts";
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
foreach ($defaults as $k => $v) {
$sqlVal = $trec->_getSqlVal($k, $v);
$names .= ", $k";
$values .= ", $sqlVal";
}
$query = "
INSERT INTO ".$CC_CONFIG['transTable']."
($names)
VALUES
($values)
";
$res = $CC_DBC->query($query);
if (PEAR::isError($res)) {
return $res;
}
return $trec;
}
/**
* Recall transport record from DB
*
* @param Transport $tr
* @param string $trtok
* transport token
* @return TransportRecord
*/
function recall(&$tr, $trtok)
{
global $CC_DBC, $CC_CONFIG;
$trec = new TransportRecord($tr);
$trec->trtok = $trtok;
$row = $CC_DBC->getRow("
SELECT
id, trtok, state, trtype, direction,
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
fname, localfile, url, rtrtok, mdtrtok, uid,
expectedsize, realsize, expectedsum, realsum,
errmsg, title, jobpid
FROM ".$CC_CONFIG['transTable']."
WHERE trtok='$trtok'
");
if (PEAR::isError($row)) {
return $row;
}
if (is_null($row)) {
return PEAR::raiseError("TransportRecord::recall:".
" invalid transport token ($trtok)", TRERR_TOK
);
}
$row['pdtoken'] = StoredFile::NormalizeGunid($row['pdtoken']);
$row['gunid'] = StoredFile::NormalizeGunid($row['gunid']);
$trec->row = $row;
$trec->recalled = TRUE;
return $trec;
}
/**
* Set state of transport record
*
* @param string $newState
* @param array $data
* other data fields to set
* @param string $oldState
* check old state and do nothing if differ
* @param boolean $lock
* check lock and do nothing if differ
* @return boolean success
*/
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
{
global $CC_CONFIG, $CC_DBC;
$set = " state='$newState', ts=now()";
if (!is_null($lock)) {
$slock = ($lock ? 'Y' : 'N');
$nlock = (!$lock);
$snlock = ($nlock ? 'Y' : 'N');
$set .= ", lock='$snlock'";
}
foreach ($data as $k => $v) {
$set .= ", $k=".$this->_getSqlVal($k, $v);
}
$r = $CC_DBC->query("
UPDATE ".$CC_CONFIG['transTable']."
SET $set
WHERE trtok='{$this->trtok}'".
(is_null($oldState) ? '' : " AND state='$oldState'").
(is_null($lock) ? '' : " AND lock = '$slock'")
);
if (PEAR::isError($r)) {
return $r;
}
// return TRUE;
$affRows = $CC_DBC->affectedRows();
if (PEAR::isError($affRows)) {
return $affRows;
}
return ($affRows == 1);
}
/**
* Return state of transport record
*
* @return string
* state
*/
function getState()
{
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::getState:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
return $this->row['state'];
}
/**
* Set lock on transport record and save/clear process id
*
* @param boolean $lock
* lock if true, release lock if false
* @param int $pid
* process id
* @return mixed
* true or error
*/
function setLock($lock, $pid=NULL)
{
global $CC_CONFIG, $CC_DBC;
$pidsql = (is_null($pid) ? "NULL" : "$pid" );
if ($this->dropped) {
return TRUE;
}
$slock = ($lock ? 'Y' : 'N');
$nlock = (!$lock);
$snlock = ($nlock ? 'Y' : 'N');
$r = $CC_DBC->query("
UPDATE ".$CC_CONFIG['transTable']."
SET lock='$slock', jobpid=$pidsql, ts=now()
WHERE trtok='{$this->trtok}' AND lock = '$snlock'"
);
if (PEAR::isError($r)) {
return $r;
}
$affRows = $CC_DBC->affectedRows();
if (PEAR::isError($affRows)) {
return $affRows;
}
if ($affRows === 0) {
$ltxt = ($lock ? 'lock' : 'unlock' );
return PEAR::raiseError(
"TransportRecord::setLock: can't $ltxt ({$this->trtok})"
);
}
return TRUE;
}
/**
* Return type of transport
*
* @return string
* Transport type
*/
function getTransportType()
{
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::getTransportType:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
return $this->row['trtype'];
}
/**
* Kill transport job (on pause or cancel)
*
* @return string
* Transport type
*/
function killJob()
{
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::getTransportType:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
$jobpid = $this->row['jobpid'];
$res = system("pkill -P $jobpid", $status);
}
/**
* Set state to failed and set error message in transport record
*
* @param string $txt
* base part of error message
* @param PEAR_Error $eo
* (opt.) error msg can be construct from it
* @return mixed
* boolean true or error
*/
function fail($txt='', $eo=NULL)
{
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::fail:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
$msg = $txt;
if (!is_null($eo)) {
$msg .= $eo->getMessage()." ".$eo->getUserInfo().
" [".$eo->getCode()."]";
}
$r = $this->setState('failed', array('errmsg'=>$msg));
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
}
/**
* Close transport record
*
* @return mixed
* boolean true or error
*/
function close()
{
global $CC_CONFIG, $CC_DBC;
if (!$this->recalled) {
return PEAR::raiseError("TransportRecord::close:".
" not recalled ({$this->trtok})", TRERR_TOK
);
}
if (TR_LEAVE_CLOSED) {
$r = $this->setState('closed');
if (PEAR::isError($r)) {
return $r;
}
} else {
$r = $CC_DBC->query("
DELETE FROM ".$CC_CONFIG['transTable']."
WHERE trtok='{$this->trtok}'
");
if (PEAR::isError($r)) {
return $r;
}
$this->recalled = FALSE;
$this->dropped = TRUE;
}
return TRUE;
}
/**
* Add field specific envelopes to values (e.g. ' around strings)
*
* @param string $fldName
* field name
* @param mixed $fldVal
* field value
* @return string
*/
function _getSqlVal($fldName, $fldVal)
{
switch ($fldName) {
case 'realsize':
case 'expectedsize':
case 'uid':
return ("$fldVal"!='' ? "$fldVal" : "NULL");
break;
case 'gunid':
case 'pdtoken':
return "x'$fldVal'::bigint";
break;
default:
$fldVal = pg_escape_string($fldVal);
return "'$fldVal'";
break;
}
}
/**
* Get title from transported object's metadata (if exists)
*
* @return string
* the title or descriptive string
*/
function getTitle()
{
$defStr = 'unknown';
$trtype = $this->getTransportType(); //contains recall check
if (PEAR::isError($trtype)) {
return $trtype;
}
switch ($trtype) {
case "audioclip":
case "playlist":
case "playlistPkg":
case "metadata":
$title = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
if (is_null($title)) {
$title = $defStr;
}
if (PEAR::isError($title)) {
if ($title->getCode() == GBERR_FOBJNEX) {
$title = $defStr;
} else {
return $title;
}
}
break;
case "searchjob":
$title = 'searchjob';
break;
case "file":
$title = ( isset($this->row['localfile']) ?
basename($this->row['localfile']) : 'regular file');
break;
default:
$title = $defStr;
}
return $title;
}
} // class TransportRecord
?>

View File

@ -1,385 +0,0 @@
<?php
define('VAL_ROOT', 110);
define('VAL_NOREQE', 111);
define('VAL_NOONEOF', 112);
define('VAL_UNKNOWNE', 113);
define('VAL_UNKNOWNA', 114);
define('VAL_NOTDEF', 115);
define('VAL_UNEXPONEOF', 116);
define('VAL_FORMAT', 117);
define('VAL_CONTENT', 118);
define('VAL_NOREQA', 119);
define('VAL_ATTRIB', 120);
define('VAL_PREDXML', 121);
/**
* Simple XML validator against structure stored in PHP hash-array hierarchy.
*
* Basic format files:
* <ul>
* <li>audioClipFormat.php</li>
* <li>webstreamFormat.php</li>
* <li>playlistFormat.php</li>
* </ul>
* It probably should be replaced by XML schema validation in the future.
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Validator {
/**
* Format type of validated document
* @var string
*/
private $format = NULL;
/**
* Preloaded format tree structure
* @var array
*/
private $formTree = NULL;
/**
* Gunid of validated file for identification in mass input
* @var string
*/
private $gunid = NULL;
/**
* Constructor
*
* @param string $format
* format type of validated document
* @param string $gunid
* gunid of validated file for identification in mass input
*/
public function __construct($format, $gunid)
{
$format = strtolower($format);
$this->format = $format;
$this->gunid = $gunid;
$formats = array(
'audioclip' => "audioClipFormat",
'playlist' => "playlistFormat",
'webstream' => "webstreamFormat",
);
if (!isset($formats[$format])) {
return $this->_err(VAL_FORMAT);
}
$formatName = $formats[$format];
$formatFile = dirname(__FILE__)."/$formatName.php";
if (!file_exists($formatFile)) {
return $this->_err(VAL_FORMAT);
}
require($formatFile);
$this->formTree = $$formatName;
}
/**
* Validate document - only wrapper for validateNode method
*
* @param object $data
* validated object tree
* @return mixed
* TRUE or PEAR::error
*/
function validate(&$data)
{
$r = $this->validateNode($data, $this->formTree['_root']);
return $r;
}
/**
* Validate one metadata value (on insert/update)
*
* @param string $fname
* parent element name
* @param string $category
* qualif.category name
* @param string $predxml
* 'A' | 'T' (attr or tag)
* @param string $value
* validated element value
* @return TRUE|PEAR_Error
*/
function validateOneValue($fname, $category, $predxml, $value)
{
$formTree =& $this->formTree;
switch ($predxml) {
case 'T':
if (!$this->isChildInFormat($fname, $category)) {
return $this->_err(VAL_UNKNOWNE, "$category in $fname");
}
break;
case 'A':
if (!$this->isAttrInFormat($fname, $category)) {
return $this->_err(VAL_UNKNOWNA, "$category in $fname");
}
break;
case 'N':
return TRUE;
break;
default:
return $this->_err(VAL_PREDXML, $predxml);
}
if (isset($formTree[$category]['regexp'])) {
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
if (!preg_match("|{$formTree[$category]['regexp']}|", $value)) {
return $this->_err(VAL_CONTENT, "$category/$value");
}
}
}
/**
* Validation of one element node from object tree
*
* @param object $node
* validated node
* @param string $fname
* actual name in format structure
* @return mixed
* TRUE or PEAR::error
*/
function validateNode(&$node, $fname)
{
$dname = (($node->ns? $node->ns.":" : '').$node->name);
$formTree =& $this->formTree;
if (DEBUG) {
echo"\nVAL::validateNode: 1 $dname/$fname\n";
}
// check root node name:
if ($dname != $fname) {
return $this->_err(VAL_ROOT, $fname);
}
// check if this element is defined in format:
if (!isset($formTree[$fname])) {
return $this->_err(VAL_NOTDEF, $fname);
}
// check element content
if (isset($formTree[$fname]['regexp'])) {
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
if (!preg_match("|{$formTree[$fname]['regexp']}|", $node->content)) {
return $this->_err(VAL_CONTENT, "$fname/{$node->content}");
}
}
// validate attributes:
$ra = $this->validateAttributes($node, $fname);
if (PEAR::isError($ra)) {
return $ra;
}
// validate children:
$r = $this->validateChildren($node, $fname);
if (PEAR::isError($r)) {
return $r;
}
return TRUE;
}
/**
* Validation of attributes
*
* @param object $node
* validated node
* @param string $fname
* actual name in format structure
* @return mixed
* TRUE or PEAR::error
*/
function validateAttributes(&$node, $fname)
{
$formTree =& $this->formTree;
$attrs = array();
// check if all attrs are permitted here:
foreach ($node->attrs as $i => $attr) {
$aname = (($attr->ns? $attr->ns.":" : '').$attr->name);
$attrs[$aname] =& $node->attrs[$i];
if (!$this->isAttrInFormat($fname, $aname)) {
return $this->_err(VAL_UNKNOWNA, $aname);
}
// check attribute format
// echo "XXA $aname\n";
if (isset($formTree[$aname]['regexp'])) {
// echo "XAR {$formTree[$fname]['regexp']} / ".$node->content."\n";
if (!preg_match("|{$formTree[$aname]['regexp']}|", $attr->val)) {
return $this->_err(VAL_ATTRIB, "$aname [".var_export($attr->val,TRUE)."]");
}
}
}
// check if all required attrs are here:
if (isset($formTree[$fname]['attrs'])) {
$fattrs =& $formTree[$fname]['attrs'];
if (isset($fattrs['required'])) {
foreach ($fattrs['required'] as $i => $attr) {
if (!isset($attrs[$attr])) {
return $this->_err(VAL_NOREQA, $attr);
}
}
}
}
return TRUE;
}
/**
* Validation children nodes
*
* @param object $node
* validated node
* @param string $fname
* actual name in format structure
* @return mixed
* TRUE or PEAR::error
*/
function validateChildren(&$node, $fname)
{
$formTree =& $this->formTree;
$childs = array();
// check if all children are permitted here:
foreach ($node->children as $i => $ch) {
$chname = (($ch->ns? $ch->ns.":" : '').$ch->name);
// echo "XXE $chname\n";
if (!$this->isChildInFormat($fname, $chname)) {
return $this->_err(VAL_UNKNOWNE, $chname);
}
// call children recursive:
$r = $this->validateNode($node->children[$i], $chname);
if (PEAR::isError($r)) {
return $r;
}
$childs[$chname] = TRUE;
}
// check if all required children are here:
if (isset($formTree[$fname]['childs'])) {
$fchilds =& $formTree[$fname]['childs'];
if (isset($fchilds['required'])) {
foreach ($fchilds['required'] as $i => $ch) {
if (!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
}
}
// required one from set
if (isset($fchilds['oneof'])) {
$one = FALSE;
foreach ($fchilds['oneof'] as $i => $ch) {
if (isset($childs[$ch])) {
if ($one) {
return $this->_err(VAL_UNEXPONEOF, "$ch in $fname");
}
$one = TRUE;
}
}
if (!$one) {
return $this->_err(VAL_NOONEOF);
}
}
}
return TRUE;
}
/**
* Test if child is presented in format structure
*
* @param string $fname
* node name in format structure
* @param string $chname
* child node name
* @return boolean
*/
function isChildInFormat($fname, $chname)
{
$listo = $this->isInFormatAs($fname, $chname, 'childs', 'optional');
$listr = $this->isInFormatAs($fname, $chname, 'childs', 'required');
$list1 = $this->isInFormatAs($fname, $chname, 'childs', 'oneof');
return ($listo!==FALSE || $listr!==FALSE || $list1!==FALSE);
}
/**
* Test if attribute is presented in format structure
*
* @param string $fname
* node name in format structure
* @param string $aname
* attribute name
* @return boolean
*/
function isAttrInFormat($fname, $aname)
{
$listr = $this->isInFormatAs($fname, $aname, 'attrs', 'required');
$listi = $this->isInFormatAs($fname, $aname, 'attrs', 'implied');
$listn = $this->isInFormatAs($fname, $aname, 'attrs', 'normal');
return ($listr!==FALSE || $listi!==FALSE || $listn!==FALSE);
}
/**
* Check if node/attribute is presented in format structure
*
* @param string $fname
* node name in format structure
* @param string $chname
* node/attribute name
* @param string $nType
* 'childs' | 'attrs'
* @param string $reqType
* <ul>
* <li>for elements: 'required' | 'optional' | 'oneof'</li>
* <li>for attributes: 'required' | 'implied' | 'normal'</li>
* </ul>
* @return mixed
* boolean/int (index int format array returned if found)
*/
function isInFormatAs($fname, $chname, $nType='childs', $reqType='required')
{
$formTree =& $this->formTree;
$listed = (
isset($formTree[$fname][$nType][$reqType]) ?
array_search($chname, $formTree[$fname][$nType][$reqType]) :
FALSE
);
return $listed;
}
/**
* Error exception generator
*
* @param int $errno
* erron code
* @param string $par
* optional string for more descriptive error messages
* @return PEAR_Error
*/
function _err($errno, $par='')
{
$msg = array(
VAL_ROOT => 'Wrong root element',
VAL_NOREQE => 'Required element missing',
VAL_NOONEOF => 'One-of element missing',
VAL_UNKNOWNE => 'Unknown element',
VAL_UNKNOWNA => 'Unknown attribute',
VAL_NOTDEF => 'Not defined',
VAL_UNEXPONEOF => 'Unexpected second object from one-of set',
VAL_FORMAT => 'Unknown format',
VAL_CONTENT => 'Invalid content',
VAL_NOREQA => 'Required attribute missing',
VAL_ATTRIB => 'Invalid attribute format',
VAL_PREDXML => 'Invalid predicate type',
);
return PEAR::raiseError(
"Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})",
$errno
);
}
} // class Validator
?>

View File

@ -1,398 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage StorageServer
*/
require_once "XML/Util.php";
/* ================================================================== Element */
/**
* Object representation of one XML element
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @see MetaData
*/
class XmlElement {
/**
* Namespace prefix
* @var string
*/
public $ns;
/**
* Element name
* @var string
*/
public $name;
/**
* Attributes
* @var array
*/
public $attrs = array();
/**
* Namespace definitions
* @var array
*/
public $nSpaces = array();
/**
* Child nodes
* @var array
*/
public $children = array();
/**
* Text content of element
* @var string
*/
public $content = '';
/**
* @param string $fullname
* Fully qualified name of element
* @param array $attrs
* hash of attributes
* @param array $nSpaces
* hash of namespace definitions
* @param array $children
* hash of child nodes
*/
public function __construct($fullname, $attrs, $nSpaces=array(), $children=array())
{
$a = XML_Util::splitQualifiedName($fullname);
$this->ns = $a['namespace'];
$this->name = $a['localPart'];
$this->attrs = $attrs;
$this->nSpaces = $nSpaces;
$this->children = $children;
}
} // class XmlElement
/* ================================================================ Attribute */
/**
* Object representation of one XML attribute
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @see MetaData
*/
class XmlAttrib {
/**
* Namespace prefix
* @var string
*/
public $ns;
/**
* Attribute name
* @var string
*/
public $name;
/**
* Attribute value
* @var string
*/
public $val;
/**
* @param string $atns
* namespace prefix
* @param string $atnm
* attribute name
* @param string $atv
* attribute value
*/
public function __construct($atns, $atnm, $atv)
{
$this->ns = $atns;
$this->name = $atnm;
$this->val = $atv;
}
} // fn XmlAttrib
/* =================================================================== Parser */
/**
* XML parser object encapsulation
*
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @see MetaData
*/
class XmlParser {
/**
* Tree of nodes
* @var array
*/
private $tree = NULL;
/**
* Parse stack
* @var array
*/
private $stack = array();
/**
* Error structure
* @var array
*/
private $err = array(FALSE, '');
/**
* @param string $data
* XML string to be parsed
*/
public function __construct($data){
$xml_parser = xml_parser_create('UTF-8');
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE);
xml_set_object($xml_parser, $this);
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_parser, 'characterData');
$res = xml_parse($xml_parser, $data, TRUE);
if (!$res) {
$this->err = array(TRUE,
sprintf("XML error: %s at line %d\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)
)
);
// var_dump($data);
}
xml_parser_free($xml_parser);
}
/**
* Parse XML file or string
*
* @param string $data
* local path to XML file or XML string
* @param string $loc
* location: 'file'|'string'
* @return array
* reference, parse result tree (or PEAR::error)
*/
function &parse($data='', $loc='file')
{
switch ($loc) {
case "file":
if (!is_file($data)) {
return PEAR::raiseError(
"XmlParser::parse: file not found ($data)"
);
}
if (!is_readable($data)) {
return PEAR::raiseError(
"XmlParser::parse: can't read file ($data)"
);
}
$data = file_get_contents($data);
case "string":
$parser = new XmlParser($data);
if ($parser->isError()) {
return PEAR::raiseError(
"XmlParser::parse: ".$parser->getError()
);
}
$tree = $parser->getTree();
break;
default:
return PEAR::raiseError(
"XmlParser::parse: unsupported source location ($loc)"
);
}
return $tree;
}
/**
* Start tag handler
*
* @param resource $parser
* reference to parser resource
* @param string $fullname
* element name
* @param array $attrs
* array of attributes
* @return none
*/
function startTag($parser, $fullname, $attrs) {
$nSpaces = array();
foreach ($attrs as $atn => $atv) {
$a = XML_Util::splitQualifiedName($atn);
$atns = $a['namespace'];
$atnm = $a['localPart'];
unset($attrs[$atn]);
if ($atns == 'xmlns') {
$nSpaces[$atnm] = $atv;
} else if ($atns == NULL && $atnm == 'xmlns') {
$nSpaces[''] = $atv;
} else {
$attrs[$atn] = new XmlAttrib($atns, $atnm, $atv);
}
}
$el = new XmlElement($fullname, $attrs, $nSpaces);
array_push($this->stack, $el);
}
/**
* End tag handler
*
* @param resource $parser
* reference to parser resource
* @param string $fullname
* element name
* @return none
*/
function endTag($parser, $fullname) {
$cnt = count($this->stack);
if ($cnt > 1) {
$this->stack[$cnt-2]->children[] = $this->stack[$cnt-1];
$lastEl = array_pop($this->stack);
} else {
$this->tree = $this->stack[0];
}
}
/**
* Character data handler
*
* @param resource $parser
* reference to parser resource
* @param string $data
* @return none
*/
function characterData($parser, $data) {
$cnt = count($this->stack);
if (trim($data)!='') {
$this->stack[$cnt-1]->content .= $data;
}
}
/**
* Default handler
*
* @param resource $parser
* reference to parser resource
* @param string $data
* @return none
*/
function defaultHandler($parser, $data)
{
$cnt = count($this->stack);
//if(substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";"){
// $this->stack[$cnt-1]->content .= trim($data);
//}else{
$this->stack[$cnt-1]->content .= "*** $data ***";
//}
}
/**
* Return result tree
*
* @return array
* tree structure
*/
function getTree()
{
return $this->tree;
}
/**
* Return error string
*
* @return boolean
* whether error occured
*/
function isError()
{
return $this->err[0];
}
/**
* Return error string
*
* @return string
* error message
*/
function getError()
{
return $this->err[1];
}
/* ----------------------------------- auxiliary methos for serialization */
/**
* Serialize metadata of one file
*
* @return string, serialized XML
*/
function serialize()
{
$res = '<?xml version="1.0" encoding="utf-8"?>';
$res .= $this->serializeEl($this->tree);
$res .= "\n";
return $res;
}
/**
* Serialize one metadata element
*
* @param el object, element object
* @param lvl int, level for indentation
* @return string, serialized XML
*/
function serializeEl($el, $lvl=0)
{
$ind = str_repeat(" ", $lvl);
$elNs = $el->ns;
$elName = $el->name;
$attrs = XML_Util::attributesToString($el->attrs);
$fullName = ($elNs=='' ? '' : "$elNs:")."$elName";
$res = "\n{$ind}<{$fullName}{$attrs}>";
$haveCh = (count($el->children)>0);
foreach ($el->children as $ch) {
$res .= $this->serializeEl($ch, $lvl+1);
}
$res .= XML_Util::replaceEntities("{$el->content}");
if ($haveCh) {
$res .= "\n{$ind}";
}
$res .= "</{$fullName}>";
return $res;
}
/* -------------------------------------------------------- debug methods */
/**
* Debug dump of tree
*
* @return hash, tree structure
*/
function dump()
{
var_dump($this->tree);
}
}
?>

View File

@ -1,328 +0,0 @@
<?php
$audioClipFormat = array(
'_root'=>'audioClip',
'audioClip'=>array(
'childs'=>array(
'required'=>array('metadata'),
),
),
'metadata'=>array(
'childs'=>array(
'required'=>array(
'dc:title', 'dcterms:extent'
),
'optional'=>array(
'dc:identifier',
'dc:creator', 'dc:source', 'ls:genre',
'ls:year', 'dc:type', 'dc:description', 'dc:format',
'ls:bpm', 'ls:rating', 'ls:encoded_by', 'ls:track_num',
'ls:disc_num', 'ls:disc_num', 'dc:publisher', 'ls:composer',
'ls:bitrate', 'ls:channels', 'ls:samplerate', 'ls:encoder',
'ls:crc', 'ls:lyrics', 'ls:orchestra', 'ls:conductor',
'ls:lyricist', 'ls:originallyricist', 'ls:radiostationname',
'ls:audiofileinfourl', 'ls:artisturl', 'ls:audiosourceurl',
'ls:radiostationurl', 'ls:buycdurl', 'ls:isrcnumber',
'ls:catalognumber', 'ls:originalartist', 'dc:rights',
'ls:license', 'dc:title', 'dcterms:temporal',
'dcterms:spatial', 'dcterms:entity', 'dc:description',
'dc:creator', 'dc:subject', 'dc:type', 'dc:format',
'dc:contributor', 'dc:language', 'dc:rights',
'dcterms:isPartOf', 'dc:date',
'dc:publisher',
// extra
'dcterms:alternative', 'ls:filename', 'ls:mtime',
// added lately by sebastian
'ls:mood',
),
),
'namespaces'=>array(
'dc'=>"http://purl.org/dc/elements/1.1/",
'dcterms'=>"http://purl.org/dc/terms/",
'xbmf'=>"http://www.streamonthefly.org/xbmf",
'xsi'=>"http://www.w3.org/2001/XMLSchema-instance",
'xml'=>"http://www.w3.org/XML/1998/namespace",
),
),
'dc:identifier'=>array(
'type'=>'Text',
'auto'=>TRUE,
),
'dc:title'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:alternative'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:extent'=>array(
'type'=>'Time',
// 'regexp'=>'^\d{2}:\d{2}:\d{2}.\d{6}$',
'regexp'=>'^((\d{1,2}:)?\d{1,2}:)?\d{1,20}(.\d{1,6})?$',
),
'dc:creator'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:source'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:genre'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:year'=>array(
'type'=>'Menu',
'area'=>'Music',
),
'dc:type'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:description'=>array(
'type'=>'Longtext',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:format'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:bpm'=>array(
'type'=>'Number',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:rating'=>array(
'type'=>'Number',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:encoded_by'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:track_num'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:disc_num'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:disc_num'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:publisher'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:composer'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:bitrate'=>array(
'type'=>'Number',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:channels'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:samplerate'=>array(
'type'=>'Menu',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:encoder'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:crc'=>array(
'type'=>'Number',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:lyrics'=>array(
'type'=>'Longtext',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:orchestra'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:conductor'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:lyricist'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:originallyricist'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:radiostationname'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:audiofileinfourl'=>array(
'type'=>'URL',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:artisturl'=>array(
'type'=>'URL',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:audiosourceurl'=>array(
'type'=>'URL',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:radiostationurl'=>array(
'type'=>'URL',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:buycdurl'=>array(
'type'=>'URL',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:isrcnumber'=>array(
'type'=>'Number',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:catalognumber'=>array(
'type'=>'Number',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:originalartist'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:rights'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:license'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:title'=>array(
'type'=>'Text',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:temporal'=>array(
'type'=>'Time/Date',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:spatial'=>array(
'type'=>'Menu',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:entity'=>array(
'type'=>'Text',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:description'=>array(
'type'=>'Longtext',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:creator'=>array(
'type'=>'Menu',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:subject'=>array(
'type'=>'Text',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:type'=>array(
'type'=>'Menu',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:format'=>array(
'type'=>'Menu',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:contributor'=>array(
'type'=>'Text',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:language'=>array(
'type'=>'Menu',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:rights'=>array(
'type'=>'Menu',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:isPartOf'=>array(
'type'=>'Text',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:date'=>array(
'type'=>'Date',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:publisher'=>array(
'type'=>'Text',
'area'=>'Talk',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:filename'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:mtime'=>array(
'type'=>'Int',
// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$',
),
);
?>

47
backend/configure vendored
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.sourcefabric.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 $*)

View File

@ -1,214 +0,0 @@
<?php
require_once (dirname(__FILE__).'/Crontab.php');
require_once (dirname(__FILE__).'/../../conf.php');
/**
* This class can call a PHP function from crontab.
* Example:
* <pre>
* $cron = new Cron();
* $access = $cron->openCrontab('write');
* if ($access != 'write') {
* do {
* $access = $cron->forceWriteable();
* } while ($access != 'write');
* }
* $cron->addCronJob('*','*','*','*','*',
* 'ClassName',
* array('first','secound','third')
* );
* $cron->closeCrontab();
* </pre>
* @package Campcaster
* @subpackage StorageServer.Cron
*/
class Cron {
/**
* @var Crontab
*/
public $ct;
/**
* @var array This array created with getCommand() function
*/
private $params;
/**
* @var string available values: read | write
*/
private $ctAccess = 'read';
private $lockfile;
private $cronfile;
private $paramdir;
private $cronUserName;
/**
* Constructor
*/
function Cron() {
global $CC_CONFIG;
$this->lockfile = $CC_CONFIG['lockfile'];
$this->cronfile = $CC_CONFIG['cronfile'];
$this->paramdir = $CC_CONFIG['paramdir'];
$this->cronUserName = $CC_CONFIG['cronUserName'];
}
/* ==================================================== Cronjob functions */
/**
* Add a cronjob to the crontab
*
* @access public
* @param string $m minute
* @param string $h hour
* @param string $dom day of month
* @param string $mo month
* @param string $dow day of week
* @param string $className name of class, which's execute() is called by croncall.php
* @param string $params the parameter(s)
* @return bool true if success else PEAR error.
*/
function addCronJob($m, $h, $dom, $mo, $dow, $className, $params)
{
if ($this->ctAccess == 'write') {
$this->ct->addCron($m, $h, $dom, $mo, $dow,
$this->getCommand($className, $params));
return true;
} else {
return PEAR::raiseError('CronJob::addCronJob : '.
'The crontab is not writable');
}
}
/**
* This function return with the active cronjobs
*
* @access public
* @return array array of cronjob struct
*/
function listCronJob()
{
return $this->ct->getByType(CRON_CMD);
}
/**
* Remove a cronjob.
*
* @access public
* @param int $index index of the cronjobs' array.
* @return bool true if success else PEAR error.
*/
function removeCronJob($index)
{
if ($this->ctAccess == 'write') {
$this->crontab->delEntry($index);
return true;
} else {
return PEAR::raiseError('CronJob::removeCronJob : '.
'The crontab is not writable');
}
}
/* ==================================================== Crontab functions */
/**
* Open the crontab
*
* @access public
* @param string $access only for listing 'read', for add and delete 'write'
* @return string sucessed access - available values read | write
*/
function openCrontab($access = 'read')
{
$access = strtolower($access);
$this->ct = new Crontab($this->cronUserName);
if ($access == 'write' &&
$this->isCrontabWritable() &&
$this->lockCrontab()) {
$this->ctAccess = $access;
} else {
$this->ctAccess = 'read';
}
return $this->ctAccess;
}
/**
* Close the crontab
*
* @access public
* @return bool true if everything is ok, false is the lock file can't delete
*/
function closeCrontab()
{
if ($this->ctAccess == 'write') {
$this->ct->writeCrontab();
}
return $this->ctAccess == 'write' ? $this->unlockCrontab() : true;
}
/**
* Check the crontab is writable
*
* @access private
* @return bool
*/
function isCrontabWritable()
{
return !is_file($this->lockfile);
}
/**
* Try to lock the crontab
*
* @access private
* @return bool true if the locking is success
*/
function lockCrontab()
{
return @touch($this->lockfile);
}
/**
* Try to unlock the crontab
*
* @access private
* @return bool true if the unlocking is success
*/
function unlockCrontab()
{
return unlink($this->lockfile);
}
/**
* If the crontab opened with read access. This function force set
* the access to write.
*
* @access public
* @return bool true if the setting is success
*/
function forceWriteable()
{
if ($this->isCrontabWritable() && $this->lockCrontab()) {
$this->ctAccess = 'write';
return true;
}
return false;
}
/* ======================================================= Misc functions */
/**
* Get the shell command for the cronjob
*
* @param string $className name of the class what is called by croncall.php
* @param mixed $params with this parameter could be called the execute() of class
* @return string shell command
*/
function getCommand($className, $params)
{
$this->params = array (
'class' => $className,
'params' => $params
);
return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"';
}
}
?>

View File

@ -1,17 +0,0 @@
<?php
/**
* Cron jobs handling abstract class
*
* @package Campcaster
* @subpackage StorageServer.Cron
*/
class CronJob
{
/**
* The croncall.php call this function after the objectcreation.
*/
function execute()
{
}
}
?>

View File

@ -1,284 +0,0 @@
<?php
define('CRON_COMMENT', 0);
define('CRON_ASSIGN', 1);
define('CRON_CMD', 2);
define('CRON_SPECIAL', 3);
define('CRON_EMPTY', 4);
/**
* A class that interfaces with the crontab. (cjpa@audiophile.com)
*
* This class lets you manipulate a user's crontab.
* It lets you add delete update entries easily.
*
* @package Campcaster
* @subpackage StorageServer.Cron
*/
class Crontab
{
// {{{ properties
/**
* Holds all the different lines.
* Lines are associative arrays with the following fields:
* "minute" : holds the minutes (0-59)
* "hour" : holds the hour (0-23)
* "dayofmonth" : holds the day of the month (1-31)
* "month" : the month (1-12 or the names)
* "dayofweek" : 0-7 (or the names)
*
* or a line can be a 2-value array that represents an assignment:
* "name" => "value"
* or a line can be a comment (string beginning with #)
* or it can be a special command (beginning with an @)
* @var array
*/
private $crontabs;
/**
* The user for whom the crontab will be manipulated
* @var string
*/
private $user;
/**
* Lists the type of line of each line in $crontabs.
* can be: any of the CRON_* constants.
* so $linetype[5] is the type of $crontabs[5].
* @var string
*/
private $linetypes;
// }}}
/**
* Constructor
*
* Initialises $this->crontabs
*
* @param string $user the user for whom the crontab will be manipulated
*/
function Crontab($user)
{
$this->user = $user;
$this->readCrontab();
}
/**
* This reads the crontab of $this->user and parses it in $this->crontabs
*
*/
function readCrontab()
{
// return code is 0 or 1 if crontab was empty, elsewhere stop here
$cmd = "crontab -u {$this->user} -l";
@exec("crontab -u {$this->user} -l", $crons, $return);
if ($return > 1) {
return PEAR::raiseError("*** Can't read crontab ***\n".
" Set crontab manually!\n");
}
foreach ($crons as $line)
{
$line = trim($line); // discarding all prepending spaces and tabs
// empty lines..
if (!$line) {
$this->crontabs[] = "empty line";
$this->linetypes[] = CRON_EMPTY;
continue;
}
// checking if this is a comment
if ($line[0] == "#") {
$this->crontabs[] = trim($line);
$this->linetypes[] = CRON_COMMENT;
continue;
}
// Checking if this is an assignment
if (ereg("(.*)=(.*)", $line, $assign)) {
$this->crontabs[] = array ("name" => $assign[1], "value" => $assign[2]);
$this->linetypes[] = CRON_ASSIGN;
continue;
}
// Checking if this is a special @-entry. check man 5 crontab for more info
if ($line[0] == '@') {
$this->crontabs[] = split("[ \t]", $line, 2);
$this->linetypes[] = CRON_SPECIAL;
continue;
}
// It's a regular crontab-entry
$ct = split("[ \t]", $line, 6);
$this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5]);
}
}
/**
* Writes the current crontab
*/
function writeCrontab()
{
global $DEBUG, $PATH;
if (empty($this->linetypes)) {
return;
}
$filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron"));
$file = fopen($filename, "w");
foreach($this->linetypes as $i => $line) {
switch ($this->linetypes[$i]) {
case CRON_COMMENT:
$line = $this->crontabs[$i];
break;
case CRON_ASSIGN:
$line = $this->crontabs[$i][name]." = ".$this->crontabs[$i][value];
break;
case CRON_CMD:
$line = implode(" ", $this->crontabs[$i]);
break;
case CRON_SPECIAL:
$line = implode(" ", $this->crontabs[$i]);
break;
case CRON_EMPTY:
$line = "\n"; // an empty line in the crontab-file
break;
default:
unset($line);
echo "Something very weird is going on. This line ($i) has an unknown type.\n";
break;
}
// echo "line $i : $line\n";
if ($line) {
$r = @fwrite($file, $line."\n");
if($r === FALSE) {
return PEAR::raiseError("*** Can't write crontab ***\n".
" Set crontab manually!\n");
}
}
}
fclose($file);
if ($DEBUG) {
echo "DEBUGMODE: not updating crontab. writing to $filename instead.\n";
} else {
exec("crontab -u {$this->user} $filename", $returnar, $return);
if ($return != 0) {
echo "Error running crontab ($return). $filename not deleted\n";
} else {
unlink($filename);
}
}
}
/**
* Add a item of type CRON_CMD to the end of $this->crontabs
*
* @param string $m
* minute
* @param string $h
* hour
* @param string $dom
* day of month
* @param string $mo
* month
* @param string $dow
* day of week
* @param string $cmd
* command
*
*/
function addCron($m, $h, $dom, $mo, $dow, $cmd)
{
$this->crontabs[] = array ("minute" => $m, "hour" => $h, "dayofmonth" => $dom, "month" => $mo, "dayofweek" => $dow, "command" => $cmd);
$this->linetypes[] = CRON_CMD;
}
/**
* Add a comment to the cron to the end of $this->crontabs
*
* @param string $comment
*/
function addComment($comment)
{
$this->crontabs[] = "# $comment\n";
$this->linetypes[] = CRON_COMMENT;
}
/**
* Add a special command (check man 5 crontab for more information)
*
* @param string $sdate special date
* string meaning
* ------ -------
* @reboot Run once, at startup.
* @yearly Run once a year, "0 0 1 1 *".
* @annually (same as @yearly)
* @monthly Run once a month, "0 0 1 * *".
* @weekly Run once a week, "0 0 * * 0".
* @daily Run once a day, "0 0 * * *".
* @midnight (same as @daily)
* @hourly Run once an hour, "0 * * * *".
* @param string $cmd command
*/
function addSpecial($sdate, $cmd)
{
$this->crontabs[] = array ("special" => $sdate, "command" => $cmd);
$this->linetypes[] = CRON_SPECIAL;
}
/**
* Add an assignment (name = value)
*
* @param string $name
* @param string $value
*/
function addAssign($name, $value)
{
$this->crontabs[] = array ("name" => $name, "value" => $value);
$this->linetypes[] = CRON_ASSIGN;
}
/**
* Delete a line from the arrays.
*
* @param int $index the index in $this->crontabs
*/
function delEntry($index)
{
unset ($this->crontabs[$index]);
unset ($this->linetypes[$index]);
}
/**
* Get all the lines of a certain type in an array
*
* @param string $type
*/
function getByType($type)
{
if ($type < CRON_COMMENT || $type > CRON_EMPTY)
{
trigger_error("Wrong type: $type", E_USER_WARNING);
return 0;
}
$returnar = array ();
for ($i = 0; $i < count($this->linetypes); $i ++)
if ($this->linetypes[$i] == $type)
$returnar[] = $this->crontabs[$i];
return $returnar;
}
}
?>

View File

@ -1,9 +0,0 @@
#!/usr/bin/php
<?php
chdir(dirname(__FILE__));
$p = unserialize($argv[1]);
require_once (dirname(__FILE__).'/'.$p['class'].'.php');
$cronjob = new $p['class']();
$ret = $cronjob->execute($p['params']);
exit(0);
?>

View File

@ -1,21 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/../../conf.php');
require_once('DB.php');
require_once(dirname(__FILE__).'/../LocStor.php');
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = new LocStor();
$tr = new Transport($gb);
$r = $tr->cronMain();
if (!$r) {
exit(1);
}
exit(0);
?>

View File

@ -1,42 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/../conf.php');
require_once('DB.php');
require_once(dirname(__FILE__).'/../LocStor.php');
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = new LocStor();
$tr = new Transport($gb);
$pid = getmypid();
list(, $trtok) = $_SERVER['argv'];
if (TR_LOG_LEVEL > 1) {
$tr->trLog("transportCronJob($pid) start ($trtok)");
}
// 4-pass on job:
$cnt = 4;
for ($i = 0; $i < $cnt; $i++, sleep(1)) {
// run the action:
$r = $tr->cronCallMethod($trtok);
if (PEAR::isError($r)) {
$tr->trLogPear("transportCronJob($pid): ($trtok): ", $r);
} else {
# $tr->trLog("X transportCronJob: ".var_export($r, TRUE));
if ($r !== TRUE) {
$tr->trLog("transportCronJob($pid): ($trtok): nonTRUE returned");
}
}
#if(!$r) exit(1);
#sleep(2);
}
if (TR_LOG_LEVEL>1) {
$tr->trLog("transportCronJob($pid) end ($trtok)");
}
exit(0);
?>

View File

@ -1,259 +0,0 @@
#-------------------------------------------------------------------------------
# StorageServer - file storage component
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
#
# 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
#
# @configure_input@
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# General command definitions
#-------------------------------------------------------------------------------
SHELL = /bin/bash
MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -rf
DOXYGEN = doxygen
CP = cp -rP
SED = sed
ECHO = echo
CAT = cat
PHP = php
#-------------------------------------------------------------------------------
# Misc
#-------------------------------------------------------------------------------
MODULE_NAME = storageServer
TAR_C = tar -cj --exclude .svn --exclude '*~' -C ${BASE_DIR} -f
DIST_EXT = .tgz
DATE = `date +%y%m%d`
#-------------------------------------------------------------------------------
# Basic directory and file definitions
#-------------------------------------------------------------------------------
#BASE_DIR = @builddir@
BASE_DIR = .
BIN_DIR = ${BASE_DIR}/bin
DOC_DIR = ${BASE_DIR}/doc
DOXYGEN_DIR = ${DOC_DIR}/doxygen
ETC_DIR = ${BASE_DIR}/etc
INCLUDE_DIR = ${BASE_DIR}/include
LIB_DIR = ${BASE_DIR}/lib
SRC_DIR = ${BASE_DIR}/src
TMP_DIR = ${BASE_DIR}/tmp
VAR_DIR = ${BASE_DIR}/var
prefix = @prefix@
USR_DIR = ${prefix}
USR_INCLUDE_DIR = ${USR_DIR}/include
USR_LIB_DIR = ${USR_DIR}/lib
USR_VAR_DIR = ${USR_DIR}/var
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
PHP_DIR = ${VAR_DIR}
INSTALL_DIR = ${PHP_DIR}/install
STOR_DIR = ${PHP_DIR}/stor
ACCESS_DIR = ${PHP_DIR}/access
TRANS_DIR = ${PHP_DIR}/trans
BUFF_DIR = ${STOR_DIR}/buffer
TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh
DEST_DIR = ${USR_VAR_DIR}/Campcaster/storageServer
DEST_VAR_DIR = ${DEST_DIR}/var
DEST_BIN_DIR = ${DEST_DIR}/bin
HOSTNAME = @HOSTNAME@
APACHE_GROUP = @APACHE_GROUP@
WWW_PORT = @WWW_PORT@
DB_SERVER = @DB_SERVER@
DATABASE = @DATABASE@
DB_USER = @DB_USER@
DB_PASSWORD = @DB_PASSWORD@
SCHEDULER_PORT = @SCHEDULER_PORT@
WWW_DOCROOT = @WWW_DOCROOT@
PHP_URL_PREFIX = @URL_PREFIX@
SCHEDULER_URL_PREFIX =
SCHEDULER_XML_RPC_PREFIX = RC2
USR_LIB_DIR_S=$(shell ${ECHO} ${USR_LIB_DIR} | ${SED} -e "s/\//\\\\\\\\\//g")
PHP_URL_PREFIX_S=$(shell ${ECHO} ${PHP_URL_PREFIX} | ${SED} -e "s/\//\\\\\\\\\//g")
REPLACE_SED_STRING="s/ls_lib_dir/${USR_LIB_DIR_S}/; \
s/ls_dbuser/${DB_USER}/; \
s/ls_dbpassword/${DB_PASSWORD}/; \
s/ls_dbserver/${DB_SERVER}/; \
s/ls_database/${DATABASE}/; \
s/ls_apache_group/${APACHE_GROUP}/; \
s/ls_storageUrlPath/\/${PHP_URL_PREFIX_S}\/storageServer\/var/; \
s/ls_php_host/${HOSTNAME}/; \
s/ls_php_port/${WWW_PORT}/; \
s/ls_archiveUrlPath/\/${PHP_URL_PREFIX_S}\/archiveServer\/var/; \
s/ls_scheduler_urlPrefix/${SCHEDULER_URL_PREFIX}/; \
s/ls_scheduler_xmlRpcPrefix/${SCHEDULER_XML_RPC_PREFIX}/; \
s/ls_scheduler_host/${HOSTNAME}/; \
s/ls_scheduler_port/${SCHEDULER_PORT}/;"
#-------------------------------------------------------------------------------
# Configuration parameters
#-------------------------------------------------------------------------------
#CPPFLAGS = @CPPFLAGS@
#CXXFLAGS = @CXXFLAGS@ @DEFS@ -I${USR_INCLUDE_DIR} -I${INCLUDE_DIR} -I${TMP_DIR}\
# -pedantic -Wall
#LDFLAGS = @LDFLAGS@ -L${USR_LIB_DIR} -L${LIB_DIR}
#-------------------------------------------------------------------------------
# Dependencies
#-------------------------------------------------------------------------------
#HELLO_LIB_OBJS = ${TMP_DIR}/Hello.o
#TEST_RUNNER_OBJS = ${TMP_DIR}/HelloTest.o ${TMP_DIR}/TestRunner.o
#-------------------------------------------------------------------------------
# Targets
#-------------------------------------------------------------------------------
.PHONY: all dir_setup doc clean docclean depclean distclean dist install
.PHONY: db_init db_clean testonly transtest storage reset
.PHONY: copy_files create_database init_database
all:
doc:
${DOXYGEN} ${DOXYGEN_CONFIG}
clean: db_clean
${RMDIR} ${STOR_DIR}
${RMDIR} ${ACCESS_DIR}
${RMDIR} ${TRANS_DIR}
docclean:
${RMDIR} ${DOXYGEN_DIR}/html
depclean: clean
dist:
${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} *
distclean: clean docclean
testonly: ${TEST_RUNNER}
${TEST_RUNNER}
check: all testonly
install: copy_files create_database init_database
copy_files:
${MKDIR} ${DEST_DIR}
${MKDIR} ${DEST_VAR_DIR}
${MKDIR} ${DEST_BIN_DIR}
${MKDIR} ${DEST_VAR_DIR}/access
${MKDIR} ${DEST_VAR_DIR}/cron
${MKDIR} ${DEST_VAR_DIR}/install
${MKDIR} ${DEST_VAR_DIR}/install/upgrade
${MKDIR} ${DEST_VAR_DIR}/stor
${MKDIR} ${DEST_VAR_DIR}/stor/buffer
${MKDIR} ${DEST_VAR_DIR}/trans
${MKDIR} ${DEST_VAR_DIR}/xmlrpc
${CP} ${VAR_DIR}/*.{php,xml} ${DEST_VAR_DIR}
${CP} ${VAR_DIR}/cron/*.php ${DEST_VAR_DIR}/cron
${CP} ${VAR_DIR}/install/*.php \
${DEST_VAR_DIR}/install
${CP} ${VAR_DIR}/install/upgrade/*.php \
${DEST_VAR_DIR}/install/upgrade
${CP} ${VAR_DIR}/xmlrpc/*.php \
${DEST_VAR_DIR}/xmlrpc
${CAT} ${VAR_DIR}/conf.php.template | ${SED} -e ${REPLACE_SED_STRING} \
> ${DEST_VAR_DIR}/conf.php
${CP} ${BIN_DIR}/backup.sh ${BIN_DIR}/restore.php \
${DEST_BIN_DIR}
chgrp ${APACHE_GROUP} ${DEST_VAR_DIR}/access
chgrp ${APACHE_GROUP} ${DEST_VAR_DIR}/stor
chgrp ${APACHE_GROUP} ${DEST_VAR_DIR}/stor/buffer
chgrp ${APACHE_GROUP} ${DEST_VAR_DIR}/trans
chmod g+sw ${DEST_VAR_DIR}/access
chmod g+sw ${DEST_VAR_DIR}/stor
chmod g+sw ${DEST_VAR_DIR}/stor/buffer
chmod g+sw ${DEST_VAR_DIR}/trans
${RM} ${WWW_DOCROOT}/${PHP_URL_PREFIX}
ln -sf ${USR_VAR_DIR}/Campcaster ${WWW_DOCROOT}/${PHP_URL_PREFIX}
create_database:
ifeq (@CREATE_LS_DATABASE@,yes)
${BIN_DIR}/createDatabase.sh --database=${DATABASE} \
--dbserver=${DB_SERVER} \
--dbuser=${DB_USER} \
--dbpassword=${DB_PASSWORD}
endif
init_database:
ifeq (@INIT_LS_DATABASE@,yes)
-cd ${DEST_VAR_DIR}/install && ${PHP} -q install.php
endif
recheck: clean check
#-------------------------------------------------------------------------------
# Specific targets
#-------------------------------------------------------------------------------
storage: db_init dir_setup
storagecheck: storage testonly
dir_setup:
bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR}
db_init:
-cd var/install && php -q install.php
chgrp ${APACHE_GROUP} ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR}
chmod g+sw ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR}
db_clean:
-cd var/install && php -q uninstall.php
reset:
./bin/resetStorage.sh
transtest:
./var/tests/transTest.sh
# cd var/tests; php -q transTest.php
${TMP_DIR}:
${MKDIR} ${TMP_DIR}
${DOXYGEN_DIR}:
${MKDIR} ${DOXYGEN_DIR}
${TEST_RUNNER}:
#-------------------------------------------------------------------------------
# Pattern rules
#-------------------------------------------------------------------------------
#${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx
# ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $<

View File

@ -1,220 +0,0 @@
dnl-----------------------------------------------------------------------------
dnl Copyright (c) 2010 Sourcefabric O.P.S.
dnl
dnl This file is part of the Campcaster project.
dnl http://campcaster.sourcefabric.org/
dnl
dnl Campcaster is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl Campcaster is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Campcaster; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl-----------------------------------------------------------------------------
dnl-----------------------------------------------------------------------------
dnl NOTE: Run all configure related scripts from the tmp directory of the
dnl project.
dnl This is due to the fact that configure spreads a lot of trash around,
dnl like atom4te cache directories, config.* files, etc. into the directory
dnl it is being run from. We clearly don't want these in our base directory.
dnl-----------------------------------------------------------------------------
AC_INIT(StorageServer, 0.0, bugs@campware.org)
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL])
AC_REVISION($Revision$)
AC_CONFIG_SRCDIR(../var/BasicStor.php)
dnl-----------------------------------------------------------------------------
dnl specify wether the Campcaster database and user should be created
dnl-----------------------------------------------------------------------------
AC_SUBST(CREATE_LS_DATABASE)
AC_ARG_WITH([create-database],
AC_HELP_STRING([--with-create-database],
[specify wether the Campcaster database and database user
should be created (no)]),
[CREATE_LS_DATABASE=${withval}],
[CREATE_LS_DATABASE=no])
AC_MSG_RESULT([creating Campcaster database: ${CREATE_LS_DATABASE}])
dnl-----------------------------------------------------------------------------
dnl specify wether the Campcaster database tables should be initialized
dnl-----------------------------------------------------------------------------
AC_SUBST(INIT_LS_DATABASE)
AC_ARG_WITH([init-database],
AC_HELP_STRING([--with-init-database],
[specify wether the Campcaster database tables should be
initialized (no)]),
[INIT_LS_DATABASE=${withval}],
[INIT_LS_DATABASE=no])
AC_MSG_RESULT([initializing Campcaster database: ${INIT_LS_DATABASE}])
dnl-----------------------------------------------------------------------------
dnl specify the FQDN
dnl-----------------------------------------------------------------------------
AC_SUBST(HOSTNAME)
AC_ARG_WITH([hostname],
AC_HELP_STRING([--with-hostname],
[use the specified hostname (guess)]),
[HOSTNAME=${withval}], [HOSTNAME=`hostname -f`])
AC_MSG_RESULT([using hostname: ${HOSTNAME}])
dnl-----------------------------------------------------------------------------
dnl specify group in which apache is running
dnl-----------------------------------------------------------------------------
AC_SUBST(APACHE_GROUP)
AC_ARG_WITH([apache-group],
AC_HELP_STRING([--with-apache-group],
[use apache running in the specified group (apache)]),
[APACHE_GROUP=${withval}], [APACHE_GROUP=apache])
AC_MSG_RESULT([using apache group: ${APACHE_GROUP}])
dnl-----------------------------------------------------------------------------
dnl specify the web server port
dnl-----------------------------------------------------------------------------
AC_SUBST(WWW_PORT)
AC_ARG_WITH([www-port],
AC_HELP_STRING([--with-www-port],
[use the specified www port (80)]),
[WWW_PORT=${withval}], [WWW_PORT=80])
AC_MSG_RESULT([using www port: ${WWW_PORT}])
dnl-----------------------------------------------------------------------------
dnl specify the scheduler server port
dnl-----------------------------------------------------------------------------
AC_SUBST(SCHEDULER_PORT)
AC_ARG_WITH([scheduler-port],
AC_HELP_STRING([--with-scheduler-port],
[use the specified scheduler port (3344)]),
[SCHEDULER_PORT=${withval}], [SCHEDULER_PORT=3344])
AC_MSG_RESULT([using scheduler port: ${SCHEDULER_PORT}])
dnl-----------------------------------------------------------------------------
dnl specify the database server name
dnl-----------------------------------------------------------------------------
AC_SUBST(DB_SERVER)
AC_ARG_WITH([database-server],
AC_HELP_STRING([--with-database-server],
[use the specified database server (localhost)]),
[DB_SERVER=${withval}], [DB_SERVER=localhost])
AC_MSG_RESULT([using database server: ${DB_SERVER}])
dnl-----------------------------------------------------------------------------
dnl get the name of the Campcaster database
dnl-----------------------------------------------------------------------------
AC_SUBST(DATABASE)
AC_ARG_WITH([database],
AC_HELP_STRING([--with-database],
[the name of the postgresql database to use (Campcaster)]),
[DATABASE=${withval}], [DATABASE=Campcaster])
AC_MSG_RESULT([using database: ${DATABASE}])
dnl-----------------------------------------------------------------------------
dnl specify the database server user
dnl-----------------------------------------------------------------------------
AC_SUBST(DB_USER)
AC_ARG_WITH([database-user],
AC_HELP_STRING([--with-database-user],
[use the specified database server user (campcaster)]),
[DB_USER=${withval}], [DB_USER=campcaster])
AC_MSG_RESULT([using database server user: ${DB_USER}])
dnl-----------------------------------------------------------------------------
dnl specify the database server user password
dnl-----------------------------------------------------------------------------
AC_SUBST(DB_PASSWORD)
AC_ARG_WITH([database-password],
AC_HELP_STRING([--with-database-password],
[use the specified database server user password (campcaster)]),
[DB_PASSWORD=${withval}], [DB_PASSWORD=campcaster])
AC_MSG_RESULT([using database server user password: ${DB_PASSWORD}])
dnl-----------------------------------------------------------------------------
dnl specify web document root
dnl-----------------------------------------------------------------------------
AC_SUBST(WWW_DOCROOT)
AC_ARG_WITH([www-docroot],
AC_HELP_STRING([--with-www-docroot],
[deploy Campcaster under the specified docroot (/var/www)]),
[WWW_DOCROOT=${withval}], [WWW_DOCROOT=/var/www])
AC_MSG_RESULT([using www document root: ${WWW_DOCROOT}])
dnl-----------------------------------------------------------------------------
dnl specify url prefix
dnl-----------------------------------------------------------------------------
AC_SUBST(URL_PREFIX)
AC_ARG_WITH([url-prefix],
AC_HELP_STRING([--with-url-prefix],
[use the specified url prefix (campcaster)]),
[URL_PREFIX=${withval}], [URL_PREFIX=campcaster])
AC_MSG_RESULT([using url prefix: ${URL_PREFIX}])
dnl display status info on what libraries will get compiled
AC_MSG_NOTICE(
[using the following configuration settings:
hostname: ${HOSTNAME}
www port: ${WWW_PORT}
scheduler port: ${SCHEDULER_PORT}
database server: ${DB_SERVER}
database name: ${DATABASE}
database user: ${DB_USER}
database user password: ${DB_PASSWORD}
creating Campcaster database: ${CREATE_LS_DATABASE}
initialize Campcaster database: ${INIT_LS_DATABASE}
www document root: ${WWW_DOCROOT}
url prefix: ${URL_PREFIX}
])
AC_CONFIG_FILES(../Makefile:../etc/Makefile.in)
AC_OUTPUT()

View File

@ -1,136 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE options [
<!ELEMENT options (option*) >
<!ELEMENT option (label+) >
<!ELEMENT label (#PCDATA) >
<!ATTLIST option id CDATA #REQUIRED >
<!ATTLIST label xml:lang CDATA #IMPLIED >
]>
<options>
<option id="Blues"><label>Blues</label></option>
<option id="Classic Rock"><label>Classic Rock</label></option>
<option id="Country"><label>Country</label></option>
<option id="Dance"><label>Dance</label></option>
<option id="Disco"><label>Disco</label></option>
<option id="Funk"><label>Funk</label></option>
<option id="Grunge"><label>Grunge</label></option>
<option id="Hip-Hop"><label>Hip-Hop</label></option>
<option id="Jazz"><label>Jazz</label></option>
<option id="Metal"><label>Metal</label></option>
<option id="New Age"><label>New Age</label></option>
<option id="Oldies"><label>Oldies</label></option>
<option id="Other"><label>Other</label></option>
<option id="Pop"><label>Pop</label></option>
<option id="R&amp;B"><label>R&amp;B</label></option>
<option id="Rap"><label>Rap</label></option>
<option id="Reggae"><label>Reggae</label></option>
<option id="Rock"><label>Rock</label></option>
<option id="Techno"><label>Techno</label></option>
<option id="Industrial"><label>Industrial</label></option>
<option id="Alternative"><label>Alternative</label></option>
<option id="Ska"><label>Ska</label></option>
<option id="Death Metal"><label>Death Metal</label></option>
<option id="Pranks"><label>Pranks</label></option>
<option id="Soundtrack"><label>Soundtrack</label></option>
<option id="Euro-Techno"><label>Euro-Techno</label></option>
<option id="Ambient"><label>Ambient</label></option>
<option id="Trip-Hop"><label>Trip-Hop</label></option>
<option id="Vocal"><label>Vocal</label></option>
<option id="Jazz+Funk"><label>Jazz+Funk</label></option>
<option id="Fusion"><label>Fusion</label></option>
<option id="Trance"><label>Trance</label></option>
<option id="Classical"><label>Classical</label></option>
<option id="Instrumental"><label>Instrumental</label></option>
<option id="Acid"><label>Acid</label></option>
<option id="House"><label>House</label></option>
<option id="Game"><label>Game</label></option>
<option id="Sound Clip"><label>Sound Clip</label></option>
<option id="Gospel"><label>Gospel</label></option>
<option id="Noise"><label>Noise</label></option>
<option id="AlternRock"><label>AlternRock</label></option>
<option id="Bass"><label>Bass</label></option>
<option id="Soul"><label>Soul</label></option>
<option id="Punk"><label>Punk</label></option>
<option id="Space"><label>Space</label></option>
<option id="Meditative"><label>Meditative</label></option>
<option id="Instrumental Pop"><label>Instrumental Pop</label></option>
<option id="Instrumental Rock"><label>Instrumental Rock</label></option>
<option id="Ethnic"><label>Ethnic</label></option>
<option id="Gothic"><label>Gothic</label></option>
<option id="Darkwave"><label>Darkwave</label></option>
<option id="Techno-Industrial"><label>Techno-Industrial</label></option>
<option id="Electronic"><label>Electronic</label></option>
<option id="Pop-Folk"><label>Pop-Folk</label></option>
<option id="Eurodance"><label>Eurodance</label></option>
<option id="Dream"><label>Dream</label></option>
<option id="Southern Rock"><label>Southern Rock</label></option>
<option id="Comedy"><label>Comedy</label></option>
<option id="Cult"><label>Cult</label></option>
<option id="Gangsta"><label>Gangsta</label></option>
<option id="Top 40"><label>Top 40</label></option>
<option id="Christian Rap"><label>Christian Rap</label></option>
<option id="Pop/Funk"><label>Pop/Funk</label></option>
<option id="Jungle"><label>Jungle</label></option>
<option id="Native American"><label>Native American</label></option>
<option id="Cabaret"><label>Cabaret</label></option>
<option id="New Wave"><label>New Wave</label></option>
<option id="Psychadelic"><label>Psychadelic</label></option>
<option id="Rave"><label>Rave</label></option>
<option id="Showtunes"><label>Showtunes</label></option>
<option id="Trailer"><label>Trailer</label></option>
<option id="Lo-Fi"><label>Lo-Fi</label></option>
<option id="Tribal"><label>Tribal</label></option>
<option id="Acid Punk"><label>Acid Punk</label></option>
<option id="Acid Jazz"><label>Acid Jazz</label></option>
<option id="Polka"><label>Polka</label></option>
<option id="Retro"><label>Retro</label></option>
<option id="Musical"><label>Musical</label></option>
<option id="Rock &amp; Roll"><label>Rock &amp; Roll</label></option>
<option id="Hard Rock"><label>Hard Rock</label></option>
<option id="Folk"><label>Folk</label></option>
<option id="Folk-Rock"><label>Folk-Rock</label></option>
<option id="National Folk"><label>National Folk</label></option>
<option id="Swing"><label>Swing</label></option>
<option id="Fast Fusion"><label>Fast Fusion</label></option>
<option id="Bebob"><label>Bebob</label></option>
<option id="Latin"><label>Latin</label></option>
<option id="Revival"><label>Revival</label></option>
<option id="Celtic"><label>Celtic</label></option>
<option id="Bluegrass"><label>Bluegrass</label></option>
<option id="Avantgarde"><label>Avantgarde</label></option>
<option id="Gothic Rock"><label>Gothic Rock</label></option>
<option id="Progressive Rock"><label>Progressive Rock</label></option>
<option id="Psychedelic Rock"><label>Psychedelic Rock</label></option>
<option id="Symphonic Rock"><label>Symphonic Rock</label></option>
<option id="Slow Rock"><label>Slow Rock</label></option>
<option id="Big Band"><label>Big Band</label></option>
<option id="Chorus"><label>Chorus</label></option>
<option id="Easy Listening"><label>Easy Listening</label></option>
<option id="Acoustic"><label>Acoustic</label></option>
<option id="Humour"><label>Humour</label></option>
<option id="Speech"><label>Speech</label></option>
<option id="Chanson"><label>Chanson</label></option>
<option id="Opera"><label>Opera</label></option>
<option id="Chamber Music"><label>Chamber Music</label></option>
<option id="Sonata"><label>Sonata</label></option>
<option id="Symphony"><label>Symphony</label></option>
<option id="Booty Bass"><label>Booty Bass</label></option>
<option id="Primus"><label>Primus</label></option>
<option id="Porn Groove"><label>Porn Groove</label></option>
<option id="Satire"><label>Satire</label></option>
<option id="Slow Jam"><label>Slow Jam</label></option>
<option id="Club"><label>Club</label></option>
<option id="Tango"><label>Tango</label></option>
<option id="Samba"><label>Samba</label></option>
<option id="Folklore"><label>Folklore</label></option>
<option id="Ballad"><label>Ballad</label></option>
<option id="Power Ballad"><label>Power Ballad</label></option>
<option id="Rhythmic Soul"><label>Rhythmic Soul</label></option>
<option id="Freestyle"><label>Freestyle</label></option>
<option id="Duet"><label>Duet</label></option>
<option id="Punk Rock"><label>Punk Rock</label></option>
<option id="Drum Solo"><label>Drum Solo</label></option>
<option id="A capella"><label>A capella</label></option>
<option id="Euro-House"><label>Euro-House</label></option>
<option id="Dance Hall"><label>Dance Hall</label></option>
</options>

View File

@ -1,17 +0,0 @@
<?php
header ("location: html/");
exit;
/*
?>
<html><head>
<title>StorageServer module</title>
</head><body>
<h3>StorageServer module</h3>
<br>
<a href="../html/" accesskey="H"><b>H</b>TML client</a><br>
<a href="../xmlrpc/" accesskey="X"><b>X</b>mlRpc test</a><br>
<a href="../tests/" accesskey="T"><b>T</b>est</a><br>
</body></html>
<?
*/
?>

View File

@ -1,117 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
$playlistFormat = array(
'_root'=>'playlist',
'playlist'=>array(
'childs'=>array(
// 'repeatable'=>array('playlistElement'),
'optional'=>array('metadata', 'playlistElement'),
),
'attrs'=>array(
'required'=>array('id'),
'implied'=>array('title', 'playlength'),
),
),
'playlistElement'=>array(
'childs'=>array(
'oneof'=>array('audioClip', 'playlist'),
'optional'=>array('fadeInfo'),
),
'attrs'=>array(
'required'=>array('id', 'relativeOffset', 'clipStart', 'clipEnd', 'clipLength'),
),
),
'audioClip'=>array(
'childs'=>array(
'optional'=>array('metadata'),
),
'attrs'=>array(
'implied'=>array('id', 'title', 'playlength', 'uri'),
),
),
'fadeInfo'=>array(
'attrs'=>array(
'required'=>array('id', 'fadeIn', 'fadeOut'),
),
),
'metadata'=>array(
'childs'=>array(
'optional'=>array(
'dc:title', 'dcterms:extent', 'dc:creator', 'dc:description',
'dcterms:alternative', 'ls:filename', 'ls:mtime',
),
),
'namespaces'=>array(
'dc'=>"http://purl.org/dc/elements/1.1/",
'dcterms'=>"http://purl.org/dc/terms/",
'xbmf'=>"http://www.streamonthefly.org/xbmf",
'xsi'=>"http://www.w3.org/2001/XMLSchema-instance",
'xml'=>"http://www.w3.org/XML/1998/namespace",
),
),
'dc:title'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:alternative'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dcterms:extent'=>array(
'type'=>'Time',
'regexp'=>'^\d{2}:\d{2}:\d{2}.\d{6}$',
),
'dc:creator'=>array(
'type'=>'Text',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'dc:description'=>array(
'type'=>'Longtext',
'area'=>'Music',
'attrs'=>array('implied'=>array('xml:lang')),
),
'playlength'=>array(
'type'=>'Time',
'regexp'=>'^((\d{2}:)?\d{2}:)?\d{1,2}(.\d{6})?$',
),
'id'=>array(
'type'=>'Attribute',
'regexp'=>'^[0-9a-f]{16}$',
),
'fadeIn'=>array(
'type'=>'Attribute',
'regexp'=>'^((\d{2}:)?\d{2}:)?\d{1,2}(.\d{6})?$',
),
'fadeOut'=>array(
'type'=>'Attribute',
'regexp'=>'^((\d{2}:)?\d{2}:)?\d{1,2}(.\d{6})?$',
),
'ls:filename'=>array(
'type'=>'Text',
'attrs'=>array('implied'=>array('xml:lang')),
),
'ls:mtime'=>array(
'type'=>'Int',
// 'regexp'=>'^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}\.\d+)?(Z)|([\+\-]?\d{2}:\d{2}))?)?)?$',
),
/*
''=>array(
'childs'=>array(''),
'attrs'=>array('implied'=>array()),
),
*/
);
/*
?
ls:filename Text auto
*/
?>

View File

@ -1,7 +0,0 @@
#Database driver
propel.database = pgsql
propel.database.url = pgsql:host=localhost dbname=campcaster user=campcaster password=campcaster
#Project name
propel.project = campcaster

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_access' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcAccess extends BaseCcAccess {
} // CcAccess

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_access' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcAccessPeer extends BaseCcAccessPeer {
} // CcAccessPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_access' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcAccessQuery extends BaseCcAccessQuery {
} // CcAccessQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_backup' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcBackup extends BaseCcBackup {
} // CcBackup

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_backup' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcBackupPeer extends BaseCcBackupPeer {
} // CcBackupPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_backup' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcBackupQuery extends BaseCcBackupQuery {
} // CcBackupQuery

View File

@ -1,31 +0,0 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcFiles extends BaseCcFiles {
public function getDbLength()
{
return $this->length;
}
public function setDbLength($time)
{
$this->length = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH;
return Common::setTimeInSub($this, 'LENGTH', $time);
}
} // CcFiles

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcFilesPeer extends BaseCcFilesPeer {
} // CcFilesPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcFilesQuery extends BaseCcFilesQuery {
} // CcFilesQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_perms' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPerms extends BaseCcPerms {
} // CcPerms

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_perms' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPermsPeer extends BaseCcPermsPeer {
} // CcPermsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_perms' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPermsQuery extends BaseCcPermsQuery {
} // CcPermsQuery

View File

@ -1,48 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylist extends BaseCcPlaylist {
public function computeLastPosition()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT MAX('.CcPlaylistcontentsPeer::POSITION.') AS pos'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
public function computeLength()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT SUM('.CcPlaylistcontentsPeer::CLIPLENGTH.') AS length'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
} // CcPlaylist

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistPeer extends BaseCcPlaylistPeer {
} // CcPlaylistPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistQuery extends BaseCcPlaylistQuery {
} // CcPlaylistQuery

View File

@ -1,78 +0,0 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistcontents extends BaseCcPlaylistcontents {
public function getDbFadein()
{
return $this->fadein;
}
public function setDbFadein($time)
{
$this->fadein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
return Common::setTimeInSub($this, 'FADEIN', $time);
}
public function getDbFadeout()
{
return $this->fadeout;
}
public function setDbFadeout($time)
{
$this->fadeout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
return Common::setTimeInSub($this, 'FADEOUT', $time);
}
public function getDbCuein()
{
return $this->cuein;
}
public function setDbCuein($time)
{
$this->cuein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
return Common::setTimeInSub($this, 'CUEIN', $time);
}
public function getDbCueout()
{
return $this->cueout;
}
public function setDbCueout($time)
{
$this->cueout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
return Common::setTimeInSub($this, 'CUEOUT', $time);
}
public function getDbCliplength()
{
return $this->cliplength;
}
public function setDbCliplength($time)
{
$this->cliplength = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
return Common::setTimeInSub($this, 'CLIPLENGTH', $time);
}
} // CcPlaylistcontents

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistcontentsPeer extends BaseCcPlaylistcontentsPeer {
} // CcPlaylistcontentsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistcontentsQuery extends BaseCcPlaylistcontentsQuery {
} // CcPlaylistcontentsQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_pref' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPref extends BaseCcPref {
} // CcPref

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_pref' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPrefPeer extends BaseCcPrefPeer {
} // CcPrefPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_pref' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPrefQuery extends BaseCcPrefQuery {
} // CcPrefQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSchedule extends BaseCcSchedule {
} // CcSchedule

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSchedulePeer extends BaseCcSchedulePeer {
} // CcSchedulePeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_schedule' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcScheduleQuery extends BaseCcScheduleQuery {
} // CcScheduleQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_sess' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSess extends BaseCcSess {
} // CcSess

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_sess' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSessPeer extends BaseCcSessPeer {
} // CcSessPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_sess' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSessQuery extends BaseCcSessQuery {
} // CcSessQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_smemb' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSmemb extends BaseCcSmemb {
} // CcSmemb

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_smemb' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSmembPeer extends BaseCcSmembPeer {
} // CcSmembPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_smemb' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSmembQuery extends BaseCcSmembQuery {
} // CcSmembQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_subjs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSubjs extends BaseCcSubjs {
} // CcSubjs

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_subjs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSubjsPeer extends BaseCcSubjsPeer {
} // CcSubjsPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_subjs' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcSubjsQuery extends BaseCcSubjsQuery {
} // CcSubjsQuery

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_trans' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcTrans extends BaseCcTrans {
} // CcTrans

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_trans' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcTransPeer extends BaseCcTransPeer {
} // CcTransPeer

View File

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_trans' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcTransQuery extends BaseCcTransQuery {
} // CcTransQuery

View File

@ -1,19 +0,0 @@
<?php
class Common {
public static function setTimeInSub($row, $col, $time)
{
$class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME);
$sql = 'UPDATE '.$class::TABLE_NAME
. ' SET '.$col.' = :f1'
. ' WHERE ' .$class::ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':f1', $time);
$stmt->bindValue(':p1', $row->getDbId());
$stmt->execute();
}
}

View File

@ -1,61 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_access' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcAccessTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcAccessTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_access');
$this->setPhpName('CcAccess');
$this->setClassname('CcAccess');
$this->setPackage('campcaster');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_access_id_seq');
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('GUNID', 'Gunid', 'CHAR', false, 32, null);
$this->addColumn('TOKEN', 'Token', 'BIGINT', false, null, null);
$this->addColumn('CHSUM', 'Chsum', 'CHAR', true, 32, '');
$this->addColumn('EXT', 'Ext', 'VARCHAR', true, 128, '');
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 20, '');
$this->addColumn('PARENT', 'Parent', 'BIGINT', false, null, null);
$this->addForeignKey('OWNER', 'Owner', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('TS', 'Ts', 'TIMESTAMP', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('owner' => 'id', ), null, null);
} // buildRelations()
} // CcAccessTableMap

View File

@ -1,55 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_backup' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcBackupTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcBackupTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_backup');
$this->setPhpName('CcBackup');
$this->setClassname('CcBackup');
$this->setPackage('campcaster');
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('TOKEN', 'Token', 'VARCHAR', true, 64, null);
$this->addColumn('SESSIONID', 'Sessionid', 'VARCHAR', true, 64, null);
$this->addColumn('STATUS', 'Status', 'VARCHAR', true, 32, null);
$this->addColumn('FROMTIME', 'Fromtime', 'TIMESTAMP', true, null, null);
$this->addColumn('TOTIME', 'Totime', 'TIMESTAMP', true, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
} // buildRelations()
} // CcBackupTableMap

View File

@ -1,107 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_files' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcFilesTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcFilesTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_files');
$this->setPhpName('CcFiles');
$this->setClassname('CcFiles');
$this->setPackage('campcaster');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_files_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('GUNID', 'Gunid', 'CHAR', true, 32, null);
$this->addColumn('NAME', 'Name', 'VARCHAR', true, 255, '');
$this->addColumn('MIME', 'Mime', 'VARCHAR', true, 255, '');
$this->addColumn('FTYPE', 'Ftype', 'VARCHAR', true, 128, '');
$this->addColumn('FILEPATH', 'filepath', 'LONGVARCHAR', false, null, '');
$this->addColumn('STATE', 'State', 'VARCHAR', true, 128, 'empty');
$this->addColumn('CURRENTLYACCESSING', 'Currentlyaccessing', 'INTEGER', true, null, 0);
$this->addForeignKey('EDITEDBY', 'Editedby', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('MTIME', 'Mtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('MD5', 'Md5', 'CHAR', false, 32, null);
$this->addColumn('TRACK_TITLE', 'TrackTitle', 'VARCHAR', false, 512, null);
$this->addColumn('ARTIST_NAME', 'ArtistName', 'VARCHAR', false, 512, null);
$this->addColumn('BIT_RATE', 'BitRate', 'VARCHAR', false, 32, null);
$this->addColumn('SAMPLE_RATE', 'SampleRate', 'VARCHAR', false, 32, null);
$this->addColumn('FORMAT', 'Format', 'VARCHAR', false, 128, null);
$this->addColumn('LENGTH', 'DbLength', 'TIME', false, null, null);
$this->addColumn('ALBUM_TITLE', 'AlbumTitle', 'VARCHAR', false, 512, null);
$this->addColumn('GENRE', 'Genre', 'VARCHAR', false, 64, null);
$this->addColumn('COMMENTS', 'Comments', 'LONGVARCHAR', false, null, null);
$this->addColumn('YEAR', 'Year', 'VARCHAR', false, 16, null);
$this->addColumn('TRACK_NUMBER', 'TrackNumber', 'INTEGER', false, null, null);
$this->addColumn('CHANNELS', 'Channels', 'INTEGER', false, null, null);
$this->addColumn('URL', 'Url', 'VARCHAR', false, 1024, null);
$this->addColumn('BPM', 'Bpm', 'VARCHAR', false, 8, null);
$this->addColumn('RATING', 'Rating', 'VARCHAR', false, 8, null);
$this->addColumn('ENCODED_BY', 'EncodedBy', 'VARCHAR', false, 255, null);
$this->addColumn('DISC_NUMBER', 'DiscNumber', 'VARCHAR', false, 8, null);
$this->addColumn('MOOD', 'Mood', 'VARCHAR', false, 64, null);
$this->addColumn('LABEL', 'Label', 'VARCHAR', false, 512, null);
$this->addColumn('COMPOSER', 'Composer', 'VARCHAR', false, 512, null);
$this->addColumn('ENCODER', 'Encoder', 'VARCHAR', false, 64, null);
$this->addColumn('CHECKSUM', 'Checksum', 'VARCHAR', false, 256, null);
$this->addColumn('LYRICS', 'Lyrics', 'LONGVARCHAR', false, null, null);
$this->addColumn('ORCHESTRA', 'Orchestra', 'VARCHAR', false, 512, null);
$this->addColumn('CONDUCTOR', 'Conductor', 'VARCHAR', false, 512, null);
$this->addColumn('LYRICIST', 'Lyricist', 'VARCHAR', false, 512, null);
$this->addColumn('ORIGINAL_LYRICIST', 'OriginalLyricist', 'VARCHAR', false, 512, null);
$this->addColumn('RADIO_STATION_NAME', 'RadioStationName', 'VARCHAR', false, 512, null);
$this->addColumn('INFO_URL', 'InfoUrl', 'VARCHAR', false, 512, null);
$this->addColumn('ARTIST_URL', 'ArtistUrl', 'VARCHAR', false, 512, null);
$this->addColumn('AUDIO_SOURCE_URL', 'AudioSourceUrl', 'VARCHAR', false, 512, null);
$this->addColumn('RADIO_STATION_URL', 'RadioStationUrl', 'VARCHAR', false, 512, null);
$this->addColumn('BUY_THIS_URL', 'BuyThisUrl', 'VARCHAR', false, 512, null);
$this->addColumn('ISRC_NUMBER', 'IsrcNumber', 'VARCHAR', false, 512, null);
$this->addColumn('CATALOG_NUMBER', 'CatalogNumber', 'VARCHAR', false, 512, null);
$this->addColumn('ORIGINAL_ARTIST', 'OriginalArtist', 'VARCHAR', false, 512, null);
$this->addColumn('COPYRIGHT', 'Copyright', 'VARCHAR', false, 512, null);
$this->addColumn('REPORT_DATETIME', 'ReportDatetime', 'VARCHAR', false, 32, null);
$this->addColumn('REPORT_LOCATION', 'ReportLocation', 'VARCHAR', false, 512, null);
$this->addColumn('REPORT_ORGANIZATION', 'ReportOrganization', 'VARCHAR', false, 512, null);
$this->addColumn('SUBJECT', 'Subject', 'VARCHAR', false, 512, null);
$this->addColumn('CONTRIBUTOR', 'Contributor', 'VARCHAR', false, 512, null);
$this->addColumn('LANGUAGE', 'Language', 'VARCHAR', false, 512, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null);
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null);
} // buildRelations()
} // CcFilesTableMap

View File

@ -1,56 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_perms' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcPermsTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcPermsTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_perms');
$this->setPhpName('CcPerms');
$this->setClassname('CcPerms');
$this->setPackage('campcaster');
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('PERMID', 'Permid', 'INTEGER', true, null, null);
$this->addForeignKey('SUBJ', 'Subj', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('ACTION', 'Action', 'VARCHAR', false, 20, null);
$this->addColumn('OBJ', 'Obj', 'INTEGER', false, null, null);
$this->addColumn('TYPE', 'Type', 'CHAR', false, 1, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('subj' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CcPermsTableMap

View File

@ -1,61 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_playlist' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcPlaylistTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcPlaylistTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_playlist');
$this->setPhpName('CcPlaylist');
$this->setClassname('CcPlaylist');
$this->setPackage('campcaster');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_playlist_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, '');
$this->addColumn('STATE', 'DbState', 'VARCHAR', true, 128, 'empty');
$this->addColumn('CURRENTLYACCESSING', 'DbCurrentlyaccessing', 'INTEGER', true, null, 0);
$this->addForeignKey('EDITEDBY', 'DbEditedby', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('CREATOR', 'DbCreator', 'VARCHAR', false, 32, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null);
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
} // buildRelations()
} // CcPlaylistTableMap

View File

@ -1,62 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_playlistcontents' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcPlaylistcontentsTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcPlaylistcontentsTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_playlistcontents');
$this->setPhpName('CcPlaylistcontents');
$this->setClassname('CcPlaylistcontents');
$this->setPackage('campcaster');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_playlistcontents_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', false, null, null);
$this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null);
$this->addColumn('POSITION', 'DbPosition', 'INTEGER', false, null, null);
$this->addColumn('CLIPLENGTH', 'DbCliplength', 'TIME', false, null, '00:00:00');
$this->addColumn('CUEIN', 'DbCuein', 'TIME', false, null, '00:00:00');
$this->addColumn('CUEOUT', 'DbCueout', 'TIME', false, null, '00:00:00');
$this->addColumn('FADEIN', 'DbFadein', 'TIME', false, null, '00:00:00');
$this->addColumn('FADEOUT', 'DbFadeout', 'TIME', false, null, '00:00:00');
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null);
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CcPlaylistcontentsTableMap

View File

@ -1,56 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_pref' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcPrefTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcPrefTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_pref');
$this->setPhpName('CcPref');
$this->setClassname('CcPref');
$this->setPackage('campcaster');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_pref_id_seq');
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('SUBJID', 'Subjid', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('KEYSTR', 'Keystr', 'VARCHAR', false, 255, null);
$this->addColumn('VALSTR', 'Valstr', 'LONGVARCHAR', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('subjid' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CcPrefTableMap

View File

@ -1,61 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_schedule' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcScheduleTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcScheduleTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_schedule');
$this->setPhpName('CcSchedule');
$this->setClassname('CcSchedule');
$this->setPackage('campcaster');
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('ID', 'Id', 'BIGINT', true, null, null);
$this->addColumn('PLAYLIST_ID', 'PlaylistId', 'INTEGER', true, null, null);
$this->addColumn('STARTS', 'Starts', 'TIMESTAMP', true, null, null);
$this->addColumn('ENDS', 'Ends', 'TIMESTAMP', true, null, null);
$this->addColumn('GROUP_ID', 'GroupId', 'INTEGER', false, null, null);
$this->addColumn('FILE_ID', 'FileId', 'INTEGER', false, null, null);
$this->addColumn('CLIP_LENGTH', 'ClipLength', 'TIME', false, null, '00:00:00');
$this->addColumn('FADE_IN', 'FadeIn', 'TIME', false, null, '00:00:00');
$this->addColumn('FADE_OUT', 'FadeOut', 'TIME', false, null, '00:00:00');
$this->addColumn('CUE_IN', 'CueIn', 'TIME', false, null, '00:00:00');
$this->addColumn('CUE_OUT', 'CueOut', 'TIME', false, null, '00:00:00');
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
} // buildRelations()
} // CcScheduleTableMap

View File

@ -1,55 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_sess' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcSessTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcSessTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_sess');
$this->setPhpName('CcSess');
$this->setClassname('CcSess');
$this->setPackage('campcaster');
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('SESSID', 'Sessid', 'CHAR', true, 32, null);
$this->addForeignKey('USERID', 'Userid', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', false, 255, null);
$this->addColumn('TS', 'Ts', 'TIMESTAMP', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('userid' => 'id', ), 'CASCADE', null);
} // buildRelations()
} // CcSessTableMap

View File

@ -1,55 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_smemb' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcSmembTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcSmembTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_smemb');
$this->setPhpName('CcSmemb');
$this->setClassname('CcSmemb');
$this->setPackage('campcaster');
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('UID', 'Uid', 'INTEGER', true, null, 0);
$this->addColumn('GID', 'Gid', 'INTEGER', true, null, 0);
$this->addColumn('LEVEL', 'Level', 'INTEGER', true, null, 0);
$this->addColumn('MID', 'Mid', 'INTEGER', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
} // buildRelations()
} // CcSmembTableMap

View File

@ -1,63 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_subjs' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcSubjsTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcSubjsTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_subjs');
$this->setPhpName('CcSubjs');
$this->setClassname('CcSubjs');
$this->setPackage('campcaster');
$this->setUseIdGenerator(false);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, '');
$this->addColumn('PASS', 'Pass', 'VARCHAR', true, 255, '');
$this->addColumn('TYPE', 'Type', 'CHAR', true, 1, 'U');
$this->addColumn('REALNAME', 'Realname', 'VARCHAR', true, 255, '');
$this->addColumn('LASTLOGIN', 'Lastlogin', 'TIMESTAMP', false, null, null);
$this->addColumn('LASTFAIL', 'Lastfail', 'TIMESTAMP', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CcAccess', 'CcAccess', RelationMap::ONE_TO_MANY, array('id' => 'owner', ), null, null);
$this->addRelation('CcFiles', 'CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null);
$this->addRelation('CcPerms', 'CcPerms', RelationMap::ONE_TO_MANY, array('id' => 'subj', ), 'CASCADE', null);
$this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null);
$this->addRelation('CcPref', 'CcPref', RelationMap::ONE_TO_MANY, array('id' => 'subjid', ), 'CASCADE', null);
$this->addRelation('CcSess', 'CcSess', RelationMap::ONE_TO_MANY, array('id' => 'userid', ), 'CASCADE', null);
} // buildRelations()
} // CcSubjsTableMap

View File

@ -1,75 +0,0 @@
<?php
/**
* This class defines the structure of the 'cc_trans' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.campcaster.map
*/
class CcTransTableMap extends TableMap {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'campcaster.map.CcTransTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cc_trans');
$this->setPhpName('CcTrans');
$this->setClassname('CcTrans');
$this->setPackage('campcaster');
$this->setUseIdGenerator(true);
$this->setPrimaryKeyMethodInfo('cc_trans_id_seq');
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('TRTOK', 'Trtok', 'CHAR', true, 16, null);
$this->addColumn('DIRECTION', 'Direction', 'VARCHAR', true, 128, null);
$this->addColumn('STATE', 'State', 'VARCHAR', true, 128, null);
$this->addColumn('TRTYPE', 'Trtype', 'VARCHAR', true, 128, null);
$this->addColumn('LOCK', 'Lock', 'CHAR', true, 1, 'N');
$this->addColumn('TARGET', 'Target', 'VARCHAR', false, 255, null);
$this->addColumn('RTRTOK', 'Rtrtok', 'CHAR', false, 16, null);
$this->addColumn('MDTRTOK', 'Mdtrtok', 'CHAR', false, 16, null);
$this->addColumn('GUNID', 'Gunid', 'CHAR', false, 32, null);
$this->addColumn('PDTOKEN', 'Pdtoken', 'BIGINT', false, null, null);
$this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null);
$this->addColumn('LOCALFILE', 'Localfile', 'VARCHAR', false, 255, null);
$this->addColumn('FNAME', 'Fname', 'VARCHAR', false, 255, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('EXPECTEDSUM', 'Expectedsum', 'CHAR', false, 32, null);
$this->addColumn('REALSUM', 'Realsum', 'CHAR', false, 32, null);
$this->addColumn('EXPECTEDSIZE', 'Expectedsize', 'INTEGER', false, null, null);
$this->addColumn('REALSIZE', 'Realsize', 'INTEGER', false, null, null);
$this->addColumn('UID', 'Uid', 'INTEGER', false, null, null);
$this->addColumn('ERRMSG', 'Errmsg', 'VARCHAR', false, 255, null);
$this->addColumn('JOBPID', 'Jobpid', 'INTEGER', false, null, null);
$this->addColumn('START', 'Start', 'TIMESTAMP', false, null, null);
$this->addColumn('TS', 'Ts', 'TIMESTAMP', false, null, null);
// validators
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
} // buildRelations()
} // CcTransTableMap

File diff suppressed because it is too large Load Diff

View File

@ -1,477 +0,0 @@
<?php
/**
* Base class that represents a query for the 'cc_access' table.
*
*
*
* @method CcAccessQuery orderById($order = Criteria::ASC) Order by the id column
* @method CcAccessQuery orderByGunid($order = Criteria::ASC) Order by the gunid column
* @method CcAccessQuery orderByToken($order = Criteria::ASC) Order by the token column
* @method CcAccessQuery orderByChsum($order = Criteria::ASC) Order by the chsum column
* @method CcAccessQuery orderByExt($order = Criteria::ASC) Order by the ext column
* @method CcAccessQuery orderByType($order = Criteria::ASC) Order by the type column
* @method CcAccessQuery orderByParent($order = Criteria::ASC) Order by the parent column
* @method CcAccessQuery orderByOwner($order = Criteria::ASC) Order by the owner column
* @method CcAccessQuery orderByTs($order = Criteria::ASC) Order by the ts column
*
* @method CcAccessQuery groupById() Group by the id column
* @method CcAccessQuery groupByGunid() Group by the gunid column
* @method CcAccessQuery groupByToken() Group by the token column
* @method CcAccessQuery groupByChsum() Group by the chsum column
* @method CcAccessQuery groupByExt() Group by the ext column
* @method CcAccessQuery groupByType() Group by the type column
* @method CcAccessQuery groupByParent() Group by the parent column
* @method CcAccessQuery groupByOwner() Group by the owner column
* @method CcAccessQuery groupByTs() Group by the ts column
*
* @method CcAccessQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcAccessQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CcAccessQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method CcAccessQuery leftJoinCcSubjs($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcSubjs relation
* @method CcAccessQuery rightJoinCcSubjs($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcSubjs relation
* @method CcAccessQuery innerJoinCcSubjs($relationAlias = '') Adds a INNER JOIN clause to the query using the CcSubjs relation
*
* @method CcAccess findOne(PropelPDO $con = null) Return the first CcAccess matching the query
* @method CcAccess findOneOrCreate(PropelPDO $con = null) Return the first CcAccess matching the query, or a new CcAccess object populated from the query conditions when no match is found
*
* @method CcAccess findOneById(int $id) Return the first CcAccess filtered by the id column
* @method CcAccess findOneByGunid(string $gunid) Return the first CcAccess filtered by the gunid column
* @method CcAccess findOneByToken(string $token) Return the first CcAccess filtered by the token column
* @method CcAccess findOneByChsum(string $chsum) Return the first CcAccess filtered by the chsum column
* @method CcAccess findOneByExt(string $ext) Return the first CcAccess filtered by the ext column
* @method CcAccess findOneByType(string $type) Return the first CcAccess filtered by the type column
* @method CcAccess findOneByParent(string $parent) Return the first CcAccess filtered by the parent column
* @method CcAccess findOneByOwner(int $owner) Return the first CcAccess filtered by the owner column
* @method CcAccess findOneByTs(string $ts) Return the first CcAccess filtered by the ts column
*
* @method array findById(int $id) Return CcAccess objects filtered by the id column
* @method array findByGunid(string $gunid) Return CcAccess objects filtered by the gunid column
* @method array findByToken(string $token) Return CcAccess objects filtered by the token column
* @method array findByChsum(string $chsum) Return CcAccess objects filtered by the chsum column
* @method array findByExt(string $ext) Return CcAccess objects filtered by the ext column
* @method array findByType(string $type) Return CcAccess objects filtered by the type column
* @method array findByParent(string $parent) Return CcAccess objects filtered by the parent column
* @method array findByOwner(int $owner) Return CcAccess objects filtered by the owner column
* @method array findByTs(string $ts) Return CcAccess objects filtered by the ts column
*
* @package propel.generator.campcaster.om
*/
abstract class BaseCcAccessQuery extends ModelCriteria
{
/**
* Initializes internal state of BaseCcAccessQuery object.
*
* @param string $dbName The dabase name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'campcaster', $modelName = 'CcAccess', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new CcAccessQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return CcAccessQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CcAccessQuery) {
return $criteria;
}
$query = new CcAccessQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key
* Use instance pooling to avoid a database query if the object exists
* <code>
* $obj = $c->findPk(12, $con);
* </code>
* @param mixed $key Primary key to use for the query
* @param PropelPDO $con an optional connection object
*
* @return CcAccess|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ((null !== ($obj = CcAccessPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
// the object is alredy in the instance pool
return $obj;
} else {
// the object has not been requested yet, or the formatter is not an object formatter
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->getSelectStatement($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
}
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param PropelPDO $con an optional connection object
*
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
$criteria = $this->isKeepQuery() ? clone $this : $this;
return $this
->filterByPrimaryKeys($keys)
->find($con);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CcAccessPeer::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CcAccessPeer::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* @param int|array $id 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 CcAccessQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id) && null === $comparison) {
$comparison = Criteria::IN;
}
return $this->addUsingAlias(CcAccessPeer::ID, $id, $comparison);
}
/**
* Filter the query on the gunid column
*
* @param string $gunid The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByGunid($gunid = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($gunid)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $gunid)) {
$gunid = str_replace('*', '%', $gunid);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcAccessPeer::GUNID, $gunid, $comparison);
}
/**
* Filter the query on the token column
*
* @param string|array $token 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 CcAccessQuery The current query, for fluid interface
*/
public function filterByToken($token = null, $comparison = null)
{
if (is_array($token)) {
$useMinMax = false;
if (isset($token['min'])) {
$this->addUsingAlias(CcAccessPeer::TOKEN, $token['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($token['max'])) {
$this->addUsingAlias(CcAccessPeer::TOKEN, $token['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcAccessPeer::TOKEN, $token, $comparison);
}
/**
* Filter the query on the chsum column
*
* @param string $chsum The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByChsum($chsum = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($chsum)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $chsum)) {
$chsum = str_replace('*', '%', $chsum);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcAccessPeer::CHSUM, $chsum, $comparison);
}
/**
* Filter the query on the ext column
*
* @param string $ext The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByExt($ext = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($ext)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $ext)) {
$ext = str_replace('*', '%', $ext);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcAccessPeer::EXT, $ext, $comparison);
}
/**
* Filter the query on the type column
*
* @param string $type The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByType($type = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($type)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $type)) {
$type = str_replace('*', '%', $type);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcAccessPeer::TYPE, $type, $comparison);
}
/**
* Filter the query on the parent column
*
* @param string|array $parent 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 CcAccessQuery The current query, for fluid interface
*/
public function filterByParent($parent = null, $comparison = null)
{
if (is_array($parent)) {
$useMinMax = false;
if (isset($parent['min'])) {
$this->addUsingAlias(CcAccessPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($parent['max'])) {
$this->addUsingAlias(CcAccessPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcAccessPeer::PARENT, $parent, $comparison);
}
/**
* Filter the query on the owner column
*
* @param int|array $owner 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 CcAccessQuery The current query, for fluid interface
*/
public function filterByOwner($owner = null, $comparison = null)
{
if (is_array($owner)) {
$useMinMax = false;
if (isset($owner['min'])) {
$this->addUsingAlias(CcAccessPeer::OWNER, $owner['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($owner['max'])) {
$this->addUsingAlias(CcAccessPeer::OWNER, $owner['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcAccessPeer::OWNER, $owner, $comparison);
}
/**
* Filter the query on the ts column
*
* @param string|array $ts 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 CcAccessQuery The current query, for fluid interface
*/
public function filterByTs($ts = null, $comparison = null)
{
if (is_array($ts)) {
$useMinMax = false;
if (isset($ts['min'])) {
$this->addUsingAlias(CcAccessPeer::TS, $ts['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($ts['max'])) {
$this->addUsingAlias(CcAccessPeer::TS, $ts['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcAccessPeer::TS, $ts, $comparison);
}
/**
* Filter the query by a related CcSubjs object
*
* @param CcSubjs $ccSubjs the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function filterByCcSubjs($ccSubjs, $comparison = null)
{
return $this
->addUsingAlias(CcAccessPeer::OWNER, $ccSubjs->getId(), $comparison);
}
/**
* Adds a JOIN clause to the query using the CcSubjs relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function joinCcSubjs($relationAlias = '', $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CcSubjs');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CcSubjs');
}
return $this;
}
/**
* Use the CcSubjs relation CcSubjs object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcSubjsQuery A secondary query class using the current class as primary query
*/
public function useCcSubjsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinCcSubjs($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery');
}
/**
* Exclude object from result
*
* @param CcAccess $ccAccess Object to remove from the list of results
*
* @return CcAccessQuery The current query, for fluid interface
*/
public function prune($ccAccess = null)
{
if ($ccAccess) {
$this->addUsingAlias(CcAccessPeer::ID, $ccAccess->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
} // BaseCcAccessQuery

View File

@ -1,956 +0,0 @@
<?php
/**
* Base class that represents a row from the 'cc_backup' table.
*
*
*
* @package propel.generator.campcaster.om
*/
abstract class BaseCcBackup extends BaseObject implements Persistent
{
/**
* Peer class name
*/
const PEER = 'CcBackupPeer';
/**
* The Peer class.
* Instance provides a convenient way of calling static methods on a class
* that calling code may not be able to identify.
* @var CcBackupPeer
*/
protected static $peer;
/**
* The value for the token field.
* @var string
*/
protected $token;
/**
* The value for the sessionid field.
* @var string
*/
protected $sessionid;
/**
* The value for the status field.
* @var string
*/
protected $status;
/**
* The value for the fromtime field.
* @var string
*/
protected $fromtime;
/**
* The value for the totime field.
* @var string
*/
protected $totime;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [token] column value.
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
* Get the [sessionid] column value.
*
* @return string
*/
public function getSessionid()
{
return $this->sessionid;
}
/**
* Get the [status] column value.
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* Get the [optionally formatted] temporal [fromtime] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getFromtime($format = 'Y-m-d H:i:s')
{
if ($this->fromtime === null) {
return null;
}
try {
$dt = new DateTime($this->fromtime);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fromtime, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Get the [optionally formatted] temporal [totime] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getTotime($format = 'Y-m-d H:i:s')
{
if ($this->totime === null) {
return null;
}
try {
$dt = new DateTime($this->totime);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->totime, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Set the value of [token] column.
*
* @param string $v new value
* @return CcBackup The current object (for fluent API support)
*/
public function setToken($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->token !== $v) {
$this->token = $v;
$this->modifiedColumns[] = CcBackupPeer::TOKEN;
}
return $this;
} // setToken()
/**
* Set the value of [sessionid] column.
*
* @param string $v new value
* @return CcBackup The current object (for fluent API support)
*/
public function setSessionid($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->sessionid !== $v) {
$this->sessionid = $v;
$this->modifiedColumns[] = CcBackupPeer::SESSIONID;
}
return $this;
} // setSessionid()
/**
* Set the value of [status] column.
*
* @param string $v new value
* @return CcBackup The current object (for fluent API support)
*/
public function setStatus($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->status !== $v) {
$this->status = $v;
$this->modifiedColumns[] = CcBackupPeer::STATUS;
}
return $this;
} // setStatus()
/**
* Sets the value of [fromtime] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcBackup The current object (for fluent API support)
*/
public function setFromtime($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->fromtime !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->fromtime !== null && $tmpDt = new DateTime($this->fromtime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->fromtime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
$this->modifiedColumns[] = CcBackupPeer::FROMTIME;
}
} // if either are not null
return $this;
} // setFromtime()
/**
* Sets the value of [totime] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcBackup The current object (for fluent API support)
*/
public function setTotime($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->totime !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->totime !== null && $tmpDt = new DateTime($this->totime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->totime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
$this->modifiedColumns[] = CcBackupPeer::TOTIME;
}
} // if either are not null
return $this;
} // setTotime()
/**
* Indicates whether the columns in this object are only set to default values.
*
* This method can be used in conjunction with isModified() to indicate whether an object is both
* modified _and_ has some values set which are non-default.
*
* @return boolean Whether the columns in this object are only been set with default values.
*/
public function hasOnlyDefaultValues()
{
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (0-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
* @param int $startcol 0-based offset column which indicates which restultset column to start with.
* @param boolean $rehydrate Whether this object is being re-hydrated from the database.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->token = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
$this->sessionid = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->status = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->fromtime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->totime = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
return $startcol + 5; // 5 = CcBackupPeer::NUM_COLUMNS - CcBackupPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcBackup object", $e);
}
}
/**
* Checks and repairs the internal consistency of the object.
*
* This method is executed after an already-instantiated object is re-hydrated
* from the database. It exists to check any foreign keys to make sure that
* the objects related to the current object are correct based on foreign key.
*
* You can override this method in the stub class, but you should always invoke
* the base method from the overridden method (i.e. parent::ensureConsistency()),
* in case your model changes.
*
* @throws PropelException
*/
public function ensureConsistency()
{
} // ensureConsistency
/**
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
*
* This will only work if the object has been saved and has a valid primary key set.
*
* @param boolean $deep (optional) Whether to also de-associated any related objects.
* @param PropelPDO $con (optional) The PropelPDO connection to use.
* @return void
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
*/
public function reload($deep = false, PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
$stmt = CcBackupPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
$row = $stmt->fetch(PDO::FETCH_NUM);
$stmt->closeCursor();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true); // rehydrate
if ($deep) { // also de-associate any related objects?
} // if (deep)
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param PropelPDO $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete(PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
$ret = $this->preDelete($con);
if ($ret) {
CcBackupQuery::create()
->filterByPrimaryKey($this->getPrimaryKey())
->delete($con);
$this->postDelete($con);
$con->commit();
$this->setDeleted(true);
} else {
$con->commit();
}
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Persists this object to the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All modified related objects will also be persisted in the doSave()
* method. This method wraps all precipitate database operations in a
* single transaction.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save(PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
} else {
$ret = $ret && $this->preUpdate($con);
}
if ($ret) {
$affectedRows = $this->doSave($con);
if ($isInsert) {
$this->postInsert($con);
} else {
$this->postUpdate($con);
}
$this->postSave($con);
CcBackupPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
}
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$criteria = $this->buildCriteria();
$pk = BasePeer::doInsert($criteria, $con);
$affectedRows = 1;
$this->setNew(false);
} else {
$affectedRows = CcBackupPeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = CcBackupPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CcBackupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
$field = $this->getByPosition($pos);
return $field;
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getToken();
break;
case 1:
return $this->getSessionid();
break;
case 2:
return $this->getStatus();
break;
case 3:
return $this->getFromtime();
break;
case 4:
return $this->getTotime();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* Defaults to BasePeer::TYPE_PHPNAME.
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
*
* @return array an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
{
$keys = CcBackupPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getToken(),
$keys[1] => $this->getSessionid(),
$keys[2] => $this->getStatus(),
$keys[3] => $this->getFromtime(),
$keys[4] => $this->getTotime(),
);
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CcBackupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setToken($value);
break;
case 1:
$this->setSessionid($value);
break;
case 2:
$this->setStatus($value);
break;
case 3:
$this->setFromtime($value);
break;
case 4:
$this->setTotime($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* The default key type is the column's phpname (e.g. 'AuthorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CcBackupPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setToken($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setSessionid($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setStatus($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setFromtime($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setTotime($arr[$keys[4]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(CcBackupPeer::DATABASE_NAME);
if ($this->isColumnModified(CcBackupPeer::TOKEN)) $criteria->add(CcBackupPeer::TOKEN, $this->token);
if ($this->isColumnModified(CcBackupPeer::SESSIONID)) $criteria->add(CcBackupPeer::SESSIONID, $this->sessionid);
if ($this->isColumnModified(CcBackupPeer::STATUS)) $criteria->add(CcBackupPeer::STATUS, $this->status);
if ($this->isColumnModified(CcBackupPeer::FROMTIME)) $criteria->add(CcBackupPeer::FROMTIME, $this->fromtime);
if ($this->isColumnModified(CcBackupPeer::TOTIME)) $criteria->add(CcBackupPeer::TOTIME, $this->totime);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(CcBackupPeer::DATABASE_NAME);
$criteria->add(CcBackupPeer::TOKEN, $this->token);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return string
*/
public function getPrimaryKey()
{
return $this->getToken();
}
/**
* Generic method to set the primary key (token column).
*
* @param string $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setToken($key);
}
/**
* Returns true if the primary key for this object is null.
* @return boolean
*/
public function isPrimaryKeyNull()
{
return null === $this->getToken();
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of CcBackup (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setToken($this->token);
$copyObj->setSessionid($this->sessionid);
$copyObj->setStatus($this->status);
$copyObj->setFromtime($this->fromtime);
$copyObj->setTotime($this->totime);
$copyObj->setNew(true);
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return CcBackup Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* Since Peer classes are not to have any instance attributes, this method returns the
* same instance for all member of this class. The method could therefore
* be static, but this would prevent one from overriding the behavior.
*
* @return CcBackupPeer
*/
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new CcBackupPeer();
}
return self::$peer;
}
/**
* Clears the current object and sets all attributes to their default values
*/
public function clear()
{
$this->token = null;
$this->sessionid = null;
$this->status = null;
$this->fromtime = null;
$this->totime = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
}
/**
* Resets all collections of referencing foreign keys.
*
* This method is a user-space workaround for PHP's inability to garbage collect objects
* with circular references. This is currently necessary when using Propel in certain
* daemon or large-volumne/high-memory operations.
*
* @param boolean $deep Whether to also clear the references on all associated objects.
*/
public function clearAllReferences($deep = false)
{
if ($deep) {
} // if ($deep)
}
/**
* Catches calls to virtual methods
*/
public function __call($name, $params)
{
if (preg_match('/get(\w+)/', $name, $matches)) {
$virtualColumn = $matches[1];
if ($this->hasVirtualColumn($virtualColumn)) {
return $this->getVirtualColumn($virtualColumn);
}
// no lcfirst in php<5.3...
$virtualColumn[0] = strtolower($virtualColumn[0]);
if ($this->hasVirtualColumn($virtualColumn)) {
return $this->getVirtualColumn($virtualColumn);
}
}
throw new PropelException('Call to undefined method: ' . $name);
}
} // BaseCcBackup

View File

@ -1,750 +0,0 @@
<?php
/**
* Base static class for performing query and update operations on the 'cc_backup' table.
*
*
*
* @package propel.generator.campcaster.om
*/
abstract class BaseCcBackupPeer {
/** the default database name for this class */
const DATABASE_NAME = 'campcaster';
/** the table name for this class */
const TABLE_NAME = 'cc_backup';
/** the related Propel class for this table */
const OM_CLASS = 'CcBackup';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'campcaster.CcBackup';
/** the related TableMap class for this table */
const TM_CLASS = 'CcBackupTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 5;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the TOKEN field */
const TOKEN = 'cc_backup.TOKEN';
/** the column name for the SESSIONID field */
const SESSIONID = 'cc_backup.SESSIONID';
/** the column name for the STATUS field */
const STATUS = 'cc_backup.STATUS';
/** the column name for the FROMTIME field */
const FROMTIME = 'cc_backup.FROMTIME';
/** the column name for the TOTIME field */
const TOTIME = 'cc_backup.TOTIME';
/**
* An identiy map to hold any loaded instances of CcBackup objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
* queries.
* @var array CcBackup[]
*/
public static $instances = array();
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Token', 'Sessionid', 'Status', 'Fromtime', 'Totime', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('token', 'sessionid', 'status', 'fromtime', 'totime', ),
BasePeer::TYPE_COLNAME => array (self::TOKEN, self::SESSIONID, self::STATUS, self::FROMTIME, self::TOTIME, ),
BasePeer::TYPE_RAW_COLNAME => array ('TOKEN', 'SESSIONID', 'STATUS', 'FROMTIME', 'TOTIME', ),
BasePeer::TYPE_FIELDNAME => array ('token', 'sessionid', 'status', 'fromtime', 'totime', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Token' => 0, 'Sessionid' => 1, 'Status' => 2, 'Fromtime' => 3, 'Totime' => 4, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('token' => 0, 'sessionid' => 1, 'status' => 2, 'fromtime' => 3, 'totime' => 4, ),
BasePeer::TYPE_COLNAME => array (self::TOKEN => 0, self::SESSIONID => 1, self::STATUS => 2, self::FROMTIME => 3, self::TOTIME => 4, ),
BasePeer::TYPE_RAW_COLNAME => array ('TOKEN' => 0, 'SESSIONID' => 1, 'STATUS' => 2, 'FROMTIME' => 3, 'TOTIME' => 4, ),
BasePeer::TYPE_FIELDNAME => array ('token' => 0, 'sessionid' => 1, 'status' => 2, 'fromtime' => 3, 'totime' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
* @throws PropelException - if the specified name could not be found in the fieldname mappings.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CcBackupPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CcBackupPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CcBackupPeer::TOKEN);
$criteria->addSelectColumn(CcBackupPeer::SESSIONID);
$criteria->addSelectColumn(CcBackupPeer::STATUS);
$criteria->addSelectColumn(CcBackupPeer::FROMTIME);
$criteria->addSelectColumn(CcBackupPeer::TOTIME);
} else {
$criteria->addSelectColumn($alias . '.TOKEN');
$criteria->addSelectColumn($alias . '.SESSIONID');
$criteria->addSelectColumn($alias . '.STATUS');
$criteria->addSelectColumn($alias . '.FROMTIME');
$criteria->addSelectColumn($alias . '.TOTIME');
}
}
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
{
// we may modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcBackupPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcBackupPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// BasePeer returns a PDOStatement
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param PropelPDO $con
* @return CcBackup
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CcBackupPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
return CcBackupPeer::populateObjects(CcBackupPeer::doSelectStmt($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
*
* Use this method directly if you want to work with an executed statement durirectly (for example
* to perform your own object hydration).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con The connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return PDOStatement The executed PDOStatement object.
* @see BasePeer::doSelect()
*/
public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
if (!$criteria->hasSelectClause()) {
$criteria = clone $criteria;
CcBackupPeer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a PDOStatement
return BasePeer::doSelect($criteria, $con);
}
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param CcBackup $value A CcBackup object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(CcBackup $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getToken();
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A CcBackup object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && $value !== null) {
if (is_object($value) && $value instanceof CcBackup) {
$key = (string) $value->getToken();
} elseif (is_scalar($value)) {
// assume we've been passed a primary key
$key = (string) $value;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcBackup object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
throw $e;
}
unset(self::$instances[$key]);
}
} // removeInstanceFromPool()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param string $key The key (@see getPrimaryKeyHash()) for this instance.
* @return CcBackup Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
* @see getPrimaryKeyHash()
*/
public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(self::$instances[$key])) {
return self::$instances[$key];
}
}
return null; // just to be explicit
}
/**
* Clear the instance pool.
*
* @return void
*/
public static function clearInstancePool()
{
self::$instances = array();
}
/**
* Method to invalidate the instance pool of all tables related to cc_backup
* by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return string A string version of PK or NULL if the components of primary key in result array are all null.
*/
public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[$startcol] === null) {
return null;
}
return (string) $row[$startcol];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $startcol = 0)
{
return (string) $row[$startcol];
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(PDOStatement $stmt)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = CcBackupPeer::getOMClass(false);
// populate the object(s)
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key = CcBackupPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj = CcBackupPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CcBackupPeer::addInstanceToPool($obj, $key);
} // if key exists
}
$stmt->closeCursor();
return $results;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CcBackup object, last column rank)
*/
public static function populateObject($row, $startcol = 0)
{
$key = CcBackupPeer::getPrimaryKeyHashFromRow($row, $startcol);
if (null !== ($obj = CcBackupPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $startcol, true); // rehydrate
$col = $startcol + CcBackupPeer::NUM_COLUMNS;
} else {
$cls = CcBackupPeer::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $startcol);
CcBackupPeer::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this peer class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseCcBackupPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseCcBackupPeer::TABLE_NAME))
{
$dbMap->addTableObject(new CcBackupTableMap());
}
}
/**
* The class that the Peer will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CcBackupPeer::CLASS_DEFAULT : CcBackupPeer::OM_CLASS;
}
/**
* Method perform an INSERT on the database, given a CcBackup or Criteria object.
*
* @param mixed $values Criteria or CcBackup object containing data that is used to create the INSERT statement.
* @param PropelPDO $con the PropelPDO connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from CcBackup object
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a CcBackup or Criteria object.
*
* @param mixed $values Criteria or CcBackup object containing data that is used to create the UPDATE statement.
* @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CcBackupPeer::TOKEN);
$value = $criteria->remove(CcBackupPeer::TOKEN);
if ($value) {
$selectCriteria->add(CcBackupPeer::TOKEN, $value, $comparison);
} else {
$selectCriteria->setPrimaryTableName(CcBackupPeer::TABLE_NAME);
}
} else { // $values is CcBackup object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the cc_backup table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(CcBackupPeer::TABLE_NAME, $con, CcBackupPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CcBackupPeer::clearInstancePool();
CcBackupPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a CcBackup or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CcBackup object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param PropelPDO $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
CcBackupPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CcBackup) { // it's a model object
// invalidate the cache for this single object
CcBackupPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CcBackupPeer::TOKEN, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
CcBackupPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
CcBackupPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Validates all modified columns of given CcBackup object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param CcBackup $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(CcBackup $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CcBackupPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CcBackupPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(CcBackupPeer::DATABASE_NAME, CcBackupPeer::TABLE_NAME, $columns);
}
/**
* Retrieve a single object by pkey.
*
* @param string $pk the primary key.
* @param PropelPDO $con the connection to use
* @return CcBackup
*/
public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = CcBackupPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(CcBackupPeer::DATABASE_NAME);
$criteria->add(CcBackupPeer::TOKEN, $pk);
$v = CcBackupPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param PropelPDO $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcBackupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(CcBackupPeer::DATABASE_NAME);
$criteria->add(CcBackupPeer::TOKEN, $pks, Criteria::IN);
$objs = CcBackupPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseCcBackupPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
BaseCcBackupPeer::buildTableMap();

View File

@ -1,292 +0,0 @@
<?php
/**
* Base class that represents a query for the 'cc_backup' table.
*
*
*
* @method CcBackupQuery orderByToken($order = Criteria::ASC) Order by the token column
* @method CcBackupQuery orderBySessionid($order = Criteria::ASC) Order by the sessionid column
* @method CcBackupQuery orderByStatus($order = Criteria::ASC) Order by the status column
* @method CcBackupQuery orderByFromtime($order = Criteria::ASC) Order by the fromtime column
* @method CcBackupQuery orderByTotime($order = Criteria::ASC) Order by the totime column
*
* @method CcBackupQuery groupByToken() Group by the token column
* @method CcBackupQuery groupBySessionid() Group by the sessionid column
* @method CcBackupQuery groupByStatus() Group by the status column
* @method CcBackupQuery groupByFromtime() Group by the fromtime column
* @method CcBackupQuery groupByTotime() Group by the totime column
*
* @method CcBackupQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcBackupQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CcBackupQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method CcBackup findOne(PropelPDO $con = null) Return the first CcBackup matching the query
* @method CcBackup findOneOrCreate(PropelPDO $con = null) Return the first CcBackup matching the query, or a new CcBackup object populated from the query conditions when no match is found
*
* @method CcBackup findOneByToken(string $token) Return the first CcBackup filtered by the token column
* @method CcBackup findOneBySessionid(string $sessionid) Return the first CcBackup filtered by the sessionid column
* @method CcBackup findOneByStatus(string $status) Return the first CcBackup filtered by the status column
* @method CcBackup findOneByFromtime(string $fromtime) Return the first CcBackup filtered by the fromtime column
* @method CcBackup findOneByTotime(string $totime) Return the first CcBackup filtered by the totime column
*
* @method array findByToken(string $token) Return CcBackup objects filtered by the token column
* @method array findBySessionid(string $sessionid) Return CcBackup objects filtered by the sessionid column
* @method array findByStatus(string $status) Return CcBackup objects filtered by the status column
* @method array findByFromtime(string $fromtime) Return CcBackup objects filtered by the fromtime column
* @method array findByTotime(string $totime) Return CcBackup objects filtered by the totime column
*
* @package propel.generator.campcaster.om
*/
abstract class BaseCcBackupQuery extends ModelCriteria
{
/**
* Initializes internal state of BaseCcBackupQuery object.
*
* @param string $dbName The dabase name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'campcaster', $modelName = 'CcBackup', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new CcBackupQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return CcBackupQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CcBackupQuery) {
return $criteria;
}
$query = new CcBackupQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key
* Use instance pooling to avoid a database query if the object exists
* <code>
* $obj = $c->findPk(12, $con);
* </code>
* @param mixed $key Primary key to use for the query
* @param PropelPDO $con an optional connection object
*
* @return CcBackup|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ((null !== ($obj = CcBackupPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
// the object is alredy in the instance pool
return $obj;
} else {
// the object has not been requested yet, or the formatter is not an object formatter
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->getSelectStatement($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
}
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param PropelPDO $con an optional connection object
*
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
$criteria = $this->isKeepQuery() ? clone $this : $this;
return $this
->filterByPrimaryKeys($keys)
->find($con);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return CcBackupQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CcBackupPeer::TOKEN, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return CcBackupQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CcBackupPeer::TOKEN, $keys, Criteria::IN);
}
/**
* Filter the query on the token column
*
* @param string $token The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcBackupQuery The current query, for fluid interface
*/
public function filterByToken($token = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($token)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $token)) {
$token = str_replace('*', '%', $token);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcBackupPeer::TOKEN, $token, $comparison);
}
/**
* Filter the query on the sessionid column
*
* @param string $sessionid The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcBackupQuery The current query, for fluid interface
*/
public function filterBySessionid($sessionid = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($sessionid)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $sessionid)) {
$sessionid = str_replace('*', '%', $sessionid);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcBackupPeer::SESSIONID, $sessionid, $comparison);
}
/**
* Filter the query on the status column
*
* @param string $status The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcBackupQuery The current query, for fluid interface
*/
public function filterByStatus($status = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($status)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $status)) {
$status = str_replace('*', '%', $status);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcBackupPeer::STATUS, $status, $comparison);
}
/**
* Filter the query on the fromtime column
*
* @param string|array $fromtime 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 CcBackupQuery The current query, for fluid interface
*/
public function filterByFromtime($fromtime = null, $comparison = null)
{
if (is_array($fromtime)) {
$useMinMax = false;
if (isset($fromtime['min'])) {
$this->addUsingAlias(CcBackupPeer::FROMTIME, $fromtime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($fromtime['max'])) {
$this->addUsingAlias(CcBackupPeer::FROMTIME, $fromtime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcBackupPeer::FROMTIME, $fromtime, $comparison);
}
/**
* Filter the query on the totime column
*
* @param string|array $totime 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 CcBackupQuery The current query, for fluid interface
*/
public function filterByTotime($totime = null, $comparison = null)
{
if (is_array($totime)) {
$useMinMax = false;
if (isset($totime['min'])) {
$this->addUsingAlias(CcBackupPeer::TOTIME, $totime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($totime['max'])) {
$this->addUsingAlias(CcBackupPeer::TOTIME, $totime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcBackupPeer::TOTIME, $totime, $comparison);
}
/**
* Exclude object from result
*
* @param CcBackup $ccBackup Object to remove from the list of results
*
* @return CcBackupQuery The current query, for fluid interface
*/
public function prune($ccBackup = null)
{
if ($ccBackup) {
$this->addUsingAlias(CcBackupPeer::TOKEN, $ccBackup->getToken(), Criteria::NOT_EQUAL);
}
return $this;
}
} // BaseCcBackupQuery

File diff suppressed because it is too large Load Diff

View File

@ -1,945 +0,0 @@
<?php
/**
* Base class that represents a row from the 'cc_perms' table.
*
*
*
* @package propel.generator.campcaster.om
*/
abstract class BaseCcPerms extends BaseObject implements Persistent
{
/**
* Peer class name
*/
const PEER = 'CcPermsPeer';
/**
* The Peer class.
* Instance provides a convenient way of calling static methods on a class
* that calling code may not be able to identify.
* @var CcPermsPeer
*/
protected static $peer;
/**
* The value for the permid field.
* @var int
*/
protected $permid;
/**
* The value for the subj field.
* @var int
*/
protected $subj;
/**
* The value for the action field.
* @var string
*/
protected $action;
/**
* The value for the obj field.
* @var int
*/
protected $obj;
/**
* The value for the type field.
* @var string
*/
protected $type;
/**
* @var CcSubjs
*/
protected $aCcSubjs;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [permid] column value.
*
* @return int
*/
public function getPermid()
{
return $this->permid;
}
/**
* Get the [subj] column value.
*
* @return int
*/
public function getSubj()
{
return $this->subj;
}
/**
* Get the [action] column value.
*
* @return string
*/
public function getAction()
{
return $this->action;
}
/**
* Get the [obj] column value.
*
* @return int
*/
public function getObj()
{
return $this->obj;
}
/**
* Get the [type] column value.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of [permid] column.
*
* @param int $v new value
* @return CcPerms The current object (for fluent API support)
*/
public function setPermid($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->permid !== $v) {
$this->permid = $v;
$this->modifiedColumns[] = CcPermsPeer::PERMID;
}
return $this;
} // setPermid()
/**
* Set the value of [subj] column.
*
* @param int $v new value
* @return CcPerms The current object (for fluent API support)
*/
public function setSubj($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->subj !== $v) {
$this->subj = $v;
$this->modifiedColumns[] = CcPermsPeer::SUBJ;
}
if ($this->aCcSubjs !== null && $this->aCcSubjs->getId() !== $v) {
$this->aCcSubjs = null;
}
return $this;
} // setSubj()
/**
* Set the value of [action] column.
*
* @param string $v new value
* @return CcPerms The current object (for fluent API support)
*/
public function setAction($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->action !== $v) {
$this->action = $v;
$this->modifiedColumns[] = CcPermsPeer::ACTION;
}
return $this;
} // setAction()
/**
* Set the value of [obj] column.
*
* @param int $v new value
* @return CcPerms The current object (for fluent API support)
*/
public function setObj($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->obj !== $v) {
$this->obj = $v;
$this->modifiedColumns[] = CcPermsPeer::OBJ;
}
return $this;
} // setObj()
/**
* Set the value of [type] column.
*
* @param string $v new value
* @return CcPerms The current object (for fluent API support)
*/
public function setType($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->type !== $v) {
$this->type = $v;
$this->modifiedColumns[] = CcPermsPeer::TYPE;
}
return $this;
} // setType()
/**
* Indicates whether the columns in this object are only set to default values.
*
* This method can be used in conjunction with isModified() to indicate whether an object is both
* modified _and_ has some values set which are non-default.
*
* @return boolean Whether the columns in this object are only been set with default values.
*/
public function hasOnlyDefaultValues()
{
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (0-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
* @param int $startcol 0-based offset column which indicates which restultset column to start with.
* @param boolean $rehydrate Whether this object is being re-hydrated from the database.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->permid = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->subj = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
$this->action = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->obj = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
$this->type = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
return $startcol + 5; // 5 = CcPermsPeer::NUM_COLUMNS - CcPermsPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcPerms object", $e);
}
}
/**
* Checks and repairs the internal consistency of the object.
*
* This method is executed after an already-instantiated object is re-hydrated
* from the database. It exists to check any foreign keys to make sure that
* the objects related to the current object are correct based on foreign key.
*
* You can override this method in the stub class, but you should always invoke
* the base method from the overridden method (i.e. parent::ensureConsistency()),
* in case your model changes.
*
* @throws PropelException
*/
public function ensureConsistency()
{
if ($this->aCcSubjs !== null && $this->subj !== $this->aCcSubjs->getId()) {
$this->aCcSubjs = null;
}
} // ensureConsistency
/**
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
*
* This will only work if the object has been saved and has a valid primary key set.
*
* @param boolean $deep (optional) Whether to also de-associated any related objects.
* @param PropelPDO $con (optional) The PropelPDO connection to use.
* @return void
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
*/
public function reload($deep = false, PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
$stmt = CcPermsPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
$row = $stmt->fetch(PDO::FETCH_NUM);
$stmt->closeCursor();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true); // rehydrate
if ($deep) { // also de-associate any related objects?
$this->aCcSubjs = null;
} // if (deep)
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param PropelPDO $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete(PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
$ret = $this->preDelete($con);
if ($ret) {
CcPermsQuery::create()
->filterByPrimaryKey($this->getPrimaryKey())
->delete($con);
$this->postDelete($con);
$con->commit();
$this->setDeleted(true);
} else {
$con->commit();
}
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Persists this object to the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All modified related objects will also be persisted in the doSave()
* method. This method wraps all precipitate database operations in a
* single transaction.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save(PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
$isInsert = $this->isNew();
try {
$ret = $this->preSave($con);
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
} else {
$ret = $ret && $this->preUpdate($con);
}
if ($ret) {
$affectedRows = $this->doSave($con);
if ($isInsert) {
$this->postInsert($con);
} else {
$this->postUpdate($con);
}
$this->postSave($con);
CcPermsPeer::addInstanceToPool($this);
} else {
$affectedRows = 0;
}
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aCcSubjs !== null) {
if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) {
$affectedRows += $this->aCcSubjs->save($con);
}
$this->setCcSubjs($this->aCcSubjs);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$criteria = $this->buildCriteria();
$pk = BasePeer::doInsert($criteria, $con);
$affectedRows += 1;
$this->setNew(false);
} else {
$affectedRows += CcPermsPeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aCcSubjs !== null) {
if (!$this->aCcSubjs->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures());
}
}
if (($retval = CcPermsPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CcPermsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
$field = $this->getByPosition($pos);
return $field;
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getPermid();
break;
case 1:
return $this->getSubj();
break;
case 2:
return $this->getAction();
break;
case 3:
return $this->getObj();
break;
case 4:
return $this->getType();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* Defaults to BasePeer::TYPE_PHPNAME.
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
* @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
*
* @return array an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $includeForeignObjects = false)
{
$keys = CcPermsPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getPermid(),
$keys[1] => $this->getSubj(),
$keys[2] => $this->getAction(),
$keys[3] => $this->getObj(),
$keys[4] => $this->getType(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcSubjs) {
$result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, true);
}
}
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CcPermsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setPermid($value);
break;
case 1:
$this->setSubj($value);
break;
case 2:
$this->setAction($value);
break;
case 3:
$this->setObj($value);
break;
case 4:
$this->setType($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* The default key type is the column's phpname (e.g. 'AuthorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CcPermsPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setPermid($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setSubj($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setObj($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setType($arr[$keys[4]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(CcPermsPeer::DATABASE_NAME);
if ($this->isColumnModified(CcPermsPeer::PERMID)) $criteria->add(CcPermsPeer::PERMID, $this->permid);
if ($this->isColumnModified(CcPermsPeer::SUBJ)) $criteria->add(CcPermsPeer::SUBJ, $this->subj);
if ($this->isColumnModified(CcPermsPeer::ACTION)) $criteria->add(CcPermsPeer::ACTION, $this->action);
if ($this->isColumnModified(CcPermsPeer::OBJ)) $criteria->add(CcPermsPeer::OBJ, $this->obj);
if ($this->isColumnModified(CcPermsPeer::TYPE)) $criteria->add(CcPermsPeer::TYPE, $this->type);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(CcPermsPeer::DATABASE_NAME);
$criteria->add(CcPermsPeer::PERMID, $this->permid);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return int
*/
public function getPrimaryKey()
{
return $this->getPermid();
}
/**
* Generic method to set the primary key (permid column).
*
* @param int $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setPermid($key);
}
/**
* Returns true if the primary key for this object is null.
* @return boolean
*/
public function isPrimaryKeyNull()
{
return null === $this->getPermid();
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of CcPerms (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setPermid($this->permid);
$copyObj->setSubj($this->subj);
$copyObj->setAction($this->action);
$copyObj->setObj($this->obj);
$copyObj->setType($this->type);
$copyObj->setNew(true);
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return CcPerms Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* Since Peer classes are not to have any instance attributes, this method returns the
* same instance for all member of this class. The method could therefore
* be static, but this would prevent one from overriding the behavior.
*
* @return CcPermsPeer
*/
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new CcPermsPeer();
}
return self::$peer;
}
/**
* Declares an association between this object and a CcSubjs object.
*
* @param CcSubjs $v
* @return CcPerms The current object (for fluent API support)
* @throws PropelException
*/
public function setCcSubjs(CcSubjs $v = null)
{
if ($v === null) {
$this->setSubj(NULL);
} else {
$this->setSubj($v->getId());
}
$this->aCcSubjs = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the CcSubjs object, it will not be re-added.
if ($v !== null) {
$v->addCcPerms($this);
}
return $this;
}
/**
* Get the associated CcSubjs object
*
* @param PropelPDO Optional Connection object.
* @return CcSubjs The associated CcSubjs object.
* @throws PropelException
*/
public function getCcSubjs(PropelPDO $con = null)
{
if ($this->aCcSubjs === null && ($this->subj !== null)) {
$this->aCcSubjs = CcSubjsQuery::create()->findPk($this->subj, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCcSubjs->addCcPermss($this);
*/
}
return $this->aCcSubjs;
}
/**
* Clears the current object and sets all attributes to their default values
*/
public function clear()
{
$this->permid = null;
$this->subj = null;
$this->action = null;
$this->obj = null;
$this->type = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
}
/**
* Resets all collections of referencing foreign keys.
*
* This method is a user-space workaround for PHP's inability to garbage collect objects
* with circular references. This is currently necessary when using Propel in certain
* daemon or large-volumne/high-memory operations.
*
* @param boolean $deep Whether to also clear the references on all associated objects.
*/
public function clearAllReferences($deep = false)
{
if ($deep) {
} // if ($deep)
$this->aCcSubjs = null;
}
/**
* Catches calls to virtual methods
*/
public function __call($name, $params)
{
if (preg_match('/get(\w+)/', $name, $matches)) {
$virtualColumn = $matches[1];
if ($this->hasVirtualColumn($virtualColumn)) {
return $this->getVirtualColumn($virtualColumn);
}
// no lcfirst in php<5.3...
$virtualColumn[0] = strtolower($virtualColumn[0]);
if ($this->hasVirtualColumn($virtualColumn)) {
return $this->getVirtualColumn($virtualColumn);
}
}
throw new PropelException('Call to undefined method: ' . $name);
}
} // BaseCcPerms

View File

@ -1,984 +0,0 @@
<?php
/**
* Base static class for performing query and update operations on the 'cc_perms' table.
*
*
*
* @package propel.generator.campcaster.om
*/
abstract class BaseCcPermsPeer {
/** the default database name for this class */
const DATABASE_NAME = 'campcaster';
/** the table name for this class */
const TABLE_NAME = 'cc_perms';
/** the related Propel class for this table */
const OM_CLASS = 'CcPerms';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'campcaster.CcPerms';
/** the related TableMap class for this table */
const TM_CLASS = 'CcPermsTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 5;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the PERMID field */
const PERMID = 'cc_perms.PERMID';
/** the column name for the SUBJ field */
const SUBJ = 'cc_perms.SUBJ';
/** the column name for the ACTION field */
const ACTION = 'cc_perms.ACTION';
/** the column name for the OBJ field */
const OBJ = 'cc_perms.OBJ';
/** the column name for the TYPE field */
const TYPE = 'cc_perms.TYPE';
/**
* An identiy map to hold any loaded instances of CcPerms objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
* queries.
* @var array CcPerms[]
*/
public static $instances = array();
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Permid', 'Subj', 'Action', 'Obj', 'Type', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('permid', 'subj', 'action', 'obj', 'type', ),
BasePeer::TYPE_COLNAME => array (self::PERMID, self::SUBJ, self::ACTION, self::OBJ, self::TYPE, ),
BasePeer::TYPE_RAW_COLNAME => array ('PERMID', 'SUBJ', 'ACTION', 'OBJ', 'TYPE', ),
BasePeer::TYPE_FIELDNAME => array ('permid', 'subj', 'action', 'obj', 'type', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Permid' => 0, 'Subj' => 1, 'Action' => 2, 'Obj' => 3, 'Type' => 4, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('permid' => 0, 'subj' => 1, 'action' => 2, 'obj' => 3, 'type' => 4, ),
BasePeer::TYPE_COLNAME => array (self::PERMID => 0, self::SUBJ => 1, self::ACTION => 2, self::OBJ => 3, self::TYPE => 4, ),
BasePeer::TYPE_RAW_COLNAME => array ('PERMID' => 0, 'SUBJ' => 1, 'ACTION' => 2, 'OBJ' => 3, 'TYPE' => 4, ),
BasePeer::TYPE_FIELDNAME => array ('permid' => 0, 'subj' => 1, 'action' => 2, 'obj' => 3, 'type' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
* @throws PropelException - if the specified name could not be found in the fieldname mappings.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CcPermsPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CcPermsPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CcPermsPeer::PERMID);
$criteria->addSelectColumn(CcPermsPeer::SUBJ);
$criteria->addSelectColumn(CcPermsPeer::ACTION);
$criteria->addSelectColumn(CcPermsPeer::OBJ);
$criteria->addSelectColumn(CcPermsPeer::TYPE);
} else {
$criteria->addSelectColumn($alias . '.PERMID');
$criteria->addSelectColumn($alias . '.SUBJ');
$criteria->addSelectColumn($alias . '.ACTION');
$criteria->addSelectColumn($alias . '.OBJ');
$criteria->addSelectColumn($alias . '.TYPE');
}
}
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
{
// we may modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcPermsPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcPermsPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// BasePeer returns a PDOStatement
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param PropelPDO $con
* @return CcPerms
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CcPermsPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
return CcPermsPeer::populateObjects(CcPermsPeer::doSelectStmt($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
*
* Use this method directly if you want to work with an executed statement durirectly (for example
* to perform your own object hydration).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con The connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return PDOStatement The executed PDOStatement object.
* @see BasePeer::doSelect()
*/
public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
if (!$criteria->hasSelectClause()) {
$criteria = clone $criteria;
CcPermsPeer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a PDOStatement
return BasePeer::doSelect($criteria, $con);
}
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param CcPerms $value A CcPerms object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(CcPerms $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getPermid();
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A CcPerms object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && $value !== null) {
if (is_object($value) && $value instanceof CcPerms) {
$key = (string) $value->getPermid();
} elseif (is_scalar($value)) {
// assume we've been passed a primary key
$key = (string) $value;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcPerms object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
throw $e;
}
unset(self::$instances[$key]);
}
} // removeInstanceFromPool()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param string $key The key (@see getPrimaryKeyHash()) for this instance.
* @return CcPerms Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
* @see getPrimaryKeyHash()
*/
public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(self::$instances[$key])) {
return self::$instances[$key];
}
}
return null; // just to be explicit
}
/**
* Clear the instance pool.
*
* @return void
*/
public static function clearInstancePool()
{
self::$instances = array();
}
/**
* Method to invalidate the instance pool of all tables related to cc_perms
* by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return string A string version of PK or NULL if the components of primary key in result array are all null.
*/
public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[$startcol] === null) {
return null;
}
return (string) $row[$startcol];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $startcol = 0)
{
return (int) $row[$startcol];
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(PDOStatement $stmt)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = CcPermsPeer::getOMClass(false);
// populate the object(s)
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key = CcPermsPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj = CcPermsPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CcPermsPeer::addInstanceToPool($obj, $key);
} // if key exists
}
$stmt->closeCursor();
return $results;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row PropelPDO resultset row.
* @param int $startcol The 0-based offset for reading from the resultset row.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CcPerms object, last column rank)
*/
public static function populateObject($row, $startcol = 0)
{
$key = CcPermsPeer::getPrimaryKeyHashFromRow($row, $startcol);
if (null !== ($obj = CcPermsPeer::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $startcol, true); // rehydrate
$col = $startcol + CcPermsPeer::NUM_COLUMNS;
} else {
$cls = CcPermsPeer::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $startcol);
CcPermsPeer::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* Returns the number of rows matching criteria, joining the related CcSubjs table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
public static function doCountJoinCcSubjs(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcPermsPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcPermsPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Selects a collection of CcPerms objects pre-filled with their CcSubjs objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of CcPerms objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinCcSubjs(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
CcPermsPeer::addSelectColumns($criteria);
$startcol = (CcPermsPeer::NUM_COLUMNS - CcPermsPeer::NUM_LAZY_LOAD_COLUMNS);
CcSubjsPeer::addSelectColumns($criteria);
$criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CcPermsPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CcPermsPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CcPermsPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
CcPermsPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
$key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
$obj2 = CcSubjsPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CcSubjsPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
CcSubjsPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
// Add the $obj1 (CcPerms) to $obj2 (CcSubjs)
$obj2->addCcPerms($obj1);
} // if joined row was not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
/**
* Returns the number of rows matching criteria, joining all related tables
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(CcPermsPeer::TABLE_NAME);
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->setDistinct();
}
if (!$criteria->hasSelectClause()) {
CcPermsPeer::addSelectColumns($criteria);
}
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
}
/**
* Selects a collection of CcPerms objects pre-filled with all related objects.
*
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of CcPerms objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
CcPermsPeer::addSelectColumns($criteria);
$startcol2 = (CcPermsPeer::NUM_COLUMNS - CcPermsPeer::NUM_LAZY_LOAD_COLUMNS);
CcSubjsPeer::addSelectColumns($criteria);
$startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS);
$criteria->addJoin(CcPermsPeer::SUBJ, CcSubjsPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CcPermsPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CcPermsPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CcPermsPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
CcPermsPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
// Add objects for joined CcSubjs rows
$key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
$obj2 = CcSubjsPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CcSubjsPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
CcSubjsPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
// Add the $obj1 (CcPerms) to the collection in $obj2 (CcSubjs)
$obj2->addCcPerms($obj1);
} // if joined row not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this peer class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseCcPermsPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseCcPermsPeer::TABLE_NAME))
{
$dbMap->addTableObject(new CcPermsTableMap());
}
}
/**
* The class that the Peer will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CcPermsPeer::CLASS_DEFAULT : CcPermsPeer::OM_CLASS;
}
/**
* Method perform an INSERT on the database, given a CcPerms or Criteria object.
*
* @param mixed $values Criteria or CcPerms object containing data that is used to create the INSERT statement.
* @param PropelPDO $con the PropelPDO connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from CcPerms object
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a CcPerms or Criteria object.
*
* @param mixed $values Criteria or CcPerms object containing data that is used to create the UPDATE statement.
* @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CcPermsPeer::PERMID);
$value = $criteria->remove(CcPermsPeer::PERMID);
if ($value) {
$selectCriteria->add(CcPermsPeer::PERMID, $value, $comparison);
} else {
$selectCriteria->setPrimaryTableName(CcPermsPeer::TABLE_NAME);
}
} else { // $values is CcPerms object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the cc_perms table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(CcPermsPeer::TABLE_NAME, $con, CcPermsPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CcPermsPeer::clearInstancePool();
CcPermsPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a CcPerms or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CcPerms object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param PropelPDO $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
CcPermsPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof CcPerms) { // it's a model object
// invalidate the cache for this single object
CcPermsPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CcPermsPeer::PERMID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
CcPermsPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
CcPermsPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
/**
* Validates all modified columns of given CcPerms object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param CcPerms $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(CcPerms $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CcPermsPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CcPermsPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(CcPermsPeer::DATABASE_NAME, CcPermsPeer::TABLE_NAME, $columns);
}
/**
* Retrieve a single object by pkey.
*
* @param int $pk the primary key.
* @param PropelPDO $con the connection to use
* @return CcPerms
*/
public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = CcPermsPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(CcPermsPeer::DATABASE_NAME);
$criteria->add(CcPermsPeer::PERMID, $pk);
$v = CcPermsPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param PropelPDO $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CcPermsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(CcPermsPeer::DATABASE_NAME);
$criteria->add(CcPermsPeer::PERMID, $pks, Criteria::IN);
$objs = CcPermsPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseCcPermsPeer
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
BaseCcPermsPeer::buildTableMap();

Some files were not shown because too many files have changed in this diff Show More