thinkphp Authority.class.php Modify the permissions to be verified $name if the permission list does not exist then the permission is default

Source: Internet
Author: User
Tags diff

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.