$check_updates = retrieve(GET, 'check', false); $update_type = retrieve(GET, 'type', ''); if (!in_array($update_type, array('', 'kernel', 'module', 'theme'))) { $update_type = ''; } if ($check_updates === true) { $Session->csrf_get_protect(); new Updates(); redirect('updates.php' . (!empty($update_type) ? '?type=' . $update_type : '')); } $tpl = new Template('admin/updates/updates.tpl'); $updates_availables = 0; if (phpversion() > PHP_MIN_VERSION_UPDATES) { import('events/administrator_alert_service'); import('core/application'); $update_alerts = AdministratorAlertService::find_by_criteria(null, 'updates'); $updates = array(); foreach ($update_alerts as $update_alert) { $update = unserialize($update_alert->get_properties()); if ($update_type == '' || $update->get_type() == $update_type) { if ($update->check_compatibility()) { $updates[] = $update; } else { $update_alert->set_status(EVENT_STATUS_PROCESSED); AdministratorAlertService::save_alert($update_alert); } } } foreach ($updates as $update) { switch ($update->get_priority()) { case ADMIN_ALERT_VERY_HIGH_PRIORITY:
$user_avatar = $path; } } $user_avatar = !empty($user_avatar) ? "user_avatar = '" . $user_avatar . "', " : ''; if (!empty($login) && !empty($user_mail)) { $info_mbr = $Sql->query_array(DB_TABLE_MEMBER, "user_theme", "user_sex", "WHERE user_id = '" . $id_post . "'", __LINE__, __FILE__); if ($info_mbr['user_sex'] != $user_sex) { @unlink('../cache/sex.png'); } if ($info_mbr['user_theme'] != $user_theme) { @unlink('../cache/theme.png'); } $member_infos = $Sql->query_array(DB_TABLE_MEMBER, "user_aprob", "level", "WHERE user_id = '" . $id_post . "'", __LINE__, __FILE__); if ($member_infos['user_aprob'] != $user_aprob && $member_infos['user_aprob'] == 0) { import('events/administrator_alert_service'); $matching_alerts = AdministratorAlertService::find_by_criteria($id_post, 'member_account_to_approbate'); if (count($matching_alerts) == 1) { $alert = $matching_alerts[0]; $alert->set_status(ADMIN_ALERT_STATUS_PROCESSED); AdministratorAlertService::save_alert($alert); } $Cache->Generate_file('stats'); } $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET login = '******', level = '" . $MEMBER_LEVEL . "', user_lang = '" . $user_lang . "', user_theme = '" . $user_theme . "', user_mail = '" . $user_mail . "', user_show_mail = " . $user_show_mail . ", user_editor = '" . $user_editor . "', user_timezone = '" . $user_timezone . "', user_local = '" . $user_local . "', " . $user_avatar . "user_msn = '" . $user_msn . "', user_yahoo = '" . $user_yahoo . "', user_web = '" . $user_web . "', user_occupation = '" . $user_occupation . "', user_hobbies = '" . $user_hobbies . "', user_desc = '" . $user_desc . "', user_sex = '" . $user_sex . "', user_born = '" . $user_born . "', user_sign = '" . $user_sign . "', user_warning = '" . $user_warning . "', user_readonly = '" . $user_readonly . "', user_ban = '" . $user_ban . "', user_aprob = '" . $user_aprob . "' WHERE user_id = '" . $id_post . "'", __LINE__, __FILE__); if ($member_infos['level'] != $MEMBER_LEVEL) { $Sql->query_inject("UPDATE " . DB_TABLE_SESSIONS . " SET level = '" . $MEMBER_LEVEL . "' WHERE user_id = '" . $id_post . "'", __LINE__, __FILE__); } if ($user_ban > 0) { $Sql->query_inject("DELETE FROM " . DB_TABLE_SESSIONS . " WHERE user_id = '" . $id_post . "'", __LINE__, __FILE__); import('io/mail'); $Mail = new Mail();
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']); } }
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()) { $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_UNREAD); AdministratorAlertService::save_alert($alert); } else { if ($this->config->is_admin_alerts_fix_action_fix()) { $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_PROCESSED); AdministratorAlertService::save_alert($alert); } else { AdministratorAlertService::delete_alert($alert); } } } } BugtrackerStatsCache::invalidate(); }
private function save() { $now = new Date(); $current_user = AppContext::get_current_user(); if ($this->config->are_pm_enabled() && $this->config->are_pm_delete_enabled()) { //Add comment if needed $comment = !$this->form->field_is_disabled('comments_message') ? $this->form->get_value('comments_message', '') : ''; //Send PM with comment to updaters if the option is enabled BugtrackerPMService::send_PM_to_updaters('delete', $this->bug->get_id(), $comment); } //Delete bug BugtrackerService::delete("WHERE id=:id", array('id' => $this->bug->get_id())); //Delete bug history BugtrackerService::delete_history("WHERE bug_id=:id", array('id' => $this->bug->get_id())); //Delete comments CommentsService::delete_comments_topic_module('bugtracker', $this->bug->get_id()); //Delete admin alert if ($this->config->are_admin_alerts_enabled()) { $alerts = AdministratorAlertService::find_by_criteria($this->bug->get_id(), 'bugtracker'); if (!empty($alerts)) { AdministratorAlertService::delete_alert($alerts[0]); } } BugtrackerStatsCache::invalidate(); Feed::clear_cache('bugtracker'); }