diff options
| author | fisharebest <fisharebest@gmail.com> | 2010-12-14 15:13:32 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2010-12-14 15:13:32 +0000 |
| commit | 12e41de1fc066a9e05adad8c98bad11c291243ae (patch) | |
| tree | 8d313c7cb34fc6a80ae4005e3ad2a0ee1de2ef82 /includes | |
| parent | 970e49fb0d4fc3306e550d1dcf43a3d480d4abd7 (diff) | |
| download | webtrees-12e41de1fc066a9e05adad8c98bad11c291243ae.tar.gz webtrees-12e41de1fc066a9e05adad8c98bad11c291243ae.tar.bz2 webtrees-12e41de1fc066a9e05adad8c98bad11c291243ae.zip | |
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/classes/class_family.php | 2 | ||||
| -rw-r--r-- | includes/classes/class_gedcomrecord.php | 97 | ||||
| -rw-r--r-- | includes/classes/class_localclient.php | 138 | ||||
| -rw-r--r-- | includes/classes/class_menubar.php | 13 | ||||
| -rw-r--r-- | includes/classes/class_person.php | 4 | ||||
| -rw-r--r-- | includes/classes/class_serviceclient.php | 906 | ||||
| -rw-r--r-- | includes/controllers/descendancy_ctrl.php | 8 | ||||
| -rw-r--r-- | includes/controllers/family_ctrl.php | 11 | ||||
| -rw-r--r-- | includes/controllers/individual_ctrl.php | 48 | ||||
| -rw-r--r-- | includes/controllers/remotelink_ctrl.php | 397 | ||||
| -rw-r--r-- | includes/controllers/search_ctrl.php | 213 | ||||
| -rw-r--r-- | includes/functions/functions.php | 25 | ||||
| -rw-r--r-- | includes/functions/functions_db.php | 35 | ||||
| -rw-r--r-- | includes/functions/functions_edit.php | 7 | ||||
| -rw-r--r-- | includes/functions/functions_import.php | 31 | ||||
| -rw-r--r-- | includes/functions/functions_print_facts.php | 56 | ||||
| -rw-r--r-- | includes/session.php | 11 | ||||
| -rw-r--r-- | includes/session_spider.php | 9 | ||||
| -rw-r--r-- | includes/set_gedcom_defaults.php | 1 |
19 files changed, 31 insertions, 1981 deletions
diff --git a/includes/classes/class_family.php b/includes/classes/class_family.php index 8023d2d5a4..3768a7fba9 100644 --- a/includes/classes/class_family.php +++ b/includes/classes/class_family.php @@ -48,7 +48,7 @@ class Family extends GedcomRecord { private $_isNotMarried = null; // Create a Family object from either raw GEDCOM data or a database row - function __construct($data, $simple=true) { + function __construct($data) { if (is_array($data)) { // Construct from a row from the database if ($data['f_husb']) { diff --git a/includes/classes/class_gedcomrecord.php b/includes/classes/class_gedcomrecord.php index 9952052e8c..84a0c7a315 100644 --- a/includes/classes/class_gedcomrecord.php +++ b/includes/classes/class_gedcomrecord.php @@ -41,14 +41,12 @@ require_once WT_ROOT.'includes/classes/class_repository.php'; require_once WT_ROOT.'includes/classes/class_note.php'; require_once WT_ROOT.'includes/classes/class_media.php'; require_once WT_ROOT.'includes/classes/class_event.php'; -require_once WT_ROOT.'includes/classes/class_serviceclient.php'; class GedcomRecord { protected $xref =null; // The record identifier protected $type =null; // INDI, FAM, etc. public $ged_id =null; // The gedcom file, only set if this record comes from the database protected $gedrec =null; // Raw gedcom text (privatised) - protected $rfn =null; protected $facts =null; protected $changeEvent=null; public $disp =true; // Can we display details of this object @@ -62,7 +60,7 @@ class GedcomRecord { protected $_getSecondaryName=null; // Create a GedcomRecord object from either raw GEDCOM data or a database row - public function __construct($data, $simple=false) { + public function __construct($data) { if (is_array($data)) { // Construct from a row from the database $this->xref =$data['xref']; @@ -79,24 +77,6 @@ class GedcomRecord { } } - //-- lookup the record from another gedcom - $remoterfn = get_gedcom_value('RFN', 1, $this->gedrec); - if (!empty($remoterfn)) { - $parts = explode(':', $remoterfn); - if (count($parts)==2) { - $servid = $parts[0]; - $aliaid = $parts[1]; - if (!empty($servid)&&!empty($aliaid)) { - $serviceClient = ServiceClient::getInstance($servid); - if (!is_null($serviceClient)) { - if (!$simple || $serviceClient->type=='local') { - $this->gedrec = $serviceClient->mergeGedcomRecord($aliaid, $this->gedrec, true); - } - } - } - } - } - //-- set the gedcom record a privatized version $this->disp =canDisplayRecord($this->ged_id, $this->gedrec); $this->gedrec=privatize_gedcom($this->gedrec); @@ -156,16 +136,6 @@ class GedcomRecord { $data=fetch_gedcom_record($pid, $ged_id); } - // If we didn't find the record in the database, it may be remote - if (!$data && strpos($pid, ':')) { - list($servid, $remoteid)=explode(':', $pid); - $service=ServiceClient::getInstance($servid); - if ($service) { - // TYPE will be replaced with the type from the remote record - $data=$service->mergeGedcomRecord($remoteid, "0 @{$pid}@ TYPE\n1 RFN {$pid}", false); - } - } - // If we didn't find the record in the database, it may be new/pending if (!$data && WT_USER_CAN_EDIT && ($data=find_gedcom_record($pid, $ged_id, true))!='') { $is_pending=true; @@ -218,8 +188,6 @@ class GedcomRecord { // Store it in the cache $gedcom_record_cache[$object->xref][$object->ged_id]=&$object; - //-- also store it using its reference id (sid:pid and local gedcom for remote links) - $gedcom_record_cache[$pid][$ged_id]=&$object; return $object; } @@ -272,21 +240,6 @@ class GedcomRecord { } /** - * is this person from another server - * @return boolean return true if this person was linked from another server - */ - public function isRemote() { - if (is_null($this->rfn)) $this->rfn = get_gedcom_value('RFN', 1, $this->gedrec); - if (empty($this->rfn) || $this->xref!=$this->rfn) return false; - - $parts = explode(':', $this->rfn); - if (count($parts)==2) { - return true; - } - return false; - } - - /** * check if this object is equal to the given object * @param GedcomRecord $obj */ @@ -306,55 +259,11 @@ class GedcomRecord { protected function _getLinkUrl($link, $separator) { if ($this->ged_id) { // If the record was created from the database, we know the gedcom - $url=$link.rawurlencode($this->getXref()).$separator.'ged='.rawurlencode(get_gedcom_from_id($this->ged_id)); + return $link.$this->getXref().$separator.'ged='.rawurlencode(get_gedcom_from_id($this->ged_id)); } else { // If the record was created from a text string, assume the current gedcom - $url=$link.rawurlencode($this->getXref()).$separator.'ged='.WT_GEDURL; - } - if ($this->isRemote()) { - list($servid, $aliaid)=explode(':', $this->rfn); - if ($aliaid && $servid) { - $serviceClient = ServiceClient::getInstance($servid); - if ($serviceClient) { - $surl = $serviceClient->getURL(); - $url = $link.$aliaid; - if ($serviceClient->getType()=='remote') { - if (!empty($surl)) { - $url = dirname($surl).'/'.$url; - } - } else { - $url = $surl.$url; - } - $gedcom = $serviceClient->getGedfile(); - if ($gedcom) { - $url .= $separator.'ged='.rawurlencode($gedcom); - } - } - } - } - return $url; - } - - /** - * Get the title that should be used in the link - * @return string - */ - public function getLinkTitle() { - $title = get_gedcom_setting($this->ged_id, 'title'); - if ($this->isRemote()) { - $parts = explode(':', $this->rfn); - if (count($parts)==2) { - $servid = $parts[0]; - $aliaid = $parts[1]; - if (!empty($servid)&&!empty($aliaid)) { - $serviceClient = ServiceClient::getInstance($servid); - if (!empty($serviceClient)) { - $title = $serviceClient->getTitle(); - } - } - } + return $link.$this->getXref().$separator.'ged='.WT_GEDURL; } - return $title; } // Get an HTML link to this object, for use in sortable lists. diff --git a/includes/classes/class_localclient.php b/includes/classes/class_localclient.php deleted file mode 100644 index 6aaf812c33..0000000000 --- a/includes/classes/class_localclient.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -/** - * - * webtrees: Web based Family History software - * Copyright (C) 2010 webtrees development team. - * - * Derived from PhpGedView - * Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package webtrees - * @subpackage DataModel - * @version $Id$ - */ - -if (!defined('WT_WEBTREES')) { - header('HTTP/1.0 403 Forbidden'); - exit; -} - -define('WT_CLASS_LOCALCLIENT_PHP', ''); - -require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - -class LocalClient extends ServiceClient { - /** - * constructor - * @param string $gedrec the gedcom record - */ - function __construct($gedrec) { - parent::__construct($gedrec); - $this->type = "local"; - } - - /** - * authenticate the client - */ - function authenticate() { - //-- nothing to do in a local client - } - - /** - * Get a record from the remote site - * @param string $remoteid the id of the record to get - */ - function getRemoteRecord($remoteid) { - $rec = find_gedcom_record($remoteid, WT_GED_ID); - $rec = preg_replace("/@(.*)@/", "@".$this->xref.":$1@", $rec); - return $rec; - } - - /** - * merge a local gedcom record with the information from the remote site - * @param string $xref the remote ID to merge with - * @param string $localrec the local gedcom record to merge the remote record with - * @param boolean $isStub whether or not this is a stub record - * @param boolean $firstLink is this the first time this record is being linked - */ - function mergeGedcomRecord($xref, $localrec, $isStub=false, $firstLink=false) { - //-- get the record from the database - $gedrec = find_gedcom_record($xref, WT_GED_ID); - $gedrec = preg_replace("/@(.*)@/", "@".$this->xref.":$1@", $gedrec); - $gedrec = $this->checkIds($gedrec); - if (empty($localrec)) return $gedrec; - $localrec = $this->_merge($localrec, $gedrec); - - //-- used to force an update on the first time linking a person - if ($firstLink) { - require_once WT_ROOT.'includes/functions/functions_edit.php'; - $ct=preg_match("/0 @(.*)@/", $localrec, $match); - if ($ct>0) - { - $pid = trim($match[1]); - $localrec = $this->UpdateFamily($localrec,$gedrec); - //-- restore the correct id since it may have been changed by the UpdateFamily method - $localrec = preg_replace("/0 @(.*)@/", "0 @$pid@", $localrec); - replace_gedrec($pid, WT_GED_ID, $localrec); - } - } - return $localrec; - } - - /** - * get a singleton instance of the results - * returned by the soapClient search method - * - * @param string $query - the query to search on - * @param integer $start - the start index of the results to return - * @param integer $max - the maximum number of results to return - */ - function search($query, $start=0, $max=100) { - //$this->authenticate(); - //$result = $this->soapClient->search($this->SID, $query, $start, $max); - $search_results = search_indis(array($query), array($this->gedfile), 'AND', true); - - // loop thru the returned result of the method call - foreach ($search_results as $gid=>$indi) - { - // privatize the gedcoms returned - $gedrec = privatize_gedcom($indi["gedcom"]); - // set the fields that exist and return all the results that are not private - if (preg_match("~".$query."~i",$gedrec)>0) - { - $person = new SOAP_Value('person', 'person', ""); - $person->PID = $gid; - $person->gedcomName = get_gedcom_value("NAME", 1, $gedrec, '', false); - $person->birthDate = get_gedcom_value("BIRT:DATE", 1, $gedrec, '', false); - $person->birthPlace = get_gedcom_value("BIRT:PLAC", 1, $gedrec, '', false); - $person->deathDate = get_gedcom_value("DEAT:DATE", 1, $gedrec, '', false); - $person->deathPlace = get_gedcom_value("DEAT:PLAC", 1, $gedrec, '', false); - $person->gender = get_gedcom_value("SEX", 1, $gedrec, '', false); - //$search_result_element['gedcom'] = $gedrec; - $results_array[] = $person; - } - } - // set the number of possible results - //$results[0]['totalResults'] = count($results_array); - $results_array = array_slice($results_array,$start,$max); - //$results[0]['persons'] = $results_array; - $return = new SOAP_Value('searchResult', 'searchResult', ""); - $return->totalResults = count($results_array); - $return->persons = $results_array; - return $return; - } -} diff --git a/includes/classes/class_menubar.php b/includes/classes/class_menubar.php index 3f1101c215..1d705ba060 100644 --- a/includes/classes/class_menubar.php +++ b/includes/classes/class_menubar.php @@ -610,7 +610,7 @@ class MenuBar { * @return Menu the menu item */ public static function getSearchMenu() { - global $TEXT_DIRECTION, $WT_IMAGES, $SHOW_MULTISITE_SEARCH, $SEARCH_SPIDER; + global $TEXT_DIRECTION, $WT_IMAGES, $SEARCH_SPIDER; if ($TEXT_DIRECTION=="rtl") $ff="_rtl"; else $ff=""; if ((!file_exists(WT_ROOT.'search.php')) || (!empty($SEARCH_SPIDER))) { @@ -642,17 +642,6 @@ class MenuBar { $submenu->addClass("submenuitem$ff", "submenuitem_hover$ff", "", "icon_small_search"); $menu->addSubmenu($submenu); } - - //-- search_multisite sub menu - if ($SHOW_MULTISITE_SEARCH >= WT_USER_ACCESS_LEVEL) { - $sitelist = get_server_list(); - if (count($sitelist)>0) { - $submenu = new Menu(i18n::translate('Multi Site Search'), "search.php?ged=".WT_GEDURL."&action=multisite"); - $submenu->addIcon('search'); - $submenu->addClass("submenuitem$ff", "submenuitem_hover$ff", "", "icon_small_search"); - $menu->addSubmenu($submenu); - } - } return $menu; } diff --git a/includes/classes/class_person.php b/includes/classes/class_person.php index 5efdf7f6c5..7e7730b8cc 100644 --- a/includes/classes/class_person.php +++ b/includes/classes/class_person.php @@ -68,7 +68,7 @@ class Person extends GedcomRecord { private $_getEstimatedDeathDate=null; // Create a Person object from either raw GEDCOM data or a database row - function __construct($data, $simple=true) { + function __construct($data) { if (is_array($data)) { // Construct from a row from the database $this->isdead=$data['i_isdead']; @@ -77,7 +77,7 @@ class Person extends GedcomRecord { // Construct from raw GEDCOM data } - parent::__construct($data, $simple); + parent::__construct($data); $this->dispname=$this->disp || showLivingNameById($this->xref); } diff --git a/includes/classes/class_serviceclient.php b/includes/classes/class_serviceclient.php deleted file mode 100644 index 17aa414b13..0000000000 --- a/includes/classes/class_serviceclient.php +++ /dev/null @@ -1,906 +0,0 @@ -<?php -/** -* Class used to access records and data on a remote server -* -* webtrees: Web based Family History software - * Copyright (C) 2010 webtrees development team. - * - * Derived from PhpGedView -* Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. -* -* 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 2 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, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* @package webtrees -* @subpackage DataModel -* @version $Id$ -*/ - -if (!defined('WT_WEBTREES')) { - header('HTTP/1.0 403 Forbidden'); - exit; -} - -define('WT_CLASS_SERVICECLIENT_PHP', ''); - -require_once WT_ROOT.'includes/classes/class_gedcomrecord.php'; -require_once WT_ROOT.'includes/classes/class_family.php'; -require_once WT_ROOT.'includes/functions/functions_import.php'; - -class ServiceClient extends GedcomRecord { - var $url = ""; - var $soapClient = null; - var $SID = ""; - var $gedfile = ""; - var $title = ""; - var $username = ""; - var $password = ""; - var $type = ""; - var $client_type = "SOAP"; // whether to use SOAP or PEAR:SOAP by default - - /** - * contstructor to create a new ServiceClient object - * @param string $gedrec the SERV gedcom record - */ - function __construct($gedrec) { - //parse url - //crate soap client class - //authenticate/get/set sid - parent::__construct($gedrec); - //echo "creating new service client ".$this->xref; - //get the url from the gedcom - $this->url = get_gedcom_value("URL",1,$gedrec); - $this->gedfile = get_gedcom_value("_DBID", 1, $gedrec); - $this->title = get_gedcom_value("TITL", 1, $gedrec); - $this->username = get_gedcom_value("_USER", 2, $gedrec); - $this->password = get_gedcom_value("_PASS", 2, $gedrec); - $this->type = "remote"; - if (empty($this->url) && empty($this->gedfile)) - return null; - } - - /** - * check if the service returned an error - */ - static function isError($result) { - if (PEAR::isError($result) || isset($result->faultcode) || isset($result->message) || get_class($result)=='SOAP_Fault') { - return true; - } - return false; - } - - /** - * get the title of this source record - * @return string - */ - function getTitle() { - if (empty($this->title)) return i18n::translate('unknown'); - return $this->title; - } - - function getURL() { - return $this->url; - } - - /** - * get the gedcom file - */ - function getGedfile() { - return $this->gedfile; - } - - /** - * authenticate the client - */ - function authenticate() { - if (!empty($this->SID)) return $this->SID; - if (is_null($this->soapClient)) { - if (!class_exists('Soap_Client') || $this->client_type=='PEAR:SOAP') { - - require_once './SOAP/Client.php'; - // get the wsdl and cache it - $wsdl = new SOAP_WSDL($this->url); - //change the encoding style - $this->__change_encoding($wsdl); - $this->soapClient = $wsdl->getProxy(); - } else { - //AddtoLog("Using SOAP Extension"); - //-- don't use exceptions in PHP 4 - $this->soapClient = new Soap_Client($this->url, array('exceptions' => 0)); - } - } - if ($this->soapClient!=null && !$this->isError($this->soapClient)) { - $res = $this->soapClient->Authenticate($this->username, $this->password, $this->gedfile, ""); - if (!is_object($res)) { - return false; - } - if (!isset($res->SID)) { - return false; - } - $this->SID = $res->SID; - return $this->SID; - } else { - addToLog("Unable to generate web service proxy from WSDL. ".print_r($this->soapClient, true)); - return false; - } - } - - /** - * Get a record from the remote site - * @param string $remoteid the id of the record to get - */ - function getRemoteRecord($remoteid) { - if (!is_object($this->soapClient)) $this->authenticate(); - if (!is_object($this->soapClient)||$this->isError($this->soapClient)) return false; - $rec = $this->soapClient->getGedcomRecord($this->SID, $remoteid); - if (is_string($rec)) { - $rec = preg_replace("/@([^#@\s]+)@/", "@".$this->xref.":$1@", $rec); - return $rec; - } else { - return ""; - } - } - - /** - * get the title for this service - * @return string - */ - function getServiceTitle() { - if (!empty($this->title)) return $this->title; - - $this->authenticate(); - $info = $this->soapClient->ServiceInfo(); - //print_r($info); - foreach ($info->gedcoms as $ind=>$gedobj) { - if ($gedobj->ID==$this->gedfile) break; - } - $this->title = $gedobj->title; - return $this->title; - } - - /** - * Merge people together. - */ - function _merge($record1, $record2) { - // Returns second record if first is empty, no merge needed - if (empty($record1)) return $record2; - // Returns first record if second is empty, no merge needed - if (empty($record2)) return $record1; - - $remoterecs = get_all_subrecords($record2, "", false, false); - $localrecs = get_all_subrecords($record1, "", false, false); - - $newrecs = array(); - //-- make sure we don't get circular links - foreach ($remoterecs as $ind2=>$subrec2) { - if (strpos($subrec2, "1 RFN")===false) { - $newrecs[] = $subrec2; - } - } - - foreach ($localrecs as $ind=>$subrec) { - $found = false; - if (strpos($subrec, "1 CHAN")===false) { - $subrec = trim($subrec); - $orig_subrec = $subrec; - $subrec = preg_replace("/\s+/", " ", $subrec); - - foreach ($remoterecs as $ind2=>$subrec2) { - $subrec2 = trim($subrec2); - $subrec2 = preg_replace("/\s+/", " ", $subrec2); - - if ($subrec2 == $subrec) { - $found = true; - break; - } - } - } else { - $found = true; - } - if (!$found) { - $newrecs[] = $orig_subrec; - } - } - - //-- start with the first line from the local record - $pos1 = strpos($record1, "\n1"); - if ($pos1!==false) $localrec = substr($record1, 0, $pos1+1); - else $localrec = $record1; - - //-- update the type of the remote record - $ct = preg_match("/0 @(.*)@ (\w*)/", $record2, $match); - if ($ct>0) $localrec = preg_replace("/0 @(.*)@ (\w*)/", "0 @$1@ ".trim($match[2]), $localrec); - //-- add all of the new records - foreach ($newrecs as $ind=>$subrec) { - $localrec .= trim($subrec)."\n"; - } - $localrec = trim($localrec); -//echo "[<pre>$localrec</pre>]"; - // Update the last change time - $pos1 = strpos($localrec, "1 CHAN"); - if ($pos1!==false) { - $pos2 = strpos($localrec, "\n1", $pos1+4); - if ($pos2===false) $pos2 = strlen($localrec); - $newgedrec = substr($localrec, 0, $pos1); - $newgedrec .= "1 CHAN\n2 DATE ".date("d M Y")."\n"; - $newgedrec .= "3 TIME ".date("H:i:s")."\n"; - $newgedrec .= "2 _WT_USER @".$this->xref."@\n"; - $newgedrec .= trim(substr($localrec, $pos2+1)); - $localrec = $newgedrec; - } else { - $newgedrec = "\n1 CHAN\n2 DATE ".date("d M Y")."\n"; - $newgedrec .= "3 TIME ".date("H:i:s")."\n"; - $newgedrec .= "2 _WT_USER @".$this->xref."@"; - $localrec .= $newgedrec; - } - - //echo "merged record is ".$localrec; - return $localrec; - } - - /** - * Updates Family Records such as children, spouse, and parents - */ - function UpdateFamily($record1,$record2) { - // This makes sure there is a record in both the server and client else it returns the record that - // exist if any - if (empty($record1)) { - return $record2; - } elseif (empty($record2)) { - return $record1; - } - - $this->authenticate(); - //this makes sure that the person is the one that was clicked so that this methade is not called more then ti needs to be - $ct = preg_match("/0 @(.*)@ (.*)/", $record1, $match); - $personId1=null; - if ($ct>0) { - $personId1 = $match[1]; - $type1 = trim($match[2]); - if ($type1!="INDI") { - return $record1; - } - } - $ct = preg_match("/0 @(.*)@ (.*)/", $record2, $match); - if ($ct>0) { - $personId2 = $match[1]; - $type2 = trim($match[2]); - if ($type2!="INDI") { - return $record1; - } - } - - //-- remove all remote family links added in _merge() so that we can add them back in if we need to - $record1 = preg_replace("/\d FAM[SC] @".$this->xref.":[\w\d]+@\r?\n/", "", $record1); - - //debug_print_backtrace(); - // holds the arrays of the current individual Familys - $List1FamilyChildID = find_families_in_record($record1, "FAMC"); - $List2FamilyChildID = find_families_in_record($record2, "FAMC"); - $List1FamilySpouseID = find_families_in_record($record1, "FAMS"); - $List2FamilySpouseID = find_families_in_record($record2, "FAMS"); - $FamilyListSpouse = array(); - $FamilyListChild = array(); - - // bools used to make sure the same children and/or familys are not counted more then twice - $firstTimeFamily=true; - - // starting the comparisons for family as child - if (empty($List1FamilyChildID)) { - //-- add all remote ids - foreach ($List2FamilyChildID as $famc=>$famCild2) { - $FamilyListChild[] = $famCild2; - } - } elseif (empty($List2FamilyChildID)) { - //-- nothing to do if there are no remote families - } else { - // Creating the first family - foreach ($List1FamilyChildID as $famc=>$famCild1) { - if (!empty($famCild1)) { - // Creating the Secound Family - foreach ($List2FamilyChildID as $famc=>$famCild2) { - if (!empty($famCild2)) { - if (!$this->CompairForUpdateFamily($famCild1,$famCild2)) { - if ($firstTimeFamily) { - $FamilyListChild[] = $famCild2; - } - } else { - $this->MergeForUpdateFamily($famCild1,$famCild2,$FamilyListChild,$FamilyListChild); - } - } - } - } - } - } - // starting the comparisons for family as spouse - if (empty($List1FamilySpouseID)) { - //-- add all remote ids - foreach ($List2FamilySpouseID as $fams=>$famSpouse2) { - if (!empty($famSpouse2)) { - $FamilyListSpouse[] = $famSpouse2; - } - } - } elseif (empty($List2FamilySpouseID)) { - //-- don't do anything if there are no remote families - } else { - // Creating the first family - foreach ($List1FamilySpouseID as $fams=>$famSpouse1) { - if (!empty($famSpouse1)) { - // Creating the Secound Family - foreach ($List2FamilySpouseID as $fams=>$famSpouse2) { - if (!empty($famSpouse2)) { - if (!$this->CompairForUpdateFamily($famSpouse1,$famSpouse2)) { - if ($firstTimeFamily) { - $FamilyListSpouse[] = $famSpouse2; - } - } else { - $this->MergeForUpdateFamily($famSpouse1,$famSpouse2,$FamilyListSpouse,$FamilyListSpouse); - } - } - } - } - } - } - // This Adds any new familys to the person. - if (count($FamilyListChild)>0) { - for ($i=0;$i<count($FamilyListChild);$i++) { - $record1.="\n1 FAMC @"; - if (strpos($FamilyListChild[$i], $this->xref)!==0) $record1 .= $this->xref.":"; - $record1 .= $FamilyListChild[$i]."@"; - } - } - if (count($FamilyListSpouse)>0) { - for ($i=0;$i<count($FamilyListSpouse);$i++) { - $record1.="\n1 FAMS @"; - if (strpos($FamilyListSpouse[$i], $this->xref)!==0) $record1 .= $this->xref.":"; - $record1 .= $FamilyListSpouse[$i]."@"; - } - } - return $record1; - } - - /** - * This mergest the the two familys together - */ - function MergeForUpdateFamily($Family1,$Family2,$Familylist,&$FamilyListReturn) { - global $GEDCOM; - require_once WT_ROOT.'includes/functions/functions_edit.php'; - - //echo "<br />In MergeForUpdateFamily ".$Family1." ".$Family2; - //print_r($Familylist); - $FamilyListReturn=$Familylist; - - $famrec1 = find_gedcom_record($Family1, get_id_from_gedcom($GEDCOM), true); - - $ct = preg_match("/(\w+):(.+)/", $Family2, $match); - if ($ct>0) { - $servid = trim($match[1]); - $remoteid = trim($match[2]); - $famrec2 = $this->getRemoteRecord($remoteid); - } else { - return $famrec1; - } - - // Creating the familys from the xref - $family1 = Family::getInstance($Family1); - $family2 = new Family($famrec2); - - // Creat the fathers if their is some - $father1 = $family1->getHusband(); - $father2 = $family2->getHusband(); - - // Creat the mothers if their is some - $mother1=$family1->getWife(); - $mother2=$family2->getWife(); - - // Creat an array of Children - $children1=$family1->getChildren(); - $children2=$family2->getChildren(); - - if (count($FamilyListReturn)>0) { // removes the updated family from the list so it does not get added later. - $index=null; - for ($i=0; $i<count($FamilyListReturn); $i++) { - if ($FamilyListReturn[$i]==$Family2) { - $ndex=$i; - break; - } - } - if ($index!=null) { - unset($FamilyListReturn[$index]); - } - } - - $famupdated = false; - // Merging starts here, the merging of children. - if (empty($children1)) { - $children1=$children2; - } elseif (empty($children2)) { - } else { - // Children are looped to see if they need to be added or merged to an esisting child - foreach ($children2 as $childID2=>$Child2) { - if (!empty($Child2)) { - //echo "<br/>child 2 Xref ".$Child2->getXref()."-".$childID2; - - $found = false; - //-- compare to children in local family - foreach ($children1 as $childID1=>$Child1) { - if (!empty($Child1)) { - //echo "<br/>child 2 Xref ".$Child2->getXref()." == ".$Child1->getXref(); - $found=$this->ComparePeople($Child1,$Child2); - if ($found) break; - } - } - if ($found) { - $childrec = $Child1->getGedcomRecord(); - if (strpos($childrec, "1 RFN ".$this->xref.":")===false) { - $childrec .= "\n1 RFN ".$Child2->getXref(); - //echo "<br/> repalcing for child ".$Child1->getXref(); - replace_gedrec($Child1->getXref(), WT_GED_ID, $childrec); - $this->setSameId($Child1->getXref(), $Child2->getXref()); - } - } else { - $famupdated = true; - $famrec1 .="\n1 CHIL @".$Child2->getXref()."@"; - //echo "<br/> adding for child ".$Child2->getXref(); - } - } - } - } - - //-- update the family record - if (strpos($famrec1, "1 RFN ".$this->xref.":")===false) { - $famrec1 .= "\n1 RFN ".$family2->getXref(); - $famupdated = true; - } - if ($famupdated) { - //echo "<br /> updating family record ".$family1->getXref(); - replace_gedrec($family1->getXref(), WT_GED_ID, $famrec1); - } - - // Merge Father basicly they just add the rfn numer and let the merge handle it latter - if (empty($father1)) { - if (!empty($father2)) { - $father1=$father2; - $famrec1 .="\n1 HUSB @".$father1->getXref()."@"; - //echo "<br/> adding for fahter ".$father1->getXref(); - replace_gedrec($family1->getXref(), WT_GED_ID, $famrec1); - } - } elseif (!empty($father2)) { - if ($this->ComparePeople($father1,$father2)) { - $fatherrec = $father1->getGedcomRecord(); - if (strpos($fatherrec, "1 RFN ".$this->xref.":")===false) { - $fatherrec .= "\n1 RFN ".$father2->getXref(); - //echo "<br/> repalcing for father ".$father1->getXref(); - replace_gedrec($father1->getXref(), WT_GED_ID, $fatherrec); - $this->setSameId($father1->getXref(), $father2->getXref()); - } - } - } - // Merge Mother - if (empty($mother1)) { - if (!empty($mother2)) { - $mother1=$mother2; - $famrec1 .="\n1 WIFE @".$mother1->getXref()."@"; - //echo "<br/> adding for mother ".$mother1->getXref(); - replace_gedrec($family1->getXref(), WT_GED_ID, $famrec1); - } - } else if (!empty($mother2)) { - if ($this->ComparePeople($mother1,$mother2)) { - $motherrec = $mother1->getGedcomRecord(); - if (strpos($motherrec, "1 RFN ".$this->xref.":")===false) { - $motherrec .= "\n1 RFN ".$mother2->getXref(); - //echo "<br/> repalcing for mother ".$mother1->getXref(); - replace_gedrec($mother1->getXref(), WT_GED_ID, $motherrec); - $this->setSameId($mother1->getXref(), $mother2->getXref()); - } - } - } - $this->setSameId($Family1, $Family2); - } - - /** - * Compairs familys and then returns true if the have 50% or more chance of being the same family. - * Other wise it returns false. - */ - function CompairForUpdateFamily($family1,$family2) { - global $GEDCOM; - - // Values used to calculate the Percent of likley hood that the family is the same. - $ChanceSameFamily=0.0; - $CountFamily1=0.0; - $CountFamily2=0.0; - $ChanceSame=0.0; - - $firstTimeChildren=true; - - $famrec1 = find_family_record($family1, get_id_from_gedcom($GEDCOM)); - $ct = preg_match("/(\w+):(.+)/", $family2, $match); - if ($ct>0) { - $servid = trim($match[1]); - $remoteid = trim($match[2]); - $famrec2 = $this->getRemoteRecord($remoteid); - } else return false; - $family1 = Family::getInstance($family1); - if (is_null($family1)) return false; - $family2 = new Family($famrec2); - - if (!is_null($family1)) { - // Creat the fathers if their is some - $father1 = $family1->getHusband(); - $CountFamily1+=1.0; - $mother1=$family1->getWife(); - $CountFamily1+=1.0; - } - $father2 = $family2->getHusband(); - $CountFamily2+=1.0; - if (empty($father1)) { - unset($father1); - $CountFamily1-=1.0; - } - if (empty($father2)) { - unset($father2); - $CountFamily2-=1.0; - } - - // Creat the mothers if their is some - $mother2=$family2->getWife(); - $CountFamily2+=1.0; - if (empty($mother1)) { - unset($mother1); - $CountFamily1-=1.0; - } - if (empty($mother2)) { - unset($mother2); - $CountFamily2-=1.0; - } - - // Creat an array of Children - $children1=$family1->getChildren(); - $children2=$family2->getChildren(); - - // finds the probablity that they are the same family Bassed of both sites information - $CountFamily1 += count($children1); - $CountFamily2 += count($children2); - foreach ($children1 as $childID1=>$Person1) { - if (!empty($Person1)) { - foreach ($children2 as $childID2=>$Person2) { - if (!empty($Person2)) { - if ($this->ComparePeople($Person1,$Person2)) { - $ChanceSameFamily+=1.0; - //echo "<br />".$Person1->getXref()." equals ".$Person2->getXref(); - break; - } - } - } - } - } - - if (empty($father1)) { - } elseif (empty($father2)) { - } else { - if ($this->ComparePeople($father1,$father2)) { - $ChanceSameFamily+=1.0; - } - } - if (empty($mother1)) { - } elseif (empty($mother2)) { - } else { - if ($this->ComparePeople($mother1,$mother2)) { - $ChanceSameFamily+=1.0; - } - } - if ($CountFamily1!=0&&$CountFamily2!=0) { - $ChanceSame=(($ChanceSameFamily/$CountFamily1)+($ChanceSameFamily/$CountFamily2))/2; - //echo "<br />chancesame=".$ChanceSameFamily." count1=".$CountFamily1." count2=".$CountFamily2." ".$family1->getXref()." compared to ".$family2->getXref()." is ".$ChanceSame; - } else - return false; - - if ($ChanceSame<0.5) { // If the probabilty is less then 0.5 or 50% then the current family is stored here to be added later - return false; - } else { return true; } - } - - /** - * set two ids in the same person - * @param string $local The local id - * @param string $remote the remote id that matches the $local id - */ - static function setSameId($local, $remote) { - global $GEDCOM; - - if ($local == $remote) { - debug_print_backtrace(); - return; - } - //-- check if the link already exists - $gid=get_remote_id($remote); - if (empty($gid)) { - WT_DB::prepare("INSERT INTO `##remotelinks` (r_gid, r_linkid, r_file) VALUES (? ,? ,?)") - ->execute(array($local, $remote, get_id_from_gedcom($GEDCOM))); - } - } - - /** - * Compares to see if two people are the same, and it returns true if they are, but - * false if they are not. It only compares the name, sex birthdate, and deathdate - * of the person - */ - static function ComparePeople(&$Person1,&$Person2) { - $PersonName1=$Person1->getFullName(); - $PersonSex1=$Person1->getSex(); - $PersonBirth1=$Person1->getEstimatedBirthDate(); - $PersonDeath1=$Person1->getEstimatedDeathDate(); - - $PersonName2=$Person2->getFullName(); - $PersonSex2=$Person2->getSex(); - $PersonBirth2=$Person2->getEstimatedBirthDate(); - $PersonDeath2=$Person2->getEstimatedDeathDate(); - - $count=0; - $Probability=0; - if (!empty($PersonName1)&&!empty($PersonName2)) { - $lev = levenshtein(utf8_strtolower($PersonName1), utf8_strtolower($PersonName2)); - if ($lev<4) { - $Probability+=2; - } else - $Probability-=2; - $count+=2; - } - $sex_prob=array('UU'=>0, 'UF'=>0, 'UM'=>0, 'MU'=>0, 'FU'=>0, 'MM'=>1, 'FF'=>1,'MF'=>-2, 'FM'=>-2); - $Probability+=$sex_prob[$PersonSex1.$PersonSex2]; - $count++; - - if ($PersonBirth1->isOK() && $PersonBirth2->isOK()) { - $diff=abs($PersonBirth1->JD() - $PersonBirth2->JD()); - if ($diff==0) { - $Probability+=2; - } elseif ($diff<366) { - $Probability+=1; - } else { - $Probability-=1; - } - $count++; - } - - if ($PersonDeath1->isOK() && $PersonDeath2->isOK()) { - $diff=abs($PersonDeath1->JD() - $PersonDeath2->JD()); - if ($diff==0) { - $Probability+=2; - } elseif ($diff<366) { - $Probability+=1; - } else { - $Probability-=1; - } - $count++; - } - - $prob=$Probability/$count; - if ($prob<0.5) { - return false; - } else { - return true; - } - } - - /** - * check if any there are any stub records with RFN tags that match the - * ids in the gedcom record - * @param string $gedrec - * @return string - */ - function checkIds($gedrec) { - $ids_checked = array(); - $ct = preg_match_all("/@(".$this->xref.":.*)@/", $gedrec, $match, PREG_SET_ORDER); - for ($i=0; $i<$ct; $i++) { - $id = trim($match[$i][1]); - if (isset($ids_checked[$id])) continue; - $ids_checked[$id]=true; - $gid=get_remote_id($id); - if ($gid) - $gedrec = str_replace("@".$id."@", "@".$gid."@", $gedrec); - } - return $gedrec; - } - - /** - * merge a local gedcom record with the information from the remote site - * @param string $xref the remote ID to merge with - * @param string $localrec the local gedcom record to merge the remote record with - * @param boolean $isStub whether or not this is a stub record - * @param boolean $firstLink is this the first time this record is being linked - */ - function mergeGedcomRecord($xref, $localrec, $isStub=false, $firstLink=false) { - global $GEDCOM; - - if (!$isStub) { - $gedrec = find_gedcom_record($this->xref.":".$xref, get_id_from_gedcom($GEDCOM)); - if (!empty($gedrec)) $localrec = $gedrec; - } - //-- used to force an update on the first time linking a person - if ($firstLink) { - $this->authenticate(); - $result = $this->soapClient->getGedcomRecord($this->SID, $xref); - if (PEAR::isError($result) || isset($result->faultcode) || get_class($result)=='SOAP_Fault' || is_object($result)) { - if (isset($result->faultstring)) { - AddToLog($result->faultstring, 'error'); - echo $result->faultstring; - } - return $localrec; - } - $gedrec = $result; - $gedrec = preg_replace("/@([^#@\s]+)@/", "@".$this->xref.":$1@", $gedrec); - $gedrec = $this->checkIds($gedrec); - $localrec = $this->_merge($localrec, $gedrec); - require_once WT_ROOT.'includes/functions/functions_edit.php'; - $localrec = $this->UpdateFamily($localrec,$gedrec); - $ct=preg_match("/0 @(.*)@/", $localrec, $match); - if ($ct>0) { - $pid = trim($match[1]); - replace_gedrec($pid, WT_GED_ID, $localrec); - } - } - - //-- get the last change date of the record - $change_date = get_gedcom_value("CHAN:DATE", 1, $localrec, '', false); - if (empty($change_date)) { - $this->authenticate(); - if (!is_object($this->soapClient) || $this->isError($this->soapClient)) return false; - $result = $this->soapClient->getGedcomRecord($this->SID, $xref); - if (PEAR::isError($result) || isset($result->faultcode) || is_object($result) && get_class($result)=='SOAP_Fault') { - if (isset($result->faultstring)) { - AddToLog($result->faultstring, 'error'); - echo $result->faultstring; - } - return $localrec; - } - $gedrec = $result; - $gedrec = preg_replace("/@([^#@\s]+)@/", "@".$this->xref.":$1@", $gedrec); - $gedrec = $this->checkIds($gedrec); - - $localrec = $this->_merge($localrec, $gedrec); - $ct=preg_match("/0 @(.*)@/", $localrec, $match); - if ($ct>0) { - $pid = trim($match[1]); - if ($isStub) { - require_once WT_ROOT.'includes/functions/functions_edit.php'; - $localrec = $this->UpdateFamily($localrec,$gedrec); - replace_gedrec($pid, WT_GED_ID, $localrec); - } else { - update_record($localrec, get_id_from_gedcom($GEDCOM), false); - } - } - } else { - $chan_date = new GedcomDate($change_date); - $chan_time_str = get_gedcom_value("CHAN:DATE:TIME", 1, $localrec, '', false); - $chan_time = parse_time($chan_time_str); - $change_time = mktime($chan_time[0], $chan_time[1], $chan_time[2], $chan_date->date1->m, $chan_date->date1->d, $chan_date->date1->y); - /** - * @todo make the timeout a config option - */ - // Time Clock (determines how often a record is checked) - if ($change_time < time()-(60*60*24*14)) // if the last update (to the remote individual) was made more than 14 days ago - { - //$change_date= "1 JAN 2000"; - $this->authenticate(); - if (!is_object($this->soapClient) || $this->isError($this->soapClient)) return false; - $person = $this->soapClient->checkUpdatesByID($this->SID, $xref, $change_date); - // If there are no changes between the local and remote copies - if (PEAR::isError($person) || isset($person->faultcode) || get_class($person)=='SOAP_Fault' || isset($person->error_message_prefix)) { - - if (isset($person->faultstring)) AddToLog($person->faultstring, 'error'); - else AddToLog($person->message, 'edit'); - //-- update the last change time - $pos1 = strpos($localrec, "1 CHAN"); - if ($pos1!==false) { - $pos2 = strpos($localrec, "\n1", $pos1+4); - if ($pos2===false) $pos2 = strlen($localrec); - $newgedrec = substr($localrec, 0, $pos1); - $newgedrec .= "1 CHAN\n2 DATE ".date("d M Y")."\n"; - $newgedrec .= "3 TIME ".date("H:i:s")."\n"; - $newgedrec .= "2 _WT_USER @".$this->xref."@\n"; - $newgedrec .= substr($localrec, $pos2); - $localrec = $newgedrec; - } else { - $newgedrec = "\n1 CHAN\n2 DATE ".date("d M Y")."\n"; - $newgedrec .= "3 TIME ".date("H:i:s")."\n"; - $newgedrec .= "2 _WT_USER @".$this->xref."@"; - $localrec .= $newgedrec; - } - update_record($localrec, get_id_from_gedcom($GEDCOM), false); - } - // If changes have been made to the remote record - else { - $gedrec = $person->gedcom; - $gedrec = preg_replace("/@([^#@\s]+)@/", "@".$this->xref.":$1@", $gedrec); - $gedrec = $this->checkIds($gedrec); - $ct=preg_match("/0 @(.*)@/", $localrec, $match); - if ($ct>0) { - $pid = trim($match[1]); - $localrec = find_gedcom_record($pid, get_id_from_gedcom($GEDCOM), true); - $localrec = $this->_merge($localrec, $gedrec); - if ($isStub) { - require_once WT_ROOT.'includes/functions/functions_edit.php'; - $localrec = $this->UpdateFamily($localrec,$gedrec); - replace_gedrec($pid, WT_GED_ID, $localrec); - } else { - update_record($localrec, get_id_from_gedcom($GEDCOM), false); - } - } - } - } - } - - return $localrec; - } - - /** - * get a singleton instance of the results - * returned by the soapClient search method - * - * @param string $query - the query to search on - * @param integer $start - the start index of the results to return - * @param integer $max - the maximum number of results to return - */ - function search($query, $start=0, $max=100) { - $this->authenticate(); - $result = $this->soapClient->search($this->SID, $query, $start, $max); - return $result; - } - - /*** - * Change encoding style to literal - * used when calling a java service - * - * @param object $wsdl SOAP_WSDL object - * @returns object modified wsdl object - */ - function __change_encoding(&$wsdl) { - $namespace = array_keys($wsdl->bindings); - if (isset($namespace[0]) && isset($wsdl->bindings[$namespace[0]]['operations'])) { - $operations = array_keys($wsdl->bindings[$namespace[0]]['operations']); - - for ($i = 0; $i<count($operations); $i++) { - $wsdl->bindings[$namespace[0]]['operations'][$operations[$i]]['input']['use'] = 'literal'; - $wsdl->bindings[$namespace[0]]['operations'][$operations[$i]]['output']['use'] = 'literal'; - } - } - } - - /** - * get a singleton instance of this client - * @return ServiceClient - */ - static function &getInstance($id) { - global $WT_SERVERS, $GEDCOM; - $ged_id=get_id_from_gedcom($GEDCOM); - - if (isset($WT_SERVERS[$id])) return $WT_SERVERS[$id]; - $gedrec = find_gedcom_record($id, $ged_id, true); - if (!empty($gedrec)) { - $url = get_gedcom_value("URL",1,$gedrec); - $gedfile = get_gedcom_value("_DBID", 1, $gedrec); - if (empty($url) && empty($gedfile)) - return null; - if (!empty($url) && (strtolower($url)!=strtolower(WT_SERVER_NAME.WT_SCRIPT_PATH))) { - $server = new ServiceClient($gedrec); - } else { - require_once WT_ROOT.'includes/classes/class_localclient.php'; - $server = new LocalClient($gedrec); - } - $WT_SERVERS[$id] = $server; - return $server; - } - return null; - } -} diff --git a/includes/controllers/descendancy_ctrl.php b/includes/controllers/descendancy_ctrl.php index a3de123406..92c5136c6f 100644 --- a/includes/controllers/descendancy_ctrl.php +++ b/includes/controllers/descendancy_ctrl.php @@ -106,14 +106,6 @@ class DescendancyController extends BaseController { $this->descPerson = Person::getInstance($this->pid); $this->name=$this->descPerson->getFullName(); - - //-- if the person is from another gedcom then forward to the correct site - /* - if ($this->indi->isRemote()) { - header('Location: '.$this->indi->getRawUrl()); - exit; - } - */ } /** diff --git a/includes/controllers/family_ctrl.php b/includes/controllers/family_ctrl.php index bd8e0534d8..d5ee19447b 100644 --- a/includes/controllers/family_ctrl.php +++ b/includes/controllers/family_ctrl.php @@ -63,17 +63,6 @@ class FamilyController extends BaseController { $this->family = Family::getInstance($this->famid); if (empty($this->famrec)) { - $ct = preg_match('/(\w+):(.+)/', $this->famid, $match); - if ($ct>0) { - $servid = trim($match[1]); - $remoteid = trim($match[2]); - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - $service = ServiceClient::getInstance($servid); - if (!is_null($service)) { - $newrec= $service->mergeGedcomRecord($remoteid, "0 @".$this->famid."@ FAM\n1 RFN ".$this->famid, false); - $this->famrec = $newrec; - } - } //-- if no record was found create a default empty one if (find_updated_record($this->famid, WT_GED_ID)!==null) { $this->famrec = "0 @".$this->famid."@ FAM\n"; diff --git a/includes/controllers/individual_ctrl.php b/includes/controllers/individual_ctrl.php index 593894bb98..1d4d5170f0 100644 --- a/includes/controllers/individual_ctrl.php +++ b/includes/controllers/individual_ctrl.php @@ -70,19 +70,7 @@ class IndividualController extends BaseController { $gedrec = find_person_record($this->pid, WT_GED_ID); } if (empty($gedrec)) { - $ct = preg_match('/(\w+):(.+)/', $this->pid, $match); - if ($ct>0) { - $servid = trim($match[1]); - $remoteid = trim($match[2]); - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - $service = ServiceClient::getInstance($servid); - if ($service != null) { - $newrec= $service->mergeGedcomRecord($remoteid, "0 @".$this->pid."@ INDI\n1 RFN ".$this->pid, false); - $gedrec = $newrec; - } - } else { - $gedrec = "0 @".$this->pid."@ INDI\n"; - } + $gedrec = "0 @".$this->pid."@ INDI\n"; } if (WT_USER_ID) { @@ -94,7 +82,7 @@ class IndividualController extends BaseController { } if (find_person_record($this->pid, WT_GED_ID) || find_updated_record($this->pid, WT_GED_ID)!==null) { - $this->indi = new Person($gedrec, false); + $this->indi = new Person($gedrec); $this->indi->ged_id=WT_GED_ID; // This record is from a file } else if (!$this->indi) { return false; @@ -154,38 +142,8 @@ class IndividualController extends BaseController { //-- if the user can edit and there are changes then get the new changes if ($this->show_changes && WT_USER_CAN_EDIT) { $newrec = find_updated_record($this->pid, WT_GED_ID); - if ($newrec) { - //-- get the changed record from the file - //print("jkdsakjhdkjsadkjsakjdhsakd".$newrec); - $remoterfn = get_gedcom_value("RFN", 1, $newrec); - } else { - $remoterfn = get_gedcom_value("RFN", 1, $gedrec); - } - // print "remoterfn=".$remoterfn; - //-- get an updated record from the web service - if (!empty($remoterfn)) { - $parts = explode(':', $remoterfn); - if (count($parts)==2) { - $servid = $parts[0]; - $aliaid = $parts[1]; - if (!empty($servid)&&!empty($aliaid)) { - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - $serviceClient = ServiceClient::getInstance($servid); - if (!is_null($serviceClient)) { - if (!empty($newrec)) $mergerec = $serviceClient->mergeGedcomRecord($aliaid, $newrec, true); - else $mergerec = $serviceClient->mergeGedcomRecord($aliaid, $gedrec, true); - if ($serviceClient->type=="remote") { - $newrec = $mergerec; - } - else { - $gedrec = $mergerec; - } - } - } - } - } if (!empty($newrec)) { - $this->diffindi = new Person($newrec, false); + $this->diffindi = new Person($newrec); $this->diffindi->setChanged(true); $gedrec = $newrec; } diff --git a/includes/controllers/remotelink_ctrl.php b/includes/controllers/remotelink_ctrl.php deleted file mode 100644 index 5b9e5a5242..0000000000 --- a/includes/controllers/remotelink_ctrl.php +++ /dev/null @@ -1,397 +0,0 @@ -<?php -// Add Remote Link Page -// -// Allow a user the ability to add links to people from other servers and other gedcoms. -// -// webtrees: Web based Family History software -// Copyright (C) 2010 webtrees development team. -// -// Derived from PhpGedView -// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. -// -// 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 2 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, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// @version $Id$ - -if (!defined('WT_WEBTREES')) { - header('HTTP/1.0 403 Forbidden'); - exit; -} - -define('WT_REMOTELINK_CTRL_PHP', ''); - -require_once WT_ROOT.'includes/controllers/basecontrol.php'; -require_once WT_ROOT.'includes/functions/functions_edit.php'; -require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - -class RemoteLinkController extends BaseController { - var $has_familysearch=null; - var $pid=null; - var $person=null; - var $server_list=null; - var $gedcom_list=null; - - // Values from the add remote link form. - public $form_txtPID=null; - public $form_cbRelationship='current_person'; - public $form_location=null; - public $form_txtURL=null; - public $form_txtTitle=null; - public $form_txtGID=null; - public $form_txtUsername=null; - public $form_txtPassword=null; - public $form_cbExistingServers=null; - public $form_txtCB_Title=null; - public $form_txtCB_GID=null; - public $form_txtFS_URL=null; - public $form_txtFS_Title=null; - public $form_txtFS_GID=null; - public $form_txtFS_Username=null; - public $form_txtFS_Password=null; - - // Initialize the controller for the add remote link - function init() { - // Coming soon ??? - $this->has_familysearch=file_exists(WT_ROOT.'modules/FamilySearch/familySearchWrapper.php'); - if ($this->has_familysearch) {; - require_once WT_ROOT.'modules/FamilySearch/familySearchWrapper.php'; - } - - // The PID can come from a URL or a form - $this->pid=safe_REQUEST($_REQUEST, 'pid', WT_REGEX_XREF); - - $this->person=Person::getInstance($this->pid); - $this->server_list=get_server_list(); - $this->gedcom_list=get_all_gedcoms(); - - // Other input values come from the form - $this->form_txtPID =safe_POST('txtPID', WT_REGEX_XREF); - $this->form_cbRelationship =safe_POST('cbRelationship'); - $this->form_location =safe_POST('location'); - $this->form_txtURL =safe_POST('txtURL', WT_REGEX_URL); - $this->form_txtTitle =safe_POST('txtTitle', '[^<>"%{};]+'); - $this->form_txtGID =safe_POST('txtGID', preg_quote_array($this->gedcom_list)); - $this->form_txtUsername =safe_POST('txtUsername', WT_REGEX_USERNAME); - $this->form_txtPassword =safe_POST('txtPassword', WT_REGEX_PASSWORD); - $this->form_cbExistingServers=safe_POST('cbExistingServers', array_keys($this->server_list)); - $this->form_txtCB_Title =safe_POST('txtCB_Title', '[^<>"%{};]+'); - $this->form_txtCB_GID =safe_POST('txtCB_GID', preg_quote_array($this->gedcom_list)); - $this->form_txtFS_URL =safe_POST('txtFS_URL', WT_REGEX_URL); - $this->form_txtFS_Title =safe_POST('txtFS_Title', '[^<>"%{};]+'); - $this->form_txtFS_GID =safe_POST('txtFS_GID', preg_quote_array($this->gedcom_list)); - $this->form_txtFS_Username =safe_POST('txtFS_Username', WT_REGEX_USERNAME); - $this->form_txtFS_Password =safe_POST('txtFS_Password', WT_REGEX_PASSWORD); - - if (is_null($this->form_location)) { - if ($this->server_list) { - $this->form_location='existing'; - } else { - $this->form_location='remote'; - } - } - - } - - // Perform the desired action and return true/false success. - function runAction($action) { - switch ($action) { - case 'addlink': - return $this->addLink(); - default: - return false; - } - } - - // Add a remote webtrees server - // - // @param string $title - // @param string $url - // @param string $gedcom_id - // @param string $username - // @param string $password - // @return mixed the serverID of the server to link to - function addRemoteServer($title, $url, $gedcom_id, $username, $password) { - if (!$url || !$gedcom_id || !$username || !$password) { - return null; - } - - if (preg_match('/\?wsdl$/', $url)==0) { - $url.="?wsdl"; - } - - $serverID=$this->checkExistingServer($url, $gedcom_id); - if (!$serverID) { - $gedcom_string="0 @new@ SOUR\n1 URL {$url}\n1 _DBID {$gedcom_id}\n2 _USER {$username}\n2 _PASS {$password}\n3 RESN confidential"; - $service=new ServiceClient($gedcom_string); - $sid=$service->authenticate(); - if (PEAR::isError($sid)) { - $sid=''; - } - if (!$sid) { - echo '<span class="error">failed to authenticate to remote site</span>'; - $serverID=null; - } else { - if (!$title) { - $title=$service->getServiceTitle(); - } - $gedcom_string.="\n1 TITL {$title}"; - $serverID=append_gedrec($gedcom_string, WT_GED_ID); - } - } - return $serverID; - } - - // Add a familySearch server - // - // @param string $title - // @param string $url - // @param string $gedcom_id - // @param string $username - // @param string $password - // @return mixed the serverID of the server to link to - function addFamilySearchServer($title, $url, $gedcom_id, $username, $password) { - $serverID = $this->checkExistingServer($url, $gedcom_id); - if (!$serverID) { - $gedcom_string = "0 @new@ SOUR\n"; - $gedcom_string.= "1 URL ".$url."\n"; - $gedcom_string.= "2 TYPE FamilySearch\n"; - $gedcom_string.= "1 _DBID ".$gedcom_id."\n"; - $gedcom_string.= "2 _USER ".$username."\n"; - $gedcom_string.= "2 _PASS ".$password."\n"; - //-- only allow admin users to see password - $gedcom_string.= "3 RESN confidential\n"; - $service = new FamilySearchWrapper($gedcom_string); - $sid = $service->authenticate(); - if (PEAR::isError($sid)) { - $sid = ''; - } - if (empty($sid)) { - echo "<span class=\"error\">failed to authenticate to remote site</span>"; - } else { - if (empty($title)) { - $title = $service->getServiceTitle(); - } - $title = $service->getServiceTitle(); - $gedcom_string.= "1 TITL ".$title."\n"; - $serverID = append_gedrec($gedcom_string, WT_GED_ID); - } - } - return $serverID; - } - - // Add a server record for a local remote link - // - // @param string $gedcom_id - // @return mixed the serverID of the server to link to - function addLocalServer($title, $gedcom_id) { - $serverID = $this->checkExistingServer(WT_SERVER_NAME.WT_SCRIPT_PATH, $gedcom_id); - if (!$serverID) { - $gedcom_string = "0 @new@ SOUR\n"; - if (empty($title)) { - $title=get_gedcom_setting(get_id_from_gedcom($gedcom_id), 'title'); - } - $gedcom_string.= "1 TITL ".$title."\n"; - $gedcom_string.= "1 URL ".WT_SERVER_NAME.WT_SCRIPT_PATH."\n"; - $gedcom_string.= "1 _DBID ".$gedcom_id."\n"; - $gedcom_string.= "2 _BLOCK false\n"; - $serverID = append_gedrec($gedcom_string, WT_GED_ID); - } - return $serverID; - } - - // check if the server already exists - // - // @param string $url - // @param string $gedcom_id - // @return mixed the id of the server to link to or false if it does not exist - function checkExistingServer($url, $gedcom_id='') { - //-- get rid of the protocol - $turl = preg_replace('~^\w+://~', '', $url); - //-- check the existing server list - foreach ($this->server_list as $id=>$server) { - if (stristr($server['url'], $turl)) { - if (empty($gedcom_id) || preg_match("/\n1 _DBID {$gedcom_id}/", $server['gedcom'])) - return $id; - } - } - - //-- check for recent additions - return WT_DB::prepare( - "SELECT xref". - " FROM `##change`". - " WHERE status='pending' AND gedcom_id=? AND new_gedcom LIKE CONCAT('%\n1 _DBID ', ?, '%')". - " ORDER BY change_id DESC". - " LIMIT 1" - )->execute(array(WT_GED_ID, $gedcom_id))->fetchOne(); - } - - function addLink() { - global $GEDCOM; - - switch ($this->form_location) { - case 'remote': - $serverID=$this->addRemoteServer( - $this->form_txtTitle, - $this->form_txtURL, - $this->form_txtGID, - $this->form_txtUsername, - $this->form_txtPassword - ); - break; - case 'local': - $serverID=$this->addLocalServer( - $this->form_txtCB_Title, - $this->form_txtCB_GID - ); - break; - case 'existing': - $serverID=$this->form_cbExistingServers; - break; - case "FamilySearch": - //TODO: Make sure that it is merging correctly - $serverID=$this->addFamilySearchServer( - $this->form_txtFS_URL, - $this->form_txtFS_URL, - $this->form_txtFS_GID, - $this->form_txtFS_Username, - $this->form_txtFS_Password - ); - break; - } - - $link_pid =$this->form_txtPID; - $relation_type=$this->form_cbRelationship; - if ($serverID && $link_pid) { - $indirec=find_gedcom_record($this->pid, WT_GED_ID, true); - - switch ($relation_type) { - case "father": - $indistub="0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}"; - $stub_id=append_gedrec($indistub, WT_GED_ID); - $indistub=find_gedcom_record($stub_id, WT_GED_ID, true); - - $gedcom_fam="0 @new@ FAM\n1 HUSB @{$stub_id}@\n1 CHIL @{$this->pid}@"; - $fam_id=append_gedrec($gedcom_fam, WT_GED_ID); - - $indirec.= "\n1 FAMC @{$fam_id}@"; - replace_gedrec($this->pid, WT_GED_ID, $indirec); - - $serviceClient=ServiceClient::getInstance($serverID); - $indistub=$serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true); - $indistub.="\n1 FAMS @{$fam_id}@"; - replace_gedrec($stub_id, WT_GED_ID, $indistub); - break; - case "mother": - $indistub="0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}"; - $stub_id=append_gedrec($indistub, WT_GED_ID); - $indistub=find_gedcom_record($stub_id, WT_GED_ID, true); - - $gedcom_fam="0 @new@ FAM\n1 WIFE @{$stub_id}@\n1 CHIL @{$this->pid}@"; - $fam_id=append_gedrec($gedcom_fam, WT_GED_ID); - - $indirec.="\n1 FAMC @{$fam_id}@"; - replace_gedrec($this->pid, WT_GED_ID, $indirec); - - $serviceClient=ServiceClient::getInstance($serverID); - $indistub=$serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true); - $indistub.="\n1 FAMS @".$fam_id."@"; - replace_gedrec($stub_id, WT_GED_ID, $indistub); - break; - case "husband": - $indistub="0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}"; - $stub_id=append_gedrec($indistub, WT_GED_ID); - $indistub=find_gedcom_record($stub_id, WT_GED_ID, true); - - $gedcom_fam="0 @new@ FAM\n1 MARR Y\n1 WIFE @{$this->pid}@\n1 HUSB @{$stub_id}@\n"; - $fam_id=append_gedrec($gedcom_fam, WT_GED_ID); - - $indirec.="\n1 FAMS @{$fam_id}@"; - replace_gedrec($this->pid, WT_GED_ID, $indirec); - - $serviceClient=ServiceClient::getInstance($serverID); - $indistub=$serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true); - $indistub.="\n1 FAMS @{$fam_id}@"; - replace_gedrec($stub_id, WT_GED_ID, $indistub); - break; - case "wife": - $indistub="0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}"; - $stub_id=append_gedrec($indistub, WT_GED_ID); - $indistub=find_gedcom_record($stub_id, WT_GED_ID, true); - - $gedcom_fam="0 @new@ FAM\n1 MARR Y\n1 WIFE @{$stub_id}@\n1 HUSB @{$this->pid}@"; - $fam_id=append_gedrec($gedcom_fam, WT_GED_ID); - - $indirec.="\n1 FAMS @{$fam_id}@"; - replace_gedrec($this->pid, WT_GED_ID, $indirec); - - $serviceClient=ServiceClient::getInstance($serverID); - $indistub=$serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true); - $indistub.="\n1 FAMS @{$fam_id}@\n"; - replace_gedrec($stub_id, WT_GED_ID, $indistub); - break; - case "son": - case "daughter": - $indistub="0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}"; - $stub_id=append_gedrec($indistub, WT_GED_ID); - $indistub=find_gedcom_record($stub_id, WT_GED_ID, true); - - if (get_gedcom_value('SEX', 1, $indirec, '', false)=='F') { - $gedcom_fam="0 @new@ FAM\n1 WIFE @{$this->pid}@\n1 CHIL @{$stub_id}@"; - } else { - $gedcom_fam="0 @new@ FAM\n1 HUSB @{$this->pid}@\n1 CHIL @{$stub_id}@"; - } - $fam_id=append_gedrec($gedcom_fam, WT_GED_ID); - $indirec.="\n1 FAMS @{$fam_id}@"; - replace_gedrec($this->pid, WT_GED_ID, $indirec); - - $serviceClient=ServiceClient::getInstance($serverID); - $indistub=$serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true); - $indistub.="\n1 FAMC @".$fam_id."@"; - replace_gedrec($stub_id, WT_GED_ID, $indistub); - break; - case 'current_person': - $indirec.="\n1 RFN {$serverID}:{$link_pid}\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}"; - - $serviceClient = ServiceClient::getInstance($serverID); - if (!is_null($serviceClient)) { - //-- get rid of change date - $pos1=strpos($indirec, "\n1 CHAN"); - if ($pos1!==false) { - $pos2=strpos($indirec, "\n1", $pos1+5); - $indirec=substr($indirec, 0, $pos1).substr($indirec, $pos2); - } - $indirec=$serviceClient->mergeGedcomRecord($link_pid, $indirec, true, true); - } else { - echo 'Unable to find server'; - } - break; - } - echo '<b>', i18n::translate('Successfully added link'), '</b>'; - return true; - } - return false; - } - - /** - * whether or not the user has access to this area - * - * @return boolean - */ - function canAccess() { - global $ALLOW_EDIT_GEDCOM; - - return $ALLOW_EDIT_GEDCOM && WT_USER_GEDCOM_ADMIN && $this->person->canDisplayDetails(); - } -} diff --git a/includes/controllers/search_ctrl.php b/includes/controllers/search_ctrl.php index 29dd72d68d..35aeabbaea 100644 --- a/includes/controllers/search_ctrl.php +++ b/includes/controllers/search_ctrl.php @@ -47,8 +47,6 @@ class SearchController extends BaseController { var $indiResultsPrinted = -1; var $famResultsPrinted = -1; var $srcResultsPrinted = -1; - var $multiResultsPerPage = -1; - var $multiTotalResults = -1; var $query; var $myquery = ""; //var $soundex = "Russell"; @@ -57,8 +55,6 @@ class SearchController extends BaseController { var $nameprt = ""; var $tagfilter = "on"; var $showasso = "off"; - var $multiquery=""; - var $mymultiquery; var $name=""; var $myname; var $birthdate=""; @@ -80,12 +76,10 @@ class SearchController extends BaseController { var $year=""; var $myyear; var $sgeds = array (); - var $Sites = array (); var $myindilist = array (); var $mysourcelist = array (); var $myfamlist = array (); var $mynotelist = array (); - var $multisiteResults = array (); var $inputFieldNames = array (); var $replace = false; var $replaceNames = false; @@ -134,7 +128,7 @@ class SearchController extends BaseController { } // Aquire all the variables values from the $_REQUEST - $varNames = array ("isPostBack", "action", "topsearch", "srfams", "srindi", "srsour", "srnote", "view", "soundex", "subaction", "nameprt", "tagfilter", "showasso", "resultsPageNum", "resultsPerPage", "totalResults", "totalGeneralResults", "indiResultsPrinted", "famResultsPrinted", "multiTotalResults", "srcResultsPrinted", "multiResultsPerPage", "myindilist", "mysourcelist", "mynotelist", "myfamlist"); + $varNames = array ("isPostBack", "action", "topsearch", "srfams", "srindi", "srsour", "srnote", "view", "soundex", "subaction", "nameprt", "tagfilter", "showasso", "resultsPageNum", "resultsPerPage", "totalResults", "totalGeneralResults", "indiResultsPrinted", "famResultsPrinted", "srcResultsPrinted", "myindilist", "mysourcelist", "mynotelist", "myfamlist"); $this->setRequestValues($varNames); if (!$this->isPostBack) { @@ -157,9 +151,6 @@ class SearchController extends BaseController { $this->sgeds[WT_GED_ID] = $GEDCOM; } - // Retrieve the sites that can be searched - $this->Sites = get_server_list(); - // vars use for soundex search if (!empty ($_REQUEST["firstname"])) { $this->firstname = $_REQUEST["firstname"]; @@ -194,14 +185,6 @@ class SearchController extends BaseController { $this->myquery=htmlspecialchars(implode(' ', array($this->firstname, $this->lastname, $this->place))); }; - // vars use for multisite search - if (!empty ($_REQUEST["multiquery"])) { - $this->multiquery = $_REQUEST["multiquery"]; - $this->mymultiquery = $this->multiquery; - } else { - $this->multiquery=""; - $this->mymultiquery = ""; - } if (!empty ($_REQUEST["name"])) { $this->name = $_REQUEST["name"]; $this->myname = $this->name; @@ -261,7 +244,6 @@ class SearchController extends BaseController { $this->inputFieldNames[] = "soundex"; $this->inputFieldNames[] = "nameprt"; $this->inputFieldNames[] = "subaction"; - $this->inputFieldNames[] = "multiquery"; $this->inputFieldNames[] = "name"; $this->inputFieldNames[] = "birthdate"; $this->inputFieldNames[] = "birthplace"; @@ -285,10 +267,6 @@ class SearchController extends BaseController { case 'replace': $this->SearchAndReplace(); return; - case 'multisite': - $this->MultiSiteSearch(); - break; - } } @@ -300,8 +278,6 @@ class SearchController extends BaseController { return i18n::translate('Soundex Search'); case 'replace': return i18n::translate('Search and replace'); - case 'multisite': - return i18n::translate('Multi Site Search'); } } @@ -643,77 +619,6 @@ class SearchController extends BaseController { usort($this->myfamlist, array('GedcomRecord', 'Compare')); } - /** - * - */ - function MultiSiteSearch() { - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - - if (!empty ($this->Sites) && count($this->Sites) > 0) { - $this->myindilist = array (); - // This first tests to see if it just a basic site search - if (!empty ($this->multiquery) && ($this->subaction == "basic")) { - // Find out if the string is longer then one char if dont perform the search - if (strlen($this->multiquery) > 1) { - $my_query = $this->multiquery; - // Now see if there is a query left after the cleanup - if (trim($my_query) != "") { - // Cleanup the querystring so it can be used in a database query - $my_query = "%".preg_replace("/\s+/", "%", $my_query)."%"; - } - } - - } else - if (($this->subaction == "advanced") && (!empty ($this->myname) || !empty ($this->mybirthdate) || !empty ($this->mybirthplace) || !empty ($this->deathdate) || !empty ($this->mydeathplace) || !empty ($this->mygender))) { - //Building the query string up - $my_query = ''; - if (!empty ($this->myname)) { - $my_query .= "NAME=".$this->myname; - } - if (!empty ($this->mybirthdate)) { - if ($my_query != '') - $my_query .= '&'; - $my_query .= "BIRTHDATE=".$this->mybirthdate; - } - if (!empty ($this->mybirthplace)) { - if ($my_query != '') - $my_query .= '&'; - $my_query .= "BIRTHPLACE=".$this->mybirthplace; - } - if (!empty ($this->deathdate)) { - if ($my_query != '') - $my_query .= '&'; - $my_query .= "DEATHDATE=".$this->deathdate; - } - if (!empty ($this->mydeathplace)) { - if ($my_query != '') - $my_query .= '&'; - $my_query."DEATHPLACE=".$this->mydeathplace; - } - if (!empty ($this->mygender)) { - if ($my_query != '') - $my_query .= '&'; - $my_query .= "GENDER=".$this->mygender; - } - } - - if (!empty ($my_query)) { - $this->multisiteResults = array (); - // loop through the selected site to search - $i = 0; - foreach ($this->Sites as $key => $site) { - $vartemp = "server".$i; - if (isset ($_REQUEST["$vartemp"])) { - $serviceClient = ServiceClient :: getInstance($key); - $result = $serviceClient->search($my_query); - $this->multisiteResults[$key] = $result; - } - $i++; - } - } - } - } - function printResults() { require_once WT_ROOT.'includes/functions/functions_print_lists.php'; global $GEDCOM, $TEXT_DIRECTION, $WT_IMAGES; @@ -803,122 +708,6 @@ class SearchController extends BaseController { $this->printPageResultsLinks($this->inputFieldNames, $this->totalGeneralResults, $this->resultsPerPage); } } - - // ----- section to search and display results for multisite - if ($this->action == "multisite") { - // Only Display 5 results per 2 sites if the total results per page is 10 - $sitesChecked = 0; - $i = 0; - foreach ($this->Sites as $server) { - $siteName = "server".$i; - if (isset ($_REQUEST["$siteName"])) - $sitesChecked ++; - $i ++; - } - if ($sitesChecked >= 1) { - $this->multiResultsPerPage = $this->resultsPerPage / $sitesChecked; - - if (!empty ($this->Sites) && count($this->Sites) > 0) { - $no_results_found = false; - // Start output here, because from the indi's we may have printed some fams which need the column header. - echo "<br />"; - echo "<div class=\"center\">"; - - if (isset ($this->multisiteResults) && (count($this->multisiteResults) > 0)) { - $this->totalResults = 0; - $this->multiTotalResults = 0; - $somethingPrinted = true; - foreach ($this->multisiteResults as $key => $siteResults) { - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - $serviceClient = ServiceClient :: getInstance($key); - $siteName = $serviceClient->getServiceTitle(); - $siteURL = dirname($serviceClient->getURL()); - - echo "<table id=\"multiResultsOutTbl\" class=\"list_table, $TEXT_DIRECTION\" align=\"center\">"; - - if (isset ($siteResults) && !empty ($siteResults->persons)) { - $displayed_once = false; - $personlist = $siteResults->persons; - - /***************************************************** PAGING HERE **********************************************************************/ - - //set the total results and only get the results for this page - $this->multiTotalResults += count($personlist); - if ($this->totalResults < $this->multiTotalResults) - $this->totalResults = $this->multiTotalResults; - $personlist = $this->getPagedResults($personlist, $this->multiResultsPerPage); - $pageResultsNum = 0; - foreach ($personlist as $index => $person) { - //if there is a name to display then diplay it - if (!empty ($person->gedcomName)) { - if (!$displayed_once) { - if (!$no_results_found) { - $no_results_found = true; - echo "<tr><td class=\"list_label\" colspan=\"2\" width=\"100%\">"; - if (isset($WT_IMAGES["indis"])) echo "<img src=\"".$WT_IMAGES["indis"]."\" border=\"0\" width=\"25\" alt=\"\" /> "; - echo i18n::translate('People')."</td></tr>"; - echo "<tr><td><table id=\"multiResultsInTbl\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" ><tr>"; - } - $displayed_once = true; - echo "<td class=\"list_label\" colspan=\"2\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" >".i18n::translate('Site: ')."<a href=\"".$siteURL."\" target=\"_blank\">".$siteName."</a>".i18n::translate(' contained the following')."</td></tr>"; - } - echo "<tr><td class=\"list_value $TEXT_DIRECTION\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" valign=\"center\" ><ul>"; - echo "<li class=\"$TEXT_DIRECTION\" dir=\"$TEXT_DIRECTION\">"; - echo "<a href=\"{$siteURL}/individual.php?pid={$person->PID}&ged=".rawurlencode($serviceClient->gedfile)."\" target=\"_blank\">"; - $pageResultsNum += 1; - echo "<b>".$person->getFullName()."</b>"; - if (!empty ($person->PID)) { - echo " (".$person->PID.")"; - } - if (!empty ($person->birthDate) || !empty ($person->birthPlace)) { - echo " -- <i>"; - if (!empty ($person->birthDate)) { - echo " ".$person->birthDate; - } - if (!empty ($person->birthPlace)) { - echo " ".$person->birthPlace; - } - echo "</i>"; - } - echo "</a></li></ul></td>"; - - /******************************* Remote Links Per Result *************************************************/ - if (WT_USER_CAN_EDIT) { - echo "<td class=\"list_value $TEXT_DIRECTION\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" >"."<ul style=\"list-style: NONE\"><li><a href=\"javascript:;\" "."onclick=\"return open_link('".$key."', '".$person->PID."', '".$person->getFullName()."');\">"."<b>".i18n::translate('Add Local Link')."</b></a></ul></li></td></tr>"; - } - } - } - - echo "</table>"; - - echo " </td></tr></table>"; - } - if ($this->multiTotalResults > 0) { - echo "</tr><tr><td align=\"left\">Displaying individuals "; - echo (($this->multiResultsPerPage * $this->resultsPageNum) + 1)." ".i18n::translate('to')." ". (($this->multiResultsPerPage * $this->resultsPageNum) + $pageResultsNum); - echo " ".i18n::translate('of')." ". ($this->multiTotalResults)."</td></tr></table>"; - $this->multiTotalResults = 0; - } else - echo "</tr></table>"; - } - echo "</table>"; - } - echo '</div>'; - if (!$no_results_found && $this->multiTotalResults == 0 && (isset ($this->multiquery) || isset ($this->name) || isset ($this->birthdate) || isset ($this->birthplace) || isset ($this->deathdate) || isset ($this->deathplace) || isset ($this->gender))) { - echo "<table align=\"center\" \><td class=\"warning\" style=\" text-align: center;\"><font color=\"red\"><b><i>".i18n::translate('No results found.')."</i></b></font><br /></td></tr></table>"; - } - } - } else - if ($sitesChecked < 1 && $this->isPostBack) { - echo "<table align=\"center\" \><tr><td class=\"warning\" style=\" text-align: center;\"><font color=\"red\"><b><i>".i18n::translate('Be sure to select at least one remote site.')."</i></b></font><br /></td></tr></table>"; - } - - echo "</table>"; - // Prints the Paged Results: << 1 2 3 4 >> links if there are more than $this->resultsPerPage results - if ($this->resultsPerPage > 1 && $this->totalResults > $this->resultsPerPage) { - $this->printPageResultsLinks($this->inputFieldNames, $this->totalResults, $this->multiResultsPerPage); - } - } return $somethingPrinted; // whether anything printed } diff --git a/includes/functions/functions.php b/includes/functions/functions.php index fe76f48646..6319c8dea4 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -294,7 +294,6 @@ function load_gedcom_settings($ged_id=WT_GED_ID) { global $SHOW_MARRIED_NAMES; $SHOW_MARRIED_NAMES =get_gedcom_setting($ged_id, 'SHOW_MARRIED_NAMES'); global $SHOW_MEDIA_DOWNLOAD; $SHOW_MEDIA_DOWNLOAD =get_gedcom_setting($ged_id, 'SHOW_MEDIA_DOWNLOAD'); global $SHOW_MEDIA_FILENAME; $SHOW_MEDIA_FILENAME =get_gedcom_setting($ged_id, 'SHOW_MEDIA_FILENAME'); - global $SHOW_MULTISITE_SEARCH; $SHOW_MULTISITE_SEARCH =get_gedcom_setting($ged_id, 'SHOW_MULTISITE_SEARCH'); global $SHOW_NO_WATERMARK; $SHOW_NO_WATERMARK =get_gedcom_setting($ged_id, 'SHOW_NO_WATERMARK'); global $SHOW_PARENTS_AGE; $SHOW_PARENTS_AGE =get_gedcom_setting($ged_id, 'SHOW_PARENTS_AGE'); global $SHOW_PEDIGREE_PLACES; $SHOW_PEDIGREE_PLACES =get_gedcom_setting($ged_id, 'SHOW_PEDIGREE_PLACES'); @@ -975,25 +974,6 @@ function find_highlighted_object($pid, $ged_id, $indirec) { $objectC = array(); $objectD = array(); - //-- handle finding the media of remote objects - $ct = preg_match("/(.*):(.*)/", $pid, $match); - if ($ct>0) { - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - $client = ServiceClient::getInstance($match[1]); - if (!is_null($client)) { - $mt = preg_match_all('/\n\d OBJE @('.WT_REGEX_XREF.')@/', $indirec, $matches, PREG_SET_ORDER); - for ($i=0; $i<$mt; $i++) { - $mediaObj = Media::getInstance($matches[$i][1]); - $mrec = $mediaObj->getGedcomRecord(); - if (!empty($mrec)) { - $file = get_gedcom_value("FILE", 1, $mrec); - $row = array($matches[$i][1], $file, $mrec, $matches[$i][0]); - $media[] = $row; - } - } - } - } - //-- find all of the media items for a person $media= WT_DB::prepare("SELECT m_media, m_file, m_gedrec, mm_gedrec FROM `##media`, `##media_mapping` WHERE m_media=mm_media AND m_gedfile=mm_gedfile AND m_gedfile=? AND mm_gid=? ORDER BY mm_order") @@ -3561,8 +3541,3 @@ function pathinfo_utf($path) { return array('dirname'=>$dirname, 'basename'=>$basename, 'extension'=>$extension, 'filename'=>$filename); } - -// optional extra file -if (file_exists(WT_ROOT.'includes/functions.extra.php')) { - require WT_ROOT.'includes/functions.extra.php'; -} diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php index 293d476ad1..50d2c0387f 100644 --- a/includes/functions/functions_db.php +++ b/includes/functions/functions_db.php @@ -1650,27 +1650,6 @@ function get_top_surnames($ged_id, $min, $max) { } } -/** -* get a list of remote servers -*/ -function get_server_list($ged_id=WT_GED_ID) { - $sitelist = array(); - - $rows=WT_DB::prepare("SELECT s_id, s_name, s_gedcom, s_file FROM `##sources` WHERE s_file=? AND s_dbid=? ORDER BY s_name") - ->execute(array($ged_id, 'Y')) - ->fetchAll(); - foreach ($rows as $row) { - $source = array(); - $source["name"] = $row->s_name; - $source["gedcom"] = $row->s_gedcom; - $source["gedfile"] = $row->s_file; - $source["url"] = get_gedcom_value("URL", 1, $row->s_gedcom); - $sitelist[$row->s_id] = $source; - } - - return $sitelist; -} - function delete_fact($linenum, $pid, $gedrec) { global $linefix; @@ -1715,20 +1694,6 @@ function delete_fact($linenum, $pid, $gedrec) { } } -/** -* get_remote_id Recieves a RFN key and returns a Stub ID if the RFN exists -* -* @param mixed $rfn RFN number to see if it exists -* @access public -* @return gid Stub ID that contains the RFN number. Returns false if it didn't find anything -*/ -function get_remote_id($rfn) { - return - WT_DB::prepare("SELECT r_gid FROM `##remotelinks` WHERE r_linkid=? AND r_file=?") - ->execute(array($rfn, WT_GED_ID)) - ->fetchOne(); -} - //////////////////////////////////////////////////////////////////////////////// // Get a list of events whose anniversary occured on a given julian day. // Used on the on-this-day/upcoming blocks and the day/month calendar views. diff --git a/includes/functions/functions_edit.php b/includes/functions/functions_edit.php index 338038652c..6708492638 100644 --- a/includes/functions/functions_edit.php +++ b/includes/functions/functions_edit.php @@ -291,13 +291,6 @@ function edit_field_default_tab($name, $selected='', $extra='') { return select_edit_control($name, $tabs, null, $selected, $extra); } -//-- this function creates a new unique connection -//-- and adds it to the connections file -//-- it returns the connection identifier -function newConnection() { - return WT_SESSION_NAME."\t".Zend_Session::getId()."\n"; -} - /** * Check if the given gedcom record has changed since the last session access * This is used to check if the gedcom record changed between the time the user diff --git a/includes/functions/functions_import.php b/includes/functions/functions_import.php index bc6b4ae2f5..c68b572d92 100644 --- a/includes/functions/functions_import.php +++ b/includes/functions/functions_import.php @@ -597,7 +597,7 @@ function import_record($gedrec, $ged_id, $update) { "INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil) VALUES (?,?,?,?,?,?)" ); $sql_insert_sour=WT_DB::prepare( - "INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom, s_dbid) VALUES (?,?,?,?,?)" + "INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom) VALUES (?,?,?,?)" ); $sql_insert_other=WT_DB::prepare( "INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom) VALUES (?,?,?,?)" @@ -669,7 +669,6 @@ function import_record($gedrec, $ged_id, $update) { update_places($xref, $ged_id, $gedrec); update_dates ($xref, $ged_id, $gedrec); update_links ($xref, $ged_id, $gedrec); - update_rlinks($xref, $ged_id, $gedrec); update_names ($xref, $ged_id, $record); switch ($type) { @@ -714,12 +713,7 @@ function import_record($gedrec, $ged_id, $update) { } else { $name=$xref; } - if (strpos($gedrec, "\n1 _DBID")) { - $_dbid='Y'; - } else { - $_dbid=null; - } - $sql_insert_sour->execute(array($xref, $ged_id, $name, $gedrec, $_dbid)); + $sql_insert_sour->execute(array($xref, $ged_id, $name, $gedrec)); break; case 'OBJE': // OBJE records are imported by update_media function @@ -856,25 +850,6 @@ function update_dates($xref, $ged_id, $gedrec) { return; } -// extract all the remote links from the given record and insert them into the database -function update_rlinks($xref, $ged_id, $gedrec) { - static $sql_insert_rlink=null; - if (!$sql_insert_rlink) { - $sql_insert_rlink=WT_DB::prepare("INSERT INTO `##remotelinks` (r_gid,r_linkid,r_file) VALUES (?,?,?)"); - } - - if (preg_match_all("/\n1 RFN (".WT_REGEX_XREF.')/', $gedrec, $matches, PREG_SET_ORDER)) { - foreach ($matches as $match) { - // Ignore any errors, which may be caused by "duplicates" that differ on case/collation, e.g. "S1" and "s1" - try { - $sql_insert_rlink->execute(array($xref, $match[1], $ged_id)); - } catch (PDOException $e) { - // We could display a warning here.... - } - } - } -} - // extract all the links from the given record and insert them into the database function update_links($xref, $ged_id, $gedrec) { static $sql_insert_link=null; @@ -1160,7 +1135,6 @@ function empty_database($ged_id, $keepmedia) { WT_DB::prepare("DELETE FROM `##other` WHERE o_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM `##places` WHERE p_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM `##placelinks` WHERE pl_file=?")->execute(array($ged_id)); - WT_DB::prepare("DELETE FROM `##remotelinks` WHERE r_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM `##name` WHERE n_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM `##dates` WHERE d_file =?")->execute(array($ged_id)); WT_DB::prepare("DELETE FROM `##change` WHERE gedcom_id=?")->execute(array($ged_id)); @@ -1261,7 +1235,6 @@ function update_record($gedrec, $ged_id, $delete) { } WT_DB::prepare("DELETE FROM `##media_mapping` WHERE mm_gid=? AND mm_gedfile=?")->execute(array($gid, $ged_id)); - WT_DB::prepare("DELETE FROM `##remotelinks` WHERE r_gid=? AND r_file=?")->execute(array($gid, $ged_id)); WT_DB::prepare("DELETE FROM `##name` WHERE n_id=? AND n_file=?")->execute(array($gid, $ged_id)); WT_DB::prepare("DELETE FROM `##link` WHERE l_from=? AND l_file=?")->execute(array($gid, $ged_id)); diff --git a/includes/functions/functions_print_facts.php b/includes/functions/functions_print_facts.php index 054752cf78..1777adfc14 100644 --- a/includes/functions/functions_print_facts.php +++ b/includes/functions/functions_print_facts.php @@ -1359,46 +1359,22 @@ function print_main_media($pid, $level=1, $related=false, $noedit=false) { foreach ($current_objes as $media_id=>$value) { while ($value>0) { $objSubrec = array_pop($obje_links[$media_id]); - //-- check if we need to get the object from a remote location - $ct = preg_match("/(.*):(.*)/", $media_id, $match); - if ($ct>0) { - require_once WT_ROOT.'includes/classes/class_serviceclient.php'; - $client = ServiceClient::getInstance($match[1]); - if (!is_null($client)) { - $newrec = $client->getRemoteRecord($match[2]); - $row['m_media'] = $media_id; - $row['m_gedfile']=$ged_id; - $row['m_file'] = get_gedcom_value("FILE", 1, $newrec); - $row['m_titl'] = get_gedcom_value("TITL", 1, $newrec); - if (empty($row['m_titl'])) $row['m_titl'] = get_gedcom_value("FILE:TITL", 1, $newrec); - $row['m_gedrec'] = $newrec; - $et = preg_match("/(\.\w+)$/", $row['m_file'], $ematch); - $ext = ""; - if ($et>0) $ext = substr(trim($ematch[1]), 1); - $row['m_ext'] = $ext; - $row['mm_gid'] = $pid; - $row['mm_gedrec'] = get_sub_record($objSubrec{0}, $objSubrec, $gedrec); - $res = print_main_media_row('normal', $row, $pid); - $media_found = $media_found || $res; - } - } else { - $row = array(); - $newrec = find_gedcom_record($media_id, $ged_id, true); - $row['m_media'] = $media_id; - $row['m_gedfile']=$ged_id; - $row['m_file'] = get_gedcom_value("FILE", 1, $newrec); - $row['m_titl'] = get_gedcom_value("TITL", 1, $newrec); - if (empty($row['m_titl'])) $row['m_titl'] = get_gedcom_value("FILE:TITL", 1, $newrec); - $row['m_gedrec'] = $newrec; - $et = preg_match("/(\.\w+)$/", $row['m_file'], $ematch); - $ext = ""; - if ($et>0) $ext = substr(trim($ematch[1]), 1); - $row['m_ext'] = $ext; - $row['mm_gid'] = $pid; - $row['mm_gedrec'] = get_sub_record($objSubrec{0}, $objSubrec, $gedrec); - $res = print_main_media_row('new', $row, $pid); - $media_found = $media_found || $res; - } + $row = array(); + $newrec = find_gedcom_record($media_id, $ged_id, true); + $row['m_media'] = $media_id; + $row['m_gedfile']=$ged_id; + $row['m_file'] = get_gedcom_value("FILE", 1, $newrec); + $row['m_titl'] = get_gedcom_value("TITL", 1, $newrec); + if (empty($row['m_titl'])) $row['m_titl'] = get_gedcom_value("FILE:TITL", 1, $newrec); + $row['m_gedrec'] = $newrec; + $et = preg_match("/(\.\w+)$/", $row['m_file'], $ematch); + $ext = ""; + if ($et>0) $ext = substr(trim($ematch[1]), 1); + $row['m_ext'] = $ext; + $row['mm_gid'] = $pid; + $row['mm_gedrec'] = get_sub_record($objSubrec{0}, $objSubrec, $gedrec); + $res = print_main_media_row('new', $row, $pid); + $media_found = $media_found || $res; $value--; } } diff --git a/includes/session.php b/includes/session.php index 68da16de39..9192508952 100644 --- a/includes/session.php +++ b/includes/session.php @@ -48,7 +48,7 @@ define('WT_DEBUG_SQL', false); define('WT_ERROR_LEVEL', 2); // 0=none, 1=minimal, 2=full // Required version of database tables/columns/indexes/etc. -define('WT_SCHEMA_VERSION', 6); +define('WT_SCHEMA_VERSION', 7); // Regular expressions for validating user input, etc. define('WT_REGEX_XREF', '[A-Za-z0-9:_-]+'); @@ -303,15 +303,6 @@ if ($SEARCH_SPIDER) { Zend_Session::setId('search_engine_'.$_SERVER['REMOTE_ADDR']); } -// If we're using remote linking, the session ID is in the body of the POST request -if ( - WT_SCRIPT_NAME=='genservice.php' && - isset($HTTP_RAW_POST_DATA) && - preg_match('/<SID xsi:type="xsd:string">([a-z0-9]+)<\/SID>/', $HTTP_RAW_POST_DATA, $match) -) { - Zend_Session::setId($match[1]); -} - Zend_Session::start($cfg); // Register a session "namespace" to store session data. This is better than diff --git a/includes/session_spider.php b/includes/session_spider.php index 89e313c563..a19b24dccb 100644 --- a/includes/session_spider.php +++ b/includes/session_spider.php @@ -225,20 +225,13 @@ if ($ua != "") { } } } -} -else { +} else { // For the people who firewall identifying information // Switch real to false if you wish to restrict these connections. $ua = "Browser User Agent Empty"; $real = true; } -if (WT_SCRIPT_NAME=='genservice.php') { - // Robots look very similar to remote-link requests. Allow them to - // access the remote linking service. - $real=true; -} - if (!$real) { $bot_name = $ua; // strip out several common strings that clutter the User Agent. diff --git a/includes/set_gedcom_defaults.php b/includes/set_gedcom_defaults.php index 75d4131499..7cc95c5f73 100644 --- a/includes/set_gedcom_defaults.php +++ b/includes/set_gedcom_defaults.php @@ -124,7 +124,6 @@ set_gedcom_setting($ged_id, 'SHOW_LIVING_NAMES', WT_PRIV_USER); set_gedcom_setting($ged_id, 'SHOW_MARRIED_NAMES', true); set_gedcom_setting($ged_id, 'SHOW_MEDIA_DOWNLOAD', false); set_gedcom_setting($ged_id, 'SHOW_MEDIA_FILENAME', false); -set_gedcom_setting($ged_id, 'SHOW_MULTISITE_SEARCH', WT_PRIV_NONE); set_gedcom_setting($ged_id, 'SHOW_NO_WATERMARK', WT_PRIV_USER); set_gedcom_setting($ged_id, 'SHOW_PARENTS_AGE', true); set_gedcom_setting($ged_id, 'SHOW_PEDIGREE_PLACES', '9'); |
