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