当前位置: 首页>>代码示例>>PHP>>正文


PHP UserService::update方法代码示例

本文整理汇总了PHP中UserService::update方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::update方法的具体用法?PHP UserService::update怎么用?PHP UserService::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserService的用法示例。


在下文中一共展示了UserService::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: put

 /**
  * Edit a user; requires the user to be logged in and the current password provided
  *
  * @param  Request $request
  * @return array
  */
 public function put(Request $request)
 {
     $user = $this->getUser();
     $userValidationCopy = clone $user;
     // Validate the modified fields
     $content = $this->getContentAsArray($request);
     $errors = $this->userValidator->validate($content, $user);
     if (count($errors) > 0) {
         return $this->createConstraintViolationResponse($errors);
     }
     $userValidationCopy->exchangeArray($content ?: [])->getArrayCopy();
     try {
         $user = $this->userService->update($user, $this->getContentAsArray($request));
     } catch (OutOfBoundsException $e) {
         return $this->createEmailNotUniqueResponse();
     }
     return $this->userArrayWithoutPassword($user);
 }
开发者ID:bodetree,项目名称:synapse-base,代码行数:24,代码来源:UserController.php

示例2: update_lang

 /**
  * @desc Modify the lang for guest in the database (sessions table).
  * @param string $theme The new lang
  */
 public function update_lang($lang)
 {
     $db_querier = PersistenceContext::get_querier();
     if ($this->get_level() != User::VISITOR_LEVEL) {
         $this->set_locale($lang);
         UserService::update($this);
     } else {
         $session = AppContext::get_session();
         $session->add_cached_data('locale', $lang);
         $session->save();
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:16,代码来源:CurrentUser.class.php

示例3: array

        $app->response()->setStatus(200);
        $result = array("message" => $service->login($usuario, $password));
        $app->response->body(json_encode($result));
    } catch (PDOException $e) {
        $app->response()->setStatus(500);
        $app->response->body(json_encode($e->getMessage()));
    }
});
$app->put("/usuario/", function () use($app) {
    $usuario = $app->request->put('usuario');
    $nombre = $app->request->put('nombre');
    $clave = $app->request->put('clave');
    $nivel = $app->request->put('nivel');
    try {
        $service = new UserService();
        $result = array("message" => $service->update($usuario, $nombre, $clave, $nivel));
        print_r($result);
        $app->response->body(json_encode($result));
    } catch (UserNotFoundExeption $ue) {
        $app->response()->setStatus(200);
        $result = array("message" => $service->login($usuario, $password));
        $app->response->body(json_encode($result));
    } catch (PDOException $e) {
        $app->response()->setStatus(500);
        $app->response->body(json_encode($e->getMessage()));
    }
});
//=================================================================
//Articulos
$app->get("/articulos", function () use($app) {
    try {
开发者ID:ChristianDRubin,项目名称:SlimFrameworkRepository,代码行数:31,代码来源:api.php

示例4: save

 private function save(HTTPRequestCustom $request)
 {
     $has_error = false;
     $user_id = $this->user->get_id();
     if ($this->form->get_value('delete_account')) {
         UserService::delete_by_id($user_id);
     } else {
         $approbation = $this->internal_auth_infos['approved'];
         if (AppContext::get_current_user()->is_admin()) {
             $old_approbation = $approbation;
             $approbation = $this->form->get_value('approbation');
             $groups = array();
             foreach ($this->form->get_value('groups') as $field => $option) {
                 $groups[] = $option->get_raw_value();
             }
             GroupsService::edit_member($user_id, $groups);
             $this->user->set_groups($groups);
             $this->user->set_level($this->form->get_value('rank')->get_raw_value());
         }
         if ($this->form->has_field('theme')) {
             $this->user->set_theme($this->form->get_value('theme')->get_raw_value());
         }
         $this->user->set_locale($this->form->get_value('lang')->get_raw_value());
         $this->user->set_display_name($this->form->get_value('display_name'));
         $this->user->set_email($this->form->get_value('email'));
         $this->user->set_locale($this->form->get_value('lang')->get_raw_value());
         $this->user->set_editor($this->form->get_value('text-editor')->get_raw_value());
         $this->user->set_show_email(!$this->form->get_value('user_hide_mail'));
         $this->user->set_timezone($this->form->get_value('timezone')->get_raw_value());
         try {
             UserService::update($this->user, $this->member_extended_fields_service);
         } catch (MemberExtendedFieldErrorsMessageException $e) {
             $has_error = true;
             $this->tpl->put('MSG', MessageHelper::display($e->getMessage(), MessageHelper::NOTICE));
         }
         $login = $this->form->get_value('email');
         if ($this->form->get_value('custom_login', false)) {
             $login = $this->form->get_value('login');
         }
         $password = $this->form->get_value('password');
         if ($this->internal_auth_infos === null && !empty($password)) {
             $authentication_method = new PHPBoostAuthenticationMethod($login, $password);
             AuthenticationService::associate($authentication_method, $user_id);
         } elseif (!empty($password)) {
             $old_password = $this->form->get_value('old_password');
             if (!empty($old_password)) {
                 $old_password_hashed = KeyGenerator::string_hash($old_password);
                 if ($old_password_hashed == $this->internal_auth_infos['password']) {
                     PHPBoostAuthenticationMethod::update_auth_infos($user_id, $login, $approbation, KeyGenerator::string_hash($password));
                     $has_error = false;
                 } else {
                     $has_error = true;
                     $this->tpl->put('MSG', MessageHelper::display($this->lang['profile.edit.password.error'], MessageHelper::NOTICE));
                 }
             }
         } else {
             PHPBoostAuthenticationMethod::update_auth_infos($user_id, $login, $approbation);
         }
         if (AppContext::get_current_user()->is_admin()) {
             if ($old_approbation != $approbation && $old_approbation == 0) {
                 //Recherche de l'alerte correspondante
                 $matching_alerts = AdministratorAlertService::find_by_criteria($user_id, 'member_account_to_approbate');
                 //L'alerte a été trouvée
                 if (count($matching_alerts) == 1) {
                     $alert = $matching_alerts[0];
                     $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_PROCESSED);
                     AdministratorAlertService::save_alert($alert);
                     $site_name = GeneralConfig::load()->get_site_name();
                     $subject = StringVars::replace_vars($this->user_lang['registration.subject-mail'], array('site_name' => $site_name));
                     $content = StringVars::replace_vars($this->user_lang['registration.email.mail-administrator-validation'], array('pseudo' => $this->user->get_display_name(), 'site_name' => $site_name, 'signature' => MailServiceConfig::load()->get_mail_signature()));
                     AppContext::get_mail_service()->send_from_properties($this->user->get_email(), $subject, $content);
                 }
             }
             $user_warning = $this->form->get_value('user_warning')->get_raw_value();
             if (!empty($user_warning) && $user_warning != $this->user->get_warning_percentage()) {
                 MemberSanctionManager::caution($user_id, $user_warning, MemberSanctionManager::SEND_MP, str_replace('%level%', $user_warning, LangLoader::get_message('user_warning_level_changed', 'main')));
             } elseif (empty($user_warning)) {
                 MemberSanctionManager::cancel_caution($user_id);
             }
             $user_readonly = $this->form->get_value('user_readonly')->get_raw_value();
             if (!empty($user_readonly) && $user_readonly != $this->user->get_delay_readonly()) {
                 MemberSanctionManager::remove_write_permissions($user_id, time() + $user_readonly, MemberSanctionManager::SEND_MP, str_replace('%date%', $this->form->get_value('user_readonly')->get_label(), LangLoader::get_message('user_readonly_changed', 'main')));
             } elseif (empty($user_readonly)) {
                 MemberSanctionManager::restore_write_permissions($user_id);
             }
             $user_ban = $this->form->get_value('user_ban')->get_raw_value();
             if (!empty($user_ban) && $user_ban != $this->user->get_delay_banned()) {
                 MemberSanctionManager::banish($user_id, time() + $user_ban, MemberSanctionManager::SEND_MAIL);
             } elseif ($user_ban != $this->user->get_delay_banned()) {
                 MemberSanctionManager::cancel_banishment($user_id);
             }
         }
         SessionData::recheck_cached_data_from_user_id($user_id);
     }
     if (!$has_error) {
         AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : UserUrlBuilder::edit_profile($user_id), $this->lang['user.message.success.edit']);
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:98,代码来源:UserEditProfileController.class.php


注:本文中的UserService::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。