xref: /webtrees/resources/views/edit-account-page.phtml (revision 090a06287954f43677f06ea778b3f67c029de8fe)
1<?php
2
3use Fisharebest\Webtrees\Contracts\UserInterface;
4use Fisharebest\Webtrees\Http\RequestHandlers\AccountDelete;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Individual;
7use Fisharebest\Webtrees\Tree;
8use Fisharebest\Webtrees\View;
9
10/**
11 * @var array<string,string> $contact_methods
12 * @var Individual|null      $default_individual
13 * @var array<string,string> $languages
14 * @var Individual|null      $my_individual_record
15 * @var bool                 $show_delete_option
16 * @var array<string,string> $timezones
17 * @var string               $title
18 * @var Tree|null            $tree
19 * @var UserInterface        $user
20 */
21
22?>
23
24<h2 class="wt-page-title">
25    <?= $title ?>
26</h2>
27
28<form method="post" class="wt-page-options wt-page-options-my-account">
29    <?= csrf_field() ?>
30
31    <div class="row form-group">
32        <label class="col-sm-3 col-form-label wt-page-options-label" for="user-name">
33            <?= I18N::translate('Username') ?>
34        </label>
35        <div class="col-sm-9 wt-page-options-value">
36            <input type="text" class="form-control" id="user-name" name="user_name" value="<?= e($user->userName()) ?>" dir="auto" aria-describedby="username-description" required="required">
37            <p class="small text-muted" id="username-description">
38                <?= I18N::translate('Usernames are case-insensitive and ignore accented letters, so that “chloe”, “chloë”, and “Chloe” are considered to be the same.') ?>
39            </p>
40        </div>
41    </div>
42
43    <div class="row form-group">
44        <label class="col-sm-3 col-form-label wt-page-options-label" for="real-name">
45            <?= I18N::translate('Real name') ?>
46        </label>
47        <div class="col-sm-9 wt-page-options-value">
48            <input type="text" class="form-control" id="real-name" name="real_name" value="<?= e($user->realName()) ?>" dir="auto" aria-describedby="real-name-description" required="required">
49            <p class="small text-muted" id="real-name-description">
50                <?= I18N::translate('This is your real name, as you would like it displayed on screen.') ?>
51            </p>
52        </div>
53    </div>
54
55    <?php if ($tree instanceof Tree) : ?>
56        <div class="row form-group">
57            <label class="col-sm-3 col-form-label wt-page-options-label" for="gedcom-id">
58                <?= I18N::translate('Individual record') ?>
59            </label>
60            <div class="col-sm-9 wt-page-options-value">
61                <select class="form-control" id="gedcom-id" aria-describedby="gedcom-id-description" disabled>
62                    <?php if ($my_individual_record !== null) : ?>
63                        <option value=""><?= $my_individual_record->fullName() ?></option>
64                    <?php else : ?>
65                        <option value=""><?= I18N::translateContext('unknown people', 'Unknown') ?></option>
66                    <?php endif ?>
67                </select>
68                <p class="small text-muted" id="gedcom-id-description">
69                    <?= I18N::translate('This is a link to your own record in the family tree. If this is the wrong individual, contact an administrator.') ?>
70                </p>
71            </div>
72        </div>
73
74        <div class="row form-group">
75            <label class="col-sm-3 col-form-label wt-page-options-label" for="default-xref">
76                <?= I18N::translate('Default individual') ?>
77            </label>
78            <div class="col-sm-9 wt-page-options-value">
79                <?= view('components/select-individual', ['name' => 'default-xref', 'id' => 'default-xref', 'individual' => $default_individual, 'tree' => $tree]) ?>
80                <p class="small text-muted" id="default-xref-description">
81                    <?= I18N::translate('This individual will be selected by default when viewing charts and reports.') ?>
82                </p>
83            </div>
84        </div>
85    <?php endif ?>
86
87    <div class="row form-group">
88        <label class="col-sm-3 col-form-label wt-page-options-label" for="password">
89            <?= I18N::translate('Password') ?>
90        </label>
91        <div class="col-sm-9 wt-page-options-value">
92            <input class="form-control" type="password" id="password" name="password" aria-describedby="password-description" autocomplete="new-password">
93            <p class="small text-muted" id="password-description">
94                <?= I18N::translate('Passwords must be at least 8 characters long and are case-sensitive, so that “secret” is different from “SECRET”.') ?>
95                <br>
96                <?= I18N::translate('Leave the password blank if you want to keep the current password.') ?>
97            </p>
98        </div>
99    </div>
100
101    <div class="row form-group">
102        <label class="col-sm-3 col-form-label wt-page-options-label" for="language">
103            <?= I18N::translate('Language') ?>
104        </label>
105        <div class="col-sm-9 wt-page-options-value">
106            <?= view('components/select', ['name' => 'language', 'selected' => $user->getPreference(UserInterface::PREF_LANGUAGE), 'options' => $languages]) ?>
107        </div>
108    </div>
109
110    <div class="row form-group">
111        <label class="col-sm-3 col-form-label wt-page-options-label" for="timezone">
112            <?= I18N::translate('Time zone') ?>
113        </label>
114        <div class="col-sm-9 wt-page-options-value">
115            <?= view('components/select', ['name' => 'timezone', 'selected' => $user->getPreference(UserInterface::PREF_TIME_ZONE, 'UTC'), 'options' => $timezones]) ?>
116            <p class="small text-muted" id="timezone-description">
117                <?= I18N::translate('The time zone is required for date calculations, such as knowing today’s date.') ?>
118            </p>
119        </div>
120    </div>
121
122    <div class="row form-group">
123        <label class="col-sm-3 col-form-label wt-page-options-label" for="email">
124            <?= I18N::translate('Email address') ?>
125        </label>
126        <div class="col-sm-9 wt-page-options-value">
127            <input class="form-control" type="email" id="email" name="email" value="<?= e($user->email()) ?>" aria-describedby="email-description">
128            <p class="small text-muted" id="email-description">
129                <?= I18N::translate('This email address will be used to send password reminders, website notifications, and messages from other family members who are registered on the website.') ?>
130            </p>
131        </div>
132    </div>
133
134    <div class="row form-group">
135        <label class="col-sm-3 col-form-label wt-page-options-label" for="contact-method">
136            <?= I18N::translate('Contact method') ?>
137        </label>
138        <div class="col-sm-9 wt-page-options-value">
139            <?= view('components/select', ['name' => 'contact-method', 'id' => 'contact-method', 'selected' => $user->getPreference(UserInterface::PREF_CONTACT_METHOD), 'options' => $contact_methods]) ?>
140            <p class="small text-muted" id="contact-method-description">
141            <?= I18N::translate('Site members can send each other messages. You can choose to how these messages are sent to you, or choose not receive them at all.') ?>
142            </p>
143        </div>
144    </div>
145
146    <fieldset class="form-group">
147        <div class="row">
148            <legend class="col-sm-3 col-form-label wt-page-options-label">
149                <?= I18N::translate('Visible online') ?>
150            </legend>
151            <div class="col-sm-9 wt-page-options-value">
152                <?= view('components/checkbox', ['label' => I18N::translate('Visible to other users when online'), 'name' => 'visible-online', 'checked' => (bool) $user->getPreference(UserInterface::PREF_IS_VISIBLE_ONLINE)]) ?>
153                <p class="small text-muted" id="visible-online-description">
154                    <?= I18N::translate('You can choose whether to appear in the list of users who are currently signed-in.') ?>
155                </p>
156            </div>
157        </div>
158    </fieldset>
159
160    <div class="row form-group">
161        <div class="col-sm-3 wt-page-options-label"></div>
162        <div class="col-sm-9 wt-page-options-value">
163            <button type="submit" class="btn btn-primary">
164                <?= view('icons/save') ?>
165                <?= I18N::translate('save') ?>
166            </button>
167        </div>
168    </div>
169</form>
170
171<?php if ($show_delete_option) : ?>
172    <div class="row form-group">
173        <div class="col-sm-3 wt-page-options-label"></div>
174        <div class="col-sm-9 wt-page-options-value">
175            <a href="#" class="btn btn-danger" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($user->userName())) ?>" data-post-url="<?= e(route(AccountDelete::class)) ?>">
176                <?= view('icons/delete') ?>
177                <?= I18N::translate('Delete your account') ?>
178            </a>
179        </div>
180    </div>
181<?php endif ?>
182
183<?php View::push('javascript') ?>
184<script>
185    $('#password').hideShowPassword('infer', true);
186</script>
187<?php View::endpush() ?>
188