StoredFile::recallByGunid method added for more clear recalling by gunid.

This commit is contained in:
tomas 2004-11-25 17:38:03 +00:00
parent a0eba92d89
commit 496e49a68c
3 changed files with 24 additions and 12 deletions

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -48,7 +48,7 @@ require_once "Transport.php";
* LiveSupport file storage module * LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
* @see Alib * @see Alib
*/ */
class GreenBox extends Alib{ class GreenBox extends Alib{
@ -548,7 +548,7 @@ class GreenBox extends Alib{
{ {
if(!$gunid) $gunid = $this->_gunidFromId($id); if(!$gunid) $gunid = $this->_gunidFromId($id);
else $id = $this->_idFromGunid($gunid); else $id = $this->_idFromGunid($gunid);
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
$mediaTarget = $ac->_getRealRADFname(); $mediaTarget = $ac->_getRealRADFname();
$mediaFile = "$gunid"; $mediaFile = "$gunid";

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.5 $ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -46,7 +46,7 @@ class LocStor extends GreenBox{
*/ */
function existsAudioClip($sessid, $gunid) function existsAudioClip($sessid, $gunid)
{ {
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(PEAR::isError($ac)){ if(PEAR::isError($ac)){
// catch some exceptions // catch some exceptions
switch($ac->getCode()){ switch($ac->getCode()){
@ -73,7 +73,7 @@ class LocStor extends GreenBox{
function storeAudioClip($sessid, $gunid, $mediaFileLP, $mdataFileLP) function storeAudioClip($sessid, $gunid, $mediaFileLP, $mdataFileLP)
{ {
// test if specified gunid exists: // test if specified gunid exists:
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(!PEAR::isError($ac)){ if(!PEAR::isError($ac)){
// gunid exists - do replace // gunid exists - do replace
if(($res = $this->_authorize( if(($res = $this->_authorize(
@ -117,7 +117,7 @@ class LocStor extends GreenBox{
*/ */
function deleteAudioClip($sessid, $gunid) function deleteAudioClip($sessid, $gunid)
{ {
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE)
return $res; return $res;
@ -135,7 +135,7 @@ class LocStor extends GreenBox{
*/ */
function updateAudioClipMetadata($sessid, $gunid, $mdataFileLP) function updateAudioClipMetadata($sessid, $gunid, $mdataFileLP)
{ {
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE)
return $res; return $res;
@ -150,7 +150,7 @@ class LocStor extends GreenBox{
*/ */
function accessRawAudioData($sessid, $gunid) function accessRawAudioData($sessid, $gunid)
{ {
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE)
return $res; return $res;
@ -193,7 +193,7 @@ class LocStor extends GreenBox{
*/ */
function getAudioClip($sessid, $gunid) function getAudioClip($sessid, $gunid)
{ {
$ac =& StoredFile::recall(&$this, '', $gunid); $ac =& StoredFile::recallByGunid(&$this, $gunid);
if(PEAR::isError($ac)) return $ac; if(PEAR::isError($ac)) return $ac;
if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE)
return $res; return $res;

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -131,7 +131,7 @@ class StoredFile{
*/ */
function recall(&$gb, $oid='', $gunid='') function recall(&$gb, $oid='', $gunid='')
{ {
$cond = ($gunid=='' ? "id='$oid'" : "gunid='$gunid'" ); $cond = ($oid != '' ? "id='".intval($oid)."'" : "gunid='$gunid'" );
$row = $gb->dbc->getRow("SELECT id, gunid, type, name $row = $gb->dbc->getRow("SELECT id, gunid, type, name
FROM {$gb->filesTable} WHERE $cond"); FROM {$gb->filesTable} WHERE $cond");
if(PEAR::isError($row)) return $row; if(PEAR::isError($row)) return $row;
@ -147,6 +147,18 @@ class StoredFile{
$ac->id = $row['id']; $ac->id = $row['id'];
return $ac; return $ac;
} }
/**
* Create instace of StoreFile object and recall existing file
* by gunid.<br>
*
* @param gb reference to GreenBox object
* @param gunid string, optional, global unique id of file
* @return instace of StoredFile object
*/
function recallByGunid(&$gb, $gunid='')
{
return StoredFile::recall(&$gb, '', $gunid);
}
/** /**
* Create instace of StoreFile object and recall existing file from tmpLink * Create instace of StoreFile object and recall existing file from tmpLink
* *