Exemple #1
0
 static function getFields($prefix)
 {
     global $currentRequest;
     $fields = array("title", "reference", "url", "ref_date", "notes", "certainty");
     $ret = Base::addFields($prefix, $fields);
     return $ret;
 }
Exemple #2
0
 static function getFields($prefix)
 {
     global $currentRequest;
     $fields = array("event_id", "etype", "descrip", "person_id", "location_id", "d1type", "date1", "d2type", "date2", "notes");
     $ret = Base::addFields($prefix, $fields);
     $ret .= ", DATE_FORMAT(" . $prefix . ".date1, " . $currentRequest->datefmt . ") AS " . $prefix . "_fdate1";
     //$ret .= ", DATE_FORMAT(".$prefix.".date2, ".$currentRequest->datefmt.") AS ".$prefix."_fdate2";
     return $ret;
 }
 static function getFields($tbl = 'p', $name = 'n', $birth = 'b', $death = 'd')
 {
     global $currentRequest;
     $fields = array("person_id", "gender");
     $ret = Base::addFields($tbl, $fields);
     $prefix = "";
     $tbl_pref = "";
     if (strlen($tbl) > 0) {
         $prefix = $tbl . "_";
         $tbl_pref = $tbl . ".";
     }
     $ret .= ", DATE_FORMAT(" . $birth . ".date1, " . $currentRequest->datefmt . ") AS " . $prefix . "DOB";
     $ret .= ", " . $birth . ".date1 AS " . $prefix . "date_of_birth";
     $ret .= ", DATE_FORMAT(" . $death . ".date1, " . $currentRequest->datefmt . ") AS " . $prefix . "DOD";
     $ret .= ", " . $death . ".date1 AS " . $prefix . "date_of_death";
     $ret .= ", " . Name::getFields($name);
     return $ret;
 }
Exemple #4
0
 static function getFields($tbl)
 {
     global $currentRequest;
     $fields = array("title", "forenames", "link", "surname", "suffix", "knownas");
     return Base::addFields($tbl, $fields);
 }
Exemple #5
0
 function getPersonDetails(&$search, $callback = '')
 {
     global $tblprefix, $err_listpeeps, $currentRequest;
     if ($search->queryType == Q_IND && !isset($search->person_id)) {
         return;
     }
     $use_callback = false;
     $numargs = func_num_args();
     if ($numargs > 1) {
         $use_callback = true;
     }
     $res = array();
     // create the query based on the parameters
     $query = "SELECT DISTINCT ";
     switch ($search->queryType) {
         case Q_COUNT:
             $fields = "COUNT(p.person_id) AS count ";
             break;
         default:
             $flds = array("death_reason", "mother_id", "father_id", "narrative", "updated");
             $fields = PersonDetail::getFields() . ", bl.place AS p_birth_place" . ", YEAR(b.date1) AS p_year_of_birth" . ", " . Base::addFields("p", $flds) . ", DATE_FORMAT(updated, " . $currentRequest->datefmt . ") AS ddate";
             break;
     }
     $from = " FROM " . $tblprefix . "people p ";
     $from .= PersonDetail::getJoins();
     $from .= " LEFT JOIN " . $tblprefix . "locations bl ON bl.location_id = b.location_id";
     switch ($search->queryType) {
         case Q_TYPE:
         case Q_COUNT:
             $where = " WHERE p.person_id <> -1";
             //.$search->person_id;
             break;
         default:
             $where = " WHERE p.person_id = " . $search->person_id;
             break;
     }
     // if the user is not logged in, only show people pre $restrictdate
     $where .= $this->addPersonRestriction(" AND ");
     // need the gender if listing for mother or father selection
     if (isset($search->gender)) {
         if ($search->gender != 'A') {
             $where .= " AND gender = '" . $search->gender . "'";
         }
     }
     if (isset($search->date_of_birth) && $search->date_of_birth != '') {
         $where .= " AND b.date1 <= '" . $search->date_of_birth . "'";
     }
     if (isset($search->name->surname)) {
         $where .= " AND (";
         $op = " OR ";
         if (isset($search->name->forenames)) {
             $firstname = $search->name->forenames;
             $op = " AND ";
         } else {
             $firstname = $search->name->surname;
         }
         $lastname = $search->name->surname;
         $where .= " n.forenames LIKE " . quote_smart($firstname) . $op . " n.surname LIKE " . quote_smart($lastname);
         $where .= ")";
     }
     if (isset($search->filter)) {
         $where .= " AND (" . $search->filter . ")";
     }
     $query .= $fields . $from . $where;
     // and sort the query
     if (!$use_callback) {
         if (!isset($search->count)) {
             $search->count = 10;
         }
     }
     if ($search->queryType != Q_COUNT) {
         if (isset($search->order)) {
             $query .= " ORDER BY " . $search->order;
         } else {
             $query .= " ORDER BY n.surname, n.forenames, b.date1";
         }
         $this->addLimit($search, $query);
     }
     $result = $this->runQuery($query, $err_listpeeps);
     $search->numResults = 0;
     while ($row = $this->getNextRow($result)) {
         switch ($search->queryType) {
             case Q_COUNT:
                 $search->numResults = $row["count"];
                 break;
             default:
                 $search->numResults++;
                 $per = new PersonDetail();
                 $per->loadFields($row, L_ALL, "p_");
                 $per->name->loadFields($row, "n_");
                 $per->name->person_id = $per->person_id;
                 $per->updated = $row["p_updated"];
                 $per->dupdated = $row["ddate"];
                 if ($use_callback) {
                     call_user_func($callback, $search, $per);
                 } else {
                     $res[] = $per;
                 }
                 break;
         }
     }
     $this->freeResultSet($result);
     $search->results = $res;
 }
Exemple #6
0
 static function getFields($prefix)
 {
     $fields = array("attendee_id", "event_id", "person_id", "age", "location_id", "profession", "r_status", "loc_descrip", "certified", "notes");
     $ret = Base::addFields($prefix, $fields);
     return $ret;
 }
Exemple #7
0
 static function getFields($tbl)
 {
     $fields = array("location_id", "name", "place", "lat", "lng", "centre");
     $ret = Base::addFields($tbl, $fields);
     return $ret;
 }