xref: /webtrees/resources/views/admin/trees-privacy.phtml (revision 81443e3cbe4eef5ccdcf8dae716a7e35f7417b60)
1b6c326d8SGreg Roach<?php
2b6c326d8SGreg Roach
3870365fbSGreg Roachuse Fisharebest\Webtrees\Auth;
40c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
56fd01894SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees;
66fd01894SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\TreePrivacyAction;
7269403b3SGreg Roachuse Fisharebest\Webtrees\I18N;
87c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree;
9b6c326d8SGreg Roachuse Fisharebest\Webtrees\View;
10b6c326d8SGreg Roach
117c2c99faSGreg Roach/**
127c2c99faSGreg Roach * @var array<string,string> $all_tags
137c2c99faSGreg Roach * @var int                  $count_trees
147c2c99faSGreg Roach * @var array<string,string> $privacy_constants
157c2c99faSGreg Roach * @var array<int,object>    $privacy_restrictions
167c2c99faSGreg Roach * @var string               $title
177c2c99faSGreg Roach * @var Tree                 $tree
187c2c99faSGreg Roach */
197c2c99faSGreg Roach
20b6c326d8SGreg Roach?>
21dd6b2bfcSGreg Roach
226fd01894SGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees'), $title]]) ?>
23dd6b2bfcSGreg Roach
24dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
25dd6b2bfcSGreg Roach
266fd01894SGreg Roach<form method="post" action="<?= e(route(TreePrivacyAction::class, ['tree' => $tree->name()])) ?>">
27dd6b2bfcSGreg Roach    <!-- REQUIRE_AUTHENTICATION -->
289e3c2cf9SGreg Roach    <div class="row mb-3">
29dd6b2bfcSGreg Roach        <div class="col-form-label col-sm-4">
30dd6b2bfcSGreg Roach            <label>
31dd6b2bfcSGreg Roach                <?= /* I18N: A configuration setting */ I18N::translate('Show the family tree') ?>
32dd6b2bfcSGreg Roach            </label>
33dd6b2bfcSGreg Roach            <div class="hidden-xs">
34dd6b2bfcSGreg Roach                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
35dd6b2bfcSGreg Roach                <span class="badge members"><?= I18N::translate('members') ?></span>
36dd6b2bfcSGreg Roach            </div>
37dd6b2bfcSGreg Roach        </div>
38dd6b2bfcSGreg Roach        <div class="col-sm-8">
39c9e11c2aSGreg Roach            <?= view('components/select', ['name' => 'REQUIRE_AUTHENTICATION', 'selected' => $tree->getPreference('REQUIRE_AUTHENTICATION'), 'options' => ['0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')]]) ?>
40315eb316SGreg Roach            <div class="form-text">
41dd6b2bfcSGreg Roach                <?= /* 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.') ?>
42315eb316SGreg Roach            </div>
43dd6b2bfcSGreg Roach        </div>
44dd6b2bfcSGreg Roach    </div>
45dd6b2bfcSGreg Roach
46dd6b2bfcSGreg Roach    <!-- SHOW_DEAD_PEOPLE -->
479e3c2cf9SGreg Roach    <div class="row mb-3">
48dd6b2bfcSGreg Roach        <div class="col-form-label col-sm-4">
49dd6b2bfcSGreg Roach            <label for="SHOW_DEAD_PEOPLE">
50dd6b2bfcSGreg Roach                <?= /* I18N: A configuration setting */ I18N::translate('Show dead individuals') ?>
51dd6b2bfcSGreg Roach            </label>
52dd6b2bfcSGreg Roach            <div class="hidden-xs">
53dd6b2bfcSGreg Roach                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
54dd6b2bfcSGreg Roach                <span class="badge members"><?= I18N::translate('members') ?></span>
55dd6b2bfcSGreg Roach            </div>
56dd6b2bfcSGreg Roach        </div>
57dd6b2bfcSGreg Roach        <div class="col-sm-8">
58870365fbSGreg Roach            <?= view('components/select', ['name' => 'SHOW_DEAD_PEOPLE', 'selected' => $tree->getPreference('SHOW_DEAD_PEOPLE'), 'options' => array_slice(Auth::accessLevelNames(), 0, 2, true)]) ?>
59315eb316SGreg Roach            <div class="form-text">
60dd6b2bfcSGreg Roach                <?= /* I18N: Help text for the “Show dead individuals” configuration setting */ I18N::translate('Set the privacy access level for all dead individuals.') ?>
61315eb316SGreg Roach            </div>
62dd6b2bfcSGreg Roach        </div>
63dd6b2bfcSGreg Roach    </div>
64dd6b2bfcSGreg Roach
65dd6b2bfcSGreg Roach
66dd6b2bfcSGreg Roach    <!-- MAX_ALIVE_AGE -->
679e3c2cf9SGreg Roach    <div class="row mb-3">
68dd6b2bfcSGreg Roach        <label class="col-form-label col-sm-4" for="MAX_ALIVE_AGE">
69dd6b2bfcSGreg Roach            <?= I18N::translate('Age at which to assume an individual is dead') ?>
70dd6b2bfcSGreg Roach        </label>
71dd6b2bfcSGreg Roach        <div class="col-sm-8">
72315eb316SGreg Roach            <input class="form-control" id="MAX_ALIVE_AGE" min="1" max="9999" name="MAX_ALIVE_AGE" required type="number" value="<?= e($tree->getPreference('MAX_ALIVE_AGE')) ?>">
73315eb316SGreg Roach            <div class="form-text">
74dd6b2bfcSGreg Roach                <?= /* 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.') ?>
75315eb316SGreg Roach            </div>
76dd6b2bfcSGreg Roach        </div>
77dd6b2bfcSGreg Roach    </div>
78dd6b2bfcSGreg Roach
79dd6b2bfcSGreg Roach    <!-- HIDE_LIVE_PEOPLE -->
809e3c2cf9SGreg Roach    <fieldset class="row mb-3">
81315eb316SGreg Roach        <legend class="col-sm-4 col-form-label">
82dd6b2bfcSGreg Roach            <?= /* I18N: A configuration setting */ I18N::translate('Show living individuals') ?>
83dd6b2bfcSGreg Roach            <div class="hidden-xs">
84dd6b2bfcSGreg Roach                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
85dd6b2bfcSGreg Roach                <span class="badge members"><?= I18N::translate('members') ?></span>
86dd6b2bfcSGreg Roach            </div>
87dd6b2bfcSGreg Roach        </legend>
88315eb316SGreg Roach
89dd6b2bfcSGreg Roach        <div class="col-sm-8">
90c9e11c2aSGreg Roach            <?= view('components/select', ['name' => 'HIDE_LIVE_PEOPLE', 'selected' => $tree->getPreference('HIDE_LIVE_PEOPLE'), 'options' => ['0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')]]) ?>
91315eb316SGreg Roach            <div class="form-text">
92dd6b2bfcSGreg Roach                <?= /* 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.') ?>
93dd6b2bfcSGreg Roach            </div>
94dd6b2bfcSGreg Roach        </div>
95dd6b2bfcSGreg Roach    </fieldset>
96dd6b2bfcSGreg Roach
97dd6b2bfcSGreg Roach    <!-- KEEP_ALIVE_YEARS_BIRTH / KEEP_ALIVE_YEARS_DEATH -->
989e3c2cf9SGreg Roach    <fieldset class="row mb-3">
99dd6b2bfcSGreg Roach        <legend class="col-form-label col-sm-4">
100dd6b2bfcSGreg Roach            <?= /* 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') ?>
101dd6b2bfcSGreg Roach        </legend>
102dd6b2bfcSGreg Roach        <div class="col-sm-8">
103dd6b2bfcSGreg Roach            <?php
104dd6b2bfcSGreg Roach            echo
105dd6b2bfcSGreg Roach                /* I18N: Extend privacy to dead individuals who were… */ I18N::translate(
106dd6b2bfcSGreg Roach                    'born in the last %1$s years or died in the last %2$s years',
107dd6b2bfcSGreg Roach                    '<input type="text" name="KEEP_ALIVE_YEARS_BIRTH" value="' . $tree->getPreference('KEEP_ALIVE_YEARS_BIRTH') . '" size="5" maxlength="3">',
108dd6b2bfcSGreg Roach                    '<input type="text" name="KEEP_ALIVE_YEARS_DEATH" value="' . $tree->getPreference('KEEP_ALIVE_YEARS_DEATH') . '" size="5" maxlength="3">'
109dd6b2bfcSGreg Roach                ) ?>
110315eb316SGreg Roach            <div class="form-text">
111dd6b2bfcSGreg Roach                <?= /* 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.') ?>
112dd6b2bfcSGreg Roach            </div>
113dd6b2bfcSGreg Roach        </div>
114dd6b2bfcSGreg Roach    </fieldset>
115dd6b2bfcSGreg Roach
116dd6b2bfcSGreg Roach    <!-- SHOW_LIVING_NAMES -->
1179e3c2cf9SGreg Roach    <div class="row mb-3">
118dd6b2bfcSGreg Roach        <div class="col-form-label col-sm-4">
119dd6b2bfcSGreg Roach            <label for="SHOW_LIVING_NAMES">
120dd6b2bfcSGreg Roach                <?= /* I18N: A configuration setting */ I18N::translate('Show names of private individuals') ?>
121dd6b2bfcSGreg Roach            </label>
122dd6b2bfcSGreg Roach            <div class="hidden-xs">
123dd6b2bfcSGreg Roach                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
124dd6b2bfcSGreg Roach                <span class="badge members"><?= I18N::translate('members') ?></span>
125dd6b2bfcSGreg Roach                <span class="badge managers"><?= I18N::translate('managers') ?></span>
126dd6b2bfcSGreg Roach            </div>
127dd6b2bfcSGreg Roach        </div>
128dd6b2bfcSGreg Roach        <div class="col-sm-8">
129870365fbSGreg Roach            <?= view('components/select', ['name' => 'SHOW_LIVING_NAMES', 'selected' => $tree->getPreference('SHOW_LIVING_NAMES'), 'options' => array_slice(Auth::accessLevelNames(), 0, 3, true)]) ?>
130315eb316SGreg Roach            <div class="form-text">
131dd6b2bfcSGreg Roach                <?= /* 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.') ?>
132315eb316SGreg Roach            </div>
133dd6b2bfcSGreg Roach        </div>
134dd6b2bfcSGreg Roach    </div>
135dd6b2bfcSGreg Roach
136dd6b2bfcSGreg Roach    <!-- SHOW_PRIVATE_RELATIONSHIPS -->
1379e3c2cf9SGreg Roach    <div class="row mb-3">
138dd6b2bfcSGreg Roach        <div class="col-form-label col-sm-4">
139dd6b2bfcSGreg Roach            <label for="SHOW_PRIVATE_RELATIONSHIPS">
140dd6b2bfcSGreg Roach                <?= /* I18N: A configuration setting */ I18N::translate('Show private relationships') ?>
141dd6b2bfcSGreg Roach            </label>
142dd6b2bfcSGreg Roach            <div class="hidden-xs">
143dd6b2bfcSGreg Roach                <span class="badge visitors"><?= I18N::translate('visitors') ?></span>
144dd6b2bfcSGreg Roach                <span class="badge members"><?= I18N::translate('members') ?></span>
145dd6b2bfcSGreg Roach            </div>
146dd6b2bfcSGreg Roach        </div>
147dd6b2bfcSGreg Roach        <div class="col-sm-8">
148c9e11c2aSGreg Roach            <?= view('components/select', ['name' => 'SHOW_PRIVATE_RELATIONSHIPS', 'selected' => $tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'), 'options' => ['0' => I18N::translate('Hide from everyone'), '1' => I18N::translate('Show to visitors')]]) ?>
149315eb316SGreg Roach            <div class="form-text">
150dd6b2bfcSGreg Roach                <?= /* 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.') ?>
151315eb316SGreg Roach            </div>
152dd6b2bfcSGreg Roach        </div>
153dd6b2bfcSGreg Roach    </div>
154dd6b2bfcSGreg Roach    <h2><?= /* I18N: Privacy restrictions are set by RESN tags in GEDCOM. */ I18N::translate('Privacy restrictions') ?></h2>
155dd6b2bfcSGreg Roach    <p>
156dd6b2bfcSGreg Roach        <?= /* 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.') ?>
157dd6b2bfcSGreg Roach    </p>
158dd6b2bfcSGreg Roach
159dd6b2bfcSGreg Roach    <script id="new-resn-template" type="text/html">
160dd6b2bfcSGreg Roach        <tr>
161a5045593SGreg Roach            <td class="w-50">
1624b9213b3SGreg Roach                <select class="form-select record-type-selector mb-3">
163ac5ee73fSGreg Roach                    <option value="all"><?= I18N::translate('All records') ?></option>
164dd6b2bfcSGreg Roach                    <option value="individual"><?= I18N::translate('Individual') ?></option>
165dd6b2bfcSGreg Roach                    <option value="family"><?= I18N::translate('Family') ?></option>
166dd6b2bfcSGreg Roach                    <option value="source"><?= I18N::translate('Source') ?></option>
167dd6b2bfcSGreg Roach                    <option value="repository"><?= I18N::translate('Repository') ?></option>
168dd6b2bfcSGreg Roach                    <option value="note"><?= I18N::translate('Note') ?></option>
169dd6b2bfcSGreg Roach                    <option value="media"><?= I18N::translate('Media object') ?></option>
170dd6b2bfcSGreg Roach                </select>
171ac5ee73fSGreg Roach
172ac5ee73fSGreg Roach                <div class="select-record select-all">
173a5045593SGreg Roach                    <div class="d-none">
174a5045593SGreg Roach                        <select name="xref[] required="required">
175a5045593SGreg Roach                            <option selected="selected"></option>
176a5045593SGreg Roach                        </select>
177a5045593SGreg Roach                    </div>
178ac5ee73fSGreg Roach                </div>
179ac5ee73fSGreg Roach
18064b4a654SGreg Roach                <div class="select-record select-individual d-none">
181a5045593SGreg Roach                    <?= view('components/select-individual', ['name' => 'xref[]', 'id' => '', 'tree' => $tree, 'disabled' => true, 'required' => true]) ?>
18264b4a654SGreg Roach                </div>
183ac5ee73fSGreg Roach
18464b4a654SGreg Roach                <div class="select-record select-family d-none">
185a5045593SGreg Roach                    <?= view('components/select-family', ['name' => 'xref[]', 'id' => '', 'tree' => $tree, 'disabled' => true, 'required' => true]) ?>
18664b4a654SGreg Roach                </div>
187ac5ee73fSGreg Roach
18864b4a654SGreg Roach                <div class="select-record select-source d-none">
189a5045593SGreg Roach                    <?= view('components/select-source', ['name' => 'xref[]', 'id' => '', 'tree' => $tree, 'disabled' => true, 'required' => true]) ?>
19064b4a654SGreg Roach                </div>
191ac5ee73fSGreg Roach
19264b4a654SGreg Roach                <div class="select-record select-repository d-none">
193a5045593SGreg Roach                    <?= view('components/select-repository', ['name' => 'xref[]', 'id' => '', 'tree' => $tree, 'disabled' => true, 'required' => true]) ?>
19464b4a654SGreg Roach                </div>
195ac5ee73fSGreg Roach
19664b4a654SGreg Roach                <div class="select-record select-note d-none">
197a5045593SGreg Roach                    <?= view('components/select-note', ['name' => 'xref[]', 'id' => '', 'tree' => $tree, 'disabled' => true, 'required' => true]) ?>
19864b4a654SGreg Roach                </div>
199ac5ee73fSGreg Roach
20064b4a654SGreg Roach                <div class="select-record select-media d-none">
201a5045593SGreg Roach                    <?= view('components/select-media', ['name' => 'xref[]', 'id' => '', 'tree' => $tree, 'disabled' => true, 'required' => true]) ?>
20264b4a654SGreg Roach                </div>
203dd6b2bfcSGreg Roach            </td>
204ac5ee73fSGreg Roach
205dd6b2bfcSGreg Roach            <td>
206ac5ee73fSGreg Roach                <?= view('components/select', ['name' => 'tag_type[]', 'id' => '', 'selected' => '', 'options' => $all_tags]) ?>
207dd6b2bfcSGreg Roach            </td>
208ac5ee73fSGreg Roach
209dd6b2bfcSGreg Roach            <td>
210ac5ee73fSGreg Roach                <?= view('components/select', ['name' => 'resn[]', 'id' => '', 'selected' => 'privacy', 'options' => $privacy_constants]) ?>
211dd6b2bfcSGreg Roach            </td>
212ac5ee73fSGreg Roach
213dd6b2bfcSGreg Roach            <td>
214dd6b2bfcSGreg Roach            </td>
215dd6b2bfcSGreg Roach        </tr>
216dd6b2bfcSGreg Roach    </script>
217dd6b2bfcSGreg Roach
218dd6b2bfcSGreg Roach    <table class="table table-bordered table-sm table-hover" id="default-resn">
219315eb316SGreg Roach        <caption class="visually-hidden">
220dd6b2bfcSGreg Roach            <?= I18N::translate('Privacy restrictions - these apply to records and facts that do not contain a GEDCOM RESN tag') ?>
221dd6b2bfcSGreg Roach        </caption>
222dd6b2bfcSGreg Roach        <thead>
223dd6b2bfcSGreg Roach            <tr>
224a5045593SGreg Roach                <th class="w-50">
225dd6b2bfcSGreg Roach                    <?= I18N::translate('Record') ?>
226dd6b2bfcSGreg Roach                </th>
227dd6b2bfcSGreg Roach                <th>
228dd6b2bfcSGreg Roach                    <?= I18N::translate('Fact or event') ?>
229dd6b2bfcSGreg Roach                </th>
230dd6b2bfcSGreg Roach                <th>
231dd6b2bfcSGreg Roach                    <?= I18N::translate('Access level') ?>
232dd6b2bfcSGreg Roach                </th>
233dd6b2bfcSGreg Roach                <th>
234dd6b2bfcSGreg Roach                    <button class="btn btn-primary" id="add-resn" type="button">
235dd6b2bfcSGreg Roach                <?= view('icons/add') ?>
236dd6b2bfcSGreg Roach                        <?= /* I18N: A button label. */ I18N::translate('add') ?>
237dd6b2bfcSGreg Roach                    </button>
238dd6b2bfcSGreg Roach                </th>
239dd6b2bfcSGreg Roach            </tr>
240dd6b2bfcSGreg Roach        </thead>
241dd6b2bfcSGreg Roach        <tbody>
242dd6b2bfcSGreg Roach            <?php foreach ($privacy_restrictions as $privacy_restriction) : ?>
243dd6b2bfcSGreg Roach                <tr>
244dd6b2bfcSGreg Roach                    <td>
245dd6b2bfcSGreg Roach                        <?php if ($privacy_restriction->record) : ?>
24639ca88baSGreg Roach                            <a href="<?= e($privacy_restriction->record->url()) ?>"><?= $privacy_restriction->record->fullName() ?></a>
247dd6b2bfcSGreg Roach                        <?php elseif ($privacy_restriction->xref) : ?>
248dd6b2bfcSGreg Roach                            <div class="text-danger">
249dd6b2bfcSGreg Roach                                <?= $privacy_restriction->xref ?><?= I18N::translate('This record does not exist.') ?>
250dd6b2bfcSGreg Roach                            </div>
251dd6b2bfcSGreg Roach                        <?php else : ?>
252dd6b2bfcSGreg Roach                            <div class="text-muted">
253dd6b2bfcSGreg Roach                                <?= I18N::translate('All records') ?>
254dd6b2bfcSGreg Roach                            </div>
255dd6b2bfcSGreg Roach                        <?php endif ?>
256dd6b2bfcSGreg Roach                    </td>
257dd6b2bfcSGreg Roach                    <td>
258cd494761SGreg Roach                        <?php if ($privacy_restriction->tag_label === '') : ?>
259dd6b2bfcSGreg Roach                            <div class="text-muted">
260dd6b2bfcSGreg Roach                                <?= I18N::translate('All facts and events') ?>
261dd6b2bfcSGreg Roach                            </div>
262cd494761SGreg Roach                        <?php else : ?>
263cd494761SGreg Roach                            <?= $privacy_restriction->tag_label ?>
264dd6b2bfcSGreg Roach                        <?php endif ?>
265dd6b2bfcSGreg Roach                    </td>
266dd6b2bfcSGreg Roach                    <td>
267138139c2SGreg Roach                        <?= Auth::privacyRuleNames()[$privacy_restriction->resn] ?>
268dd6b2bfcSGreg Roach                    </td>
269dd6b2bfcSGreg Roach                    <td>
270dd6b2bfcSGreg Roach                        <label for="delete-<?= $privacy_restriction->default_resn_id ?>">
271dd6b2bfcSGreg Roach                            <input id="delete-<?= $privacy_restriction->default_resn_id ?>" name="delete[]" type="checkbox" value="<?= $privacy_restriction->default_resn_id ?>">
272dd6b2bfcSGreg Roach                            <?= I18N::translate('Delete') ?>
273dd6b2bfcSGreg Roach                        </label>
274dd6b2bfcSGreg Roach                    </td>
275dd6b2bfcSGreg Roach                </tr>
276dd6b2bfcSGreg Roach            <?php endforeach ?>
277dd6b2bfcSGreg Roach        </tbody>
278dd6b2bfcSGreg Roach    </table>
279dd6b2bfcSGreg Roach
2809e3c2cf9SGreg Roach    <div class="row mb-3">
281dd6b2bfcSGreg Roach        <div class="offset-sm-4 col-sm-8">
282dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
283dd6b2bfcSGreg Roach                <?= view('icons/save') ?>
284dd6b2bfcSGreg Roach                <?= I18N::translate('save') ?>
285dd6b2bfcSGreg Roach            </button>
2860c0910bfSGreg Roach
2876fd01894SGreg Roach            <a class="btn btn-secondary" href="<?= route(ManageTrees::class, ['tree' => $tree->name()]) ?>">
288dd6b2bfcSGreg Roach                <?= view('icons/cancel') ?>
289dd6b2bfcSGreg Roach                <?= I18N::translate('cancel') ?>
290dd6b2bfcSGreg Roach            </a>
291dd6b2bfcSGreg Roach            <!-- Coming soon
292dd6b2bfcSGreg Roach            <div class="form-check">
293dd6b2bfcSGreg Roach                <?php if ($count_trees > 1) : ?>
294dd6b2bfcSGreg Roach                <label>
295dd6b2bfcSGreg Roach                    <input type="checkbox" name="all_trees">
296dd6b2bfcSGreg Roach                    <?= /* I18N: Label for checkbox */ I18N::translate('Apply these preferences to all family trees') ?>
297dd6b2bfcSGreg Roach                </label>
298dd6b2bfcSGreg Roach                <?php endif ?>
299dd6b2bfcSGreg Roach            </div>
300dd6b2bfcSGreg Roach            <div class="form-check">
301dd6b2bfcSGreg Roach                <label>
302dd6b2bfcSGreg Roach                    <input type="checkbox" name="new_trees">
303dd6b2bfcSGreg Roach                    <?= /* I18N: Label for checkbox */ I18N::translate('Apply these preferences to new family trees') ?>
304dd6b2bfcSGreg Roach                </label>
305dd6b2bfcSGreg Roach            </div>
306dd6b2bfcSGreg Roach            -->
307dd6b2bfcSGreg Roach        </div>
308*81443e3cSGreg Roach    </div>
309dd6b2bfcSGreg Roach
310*81443e3cSGreg Roach    <?= csrf_field() ?>
311dd6b2bfcSGreg Roach</form>
312dd6b2bfcSGreg Roach
313dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
314dd6b2bfcSGreg Roach<script>
315c8d78f19SGreg Roach  'use strict';
316dd6b2bfcSGreg Roach
317dd6b2bfcSGreg Roach  /**
318dd6b2bfcSGreg Roach   * Hide/show the feedback labels for a privacy option.
319dd6b2bfcSGreg Roach   *
320dd6b2bfcSGreg Roach   * @param sel    the control to change
321dd6b2bfcSGreg Roach   * @param who    "visitors", "members" or "managers"
322dd6b2bfcSGreg Roach   * @param access true or false
323dd6b2bfcSGreg Roach   */
324dd6b2bfcSGreg Roach  function setPrivacyFeedback (sel, who, access) {
325c3521ffbSGreg Roach    var formGroup = $(sel).closest('.row');
326dd6b2bfcSGreg Roach
327dd6b2bfcSGreg Roach    if (access) {
328c8d78f19SGreg Roach      $('.' + who, formGroup).addClass('bg-success').removeClass('bg-secondary');
329c8d78f19SGreg Roach      $('.' + who + ' i', formGroup).addClass('fa-check').removeClass('fa-times');
330dd6b2bfcSGreg Roach    } else {
331c8d78f19SGreg Roach      $('.' + who, formGroup).addClass('bg-secondary').removeClass('bg-success');
332c8d78f19SGreg Roach      $('.' + who + ' i', formGroup).addClass('fa-times').removeClass('fa-check');
333dd6b2bfcSGreg Roach    }
334dd6b2bfcSGreg Roach  }
335dd6b2bfcSGreg Roach
336dd6b2bfcSGreg Roach  /**
337dd6b2bfcSGreg Roach   * Update all the privacy feedback labels.
338dd6b2bfcSGreg Roach   */
339dd6b2bfcSGreg Roach  function updatePrivacyFeedback () {
340c8d78f19SGreg Roach    var requireAuthentication = parseInt($('[name=REQUIRE_AUTHENTICATION]').val(), 10);
341c8d78f19SGreg Roach    var showDeadPeople = parseInt($('[name=SHOW_DEAD_PEOPLE]').val(), 10);
342c8d78f19SGreg Roach    var hideLivePeople = parseInt($('[name=HIDE_LIVE_PEOPLE]').val(), 10);
343c8d78f19SGreg Roach    var showLivingNames = parseInt($('[name=SHOW_LIVING_NAMES]').val(), 10);
344c8d78f19SGreg Roach    var showPrivateRelationships = parseInt($('[name=SHOW_PRIVATE_RELATIONSHIPS]').val(), 10);
345dd6b2bfcSGreg Roach
346c8d78f19SGreg Roach    setPrivacyFeedback('[name=REQUIRE_AUTHENTICATION]', 'visitors', requireAuthentication === 0);
347c8d78f19SGreg Roach    setPrivacyFeedback('[name=REQUIRE_AUTHENTICATION]', 'members', true);
348dd6b2bfcSGreg Roach
349c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_DEAD_PEOPLE]', 'visitors', requireAuthentication === 0 && (showDeadPeople >= 2 || hideLivePeople === 0));
350c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_DEAD_PEOPLE]', 'members', showDeadPeople >= 1 || hideLivePeople === 0);
351dd6b2bfcSGreg Roach
352c8d78f19SGreg Roach    setPrivacyFeedback('[name=HIDE_LIVE_PEOPLE]', 'visitors', requireAuthentication === 0 && hideLivePeople === 0);
353c8d78f19SGreg Roach    setPrivacyFeedback('[name=HIDE_LIVE_PEOPLE]', 'members', true);
354dd6b2bfcSGreg Roach
355c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_LIVING_NAMES]', 'visitors', requireAuthentication === 0 && showLivingNames >= 2);
356c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_LIVING_NAMES]', 'members', showLivingNames >= 1);
357c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_LIVING_NAMES]', 'managers', showLivingNames >= 0);
358dd6b2bfcSGreg Roach
359c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_PRIVATE_RELATIONSHIPS]', 'visitors', requireAuthentication === 0 && showPrivateRelationships >= 1);
360c8d78f19SGreg Roach    setPrivacyFeedback('[name=SHOW_PRIVATE_RELATIONSHIPS]', 'members', showPrivateRelationships >= 1);
361dd6b2bfcSGreg Roach  }
362dd6b2bfcSGreg Roach
363dd6b2bfcSGreg Roach  // Activate the privacy feedback labels.
364dd6b2bfcSGreg Roach  updatePrivacyFeedback();
365c8d78f19SGreg Roach  $('[name=REQUIRE_AUTHENTICATION], [name=HIDE_LIVE_PEOPLE], [name=SHOW_DEAD_PEOPLE], [name=SHOW_LIVING_NAMES], [name=SHOW_PRIVATE_RELATIONSHIPS]').on('change', function () {
366dd6b2bfcSGreg Roach    updatePrivacyFeedback();
367dd6b2bfcSGreg Roach  });
368dd6b2bfcSGreg Roach
369dd6b2bfcSGreg Roach  // Mute a line when it is marked for deletion
370c8d78f19SGreg Roach  $('#default-resn').on('click', 'input[type=checkbox]', function () {
371c8d78f19SGreg Roach    if ($(this).prop('checked')) {
372c8d78f19SGreg Roach      $($(this).closest('tr').addClass('text-muted'));
373dd6b2bfcSGreg Roach    } else {
374c8d78f19SGreg Roach      $($(this).closest('tr').removeClass('text-muted'));
375dd6b2bfcSGreg Roach    }
376dd6b2bfcSGreg Roach  });
377dd6b2bfcSGreg Roach
378dd6b2bfcSGreg Roach  // Add a new row to the table
379c8d78f19SGreg Roach  $('#add-resn').on('click', function () {
380c8d78f19SGreg Roach    $('#default-resn tbody').prepend($('#new-resn-template').html());
381269403b3SGreg Roach
382a5045593SGreg Roach    document.querySelectorAll('#default-resn tbody tr:first-child select.tom-select')
383c8d78f19SGreg Roach      .forEach(element => webtrees.initializeTomSelect(element));
384269403b3SGreg Roach
385c8d78f19SGreg Roach    let row = document.getElementById('default-resn').querySelector('tbody tr');
386c8d78f19SGreg Roach    webtrees.initializeIFSRO(row.querySelector('select'), row);
387dd6b2bfcSGreg Roach  });
388dd6b2bfcSGreg Roach</script>
389dd6b2bfcSGreg Roach<?php View::endpush() ?>
390