00001 <?php
00002 class NotificationsAccessControl extends AccessControlBase {
00003
00004
00005
00006 public function __construct() {
00007 parent::__construct(array('notifications', 'users'));
00008 }
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 protected function do_is_allowed_for_user($action, $item, $user, $params = false) {
00021
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 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 protected function do_is_allowed_for_anonymous($action, $item, $params = false) {
00063 return self::NOT_ALLOWED;
00064 }
00065 }