Ejemplo n.º 1
0
 /**
  * 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, $this->gedfile);
     $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) {
         include_once "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, $localrec);
         }
     }
     return $localrec;
 }
Ejemplo n.º 2
0
            if (!isset($pgv_changes[$pid . "_" . $GEDCOM])) {
                $gedrec = find_gedcom_record($pid);
            } else {
                $gedrec = find_updated_record($pid);
            }
        }
        $newrec = "0 @{$pid}@ OBJE\n";
        $newrec = handle_updates($newrec);
        if (!$update_CHAN) {
            $newrec .= get_sub_record(1, "1 CHAN", $gedrec);
        }
        //print("[".$newrec."]");
        //-- look for the old record media in the file
        //-- if the old media record does not exist that means it was
        //-- generated at import and we need to append it
        if (replace_gedrec($pid, $newrec, $update_CHAN)) {
            AddToChangeLog("Media ID " . $pid . " successfully updated.");
        }
        if ($pid && $linktoid != "") {
            $link = linkMedia($pid, $linktoid, $level);
            if ($link) {
                AddToChangeLog("Media ID " . $pid . " successfully added to {$linktoid}.");
            }
        }
    }
    if ($finalResult) {
        print $pgv_lang["update_successful"];
    }
}
// **** end action "update"
// **** begin action "delete"
Ejemplo n.º 3
0
             print "SUCCESS\n" . ${$var};
         } else {
             addDebugLog($action . " var={$var} ERROR 13: Invalid variable specified.  Please provide a variable.");
             print "ERROR 13: Invalid variable specified.\n";
         }
     }
     exit;
 case 'update':
     $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF);
     if ($xref) {
         $gedrec = safe_REQUEST($_REQUEST, 'gedrec', PGV_REGEX_UNSAFE);
         // raw data may contain any characters
         if ($gedrec) {
             if (empty($_SESSION['readonly']) && PGV_USER_CAN_EDIT && displayDetailsById($xref)) {
                 $gedrec = preg_replace(array("/\\\\+r/", "/\\\\+n/"), array("\r", "\n"), $gedrec);
                 $success = replace_gedrec($xref, $gedrec);
                 if ($success) {
                     addDebugLog($action . " xref={$xref} gedrec={$gedrec} SUCCESS");
                     print "SUCCESS\n";
                 }
             } else {
                 addDebugLog($action . " xref={$xref} ERROR 11: No write privileges for this record.");
                 print "ERROR 11: No write privileges for this record.\n";
             }
         } else {
             addDebugLog($action . " xref={$xref} ERROR 8: No gedcom record provided.  Unable to process request.");
             print "ERROR 8: No gedcom record provided.  Unable to process request.\n";
         }
     } else {
         addDebugLog($action . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
Ejemplo n.º 4
0
/**
* Delete a person and update all records that link to that person
* @param string $pid the id of the person to delete
* @param string $gedrec the gedcom record of the person to delete
* @return boolean true or false based on the successful completion of the deletion
*/
function delete_family($pid, $gedrec = '')
{
    // NOTE: $pgv_changes isn't a global.  Making it global appears to cause problems.
    global $GEDCOM, $pgv_lang;
    if (empty($gedrec)) {
        $gedrec = find_family_record($pid);
    }
    if (!empty($gedrec)) {
        $success = true;
        $ct = preg_match_all("/1 (\\w+) @(.*)@/", $gedrec, $match, PREG_SET_ORDER);
        for ($i = 0; $i < $ct; $i++) {
            $type = $match[$i][1];
            $id = $match[$i][2];
            if (PGV_DEBUG) {
                echo $type . " " . $id . " ";
            }
            if (!isset($pgv_changes[$id . "_" . $GEDCOM])) {
                $indirec = find_gedcom_record($id);
            } else {
                $indirec = find_updated_record($id);
            }
            if (!empty($indirec)) {
                $lines = explode("\n", $indirec);
                $newindirec = "";
                $lastlevel = -1;
                foreach ($lines as $indexval => $line) {
                    $lct = preg_match("/^(\\d+)/", $line, $levelmatch);
                    if ($lct > 0) {
                        $level = $levelmatch[1];
                    } else {
                        $level = 1;
                    }
                    //-- make sure we don't add any sublevel records
                    if ($level <= $lastlevel) {
                        $lastlevel = -1;
                    }
                    if (preg_match("/@{$pid}@/", $line) == 0 && $lastlevel == -1) {
                        $newindirec .= $line . "\n";
                    } else {
                        $lastlevel = $level;
                    }
                }
                $success = $success && replace_gedrec($id, $newindirec);
            }
        }
        if ($success) {
            $success = $success && delete_gedrec($pid);
        }
        return $success;
    }
    return false;
}
Ejemplo n.º 5
0
         $cxref = append_gedrec($childrec);
         $famrec .= "\n1 CHIL @{$cxref}@";
         $famupdate = true;
     }
     if ($famupdate && $oldfamrec != $famrec) {
         $famrec = preg_replace("/0 @(.*)@/", "0 @" . $famid . "@", $famrec);
         replace_gedrec($famid, $famrec, $update_CHAN);
     }
     $i++;
 }
 if ($updated && empty($error)) {
     echo $pgv_lang["update_successful"], "<br />";
     AddToChangeLog("Quick update for {$pid} by >" . PGV_USER_NAME . "<");
     //echo "<pre>$gedrec</pre>";
     if ($oldgedrec != $gedrec) {
         replace_gedrec($pid, $gedrec, $update_CHAN);
     }
 }
 if (!empty($error)) {
     echo "<span class=\"error\">", $error, "</span>";
 }
 if ($closewin) {
     // autoclose window when update successful
     if ($EDIT_AUTOCLOSE && !PGV_DEBUG) {
         echo "\n<script type=\"text/javascript\">\n<!--\nif (window.opener.showchanges) window.opener.showchanges(); window.close();\n//-->\n</script>";
     }
     echo "<center><br /><br /><br />";
     echo "<a href=\"#\" onclick=\"if (window.opener.showchanges) window.opener.showchanges(); window.close();\">", $pgv_lang["close_window"], "</a><br /></center>\n";
     print_simple_footer();
     exit;
 }
Ejemplo n.º 6
0
                     $newgedrec = "0 @{$gid1}@ {$type1}\n";
                     for ($i = 0; $i < count($facts1) || $i < count($facts2); $i++) {
                         if (isset($facts1[$i])) {
                             if (in_array($i, $keep1)) {
                                 $newgedrec .= $facts1[$i]["subrec"] . "\n";
                                 print $pgv_lang["adding"] . " " . $facts1[$i]["fact"] . " " . $pgv_lang["from"] . " {$gid1}<br />\n";
                             }
                         }
                         if (isset($facts2[$i])) {
                             if (in_array($i, $keep2)) {
                                 $newgedrec .= $facts2[$i]["subrec"] . "\n";
                                 print $pgv_lang["adding"] . " " . $facts2[$i]["fact"] . " " . $pgv_lang["from"] . " {$gid2}<br />\n";
                             }
                         }
                     }
                     replace_gedrec($gid1, $newgedrec);
                     if ($SYNC_GEDCOM_FILE) {
                         write_file();
                     }
                     write_changes();
                     $rec = GedcomRecord::getInstance($gid1);
                     $pid = $rec->getXrefLink();
                     // $pid is embedded in $pgv_lang['record_updated']
                     echo '<br />', print_text('record_updated', 0, 1), '<br />';
                     print "<br /><a href=\"edit_merge.php?action=choose\">" . $pgv_lang["merge_more"] . "</a><br />\n";
                     print "<br /><br /><br />\n";
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 set_user_setting(PGV_USER_ID, 'defaulttab', $form_default_tab);
 set_user_gedcom_setting(PGV_USER_ID, PGV_GED_ID, 'rootid', $form_rootid);
 // update gedcom record with new email address
 if (get_user_setting(PGV_USER_ID, 'sync_gedcom') == 'Y') {
     if ($form_email != $old_email) {
         foreach (get_all_gedcoms() as $ged_id => $ged_name) {
             $myid = get_user_gedcom_setting(PGV_USER_ID, $ged_id, 'gedcomid');
             if ($myid) {
                 $OLDGEDCOM = $GEDCOM;
                 $GEDCOM = $ged_name;
                 $person = Person::getInstance($myid);
                 if ($person) {
                     if (preg_match('/\\d _?EMAIL/', $person->getGedcomRecord())) {
                         replace_gedrec($myid, preg_replace("/(\n\\d _?EMAIL).*/", '$1 ' . $form_email, $person->getGedcomRecord()));
                     } else {
                         replace_gedrec($myid, $person->getGedcomRecord() . "\n1 EMAIL " . $form_email);
                     }
                 }
                 $GEDCOM = $OLDGEDCOM;
             }
         }
     }
     if ($form_firstname != $old_firstname || $form_lastname != $old_lastname) {
         // update gedcom record with new name
         // Is this functionality required?
     }
 }
 // Change username
 if ($form_username != PGV_USER_NAME) {
     AddToLog('User renamed to ->' . $form_username . '<-');
     rename_user(PGV_USER_ID, $form_username);
Ejemplo n.º 8
0
 function addLink()
 {
     global $pgv_lang, $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) {
         if (isset($pgv_changes[$this->pid . "_" . $GEDCOM])) {
             $indirec = find_updated_record($this->pid);
         } else {
             $indirec = find_person_record($this->pid);
         }
         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, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 HUSB @{$stub_id}@\n1 CHIL @{$this->pid}@";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMC @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "mother":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 WIFE @{$stub_id}@\n1 CHIL @{$this->pid}@";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMC @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @" . $fam_id . "@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "husband":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 MARR Y\n1 WIFE @{$this->pid}@\n1 HUSB @{$stub_id}@\n";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "wife":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 MARR Y\n1 WIFE @{$stub_id}@\n1 HUSB @{$this->pid}@";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @{$fam_id}@\n";
                 replace_gedrec($stub_id, $indistub, false);
                 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, false);
                 $indistub = find_updated_record($stub_id);
                 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);
                 $indirec .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMC @" . $fam_id . "@";
                 replace_gedrec($stub_id, $indistub, false);
                 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>', $pgv_lang['link_success'], '</b>';
         return true;
     }
     return false;
 }
Ejemplo n.º 9
0
 /**
  *  Preforms a search and replace
  */
 function SearchAndReplace()
 {
     global $GEDCOM, $pgv_changes, $manual_save, $STANDARD_NAME_FACTS, $ADVANCED_NAME_FACTS;
     $this->sgeds = array($GEDCOM);
     $this->srindi = "yes";
     $this->srfams = "yes";
     $this->srsour = "yes";
     $this->srnote = "yes";
     $oldquery = $this->query;
     $this->GeneralSearch();
     //-- don't try to make any changes if nothing was found
     if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
         return;
     }
     AddToLog("Search And Replace old:" . $oldquery . " new:" . $this->replace);
     $manual_save = true;
     // Include edit functions.
     include_once "includes/functions/functions_edit.php";
     // These contain the search query and the replace string
     // $this->replace;
     // $this->query;
     // These contain the search results
     // We need to iterate through them and do the replaces
     //$this->myindilist;
     $adv_name_tags = preg_split("/[\\s,;: ]+/", $ADVANCED_NAME_FACTS);
     $name_tags = array_unique(array_merge($STANDARD_NAME_FACTS, $adv_name_tags));
     $name_tags[] = "_MARNM";
     foreach ($this->myindilist as $id => $individual) {
         if (isset($pgv_changes[$individual->getXref() . '_' . $GEDCOM])) {
             $indirec = find_updated_record($individual->getXref());
         } else {
             $indirec = $individual->getGedcomRecord();
         }
         $oldRecord = $indirec;
         $newRecord = $indirec;
         if ($this->replaceAll) {
             $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord);
         } else {
             if ($this->replaceNames) {
                 foreach ($name_tags as $f => $tag) {
                     $newRecord = preg_replace("~(\\d) " . $tag . " (.*)" . $oldquery . "(.*)~i", "\$1 " . $tag . " \$2" . $this->replace . "\$3", $newRecord);
                 }
             }
             if ($this->replacePlaces) {
                 if ($this->replacePlacesWord) {
                     $newRecord = preg_replace("~(\\d) PLAC (.*)([,\\W\\s])" . $oldquery . "([,\\W\\s])~i", "\$1 PLAC \$2\$3" . $this->replace . "\$4", $newRecord);
                 } else {
                     $newRecord = preg_replace("~(\\d) PLAC (.*)" . $oldquery . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $newRecord);
                 }
             }
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($newRecord != $oldRecord) {
             replace_gedrec($individual->getXref(), $newRecord);
         } else {
             unset($this->myindilist[$id]);
         }
     }
     foreach ($this->myfamlist as $id => $family) {
         if (isset($pgv_changes[$family->getXref() . '_' . $GEDCOM])) {
             $indirec = find_updated_record($family->getXref());
         } else {
             $indirec = $family->getGedcomRecord();
         }
         $oldRecord = $indirec;
         $newRecord = $indirec;
         if ($this->replaceAll) {
             $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord);
         } else {
             if ($this->replacePlaces) {
                 if ($this->replacePlacesWord) {
                     $newRecord = preg_replace("~(\\d) PLAC (.*)([,\\W\\s])" . $oldquery . "([,\\W\\s])~i", "\$1 PLAC \$2\$3" . $this->replace . "\$4", $newRecord);
                 } else {
                     $newRecord = preg_replace("~(\\d) PLAC (.*)" . $oldquery . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $newRecord);
                 }
             }
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($newRecord != $oldRecord) {
             replace_gedrec($family->getXref(), $newRecord);
         } else {
             unset($this->myfamlist[$id]);
         }
     }
     foreach ($this->mysourcelist as $id => $source) {
         if (isset($pgv_changes[$source->getXref() . '_' . $GEDCOM])) {
             $indirec = find_updated_record($source->getXref());
         } else {
             $indirec = $source->getGedcomRecord();
         }
         $oldRecord = $indirec;
         $newRecord = $indirec;
         if ($this->replaceAll) {
             $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord);
         } else {
             if ($this->replaceNames) {
                 $newRecord = preg_replace("~(\\d) TITL (.*)" . $oldquery . "(.*)~i", "\$1 TITL \$2" . $this->replace . "\$3", $newRecord);
                 $newRecord = preg_replace("~(\\d) ABBR (.*)" . $oldquery . "(.*)~i", "\$1 ABBR \$2" . $this->replace . "\$3", $newRecord);
             }
             if ($this->replacePlaces) {
                 if ($this->replacePlacesWord) {
                     $newRecord = preg_replace("~(\\d) PLAC (.*)([,\\W\\s])" . $oldquery . "([,\\W\\s])~i", "\$1 PLAC \$2\$3" . $this->replace . "\$4", $newRecord);
                 } else {
                     $newRecord = preg_replace("~(\\d) PLAC (.*)" . $oldquery . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $newRecord);
                 }
             }
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($newRecord != $oldRecord) {
             replace_gedrec($source->getXref(), $newRecord);
         } else {
             unset($this->mysourcelist[$id]);
         }
     }
     foreach ($this->mynotelist as $id => $note) {
         if (isset($pgv_changes[$note->getXref() . '_' . $GEDCOM])) {
             $indirec = find_updated_record($note->getXref());
         } else {
             $indirec = $note->getGedcomRecord();
         }
         $oldRecord = $indirec;
         $newRecord = $indirec;
         if ($this->replaceAll) {
             $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord);
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($newRecord != $oldRecord) {
             replace_gedrec($note->getXref(), $newRecord);
         } else {
             unset($this->mynotelist[$id]);
         }
     }
     write_changes();
 }
