xref: /webtrees/app/Module/RelativesTabModule.php (revision 342dcecd8628deacd49d86f3247fd77e64bf33c3)
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 */
16namespace Fisharebest\Webtrees\Module;
17
18use Fisharebest\Webtrees\Auth;
19use Fisharebest\Webtrees\I18N;
20use Fisharebest\Webtrees\Individual;
21
22/**
23 * Class RelativesTabModule
24 */
25class RelativesTabModule extends AbstractModule implements ModuleTabInterface
26{
27    /**
28     * How should this module be labelled on tabs, menus, etc.?
29     *
30     * @return string
31     */
32    public function getTitle()
33    {
34        /* I18N: Name of a module */
35        return I18N::translate('Families');
36    }
37
38    /**
39     * A sentence describing what this module does.
40     *
41     * @return string
42     */
43    public function getDescription()
44    {
45        /* I18N: Description of the “Families” module */
46        return I18N::translate('A tab showing the close relatives of an individual.');
47    }
48
49    /**
50     * The user can re-arrange the tab order, but until they do, this
51     * is the order in which tabs are shown.
52     *
53     * @return int
54     */
55    public function defaultTabOrder()
56    {
57        return 20;
58    }
59
60    /** {@inheritdoc} */
61    public function getTabContent(Individual $individual)
62    {
63        $tree = $individual->getTree();
64        if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
65            $fam_access_level = Auth::PRIV_HIDE;
66        } else {
67            $fam_access_level = Auth::accessLevel($tree);
68        }
69
70        return view('modules/relatives/tab', [
71            'fam_access_level'     => $fam_access_level,
72            'can_edit'             => $individual->canEdit(),
73            'individual'           => $individual,
74            'parent_families'      => $individual->getChildFamilies(),
75            'spouse_families'      => $individual->getSpouseFamilies(),
76            'step_child_familiess' => $individual->getSpouseStepFamilies(),
77            'step_parent_families' => $individual->getChildStepFamilies(),
78        ]);
79    }
80
81    /** {@inheritdoc} */
82    public function hasTabContent(Individual $individual)
83    {
84        return true;
85    }
86
87    /** {@inheritdoc} */
88    public function isGrayedOut(Individual $individual)
89    {
90        return false;
91    }
92
93    /** {@inheritdoc} */
94    public function canLoadAjax()
95    {
96        return false;
97    }
98}
99