Example #1
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;
 }
Example #2
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;
 }
Example #3
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;
 }
Example #4
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);
 }
Example #5
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;
 }
Example #6
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;
 }
Example #7
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;
 }
Example #8
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);
 }
Example #9
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!!!");
}