Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #2755 Adding privacy for source display to visitors #4748

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Http/RequestHandlers/TreePrivacyAction.php
Expand Up @@ -113,6 +113,8 @@
$show_dead_people = Validator::parsedBody($request)->string('SHOW_DEAD_PEOPLE');
$show_living_names = Validator::parsedBody($request)->string('SHOW_LIVING_NAMES');
$show_private_relationships = Validator::parsedBody($request)->string('SHOW_PRIVATE_RELATIONSHIPS');
$show_source_detail_toggles = Validator::parsedBody($request)->string('SHOW_SOURCE_DETAIL_TOGGLES');
$show_source_titles = Validator::parsedBody($request)->string('SHOW_SOURCE_TITLES');

Check warning on line 117 in app/Http/RequestHandlers/TreePrivacyAction.php

View check run for this annotation

Codecov / codecov/patch

app/Http/RequestHandlers/TreePrivacyAction.php#L116-L117

Added lines #L116 - L117 were not covered by tests

$tree->setPreference('HIDE_LIVE_PEOPLE', $hide_live_people);
$tree->setPreference('KEEP_ALIVE_YEARS_BIRTH', (string) $keep_alive_years_birth);
Expand All @@ -122,6 +124,8 @@
$tree->setPreference('SHOW_DEAD_PEOPLE', $show_dead_people);
$tree->setPreference('SHOW_LIVING_NAMES', $show_living_names);
$tree->setPreference('SHOW_PRIVATE_RELATIONSHIPS', $show_private_relationships);
$tree->setPreference('SHOW_SOURCE_DETAIL_TOGGLES', $show_source_detail_toggles);
$tree->setPreference('SHOW_SOURCE_TITLES', $show_source_titles);

Check warning on line 128 in app/Http/RequestHandlers/TreePrivacyAction.php

View check run for this annotation

Codecov / codecov/patch

app/Http/RequestHandlers/TreePrivacyAction.php#L127-L128

Added lines #L127 - L128 were not covered by tests

FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', e($tree->title())), 'success');

Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/trees-preferences.phtml
Expand Up @@ -544,7 +544,7 @@ use Illuminate\Support\Collection;
<?= view('components/radios-inline', ['name' => 'EXPAND_SOURCES', 'options' => [I18N::translate('no'), I18N::translate('yes')], 'selected' => (int) $tree->getPreference('EXPAND_SOURCES')]) ?>
<div class="form-text">
<?= /* I18N: Help text for the “Automatically expand sources” configuration setting */
I18N::translate('This option controls whether or not to automatically display content of a <i>Source</i> record on the Individual page.') ?>
I18N::translate('This option controls whether or not to automatically display content of a <i>Source</i> record on the Individual page. A yes setting may be overriden by tree privacy settings regarding the display of source details and titles.') ?>
</div>
</div>
</fieldset>
Expand Down
51 changes: 49 additions & 2 deletions resources/views/admin/trees-privacy.phtml
Expand Up @@ -153,6 +153,45 @@ use Fisharebest\Webtrees\View;
</div>
</div>
</div>

<!-- SHOW_SOURCE_DETAIL_TOGGLES -->
<div class="row mb-3">
<div class="col-form-label col-sm-4">
<label for="SHOW_SOURCE_DETAIL_TOGGLES">
<?= /* I18N: A configuration setting */ I18N::translate('Show source detail toggles in facts and events tables') ?>
</label>
<div class="hidden-xs">
<span class="badge visitors"><?= I18N::translate('visitors') ?></span>
<span class="badge members"><?= I18N::translate('members') ?></span>
</div>
</div>
<div class="col-sm-8">
<?= view('components/select', ['name' => 'SHOW_SOURCE_DETAIL_TOGGLES', 'selected' => $tree->getPreference('SHOW_SOURCE_DETAIL_TOGGLES'), 'options' => ['0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')]]) ?>
<div class="form-text">
<?= /* I18N: Help text for the “Show source detail toggles in facts and events tables” configuration setting */ I18N::translate('This option will display the arrow toggles to expand source details in facts and events tables for individuals and families. This will override any automatic display of source details.') ?>
</div>
</div>
</div>

<!-- SHOW_SOURCE_TITLES -->
<div class="row mb-3">
<div class="col-form-label col-sm-4">
<label for="SHOW_SOURCE_TITLES">
<?= /* I18N: A configuration setting */ I18N::translate('Show source titles in facts and events tables') ?>
</label>
<div class="hidden-xs">
<span class="badge visitors"><?= I18N::translate('visitors') ?></span>
<span class="badge members"><?= I18N::translate('members') ?></span>
</div>
</div>
<div class="col-sm-8">
<?= view('components/select', ['name' => 'SHOW_SOURCE_TITLES', 'selected' => $tree->getPreference('SHOW_SOURCE_TITLES'), 'options' => ['0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')]]) ?>
<div class="form-text">
<?= /* I18N: Help text for the “Show source titles in facts and events tables” configuration setting */ I18N::translate('This option will display the source titles in facts and events tables for individuals and families. If not allowed, no source details will be available, and the source title will be replaced with PRIVATE.') ?>
</div>
</div>
</div>

