105b09c4c5
Replaces the previous "depth in generations along the strict lineal chain" definition (which excluded siblings, aunts, cousins entirely) with the metric the user actually wants: the number of descent-steps separating the target from the recipient's closest direct ancestor or descendant. Examples relative to the recipient: - sibling: 1 (parent → sibling) - great-aunt: 1 (great-grandparent → great-aunt) - nephew: 2 (parent → sibling → nephew) - first cousin: 2 (grandparent → aunt → cousin) - second cousin: 3 - ego, parents, grandparents, ..., children, ..., great-greats: 0 - own spouse, step-parents, brothers-in-law: inherit partner's distance (so spouse-of-distance-1 is also distance 1) Implementation: - Anchor set seeded with R's direct ancestors + R + direct descendants (capped at 25 generations to bound runaway data). - Multi-source BFS expanding by descent only. - Spouse propagation at every level so a person and their spouse always share the same distance. - Memoised per (recipient xref, max distance). Tree preference key and range kept (NEWSLETTER_LINEAL_DEPTH, 0–10, default 3); only the semantics and the user-facing label + help text change, with concrete examples in both English and German.
213 lines
10 KiB
PHTML
213 lines
10 KiB
PHTML
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use EmailNewsletter\Configuration;
|
|
use EmailNewsletter\Module;
|
|
use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
|
|
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllPage;
|
|
use Fisharebest\Webtrees\I18N;
|
|
use Fisharebest\Webtrees\Tree;
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* @var Module $module
|
|
* @var Collection<int,Tree> $all_trees
|
|
* @var string $cron_token
|
|
* @var string $cron_url
|
|
* @var string $title
|
|
*/
|
|
|
|
?>
|
|
|
|
<?= view('components/breadcrumbs', [
|
|
'links' => [
|
|
route(ControlPanel::class) => I18N::translate('Control panel'),
|
|
route(ModulesAllPage::class) => I18N::translate('Modules'),
|
|
$title,
|
|
],
|
|
]) ?>
|
|
|
|
<h1><?= e($title) ?></h1>
|
|
|
|
<p>
|
|
<?= I18N::translate('Configure newsletter dispatch on a per-tree basis. The sender is the contact user of each tree (falling back to the site webmaster).') ?>
|
|
</p>
|
|
|
|
<form method="post">
|
|
<?= csrf_field() ?>
|
|
|
|
<?php foreach ($all_trees as $tree) : ?>
|
|
<?php
|
|
$id = $tree->id();
|
|
$enabled = Configuration::isEnabled($tree);
|
|
$frequency = Configuration::frequencyDays($tree);
|
|
$lookahead = Configuration::lookaheadDays($tree);
|
|
$histLook = Configuration::historicalLookaheadDays($tree);
|
|
$annivs = Configuration::includeAnniversaries($tree);
|
|
$subject = Configuration::subjectPrefix($tree);
|
|
$extras = $tree->getPreference(Configuration::PREF_EXTRA_RECIPIENTS, '');
|
|
$lineal = Configuration::linealDepth($tree);
|
|
$last_sent = Configuration::lastSentAt($tree);
|
|
?>
|
|
|
|
<fieldset class="card mb-4">
|
|
<legend class="card-header h4"><?= e($tree->title()) ?></legend>
|
|
|
|
<div class="card-body">
|
|
<div class="row mb-3">
|
|
<div class="offset-sm-3 col-sm-9">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox"
|
|
id="enabled-<?= $id ?>" name="enabled-<?= $id ?>"
|
|
value="1" <?= $enabled ? 'checked' : '' ?>>
|
|
<label class="form-check-label" for="enabled-<?= $id ?>">
|
|
<?= I18N::translate('Enable newsletter for this tree') ?>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-sm-3 col-form-label" for="frequency-<?= $id ?>">
|
|
<?= I18N::translate('Send newsletters every') ?>
|
|
</label>
|
|
<div class="col-sm-9">
|
|
<div class="input-group" style="max-width: 18rem;">
|
|
<input class="form-control" type="number"
|
|
id="frequency-<?= $id ?>" name="frequency-<?= $id ?>"
|
|
value="<?= e((string) $frequency) ?>"
|
|
min="<?= Configuration::MIN_FREQUENCY_DAYS ?>"
|
|
max="<?= Configuration::MAX_FREQUENCY_DAYS ?>" required>
|
|
<span class="input-group-text"><?= I18N::translate('days') ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-sm-3 col-form-label" for="lookahead-<?= $id ?>">
|
|
<?= I18N::translate('Look ahead') ?>
|
|
</label>
|
|
<div class="col-sm-9">
|
|
<div class="input-group" style="max-width: 18rem;">
|
|
<input class="form-control" type="number"
|
|
id="lookahead-<?= $id ?>" name="lookahead-<?= $id ?>"
|
|
value="<?= e((string) $lookahead) ?>"
|
|
min="<?= Configuration::MIN_LOOKAHEAD_DAYS ?>"
|
|
max="<?= Configuration::MAX_LOOKAHEAD_DAYS ?>" required>
|
|
<span class="input-group-text"><?= I18N::translate('days') ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<div class="offset-sm-3 col-sm-9">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox"
|
|
id="anniversaries-<?= $id ?>" name="anniversaries-<?= $id ?>"
|
|
value="1" <?= $annivs ? 'checked' : '' ?>>
|
|
<label class="form-check-label" for="anniversaries-<?= $id ?>">
|
|
<?= I18N::translate('Include marriage anniversaries') ?>
|
|
</label>
|
|
</div>
|
|
<small class="form-text text-muted">
|
|
<?= I18N::translate('Only intact marriages of still-living couples are included.') ?>
|
|
</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-sm-3 col-form-label" for="historical-<?= $id ?>">
|
|
<?= I18N::translate('Historical look-ahead (days)') ?>
|
|
</label>
|
|
<div class="col-sm-9">
|
|
<input class="form-control" type="number" style="max-width: 18rem;"
|
|
id="historical-<?= $id ?>" name="historical-<?= $id ?>"
|
|
value="<?= e((string) $histLook) ?>" min="7" max="60" required>
|
|
<small class="form-text text-muted">
|
|
<?= I18N::translate('Births and deaths of deceased people are included once per calendar month.') ?>
|
|
</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-sm-3 col-form-label" for="lineal-<?= $id ?>">
|
|
<?= I18N::translate('Detailed view distance') ?>
|
|
</label>
|
|
<div class="col-sm-9">
|
|
<input class="form-control" type="number" style="max-width: 18rem;"
|
|
id="lineal-<?= $id ?>" name="lineal-<?= $id ?>"
|
|
value="<?= e((string) $lineal) ?>"
|
|
min="<?= Configuration::MIN_LINEAL_DEPTH ?>"
|
|
max="<?= Configuration::MAX_LINEAL_DEPTH ?>" required>
|
|
<small class="form-text text-muted">
|
|
<?= I18N::translate('A person is shown in detail (avatar, icon, timeline) when they sit within this many descent-steps of the recipient\'s direct lineage. Examples relative to the recipient: a sibling is distance 1 (one step down from the recipient\'s parent), a great-aunt is distance 1 (one step down from a great-grandparent), a nephew is distance 2, a first cousin is distance 2. Spouses share their partner\'s distance. Everyone outside this radius appears as a compact text bullet at the bottom of each section. Set to 0 to render the whole newsletter as text; recipients with no linked tree record always see the full detailed view.') ?>
|
|
</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-sm-3 col-form-label" for="subject-<?= $id ?>">
|
|
<?= I18N::translate('Subject prefix') ?>
|
|
</label>
|
|
<div class="col-sm-9">
|
|
<input class="form-control" type="text"
|
|
id="subject-<?= $id ?>" name="subject-<?= $id ?>"
|
|
value="<?= e($subject) ?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-sm-3 col-form-label" for="extras-<?= $id ?>">
|
|
<?= I18N::translate('Extra recipient email addresses (one per line)') ?>
|
|
</label>
|
|
<div class="col-sm-9">
|
|
<textarea class="form-control" rows="4"
|
|
id="extras-<?= $id ?>" name="extras-<?= $id ?>"><?= e($extras) ?></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($last_sent > 0) : ?>
|
|
<div class="row mb-3">
|
|
<div class="offset-sm-3 col-sm-9">
|
|
<small class="text-muted">
|
|
<?= I18N::translate('Last sent: %s', date('Y-m-d H:i', $last_sent)) ?>
|
|
</small>
|
|
</div>
|
|
</div>
|
|
<?php endif ?>
|
|
</div>
|
|
</fieldset>
|
|
<?php endforeach ?>
|
|
|
|
<fieldset class="card mb-4">
|
|
<legend class="card-header h4"><?= I18N::translate('Cron token') ?></legend>
|
|
<div class="card-body">
|
|
<p>
|
|
<?= I18N::translate('Configure your system cron, systemd timer, or any external scheduler to call the URL below. The schedule decides when newsletters are actually due — calling more frequently is safe.') ?>
|
|
</p>
|
|
<pre class="bg-light p-2"><?= e($cron_url) ?></pre>
|
|
<div class="form-check mb-2">
|
|
<input class="form-check-input" type="checkbox" id="regenerate_token"
|
|
name="regenerate_token" value="1">
|
|
<label class="form-check-label" for="regenerate_token">
|
|
<?= I18N::translate('Regenerate token') ?>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<button type="submit" class="btn btn-primary">
|
|
<?= view('icons/save') ?>
|
|
<?= I18N::translate('Save') ?>
|
|
</button>
|
|
</form>
|
|
|
|
<form method="post" action="<?= e(route('module', ['module' => $module->name(), 'action' => 'SendNowAdmin'])) ?>" class="mt-3">
|
|
<?= csrf_field() ?>
|
|
<button type="submit" class="btn btn-secondary"
|
|
onclick="return confirm('<?= e(I18N::translate('Send the newsletter now for every enabled tree?')) ?>');">
|
|
<?= I18N::translate('Send now') ?>
|
|
</button>
|
|
</form>
|