Example #1
0
 function getEvents(&$events, $type, $attendees = false)
 {
     global $tblprefix;
     $events->numResults = 0;
     $query = "SELECT " . Event::getFields('e') . "," . Location::getFields('l') . " FROM " . $tblprefix . "event e" . " LEFT JOIN " . $tblprefix . "locations l ON l.location_id = e.location_id";
     switch ($type) {
         case Q_BD:
             $query .= " WHERE etype < 4";
             $query .= " AND e.person_id = " . $events->person->person_id;
             //birth and death events only
             if (!isset($events->person) || $events->person->person_id == '') {
                 return;
             }
             break;
         case Q_REL:
             $query .= " WHERE (etype = " . BANNS_EVENT . " OR etype = " . MARRIAGE_EVENT . ")";
             $query .= " AND e.event_id = " . $events->event_id;
             if (!isset($events->event_id) || $events->event_id == '') {
                 return;
             }
             break;
         case Q_CEN:
             $query .= " WHERE etype = " . CENSUS_EVENT;
             $query .= " AND e.person_id = " . $events->person->person_id;
             if (!isset($events->person) || $events->person->person_id == '') {
                 return;
             }
             break;
         case Q_OTHER:
             $query .= " WHERE etype = " . OTHER_EVENT;
             $query .= " AND e.person_id = " . $events->person->person_id;
             if (!isset($events->person) || $events->person->person_id == '') {
                 return;
             }
             break;
         case Q_ALL:
             $query .= " WHERE e.event_id = " . $events->event_id;
             if (!isset($events->event_id) || $events->event_id == '') {
                 return;
             }
     }
     //TODO error message
     $result = $this->runQuery($query, '');
     $res = array();
     while ($row = $this->getNextRow($result)) {
         $e = new Event();
         $e->loadFields($row, "e_");
         $e->location->loadFields($row, "l_");
         if ($attendees) {
             $this->getAttendees($e);
         }
         $events->numResults++;
         $res[] = $e;
     }
     $this->freeResultSet($result);
     $events->results = $res;
 }
Example #2
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 #3
0
 function getCensusDetails(&$input)
 {
     global $tblprefix, $err_census_ret;
     $res = array();
     $input->results = $res;
     $edquery = "SELECT cen.census_id, cen.census, schedule, year, census_date, cy.country, " . Event::getFields('e') . "," . PersonDetail::getFields() . "," . Attendee::getFields('a') . "," . Location::getFields('l') . "," . Location::getFields('al') . " FROM " . $tblprefix . "attendee a" . " JOIN " . $tblprefix . "event e ON a.event_id = e.event_id" . " JOIN " . $tblprefix . "census cen ON cen.event_id = e.event_id" . " JOIN " . $tblprefix . "people p ON a.person_id = p.person_id" . " LEFT JOIN " . $tblprefix . "locations l ON l.location_id = e.location_id" . " LEFT JOIN " . $tblprefix . "locations al ON al.location_id = a.location_id" . " LEFT JOIN " . $tblprefix . "census_years cy ON cen.census = cy.census_id" . PersonDetail::getJoins();
     switch ($input->queryType) {
         case Q_TYPE:
             $where = "";
             if (isset($input->schedule)) {
                 $where = " WHERE e.reference =" . $input->schedule;
             }
             break;
         case Q_FAMILY:
             $where = " WHERE e.event_id = " . $input->event->event_id;
             if (!isset($input->event->event_id) || $input->event->event_id == '') {
                 return;
             }
             break;
         default:
             $where = " WHERE p.person_id = " . $input->person->person_id;
             break;
     }
     $where .= $this->addPersonRestriction(" AND ");
     $orderby = " ORDER BY e.date1, b.date1";
     $edquery .= $where . $orderby;
     if ($edresult = $this->runQuery($edquery, $err_census_ret)) {
         $input->numResults = 0;
         $events = array();
         while ($edrow = $this->getNextRow($edresult)) {
             $cen = new CensusDetail();
             $cen->loadFields($edrow);
             $e = new Event();
             $e->loadFields($edrow, "e_");
             $e->location->loadFields($edrow, "l_");
             $new = false;
             if (isset($events[$e->event_id])) {
                 $event = $events[$e->event_id];
             } else {
                 $new = true;
                 $e->attendees = array();
                 $events[$e->event_id] = $e;
                 $event = $e;
             }
             $a = new Attendee();
             $a->person->loadFields($edrow, L_HEADER, "p_");
             $a->person->name->loadFields($edrow, "n_");
             if ($a->person->person_id == $event->person->person_id) {
                 $event->person = $a->person;
             }
             $a->loadFields($edrow, "a_");
             $a->location->loadFields($edrow, "al_");
             $event->attendees[] = $a;
             //This is needed for php 4
             $events[$event->event_id] = $event;
             if ($new) {
                 $cen->event = $event;
                 $input->numResults++;
                 $res[] = $cen;
             }
             //This is also needed for php 4
             for ($i = 0; $i < count($res); $i++) {
                 if ($res[$i]->event->event_id == $event->event_id) {
                     $c = $res[$i];
                     $c->event = $event;
                     $res[$i] = $c;
                 }
             }
         }
         $this->freeResultSet($edresult);
     }
     $input->results = $res;
 }
Example #4
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);
 }