本文整理汇总了PHP中UserService::get_user方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::get_user方法的具体用法?PHP UserService::get_user怎么用?PHP UserService::get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService::get_user方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(HTTPRequestCustom $request)
{
$this->init();
$user_id = $request->get_getint('user_id', 0);
if (empty($user_id)) {
AppContext::get_response()->redirect(UserUrlBuilder::home());
}
try {
$this->user = UserService::get_user($user_id);
} catch (RowNotFoundException $e) {
$error_controller = PHPBoostErrors::unexisting_element();
DispatchManager::redirect($error_controller);
}
$this->build_form();
return $this->build_response($this->tpl);
}
示例2: execute
public function execute(HTTPRequestCustom $request)
{
$user_id = $request->get_int('id', null);
$user = UserService::get_user($user_id);
if (!$user->is_admin() || $user->is_admin() && UserService::count_admin_members() > 1) {
try {
UserService::delete_by_id($user_id);
} catch (RowNotFoundException $ex) {
$error_controller = PHPBoostErrors::unexisting_element();
DispatchManager::redirect($error_controller);
}
AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : AdminMembersUrlBuilder::management(), StringVars::replace_vars(LangLoader::get_message('user.message.success.delete', 'user-common'), array('name' => $user->get_display_name())));
} else {
$error_controller = PHPBoostErrors::unauthorized_action();
DispatchManager::redirect($error_controller);
}
}
示例3: build_view
private function build_view($request)
{
//Configuration load
$config = BugtrackerConfig::load();
$types = $config->get_types();
$categories = $config->get_categories();
$severities = $config->get_severities();
$priorities = $config->get_priorities();
$versions = $config->get_versions_detected();
$user_assigned = $this->bug->get_assigned_to_id() && UserService::user_exists("WHERE user_id=:user_id", array('user_id' => $this->bug->get_assigned_to_id())) ? UserService::get_user($this->bug->get_assigned_to_id()) : '';
$user_assigned_group_color = $user_assigned ? User::get_group_color($user_assigned->get_groups(), $user_assigned->get_level(), true) : '';
$this->view->put_all($this->bug->get_array_tpl_vars());
$this->view->put_all(array('C_TYPES' => $types, 'C_CATEGORIES' => $categories, 'C_SEVERITIES' => $severities, 'C_PRIORITIES' => $priorities, 'C_VERSIONS' => $versions, 'C_EDIT_BUG' => BugtrackerAuthorizationsService::check_authorizations()->moderation() || $this->current_user->get_id() == $this->bug->get_assigned_to_id() || $this->current_user->get_id() == $this->bug->get_author_user()->get_id() && $this->bug->get_author_user()->get_id() != User::VISITOR_LEVEL, 'C_DELETE_BUG' => BugtrackerAuthorizationsService::check_authorizations()->moderation(), 'C_CHANGE_STATUS' => BugtrackerAuthorizationsService::check_authorizations()->moderation() || $this->current_user->get_id() == $this->bug->get_assigned_to_id(), 'C_USER_ASSIGNED_GROUP_COLOR' => !empty($user_assigned_group_color), 'C_USER_ASSIGNED' => $user_assigned, 'USER_ASSIGNED' => $user_assigned ? $user_assigned->get_display_name() : '', 'USER_ASSIGNED_LEVEL_CLASS' => $user_assigned ? UserService::get_level_class($user_assigned->get_level()) : '', 'USER_ASSIGNED_GROUP_COLOR' => $user_assigned_group_color, 'U_CHANGE_STATUS' => BugtrackerUrlBuilder::change_status($this->bug->get_id())->rel(), 'U_EDIT' => BugtrackerUrlBuilder::edit($this->bug->get_id(), 'detail')->rel(), 'U_DELETE' => BugtrackerUrlBuilder::delete($this->bug->get_id(), 'unsolved')->rel()));
$comments_topic = new BugtrackerCommentsTopic();
$comments_topic->set_id_in_module($this->bug->get_id());
$comments_topic->set_url(BugtrackerUrlBuilder::detail_comments($this->bug->get_id() . '-' . $this->bug->get_rewrited_title()));
$this->view->put('COMMENTS', $comments_topic->display());
}
示例4: execute
public function execute(HTTPRequestCustom $request)
{
$module_id = $request->get_getstring('module_id', '');
$user_id = $request->get_getint('user_id', 0);
if (!empty($user_id)) {
try {
$this->user = UserService::get_user($user_id);
} catch (Exception $e) {
$error_controller = PHPBoostErrors::unexisting_element();
DispatchManager::redirect($error_controller);
}
}
if (!empty($module_id)) {
$this->module = ModulesManager::get_module($module_id);
}
$this->init($request);
return $this->build_response();
}
示例5: execute
public function execute(HTTPRequestCustom $request)
{
$this->init();
$user_id = $request->get_getint('user_id', AppContext::get_current_user()->get_id());
try {
$this->user = UserService::get_user($user_id);
} catch (RowNotFoundException $e) {
$error_controller = PHPBoostErrors::unexisting_element();
DispatchManager::redirect($error_controller);
}
try {
$this->internal_auth_infos = PHPBoostAuthenticationMethod::get_auth_infos($user_id);
} catch (RowNotFoundException $e) {
}
$this->user_auth_types = AuthenticationService::get_user_types_authentication($user_id);
if (!$this->check_authorizations($user_id)) {
$error_controller = PHPBoostErrors::user_not_authorized();
DispatchManager::redirect($error_controller);
}
$associate_type = $request->get_getvalue('associate', false);
if ($associate_type) {
if (!in_array($associate_type, $this->user_auth_types)) {
$authentication_method = AuthenticationService::get_authentication_method($associate_type);
AuthenticationService::associate($authentication_method, $user_id);
AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id));
}
}
$dissociate_type = $request->get_getvalue('dissociate', false);
if ($dissociate_type) {
if (in_array($dissociate_type, $this->user_auth_types) && count($this->user_auth_types) > 1) {
$authentication_method = AuthenticationService::get_authentication_method($dissociate_type);
AuthenticationService::dissociate($authentication_method, $user_id);
AppContext::get_response()->redirect(UserUrlBuilder::edit_profile($user_id));
}
}
$this->build_form();
if ($this->submit_button->has_been_submited() && $this->form->validate()) {
$this->save($request);
}
$this->tpl->put('FORM', $this->form->display());
return $this->build_response();
}
示例6: get_user
private function get_user()
{
$email = $this->form->get_value('email');
$user_id = UserService::user_exists('WHERE email=:email', array('email' => $email));
if (!$user_id) {
$controller = new UserErrorController(LangLoader::get_message('error', 'status-messages-common'), $this->lang['forget-password.error'], MessageHelper::NOTICE);
DispatchManager::redirect($controller);
} else {
return UserService::get_user($user_id);
}
}
示例7: save
private function save()
{
$now = new Date();
$pm_recipients_list = array();
$send_pm = true;
$versions = array_reverse($this->config->get_versions_fix(), true);
$status = $this->form->get_value('status')->get_raw_value();
if (count($versions)) {
if (!$this->form->field_is_disabled('fixed_in')) {
$fixed_in = $this->form->get_value('fixed_in')->get_raw_value() ? $this->form->get_value('fixed_in')->get_raw_value() : 0;
if ($fixed_in != $this->bug->get_fixed_in()) {
//Bug history update
BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'fixed_in', 'old_value' => $this->bug->get_fixed_in(), 'new_value' => $fixed_in));
$this->bug->set_fixed_in($fixed_in);
}
} else {
if (in_array($status, array(Bug::NEW_BUG, Bug::REJECTED))) {
$this->bug->set_fixed_in(0);
}
}
}
if (!$this->form->field_is_disabled('assigned_to')) {
$assigned_to = $this->form->get_value('assigned_to');
$assigned_to_id = UserService::user_exists("WHERE display_name = :display_name", array('display_name' => $assigned_to));
if ($this->bug->get_assigned_to_id()) {
$old_user_assigned_id = UserService::user_exists("WHERE user_id = :user_id", array('user_id' => $this->bug->get_assigned_to_id()));
$old_user_assigned = !empty($old_user_assigned_id) ? UserService::get_user($old_user_assigned_id) : 0;
} else {
$old_user_assigned = 0;
}
$new_user_assigned = !empty($assigned_to) && !empty($assigned_to_id) ? UserService::get_user($assigned_to_id) : 0;
$new_assigned_to_id = !empty($new_user_assigned) ? $new_user_assigned->get_id() : 0;
if ($new_assigned_to_id != $this->bug->get_assigned_to_id()) {
//Bug history update
BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'assigned_to_id', 'old_value' => $old_user_assigned ? $old_user_assigned->get_display_name() : $this->lang['notice.no_one'], 'new_value' => $new_user_assigned ? $new_user_assigned->get_display_name() : $this->lang['notice.no_one']));
//Bug update
$this->bug->set_assigned_to_id($new_assigned_to_id);
//The PM will only be sent to the assigned user
if ($new_assigned_to_id != $this->current_user->get_id()) {
$pm_recipients_list[] = $new_assigned_to_id;
} else {
$send_pm = false;
}
}
}
if ($status != $this->bug->get_status()) {
//Bug history update
BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'status', 'old_value' => $this->bug->get_status(), 'new_value' => $status));
//Bug update
$this->bug->set_status($status);
if ($this->bug->is_fixed() || $this->bug->is_rejected()) {
$this->bug->set_fix_date($now);
} else {
$this->bug->set_fix_date(0);
}
}
BugtrackerService::update($this->bug);
Feed::clear_cache('bugtracker');
switch ($status) {
case Bug::IN_PROGRESS:
$is_pm_enabled = $this->config->are_pm_in_progress_enabled();
break;
case Bug::PENDING:
$is_pm_enabled = $this->config->are_pm_pending_enabled();
break;
case Bug::ASSIGNED:
$is_pm_enabled = $this->config->are_pm_assign_enabled();
break;
case Bug::FIXED:
$is_pm_enabled = $this->config->are_pm_fix_enabled();
break;
case Bug::REOPEN:
$is_pm_enabled = $this->config->are_pm_reopen_enabled();
break;
case Bug::REJECTED:
$is_pm_enabled = $this->config->are_pm_reject_enabled();
break;
default:
$is_pm_enabled = false;
break;
}
//Add comment if needed
$comment = $this->form->get_value('comments_message', '');
if (!empty($comment)) {
$comments_topic = new BugtrackerCommentsTopic();
$comments_topic->set_id_in_module($this->bug->get_id());
$comments_topic->set_url(BugtrackerUrlBuilder::detail($this->bug->get_id() . '-' . $this->bug->get_rewrited_title()));
CommentsManager::add_comment($comments_topic->get_module_id(), $comments_topic->get_id_in_module(), $comments_topic->get_topic_identifier(), $comments_topic->get_path(), $comment);
//New line in the bug history
BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'change_comment' => $this->lang['notice.new_comment']));
}
//Send PM with comment to updaters if the option is enabled
if (!$this->bug->is_new() && $this->config->are_pm_enabled() && $is_pm_enabled && $send_pm) {
BugtrackerPMService::send_PM_to_updaters($status, $this->bug->get_id(), $comment, $pm_recipients_list);
}
if (in_array($status, array(Bug::NEW_BUG, Bug::REOPEN, Bug::REJECTED, Bug::FIXED)) && $this->config->are_admin_alerts_enabled() && in_array($this->bug->get_severity(), $this->config->get_admin_alerts_levels())) {
$alerts = AdministratorAlertService::find_by_criteria($this->bug->get_id(), 'bugtracker');
if (!empty($alerts)) {
$alert = $alerts[0];
if ($this->bug->is_new() || $this->bug->is_reopen()) {
//.........这里部分代码省略.........