summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
Diffstat (limited to 'library')
-rw-r--r--library/WT/Controller/Ancestry.php7
-rw-r--r--library/WT/Controller/Base.php11
-rw-r--r--library/WT/Controller/Descendancy.php13
-rw-r--r--library/WT/Controller/Hourglass.php7
-rw-r--r--library/WT/Controller/Lifespan.php2
-rw-r--r--library/WT/Controller/Pedigree.php8
-rw-r--r--library/WT/Controller/Timeline.php2
7 files changed, 32 insertions, 18 deletions
diff --git a/library/WT/Controller/Ancestry.php b/library/WT/Controller/Ancestry.php
index df8879bb13..74c6add22b 100644
--- a/library/WT/Controller/Ancestry.php
+++ b/library/WT/Controller/Ancestry.php
@@ -62,9 +62,6 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
$OLD_PGENS = $PEDIGREE_GENERATIONS;
- // Validate form parameters
- $this->rootid = check_rootid($this->rootid);
-
// -- size of the detailed boxes based upon optional width parameter
$Dbwidth=($box_width*$bwidth)/100;
$Dbheight=($box_width*$bheight)/100;
@@ -81,6 +78,10 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
$pbheight = $bheight+14;
$this->ancestry = WT_Person::getInstance($this->rootid);
+ if (!$this->ancestry) {
+ $this->ancestry=$this->getSignificantIndividual();
+ $this->rootid=$this->ancestry->getXref();
+ }
$this->name = $this->ancestry->getFullName();
$this->addname = $this->ancestry->getAddName();
diff --git a/library/WT/Controller/Base.php b/library/WT/Controller/Base.php
index f424d5b549..251135c2d0 100644
--- a/library/WT/Controller/Base.php
+++ b/library/WT/Controller/Base.php
@@ -309,13 +309,18 @@ class WT_Controller_Base {
// Get significant information from this page, to allow other pages such as
// charts and reports to initialise with the same records
public function getSignificantIndividual() {
- global $PEDIGREE_ROOT_ID;
+ static $individual; // Only query the DB once.
- $individual=WT_Person::getInstance(WT_USER_GEDCOM_ID);
- if (!$individual) {
+ if (!$individual && WT_USER_GEDCOM_ID) {
+ $individual=WT_Person::getInstance(WT_USER_GEDCOM_ID);
+ }
+ if (!$individual && WT_USER_ROOT_ID) {
$individual=WT_Person::getInstance(WT_USER_ROOT_ID);
}
if (!$individual) {
+ $individual=WT_Person::getInstance(get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID'));
+ }
+ if (!$individual) {
$individual=WT_Person::getInstance(
WT_DB::prepare(
"SELECT MIN(i_id) FROM `##individuals` WHERE i_file=?"
diff --git a/library/WT/Controller/Descendancy.php b/library/WT/Controller/Descendancy.php
index 6d73b5e050..ecfb8307ad 100644
--- a/library/WT/Controller/Descendancy.php
+++ b/library/WT/Controller/Descendancy.php
@@ -89,12 +89,17 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
$pbheight = $bheight+14;
// Validate form variables
- $this->rootid=check_rootid($this->rootid);
-
- if (strlen($this->name)<30) $this->cellwidth="420";
- else $this->cellwidth=(strlen($this->name)*14);
+ if (strlen($this->name)<30) {
+ $this->cellwidth=420;
+ } else {
+ $this->cellwidth=(strlen($this->name)*14);
+ }
$this->descPerson = WT_Person::getInstance($this->rootid);
+ if (!$this->descPerson) {
+ $this->descPerson=$this->getSignificantIndividual();
+ $this->rootid=$this->descPerson->getXref();
+ }
$this->name=$this->descPerson->getFullName();
$this->setPageTitle(/* I18N: %s is a person's name */ WT_I18N::translate('Descendants of %s', $this->name));
diff --git a/library/WT/Controller/Hourglass.php b/library/WT/Controller/Hourglass.php
index f5ff1a8acd..29a7d90ae8 100644
--- a/library/WT/Controller/Hourglass.php
+++ b/library/WT/Controller/Hourglass.php
@@ -108,9 +108,12 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
$bhalfheight = (int)($bheight / 2);
// Validate parameters
- $this->pid=check_rootid($this->pid);
-
$this->hourPerson = WT_Person::getInstance($this->pid);
+ if (!$this->hourPerson) {
+ $this->hourPerson=$this->getSignificantIndividual();
+ $this->pid=$this->hourPerson->getXref();
+ }
+
$this->name=$this->hourPerson->getFullName();
//Checks how many generations of descendency is for the person for formatting purposes
diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php
index d29afe6020..e9ae4c479f 100644
--- a/library/WT/Controller/Lifespan.php
+++ b/library/WT/Controller/Lifespan.php
@@ -115,7 +115,7 @@ class WT_Controller_Lifespan extends WT_Controller_Chart {
$person=WT_Person::getInstance($newpid);
$this->addFamily($person, $addfam);
} elseif (!$this->pids) {
- $this->addFamily(WT_Person::getInstance(check_rootid("")), false);
+ $this->addFamily($this->getSignificantIndividual(), false);
}
}
$_SESSION['timeline_pids']=$this->pids;
diff --git a/library/WT/Controller/Pedigree.php b/library/WT/Controller/Pedigree.php
index 34269437fb..3cddb105e8 100644
--- a/library/WT/Controller/Pedigree.php
+++ b/library/WT/Controller/Pedigree.php
@@ -83,11 +83,11 @@ class WT_Controller_Pedigree extends WT_Controller_Chart {
$show_full = $this->show_full;
$talloffset = $this->talloffset;
- // Validate parameters
- $this->rootid=check_rootid($this->rootid);
-
$this->rootPerson = WT_Person::getInstance($this->rootid);
- if (is_null($this->rootPerson)) $this->rootPerson = new WT_Person('');
+ if (!$this->rootPerson) {
+ $this->rootPerson=$this->getSignificantIndividual();
+ $this->rootid=$this->rootPerson->getXref();
+ }
$this->name = $this->rootPerson->getFullName();
$this->addname = $this->rootPerson->getAddName();
diff --git a/library/WT/Controller/Timeline.php b/library/WT/Controller/Timeline.php
index 7761a79fac..5fea9933ac 100644
--- a/library/WT/Controller/Timeline.php
+++ b/library/WT/Controller/Timeline.php
@@ -72,7 +72,7 @@ class WT_Controller_Timeline extends WT_Controller_Chart {
if (!empty($newpid) && !in_array($newpid, $this->pids)) {
$this->pids[] = $newpid;
}
- if (count($this->pids)==0) $this->pids[] = check_rootid("");
+ if (count($this->pids)==0) $this->pids[] = $this->getSignificantIndividual()->getXref();
$remove = safe_GET_xref('remove');
//-- cleanup user input
$newpids = array();