Esempio n. 1
0
 public static function getFileGroupAccessList($authId)
 {
     if ($_SESSION[C('ADMIN_AUTH_KEY')]) {
         return array();
     }
     $authId = $authId ? $authId : $_SESSION[C('USER_AUTH_KEY')];
     $file = DConfig_PATH . "/AccessList/access_" . $authId . ".php";
     if (!file_exists($file)) {
         $accessList = RBAC::getAccessList($authId);
         if (!file_exists(DConfig_PATH . "/AccessList")) {
             createFolder(dirname(DConfig_PATH . "/AccessList"));
             mkdir(DConfig_PATH . "/AccessList", 0777);
         }
         RBAC::writeover($file, "return " . RBAC::pw_var_export($accessList) . ";\n", true);
         foreach ($accessList as $k3 => $v3) {
             foreach ($accessList[$k3] as $k1 => $v1) {
                 foreach ($accessList[$k3][$k1] as $k => $v) {
                     $p = explode("-", $v);
                     $_SESSION[strtolower($k1 . '_' . $k)] = $p[1];
                 }
             }
         }
     }
     $access = (require $file);
     $groupList = array();
     $num = 0;
     foreach ($access as $k1 => $v1) {
         foreach ($v1 as $k2 => $v2) {
             if ($k2 == "INDEX") {
                 continue;
             }
             foreach ($v2 as $k3 => $v3) {
                 //等于组ID时压入到组数组
                 if ($k3 == "GROUPID") {
                     $groupList[$num] = $v3;
                     $num++;
                 }
             }
         }
     }
     $groupList = array_unique($groupList);
     return $groupList;
 }