.

AccessControl Class Reference
[Behaviour]

Facade for access control checking. More...

List of all members.

Static Public Member Functions

static  get_current_aro ()
  Returns current Access Request Object.
static  is_allowed ($action, $item, $params=false, $user=false)
  Check if action on object is allowed for user.
static  load ()
  Load all accesscontrols located in /behaviour/accesscontrol/.
static  set_current_aro ($aro)
  Set current access request object (e.g.
static  set_implementation (IAccessControl $implementation, $keep_old=false)
  Change Implementation.

Detailed Description

Facade for access control checking.

Definition at line 7 of file accesscontrol.cls.php.


Member Function Documentation

static AccessControl::get_current_aro (  )  [static]

Returns current Access Request Object.

Returns:
mixed

Definition at line 52 of file accesscontrol.cls.php.

00052                                                  {
00053                 return self::$current_aro;
00054         }
static AccessControl::is_allowed ( action,
item,
params = false,
user = false  
) [static]

Check if action on object is allowed for user.

Returns false if no implementation is set!

Parameters:
string  $action The action to perform
mixed  $item Item (e.g. table) to perform action on
mixed  $user An ARO. If ommited, self::get_current_aro() is substituted
Returns:
bool

Definition at line 66 of file accesscontrol.cls.php.

00066                                                                                           {
00067                 if (empty($user)) {
00068                         $user = self::get_current_aro();
00069                 }
00070                 if (self::$implementation) {
00071                         return self::$implementation->is_allowed($action, $item, $user, $params);
00072                 }
00073                 return false;
00074         }       
static AccessControl::load (  )  [static]

Load all accesscontrols located in /behaviour/accesscontrol/.

Definition at line 79 of file accesscontrol.cls.php.

00079                                       {
00080                 $dirs = Load::get_base_directories(Load::ORDER_DECORATORS);
00081                 foreach($dirs as $dir) {
00082                         foreach (gyro_glob($dir . 'behaviour/accesscontrol/*.access.php') as $inc) {
00083                                 include_once($inc);
00084                                 // Detect access control name from filename
00085                                 // ".", "-" and "_" get translated to camel case:
00086                                 // users.access.php => UsersAccessControl
00087                                 $clsname = Load::filename_to_classname($inc, 'Control');
00088                                 if (class_exists($clsname)) {
00089                                         self::set_implementation(new $clsname());
00090                                 }
00091                                 else {
00092                                         throw new Exception(tr('AccessControl %c not found', 'core', array('%c' => $clsname)));                                 
00093                                 }
00094                         }
00095                 }
00096         }
static AccessControl::set_current_aro ( aro  )  [static]

Set current access request object (e.g.

current user)

Parameters:
mixed  $aro

Definition at line 43 of file accesscontrol.cls.php.

00043                                                      {
00044                 self::$current_aro = $aro;
00045         }
static AccessControl::set_implementation ( IAccessControl implementation,
keep_old = false  
) [static]

Change Implementation.

Parameters:
IAccessControl  $implementation
bool  $keep_old If set to TRUE, new implementation will not get replaced, if there already is any

Definition at line 27 of file accesscontrol.cls.php.

00027                                                                                                      {
00028                 // keep old, if told so 
00029                 if (!empty(self::$implementation)) {
00030                         if ($keep_old) {
00031                                 return;
00032                         }
00033                         $implementation->set_old_implementation(self::$implementation); 
00034                 }
00035                 self::$implementation = $implementation;
00036         }

The documentation for this class was generated from the following file: