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