Skip to content

Commit

Permalink
Merge changes 12460-12466 from the trunk. This includes a major bug f…
Browse files Browse the repository at this point in the history
…ix, plus some last-minute GUI tweaks.
  • Loading branch information
fisharebest committed Oct 30, 2011
1 parent 76c9731 commit 0314eb6
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 130 deletions.
3 changes: 1 addition & 2 deletions admin_media.php
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,7 @@ function print_link_menu($mediaid) {
"sInfo": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '_START_', '_END_', '_TOTAL_'); ?>',
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo WT_I18N::translate_c('first page', 'first');?>',
"sLast": '<?php echo WT_I18N::translate('last');?>',
"sNext": '<?php echo WT_I18N::translate('next');?>',
Expand Down
2 changes: 1 addition & 1 deletion admin_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function (index, value) {
"sInfo": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '_START_', '_END_', '_TOTAL_'); ?>',
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"sSearch": '<?php echo WT_I18N::translate('Filter');?>',
"oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
Expand Down
3 changes: 1 addition & 2 deletions admin_site_logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down
3 changes: 1 addition & 2 deletions admin_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,7 @@ function paste_id(value) {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo WT_I18N::translate_c('first page', 'first');?>',
"sLast": '<?php echo WT_I18N::translate('last');?>',
"sNext": '<?php echo WT_I18N::translate('next');?>',
Expand Down
29 changes: 10 additions & 19 deletions includes/functions/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,6 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
$NODE_CACHE=array();
}

