Example #1
0
 function init()
 {
     global $PRIV_HIDE, $PRIV_PUBLIC, $ENABLE_CLIPPINGS_CART, $SCRIPT_NAME, $pgv_lang, $SERVER_URL, $CONTACT_EMAIL, $HOME_SITE_TEXT, $HOME_SITE_URL, $MEDIA_DIRECTORY;
     global $GEDCOM, $CHARACTER_SET, $cart;
     if (!isset($ENABLE_CLIPPINGS_CART)) {
         $ENABLE_CLIPPINGS_CART = $PRIV_HIDE;
     }
     if ($ENABLE_CLIPPINGS_CART === true) {
         $ENABLE_CLIPPING_CART = $PRIV_PUBLIC;
     }
     if ($ENABLE_CLIPPINGS_CART < PGV_USER_ACCESS_LEVEL) {
         header("Location: index.php");
         exit;
     }
     if (!isset($_SESSION['exportConvPath'])) {
         $_SESSION['exportConvPath'] = $MEDIA_DIRECTORY;
     }
     if (!isset($_SESSION['exportConvSlashes'])) {
         $_SESSION['exportConvSlashes'] = 'forward';
     }
     $this->action = safe_GET("action");
     $this->id = safe_GET('id');
     $remove = safe_GET('remove', "", "no");
     $convert = safe_GET('convert', "", "no");
     $this->Zip = safe_GET('Zip');
     $this->IncludeMedia = safe_GET('IncludeMedia');
     $this->conv_path = safe_GET('conv_path', PGV_REGEX_NOSCRIPT, $_SESSION['exportConvPath']);
     $this->conv_slashes = safe_GET('conv_slashes', array('forward', 'backward'), $_SESSION['exportConvSlashes']);
     $this->privatize_export = safe_GET('privatize_export', array('none', 'visitor', 'user', 'gedadmin', 'admin'));
     $this->filetype = safe_GET('filetype');
     $this->level1 = safe_GET('level1');
     $this->level2 = safe_GET('level2');
     $this->level3 = safe_GET('level3');
     if (empty($this->filetype)) {
         $this->filetype = "gedcom";
     }
     $others = safe_GET('others');
     $item = safe_GET('item');
     if (!isset($cart)) {
         $cart = $_SESSION['cart'];
     }
     $this->type = safe_GET('type');
     $this->conv_path = stripLRMRLM($this->conv_path);
     $_SESSION['exportConvPath'] = $this->conv_path;
     // remember this for the next Download
     $_SESSION['exportConvSlashes'] = $this->conv_slashes;
     if ($this->action == 'add') {
         if (empty($this->type) && !empty($this->id)) {
             $this->type = "";
             $obj = GedcomRecord::getInstance($this->id);
             if (is_null($obj)) {
                 $this->id = "";
                 $this->action = "";
             } else {
                 $this->type = strtolower($obj->getType());
             }
         } else {
             if (empty($this->id)) {
                 $this->action = "";
             }
         }
         if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') {
             $this->action = 'add1';
         }
     }
     if ($this->action == 'add1') {
         $clipping = array();
         $clipping['type'] = $this->type;
         $clipping['id'] = $this->id;
         $clipping['gedcom'] = $GEDCOM;
         $ret = $this->add_clipping($clipping);
         if ($ret) {
             if ($this->type == 'sour') {
                 if ($others == 'linked') {
                     foreach (fetch_linked_indi($this->id, 'SOUR', PGV_GED_ID) as $indi) {
                         if ($indi->canDisplayName()) {
                             $this->add_clipping(array('type' => 'indi', 'id' => $indi->getXref()));
                         }
                     }
                     foreach (fetch_linked_fam($this->id, 'SOUR', PGV_GED_ID) as $fam) {
                         if ($fam->canDisplayName()) {
                             $this->add_clipping(array('type' => 'fam', 'id' => $fam->getXref()));
                         }
                     }
                 }
             }
             if ($this->type == 'fam') {
                 if ($others == 'parents') {
                     $parents = find_parents($this->id);
                     if (!empty($parents["HUSB"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["HUSB"];
                         $ret = $this->add_clipping($clipping);
                     }
                     if (!empty($parents["WIFE"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["WIFE"];
                         $ret = $this->add_clipping($clipping);
                     }
                 } else {
                     if ($others == "members") {
                         $this->add_family_members($this->id);
                     } else {
                         if ($others == "descendants") {
                             $this->add_family_descendancy($this->id);
                         }
                     }
                 }
             } else {
                 if ($this->type == 'indi') {
                     if ($others == 'parents') {
                         $famids = find_family_ids($this->id);
                         foreach ($famids as $indexval => $famid) {
                             $clipping = array();
                             $clipping['type'] = "fam";
                             $clipping['id'] = $famid;
                             $ret = $this->add_clipping($clipping);
                             if ($ret) {
                                 $this->add_family_members($famid);
                             }
                         }
                     } else {
                         if ($others == 'ancestors') {
                             $this->add_ancestors_to_cart($this->id, $this->level1);
                         } else {
                             if ($others == 'ancestorsfamilies') {
                                 $this->add_ancestors_to_cart_families($this->id, $this->level2);
                             } else {
                                 if ($others == 'members') {
                                     $famids = find_sfamily_ids($this->id);
                                     foreach ($famids as $indexval => $famid) {
                                         $clipping = array();
                                         $clipping['type'] = "fam";
                                         $clipping['id'] = $famid;
                                         $ret = $this->add_clipping($clipping);
                                         if ($ret) {
                                             $this->add_family_members($famid);
                                         }
                                     }
                                 } else {
                                     if ($others == 'descendants') {
                                         $famids = find_sfamily_ids($this->id);
                                         foreach ($famids as $indexval => $famid) {
                                             $clipping = array();
                                             $clipping['type'] = "fam";
                                             $clipping['id'] = $famid;
                                             $ret = $this->add_clipping($clipping);
                                             if ($ret) {
                                                 $this->add_family_descendancy($famid, $this->level3);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->action == 'remove') {
             $ct = count($cart);
             for ($i = $item + 1; $i < $ct; $i++) {
                 $cart[$i - 1] = $cart[$i];
             }
             unset($cart[$ct - 1]);
         } else {
             if ($this->action == 'empty') {
                 $cart = array();
                 $_SESSION["cart"] = $cart;
             } else {
                 if ($this->action == 'download') {
                     usort($cart, "same_group");
                     if ($this->filetype == "gedcom") {
                         $path = substr($SCRIPT_NAME, 0, strrpos($SCRIPT_NAME, "/"));
                         if (empty($path)) {
                             $path = "/";
                         }
                         if ($path[strlen($path) - 1] != "/") {
                             $path .= "/";
                         }
                         if ($SERVER_URL[strlen($SERVER_URL) - 1] == "/") {
                             $dSERVER_URL = substr($SERVER_URL, 0, strlen($SERVER_URL) - 1);
                         } else {
                             $dSERVER_URL = $SERVER_URL;
                         }
                         $media = array();
                         $mediacount = 0;
                         $ct = count($cart);
                         $filetext = "0 HEAD\n1 SOUR " . PGV_PHPGEDVIEW . "\n2 NAME " . PGV_PHPGEDVIEW . "\n2 VERS " . PGV_VERSION_TEXT . "\n1 DEST DISKETTE\n1 DATE " . date("j M Y") . "\n2 TIME " . date("H:i:s") . "\n";
                         $filetext .= "1 GEDC\n2 VERS 5.5\n2 FORM LINEAGE-LINKED\n1 CHAR {$CHARACTER_SET}\n";
                         $head = find_gedcom_record("HEAD");
                         $placeform = trim(get_sub_record(1, "1 PLAC", $head));
                         if (!empty($placeform)) {
                             $filetext .= $placeform . "\n";
                         } else {
                             $filetext .= "1 PLAC\n2 FORM " . "City, County, State/Province, Country" . "\n";
                         }
                         if ($convert == "yes") {
                             $filetext = preg_replace("/UTF-8/", "ANSI", $filetext);
                             $filetext = utf8_decode($filetext);
                         }
                         $tempUserID = '#ExPoRt#';
                         if ($this->privatize_export != 'none') {
                             // Create a temporary userid
                             $export_user_id = createTempUser($tempUserID, $this->privatize_export, $GEDCOM);
                             // Create a temporary userid
                             // Temporarily become this user
                             $_SESSION["org_user"] = $_SESSION["pgv_user"];
                             $_SESSION["pgv_user"] = $tempUserID;
                         }
                         for ($i = 0; $i < $ct; $i++) {
                             $clipping = $cart[$i];
                             if ($clipping['gedcom'] == $GEDCOM) {
                                 $record = find_gedcom_record($clipping['id']);
                                 $savedRecord = $record;
                                 // Save this for the "does this file exist" check
                                 if ($clipping['type'] == 'obje') {
                                     $record = convert_media_path($record, $this->conv_path, $this->conv_slashes);
                                 }
                                 $record = privatize_gedcom($record);
                                 $record = remove_custom_tags($record, $remove);
                                 if ($convert == "yes") {
                                     $record = utf8_decode($record);
                                 }
                                 switch ($clipping['type']) {
                                     case 'indi':
                                         $ft = preg_match_all("/1 FAMC @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 $record = preg_replace("/1 FAMC @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 FAMS @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 $record = preg_replace("/1 FAMS @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 SOUR @SPGV1@\n";
                                         $filetext .= "2 PAGE " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n";
                                         $filetext .= "2 DATA\n";
                                         $filetext .= "3 TEXT " . $pgv_lang["indi_downloaded_from"] . "\n";
                                         $filetext .= "4 CONT " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n";
                                         break;
                                     case 'fam':
                                         $ft = preg_match_all("/1 CHIL @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the child is not in the list delete the record of it */
                                                 $record = preg_replace("/1 CHIL @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 HUSB @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the husband is not in the list delete the record of him */
                                                 $record = preg_replace("/1 HUSB @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 WIFE @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the wife is not in the list delete the record of her */
                                                 $record = preg_replace("/1 WIFE @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 SOUR @SPGV1@\n";
                                         $filetext .= "2 PAGE " . $dSERVER_URL . $path . "family.php?famid=" . $clipping['id'] . "\n";
                                         $filetext .= "2 DATA\n";
                                         $filetext .= "3 TEXT " . $pgv_lang["family_downloaded_from"] . "\n";
                                         $filetext .= "4 CONT " . $dSERVER_URL . "/family.php?famid=" . $clipping['id'] . "\n";
                                         break;
                                     case 'source':
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 NOTE " . $pgv_lang["source_downloaded_from"] . "\n";
                                         $filetext .= "2 CONT " . $dSERVER_URL . "/source.php?sid=" . $clipping['id'] . "\n";
                                         break;
                                     default:
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         break;
                                 }
                             }
                         }
                         if ($this->privatize_export != 'none') {
                             $_SESSION["pgv_user"] = $_SESSION["org_user"];
                             delete_user($export_user_id);
                             AddToLog("deleted dummy user -> {$tempUserID} <-");
                         }
                         if ($this->IncludeMedia == "yes") {
                             $this->media_list = $media;
                         }
                         $filetext .= "0 @SPGV1@ SOUR\n";
                         if ($user_id = get_user_id($CONTACT_EMAIL)) {
                             $filetext .= "1 AUTH " . getUserFullName($user_id) . "\n";
                         }
                         $filetext .= "1 TITL " . $HOME_SITE_TEXT . "\n";
                         $filetext .= "1 ABBR " . $HOME_SITE_TEXT . "\n";
                         $filetext .= "1 PUBL " . $HOME_SITE_URL . "\n";
                         $filetext .= "0 TRLR\n";
                         //-- make sure the preferred line endings are used
                         $filetext = preg_replace("/[\r\n]+/", PGV_EOL, $filetext);
                         $this->download_data = $filetext;
                         $this->download_clipping();
                     } else {
                         if ($this->filetype == "gramps") {
                             // Sort the clippings cart because the export works better when the cart is sorted
                             usort($cart, "same_group");
                             require_once "includes/classes/class_geclippings.php";
                             $gramps_Exp = new GEClippings();
                             $gramps_Exp->begin_xml();
                             $ct = count($cart);
                             usort($cart, "same_group");
                             for ($i = 0; $i < $ct; $i++) {
                                 $clipping = $cart[$i];
                                 switch ($clipping['type']) {
                                     case 'indi':
                                         $rec = find_person_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_person($rec, $clipping['id']);
                                         break;
                                     case 'fam':
                                         $rec = find_family_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_family($rec, $clipping['id']);
                                         break;
                                     case 'source':
                                         $rec = find_source_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_source($rec, $clipping['id']);
                                         break;
                                 }
                             }
                             $this->download_data = $gramps_Exp->dom->saveXML();
                             if ($convert) {
                                 $this->download_data = utf8_decode($this->download_data);
                             }
                             $this->media_list = $gramps_Exp->get_all_media();
                             $this->download_clipping();
                         }
                     }
                 }
             }
         }
     }
 }
 function fetchLinkedFamilies()
 {
     return fetch_linked_fam($this->getXref(), $this->getType(), $this->ged_id);
 }
Example #3
0
 /**
  * 	Gathers results for a soundex search
  *
  *  TODO
  *  ====
  *  Does not search on the selected gedcoms, searches on all the gedcoms
  *  Does not work on first names, instead of the code, value array is used in the search
  *  Returns all the names even when Names with hit selected
  *  Does not sort results by first name
  *  Does not work on separate double word surnames
  *  Does not work on duplicate code values of the searched text and does not give the correct code
  *     Cohen should give DM codes 556000, 456000, 460000 and 560000, in 4.1 we search only on 560000??
  *
  *  The names' Soundex SQL table contains all the soundex values twice
  *  The places table contains only one value
  *
  *  The code should be improved - see RFE
  *
  */
 function SoundexSearch()
 {
     if ((!empty($this->lastname) || !empty($this->firstname) || !empty($this->place)) && count($this->sgeds) > 0) {
         $logstring = "Type: Soundex<br />";
         if (!empty($this->lastname)) {
             $logstring .= "Last name: " . $this->lastname . "<br />";
         }
         if (!empty($this->firstname)) {
             $logstring .= "First name: " . $this->firstname . "<br />";
         }
         if (!empty($this->place)) {
             $logstring .= "Place: " . $this->place . "<br />";
         }
         if (!empty($this->year)) {
             $logstring .= "Year: " . $this->year . "<br />";
         }
         AddToSearchlog($logstring, $this->sgeds);
         // Get a list of gedcom IDs to search
         // TODO: don't we already have this somewhere?
         $ged_ids = array();
         foreach ($this->sgeds as $gedcom) {
             $ged_ids[] = get_id_from_gedcom($gedcom);
         }
         if ($ged_ids) {
             $this->myindilist = search_indis_soundex($this->soundex, $this->lastname, $this->firstname, $this->place, $ged_ids);
         } else {
             $this->myindilist = array();
         }
     }
     // Now we have the final list of indi's to be printed.
     // We may add the assos at this point.
     if ($this->showasso == "on") {
         foreach ($this->myindilist as $indi) {
             foreach (fetch_linked_indi($indi->getXref(), 'ASSO', $indi->getGedId()) as $asso) {
                 $this->myindilist[] = $asso;
             }
             foreach (fetch_linked_fam($indi->getXref(), 'ASSO', $indi->getGedId()) as $asso) {
                 $this->myfamlist[] = $asso;
             }
         }
     }
     //-- if only 1 item is returned, automatically forward to that item
     if (count($this->myindilist) == 1 && $this->action != "replace") {
         $indi = $this->myindilist[0];
         header("Location: " . encode_url($indi->getLinkUrl(), false));
         exit;
     }
     usort($this->myindilist, array('GedcomRecord', 'Compare'));
     usort($this->myfamlist, array('GedcomRecord', 'Compare'));
 }
Example #4
0
 /**
  * add events where pid is an ASSOciate
  *
  * @return records added to indifacts array
  *
  */
 function add_asso_facts()
 {
     global $factarray, $pgv_lang;
     $associates = array_merge(fetch_linked_indi($this->getXref(), 'ASSO', $this->ged_id), fetch_linked_fam($this->getXref(), 'ASSO', $this->ged_id));
     foreach ($associates as $associate) {
         foreach ($associate->getFacts() as $event) {
             $srec = $event->getGedcomRecord();
             $arec = get_sub_record(2, "2 ASSO @" . $this->getXref() . "@", $srec);
             if ($arec) {
                 $fact = $event->getTag();
                 $label = $event->getLabel();
                 $sdate = get_sub_record(2, "2 DATE", $srec);
                 // relationship ?
                 $rrec = get_sub_record(3, "3 RELA", $arec);
                 $rela = trim(substr($rrec, 7));
                 if (empty($rela)) {
                     $rela = "ASSO";
                 }
                 // add an event record
                 $factrec = "1 EVEN\n2 TYPE " . $label . "<br/>[ <span class=\"details_label\">";
                 if (isset($pgv_lang[strtolower($rela)])) {
                     $factrec .= $pgv_lang[strtolower($rela)] . "</span> ]";
                 } else {
                     if (isset($factarray[$rela])) {
                         $factrec .= $factarray[$rela] . "</span> ]";
                     }
                 }
                 $factrec .= "\n" . $sdate . "\n" . get_sub_record(2, '2 PLAC', $srec);
                 if (!$event->canShow()) {
                     $factrec .= "\n2 RESN privacy";
                 }
                 if ($associate->getType() == 'FAM') {
                     $famrec = find_family_record($associate->getXref());
                     if ($famrec) {
                         $parents = find_parents_in_record($famrec);
                         if ($parents["HUSB"]) {
                             $factrec .= "\n2 ASSO @" . $parents["HUSB"] . "@";
                         }
                         //\n3 RELA ".$factarray[$fact];
                         if ($parents["WIFE"]) {
                             $factrec .= "\n2 ASSO @" . $parents["WIFE"] . "@";
                         }
                         //\n3 RELA ".$factarray[$fact];
                     }
                 } else {
                     if ($fact == 'BIRT') {
                         $sex = $associate->getSex();
                         if ($sex == "M") {
                             $rela_b = "twin_brother";
                         } else {
                             if ($sex == "F") {
                                 $rela_b = "twin_sister";
                             } else {
                                 $rela_b = "twin";
                             }
                         }
                         $factrec .= "\n2 ASSO @" . $associate->getXref() . "@\n3 RELA " . $rela_b;
                     } else {
                         if ($fact == 'CHR') {
                             $sex = $associate->getSex();
                             if ($sex == "M") {
                                 $rela_chr = "godson";
                             } else {
                                 if ($sex == "F") {
                                     $rela_chr = "goddaughter";
                                 } else {
                                     $rela_chr = "godchild";
                                 }
                             }
                             $factrec .= "\n2 ASSO @" . $associate->getXref() . "@\n3 RELA " . $rela_chr;
                         } else {
                             $factrec .= "\n2 ASSO @" . $associate->getXref() . "@\n3 RELA " . $fact;
                         }
                     }
                 }
                 //$factrec .= "\n3 NOTE ".$rela;
                 $factrec .= "\n2 ASSO @" . $this->getXref() . "@\n3 RELA *" . $rela;
                 // check if this fact already exists in the list
                 $found = false;
                 if ($sdate) {
                     foreach ($this->indifacts as $k => $v) {
                         if (strpos($v->getGedcomRecord(), $sdate) && strpos($v->getGedcomRecord(), "2 ASSO @" . $this->getXref() . "@")) {
                             $found = true;
                             break;
                         }
                     }
                 }
                 if (!$found) {
                     $this->indifacts[] = new Event($factrec, 0);
                 }
             }
         }
     }
 }