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 getMarriagePlaces(&$locations, $person = null)
 {
     global $tblprefix, $strEvent, $currentRequest;
     $pquery = "select relation.event_id," . PersonDetail::getFields("groom", "ng", "bg", "dg") . "," . PersonDetail::getFields("bride", "nb", "bb", "db") . "," . Event::getFields("e") . ", relation.dissolve_date, relation.dissolve_reason," . " DATE_FORMAT(relation.dissolve_date, " . $currentRequest->datefmt . ") AS DOD " . "," . Location::getFields("l") . " FROM " . $tblprefix . "event e" . " JOIN " . $tblprefix . "spouses relation ON relation.event_id=e.event_id" . " JOIN " . $tblprefix . "locations l ON e.location_id=l.location_id " . " LEFT JOIN " . $tblprefix . "people bride ON relation.bride_id = bride.person_id " . " LEFT JOIN " . $tblprefix . "people groom ON relation.groom_id = groom.person_id " . PersonDetail::getJoins("LEFT", "groom", "ng", "bg", "dg") . PersonDetail::getJoins("LEFT", "bride", "nb", "bb", "db") . " WHERE (e.etype = " . BANNS_EVENT . " OR e.etype=" . MARRIAGE_EVENT . ") AND e.location_id is not null";
     $pquery .= $this->addPersonRestriction(" AND ", "bg", "dg");
     $pquery .= $this->addPersonRestriction(" AND ", "bb", "db");
     if ($locations->location_id > 0) {
         $pquery .= " AND l.location_id = " . $locations->location_id;
     }
     $presult = $this->runQuery($pquery, "");
     while ($row = $this->getNextRow($presult)) {
         $rel = new Relationship();
         $rel->person->loadFields($row, L_HEADER, "groom_");
         $rel->person->name->loadFields($row, "ng_");
         $rel->person->setPermissions();
         $rel->relation->loadFields($row, L_HEADER, "bride_");
         $rel->relation->name->loadFields($row, "nb_");
         $rel->relation->setPermissions();
         $rel->loadFields($row);
         $rel->event = new Event();
         $rel->event->loadFields($row, "e_");
         $rel->event->location->loadFields($row, "l_");
         $rel->event->location->setPermissions();
         $text = $rel->person->getLink() . ' ' . $strEvent[$row["e_etype"]] . ' ' . $rel->relation->getLink() . ' ' . $rel->event->getDate1();
         if ($rel->isViewable()) {
             $p = $this->createPlace($locations, $rel->event->location, $text);
             if ($p != null) {
                 $p->marriage = true;
             }
         }
     }
     $this->freeResultSet($presult);
 }