function setup_edit() { $img = new Image(); $img->image_id = -1; $img->setFromRequest(); $dao = getImageDAO(); $dao->getImages($img); if ($img->numResults == 0) { if (isset($_REQUEST["event"])) { $dao = getEventDAO(); $event = new Event(); $event->setFromRequest(); $dao->getEvents($event, Q_ALL); $img->event = $event->results[0]; $img->person = $img->event->person; } else { $img->event = new Event(); } if ($img->person->person_id > 0) { $img->person->queryType = Q_IND; $dao = getPeopleDAO(); $dao->getPersonDetails($img->person); $img->person = $img->person->results[0]; } $img->source = new Source(); $img->source->setFromRequest(); if ($img->source->source_id > 0) { $sdao = getSourceDAO(); $sdao->getSources($img->source); if ($img->source->numResults > 0) { $img->source = $img->source->results[0]; } } $ret = $img; } else { $ret = $img->results[0]; } return $ret; }
function setup_edit() { $trans = new Transcript(); $trans->setFromRequest(); if (!isset($trans->transcript_id)) { if (isset($_REQUEST["person"]) && $trans->person->person_id > 0) { $trans->person->queryType = Q_IND; $dao = getPeopleDAO(); $dao->getPersonDetails($trans->person); if ($trans->person->numResults == 0) { $trans->person = $trans->person->results[0]; } else { $trans->person = new PersonDetail(); $trans->person->setFromRequest(); } } else { $trans->person = new PersonDetail(); $trans->person->setFromRequest(); } $trans->source = new Source(); $trans->source->setFromRequest(); if ($trans->source->source_id > 0) { $sdao = getSourceDAO(); $sdao->getSources($trans->source); if ($trans->source->numResults > 0) { $trans->source = $trans->source->results[0]; } } $ret = $trans; } else { $dao = getTranscriptDAO(); $dao->getTranscripts($trans); if ($trans->numResults == 0) { if (isset($_REQUEST["event"])) { $dao = getEventDAO(); $event = new Event(); $event->setFromRequest(); $dao->getEvents($event, Q_ALL); $trans->event = $event->results[0]; $trans->person = $trans->event->person; } if ($trans->person->person_id > 0) { $trans->person->queryType = Q_IND; $dao = getPeopleDAO(); $dao->getPersonDetails($trans->person); $trans->person = $trans->person->results[0]; } else { $trans->person = new PersonDetail(); } $trans->source = new Source(); $trans->source->setFromRequest(); if ($trans->source->source_id > 0) { $sdao = getSourceDAO(); $sdao->getSources($trans->source); if ($trans->source->numResults > 0) { $trans->source = $trans->source->results[0]; } } $ret = $trans; } else { $ret = $trans->results[0]; } } return $ret; }
<?php include_once "modules/db/DAOFactory.php"; $s = new Source(); $dao = getSourceDAO(); if (isset($_REQUEST["func"]) && $_REQUEST["func"] == "delete") { $s->setFromRequest(); checkPermissions($dao, $s); $dao->deleteSource($s); } else { $s->setFromPost(''); checkPermissions($dao, $s); $dao->saveSource($s); } header("Location: index.php"); function checkPermissions($dao, $source) { $s = new Source(); $s->source_id = $source->source_id; $dao->getSources($s); if ($s->numResults > 0) { $ret = $s->results[0]; } else { $ret = $s; } /* if (!$ret->isEditable()) { die(include "inc/forbidden.inc.php"); } */ return $ret;
function printCensusRow($cen, $attendee, $type, $per, $class) { global $strEdit, $strDelete, $strCensus; if ($type == SHOW_CENSUS) { ?> <td class="<?php echo $class; ?> "> <?php echo $attendee->person->getLink(); ?> </td> <?php } else { if ($per->isEditable()) { echo "<td class=\"" . $class . "\">"; echo "<a href=\"edit.php?person=" . $per->person_id . "&area=census&event=" . $cen->event->event_id . "\">" . $strEdit . "</a>" . "::" . "<a href=\"JavaScript:confirm_delete('" . $cen->year . " (" . $cen->country . ")', '" . strtolower($strCensus) . "', 'passthru.php?func=delete&person=" . $cen->event->person->person_id . "&area=census&event=" . $cen->event->event_id . "')\" class=\"delete\">" . $strDelete . "</a>"; echo "</td>"; } ?> <td class="<?php echo $class; ?> "><?php echo $cen->year . " (" . $cen->country . ")"; ?> </td> <td class="<?php echo $class; ?> "> <a href="census.php?event=<?php echo $cen->event->event_id; ?> ">full details</a><?php $sdao = getSourceDAO(); $sdao->getEventSources($cen->event); if (is_array($cen->event->results) && count($cen->event->results) > 0) { foreach ($cen->event->results as $src) { echo $src->getFullDisplay(); } } ?> </td> <?php } ?> <td class="<?php echo $class; ?> "><?php echo $cen->event->location->getDisplayPlace(); ?> </td> <td class="<?php echo $class; ?> "><?php echo $attendee->condition; ?> </td> <td class="<?php echo $class; ?> "><?php echo $attendee->age; ?> </td> <td class="<?php echo $class; ?> "><?php echo $attendee->profession; ?> </td> <td class="<?php echo $class; ?> "><?php echo $attendee->location->getDisplayPlace(); ?> </td> <td class="<?php echo $class; ?> "><?php echo $attendee->notes; ?> </td> <?php }
function get_edit_form($s) { global $strNotes, $strTitle, $strReference, $strURL, $strCertified, $strDate, $strSubmit, $strReset; $config = Config::getInstance(); if ($config->dojo) { ?> <script type="text/javascript"> dojo.addOnLoad(function() { var widget = dijit.byId('notes'); widget.name = 'notes'; dojo.connect(widget, 'onChange', function(){ widget.endEditing(); var desc = widget.getValue(); var stext = dojo.byId('notes'); stext.value = desc; }); }); </script><?php } ?> <!--Fill out form --> <form method="post" action="passthru.php?area=source"> <input type="hidden" name="source_id" value="<?php echo $s->source_id; ?> " /> <table> <tr> <td><?php echo $strTitle; ?> </td> <td><input type="text" name="title" value="<?php echo $s->title; ?> " size="30" maxlength="255" /></td> <td></td> </tr> <tr> <td><?php echo $strReference; ?> </td> <td><input type="text" name="reference" value="<?php echo $s->reference; ?> " size="30" maxlength="255" /></td> <td></td> </tr> <tr> <td><?php echo $strURL; ?> </td> <td><input type="text" name="url" value="<?php echo $s->url; ?> " size="30" maxlength="255" /></td> <td></td> </tr> <tr> <td><?php echo $strReference . " " . $strDate; ?> </td> <td><input type="text" name="ref_date" value="<?php echo $s->ref_date; ?> " size="30" maxlength="10" /></td> <td></td> </tr> <tr> <td><?php echo $strCertified; ?> </td> <td><?php certaintySelect("certainty", $s->certainty); ?> </td> <td></td> </tr> <tr> <td><?php echo $strNotes; ?> </td> <td><?php if ($config->dojo) { ?> <input type="hidden" name="notes" id="notes"/> <div id="notes" dojoType="dijit.Editor" minHeight="5em" plugins="['undo', 'redo', 'cut', 'copy', 'paste', '|', 'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', '|', 'removeFormat', 'indent', 'outdent', 'justifyCenter', 'justifyFull', 'justifyLeft', 'justifyRight', 'delete', 'insertOrderedList', 'insertUnorderedList', 'createLink', 'foreColor','hiliteColor']"> <?php echo $s->notes; ?> </div> <?php } else { ?> <textarea name="notes" id="notes" rows="10" cols="80"><?php echo $s->notes; ?> </textarea> <?php } ?> </td> <td></td> </tr> <tr> <td class="tbl_even"><input type="submit" name="Submit1" value="<?php echo $strSubmit; ?> " /></td> <td colspan="2" class="tbl_even"><input type="reset" name="Reset1" value="<?php echo $strReset; ?> " /></td> </tr> </table> <?php if ($s->source_id > 0) { $src = new Source(); $src->source_id = $s->source_id; $sdao = getSourceDAO(); $sdao->getSourceEvents($src); if ($src->numResults > 0) { foreach ($src->results as $event) { echo $event->person->getLink(); echo $event->getFullDisplay(""); } } } ?> </form> <?php if ($s->source_id > 0) { $per = new PersonDetail(); $per->editable = $s->isEditable(); $per->person_id = -1; echo "<div id=\"images\">"; echo get_image_create_string($per, -1, $s->source_id); echo "<br/>"; show_gallery($per, $dest = "people", -1, $s->source_id); echo "</div><div id=\"transcripts\">"; echo get_transcript_create_string($per, -1, $s->source_id); echo "<br/>"; show_transcript($per, -1, $s->source_id); echo "</div>"; } }
function saveEvent(&$event) { global $tblprefix, $err_person_update, $err_detail; $rowsChanged = 0; $insert = false; $dao = getLocationDAO(); $dao->resolveLocation($event->location); if (isset($event->event_id) && $event->event_id > 0) { $query = "UPDATE " . $tblprefix . "event SET etype = " . $event->type . ", descrip = " . quote_smart($event->descrip) . ", person_id = " . $event->person->person_id . ", location_id = " . $event->location->location_id . ", d1type = " . $event->date1_modifier . ", date1 = " . quote_smart($event->date1) . ", d2type = " . $event->date2_modifier . ", date2 = " . quote_smart($event->date2) . ", notes = " . quote_smart($event->notes) . " WHERE event_id = " . quote_smart($event->event_id); $msg = $err_person_update; } else { $this->lockTable($tblprefix . "event"); $query = "INSERT INTO " . $tblprefix . "event (etype, descrip, person_id, location_id, d1type, date1, d2type, date2, notes) VALUES (" . $event->type . ", " . quote_smart($event->descrip) . ", " . $event->person->person_id . ", " . $event->location->location_id . ", " . $event->date1_modifier . ", " . quote_smart($event->date1) . ", " . $event->date2_modifier . ", " . quote_smart($event->date2) . ", " . quote_smart($event->notes) . ")"; $msg = $err_detail; $insert = true; } $ret = $this->runQuery($query, $msg); $rowsChanged += $this->rowsChanged($ret); if ($insert) { $event->event_id = $this->getInsertId(); $this->unlockTable($tblprefix . "event"); } if (count($event->attendees) > 0) { foreach ($event->attendees as $a) { $a->event->event_id = $event->event_id; $rowsChanged += $this->saveAttendee($a); } } if (count($event->sources) > 0) { $sdao = getSourceDAO(); $sdao->deleteSourceEvent(null, $event); foreach ($event->sources as $s) { $rowsChanged += $sdao->resolveSource($s); $sdao->saveSourceEvent($s, $event); } } return $rowsChanged; }
function print_person($search, $per) { global $famarray; // if trying to access a restriced person if (!$per->isExportable()) { return; } $config = Config::getInstance(); //get surename right for gedcom NAME field //if there is just one name filled in name and surname $surname = ""; if ($per->name->link != "") { $surname = $per->name->link; } $surname .= $per->name->surname; if ($per->name->suffix != "") { $surname .= $per->name->suffix; } if ($per->name->forenames != "") { $ged_name = $per->name->forenames . " /" . $surname . "/"; } else { $ged_name = $surname; } //If this person was previously imported from a gedcom file then use that id $id = $per->person_id; $gdao = getGedcomDAO(); $gedids = $gdao->getReferences($id); if (count($gedids) === 1) { $id = $gedids[0]["gedrefid"]; } output_ged(0, "@", $id, "@ INDI"); output_ged(1, "NAME ", $ged_name); output_ged(2, "GIVN ", $per->name->forenames); if ($per->name->link != "") { output_ged(2, "SPFX ", $per->name->link); } output_ged(2, "SURN ", $surname); if ($per->name->title != "") { output_ged(2, "NPFX ", $per->name->title); } if ($per->name->suffix != "") { output_ged(2, "NSFX ", $per->name->suffix); } if ($per->name->knownas != "") { output_ged(2, "NICK ", $per->name->knownas); } output_ged(1, "SEX ", $per->gender); $edao = getEventDAO(); $e = new Event(); $e->person->person_id = $per->person_id; $edao->getEvents($e, Q_BD, true); $sdao = getSourceDAO(); $classes = array("1 BIRT", "1 BAPM", "1 DEAT", "1 BURI"); foreach ($e->results as $e) { if ($e->hasData()) { echo $classes[$e->type] . "\n"; $events[$e->type] = $e; # $sdao->getEventSources($e); echo DateUtil::full_ged_date1($e); if ($e->location->place != "") { output_ged(2, "PLAC ", $e->location->place); } if ($e->type == DEATH_EVENT && $per->death_reason != "") { output_ged(2, "CAUS ", $per->death_reason); } if ($e->notes != "") { echo "2 NOTE\n"; output_ged(3, "CONT ", $e->notes); if (isset($e->source) && $e->source != "") { output_ged(2, "SOUR ", $e->source->title); } else { output_ged(3, "SOUR ", "phpmyfamily"); } } } } if ($per->mother->person_id != "00000" and $per->father->person_id != "00000") { $famc = $per->father->person_id . $per->mother->person_id; output_ged(1, "FAMC @", $famc . "@"); if (!array_key_exists($famc, $famarray)) { $famarray[$famc] = array(); } $famarray[$famc][] = $per; } if ($per->narrative != "") { //Textfield could have Returns, separate them in gedcom CONT lines $narrative = preg_replace("/\n/", "\n2 CONT ", $per->narrative); output_ged(1, "NOTE ", $narrative); } $exploded = explode(" ", $per->updated); $updated = DateUtil::ged_date($exploded[0]); echo "1 CHAN\n"; output_ged(2, "DATE ", $updated); //find photos $eid = -1; $sid = -1; $images = new Image(); $images->person = $per; $idao = getImageDAO(); $idao->getImages($images); for ($current = 0; $current < $images->numResults; $current++) { $img = $images->results[$current]; output_ged(1, "OBJE @img", $img->image_id, "@"); output_ged(2, "FILE ", $config->absurl . $img->getImageFile()); output_ged(2, "FORM ", "jpg"); output_ged(2, "TITL ", $img->title); } $trans = new Transcript(); $trans->person = $per; $tdao = getTranscriptDAO(); $tdao->getTranscripts($trans); for ($i = 0; $i < $trans->numResults; $i++) { $doc = $trans->results[$i]; output_ged(1, "SOUR @doc", $doc->transcript_id, "@"); //TITL not allowed here output_ged(2, "TEXT ", $doc->description); //FILE not allowed here } echo "1 SUBM @phpmyfamily@\n"; }
function showEventEditCols($event, $type = 0, $prefix = '', $class = 'tbl_even') { global $strDateFmt; ?> <td class="<?php echo $class; ?> "> <input type="hidden" name="<?php echo $prefix; ?> event_id" value="<?php echo $event->event_id; ?> " /> <input type="hidden" name="<?php echo $prefix; ?> person_id" value="<?php echo $event->person->person_id; ?> " /> <?php if ($type != CENSUS_EVENT) { dateModifierSelect($prefix . 'd1type', $event->date1_modifier); echo "</td><td class=\"" . $class . "\">"; $bDate = '0000-00-00'; if (isset($event->date1)) { $bDate = $event->date1; } ?> <input type="text" name="<?php echo $prefix; ?> date1" value="<?php echo $bDate; ?> " size="30" /><br/> <?php echo $strDateFmt; ?> </td> <td class="<?php echo $class; ?> "> <?php } //!= census event ?> <?php selectPlace($prefix, $event->location); ?> </td> <td class="<?php echo $class; ?> "><?php $dao = getSourceDAO(); $dao->getEventSources($event); $sp = "a"; if ($event->numResults > 0) { foreach ($event->results as $source) { selectSource($sp . "_" . $prefix, $source, $event); $sp++; } } //Always add a blank one $source = new Source(); selectSource($sp . "_" . $prefix, $source, $event); ?> </td> <td class="<?php echo $class; ?> "><input type="text" name="<?php echo $prefix; ?> notes" value="<?php echo $event->notes; ?> " size="30" /></td> <?php }
function get_edit_form($per) { global $strEvent, $strSubmit, $strReset, $strDate, $strPlace, $strSource, $strReference, $strNotes, $strDateFmt; $config = Config::getInstance(); $prefix = ''; if ($config->dojo) { ?> <script type="text/javascript"> dojo.addOnLoad(function() { var widget = dijit.byId('notes'); widget.name = '<?php echo $prefix; ?> notes'; dojo.connect(widget, 'onChange', function(){ widget.endEditing(); var desc = widget.getValue(); var stext = dojo.byId('<?php echo $prefix; ?> notes'); stext.value = desc; }); }); </script><?php } $event = $per->events[0]; ?> <form method="post" action="passthru.php?area=event&func=edit"> <input type="hidden" name="<?php echo $prefix; ?> event_id" value="<?php echo $event->event_id; ?> " /> <input type="hidden" name="<?php echo $prefix; ?> person" value="<?php echo $per->person_id; ?> " /> <input type="hidden" name="<?php echo $prefix; ?> etype" value="<?php if ($event->type < 0) { echo OTHER_EVENT; } else { echo $event->type; } ?> " /> <table> <tr><td colspan="2"> <table> <tr><td class="tbl_even"></td><td class="tbl_even"> <?php echo $strEvent[$event->type]; ?> </td><td class="tbl_even"><input type="text" name="<?php echo $prefix; ?> descrip" value="<?php echo $event->descrip; ?> " size="45" maxlength="45"/></td></tr> <tr><td class="tbl_odd"><?php echo $strDate; ?> </td><td style="white-space:nowrap;" class="tbl_odd"> <?php dateModifierSelect($prefix . 'd1type', $event->date1_modifier); $bDate = '0000-00-00'; if (isset($event->date1)) { $bDate = $event->date1; } ?> </td><td class="tbl_odd"> <input type="text" name="<?php echo $prefix; ?> date1" value="<?php echo $bDate; ?> " size="10" /><br/> <?php echo $strDateFmt; ?> </td> <tr><td class="tbl_even"><?php echo $strPlace; ?> </td><td colspan="2"><?php selectPlace($prefix, $event->location); ?> </td></tr> <tr><td class="tbl_even"><?php echo $strSource; ?> </td><td colspan="2"><?php $dao = getSourceDAO(); $dao->getEventSources($event); $sp = "a"; if ($event->numResults > 0) { foreach ($event->results as $source) { selectSource($sp . "_" . $prefix, $source); $sp++; echo "<br/>"; } } $source = new Source(); selectSource($sp . "_" . $prefix, $source, $event); ?> </td></tr> <tr><td class="tbl_even"><?php echo $strNotes; ?> </td><td class="tbl_even" colspan="2"><?php if ($config->dojo) { ?> <input type="hidden" name="<?php echo $prefix; ?> notes" id="<?php echo $prefix; ?> notes"/> <div id="notes" dojoType="dijit.Editor" minHeight="5em" plugins="['undo', 'redo', 'cut', 'copy', 'paste', '|', 'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', '|', 'removeFormat', 'indent', 'outdent', 'justifyCenter', 'justifyFull', 'justifyLeft', 'justifyRight', 'delete', 'insertOrderedList', 'insertUnorderedList', 'createLink', 'foreColor','hiliteColor']"> <?php echo $event->notes; ?> </div> <?php } else { ?> <textarea name="<?php echo $prefix; ?> notes" id="<?php echo $prefix; ?> notes" rows="10" cols="80"><?php echo $event->notes; ?> </textarea> <?php } ?> </td> </tr> <tr> <table><tr> <?php showAttendeeHeaderFields(MARRIAGE_EVENT); echo "</tr>"; if (count($event->attendees) == 0) { $event->attendees = array(); } $event->attendees[] = new Attendee(); $bDate = '0000-00-00'; if (isset($e->date1)) { $bDate = $e->date1; } $prefix = 'a'; foreach ($event->attendees as $a) { $show = false; if (isset($a->person->person_id) && $a->person->isEditable()) { echo "<tr><td>" . $a->person->getDisplayName() . " " . $a->person->getDates() . "</td>"; $show = true; } if (!isset($a->person->person_id)) { echo "<tr><td>"; selectPeople($prefix . "person_id", 0, "A", 0, 0, $bDate); echo "</td>"; $show = true; } if ($show) { showAttendeeEditCols($a, MARRIAGE_EVENT, $prefix); $prefix++; } echo "</tr>"; } ?> </tr> </table> </td> </tr> <tr> <td class="tbl_even" colspan="2"><input type="submit" name="Submit1" value="<?php echo $strSubmit; ?> " /> <input type="RESET" name="Reset1" value="<?php echo $strReset; ?> " /></td> </tr> </table> </form> <?php $ret = ""; echo get_image_create_string($per, $event->event_id); echo "<br/>"; show_gallery($per, $dest = "people", $event->event_id); }