xref: /webtrees/resources/views/admin/trees-privacy.phtml (revision 0115bc1678cafd957052cd2d256563ad3e242cc1)
1<?php use Fisharebest\Webtrees\Bootstrap4; ?>
2<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
3<?php use Fisharebest\Webtrees\I18N; ?>
4<?php use Fisharebest\Webtrees\Site; ?>
5<?php use Fisharebest\Webtrees\View; ?>
6
7<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('admin-trees') => I18N::translate('Manage family trees'), $title]]) ?>
8
9<h1><?= $title ?></h1>
10
11<form method="POST">
12    <input type="hidden" name="route" value="tree-privacy">
13    <input type="hidden" name="ged" value="<?= e($tree->name()) ?>">
14    <?= csrf_field() ?>
15
16    <!-- REQUIRE_AUTHENTICATION -->
17    <div class="row form-group">
18        <div class="col-form-label col-sm-4">
19            <label>
20                <?= /* I18N: A configuration setting */ I18N::translate('Show the family tree') ?>
21            </label>
22            <div class="hidden-xs">
23                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
24                <span class="badge members"><?= I18N::translate('members') ?></span>
25            </div>
26        </div>
27        <div class="col-sm-8">
28            <?= Bootstrap4::select(['0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')], $tree->getPreference('REQUIRE_AUTHENTICATION'), ['id' => 'REQUIRE_AUTHENTICATION', 'name' => 'REQUIRE_AUTHENTICATION']) ?>
29            <p class="small text-muted">
30                <?= /* I18N: Help text for the “Family tree” configuration setting */ I18N::translate('Enabling this option will force all visitors to sign in before they can view any data on the website.') ?>
31            </p>
32            <?php if (Site::getPreference('USE_REGISTRATION_MODULE') === '1') : ?>
33                <p class="small text-muted">
34                    <?= I18N::translate('If visitors can not see the family tree, they will not be able to sign up for an account. You will need to add their account manually.') ?>
35                </p>
36            <?php endif ?>
37        </div>
38    </div>
39
40    <!-- SHOW_DEAD_PEOPLE -->
41    <div class="row form-group">
42        <div class="col-form-label col-sm-4">
43            <label for="SHOW_DEAD_PEOPLE">
44                <?= /* I18N: A configuration setting */ I18N::translate('Show dead individuals') ?>
45            </label>
46            <div class="hidden-xs">
47                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
48                <span class="badge members"><?= I18N::translate('members') ?></span>
49            </div>
50        </div>
51        <div class="col-sm-8">
52            <?= Bootstrap4::select(array_slice(FunctionsEdit::optionsAccessLevels(), 0, 2, true), $tree->getPreference('SHOW_DEAD_PEOPLE'), ['id' => 'SHOW_DEAD_PEOPLE', 'name' => 'SHOW_DEAD_PEOPLE']) ?>
53            <p class="small text-muted">
54                <?= /* I18N: Help text for the “Show dead individuals” configuration setting */ I18N::translate('Set the privacy access level for all dead individuals.') ?>
55            </p>
56        </div>
57    </div>
58
59
60    <!-- MAX_ALIVE_AGE -->
61    <div class="row form-group">
62        <label class="col-form-label col-sm-4" for="MAX_ALIVE_AGE">
63            <?= I18N::translate('Age at which to assume an individual is dead') ?>
64        </label>
65        <div class="col-sm-8">
66            <input
67                class="form-control"
68                id="MAX_ALIVE_AGE"
69                maxlength="5"
70                name="MAX_ALIVE_AGE"
71                type="text"
72                value="<?= e($tree->getPreference('MAX_ALIVE_AGE')) ?>"
73            >
74            <p class="small text-muted">
75                <?= /* I18N: Help text for the “Age at which to assume an individual is dead” configuration setting */ I18N::translate('If this individual has any events other than death, burial, or cremation more recent than this number of years, they are considered to be “alive”. Children’s birth dates are considered to be such events for this purpose.') ?>
76            </p>
77        </div>
78    </div>
79
80    <!-- HIDE_LIVE_PEOPLE -->
81    <fieldset class="form-group">
82        <div class="row">
83            <div class="col-sm-4">
84                <legend class="col-form-label">
85                    <?= /* I18N: A configuration setting */ I18N::translate('Show living individuals') ?>
86                    <div class="hidden-xs">
87                        <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
88                        <span class="badge members"><?= I18N::translate('members') ?></span>
89                    </div>
90                </legend>
91            </div>
92            <div class="col-sm-8">
93                <?= Bootstrap4::select(['0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')], $tree->getPreference('HIDE_LIVE_PEOPLE'), ['id' => 'HIDE_LIVE_PEOPLE', 'name' => 'HIDE_LIVE_PEOPLE']) ?>
94                <p class="small text-muted">
95                    <?= /* I18N: Help text for the “Show living individuals” configuration setting */ I18N::translate('If you show living individuals to visitors, all other privacy restrictions are ignored. Do this only if all the data in your tree is public.') ?>
96                </p>
97            </div>
98        </div>
99    </fieldset>
100
101    <!-- KEEP_ALIVE_YEARS_BIRTH / KEEP_ALIVE_YEARS_DEATH -->
102    <fieldset class="form-group">
103        <div class="row">
104            <legend class="col-form-label col-sm-4">
105                <?= /* I18N: A configuration setting. …who were born in the last XX years or died in the    last YY years */ I18N::translate('Extend privacy to dead individuals') ?>
106            </legend>
107            <div class="col-sm-8">
108                <?php
109                echo
110                    /* I18N: Extend privacy to dead individuals who were… */ I18N::translate(
111                        'born in the last %1$s years or died in the last %2$s years',
112                        '<input type="text" name="KEEP_ALIVE_YEARS_BIRTH" value="' . $tree->getPreference('KEEP_ALIVE_YEARS_BIRTH') . '" size="5" maxlength="3">',
113                        '<input type="text" name="KEEP_ALIVE_YEARS_DEATH" value="' . $tree->getPreference('KEEP_ALIVE_YEARS_DEATH') . '" size="5" maxlength="3">'
114                    ) ?>
115                <p class="small text-muted">
116                    <?= /* I18N: Help text for the “Extend privacy to dead individuals” configuration setting */ I18N::translate('In some countries, privacy laws apply not only to living individuals, but also to those who have died recently. This option will allow you to extend the privacy rules for living individuals to those who were born or died within a specified number of years. Leave these values empty to disable this feature.') ?>
117                </p>
118            </div>
119        </div>
120    </fieldset>
121
122    <!-- SHOW_LIVING_NAMES -->
123    <div class="row form-group">
124        <div class="col-form-label col-sm-4">
125            <label for="SHOW_LIVING_NAMES">
126                <?= /* I18N: A configuration setting */ I18N::translate('Show names of private individuals') ?>
127            </label>
128            <div class="hidden-xs">
129                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
130                <span class="badge members"><?= I18N::translate('members') ?></span>
131                <span class="badge managers"><?= I18N::translate('managers') ?></span>
132            </div>
133        </div>
134        <div class="col-sm-8">
135            <?= Bootstrap4::select(array_slice(FunctionsEdit::optionsAccessLevels(), 0, 3, true), $tree->getPreference('SHOW_LIVING_NAMES'), ['id' => 'SHOW_LIVING_NAMES', 'name' => 'SHOW_LIVING_NAMES']) ?>
136            <p class="small text-muted">
137                <?= /* I18N: Help text for the “Show names of private individuals” configuration setting */ I18N::translate('This option will show the names (but no other details) of private individuals. Individuals are private if they are still alive or if a privacy restriction has been added to their individual record. To hide a specific name, add a privacy restriction to that name record.') ?>
138            </p>
139        </div>
140    </div>
141
142    <!-- SHOW_PRIVATE_RELATIONSHIPS -->
143    <div class="row form-group">
144        <div class="col-form-label col-sm-4">
145            <label for="SHOW_PRIVATE_RELATIONSHIPS">
146                <?= /* I18N: A configuration setting */ I18N::translate('Show private relationships') ?>
147            </label>
148            <div class="hidden-xs">
149                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
150                <span class="badge members"><?= I18N::translate('members') ?></span>
151            </div>
152        </div>
153        <div class="col-sm-8">
154            <?= Bootstrap4::select(['0' => I18N::translate('Hide from everyone'), '1' => I18N::translate('Show to visitors')], $tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'), ['id' => 'SHOW_PRIVATE_RELATIONSHIPS', 'name' => 'SHOW_PRIVATE_RELATIONSHIPS']) ?>
155            <p class="small text-muted">
156                <?= /* I18N: Help text for the “Show private relationships” configuration setting */ I18N::translate('This option will retain family links in private records. This means that you will see empty “private” boxes on the pedigree chart and on other charts with private individuals.') ?>
157            </p>
158        </div>
159    </div>
160    <h2><?= /* I18N: Privacy restrictions are set by RESN tags in GEDCOM. */ I18N::translate('Privacy restrictions') ?></h2>
161    <p>
162        <?= /* I18N: Privacy restrictions are RESN tags in GEDCOM. */ I18N::translate('You can set the access for a specific record, fact, or event by adding a restriction to it. If a record, fact, or event does not have a restriction, the following default restrictions will be used.') ?>
163    </p>
164
165    <script id="new-resn-template" type="text/html">
166        <tr>
167            <td>
168                <select class="form-control" id="record-type">
169                    <option value="individual"><?= I18N::translate('Individual') ?></option>
170                    <option value="family"><?= I18N::translate('Family') ?></option>
171                    <option value="source"><?= I18N::translate('Source') ?></option>
172                    <option value="repository"><?= I18N::translate('Repository') ?></option>
173                    <option value="note"><?= I18N::translate('Note') ?></option>
174                    <option value="media"><?= I18N::translate('Media object') ?></option>
175                </select>
176                <span class="select-record select-individual">
177                    <?= FunctionsEdit::formControlIndividual($tree, null, ['name' => 'xref', 'class' => 'form-control', 'style' => 'width:100%;']) ?>
178                </span>
179                <span class="select-record select-family d-none">
180                    <?= FunctionsEdit::formControlFamily($tree, null, ['name' => 'xref', 'class' => 'form-control', 'style' => 'width:100%;', 'disabled' => true]) ?>
181                </span>
182                <span class="select-record select-source d-none">
183                    <?= FunctionsEdit::formControlSource($tree, null, ['name' => 'xref', 'class' => 'form-control', 'style' => 'width:100%;', 'disabled' => true]) ?>
184                </span>
185                <span class="select-record select-repository d-none">
186                    <?= FunctionsEdit::formControlRepository($tree, null, ['name' => 'xref', 'class' => 'form-control', 'style' => 'width:100%;', 'disabled' => true]) ?>
187                </span>
188                <span class="select-record select-note d-none">
189                    <?= FunctionsEdit::formControlNote($tree, null, ['name' => 'xref', 'class' => 'form-control', 'style' => 'width:100%;', 'disabled' => true]) ?>
190                </span>
191                <span class="select-record select-media d-none">
192                    <?= FunctionsEdit::formControlMediaObject($tree, null, ['name' => 'xref', 'class' => 'form-control', 'style' => 'width:100%;', 'disabled' => true]) ?>
193                </span>
194                <input data-autocomplete-type="IFSRO" id="xref" maxlength="20" name="xref[]" type="text">
195            </td>
196            <td>
197                <?= Bootstrap4::select($all_tags, '', ['name' => 'tag_type[]']) ?>
198            </td>
199            <td>
200                <?= Bootstrap4::select($privacy_constants, 'privacy', ['name' => 'resn[]']) ?>
201            </td>
202            <td>
203            </td>
204        </tr>
205    </script>
206
207    <table class="table table-bordered table-sm table-hover" id="default-resn">
208        <caption class="sr-only">
209            <?= I18N::translate('Privacy restrictions - these apply to records and facts that do not contain a GEDCOM RESN tag') ?>
210        </caption>
211        <thead>
212            <tr>
213                <th>
214                    <?= I18N::translate('Record') ?>
215                </th>
216                <th>
217                    <?= I18N::translate('Fact or event') ?>
218                </th>
219                <th>
220                    <?= I18N::translate('Access level') ?>
221                </th>
222                <th>
223                    <button class="btn btn-primary" id="add-resn" type="button">
224                <?= view('icons/add') ?>
225                        <?= /* I18N: A button label. */ I18N::translate('add') ?>
226                    </button>
227                </th>
228            </tr>
229        </thead>
230        <tbody>
231            <?php foreach ($privacy_restrictions as $privacy_restriction) : ?>
232                <tr>
233                    <td>
234                        <?php if ($privacy_restriction->record) : ?>
235                            <a href="<?= e($privacy_restriction->record->url()) ?>"><?= $privacy_restriction->record->getFullName() ?></a>
236                        <?php elseif ($privacy_restriction->xref) : ?>
237                            <div class="text-danger">
238                                <?= $privacy_restriction->xref ?><?= I18N::translate('This record does not exist.') ?>
239                            </div>
240                        <?php else : ?>
241                            <div class="text-muted">
242                                <?= I18N::translate('All records') ?>
243                            </div>
244                        <?php endif ?>
245                    </td>
246                    <td>
247                        <?php if ($privacy_restriction->tag_label === '') : ?>
248                            <div class="text-muted">
249                                <?= I18N::translate('All facts and events') ?>
250                            </div>
251                        <?php else : ?>
252                            <?= $privacy_restriction->tag_label ?>
253                        <?php endif ?>
254                    </td>
255                    <td>
256                        <?= FunctionsEdit::optionsRestrictions(false)[$privacy_restriction->resn] ?>
257                    </td>
258                    <td>
259                        <label for="delete-<?= $privacy_restriction->default_resn_id ?>">
260                            <input id="delete-<?= $privacy_restriction->default_resn_id ?>" name="delete[]" type="checkbox" value="<?= $privacy_restriction->default_resn_id ?>">
261                            <?= I18N::translate('Delete') ?>
262                        </label>
263                    </td>
264                </tr>
265            <?php endforeach ?>
266        </tbody>
267    </table>
268
269    <div class="row form-group">
270        <div class="offset-sm-4 col-sm-8">
271            <button type="submit" class="btn btn-primary">
272                <?= view('icons/save') ?>
273                <?= I18N::translate('save') ?>
274            </button>
275            <a class="btn btn-secondary" href="<?= route('admin-trees', ['ged' => $tree->name()]) ?>">
276                <?= view('icons/cancel') ?>
277                <?= I18N::translate('cancel') ?>
278            </a>
279            <!-- Coming soon
280            <div class="form-check">
281                <?php if ($count_trees > 1) : ?>
282                <label>
283                    <input type="checkbox" name="all_trees">
284                    <?= /* I18N: Label for checkbox */ I18N::translate('Apply these preferences to all family trees') ?>
285                </label>
286                <?php endif ?>
287            </div>
288            <div class="form-check">
289                <label>
290                    <input type="checkbox" name="new_trees">
291                    <?= /* I18N: Label for checkbox */ I18N::translate('Apply these preferences to new family trees') ?>
292                </label>
293            </div>
294        </div>
295        -->
296        </div>
297
298</form>
299
300<?php View::push('javascript') ?>
301<script>
302  'use strict';
303
304  /**
305   * Hide/show the feedback labels for a privacy option.
306   *
307   * @param sel    the control to change
308   * @param who    "visitors", "members" or "managers"
309   * @param access true or false
310   */
311  function setPrivacyFeedback (sel, who, access) {
312    var formGroup = $(sel).closest('.form-group');
313
314    if (access) {
315      $('.' + who, formGroup).addClass('badge-success').removeClass('badge-secondary');
316      $('.' + who + ' i', formGroup).addClass('fa-check').removeClass('fa-times');
317    } else {
318      $('.' + who, formGroup).addClass('badge-secondary').removeClass('badge-success');
319      $('.' + who + ' i', formGroup).addClass('fa-times').removeClass('fa-check');
320    }
321  }
322
323  /**
324   * Update all the privacy feedback labels.
325   */
326  function updatePrivacyFeedback () {
327    var requireAuthentication = parseInt($('[name=REQUIRE_AUTHENTICATION]').val(), 10);
328    var showDeadPeople = parseInt($('[name=SHOW_DEAD_PEOPLE]').val(), 10);
329    var hideLivePeople = parseInt($('[name=HIDE_LIVE_PEOPLE]').val(), 10);
330    var showLivingNames = parseInt($('[name=SHOW_LIVING_NAMES]').val(), 10);
331    var showPrivateRelationships = parseInt($('[name=SHOW_PRIVATE_RELATIONSHIPS]').val(), 10);
332
333    setPrivacyFeedback('[name=REQUIRE_AUTHENTICATION]', 'visitors', requireAuthentication === 0);
334    setPrivacyFeedback('[name=REQUIRE_AUTHENTICATION]', 'members', true);
335
336    setPrivacyFeedback('[name=SHOW_DEAD_PEOPLE]', 'visitors', requireAuthentication === 0 && (showDeadPeople >= 2 || hideLivePeople === 0));
337    setPrivacyFeedback('[name=SHOW_DEAD_PEOPLE]', 'members', showDeadPeople >= 1 || hideLivePeople === 0);
338
339    setPrivacyFeedback('[name=HIDE_LIVE_PEOPLE]', 'visitors', requireAuthentication === 0 && hideLivePeople === 0);
340    setPrivacyFeedback('[name=HIDE_LIVE_PEOPLE]', 'members', true);
341
342    setPrivacyFeedback('[name=SHOW_LIVING_NAMES]', 'visitors', requireAuthentication === 0 && showLivingNames >= 2);
343    setPrivacyFeedback('[name=SHOW_LIVING_NAMES]', 'members', showLivingNames >= 1);
344    setPrivacyFeedback('[name=SHOW_LIVING_NAMES]', 'managers', showLivingNames >= 0);
345
346    setPrivacyFeedback('[name=SHOW_PRIVATE_RELATIONSHIPS]', 'visitors', requireAuthentication === 0 && showPrivateRelationships >= 1);
347    setPrivacyFeedback('[name=SHOW_PRIVATE_RELATIONSHIPS]', 'members', showPrivateRelationships >= 1);
348  }
349
350  // Activate the privacy feedback labels.
351  updatePrivacyFeedback();
352  $('[name=REQUIRE_AUTHENTICATION], [name=HIDE_LIVE_PEOPLE], [name=SHOW_DEAD_PEOPLE], [name=SHOW_LIVING_NAMES], [name=SHOW_PRIVATE_RELATIONSHIPS]').on('change', function () {
353    updatePrivacyFeedback();
354  });
355
356  // Mute a line when it is marked for deletion
357  $("#default-resn").on("click", "input[type=checkbox]", function() {
358    if ($(this).prop("checked")) {
359      $($(this).closest("tr").addClass("text-muted"));
360    } else {
361      $($(this).closest("tr").removeClass("text-muted"));
362    }
363  });
364
365  // Add a new row to the table
366  $("#add-resn").on("click", function() {
367    $("#default-resn tbody").prepend($("#new-resn-template").html());
368  });
369</script>
370<?php View::endpush() ?>
371