本文整理汇总了PHP中UserService::updateUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::updateUser方法的具体用法?PHP UserService::updateUser怎么用?PHP UserService::updateUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService::updateUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveContact
/**
* Save a contact against a given client object
*
*
* @param array|Contact $params
* @return Contact
*/
public function saveContact($params)
{
$contact = null;
try {
$this->dbService->beginTransaction();
// Get an existing one
$contact = $this->dbService->saveObject($params, 'Contact');
// check for a user object to also update
if ($contact->id) {
$user = $this->userService->getUserByField('contactid', $contact->id);
if ($user) {
$params = array('firstname' => $contact->firstname, 'lastname' => $contact->lastname, 'email' => $contact->email);
$this->userService->updateUser($user, $params);
}
}
$this->trackerService->track('update-contact', $contact->id, null, null, print_r($params, true));
$this->dbService->commit();
} catch (Exception $e) {
$this->dbService->rollback();
$this->log->err("Failed creating contact for params " . print_r($params, true) . ": " . $e->getMessage());
$contact = null;
throw $e;
}
return $contact;
}
示例2: processSettings
/**
* Process settings form.
*
* @return Illuminate\View\View A view.
*/
public function processSettings()
{
try {
$user = UserService::getUser(Auth::user()->id);
$user->locale_id = Input::get('locale');
unset($user->password);
UserService::updateUser(Auth::user()->id, $user);
$this->success(trans('messages.settingsSaved'));
return Redirect::to('settings');
} catch (Exception $e) {
return $this->unexpected($e);
}
}
示例3: saveAction
public function saveAction()
{
$id = (int) $this->_getParam('id');
$userToEdit = za()->getUser();
// If an ID is passed, we need to be an admin to be
// able to edit this user
if ($id > 0) {
$selectedUser = $this->userService->getUser($id);
// now, if the selectedUser has a role less than mine, we can
// edit them
if ($selectedUser->getRoleValue() < za()->getUser()->getRoleValue() || za()->getUser()->isPower()) {
$userToEdit = $selectedUser;
}
}
// we're saving?
// bind the user item
if ($this->_getParam('password') != $this->_getParam('confirm')) {
$this->view->addError('unmatched_password', 'Passwords do not match');
} else {
try {
$params = $this->_getAllParams();
// If no new pass was set, just clear it from the update
if ($params['password'] == '') {
unset($params['password']);
}
$this->userService->updateUser($userToEdit, $params);
$this->view->flash("Profile successfully updated");
} catch (InvalidModelException $im) {
$this->view->flash($im->getMessages());
$this->redirect('user', 'edit', array('id' => $userToEdit->id));
return;
} catch (ExistingUserException $eu) {
$this->view->flash("User already exists");
$this->redirect('user', 'edit', array('id' => $userToEdit->id));
return;
}
}
$this->redirect('user', 'edit', array('id' => $userToEdit->id));
}
示例4: trim
case 'pwd_change_get':
require_once './user_view_pwd_change.php';
break;
case 'pwd_change_post':
require_once 'class/user.class.php';
require_once 'class/user_service.class.php';
$username = trim($_POST['username']);
$pwd = md5(trim($_POST['pwd']));
$user = new User(null, null, null, null, $username, $pwd, null, null, null, null);
$user_service = new UserService();
$rs = $user_service->validateUser($user);
if ($rs) {
$user = $user_service->getUserByUsername($username);
$user->pwd = md5($_POST["new_pwd"]);
print_r($user);
$user_service->updateUser($user);
$_SESSION['operation'] = true;
$_SESSION['operation_msg'] = "修改密码:" . $username . "成功";
$log_service->addLog("update", "用户修改密码", $id);
header("Location: ./index.php?mod=home");
} else {
$_SESSION['operation'] = false;
$_SESSION['operation_msg'] = "密码错误,请重新输入";
header("Location: index.php?mod=user&action=pwd_change_get");
}
break;
default:
break;
}
} else {
header("Location: ./index.php?mod=user&action=ls");
示例5: processEditUser
/**
* Process a form to edit an existing user.
*
* @param integer $id The id of the user to edit.
*
* @return mixed The response.
*/
public function processEditUser($id)
{
try {
// Get inputs.
$user = new User();
$user->username = Input::get('username');
$user->password = Input::get('password');
$user->password_confirmation = Input::get('password_confirmation');
$user->first_name = Input::get('first_name');
$user->last_name = Input::get('last_name');
$user->email = Input::get('email');
$user->status = Input::get('status');
$user->role = Input::get('role');
$user->locale_id = Input::get('locale_id');
// Update user.
UserService::updateUser($id, $user);
$this->success(trans('messages.userUpdated'));
return Redirect::route('users.list');
} catch (ValidationException $e) {
return Redirect::route('users.edit', array('id' => $id))->withInput(Input::all())->withErrors($e->getValidator());
} catch (Exception $e) {
return $this->unexpected($e);
}
}
示例6: userUpdate
public function userUpdate(User $user)
{
$user = UserService::updateUser($user);
return Redirect::route('user.app')->with('message', 'User was updated');
}
示例7: UserService
//add json object { "a":"aa","b":"bb", user":{"userid":"aaaa"}}
$sv = new UserService();
$input = json_decode(file_get_contents("php://input"));
// var_dump($input);
$rs = $sv->createUser($input, getuserid($input));
// var_dump($rs);
return $rs;
exit;
}
} else {
if ($method == 'PUT' && $request[0] == 'test') {
if (isset($request[1]) && is_numeric($request[1])) {
$sv = new UserService();
$input = json_decode(file_get_contents("php://input"));
// var_dump($input);
$rs = $sv->updateUser($input, getuserid($input));
// var_dump($rs);
return $rs;
exit;
}
} else {
if ($method == 'DELETE' && $request[0] == 'test') {
if (isset($request[1]) && is_numeric($request[1])) {
$sv = new UserService();
$input = json_decode(file_get_contents("php://input"));
// var_dump($input);
$rs = $sv->deleteUser($request[1], getuserid($input));
// var_dump($rs);
return $rs;
exit;
}