public function validate() { $return = true; if ($this->name == "") { $this->errors[] = "You must enter a name"; $return = false; } if ($this->code == "") { $this->errors[] = "You must enter a code"; $return = false; } if ($this->description == "") { $this->errors[] = "You must enter a description"; $return = false; } if ($this->code) { $group = ACLGroup::find_by_code($this->code); if ($group && (!$this->id || $group->id != $this->id)) { $this->errors[] = 'The code is already in use'; } } if (count($this->errors) > 0) { $return = false; } return $return; }
public function run($action) { $controller = get_class($this); $user = Site::CurrentUser(); if ($user) { $group = $user->aclgroup; } else { $group = ACLGroup::find_by_code('guest'); } if (!$group) { throw new Error500('Unable to find ACL group'); } $rule = $this->getRule($group, $controller, $action); if (!$rule) { throw new Error403('You do not have permission to access this resource'); } switch ($rule->action) { case 'araDeny': if ($rule->error) { Site::InstantFlash('error', $rule->error); } elseif ($rule->notice) { Site::InstantFlash('notice', $rule->notice); } throw new Error403('You do not have permission to access this resource'); case 'araRedirect': if ($rule->error) { Site::Flash('error', $rule->error); } elseif ($rule->notice) { Site::Flash('notice', $rule->notice); } $uri = $_SERVER["REQUEST_URI"]; if (substr($uri, 0, 1) == '/') { $uri = substr($uri, 1); } Site::Flash('redirect', $uri); Redirect($rule->url); break; case 'araAllow': $params = func_get_args(); array_shift($params); call_user_func_array(array($this, $action), $params); break; } }
public function __construct() { $this->country_id = 74; $this->dateofbirth = strtotime("3 years ago"); $group = ACLGroup::find_by_code('user'); $this->aclgroup_id = $group->id; $this->aclgroup = $group; }