. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsEdit; use Fisharebest\Webtrees\Functions\FunctionsPrint; define('WT_SCRIPT_NAME', 'edituser.php'); require './includes/session.php'; // Need to be logged in if (!Auth::check()) { header('Location: ' . WT_BASE_URL); return; } // Extract form variables $form_action = Filter::post('form_action'); $form_username = Filter::post('form_username'); $form_realname = Filter::post('form_realname'); $form_pass1 = Filter::post('form_pass1', WT_REGEX_PASSWORD); $form_pass2 = Filter::post('form_pass2', WT_REGEX_PASSWORD); $form_email = Filter::postEmail('form_email'); $form_rootid = Filter::post('form_rootid', WT_REGEX_XREF); $form_theme = Filter::post('form_theme', implode('|', array_keys(Theme::themeNames())), '');; $form_language = Filter::post('form_language'); $form_timezone = Filter::post('form_timezone'); $form_contact_method = Filter::post('form_contact_method'); $form_visible_online = Filter::postBool('form_visible_online'); // Respond to form action if ($form_action && Filter::checkCsrf()) { switch ($form_action) { case 'update': if ($form_username !== Auth::user()->getUserName() && User::findByUserName($form_username)) { FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.')); } elseif ($form_email !== Auth::user()->getEmail() && User::findByEmail($form_email)) { FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.')); } else { // Change username if ($form_username !== Auth::user()->getUserName()) { Log::addAuthenticationLog('User ' . Auth::user()->getUserName() . ' renamed to ' . $form_username); Auth::user()->setUserName($form_username); } // Change password if ($form_pass1 && $form_pass1 === $form_pass2) { Auth::user()->setPassword($form_pass1); } // Change other settings Auth::user() ->setRealName($form_realname) ->setEmail($form_email) ->setPreference('language', $form_language) ->setPreference('TIMEZONE', $form_timezone) ->setPreference('contactmethod', $form_contact_method) ->setPreference('visibleonline', $form_visible_online ? '1' : '0'); if ($form_theme === null) { Auth::user()->deletePreference('theme'); } else { Auth::user()->setPreference('theme', $form_theme); } $WT_TREE->setUserPreference(Auth::user(), 'rootid', $form_rootid); } break; case 'delete': // An administrator can only be deleted by another administrator if (!Auth::user()->getPreference('canadmin')) { // Keep a reference to the currently logged in user because after logging out this user, // a call to Auth::user() will not return this user anymore $currentUser = Auth::user(); Auth::logout(); $currentUser->delete(); } break; } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; } $controller = new PageController; $controller ->setPageTitle(I18N::translate('My account')) ->pageHeader() ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) ->addInlineJavascript('autocomplete();'); $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(); ?>

formatList('span'); ?>


formatList('span'); ?>

getPreference('language')); ?>
getPreference('TIMEZONE') ?: 'UTC', 'class="form-control"'); ?>

getPreference('contactmethod')); ?>

getPreference('visibleonline')); ?>

getPreference('canadmin')): ?>