* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see Alib
*/
class BasicStor extends Alib {
- var $filesTable;
- var $mdataTable;
- var $accessTable;
- var $storageDir;
- var $bufferDir;
- var $accessDir;
- var $rootId;
- var $storId;
- var $doDebug = true;
+ /**
+ * The name of a database table.
+ *
+ * @var string
+ */
+ public $filesTable;
+
+ /**
+ * The name of a database table.
+ *
+ * @var string
+ */
+ public $mdataTable;
+
+ /**
+ * The name of a database table.
+ *
+ * @var string
+ */
+ public $accessTable;
+
+ /**
+ * Full path to a directory where to store media files.
+ * @var string
+ */
+ public $storageDir;
+
+ /**
+ * Full path to a directory that stores temporary files.
+ * @var string
+ */
+ public $bufferDir;
+
+ /**
+ * Full path to a directory.
+ * @var string
+ */
+ public $accessDir;
+
+ protected $rootId;
+
+ public $storId;
/**
* Constructor
@@ -51,29 +87,28 @@ class BasicStor extends Alib {
* array from conf.php
* @return class instance
*/
- function BasicStor(&$dbc, $config, $install=FALSE)
+ public function __construct(&$dbc, $config, $install=FALSE)
{
- parent::Alib($dbc, $config);
+ parent::__construct($dbc, $config);
$this->dbc->setErrorHandling(PEAR_ERROR_RETURN);
$this->config = $config;
$this->filesTable = $config['tblNamePrefix'].'files';
$this->mdataTable = $config['tblNamePrefix'].'mdata';
$this->accessTable= $config['tblNamePrefix'].'access';
$this->storageDir = realpath($config['storageDir']);
- $this->bufferDir = realpath($config['bufferDir']);
- $this->transDir = realpath($config['transDir']);
- $this->accessDir = realpath($config['accessDir']);
+ $this->bufferDir = realpath($config['bufferDir']);
+ $this->transDir = realpath($config['transDir']);
+ $this->accessDir = realpath($config['accessDir']);
if (!$install) {
- $this->rootId = $r = $this->getRootNode();
- if ($this->dbc->isError($r)) {
+ $this->rootId = $this->getRootNode();
+ if ($this->dbc->isError($this->rootId)) {
trigger_error("BasicStor: ".
- $r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
+ $this->rootId->getMessage()." ".$this->rootId->getUserInfo(),E_USER_ERROR);
}
- $this->storId = $this->wd =
- $r = $this->getObjId('StorageRoot', $this->getRootNode());
- if ($this->dbc->isError($r)) {
+ $this->storId = $this->getObjId('StorageRoot', $this->getRootNode());
+ if ($this->dbc->isError($this->storId)) {
trigger_error("BasicStor: ".
- $r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
+ $this->storId->getMessage()." ".$this->storId->getUserInfo(),E_USER_ERROR);
}
}
}
@@ -90,7 +125,7 @@ class BasicStor extends Alib {
* id of new folder
* @exception PEAR::error
*/
- function bsCreateFolder($parid, $folderName)
+ public function bsCreateFolder($parid, $folderName)
{
return $this->addObj($folderName , 'Folder', $parid);
}
@@ -116,7 +151,7 @@ class BasicStor extends Alib {
* @return int
* @exception PEAR::error
*/
- function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
+ public function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
$gunid=NULL, $ftype='unKnown', $mdataLoc='file')
{
$ftype = strtolower($ftype);
@@ -153,9 +188,9 @@ class BasicStor extends Alib {
* @param int $id
* Virtual file's local id
* @param string $newName
- * @return boolean/PEAR_Error
+ * @return boolean|PEAR_Error
*/
- function bsRenameFile($id, $newName)
+ public function bsRenameFile($id, $newName)
{
$parid = $this->getParent($id);
switch ($this->getObjType($id)) {
@@ -189,7 +224,7 @@ class BasicStor extends Alib {
* Destination folder local id
* @return boolean/PEAR_Error
*/
- function bsMoveFile($id, $did)
+ public function bsMoveFile($id, $did)
{
$parid = $this->getParent($id);
if ($this->getObjType($did) !== 'Folder') {
@@ -222,9 +257,9 @@ class BasicStor extends Alib {
* Virtual file's local id
* @param int $did
* Destination folder local id
- * @return boolean/PEAR_Error
+ * @return boolean|PEAR_Error
*/
- function bsCopyFile($id, $did)
+ public function bsCopyFile($id, $did)
{
$parid = $this->getParent($id);
if ($this->getObjType($did) !== 'Folder') {
@@ -261,10 +296,10 @@ class BasicStor extends Alib {
* Local path of metadata file
* @param string $mdataLoc
* 'file'|'string'
- * @return true/PEAR_Error
+ * @return true|PEAR_Error
* @exception PEAR::error
*/
- function bsReplaceFile($id, $mediaFileLP, $mdataFileLP, $mdataLoc='file')
+ public function bsReplaceFile($id, $mediaFileLP, $mdataFileLP, $mdataLoc='file')
{
$ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) {
@@ -294,9 +329,9 @@ class BasicStor extends Alib {
* Virtual file's local id
* @param boolean $forced
* If true don't use trash
- * @return true/PEAR_Error
+ * @return true|PEAR_Error
*/
- function bsDeleteFile($id, $forced=FALSE)
+ public function bsDeleteFile($id, $forced=FALSE)
{
// full delete:
if (!$this->config['useTrash'] || $forced) {
@@ -342,7 +377,7 @@ class BasicStor extends Alib {
* 'put'|'access'|'download'
* @return boolean
*/
- function bsCheckToken($token, $type='put')
+ public function bsCheckToken($token, $type='put')
{
$cnt = $this->dbc->getOne("
SELECT count(token) FROM {$this->accessTable}
@@ -364,21 +399,21 @@ class BasicStor extends Alib {
* 'put'|'access'|'download'
* @return string
*/
- function _gunidFromToken($token, $type='put')
- {
- $acc = $this->dbc->getRow("
- SELECT to_hex(gunid)as gunid, ext FROM {$this->accessTable}
- WHERE token=x'{$token}'::bigint AND type='$type'
- ");
- if ($this->dbc->isError($acc)) {
- return $acc;
- }
- $gunid = StoredFile::_normalizeGunid($acc['gunid']);
- if ($this->dbc->isError($gunid)) {
- return $gunid;
- }
- return $gunid;
- }
+// function _gunidFromToken($token, $type='put')
+// {
+// $acc = $this->dbc->getRow("
+// SELECT to_hex(gunid)as gunid, ext FROM {$this->accessTable}
+// WHERE token=x'{$token}'::bigint AND type='$type'
+// ");
+// if ($this->dbc->isError($acc)) {
+// return $acc;
+// }
+// $gunid = StoredFile::_normalizeGunid($acc['gunid']);
+// if ($this->dbc->isError($gunid)) {
+// return $gunid;
+// }
+// return $gunid;
+// }
/**
@@ -401,7 +436,7 @@ class BasicStor extends Alib {
* @return array
* array with: seekable filehandle, access token
*/
- function bsAccess($realFname, $ext, $gunid, $type='access',
+ public function bsAccess($realFname, $ext, $gunid, $type='access',
$parent='0', $owner=NULL)
{
if (!is_null($gunid)) {
@@ -470,7 +505,7 @@ class BasicStor extends Alib {
* owner: int, local subject id of token owner
* realFname: string, real local pathname of accessed file
*/
- function bsRelease($token, $type='access')
+ public function bsRelease($token, $type='access')
{
if (!$this->bsCheckToken($token, $type)) {
return PEAR::raiseError(
@@ -541,7 +576,7 @@ class BasicStor extends Alib {
* array with strings:
* downloadable URL, download token, chsum, size, filename
*/
- function bsOpenDownload($id, $part='media', $parent='0')
+ public function bsOpenDownload($id, $part='media', $parent='0')
{
$ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) {
@@ -589,7 +624,7 @@ class BasicStor extends Alib {
* @return string
* gunid
*/
- function bsCloseDownload($token, $part='media')
+ public function bsCloseDownload($token, $part='media')
{
if (!$this->bsCheckToken($token, 'download')) {
return PEAR::raiseError(
@@ -620,7 +655,7 @@ class BasicStor extends Alib {
* fname string: writable local filename
* token string: PUT token
*/
- function bsOpenPut($chsum, $gunid, $owner=NULL)
+ public function bsOpenPut($chsum, $gunid, $owner=NULL)
{
if (!is_null($gunid)) {
$gunid = StoredFile::_normalizeGunid($gunid);
@@ -663,7 +698,7 @@ class BasicStor extends Alib {
* fname string, local path of the file having been put
* owner int, local subject id - owner of token
*/
- function bsClosePut($token)
+ public function bsClosePut($token)
{
$token = StoredFile::_normalizeGunid($token);
if (!$this->bsCheckToken($token, 'put')) {
@@ -716,7 +751,7 @@ class BasicStor extends Alib {
* realsum: string - checksum of uploaded file
* )
*/
- function bsCheckPut($token)
+ public function bsCheckPut($token)
{
if (!$this->bsCheckToken($token, 'put')) {
return PEAR::raiseError(
@@ -748,7 +783,7 @@ class BasicStor extends Alib {
* @return string
* URL
*/
- function getUrlPart()
+ public function getUrlPart()
{
$host = $this->config['storageUrlHost'];
$port = $this->config['storageUrlPort'];
@@ -765,17 +800,17 @@ class BasicStor extends Alib {
* @return int
* local subject id
*/
- function getTokenOwner($token)
- {
- $row = $this->dbc->getOne("
- SELECT owner FROM {$this->accessTable}
- WHERE token=x'{$token}'::bigint
- ");
- if ($this->dbc->isError($row)) {
- return $row;
- }
- $owner = $row;
- }
+// function getTokenOwner($token)
+// {
+// $row = $this->dbc->getOne("
+// SELECT owner FROM {$this->accessTable}
+// WHERE token=x'{$token}'::bigint
+// ");
+// if ($this->dbc->isError($row)) {
+// return $row;
+// }
+// $owner = $row;
+// }
/**
@@ -786,7 +821,7 @@ class BasicStor extends Alib {
* @return array
* array of tokens
*/
- function getTokensByType($type)
+ public function getTokensByType($type)
{
$res = $this->dbc->query(
"SELECT TO_HEX(token) AS token FROM {$this->accessTable} WHERE type=?",
@@ -809,9 +844,9 @@ class BasicStor extends Alib {
* Local path of metadata XML file
* @param string $mdataLoc
* 'file'|'string'
- * @return boolean/PEAR_Error
+ * @return boolean|PEAR_Error
*/
- function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
+ public function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
{
$ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) {
@@ -826,9 +861,9 @@ class BasicStor extends Alib {
*
* @param int $id
* Virtual file's local id
- * @return string/PEAR_Error
+ * @return string|PEAR_Error
*/
- function bsGetMetadata($id)
+ public function bsGetMetadata($id)
{
$ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) {
@@ -850,9 +885,9 @@ class BasicStor extends Alib {
* xml:lang value for select language version
* @param string $deflang
* xml:lang for default language
- * @return string/PEAR_Error
+ * @return string|PEAR_Error
*/
- function bsGetTitle($id, $gunid=NULL, $lang=NULL, $deflang=NULL)
+ public function bsGetTitle($id, $gunid=NULL, $lang=NULL, $deflang=NULL)
{
if (is_null($gunid)) {
$ac = StoredFile::recall($this, $id);
@@ -886,7 +921,7 @@ class BasicStor extends Alib {
* array of matching records (as hash {id, value, attrs})
* @see Metadata::getMetadataValue
*/
- function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL)
+ public function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL)
{
$ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) {
@@ -915,7 +950,7 @@ class BasicStor extends Alib {
* flag, if true, regenerate XML file
* @return boolean
*/
- function bsSetMetadataValue($id, $category, $value,
+ public function bsSetMetadataValue($id, $category, $value,
$lang=NULL, $mid=NULL, $container='metadata', $regen=TRUE)
{
$ac = StoredFile::recall($this, $id);
@@ -953,7 +988,7 @@ class BasicStor extends Alib {
* value to normalize
* @return string
*/
- function normalizeExtent($v)
+ private function normalizeExtent($v)
{
if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) {
require_once("Playlist.php");
@@ -981,7 +1016,7 @@ class BasicStor extends Alib {
* flag, if true, regenerate XML file
* @return boolean
*/
- function bsSetMetadataBatch(
+ public function bsSetMetadataBatch(
$id, $values, $lang=NULL, $container='metadata', $regen=TRUE)
{
if (!is_array($values)) {
@@ -1058,13 +1093,13 @@ class BasicStor extends Alib {
* length: string - dcterms:extent in extent format
* @see DataEngine
*/
- function bsLocalSearch($criteria, $limit=0, $offset=0)
+ public function bsLocalSearch($criteria, $limit=0, $offset=0)
{
require_once("DataEngine.php");
- $de =& new DataEngine($this);
- $res = $r = $de->localSearch($criteria, $limit, $offset);
- if (PEAR::isError($r)) {
- return $r;
+ $de = new DataEngine($this);
+ $res = $de->localSearch($criteria, $limit, $offset);
+ if (PEAR::isError($res)) {
+ return $res;
}
return $res;
}
@@ -1087,10 +1122,10 @@ class BasicStor extends Alib {
* cnt : integer - number of matching values
* @see DataEngine
*/
- function bsBrowseCategory($category, $limit=0, $offset=0, $criteria=NULL)
+ public function bsBrowseCategory($category, $limit=0, $offset=0, $criteria=NULL)
{
require_once("DataEngine.php");
- $de =& new DataEngine($this);
+ $de = new DataEngine($this);
return $de->browseCategory($category, $limit, $offset, $criteria);
}
@@ -1112,7 +1147,7 @@ class BasicStor extends Alib {
* fname string: readable fname,
* token string: access token
*/
- function bsExportPlaylistOpen($plids, $type='lspl', $withContent=TRUE)
+ public function bsExportPlaylistOpen($plids, $type='lspl', $withContent=TRUE)
{
require_once("Playlist.php");
if (!is_array($plids)) {
@@ -1120,14 +1155,14 @@ class BasicStor extends Alib {
}
$gunids = array();
foreach ($plids as $plid) {
- $pl = $r = Playlist::recallByGunid($this, $plid);
- if (PEAR::isError($r)) {
- return $r;
+ $pl = Playlist::recallByGunid($this, $plid);
+ if (PEAR::isError($pl)) {
+ return $pl;
}
if ($withContent) {
- $gunidsX = $r = $pl->export();
- if (PEAR::isError($r)) {
- return $r;
+ $gunidsX = $pl->export();
+ if (PEAR::isError($gunidsX)) {
+ return $gunidsX;
}
} else {
$gunidsX = array(array('gunid'=>$plid, 'type'=>'playlist'));
@@ -1148,48 +1183,48 @@ class BasicStor extends Alib {
mkdir($tmpdc);
}
foreach ($gunids as $i => $it) {
- $ac = $r = StoredFile::recallByGunid($this, $it['gunid']);
- if (PEAR::isError($r)) {
- return $r;
+ $ac = StoredFile::recallByGunid($this, $it['gunid']);
+ if (PEAR::isError($ac)) {
+ return $ac;
}
- $MDfname = $r = $ac->md->getFname();
- if (PEAR::isError($r)) {
- return $r;
+ $MDfname = $ac->md->getFname();
+ if (PEAR::isError($MDfname)) {
+ return $MDfname;
}
if (file_exists($MDfname)) {
- switch($it['type']) {
- case "playlist":
- require_once("LsPlaylist.php");
- $ac = $r = LsPlaylist::recallByGunid($this, $it['gunid']);
- switch ($type) {
- case"smil":
- $string = $r = $ac->output2Smil();
- break;
- case"m3u":
- $string = $r = $ac->output2M3U();
- break;
- default:
- $string = $r = $ac->md->genXmlDoc();
- }
- if (PEAR::isError($r)) {
- return $r;
- }
- $r = $this->bsStr2File($string, "$tmpdp/{$it['gunid']}.$plExt");
- if (PEAR::isError($r)) {
- return $r;
- }
- break;
- default:
- copy($MDfname, "$tmpdc/{$it['gunid']}.xml"); break;
+ switch ($it['type']) {
+ case "playlist":
+ require_once("LsPlaylist.php");
+ $ac = $r = LsPlaylist::recallByGunid($this, $it['gunid']);
+ switch ($type) {
+ case"smil":
+ $string = $r = $ac->output2Smil();
+ break;
+ case"m3u":
+ $string = $r = $ac->output2M3U();
+ break;
+ default:
+ $string = $r = $ac->md->genXmlDoc();
+ }
+ if (PEAR::isError($r)) {
+ return $r;
+ }
+ $r = $this->bsStr2File($string, "$tmpdp/{$it['gunid']}.$plExt");
+ if (PEAR::isError($r)) {
+ return $r;
+ }
+ break;
+ default:
+ copy($MDfname, "$tmpdc/{$it['gunid']}.xml"); break;
} // switch
} // if file_exists()
- $RADfname = $r = $ac->_getRealRADFname();
- if (PEAR::isError($r)) {
- return $r;
+ $RADfname = $ac->_getRealRADFname();
+ if (PEAR::isError($RADfname)) {
+ return $RADfname;
}
- $RADext = $r = $ac->_getExt();
- if (PEAR::isError($r)) {
- return $r;
+ $RADext = $ac->_getExt();
+ if (PEAR::isError($RADext)) {
+ return $RADext;
}
if (file_exists($RADfname)) {
copy($RADfname, "$tmpdc/{$it['gunid']}.$RADext");
@@ -1219,7 +1254,7 @@ class BasicStor extends Alib {
* Access token obtained from bsExportPlaylistOpen method call.
* @return true/PEAR_Error
*/
- function bsExportPlaylistClose($token)
+ public function bsExportPlaylistClose($token)
{
$r = $this->bsRelease($token, 'access');
if ($this->dbc->isError($r)) {
@@ -1257,11 +1292,11 @@ class BasicStor extends Alib {
* @return int
* Result file local id (or error object)
*/
- function bsImportPlaylistRaw($parid, $plid, $aPath, $rPath, $ext, &$gunids, $subjid)
+ public function bsImportPlaylistRaw($parid, $plid, $aPath, $rPath, $ext, &$gunids, $subjid)
{
- $id = $r = $this->_idFromGunid($plid);
- if (!is_null($r)) {
- return $r;
+ $id = $this->_idFromGunid($plid);
+ if (!is_null($id)) {
+ return $id;
}
$path = realpath("$aPath/$rPath");
if (FALSE === $path) {
@@ -1319,7 +1354,7 @@ class BasicStor extends Alib {
* @return int
* Result file local id (or error object)
*/
- function bsImportPlaylist($parid, $fpath, $subjid)
+ public function bsImportPlaylist($parid, $fpath, $subjid)
{
// untar:
$tmpn = tempnam($this->bufferDir, 'plImport_');
@@ -1407,7 +1442,7 @@ class BasicStor extends Alib {
* Local ID of folder
* @return array
*/
- function bsListFolder($id)
+ public function bsListFolder($id)
{
if ($this->getObjType($id) !== 'Folder') {
return PEAR::raiseError(
@@ -1450,7 +1485,7 @@ class BasicStor extends Alib {
* Virtual file's local id
* @return array
*/
- function bsAnalyzeFile($id)
+ public function bsAnalyzeFile($id)
{
$ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) {
@@ -1470,7 +1505,7 @@ class BasicStor extends Alib {
* Relative path
* @return array
*/
- function getObjIdFromRelPath($id, $relPath='.')
+ public function getObjIdFromRelPath($id, $relPath='.')
{
$relPath = trim(urldecode($relPath));
//if($this->getObjType($id) !== 'Folder')
@@ -1530,7 +1565,7 @@ class BasicStor extends Alib {
* select file by gunid (id is then ignored)
* @return boolean
*/
- function bsExistsFile($id, $ftype=NULL, $byGunid=FALSE)
+ public function bsExistsFile($id, $ftype=NULL, $byGunid=FALSE)
{
if ($byGunid) {
$ac = StoredFile::recallByGunid($this, $id);
@@ -1567,9 +1602,9 @@ class BasicStor extends Alib {
*
* @param int $oid
* Local object id
- * @return string/err
+ * @return string|PEAR_Error
*/
- function getObjType($oid)
+ public function getObjType($oid)
{
$type = parent::getObjType($oid);
if ($type == 'File') {
@@ -1595,9 +1630,9 @@ class BasicStor extends Alib {
* @param string $login
* @param string $pass
* @param string $realname
- * @return int/err
+ * @return int|PEAR_Error
*/
- function addSubj($login, $pass=NULL, $realname='')
+ public function addSubj($login, $pass=NULL, $realname='')
{
$uid = parent::addSubj($login, $pass, $realname);
if ($this->dbc->isError($uid)) {
@@ -1647,9 +1682,9 @@ class BasicStor extends Alib {
* Remove user by login and remove also his home folder
*
* @param string $login
- * @return boolean/err
+ * @return boolean|PEAR_Error
*/
- function removeSubj($login)
+ public function removeSubj($login)
{
if (FALSE !== array_search($login, $this->config['sysSubjs'])) {
return $this->dbc->raiseError(
@@ -1689,20 +1724,17 @@ class BasicStor extends Alib {
*
* @param string $login
* @param string $pass
- * @return boolean/sessionId/err
+ * @return boolean|sessionId|PEAR_Error
*/
- function login($login, $pass)
- {
- $r = $this->upgradeDbStructure();
- if ($this->dbc->isError($r)) {
- return $r;
- }
- $r = parent::login($login, $pass);
- if ($this->dbc->isError($r)) {
- return $r;
- }
- return $r;
- }
+// function login($login, $pass)
+// {
+// $r = $this->upgradeDbStructure();
+// if ($this->dbc->isError($r)) {
+// return $r;
+// }
+// $r = parent::login($login, $pass);
+// return $r;
+// }
/* ================================================== "protected" methods */
@@ -1717,7 +1749,7 @@ class BasicStor extends Alib {
* Session id
* @return true/PEAR::error
*/
- function _authorize($acts, $pars, $sessid='')
+ public function _authorize($acts, $pars, $sessid='')
{
$userid = $this->getSessUserId($sessid);
if ($this->dbc->isError($userid)) {
@@ -1758,7 +1790,7 @@ class BasicStor extends Alib {
* @return unknown
* local folder id
*/
- function _getHomeDirId($subjid)
+ public function _getHomeDirId($subjid)
{
$login = $this->getSubjName($subjid);
if ($this->dbc->isError($login)) {
@@ -1784,7 +1816,7 @@ class BasicStor extends Alib {
* @return unknown
* local folder id
*/
- function _getHomeDirIdFromSess($sessid)
+ public function _getHomeDirIdFromSess($sessid)
{
$uid = $this->getSessUserId($sessid);
if ($this->dbc->isError($uid)) {
@@ -1802,7 +1834,7 @@ class BasicStor extends Alib {
* @return int
* Local id
*/
- function _idFromGunid($gunid)
+ public function _idFromGunid($gunid)
{
return $this->dbc->getOne(
"SELECT id FROM {$this->filesTable} WHERE gunid=x'$gunid'::bigint"
@@ -1818,7 +1850,7 @@ class BasicStor extends Alib {
* @return string
* Global id
*/
- function _gunidFromId($id)
+ public function _gunidFromId($id)
{
if (!is_numeric($id)) {
return NULL;
@@ -1845,7 +1877,7 @@ class BasicStor extends Alib {
* @return string
* see install()
*/
- function _getType($gunid)
+ public function _getType($gunid)
{
$ftype = $this->dbc->getOne("
SELECT ftype FROM {$this->filesTable}
@@ -1862,7 +1894,7 @@ class BasicStor extends Alib {
* Global unique ID
* @return boolean
*/
- function _checkGunid($gunid)
+ protected function _checkGunid($gunid)
{
$res = preg_match("|^([0-9a-fA-F]{16})?$|", $gunid);
return $res;
@@ -1871,22 +1903,22 @@ class BasicStor extends Alib {
/**
* Returns TRUE if gunid is free
- * @return boolean/err
+ * @return boolean|PEAR_Error
*/
- function _gunidIsFree($gunid)
- {
- $cnt = $this->dbc->getOne("
- SELECT count(*) FROM {$this->filesTable}
- WHERE gunid=x'{$this->gunid}'::bigint
- ");
- if ($this->dbc->isError($cnt)) {
- return $cnt;
- }
- if ($cnt > 0) {
- return FALSE;
- }
- return TRUE;
- }
+// function _gunidIsFree($gunid)
+// {
+// $cnt = $this->dbc->getOne("
+// SELECT count(*) FROM {$this->filesTable}
+// WHERE gunid=x'{$this->gunid}'::bigint
+// ");
+// if ($this->dbc->isError($cnt)) {
+// return $cnt;
+// }
+// if ($cnt > 0) {
+// return FALSE;
+// }
+// return TRUE;
+// }
/**
@@ -1903,7 +1935,7 @@ class BasicStor extends Alib {
* @return boolean
* previous state
*/
- function _setEditFlag($playlistId, $val=TRUE, $sessid=NULL, $subjid=NULL)
+ public function _setEditFlag($playlistId, $val=TRUE, $sessid=NULL, $subjid=NULL)
{
if (!is_null($sessid)) {
$subjid = $this->getSessUserId($sessid);
@@ -1933,10 +1965,10 @@ class BasicStor extends Alib {
*
* @param string $playlistId
* Playlist global unique ID
- * @return FALSE/int
+ * @return FALSE|int
* ID of user editing it
*/
- function _isEdited($playlistId)
+ public function _isEdited($playlistId)
{
$ac = StoredFile::recallByGunid($this, $playlistId);
if ($this->dbc->isError($ac)) {
@@ -1957,7 +1989,7 @@ class BasicStor extends Alib {
* @return int
* New object local id
*/
- function copyObj($id, $newParid, $after=NULL)
+ protected function copyObj($id, $newParid, $after=NULL)
{
$parid = $this->getParent($id);
$nid = parent::copyObj($id, $newParid, $after);
@@ -1988,7 +2020,7 @@ class BasicStor extends Alib {
*
* @return boolean
*/
- function moveObj($id, $newParid, $after=NULL)
+ public function moveObj($id, $newParid, $after=NULL)
{
$parid = $this->getParent($id);
switch ($this->getObjType($id)) {
@@ -2025,7 +2057,7 @@ class BasicStor extends Alib {
* @return unknown
* ID
*/
- function addObj($name, $type, $parid=1, $aftid=NULL, $param='')
+ public function addObj($name, $type, $parid=1, $aftid=NULL, $param='')
{
$exid = $this->getObjId($name, $parid);
if ($this->dbc->isError($exid)) {
@@ -2053,9 +2085,9 @@ class BasicStor extends Alib {
* Local id of removed object
* @param boolean $forced
* Unconditional delete
- * @return true/PEAR::error
+ * @return true|PEAR_Error
*/
- function removeObj($id, $forced=FALSE)
+ public function removeObj($id, $forced=FALSE)
{
switch ($ot = $this->getObjType($id)) {
case "audioclip":
@@ -2102,9 +2134,9 @@ class BasicStor extends Alib {
* string to be written to file
* @param string $fname
* pathname to file
- * @return TRUE/raiseError
+ * @return TRUE|raiseError
*/
- function bsStr2File($str, $fname)
+ private function bsStr2File($str, $fname)
{
$fp = @fopen($fname, "w");
if ($fp === FALSE) {
@@ -2131,36 +2163,38 @@ class BasicStor extends Alib {
*
* @return TRUE/error
*/
- function upgradeDbStructure()
- {
- $chDb = array(
- '1.1 Leon' => array(
- array('tbl'=>$this->accessTable, 'fld'=>'owner',
- 'type'=>"int REFERENCES {$this->subjTable}"
- ),
- ),
- '1.1 Freetown' => array(
- array('tbl'=>$this->filesTable, 'fld'=>'mtime',
- 'type'=>'timestamp(6) with time zone'
- ),
- ),
- );
- foreach ($chDb as $version => $chArr) {
- foreach ($chArr as $change) {
- extract($change); // tbl, op, fld, type
- $r = $this->dbc->tableInfo($tbl, DB_TABLEINFO_ORDERTABLE);
- if ($this->dbc->isError($r)) {
- return $r;
- }
- if (!isset($r['ordertable'][$tbl][$fld])) {
- $q = "ALTER table $tbl ADD $fld $type";
- $r = $this->dbc->query($q);
- if($this->dbc->isError($r)) return $r;
- }
- }
- }
- return TRUE;
- }
+// function upgradeDbStructure()
+// {
+// $chDb = array(
+// '1.1 Leon' => array(
+// array('tbl'=>$this->accessTable, 'fld'=>'owner',
+// 'type'=>"int REFERENCES {$this->subjTable}"
+// ),
+// ),
+// '1.1 Freetown' => array(
+// array('tbl'=>$this->filesTable, 'fld'=>'mtime',
+// 'type'=>'timestamp(6) with time zone'
+// ),
+// ),
+// );
+// foreach ($chDb as $version => $chArr) {
+// foreach ($chArr as $change) {
+// extract($change); // tbl, op, fld, type
+// $r = $this->dbc->tableInfo($tbl, DB_TABLEINFO_ORDERTABLE);
+// if ($this->dbc->isError($r)) {
+// return $r;
+// }
+// if (!isset($r['ordertable'][$tbl][$fld])) {
+// $q = "ALTER table $tbl ADD $fld $type";
+// $r = $this->dbc->query($q);
+// if ($this->dbc->isError($r)) {
+// return $r;
+// }
+// }
+// }
+// }
+// return TRUE;
+// }
/* =============================================== test and debug methods */
@@ -2183,7 +2217,7 @@ class BasicStor extends Alib {
* source: string - dc:source from metadata
* length: string - dcterms:extent in extent format
*/
- function resetStorage($loadSampleData=TRUE, $filesOnly=FALSE)
+ public function resetStorage($loadSampleData=TRUE, $filesOnly=FALSE)
{
if ($filesOnly) {
$this->deleteFiles();
@@ -2191,7 +2225,7 @@ class BasicStor extends Alib {
$this->deleteData();
}
if (!$this->config['isArchive']) {
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$tr->resetData();
}
$res = array(
@@ -2248,7 +2282,7 @@ class BasicStor extends Alib {
* dump
*
*/
- function dump($id='', $indch=' ', $ind='', $format='{name}')
+ public function dump($id='', $indch=' ', $ind='', $format='{name}')
{
if ($id=='') {
$id = $this->storId;
@@ -2261,7 +2295,7 @@ class BasicStor extends Alib {
*
*
*/
- function dumpDir($id='', $format='$o["name"]')
+ public function dumpDir($id='', $format='$o["name"]')
{
if ($id == '') {
$id = $this->storId;
@@ -2276,7 +2310,7 @@ class BasicStor extends Alib {
*
*
*/
- function debug($va)
+ public function debug($va)
{
echo"\n"; print_r($va);
}
@@ -2287,11 +2321,11 @@ class BasicStor extends Alib {
*
* @return void
*/
- function deleteFiles()
+ private function deleteFiles()
{
$ids = $this->dbc->getAll("SELECT id FROM {$this->filesTable}");
if (is_array($ids)) {
- foreach($ids as $i=>$item){
+ foreach($ids as $i => $item) {
$this->bsDeleteFile($item['id'], TRUE);
}
}
@@ -2303,7 +2337,7 @@ class BasicStor extends Alib {
*
* @return void
*/
- function deleteData()
+ public function deleteData()
{
$this->deleteFiles();
parent::deleteData();
@@ -2316,47 +2350,47 @@ class BasicStor extends Alib {
* to prevent data changes in tests
*
*/
- function createTestSpace(&$dbc, $config){
- $configBckp = $config;
- $config['tblNamePrefix'] .= '_test_';
- mkdir($config['storageDir'].'/tmp');
- $config['storageDir'] .= '/tmp/stor';
- $config['bufferDir'] = $config['storageDir'].'/buffer';
- $config['transDir'] .= '/tmp/trans';
- $config['accessDir'] .= '/tmp/access';
- mkdir($config['storageDir']);
- mkdir($config['bufferDir']);
- $bs =& new BasicStor($dbc, $config);
- $bs->configBckp = $configBckp;
- $r = $bs->install();
- if (PEAR::isError($r)) {
- return $r;
- }
- return $bs;
- }
+// function createTestSpace(&$dbc, $config){
+// $configBckp = $config;
+// $config['tblNamePrefix'] .= '_test_';
+// mkdir($config['storageDir'].'/tmp');
+// $config['storageDir'] .= '/tmp/stor';
+// $config['bufferDir'] = $config['storageDir'].'/buffer';
+// $config['transDir'] .= '/tmp/trans';
+// $config['accessDir'] .= '/tmp/access';
+// mkdir($config['storageDir']);
+// mkdir($config['bufferDir']);
+// $bs = new BasicStor($dbc, $config);
+// $bs->configBckp = $configBckp;
+// $r = $bs->install();
+// if (PEAR::isError($r)) {
+// return $r;
+// }
+// return $bs;
+// }
/**
* Clean up test space
*
*/
- function releaseTestSpace(){
- $r = $this->uninstall();
- if (PEAR::isError($r)) {
- return $r;
- }
- // rmdir($this->config['bufferDir']);
- rmdir($this->config['storageDir']);
- $this->config = $this->configBckp;
- rmdir($this->config['storageDir'].'/tmp');
- }
+// function releaseTestSpace() {
+// $r = $this->uninstall();
+// if (PEAR::isError($r)) {
+// return $r;
+// }
+// // rmdir($this->config['bufferDir']);
+// rmdir($this->config['storageDir']);
+// $this->config = $this->configBckp;
+// rmdir($this->config['storageDir'].'/tmp');
+// }
/**
* testData
*
*/
- function testData($d='')
+ public function testData($d='')
{
$exdir = dirname(__FILE__).'/tests';
$o[] = $this->addSubj('test1', 'a');
@@ -2384,7 +2418,7 @@ class BasicStor extends Alib {
* test
*
*/
- function test()
+ public function test()
{
$this->test_log = '';
// if($this->dbc->isError($p = parent::test())) return $p;
@@ -2450,7 +2484,7 @@ class BasicStor extends Alib {
* initData - initialize
*
*/
- function initData()
+ private function initData()
{
$this->rootId = $this->getRootNode();
$this->storId = $this->wd =
@@ -2526,7 +2560,7 @@ class BasicStor extends Alib {
*
download
*
*/
- function install()
+ public function install()
{
parent::install();
$r = $this->dbc->query("CREATE TABLE {$this->filesTable} (
@@ -2622,7 +2656,7 @@ class BasicStor extends Alib {
*
* @return void
*/
- function uninstall()
+ public function uninstall()
{
$this->dbc->query("DROP TABLE {$this->mdataTable}");
$this->dbc->dropSequence("{$this->mdataTable}_id_seq");
@@ -2665,9 +2699,9 @@ class BasicStor extends Alib {
*
* @param string $msg - log message
*/
- function debugLog($msg)
+ public function debugLog($msg)
{
- $fp=fopen("{$this->storageDir}/log", "a") or die("Can't write to log\n");
+ $fp = fopen("{$this->storageDir}/log", "a") or die("Can't write to log\n");
fputs($fp, date("H:i:s").">$msg<\n");
fclose($fp);
}
diff --git a/campcaster/src/modules/storageServer/var/DataEngine.php b/campcaster/src/modules/storageServer/var/DataEngine.php
index 9e482af1a..d7ffd2beb 100644
--- a/campcaster/src/modules/storageServer/var/DataEngine.php
+++ b/campcaster/src/modules/storageServer/var/DataEngine.php
@@ -42,10 +42,14 @@ require_once "XML/Util.php";
* cnt : integer - number of matching items
*
*
- * @Author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see MetaData
* @see StoredFile
*/
@@ -56,7 +60,7 @@ class DataEngine {
*
* @param BasicStor $gb
*/
- function DataEngine(&$gb)
+ public function __construct(&$gb)
{
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
diff --git a/campcaster/src/modules/storageServer/var/GreenBox.php b/campcaster/src/modules/storageServer/var/GreenBox.php
index 1b262fe26..e955c848f 100644
--- a/campcaster/src/modules/storageServer/var/GreenBox.php
+++ b/campcaster/src/modules/storageServer/var/GreenBox.php
@@ -1,16 +1,19 @@
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
- * @see BasicStor
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class GreenBox extends BasicStor {
@@ -27,9 +30,9 @@ class GreenBox extends BasicStor {
* Session id
* @return int
* ID of new folder
- * @exception PEAR::error
+ * @exception PEAR::error
*/
- function createFolder($parid, $folderName, $sessid='')
+ public function createFolder($parid, $folderName, $sessid='')
{
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
return $res;
@@ -55,9 +58,9 @@ class GreenBox extends BasicStor {
* @param string $ftype
* Internal file type
* @return int
- * @exception PEAR::error
+ * @exception PEAR::error
*/
- function putFile($parid, $fileName,
+ public function putFile($parid, $fileName,
$mediaFileLP, $mdataFileLP, $sessid='',
$gunid=NULL, $ftype='audioclip')
{
@@ -88,7 +91,7 @@ class GreenBox extends BasicStor {
* @return int
* @exception PEAR::error
*/
- function storeWebstream($parid, $fileName, $mdataFileLP, $sessid='',
+ public function storeWebstream($parid, $fileName, $mdataFileLP, $sessid='',
$gunid=NULL, $url)
{
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
@@ -121,19 +124,19 @@ class GreenBox extends BasicStor {
* session id
* @return string access token
*/
- function accessFile($id, $sessid='')
- {
- if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
- return $res;
- }
- $gunid = $this->_gunidFromId($id);
- $r = $this->bsAccess(NULL, '', $gunid, 'access');
- if (PEAR::isError($r)) {
- return $r;
- }
- $token = $r['token'];
- return $token;
- } // fn accessFile
+// function accessFile($id, $sessid='')
+// {
+// if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
+// return $res;
+// }
+// $gunid = $this->_gunidFromId($id);
+// $r = $this->bsAccess(NULL, '', $gunid, 'access');
+// if (PEAR::isError($r)) {
+// return $r;
+// }
+// $token = $r['token'];
+// return $token;
+// } // fn accessFile
/**
@@ -145,14 +148,14 @@ class GreenBox extends BasicStor {
* session id
* @return boolean
*/
- function releaseFile($token, $sessid='')
- {
- $r = $this->bsRelease($token, 'access');
- if (PEAR::isError($r)) {
- return $r;
- }
- return FALSE;
- } // fn releaseFile
+// function releaseFile($token, $sessid='')
+// {
+// $r = $this->bsRelease($token, 'access');
+// if (PEAR::isError($r)) {
+// return $r;
+// }
+// return FALSE;
+// } // fn releaseFile
/**
@@ -164,7 +167,7 @@ class GreenBox extends BasicStor {
* Session id
* @return array
*/
- function analyzeFile($id, $sessid='')
+ public function analyzeFile($id, $sessid='')
{
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
return $res;
@@ -181,9 +184,9 @@ class GreenBox extends BasicStor {
* @param string $newName
* @param string $sessid
* Session id
- * @return boolean or PEAR::error
+ * @return boolean|PEAR_Error
*/
- function renameFile($id, $newName, $sessid='')
+ public function renameFile($id, $newName, $sessid='')
{
$parid = $this->getParent($id);
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
@@ -202,9 +205,9 @@ class GreenBox extends BasicStor {
* destination folder local id
* @param string $sessid
* session id
- * @return boolean or PEAR::error
+ * @return boolean|PEAR_Error
*/
- function moveFile($id, $did, $sessid='')
+ public function moveFile($id, $did, $sessid='')
{
$res = $this->_authorize(array('read', 'write'), array($id, $did), $sessid);
if ($res !== TRUE) {
@@ -223,9 +226,9 @@ class GreenBox extends BasicStor {
* destination folder local id
* @param string $sessid
* session id
- * @return boolean or PEAR::error
+ * @return boolean|PEAR_Error
*/
- function copyFile($id, $did, $sessid='')
+ public function copyFile($id, $did, $sessid='')
{
$res = $this->_authorize(array('read', 'write'), array($id, $did), $sessid);
if($res !== TRUE) {
@@ -246,9 +249,9 @@ class GreenBox extends BasicStor {
* local path of metadata file
* @param string $sessid
* session id
- * @return true or PEAR::error
+ * @return TRUE|PEAR_Error
*/
- function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='')
+ public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='')
{
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
return $res;
@@ -265,9 +268,9 @@ class GreenBox extends BasicStor {
* @param int $sessid
* @param boolean $forced
* if true don't use trash
- * @return true or PEAR::error
+ * @return true|PEAR_Error
*/
- function deleteFile($id, $sessid='', $forced=FALSE)
+ public function deleteFile($id, $sessid='', $forced=FALSE)
{
$parid = $this->getParent($id);
if (($res = $this->_authorize('write', $parid, $sessid)) !== TRUE) {
@@ -283,16 +286,16 @@ class GreenBox extends BasicStor {
* Replace metadata with new XML file or string
*
* @param int $id
- * virt.file's local id
+ * Virtual file's local id
* @param string $mdata
* XML string or local path of metadata XML file
* @param string $mdataLoc
* metadata location: 'file'|'string'
* @param string $sessid
* session id
- * @return boolean or PEAR::error
+ * @return boolean|PEAR_Error
*/
- function replaceMetadata($id, $mdata, $mdataLoc='file', $sessid='')
+ public function replaceMetadata($id, $mdata, $mdataLoc='file', $sessid='')
{
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
return $res;
@@ -305,12 +308,13 @@ class GreenBox extends BasicStor {
* Get metadata XML tree as string
*
* @param int $id
- * virt.file's local id
+ * Virtual file's local id
* @param string $sessid
* session id
- * @return string or PEAR::error
+ * @return string|PEAR_Error
+ * @todo rename this function to "getMetadata"
*/
- function getMdata($id, $sessid='')
+ public function getMdata($id, $sessid='')
{
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
return $res;
@@ -331,8 +335,9 @@ class GreenBox extends BasicStor {
* @param string $sessid
* session ID
* @return array
+ * @todo rename this function to "getMdataArray"
*/
- function getMdataArray($id, $sessid)
+ public function getMdataArray($id, $sessid)
{
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
return $res;
@@ -372,7 +377,7 @@ class GreenBox extends BasicStor {
* Get metadata element value
*
* @param int $id
- * virt.file's local id
+ * Virtual file's local id
* @param string $category
* metadata element name
* @param string $sessid
@@ -388,8 +393,9 @@ class GreenBox extends BasicStor {
* attrs hasharray of element's attributes indexed by
* qualified name (e.g. xml:lang)
*
+ * @todo rename this function to "getMetadataValue"
*/
- function getMdataValue($id, $category, $sessid='',
+ public function getMdataValue($id, $category, $sessid='',
$lang=NULL, $deflang=NULL)
{
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
@@ -415,8 +421,9 @@ class GreenBox extends BasicStor {
* @param int $mid
* (optional on unique elements) Metadata record id
* @return boolean
+ * @todo rename this function to "setMetadataValue"
*/
- function setMdataValue($id, $category, $sessid, $value, $lang=NULL, $mid=NULL)
+ public function setMdataValue($id, $category, $sessid, $value, $lang=NULL, $mid=NULL)
{
if (($res = $this->_authorize('write', $id, $sessid)) !== TRUE) {
return $res;
@@ -478,7 +485,7 @@ class GreenBox extends BasicStor {
*
* @see BasicStor::bsLocalSearch
*/
- function localSearch($criteria, $sessid='')
+ public function localSearch($criteria, $sessid='')
{
$limit = intval(isset($criteria['limit']) ? $criteria['limit'] : 0);
$offset = intval(isset($criteria['offset']) ? $criteria['offset'] : 0);
@@ -498,9 +505,9 @@ class GreenBox extends BasicStor {
* @return array, fields:
* results : array with found values
* cnt : integer - number of matching values
- * @see BasicStor::bsBrowseCategory
+ * @see BasicStor::bsBrowseCategory
*/
- function browseCategory($category, $criteria, $sessid = '')
+ public function browseCategory($category, $criteria, $sessid = '')
{
$limit = 0;
$offset = 0;
@@ -523,13 +530,14 @@ class GreenBox extends BasicStor {
* human readable menmonic file name
* @param string $sessid
* session ID
- * @return int, local id of created playlist
+ * @return int
+ * local id of created playlist
*/
- function createPlaylist($parid, $fname, $sessid='')
+ public function createPlaylist($parid, $fname, $sessid='')
{
$gunid = StoredFile::_createGunid();
require_once"LocStor.php";
- $lc =& new LocStor($this->dbc, $this->config);
+ $lc = new LocStor($this->dbc, $this->config);
$gunid2 = $lc->createPlaylist($sessid, $gunid, $fname);
if (PEAR::isError($gunid2)) {
return $gunid2;
@@ -562,12 +570,13 @@ class GreenBox extends BasicStor {
* local object id
* @param string $sessid
* session ID
- * @return string, XML
+ * @return string
+ * XML
*/
- function getPlaylistXml($id, $sessid)
- {
- return $this->getMdata($id, $sessid);
- } // fn getPlaylistXml
+// function getPlaylistXml($id, $sessid)
+// {
+// return $this->getMdata($id, $sessid);
+// } // fn getPlaylistXml
/**
@@ -579,7 +588,7 @@ class GreenBox extends BasicStor {
* session ID
* @return array
*/
- function getPlaylistArray($id, $sessid)
+ public function getPlaylistArray($id, $sessid)
{
$gunid = $this->_gunidFromId($id);
$pl = StoredFile::recall($this, $id);
@@ -598,13 +607,14 @@ class GreenBox extends BasicStor {
* local object id
* @param string $sessid
* session ID
- * @return string, playlist access token
+ * @return string
+ * playlist access token
*/
- function lockPlaylistForEdit($id, $sessid)
+ public function lockPlaylistForEdit($id, $sessid)
{
$gunid = $this->_gunidFromId($id);
- require_once"LocStor.php";
- $lc =& new LocStor($this->dbc, $this->config);
+ require_once("LocStor.php");
+ $lc = new LocStor($this->dbc, $this->config);
$res = $lc->editPlaylist($sessid, $gunid);
if (PEAR::isError($res)) {
return $res;
@@ -622,7 +632,7 @@ class GreenBox extends BasicStor {
* session ID
* @return string gunid
*/
- function releaseLockedPlaylist($token, $sessid)
+ public function releaseLockedPlaylist($token, $sessid)
{
$gunid = $this->bsCloseDownload($token, 'metadata');
if (PEAR::isError($gunid)) {
@@ -661,7 +671,7 @@ class GreenBox extends BasicStor {
* pause between half-faded points in time format hh:mm:ss.ssssss
* @return string, generated playlistElement gunid
*/
- function addAudioClipToPlaylist($token, $acId, $sessid,
+ public function addAudioClipToPlaylist($token, $acId, $sessid,
$fadeIn=NULL, $fadeOut=NULL, $length=NULL, $pause=NULL)
{
require_once"Playlist.php";
@@ -701,10 +711,11 @@ class GreenBox extends BasicStor {
* @param string $sessid
* session ID
* @return boolean
+ * @todo rename this function to "deleteAudioClipFromPlaylist"
*/
- function delAudioClipFromPlaylist($token, $plElGunid, $sessid)
+ public function delAudioClipFromPlaylist($token, $plElGunid, $sessid)
{
- require_once "Playlist.php";
+ require_once("Playlist.php");
$pl = Playlist::recallByToken($this, $token);
if (PEAR::isError($pl)) {
return $pl;
@@ -737,9 +748,9 @@ class GreenBox extends BasicStor {
* session ID
* @return boolean
*/
- function changeFadeInfo($token, $plElGunid, $fadeIn, $fadeOut, $sessid)
+ public function changeFadeInfo($token, $plElGunid, $fadeIn, $fadeOut, $sessid)
{
- require_once "Playlist.php";
+ require_once("Playlist.php");
$pl = Playlist::recallByToken($this, $token);
if (PEAR::isError($pl)) {
return $pl;
@@ -773,9 +784,9 @@ class GreenBox extends BasicStor {
* session ID
* @return boolean
*/
- function moveAudioClipInPlaylist($token, $plElGunid, $newPos, $sessid)
+ public function moveAudioClipInPlaylist($token, $plElGunid, $newPos, $sessid)
{
- require_once "Playlist.php";
+ require_once("Playlist.php");
$pl = Playlist::recallByToken($this, $token);
if (PEAR::isError($pl)) {
return $pl;
@@ -800,12 +811,13 @@ class GreenBox extends BasicStor {
* playlist access token
* @param string $sessid
* session ID
- * @return string gunid of playlist
+ * @return string
+ * gunid of playlist
*/
- function revertEditedPlaylist($token, $sessid='')
+ public function revertEditedPlaylist($token, $sessid='')
{
- require_once "LocStor.php";
- $lc =& new LocStor($this->dbc, $this->config);
+ require_once("LocStor.php");
+ $lc = new LocStor($this->dbc, $this->config);
return $lc->revertEditedPlaylist($token, $sessid);
} // fn revertEditedPlaylist
@@ -819,11 +831,11 @@ class GreenBox extends BasicStor {
* session ID
* @return boolean
*/
- function deletePlaylist($id, $sessid)
+ public function deletePlaylist($id, $sessid)
{
$gunid = $this->_gunidFromId($id);
- require_once "LocStor.php";
- $lc =& new LocStor($this->dbc, $this->config);
+ require_once("LocStor.php");
+ $lc = new LocStor($this->dbc, $this->config);
return $lc->deletePlaylist($sessid, $gunid);
} // fn deletePlaylist
@@ -851,7 +863,7 @@ class GreenBox extends BasicStor {
* duration string, total playlength of clip
*
*/
- function displayPlaylistClipAtOffset($sessid, $plid, $offset, $distance=0,
+ public function displayPlaylistClipAtOffset($sessid, $plid, $offset, $distance=0,
$lang=NULL, $deflang=NULL)
{
require_once "Playlist.php";
@@ -899,7 +911,7 @@ class GreenBox extends BasicStor {
* fname string: readable fname,
* token string: access token
*/
- function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE)
+ public function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE)
{
return $this->bsExportPlaylistOpen($plids, $type, $standalone);
} // fn exportPlaylistOpen
@@ -911,9 +923,9 @@ class GreenBox extends BasicStor {
* @param string $token
* access token obtained from exportPlaylistOpen
* method call
- * @return boolean true or error object
+ * @return TRUE|PEAR_Error
*/
- function exportPlaylistClose($token)
+ public function exportPlaylistClose($token)
{
return $this->bsExportPlaylistClose($token);
} // fn exportPlaylistClose
@@ -930,11 +942,11 @@ class GreenBox extends BasicStor {
* fname string: writable local filename
* token string: put token
*/
- function importPlaylistOpen($sessid, $chsum='')
+ public function importPlaylistOpen($sessid, $chsum='')
{
- $userid = $r =$this->getSessUserId($sessid);
- if ($this->dbc->isError($r)) {
- return $r;
+ $userid = $this->getSessUserId($sessid);
+ if ($this->dbc->isError($userid)) {
+ return $userid;
}
$r = $this->bsOpenPut($chsum, NULL, $userid);
if (PEAR::isError($r)) {
@@ -949,30 +961,28 @@ class GreenBox extends BasicStor {
*
* @param string $token
* import token obtained by importPlaylistOpen method
- * @return int, result file local id (or error object)
+ * @return int
+ * result file local id (or error object)
*/
- function importPlaylistClose($token)
+ public function importPlaylistClose($token)
{
- $arr = $r = $this->bsClosePut($token);
- if (PEAR::isError($r)) {
- return $r;
+ $arr = $this->bsClosePut($token);
+ if (PEAR::isError($arr)) {
+ return $arr;
}
$fname = $arr['fname'];
$owner = $arr['owner'];
- $parid = $r= $this->_getHomeDirId($owner);
- if (PEAR::isError($r)) {
+ $parid = $this->_getHomeDirId($owner);
+ if (PEAR::isError($parid)) {
if (file_exists($fname)) {
@unlink($fname);
}
- return $r;
+ return $parid;
}
- $res = $r = $this->bsImportPlaylist($parid, $fname, $owner);
+ $res = $this->bsImportPlaylist($parid, $fname, $owner);
if (file_exists($fname)) {
@unlink($fname);
}
- if (PEAR::isError($r)) {
- return $r;
- }
return $res;
} // fn importPlaylistClose
@@ -986,11 +996,11 @@ class GreenBox extends BasicStor {
* session ID
* @return boolean
*/
- function existsPlaylist($id, $sessid)
+ public function existsPlaylist($id, $sessid)
{
$gunid = $this->_gunidFromId($id);
- require_once"LocStor.php";
- $lc =& new LocStor($this->dbc, $this->config);
+ require_once("LocStor.php");
+ $lc = new LocStor($this->dbc, $this->config);
return $lc->existsPlaylist($sessid, $gunid);
} // fn existsPlaylist
@@ -1007,11 +1017,11 @@ class GreenBox extends BasicStor {
* @return TRUE|int
* id of user editing it
*/
- function playlistIsAvailable($id, $sessid)
+ public function playlistIsAvailable($id, $sessid)
{
$gunid = $this->_gunidFromId($id);
- require_once"LocStor.php";
- $lc =& new LocStor($this->dbc, $this->config);
+ require_once("LocStor.php");
+ $lc = new LocStor($this->dbc, $this->config);
return $lc->playlistIsAvailable($sessid, $gunid, TRUE);
} // fn playlistIsAvailable
@@ -1022,11 +1032,12 @@ class GreenBox extends BasicStor {
*
* @param string $plt
* playlist time value (HH:mm:ss.dddddd)
- * @return int, seconds
+ * @return int
+ * seconds
*/
- function _plTimeToSecs($plt)
+ public function _plTimeToSecs($plt)
{
- require_once"Playlist.php";
+ require_once("Playlist.php");
return Playlist::_plTimeToSecs($plt);
} // fn _plTimeToSecs
@@ -1036,11 +1047,12 @@ class GreenBox extends BasicStor {
*
* @param int $s0
* seconds
- * @return string, time in playlist time format (HH:mm:ss.dddddd)
+ * @return string
+ * time in playlist time format (HH:mm:ss.dddddd)
*/
function _secsToPlTime($s0)
{
- require_once"Playlist.php";
+ require_once("Playlist.php");
return Playlist::_secsToPlTime($s0);
} // fn _secsToPlTime
@@ -1056,9 +1068,9 @@ class GreenBox extends BasicStor {
* @return string $token
* render token
*/
- function renderPlaylistToFileOpen($sessid, $plid)
+ public function renderPlaylistToFileOpen($sessid, $plid)
{
- require_once "Renderer.php";
+ require_once("Renderer.php");
$r = Renderer::rnRender2FileOpen($this, $plid);
if (PEAR::isError($r)) {
return $r;
@@ -1076,9 +1088,9 @@ class GreenBox extends BasicStor {
* status : string - susccess | working | fault
* tmpfile : string - filepath to result temporary file
*/
- function renderPlaylistToFileCheck($token)
+ public function renderPlaylistToFileCheck($token)
{
- require_once "Renderer.php";
+ require_once("Renderer.php");
$r = Renderer::rnRender2FileCheck($this, $token);
if (PEAR::isError($r)) {
return $r;
@@ -1097,9 +1109,9 @@ class GreenBox extends BasicStor {
* status : string - susccess | working | fault
* tmpfile : string - filepath to result temporary file
*/
- function renderPlaylistToFileList($status='')
+ public function renderPlaylistToFileList($status='')
{
- require_once "Renderer.php";
+ require_once("Renderer.php");
return Renderer::rnRender2FileList($this, $status);
} // fn renderPlaylistToFileList
@@ -1112,9 +1124,9 @@ class GreenBox extends BasicStor {
* @return boolean
* status
*/
- function renderPlaylistToFileClose($token)
+ public function renderPlaylistToFileClose($token)
{
- require_once "Renderer.php";
+ require_once("Renderer.php");
$r = Renderer::rnRender2FileClose($this, $token);
if (PEAR::isError($r)) {
return $r;
@@ -1133,9 +1145,9 @@ class GreenBox extends BasicStor {
* @return string
* render token
*/
- function renderPlaylistToStorageOpen($sessid, $plid)
+ public function renderPlaylistToStorageOpen($sessid, $plid)
{
- require_once "Renderer.php";
+ require_once("Renderer.php");
$owner = $this->getSessUserId($sessid);
if ($this->dbc->isError($owner)) {
return $owner;
@@ -1157,9 +1169,9 @@ class GreenBox extends BasicStor {
* status : string - susccess | working | fault
* gunid : string - gunid of result file
*/
- function renderPlaylistToStorageCheck($token)
+ public function renderPlaylistToStorageCheck($token)
{
- require_once "Renderer.php";
+ require_once("Renderer.php");
$r = Renderer::rnRender2StorageCheck($this, $token);
if (PEAR::isError($r)) {
return $r;
@@ -1178,7 +1190,7 @@ class GreenBox extends BasicStor {
* @return string
* render token
*/
- function renderPlaylistToRSSOpen($sessid, $plid)
+ public function renderPlaylistToRSSOpen($sessid, $plid)
{
$token = '123456789abcdeff';
$fakeFile = "{$this->accessDir}/$token.rss";
@@ -1196,7 +1208,7 @@ class GreenBox extends BasicStor {
* status : string - susccess | working | fault
* tmpfile : string - filepath to result temporary file
*/
- function renderPlaylistToRSSCheck($token)
+ public function renderPlaylistToRSSCheck($token)
{
$fakeFile = "{$this->accessDir}/$token.rss";
if ($token != '123456789abcdeff' || !file_exists($fakeFile)){
@@ -1220,14 +1232,14 @@ class GreenBox extends BasicStor {
* status : string - susccess | working | fault
* tmpfile : string - filepath to result temporary file
*/
- function renderPlaylistToRSSList($status='')
- {
- $dummytokens = array ('123456789abcdeff');
- foreach ($dummytokens as $token) {
- $r[] = renderPlaylistToRSSCheck($token);
- }
- return $r;
- } // fn renderPlaylistToRSSList
+// function renderPlaylistToRSSList($status='')
+// {
+// $dummytokens = array ('123456789abcdeff');
+// foreach ($dummytokens as $token) {
+// $r[] = $this->renderPlaylistToRSSCheck($token);
+// }
+// return $r;
+// } // fn renderPlaylistToRSSList
/**
@@ -1238,7 +1250,7 @@ class GreenBox extends BasicStor {
* @return boolean
* status
*/
- function renderPlaylistToRSSClose($token)
+ public function renderPlaylistToRSSClose($token)
{
if ($token != '123456789abcdeff'){
return PEAR::raiseError(
@@ -1260,15 +1272,15 @@ class GreenBox extends BasicStor {
* session id
* @param struct $criteria
* see search criteria
- * @return hasharray:
+ * @return array
* token : string - backup token
*/
- function createBackupOpen($sessid, $criteria='')
+ public function createBackupOpen($sessid, $criteria='')
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->openBackup($sessid,$criteria);
} // fn createBackupOpen
@@ -1285,12 +1297,12 @@ class GreenBox extends BasicStor {
* token : stirng - backup token
* url : string - access url
*/
- function createBackupCheck($token)
+ public function createBackupCheck($token)
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->checkBackup($token);
} // fn createBackupCheck
@@ -1308,12 +1320,12 @@ class GreenBox extends BasicStor {
* token : stirng - backup token
* url : string - access url
*/
- function createBackupList($sessid, $stat='')
+ public function createBackupList($sessid, $stat='')
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->listBackups($stat);
} // fn createBackupList
@@ -1327,12 +1339,12 @@ class GreenBox extends BasicStor {
* @return boolean
* status
*/
- function createBackupClose($token)
+ public function createBackupClose($token)
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->closeBackup($token);
} // fn createBackupClose
@@ -1349,9 +1361,9 @@ class GreenBox extends BasicStor {
* @return string
* restore token
*/
- function backupRestoreOpen($sessid, $filename)
+ public function backupRestoreOpen($sessid, $filename)
{
- require_once 'Restore.php';
+ require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
@@ -1371,9 +1383,9 @@ class GreenBox extends BasicStor {
* status: string - working | fault | success
* faultString: string - description of fault
*/
- function backupRestoreCheck($token)
+ public function backupRestoreCheck($token)
{
- require_once 'Restore.php';
+ require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
@@ -1390,8 +1402,8 @@ class GreenBox extends BasicStor {
* @return boolean
* is success
*/
- function backupRestoreClose($token) {
- require_once 'Restore.php';
+ public function backupRestoreClose($token) {
+ require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
@@ -1408,12 +1420,13 @@ class GreenBox extends BasicStor {
* session id
* @param string $key
* preference key
- * @return string, preference value
+ * @return string
+ * preference value
*/
- function loadPref($sessid, $key)
+ public function loadPref($sessid, $key)
{
- require_once 'Prefs.php';
- $pr =& new Prefs($this);
+ require_once('Prefs.php');
+ $pr = new Prefs($this);
$res = $pr->loadPref($sessid, $key);
return $res;
} // fn loadPref
@@ -1430,10 +1443,10 @@ class GreenBox extends BasicStor {
* preference value
* @return boolean
*/
- function savePref($sessid, $key, $value)
+ public function savePref($sessid, $key, $value)
{
- require_once 'Prefs.php';
- $pr =& new Prefs($this);
+ require_once('Prefs.php');
+ $pr = new Prefs($this);
$res = $pr->savePref($sessid, $key, $value);
return $res;
} // fn savePref
@@ -1448,10 +1461,10 @@ class GreenBox extends BasicStor {
* preference key
* @return boolean
*/
- function delPref($sessid, $key)
+ public function delPref($sessid, $key)
{
- require_once 'Prefs.php';
- $pr =& new Prefs($this);
+ require_once('Prefs.php');
+ $pr = new Prefs($this);
$res = $pr->delPref($sessid, $key);
return $res;
} // fn delPref
@@ -1466,12 +1479,13 @@ class GreenBox extends BasicStor {
* group name
* @param string $key
* preference key
- * @return string, preference value
+ * @return string
+ * preference value
*/
- function loadGroupPref($sessid, $group, $key)
+ public function loadGroupPref($sessid, $group, $key)
{
- require_once 'Prefs.php';
- $pr =& new Prefs($this);
+ require_once('Prefs.php');
+ $pr = new Prefs($this);
$res = $pr->loadGroupPref($sessid, $group, $key);
return $res;
} // fn loadGroupPref
@@ -1490,10 +1504,10 @@ class GreenBox extends BasicStor {
* preference value
* @return boolean
*/
- function saveGroupPref($sessid, $group, $key, $value)
+ public function saveGroupPref($sessid, $group, $key, $value)
{
- require_once 'Prefs.php';
- $pr =& new Prefs($this);
+ require_once('Prefs.php');
+ $pr = new Prefs($this);
$res = $pr->saveGroupPref($sessid, $group, $key, $value);
return $res;
} // fn saveGroupPref
@@ -1510,10 +1524,10 @@ class GreenBox extends BasicStor {
* preference key
* @return boolean
*/
- function delGroupPref($sessid, $group, $key)
+ public function delGroupPref($sessid, $group, $key)
{
- require_once 'Prefs.php';
- $pr =& new Prefs($this);
+ require_once('Prefs.php');
+ $pr = new Prefs($this);
$res = $pr->delGroupPref($sessid, $group, $key);
return $res;
} // fn delGroupPref
@@ -1536,10 +1550,10 @@ class GreenBox extends BasicStor {
* realchsum: string - transported file checksum
* ... ?
*/
- function getTransportInfo($trtok)
+ public function getTransportInfo($trtok)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->getTransportInfo($trtok);
} // fn getTransportInfo
@@ -1554,10 +1568,10 @@ class GreenBox extends BasicStor {
* @return boolean
* previous state
*/
- function turnOnOffTransports($sessid, $onOff=NULL)
+ public function turnOnOffTransports($sessid, $onOff=NULL)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->turnOnOffTransports($sessid, $onOff);
} // fn turnOnOffTransports
@@ -1572,10 +1586,10 @@ class GreenBox extends BasicStor {
* @return string
* resulting transport state
*/
- function doTransportAction($trtok, $action)
+ public function doTransportAction($trtok, $action)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
$res = $tr->doTransportAction($trtok, $action);
return $res;
} // fn doTransportAction
@@ -1591,10 +1605,10 @@ class GreenBox extends BasicStor {
* @return string
* transport token
*/
- function uploadFile2Hub($filePath)
+ public function uploadFile2Hub($filePath)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->uploadFile2Hub($filePath);
} // fn uploadFile2Hub
@@ -1606,10 +1620,10 @@ class GreenBox extends BasicStor {
* trtok: string transport token
* ... ?
*/
- function getHubInitiatedTransfers()
+ public function getHubInitiatedTransfers()
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->getHubInitiatedTransfers();
} // fn getHubInitiatedTransfers
@@ -1623,10 +1637,10 @@ class GreenBox extends BasicStor {
* @return string
* transport token
*/
- function startHubInitiatedTransfer($trtok)
+ public function startHubInitiatedTransfer($trtok)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->startHubInitiatedTransfer($trtok);
} // fn startHubInitiatedTransfer
@@ -1643,11 +1657,12 @@ class GreenBox extends BasicStor {
* if true, transport playlist content too
* @return string
* transport token
+ * @todo rename this function "uploadToHub"
*/
- function upload2Hub($gunid, $withContent=FALSE)
+ public function upload2Hub($gunid, $withContent=FALSE)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->upload2Hub($gunid, $withContent);
} // fn upload2Hub
@@ -1656,7 +1671,8 @@ class GreenBox extends BasicStor {
* Start download of audioClip/webstream/playlist from hub to local
* storageServer
*
- * @param string $sessid: session id
+ * @param string $sessid
+ * session id
* @param string $gunid
* global unique id of playlist being transported
* @param boolean $withContent
@@ -1664,13 +1680,13 @@ class GreenBox extends BasicStor {
* @return string
* transport token
*/
- function downloadFromHub($sessid, $gunid, $withContent=TRUE){
- $uid = $r = $this->getSessUserId($sessid);
- if ($this->dbc->isError($r)) {
- return $r;
+ public function downloadFromHub($sessid, $gunid, $withContent=TRUE){
+ $uid = $this->getSessUserId($sessid);
+ if ($this->dbc->isError($uid)) {
+ return $uid;
}
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->downloadFromHub($uid, $gunid, $withContent);
} // fn downloadFromHub
@@ -1679,14 +1695,15 @@ class GreenBox extends BasicStor {
/**
* Start search job on network hub
*
- * @param LS $criteria criteria format (see localSearch)
+ * @param array $criteria
+ * criteria format (see localSearch)
* @return string
* transport token
*/
- function globalSearch($criteria)
+ public function globalSearch($criteria)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->globalSearch($criteria);
} // fn globalSearch
@@ -1696,12 +1713,13 @@ class GreenBox extends BasicStor {
*
* @param string $trtok
* transport token
- * @return LS search result format (see localSearch)
+ * @return array
+ * search result format (see localSearch)
*/
- function getSearchResults($trtok)
+ public function getSearchResults($trtok)
{
- require_once"Transport.php";
- $tr =& new Transport($this);
+ require_once("Transport.php");
+ $tr = new Transport($this);
return $tr->getSearchResults($trtok);
} // fn getSearchResults
@@ -1716,7 +1734,7 @@ class GreenBox extends BasicStor {
* session id
* @return array
*/
- function listFolder($id, $sessid='')
+ public function listFolder($id, $sessid='')
{
if (($res = $this->_authorize('read', $id, $sessid)) !== TRUE) {
return $res;
@@ -1733,7 +1751,7 @@ class GreenBox extends BasicStor {
* local id
* @return string/err
*/
- function getFileType($id)
+ public function getFileType($id)
{
// $id = $this->_idFromGunid($gunid);
$type = $this->getObjType($id);
@@ -1750,9 +1768,9 @@ class GreenBox extends BasicStor {
* @param string $gunid
* @param string $ftype
* internal file type
- * @return string/err
+ * @return string|PEAR_Error
*/
- function existsFile($sessid, $gunid, $ftype=NULL)
+ public function existsFile($sessid, $gunid, $ftype=NULL)
{
$id = $this->_idFromGunid($gunid);
$ex = $this->bsExistsFile($id, $ftype);
@@ -1770,7 +1788,7 @@ class GreenBox extends BasicStor {
* @param int $id
* @return array
*/
- function getPath($id)
+ public function getPath($id)
{
$pa = parent::getPath($id, 'id, name, type');
array_shift($pa);
@@ -1786,9 +1804,9 @@ class GreenBox extends BasicStor {
* HtmlUI depends on it.
*
* @param string $sessid
- * @return int/error
+ * @return int|PEAR_Error
*/
- function getSessUserId($sessid)
+ public function getSessUserId($sessid)
{
$r = parent::getSessUserId($sessid);
if (PEAR::isError($r)) {
@@ -1817,7 +1835,7 @@ class GreenBox extends BasicStor {
* session id, required for 'superuser mode'
* @return boolean/err
*/
- function passwd($login, $oldpass=null, $pass='', $sessid='')
+ public function passwd($login, $oldpass=null, $pass='', $sessid='')
{
if (is_null($oldpass) || ($oldpass == '') ) {
if (($res = $this->_authorize('subjects', $this->rootId, $sessid)) !== TRUE) {
@@ -1856,7 +1874,7 @@ class GreenBox extends BasicStor {
* @return int
* local permission id
*/
- function addPerm($sid, $action, $oid, $type='A', $sessid='')
+ public function addPerm($sid, $action, $oid, $type='A', $sessid='')
{
$parid = $this->getParent($oid);
if (($res = $this->_authorize('editPerms', $parid, $sessid)) !== TRUE) {
@@ -1879,7 +1897,7 @@ class GreenBox extends BasicStor {
* session id
* @return boolean/error
*/
- function removePerm($permid=NULL, $subj=NULL, $obj=NULL, $sessid='')
+ public function removePerm($permid=NULL, $subj=NULL, $obj=NULL, $sessid='')
{
if (!is_null($permid)) {
$oid = $this->_getPermOid($permid);
diff --git a/campcaster/src/modules/storageServer/var/LocStor.php b/campcaster/src/modules/storageServer/var/LocStor.php
index 61ba72aef..9c8580bb1 100644
--- a/campcaster/src/modules/storageServer/var/LocStor.php
+++ b/campcaster/src/modules/storageServer/var/LocStor.php
@@ -6,26 +6,37 @@ require_once "BasicStor.php";
*
* Local storage interface
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class LocStor extends BasicStor {
/* ---------------------------------------------------------------- store */
/**
- * Store or replace existing audio clip
+ * Store or replace existing audio clip
*
- * @param string $sessid, session id
- * @param string $gunid, global unique id
- * @param string $metadata, metadata XML string
- * @param string $fname, human readable menmonic file name
- * with extension corresponding to filetype
- * @param string $chsum, md5 checksum of media file
- * @param string $ftype audioclip | playlist | webstream
- * @return struct {url:writable URL for HTTP PUT, token:access token
+ * @param string $sessid
+ * session id
+ * @param string $gunid
+ * global unique id
+ * @param string $metadata
+ * metadata XML string
+ * @param string $fname
+ * human readable menmonic file name
+ * with extension corresponding to filetype
+ * @param string $chsum
+ * md5 checksum of media file
+ * @param string $ftype
+ * audioclip | playlist | webstream
+ * @return array
+ * {url:writable URL for HTTP PUT, token:access token}
*/
function storeAudioClipOpen(
$sessid, $gunid, $metadata, $fname, $chsum, $ftype='audioclip'
@@ -98,11 +109,11 @@ class LocStor extends BasicStor {
/**
- * Store or replace existing audio clip
+ * Store or replace existing audio clip
*
- * @param string $sessid
- * @param string $token
- * @return string gunid or PEAR::error
+ * @param string $sessid
+ * @param string $token
+ * @return string gunid|PEAR_Error
*/
function storeAudioClipClose($sessid, $token)
{
@@ -133,10 +144,12 @@ class LocStor extends BasicStor {
/**
- * Check uploaded file
+ * Check uploaded file
*
- * @param string $token, put token
- * @return hash, (status: boolean, size: int - filesize)
+ * @param string $token
+ * "put" token
+ * @return array
+ * hash, (status: boolean, size: int - filesize)
*/
function uploadCheck($token)
{
@@ -145,15 +158,20 @@ class LocStor extends BasicStor {
/**
- * Store webstream
+ * Store webstream
*
- * @param string $sessid, session id
- * @param string $gunid, global unique id
- * @param string $metadata, metadata XML string
- * @param string $fname, human readable menmonic file name
- * with extension corresponding to filetype
- * @param string $url, wewbstream url
- * @return string, gunid
+ * @param string $sessid
+ * session id
+ * @param string $gunid
+ * global unique id
+ * @param string $metadata
+ * metadata XML string
+ * @param string $fname
+ * human readable menmonic file name with extension corresponding to filetype
+ * @param string $url
+ * webstream url
+ * @return string
+ * gunid
*/
function storeWebstream($sessid, $gunid, $metadata, $fname, $url)
{
@@ -182,12 +200,14 @@ class LocStor extends BasicStor {
/* --------------------------------------------------------------- access */
/**
- * Make access to audio clip
+ * Make access to audio clip
*
- * @param string $sessid
- * @param string $gunid
- * @param int $parent parent token
- * @return array with: seekable filehandle, access token
+ * @param string $sessid
+ * @param string $gunid
+ * @param int $parent
+ * parent token
+ * @return array
+ * with: seekable filehandle, access token
*/
function accessRawAudioData($sessid, $gunid, $parent='0')
{
@@ -203,11 +223,12 @@ class LocStor extends BasicStor {
/**
- * Release access to audio clip
+ * Release access to audio clip
*
- * @param string $sessid
- * @param string $token, access token
- * @return boolean or PEAR::error
+ * @param string $sessid
+ * @param string $token
+ * access token
+ * @return boolean|PEAR_Error
*/
function releaseRawAudioData($sessid, $token)
{
@@ -221,11 +242,14 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------------- download */
/**
- * Create and return downloadable URL for audio file
+ * Create and return downloadable URL for audio file
*
- * @param string $sessid, session id
- * @param string $gunid, global unique id
- * @return array with strings:
+ * @param string $sessid
+ * session id
+ * @param string $gunid
+ * global unique id
+ * @return array
+ * array with strings:
* downloadable URL, download token, chsum, size, filename
*/
function downloadRawAudioDataOpen($sessid, $gunid)
@@ -249,10 +273,12 @@ class LocStor extends BasicStor {
/**
- * Discard downloadable URL for audio file
+ * Discard downloadable URL for audio file
*
- * @param string $token, download token
- * @return string, gunid
+ * @param string $token
+ * download token
+ * @return string
+ * gunid
*/
function downloadRawAudioDataClose($token)
{
@@ -261,11 +287,14 @@ class LocStor extends BasicStor {
/**
- * Create and return downloadable URL for metadata
+ * Create and return downloadable URL for metadata
*
- * @param string $sessid, session id
- * @param string $gunid, global unique id
- * @return array with strings:
+ * @param string $sessid
+ * session id
+ * @param string $gunid
+ * global unique id
+ * @return array
+ * array with strings:
* downloadable URL, download token, chsum, filename
*/
function downloadMetadataOpen($sessid, $gunid)
@@ -288,10 +317,12 @@ class LocStor extends BasicStor {
/**
- * Discard downloadable URL for metadata
+ * Discard downloadable URL for metadata
*
- * @param string $token, download token
- * @return string, gunid
+ * @param string $token
+ * download token
+ * @return string
+ * gunid
*/
function downloadMetadataClose($token)
{
@@ -300,11 +331,11 @@ class LocStor extends BasicStor {
/**
- * Return metadata as XML
+ * Return metadata as XML
*
- * @param string $sessid
- * @param string $gunid
- * @return string or PEAR::error
+ * @param string $sessid
+ * @param string $gunid
+ * @return string|PEAR_Error
*/
function getAudioClip($sessid, $gunid)
{
@@ -326,10 +357,11 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- search, browse */
/**
- * Search in metadata database
+ * Search in metadata database
*
- * @param string $sessid
- * @param hash $criteria, with following structure:
+ * @param string $sessid
+ * @param array $criteria
+ * with following structure:
*
* - filetype - string, type of searched files,
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'
@@ -389,8 +421,6 @@ class LocStor extends BasicStor {
/**
- * Enter description here...
- *
* @param array $criteria
* @param mixed $sessid - this variable isnt used
* @return unknown
@@ -408,13 +438,16 @@ class LocStor extends BasicStor {
/**
- * Return values of specified metadata category
+ * Return values of specified metadata category
*
- * @param string $category, metadata category name
- * with or without namespace prefix (dc:title, author)
- * @param hash $criteria, see searchMetadata method
- * @param string $sessid
- * @return hash, fields:
+ * @param string $category
+ * metadata category name
+ * with or without namespace prefix (dc:title, author)
+ * @param hash $criteria
+ * see searchMetadata method
+ * @param string $sessid
+ * @return array
+ * hash, fields:
* results : array with found values
* cnt : integer - number of matching values
* @see BasicStor::bsBrowseCategory
@@ -430,11 +463,11 @@ class LocStor extends BasicStor {
/* ----------------------------------------------------------------- etc. */
/**
- * Check if audio clip exists
+ * Check if audio clip exists
*
- * @param string $sessid
- * @param string $gunid
- * @return boolean
+ * @param string $sessid
+ * @param string $gunid
+ * @return boolean
*/
function existsAudioClip($sessid, $gunid)
{
@@ -458,12 +491,13 @@ class LocStor extends BasicStor {
/**
- * Check if file exists in the storage
+ * Check if file exists in the storage
*
- * @param string $sessid
- * @param string $gunid
- * @param string $ftype, internal file type
- * @return boolean
+ * @param string $sessid
+ * @param string $gunid
+ * @param string $ftype
+ * internal file type
+ * @return boolean
*/
function existsFile($sessid, $gunid, $ftype=NULL)
{
@@ -480,12 +514,13 @@ class LocStor extends BasicStor {
/**
- * Delete existing audio clip
+ * Delete existing audio clip
*
- * @param string $sessid
- * @param string $gunid
- * @param boolean $forced, if true don't use trash
- * @return boolean or PEAR::error
+ * @param string $sessid
+ * @param string $gunid
+ * @param boolean $forced
+ * if true, don't use trash
+ * @return boolean|PEAR_Error
*/
function deleteAudioClip($sessid, $gunid, $forced=FALSE)
{
@@ -508,12 +543,13 @@ class LocStor extends BasicStor {
/**
- * Update existing audio clip metadata
+ * Update existing audio clip metadata
*
- * @param string $sessid
- * @param string $gunid
- * @param string $metadata, metadata XML string
- * @return boolean or PEAR::error
+ * @param string $sessid
+ * @param string $gunid
+ * @param string $metadata
+ * metadata XML string
+ * @return boolean|PEAR_Error
*/
function updateAudioClipMetadata($sessid, $gunid, $metadata)
{
@@ -530,12 +566,16 @@ class LocStor extends BasicStor {
/*====================================================== playlist methods */
/**
- * Create a new empty playlist.
+ * Create a new empty playlist.
*
- * @param string $sessid, session ID
- * @param string $playlistId, playlist global unique ID
- * @param string $fname, human readable mnemonic file name
- * @return string, playlist global unique ID
+ * @param string $sessid
+ * session ID
+ * @param string $playlistId
+ * playlist global unique ID
+ * @param string $fname
+ * human readable mnemonic file name
+ * @return string
+ * playlist global unique ID
*/
function createPlaylist($sessid, $playlistId, $fname)
{
@@ -588,12 +628,14 @@ class LocStor extends BasicStor {
/**
- * Open a Playlist metafile for editing.
- * Open readable URL and mark file as beeing edited.
+ * Open a Playlist metafile for editing.
+ * Open readable URL and mark file as beeing edited.
*
- * @param string $sessid, session ID
- * @param string $playlistId, playlist global unique ID
- * @return struct
+ * @param string $sessid
+ * session ID
+ * @param string $playlistId
+ * playlist global unique ID
+ * @return struct
* {url:readable URL for HTTP GET, token:access token, chsum:checksum}
*/
function editPlaylist($sessid, $playlistId)
@@ -634,12 +676,16 @@ class LocStor extends BasicStor {
/**
- * Store a new Playlist metafile in place of the old one.
+ * Store a new Playlist metafile in place of the old one.
*
- * @param string $sessid, session ID
- * @param string $playlistToken, playlist access token
- * @param string $newPlaylist, new playlist as XML string
- * @return string, playlistId
+ * @param string $sessid
+ * session ID
+ * @param string $playlistToken
+ * playlist access token
+ * @param string $newPlaylist
+ * new playlist as XML string
+ * @return string
+ * playlistId
*/
function savePlaylist($sessid, $playlistToken, $newPlaylist)
{
@@ -664,11 +710,14 @@ class LocStor extends BasicStor {
/**
- * RollBack playlist changes to the locked state
+ * RollBack playlist changes to the locked state
*
- * @param string $playlistToken, playlist access token
- * @param string $sessid, session ID
- * @return string gunid of playlist
+ * @param string $playlistToken
+ * playlist access token
+ * @param string $sessid
+ * session ID
+ * @return string
+ * gunid of playlist
*/
function revertEditedPlaylist($playlistToken, $sessid='')
{
@@ -695,12 +744,15 @@ class LocStor extends BasicStor {
/**
- * Delete a Playlist metafile.
+ * Delete a Playlist metafile.
*
- * @param string $sessid, session ID
- * @param string $playlistId, playlist global unique ID
- * @param boolean $forced, if true don't use trash
- * @return boolean
+ * @param string $sessid
+ * session ID
+ * @param string $playlistId
+ * playlist global unique ID
+ * @param boolean $forced
+ * if true don't use trash
+ * @return boolean
*/
function deletePlaylist($sessid, $playlistId, $forced=FALSE)
{
@@ -733,14 +785,17 @@ class LocStor extends BasicStor {
/**
- * Access (read) a Playlist metafile.
+ * Access (read) a Playlist metafile.
*
- * @param string $sessid, session ID
- * @param string $playlistId, playlist global unique ID
- * @param boolean $recursive, flag for recursive access content
- * inside playlist (optional, default: false)
- * @param int $parent parent token
- * @return struct {
+ * @param string $sessid
+ * session ID
+ * @param string $playlistId
+ * playlist global unique ID
+ * @param boolean $recursive
+ * flag for recursive access content inside playlist
+ * @param int $parent
+ * parent token
+ * @return struct {
* url: readable URL for HTTP GET,
* token: access token,
* chsum: checksum,
@@ -779,13 +834,16 @@ class LocStor extends BasicStor {
/**
- * Release the resources obtained earlier by accessPlaylist().
+ * Release the resources obtained earlier by accessPlaylist().
*
- * @param string $sessid, session ID
- * @param string $playlistToken, playlist access token
- * @param boolean $recursive, flag for recursive access content
- * inside playlist (optional, default: false)
- * @return string, playlist ID
+ * @param string $sessid
+ * session ID
+ * @param string $playlistToken
+ * playlist access token
+ * @param boolean $recursive
+ * flag for recursive access content inside playlist
+ * @return string
+ * playlist ID
*/
function releasePlaylist($sessid, $playlistToken, $recursive=FALSE)
{
@@ -802,16 +860,18 @@ class LocStor extends BasicStor {
/**
- * Create a tarfile with playlist export - playlist and all matching
- * sub-playlists and media files (if desired)
+ * Create a tarfile with playlist export - playlist and all matching
+ * sub-playlists and media files (if desired)
*
- * @param sessid - string, session ID
- * @param plids - array of strings, playlist global unique IDs
- * (one gunid is accepted too)
- * @param type - string, playlist format, values: lspl | smil | m3u
- * @param standalone - boolean, if only playlist should be exported or
- * with all related files
- * @return hasharray with fields:
+ * @param string $sessid
+ * session ID
+ * @param array $plids
+ * array of strings, playlist global unique IDs (one gunid is accepted too)
+ * @param string $type
+ * playlist format, values: lspl | smil | m3u
+ * @param boolean $standalone
+ * if only playlist should be exported or with all related files
+ * @return hasharray with fields:
* url string: readable url,
* token string: access token
* chsum string: md5 checksum,
@@ -834,11 +894,11 @@ class LocStor extends BasicStor {
/**
- * Close playlist export previously opened by the exportPlaylistOpen method
+ * Close playlist export previously opened by the exportPlaylistOpen method
*
- * @param token - string, access token obtained from exportPlaylistOpen
- * method call
- * @return boolean true or error object
+ * @param string $token
+ * access token obtained from exportPlaylistOpen method call
+ * @return boolean|PEAR_Error
*/
function exportPlaylistClose($token)
{
@@ -847,11 +907,13 @@ class LocStor extends BasicStor {
/**
- * Open writable handle for import playlist in LS Archive format
+ * Open writable handle for import playlist in LS Archive format
*
- * @param string $sessid, session id
- * @param string $chsum, md5 checksum of imported file
- * @return hasharray with:
+ * @param string $sessid
+ * session id
+ * @param string $chsum
+ * md5 checksum of imported file
+ * @return hasharray with:
* url string: writable URL
* token string: PUT token
*/
@@ -870,10 +932,12 @@ class LocStor extends BasicStor {
/**
- * Close import-handle and import playlist
+ * Close import-handle and import playlist
*
- * @param string $token, import token obtained by importPlaylistOpen method
- * @return string, result file global id (or error object)
+ * @param string $token
+ * import token obtained by importPlaylistOpen method
+ * @return string
+ * result file global id (or error object)
*/
function importPlaylistClose($token)
{
@@ -902,11 +966,13 @@ class LocStor extends BasicStor {
/**
- * Check whether a Playlist metafile with the given playlist ID exists.
+ * Check whether a Playlist metafile with the given playlist ID exists.
*
- * @param string $sessid, session ID
- * @param string $playlistId, playlist global unique ID
- * @return boolean
+ * @param string $sessid
+ * session ID
+ * @param string $playlistId
+ * playlist global unique ID
+ * @return boolean
*/
function existsPlaylist($sessid, $playlistId)
{
@@ -915,14 +981,17 @@ class LocStor extends BasicStor {
/**
- * Check whether a Playlist metafile with the given playlist ID
- * is available for editing, i.e., exists and is not marked as
- * beeing edited.
+ * Check whether a Playlist metafile with the given playlist ID
+ * is available for editing, i.e., exists and is not marked as
+ * being edited.
*
- * @param string $sessid, session ID
- * @param string $playlistId, playlist global unique ID
- * @param boolean $getUid, optional flag for returning editedby uid
- * @return boolean
+ * @param string $sessid
+ * session ID
+ * @param string $playlistId
+ * playlist global unique ID
+ * @param boolean $getUid
+ * flag for returning editedby uid
+ * @return boolean
*/
function playlistIsAvailable($sessid, $playlistId, $getUid=FALSE)
{
@@ -948,11 +1017,13 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- render methods */
/**
- * Render playlist to ogg file (open handle)
+ * Render playlist to ogg file (open handle)
*
- * @param string $sessid - session id
- * @param string $plid - playlist gunid
- * @return hasharray:
+ * @param string $sessid
+ * session id
+ * @param string $plid
+ * playlist gunid
+ * @return hasharray
* token: string - render token
*/
function renderPlaylistToFileOpen($sessid, $plid)
@@ -967,10 +1038,11 @@ class LocStor extends BasicStor {
/**
- * Render playlist to ogg file (check results)
+ * Render playlist to ogg file (check results)
*
- * @param string $token - render token
- * @return hasharray:
+ * @param string $token
+ * render token
+ * @return hasharray:
* status : string - success | working | fault
* url : string - readable url
*/
@@ -986,10 +1058,11 @@ class LocStor extends BasicStor {
/**
- * Render playlist to ogg file (close handle)
+ * Render playlist to ogg file (close handle)
*
- * @param string $token - render token
- * @return boolean status
+ * @param string $token
+ * render token
+ * @return boolean status
*/
function renderPlaylistToFileClose($token)
{
@@ -1003,11 +1076,14 @@ class LocStor extends BasicStor {
/**
- * Render playlist to storage media clip (open handle)
+ * Render playlist to storage media clip (open handle)
*
- * @param string $sessid - session id
- * @param string $plid - playlist gunid
- * @return string - render token
+ * @param string $sessid
+ * session id
+ * @param string $plid
+ * playlist gunid
+ * @return string
+ * render token
*/
function renderPlaylistToStorageOpen($sessid, $plid)
{
@@ -1025,10 +1101,11 @@ class LocStor extends BasicStor {
/**
- * Render playlist to storage media clip (check results)
+ * Render playlist to storage media clip (check results)
*
- * @param string $token - render token
- * @return hasharray:
+ * @param string $token
+ * render token
+ * @return hasharray:
* status : string - success | working | fault
* gunid : string - gunid of result file
*/
@@ -1044,11 +1121,14 @@ class LocStor extends BasicStor {
/**
- * Render playlist to RSS file (open handle)
+ * Render playlist to RSS file (open handle)
*
- * @param string $sessid - session id
- * @param string $plid - playlist gunid
- * @return string - render token
+ * @param string $sessid
+ * session id
+ * @param string $plid
+ * playlist gunid
+ * @return string
+ * render token
*/
function renderPlaylistToRSSOpen($sessid, $plid)
{
@@ -1060,10 +1140,11 @@ class LocStor extends BasicStor {
/**
- * Render playlist to RSS file (check results)
+ * Render playlist to RSS file (check results)
*
- * @param string $token - render token
- * @return hasharray :
+ * @param string $token
+ * render token
+ * @return hasharray :
* status : string - success | working | fault
* url : string - readable url
*/
@@ -1084,10 +1165,12 @@ class LocStor extends BasicStor {
/**
- * Render playlist to RSS file (close handle)
+ * Render playlist to RSS file (close handle)
*
- * @param string $token - render token
- * @return boolean status
+ * @param string $token
+ * render token
+ * @return boolean
+ * status
*/
function renderPlaylistToRSSClose($token)
{
@@ -1107,19 +1190,21 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------- backup methods */
/**
- * Create backup of storage (open handle)
+ * Create backup of storage (open handle)
*
- * @param string $sessid - session id
- * @param array $criteria - see search criteria
- * @return hasharray:
+ * @param string $sessid
+ * session id
+ * @param array $criteria
+ * see search criteria
+ * @return array
* token : string - backup token
*/
function createBackupOpen($sessid, $criteria='')
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
$r = $bu->openBackup($sessid,$criteria);
if ($r === FALSE) {
@@ -1132,10 +1217,12 @@ class LocStor extends BasicStor {
/**
- * Create backup of storage (check results)
+ * Create backup of storage (check results)
*
- * @param string $token - backup token
- * @return hasharray with field:
+ * @param string $token
+ * backup token
+ * @return hasharray
+ * with field:
* status : string - susccess | working | fault
* faultString: string - description of fault
* token : stirng - backup token
@@ -1143,49 +1230,53 @@ class LocStor extends BasicStor {
*/
function createBackupCheck($token)
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->checkBackup($token);
}
/**
- * Create backup of storage (list results)
+ * Create backup of storage (list results)
*
- * @param string $sessid - session id
- * @param status $stat (optional)
+ * @param string $sessid
+ * session id
+ * @param status $stat
* if this parameter is not set, then return with all unclosed backups
- * @return array of hasharray with field:
+ * @return array
+ * array of hasharray with field:
* status : string - susccess | working | fault
* token : stirng - backup token
* url : string - access url
*/
function createBackupList($sessid, $stat='')
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->listBackups($stat);
}
/**
- * Create backup of storage (close handle)
+ * Create backup of storage (close handle)
*
- * @param string $token - backup token
- * @return boolean status
+ * @param string $token
+ * backup token
+ * @return boolean
+ * status
*/
function createBackupClose($token)
{
- require_once "Backup.php";
- $bu = $r = new Backup($this);
- if (PEAR::isError($r)) {
- return $r;
+ require_once("Backup.php");
+ $bu = new Backup($this);
+ if (PEAR::isError($bu)) {
+ return $bu;
}
return $bu->closeBackup($token);
}
@@ -1194,10 +1285,12 @@ class LocStor extends BasicStor {
/* ------------------------------------------------------ restore methods */
/**
- * Restore a backup file (open handle)
+ * Restore a backup file (open handle)
*
- * @param string $sessid - session id
- * @param string $chsum, md5 checksum of imported file
+ * @param string $sessid
+ * session id
+ * @param string $chsum
+ * md5 checksum of imported file
* @return array
* array with:
* url string: writable URL
@@ -1206,9 +1299,9 @@ class LocStor extends BasicStor {
*/
function restoreBackupOpen($sessid, $chsum)
{
- $userid = $r =$this->getSessUserId($sessid);
- if ($this->dbc->isError($r)) {
- return $r;
+ $userid = $this->getSessUserId($sessid);
+ if ($this->dbc->isError($userid)) {
+ return $userid;
}
$r = $this->bsOpenPut($chsum, NULL, $userid);
if (PEAR::isError($r)) {
@@ -1219,19 +1312,22 @@ class LocStor extends BasicStor {
/**
- * Restore a backup file (close put handle)
+ * Restore a backup file (close put handle)
*
- * @param string $sessid - session id
- * @param string $token - put token
- * @return string $token - restore token
+ * @param string $sessid
+ * session id
+ * @param string $token
+ * "put" token
+ * @return string $token
+ * restore token
*/
function restoreBackupClosePut($sessid, $token) {
- $arr = $r = $this->bsClosePut($token);
- if (PEAR::isError($r)) {
- return $r;
+ $arr = $this->bsClosePut($token);
+ if (PEAR::isError($arr)) {
+ return $arr;
}
$fname = $arr['fname'];
- require_once 'Restore.php';
+ require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
@@ -1239,18 +1335,21 @@ class LocStor extends BasicStor {
return $rs->openRestore($sessid, $fname);
}
+
/**
- * Restore a backup file (check state)
- *
- * @param string $token - restore token
- * @return array status - fields:
- * token: string - restore token
- * status: string - working | fault | success
- * faultString: string - description of fault
+ * Restore a backup file (check state)
+ *
+ * @param string $token
+ * restore token
+ * @return array
+ * status - fields:
+ * token: string - restore token
+ * status: string - working | fault | success
+ * faultString: string - description of fault
*/
function restoreBackupCheck($token)
{
- require_once 'Restore.php';
+ require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
@@ -1260,15 +1359,17 @@ class LocStor extends BasicStor {
/**
- * Restore a backup file (close handle)
+ * Restore a backup file (close handle)
*
- * @param string $token - restore token
- * @return array status - fields:
- * token: string - restore token
- * status: string - working | fault | success
+ * @param string $token
+ * restore token
+ * @return array
+ * status - fields:
+ * token: string - restore token
+ * status: string - working | fault | success
*/
function restoreBackupClose($token) {
- require_once 'Restore.php';
+ require_once('Restore.php');
$rs = new Restore($this);
if (PEAR::isError($rs)) {
return $rs;
diff --git a/campcaster/src/modules/storageServer/var/LsPlaylist.php b/campcaster/src/modules/storageServer/var/LsPlaylist.php
index 64b2d888b..c38a87861 100644
--- a/campcaster/src/modules/storageServer/var/LsPlaylist.php
+++ b/campcaster/src/modules/storageServer/var/LsPlaylist.php
@@ -10,10 +10,14 @@ define('PL_URL_RELPATH', '../playlist/');
*
* Internal playlist format helper.
*
- * @author $Author: tomash $
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision: 1848 $
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @todo Rename this class
*/
class LsPlaylist extends Playlist
@@ -150,8 +154,13 @@ class LsPlaylist extends Playlist
/**
* Several auxiliary classes follows
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @todo Rename this class PlaylistTag
*/
class LsPlaylistTag
@@ -258,8 +267,13 @@ class LsPlaylistTag
/**
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @todo Rename this class "PlaylistElement"
*/
class LsPlaylistElement {
@@ -438,8 +452,13 @@ class LsPlaylistElement {
/**
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @todo Rename this class to PlaylistAudioClip (notice the caps)
*/
class LsPLaylistAudioClip
@@ -518,8 +537,13 @@ class LsPLaylistAudioClip
/**
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @todo Rename this class "PlaylistFadeInfo" (notive the caps)
*/
class LsPLaylistFadeInfo
@@ -550,9 +574,14 @@ class LsPLaylistFadeInfo
/**
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
- * @todo Rename this class to PlaylistMetadata (notive the caps)
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
+ * @todo Rename this class to PlaylistMetadata (notice the caps)
*/
class LsPLaylistMetadata
{
diff --git a/campcaster/src/modules/storageServer/var/M3uPlaylist.php b/campcaster/src/modules/storageServer/var/M3uPlaylist.php
index fcdf7811e..9cbeca89b 100644
--- a/campcaster/src/modules/storageServer/var/M3uPlaylist.php
+++ b/campcaster/src/modules/storageServer/var/M3uPlaylist.php
@@ -4,10 +4,14 @@ define('INDCH', ' ');
/**
* M3uPlaylist class
*
- * @author $Author: tomash $
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version : $Revision: 1848 $
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class M3uPlaylist {
@@ -195,10 +199,14 @@ class M3uPlaylist {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class M3uPlaylistBodyElement {
function convert2lspl(&$tree, $ind='')
@@ -231,10 +239,14 @@ class M3uPlaylistBodyElement {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class M3uPlaylistParElement {
function convert2lspl(&$tree, $ind='')
@@ -257,10 +269,14 @@ class M3uPlaylistParElement {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class M3uPlaylistAudioElement {
function convert2lspl(&$tree, $ind='')
@@ -313,10 +329,14 @@ class M3uPlaylistAudioElement {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class M3uPlaylistAnimateElement {
function convert2lspl(&$tree, $ind='') {
diff --git a/campcaster/src/modules/storageServer/var/MetaData.php b/campcaster/src/modules/storageServer/var/MetaData.php
index 400da7e35..1052f49c7 100644
--- a/campcaster/src/modules/storageServer/var/MetaData.php
+++ b/campcaster/src/modules/storageServer/var/MetaData.php
@@ -9,39 +9,45 @@ require_once "XML/Util.php";
* File storage support class.
* Store metadata tree in relational database.
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see StoredFile
* @see XmlParser
* @see DataEngine
*/
class MetaData {
+ public $config;
+ public $dbc;
+ public $mdataTable;
+ public $gunid;
+ public $resDir;
+ public $fname;
+ public $exists;
+
/**
- * Constructor
- *
- * @param Greenbox $gb
+ * @param Greenbox $gb
* A reference to GreenBox object
- * @param string $gunid
+ * @param string $gunid
* global unique id
- * @param string $resDir
+ * @param string $resDir
* resource directory
- * @return this
*/
- function MetaData(&$gb, $gunid, $resDir)
+ public function __construct(&$gb, $gunid, $resDir)
{
- $this->config =& $gb->config;
- $this->dbc =& $gb->dbc;
+ $this->config =& $gb->config;
+ $this->dbc =& $gb->dbc;
$this->mdataTable = $gb->mdataTable;
- $this->gunid = $gunid;
- $this->resDir = $resDir;
- $this->fname = $this->makeFname();
- $this->exists =
- $this->dbCheck($gunid) &&
- is_file($this->fname) &&
- is_readable($this->fname);
+ $this->gunid = $gunid;
+ $this->resDir = $resDir;
+ $this->fname = $this->makeFname();
+ $this->exists = null;
}
@@ -60,7 +66,7 @@ class MetaData {
*/
function insert($mdata, $loc='file', $format=NULL)
{
- if ($this->exists) {
+ if ($this->exists()) {
return FALSE;
}
$tree =& $this->parse($mdata, $loc);
@@ -128,7 +134,7 @@ class MetaData {
*/
function replace($mdata, $loc='file', $format=NULL)
{
- if ($this->exists) {
+ if ($this->exists()) {
$res = $this->delete();
if (PEAR::isError($res)) {
return $res;
@@ -139,20 +145,25 @@ class MetaData {
/**
- * Return true if metadata exists
+ * Return true if metadata exists
*
- * @return boolean
+ * @return boolean
*/
function exists()
{
+ if (is_null($this->exists)) {
+ $this->exists = $this->dbCheck($gunid) &&
+ is_file($this->fname) &&
+ is_readable($this->fname);
+ }
return $this->exists;
}
/**
- * Delete all file's metadata
+ * Delete all file's metadata
*
- * @return true or PEAR::error
+ * @return TRUE|PEAR_Error
*/
function delete()
{
@@ -616,7 +627,7 @@ class MetaData {
{
if ($this->config['validate'] && !is_null($this->format)) {
require_once("Validator.php");
- $val =& new Validator($this->format, $this->gunid);
+ $val = new Validator($this->format, $this->gunid);
if (PEAR::isError($val)) {
return $val;
}
@@ -646,7 +657,7 @@ class MetaData {
{
if ($this->config['validate'] && !is_null($this->format)) {
require_once("Validator.php");
- $val =& new Validator($this->format, $this->gunid);
+ $val = new Validator($this->format, $this->gunid);
if (PEAR::isError($val)) {
return $val;
}
diff --git a/campcaster/src/modules/storageServer/var/Playlist.php b/campcaster/src/modules/storageServer/var/Playlist.php
index 7ec478bd2..b3055fc03 100644
--- a/campcaster/src/modules/storageServer/var/Playlist.php
+++ b/campcaster/src/modules/storageServer/var/Playlist.php
@@ -4,10 +4,14 @@
*
* remark: dcterms:extent format: hh:mm:ss.ssssss
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class Playlist extends StoredFile {
@@ -185,15 +189,15 @@ class Playlist extends StoredFile {
function setAuxMetadata()
{
// get info about playlist
- $plInfo = $r = $this->getPlInfo();
- if (PEAR::isError($r)) {
- return $r;
+ $plInfo = $this->getPlInfo();
+ if (PEAR::isError($plInfo)) {
+ return $plInfo;
}
extract($plInfo); // 'plLen', 'parid', 'metaParid'
// set gunid as id attr in playlist tag:
- $mid = $r = $this->_getMidOrInsert('id', $parid, $this->gunid, 'A');
- if (PEAR::isError($r)) {
- return $r;
+ $mid = $this->_getMidOrInsert('id', $parid, $this->gunid, 'A');
+ if (PEAR::isError($mid)) {
+ return $mid;
}
$r = $this->_setValueOrInsert(
$mid, $this->gunid, $parid, 'id', 'A');
@@ -1160,11 +1164,16 @@ class Playlist extends StoredFile {
/**
- * Auxiliary class for GB playlist editing methods
+ * Auxiliary class for GB playlist editing methods
+ * @author Tomas Hlava
+ * @author Paul Baranowski
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class PlaylistElement {
- var $pl = NULL;
- var $plEl = NULL;
+ private $pl = NULL;
+ private $plEl = NULL;
function PlaylistElement(&$pl, $plEl)
{
diff --git a/campcaster/src/modules/storageServer/var/Prefs.php b/campcaster/src/modules/storageServer/var/Prefs.php
index 99e71dae6..badc9b3f8 100644
--- a/campcaster/src/modules/storageServer/var/Prefs.php
+++ b/campcaster/src/modules/storageServer/var/Prefs.php
@@ -3,10 +3,14 @@
/**
* Preference storage class.
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see StoredFile
*/
/* ================== Prefs ================== */
@@ -18,7 +22,7 @@ class Prefs {
* @param GreenBox $gb
* GreenBox object reference
*/
- function Prefs(&$gb)
+ public function __construct(&$gb)
{
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
diff --git a/campcaster/src/modules/storageServer/var/RawMediaData.php b/campcaster/src/modules/storageServer/var/RawMediaData.php
index 48a48d29c..d3b4a4414 100644
--- a/campcaster/src/modules/storageServer/var/RawMediaData.php
+++ b/campcaster/src/modules/storageServer/var/RawMediaData.php
@@ -217,10 +217,14 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
* File storage support class
* Store media files in real filesystem and handle access to them.
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see StoredFile
*/
class RawMediaData {
@@ -233,7 +237,7 @@ class RawMediaData {
* @param string $resDir
* resource directory
*/
- function RawMediaData($gunid, $resDir)
+ public function __construct($gunid, $resDir)
{
$this->gunid = $gunid;
$this->resDir = $resDir;
diff --git a/campcaster/src/modules/storageServer/var/Renderer.php b/campcaster/src/modules/storageServer/var/Renderer.php
index 76dec1bf9..84736a818 100644
--- a/campcaster/src/modules/storageServer/var/Renderer.php
+++ b/campcaster/src/modules/storageServer/var/Renderer.php
@@ -8,10 +8,14 @@ require_once "LsPlaylist.php";
*
* Playlist to file rendering - PHP layer, caller to the renderer executable
*
- * @author $Author: tomash $
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision: 1949 $
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see LocStor
*/
class Renderer
diff --git a/campcaster/src/modules/storageServer/var/Restore.php b/campcaster/src/modules/storageServer/var/Restore.php
index d0f599195..3e41f32eb 100644
--- a/campcaster/src/modules/storageServer/var/Restore.php
+++ b/campcaster/src/modules/storageServer/var/Restore.php
@@ -2,53 +2,61 @@
define('ACCESS_TYPE', 'restore');
/**
- * @author $Author: $
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision: $
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class Restore {
/**
- * string - name of logfile
+ * Name of logfile
+ * @var string
*/
- var $logFile;
+ private $logFile;
/**
- * string - session id
+ * session id
+ * @var string
*/
- var $sessid;
+ private $sessid;
/**
- * string - token
+ * @var string
*/
- var $token;
- /**
- * string - name of statusfile
- */
- var $statusFile;
- /**
- * string - name of temporary directory, to here extract the backup tarball
- */
- var $tmpDir;
+ private $token;
/**
- * string - loglevel
+ * Name of statusfile
+ * @var string
*/
- var $loglevel = 'warn';
- #var $loglevel = 'debug';
+ private $statusFile;
/**
- * greenbox object reference
+ * Name of temporary directory, to here extract the backup tarball
+ * @var string
*/
- var $gb;
+ private $tmpDir;
+
+ /**
+ * @var string
+ */
+ private $loglevel = 'warn';
+ #private $loglevel = 'debug';
+
+ /**
+ * @var GreenBox
+ */
+ private $gb;
/**
- * Constructor
- *
* @param GreenBox $gb
* greenbox object reference
*/
- function Restore (&$gb) {
+ public function __construct(&$gb) {
$this->gb =& $gb;
$this->token = null;
$this->logFile = $this->gb->bufferDir.'/'.ACCESS_TYPE.'.log';
diff --git a/campcaster/src/modules/storageServer/var/SmilPlaylist.php b/campcaster/src/modules/storageServer/var/SmilPlaylist.php
index 0c21e4b7d..2ed77add0 100644
--- a/campcaster/src/modules/storageServer/var/SmilPlaylist.php
+++ b/campcaster/src/modules/storageServer/var/SmilPlaylist.php
@@ -6,10 +6,14 @@ require_once "XmlParser.php";
/**
* SmilPlaylist class
*
- * @author $Author: tomash $
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision: 1848 $
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class SmilPlaylist {
@@ -122,10 +126,14 @@ class SmilPlaylist {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class SmilPlaylistBodyElement {
@@ -161,10 +169,14 @@ class SmilPlaylistBodyElement {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class SmilPlaylistParElement {
@@ -190,10 +202,14 @@ class SmilPlaylistParElement {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class SmilPlaylistAudioElement {
function convert2lspl(&$gb, &$tree, &$gunids, $parr, $ind='')
@@ -273,10 +289,14 @@ class SmilPlaylistAudioElement {
/**
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class SmilPlaylistAnimateElement {
diff --git a/campcaster/src/modules/storageServer/var/StoredFile.php b/campcaster/src/modules/storageServer/var/StoredFile.php
index 2ce90ad20..37b1e61c4 100644
--- a/campcaster/src/modules/storageServer/var/StoredFile.php
+++ b/campcaster/src/modules/storageServer/var/StoredFile.php
@@ -14,24 +14,50 @@ require_once dirname(__FILE__)."/../../getid3/var/getid3.php";
* - represented by RawMediaData class
*
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see GreenBox
* @see MetaData
* @see RawMediaData
*/
class StoredFile {
- var $gb;
- var $dbc;
- var $filesTable;
- var $accessTable;
- var $gunid;
- var $resDir;
- var $accessDir;
- var $rmd;
- var $md;
+ /**
+ * @var GreenBox
+ */
+ public $gb;
+
+ /**
+ * @var DB
+ */
+ public $dbc;
+
+ /**
+ * Name of a database table.
+ * @var string
+ */
+ public $filesTable;
+
+ /**
+ * Name of a database table.
+ * @var string
+ */
+ public $accessTable;
+
+ public $gunid;
+ private $resDir;
+ private $accessDir;
+
+ /**
+ * @var RawMediaData
+ */
+ public $rmd;
+ public $md;
/* ========================================================== constructor */
/**
@@ -39,10 +65,9 @@ class StoredFile {
*
* @param GreenBox $gb
* @param string $gunid
- * optional, globally unique id of file
- * @return this
+ * globally unique id of file
*/
- function StoredFile(&$gb, $gunid=NULL)
+ public function __construct(&$gb, $gunid=NULL)
{
$this->gb =& $gb;
$this->dbc =& $gb->dbc;
@@ -54,8 +79,8 @@ class StoredFile {
}
$this->resDir = $this->_getResDir($this->gunid);
$this->accessDir = $this->gb->accessDir;
- $this->rmd =& new RawMediaData($this->gunid, $this->resDir);
- $this->md =& new MetaData($gb, $this->gunid, $this->resDir);
+ $this->rmd = new RawMediaData($this->gunid, $this->resDir);
+ $this->md = new MetaData($gb, $this->gunid, $this->resDir);
# return $this->gunid;
}
@@ -87,7 +112,7 @@ class StoredFile {
$mediaFileLP='', $metadata='', $mdataLoc='file',
$gunid=NULL, $ftype=NULL, $className='StoredFile')
{
- $ac =& new $className($gb, ($gunid ? $gunid : NULL));
+ $ac = new $className($gb, ($gunid ? $gunid : NULL));
if (PEAR::isError($ac)) {
return $ac;
}
@@ -200,7 +225,7 @@ class StoredFile {
return $r;
}
$gunid = StoredFile::_normalizeGunid($row['gunid']);
- $ac =& new $className($gb, $gunid);
+ $ac = new $className($gb, $gunid);
$ac->mime = $row['mime'];
$ac->name = $row['name'];
$ac->id = $row['id'];
@@ -259,10 +284,11 @@ class StoredFile {
/**
* Create instance of StoredFile object and make copy of existing file
*
- * @param reference $src to source object
+ * @param StoredFile $src
+ * source object
* @param int $nid
* new local id
- * @return unknown
+ * @return StoredFile
*/
function ©Of(&$src, $nid)
{
diff --git a/campcaster/src/modules/storageServer/var/Transport.php b/campcaster/src/modules/storageServer/var/Transport.php
index 415a1bc88..e3757b06f 100644
--- a/campcaster/src/modules/storageServer/var/Transport.php
+++ b/campcaster/src/modules/storageServer/var/Transport.php
@@ -4,14 +4,13 @@ define('TRERR_MD', 71);
define('TRERR_TOK', 72);
define('TRERR_NOTFIN', 73);
define('TRERR_XR_FAIL', 74);
-
#define('TR_LOG_LEVEL', 0);
define('TR_LOG_LEVEL', 10);
define('HOSTNAME', 'storageServer');
-include_once "XML/RPC.php";
-include_once "TransportRecord.php";
+include_once("XML/RPC.php");
+include_once("TransportRecord.php");
/**
* Class for handling file tranport between StorageServer and ArchiveServer
@@ -40,54 +39,101 @@ include_once "TransportRecord.php";
* - file
*
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class Transport
{
/**
- * Container for db connection instance
+ * Container for db connection instance
+ * @var DB
*/
- var $dbc;
+ public $dbc;
/**
- * wget --timeout parameter [s]
+ * @var GreenBox
*/
- var $downTimeout = 20; // 600
+ public $gb;
+
/**
- * wget --waitretry parameter [s]
+ * @var array
*/
- var $downWaitretry = 10;
+ public $config;
+
+ /**
+ * @var string
+ */
+ private $transTable;
+
+ /**
+ * @var string
+ */
+ public $transDir;
+
+ /**
+ * File name
+ * @var string
+ */
+ private $cronJobScript;
+
/**
- * wget --limit-rate parameter
+ * wget --timeout parameter [s]
+ * @var int
*/
- var $downLimitRate = NULL;
+ private $downTimeout = 20; // 600
+
/**
- * wget -t parameter
+ * wget --waitretry parameter [s]
+ * @var int
*/
- var $downRetries = 6;
+ private $downWaitretry = 10;
+
/**
- * curl --max-time parameter
+ * wget --limit-rate parameter
*/
- var $upTrMaxTime = 600;
+ private $downLimitRate = NULL;
+
/**
- * curl --speed-time parameter
+ * wget -t parameter
+ * @var int
*/
- var $upTrSpeedTime = 20;
+ private $downRetries = 6;
+
/**
- * curl --speed-limit parameter
+ * curl --max-time parameter
+ * @var int
*/
- var $upTrSpeedLimit = 500;
+ private $upTrMaxTime = 600;
+
/**
- * curl --connect-timeout parameter
+ * curl --speed-time parameter
+ * @var int
*/
- var $upTrConnectTimeout = 20;
+ private $upTrSpeedTime = 20;
+
/**
- * curl --limit-rate parameter
+ * curl --speed-limit parameter
+ * @var int
*/
- var $upLimitRate = NULL;
+ private $upTrSpeedLimit = 500;
+
+ /**
+ * curl --connect-timeout parameter
+ * @var int
+ */
+ private $upTrConnectTimeout = 20;
+
+ /**
+ * curl --limit-rate parameter
+ * @var int
+ */
+ private $upLimitRate = NULL;
/**
@@ -96,13 +142,13 @@ class Transport
* @param LocStor $gb
* @return Transport
*/
- function Transport(&$gb)
+ public function __construct(&$gb)
{
- $this->gb =& $gb;
- $this->dbc =& $gb->dbc;
- $this->config =& $gb->config;
- $this->transTable = $gb->config['tblNamePrefix'].'trans';
- $this->transDir = $gb->config['transDir'];
+ $this->gb =& $gb;
+ $this->dbc =& $gb->dbc;
+ $this->config =& $gb->config;
+ $this->transTable = $gb->config['tblNamePrefix'].'trans';
+ $this->transDir = $gb->config['transDir'];
$this->cronJobScript = realpath(
dirname(__FILE__).
'/../../storageServer/var/cron/transportCronJob.php'
@@ -134,9 +180,9 @@ class Transport
*/
function getTransportInfo($trtok)
{
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$res = array();
foreach (array(
@@ -168,13 +214,13 @@ class Transport
function turnOnOffTransports($sessid, $onOff=NULL)
{
require_once('Prefs.php');
- $pr =& new Prefs($this->gb);
+ $pr = new Prefs($this->gb);
$group = 'StationPrefs';
$key = 'TransportsDenied';
- $res = $r = $pr->loadGroupPref($sessid, $group, $key);
- if (PEAR::isError($r)) {
- if ($r->getCode() !== GBERR_PREF) {
- return $r;
+ $res = $pr->loadGroupPref($sessid, $group, $key);
+ if (PEAR::isError($res)) {
+ if ($res->getCode() !== GBERR_PREF) {
+ return $res;
} else {
$res = FALSE; // default
}
@@ -183,9 +229,9 @@ class Transport
if (is_null($onOff)) {
return $state;
}
- $res = $r = $pr->saveGroupPref($sessid, $group, $key, !$onOff);
- if (PEAR::isError($r)) {
- return $r;
+ $res = $pr->saveGroupPref($sessid, $group, $key, !$onOff);
+ if (PEAR::isError($res)) {
+ return $res;
}
return $state;
}
@@ -203,9 +249,9 @@ class Transport
*/
function doTransportAction($trtok, $action)
{
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
if ($trec->getState() == 'closed') {
return PEAR::raiseError(
@@ -253,37 +299,37 @@ class Transport
switch ($ftype = $this->gb->_getType($gunid)) {
case "audioclip":
case "webstream":
- $ac =& StoredFile::recallByGunid($this->gb, $gunid);
+ $ac = StoredFile::recallByGunid($this->gb, $gunid);
if (PEAR::isError($ac)) {
return $ac;
}
// handle metadata:
- $mdfpath = $r = $ac->_getRealMDFname();
- if (PEAR::isError($r)) {
- return $r;
+ $mdfpath = $ac->_getRealMDFname();
+ if (PEAR::isError($mdfpath)) {
+ return $mdfpath;
}
- $mdtrec = $r = $this->_uploadGenFile2Hub($mdfpath, 'metadata',
+ $mdtrec = $this->_uploadGeneralFileToHub($mdfpath, 'metadata',
array_merge(array('gunid'=>$gunid, 'fname'=>'metadata',), $pars)
);
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($mdtrec)) {
+ return $mdtrec;
}
// handle raw media file:
- $fpath = $r = $ac->_getRealRADFname();
- if (PEAR::isError($r)) {
- return $r;
+ $fpath = $ac->_getRealRADFname();
+ if (PEAR::isError($fpath)) {
+ return $fpath;
}
- $fname = $r = $ac->_getFileName();
- if (PEAR::isError($r)) {
- return $r;
+ $fname = $ac->_getFileName();
+ if (PEAR::isError($fname)) {
+ return $fname;
}
- $trec = $r = $this->_uploadGenFile2Hub($fpath, 'audioclip',
+ $trec = $this->_uploadGeneralFileToHub($fpath, 'audioclip',
array_merge(array(
'gunid'=>$gunid, 'fname'=>$fname, 'mdtrtok'=>$mdtrec->trtok,
), $pars)
);
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$this->startCronJobProcess($mdtrec->trtok);
break;
@@ -294,36 +340,36 @@ class Transport
if (PEAR::isError($pl)) {
return $pl;
}
- $fname = $r = $pl->_getFileName();
- if (PEAR::isError($r)) {
- return $r;
+ $fname = $pl->_getFileName();
+ if (PEAR::isError($fname)) {
+ return $fname;
}
if ($withContent) {
- $res = $r = $this->gb->bsExportPlaylistOpen($plid);
- if (PEAR::isError($r)) {
- return $r;
+ $res = $this->gb->bsExportPlaylistOpen($plid);
+ if (PEAR::isError($res)) {
+ return $res;
}
$tmpn = tempnam($this->transDir, 'plExport_');
$plfpath = "$tmpn.lspl";
copy($res['fname'], $plfpath);
- $res = $r = $this->gb->bsExportPlaylistClose($res['token']);
- if (PEAR::isError($r)) {
- return $r;
+ $res = $this->gb->bsExportPlaylistClose($res['token']);
+ if (PEAR::isError($res)) {
+ return $res;
}
$fname = $fname.".lspl";
$trtype = 'playlistPkg';
} else {
- $plfpath = $r = $pl->_getRealMDFname();
- if (PEAR::isError($r)) {
- return $r;
+ $plfpath = $pl->_getRealMDFname();
+ if (PEAR::isError($plfpath)) {
+ return $plfpath;
}
$trtype = 'playlist';
}
- $trec = $r = $this->_uploadGenFile2Hub($plfpath, $trtype,
+ $trec = $this->_uploadGeneralFileToHub($plfpath, $trtype,
array_merge(array('gunid'=>$plid,'fname'=>$fname,), $pars)
);
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($trec)) {
+ return $trec;
}
break;
default:
@@ -357,7 +403,7 @@ class Transport
{
# $this->trLog(var_export($gunid, TRUE));
$trtype = ($withContent ? 'playlistPkg' : 'unknown' );
- $trec = $r = TransportRecord::create($this, $trtype, 'down',
+ $trec = TransportRecord::create($this, $trtype, 'down',
array_merge(array('gunid'=>$gunid, 'uid'=>$uid), $pars)
/* merged !???
array(
@@ -371,8 +417,8 @@ class Transport
),
*/
);
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$this->startCronJobProcess($trec->trtok);
return $trec->trtok;
@@ -386,7 +432,7 @@ class Transport
* @param array $criteria
* LS criteria format (see localSearch)
* @param string $resultMode
- * 'php' | 'xmlrpc' (optional)
+ * 'php' | 'xmlrpc'
* @param array $pars
* default parameters (optional, internal use)
* @return string
@@ -397,10 +443,10 @@ class Transport
$criteria['resultMode'] = $resultMode;
$localfile = tempnam($this->transDir, 'searchjob_');
@chmod($localfile, 0660);
- $len = $r = file_put_contents($localfile, serialize($criteria));
- $trec = $r = $this->_uploadGenFile2Hub($localfile, 'searchjob', $pars);
- if (PEAR::isError($r)) {
- return $r;
+ $len = file_put_contents($localfile, serialize($criteria));
+ $trec = $this->_uploadGeneralFileToHub($localfile, 'searchjob', $pars);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$this->startCronJobProcess($trec->trtok);
return $trec->trtok;
@@ -417,10 +463,11 @@ class Transport
*/
function getSearchResults($trtok)
{
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
+ //echo"";print_r($trec);echo " ";
$row = $trec->row;
switch ($st = $trec->getState()) {
case "failed":
@@ -429,15 +476,13 @@ class Transport
" global search or results transport failed".
" ({$trec->row['errmsg']})"
);
- break;
case "closed":
return PEAR::raiseError(
"Transport::getSearchResults:".
" closed transport token ($trtok)", TRERR_TOK
);
- break;
case "finished":
- if ($row['direction']=='down') {
+ if ($row['direction'] == 'down') {
break; // really finished
}
// otherwise only request upload finished
@@ -448,6 +493,7 @@ class Transport
);
}
$res = file_get_contents($row['localfile']);
+ //print_r($res);
$results = unserialize($res);
@unlink($row['localfile']);
$r = $trec->close();
@@ -477,9 +523,9 @@ class Transport
"Transport::uploadFile2Hub: file not found ($filePath)"
);
}
- $trec = $r = $this->_uploadGenFile2Hub($filePath, 'file', $pars);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = $this->_uploadGeneralFileToHub($filePath, 'file', $pars);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$this->startCronJobProcess($trec->trtok);
return $trec->trtok;
@@ -493,11 +539,11 @@ class Transport
* @param string $url
* readable url
* @param string $chsum
- * checksum from remote side (optional)
+ * checksum from remote side
* @param int $size
- * filesize from remote side (otional)
+ * filesize from remote side
* @param array $pars
- * default parameters (optional, internal use)
+ * default parameters (internal use)
* @return array
* trtok: string - transport token
* localfile: string - filepath of downloaded file
@@ -505,7 +551,7 @@ class Transport
function downloadFileFromHub($url, $chsum=NULL, $size=NULL, $pars=array())
{
$tmpn = tempnam($this->transDir, 'HITrans_');
- $trec = $r = TransportRecord::create($this, 'file', 'down',
+ $trec = TransportRecord::create($this, 'file', 'down',
array_merge(array(
'url' => $url,
'localfile' => $tmpn,
@@ -513,8 +559,8 @@ class Transport
'expectedsize' => $size,
), $pars)
);
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$this->startCronJobProcess($trec->trtok);
return array('trtok'=>$trec->trtok, 'localfile'=>$tmpn);
@@ -530,14 +576,10 @@ class Transport
*/
function getHubInitiatedTransfers()
{
- $ret = $r = $this->xmlrpcCall(
- 'archive.listHubInitiatedTransfers',
- array(
- 'target' => HOSTNAME,
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ $ret = $this->xmlrpcCall('archive.listHubInitiatedTransfers',
+ array('target' => HOSTNAME));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
$res = array();
foreach ($ret as $it) {
@@ -560,15 +602,13 @@ class Transport
*/
function startHubInitiatedTransfer($uid, $rtrtok)
{
- $ret = $r = $this->xmlrpcCall(
- 'archive.listHubInitiatedTransfers',
+ $ret = $this->xmlrpcCall('archive.listHubInitiatedTransfers',
array(
'target' => HOSTNAME,
'trtok' => $rtrtok,
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ ));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
if (count($ret) != 1) {
return PEAR::raiseError(
@@ -586,10 +626,10 @@ class Transport
case "audioclip":
case "playlist":
case "playlistPkg":
- $trtok = $r = $this->upload2Hub($gunid, TRUE,
+ $trtok = $this->upload2Hub($gunid, TRUE,
array('rtrtok'=>$rtrtok));
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($trtok)) {
+ return $trtok;
}
break;
//case "searchjob": break; // not supported yet
@@ -607,10 +647,10 @@ class Transport
case "audioclip":
case "playlist":
case "playlistPkg":
- $trtok = $r = $this->downloadFromHub($uid, $gunid, TRUE,
+ $trtok = $this->downloadFromHub($uid, $gunid, TRUE,
array('rtrtok'=>$rtrtok));
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($trtok)) {
+ return $trtok;
}
break;
//case "searchjob": break; // probably unusable
@@ -636,16 +676,14 @@ class Transport
"Transport::startHubInitiatedTransfer: ???"
);
}
- $ret = $r = $this->xmlrpcCall(
- 'archive.setHubInitiatedTransfer',
+ $ret = $this->xmlrpcCall('archive.setHubInitiatedTransfer',
array(
'target' => HOSTNAME,
'trtok' => $rtrtok,
'state' => 'waiting',
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ ));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
$this->startCronJobProcess($trtok);
return $trtok;
@@ -663,13 +701,11 @@ class Transport
*/
function loginToArchive()
{
- $res = $this->xmlrpcCall(
- 'archive.login',
+ $res = $this->xmlrpcCall('archive.login',
array(
'login'=>$this->config['archiveAccountLogin'],
'pass'=>$this->config['archiveAccountPass']
- )
- );
+ ));
return $res;
}
@@ -684,12 +720,8 @@ class Transport
*/
function logoutFromArchive($sessid)
{
- $res = $this->xmlrpcCall(
- 'archive.logout',
- array(
- 'sessid'=>$sessid,
- )
- );
+ $res = $this->xmlrpcCall('archive.logout',
+ array('sessid'=>$sessid));
return $res;
}
@@ -718,13 +750,13 @@ class Transport
return TRUE;
}
// fetch all opened transports
- $transports = $r = $this->getTransports($direction);
- if (PEAR::isError($r)) {
+ $transports = $this->getTransports($direction);
+ if (PEAR::isError($transports)) {
$this->trLog("cronMain: DB error");
return FALSE;
}
- if (count($transports)==0) {
- if (TR_LOG_LEVEL>1) {
+ if (count($transports) == 0) {
+ if (TR_LOG_LEVEL > 1) {
$this->trLog("cronMain: $direction - nothing to do.");
}
return TRUE;
@@ -733,7 +765,7 @@ class Transport
$r = $this->pingToArchive();
chdir($this->config['transDir']);
// for all opened transports:
- foreach ($transports as $i=>$row) {
+ foreach ($transports as $i => $row) {
$r = $this->startCronJobProcess($row['trtok']);
} // foreach transports
return TRUE;
@@ -777,16 +809,19 @@ class Transport
*/
function cronCallMethod($trtok)
{
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
$row = $trec->row;
$state = $row['state'];
- $states = array('init'=>'init', 'pending'=>'pending',
- 'waiting'=>'waiting', 'finished'=>'finished', 'failed'=>'failed',
- 'closed'=>'closed');
+ $states = array('init'=>'init',
+ 'pending'=>'pending',
+ 'waiting'=>'waiting',
+ 'finished'=>'finished',
+ 'failed'=>'failed',
+ 'closed'=>'closed');
$directions = array('up'=>'upload', 'down'=>'download');
// method name construction:
$mname = "cron";
@@ -811,16 +846,15 @@ class Transport
case 'pending':
case 'paused':
return TRUE;
- break;
case 'waiting':
require_once('Prefs.php');
- $pr =& new Prefs($this->gb);
- $group = 'StationPrefs';
- $key = 'TransportsDenied';
- $res = $r = $pr->loadGroupPref(NULL/*sessid*/, $group, $key);
- if (PEAR::isError($r)) {
- if ($r->getCode() !== GBERR_PREF) {
- return $r;
+ $pr = new Prefs($this->gb);
+ $group = 'StationPrefs';
+ $key = 'TransportsDenied';
+ $res = $pr->loadGroupPref(NULL/*sessid*/, $group, $key);
+ if (PEAR::isError($res)) {
+ if ($res->getCode() !== GBERR_PREF) {
+ return $res;
} else {
$res = FALSE; // default
}
@@ -835,16 +869,15 @@ class Transport
// NO break here!
default:
if (method_exists($this, $mname)) {
-
// lock the job:
$r = $trec->setLock(TRUE);
if (PEAR::isError($r)) {
return $r;
}
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- $r2 = $trec->setLock(FALSE);
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ $trec->setLock(FALSE);
+ return $trec;
}
$row = $trec->row;
$state = $row['state'];
@@ -857,15 +890,15 @@ class Transport
}
$asessid = $r['sessid'];
// method call:
- if (TR_LOG_LEVEL>2) {
+ if (TR_LOG_LEVEL > 2) {
$this->trLog("cronCallMethod: $mname($trtok) >");
}
$ret = call_user_func(array($this, $mname), $row, $asessid);
if (PEAR::isError($ret)) {
- $r = $trec->setLock(FALSE);
+ $trec->setLock(FALSE);
return $this->_failFatal($ret, $trec);
}
- if (TR_LOG_LEVEL>2) {
+ if (TR_LOG_LEVEL > 2) {
$this->trLog("cronCallMethod: $mname($trtok) <");
}
// unlock the job:
@@ -901,18 +934,17 @@ class Transport
function cronUploadInit($row, $asessid)
{
$trtok = $row['trtok'];
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
- $ret = $r = $this->xmlrpcCall( 'archive.uploadOpen',
+ $ret = $this->xmlrpcCall('archive.uploadOpen',
array(
- 'sessid' => $asessid ,
- 'chsum' => $row['expectedsum'],
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ 'sessid' => $asessid ,
+ 'chsum' => $row['expectedsum'],
+ ));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
$r = $trec->setState('waiting',
array('url'=>$ret['url'], 'pdtoken'=>$ret['token']));
@@ -936,12 +968,11 @@ class Transport
function cronDownloadInit($row, $asessid)
{
$trtok = $row['trtok'];
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
- $ret = $r = $this->xmlrpcCall(
- 'archive.downloadOpen',
+ $ret = $this->xmlrpcCall('archive.downloadOpen',
array(
'sessid'=> $asessid,
'trtype'=> $row['trtype'],
@@ -949,45 +980,44 @@ class Transport
'gunid' => $row['gunid'],
'token' => $row['pdtoken'],
),
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ ));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
$trtype = $ret['trtype'];
$title = $ret['title'];
$pars = array();
switch ($trtype) {
- case "searchjob":
- $r = $trec->setState('waiting', $pars);
- break;
- case "file":
- $r = $trec->setState('waiting',array_merge($pars, array(
- 'trtype'=>$trtype,
- 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
- 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
- 'fname'=>$ret['filename'],
- 'localfile'=>"{$this->transDir}/$trtok",
- )));
- break;
- case "audioclip":
- $mdtrec = $r = TransportRecord::create($this, 'metadata', 'down',
- array('gunid'=>$row['gunid'], 'uid'=>$row['uid'], )
- );
- if (PEAR::isError($r)) {
- return $r;
- }
- $this->startCronJobProcess($mdtrec->trtok);
- $pars = array('mdtrtok'=>$mdtrec->trtok);
- // NO break here !
- default:
- $r = $trec->setState('waiting',array_merge($pars, array(
- 'trtype'=>$trtype,
- 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
- 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
- 'fname'=>$ret['filename'], 'title'=>$title,
- 'localfile'=>"{$this->transDir}/$trtok",
- )));
+ case "searchjob":
+ $r = $trec->setState('waiting', $pars);
+ break;
+ case "file":
+ $r = $trec->setState('waiting',array_merge($pars, array(
+ 'trtype'=>$trtype,
+ 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
+ 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
+ 'fname'=>$ret['filename'],
+ 'localfile'=>"{$this->transDir}/$trtok",
+ )));
+ break;
+ case "audioclip":
+ $mdtrec = TransportRecord::create($this, 'metadata', 'down',
+ array('gunid'=>$row['gunid'], 'uid'=>$row['uid'], )
+ );
+ if (PEAR::isError($mdtrec)) {
+ return $mdtrec;
+ }
+ $this->startCronJobProcess($mdtrec->trtok);
+ $pars = array('mdtrtok'=>$mdtrec->trtok);
+ // NO break here !
+ default:
+ $r = $trec->setState('waiting',array_merge($pars, array(
+ 'trtype'=>$trtype,
+ 'url'=>$ret['url'], 'pdtoken'=>$ret['token'],
+ 'expectedsum'=>$ret['chsum'], 'expectedsize'=>$ret['size'],
+ 'fname'=>$ret['filename'], 'title'=>$title,
+ 'localfile'=>"{$this->transDir}/$trtok",
+ )));
}
if (PEAR::isError($r)) {
return $r;
@@ -1009,23 +1039,23 @@ class Transport
function cronUploadWaiting($row, $asessid)
{
$trtok = $row['trtok'];
- $check = $r = $this->uploadCheck($row['pdtoken']);
- if (PEAR::isError($r)) {
- return $r;
+ $check = $this->uploadCheck($row['pdtoken']);
+ if (PEAR::isError($check)) {
+ return $check;
}
// test filesize
if (!file_exists($row['localfile'])) {
return PEAR::raiseError("Transport::cronUploadWaiting:".
- " file beeing uploaded not exists! ({$row['localfile']})"
+ " file being uploaded does not exist! ({$row['localfile']})"
);
}
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
- $size = escapeshellarg($check['size']);
- $localfile = escapeshellarg($row['localfile']);
- $url = escapeshellarg($row['url']);
+ $size = escapeshellarg($check['size']);
+ $localfile = escapeshellarg($row['localfile']);
+ $url = escapeshellarg($row['url']);
$command =
"curl -f -s -C $size --max-time {$this->upTrMaxTime}".
" --speed-time {$this->upTrSpeedTime}".
@@ -1033,8 +1063,7 @@ class Transport
" --connect-timeout {$this->upTrConnectTimeout}".
(!is_null($this->upLimitRate)?
" --limit-rate {$this->upLimitRate}" : "").
- " -T $localfile $url"
- ;
+ " -T $localfile $url";
$r = $trec->setState('pending', array(), 'waiting');
if (PEAR::isError($r)) {
return $r;
@@ -1100,12 +1129,12 @@ class Transport
{
$trtok = $row['trtok'];
// wget the file
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
- $localfile = escapeshellarg($row['localfile']);
- $url = escapeshellarg($row['url']);
+ $localfile = escapeshellarg($row['localfile']);
+ $url = escapeshellarg($row['url']);
$command =
"wget -q -c".
" --timeout={$this->downTimeout}".
@@ -1124,7 +1153,7 @@ class Transport
}
$res = system($command, $status);
// check consistency
- $size = filesize($row['localfile']);
+ $size = filesize($row['localfile']);
if ($status == 0 || ($status == 1 && $size >= $row['expectedsize'])) {
$chsum = $this->_chsum($row['localfile']);
if ($chsum == $row['expectedsum']) {
@@ -1166,9 +1195,9 @@ class Transport
function cronUploadFinished($row, $asessid)
{
$trtok = $row['trtok'];
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
// don't close metadata transport - audioclip will close it
if ($row['trtype'] == 'metadata') {
@@ -1176,9 +1205,9 @@ class Transport
}
// handle metadata transport on audioclip trtype:
if ($row['trtype'] == 'audioclip') {
- $mdtrec = $r = TransportRecord::recall($this, $trec->row['mdtrtok']);
- if (PEAR::isError($r)) {
- return $r;
+ $mdtrec = TransportRecord::recall($this, $trec->row['mdtrtok']);
+ if (PEAR::isError($mdtrec)) {
+ return $mdtrec;
}
switch ($mdtrec->row['state']) {
case 'failed':
@@ -1200,7 +1229,7 @@ class Transport
} else {
$mdpdtoken = NULL;
}
- $ret = $r = $this->xmlrpcCall( 'archive.uploadClose',
+ $ret = $this->xmlrpcCall('archive.uploadClose',
array(
'token' => $row['pdtoken'] ,
'trtype' => $row['trtype'],
@@ -1209,13 +1238,12 @@ class Transport
'name' => $row['fname'],
'mdpdtoken' => $mdpdtoken,
),
- )
- );
- if (PEAR::isError($r)) {
+ ));
+ if (PEAR::isError($ret)) {
if ($row['trtype'] == 'audioclip') {
$r2 = $mdtrec->close();
}
- return $r;
+ return $ret;
}
if ($row['trtype'] == 'searchjob') {
@@ -1275,16 +1303,16 @@ class Transport
function cronDownloadFinished($row, $asessid)
{
$trtok = $row['trtok'];
- $trec = $r = TransportRecord::recall($this, $trtok);
- if (PEAR::isError($r)) {
- return $r;
+ $trec = TransportRecord::recall($this, $trtok);
+ if (PEAR::isError($trec)) {
+ return $trec;
}
switch ($row['trtype']) {
case "audioclip":
$mdtrtok = $trec->row['mdtrtok'];
- $mdtrec = $r = TransportRecord::recall($this, $mdtrtok);
- if (PEAR::isError($r)) {
- return $r;
+ $mdtrec = TransportRecord::recall($this, $mdtrtok);
+ if (PEAR::isError($mdtrec)) {
+ return $mdtrec;
}
$r = $mdtrec->setLock(TRUE);
if (PEAR::isError($r)) {
@@ -1301,30 +1329,27 @@ class Transport
return $r;
}
return TRUE;
- break;
case 'finished': // metadata finished, close main transport
- $parid = $r = $this->gb->_getHomeDirId($trec->row['uid']);
- if ($this->dbc->isError($r)) {
- $r2 = $mdtrec->setLock(FALSE);
- return $r;
+ $parid = $this->gb->_getHomeDirId($trec->row['uid']);
+ if ($this->dbc->isError($parid)) {
+ $mdtrec->setLock(FALSE);
+ return $parid;
}
- $res = $r = $this->gb->bsPutFile($parid, $row['fname'],
+ $res = $this->gb->bsPutFile($parid, $row['fname'],
$trec->row['localfile'], $mdtrec->row['localfile'],
$row['gunid'], 'audioclip', 'file');
- if ($this->dbc->isError($r)) {
- $r2 = $mdtrec->setLock(FALSE);
- return $r;
+ if ($this->dbc->isError($res)) {
+ $mdtrec->setLock(FALSE);
+ return $res;
}
- $ret = $r = $this->xmlrpcCall(
- 'archive.downloadClose',
+ $ret = $this->xmlrpcCall('archive.downloadClose',
array(
'token' => $mdtrec->row['pdtoken'] ,
'trtype' => 'metadata' ,
- )
- );
- if (PEAR::isError($r)) {
- $r2 = $mdtrec->setLock(FALSE);
- return $r;
+ ));
+ if (PEAR::isError($ret)) {
+ $mdtrec->setLock(FALSE);
+ return $ret;
}
$r = $mdtrec->close();
if (PEAR::isError($r)) {
@@ -1340,7 +1365,6 @@ class Transport
" metadata transport in wrong state: {$mdtrec->row['state']}".
" ({$this->trtok})"
);
- break;
}
$r = $mdtrec->setLock(FALSE);
if (PEAR::isError($r)) {
@@ -1352,40 +1376,38 @@ class Transport
return TRUE; // don't close
break;
}
- $ret = $r = $this->xmlrpcCall(
- 'archive.downloadClose',
+ $ret = $this->xmlrpcCall('archive.downloadClose',
array(
'token' => $row['pdtoken'] ,
'trtype' => $row['trtype'] ,
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ ));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
switch ($row['trtype']) {
case "playlist":
- $parid = $r = $this->gb->_getHomeDirId($trec->row['uid']);
- if ($this->dbc->isError($r)) {
- return $r;
+ $parid = $this->gb->_getHomeDirId($trec->row['uid']);
+ if ($this->dbc->isError($parid)) {
+ return $parid;
}
- $res = $r = $this->gb->bsPutFile($parid, $row['fname'],
+ $res = $this->gb->bsPutFile($parid, $row['fname'],
'', $trec->row['localfile'],
$row['gunid'], 'playlist', 'file');
- if ($this->dbc->isError($r)) {
- return $r;
+ if ($this->dbc->isError($res)) {
+ return $res;
}
@unlink($row['localfile']);
break;
case "playlistPkg":
$subjid = $trec->row['uid'];
$fname = $trec->row['localfile'];
- $parid = $r = $this->gb->_getHomeDirId($subjid);
- if ($this->dbc->isError($r)) {
- return $r;
+ $parid = $this->gb->_getHomeDirId($subjid);
+ if ($this->dbc->isError($parid)) {
+ return $parid;
}
- $res = $r = $this->gb->bsImportPlaylist($parid, $fname, $subjid);
- if ($this->dbc->isError($r)) {
- return $r;
+ $res = $this->gb->bsImportPlaylist($parid, $fname, $subjid);
+ if ($this->dbc->isError($res)) {
+ return $res;
}
@unlink($fname);
break;
@@ -1398,16 +1420,14 @@ class Transport
return PEAR::raiseError("DEBUG: NotImpl ".var_export($row,TRUE));
}
if (!is_null($rtrtok = $trec->row['rtrtok'])) {
- $ret = $r = $this->xmlrpcCall(
- 'archive.setHubInitiatedTransfer',
+ $ret = $this->xmlrpcCall('archive.setHubInitiatedTransfer',
array(
'target' => HOSTNAME,
'trtok' => $rtrtok,
'state' => 'closed',
- )
- );
- if (PEAR::isError($r)) {
- return $r;
+ ));
+ if (PEAR::isError($ret)) {
+ return $ret;
}
}
$r = $trec->close();
@@ -1430,17 +1450,19 @@ class Transport
* default parameters (optional, internal use)
* @return object - transportRecord instance
*/
- function _uploadGenFile2Hub($fpath, $trtype, $pars=array())
+ function _uploadGeneralFileToHub($fpath, $trtype, $pars=array())
{
$chsum = $this->_chsum($fpath);
$size = filesize($fpath);
- $trec = $r = TransportRecord::create($this, $trtype, 'up',
+ $trec = TransportRecord::create($this, $trtype, 'up',
array_merge(array(
'localfile'=>$fpath, 'fname'=>basename($fpath),
'expectedsum'=>$chsum, 'expectedsize'=>$size
), $pars)
);
- if (PEAR::isError($r)) { return $r; }
+ if (PEAR::isError($trec)) {
+ return $trec;
+ }
return $trec;
}
@@ -1451,11 +1473,10 @@ class Transport
* @return string
* transport token
*/
- function _createTrtok()
+ function _createTransportToken()
{
$ip = (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '');
- $initString =
- microtime().$ip.rand()."org.mdlf.campcaster";
+ $initString = microtime().$ip.rand()."org.mdlf.campcaster";
$hash = md5($initString);
$res = substr($hash, 0, 16);
return $res;
@@ -1477,9 +1498,15 @@ class Transport
function getTransports($direction=NULL, $target=NULL, $trtok=NULL)
{
switch ($direction) {
- case 'up': $dirCond = "direction='up' AND"; break;
- case 'down': $dirCond = "direction='down' AND"; break;
- default: $dirCond = ''; break;
+ case 'up':
+ $dirCond = "direction='up' AND";
+ break;
+ case 'down':
+ $dirCond = "direction='down' AND";
+ break;
+ default:
+ $dirCond = '';
+ break;
}
if (is_null($target)) {
$targetCond = "";
@@ -1523,10 +1550,8 @@ class Transport
*/
function uploadCheck($pdtoken)
{
- $ret = $this->xmlrpcCall(
- 'archive.uploadCheck',
- array('token'=>$pdtoken)
- );
+ $ret = $this->xmlrpcCall('archive.uploadCheck',
+ array('token'=>$pdtoken));
return $ret;
}
@@ -1539,12 +1564,8 @@ class Transport
*/
function pingToArchive()
{
- $res = $this->xmlrpcCall(
- 'archive.ping',
- array(
- 'par'=>'ping_'.date('H:i:s')
- )
- );
+ $res = $this->xmlrpcCall('archive.ping',
+ array('par'=>'ping_'.date('H:i:s')));
return $res;
}
@@ -1660,9 +1681,9 @@ class Transport
$msg = $txt.$eo->getMessage()." ".$eo->getUserInfo().
" [".$eo->getCode()."]";
if (!is_null($row)) {
- $trec = $r = TransportRecord::recall($this, $row['trtok']);
- if (!PEAR::isError($r)) {
- $r = $trec->setState('failed', array('errmsg'=>$msg));
+ $trec = TransportRecord::recall($this, $row['trtok']);
+ if (!PEAR::isError($trec)) {
+ $trec->setState('failed', array('errmsg'=>$msg));
}
$msg .= "\n ".serialize($row);
}
diff --git a/campcaster/src/modules/storageServer/var/TransportRecord.php b/campcaster/src/modules/storageServer/var/TransportRecord.php
index 980ddff3d..ac94a7e73 100644
--- a/campcaster/src/modules/storageServer/var/TransportRecord.php
+++ b/campcaster/src/modules/storageServer/var/TransportRecord.php
@@ -3,26 +3,60 @@
define('TR_LEAVE_CLOSED', TRUE);
/**
- * Auxiliary class for transport records
+ * Auxiliary class for transport records
*
- * @author $Author: tomash $
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision: 1946 $
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class TransportRecord
{
- var $dbc;
- var $recalled = FALSE;
- var $dropped = FALSE;
+ /**
+ * @var DB
+ */
+ public $dbc;
/**
- * Constructor
- *
- * @param Transport $tr object reference
- * @return TransportRecord object instance
+ * @var GreenBox
*/
- function TransportRecord(&$tr)
+ private $gb;
+
+ /**
+ * @var array
+ */
+ private $config;
+
+ /**
+ * @var string
+ */
+ private $transTable;
+
+ /**
+ * @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;
@@ -46,8 +80,8 @@ class TransportRecord
*/
function create(&$tr, $trtype, $direction='up', $defaults=array())
{
- $trec =& new TransportRecord($tr);
- $trec->trtok = $trtok = $tr->_createTrtok();
+ $trec = new TransportRecord($tr);
+ $trec->trtok = $trtok = $tr->_createTransportToken();
$trec->row = array_merge($defaults,
array('trtype'=>$trtype, 'direction'=>$direction));
$trec->recalled = TRUE;
@@ -60,7 +94,7 @@ class TransportRecord
$id = $trec->dbc->nextId("{$trec->transTable}_id_seq");
$names = "id, trtok, direction, state, trtype, start, ts";
$values = "$id, '$trtok', '$direction', 'init', '$trtype', now(), now()";
- foreach ($defaults as $k=>$v) {
+ foreach ($defaults as $k => $v) {
$sqlVal = $trec->_getSqlVal($k, $v);
$names .= ", $k";
$values .= ", $sqlVal";
@@ -71,16 +105,16 @@ class TransportRecord
VALUES
($values)
";
- $res = $r = $trec->dbc->query($query);
- if (PEAR::isError($r)) {
- return $r;
+ $res = $trec->dbc->query($query);
+ if (PEAR::isError($res)) {
+ return $res;
}
return $trec;
}
/**
- * Recall transport record from DB
+ * Recall transport record from DB
*
* @param Transport $tr
* @param string $trtok
@@ -89,9 +123,9 @@ class TransportRecord
*/
function recall(&$tr, $trtok)
{
- $trec =& new TransportRecord($tr);
+ $trec = new TransportRecord($tr);
$trec->trtok = $trtok;
- $row = $r = $trec->dbc->getRow("
+ $row = $trec->dbc->getRow("
SELECT
id, trtok, state, trtype, direction,
to_hex(gunid)as gunid, to_hex(pdtoken)as pdtoken,
@@ -101,8 +135,8 @@ class TransportRecord
FROM {$trec->transTable}
WHERE trtok='$trtok'
");
- if (PEAR::isError($r)) {
- return $r;
+ if (PEAR::isError($row)) {
+ return $row;
}
if (is_null($row)) {
return PEAR::raiseError("TransportRecord::recall:".
@@ -118,15 +152,15 @@ class TransportRecord
/**
- * Set state of transport record
+ * Set state of transport record
*
* @param string $newState
* @param array $data
* other data fields to set
* @param string $oldState
- * (opt.) check old state and do nothing if differ
+ * check old state and do nothing if differ
* @param boolean $lock
- * (opt.) check lock and do nothing if differ
+ * check lock and do nothing if differ
* @return boolean success
*/
function setState($newState, $data=array(), $oldState=NULL, $lock=NULL)
@@ -152,9 +186,9 @@ class TransportRecord
return $r;
}
// return TRUE;
- $affRows = $r = $this->dbc->affectedRows();
- if (PEAR::isError($r)) {
- return $r;
+ $affRows = $this->dbc->affectedRows();
+ if (PEAR::isError($affRows)) {
+ return $affRows;
}
return ($affRows == 1);
}
@@ -201,9 +235,9 @@ class TransportRecord
if (PEAR::isError($r)) {
return $r;
}
- $affRows = $r = $this->dbc->affectedRows();
- if (PEAR::isError($r)) {
- return $r;
+ $affRows = $this->dbc->affectedRows();
+ if (PEAR::isError($affRows)) {
+ return $affRows;
}
if ($affRows != 1) {
$ltxt = ($lock ? 'lock' : 'unlock' );
@@ -333,21 +367,21 @@ class TransportRecord
function getTitle()
{
$defStr = 'unknown';
- $trtype = $r = $this->getTransportType(); //contains recall check
- if (PEAR::isError($r)) {
- return $r;
+ $trtype = $this->getTransportType(); //contains recall check
+ if (PEAR::isError($trtype)) {
+ return $trtype;
}
switch ($trtype) {
case "audioclip":
case "playlist":
case "playlistPkg":
case "metadata":
- $title = $r = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
- if (PEAR::isError($r)) {
- if ($r->getCode()==GBERR_FOBJNEX) {
+ $title = $this->gb->bsGetTitle(NULL, $this->row['gunid']);
+ if (PEAR::isError($title)) {
+ if ($title->getCode() == GBERR_FOBJNEX) {
$title = $defStr;
} else {
- return $r;
+ return $title;
}
}
break;
diff --git a/campcaster/src/modules/storageServer/var/Validator.php b/campcaster/src/modules/storageServer/var/Validator.php
index 415082890..eefd33161 100644
--- a/campcaster/src/modules/storageServer/var/Validator.php
+++ b/campcaster/src/modules/storageServer/var/Validator.php
@@ -23,24 +23,33 @@ define('VAL_PREDXML', 121);
*
* It probably should be replaced by XML schema validation in the future.
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
class Validator {
/**
- * string - format type of validated document
+ * Format type of validated document
+ * @var string
*/
- var $format = NULL;
+ private $format = NULL;
+
/**
- * Preloaded format tree structure
+ * Preloaded format tree structure
+ * @var array
*/
- var $formTree = NULL;
+ private $formTree = NULL;
+
/**
- * string - gunid of validated file for identification in mass input
+ * Gunid of validated file for identification in mass input
+ * @var string
*/
- var $gunid = NULL;
+ private $gunid = NULL;
/**
@@ -51,11 +60,11 @@ class Validator {
* @param string $gunid
* gunid of validated file for identification in mass input
*/
- function Validator($format, $gunid)
+ public function __construct($format, $gunid)
{
- $format = strtolower($format);
- $this->format = $format;
- $this->gunid = $gunid;
+ $format = strtolower($format);
+ $this->format = $format;
+ $this->gunid = $gunid;
$formats = array(
'audioclip' => "audioClipFormat",
'playlist' => "playlistFormat",
@@ -69,7 +78,7 @@ class Validator {
if (!file_exists($formatFile)) {
return $this->_err(VAL_FORMAT);
}
- require $formatFile;
+ require($formatFile);
$this->formTree = $$formatName;
}
diff --git a/campcaster/src/modules/storageServer/var/XmlParser.php b/campcaster/src/modules/storageServer/var/XmlParser.php
index bbcea8080..bc82ce579 100644
--- a/campcaster/src/modules/storageServer/var/XmlParser.php
+++ b/campcaster/src/modules/storageServer/var/XmlParser.php
@@ -1,6 +1,7 @@
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
@@ -12,58 +13,71 @@ require_once "XML/Util.php";
/**
* Object representation of one XML element
*
- * @author $Author$
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see MetaData
*/
class XmlElement {
/**
- * Namespace prefix
+ * Namespace prefix
+ * @var string
*/
- var $ns;
- /**
- * Element name
- */
- var $name;
- /**
- * Attributes
- */
- var $attrs = array();
- /**
- * Namespace definitions
- */
- var $nSpaces = array();
- /**
- * Child nodes
- */
- var $children = array();
- /**
- * Text content of element
- */
- var $content = '';
+ public $ns;
/**
- * Constructor
- *
- * @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
- * @return this
+ * Element name
+ * @var string
*/
- function XmlElement($fullname, $attrs, $nSpaces=array(), $children=array())
+ 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->ns = $a['namespace'];
$this->name = $a['localPart'];
- $this->attrs = $attrs;
- $this->nSpaces = $nSpaces;
+ $this->attrs = $attrs;
+ $this->nSpaces = $nSpaces;
$this->children = $children;
}
} // class XmlElement
@@ -73,39 +87,47 @@ class XmlElement {
/**
* Object representation of one XML attribute
*
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
* @see MetaData
*/
class XmlAttrib {
/**
- * Namespace prefix
+ * Namespace prefix
+ * @var string
*/
- var $ns;
+ public $ns;
+
/**
- * Attribute name
+ * Attribute name
+ * @var string
*/
- var $name;
+ public $name;
+
/**
- * Attribute value
+ * Attribute value
+ * @var string
*/
- var $val;
+ public $val;
+
/**
- * Constructor
- *
- * @param string $atns
+ * @param string $atns
* namespace prefix
- * @param string $atnm
+ * @param string $atnm
* attribute name
- * @param string $atv
+ * @param string $atv
* attribute value
- * @return this
*/
- function XmlAttrib($atns, $atnm, $atv)
+ public function __construct($atns, $atnm, $atv)
{
- $this->ns = $atns;
+ $this->ns = $atns;
$this->name = $atnm;
- $this->val = $atv;
+ $this->val = $atv;
}
} // fn XmlAttrib
@@ -114,32 +136,39 @@ class XmlAttrib {
/**
* XML parser object encapsulation
*
+ * @author Tomas Hlava
+ * @author Paul Baranowski
* @package Campcaster
* @subpackage StorageServer
- * @see MetaData
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
+ * @see MetaData
*/
class XmlParser {
/**
- * Tree of nodes
+ * Tree of nodes
+ * @var array
*/
- var $tree = NULL;
- /**
- * Parse stack
- */
- var $stack = array();
- /**
- * Error structure
- */
- var $err = array(FALSE, '');
+ private $tree = NULL;
/**
- * Constructor
- *
- * @param string $data
- * XML string to be parsed
- * @return this
+ * Parse stack
+ * @var array
*/
- function XmlParser($data){
+ 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);
@@ -185,7 +214,7 @@ class XmlParser {
}
$data = file_get_contents($data);
case "string":
- $parser =& new XmlParser($data);
+ $parser = new XmlParser($data);
if ($parser->isError()) {
return PEAR::raiseError(
"SmilPlaylist::parse: ".$parser->getError()
@@ -234,13 +263,13 @@ class XmlParser {
/**
- * End tag handler
+ * End tag handler
*
- * @param resource $parser
+ * @param resource $parser
* reference to parser resource
- * @param string $fullname
+ * @param string $fullname
* element name
- * @return none
+ * @return none
*/
function endTag($parser, $fullname) {
$cnt = count($this->stack);
diff --git a/campcaster/src/modules/storageServer/var/cron/Cron.php b/campcaster/src/modules/storageServer/var/cron/Cron.php
index 23be466c1..4be3ba3c0 100755
--- a/campcaster/src/modules/storageServer/var/cron/Cron.php
+++ b/campcaster/src/modules/storageServer/var/cron/Cron.php
@@ -23,20 +23,24 @@ require_once (dirname(__FILE__).'/../conf.php');
*/
class Cron {
/**
- * @var reference Crontab object reference
+ * @var Crontab
*/
- var $ct;
+ public $ct;
/**
* @var array This array created with getCommand() function
- * @access private
*/
- var $params;
+ private $params;
/**
* @var string available values: read | write
*/
- var $ctAccess = 'read';
+ private $ctAccess = 'read';
+
+ private $lockfile;
+ private $cronfile;
+ private $paramdir;
+ private $cronUserName;
/**
* Constructor
diff --git a/campcaster/src/modules/storageServer/var/cron/Crontab.php b/campcaster/src/modules/storageServer/var/cron/Crontab.php
index 0bb40d0e0..d1c450e49 100755
--- a/campcaster/src/modules/storageServer/var/cron/Crontab.php
+++ b/campcaster/src/modules/storageServer/var/cron/Crontab.php
@@ -9,6 +9,7 @@ define('CRON_EMPTY', 4);
* A class that interfaces with the crontab. (cjpa@audiophile.com)
*
* This class lets you manipulate the crontab. It lets you add delete update entries easily.
+ *
* @author $Author: $
* @version $Revision: $
* @package Campcaster
@@ -18,7 +19,7 @@ class Crontab
{
// {{{ properties
/**
- * @var array holds all the different lines.
+ * 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)
@@ -30,20 +31,23 @@ class Crontab
* "name" => "value"
* or a line can be a comment (string beginning with #)
* or it can be a special command (beginning with an @)
+ * @var array
*/
- var $crontabs;
+ private $crontabs;
/**
- * @var string the user for whom the crontab will be manipulated
+ * The user for whom the crontab will be manipulated
+ * @var string
*/
- var $user;
+ private $user;
/**
- * @var string Lists the type of line of each line in $crontabs.
+ * 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
*/
- var $linetypes;
+ private $linetypes;
// }}}
diff --git a/campcaster/src/modules/storageServer/var/cron/transportCron.php b/campcaster/src/modules/storageServer/var/cron/transportCron.php
index 6b5237649..97255b0cb 100755
--- a/campcaster/src/modules/storageServer/var/cron/transportCron.php
+++ b/campcaster/src/modules/storageServer/var/cron/transportCron.php
@@ -9,8 +9,8 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb =& new LocStor($dbc, $config);
-$tr =& new Transport($gb);
+$gb = new LocStor($dbc, $config);
+$tr = new Transport($gb);
$r = $tr->cronMain();
if(!$r) exit(1);
diff --git a/campcaster/src/modules/storageServer/var/cron/transportCronJob.php b/campcaster/src/modules/storageServer/var/cron/transportCronJob.php
index c8bc8df31..f76c2461f 100755
--- a/campcaster/src/modules/storageServer/var/cron/transportCronJob.php
+++ b/campcaster/src/modules/storageServer/var/cron/transportCronJob.php
@@ -9,24 +9,26 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb =& new LocStor($dbc, $config);
-$tr =& new Transport($gb);
+$gb = new LocStor($dbc, $config);
+$tr = new Transport($gb);
list(, $trtok) = $_SERVER['argv'];
-if (TR_LOG_LEVEL>1) {
+if (TR_LOG_LEVEL > 1) {
$tr->trLog("transportCronJob start ($trtok)");
}
// 4-pass on job:
$cnt = 4;
-for ($i = 0; $i < $cnt; $i++, sleep(1)){
+for ($i = 0; $i < $cnt; $i++, sleep(1)) {
// run the action:
$r = $tr->cronCallMethod($trtok);
if (PEAR::isError($r)) {
$tr->trLogPear("transportCronJob: ($trtok): ", $r);
} else {
# $tr->trLog("X transportCronJob: ".var_export($r, TRUE));
- if($r!==TRUE) $tr->trLog("transportCronJob: ($trtok): nonTRUE returned");
+ if ($r !== TRUE) {
+ $tr->trLog("transportCronJob: ($trtok): nonTRUE returned");
+ }
}
#if(!$r) exit(1);
#sleep(2);
diff --git a/campcaster/src/modules/storageServer/var/install/install.php b/campcaster/src/modules/storageServer/var/install/install.php
index b60dd9781..99b4df999 100644
--- a/campcaster/src/modules/storageServer/var/install/install.php
+++ b/campcaster/src/modules/storageServer/var/install/install.php
@@ -49,9 +49,9 @@ if(PEAR::isError($dbc)){
}
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb =& new GreenBox($dbc, $config, TRUE);
-$tr =& new Transport($gb);
-$pr =& new Prefs($gb);
+$gb = new GreenBox($dbc, $config, TRUE);
+$tr = new Transport($gb);
+$pr = new Prefs($gb);
//------------------------------------------------------------------------------
// install
diff --git a/campcaster/src/modules/storageServer/var/install/uninstall.php b/campcaster/src/modules/storageServer/var/install/uninstall.php
index 7efe2ce43..a216b1bdd 100644
--- a/campcaster/src/modules/storageServer/var/install/uninstall.php
+++ b/campcaster/src/modules/storageServer/var/install/uninstall.php
@@ -42,9 +42,9 @@ if(PEAR::isError($dbc)){
echo "#StorageServer uninstall:\n";
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb = &new GreenBox($dbc, $config, TRUE);
-$tr =& new Transport($gb);
-$pr =& new Prefs($gb);
+$gb = new GreenBox($dbc, $config, TRUE);
+$tr = new Transport($gb);
+$pr = new Prefs($gb);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
echo "# Uninstall Prefs submodule";
diff --git a/campcaster/src/modules/storageServer/var/playlistFormat.php b/campcaster/src/modules/storageServer/var/playlistFormat.php
index 0db965ae1..ca4fe00f7 100644
--- a/campcaster/src/modules/storageServer/var/playlistFormat.php
+++ b/campcaster/src/modules/storageServer/var/playlistFormat.php
@@ -1,9 +1,13 @@
+ * @author Paul Baranowski
* @version $Revision$
* @package Campcaster
* @subpackage StorageServer
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
diff --git a/campcaster/src/modules/storageServer/var/tests/analyze.php b/campcaster/src/modules/storageServer/var/tests/analyze.php
index c1421d171..611acbf78 100755
--- a/campcaster/src/modules/storageServer/var/tests/analyze.php
+++ b/campcaster/src/modules/storageServer/var/tests/analyze.php
@@ -11,11 +11,11 @@ require_once '../conf.php';
require_once 'DB.php';
require_once '../GreenBox.php';
-#$rmd =& new RawMediaData('qwerty', '../stor');
+#$rmd = new RawMediaData('qwerty', '../stor');
#$r = $rmd->insert('./ex1.mp3', 'mp3');
#$r = $rmd->test('./ex1.mp3', './ex2.wav', '../access/xyz.ext');
-$rmd =& new RawMediaData($gunid, '../stor/'.substr($gunid, 0, 3));
+$rmd = new RawMediaData($gunid, '../stor/'.substr($gunid, 0, 3));
$r = $rmd->analyze();
echo "r=$r (".gettype($r).")\n";
diff --git a/campcaster/src/modules/storageServer/var/tests/transTest.php b/campcaster/src/modules/storageServer/var/tests/transTest.php
index ab6fa3bf0..eb19d3f74 100644
--- a/campcaster/src/modules/storageServer/var/tests/transTest.php
+++ b/campcaster/src/modules/storageServer/var/tests/transTest.php
@@ -11,9 +11,9 @@ require_once '../LocStor.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb = &new GreenBox($dbc, $config);
-$tr = &new Transport($gb);
-$ls = &new LocStor($dbc, $config);
+$gb = new GreenBox($dbc, $config);
+$tr = new Transport($gb);
+$ls = new LocStor($dbc, $config);
@unlink("{$tr->transDir}/activity.log");
@unlink("{$tr->transDir}/debug.log");
$tr->_cleanUp();
diff --git a/campcaster/src/modules/storageServer/var/tests/webstreamTest.php b/campcaster/src/modules/storageServer/var/tests/webstreamTest.php
index 7929dfada..0ef3432d6 100644
--- a/campcaster/src/modules/storageServer/var/tests/webstreamTest.php
+++ b/campcaster/src/modules/storageServer/var/tests/webstreamTest.php
@@ -10,7 +10,7 @@ require_once '../GreenBox.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb = &new GreenBox($dbc, $config);
+$gb = new GreenBox($dbc, $config);
#$gunid = "123456789abcdee0";
$gunid = "";
diff --git a/campcaster/src/modules/storageServer/var/webstreamFormat.php b/campcaster/src/modules/storageServer/var/webstreamFormat.php
index a45f43927..e6274121b 100644
--- a/campcaster/src/modules/storageServer/var/webstreamFormat.php
+++ b/campcaster/src/modules/storageServer/var/webstreamFormat.php
@@ -1,7 +1,11 @@
+ * @author Paul Baranowski
* @version $Revision$
+ * @copyright 2006 MDLF, Inc.
+ * @license http://www.gnu.org/licenses/gpl.txt
+ * @link http://www.campware.org
*/
$webstreamFormat = array(
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
index 6280d1974..965ca5529 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php
@@ -2,12 +2,12 @@
require_once dirname(__FILE__).'/../LocStor.php';
/**
- * XML-RPC interface for LocStor class
+ * XML-RPC interface for LocStor class
* @author $Author$
* @version $Revision$
*
*/
-class XR_LocStor extends LocStor{
+class XR_LocStor extends LocStor {
/* ----------------------------------------------------------- getVersion */
/**
@@ -39,9 +39,11 @@ class XR_LocStor extends LocStor{
function xr_getVersion($input)
{
list($ok, $r) = $this->_xr_getPars($input);
- if(!$ok) return $r;
+ if (!$ok) {
+ return $r;
+ }
$res = $this->getVersion();
- if(PEAR::isError($res)){
+ if (PEAR::isError($res)) {
return new XML_RPC_Response(0, 805,
"xr_getVersion: ".$res->getMessage().
" ".$res->getUserInfo()
@@ -52,6 +54,7 @@ class XR_LocStor extends LocStor{
);
}
+
/* ------------------------------------------------------- authentication */
/**
* Checks the login name and password of the user and return
@@ -85,9 +88,11 @@ class XR_LocStor extends LocStor{
function xr_authenticate($input)
{
list($ok, $r) = $this->_xr_getPars($input);
- if(!$ok) return $r;
+ if (!$ok) {
+ return $r;
+ }
$res = $this->authenticate($r['login'], $r['pass']);
- if(PEAR::isError($res)){
+ if (PEAR::isError($res)) {
return new XML_RPC_Response(0, 804,
"xr_authenticate: ".$res->getMessage().
" ".$res->getUserInfo()
@@ -99,6 +104,7 @@ class XR_LocStor extends LocStor{
);
}
+
/**
* Checks the login name and password of the user. If the login is
* correct, a new session ID string is generated, to be used in all
@@ -2451,7 +2457,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php';
- $pr =& new Prefs($this);
+ $pr = new Prefs($this);
$res = $pr->loadPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2502,7 +2508,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php';
- $pr =& new Prefs($this);
+ $pr = new Prefs($this);
$res = $pr->savePref($r['sessid'], $r['key'], $r['value']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2552,7 +2558,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php';
- $pr =& new Prefs($this);
+ $pr = new Prefs($this);
$res = $pr->delPref($r['sessid'], $r['key']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2604,7 +2610,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php';
- $pr =& new Prefs($this);
+ $pr = new Prefs($this);
$res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2660,7 +2666,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Prefs.php';
- $pr =& new Prefs($this);
+ $pr = new Prefs($this);
$res = $pr->saveGroupPref($r['sessid'], $r['group'], $r['key'], $r['value']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2719,7 +2725,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->getTransportInfo($r['trtok']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2769,7 +2775,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->turnOnOffTransports($r['onOff']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2819,7 +2825,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->doTransportAction($r['trtok'], $r['action']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2870,7 +2876,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->uploadFile2Hub($r['filePath']); // local files on XML-RPC :(
// there should be something as uploadFile2storageServer
if(PEAR::isError($res)){
@@ -2924,7 +2930,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->getHubInitiatedTransfers();
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -2972,8 +2978,8 @@ class XR_LocStor extends LocStor{
function xr_startHubInitiatedTransfer($input) {
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
- require_once '../Transport.php';
- $tr =& new Transport($this);
+ require_once('../Transport.php');
+ $tr = new Transport($this);
$res = $tr->startHubInitiatedTransfer($r['trtok']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -3025,7 +3031,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->upload2Hub($r['gunid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -3075,7 +3081,7 @@ class XR_LocStor extends LocStor{
list($ok, $par) = $this->_xr_getPars($input);
if(!$ok) return $par;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$uid = $r = $this->getSessUserId($par['sessid']); // ###
$res = $tr->downloadFromHub($uid, $par['gunid']);
if(PEAR::isError($res)){
@@ -3127,7 +3133,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->globalSearch($r['criteria']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -3189,7 +3195,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once '../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->getSearchResults($r['trtok']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -3241,7 +3247,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->uploadToArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
@@ -3291,7 +3297,7 @@ class XR_LocStor extends LocStor{
list($ok, $r) = $this->_xr_getPars($input);
if(!$ok) return $r;
require_once dirname(__FILE__).'/../Transport.php';
- $tr =& new Transport($this);
+ $tr = new Transport($this);
$res = $tr->downloadFromArchive($r['gunid'], $r['sessid']);
if(PEAR::isError($res)){
$ec0 = intval($res->getCode());
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/put.php b/campcaster/src/modules/storageServer/var/xmlrpc/put.php
index 808e5d5db..987549a37 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/put.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/put.php
@@ -35,7 +35,7 @@ require_once dirname(__FILE__).'/../LocStor.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$gb = &new LocStor($dbc, $config);
+$gb = new LocStor($dbc, $config);
function http_error($code, $err){
header("HTTP/1.1 $code");
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php b/campcaster/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php
index 9d9ad8a3d..b38020907 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php
@@ -5,9 +5,9 @@
*/
/* ================================================================= includes */
-include_once dirname(__FILE__)."/../conf.php";
-require_once 'DB.php';
-include_once "XML/RPC.php";
+include_once(dirname(__FILE__)."/../conf.php");
+require_once('DB.php');
+include_once("XML/RPC.php");
/* ================================================== method definition array */
/**
@@ -333,42 +333,54 @@ $mdefs = array(
/* ======================================================== class definitions */
-class SchedulerPhpClient{
+class SchedulerPhpClient {
/**
- * Databases object reference
+ * Databases object reference
+ * @var DB
*/
- var $dbc = NULL;
+ public $dbc = NULL;
+
/**
- * Array with methods description
+ * Array with methods description
+ * @var array
*/
- var $mdefs = array();
+ private $mdefs = array();
+
/**
- * Confiduration array from ../conf.php
+ * Confiduration array from ../conf.php
+ * @var array
*/
- var $config = array();
+ public $config = array();
+
/**
- * XMLRPC client object reference
+ * XMLRPC client object reference
*/
- var $client = NULL;
+ private $client = NULL;
+
/**
* Verbosity flag
*/
- var $verbose = FALSE;
+ private $verbose = FALSE;
+
/**
* XMLRPC debug flag
*/
- var $debug = 0;
+ private $debug = 0;
+
/**
- * Constructor - pelase DON'T CALL IT, use factory method instead
+ * Constructor - please DON'T CALL IT, use factory method instead
*
- * @param dbc object, database object reference
- * @param mdefs array, hash array with methods description
- * @param config array, hash array with configuration
- * @param debug int, XMLRPC debug flag
- * @param verbose boolean, verbosity flag
- * @return this
+ * @param DB $dbc
+ * @param array $mdefs
+ * hash array with methods description
+ * @param array $config
+ * hash array with configuration
+ * @param int $debug
+ * XMLRPC debug flag
+ * @param boolean $verbose
+ * verbosity flag
*/
- function SchedulerPhpClient(
+ public function __construct(
&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
{
$this->dbc = $dbc;
@@ -382,32 +394,40 @@ class SchedulerPhpClient{
"http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
"{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
#$serverPath = "http://localhost:80/campcasterStorageServerCVS/xmlrpc/xrLocStor.php";
- if($this->verbose) echo "serverPath: $serverPath\n";
+ if ($this->verbose) {
+ echo "serverPath: $serverPath\n";
+ }
$url = parse_url($serverPath);
$this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
}
+
/**
- * Factory, create object instance
+ * Factory, create object instance
*
- * In fact it doesn't create instance of SchedulerPhpClient, but
- * dynamically extend this class with set of methods based on $mdefs array
- * (using eval function) and instantiate resulting class
- * SchedulerPhpClientCore instead.
- * Each new method in this subclass accepts parameters according to $mdefs
- * array, call wrapper callMethod(methodname, parameters) and return its
- * result.
+ * In fact it doesn't create instance of SchedulerPhpClient, but
+ * dynamically extend this class with set of methods based on $mdefs array
+ * (using eval function) and instantiate resulting class
+ * SchedulerPhpClientCore instead.
+ * Each new method in this subclass accepts parameters according to $mdefs
+ * array, call wrapper callMethod(methodname, parameters) and return its
+ * result.
*
- * @param dbc object, database object reference
- * @param mdefs array, hash array with methods description
- * @param config array, hash array with configuration
- * @param debug int, XMLRPC debug flag
- * @param verbose boolean, verbosity flag
- * @return object, created object instance
+ * @param DB $dbc
+ * @param array $mdefs
+ * hash array with methods description
+ * @param array $config
+ * hash array with configuration
+ * @param int $debug
+ * XMLRPC debug flag
+ * @param boolean $verbose
+ * verbosity flag
+ * @return SchedulerPhpClientCore
*/
- function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE){
+ function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
+ {
$f = '';
- foreach($mdefs as $fn=>$farr){
+ foreach ($mdefs as $fn => $farr) {
$f .=
' function '.$fn.'(){'."\n".
' $pars = func_get_args();'."\n".
@@ -420,32 +440,38 @@ class SchedulerPhpClient{
"$f\n".
"}\n";
# echo $e;
- if(FALSE === eval($e)) return $dbc->raiseError("Eval failed");
- $spc =& new SchedulerPhpClientCore(
+ if (FALSE === eval($e)) {
+ return $dbc->raiseError("Eval failed");
+ }
+ $spc = new SchedulerPhpClientCore(
$dbc, $mdefs, $config, $debug, $verbose);
return $spc;
}
+
/**
* XMLRPC methods wrapper
* Encode XMLRPC request message, send it, receive and decode response.
*
- * @param method string, method name
- * @param gettedPars array, returned by func_get_args() in called method
- * @return array, PHP hash with response
+ * @param string $method
+ * method name
+ * @param array $gettedPars
+ * returned by func_get_args() in called method
+ * @return array
+ * PHP hash with response
*/
function callMethod($method, $gettedPars)
{
$parr = array();
$XML_RPC_val = new XML_RPC_Value;
- foreach($this->mdefs[$method]['p'] as $i=>$p){
+ foreach ($this->mdefs[$method]['p'] as $i => $p) {
$parr[$p] = new XML_RPC_Value;
$parr[$p]->addScalar($gettedPars[$i], $this->mdefs[$method]['t'][$i]);
}
$XML_RPC_val->addStruct($parr);
$fullmethod = $this->mdefs[$method]['m'];
$msg = new XML_RPC_Message($fullmethod, array($XML_RPC_val));
- if($this->verbose){
+ if ($this->verbose) {
echo "parr:\n";
var_dump($parr);
echo "message:\n";
@@ -453,14 +479,14 @@ class SchedulerPhpClient{
}
$this->client->setDebug($this->debug);
$res = $this->client->send($msg);
- if($res->faultCode() > 0) {
+ if ($res->faultCode() > 0) {
return PEAR::raiseError(
"SchedulerPhpClient::$method:".$res->faultString()." ".
$res->faultCode()."\n", $res->faultCode(),
PEAR_ERROR_RETURN
);
}
- if($this->verbose){
+ if ($this->verbose) {
echo "result:\n";
echo $res->serialize();
}
@@ -469,7 +495,7 @@ class SchedulerPhpClient{
return $resp;
}
-}
+} // class SchedulerPhpClient
/* ======================================================== class definitions */
@@ -485,8 +511,8 @@ $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
// scheduler client instantiation:
-$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config);
-#$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE);
+$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config);
+#$spc = SchedulerPhpClient::factory($dbc, $mdefs, $config, 0, TRUE);
if(PEAR::isError($spc)){ echo $spc->getMessage."\n"; exit; }
// call of chosen function by name according to key values in $mdefs array:
@@ -504,4 +530,4 @@ $r = $spc->DisplayScheduleMethod($this->Base->sessid, '20040101T00:00:00', '2005
#$r = $spc->GetSchedulerTimeMethod(); var_dump($r);
================= */
-?>
+?>
\ No newline at end of file
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php b/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php
index 2c4c95d06..86788b62e 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/simpleGet.php
@@ -35,7 +35,7 @@ $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$locStor = &new LocStor($dbc, $config);
+$locStor = new LocStor($dbc, $config);
function http_error($code, $err){
header("HTTP/1.1 $code");
diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php
index 5b32b48e7..8acbd39ff 100644
--- a/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php
+++ b/campcaster/src/modules/storageServer/var/xmlrpc/xrLocStor.php
@@ -44,7 +44,7 @@ function errHndl($errno, $errmsg, $filename, $linenum, $vars)
return;
break;
default:
- $xr =& new XML_RPC_Response(0, 805,
+ $xr = new XML_RPC_Response(0, 805,
htmlspecialchars("ERROR:xrLocStor: $errno $errmsg ($filename:$linenum)"));
header("Content-type: text/xml");
echo $xr->serialize();
@@ -58,14 +58,14 @@ if (PHP5) {
}
/* ============================================================= runable code */
-$r = $dbc =& DB::connect($config['dsn'], TRUE);
+$r = $dbc = DB::connect($config['dsn'], TRUE);
if (PEAR::isError($r)) {
trigger_error("DB::connect: ".$r->getMessage()." ".$r->getUserInfo(),E_USER_ERROR);
}
$dbc->setErrorHandling(PEAR_ERROR_RETURN);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
-$locStor = &new XR_LocStor($dbc, $config);
+$locStor = new XR_LocStor($dbc, $config);
$methods = array(
'test' => 'Tests toupper and checks sessid, params: '.
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |