本文整理汇总了PHP中UserService::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::getUser方法的具体用法?PHP UserService::getUser怎么用?PHP UserService::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService::getUser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeroleAction
public function changeroleAction()
{
$user = $this->userService->getUser((int) $this->_getParam('id'));
if (!$user) {
$this->flash("Cannot change role for that user");
$this->redirect('admin', 'userlist');
}
$this->userService->setUserRole($user, $this->_getParam('role'));
$this->redirect('admin', 'userlist');
}
示例2: addUsersToGroup
/**
* Add a bunch of users to a group
*
* @param UserGroup $group
* @param array $userids
*/
public function addUsersToGroup(UserGroup $group, array $userids)
{
$this->dbService->beginTransaction();
$this->emptyGroup($group);
foreach ($userids as $userid) {
$this->log->debug("Adding user {$userid} to group {$group->id}");
$user = $this->userService->getUser($userid);
$this->addToGroup($group, $user);
}
$this->dbService->commit();
}
示例3: showEditUser
/**
* Show a form to edit a particular user.
*
* @param integer $id The id of the user to edit.
*
* @return mixed The response.
*/
public function showEditUser($id)
{
try {
$user = UserService::getUser($id);
$data = array('user' => $user);
$data = array_merge_recursive($data, $this->getCommonData());
return View::make('users.edit', $data);
} catch (Exception $e) {
return $this->unexpected($e);
}
}
示例4: do_login
/**
* 登录处理
*/
function do_login()
{
$userName = $_REQUEST['userName'];
$password = md5($_REQUEST['password']);
$rememberMe = $_REQUEST['rememberMe'];
$userService = new UserService();
$userId = $userService->checkPassword($userName, $password);
// 检查cookie中是否设置了“记住我”
$isCookieLogin = false;
if (isset($_COOKIE['rememberMe'])) {
$userId = (int) substr($_COOKIE['rememberMe'], 0, 1);
$isCookieLogin = true;
}
if ($userId == -1) {
// 用户名或密码不存在
$output = array('result' => 'wrongUserNamePassword');
echo get_json($output);
} else {
// 登录处理
$result = $userService->getUser($userId);
$code = '0';
$redirect = '';
if ($result != null) {
$_SESSION['userId'] = $result['user_id'];
$_SESSION['userDetail'] = $result;
// 用户数据
// 将用户名保存至cookie
setcookie('userName', $result['user_name'], time() + 60 * 60 * 24 * 30, '/');
// “记住我”流程补充
if ($rememberMe == 1) {
$saveVal = $_SESSION['userId'] . md5($_SESSION['userId']);
setcookie('rememberMe', $saveVal, time() + 60 * 60 * 24 * 30, '/');
} else {
setcookie('rememberMe', '', time() - 3600, '/');
}
$code = '0';
if (isset($_SESSION['lastUrl'])) {
$redirect = $_SESSION['lastUrl'];
} else {
$redirect = DOMAIN_NAME . '/' . APP_NAME . '/index.php';
}
} else {
$code = 'wrongUserNamePassword';
}
$output = array('retCode' => $code, 'redirect' => $redirect);
echo get_json($output);
if ($isCookieLogin == true) {
header('location: ' . $redirect);
exit;
}
}
}
示例5: 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);
}
}
示例6: saveapplicationAction
/**
* Save a leave application
*/
public function saveapplicationAction()
{
$user = $this->userService->getUser((int) $this->_getParam('userid'));
try {
$this->_setParam('username', $user->getUsername());
$params = $this->filterParams();
$model = $this->userService->applyForLeave($user, $params);
} catch (InvalidModelException $ime) {
$this->flash($ime->getMessages());
$model = new LeaveApplication();
$model->bind($this->_getAllParams());
$this->applyAction($model);
return;
}
$this->onModelSaved($model);
}
示例7: viewAction
/**
* View a user and their session booking details.
*
*/
public function viewAction()
{
$id = (int) $this->_getParam('id');
$user = za()->getUser();
if (!$id) {
$viewUser = $user;
} else {
$viewUser = $this->userService->getUser($id);
}
// If the user isn't the same as the current user,
// we need to be an admin to view it
if ($viewUser->id != $user->id && $user->getRole() != 'Admin') {
$this->view->flash("You must be logged in as an administrator to view that");
$this->redirect('user', 'login');
return;
}
// Okay, load up the user view page then!
$this->view->user = $viewUser;
$this->renderView('user/view.php');
}
示例8: userLogin
function userLogin($username, $user_password)
{
// Open a connection to the database
try {
$pdo = new PDO(DB_PDODRIVER . ':host=' . DB_HOST . ';dbname=' . DB_NAME . '', DB_USER, DB_PASS);
} catch (\PDOException $e) {
echo "Connection failed: " . $e->getMessage();
exit;
}
// Create a new instance of UserService
$login_service = new UserService($pdo, $username, $password);
// Set user_id equal to login()
if ($user_id = $login_service->login()) {
$user_data = $login_service->getUser();
$pdo = null;
header('Location: ../index.php');
} else {
$pdo = null;
header('Location: ../error.php?error=login');
}
}
示例9: login
function login($req)
{
$emailOrTel = trim($req['user']);
$password = $req['password'];
$response['status'] = 0;
if (empty($emailOrTel) || empty($password)) {
$response['msg'] = "用户名密码格式错误";
echo json_encode($response);
return;
}
$user['user'] = $emailOrTel;
$user['password'] = $password;
$res = UserService::getUser($user);
if (empty($res) || count($res) <= 0) {
$response['msg'] = "用户名密码错误";
echo json_encode($response);
return;
}
$response['status'] = 1;
setSessionCookie($res);
echo json_encode($response);
}
示例10: milestoneslistAction
public function milestoneslistAction()
{
$project = $this->projectService->getProject((int) $this->_getParam('projectid'));
if ($project == null) {
$this->flash("Project not found");
$this->renderRawView('error.php');
return;
}
$this->view->projectuser = za()->getUser();
if ($this->_getParam('projectuser')) {
if ($this->_getParam('projectuser') == 'all') {
$this->view->projectuser = null;
} else {
$this->view->projectuser = $this->userService->getUser($this->_getParam('projectuser'));
}
}
$this->view->groupusers = $project->getUsers();
if ($this->view->projectuser && !isset($this->view->groupusers[$this->view->projectuser->id])) {
$this->view->projectuser = null;
}
$this->view->project = $project;
$this->renderRawView('project/milestone-list.php');
}
示例11: it_returns_null_when_a_user_can_not_be_found_by_id
/**
* @test
*/
public function it_returns_null_when_a_user_can_not_be_found_by_id()
{
$this->cultureFeed->expects($this->once())->method('getUser')->with(1, UserService::INCLUDE_PRIVATE_FIELDS)->willThrowException(new \CultureFeed_ParseException('error'));
$user = $this->service->getUser(1);
$this->assertNull($user);
}