Get permission $name can be a string or an array or a comma-delimited, UID is an authenticated user ID, $or is an or relationship, and true is, name is an array, as long as there is a condition passed through in the arrays, if false requires that all conditions pass. Last modified function: permissions to be verified $name if the permission list does not exist then the default has the public function GetAuth ($name, $uid, $relation = ' or ') {if (! $this->_config[') Auth_on ']) return true; $authList = $this->getauthlist ($uid); if (is_string ($name)) {if (Strpos ($name, ', ')!== false) {$name = explode (', ', $name); } else {$name = array ($name); }}//Modify section to start foreach ($name as $key + = $val) {if (! $this->isexistsrule ($val)) {unset ($name [$k EY]); }} if (count ($name) ==0) {return true; }//Modify partial end $list = Array (); The name of the right foreach ($authList as $val) {if (In_array ($val, $name)) $list [] = $val; } if ($relation = = ' or ' and!empty ($list)) {return true; } $diff = Array_diff ($name, $list); if ($relation = = ' and ' and Empty ($diff)) {return true; } return false;} /** * @desC Determine if the database has permissions * @param string $name rulename */public function Isexistsrule ($name) {Static $rule = array (); if (!empty ($rule [$name])) {return $rule [$name]; } $rule [$name] = M ()->table ($this->_config[' Auth_rule ')->where (Array (' name ' = = $name))->count (); return $rule [$name];}
thinkphp Authority.class.php Modify the permissions to be verified $name if the permission list does not exist then the permission is default