. */ namespace Fisharebest\Webtrees; use DateTimeZone; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsEdit; /** @global Tree $WT_TREE */ global $WT_TREE; require 'includes/session.php'; // Need to be logged in if (!Auth::check()) { header('Location: index.php'); return; } // Extract form variables $action = Filter::post('action', 'update|delete', ''); $username = Filter::post('username'); $real_name = Filter::post('real-name'); $password_1 = Filter::post('password-1', WT_REGEX_PASSWORD); $password_2 = Filter::post('password-2', WT_REGEX_PASSWORD); $email = Filter::post('email'); $root_id = Filter::post('root-id', WT_REGEX_XREF); $theme = Filter::post('theme', implode('|', array_keys(Theme::themeNames())), ''); $language = Filter::post('language', null, ''); $time_zone = Filter::post('time-zone', null, 'UTC'); $contact_method = Filter::post('contact-method', null, ''); $visible_online = Filter::postBool('visible-online'); // Respond to form action if ($action !== '' && Filter::checkCsrf()) { switch ($action) { case 'update': if ($username !== Auth::user()->getUserName() && User::findByUserName($username)) { FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.')); } elseif ($email !== Auth::user()->getEmail() && User::findByEmail($email)) { FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.')); } else { // Change username if ($username !== Auth::user()->getUserName()) { Log::addAuthenticationLog('User ' . Auth::user()->getUserName() . ' renamed to ' . $username); Auth::user()->setUserName($username); } // Change password if ($password_1 !== '' && $password_1 === $password_2) { Auth::user()->setPassword($password_1); } // Change other settings Auth::user() ->setRealName($real_name) ->setEmail($email) ->setPreference('language', $language) ->setPreference('TIMEZONE', $time_zone) ->setPreference('contactmethod', $contact_method) ->setPreference('visibleonline', $visible_online ? '1' : '0'); Auth::user()->setPreference('theme', $theme); $WT_TREE->setUserPreference(Auth::user(), 'rootid', $root_id); } break; case 'delete': // An administrator can only be deleted by another administrator if (!Auth::user()->getPreference('canadmin')) { $currentUser = Auth::user(); Auth::logout(); $currentUser->delete(); } break; } header('Location: edit_user.php'); return; } $controller = new PageController; $controller ->setPageTitle(I18N::translate('My account')) ->pageHeader(); $my_individual_record = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'gedcomid'), $WT_TREE); $default_individual = Individual::getInstance($WT_TREE->getUserPreference(Auth::user(), 'rootid'), $WT_TREE); // Form validation ?>

getPageTitle() ?>

'root-id', 'name' => 'root-id', 'aria-describedby' => 'root-id-description']) ?>


getPreference('language'), ['id' => 'language', 'name' => 'language']) ?>
getPreference('TIMEZONE', 'UTC'), ['id' => 'time-zone', 'name', 'time-zone', 'aria-describedby' => 'time-zone-description']) ?>

getPreference('contactmethod'), ['id' => 'contact-method', 'name' => 'contact-method', 'aria-describedby' => 'contact-method-description']) ?>

'visible-online', 'checked' => (bool) Auth::user()->getPreference('visibleonline'), 'aria-describedby' => 'visible-online-description']) ?>

getPreference('canadmin')): ?>