public function auth()
 {
     $role = spyc_load_file("./Conf/role.yml");
     $names = trim($_GET["id"]);
     if (!isset($role[$names])) {
         $this->error("角色不存在", U("lists"));
         exit;
     }
     $array_id = explode(",", $role[$names]["lists"]);
     import("ORG.Util.ArrayModel");
     //数组解析类
     $nav_arr = spyc_load_file("./Conf/nav.yml");
     $nav = new ArrayModel($nav_arr);
     $where["pid"] = array("eq", 0);
     $top_nav = $nav->where($where)->order("sort asc")->select();
     foreach ($top_nav as $v) {
         $item .= "<tr><td>";
         $item .= $v["id"] . "</td><td>";
         $item .= in_array($v["id"], $array_id) ? "<input type=\"checkbox\" name=\"nav_id[]\" value=\"{$v["id"]}\"></td>" : "<input type=\"checkbox\" name=\"nav_id[]\" checked value=\"{$v["id"]}\"></td>";
         $item .= "<td class=\"tl\">{$v['names']}</td>";
         $item .= $v["enable"] == 1 ? "<td>已启用</td>" : "<td>已禁用</td>";
         $item .= "</tr>";
         $item .= $this->getsubnav($nav, $v["id"], $array_id);
     }
     $this->assign("names", $names);
     $this->assign("role_info", $role[$names]);
     $this->assign("nav_str", $item);
     $this->display();
 }
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (empty($this->menuid)) {
             return false;
         }
         if (!isset($this->visible)) {
             $this->visible = true;
         }
         if (!isset($this->descriptionashint)) {
             $this->descriptionashint = true;
         }
         if (!isset($this->titles)) {
             $this->titles = $this->asa('attributesBehavior')->initLanguageAttribute('titles');
         }
         if (empty($this->sortposition)) {
             $this->sortposition = 0;
         }
         if (!isset($this->adminroles)) {
             $this->adminroles = '';
         }
         if (is_array($this->adminroles)) {
             $this->adminroles = implode(',', $this->adminroles);
         }
         return true;
     } else {
         return false;
     }
 }
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (empty($this->itemid)) {
             $this->itemid = md5(uniqid());
         }
         if (empty($this->url)) {
             $this->url = '#';
         }
         if (!isset($this->active)) {
             $this->active = false;
         }
         if (!isset($this->visible)) {
             $this->visible = true;
         }
         if (!isset($this->descriptionashint)) {
             $this->descriptionashint = true;
         }
         if (!isset($this->labels)) {
             $this->labels = $this->asa('attributesBehavior')->initLanguageAttribute('labels');
         }
         if (!isset($this->descriptions)) {
             $this->descriptions = $this->asa('attributesBehavior')->initLanguageAttribute('descriptions');
         }
         return true;
     } else {
         return false;
     }
 }