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 $
|
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 $
|
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
|
* Core of LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.28 $
|
* @version $Revision: 1.29 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib{
|
class BasicStor extends Alib{
|
||||||
|
@ -805,6 +805,31 @@ class BasicStor extends Alib{
|
||||||
return $nid;
|
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 */
|
/* ---------------------------------------------------- redefined methods */
|
||||||
/**
|
/**
|
||||||
* Get object type by id.
|
* Get object type by id.
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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
|
* LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.32 $
|
* @version $Revision: 1.33 $
|
||||||
* @see BasicStor
|
* @see BasicStor
|
||||||
*/
|
*/
|
||||||
class GreenBox extends BasicStor{
|
class GreenBox extends BasicStor{
|
||||||
|
@ -882,6 +882,36 @@ class GreenBox extends BasicStor{
|
||||||
return $listArr;
|
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 */
|
/* ---------------------------------------------------- redefined methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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 sessid string
|
||||||
* @param gunid string
|
* @param gunid string
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @see GreenBox
|
|
||||||
*/
|
*/
|
||||||
function existsAudioClip($sessid, $gunid)
|
function existsAudioClip($sessid, $gunid)
|
||||||
{
|
{
|
||||||
|
@ -412,23 +411,13 @@ class LocStor extends BasicStor{
|
||||||
* @param gunid string
|
* @param gunid string
|
||||||
* @param ftype string, internal file type
|
* @param ftype string, internal file type
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @see GreenBox
|
|
||||||
*/
|
*/
|
||||||
function existsFile($sessid, $gunid, $ftype=NULL)
|
function existsFile($sessid, $gunid, $ftype=NULL)
|
||||||
{
|
{
|
||||||
$ac =& StoredFile::recallByGunid($this, $gunid);
|
$id = $this->_idFromGunid($gunid);
|
||||||
if(PEAR::isError($ac)){
|
if(is_null($id)) return FALSE;
|
||||||
// catch some exceptions
|
$ex = $this->bsExistsFile($id, $ftype);
|
||||||
switch($ac->getCode()){
|
if(($res = $this->_authorize('read', $id, $sessid)) !== TRUE)
|
||||||
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)
|
|
||||||
return $res;
|
return $res;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue