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