Esempio n. 1
0
function setup_edit()
{
    $dao = getEventDAO();
    $e = new Event();
    $e->setFromRequest();
    $dao->getEvents($e, Q_ALL, true);
    if ($e->numResults > 0) {
        $per = $e->results[0]->person;
    } else {
        $per = new PersonDetail();
        $per->setFromRequest();
        $e->results = array(new Event());
        $e->results[0]->type = -1;
    }
    $per->queryType = Q_IND;
    $dao = getPeopleDAO();
    $dao->getPersonDetails($per);
    if ($per->numResults > 0) {
        $ret = $per->results[0];
    } else {
        $ret = $per;
    }
    $ret->events = $e->results;
    return $ret;
}
Esempio n. 2
0
 function getMarriages(&$search, $limit = 0)
 {
     global $tblprefix, $err_marriage, $currentRequest;
     $res = array();
     $query = "SELECT DISTINCT CONCAT_WS('-', YEAR(NOW()), LPAD(MONTH(e.date1), 2, '0'), LPAD(DAYOFMONTH(e.date1), 2, '0')) AS fake_marriage, " . "DATE_FORMAT(e.date1, " . $currentRequest->datefmt . ") AS DOM, e.date1, " . PersonDetail::getFields("groom", "ng", "bg", "dg") . "," . PersonDetail::getFields("bride", "nb", "bb", "db") . ", sp.dissolve_date, sp.dissolve_reason," . " DATE_FORMAT(sp.dissolve_date, " . $currentRequest->datefmt . ") AS DOD, e.event_id " . " FROM " . $tblprefix . "event e" . " JOIN " . $tblprefix . "spouses sp ON sp.event_id = e.event_id" . " LEFT JOIN " . $tblprefix . "people bride ON sp.bride_id = bride.person_id " . " LEFT JOIN " . $tblprefix . "people groom ON sp.groom_id = groom.person_id " . PersonDetail::getJoins("LEFT", "groom", "ng", "bg", "dg") . PersonDetail::getJoins("LEFT", "bride", "nb", "bb", "db");
     // if the user is not logged in, only show people pre $restrictdate
     $query .= $this->addPersonRestriction(" WHERE ", "bb", "db");
     $query .= $this->addPersonRestriction(" AND ", "bg", "dg");
     $query .= " AND (e.etype = " . BANNS_EVENT . " OR e.etype = " . MARRIAGE_EVENT . ") ";
     if ($limit > 0) {
         $query .= " HAVING fake_marriage >= now() AND fake_marriage <= DATE_ADD(NOW(), INTERVAL {$limit} DAY) ORDER BY fake_marriage";
     }
     $this->addLimit($search, $query);
     $result = $this->runQuery($query, $err_marriage);
     $search->numResults = 0;
     while ($row = $this->getNextRow($result)) {
         $rel = new Relationship();
         $rel->person->loadFields($row, L_HEADER, "groom_");
         $rel->person->name->loadFields($row, "ng_");
         $rel->relation->loadFields($row, L_HEADER, "bride_");
         $rel->relation->name->loadFields($row, "nb_");
         $rel->loadFields($row);
         $rel->marriage_date = $row["date1"];
         $rel->dom = $row["DOM"];
         $search->numResults++;
         $res[] = $rel;
     }
     $this->freeResultSet($result);
     $search->results = $res;
 }
Esempio n. 3
0
 function getImages(&$img, $eid = -1, $sid = -1)
 {
     global $tblprefix, $err_images;
     $iquery = "SELECT image_id, i.title, p.person_id as p_person_id, i.event_id, " . Event::getFields("e") . "," . PersonDetail::getFields() . "," . Source::getFields("s") . ", s.source_id as s_source_id" . " FROM " . $tblprefix . "images i " . " LEFT JOIN " . $tblprefix . "event e ON e.event_id = i.event_id " . " LEFT JOIN " . $tblprefix . "people p ON p.person_id = e.person_id " . " LEFT JOIN " . $tblprefix . "source s ON s.source_id = i.source_id " . PersonDetail::getJoins();
     switch ($img->queryType) {
         case Q_RANDOM:
             $iquery .= $this->addPersonRestriction(" WHERE ") . $this->addRandom();
             break;
         default:
             if ($sid > 0) {
                 $iquery .= " WHERE s.source_id = " . quote_smart($sid);
             } else {
                 if ($eid > 0) {
                     $iquery .= " WHERE e.event_id = " . quote_smart($eid);
                 } else {
                     if (isset($img->person->person_id)) {
                         $iquery .= " WHERE ";
                         $iquery .= "p.person_id = " . quote_smart($img->person->person_id);
                         $iquery .= $this->addPersonRestriction(" AND ");
                         if (isset($img->image_id)) {
                             $iquery .= " AND image_id=" . $img->image_id;
                         }
                         $iquery .= " ORDER BY e.date1";
                     } else {
                         $bool = " WHERE ";
                         if (isset($img->image_id)) {
                             $iquery .= " WHERE image_id=" . $img->image_id;
                             $bool = " AND ";
                         }
                         $iquery .= $this->addPersonRestriction($bool) . " ORDER BY b.date1";
                     }
                 }
             }
             break;
     }
     $this->addLimit($img, $query);
     $iresult = $this->runQuery($iquery, $err_images);
     $res = array();
     $img->numResults = 0;
     while ($row = $this->getNextRow($iresult)) {
         $image = new Image();
         $image->person = new PersonDetail();
         $image->person->loadFields($row, L_HEADER, "p_");
         $image->person->name->loadFields($row, "n_");
         $image->image_id = $row["image_id"];
         $image->title = $row["title"];
         $image->event = new Event();
         $image->event->loadFields($row, "e_");
         $image->source = new Source();
         $image->source->loadFields($row, "s_");
         $image->description = $image->event->descrip;
         $image->date = $image->event->date1;
         $res[] = $image;
         $img->numResults++;
     }
     $this->freeResultSet($iresult);
     $img->results = $res;
 }
Esempio n. 4
0
 function getTranscripts(&$trans, $eid = -1, $sid = -1)
 {
     global $tblprefix, $err_trans, $currentRequest;
     $res = array();
     $squery = "SELECT p.person_id, id, doc_title, file_name, e.event_id, e.descrip, e.date1," . Event::getFields("e") . "," . Source::getFields("s") . ", s.source_id as s_source_id," . PersonDetail::getFields() . " FROM " . $tblprefix . "documents doc" . " LEFT JOIN " . $tblprefix . "event e ON e.event_id = doc.event_id " . " LEFT JOIN " . $tblprefix . "people p ON p.person_id = e.person_id " . " LEFT JOIN " . $tblprefix . "source s ON s.source_id = doc.source_id " . PersonDetail::getJoins("LEFT");
     if ($sid > 0) {
         $squery .= " WHERE s.source_id = " . quote_smart($sid);
     } else {
         if ($eid > 0) {
             $squery .= " WHERE e.event_id = " . quote_smart($eid);
         } else {
             if (isset($trans->person->person_id) && $trans->person->person_id > 0) {
                 $squery .= " WHERE ";
                 $squery .= "p.person_id = " . quote_smart($trans->person->person_id);
                 $squery .= $this->addPersonRestriction(" AND ");
                 if (isset($trans->transcript_id)) {
                     $squery .= " AND id=" . $trans->transcript_id;
                 }
                 $squery .= " ORDER BY e.date1";
             } else {
                 $bool = " WHERE ";
                 if (isset($trans->transcript_id)) {
                     $squery .= " WHERE id=" . $trans->transcript_id;
                     $bool = " AND ";
                 }
                 $squery .= $this->addPersonRestriction($bool) . " ORDER BY b.date1";
             }
         }
     }
     $result = $this->runQuery($squery, $err_trans);
     $trans->numResults = 0;
     while ($row = $this->getNextRow($result)) {
         $t = new Transcript();
         $t->person = new PersonDetail();
         $t->person->loadFields($row, L_HEADER, "p_");
         $t->person->name->loadFields($row, "n_");
         $t->person->person_id = $row["person_id"];
         $t->transcript_id = $row["id"];
         $t->event = new Event();
         $t->event->loadFields($row, "e_");
         $t->event->event_id = $row["event_id"];
         $t->source = new Source();
         $t->source->loadFields($row, "s_");
         $t->description = $t->event->descrip;
         $t->date = $t->event->date1;
         $t->title = $row["doc_title"];
         $t->file_name = $row["file_name"];
         $trans->numResults++;
         $res[] = $t;
     }
     $this->freeResultSet($result);
     $trans->results = $res;
 }
Esempio n. 5
0
function setup_edit()
{
    $per = new PersonDetail();
    $per->father = new PersonDetail();
    $per->mother = new PersonDetail();
    $per->birth_place = new Location();
    $per->setFromRequest();
    $per->queryType = Q_IND;
    $dao = getPeopleDAO();
    $dao->getPersonDetails($per);
    if ($per->numResults > 0) {
        $ret = $per->results[0];
    } else {
        $ret = $per;
    }
    $dao = getEventDAO();
    $e = new Event();
    $e->person->person_id = $per->person_id;
    $dao->getEvents($e, Q_BD, true);
    $ret->events = $e->results;
    return $ret;
}
Esempio n. 6
0
 function getAttendees(&$event)
 {
     global $tblprefix;
     $query = "SELECT " . Attendee::getFields('a') . "," . PersonDetail::getFields('p') . "," . Location::getFields('l') . " FROM " . $tblprefix . "attendee a" . " JOIN " . $tblprefix . "people p ON a.person_id = p.person_id" . " LEFT JOIN " . $tblprefix . "locations l ON l.location_id = a.location_id" . PersonDetail::getJoins();
     $query .= " WHERE a.event_id = " . $event->event_id;
     $query .= $this->addPersonRestriction(" AND ");
     //TODO error message
     $result = $this->runQuery($query, '');
     $res = array();
     while ($row = $this->getNextRow($result)) {
         $e = new Attendee();
         $e->loadFields($row, "a_");
         $per = new PersonDetail();
         $per->loadFields($row, L_HEADER, "p_");
         $per->name->loadFields($row, "n_");
         $per->name->person_id = $per->person_id;
         $e->person = $per;
         $e->location->loadFields($row, "l_");
         $res[] = $e;
     }
     $this->freeResultSet($result);
     $event->attendees = $res;
 }
Esempio n. 7
0
 function getSourceEvents(&$source)
 {
     global $tblprefix, $restrictdate, $strEvent, $datefmt;
     $pquery = "SELECT s.source_id, " . Source::getFields("s") . "," . Event::getFields("e") . "," . PersonDetail::getFields('p') . " FROM " . $tblprefix . "source s" . " JOIN " . $tblprefix . "source_event se ON s.source_id=se.source_id" . " JOIN " . $tblprefix . "event e ON se.event_id=e.event_id" . " JOIN " . $tblprefix . "people p ON e.person_id = p.person_id" . PersonDetail::getJoins();
     if ($source->source_id > 0) {
         $pquery .= " WHERE s.source_id = " . $source->source_id;
     }
     $presult = $this->runQuery($pquery, "");
     $source->numResults = 0;
     while ($row = $this->getNextRow($presult)) {
         $e = new Event();
         $e->loadFields($row, "e_");
         $e->person->loadFields($row, L_HEADER, "p_");
         $e->person->name->loadFields($row, "n_");
         $e->person->setPermissions();
         $source->results[] = $e;
         $source->numResults++;
     }
     $this->freeResultSet($presult);
 }
Esempio n. 8
0
$gridsize = "40";
function a2p($a)
{
    global $base, $gridsize;
    $r = $a + $base;
    if ($r < 0) {
        return 20;
    }
    return $r * $gridsize + 20;
}
// --------------------------------------------------------------------
// ---------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Get the details of the first person
// check we have a person
$peep = new PersonDetail();
$peep->setFromRequest();
$peep->queryType = Q_IND;
$dao = getPeopleDAO();
$dao->getPersonDetails($peep);
if ($peep->numResults != 1) {
    die("Could not find person");
}
$per = $peep->results[0];
// the query for the database
// Security ------------------
// set security for living people (born after 01/01/1910)
if (!$per->isViewable()) {
    // ATTENTION: Correct path to the inc directory
    //		   die(include $our_path."inc/forbidden.inc.php");
    die(include "inc/forbidden.inc.php");
Esempio n. 9
0
include_once "modules/db/DAOFactory.php";
include_once "inc/DateUtil.php";
ini_set("auto_detect_line_endings", TRUE);
$config = Config::getInstance();
$filename = "{$config->desc}.ged";
header("Content-Location: " . $filename);
header("Content-Type: application/unknown");
header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
header("Content-Transfer-Encoding: binary");
// write gedcom header
$today = date("d M Y");
echo "0 HEAD\n1 SOUR phpmyfamily\n2 VERS {$version}\n2 CORP phpmyfamily.sourceforge.net\n3 ADDR http://www.phpmyfamily.net\n1 DEST any\t\t\n1 DATE {$today}\n1 SUBM @phpmyfamily@\n1 GEDC\n2 VERS 5.5\n2 FORM Lineage-Linked\n1 CHAR ASCII\n1 FILE {$config->desc}.ged\n";
//end of header
// deal with gedcom INDIviduals
$famarray = array();
$peep = new PersonDetail();
$peep->setFromRequest();
if (isset($peep->person_id)) {
    $peep->queryType = Q_IND;
} else {
    $peep->queryType = Q_TYPE;
}
$dao = getPeopleDAO();
$dao->getPersonDetails($peep, "print_person");
function output_ged($level, $tag, $data, $suffix = "")
{
    echo $level . " " . $tag . html_entity_decode($data, ENT_QUOTES) . $suffix . "\n";
}
function print_person($search, $per)
{
    global $famarray;
Esempio n. 10
0
 function getMissingRecords($cen)
 {
     global $tblprefix;
     $tquery = "SELECT DISTINCT " . PersonDetail::getFields() . " FROM " . $tblprefix . "people p " . " LEFT JOIN " . $tblprefix . "attendee a ON p.person_id = a.person_id" . " LEFT JOIN " . $tblprefix . "census c ON a.event_id = c.event_id AND census = " . $cen->census_id . " JOIN " . $tblprefix . "census_years cy ON cy.census_id = " . $cen->census_id . PersonDetail::getJoins() . "WHERE c.event_id is null AND (b.date1 <= cy.census_date AND d.date1 >= cy.census_date)";
     $tquery .= $this->addPersonRestriction(" AND ", "p");
     $tquery .= " ORDER BY date_of_birth";
     //TODO error message
     $tresult = $this->runQuery($tquery, "");
     $ret = array();
     while ($trow = $this->getNextRow($tresult)) {
         $p = new PersonDetail();
         $p->loadFields($trow, L_HEADER, "p_");
         $p->name->loadFields($trow, "n_");
         $ret[] = $p;
     }
     $this->freeResultSet($tresult);
     return $ret;
 }
Esempio n. 11
0
<?php

include_once "modules/db/DAOFactory.php";
$peep = new PersonDetail();
$peep->queryType = Q_IND;
$config = Config::getInstance();
$per = new PersonDetail();
$dao = getPeopleDAO();
$loc = "index.php";
if (isset($_REQUEST["func"]) && $_REQUEST["func"] == "delete") {
    $per->setFromRequest();
    $peep->setFromRequest();
    $dao->getPersonDetails($peep);
    $peep = $peep->results[0];
    if (!$peep->isEditable()) {
        die(include "inc/forbidden.inc.php");
    }
    // If Big Brother is watching
    // We need to call it here while we can!
    stamppeeps($per);
    $dao->deletePerson($per);
    // have to go to index, cos don't know where else to go
    $loc = "index.php";
} else {
    $peep->setFromPost();
    if (isset($peep->person_id)) {
        $peep->name = new Name();
        unset($peep->date_of_birth);
        unset($peep->gender);
        $peep->queryType = Q_IND;
        $dao->getPersonDetails($peep);
Esempio n. 12
0
 function getTrackedPeople()
 {
     global $tblprefix, $currentRequest, $err_listpeeps;
     $query = "SELECT p.person_id as p_person_id," . PersonDetail::getFields() . ",updated, DATE_FORMAT(updated, " . $currentRequest->datefmt . ") AS ddate" . " FROM " . $tblprefix . "people p " . PersonDetail::getJoins() . " JOIN " . $tblprefix . "tracking t ON p.person_id = t.person_id" . " WHERE " . "t.email = " . quote_smart($_SESSION["email"]);
     $result = $this->runQuery($query, $err_listpeeps);
     $res = array();
     while ($row = $this->getNextRow($result)) {
         $per = new PersonDetail();
         $per->loadFields($row, L_HEADER, "p_");
         $per->name->loadFields($row, "n_");
         $per->name->person_id = $per->person_id;
         $per->updated = $row["updated"];
         $per->dupdated = $row["ddate"];
         $res[] = $per;
     }
     return $res;
 }
            if (isset($_GET["start"])) {
                $start = $_GET["start"];
            }
            if (isset($_GET["date"]) && $_GET["date"] != "0") {
                $date = $_GET["date"];
            }
            if (isset($_GET["count"])) {
                $count = $_GET["count"];
            }
            if (isset($_GET["name"])) {
                $name = $_GET["name"];
            }
        }
        break;
}
$search = new PersonDetail();
$search->queryType = Q_TYPE;
$search->person_id = 0;
$search->gender = 'A';
if (isset($id)) {
    $search->person_id = $id;
    $search->queryType = Q_IND;
} else {
    ?>
    <?php 
    //{name:"", label:"",personid:"-1"},
}
if (isset($gender)) {
    $search->gender = $gender;
}
if (isset($start)) {
Esempio n. 14
0
 function getAttendeePlaces(&$locations, $person = null)
 {
     global $tblprefix, $strEvent, $datefmt;
     global $strBirthPlace, $strAddress;
     $query = "SELECT " . Attendee::getFields('a') . "," . PersonDetail::getFields('p') . ", " . Event::getFields("e") . "," . Location::getFields("l") . "," . Location::getFields("el") . " FROM " . $tblprefix . "attendee a" . " JOIN " . $tblprefix . "people p ON a.person_id = p.person_id" . " JOIN " . $tblprefix . "event e ON a.event_id = e.event_id" . " LEFT JOIN " . $tblprefix . "locations el ON el.location_id = e.location_id" . " LEFT JOIN " . $tblprefix . "locations l ON l.location_id = a.location_id" . PersonDetail::getJoins() . " WHERE (a.location_id is not null OR e.location_id is not null)" . " AND (NOT (e.etype = " . BANNS_EVENT . " OR e.etype=" . MARRIAGE_EVENT . "))";
     $query .= $this->addPersonRestriction(" AND ");
     if ($locations->location_id > 0) {
         $query .= " AND (a.location_id = " . $locations->location_id . " OR e.location_id = " . $locations->location_id . ")";
     }
     $presult = $this->runQuery($query, "");
     while ($prow = $this->getNextRow($presult)) {
         $per = new PersonDetail();
         $per->loadFields($prow, L_HEADER, 'p_');
         $per->name->loadFields($prow, 'n_');
         $per->setPermissions();
         $e = new Event();
         $e->loadFields($prow, "e_");
         $loc = new Location();
         $loc->loadFields($prow, "l_");
         $loc->setPermissions();
         if ($per->isViewable() && $loc->hasData()) {
             $text = $per->getLink() . ' ';
             switch ($e->type) {
                 case CENSUS_EVENT:
                     $text .= $strEvent[$e->type] . " " . $strBirthPlace;
                     break;
                 default:
                     $text .= $strAddress;
                     break;
             }
             $text .= ' ' . $e->getDate1();
             if ($locations->location_id > 0 && $loc->location_id == $locations->location_id || $locations->location_id <= 0) {
                 $p = $this->createPlace($locations, $loc, $text);
             }
         }
         $e->location->loadFields($prow, "el_");
         $e->location->setPermissions();
         if ($per->isViewable() && $e->location->hasData()) {
             $text = $per->getLink() . ' ' . $strEvent[$e->type] . ' ' . $e->getDate1();
             if ($locations->location_id > 0 && $e->location->location_id == $locations->location_id || $locations->location_id <= 0) {
                 $p = $this->createPlace($locations, $e->location, $text);
             }
         }
     }
     $this->freeResultSet($presult);
 }
Esempio n. 15
0
<?php

set_include_path('..');
include_once 'modules/db/DAOFactory.php';
$view = "CREATE OR REPLACE VIEW `" . $tblprefix . "person_detail` AS \n\t\tselect " . PersonDetail::getFields() . " FROM " . $tblprefix . "people p " . PersonDetail::getJoins();
if ($rconfig = mysql_query($view)) {
    echo "person_detail view created<br>\n";
} else {
    echo mysql_error();
    die("phpmyfamily: Error creating person_detail view!!!");
}