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