Ejemplo n.º 10
0
 /**
  * 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 $FILE, $GEDCOM;
     global $TBLPREFIX, $pgv_changes;
     $FILE = $GEDCOM;
     if (!$isStub) {
         $gedrec = find_gedcom_record($this->xref . ":" . $xref);
         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);
                 print $result->faultstring;
             }
             return $localrec;
         }
         $gedrec = $result;
         $gedrec = preg_replace("/@([^#@\\s]+)@/", "@" . $this->xref . ":\$1@", $gedrec);
         $gedrec = $this->checkIds($gedrec);
         $localrec = $this->_merge($localrec, $gedrec);
         include_once "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, $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) || get_class($result) == 'SOAP_Fault' || is_object($result)) {
             if (isset($result->faultstring)) {
                 AddToLog($result->faultstring);
                 print $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) {
                 include_once "includes/functions/functions_edit.php";
                 $localrec = $this->UpdateFamily($localrec, $gedrec);
                 replace_gedrec($pid, $localrec);
             } else {
                 update_record($localrec);
             }
         }
     } 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) {
             //$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);
                 } else {
                     AddToLog($person->message);
                 }
                 //-- 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 _PGVU @" . $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 _PGVU @" . $this->xref . "@";
                     $localrec .= $newgedrec;
                 }
                 update_record($localrec);
             } 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]);
                     if (isset($pgv_changes[$pid . "_" . $GEDCOM])) {
                         $localrec = find_updated_record($pid);
                     }
                     $localrec = $this->_merge($localrec, $gedrec);
                     if ($isStub) {
                         include_once "includes/functions/functions_edit.php";
                         $localrec = $this->UpdateFamily($localrec, $gedrec);
                         replace_gedrec($pid, $localrec);
                     } else {
                         update_record($localrec);
                     }
                 }
             }
         }
     }
     return $localrec;
 }
Ejemplo n.º 11
0
     asort($order);
     reset($order);
     $lines = explode("\n", $gedrec);
     $newgedrec = "";
     foreach ($lines as $line) {
         if (strpos($line, "1 FAMS") === false) {
             $newgedrec .= $line . "\n";
         }
     }
     foreach ($order as $famid => $num) {
         $newgedrec .= "1 FAMS @" . $famid . "@\n";
     }
     if (PGV_DEBUG) {
         echo "<pre>{$newgedrec}</pre>";
     }
     $success = replace_gedrec($pid, $newgedrec, $update_CHAN);
     if ($success) {
         echo "<br /><br />", $pgv_lang["update_successful"];
     }
     break;
     //------------------------------------------------------------------------------
     //-- the following section provides a hook for modules
     //-- for reuse of editing functions from forms
 //------------------------------------------------------------------------------
 //-- the following section provides a hook for modules
 //-- for reuse of editing functions from forms
 case 'mod_edit_fact':
     if (isset($_REQUEST['mod'])) {
         $mod = $_REQUEST['mod'];
     }
     require_once PGV_ROOT . 'modules/' . $mod . '/' . $mod . '.php';
Ejemplo n.º 12
0
     asort($order);
     reset($order);
     $lines = explode("\n", $gedrec);
     $newgedrec = "";
     for ($i = 0; $i < count($lines); $i++) {
         if (preg_match("/1 FAMS/", $lines[$i]) == 0) {
             $newgedrec .= $lines[$i] . "\n";
         }
     }
     foreach ($order as $famid => $num) {
         $newgedrec .= "1 FAMS @" . $famid . "@\n";
     }
     if (PGV_DEBUG) {
         echo "<pre>{$newgedrec}</pre>";
     }
     $success = replace_gedrec($pid, $newgedrec);
     if ($success) {
         echo "<br /><br />" . $pgv_lang["update_successful"];
     }
     break;
     //------------------------------------------------------------------------------
     //-- the following section provides a hook for modules
     //-- for reuse of editing functions from forms
 //------------------------------------------------------------------------------
 //-- the following section provides a hook for modules
 //-- for reuse of editing functions from forms
 case 'mod_edit_fact':
     if (isset($_REQUEST['mod'])) {
         $mod = $_REQUEST['mod'];
     }
     include_once 'modules/' . $mod . '/' . $mod . '.php';