Exemple #1
0
 public function role_perm($type = 'module', $id = '')
 {
     $this->data['type'] = $type;
     if ($id) {
         $role = $this->db->where(array('roleid' => $id))->get('admin_role')->row_array();
         $this->data['role'] = $role;
         $role_perm = $this->data['roles'] = $this->M_user->get_admin_role_perm($id);
         if ($type == 'module') {
             //print_r($role_perm);
             $this->data['role_perm'] = $role_perm['module'];
         }
         if ($type == 'category') {
             require APPPATH . 'libraries/tree.class.php';
             $this->load->model('M_content');
             $categorys = $this->M_content->get_category();
             $tree = new tree();
             $tree->icon = array('   │ ', '   ├─ ', '   └─ ');
             $tree->nbsp = '         ';
             $str = "<tr>\n            \t\t\t\t<td><label><input type='checkbox' \$checked class='ace' name='perm[]' value='\$id' /><span class='lbl'></span></label></td>\n            \t\t\t\t<td>\$id</td>\n            \t\t\t\t<td class='left'>\$spacer\$catname</td>\n            \t\t\t</tr>";
             $str2 = "<tr>\n            \t\t\t\t<td><label><input type='checkbox' class='ace' name='perm[]' value='\$id' /><span class='lbl'></span></label></td>\n            \t\t\t\t<td>\$id</td>\n            \t\t\t\t<td class='left'>\$spacer\$catname</td>\n            \t\t\t</tr>";
             $tree->init($categorys);
             $string = $tree->get_tree_multi(0, $str, implode(',', $role_perm['category']));
             $this->data['categorys'] = $string;
         }
         $this->load->view('user/role_perm', $this->data);
     } else {
         show_error('参数异常');
     }
 }