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