xref: /webtrees/app/Module/RelativesTabModule.php (revision 30158ae76837ce51811d3e0fca2ea5852182f42e)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Module;
19
20use Fisharebest\Webtrees\Auth;
21use Fisharebest\Webtrees\I18N;
22use Fisharebest\Webtrees\Individual;
23
24/**
25 * Class RelativesTabModule
26 */
27class RelativesTabModule extends AbstractModule implements ModuleTabInterface
28{
29    /**
30     * How should this module be labelled on tabs, menus, etc.?
31     *
32     * @return string
33     */
34    public function getTitle(): string
35    {
36        /* I18N: Name of a module */
37        return I18N::translate('Families');
38    }
39
40    /**
41     * A sentence describing what this module does.
42     *
43     * @return string
44     */
45    public function getDescription(): string
46    {
47        /* I18N: Description of the “Families” module */
48        return I18N::translate('A tab showing the close relatives of an individual.');
49    }
50
51    /**
52     * The user can re-arrange the tab order, but until they do, this
53     * is the order in which tabs are shown.
54     *
55     * @return int
56     */
57    public function defaultTabOrder(): int
58    {
59        return 20;
60    }
61
62    /** {@inheritdoc} */
63    public function getTabContent(Individual $individual): string
64    {
65        $tree = $individual->tree();
66        if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
67            $fam_access_level = Auth::PRIV_HIDE;
68        } else {
69            $fam_access_level = Auth::accessLevel($tree);
70        }
71
72        return view('modules/relatives/tab', [
73            'fam_access_level'     => $fam_access_level,
74            'can_edit'             => $individual->canEdit(),
75            'individual'           => $individual,
76            'parent_families'      => $individual->getChildFamilies(),
77            'spouse_families'      => $individual->getSpouseFamilies(),
78            'step_child_familiess' => $individual->getSpouseStepFamilies(),
79            'step_parent_families' => $individual->getChildStepFamilies(),
80        ]);
81    }
82
83    /** {@inheritdoc} */
84    public function hasTabContent(Individual $individual): bool
85    {
86        return true;
87    }
88
89    /** {@inheritdoc} */
90    public function isGrayedOut(Individual $individual): bool
91    {
92        return false;
93    }
94
95    /** {@inheritdoc} */
96    public function canLoadAjax(): bool
97    {
98        return false;
99    }
100}
101