forked from hartenthaler/hh_extended_family
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtendedFamilyPersonExists.php
105 lines (97 loc) · 4.08 KB
/
ExtendedFamilyPersonExists.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/*
* webtrees - extended family part
*
* Copyright (C) 2021 Hermann Hartenthaler. All rights reserved.
*
* webtrees: online genealogy / web based family history software
* Copyright (C) 2021 webtrees development team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; If not, see <https://www.gnu.org/licenses/>.
*/
namespace Hartenthaler\Webtrees\Module\ExtendedFamily;
use Fisharebest\Webtrees\Individual;
require_once(__DIR__ . '/src/Factory/ExtendedFamilyPartFactory.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyPart.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Great_grandparents.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Grandparents.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Uncles_and_aunts.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Uncles_and_aunts_bm.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Parents.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Parents_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Co_parents_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Siblings.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Siblings_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Co_siblings_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Partners.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Partner_chains.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Cousins.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Nephews_and_nieces.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Children.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Children_in_law.php');
require_once(__DIR__ . '/src/Factory/ExtendedFamilyParts/Grandchildren.php');
/**
* class ExtendedFamilyPersonExists
* to check in an efficient way if there exists at least one person in one of
* the selected extended family parts of the proband
* (used in the function to decide if the tab has to be grayed out)
*/
class ExtendedFamilyPersonExists extends ExtendedFamily
{
/**
* @var bool $found
*/
public $found;
/**
* constructor for this class
*
* @param Individual $proband the proband for whom the extended family members are searched
* @param object $config configuration parameters for this extended family
*/
public function __construct(Individual $proband, object $config)
{
$this->constructConfig($config);
$this->constructProband($proband);
$this->found = $this->constructCheck();
}
/**
* build extended family parts, but stop as soon as a person is found in one of the extended family parts
* tbd: start with parents, children, siblings, ... this is maybe a bit more efficient
*
* @return bool
*/
private function constructCheck(): bool
{
foreach ($this->config->shownFamilyParts as $efp => $element) {
if ($element->enabled) {
if (ExtendedFamilyPartFactory::create(ucfirst($efp),
$this->proband->indi,
'all')
->getEfpObject()->allCount > 0) {
return true;
}
}
}
return false;
}
/**
* provide value of $found
*
* @return bool
*/
public function found(): bool
{
return $this->found;
}
}