$time_limit=ini_get('max_execution_time');
$indi = WT_Person::getInstance($pid2);
//-- check the cache
if (!$ignore_cache) {
Expand All @@ -1275,8 +1274,8 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
return false;
}
//-- check the cache for person 2's children
foreach ($indi->getSpouseFamilies() as $fam) {
foreach ($fam->getChildren() as $child) {
foreach ($indi->getSpouseFamilies(WT_PRIV_HIDE) as $family) {
foreach ($family->getChildren(WT_PRIV_HIDE) as $child) {
if (isset($NODE_CACHE["$pid1-".$child->getXref()])) {
if (($maxlength==0)||(count($NODE_CACHE["$pid1-".$child->getXref()]["path"])+1<=$maxlength)) {
$node1 = $NODE_CACHE["$pid1-".$child->getXref()];
Expand Down Expand Up @@ -1339,14 +1338,6 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
flush();
}
$count++;
$end_time = microtime(true);
$exectime = $end_time - $start_time;
if (($time_limit>1)&&($exectime > $time_limit-1)) {
echo '<div>';
echo "<span class=\"error\">", WT_I18N::translate('The script timed out before a relationship could be found.'), "</span>";
echo '</div>';
return false;
}
if (count($p1nodes)==0) {
if ($maxlength!=0) {
if (!isset($NODE_CACHE_LENGTH)) {
Expand Down Expand Up @@ -1446,9 +1437,9 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
// }
// }
//-- check all parents and siblings of this node
foreach ($indi->getChildFamilies() as $fam) {
$visited[$fam->getXref()] = true;
foreach ($fam->getSpouses() as $spouse) {
foreach ($indi->getChildFamilies(WT_PRIV_HIDE) as $family) {
$visited[$family->getXref()] = true;
foreach ($family->getSpouses(WT_PRIV_HIDE) as $spouse) {
if (!isset($visited[$spouse->getXref()])) {
$node1 = $node;
$node1["length"]+=$fatherh;
Expand All @@ -1468,7 +1459,7 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
$NODE_CACHE["$pid1-".$node1["pid"]] = $node1;
}
}
foreach ($fam->getChildren() as $child) {
foreach ($family->getChildren(WT_PRIV_HIDE) as $child) {
if (!isset($visited[$child->getXref()])) {
$node1 = $node;
$node1["length"]+=$siblingh;
Expand All @@ -1490,10 +1481,10 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
}
}
//-- check all spouses and children of this node
foreach ($indi->getSpouseFamilies() as $fam) {
$visited[$fam->getXref()] = true;
foreach ($indi->getSpouseFamilies(WT_PRIV_HIDE) as $family) {
$visited[$family->getXref()] = true;
if ($followspouse) {
foreach ($fam->getSpouses() as $spouse) {
foreach ($family->getSpouses(WT_PRIV_HIDE) as $spouse) {
if (!in_arrayr($spouse->getXref(), $node1) || !isset($visited[$spouse->getXref()])) {
$node1 = $node;
$node1["length"]+=$spouseh;
Expand All @@ -1514,7 +1505,7 @@ function get_relationship($pid1, $pid2, $followspouse=true, $maxlength=0, $ignor
}
}
}
foreach ($fam->getChildren() as $child) {
foreach ($family->getChildren(WT_PRIV_HIDE) as $child) {
if (!isset($visited[$child->getXref()])) {
$node1 = $node;
$node1["length"]+=$childh;
Expand Down
18 changes: 6 additions & 12 deletions includes/functions/functions_print_lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ function print_indi_table($datalist, $legend='', $option='') {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down Expand Up @@ -501,8 +500,7 @@ function print_fam_table($datalist, $legend='', $option='') {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down Expand Up @@ -895,8 +893,7 @@ function print_sour_table($datalist, $legend=null) {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down Expand Up @@ -1059,8 +1056,7 @@ function print_note_table($datalist, $legend=null) {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down Expand Up @@ -1180,8 +1176,7 @@ function print_repo_table($repos, $legend='') {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down Expand Up @@ -1292,8 +1287,7 @@ function print_media_table($datalist, $legend) {
"sInfoEmpty": '<?php echo /* I18N: %s are placeholders for numbers */ WT_I18N::translate('Showing %1$s to %2$s of %3$s', '0', '0', '0'); ?>',
"sInfoFiltered": '<?php echo /* I18N: %s is a placeholder for a number */ WT_I18N::translate('(filtered from %s total entries)', '_MAX_'); ?>',
"sProcessing": '<?php echo WT_I18N::translate('Loading...');?>',
"sSearch": '<?php echo WT_I18N::translate('Search');?>',
"oPaginate": {
"sSearch": '<?php echo WT_I18N::translate('Filter');?>', "oPaginate": {
"sFirst": '<?php echo /* I18N: button label, first page */ WT_I18N::translate('first'); ?>',
"sLast": '<?php echo /* I18N: button label, last page */ WT_I18N::translate('last'); ?>',
"sNext": '<?php echo /* I18N: button label, next page */ WT_I18N::translate('next'); ?>',
Expand Down
10 changes: 3 additions & 7 deletions library/WT/Controller/Hourglass.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,10 @@ function max_descendency_generations($pid, $depth) {
if ($depth > $this->generations) return $depth;
$person = WT_Person::getInstance($pid);
if (is_null($person)) return $depth;
$famids = $person->getSpouseFamilies();
if ($person->getNumberOfChildren()==0) return $depth-1;
$maxdc = $depth;
foreach ($famids as $family) {
$ct = preg_match_all("/1 CHIL @(.*)@/", $family->getGedcomRecord(), $match, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
$chil = trim($match[$i][1]);
$dc = $this->max_descendency_generations($chil, $depth+1);
foreach ($person->getSpouseFamilies() as $family) {
foreach ($family->getChildren() as $child) {
$dc = $this->max_descendency_generations($child->getXref(), $depth+1);
if ($dc >= $this->generations) return $dc;
if ($dc > $maxdc) $maxdc = $dc;
}
Expand Down
36 changes: 15 additions & 21 deletions library/WT/Family.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function createPrivateGedcomRecord($access_level) {
preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @('.WT_REGEX_XREF.')@/', $this->_gedrec, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$rela=WT_Person::getInstance($match[1]);
if ($SHOW_PRIVATE_RELATIONSHIPS || $rela && $rela->canDisplayDetails($access_level)) {
if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canDisplayDetails($access_level))) {
$rec.=$match[0];
}
}
Expand Down Expand Up @@ -130,36 +130,30 @@ public function canDisplayName($access_level=WT_USER_ACCESS_LEVEL) {
* @param Person $person
* @return Person
*/
function getSpouse($person) {
if (is_null($this->wife) || is_null($this->husb)) return null;
if ($this->wife->equals($person)) return $this->husb;
if ($this->husb->equals($person)) return $this->wife;
function getSpouse($person, $access_level=WT_USER_ACCESS_LEVEL) {
if (is_null($this->wife) || is_null($this->husb)) {
return null;
}
if ($this->wife->equals($person) && $this->husb->canDisplayDetails($access_level)) {
return $this->husb;
}
if ($this->husb->equals($person) && $this->wife->canDisplayDetails($access_level)) {
return $this->wife;
}
return null;
}

function getSpouses() {
function getSpouses($access_level=WT_USER_ACCESS_LEVEL) {
$spouses=array();
if ($this->husb) {
if ($this->husb && $this->husb->canDisplayDetails($access_level)) {
$spouses[]=$this->husb;
}
if ($this->wife) {
if ($this->wife && $this->wife->canDisplayDetails($access_level)) {
$spouses[]=$this->wife;
}
return $spouses;
}

/**
* return the spouse id of the given person id
* @param string $pid
* @return string
*/
function getSpouseId($pid) {
if (is_null($this->wife) or is_null($this->husb)) return null;
if ($this->wife->getXref()==$pid) return $this->husb->getXref();
if ($this->husb->getXref()==$pid) return $this->wife->getXref();
return null;
}

/**
* get the children
* @return array array of children Persons
Expand All @@ -171,7 +165,7 @@ function getChildren($access_level=WT_USER_ACCESS_LEVEL) {
preg_match_all('/\n1 CHIL @('.WT_REGEX_XREF.')@/', $this->_gedrec, $match);
foreach ($match[1] as $pid) {
$child=WT_Person::getInstance($pid);
if ($SHOW_PRIVATE_RELATIONSHIPS || $child && $child->canDisplayDetails($access_level)) {
if ($child && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canDisplayDetails($access_level))) {
$children[]=$child;
}
}
Expand Down
4 changes: 4 additions & 0 deletions library/WT/GedcomRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ public function canDisplayDetails($access_level=WT_USER_ACCESS_LEVEL) {
$this->disp_none=$this->_canDisplayDetails(WT_PRIV_NONE);
}
return $this->disp_none;
case WT_PRIV_HIDE: // hidden from admins
// We use this value to bypass privacy checks. For example,
// when downloading data or when calculating privacy itself.
return true;
default:
// Should never get here.
return false;
Expand Down

0 comments on commit 0314eb6

Please sign in to comment.