BasicStor: bsExistsFile added
GreenBox: getFileType and existsFile added LocStor: minor changes
This commit is contained in:
parent
e88e501365
commit
7391795ac5
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.28 $
|
||||
Version : $Revision: 1.29 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -52,7 +52,7 @@ require_once "Transport.php";
|
|||
* Core of LiveSupport file storage module
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.28 $
|
||||
* @version $Revision: 1.29 $
|
||||
* @see Alib
|
||||
*/
|
||||
class BasicStor extends Alib{
|
||||
|
@ -805,6 +805,31 @@ class BasicStor extends Alib{
|
|||
return $nid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists in the storage
|
||||
*
|
||||
* @param id int, local id
|
||||
* @param ftype string, internal file type
|
||||
* @return boolean
|
||||
*/
|
||||
function bsExistsFile($id, $ftype=NULL)
|
||||
{
|
||||
$ac =& StoredFile::recall($this, $id);
|
||||
if(PEAR::isError($ac)){
|
||||
// catch some exceptions
|
||||
switch($ac->getCode()){
|
||||
case GBERR_FILENEX:
|
||||
case GBERR_FOBJNEX:
|
||||
return FALSE;
|
||||
break;
|
||||
default: return $ac;
|
||||
}
|
||||
}
|
||||
if(!is_null($ftype) && ($this->_getType($ac->gunid) != $ftype))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------- redefined methods */
|
||||
/**
|
||||
* Get object type by id.
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.32 $
|
||||
Version : $Revision: 1.33 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,7 +35,7 @@ require_once "BasicStor.php";
|
|||
* LiveSupport file storage module
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.32 $
|
||||
* @version $Revision: 1.33 $
|
||||
* @see BasicStor
|
||||
*/
|
||||
class GreenBox extends BasicStor{
|
||||
|
@ -882,6 +882,36 @@ class GreenBox extends BasicStor{
|
|||
return $listArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type of stored file (by local id)
|
||||
*
|
||||
* @param id int, local id
|
||||
* @return string/err
|
||||
*/
|
||||
function getFileType($id)
|
||||
{
|
||||
// $id = $this->_idFromGunid($gunid);
|
||||
$type = $this->getObjType($id);
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists in the storage and
|
||||
* user have permission to read it
|
||||
*
|
||||
* @param gunid string
|
||||
* @param ftype string, internal file type
|
||||
* @return string/err
|
||||
*/
|
||||
function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = $this->_idFromGunid($gunid);
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||
return $res;
|
||||
return $ex;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------- redefined methods */
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.29 $
|
||||
Version : $Revision: 1.30 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -390,7 +390,6 @@ class LocStor extends BasicStor{
|
|||
* @param sessid string
|
||||
* @param gunid string
|
||||
* @return boolean
|
||||
* @see GreenBox
|
||||
*/
|
||||
function existsAudioClip($sessid, $gunid)
|
||||
{
|
||||
|
@ -412,23 +411,13 @@ class LocStor extends BasicStor{
|
|||
* @param gunid string
|
||||
* @param ftype string, internal file type
|
||||
* @return boolean
|
||||
* @see GreenBox
|
||||
*/
|
||||
function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$ac =& StoredFile::recallByGunid($this, $gunid);
|
||||
if(PEAR::isError($ac)){
|
||||
// catch some exceptions
|
||||
switch($ac->getCode()){
|
||||
case GBERR_FILENEX:
|
||||
case GBERR_FOBJNEX:
|
||||
return FALSE;
|
||||
break;
|
||||
default: return $ac;
|
||||
}
|
||||
}
|
||||
if(!is_null($ftype) && ($this->_getType($gunid) != $ftype)) return FALSE;
|
||||
if(($res = $this->_authorize('read', $ac->getId(), $sessid)) !== TRUE)
|
||||
$id = $this->_idFromGunid($gunid);
|
||||
if(is_null($id)) return FALSE;
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||
return $res;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue