예제 #1
0
 function __construct()
 {
     global $USE_RIN;
     $xref = WT_Filter::get('pid', WT_REGEX_XREF);
     $this->record = WT_Individual::getInstance($xref);
     if (!$this->record && $USE_RIN) {
         $rin = find_rin_id($xref);
         $this->record = WT_Individual::getInstance($rin);
     }
     parent::__construct();
     $this->tabs = WT_Module::getActiveTabs();
     // If we can display the details, add them to the page header
     if ($this->record && $this->record->canShow()) {
         $this->setPageTitle($this->record->getFullName() . ' ' . $this->record->getLifespan());
     }
 }
예제 #2
0
 /**
  * Initialization function
  */
 function init()
 {
     global $USE_RIN, $MAX_ALIVE_AGE, $GEDCOM, $GEDCOM_DEFAULT_TAB, $pgv_changes, $pgv_lang, $CHARACTER_SET;
     global $USE_QUICK_UPDATE, $pid;
     global $Fam_Navigator, $gBitUser, $gGedcom;
     $this->sexarray["M"] = $pgv_lang["male"];
     $this->sexarray["F"] = $pgv_lang["female"];
     $this->sexarray["U"] = $pgv_lang["unknown"];
     $this->pid = safe_GET_xref('pid');
     $show_famlink = $this->view != 'preview';
     $pid = $this->pid;
     $this->default_tab = $GEDCOM_DEFAULT_TAB;
     $indirec = find_person_record($this->pid);
     if ($USE_RIN && $indirec == false) {
         $this->pid = find_rin_id($this->pid);
         $indirec = find_person_record($this->pid);
     }
     if (empty($indirec)) {
         $ct = preg_match("/(\\w+):(.+)/", $this->pid, $match);
         if ($ct > 0) {
             $servid = trim($match[1]);
             $remoteid = trim($match[2]);
             include_once '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);
                 $indirec = $newrec;
             }
         } else {
             if (isset($pgv_changes[$this->pid . "_" . $GEDCOM])) {
                 $indirec = "0 @" . $this->pid . "@ INDI\n";
             } else {
                 return false;
             }
         }
     }
     //-- check for the user
     if ($gBitUser->isRegistered()) {
         $this->default_tab = get_user_setting($gBitUser->mUserId, 'defaulttab');
     }
     //-- check for a cookie telling what the last tab was when they were last
     //-- visiting this individual
     if ($this->default_tab == -2) {
         if (isset($_COOKIE['lasttabs'])) {
             $ct = preg_match("/" . $this->pid . "=(\\d+)/", $_COOKIE['lasttabs'], $match);
             if ($ct > 0) {
                 $this->default_tab = $match[1] - 1;
             }
         }
     }
     //-- if the action is a research assistant action then default to the RA tab
     if (strstr($this->action, 'ra_') !== false) {
         $this->default_tab = 6;
     }
     //-- set the default tab from a request parameter
     if (isset($_REQUEST['tab'])) {
         $this->default_tab = $_REQUEST['tab'];
     }
     if ($this->default_tab < -2 || $this->default_tab > 9) {
         $this->default_tab = 0;
     }
     $this->indi = new Person($indirec, false);
     $this->indi->ged_id = $gGedcom->mGEDCOMId;
     // This record is from a file
     //-- if the person is from another gedcom then forward to the correct site
     /*
     if ($this->indi->isRemote()) {
     	header('Location: '.encode_url(decode_url($this->indi->getLinkUrl()), false));
     	exit;
     }
     */
     if (!$this->isPrintPreview()) {
         $this->visibility = "hidden";
         $this->position = "absolute";
         $this->display = "none";
     }
     //-- perform the desired action
     switch ($this->action) {
         case "addfav":
             $this->addFavorite();
             break;
         case "accept":
             $this->acceptChanges();
             break;
         case "undo":
             $this->indi->undoChange();
             break;
     }
     //-- if the user can edit and there are changes then get the new changes
     if ($this->show_changes && $gGedcom->isEditable()) {
         if (isset($pgv_changes[$this->pid . "_" . $GEDCOM])) {
             //-- get the changed record from the file
             $newrec = find_updated_record($this->pid);
             //print("jkdsakjhdkjsadkjsakjdhsakd".$newrec);
             $remoterfn = get_gedcom_value("RFN", 1, $newrec);
         } else {
             $remoterfn = get_gedcom_value("RFN", 1, $indirec);
         }
         // 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 "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, $indirec, true);
                         }
                         if ($serviceClient->type == "remote") {
                             $newrec = $mergerec;
                         } else {
                             $indirec = $mergerec;
                         }
                     }
                 }
             }
         }
         if (!empty($newrec)) {
             $this->diffindi = new Person($newrec, false);
             $this->diffindi->setChanged(true);
             $indirec = $newrec;
         }
     }
     if ($this->show_changes) {
         $this->indi->diffMerge($this->diffindi);
     }
     //-- only allow editors or users who are editing their own individual or their immediate relatives
     if ($this->indi->canDisplayDetails()) {
         $this->canedit = $gGedcom->isEditable();
         /* Disable self-editing completely until we have a GEDCOM config option to control this
         			if (!$this->canedit && $USE_QUICK_UPDATE) {
         				$my_id=PGV_USER_GEDCOM_ID;
         				if ($my_id) {
         					if ($this->pid==$my_id) $this->canedit=true;
         					else {
         						$famids = array_merge(find_sfamily_ids($my_id), find_family_ids($my_id));
         						foreach($famids as $indexval => $famid) {
         							if (!isset($pgv_changes[$famid."_".$GEDCOM])) $famrec = find_family_record($famid);
         							else $famrec = find_updated_record($famid);
         							if (preg_match("/1 (HUSB|WIFE|CHIL) @$this->pid@/", $famrec)>0) $this->canedit=true;
         						}
         					}
         				}
         			}
         */
     }
     //-- handle ajax calls
     if ($this->action == "ajax") {
         $tab = 0;
         if (isset($_REQUEST['tab'])) {
             $tab = $_REQUEST['tab'] - 1;
         }
         header("Content-Type: text/html; charset={$CHARACTER_SET}");
         //AJAX calls do not have the meta tag headers and need this set
         $this->getTab($tab);
         //-- only get the requested tab and then exit
         /* TODO
         			if (PGV_DEBUG_SQL) {
         				echo ADOdb::getQueryLog();
         			}
          */
         exit;
     }
 }
예제 #3
0
/**
 * 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;
}