.

NotificationsAccessControl Class Reference

Inheritance diagram for NotificationsAccessControl:
AccessControlBase IAccessControl

List of all members.

Public Member Functions

  __construct ()
  Constructor.

Protected Member Functions

  do_is_allowed_for_anonymous ($action, $item, $params=false)
  Overloadable.
  do_is_allowed_for_user ($action, $item, $user, $params=false)
  Overloadable.

Detailed Description

Definition at line 2 of file notifications.access.php.


Constructor & Destructor Documentation

NotificationsAccessControl::__construct (  ) 

Constructor.

Sets type on parent.

Definition at line 6 of file notifications.access.php.

00006                                       {
00007                 parent::__construct(array('notifications', 'users'));
00008         }

Member Function Documentation

NotificationsAccessControl::do_is_allowed_for_anonymous ( action,
item,
params = false  
) [protected]

Overloadable.

Check if action on object is allowed for no user

User is always valid

Parameters:
string  $action The action to perform (edit, delete, ....)
mixed  $item Item to perform the action on (may be a DataObject, e.g.)
Returns:
int One of Constants ALLOWED, NOT_ALLOWED and NOT_RESPONSIBLE

Reimplemented from AccessControlBase.

Definition at line 62 of file notifications.access.php.

00062                                                                                         {
00063                 return self::NOT_ALLOWED;
00064         }               
NotificationsAccessControl::do_is_allowed_for_user ( action,
item,
user,
params = false  
) [protected]

Overloadable.

Check if action on object is allowed for given user

User is always valid

Parameters:
string  $action The action to perform (edit, delete, ....)
mixed  $item Item to perform the action on (may be a DataObject, e.g.)
DAOUsers  $user A user, role, ACO, depending on user management chosen
Returns:
int One of Constants ALLOWED, NOT_ALLOWED and NOT_RESPONSIBLE

Reimplemented from AccessControlBase.

Definition at line 20 of file notifications.access.php.

00020                                                                                           {
00021                 // we know that item is of type "notifications" or "users"
00022                 $ret = self::NOT_RESPONSIBLE;
00023                 if ($item instanceof DAONotifications) {
00024                         $ret = self::NOT_ALLOWED;
00025                         switch ($action) {
00026                                 case 'status':
00027                                         $ret =  $this->to_result($item->id_user == $user->id); 
00028                                         break;
00029                                 case 'exclude':
00030                                         $ret = $this->to_result(!empty($item->source_id));
00031                                         break;
00032                         }
00033                 } else if ($item instanceof DAOUsers) {
00034                         switch ($action) {
00035                                 case 'notifyall':
00036                                         $ret = $this->to_result($user->has_role(USER_ROLE_ADMIN)); 
00037                                         break;
00038                                 case 'notify':
00039                                         $ret = $this->to_result($item->is_active());
00040                                         break;
00041                         }                       
00042                 }
00043                 else {
00044                         switch ($action) {
00045                                 case 'markallasread':
00046                                         $ret = self::ALLOWED; 
00047                                         break;
00048                         }
00049                 }
00050                 return $ret;            
00051         }

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