18c2e8227SGreg Roach<?php 23976b470SGreg Roach 38c2e8227SGreg Roach/** 48c2e8227SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 68c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 78c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 88c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 98c2e8227SGreg Roach * (at your option) any later version. 108c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 118c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138c2e8227SGreg Roach * GNU General Public License for more details. 148c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 168c2e8227SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module; 2176692c8bSGreg Roach 220e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth; 230e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 240e62c4b8SGreg Roachuse Fisharebest\Webtrees\Individual; 258eaf8709SGreg Roachuse Illuminate\Support\Collection; 268c2e8227SGreg Roach 278c2e8227SGreg Roach/** 288c2e8227SGreg Roach * Class RelativesTabModule 298c2e8227SGreg Roach */ 3037eb8894SGreg Roachclass RelativesTabModule extends AbstractModule implements ModuleTabInterface 31c1010edaSGreg Roach{ 3249a243cbSGreg Roach use ModuleTabTrait; 3349a243cbSGreg Roach 3476692c8bSGreg Roach /** 350cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 3676692c8bSGreg Roach * 3776692c8bSGreg Roach * @return string 3876692c8bSGreg Roach */ 3949a243cbSGreg Roach public function title(): string 40c1010edaSGreg Roach { 41bbb76c12SGreg Roach /* I18N: Name of a module */ 42bbb76c12SGreg Roach return I18N::translate('Families'); 438c2e8227SGreg Roach } 448c2e8227SGreg Roach 4549a243cbSGreg Roach public function description(): 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 /** 5249a243cbSGreg Roach * The default position for this tab. It can be changed in the control panel. 5376692c8bSGreg Roach * 5476692c8bSGreg Roach * @return int 5576692c8bSGreg Roach */ 56cbf4b7faSGreg Roach public function defaultTabOrder(): int 57cbf4b7faSGreg Roach { 58fb7a0427SGreg Roach return 2; 598c2e8227SGreg Roach } 608c2e8227SGreg Roach 613caaa4d2SGreg Roach /** 623caaa4d2SGreg Roach * Generate the HTML content of this tab. 633caaa4d2SGreg Roach * 643caaa4d2SGreg Roach * @param Individual $individual 653caaa4d2SGreg Roach * 663caaa4d2SGreg Roach * @return string 673caaa4d2SGreg Roach */ 689b34404bSGreg Roach public function getTabContent(Individual $individual): string 69c1010edaSGreg Roach { 70f4afa648SGreg Roach $tree = $individual->tree(); 71d9e083e7SGreg Roach if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS') === '1') { 72225e381fSGreg Roach $fam_access_level = Auth::PRIV_HIDE; 738c2e8227SGreg Roach } else { 74225e381fSGreg Roach $fam_access_level = Auth::accessLevel($tree); 758c2e8227SGreg Roach } 768c2e8227SGreg Roach 77a8cd57e1SGreg Roach return view('modules/relatives/tab', [ 78225e381fSGreg Roach 'fam_access_level' => $fam_access_level, 79225e381fSGreg Roach 'can_edit' => $individual->canEdit(), 80225e381fSGreg Roach 'individual' => $individual, 8139ca88baSGreg Roach 'parent_families' => $individual->childFamilies(), 8239ca88baSGreg Roach 'spouse_families' => $individual->spouseFamilies(), 83fceda430SGreg Roach 'step_child_families' => $individual->spouseStepFamilies(), 8439ca88baSGreg Roach 'step_parent_families' => $individual->childStepFamilies(), 85225e381fSGreg Roach ]); 868c2e8227SGreg Roach } 878c2e8227SGreg Roach 883caaa4d2SGreg Roach /** 893caaa4d2SGreg Roach * Is this tab empty? If so, we don't always need to display it. 903caaa4d2SGreg Roach * 913caaa4d2SGreg Roach * @param Individual $individual 923caaa4d2SGreg Roach * 933caaa4d2SGreg Roach * @return bool 943caaa4d2SGreg Roach */ 958f53f488SRico Sonntag public function hasTabContent(Individual $individual): bool 96c1010edaSGreg Roach { 9776092b6cSGreg Roach return $individual->canEdit() || $individual->facts(['FAMC', 'FAMS'], false, null, true)->isNotEmpty(); 988c2e8227SGreg Roach } 99c1010edaSGreg Roach 1003caaa4d2SGreg Roach /** 1013caaa4d2SGreg Roach * A greyed out tab has no actual content, but may perhaps have 1023caaa4d2SGreg Roach * options to create content. 1033caaa4d2SGreg Roach * 1043caaa4d2SGreg Roach * @param Individual $individual 1053caaa4d2SGreg Roach * 1063caaa4d2SGreg Roach * @return bool 1073caaa4d2SGreg Roach */ 1088f53f488SRico Sonntag public function isGrayedOut(Individual $individual): bool 109c1010edaSGreg Roach { 1108c2e8227SGreg Roach return false; 1118c2e8227SGreg Roach } 112c1010edaSGreg Roach 1133caaa4d2SGreg Roach /** 1143caaa4d2SGreg Roach * Can this tab load asynchronously? 1153caaa4d2SGreg Roach * 1163caaa4d2SGreg Roach * @return bool 1173caaa4d2SGreg Roach */ 1188f53f488SRico Sonntag public function canLoadAjax(): bool 119c1010edaSGreg Roach { 12015d603e7SGreg Roach return false; 1218c2e8227SGreg Roach } 1228eaf8709SGreg Roach 1238eaf8709SGreg Roach /** 1248eaf8709SGreg Roach * This module handles the following facts - so don't show them on the "Facts and events" tab. 1258eaf8709SGreg Roach * 12636779af1SGreg Roach * @return Collection<int,string> 1278eaf8709SGreg Roach */ 1288eaf8709SGreg Roach public function supportedFacts(): Collection 1298eaf8709SGreg Roach { 130d0889c63SGreg Roach return new Collection(['INDI:FAMC', 'INDI:FAMS', 'FAM:HUSB', 'FAM:WIFE', 'FAM:CHIL']); 1318eaf8709SGreg Roach } 1328c2e8227SGreg Roach} 133