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; } }
protected static function get_fields() { return implode(', ', array(self::select_fields(), UserProfile::select_fields(), User::select_fields('referer'), ACLGroup::select_fields(), Country::select_fields())); }
protected static function get_fields() { return self::select_fields() . ', ' . ACLGroup::select_fields() . ', ' . ACL::select_fields(); }
public function aclgroup($nickname = null) { $user = $this->load_user($nickname); if ($this->post) { $user->aclgroup_id = $this->PostData('aclgroup_id'); if ($user->save()) { Site::flash("notice", "User's ACL group has been updated"); Redirect("admin/users/" . $user->permalink()); } } $allGroups = ACLGroup::find_all(''); foreach ($allGroups as $group) { $groups[$group->id] = $group->name; } $this->assign('groups', $groups); $this->assign("user", $user); $this->title = "Edit User's ACL Group"; $this->render("user/aclgroup.tpl"); }
protected function load_group($id = null) { if (!$id) { $id = $this->GetData('group_id'); } $group = ACLGroup::find_by_id($id); if (!$group) { throw new Error404('Unable to find ACL Group'); } return $group; }