Ejemplo n.º 1
0
 public function actionUpdate()
 {
     $op = Yii::app()->request->getParam('op', '');
     $id = Yii::app()->request->getPost('id', '');
     $username = Yii::app()->request->getPost("username", '');
     $password = Yii::app()->request->getPost("password", '');
     $hospital = Yii::app()->request->getPost("hospital", '');
     $role = Yii::app()->request->getPost("role", '');
     if (!$username || !$password) {
         $this->_output(-1, '参数错误');
     }
     $userModel = new AdminModel();
     $userModel['username'] = $username;
     $userModel['password'] = $password;
     $userModel['hospital'] = $hospital;
     $userModel['role'] = $role;
     $userModel['create_time'] = time();
     //更新
     if ($op == 'edit' && $id && ($user = $userModel->getById($id))) {
         $userModel['id'] = $user['id'];
         $userModel->update();
     }
     // 新增
     if ($op == 'add') {
         $userModel->setIsNewRecord(1);
         $userModel->save();
     }
     $this->redirect(Yii::app()->getBaseUrl() . "/admin/user/list");
 }
Ejemplo n.º 2
0
 public function editPwdAction()
 {
     $p = $_REQUEST;
     $pId = empty($p['id']) ? die('id不能为空') : intval($p['id']);
     $tAMO = new AdminModel();
     $tRow = $tAMO->field('id,name')->where(' id = ' . $pId)->fRow();
     $this->assign('pId', $tRow['id']);
     $this->assign('pName', $tRow['name']);
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $pPasswd = empty($p['passwd']) ? Tool_Fnc::ajaxMsg('密码不能为空') : trim($p['passwd']);
         $pRepasswd = empty($p['repasswd']) ? Tool_Fnc::ajaxMsg('重复密码不能为空') : trim($p['repasswd']);
         strlen($pPasswd) < 6 || strlen($pRepasswd) < 6 ? Tool_Fnc::ajaxMsg('密码长度至少为6位') : '';
         if ($pPasswd !== $pRepasswd) {
             Tool_Fnc::ajaxMsg('两次密码不一置');
         }
         $tAM = new AdminModel();
         $tRow = $tAM->field('private_key')->where("id = " . $pId)->fRow();
         $pPasswd = Tool_Fnc::markmd5($pPasswd, $tRow['private_key']);
         $tData = array('id' => $pId, 'passwd' => $pPasswd);
         if (!$tAM->update($tData)) {
             Tool_Fnc::ajaxMsg('修改失败');
         }
         Tool_Fnc::ajaxMsg('修改成功', 1);
     }
 }
Ejemplo n.º 3
0
 public function set_banAction()
 {
     if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         error404();
     }
     $model = new AdminModel();
     $id = post('id', 'int');
     $user = $model->getUserByID(post('id', 'int'));
     if ($user->id && $user->role == 'user') {
         $data['role'] = 'ban';
         $data['banDate'] = time();
         $data['banRange'] = post('__banRange', 'int');
         $data['banComment'] = post('__banComment');
         if (!$data['banRange']) {
             $data['banRange'] = "0";
         }
         $model->update('users', $data, "`id` = '{$user->id}' LIMIT 1");
         $response['target_h']['#status'] = Lang::translate('SET_BAN_BANNED');
     }
     $response['error'] = 0;
     echo json_encode($response);
     exit;
 }