示例#1
0
 $warning_contents = retrieve(POST, 'action_contents', '', TSTRING_UNCHANGE);
 if ($new_warning_level >= 0 && $new_warning_level <= 100 && AppContext::get_request()->has_postparameter('new_info') && !empty($id_get) && $valid_user) {
     try {
         $info_mbr = PersistenceContext::get_querier()->select_single_row(DB_TABLE_MEMBER, array('user_id', 'level', 'email'), 'WHERE user_id=:id', array('id' => $id_get));
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_element();
         DispatchManager::redirect($error_controller);
     }
     //Modérateur ne peux avertir l'admin (logique non?).
     if (!empty($info_mbr['user_id']) && ($info_mbr['level'] < 2 || AppContext::get_current_user()->check_level(User::ADMIN_LEVEL))) {
         if ($new_warning_level <= 100) {
             //Envoi d'un MP au membre pour lui signaler, si le membre en question n'est pas lui-même.
             if ($id_get != AppContext::get_current_user()->get_id()) {
                 MemberSanctionManager::caution($id_get, $new_warning_level, MemberSanctionManager::SEND_MP, $warning_contents);
             } else {
                 MemberSanctionManager::caution($id_get, $new_warning_level, MemberSanctionManager::NO_SEND_CONFIRMATION, $warning_contents);
             }
             SessionData::recheck_cached_data_from_user_id($user_id);
         }
     }
     AppContext::get_response()->redirect(UserUrlBuilder::moderation_panel('warning'));
 }
 $moderation_panel_template->put_all(array('C_MODO_PANEL_USER' => true, 'L_ACTION_INFO' => $LANG['warning_management'], 'L_LOGIN' => LangLoader::get_message('display_name', 'user-common'), 'L_INFO_MANAGEMENT' => $LANG['warning_management'], 'U_XMLHTTPREQUEST' => 'warning_user', 'U_ACTION' => UserUrlBuilder::moderation_panel('warning')->rel() . '&amp;' . AppContext::get_session()->get_token()));
 if (empty($id_get)) {
     if ($search_member) {
         $login = retrieve(POST, 'login_mbr', '');
         $user_id = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'user_id', 'WHERE display_name LIKE :name', array('name' => '%' . $login . '%'));
         if (!empty($user_id) && !empty($login)) {
             AppContext::get_response()->redirect(UserUrlBuilder::moderation_panel('warning', $user_id));
         } else {
             AppContext::get_response()->redirect(UserUrlBuilder::moderation_panel('warning'));
 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']);
     }
 }