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