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