<h2><?= /* I18N: Privacy restrictions are set by RESN tags in GEDCOM. */ I18N::translate('Privacy restrictions') ?></h2>
<p>
<?= /* 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.') ?>
Expand Down Expand Up @@ -344,7 +383,9 @@ use Fisharebest\Webtrees\View;
var hideLivePeople = parseInt($('[name=HIDE_LIVE_PEOPLE]').val(), 10);
var showLivingNames = parseInt($('[name=SHOW_LIVING_NAMES]').val(), 10);
var showPrivateRelationships = parseInt($('[name=SHOW_PRIVATE_RELATIONSHIPS]').val(), 10);

var showSourceDetailToggles = parseInt($('[name=SHOW_SOURCE_DETAIL_TOGGLES]').val(), 10);
var showSourceTitles = parseInt($('[name=SHOW_SOURCE_TITLES]').val(), 10);

setPrivacyFeedback('[name=REQUIRE_AUTHENTICATION]', 'visitors', requireAuthentication === 0);
setPrivacyFeedback('[name=REQUIRE_AUTHENTICATION]', 'members', true);

Expand All @@ -360,11 +401,17 @@ use Fisharebest\Webtrees\View;

setPrivacyFeedback('[name=SHOW_PRIVATE_RELATIONSHIPS]', 'visitors', requireAuthentication === 0 && showPrivateRelationships >= 1);
setPrivacyFeedback('[name=SHOW_PRIVATE_RELATIONSHIPS]', 'members', showPrivateRelationships >= 1);

setPrivacyFeedback('[name=SHOW_SOURCE_DETAIL_TOGGLES]', 'visitors', requireAuthentication === 0 && showSourceDetailToggles === 0);
setPrivacyFeedback('[name=SHOW_SOURCE_DETAIL_TOGGLES]', 'members', true);

setPrivacyFeedback('[name=SHOW_SOURCE_TITLES]', 'visitors', requireAuthentication === 0 && showSourceTitles === 0);
setPrivacyFeedback('[name=SHOW_SOURCE_TITLES]', 'members', true);
}

// Activate the privacy feedback labels.
updatePrivacyFeedback();
$('[name=REQUIRE_AUTHENTICATION], [name=HIDE_LIVE_PEOPLE], [name=SHOW_DEAD_PEOPLE], [name=SHOW_LIVING_NAMES], [name=SHOW_PRIVATE_RELATIONSHIPS]').on('change', function () {
$('[name=REQUIRE_AUTHENTICATION], [name=HIDE_LIVE_PEOPLE], [name=SHOW_DEAD_PEOPLE], [name=SHOW_LIVING_NAMES], [name=SHOW_PRIVATE_RELATIONSHIPS], [name=SHOW_SOURCE_DETAIL_TOGGLES], [name=SHOW_SOURCE_TITLES]').on('change', function () {
updatePrivacyFeedback();
});

Expand Down
21 changes: 15 additions & 6 deletions resources/views/fact-gedcom-fields.phtml
Expand Up @@ -10,6 +10,7 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Source;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\Auth;

/**
* @var string $gedcom
Expand Down Expand Up @@ -58,16 +59,24 @@ foreach ($keys as $key) {
<?php $id = Registry::idFactory()->id() ?>
<?php $expanded = $tree->getPreference('EXPAND_SOURCES') === '1' ?>
<div>
<button type="button" class="btn btn-text p-0" href="#<?= e($id) ?>" data-bs-toggle="collapse" aria-controls="<?= e($id) ?>" aria-expanded="<?= $expanded ? 'true' : 'false' ?>">
<?= view('icons/expand') ?>
<?= view('icons/collapse') ?>
</button>
<?php if (Auth::isMember($tree) || ($tree->getPreference('SHOW_SOURCE_DETAIL_TOGGLES') === '0' && $tree->getPreference('SHOW_SOURCE_TITLES') === '0')) : ?>
<button type="button" class="btn btn-text p-0" href="#<?= e($id) ?>" data-bs-toggle="collapse" aria-controls="<?= e($id) ?>" aria-expanded="<?= $expanded ? 'true' : 'false' ?>">
<?= view('icons/expand') ?>
<?= view('icons/collapse') ?>
</button>
<?php else: ?>
<?php $expanded = '' ?>
<?php endif ?>

<?php $label = '<span class="label">' . I18N::translate('Source') . '</span>' ?>
<?php $value = '<span class="field" dir="auto"><a href="' . e($source->url()) . '">' . $source->fullName() . '</a></span>' ?>
<?php if (Auth::isMember($tree) || $tree->getPreference('SHOW_SOURCE_TITLES') === '0') : ?>
<?php $value = '<span class="field" dir="auto"><a href="' . e($source->url()) . '">' . $source->fullName() . '</a></span>' ?>
<?php else: ?>
<?php $value = '<span class="field" dir="auto">' . I18N::translate('PRIVATE') . '</span>' ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use I18N::translate('Private') instead of I18N::translate('PRIVATE') the existing translations to other langguages will be successful ;-)

<?php $expanded = '' ?>
<?php endif ?>
<?= I18N::translate('%1$s: %2$s', $label, $value) ?>
</div>

<div id="<?= e($id) ?>" class="ps-4 collapse <?= $expanded ? 'show' : '' ?>">
<?php array_shift($keys) ?>
<?php foreach ($keys as $key) : ?>
Expand Down