From 496e49a68c7a737b38e6412c1871e43aae78d0f1 Mon Sep 17 00:00:00 2001 From: tomas Date: Thu, 25 Nov 2004 17:38:03 +0000 Subject: [PATCH] StoredFile::recallByGunid method added for more clear recalling by gunid. --- .../modules/storageServer/var/GreenBox.php | 6 +++--- .../modules/storageServer/var/LocStor.php | 14 +++++++------- .../modules/storageServer/var/StoredFile.php | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php index da3e7d1cc..b411ccf43 100644 --- a/livesupport/modules/storageServer/var/GreenBox.php +++ b/livesupport/modules/storageServer/var/GreenBox.php @@ -23,7 +23,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -48,7 +48,7 @@ require_once "Transport.php"; * LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @see Alib */ class GreenBox extends Alib{ @@ -548,7 +548,7 @@ class GreenBox extends Alib{ { if(!$gunid) $gunid = $this->_gunidFromId($id); else $id = $this->_idFromGunid($gunid); - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(PEAR::isError($ac)) return $ac; $mediaTarget = $ac->_getRealRADFname(); $mediaFile = "$gunid"; diff --git a/livesupport/modules/storageServer/var/LocStor.php b/livesupport/modules/storageServer/var/LocStor.php index 9dce52160..d117b0f92 100644 --- a/livesupport/modules/storageServer/var/LocStor.php +++ b/livesupport/modules/storageServer/var/LocStor.php @@ -23,7 +23,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -46,7 +46,7 @@ class LocStor extends GreenBox{ */ function existsAudioClip($sessid, $gunid) { - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(PEAR::isError($ac)){ // catch some exceptions switch($ac->getCode()){ @@ -73,7 +73,7 @@ class LocStor extends GreenBox{ function storeAudioClip($sessid, $gunid, $mediaFileLP, $mdataFileLP) { // test if specified gunid exists: - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(!PEAR::isError($ac)){ // gunid exists - do replace if(($res = $this->_authorize( @@ -117,7 +117,7 @@ class LocStor extends GreenBox{ */ function deleteAudioClip($sessid, $gunid) { - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(PEAR::isError($ac)) return $ac; if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) return $res; @@ -135,7 +135,7 @@ class LocStor extends GreenBox{ */ function updateAudioClipMetadata($sessid, $gunid, $mdataFileLP) { - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(PEAR::isError($ac)) return $ac; if(($res = $this->_authorize('write', $ac->getId(), $sessid)) !== TRUE) return $res; @@ -150,7 +150,7 @@ class LocStor extends GreenBox{ */ function accessRawAudioData($sessid, $gunid) { - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(PEAR::isError($ac)) return $ac; if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) return $res; @@ -193,7 +193,7 @@ class LocStor extends GreenBox{ */ function getAudioClip($sessid, $gunid) { - $ac =& StoredFile::recall(&$this, '', $gunid); + $ac =& StoredFile::recallByGunid(&$this, $gunid); if(PEAR::isError($ac)) return $ac; if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE) return $res; diff --git a/livesupport/modules/storageServer/var/StoredFile.php b/livesupport/modules/storageServer/var/StoredFile.php index 30a37b2f0..c290b1d3f 100644 --- a/livesupport/modules/storageServer/var/StoredFile.php +++ b/livesupport/modules/storageServer/var/StoredFile.php @@ -23,7 +23,7 @@ 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 $ ------------------------------------------------------------------------------*/ @@ -131,7 +131,7 @@ class StoredFile{ */ 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 FROM {$gb->filesTable} WHERE $cond"); if(PEAR::isError($row)) return $row; @@ -147,6 +147,18 @@ class StoredFile{ $ac->id = $row['id']; return $ac; } + /** + * Create instace of StoreFile object and recall existing file + * by gunid.
+ * + * @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 *