コード例 #1
0
 public function indexAction()
 {
     $preNum = C('page');
     $condition = '';
     $name = fpBase('http')->getPost('name');
     $orderDirection = fpBase('http')->getPost('orderDirection');
     $orderField = fpBase('http')->getPost('orderField');
     $pageNum = fpBase('http')->getPost('pageNum') ? fpBase('http')->getPost('pageNum') - 1 : 0;
     if (!empty($orderField)) {
         $order = '`' . $orderField . '` ' . $orderDirection;
     } else {
         $order = '';
     }
     if (fpBase('http')->isPost() && !empty($name)) {
         $condition = "name like '%{$name}%'";
     }
     $count = M($this->table)->where($condition)->order($order)->count();
     $data = M($this->table)->where($condition)->order($order)->limit($pageNum * $preNum, $preNum)->doFind();
     foreach ($data as $key => $val) {
         $data[$key]['cat_id'] = M('cat')->getName($val['cat_id']);
         $data[$key]['restaurant_id'] = M('restaurant')->getName($val['restaurant_id']);
     }
     $this->assign('countNum', $count);
     $this->assign('data', $data);
     $this->assign('preNum', $preNum);
     $this->assign('nowPage', $pageNum + 1);
     $this->display();
 }
コード例 #2
0
 public function editAction()
 {
     $department_id = fpBase('http')->getParam('id');
     $cat = M('department')->find('id=' . $department_id);
     if (empty($cat)) {
         exit(json_encode(array('statusCode' => 300, 'message' => '选择的部门有误')));
     } else {
         $dep = M('department')->getSelect($cat['pid']);
     }
     $this->assign('dep', $dep);
     parent::editAction();
 }
コード例 #3
0
 public function loginOutAction()
 {
     if (get_cookie('username') || get_cookie('uid') || get_cookie('key')) {
         fpBase('cache')->delete('user_uid_' . get_cookie('uid'));
         set_cookie('uid', '', -1);
         set_cookie('username', '', -1);
         set_cookie('key', '', -1);
         $this->showMessage('成功退出', 1, SITE_URL . 'index.php/public/login', 1);
     } else {
         $this->showMessage('成功退出', 1, SITE_URL . 'index.php/public/login', 1);
     }
 }
コード例 #4
0
 public function deleteAction()
 {
     $id = intval(fpBase('http')->getQuery('id'));
     //先判断该分类下是否有菜,有的话就不能删除
     $restaurant = M('fast')->find('restaurant_id=' . $id);
     if (!empty($restaurant)) {
         exit(json_encode(array('statusCode' => 300, 'message' => '该菜馆下还有菜单,无法删除')));
     }
     if (M($this->table)->delete('id=' . $id)) {
         exit(json_encode(array('statusCode' => 200, 'message' => '操作成功')));
     } else {
         exit(json_encode(array('statusCode' => 300, 'message' => '操作失败')));
     }
 }
コード例 #5
0
 public function checkPra($user)
 {
     //公共模块返回
     $nowAction = CONTROLLER . '-' . ACTION;
     if (in_array(CONTROLLER, array('public', 'index'))) {
         return true;
     }
     if ($user['role_id'] == 1) {
         $list = array('book-ajaxGetAll', 'book-save', 'book-index', 'book-delete', 'fast-index', 'user-edit');
         if (!in_array($nowAction, $list)) {
             if (fpBase('http')->isPost()) {
                 exit(json_encode(array('statusCode' => 300, 'message' => '权限不足')));
             }
             exit('权限不足 !');
         } else {
             if ($nowAction == 'user-edit') {
                 $role = fpBase('http')->getPost('role_id');
                 if ($role != 1 && !empty($role)) {
                     exit(json_encode(array('statusCode' => 300, 'message' => '你只能选择普通会员身份')));
                 }
             }
         }
     } else {
         return true;
     }
 }
コード例 #6
0
 private function checkEmpty()
 {
     $msg = '';
     if (!fpBase('http')->getPost('dbhost')) {
         $msg = '数据库地址不能为空';
     } else {
         if (!fpBase('http')->getPost('dbname')) {
             $msg = '数据库名不能为空';
         } else {
             if (!fpBase('http')->getPost('dbuser')) {
                 $msg = '数据库用户不能为空';
             } else {
                 if (!fpBase('http')->getPost('pre')) {
                     $msg = '数据表前缀不能为空';
                 } else {
                     if (!fpBase('http')->getPost('department')) {
                         $msg = '管理员所在部门不能为空';
                     } else {
                         if (!fpBase('http')->getPost('username')) {
                             $msg = '管理员姓名不能为空';
                         } else {
                             if (!fpBase('http')->getPost('password')) {
                                 $msg = '管理员密码不能为空';
                             } else {
                                 if (!fpBase('http')->getPost('qq')) {
                                     $msg = '管理员qq不能为空';
                                 } else {
                                     if (!fpBase('http')->getPost('tel')) {
                                         $msg = '管理员电话号码不能为空';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $msg;
 }