xref: /webtrees/app/Module/RelativesTabModule.php (revision cbf4b7fa194b4e336add2747abfccb05fbb0f4da)
18c2e8227SGreg Roach<?php
28c2e8227SGreg Roach/**
38c2e8227SGreg Roach * webtrees: online genealogy
48fcd0d32SGreg 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 */
2749a243cbSGreg Roachclass RelativesTabModule extends AbstractModule implements ModuleInterface, ModuleTabInterface
28c1010edaSGreg Roach{
2949a243cbSGreg Roach    use ModuleTabTrait;
3049a243cbSGreg Roach
3176692c8bSGreg Roach    /**
3276692c8bSGreg Roach     * How should this module be labelled on tabs, menus, etc.?
3376692c8bSGreg Roach     *
3476692c8bSGreg Roach     * @return string
3576692c8bSGreg Roach     */
3649a243cbSGreg Roach    public function title(): string
37c1010edaSGreg Roach    {
38bbb76c12SGreg Roach        /* I18N: Name of a module */
39bbb76c12SGreg Roach        return I18N::translate('Families');
408c2e8227SGreg Roach    }
418c2e8227SGreg Roach
4276692c8bSGreg Roach    /**
4376692c8bSGreg Roach     * A sentence describing what this module does.
4476692c8bSGreg Roach     *
4576692c8bSGreg Roach     * @return string
4676692c8bSGreg Roach     */
4749a243cbSGreg Roach    public function description(): string
48c1010edaSGreg Roach    {
49bbb76c12SGreg Roach        /* I18N: Description of the “Families” module */
50bbb76c12SGreg Roach        return I18N::translate('A tab showing the close relatives of an individual.');
518c2e8227SGreg Roach    }
528c2e8227SGreg Roach
5376692c8bSGreg Roach    /**
5449a243cbSGreg Roach     * The default position for this tab.  It can be changed in the control panel.
5576692c8bSGreg Roach     *
5676692c8bSGreg Roach     * @return int
5776692c8bSGreg Roach     */
58*cbf4b7faSGreg Roach    public function defaultTabOrder(): int
59*cbf4b7faSGreg Roach    {
6049a243cbSGreg Roach        return 30;
618c2e8227SGreg Roach    }
628c2e8227SGreg Roach
63225e381fSGreg Roach    /** {@inheritdoc} */
649b34404bSGreg Roach    public function getTabContent(Individual $individual): string
65c1010edaSGreg Roach    {
66f4afa648SGreg Roach        $tree = $individual->tree();
67225e381fSGreg Roach        if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
68225e381fSGreg Roach            $fam_access_level = Auth::PRIV_HIDE;
698c2e8227SGreg Roach        } else {
70225e381fSGreg Roach            $fam_access_level = Auth::accessLevel($tree);
718c2e8227SGreg Roach        }
728c2e8227SGreg Roach
73a8cd57e1SGreg Roach        return view('modules/relatives/tab', [
74225e381fSGreg Roach            'fam_access_level'     => $fam_access_level,
75225e381fSGreg Roach            'can_edit'             => $individual->canEdit(),
76225e381fSGreg Roach            'individual'           => $individual,
77225e381fSGreg Roach            'parent_families'      => $individual->getChildFamilies(),
78225e381fSGreg Roach            'spouse_families'      => $individual->getSpouseFamilies(),
79225e381fSGreg Roach            'step_child_familiess' => $individual->getSpouseStepFamilies(),
80225e381fSGreg Roach            'step_parent_families' => $individual->getChildStepFamilies(),
81225e381fSGreg Roach        ]);
828c2e8227SGreg Roach    }
838c2e8227SGreg Roach
848c2e8227SGreg Roach    /** {@inheritdoc} */
858f53f488SRico Sonntag    public function hasTabContent(Individual $individual): bool
86c1010edaSGreg Roach    {
878c2e8227SGreg Roach        return true;
888c2e8227SGreg Roach    }
89c1010edaSGreg Roach
908c2e8227SGreg Roach    /** {@inheritdoc} */
918f53f488SRico Sonntag    public function isGrayedOut(Individual $individual): bool
92c1010edaSGreg Roach    {
938c2e8227SGreg Roach        return false;
948c2e8227SGreg Roach    }
95c1010edaSGreg Roach
968c2e8227SGreg Roach    /** {@inheritdoc} */
978f53f488SRico Sonntag    public function canLoadAjax(): bool
98c1010edaSGreg Roach    {
9915d603e7SGreg Roach        return false;
1008c2e8227SGreg Roach    }
1018c2e8227SGreg Roach}
102