Ejemplo n.º 1
0
        }
        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"
if ($action == "delete") {
    if (delete_gedrec($pid)) {
        AddToChangeLog("Media ID " . $pid . " successfully deleted.");
        print $pgv_lang["update_successful"];
    }
}
// **** end action "delete"
// **** begin action "showmediaform"
if ($action == "showmediaform") {
    if (!isset($pid)) {
        $pid = "";
    }
    if (empty($level)) {
        $level = 1;
    }
    if (!isset($linktoid)) {
        $linktoid = "";
Ejemplo n.º 2
0
                 print "SUCCESS\n{$xref}\n";
             }
         } else {
             addDebugLog($action . " gedrec={$gedrec} ERROR 11: No write privileges for this record.");
             print "ERROR 11: No write privileges for this record.\n";
         }
     } else {
         addDebugLog($action . " ERROR 8: No gedcom record provided.  Unable to process request.");
         print "ERROR 8: No gedcom record provided.  Unable to process request.\n";
     }
     exit;
 case 'delete':
     $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF);
     if ($xref) {
         if (empty($_SESSION['readonly']) && PGV_USER_CAN_EDIT && displayDetailsById($xref)) {
             $success = delete_gedrec($xref);
             if ($success) {
                 addDebugLog($action . " xref={$xref} 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 . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
     }
     exit;
 case 'getnext':
     $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF);
Ejemplo n.º 3
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.º 4
0
         if ($fact2["fact"] != "CHAN" && !in_array($j, $skip2)) {
             print "<tr><td><input type=\"checkbox\" name=\"keep2[]\" value=\"{$j}\" checked=\"checked\" /></td>";
             print "<td>" . nl2br($fact2["subrec"]) . "</td></tr>\n";
         }
     }
     print "</table>\n";
     print "</td></tr>\n";
     print "</table>\n";
     print "<input type=\"submit\" value=\"" . $pgv_lang["merge_records"] . "\">\n";
     print "</form>\n";
 } else {
     if ($action == "merge") {
         $manual_save = true;
         print "<h2>" . $pgv_lang["merge_step3"] . "</h2>\n";
         if ($GEDCOM == $ged2) {
             $success = delete_gedrec($gid2);
             if ($success) {
                 print "<br />" . $pgv_lang["gedrec_deleted"] . "<br />\n";
             }
             //-- replace all the records that linked to gid2
             $ids = fetch_all_links($gid2, PGV_GED_ID);
             foreach ($ids as $id) {
                 if (isset($pgv_changes[$id . "_" . $GEDCOM])) {
                     $record = find_updated_record($id);
                 } else {
                     $record = fetch_gedcom_record($id, PGV_GED_ID);
                     $record = $record['gedrec'];
                     echo $pgv_lang["updating_linked"] . " {$id}<br />\n";
                     $newrec = str_replace("@{$gid2}@", "@{$gid1}@", $record);
                     replace_gedrec($id, $newrec);
                 }
Ejemplo n.º 5
0
function delete_fact($linenum, $pid, $gedrec)
{
    global $linefix, $pgv_lang;
    if (!empty($linenum)) {
        if ($linenum == 0) {
            if (delete_gedrec($pid)) {
                print $pgv_lang["gedrec_deleted"];
            }
        } else {
            $gedlines = explode("\n", $gedrec);
            // NOTE: The array_pop is used to kick off the last empty element on the array
            // NOTE: To prevent empty lines in the GEDCOM
            // DEBUG: Records without line breaks are imported as 1 big string
            if ($linefix > 0) {
                array_pop($gedlines);
            }
            $newged = "";
            // NOTE: Add all lines that are before the fact to be deleted
            for ($i = 0; $i < $linenum; $i++) {
                $newged .= trim($gedlines[$i]) . "\n";
            }
            if (isset($gedlines[$linenum])) {
                $fields = explode(' ', $gedlines[$linenum]);
                $glevel = $fields[0];
                $ctlines = count($gedlines);
                $i++;
                if ($i < $ctlines) {
                    // Remove the fact
                    while (isset($gedlines[$i]) && $gedlines[$i][0] > $glevel) {
                        $i++;
                    }
                    // Add the remaining lines
                    while ($i < $ctlines) {
                        $newged .= $gedlines[$i] . "\n";
                        $i++;
                    }
                }
            }
            if ($newged != "") {
                return $newged;
            }
        }
    }
}
Ejemplo n.º 6
0
                         $skipline = true;
                     } else {
                         if ($line[0] <= $glevel) {
                             $skipline = false;
                             $newrec .= $line . "\n";
                         }
                     }
                 }
             }
             if (PGV_DEBUG) {
                 echo "<pre>{$newrec}</pre>";
             }
             $success = $success && replace_gedrec($xref, $newrec, $update_CHAN);
         }
         if ($success) {
             $success = $success && delete_gedrec($pid);
         }
         if ($success) {
             echo "<br /><br />" . $pgv_lang["gedrec_deleted"];
         }
     }
     break;
     //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 case 'editname':
     $gedlines = explode("\n", trim($gedrec));
     $fields = explode(' ', $gedlines[$linenum]);
     $glevel = $fields[0];
     $i = $linenum + 1;
     $namerec = $gedlines[$linenum];
     while ($i < count($gedlines) && $gedlines[$i][0] > $glevel) {