Пример #1
0
function get_all_access_id($pid = 0)
{
    $data = M('access')->where("pid=%d", $pid)->field('id')->select();
    $list[] = $pid;
    foreach ($data as $value) {
        $count = M('access')->where("pid=%d", $value['id'])->count();
        if ($count > 0) {
            $list = array_merge($list, get_all_access_id($value['id']));
        } else {
            $list[] = $value['id'];
        }
    }
    return $list;
}
Пример #2
0
 public function info()
 {
     $type = array('0' => '无限制', '1' => '系统级', '2' => '管理员');
     $field['title'] = array('label' => '访问名称', 'type' => 'text', 'filter' => 'htmlspecialchars');
     $field['pid'] = array('label' => '上级权限', 'type' => 'select', 'filter' => 'htmlspecialchars', 'option' => 'get_access_list');
     $field['app'] = array('label' => '应用名称', 'type' => 'text', 'filter' => 'htmlspecialchars');
     $field['model'] = array('label' => '控制器', 'type' => 'text', 'filter' => 'htmlspecialchars');
     $field['action'] = array('label' => '操作名称', 'type' => 'text', 'filter' => 'htmlspecialchars');
     $field['data'] = array('label' => '额外参数', 'type' => 'text', 'filter' => 'htmlspecialchars');
     $field['type'] = array('label' => '访问类型', 'type' => 'radio', 'filter' => 'htmlspecialchars', 'option' => $type);
     $field['sort'] = array('label' => '排序', 'type' => 'text', 'filter' => 'htmlspecialchars');
     $field['status'] = array('label' => '状态', 'type' => 'radio', 'filter' => 'htmlspecialchars', 'option' => array('0' => '禁用', '1' => '启用'));
     if (I('get.id')) {
         $field['pid']['disabled'] = get_all_access_id(I('get.id'));
     }
     $groups['base'] = array('label' => '基本信息', 'data' => array('title', 'pid', 'app', 'model', 'action', 'data', 'type', 'sort', 'status'));
     W('info/form', array('model' => 'access', 'groups' => $groups, 'field' => $field));
 }