xref: /webtrees/app/Module/RelativesTabModule.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
18c2e8227SGreg Roach<?php
28c2e8227SGreg Roach/**
38c2e8227SGreg Roach * webtrees: online genealogy
4*8fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
88c2e8227SGreg Roach * (at your option) any later version.
98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128c2e8227SGreg Roach * GNU General Public License for more details.
138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158c2e8227SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
1976692c8bSGreg Roach
200e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth;
210e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
220e62c4b8SGreg Roachuse Fisharebest\Webtrees\Individual;
238c2e8227SGreg Roach
248c2e8227SGreg Roach/**
258c2e8227SGreg Roach * Class RelativesTabModule
268c2e8227SGreg Roach */
27c1010edaSGreg Roachclass RelativesTabModule extends AbstractModule implements ModuleTabInterface
28c1010edaSGreg Roach{
2976692c8bSGreg Roach    /**
3076692c8bSGreg Roach     * How should this module be labelled on tabs, menus, etc.?
3176692c8bSGreg Roach     *
3276692c8bSGreg Roach     * @return string
3376692c8bSGreg Roach     */
348f53f488SRico Sonntag    public function getTitle(): string
35c1010edaSGreg Roach    {
36bbb76c12SGreg Roach        /* I18N: Name of a module */
37bbb76c12SGreg Roach        return I18N::translate('Families');
388c2e8227SGreg Roach    }
398c2e8227SGreg Roach
4076692c8bSGreg Roach    /**
4176692c8bSGreg Roach     * A sentence describing what this module does.
4276692c8bSGreg Roach     *
4376692c8bSGreg Roach     * @return string
4476692c8bSGreg Roach     */
458f53f488SRico Sonntag    public function getDescription(): string
46c1010edaSGreg Roach    {
47bbb76c12SGreg Roach        /* I18N: Description of the “Families” module */
48bbb76c12SGreg Roach        return I18N::translate('A tab showing the close relatives of an individual.');
498c2e8227SGreg Roach    }
508c2e8227SGreg Roach
5176692c8bSGreg Roach    /**
5276692c8bSGreg Roach     * The user can re-arrange the tab order, but until they do, this
5376692c8bSGreg Roach     * is the order in which tabs are shown.
5476692c8bSGreg Roach     *
5576692c8bSGreg Roach     * @return int
5676692c8bSGreg Roach     */
578f53f488SRico Sonntag    public function defaultTabOrder(): int
58c1010edaSGreg Roach    {
598c2e8227SGreg Roach        return 20;
608c2e8227SGreg Roach    }
618c2e8227SGreg Roach
62225e381fSGreg Roach    /** {@inheritdoc} */
639b34404bSGreg Roach    public function getTabContent(Individual $individual): string
64c1010edaSGreg Roach    {
65f4afa648SGreg Roach        $tree = $individual->tree();
66225e381fSGreg Roach        if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
67225e381fSGreg Roach            $fam_access_level = Auth::PRIV_HIDE;
688c2e8227SGreg Roach        } else {
69225e381fSGreg Roach            $fam_access_level = Auth::accessLevel($tree);
708c2e8227SGreg Roach        }
718c2e8227SGreg Roach
72a8cd57e1SGreg Roach        return view('modules/relatives/tab', [
73225e381fSGreg Roach            'fam_access_level'     => $fam_access_level,
74225e381fSGreg Roach            'can_edit'             => $individual->canEdit(),
75225e381fSGreg Roach            'individual'           => $individual,
76225e381fSGreg Roach            'parent_families'      => $individual->getChildFamilies(),
77225e381fSGreg Roach            'spouse_families'      => $individual->getSpouseFamilies(),
78225e381fSGreg Roach            'step_child_familiess' => $individual->getSpouseStepFamilies(),
79225e381fSGreg Roach            'step_parent_families' => $individual->getChildStepFamilies(),
80225e381fSGreg Roach        ]);
818c2e8227SGreg Roach    }
828c2e8227SGreg Roach
838c2e8227SGreg Roach    /** {@inheritdoc} */
848f53f488SRico Sonntag    public function hasTabContent(Individual $individual): bool
85c1010edaSGreg Roach    {
868c2e8227SGreg Roach        return true;
878c2e8227SGreg Roach    }
88c1010edaSGreg Roach
898c2e8227SGreg Roach    /** {@inheritdoc} */
908f53f488SRico Sonntag    public function isGrayedOut(Individual $individual): bool
91c1010edaSGreg Roach    {
928c2e8227SGreg Roach        return false;
938c2e8227SGreg Roach    }
94c1010edaSGreg Roach
958c2e8227SGreg Roach    /** {@inheritdoc} */
968f53f488SRico Sonntag    public function canLoadAjax(): bool
97c1010edaSGreg Roach    {
9815d603e7SGreg Roach        return false;
998c2e8227SGreg Roach    }
1008c2e8227SGreg Roach}
101