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; 238eaf8709SGreg Roachuse Illuminate\Support\Collection; 248c2e8227SGreg Roach 258c2e8227SGreg Roach/** 268c2e8227SGreg Roach * Class RelativesTabModule 278c2e8227SGreg Roach */ 2837eb8894SGreg Roachclass RelativesTabModule extends AbstractModule implements ModuleTabInterface 29c1010edaSGreg Roach{ 3049a243cbSGreg Roach use ModuleTabTrait; 3149a243cbSGreg Roach 3276692c8bSGreg Roach /** 330cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 3476692c8bSGreg Roach * 3576692c8bSGreg Roach * @return string 3676692c8bSGreg Roach */ 3749a243cbSGreg Roach public function title(): string 38c1010edaSGreg Roach { 39bbb76c12SGreg Roach /* I18N: Name of a module */ 40bbb76c12SGreg Roach return I18N::translate('Families'); 418c2e8227SGreg Roach } 428c2e8227SGreg Roach 4376692c8bSGreg Roach /** 4476692c8bSGreg Roach * A sentence describing what this module does. 4576692c8bSGreg Roach * 4676692c8bSGreg Roach * @return string 4776692c8bSGreg Roach */ 4849a243cbSGreg Roach public function description(): string 49c1010edaSGreg Roach { 50bbb76c12SGreg Roach /* I18N: Description of the “Families” module */ 51bbb76c12SGreg Roach return I18N::translate('A tab showing the close relatives of an individual.'); 528c2e8227SGreg Roach } 538c2e8227SGreg Roach 5476692c8bSGreg Roach /** 5549a243cbSGreg Roach * The default position for this tab. It can be changed in the control panel. 5676692c8bSGreg Roach * 5776692c8bSGreg Roach * @return int 5876692c8bSGreg Roach */ 59cbf4b7faSGreg Roach public function defaultTabOrder(): int 60cbf4b7faSGreg Roach { 61fb7a0427SGreg Roach return 2; 628c2e8227SGreg Roach } 638c2e8227SGreg Roach 64225e381fSGreg Roach /** {@inheritdoc} */ 659b34404bSGreg Roach public function getTabContent(Individual $individual): string 66c1010edaSGreg Roach { 67f4afa648SGreg Roach $tree = $individual->tree(); 68225e381fSGreg Roach if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) { 69225e381fSGreg Roach $fam_access_level = Auth::PRIV_HIDE; 708c2e8227SGreg Roach } else { 71225e381fSGreg Roach $fam_access_level = Auth::accessLevel($tree); 728c2e8227SGreg Roach } 738c2e8227SGreg Roach 74a8cd57e1SGreg Roach return view('modules/relatives/tab', [ 75225e381fSGreg Roach 'fam_access_level' => $fam_access_level, 76225e381fSGreg Roach 'can_edit' => $individual->canEdit(), 77225e381fSGreg Roach 'individual' => $individual, 7839ca88baSGreg Roach 'parent_families' => $individual->childFamilies(), 7939ca88baSGreg Roach 'spouse_families' => $individual->spouseFamilies(), 8039ca88baSGreg Roach 'step_child_familiess' => $individual->spouseStepFamilies(), 8139ca88baSGreg Roach 'step_parent_families' => $individual->childStepFamilies(), 82225e381fSGreg Roach ]); 838c2e8227SGreg Roach } 848c2e8227SGreg Roach 858c2e8227SGreg Roach /** {@inheritdoc} */ 868f53f488SRico Sonntag public function hasTabContent(Individual $individual): bool 87c1010edaSGreg Roach { 888c2e8227SGreg Roach return true; 898c2e8227SGreg Roach } 90c1010edaSGreg Roach 918c2e8227SGreg Roach /** {@inheritdoc} */ 928f53f488SRico Sonntag public function isGrayedOut(Individual $individual): bool 93c1010edaSGreg Roach { 948c2e8227SGreg Roach return false; 958c2e8227SGreg Roach } 96c1010edaSGreg Roach 978c2e8227SGreg Roach /** {@inheritdoc} */ 988f53f488SRico Sonntag public function canLoadAjax(): bool 99c1010edaSGreg Roach { 10015d603e7SGreg Roach return false; 1018c2e8227SGreg Roach } 1028eaf8709SGreg Roach 1038eaf8709SGreg Roach /** 1048eaf8709SGreg Roach * This module handles the following facts - so don't show them on the "Facts and events" tab. 1058eaf8709SGreg Roach * 106*54c7f8dfSGreg Roach * @return Collection 107*54c7f8dfSGreg Roach * @return string[] 1088eaf8709SGreg Roach */ 1098eaf8709SGreg Roach public function supportedFacts(): Collection 1108eaf8709SGreg Roach { 1118eaf8709SGreg Roach return new Collection(['FAMC', 'FAMS', 'HUSB', 'WIFE', 'CHIL']); 1128eaf8709SGreg Roach } 1138c2e8227SGreg Roach} 114