コード例 #1
0
 public function _initialize()
 {
     $c = CONTROLLER_NAME;
     //控制器名Common/Product/ProductCate
     define('MID', manage_id());
     if (!MID) {
         $this->error('请先登陆', U('Public/login'));
     }
     $admin = D('Admin/Manage')->getOne(array('id' => MID));
     $this->assign('manage_auth', $admin);
     $permissions = explode(',', $admin['cate']['permissions']);
     $action = $c . "/" . ACTION_NAME;
     if (!in_array($action, $permissions) && MID != 1) {
         $this->error('没有权限', U('Index/index'));
     }
     //关联表
     if ($c != 'Index') {
         $relations = D('Admin/' . $c)->relationTable();
         //print_r($relations);
         foreach ($relations as $k => $v) {
             if ($c == biaoming2MVCname($k)) {
                 //自己关联自己
                 $v = array_merge([['id' => 0, 'mingcheng' => '根']], D('Admin/Tree')->toFormatTree($v, 'mingcheng'));
             }
             $this->assign($k, $v);
         }
     }
 }
コード例 #2
0
 public function login()
 {
     if (manage_id()) {
         $this->redirect('Index/index');
     }
     if (IS_POST) {
         $name = I('name');
         $pwd = I('pwd');
         /*$verify_code = I('verify_code');
           if (!$this->checkVerify($verify_code)) {
               $this->error('验证码不正确');
           }*/
         $rs = D('Admin/Manage')->login($name, $pwd);
         if ($rs['status']) {
             $this->redirect('Index/index');
         } else {
             $this->error($rs['info']);
         }
     } else {
         $this->assign('on_login_code', 0);
         $this->display();
     }
 }
コード例 #3
0
ファイル: CommonModel.class.php プロジェクト: biaoqianwo/cms
 public function deleteOne($params)
 {
     $table = $this->getTableName();
     $rs = ['status' => 0, 'id' => 0, 'info' => ''];
     $status = $this->where(array('id' => $params['id']))->save(['deleted_at' => NOW_TIME, 'updated_at' => NOW_TIME]);
     if (!$status) {
         $rs['info'] = "删除{$table}失败";
     } else {
         $rs = ['status' => 1, 'id' => $params['id'], 'info' => "删除{$table}成功"];
     }
     insert_log(['manage_id' => manage_id(), 'table' => $table, 'table_id' => $params['id'], 'biaoti' => $rs['info']]);
     return $rs;
 }