예제 #1
0
 public function login_check($t)
 {
     if (public_user_type() != 2) {
         if ($t == 1) {
             //直接跳转
             $this->error('请先登录后操作!', U('Home/Login/index'), 3);
         } else {
             if ($t == 2) {
                 //ajax返回
                 $msg = array('status' => 0, 'msg' => '未登录,无法操作');
                 $this->ajaxReturn($msg);
             }
         }
     }
 }
예제 #2
0
 public function file()
 {
     //获取登录用户信息
     $user_type = public_user_type();
     $user = array('login' => 0, 'name' => '', 'pic' => '', 'home' => '');
     if ($user_type) {
         $user_id = public_user_id();
         $model_user = D('User');
         $rs_user = $model_user->getInfo($user_type, $user_id);
         $user = array('login' => 1, 'name' => $rs_user['name'], 'pic' => $rs_user['pic'], 'home' => $rs_user['home']);
     }
     $model_file = D('Index');
     $file = $model_file->getFiles();
     $this->assign('total', count($file));
     $this->assign('file', $file);
     $this->assign('user', $user);
     $this->display();
 }
예제 #3
0
 public function teacher_handler()
 {
     //条件查找,删改,查
     $type = I('post.type');
     $model_user = M('user_teacher');
     if ($type == 'search') {
         $this->login_check(2);
         $key = I('post.key');
         $_SESSION['excel_teacher_key'] = $key;
         $dep = I('post.dep');
         $_SESSION['excel_teacher_dep'] = $dep;
         $current_p = I('post.p') ? I('post.p') : 1;
         $pagenum = 7;
         if (preg_match('/^\\d+$/', $key) or $key == '') {
             //如果是教工号则按教工号查询
             $match_type = 'user';
         } else {
             //否则按姓名查询
             $match_type = 'name';
         }
         if ($dep == '0') {
             $rs_user = $model_user->where("{$match_type} like '%{$key}%'")->limit($pagenum * ($current_p - 1), $pagenum)->select();
             $page_total = ceil($model_user->where("{$match_type} like '%{$key}%'")->count() / $pagenum);
         } else {
             $rs_user = $model_user->where("dep='{$dep}' and {$match_type} like '%{$key}%'")->limit($pagenum * ($current_p - 1), $pagenum)->select();
             $page_total = ceil($model_user->where("dep='{$dep}' and {$match_type} like '%{$key}%'")->count() / $pagenum);
         }
         if (is_array($rs_user)) {
             foreach ($rs_user as $key => &$value) {
                 $value['kt_count'] = M('bs_kt')->where(array('teacher' => $value['user']))->count();
             }
         }
         $page = array('total' => $page_total, 'current' => $current_p);
         $r = array('page' => $page, 'r' => $rs_user);
         $this->ajaxReturn($r);
     } else {
         if ($type == 'del') {
             $this->login_check(2);
             $user = I('post.user');
             $rs_user = $model_user->where("user='******'")->delete();
             if ($rs_user) {
                 $msg = array('status' => 1, 'msg' => '删除成功!');
             } else {
                 $msg = array('status' => 0, 'msg' => '操作失败!');
             }
             $this->ajaxReturn($msg);
         } else {
             if ($type == 'update') {
                 $this->login_check(2);
             } else {
                 if ($type == 'view') {
                     //只要登录即可查看
                     if (public_user_type() != null) {
                         $user = I('post.user');
                         $rs_user = $model_user->where("user='******'")->select();
                         $this->ajaxReturn($rs_user);
                     } else {
                         $this->ajaxReturn(array('status' => 0, 'msg' => '必须登录!'));
                     }
                 }
             }
         }
     }
 }
예제 #4
0
 public function _before_index()
 {
     if (public_user_type() != '1') {
         $this->error('未登录,请先登录后再操作!', U('Home/Login/index'), 3);
     }
 }