xref: /webtrees/resources/views/admin/users-edit.phtml (revision 06f42609e3f1764a2e55be21f0ce941f29f42167)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\Functions\FunctionsPrint;
5use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
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" name="newform" 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('verified') ? 'checked' : '' ?>>
82                    <?= I18N::translate('Email verified') ?>
83                </label>
84                <label>
85                    <input type="checkbox" name="approved" value="1" <?= $user->getPreference('verified_by_admin') ? '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            <select id="language" name="language" class="form-control">
111                <?php foreach ($locales as $locale) : ?>
112                    <option value="<?= $locale->languageTag() ?>" <?= $user->getPreference('language', $default_locale) === $locale->languageTag() ? 'selected' : '' ?>>
113                        <?= $locale->endonym() ?>
114                    </option>
115                <?php endforeach ?>
116            </select>
117        </div>
118    </div>
119
120    <!-- TIMEZONE -->
121    <div class="row form-group">
122        <label class="col-sm-3 col-form-label" for="timezone">
123            <?= /* I18N: A configuration setting */ I18N::translate('Time zone') ?>
124        </label>
125        <div class="col-sm-9">
126            <?= view('components/select', ['name' => 'timezone', 'selected' => $user->getPreference('TIMEZONE', 'UTC'), 'options' => array_combine(DateTimeZone::listIdentifiers(), DateTimeZone::listIdentifiers())]) ?>
127            <p class="small text-muted">
128                <?= I18N::translate('The time zone is required for date calculations, such as knowing today’s date.') ?>
129            </p>
130        </div>
131    </div>
132
133    <!-- AUTO ACCEPT -->
134    <div class="row form-group">
135        <label class="col-sm-3 col-form-label" for="auto_accept">
136            <?= I18N::translate('Changes') ?>
137        </label>
138        <div class="col-sm-9">
139            <div class="form-check">
140                <label>
141                    <input type="checkbox" name="auto_accept" value="1" <?= $user->getPreference('auto_accept') ? 'checked' : '' ?>>
142                    <?= I18N::translate('Automatically accept changes made by this user') ?>
143                </label>
144                <p class="small text-muted">
145                    <?= 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.') ?>
146                </p>
147            </div>
148        </div>
149    </div>
150
151    <!-- VISIBLE ONLINE -->
152    <div class="row form-group">
153        <label class="col-sm-3 col-form-label" for="visible_online">
154            <?= /* I18N: A configuration setting */ I18N::translate('Visible online') ?>
155        </label>
156        <div class="col-sm-9">
157            <div class="form-check">
158                <label>
159                    <input type="checkbox" id="visible_online" name="visible_online" value="1" <?= $user->getPreference('visibleonline') ? 'checked' : '' ?>>
160                    <?= /* I18N: A configuration setting */ I18N::translate('Visible to other users when online') ?>
161                </label>
162                <p class="small text-muted">
163                    <?= I18N::translate('You can choose whether to appear in the list of users who are currently signed-in.') ?>
164                </p>
165            </div>
166        </div>
167    </div>
168
169    <!-- CONTACT METHOD -->
170    <div class="row form-group">
171        <label class="col-sm-3 col-form-label" for="contactmethod">
172            <?= /* I18N: A configuration setting */ I18N::translate('Preferred contact method') ?>
173        </label>
174        <div class="col-sm-9">
175            <?= view('components/select', ['name' => 'contact_method', 'selected' => $user->getPreference('contactmethod'), 'options' => $contact_methods]) ?>
176            <p class="small text-muted">
177                <?= /* I18N: Help text for the “Preferred contact method” configuration setting */
178                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.') ?>
179            </p>
180        </div>
181    </div>
182
183    <!-- THEME -->
184    <div class="row form-group">
185        <label class="col-sm-3 col-form-label" for="theme">
186            <?= I18N::translate('Theme') ?>
187        </label>
188        <div class="col-sm-9">
189            <?= view('components/select', ['name' => 'theme', 'selected' => $user->getPreference('theme'), 'options' => $theme_options]) ?>
190        </div>
191    </div>
192
193    <!-- COMMENTS -->
194    <div class="row form-group">
195        <label class="col-sm-3 col-form-label" for="comment">
196            <?= I18N::translate('Administrator comments on user') ?>
197        </label>
198        <div class="col-sm-9">
199            <textarea class="form-control" id="comment" name="comment" rows="5" dir="auto" maxlength="255"><?= e($user->getPreference('comment')) ?></textarea>
200        </div>
201    </div>
202
203    <!-- ADMINISTRATOR -->
204    <div class="row form-group">
205        <label class="col-sm-3 col-form-label" for="admin">
206        </label>
207        <div class="col-sm-9">
208            <div class="form-check">
209                <label>
210                    <input type="checkbox" id="admin" name="canadmin" value="1" <?= $user->getPreference('canadmin') ? 'checked' : '' ?>  <?= $user->id() === Auth::id() ? 'disabled' : '' ?>>
211                    <?= I18N::translate('Administrator') ?>
212                </label>
213            </div>
214        </div>
215    </div>
216
217    <h3><?= I18N::translate('Access to family trees') ?></h3>
218
219    <p>
220        <?= 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.') ?>
221    </p>
222
223    <div class="row">
224        <div class="col-xs-4">
225            <h4>
226                <?= I18N::translate('Visitor') ?>
227            </h4>
228            <p class="small text-muted">
229                <?= I18N::translate('Everybody has this role, including visitors to the website and search engines.') ?>
230            </p>
231            <h4>
232                <?= I18N::translate('Member') ?>
233            </h4>
234            <p class="small text-muted">
235                <?= I18N::translate('This role has all the permissions of the visitor role, plus any additional access granted by the family tree configuration.') ?>
236            </p>
237        </div>
238        <div class="col-xs-4">
239            <h4>
240                <?= I18N::translate('Editor') ?>
241            </h4>
242            <p class="small text-muted">
243                <?= 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.') ?>
244            </p>
245            <h4>
246                <?= I18N::translate('Moderator') ?>
247            </h4>
248            <p class="small text-muted">
249                <?= I18N::translate('This role has all the permissions of the editor role, plus permission to accept/reject changes made by other users.') ?>
250            </p>
251        </div>
252        <div class="col-xs-4">
253            <h4>
254                <?= I18N::translate('Manager') ?>
255            </h4>
256            <p class="small text-muted">
257                <?= 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.') ?>
258            </p>
259            <h4>
260                <?= I18N::translate('Administrator') ?>
261            </h4>
262            <p class="small text-muted">
263                <?= 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.') ?>
264            </p>
265        </div>
266    </div>
267
268    <table class="table table-bordered table-sm">
269        <thead>
270            <tr>
271                <th>
272                    <?= I18N::translate('Family tree') ?>
273                </th>
274                <th>
275                    <?= I18N::translate('Role') ?>
276                </th>
277                <th>
278                    <?= I18N::translate('Individual record') ?>
279                </th>
280                <th>
281                    <?= I18N::translate('Restrict to immediate family') ?>
282                    <?= FunctionsPrint::helpLink('relationship-privacy') ?>
283                </th>
284            </tr>
285            <tr>
286                <td>
287                </td>
288                <td>
289                </td>
290                <td>
291                    <p class="small text-muted">
292                        <?= I18N::translate('Link this user to an individual in the family tree.') ?>
293                    </p>
294                </td>
295                <td>
296                </td>
297            </tr>
298        </thead>
299        <tbody>
300            <?php foreach ($trees as $tree) : ?>
301                <tr>
302                    <td>
303                        <?= e($tree->title()) ?>
304                    </td>
305                    <td>
306                        <select class="form-control" name="canedit<?= $tree->id() ?>">
307                            <?php foreach ($roles as $role => $description) : ?>
308                                <option value="<?= $role ?>"
309                                    <?= $role === $tree->getUserPreference($user, 'canedit') ? 'selected' : '' ?>>
310                                    <?= $description ?>
311                                </option>
312                            <?php endforeach ?>
313                        </select>
314                    </td>
315                    <td>
316                        <?= view('components/select-individual', ['name' => 'gedcomid' . $tree->id(), 'individual' => Individual::getInstance($tree->getUserPreference($user, 'gedcomid'), $tree), 'tree' => $tree]) ?>
317                    </td>
318                    <td>
319                        <select class="form-control" name="RELATIONSHIP_PATH_LENGTH<?= $tree->id() ?>" id="RELATIONSHIP_PATH_LENGTH<?= $tree->id() ?>" class="relpath">
320                            <?php for ($n = 0; $n <= 10; ++$n) : ?>
321                                <option value="<?= $n ?>" <?= $tree->getUserPreference($user, 'RELATIONSHIP_PATH_LENGTH') == $n ? 'selected' : '' ?>>
322                                    <?= $n ?: I18N::translate('No') ?>
323                                </option>
324                            <?php endfor ?>
325                        </select>
326                    </td>
327                </tr>
328            <?php endforeach ?>
329        </tbody>
330    </table>
331
332    <div class="row form-group">
333        <div class="offset-sm-3 col-sm-9">
334            <button type="submit" class="btn btn-primary">
335                <?= I18N::translate('save') ?>
336            </button>
337        </div>
338    </div>
339</form>
340
341<?= view('modals/ajax') ?>
342
343<?php View::push('javascript') ?>
344<script>
345    $(".relpath").change(function () {
346        var fieldIDx = $(this).attr("id");
347        var idNum    = fieldIDx.replace("RELATIONSHIP_PATH_LENGTH", "");
348        var newIDx   = "gedcomid" + idNum;
349        if ($("#" + newIDx).val() === "" && $("#".fieldIDx).val() !== "0") {
350            alert("<?= I18N::translate('You must specify an individual record before you can restrict the user to their immediate family.') ?>");
351            $(this).val("0");
352        }
353    });
354
355    $("#password").hideShowPassword('infer', true);
356</script>
357<?php View::endpush() ?>
358
359