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