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