Example #1
0
 public function add1()
 {
     // 将add 拆分为二个 add显示添加界面 insert 负责添加数据
     if (!empty($_POST)) {
         // print_r($_POST);
         // 在AuthModel 里边通过一个指定方法实现权限添加
         $auth = new \Model\AuthModel();
         $res = $auth->addAuth($_POST);
         if ($res) {
             // echo 'success';
             $this->success('添加权限成功', U('list'));
         } else {
             // echo 'fail';
             $this->error('添加权限失败', U('list'));
         }
     } else {
         // 获取父类权限信息(不获取三级分类)
         $info = $this->getinfo(true);
         // show_bug($info); // array(1 => '商品管理', 2 => '')
         // 从$info 里边获得信息
         // 以方便在smarty 模板中使用{html_options}
         $authinfo = array();
         foreach ($info as $k => $v) {
             $authinfo[$v['id']] = $v['name'];
         }
         //show_bug($authinfo);
         $this->assign('authinfo', $authinfo);
         $this->display();
     }
 }
    function add(){
        if(!empty($_POST)){
            //在AuthModel里边通过一个指定方法实现权限添加
            $auth = new \Model\AuthModel();
            $z = $auth->addAuth($_POST);
            if($z){
                $this -> success('添加权限成功!',U('showlist'));
            }else {
                $this -> error('添加权限失败!',U('showlist'));
            }
        }else{
            //获得父级权限信息
            $info = $this -> getInfo(true);
            //show_bug($info); 
            //从$info里边获得信息。例如:array(1=>'商品管理',2=>'添加商品',3=>'订单打印')
            //以便在smarty模板中使用{html_options}
            $authinfo = array();
            foreach($info as $v){
                $authinfo[$v['auth_id']] = $v['auth_name'];
            }

            $this -> assign('authinfo', $authinfo);
            $this -> display();
        }
    }
Example #3
0
 public function update($auth_id)
 {
     $auth = new \Model\AuthModel();
     $auth_infoA = $auth->where('auth_level=0')->select();
     if (!empty($_POST)) {
         //搜集所有字段
         if ($auth->upData($_POST)) {
             $this->redirect('showlist', array(), 2, "修改权限成功");
         }
     }
     $info = $auth->find($auth_id);
     $this->assign('auth_infoA', $auth_infoA);
     $this->assign('info', $info);
     $this->display();
 }
 function add()
 {
     if (!empty($_POST)) {
         //通过数据模型 将提交的数据整合以便将所有字段插入数据表中
         $auth_M = new \Model\AuthModel();
         $t = $auth_M->auth_save($_POST);
         if ($t) {
             $this->success('添加成功', U('showlist'));
         } else {
             $this->success('添加失败,请重试', U('showlist'));
         }
     } else {
         $info = $this->getInfo();
         $authinfo = array();
         foreach ($info as $k => $v) {
             $authinfo[$v['auth_id']] = $v['auth_name'];
         }
         $this->assign('authinfo', $authinfo);
         $this->display();
     }
 }