Authority. class. php modify the permission to be verified $ name if the permission list does not exist, this permission is granted to php code by default.
// Get the permission $ name can be a string or an array or separated by commas. uid is the authenticated user ID, $ or is in the or relation, true is, and name is an array, if one of the conditions in the array is passed, it is passed. if it is false, all conditions must pass. // Last modification function: permission to be verified $ name if the permission list does not exist, this permission is granted by default to 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 the part to start foreach ($ name as $ key => $ val) {if (! $ This-> isExistsRule ($ val) {unset ($ name [$ key]) ;}} if (count ($ name) == 0) {return true ;} // end of modifying part $ list = array (); // name foreach ($ authList as $ val) with permission {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 determines whether the database has the permission * @ 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];}