Пример #1
0
 /**
  *
  * @do my data
  *
  * @access public 
  * @author Nick
  * @copyright rockhippo
  * @param -
  * @return -
  *
  */
 public function mydataAction()
 {
     global $G_X;
     $user = XSession::Get("TA_user");
     $userModel = new PSys_UserModel();
     if ($this->ispost) {
         $where = array();
         $where['user_id'] = $user['id'];
         $data = array();
         $data['nick'] = reqstr("nick", "");
         $data['age'] = reqstr("age", "");
         $data['phone'] = reqstr("phone", "");
         $data['address'] = reqstr("address", "");
         $data['photo'] = reqstr("photo", "");
         $return = $userModel->UpdateOne($data, $where, "ta_user_information");
         if ($return) {
             $this->jump("Edit success.", "success", "/index/mydata", 1);
         } else {
             $this->jump("Edit failed.", "errors", "/index/mydata", 1);
         }
         exit;
     }
     $where = array();
     $where['id'] = $user['id'];
     $data = $userModel->GetOne($where, "*", "view_user");
     $timestamp = time();
     $timestamp_token = md5($G_X['upload']['unique_salt'] . $timestamp);
     $this->smarty->assign("timestamp", $timestamp);
     $this->smarty->assign("timestamp_token", $timestamp_token);
     $this->smarty->assign("data", $data);
     $this->forward = "mydata";
 }
Пример #2
0
 /**
  *
  * @do 编辑用户
  *
  * @access public 
  * @author Nick
  * @copyright rockhippo
  * @param -
  * @return -
  *
  */
 public function editAction()
 {
     global $G_X;
     $PSys_UserModel = new PSys_UserModel();
     if ($this->ispost) {
         $data['id'] = reqnum("id", 0);
         $data['password'] = reqstr("password", "");
         $data['email'] = reqstr("email", "");
         $data['role_id'] = reqnum("role_id", 0);
         $data['nick'] = reqstr("nick", "");
         $data['phone'] = reqstr("phone", "");
         $data['address'] = reqstr("address", "");
         $data['photo'] = reqstr("photo", "");
         $data['age'] = reqstr("age", 0);
         $data['sex'] = reqnum("sex", 1);
         if (!$data['email'] || !$data['role_id']) {
             $this->jump('The user information is error.', 'errors', '/user/edit?id=' . $data['id']);
             exit;
         }
         //是否有修改密码
         if ($data['password']) {
             $data['password'] = md5($G_X['passAddTo'] . $data['password']);
         }
         $return = $PSys_UserModel->MEditUser($data);
         if ($return['output'] == 1) {
             $this->operateLogs(1);
             $this->jump('Edit the user successed.', 'success', '/user/index');
         } else {
             $this->operateLogs(0);
             $this->jump('Edit the user failed.', 'errors', '/user/index');
         }
         exit;
     }
     $where = array();
     $where['id'] = reqnum("id", 0);
     if ($where['id'] == 0) {
         $this->jump('The user id is error.', 'errors', '/user/index');
         exit;
     }
     $data = $PSys_UserModel->GetOne($where, "*", "view_user");
     $PSys_RoleModel = new PSys_RoleModel();
     $where = array();
     $order = "role_id ASC";
     $role = $PSys_RoleModel->GetList($where, $order, 1, 100, "role_id,rolename");
     $timestamp = time();
     $timestamp_token = md5($G_X['upload']['unique_salt'] . $timestamp);
     $this->smarty->assign("timestamp", $timestamp);
     $this->smarty->assign("timestamp_token", $timestamp_token);
     $this->smarty->assign("role", $role);
     $this->smarty->assign("data", $data);
     $this->smarty->assign("active", "user/index");
     $this->forward = "edit";
 }