xref: /webtrees/resources/views/admin/users-edit.phtml (revision 4852d81f2623f779034b8fe4d2eabeda2f426c40)
1<?php use Fisharebest\Webtrees\Auth; ?>
2<?php use Fisharebest\Webtrees\Bootstrap4; ?>
3<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
4<?php use Fisharebest\Webtrees\I18N; ?>
5<?php use Fisharebest\Webtrees\Individual; ?>
6<?php use Fisharebest\Webtrees\View; ?>
7
8<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('admin-users') => I18N::translate('User administration'), $title]]) ?>
9
10<h1><?= $title ?></h1>
11
12<form class="form-horizontal" name="newform" method="post" autocomplete="off" action="<?= e(route('admin-users-edit')) ?>">
13    <?= csrf_field() ?>
14    <input type="hidden" name="user_id" value="<?= $user->getUserId() ?>">
15
16    <!-- REAL NAME -->
17    <div class="row form-group">
18        <label class="col-sm-3 col-form-label" for="real_name">
19            <?= I18N::translate('Real name') ?>
20        </label>
21        <div class="col-sm-9">
22            <input class="form-control" type="text" id="real_name" name="real_name" required maxlength="64" value="<?= e($user->getRealName()) ?>" dir="auto">
23            <p class="small text-muted">
24                <?= I18N::translate('This is your real name, as you would like it displayed on screen.') ?>
25            </p>
26        </div>
27    </div>
28
29    <!-- USER NAME -->
30    <div class="row form-group">
31        <label class="col-sm-3 col-form-label" for="username">
32            <?= I18N::translate('Username') ?>
33        </label>
34        <div class="col-sm-9">
35            <input class="form-control" type="text" id="username" name="username" required maxlength="32" value="<?= e($user->getUserName()) ?>" dir="auto">
36            <p class="small text-muted">
37                <?= I18N::translate('Usernames are case-insensitive and ignore accented letters, so that “chloe”, “chloë”, and “Chloe” are considered to be the same.') ?>
38            </p>
39        </div>
40    </div>
41
42    <!-- PASSWORD -->
43    <div class="row form-group">
44        <label class="col-sm-3 col-form-label" for="pass1">
45            <?= I18N::translate('Password') ?>
46        </label>
47        <div class="col-sm-9">
48            <input class="form-control" type="password" id="pass1" name="pass1" pattern = "<?= WT_REGEX_PASSWORD ?>" placeholder="<?= I18N::plural('Use at least %s character.', 'Use at least %s characters.', WT_MINIMUM_PASSWORD_LENGTH, I18N::number(WT_MINIMUM_PASSWORD_LENGTH)) ?>" <?= $user->getUserId() ? '' : 'required' ?> onchange="form.pass2.pattern = regex_quote(this.value);" autocomplete="new-password">
49            <p class="small text-muted">
50                <?= I18N::translate('Passwords must be at least 6 characters long and are case-sensitive, so that “secret” is different from “SECRET”.') ?>
51            </p>
52        </div>
53    </div>
54
55    <!-- CONFIRM PASSWORD -->
56    <div class="row form-group">
57        <label class="col-sm-3 col-form-label" for="pass2">
58            <?= I18N::translate('Confirm password') ?>
59        </label>
60        <div class="col-sm-9">
61            <input class="form-control" type="password" id="pass2" name="pass2" pattern = "<?= WT_REGEX_PASSWORD ?>" placeholder="<?= I18N::translate('Type the password again.') ?>" <?= $user->getUserId() ? '' : 'required' ?> autocomplete="new-password">
62        </div>
63    </div>
64
65    <!-- EMAIL ADDRESS -->
66    <div class="row form-group">
67        <label class="col-sm-3 col-form-label" for="email">
68            <?= I18N::translate('Email address') ?>
69        </label>
70        <div class="col-sm-9">
71            <input class="form-control" type="email" id="email" name="email" required maxlength="64" value="<?= e($user->getEmail()) ?>">
72            <p class="small text-muted">
73                <?= 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.') ?>
74            </p>
75        </div>
76    </div>
77
78    <!-- EMAIL VERIFIED -->
79    <!-- ACCOUNT APPROVED -->
80    <div class="row form-group">
81        <label class="col-sm-3 col-form-label" for="verified">
82            <?= I18N::translate('Account approval and email verification') ?>
83        </label>
84        <div class="col-sm-9">
85            <div class="form-check">
86                <label>
87                    <input type="checkbox" name="verified" value="1" <?= $user->getPreference('verified') ? 'checked' : '' ?>>
88                    <?= I18N::translate('Email verified') ?>
89                </label>
90                <label>
91                    <input type="checkbox" name="approved" value="1" <?= $user->getPreference('verified_by_admin') ? 'checked' : '' ?>>
92                    <?= I18N::translate('Approved by administrator') ?>
93                </label>
94                <p class="small text-muted">
95                    <?= I18N::translate('When a user registers for an account, an email is sent to their email address with a verification link. When they follow this link, we know the email address is correct, and the “email verified” option is selected automatically.') ?>
96                </p>
97                <p class="small text-muted">
98                    <?= I18N::translate('If an administrator creates a user account, the verification email is not sent, and the email must be verified manually.') ?>
99                </p>
100                <p class="small text-muted">
101                    <?= I18N::translate('You should not approve an account unless you know that the email address is correct.') ?>
102                </p>
103                <p class="small text-muted">
104                    <?= I18N::translate('A user will not be able to sign in until both “email verified” and “approved by administrator” are selected.') ?>
105                </p>
106            </div>
107        </div>
108    </div>
109
110    <!-- LANGUAGE -->
111    <div class="row form-group">
112        <label class="col-sm-3 col-form-label" for="language">
113            <?= /* I18N: A configuration setting */ I18N::translate('Language') ?>
114        </label>
115        <div class="col-sm-9">
116            <select id="language" name="language" class="form-control">
117                <?php foreach ($locales as $locale) : ?>
118                    <option value="<?= $locale->languageTag() ?>" <?= $user->getPreference('language', $default_locale) === $locale->languageTag() ? 'selected' : '' ?>>
119                        <?= $locale->endonym() ?>
120                    </option>
121                <?php endforeach ?>
122            </select>
123        </div>
124    </div>
125
126    <!-- TIMEZONE -->
127    <div class="row form-group">
128        <label class="col-sm-3 col-form-label" for="timezone">
129            <?= /* I18N: A configuration setting */ I18N::translate('Time zone') ?>
130        </label>
131        <div class="col-sm-9">
132            <?= Bootstrap4::select(array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), $user->getPreference('TIMEZONE', 'UTC'), ['id' => 'timezone', 'name' => 'timezone']) ?>
133            <p class="small text-muted">
134                <?= I18N::translate('The time zone is required for date calculations, such as knowing today’s date.') ?>
135            </p>
136        </div>
137    </div>
138
139    <!-- AUTO ACCEPT -->
140    <div class="row form-group">
141        <label class="col-sm-3 col-form-label" for="auto_accept">
142            <?= I18N::translate('Changes') ?>
143        </label>
144        <div class="col-sm-9">
145            <div class="form-check">
146                <label>
147                    <input type="checkbox" name="auto_accept" value="1" <?= $user->getPreference('auto_accept') ? 'checked' : '' ?>>
148                    <?= I18N::translate('Automatically accept changes made by this user') ?>
149                </label>
150                <p class="small text-muted">
151                    <?= I18N::translate('Normally, any changes made to a family tree need to be reviewed by a moderator. This option allows a user to make changes without needing a moderator.') ?>
152                </p>
153            </div>
154        </div>
155    </div>
156
157    <!-- VISIBLE ONLINE -->
158    <div class="row form-group">
159        <label class="col-sm-3 col-form-label" for="visible_online">
160            <?= /* I18N: A configuration setting */ I18N::translate('Visible online') ?>
161        </label>
162        <div class="col-sm-9">
163            <div class="form-check">
164                <label>
165                    <input type="checkbox" id="visible_online" name="visible_online" value="1" <?= $user->getPreference('visibleonline') ? 'checked' : '' ?>>
166                    <?= /* I18N: A configuration setting */ I18N::translate('Visible to other users when online') ?>
167                </label>
168                <p class="small text-muted">
169                    <?= I18N::translate('You can choose whether to appear in the list of users who are currently signed-in.') ?>
170                </p>
171            </div>
172        </div>
173    </div>
174
175    <!-- CONTACT METHOD -->
176    <div class="row form-group">
177        <label class="col-sm-3 col-form-label" for="contactmethod">
178            <?= /* I18N: A configuration setting */ I18N::translate('Preferred contact method') ?>
179        </label>
180        <div class="col-sm-9">
181            <?= Bootstrap4::select($contact_methods, $user->getPreference('contactmethod'), ['id' => 'contact_method', 'name' => 'contact_method']) ?>
182            <p class="small text-muted">
183                <?= /* I18N: Help text for the “Preferred contact method” configuration setting */
184                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.') ?>
185            </p>
186        </div>
187    </div>
188
189    <!-- THEME -->
190    <div class="row form-group">
191        <label class="col-sm-3 col-form-label" for="theme">
192            <?= I18N::translate('Theme') ?>
193        </label>
194        <div class="col-sm-9">
195            <?= Bootstrap4::select($theme_options, $user->getPreference('theme'), ['id' => 'theme', 'name' => 'theme']) ?>
196        </div>
197    </div>
198
199    <!-- COMMENTS -->
200    <div class="row form-group">
201        <label class="col-sm-3 col-form-label" for="comment">
202            <?= I18N::translate('Administrator comments on user') ?>
203        </label>
204        <div class="col-sm-9">
205            <textarea class="form-control" id="comment" name="comment" rows="5" maxlength="255"><?= e($user->getPreference('comment')) ?></textarea>
206        </div>
207    </div>
208
209    <!-- ADMINISTRATOR -->
210    <div class="row form-group">
211        <label class="col-sm-3 col-form-label" for="admin">
212        </label>
213        <div class="col-sm-9">
214            <div class="form-check">
215                <label>
216                    <input type="checkbox" id="admin" name="canadmin" value="1" <?= $user->getPreference('canadmin') ? 'checked' : '' ?>  <?= $user->getUserId() === Auth::id() ? 'disabled' : '' ?>>
217                    <?= I18N::translate('Administrator') ?>
218                </label>
219            </div>
220        </div>
221    </div>
222
223    <h3><?= I18N::translate('Access to family trees') ?></h3>
224
225    <p>
226        <?= I18N::translate('A role is a set of access rights, which give permission to view data, change preferences, etc. Access rights are assigned to roles, and roles are granted to users. Each family tree can assign different access to each role, and users can have a different role in each family tree.') ?>
227    </p>
228
229    <div class="row">
230        <div class="col-xs-4">
231            <h4>
232                <?= I18N::translate('Visitor') ?>
233            </h4>
234            <p class="small text-muted">
235                <?= I18N::translate('Everybody has this role, including visitors to the website and search engines.') ?>
236            </p>
237            <h4>
238                <?= I18N::translate('Member') ?>
239            </h4>
240            <p class="small text-muted">
241                <?= I18N::translate('This role has all the permissions of the visitor role, plus any additional access granted by the family tree configuration.') ?>
242            </p>
243        </div>
244        <div class="col-xs-4">
245            <h4>
246                <?= I18N::translate('Editor') ?>
247            </h4>
248            <p class="small text-muted">
249                <?= I18N::translate('This role has all the permissions of the member role, plus permission to add/change/delete data. Any changes will need to be reviewed by a moderator, unless the user has the “automatically accept changes” option enabled.') ?>
250            </p>
251            <h4>
252                <?= I18N::translate('Moderator') ?>
253            </h4>
254            <p class="small text-muted">
255                <?= I18N::translate('This role has all the permissions of the editor role, plus permission to accept/reject changes made by other users.') ?>
256            </p>
257        </div>
258        <div class="col-xs-4">
259            <h4>
260                <?= I18N::translate('Manager') ?>
261            </h4>
262            <p class="small text-muted">
263                <?= I18N::translate('This role has all the permissions of the moderator role, plus any additional access granted by the family tree configuration, plus permission to change the settings/configuration of a family tree.') ?>
264            </p>
265            <h4>
266                <?= I18N::translate('Administrator') ?>
267            </h4>
268            <p class="small text-muted">
269                <?= I18N::translate('This role has all the permissions of the manager role in all family trees, plus permission to change the settings/configuration of the website, users, and modules.') ?>
270            </p>
271        </div>
272    </div>
273
274    <table class="table table-bordered table-sm">
275        <thead>
276            <tr>
277                <th>
278                    <?= I18N::translate('Family tree') ?>
279                </th>
280                <th>
281                    <?= I18N::translate('Role') ?>
282                </th>
283                <th>
284                    <?= I18N::translate('Individual record') ?>
285                </th>
286                <th>
287                    <?= I18N::translate('Restrict to immediate family') ?>
288                </th>
289            </tr>
290            <tr>
291                <td>
292                </td>
293                <td>
294                </td>
295                <td>
296                    <p class="small text-muted">
297                        <?= I18N::translate('Link this user to an individual in the family tree.') ?>
298                    </p>
299                </td>
300                <td>
301                    <p class="small text-muted">
302                        <?= I18N::translate('Where a user is associated to an individual record in a family tree and has a role of member, editor, or moderator, you can prevent them from accessing the details of distant, living relations. You specify the number of relationship steps that the user is allowed to see.') ?>
303                        <?= I18N::translate('For example, if you specify a path length of 2, the individual will be able to see their grandson (child, child), their aunt (parent, sibling), their step-daughter (spouse, child), but not their first cousin (parent, sibling, child).') ?>
304                        <?= I18N::translate('Note: longer path lengths require a lot of calculation, which can make your website run slowly for these users.') ?>
305                    </p>
306                </td>
307            </tr>
308        </thead>
309        <tbody>
310            <?php foreach ($trees as $tree) : ?>
311                <tr>
312                    <td>
313                        <?= e($tree->title()) ?>
314                    </td>
315                    <td>
316                        <select class="form-control" name="canedit<?= $tree->id() ?>">
317                            <?php foreach ($roles as $role => $description) : ?>
318                                <option value="<?= $role ?>"
319                                    <?= $role === $tree->getUserPreference($user, 'canedit') ? 'selected' : '' ?>>
320                                    <?= $description ?>
321                                </option>
322                            <?php endforeach ?>
323                        </select>
324                    </td>
325                    <td>
326                        <?= FunctionsEdit::formControlIndividual($tree, Individual::getInstance($tree->getUserPreference($user, 'gedcomid'), $tree), ['id' => 'gedcomid' . $tree->id(), 'name' => 'gedcomid' . $tree->id()]) ?>
327                    </td>
328                    <td>
329                        <select class="form-control" name="RELATIONSHIP_PATH_LENGTH<?= $tree->id() ?>" id="RELATIONSHIP_PATH_LENGTH<?= $tree->id() ?>" class="relpath">
330                            <?php for ($n = 0; $n <= 10; ++$n) : ?>
331                                <option value="<?= $n ?>" <?= $tree->getUserPreference($user, 'RELATIONSHIP_PATH_LENGTH') == $n ? 'selected' : '' ?>>
332                                    <?= $n ?: I18N::translate('No') ?>
333                                </option>
334                            <?php endfor ?>
335                        </select>
336                    </td>
337                </tr>
338            <?php endforeach ?>
339        </tbody>
340    </table>
341
342    <div class="row form-group">
343        <div class="offset-sm-3 col-sm-9">
344            <button type="submit" class="btn btn-primary">
345                <?= I18N::translate('save') ?>
346            </button>
347        </div>
348    </div>
349</form>
350
351<?php View::push('javascript') ?>
352<script>
353  $(".relpath").change(function() {
354    var fieldIDx = $(this).attr("id");
355    var idNum = fieldIDx.replace("RELATIONSHIP_PATH_LENGTH","");
356    var newIDx = "gedcomid"+idNum;
357    if ($("#"+newIDx).val() === "" && $("#".fieldIDx).val() !== "0") {
358      alert("<?= I18N::translate('You must specify an individual record before you can restrict the user to their immediate family.') ?>");
359      $(this).val("0");
360    }
361  });
362  function regex_quote(str) {
363    return str.replace(/[\\.?+*()[\](){}|]/g, "\\$&");
364  }
365</script>
366<?php View::endpush() ?>
367