diff options
Diffstat (limited to 'app/Module')
25 files changed, 193 insertions, 145 deletions
diff --git a/app/Module/AlbumModule.php b/app/Module/AlbumModule.php index bd34ee1f7b..bfa9fbcfea 100644 --- a/app/Module/AlbumModule.php +++ b/app/Module/AlbumModule.php @@ -187,7 +187,7 @@ class AlbumModule extends Module implements ModuleTabInterface { if (!$fact->isPendingDeletion()) { preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches); foreach ($matches[1] as $match) { - $media = Media::getInstance($match); + $media = Media::getInstance($match, $controller->record->getTree()); if ($media && $media->canShow()) { $this->media_list[] = $media; } diff --git a/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php b/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php index 50ff0a56f4..cdee3380d2 100644 --- a/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php +++ b/app/Module/BatchUpdate/BatchUpdateMissingDeathPlugin.php @@ -47,7 +47,9 @@ class BatchUpdateMissingDeathPlugin extends BatchUpdateBasePlugin { * @return boolean */ public function doesRecordNeedUpdate($xref, $gedrec) { - return !preg_match('/\n1 (' . WT_EVENTS_DEAT . ')/', $gedrec) && Individual::getInstance($xref)->isDead(); + global $WT_TREE; + + return !preg_match('/\n1 (' . WT_EVENTS_DEAT . ')/', $gedrec) && Individual::getInstance($xref, $WT_TREE)->isDead(); } /** diff --git a/app/Module/BatchUpdateModule.php b/app/Module/BatchUpdateModule.php index d9b7c63102..001737b394 100644 --- a/app/Module/BatchUpdateModule.php +++ b/app/Module/BatchUpdateModule.php @@ -88,6 +88,8 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { * @return string */ function main() { + global $WT_TREE; + $this->plugins = $this->getPluginList(); // List of available plugins $this->plugin = Filter::get('plugin'); // User parameters $this->xref = Filter::get('xref', WT_REGEX_XREF); @@ -107,9 +109,9 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { $newrecord = $this->PLUGIN->updateRecord($this->xref, $record); if ($newrecord != $record) { if ($newrecord) { - GedcomRecord::getInstance($this->xref)->updateRecord($newrecord, $this->PLUGIN->chan); + GedcomRecord::getInstance($this->xref, $WT_TREE)->updateRecord($newrecord, $this->PLUGIN->chan); } else { - GedcomRecord::getInstance($this->xref)->deleteRecord(); + GedcomRecord::getInstance($this->xref, $WT_TREE)->deleteRecord(); } } } @@ -122,9 +124,9 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { $newrecord = $this->PLUGIN->updateRecord($xref, $record); if ($newrecord != $record) { if ($newrecord) { - GedcomRecord::getInstance($this->xref)->updateRecord($newrecord, $this->PLUGIN->chan); + GedcomRecord::getInstance($this->xref, $WT_TREE)->updateRecord($newrecord, $this->PLUGIN->chan); } else { - GedcomRecord::getInstance($this->xref)->deleteRecord(); + GedcomRecord::getInstance($this->xref, $WT_TREE)->deleteRecord(); } } } @@ -166,7 +168,7 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { '<input type="hidden" name="data" value="">' . // will be set by javascript for next update '<table id="batch_update"><tr>' . '<th>' . I18N::translate('Family tree') . '</th>' . - '<td>' . select_edit_control('ged', Tree::getNameList(), '', WT_GEDCOM, 'onchange="reset_reload();"') . + '<td>' . select_edit_control('ged', Tree::getNameList(), '', $WT_TREE->getName(), 'onchange="reset_reload();"') . '</td></tr><tr><th>' . I18N::translate('Batch update') . '</th><td><select name="plugin" onchange="reset_reload();">'; if (!$this->plugin) { $html .= '<option value="" selected></option>'; @@ -195,7 +197,7 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { } else { if ($this->curr_xref) { // Create an object, so we can get the latest version of the name. - $this->record = GedcomRecord::getInstance($this->curr_xref); + $this->record = GedcomRecord::getInstance($this->curr_xref, $WT_TREE); $html .= '</table><table id="batch_update2"><tr><td>' . @@ -260,31 +262,33 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { * Generate a list of all XREFs. */ private function getAllXrefs() { + global $WT_TREE; + $sql = array(); $vars = array(); foreach ($this->PLUGIN->getRecordTypesToUpdate() as $type) { switch ($type) { case 'INDI': $sql[] = "SELECT i_id, 'INDI' FROM `##individuals` WHERE i_file=?"; - $vars[] = WT_GED_ID; + $vars[] = $WT_TREE->getTreeId(); break; case 'FAM': $sql[] = "SELECT f_id, 'FAM' FROM `##families` WHERE f_file=?"; - $vars[] = WT_GED_ID; + $vars[] = $WT_TREE->getTreeId(); break; case 'SOUR': $sql[] = "SELECT s_id, 'SOUR' FROM `##sources` WHERE s_file=?"; - $vars[] = WT_GED_ID; + $vars[] = $WT_TREE->getTreeId(); break; case 'OBJE': $sql[] = "SELECT m_id, 'OBJE' FROM `##media` WHERE m_file=?"; - $vars[] = WT_GED_ID; + $vars[] = $WT_TREE->getTreeId(); break; default: $sql[] = "SELECT o_id, ? FROM `##other` WHERE o_type=? AND o_file=?"; $vars[] = $type; $vars[] = $type; - $vars[] = WT_GED_ID; + $vars[] = $WT_TREE->getTreeId(); break; } } @@ -359,21 +363,23 @@ class BatchUpdateModule extends Module implements ModuleConfigInterface { * @return string */ public static function getLatestRecord($xref, $type) { + global $WT_TREE; + switch ($type) { case 'INDI': - return Individual::getInstance($xref)->getGedcom(); + return Individual::getInstance($xref, $WT_TREE)->getGedcom(); case 'FAM': - return Family::getInstance($xref)->getGedcom(); + return Family::getInstance($xref, $WT_TREE)->getGedcom(); case 'SOUR': - return Source::getInstance($xref)->getGedcom(); + return Source::getInstance($xref, $WT_TREE)->getGedcom(); case 'REPO': - return Repository::getInstance($xref)->getGedcom(); + return Repository::getInstance($xref, $WT_TREE)->getGedcom(); case 'OBJE': - return Media::getInstance($xref)->getGedcom(); + return Media::getInstance($xref, $WT_TREE)->getGedcom(); case 'NOTE': - return Note::getInstance($xref)->getGedcom(); + return Note::getInstance($xref, $WT_TREE)->getGedcom(); default: - return GedcomRecord::getInstance($xref)->getGedcom(); + return GedcomRecord::getInstance($xref, $WT_TREE)->getGedcom(); } } diff --git a/app/Module/CensusAssistantModule.php b/app/Module/CensusAssistantModule.php index 78b4516e38..76ea3c80cd 100644 --- a/app/Module/CensusAssistantModule.php +++ b/app/Module/CensusAssistantModule.php @@ -152,6 +152,8 @@ class CensusAssistantModule extends Module { * ... */ private static function mediaQuery() { + global $WT_TREE; + $iid2 = Filter::get('iid', WT_REGEX_XREF); $controller = new SimpleController; @@ -159,7 +161,7 @@ class CensusAssistantModule extends Module { ->setPageTitle(I18N::translate('Link to an existing media object')) ->pageHeader(); - $record = GedcomRecord::getInstance($iid2); + $record = GedcomRecord::getInstance($iid2, $WT_TREE); if ($record) { $headjs = ''; if ($record instanceof Family) { @@ -307,10 +309,10 @@ class CensusAssistantModule extends Module { * @return string */ static function addNoteWithAssistantLink($element_id, $xref, $action) { - global $controller; + global $controller, $WT_TREE; // We do not yet support family records - if (!GedcomRecord::getInstance($xref) instanceof Individual) { + if (!GedcomRecord::getInstance($xref, $WT_TREE) instanceof Individual) { return ''; } diff --git a/app/Module/ChartsBlockModule.php b/app/Module/ChartsBlockModule.php index 721972f488..e7db563108 100644 --- a/app/Module/ChartsBlockModule.php +++ b/app/Module/ChartsBlockModule.php @@ -49,11 +49,11 @@ class ChartsBlockModule extends Module implements ModuleBlockInterface { } } - $person = Individual::getInstance($pid); + $person = Individual::getInstance($pid, $WT_TREE); if (!$person) { $pid = $PEDIGREE_ROOT_ID; set_block_setting($block_id, 'pid', $pid); - $person = Individual::getInstance($pid); + $person = Individual::getInstance($pid, $WT_TREE); } $id = $this->getName() . $block_id; @@ -196,7 +196,7 @@ class ChartsBlockModule extends Module implements ModuleBlockInterface { <input data-autocomplete-type="INDI" type="text" name="pid" id="pid" value="<?php echo $pid; ?>" size="5"> <?php echo print_findindi_link('pid'); - $root = Individual::getInstance($pid); + $root = Individual::getInstance($pid, $WT_TREE); if ($root) { echo ' <span class="list_item">', $root->getFullName(), $root->format_first_major_fact(WT_EVENTS_BIRT, 1), '</span>'; } diff --git a/app/Module/ClippingsCart/ClippingsCart.php b/app/Module/ClippingsCart/ClippingsCart.php index 2d2fa00895..1f4475eb86 100644 --- a/app/Module/ClippingsCart/ClippingsCart.php +++ b/app/Module/ClippingsCart/ClippingsCart.php @@ -66,8 +66,8 @@ class ClippingsCart { if (!is_array($WT_SESSION->cart)) { $WT_SESSION->cart = array(); } - if (!array_key_exists(WT_GED_ID, $WT_SESSION->cart)) { - $WT_SESSION->cart[WT_GED_ID] = array(); + if (!array_key_exists($WT_TREE->getTreeId(), $WT_SESSION->cart)) { + $WT_SESSION->cart[$WT_TREE->getTreeId()] = array(); } $this->action = Filter::get('action'); @@ -92,7 +92,7 @@ class ClippingsCart { if ($this->action === 'add') { if (empty($this->type) && !empty($this->id)) { - $obj = GedcomRecord::getInstance($this->id); + $obj = GedcomRecord::getInstance($this->id, $WT_TREE); if ($obj) { $this->type = $obj::RECORD_TYPE; } else { @@ -109,7 +109,7 @@ class ClippingsCart { } if ($this->action === 'add1') { - $obj = GedcomRecord::getInstance($this->id); + $obj = GedcomRecord::getInstance($this->id, $WT_TREE); $this->addClipping($obj); if ($this->type === 'SOUR') { if ($others === 'linked') { @@ -126,50 +126,50 @@ class ClippingsCart { $this->addClipping($obj->getHusband()); $this->addClipping($obj->getWife()); } elseif ($others === "members") { - $this->addFamilyMembers(Family::getInstance($this->id)); + $this->addFamilyMembers(Family::getInstance($this->id, $WT_TREE)); } elseif ($others === "descendants") { - $this->addFamilyDescendancy(Family::getInstance($this->id)); + $this->addFamilyDescendancy(Family::getInstance($this->id, $WT_TREE)); } } elseif ($this->type === 'INDI') { if ($others === 'parents') { - foreach (Individual::getInstance($this->id)->getChildFamilies() as $family) { + foreach (Individual::getInstance($this->id, $WT_TREE)->getChildFamilies() as $family) { $this->addFamilyMembers($family); } } elseif ($others === 'ancestors') { - $this->addAncestorsToCart(Individual::getInstance($this->id), $this->level1); + $this->addAncestorsToCart(Individual::getInstance($this->id, $WT_TREE), $this->level1); } elseif ($others === 'ancestorsfamilies') { - $this->addAncestorsToCartFamilies(Individual::getInstance($this->id), $this->level2); + $this->addAncestorsToCartFamilies(Individual::getInstance($this->id, $WT_TREE), $this->level2); } elseif ($others === 'members') { - foreach (Individual::getInstance($this->id)->getSpouseFamilies() as $family) { + foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { $this->addFamilyMembers($family); } } elseif ($others === 'descendants') { - foreach (Individual::getInstance($this->id)->getSpouseFamilies() as $family) { + foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { $this->addClipping($family); $this->addFamilyDescendancy($family, $this->level3); } } - uksort($WT_SESSION->cart[WT_GED_ID], __NAMESPACE__ . '\ClippingsCart::compareClippings'); + uksort($WT_SESSION->cart[$WT_TREE->getTreeId()], __NAMESPACE__ . '\ClippingsCart::compareClippings'); } } elseif ($this->action === 'remove') { - unset ($WT_SESSION->cart[WT_GED_ID][$this->id]); + unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$this->id]); } elseif ($this->action === 'empty') { - $WT_SESSION->cart[WT_GED_ID] = array(); + $WT_SESSION->cart[$WT_TREE->getTreeId()] = array(); } elseif ($this->action === 'download') { $media = array(); $mediacount = 0; - $filetext = gedcom_header(WT_GEDCOM); + $filetext = gedcom_header($WT_TREE->getName()); // Include SUBM/SUBN records, if they exist $subn = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?") - ->execute(array('SUBN', WT_GED_ID)) + ->execute(array('SUBN', $WT_TREE->getTreeId())) ->fetchOne(); if ($subn) { $filetext .= $subn . "\n"; } $subm = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?") - ->execute(array('SUBM', WT_GED_ID)) + ->execute(array('SUBM', $WT_TREE->getTreeId())) ->fetchOne(); if ($subm) { $filetext .= $subm . "\n"; @@ -194,27 +194,27 @@ class ClippingsCart { break; } - foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { - $object = GedcomRecord::getInstance($xref); + foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) { + $object = GedcomRecord::getInstance($xref, $WT_TREE); // The object may have been deleted since we added it to the cart.... if ($object) { $record = $object->privatizeGedcom($access_level); // Remove links to objects that aren't in the cart preg_match_all('/\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) { + if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) { $record = str_replace($match[0], '', $record); } } preg_match_all('/\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) { + if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) { $record = str_replace($match[0], '', $record); } } preg_match_all('/\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { - if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) { + if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) { $record = str_replace($match[0], '', $record); } } @@ -340,11 +340,11 @@ class ClippingsCart { global $WT_SESSION; if ($record->canShowName()) { - $WT_SESSION->cart[WT_GED_ID][$record->getXref()] = true; + $WT_SESSION->cart[$record->getTree()->getTreeId()][$record->getXref()] = true; // Add directly linked records preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->getGedcom(), $matches); foreach ($matches[1] as $match) { - $WT_SESSION->cart[WT_GED_ID][$match] = true; + $WT_SESSION->cart[$record->getTree()->getTreeId()][$match] = true; } } } @@ -439,8 +439,10 @@ class ClippingsCart { * @return integer */ static function compareClippings($a, $b) { - $a = GedcomRecord::getInstance($a); - $b = GedcomRecord::getInstance($b); + global $WT_TREE; + + $a = GedcomRecord::getInstance($a, $WT_TREE); + $b = GedcomRecord::getInstance($b, $WT_TREE); if ($a && $b) { switch ($a::RECORD_TYPE) { case 'INDI': $t1 = 1; break; diff --git a/app/Module/ClippingsCartModule.php b/app/Module/ClippingsCartModule.php index 00350cd1a4..c1726d9712 100644 --- a/app/Module/ClippingsCartModule.php +++ b/app/Module/ClippingsCartModule.php @@ -65,12 +65,12 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}'; echo '</script>'; - if (!$WT_SESSION->cart[WT_GED_ID]) { + if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) { echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>'; } if ($clip_ctrl->action == 'add') { - $person = GedcomRecord::getInstance($clip_ctrl->id); + $person = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE); echo '<h3><a href="', $person->getHtmlUrl(), '">' . $person->getFullName(), '</a></h3>'; if ($clip_ctrl->type === 'FAM') { ?> <form action="module.php" method="get"> @@ -127,7 +127,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS <?php } } - if (!$WT_SESSION->cart[WT_GED_ID]) { + if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) { if ($clip_ctrl->action != 'add') { echo I18N::translate('The clippings cart allows you to take extracts (“clippings”) from this family tree and bundle them up into a single file for downloading and subsequent importing into your own genealogy program. The downloadable file is recorded in GEDCOM format.<br><ul><li>How to take clippings?<br>This is really simple. Whenever you see a clickable name (individual, family, or source) you can go to the Details page of that name. There you will see the <b>Add to clippings cart</b> option. When you click that link you will be offered several options to download.</li><li>How to download?<br>Once you have items in your cart, you can download them just by clicking the “Download” link. Follow the instructions and links.</li></ul>'); @@ -263,8 +263,8 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS <th class="list_label"><?php echo I18N::translate('Remove'); ?></th> </tr> <?php - foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { - $record = GedcomRecord::getInstance($xref); + foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) { + $record = GedcomRecord::getInstance($xref, $WT_TREE); if ($record) { switch ($record::RECORD_TYPE) { case 'INDI': $icon = 'icon-indis'; break; @@ -357,7 +357,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS /** {@inheritdoc} */ public function getSidebarAjaxContent() { - global $WT_SESSION; + global $WT_SESSION, $WT_TREE; $clip_ctrl = new ClippingsCart; $add = Filter::get('add', WT_REGEX_XREF); @@ -368,14 +368,14 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS $clip_ctrl->level2 = Filter::getInteger('level2'); $clip_ctrl->level3 = Filter::getInteger('level3'); if ($add) { - $record = GedcomRecord::getInstance($add); + $record = GedcomRecord::getInstance($add, $WT_TREE); if ($record) { $clip_ctrl->id = $record->getXref(); $clip_ctrl->type = $record::RECORD_TYPE; $clip_ctrl->addClipping($record); } } elseif ($add1) { - $record = Individual::getInstance($add1); + $record = Individual::getInstance($add1, $WT_TREE); if ($record) { $clip_ctrl->id = $record->getXref(); $clip_ctrl->type = $record::RECORD_TYPE; @@ -401,9 +401,9 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS } } } elseif ($remove) { - unset ($WT_SESSION->cart[WT_GED_ID][$remove]); + unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$remove]); } elseif (isset($_REQUEST['empty'])) { - $WT_SESSION->cart[WT_GED_ID] = array(); + $WT_SESSION->cart[$WT_TREE->getTreeId()] = array(); } elseif (isset($_REQUEST['download'])) { return $this->downloadForm($clip_ctrl); } @@ -416,18 +416,18 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS * @return string */ public function getCartList() { - global $WT_SESSION; + global $WT_SESSION, $WT_TREE; // Keep track of the INDI from the parent page, otherwise it will // get lost after ajax updates $pid = Filter::get('pid', WT_REGEX_XREF); - if (!$WT_SESSION->cart[WT_GED_ID]) { + if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) { $out = I18N::translate('Your clippings cart is empty.'); } else { $out = '<ul>'; - foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { - $record = GedcomRecord::getInstance($xref); + foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) { + $record = GedcomRecord::getInstance($xref, $WT_TREE); if ($record instanceof Individual || $record instanceof Family) { switch ($record::RECORD_TYPE) { case 'INDI': @@ -457,7 +457,7 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS $out .= '</ul>'; } - if ($WT_SESSION->cart[WT_GED_ID]) { + if ($WT_SESSION->cart[$WT_TREE->getTreeId()]) { $out .= '<br><a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&empty=true&pid=' . $pid . '" class="remove_cart">' . I18N::translate('Empty the clippings cart') . @@ -467,8 +467,8 @@ class ClippingsCartModule extends Module implements ModuleMenuInterface, ModuleS I18N::translate('Download') . '</a>'; } - $record = Individual::getInstance($pid); - if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[WT_GED_ID])) { + $record = Individual::getInstance($pid, $WT_TREE); + if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[$WT_TREE->getTreeId()])) { $out .= '<br><a href="module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&add=' . $pid . '&pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>'; } return $out; diff --git a/app/Module/DescendancyModule.php b/app/Module/DescendancyModule.php index 01583a8258..8439920d3c 100644 --- a/app/Module/DescendancyModule.php +++ b/app/Module/DescendancyModule.php @@ -36,6 +36,8 @@ class DescendancyModule extends Module implements ModuleSidebarInterface { /** {@inheritdoc} */ public function modAction($modAction) { + global $WT_TREE; + Zend_Session::writeClose(); header('Content-Type: text/html; charset=UTF-8'); @@ -45,7 +47,7 @@ class DescendancyModule extends Module implements ModuleSidebarInterface { echo $this->search($search); break; case 'descendants': - $individual = Individual::getInstance(Filter::get('xref', WT_REGEX_XREF)); + $individual = Individual::getInstance(Filter::get('xref', WT_REGEX_XREF), $WT_TREE); if ($individual) { echo $this->loadSpouses($individual, 1); } @@ -168,6 +170,8 @@ class DescendancyModule extends Module implements ModuleSidebarInterface { * @return string */ public function search($query) { + global $WT_TREE; + if (strlen($query) < 2) { return ''; } @@ -178,12 +182,12 @@ class DescendancyModule extends Module implements ModuleSidebarInterface { " AND i_id=n_id AND i_file=n_file AND i_file=?" . " ORDER BY n_sort" ) - ->execute(array("%{$query}%", "%{$query}%", WT_GED_ID)) + ->execute(array("%{$query}%", "%{$query}%", $WT_TREE->getTreeId())) ->fetchAll(); $out = ''; foreach ($rows as $row) { - $person = Individual::getInstance($row->xref); + $person = Individual::getInstance($row->xref, $WT_TREE); if ($person->canShowName()) { $out .= $this->getPersonLi($person); } diff --git a/app/Module/FamiliesSidebarSidebarModule.php b/app/Module/FamiliesSidebarSidebarModule.php index 847b753059..c6a4839503 100644 --- a/app/Module/FamiliesSidebarSidebarModule.php +++ b/app/Module/FamiliesSidebarSidebarModule.php @@ -75,10 +75,10 @@ class FamiliesSidebarModule extends Module implements ModuleSidebarInterface { /** {@inheritdoc} */ public function getSidebarContent() { - global $UNKNOWN_NN, $controller; + global $UNKNOWN_NN, $controller, $WT_TREE; // Fetch a list of the initial letters of all surnames in the database - $initials = QueryName::surnameAlpha(true, false, WT_GED_ID, false); + $initials = QueryName::surnameAlpha(true, false, $WT_TREE->getTreeId(), false); $controller->addInlineJavascript(' var famloadedNames = new Array(); @@ -164,7 +164,9 @@ class FamiliesSidebarModule extends Module implements ModuleSidebarInterface { * @return string */ public function getAlphaSurnames($alpha, $surname1 = '') { - $surnames = QueryName::surnames('', $alpha, true, true, WT_GED_ID); + global $WT_TREE; + + $surnames = QueryName::surnames('', $alpha, true, true, $WT_TREE->getTreeId()); $out = '<ul>'; foreach (array_keys($surnames) as $surname) { $out .= '<li id="sb_fam_' . $surname . '" class="sb_fam_surname_li"><a href="' . $surname . '" title="' . $surname . '" alt="' . $alpha . '" class="sb_fam_surname">' . $surname . '</a>'; @@ -188,7 +190,9 @@ class FamiliesSidebarModule extends Module implements ModuleSidebarInterface { * @return string */ public function getSurnameFams($alpha, $surname) { - $families = QueryName::families($surname, $alpha, '', true, WT_GED_ID); + global $WT_TREE; + + $families = QueryName::families($surname, $alpha, '', true, $WT_TREE->getTreeId()); $out = '<ul>'; foreach ($families as $family) { if ($family->canShowName()) { @@ -212,6 +216,9 @@ class FamiliesSidebarModule extends Module implements ModuleSidebarInterface { * @return string */ public function search($query) { + global $WT_TREE; + + $tree = Tree::findById($WT_TREE->getTreeId()); if (strlen($query) < 2) { return ''; } @@ -224,7 +231,7 @@ class FamiliesSidebarModule extends Module implements ModuleSidebarInterface { " AND i_id=n_id AND i_file=n_file AND i_file=?" . " ORDER BY n_sort" ) - ->execute(array("%{$query}%", "%{$query}%", WT_GED_ID)) + ->execute(array("%{$query}%", "%{$query}%", $WT_TREE->getTreeId())) ->fetchAll(); $ids = array(); foreach ($rows as $row) { @@ -243,14 +250,14 @@ class FamiliesSidebarModule extends Module implements ModuleSidebarInterface { $vars = array_merge($vars, $ids, $ids); } - $vars[] = WT_GED_ID; + $vars[] = $WT_TREE->getTreeId(); $rows = Database::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE {$where} AND f_file=?") ->execute($vars) ->fetchAll(); $out = '<ul>'; foreach ($rows as $row) { - $family = Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $family = Family::getInstance($row->xref, $tree, $row->gedcom); if ($family->canShowName()) { $out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' '; if ($family->canShow()) { diff --git a/app/Module/FamilyTreeFavoritesModule.php b/app/Module/FamilyTreeFavoritesModule.php index 260b09845f..d3f3fc1baa 100644 --- a/app/Module/FamilyTreeFavoritesModule.php +++ b/app/Module/FamilyTreeFavoritesModule.php @@ -58,11 +58,11 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { $favtitle = Filter::get('favtitle'); if ($gid) { - $record = GedcomRecord::getInstance($gid); + $record = GedcomRecord::getInstance($gid, $WT_TREE); if ($record && $record->canShow()) { self::addFavorite(array( 'user_id' => $ctype === 'user' ? Auth::id() : null, - 'gedcom_id' => WT_GED_ID, + 'gedcom_id' => $WT_TREE->getTreeId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, @@ -73,7 +73,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { } elseif ($url) { self::addFavorite(array( 'user_id' => $ctype === 'user' ? Auth::id() : null, - 'gedcom_id' => WT_GED_ID, + 'gedcom_id' => $WT_TREE->getTreeId(), 'gid' => null, 'type' => 'URL', 'url' => $url, @@ -94,7 +94,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { } } - $userfavs = $this->getFavorites($ctype === 'user' ? Auth::id() : WT_GED_ID); + $userfavs = $this->getFavorites($ctype === 'user' ? Auth::id() : $WT_TREE->getTreeId()); if (!is_array($userfavs)) { $userfavs = array(); } @@ -125,7 +125,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { $content .= '<br>' . $favorite['note']; $content .= '</div>'; } else { - $record = GedcomRecord::getInstance($favorite['gid']); + $record = GedcomRecord::getInstance($favorite['gid'], $WT_TREE); if ($record && $record->canShow()) { if ($record instanceof Individual) { $content .= '<div id="box' . $favorite["gid"] . '.0" class="person_box action_header'; @@ -168,7 +168,7 @@ class FamilyTreeFavoritesModule extends Module implements ModuleBlockInterface { $content .= '<form name="addfavform" method="get" action="index.php">'; $content .= '<input type="hidden" name="action" value="addfav">'; $content .= '<input type="hidden" name="ctype" value="' . $ctype . '">'; - $content .= '<input type="hidden" name="ged" value="' . WT_GEDCOM . '">'; + $content .= '<input type="hidden" name="ged" value="' . $WT_TREE->getNameHtml() . '">'; $content .= '<div class="add_fav_ref">'; $content .= '<input type="radio" name="fav_category" value="record" checked onclick="jQuery(\'#gid' . $uniqueID . '\').removeAttr(\'disabled\'); jQuery(\'#url, #favtitle\').attr(\'disabled\',\'disabled\').val(\'\');">'; $content .= '<label for="gid' . $uniqueID . '">' . I18N::translate('Enter an individual, family, or source ID') . '</label>'; diff --git a/app/Module/FamilyTreeNewsModule.php b/app/Module/FamilyTreeNewsModule.php index c14b35ab0e..754e5c243a 100644 --- a/app/Module/FamilyTreeNewsModule.php +++ b/app/Module/FamilyTreeNewsModule.php @@ -63,7 +63,7 @@ class FamilyTreeNewsModule extends Module implements ModuleBlockInterface { } $usernews = Database::prepare( "SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE gedcom_id=? ORDER BY updated DESC" - )->execute(array(WT_GED_ID))->fetchAll(); + )->execute(array($WT_TREE->getTreeId()))->fetchAll(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; @@ -106,7 +106,7 @@ class FamilyTreeNewsModule extends Module implements ModuleBlockInterface { } $printedAddLink = false; if (Auth::isManager($WT_TREE)) { - $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?gedcom_id='+WT_GED_ID, '_blank', news_window_specs); return false;\">" . I18N::translate('Add a news article') . "</a>"; + $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?gedcom_id=" . $WT_TREE->getTreeId() . "', '_blank', news_window_specs); return false;\">" . I18N::translate('Add a news article') . "</a>"; $printedAddLink = true; } if ($limit == 'date' || $limit == 'count') { diff --git a/app/Module/FrequentlyAskedQuestionsModule.php b/app/Module/FrequentlyAskedQuestionsModule.php index 39f01f4da3..f7cdead6fc 100644 --- a/app/Module/FrequentlyAskedQuestionsModule.php +++ b/app/Module/FrequentlyAskedQuestionsModule.php @@ -68,6 +68,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa * Action from the configuration page */ private function edit() { + global $WT_TREE; + if (Filter::postBool('save') && Filter::checkCsrf()) { $block_id = Filter::postInteger('block_id'); if ($block_id) { @@ -114,7 +116,7 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa $block_order = Database::prepare( "SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name" )->execute(array('module_name' => $this->getName()))->fetchOne(); - $gedcom_id = WT_GED_ID; + $gedcom_id = $WT_TREE->getTreeId(); } $controller->pageHeader(); if (Module::getModuleByName('ckeditor')) { @@ -283,8 +285,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa " ORDER BY block_order" )->execute(array( 'module_name' => $this->getName(), - 'tree_id_1' => WT_GED_ID, - 'tree_id_2' => WT_GED_ID, + 'tree_id_1' => $WT_TREE->getTreeId(), + 'tree_id_2' => $WT_TREE->getTreeId(), ))->fetchAll(); // Define your colors for the alternating rows @@ -327,6 +329,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa * Provide a form to manage the FAQs. */ private function config() { + global $WT_TREE; + $controller = new PageController; $controller ->setPageTitle(I18N::translate('Frequently asked questions')) @@ -344,8 +348,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa " ORDER BY block_order" )->execute(array( 'module_name' => $this->getName(), - 'tree_id_1' => WT_GED_ID, - 'tree_id_2' => WT_GED_ID, + 'tree_id_1' => $WT_TREE->getTreeId(), + 'tree_id_2' => $WT_TREE->getTreeId(), ))->fetchAll(); $min_block_order = Database::prepare( @@ -374,7 +378,7 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa I18N::translate('Family tree'), ' ', '<input type="hidden" name="mod", value="', $this->getName(), '">', '<input type="hidden" name="mod_action" value="admin_config">', - select_edit_control('ged', Tree::getNameList(), null, WT_GEDCOM), + select_edit_control('ged', Tree::getNameList(), null, $WT_TREE->getNameHtml()), '<input type="submit" value="', I18N::translate('show'), '">', '</form></p>'; @@ -431,6 +435,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa /** {@inheritdoc} */ public function getMenu() { + global $WT_TREE; + if (Auth::isSearchEngine()) { return null; } @@ -439,8 +445,8 @@ class FrequentlyAskedQuestionsModule extends Module implements ModuleMenuInterfa "SELECT block_id FROM `##block` WHERE module_name = :module_name AND IFNULL(gedcom_id, :tree_id_1) = :tree_id_2" )->execute(array( 'module_name' => $this->getName(), - 'tree_id_1' => WT_GED_ID, - 'tree_id_2' => WT_GED_ID, + 'tree_id_1' => $WT_TREE->getTreeId(), + 'tree_id_2' => $WT_TREE->getTreeId(), ))->fetchAll(); if (!$faqs) { diff --git a/app/Module/GoogleMapsModule.php b/app/Module/GoogleMapsModule.php index 7e1a15d1e9..c10049dabc 100644 --- a/app/Module/GoogleMapsModule.php +++ b/app/Module/GoogleMapsModule.php @@ -757,7 +757,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa // -- print the form to change the number of displayed generations ?> <form name="people" method="get" action="?"> - <input type="hidden" name="ged" value="<?php echo Filter::escapeHtml(WT_GEDCOM); ?>"> + <input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>"> <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="pedigree_map"> <table class="list_table" width="555"> @@ -1481,8 +1481,10 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa * ... */ private function adminPlaceCheck() { + global $WT_TREE; + $action = Filter::get('action', '', 'go'); - $gedcom_id = Filter::get('gedcom_id', null, WT_GED_ID); + $gedcom_id = Filter::get('gedcom_id', null, $WT_TREE->getTreeId()); $country = Filter::get('country', '.+', 'XYZ'); $state = Filter::get('state', '.+', 'XYZ'); $matching = Filter::getBool('matching'); @@ -2534,7 +2536,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa "SELECT p_id FROM `##places` WHERE p_parent_id = :place_id AND p_file = :tree_id AND p_place = :placename" )->execute(array( 'place_id' => $place_id, - 'tree_id' => WT_GED_ID, + 'tree_id' => $WT_TREE->getTreeId(), 'placename' => $placename, ))->fetchOne(); if ($pl_id) { @@ -2649,7 +2651,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa $placelevels = preg_replace('/, ' . I18N::translate('unknown') . '/', ', ', $placelevels); // replace ", unknown" with ", " $placelevels = substr($placelevels, 2); // remove the leading ", " if ($placelevels) { - $batchupdate_url = 'module.php?mod=batch_update&mod_action=admin_batch_update&plugin=BatchUpdateSearchReplacePlugin&method=exact&ged=' . WT_GEDCOM . '&search=' . urlencode($placelevels); // exact match + $batchupdate_url = 'module.php?mod=batch_update&mod_action=admin_batch_update&plugin=BatchUpdateSearchReplacePlugin&method=exact&ged=' . $WT_TREE->getNameHtml() . '&search=' . urlencode($placelevels); // exact match echo ' | '; echo '<a href="' . $batchupdate_url . '">', I18N::translate('Batch update'), '</a>'; } @@ -4150,7 +4152,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa $j = 0; $gedcom_records = Database::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_file=? UNION ALL SELECT f_gedcom FROM `##families` WHERE f_file=?") - ->execute(array(WT_GED_ID, WT_GED_ID)) + ->execute(array($WT_TREE->getTreeId(), $WT_TREE->getTreeId())) ->fetchOneColumn(); foreach ($gedcom_records as $gedrec) { $i = 1; @@ -4613,7 +4615,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="admin_places"> <input type="hidden" name="action" value="ImportGedcom"> - <?php echo select_edit_control('ged', Tree::getNameList(), null, WT_GEDCOM); ?> + <?php echo select_edit_control('ged', Tree::getNameList(), null, $WT_TREE->getName()); ?> <input type="submit" value="<?php echo I18N::translate('Import'); ?>"> </form> </td> @@ -4640,7 +4642,7 @@ class GoogleMapsModule extends Module implements ModuleConfigInterface, ModuleTa <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="admin_places"> <input type="hidden" name="action" value="ExportFile"> - <?php echo select_edit_control('parent', $where_am_i, I18N::translate('All'), WT_GED_ID); ?> + <?php echo select_edit_control('parent', $where_am_i, I18N::translate('All'), $WT_TREE->getTreeId()); ?> <input type="submit" value="<?php echo I18N::translate('Download'); ?>"> </form> </td> diff --git a/app/Module/IndividualSidebarModule.php b/app/Module/IndividualSidebarModule.php index 12476f4b4d..7a80987d13 100644 --- a/app/Module/IndividualSidebarModule.php +++ b/app/Module/IndividualSidebarModule.php @@ -75,10 +75,10 @@ class IndividualSidebarModule extends Module implements ModuleSidebarInterface { /** {@inheritdoc} */ public function getSidebarContent() { - global $WT_IMAGES, $UNKNOWN_NN, $controller; + global $WT_IMAGES, $UNKNOWN_NN, $controller, $WT_TREE; // Fetch a list of the initial letters of all surnames in the database - $initials = QueryName::surnameAlpha(true, false, WT_GED_ID, false); + $initials = QueryName::surnameAlpha(true, false, $WT_TREE->getTreeId(), false); $controller->addInlineJavascript(' var loadedNames = new Array(); @@ -164,7 +164,9 @@ class IndividualSidebarModule extends Module implements ModuleSidebarInterface { * @return string */ public function getAlphaSurnames($alpha, $surname1 = '') { - $surnames = QueryName::surnames('', $alpha, true, false, WT_GED_ID); + global $WT_TREE; + + $surnames = QueryName::surnames('', $alpha, true, false, $WT_TREE->getTreeId()); $out = '<ul>'; foreach (array_keys($surnames) as $surname) { $out .= '<li id="sb_indi_' . $surname . '" class="sb_indi_surname_li"><a href="' . $surname . '" title="' . $surname . '" alt="' . $alpha . '" class="sb_indi_surname">' . $surname . '</a>'; @@ -189,7 +191,9 @@ class IndividualSidebarModule extends Module implements ModuleSidebarInterface { * @return string */ public function getSurnameIndis($alpha, $surname) { - $indis = QueryName::individuals($surname, $alpha, '', true, false, WT_GED_ID); + global $WT_TREE; + + $indis = QueryName::individuals($surname, $alpha, '', true, false, $WT_TREE->getTreeId()); $out = '<ul>'; foreach ($indis as $person) { if ($person->canShowName()) { @@ -214,24 +218,27 @@ class IndividualSidebarModule extends Module implements ModuleSidebarInterface { * @return string */ public function search($query) { + global $WT_TREE; + + $tree = Tree::findById($WT_TREE->getTreeId()); if (strlen($query) < 2) { return ''; } $rows = Database::prepare( - "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom" . + "SELECT i_id AS xref, i_gedcom AS gedcom" . " FROM `##individuals`, `##name`" . " WHERE (i_id LIKE ? OR n_sort LIKE ?)" . " AND i_id=n_id AND i_file=n_file AND i_file=?" . " ORDER BY n_sort COLLATE '" . I18N::$collation . "'" . " LIMIT 50" ) - ->execute(array("%{$query}%", "%{$query}%", WT_GED_ID)) + ->execute(array("%{$query}%", "%{$query}%", $WT_TREE->getTreeId())) ->fetchAll(); $out = '<ul>'; foreach ($rows as $row) { - $person = Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $person = Individual::getInstance($row->xref, $tree, $row->gedcom); if ($person->canShowName()) { $out .= '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getSexImage() . ' ' . $person->getFullName() . ' '; if ($person->canShow()) { diff --git a/app/Module/InteractiveTree/TreeView.php b/app/Module/InteractiveTree/TreeView.php index 0dc21ff173..6f660f5d32 100644 --- a/app/Module/InteractiveTree/TreeView.php +++ b/app/Module/InteractiveTree/TreeView.php @@ -77,6 +77,8 @@ class TreeView { * @return string */ public function getPersons($list) { + global $WT_TREE; + $list = explode(';', $list); $r = array(); foreach ($list as $jsonRequest) { @@ -87,7 +89,7 @@ class TreeView { $fidlist = explode(',', $jsonRequest); $flist = array(); foreach ($fidlist as $fid) { - $flist[] = Family::getInstance($fid); + $flist[] = Family::getInstance($fid, $WT_TREE); } $r[] = $this->drawChildren($flist, 1, true); break; @@ -95,7 +97,7 @@ class TreeView { $params = explode('@', $jsonRequest); $fid = $params[0]; $order = $params[1]; - $f = Family::getInstance($fid); + $f = Family::getInstance($fid, $WT_TREE); if ($f->getHusband()) { $r[] = $this->drawPerson($f->getHusband(), 0, 1, $f, $order); } elseif ($f->getWife()) { diff --git a/app/Module/InteractiveTreeModule.php b/app/Module/InteractiveTreeModule.php index b1c86f19a1..c509d9b977 100644 --- a/app/Module/InteractiveTreeModule.php +++ b/app/Module/InteractiveTreeModule.php @@ -88,9 +88,10 @@ class InteractiveTreeModule extends Module implements ModuleTabInterface { /** {@inheritdoc} */ public function modAction($mod_action) { + global $controller, $WT_TREE; + switch ($mod_action) { case 'treeview': - global $controller; $controller = new ChartController; $tv = new TreeView('tv'); ob_start(); @@ -121,7 +122,7 @@ class InteractiveTreeModule extends Module implements ModuleTabInterface { $pid = Filter::get('pid', WT_REGEX_XREF); $i = Filter::get('instance'); $tv = new TreeView($i); - $individual = Individual::getInstance($pid); + $individual = Individual::getInstance($pid, $WT_TREE); if ($individual) { echo $tv->getDetails($individual); } diff --git a/app/Module/ResearchTaskModule.php b/app/Module/ResearchTaskModule.php index 7b6c3e1eb3..e4b9a7c4a2 100644 --- a/app/Module/ResearchTaskModule.php +++ b/app/Module/ResearchTaskModule.php @@ -99,7 +99,7 @@ class ResearchTaskModule extends Module implements ModuleBlockInterface { $found = false; $end_jd = $show_future ? 99999999 : WT_CLIENT_JD; - foreach (get_calendar_events(0, $end_jd, '_TODO', WT_GED_ID) as $fact) { + foreach (get_calendar_events(0, $end_jd, '_TODO', $WT_TREE) as $fact) { $record = $fact->getParent(); $user_name = $fact->getAttribute('_WT_USER'); if ($user_name === Auth::user()->getUserName() || !$user_name && $show_unassigned || $user_name && $show_other) { diff --git a/app/Module/ReviewChangesModule.php b/app/Module/ReviewChangesModule.php index 922262475c..f1759e110b 100644 --- a/app/Module/ReviewChangesModule.php +++ b/app/Module/ReviewChangesModule.php @@ -103,9 +103,9 @@ class ReviewChangesModule extends Module implements ModuleBlockInterface { " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref" - )->execute(array(WT_GED_ID))->fetchAll(); + )->execute(array($WT_TREE->getTreeId()))->fetchAll(); foreach ($changes as $change) { - $record = GedcomRecord::getInstance($change->xref); + $record = GedcomRecord::getInstance($change->xref, $WT_TREE); if ($record->canShow()) { $content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>'; } diff --git a/app/Module/SiteMapModule.php b/app/Module/SiteMapModule.php index 1f33b1da7c..ff2eeecdd8 100644 --- a/app/Module/SiteMapModule.php +++ b/app/Module/SiteMapModule.php @@ -136,6 +136,7 @@ class SiteMapModule extends Module implements ModuleConfigInterface { * @param string $volume */ private function generateFile($ged_id, $rec_type, $volume) { + $tree = Tree::findById($ged_id); // Check the cache $timestamp = $this->getSetting('sitemap-' . $ged_id . '-' . $rec_type . '-' . $volume . '.timestamp'); if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE && !Auth::check()) { @@ -147,7 +148,7 @@ class SiteMapModule extends Module implements ModuleConfigInterface { switch ($rec_type) { case 'i': $rows = Database::prepare( - "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom" . + "SELECT i_id AS xref, i_gedcom AS gedcom" . " FROM `##individuals`" . " WHERE i_file = :tree_id" . " ORDER BY i_id" . @@ -158,12 +159,12 @@ class SiteMapModule extends Module implements ModuleConfigInterface { 'offset' => self::RECORDS_PER_VOLUME * $volume, ))->fetchAll(); foreach ($rows as $row) { - $records[] = Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $records[] = Individual::getInstance($row->xref, $tree, $row->gedcom); } break; case 's': $rows = Database::prepare( - "SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom" . + "SELECT s_id AS xref, s_gedcom AS gedcom" . " FROM `##sources`" . " WHERE s_file = :tree_id" . " ORDER BY s_id" . @@ -174,12 +175,12 @@ class SiteMapModule extends Module implements ModuleConfigInterface { 'offset' => self::RECORDS_PER_VOLUME * $volume, ))->fetchAll(); foreach ($rows as $row) { - $records[] = Source::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $records[] = Source::getInstance($row->xref, $tree, $row->gedcom); } break; case 'r': $rows = Database::prepare( - "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom" . + "SELECT o_id AS xref, o_gedcom AS gedcom" . " FROM `##other`" . " WHERE o_file = :tree_id AND o_type = 'REPO'" . " ORDER BY o_id" . @@ -190,12 +191,12 @@ class SiteMapModule extends Module implements ModuleConfigInterface { 'offset' => self::RECORDS_PER_VOLUME * $volume, ))->fetchAll(); foreach ($rows as $row) { - $records[] = Repository::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $records[] = Repository::getInstance($row->xref, $tree, $row->gedcom); } break; case 'n': $rows = Database::prepare( - "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom" . + "SELECT o_id AS xref, o_gedcom AS gedcom" . " FROM `##other`" . " WHERE o_file = :tree_id AND o_type = 'NOTE'" . " ORDER BY o_id" . @@ -206,12 +207,12 @@ class SiteMapModule extends Module implements ModuleConfigInterface { 'offset' => self::RECORDS_PER_VOLUME * $volume, ))->fetchAll(); foreach ($rows as $row) { - $records[] = Note::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $records[] = Note::getInstance($row->xref, $tree, $row->gedcom); } break; case 'm': $rows = Database::prepare( - "SELECT m_id AS xref, m_file AS gedcom_id, m_gedcom AS gedcom" . + "SELECT m_id AS xref, m_gedcom AS gedcom" . " FROM `##media`" . " WHERE m_file = :tree_id" . " ORDER BY m_id" . @@ -222,7 +223,7 @@ class SiteMapModule extends Module implements ModuleConfigInterface { 'offset' => self::RECORDS_PER_VOLUME * $volume, ))->fetchAll(); foreach ($rows as $row) { - $records[] = Media::getInstance($row->xref, $row->gedcom_id, $row->gedcom); + $records[] = Media::getInstance($row->xref, $tree, $row->gedcom); } break; } diff --git a/app/Module/SlideShowModule.php b/app/Module/SlideShowModule.php index 7e6526ff00..c6429cf46e 100644 --- a/app/Module/SlideShowModule.php +++ b/app/Module/SlideShowModule.php @@ -46,7 +46,7 @@ class SlideShowModule extends Module implements ModuleBlockInterface { " AND m_ext IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')" . " AND m_type IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')" )->execute(array( - WT_GED_ID, + $WT_TREE->getTreeId(), get_block_setting($block_id, 'filter_avi', '0') ? 'avi' : null, get_block_setting($block_id, 'filter_bmp', '1') ? 'bmp' : null, get_block_setting($block_id, 'filter_gif', '1') ? 'gif' : null, @@ -83,7 +83,7 @@ class SlideShowModule extends Module implements ModuleBlockInterface { $random_media = null; while ($all_media) { $n = array_rand($all_media); - $media = Media::getInstance($all_media[$n]); + $media = Media::getInstance($all_media[$n], $WT_TREE); if ($media->canShow() && !$media->isExternal()) { // Check if it is linked to a suitable individual foreach ($media->linkedIndividuals('OBJE') as $indi) { diff --git a/app/Module/StoriesModule.php b/app/Module/StoriesModule.php index 036d8fbb50..7416fd531d 100644 --- a/app/Module/StoriesModule.php +++ b/app/Module/StoriesModule.php @@ -75,7 +75,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn )->execute(array( $this->getName(), $controller->record->getXref(), - WT_GED_ID + $controller->record->getTree()->getTreeId() ))->fetchOneColumn(); $html = ''; @@ -119,7 +119,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn )->execute(array( $this->getName(), $controller->record->getXref(), - WT_GED_ID + $controller->record->getTree()->getTreeId() ))->fetchOne(); return $count_of_stories == 0; @@ -204,7 +204,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn echo Filter::getCsrf(); echo '<input type="hidden" name="save" value="1">'; echo '<input type="hidden" name="block_id" value="', $block_id, '">'; - echo '<input type="hidden" name="gedcom_id" value="', WT_GED_ID, '">'; + echo '<input type="hidden" name="gedcom_id" value="', $WT_TREE->getTreeId(), '">'; echo '<table id="story_module">'; echo '<tr><th>'; echo I18N::translate('Story title'); @@ -224,7 +224,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn echo '<input data-autocomplete-type="INDI" type="text" name="xref" id="pid" size="4" value="' . $xref . '">'; echo print_findindi_link('pid'); if ($xref) { - $person = Individual::getInstance($xref); + $person = Individual::getInstance($xref, $WT_TREE); if ($person) { echo ' ', $person->formatList('span'); } @@ -269,6 +269,8 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn * The admin view - list, create, edit, delete stories. */ private function config() { + global $WT_TREE; + $controller = new PageController; $controller ->restrictAccess(Auth::isAdmin()) @@ -301,7 +303,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn " WHERE module_name=?" . " AND gedcom_id=?" . " ORDER BY xref" - )->execute(array($this->getName(), WT_GED_ID))->fetchAll(); + )->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll(); ?> <ol class="breadcrumb small"> @@ -318,7 +320,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn </label> <input type="hidden" name="mod" value="<?php echo $this->getName(); ?>"> <input type="hidden" name="mod_action" value="admin_config"> - <?php echo select_edit_control('ged', Tree::getNameList(), null, WT_GEDCOM, 'class="form-control"'); ?> + <?php echo select_edit_control('ged', Tree::getNameList(), null, $WT_TREE->getName(), 'class="form-control"'); ?> <input type="submit" class="btn btn-primary" value="<?php echo I18N::translate('show'); ?>"> </form> @@ -345,7 +347,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn <?php echo Filter::escapeHtml(get_block_setting($story->block_id, 'title')); ?> </td> <td> - <?php if ($indi = Individual::getInstance($story->xref)): ?> + <?php if ($indi = Individual::getInstance($story->xref, $WT_TREE)): ?> <a href="<?php echo $indi->getHtmlUrl(); ?>#stories"> <?php echo $indi->getFullName(); ?> </a> @@ -377,7 +379,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn * Show the list of stories */ private function showList() { - global $controller; + global $controller, $WT_TREE; $controller = new PageController; $controller @@ -409,7 +411,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn " WHERE module_name=?" . " AND gedcom_id=?" . " ORDER BY xref" - )->execute(array($this->getName(), WT_GED_ID))->fetchAll(); + )->execute(array($this->getName(), $WT_TREE->getTreeId()))->fetchAll(); echo '<h2 class="center">', I18N::translate('Stories'), '</h2>'; if (count($stories) > 0) { @@ -420,7 +422,7 @@ class StoriesModule extends Module implements ModuleTabInterface, ModuleConfigIn </tr></thead> <tbody>'; foreach ($stories as $story) { - $indi = Individual::getInstance($story->xref); + $indi = Individual::getInstance($story->xref, $WT_TREE); $story_title = get_block_setting($story->block_id, 'title'); $languages = get_block_setting($story->block_id, 'languages'); if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) { diff --git a/app/Module/TopPageViewsModule.php b/app/Module/TopPageViewsModule.php index eb7deee3af..6cbb8fe493 100644 --- a/app/Module/TopPageViewsModule.php +++ b/app/Module/TopPageViewsModule.php @@ -63,7 +63,7 @@ class TopPageViewsModule extends Module implements ModuleBlockInterface { " WHERE gedcom_id = :tree_id AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT :limit" )->execute(array( - 'tree_id' => WT_GED_ID, + 'tree_id' => $WT_TREE->getTreeId(), 'limit' => (int) $num, ))->FetchAssoc(); @@ -74,7 +74,7 @@ class TopPageViewsModule extends Module implements ModuleBlockInterface { $content .= "<table>"; } foreach ($top10 as $id=>$count) { - $record = GedcomRecord::getInstance($id); + $record = GedcomRecord::getInstance($id, $WT_TREE); if ($record && $record->canShow()) { $content .= '<tr valign="top">'; if ($count_placement == 'before') { diff --git a/app/Module/TopSurnamesModule.php b/app/Module/TopSurnamesModule.php index 0de0b21ef1..904e7d0448 100644 --- a/app/Module/TopSurnamesModule.php +++ b/app/Module/TopSurnamesModule.php @@ -50,7 +50,7 @@ class TopSurnamesModule extends Module implements ModuleBlockInterface { } // This next function is a bit out of date, and doesn't cope well with surname variants - $top_surnames = get_top_surnames(WT_GED_ID, $COMMON_NAMES_THRESHOLD, $num); + $top_surnames = get_top_surnames($WT_TREE->getTreeId(), $COMMON_NAMES_THRESHOLD, $num); // Remove names found in the "Remove Names" list if ($COMMON_NAMES_REMOVE) { @@ -63,7 +63,7 @@ class TopSurnamesModule extends Module implements ModuleBlockInterface { $all_surnames = array(); $i = 0; foreach (array_keys($top_surnames) as $top_surname) { - $all_surnames = array_merge($all_surnames, QueryName::surnames($top_surname, '', false, false, WT_GED_ID)); + $all_surnames = array_merge($all_surnames, QueryName::surnames($top_surname, '', false, false, $WT_TREE->getTreeId())); if (++$i == $num) { break; } diff --git a/app/Module/UserFavoritesModule.php b/app/Module/UserFavoritesModule.php index c39334a70f..f59b34626d 100644 --- a/app/Module/UserFavoritesModule.php +++ b/app/Module/UserFavoritesModule.php @@ -47,22 +47,26 @@ class UserFavoritesModule extends FamilyTreeFavoritesModule { * @return string[][] */ public static function getFavorites($user_id) { + global $WT_TREE; + self::updateSchema(); // make sure the favorites table has been created return Database::prepare( "SELECT SQL_CACHE favorite_id AS id, user_id, gedcom_id, xref AS gid, favorite_type AS type, title AS title, note AS note, url AS url" . " FROM `##favorite` WHERE user_id=? AND gedcom_id=?") - ->execute(array($user_id, WT_GED_ID)) + ->execute(array($user_id, $WT_TREE->getTreeId())) ->fetchAll(PDO::FETCH_ASSOC); } /** {@inheritdoc} */ public function modAction($modAction) { + global $WT_TREE; + switch ($modAction) { case 'menu-add-favorite': // Process the "add to user favorites" menu item on indi/fam/etc. pages - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF)); + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); if (Auth::check() && $record->canShowName()) { self::addFavorite(array( 'user_id' => Auth::id(), diff --git a/app/Module/YahrzeitModule.php b/app/Module/YahrzeitModule.php index 34afad1313..51f4c921f7 100644 --- a/app/Module/YahrzeitModule.php +++ b/app/Module/YahrzeitModule.php @@ -68,7 +68,7 @@ class YahrzeitModule extends Module implements ModuleBlockInterface { // Fetch normal anniversaries... $yahrzeits = array(); for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) { - foreach (get_anniversary_events($jd, 'DEAT _YART') as $fact) { + foreach (get_anniversary_events($jd, 'DEAT _YART', $WT_TREE) as $fact) { // Exact hebrew dates only $date = $fact->getDate(); if ($date->minimumDate() instanceof JewishDate && $date->minimumJulianDay() === $date->maximumJulianDay()) { |
