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; }
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; }
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); }