diff options
| -rw-r--r-- | library/WT/Family.php | 14 | ||||
| -rwxr-xr-x | library/WT/GedcomRecord.php | 6 | ||||
| -rw-r--r-- | library/WT/Individual.php | 16 |
3 files changed, 13 insertions, 23 deletions
diff --git a/library/WT/Family.php b/library/WT/Family.php index c4bb3d1b05..f92b4080e5 100644 --- a/library/WT/Family.php +++ b/library/WT/Family.php @@ -139,19 +139,15 @@ class WT_Family extends WT_GedcomRecord { return $spouses; } - /** - * get the children - * @return array array of children Persons - */ + // Get a list of this family’s children function getChildren($access_level=WT_USER_ACCESS_LEVEL) { global $SHOW_PRIVATE_RELATIONSHIPS; - $children=array(); - preg_match_all('/\n1 CHIL @('.WT_REGEX_XREF.')@/', $this->gedcom, $match); - foreach ($match[1] as $pid) { - $child=WT_Individual::getInstance($pid); + $children = array(); + foreach ($this->getFacts('CHIL', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { + $child = $fact->getTarget(); if ($child && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) { - $children[]=$child; + $children[] = $child; } } return $children; diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php index b7e4c53b25..2e605fc10b 100755 --- a/library/WT/GedcomRecord.php +++ b/library/WT/GedcomRecord.php @@ -788,9 +788,11 @@ class WT_GedcomRecord { } // The facts and events for this record - public function getFacts($filter=null, $sort=false, $access_level=WT_USER_ACCESS_LEVEL) { + // $override allows us to implement $SHOW_PRIVATE_RELATIONSHIPS and $SHOW_LIVING_NAMES, by giving + // access to otherwise private records. + public function getFacts($filter=null, $sort=false, $access_level=WT_USER_ACCESS_LEVEL, $override=false) { $facts=array(); - if ($this->canShow($access_level)) { + if ($this->canShow($access_level) || $override) { foreach ($this->facts as $fact) { if (($filter==null || preg_match('/^' . $filter . '$/', $fact->getTag())) && $fact->canShow($access_level)) { $facts[] = $fact; diff --git a/library/WT/Individual.php b/library/WT/Individual.php index 62e8a183b5..8887f4022f 100644 --- a/library/WT/Individual.php +++ b/library/WT/Individual.php @@ -596,7 +596,7 @@ class WT_Individual extends WT_GedcomRecord { global $SHOW_PRIVATE_RELATIONSHIPS; $families = array(); - foreach ($this->getFacts('FAMS', false, $access_level) as $fact) { + foreach ($this->getFacts('FAMS', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { $family = $fact->getTarget(); if ($family && ($SHOW_PRIVATE_RELATIONSHIPS || $family->canShow($access_level))) { $families[] = $family; @@ -638,7 +638,7 @@ class WT_Individual extends WT_GedcomRecord { global $SHOW_PRIVATE_RELATIONSHIPS; $families = array(); - foreach ($this->getFacts('FAMC', false, $access_level) as $fact) { + foreach ($this->getFacts('FAMC', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { $family = $fact->getTarget(); if ($family && ($SHOW_PRIVATE_RELATIONSHIPS || $family->canShow($access_level))) { $families[] = $family; @@ -1017,18 +1017,10 @@ class WT_Individual extends WT_GedcomRecord { // Get an array of structures containing all the names in the record public function extractNames() { - // Cannot use ->getFacts('NAME'), as we need to bypass some of the privacy using $SHOW_LIVING_NAMES / canShowName() - if ($this->canShowName()) { - $facts = array(); - foreach ($this->facts as $fact) { - if ($fact->getTag() == 'NAME' && $fact->canShow()) { - $facts[] = $fact; - } - } - $this->_extractNames(1, 'NAME', $facts); - } + $this->_extractNames(1, 'NAME', $this->getFacts('NAME', false, WT_USER_ACCESS_LEVEL, $this->canShowName())); } + // Extra info to display when displaying this record in a list of // selection items or favorites. function format_list_details() { |
