Example #1
0
 $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF);
 if ($position == 'next' && !$xref) {
     $position = 'first';
 }
 if ($position == 'prev' && !$xref) {
     $position = 'last';
 }
 if (!$position || !$type) {
     addDebugLog($action . " type={$type} position={$position} ERROR 18: Invalid \$type specification.  Valid types are INDI, FAM, SOUR, REPO, NOTE, OBJE, or OTHER");
     print "ERROR 18: Invalid \$type or \$position specification.  Valid types are INDI, FAM, SOUR, REPO, NOTE, OBJE, or OTHER\n";
     exit;
 }
 global $gBitDb;
 switch ($position) {
     case 'first':
         $xref = get_first_xref($type, $GED_ID);
         addDebugLog($action . " type={$type} position={$position} SUCCESS\n{$xref}");
         print "SUCCESS\n{$xref}\n";
         break;
     case 'last':
         $xref = get_last_xref($type, $GED_ID);
         addDebugLog($action . " type={$type} position={$position} SUCCESS\n{$xref}");
         print "SUCCESS\n{$xref}\n";
         break;
     case 'next':
         $xref = get_next_xref($xref, $GED_ID);
         addDebugLog($action . " type={$type} position={$position} SUCCESS\n{$xref}");
         print "SUCCESS\n{$xref}\n";
         break;
     case 'prev':
         $xref = get_prev_xref($xref, $GED_ID);
/**
 * check root id for pedigree tree
 *
 * @param string $rootid root ID
 * @return string $rootid validated root ID
 */
function check_rootid($rootid)
{
    global $PEDIGREE_ROOT_ID, $USE_RIN, $gGedcom;
    // -- if the $rootid is not already there then find the first person in the file and make him the root
    if (!find_person_record($rootid)) {
        if (find_person_record($gGedcom->mRootId)) {
            $rootid = $gGedcom->mRootId;
        } else {
            // TODO - Add options for user gedcom id's'
            if (find_person_record($gGedcom->mRootId)) {
                $rootid = $gGedcom->mRootId;
            } else {
                if (find_person_record(trim($PEDIGREE_ROOT_ID))) {
                    $rootid = trim($PEDIGREE_ROOT_ID);
                } else {
                    $rootid = get_first_xref('INDI', $gGedcom->mGEDCOMId);
                    // If there are no users in the gedcom, do something.
                    if (!$rootid) {
                        $rootid = 'I1';
                    }
                }
            }
        }
    }
    if ($USE_RIN) {
        $indirec = find_person_record($rootid);
        if ($indirec == false) {
            $rootid = find_rin_id($rootid);
        }
    }
    return $rootid;
}