* @package WB * @subpackage vfs */ WBClass::load('WBVFS' ); /** * Virtual File System: Access Control Rule * * @version 0.2.0 * @package WB * @subpackage vfs */ class WBVFS_AccessControlRule extends WBStdClass { const GRANT_NA = 0; const GRANT_ALLOW = 1; const GRANT_DENY = 2; /** * Configuration parameters * @var array */ protected $config = array( // 'foo' => 'bar' ); /** * File * @var WBVFS_File */ protected $file; /** * Mime Handler * @var WBVFS_Mime */ protected $mime; /** * Mime Minor * @var string */ protected $mimeMinor; /** * Logging Facility * @var WBLog */ protected $log; /** * Constructor * @param array $parameter */ public function __construct($parameter = array()) { } /** * Logger * @param WBLog */ public function setLogger($log) { $this->log = $log; } /** * Set Instnace Parameters * * @param array */ public final function setConfig($config = array()) { $this->config = array_merge($this->config, $config); $this->init(); } /** * 2nc Constructor * * Called after configuration was set */ protected function init() { } /** * Set File and Mime Handler * * @param WBVFS_File * @param WBVFS_Mime */ public final function setVFSFile($file, $mime) { $this->file = $file; $this->mime = $mime; } /** * Set File and Mime Handler * * @param string mime minor */ public final function setRequestMimeMinor($mimeMinor = null) { $this->mimeMinor = $mimeMinor; } /** * Check Permissions 4 Request * * @param WBRequest * @return bool */ public function isRequestGranted($req) { return true; } /** * Get Predefined log Messagage * * @see GRANT_NA * @param int GRANT * @param string * @return array */ protected function getLogMsg($grant = self::GRANT_NA, $txt = '') { $hdl = substr(get_class($this->mime), strlen('WBVFS_Mime_')); $rule = substr(get_class($this), strlen(__CLASS__) + 1); switch ($grant) { case self::GRANT_NA: $grant = '-'; break; case self::GRANT_ALLOW: $grant = 'allowed'; break; case self::GRANT_DENY: $grant = 'denied'; break; default: $grant = 'unknown'; break; } $msg = array( 'vfsfile' => $this->file->getId(), 'mime' => $this->file->getMime(), 'handler' => $hdl, 'rule' => $rule, 'access' => $grant, ); $txt = trim($txt); if (empty($txt)) { return $msg; } $msg['msg'] = $txt; return $msg; } }