mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
- application/core/* -> CS compliant
- application/libraries/* -> CS compliant - FHC_Model isEntitled method now return error() or success() - Updated all code that uses isEntitled method from FHC_Model - Removed Squiz.PHP.DisallowSizeFunctionsInLoops from CS ruleset - Removed depracated method replace from DB_Model - Removed unused method pgArrayPhp from DB_Model - Renamed method arrayMergeIndex to _arrayCombine in DB_Model and set as private - Added method _manageUDFs to DB_Model (a wrapper for UDFLib->manageUDFs)
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
class FS_Model extends FHC_Model
|
||||
{
|
||||
protected $filepath; // Path of the file
|
||||
protected $acl; // Name of the permissions array index for FS writing, reading...
|
||||
|
||||
function __construct($filepath = null)
|
||||
|
||||
/**
|
||||
* Loads FilesystemLib and set properties
|
||||
*/
|
||||
public function __construct($filepath = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
@@ -26,16 +28,13 @@ class FS_Model extends FHC_Model
|
||||
public function read($filename)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check rights
|
||||
if (($chkRights = $this->isEntitled($this->filepath, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (isError($ent = $this->isEntitled($this->filepath, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
|
||||
|
||||
if (!is_null($data = $this->filesystemlib->read($this->filepath, $filename)))
|
||||
{
|
||||
@@ -56,18 +55,14 @@ class FS_Model extends FHC_Model
|
||||
public function write($filename, $content)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($content))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($content)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check rights
|
||||
if (($chkRights = $this->isEntitled($this->filepath, PermissionLib::INSERT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (isError(($ent = $this->isEntitled($this->filepath, PermissionLib::INSERT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)))) return $ent;
|
||||
|
||||
if ($this->filesystemlib->write($this->filepath, $filename, base64_decode($content)) === true)
|
||||
{
|
||||
@@ -88,18 +83,14 @@ class FS_Model extends FHC_Model
|
||||
public function append($filename, $content)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($content))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($content)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check rights
|
||||
if (($chkRights = $this->isEntitled($this->filepath, PermissionLib::INSERT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (isError($ent = $this->isEntitled($this->filepath, PermissionLib::INSERT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
|
||||
|
||||
if ($this->filesystemlib->append($this->filepath, $filename, base64_decode($content)) === true)
|
||||
{
|
||||
@@ -120,16 +111,13 @@ class FS_Model extends FHC_Model
|
||||
public function remove($filename)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check rights
|
||||
if (($chkRights = $this->isEntitled($this->filepath, PermissionLib::DELETE_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (isError($ent = $this->isEntitled($this->filepath, PermissionLib::DELETE_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
|
||||
|
||||
if ($this->filesystemlib->remove($this->filepath, $filename) === true)
|
||||
{
|
||||
@@ -150,18 +138,14 @@ class FS_Model extends FHC_Model
|
||||
public function rename($filename, $newFilename)
|
||||
{
|
||||
// Check Class-Attributes
|
||||
if (is_null($this->filepath))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($this->filepath)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check method parameters
|
||||
if (is_null($filename))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($newFilename))
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($filename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
if (is_null($newFilename)) return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
|
||||
// Check rights
|
||||
if (($chkRights = $this->isEntitled($this->filepath, PermissionLib::UPDATE_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $chkRights;
|
||||
if (isError($ent = $this->isEntitled($this->filepath, PermissionLib::UPDATE_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
|
||||
|
||||
if ($this->filesystemlib->rename($this->filepath, $filename, $this->filepath, $newFilename) === true)
|
||||
{
|
||||
@@ -172,4 +156,4 @@ class FS_Model extends FHC_Model
|
||||
return error(FHC_MODEL_ERROR, FHC_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user