Make sure not to double-escape strings used in SQL. Fixed some formatting to comply with style guidelines.

This commit is contained in:
paul 2006-10-25 20:34:28 +00:00
parent 6ad26b3080
commit 6f2013845c

View file

@ -46,8 +46,9 @@ class BasicStor extends Alib {
/**
* Constructor
*
* @param PEAR::db $dbc abstract class reference
* @param config $config array from conf.php
* @param DB $dbc
* @param array $config
* array from conf.php
* @return class instance
*/
function BasicStor(&$dbc, $config, $install=FALSE)
@ -81,9 +82,12 @@ class BasicStor extends Alib {
/**
* Create new folder
*
* @param int $parid, parent id
* @param string $folderName, name for new folder
* @return id of new folder
* @param int $parid
* Parent id
* @param string $folderName
* Name for new folder
* @return unknown
* id of new folder
* @exception PEAR::error
*/
function bsCreateFolder($parid, $folderName)
@ -95,27 +99,33 @@ class BasicStor extends Alib {
/**
* Store new file in the storage
*
* @param int $parid, parent id
* @param string $fileName, name for new file
* @param string $mediaFileLP, local path of media file
* @param string $mdataFileLP, local path of metadata file
* @param string $gunid, global unique id OPTIONAL
* @param string $ftype, internal file type
* @param string $mdataLoc 'file'|'string' (optional)
* @param int $parid
* Parent id
* @param string $fileName
* Name for new file
* @param string $mediaFileLP
* Local path of media file
* @param string $mdataFileLP
* Local path of metadata file
* @param string $gunid
* global unique id
* @param string $ftype
* Internal file type
* @param string $mdataLoc
* 'file'|'string'
* @return int
* @exception PEAR::error
*/
function bsPutFile($parid, $fileName, $mediaFileLP, $mdataFileLP,
$gunid=NULL, $ftype='unKnown', $mdataLoc='file')
{
$name = pg_escape_string($fileName);
$ftype = strtolower($ftype);
$id = $this->addObj($name , $ftype, $parid);
$id = $this->addObj($fileName, $ftype, $parid);
if ($this->dbc->isError($id)) {
return $id;
}
$ac = StoredFile::insert(
$this, $id, $name, $mediaFileLP, $mdataFileLP, $mdataLoc,
$this, $id, $fileName, $mediaFileLP, $mdataFileLP, $mdataLoc,
$gunid, $ftype
);
if ($this->dbc->isError($ac)){
@ -140,9 +150,10 @@ class BasicStor extends Alib {
/**
* Rename file
*
* @param int $id, virt.file's local id
* @param int $id
* Virtual file's local id
* @param string $newName
* @return boolean or PEAR::error
* @return boolean/PEAR_Error
*/
function bsRenameFile($id, $newName)
{
@ -172,9 +183,11 @@ class BasicStor extends Alib {
/**
* Move file
*
* @param int $id, virt.file's local id
* @param int $did, destination folder local id
* @return boolean or PEAR::error
* @param int $id
* Virtual file's local id
* @param int $did
* Destination folder local id
* @return boolean/PEAR_Error
*/
function bsMoveFile($id, $did)
{
@ -205,9 +218,11 @@ class BasicStor extends Alib {
/**
* Copy file
*
* @param int $id, virt.file's local id
* @param int $did, destination folder local id
* @return boolean or PEAR::error
* @param int $id
* Virtual file's local id
* @param int $did
* Destination folder local id
* @return boolean/PEAR_Error
*/
function bsCopyFile($id, $did)
{
@ -238,11 +253,15 @@ class BasicStor extends Alib {
/**
* Replace file. Doesn't change filetype!
*
* @param int $id, virt.file's local id
* @param string $mediaFileLP, local path of media file
* @param string $mdataFileLP, local path of metadata file
* @param string $mdataLoc 'file'|'string' (optional)
* @return true or PEAR::error
* @param int $id
* Virtual file's local id
* @param string $mediaFileLP
* Local path of media file
* @param string $mdataFileLP
* Local path of metadata file
* @param string $mdataLoc
* 'file'|'string'
* @return true/PEAR_Error
* @exception PEAR::error
*/
function bsReplaceFile($id, $mediaFileLP, $mdataFileLP, $mdataLoc='file')
@ -271,9 +290,11 @@ class BasicStor extends Alib {
/**
* Delete file
*
* @param int $id, virt.file's local id
* @param boolean $forced, if true don't use trash
* @return true or PEAR::error
* @param int $id
* Virtual file's local id
* @param boolean $forced
* If true don't use trash
* @return true/PEAR_Error
*/
function bsDeleteFile($id, $forced=FALSE)
{
@ -313,10 +334,12 @@ class BasicStor extends Alib {
/* ----------------------------------------------------- put, access etc. */
/**
* Check validity of asscess/put token
* Check validity of access/put token
*
* @param string $token, access/put token
* @param string $type 'put'|'access'|'download'
* @param string $token
* Access/put token
* @param string $type
* 'put'|'access'|'download'
* @return boolean
*/
function bsCheckToken($token, $type='put')
@ -335,8 +358,10 @@ class BasicStor extends Alib {
/**
* Get gunid from token
*
* @param string $token, access/put token
* @param string $type 'put'|'access'|'download'
* @param string $token
* Access/put token
* @param string $type
* 'put'|'access'|'download'
* @return string
*/
function _gunidFromToken($token, $type='put')
@ -359,15 +384,22 @@ class BasicStor extends Alib {
/**
* Create and return access link to real file
*
* @param string $realFname, local filepath to accessed file
* @param string $realFname
* Local filepath to accessed file
* (NULL for only increase access counter, no symlink)
* @param string $ext, useful filename extension for accessed file
* @param int $gunid, global unique id
* @param string $ext
* Useful filename extension for accessed file
* @param int $gunid
* Global unique id
* (NULL for special files such exported playlists)
* @param string $type 'access'|'download'
* @param int $parent parent token (recursive access/release)
* @param int $owner, local user id - owner of token
* @return array with: seekable filehandle, access token
* @param string $type
* 'access'|'download'
* @param int $parent
* parent token (recursive access/release)
* @param int $owner
* Local user id - owner of token
* @return array
* array with: seekable filehandle, access token
*/
function bsAccess($realFname, $ext, $gunid, $type='access',
$parent='0', $owner=NULL)
@ -375,8 +407,6 @@ class BasicStor extends Alib {
if (!is_null($gunid)) {
$gunid = StoredFile::_normalizeGunid($gunid);
}
$ext = pg_escape_string($ext);
$type = pg_escape_string($type);
$token = StoredFile::_createGunid();
if (!is_null($realFname)) {
$linkFname = "{$this->accessDir}/$token.$ext";
@ -393,6 +423,8 @@ class BasicStor extends Alib {
} else {
$linkFname = NULL;
}
$escapedExt = pg_escape_string($ext);
$escapedType = pg_escape_string($type);
$this->dbc->query("BEGIN");
$gunidSql = (is_null($gunid) ? "NULL" : "x'{$gunid}'::bigint" );
$ownerSql = (is_null($owner) ? "NULL" : "$owner" );
@ -401,7 +433,7 @@ class BasicStor extends Alib {
(gunid, token, ext, type, parent, owner, ts)
VALUES
($gunidSql, x'$token'::bigint,
'$ext', '$type', x'{$parent}'::bigint, $ownerSql, now())
'$escapedExt', '$escapedType', x'{$parent}'::bigint, $ownerSql, now())
");
if ($this->dbc->isError($res)) {
$this->dbc->query("ROLLBACK");
@ -429,9 +461,11 @@ class BasicStor extends Alib {
/**
* Release access link to real file
*
* @param string $token, access token
* @param string $type 'access'|'download'
* @return hasharray
* @param string $token
* Access token
* @param string $type
* 'access'|'download'
* @return array
* gunid: string, global unique ID or real pathname of special file
* owner: int, local subject id of token owner
* realFname: string, real local pathname of accessed file
@ -497,10 +531,14 @@ class BasicStor extends Alib {
/**
* Create and return downloadable URL for file
*
* @param int $id, virt.file's local id
* @param string $part, 'media'|'metadata'
* @param int $parent parent token (recursive access/release)
* @return array with strings:
* @param int $id
* Virtual file's local id
* @param string $part
* 'media'|'metadata'
* @param int $parent
* parent token (recursive access/release)
* @return array
* array with strings:
* downloadable URL, download token, chsum, size, filename
*/
function bsOpenDownload($id, $part='media', $parent='0')
@ -544,9 +582,12 @@ class BasicStor extends Alib {
/**
* Discard downloadable URL
*
* @param string $token, download token
* @param string $part, 'media'|'metadata'
* @return string, gunid
* @param string $token
* Download token
* @param string $part
* 'media'|'metadata'
* @return string
* gunid
*/
function bsCloseDownload($token, $part='media')
{
@ -566,11 +607,15 @@ class BasicStor extends Alib {
/**
* Create writable URL for HTTP PUT method file insert
*
* @param string $chsum, md5sum of the file having been put
* @param string $gunid, global unique id
* @param string $chsum
* md5sum of the file having been put
* @param string $gunid
* global unique id
* (NULL for special files such imported playlists)
* @param int $owner, local user id - owner of token
* @return hasharray with:
* @param int $owner
* local user id - owner of token
* @return array
* array with:
* url string: writable URL
* fname string: writable local filename
* token string: PUT token
@ -580,8 +625,7 @@ class BasicStor extends Alib {
if (!is_null($gunid)) {
$gunid = StoredFile::_normalizeGunid($gunid);
}
$chsum = pg_escape_string($chsum);
$ext = '';
$escapedChsum = pg_escape_string($chsum);
$token = StoredFile::_createGunid();
$res = $this->dbc->query("
DELETE FROM {$this->accessTable} WHERE token=x'$token'::bigint
@ -596,7 +640,7 @@ class BasicStor extends Alib {
(gunid, token, ext, chsum, type, owner, ts)
VALUES
($gunidSql, x'$token'::bigint,
'$ext', '$chsum', 'put', $ownerSql, now())
'', '$escapedChsum', 'put', $ownerSql, now())
");
if ($this->dbc->isError($res)) {
return $res;
@ -612,8 +656,10 @@ class BasicStor extends Alib {
* Get file from writable URL and return local filename.
* Caller should move or unlink this file.
*
* @param string $token, PUT token
* @return hash with fields:
* @param string $token
* PUT token
* @return array
* hash with fields:
* fname string, local path of the file having been put
* owner int, local subject id - owner of token
*/
@ -660,8 +706,10 @@ class BasicStor extends Alib {
/**
* Check uploaded file
*
* @param string $token, put token
* @return hash, (
* @param string $token
* "Put" token
* @return array
* hash, (
* status: boolean,
* size: int - filesize
* expectedsum: string - expected checksum
@ -697,7 +745,8 @@ class BasicStor extends Alib {
/**
* Return starting part of storageServer URL
*
* @return string, url
* @return string
* URL
*/
function getUrlPart()
{
@ -711,8 +760,10 @@ class BasicStor extends Alib {
/**
* Return local subject id of token owner
*
* @param token: string - access/put/render etc. token
* @return int - local subject id
* @param string $token
* access/put/render etc. token
* @return int
* local subject id
*/
function getTokenOwner($token)
{
@ -730,8 +781,10 @@ class BasicStor extends Alib {
/**
* Get tokens by type
*
* @param type: string - access|put|render etc.
* @return array - array of tokens
* @param string $type
* access|put|render etc.
* @return array
* array of tokens
*/
function getTokensByType($type)
{
@ -750,10 +803,13 @@ class BasicStor extends Alib {
/**
* Replace metadata with new XML file or string
*
* @param int $id, virt.file's local id
* @param string $mdata, local path of metadata XML file
* @param string $mdataLoc 'file'|'string'
* @return boolean or PEAR::error
* @param int $id
* Virtual file's local id
* @param string $mdata
* Local path of metadata XML file
* @param string $mdataLoc
* 'file'|'string'
* @return boolean/PEAR_Error
*/
function bsReplaceMetadata($id, $mdata, $mdataLoc='file')
{
@ -768,8 +824,9 @@ class BasicStor extends Alib {
/**
* Get metadata as XML string
*
* @param int $id, virt.file's local id
* @return string or PEAR::error
* @param int $id
* Virtual file's local id
* @return string/PEAR_Error
*/
function bsGetMetadata($id)
{
@ -784,12 +841,16 @@ class BasicStor extends Alib {
/**
* Get dc:title (if exists)
*
* @param int $id, virt.file's local id
* @param string $gunid, virt.file's gunid, optional, used only if not
* @param int $id
* Virtual file's local id
* @param string $gunid
* Virtual file's gunid, optional, used only if not
* null, id is then ignored
* @param string $lang, optional xml:lang value for select language version
* @param string $deflang, optional xml:lang for default language
* @return string or PEAR::error
* @param string $lang
* xml:lang value for select language version
* @param string $deflang
* xml:lang for default language
* @return string/PEAR_Error
*/
function bsGetTitle($id, $gunid=NULL, $lang=NULL, $deflang=NULL)
{
@ -813,11 +874,16 @@ class BasicStor extends Alib {
/**
* Get metadata element value
*
* @param int $id, virt.file's local id
* @param string $category, metadata element name
* @param string $lang, optional xml:lang value for select language version
* @param string $deflang, optional xml:lang for default language
* @return array of matching records (as hash {id, value, attrs})
* @param int $id
* Virtual file's local id
* @param string $category
* metadata element name
* @param string $lang
* xml:lang value for select language version
* @param string $deflang
* xml:lang for default language
* @return array
* array of matching records (as hash {id, value, attrs})
* @see Metadata::getMetadataValue
*/
function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL)
@ -833,13 +899,20 @@ class BasicStor extends Alib {
/**
* Set metadata element value
*
* @param int $id, virt.file's local id
* @param string $category, metadata element identification (e.g. dc:title)
* @param string $value/NULL value to store, if NULL then delete record
* @param string $lang, optional xml:lang value for select language version
* @param int $mid, metadata record id (OPTIONAL on unique elements)
* @param string $container, container element name for insert
* @param boolean $regen, optional flag, if true, regenerate XML file
* @param int $id
* Virtual file's local id
* @param string $category
* Metadata element identification (e.g. dc:title)
* @param string $value
* value to store, if NULL then delete record
* @param string $lang
* xml:lang value for select language version
* @param int $mid
* (optional on unique elements) metadata record id
* @param string $container
* container element name for insert
* @param boolean $regen
* flag, if true, regenerate XML file
* @return boolean
*/
function bsSetMetadataValue($id, $category, $value,
@ -859,8 +932,7 @@ class BasicStor extends Alib {
if ($category == 'dcterms:extent') {
$value = $this->normalizeExtent($value);
}
$res = $ac->md->setMetadataValue(
$category, $value, $lang, $mid, $container);
$res = $ac->md->setMetadataValue($category, $value, $lang, $mid, $container);
if ($this->dbc->isError($res)) {
return $res;
}
@ -877,13 +949,14 @@ class BasicStor extends Alib {
/**
* Normalize time value to hh:mm:ss:dddddd format
*
* @param mixed $v, value to normalize
* @param mixed $v
* value to normalize
* @return string
*/
function normalizeExtent($v)
{
if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) {
require_once"Playlist.php";
require_once("Playlist.php");
$s = Playlist::_plTimeToSecs($v);
$t = Playlist::_secsToPlTime($s);
return $t;
@ -895,12 +968,17 @@ class BasicStor extends Alib {
/**
* Set metadata values in 'batch' mode
*
* @param int $id, virt.file's local id
* @param hasharray $values, array of key/value pairs
* @param int $id
* Virtual file's local ID
* @param array $values
* array of key/value pairs
* (e.g. 'dc:title'=>'New title')
* @param string $lang, optional xml:lang value for select language version
* @param string $container, container element name for insert
* @param boolean $regen, optional flag, if true, regenerate XML file
* @param string $lang
* xml:lang value for select language version
* @param string $container
* Container element name for insert
* @param boolean $regen
* flag, if true, regenerate XML file
* @return boolean
*/
function bsSetMetadataBatch(
@ -933,7 +1011,8 @@ class BasicStor extends Alib {
/**
* Search in local metadata database.
*
* @param hash $criteria, with following structure:<br>
* @param array $criteria
* has the following structure:<br>
* <ul>
* <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'webstream', 'playlist', 'all'</li>
@ -958,9 +1037,12 @@ class BasicStor extends Alib {
* </ul>
* </li>
* </ul>
* @param int $limit, limit for result arrays (0 means unlimited)
* @param int $offset, starting point (0 means without offset)
* @return array of hashes, fields:
* @param int $limit
* limit for result arrays (0 means unlimited)
* @param int $offset
* starting point (0 means without offset)
* @return array
* array of hashes, fields:
* cnt : integer - number of matching gunids
* of files have been found
* results : array of hashes:
@ -974,7 +1056,7 @@ class BasicStor extends Alib {
*/
function bsLocalSearch($criteria, $limit=0, $offset=0)
{
require_once "DataEngine.php";
require_once("DataEngine.php");
$de =& new DataEngine($this);
$res = $r = $de->localSearch($criteria, $limit, $offset);
if (PEAR::isError($r)) {
@ -987,19 +1069,23 @@ class BasicStor extends Alib {
/**
* Return values of specified metadata category
*
* @param string $category, metadata category name
* with or without namespace prefix (dc:title, author)
* @param int $limit, limit for result arrays (0 means unlimited)
* @param int $offset, starting point (0 means without offset)
* @param hash $criteria, see bsLocalSearch method
* @return hash, fields:
* @param string $category
* metadata category name with or without namespace prefix (dc:title, author)
* @param int $limit
* limit for result arrays (0 means unlimited)
* @param int $offset
* starting point (0 means without offset)
* @param array $criteria
* see bsLocalSearch method
* @return array
* hash, fields:
* results : array with found values
* cnt : integer - number of matching values
* @see DataEngine
*/
function bsBrowseCategory($category, $limit=0, $offset=0, $criteria=NULL)
{
require_once "DataEngine.php";
require_once("DataEngine.php");
$de =& new DataEngine($this);
return $de->browseCategory($category, $limit, $offset, $criteria);
}
@ -1011,18 +1097,20 @@ class BasicStor extends Alib {
* Create a tarfile with playlist export - playlist and all matching
* sub-playlists and media files (if desired)
*
* @param array $plids - array of strings, playlist global unique IDs
* (one gunid is accepted too)
* @param string $type - playlist format,
* possible values: lspl | smil | m3u
* @param boolean $withContent - if true, export related files too
* @return hasharray with fields:
* @param array $plids
* Array of strings, playlist global unique IDs (one gunid is accepted too)
* @param string $type
* Playlist format, possible values: lspl | smil | m3u
* @param boolean $withContent
* if true, export related files too
* @return array
* hasharray with fields:
* fname string: readable fname,
* token string: access token
*/
function bsExportPlaylistOpen($plids, $type='lspl', $withContent=TRUE)
{
require_once"Playlist.php";
require_once("Playlist.php");
if (!is_array($plids)) {
$plids = array($plids);
}
@ -1047,10 +1135,13 @@ class BasicStor extends Alib {
$res = array();
$tmpn = tempnam($this->bufferDir, 'plExport_');
$tmpf = "$tmpn.tar";
$tmpd = "$tmpn.dir"; mkdir($tmpd);
$tmpdp = "$tmpn.dir/playlist"; mkdir($tmpdp);
$tmpd = "$tmpn.dir";
mkdir($tmpd);
$tmpdp = "$tmpn.dir/playlist";
mkdir($tmpdp);
if ($withContent) {
$tmpdc = "$tmpn.dir/audioClip"; mkdir($tmpdc);
$tmpdc = "$tmpn.dir/audioClip";
mkdir($tmpdc);
}
foreach ($gunids as $i => $it) {
$ac = $r = StoredFile::recallByGunid($this, $it['gunid']);
@ -1064,7 +1155,7 @@ class BasicStor extends Alib {
if (file_exists($MDfname)) {
switch($it['type']) {
case "playlist":
require_once"LsPlaylist.php";
require_once("LsPlaylist.php");
$ac = $r = LsPlaylist::recallByGunid($this, $it['gunid']);
switch ($type) {
case"smil":
@ -1120,9 +1211,9 @@ class BasicStor extends Alib {
* Close playlist export previously opened by the bsExportPlaylistOpen
* method
*
* @param string $token - access token obtained from
* bsExportPlaylistOpen method call
* @return boolean true or error object
* @param string $token
* Access token obtained from bsExportPlaylistOpen method call.
* @return true/PEAR_Error
*/
function bsExportPlaylistClose($token)
{
@ -1145,16 +1236,22 @@ class BasicStor extends Alib {
/**
* Import playlist in LS Archive format
*
* @param int $parid, destination folder local id
* @param string $plid, playlist gunid
* @param string $aPath, absolute path part of imported file
* (e.g. /home/user/campcaster)
* @param string $rPath, relative path/filename part of imported file
* (e.g. playlists/playlist_1.smil)
* @param string $ext, playlist extension (determines type of import)
* @param hasharray $gunids, hash relation from filenames to gunids
* @param int $subjid, local subject (user) id (id of user doing the import)
* @return int, result file local id (or error object)
* @param int $parid
* Destination folder local id
* @param string $plid
* Playlist gunid
* @param string $aPath
* Absolute path part of imported file (e.g. /home/user/campcaster)
* @param string $rPath
* Relative path/filename part of imported file (e.g. playlists/playlist_1.smil)
* @param string $ext
* Playlist extension (determines type of import)
* @param array $gunids
* Hash relation from filenames to gunids
* @param int $subjid
* Local subject (user) id (id of user doing the import)
* @return int
* Result file local id (or error object)
*/
function bsImportPlaylistRaw($parid, $plid, $aPath, $rPath, $ext, &$gunids, $subjid)
{
@ -1209,10 +1306,14 @@ class BasicStor extends Alib {
/**
* Import playlist in LS Archive format
*
* @param int $parid, destination folder local id
* @param string $fpath, imported file pathname
* @param int $subjid, local subject (user) id (id of user doing the import)
* @return int, result file local id (or error object)
* @param int $parid
* Destination folder local id
* @param string $fpath
* Imported file pathname
* @param int $subjid
* Local subject (user) id (id of user doing the import)
* @return int
* Result file local id (or error object)
*/
function bsImportPlaylist($parid, $fpath, $subjid)
{
@ -1268,7 +1369,7 @@ class BasicStor extends Alib {
}
}
// playlists:
require_once"Playlist.php";
require_once("Playlist.php");
$d = @dir($tmpdp);
if ($d !== false) {
while ((!PEAR::isError($res)) && false !== ($entry = $d->read())) {
@ -1285,7 +1386,9 @@ class BasicStor extends Alib {
$d->close();
}
//@rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd);
@system("rm -rf $tmpdc"); @system("rm -rf $tmpdp"); @system("rm -rf $tmpd");
@system("rm -rf $tmpdc");
@system("rm -rf $tmpdp");
@system("rm -rf $tmpd");
@unlink($tmpn);
return $res;
}
@ -1296,7 +1399,8 @@ class BasicStor extends Alib {
/**
* List files in folder
*
* @param int $id, local id of folder
* @param int $id
* Local ID of folder
* @return array
*/
function bsListFolder($id)
@ -1338,7 +1442,8 @@ class BasicStor extends Alib {
/**
* Analyze media file for internal metadata information
*
* @param int $id, virt.file's local id
* @param int $id
* Virtual file's local id
* @return array
*/
function bsAnalyzeFile($id)
@ -1355,8 +1460,10 @@ class BasicStor extends Alib {
/**
* List files in folder
*
* @param int $id, local id of object
* @param string $relPath, relative path
* @param int $id
* Local id of object
* @param string $relPath
* Relative path
* @return array
*/
function getObjIdFromRelPath($id, $relPath='.')
@ -1411,9 +1518,12 @@ class BasicStor extends Alib {
/**
* Check if file exists in the storage
*
* @param id: int, local id
* @param ftype: string, internal file type
* @param byGunid: boolean, select file by gunid (id is then ignored)
* @param int $id
* Local id
* @param string $ftype
* Internal file type
* @param boolean $byGunid
* select file by gunid (id is then ignored)
* @return boolean
*/
function bsExistsFile($id, $ftype=NULL, $byGunid=FALSE)
@ -1430,7 +1540,8 @@ class BasicStor extends Alib {
case GBERR_FOBJNEX:
return FALSE;
break;
default: return $ac;
default:
return $ac;
}
}
$realFtype = $this->_getType($ac->gunid);
@ -1450,7 +1561,8 @@ class BasicStor extends Alib {
* Get object type by id.
* (RootNode, Folder, File, )
*
* @param int $oid, local object id
* @param int $oid
* Local object id
* @return string/err
*/
function getObjType($oid)
@ -1477,8 +1589,8 @@ class BasicStor extends Alib {
* Add new user with home folder
*
* @param string $login
* @param string $pass OPT
* @param string $realname OPT
* @param string $pass
* @param string $realname
* @return int/err
*/
function addSubj($login, $pass=NULL, $realname='')
@ -1593,10 +1705,13 @@ class BasicStor extends Alib {
/**
* Check authorization - auxiliary method
*
* @param array $acts of actions
* @param array $pars of parameters - e.g. ids
* @param string $sessid, session id
* @return true or PEAR::error
* @param array $acts
* Array of actions
* @param array $pars
* Array of parameters - e.g. ids
* @param string $sessid
* Session id
* @return true/PEAR::error
*/
function _authorize($acts, $pars, $sessid='')
{
@ -1634,8 +1749,10 @@ class BasicStor extends Alib {
/**
* Return users's home folder local ID
*
* @param string $subjid, local subject id
* @return local folder id
* @param string $subjid
* Local subject id
* @return unknown
* local folder id
*/
function _getHomeDirId($subjid)
{
@ -1658,8 +1775,10 @@ class BasicStor extends Alib {
/**
* Return users's home folder local ID
*
* @param string $sessid, session ID
* @return local folder id
* @param string $sessid
* session ID
* @return unknown
* local folder id
*/
function _getHomeDirIdFromSess($sessid)
{
@ -1674,8 +1793,10 @@ class BasicStor extends Alib {
/**
* Get local id from global id
*
* @param string $gunid global id
* @return int local id
* @param string $gunid
* Global id
* @return int
* Local id
*/
function _idFromGunid($gunid)
{
@ -1688,8 +1809,10 @@ class BasicStor extends Alib {
/**
* Get global id from local id
*
* @param int $id local id
* @return string global id
* @param int $id
* Local id
* @return string
* Global id
*/
function _gunidFromId($id)
{
@ -1713,8 +1836,10 @@ class BasicStor extends Alib {
/**
* Get storage-internal file type
*
* @param string $gunid, global unique id of file
* @return string, see install()
* @param string $gunid
* Global unique id of file
* @return string
* see install()
*/
function _getType($gunid)
{
@ -1729,7 +1854,8 @@ class BasicStor extends Alib {
/**
* Check gunid format
*
* @param string $gunid, global unique ID
* @param string $gunid
* Global unique ID
* @return boolean
*/
function _checkGunid($gunid)
@ -1740,8 +1866,8 @@ class BasicStor extends Alib {
/**
* Returns if gunid is free
*
* Returns TRUE if gunid is free
* @return boolean/err
*/
function _gunidIsFree($gunid)
{
@ -1762,11 +1888,16 @@ class BasicStor extends Alib {
/**
* Set playlist edit flag
*
* @param string $playlistId, playlist global unique ID
* @param boolean $val, set/clear of edit flag
* @param string $sessid, session id
* @param int $subjid, subject id (if sessid is not specified)
* @return boolean, previous state
* @param string $playlistId
* Playlist global unique ID
* @param boolean $val
* Set/clear of edit flag
* @param string $sessid
* Session id
* @param int $subjid
* Subject id (if sessid is not specified)
* @return boolean
* previous state
*/
function _setEditFlag($playlistId, $val=TRUE, $sessid=NULL, $subjid=NULL)
{
@ -1796,8 +1927,10 @@ class BasicStor extends Alib {
/**
* Check if playlist is marked as edited
*
* @param string $playlistId, playlist global unique ID
* @return FALSE | int - id of user editing it
* @param string $playlistId
* Playlist global unique ID
* @return FALSE/int
* ID of user editing it
*/
function _isEdited($playlistId)
{
@ -1814,10 +1947,11 @@ class BasicStor extends Alib {
/* ---------------------------------------- redefined "protected" methods */
/**
* Copy virtual file.<br>
* Copy virtual file.
* Redefined from parent class.
*
* @return int, new object local id
* @return int
* New object local id
*/
function copyObj($id, $newParid, $after=NULL)
{
@ -1863,11 +1997,11 @@ class BasicStor extends Alib {
}
if ($ac->isEdited()) {
return PEAR::raiseError(
'BasicStor::moveObj: is edited');
'BasicStor::moveObj: file is currently being edited, it cannot be moved.');
}
if ($ac->isAccessed()) {
return PEAR::raiseError(
'BasicStor::moveObj: is accessed');
'BasicStor::moveObj: file is currently in use, it cannot be moved.');
}
break;
default:
@ -1884,11 +2018,11 @@ class BasicStor extends Alib {
* Optionaly remove virtual file with the same name and add new one.<br>
* Redefined from parent class.
*
* @return id
* @return unknown
* ID
*/
function addObj($name, $type, $parid=1, $aftid=NULL, $param='')
{
$name = pg_escape_string($name);
$exid = $this->getObjId($name, $parid);
if ($this->dbc->isError($exid)) {
return $exid;
@ -1911,9 +2045,11 @@ class BasicStor extends Alib {
* Remove virtual file.<br>
* Redefined from parent class.
*
* @param int $id, local id of removed object
* @param boolean $forced, unconditional delete
* @return true or PEAR::error
* @param int $id
* Local id of removed object
* @param boolean $forced
* Unconditional delete
* @return true/PEAR::error
*/
function removeObj($id, $forced=FALSE)
{
@ -1958,9 +2094,11 @@ class BasicStor extends Alib {
/**
* Write string to file
*
* @param str - string to be written to file
* @param fname - string, pathname to file
* @return TRUE or raise error
* @param string $str
* string to be written to file
* @param string $fname
* pathname to file
* @return TRUE/raiseError
*/
function bsStr2File($str, $fname)
{
@ -1987,7 +2125,7 @@ class BasicStor extends Alib {
* <li>type - type of field</li>
* </ul>
*
* @return boolean TRUE or error
* @return TRUE/error
*/
function upgradeDbStructure()
{
@ -2025,9 +2163,12 @@ class BasicStor extends Alib {
/**
* Reset storageServer for debugging.
*
* @param boolean $loadSampleData - flag for allow sample data loading
* @param boolean $filesOnly - flag for operate only on files in storage
* @return result of localSearch with filetype 'all' and no conditions,
* @param boolean $loadSampleData
* Flag for allow sample data loading
* @param boolean $filesOnly
* Flag for operate only on files in storage
* @return array
* result of localSearch with filetype 'all' and no conditions,
* i.e. array of hashes, fields:
* cnt : integer - number of inserted files
* results : array of hashes: