function generateConfirm($edit) { $dataInvalid = $this->isDataInvalid($edit); if ($this->formbuilder) { $this->formbuilder->bulk_set_answers($_POST[$this->event->formkey()]); $dataInvalid .= $this->formbuilder->answers_invalid(); } if ($dataInvalid) { error_exit($dataInvalid . '<br>Please use your back button to return to the form, fix these errors, and try again.'); } $output = para('Please confirm that this data is correct and click the submit button to proceed to the payment information page.'); $output .= form_hidden('edit[step]', 'submit'); $fields = array('Registration Status' => 'payment', 'Notes' => 'notes'); $rows = array(); foreach ($fields as $display => $column) { array_push($rows, array($display, form_hidden("edit[{$column}]", $edit[$column]) . check_form($edit[$column]))); } $output .= form_group('Registration details', "<div class='pairtable'>" . table(null, $rows) . '</div>'); if ($this->formbuilder) { $form = $this->formbuilder->render_viewable(); $form .= $this->formbuilder->render_hidden(); $output .= form_group('Registration answers', $form); } $output .= para(form_submit('submit')); return form($output); }
function pop_child($child, $parent, $coparent = 0) { global $_Child, $_Source, $_with, $_toolhelp_has_descendants; $name = get_name($child); $sentence = bold($_Child . ':') . conc(linked_name($child)); if ($coparent) { // illegitimate child, print coparent $sentence .= conc($_with) . conc(linked_name($coparent)); } if (has_descendants($child)) { $sentence .= conc(span_type('+', "alert", sprintf($_toolhelp_has_descendants, $child))); } $sentence = para($sentence, "name"); /* // This section has become obsolete with the addition of inline source // citations in print_bd() above. Left here because you may prefer to // document parent/child relations rather than BD events of spouses and // children, or maybe both. // print relation source(s) $handle = pg_query(" SELECT source_text FROM relation_notes WHERE note_id = ( SELECT relation_id FROM relations WHERE child_fk = $child AND parent_fk = $parent ) "); while ($row = pg_fetch_assoc($handle)) { $sentence .= para(paren($_Source . ':' . conc(ltrim($row['source_text']))), "childsource"); } */ echo $sentence; print_bd($child, 1); print_marriage($child); print_bd($child, 3); pg_query("DELETE FROM tmp_children WHERE child = {$child}"); }
function process() { $this->title = 'Settings'; $op = $_POST['op']; switch ($op) { case 'save': foreach ($_POST['edit'] as $name => $value) { variable_set($name, $value); } $output = para('Settings saved'); $output .= $this->get_settings_form('Settings saved'); return $output; default: $output = para('Make your changes below'); $output .= $this->get_settings_form(); return $output; } }
function interim_game_result($edit, $opponent) { $win = variable_get('default_winning_score', 6); $lose = variable_get('default_losing_score', 0); $output = para("For the game of " . $this->game->sprintf('short') . " you have entered:"); $rows = array(); switch ($edit['defaulted']) { case 'us': $rows[] = array($this->team->name, "{$lose} (defaulted)"); $rows[] = array($opponent->name, $win); break; case 'them': $rows[] = array($this->team->name, $win); $rows[] = array($opponent->name, "{$lose} (defaulted)"); break; default: $rows[] = array($this->team->name, $edit['score_for']); $rows[] = array($opponent->name, $edit['score_against']); break; } $output .= '<div class="pairtable">' . table(null, $rows) . "</div>"; // now, check if the opponent has an entry $opponent_entry = $this->game->get_score_entry($opponent->team_id); if ($opponent_entry) { if (!$this->game->score_entries_agree($edit, (array) $opponent_entry)) { $output .= para("<b>Note:</b> this score does NOT agree with the one provided by your opponent, so coordinator approval will be required if you submit it"); } } if ($edit['defaulted'] == 'them' || $edit['score_for'] > $edit['score_against']) { $what = 'win for your team'; } else { if ($edit['defaulted'] == 'us' || $edit['score_for'] < $edit['score_against']) { $what = 'loss for your team'; } else { $what = 'tie game'; } } $output .= para("If confirmed, this would be recorded as a <b>{$what}</b>."); if ($edit['field_report']) { $output .= para("You have also submitted the following field report:<blockquote>" . $edit['field_report'] . "</blockquote>"); } return $output; }
function generateStatusPage() { global $dbh; // make sure the teams are loaded $this->league->load_teams(); list($order, $season, $round) = $this->league->calculate_standings(array('round' => $this->league->current_round)); $fields = array(); $sth = Field::query(array('_order' => 'f.code')); while ($field = $sth->fetchObject('Field')) { $fields[$field->code] = $field->region; } $output = para("This is a general field scheduling balance report for the league. The first number in each cell is the number of games that team has played at a given site. The second number, in brackets, is the team's average ranking for that site. Zero represents an unranked field."); $num_teams = sizeof($order); $header[] = array('data' => "Rating", 'rowspan' => 2); $header[] = array('data' => "Team", 'rowspan' => 2); // now gather all possible fields this league can use $sth = $dbh->prepare('SELECT DISTINCT IF(f.parent_fid, pf.code, f.code) AS field_code, TIME_FORMAT(g.game_start, "%H:%i") as game_start, IF(f.parent_fid, pf.region, f.region) AS field_region, IF(f.parent_fid, pf.fid, f.fid) AS fid, IF(f.parent_fid, pf.name, f.name) AS name FROM league_gameslot_availability a INNER JOIN gameslot g ON (g.slot_id = a.slot_id) LEFT JOIN field f ON (f.fid = g.fid) LEFT JOIN field pf ON (pf.fid = f.parent_fid) WHERE a.league_id = ? ORDER BY field_region DESC, field_code, game_start'); $sth->execute(array($this->league->league_id)); $last_region = ""; $field_region_count = 0; while ($row = $sth->fetch(PDO::FETCH_OBJ)) { $field_list[] = "{$row->field_code} {$row->game_start}"; $subheader[] = array('data' => l($row->field_code, "field/view/{$row->fid}", array('title' => $row->name)) . " {$row->game_start}", 'class' => "subtitle"); if ($last_region == $row->field_region) { $field_region_count++; } else { if ($field_region_count > 0) { $header[] = array('data' => $last_region, 'colspan' => $field_region_count); } $last_region = $row->field_region; $field_region_count = 1; } } // and make the last region header too if ($field_region_count > 0) { $header[] = array('data' => $last_region, 'colspan' => $field_region_count); } $header[] = array('data' => "Games", 'rowspan' => 2); $rows = array(); $rows[] = $subheader; $rowstyle = "standings_light"; // get the schedule $schedule = array(); $sth = Game::query(array('league_id' => $this->league->league_id, '_order' => 'g.game_date, g.game_start, field_code')); while ($g = $sth->fetchObject('Game')) { $schedule[] = $g; } // we'll cache these results, so we can compute avgs and highlight numbers too far from average $cache_rows = array(); $total_at_field = array(); $sum_field_rankings = array(); while (list(, $tid) = each($order)) { if ($rowstyle == "standings_light") { $rowstyle = "standings_dark"; } else { $rowstyle = "standings_light"; } $row = array(array('data' => $season[$tid]->rating, 'class' => "{$rowstyle}")); $row[] = array('data' => l($season[$tid]->name, "team/view/{$tid}"), 'class' => "{$rowstyle}"); // count number of games per field for this team: $numgames = 0; $count = array(); $site_ranks = array(); // parse the schedule reset($schedule); while (list(, $game) = each($schedule)) { if ($game->home_team == $tid || $game->away_team == $tid) { $numgames++; list($code, $num) = explode(' ', $game->field_code); $count["{$code} {$game->game_start}"]++; $rank = $game->get_site_ranking($tid); if ($rank != 'unranked') { $site_ranks["{$code} {$game->game_start}"] += $rank; } } } foreach ($field_list as $f) { $thisrow = array('data' => "0", 'class' => "{$rowstyle}", 'align' => 'center'); if ($count[$f]) { $thisrow['data'] = $count[$f] . sprintf(' (%.3f)', $site_ranks[$f] / $count[$f]); $total_at_field[$f] += $count[$f]; $sum_field_ranks[$f] += $site_ranks[$f]; } $row[] = $thisrow; } $row[] = array('data' => $numgames, 'class' => "{$rowstyle}", 'align' => "center"); $cache_rows[] = $row; } // pass through cached rows and highlight entries far from avg foreach ($cache_rows as $row) { $i = 3; // first data column foreach ($field_list as $f) { $avg = $total_at_field[$f] / $num_teams; // we'll consider more than 1.5 game from avg too much if ($avg - 1.5 > $row[$i]['data'] || $row[$i]['data'] > $avg + 1.5) { $row[$i]['data'] = "<b><font color='red'>" . $row[$i]['data'] . "</font></b>"; } $i++; // move to next column in cached row } $rows[] = $row; } // output totals lines $total_row = array(array('data' => "Total games:", 'colspan' => 2, 'align' => 'right')); $avg_row = array(array('data' => "Avg num at site:", 'colspan' => 2, 'align' => 'right')); $rank_row = array(array('data' => "Average Rank:", 'colspan' => 2, 'align' => 'right')); $column_idx = 1; foreach ($field_list as $f) { $total_row[$column_idx] = array('data' => "0", 'align' => 'center'); $avg_row[$column_idx] = array('data' => "0", 'align' => 'center'); $rank_row[$column_idx] = array('data' => "0", 'align' => 'center'); if ($total_at_field[$f]) { $total_row[$column_idx]['data'] = $total_at_field[$f]; $avg_row[$column_idx]['data'] = sprintf('%.1f', $total_at_field[$f] / $num_teams); $rank_row[$column_idx]['data'] = sprintf("%.3f", $sum_field_ranks[$f] / $total_at_field[$f]); } $column_idx++; } $rows[] = $total_row; $rows[] = $avg_row; $rows[] = $rank_row; $rows[] = array_merge(array(array('colspan' => 2, 'data' => '')), $subheader); //$output .= table($header, $rows); $output .= "<div class='listtable'>" . table($header, $rows) . "</div>"; return form($output); }
function perform($edit = array()) { global $lr_session; $person = $this->person; if ($edit['username'] && $lr_session->has_permission('person', 'edit', $this->person->user_id, 'username')) { $person->set('username', $edit['username']); } /* EVIL HACK * If this person is currently a 'visitor', it does not have a * member number, so if we move it to another class, it needs * to be given one. We do this by forcing its status to 'new' and * requiring it be reapproved. Ugly hack, but since * we're likely to scrutinize non-player accounts less than player * accounts, it's necessary. */ if ($person->class == 'visitor' && $edit['class'] == 'player') { $person->set('status', 'new'); $person->set('class', 'player'); $status_changed = true; } if ($edit['class'] && $lr_session->has_permission('person', 'edit', $this->person->user_id, 'class')) { $person->set('class', $edit['class']); } if ($edit['status'] && $lr_session->has_permission('person', 'edit', $this->person->user_id, 'status')) { $person->set('status', $edit['status']); } $person->set('email', $edit['email']); $person->set('allow_publish_email', $edit['allow_publish_email']); foreach (array('home_phone', 'work_phone', 'mobile_phone') as $type) { $num = $edit[$type]; if (strlen($num)) { $person->set($type, clean_telephone_number($num)); } else { $person->set($type, null); } $person->set('publish_' . $type, $edit['publish_' . $type] ? 'Y' : 'N'); } if ($lr_session->has_permission('person', 'edit', $this->person->user_id, 'name')) { $person->set('firstname', $edit['firstname']); $person->set('lastname', $edit['lastname']); } $person->set('addr_street', $edit['addr_street']); $person->set('addr_city', $edit['addr_city']); $person->set('addr_prov', $edit['addr_prov']); $person->set('addr_country', $edit['addr_country']); $postcode = $edit['addr_postalcode']; if (strlen($postcode) == 6) { $foo = substr($postcode, 0, 3) . " " . substr($postcode, 3); $postcode = $foo; } $person->set('addr_postalcode', $edit['addr_postalcode']); $person->set('birthdate', $edit['birthdate']); if ($edit['height']) { $person->set('height', $edit['height']); } $person->set('shirtsize', $edit['shirtsize']); $person->set('gender', $edit['gender']); $person->set('skill_level', $edit['skill_level']); $person->set('year_started', $edit['year_started']); if (variable_get('dog_questions', 1)) { $person->set('has_dog', $edit['has_dog']); } $person->set('willing_to_volunteer', $edit['willing_to_volunteer']); $person->set('contact_for_feedback', $edit['contact_for_feedback']); $person->set('show_gravatar', $edit['show_gravatar']); if (!$person->save()) { error_exit("Internal error: couldn't save changes"); } else { /* EVIL HACK * If a user changes their own status from visitor to player, they * will get logged out, so we need to warn them of this fact. */ if ($status_changed) { $result = para("You have requested to change your account status to 'Player'. As such, your account is now being held for one of the administrators to approve. " . 'Once your account is approved, you will receive an email informing you of your new ' . variable_get('app_org_short_name', 'League') . ' member number. ' . 'You will then be able to log in once again with your username and password.'); $this->smarty->assign('title', $this->title); $this->smarty->assign('menu', menu_render('_root')); $this->smarty->assign('content', $result); $this->smarty->display('backwards_compatible.tpl'); exit; } } return true; }
function ilia_debug_builds_unsupported() { return para("IMPORTANT NOTE: Your PHP installation may be incorrect\n" . "------------------------------------------------------\n" . "\n" . "Your PHP installation appears to be built with debugging\n" . "support enabled, and extensions cannot be installed in this case.") . para("Debugging support in PHP produces slower execution, is not recommended for\n" . "production builds, and was probably a mistake.") . para("Debugging support may sometimes be incorrectly detected, and so please\n" . "continue to follow the installation instructions and try the Loader.\n" . "However do contact the ionCube helpdesk if the Loader fails to\n" . "install, and include a web link to either this script or a page that\n" . "calls phpinfo() so that we can help."); }
pg_query("\n DELETE FROM relations\n WHERE relation_id = {$relid_s}\n "); } // transfer remaining relations pg_query("\n UPDATE relations\n SET child_fk = {$target}\n WHERE child_fk = {$source}\n "); pg_query("\n UPDATE relations\n SET parent_fk = {$target}\n WHERE parent_fk = {$source}\n "); // update source_linkage pg_query("\n UPDATE source_linkage\n SET person_fk = {$target}\n WHERE person_fk = {$source}\n "); // insert "event" for source person with a link to target person $event_note = " [p={$target}|ID #{$target}]"; $event = fetch_val("\n INSERT INTO events (\n tag_fk,\n place_fk,\n event_date,\n sort_date,\n event_note\n )\n VALUES (\n 1040,\n 1,\n '000000003000000001',\n '00010101',\n '{$event_note}'\n )\n RETURNING event_id\n "); add_participant($source, $event); pg_query("\n INSERT INTO merged (old_person_fk,new_person_fk)\n VALUES ({$source}, {$target})\n "); set_last_edit($source); set_last_edit($target); pg_query("\n COMMIT\n "); // return to main view of "stripped" person. header("Location: {$app_root}/family.php?person={$source}"); } else { // explain why the merge failed $title = "{$_App_name}: {$_Merge_persons_failed}"; require "./form_header.php"; echo "<h2>{$title}!</h2>\n"; $name_1 = get_name($person_1); $name_2 = get_name($person_2); echo "<p>{$_Cannot_merge} {$name_1} ({$_born} {$bdate_1}), {$_with} {$name_2} ({$_born} {$bdate_2}).<br />\n"; echo "{$_Reason}: {$reason}</p>\n"; echo para(to_url('../family.php', array(person => $person_1), "{$_Return_to} {$person_1} {$name_1}")); echo para(to_url('../family.php', array(person => $person_2), "{$_Return_to} {$person_2} {$name_2}")); echo "</body>\n</html>\n"; } }
function choose_league() { global $lr_session, $dbh; $leagues = array(); $leagues[0] = '-- select from list --'; if ($lr_session->is_admin()) { # TODO: League::load? $sth = $dbh->prepare("\n\t\t\t\tSELECT\n\t\t\t\t\tleague_id as theKey,\n\t\t\t\t\tIF(tier,CONCAT(name,' Tier ',IF(tier>9,tier,CONCAT('0',tier))), name) as theValue\n\t\t\t\tFROM league\n\t\t\t\tWHERE league.status = 'open'\n\t\t\t\tORDER BY season,TheValue,tier"); $sth->execute(); while ($row = $sth->fetch()) { $leagues[$row['theKey']] = $row['theValue']; } } else { $leagues[1] = 'Inactive Teams'; foreach ($lr_session->user->leagues as $league) { $leagues[$league->league_id] = $league->fullname; } } $output = form_hidden('edit[step]', 'swaptarget'); $output .= para("You are attempting to move the team <b>" . $this->team->name . "</b>. Select the league you wish to move it to"); $output .= form_select('', 'edit[target]', '', $leagues); $output .= form_submit("Submit"); $output .= form_reset("Reset"); return form($output); }
function generateConfirm($edit) { global $dbh; $dataInvalid = $this->isDataInvalid($edit['games']); if ($dataInvalid) { error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again"); } $gameslots = $this->league->get_gameslots($this->day_id); if (count($gameslots) <= 1) { error_exit("There are no fields assigned to this league!"); } $output = para("Confirm that the changes below are correct, and click 'Submit' to proceed."); if ($edit['published'] == 'yes') { $output .= para("Games will be made available for player viewing.") . form_hidden('edit[published]', 'yes'); } else { $output .= para("Games will be hidden from player view until you choose to publish them.") . form_hidden('edit[published]', 'no'); } $output .= form_hidden('edit[step]', 'perform'); $header = array("Game ID", "Round", "Game Slot", "Home", "Away"); $rows = array(); while (list($game_id, $game_info) = each($edit['games'])) { reset($game_info); $slot = GameSlot::load(array('slot_id' => $game_info['slot_id'])); $team_sth = $dbh->prepare('SELECT name FROM team WHERE team_id = ?'); $team_sth->execute(array($game_info['home_id'])); $home_name = $team_sth->fetchColumn(); $team_sth->execute(array($game_info['away_id'])); $away_name = $team_sth->fetchColumn(); $rows[] = array(form_hidden("edit[games][{$game_id}][game_id]", $game_id) . $game_id, form_hidden("edit[games][{$game_id}][round]", $game_info['round']) . $game_info['round'], form_hidden("edit[games][{$game_id}][slot_id]", $game_info['slot_id']) . $gameslots[$game_info['slot_id']], form_hidden("edit[games][{$game_id}][home_id]", $game_info['home_id']) . $home_name, form_hidden("edit[games][{$game_id}][away_id]", $game_info['away_id']) . $away_name); } $output .= "<div class='listtable'>" . table($header, $rows) . "</div>"; $output .= para(form_submit('submit')); return form($output); }
function generateConfirm($game, $edit) { if (!$this->can_edit) { error_exit("You do not have permission to edit this game"); } $dataInvalid = $this->isDataInvalid($edit); $s = new Spirit(); $home_spirit = $s->as_formbuilder(); $away_spirit = $s->as_formbuilder(); $win = variable_get('default_winning_score', 6); $lose = variable_get('default_losing_score', 0); switch ($edit['status']) { case 'home_default': $edit['home_score'] = "{$lose} (defaulted)"; $edit['away_score'] = $win; break; case 'away_default': $edit['home_score'] = $win; $edit['away_score'] = "{$lose} (defaulted)"; break; case 'forfeit': $edit['home_score'] = '0 (forfeit)'; $edit['away_score'] = '0 (forfeit)'; break; case 'normal': default: $home_spirit->bulk_set_answers($_POST['spirit_home']); $away_spirit->bulk_set_answers($_POST['spirit_away']); $dataInvalid .= $home_spirit->answers_invalid(); $dataInvalid .= $away_spirit->answers_invalid(); break; } if ($dataInvalid) { error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again"); } $output = para("You have made the changes below for the {$game->game_date} {$game->game_start} game between {$game->home_name} and {$game->away_name}. "); $output .= para("If this is correct, please click 'Submit' to continue. If not, use your back button to return to the previous page and correct the score."); $output .= form_hidden('edit[step]', 'perform'); $output .= form_hidden('edit[status]', $edit['status']); $output .= form_hidden('edit[home_score]', $edit['home_score']); $output .= form_hidden('edit[away_score]', $edit['away_score']); $score_group .= form_item("Home ({$game->home_name} [rated: {$game->rating_home}]) Score", $edit['home_score']); $score_group .= form_item("Away ({$game->away_name} [rated: {$game->rating_away}]) Score", $edit['away_score']); $output .= form_group("Scoring", $score_group); if ($edit['status'] == 'normal') { $output .= form_group("Spirit assigned to home ({$game->home_name})", $home_spirit->render_viewable()); $output .= $home_spirit->render_hidden('home'); $output .= form_group("Spirit assigned to away ({$game->away_name})", $away_spirit->render_viewable()); $output .= $away_spirit->render_hidden('away'); } $output .= para(form_submit('submit')); return form($output); }
} // by default, we will display the 50 most recently edited persons. if (!isset($given) && !isset($surname)) { $headline = "{$_The_last_50_edited}"; // This query is sluggish without the following db modification: // create index last_edited_persons_key on persons(last_edit,person_id); $query = "select person_id, last_edit from persons\n where is_merged(person_id) is false\n order by last_edit desc, person_id desc limit 50"; } else { if (substr($surname, 0, 1) == '!') { $literal = ltrim($surname, '!'); } else { $literal = "%{$surname}%"; } $headline = "{$_Search_result}"; $query = "SELECT\n person_id,\n get_pbdate(person_id) as pbd\n FROM\n persons\n WHERE\n given LIKE '%{$given}%'\n AND (\n patronym LIKE '%{$surname}%'\n OR toponym LIKE '{$literal}'\n OR surname LIKE '%{$surname}%'\n OR occupation LIKE '%{$surname}%'\n )\n AND is_merged(person_id) IS FALSE\n "; if ($bdate) { $query .= "\n AND f_year(get_pbdate(person_id))\n BETWEEN (({$bdate})::INTEGER - {$diff})\n AND (({$bdate})::INTEGER + {$diff})\n "; } $query .= "\n ORDER BY pbd"; } echo "<h3>{$headline}:</h3>\n"; $handle = pg_query($query); echo "<p>"; while ($row = pg_fetch_row($handle)) { $p = $row[0]; echo get_name_and_dates("./family.php", $p) . conc(child_of($p)) . "<br />\n"; } echo "</p>\n"; echo para(paren(fetch_num_rows($query) . conc($_persons))); echo "</div>\n"; include "./footer.php";
</tr> <tr> <td> <?php para("Survey Interviewer"); ?> <h4>Vision Research</h4> </td> <td> July 2006 - Aug 2006 </td> </tr> <tr> <td> <?php para("Tube Fab Inc"); ?> <h4></h4> </td> <td> May 2006 - June 2006 </td> </tr> </table> <!-- WORK EXPERENCE SECTION END --> <!-- REFERENCES SECTION START --> <?php createHTML("h2", $sub_heading6); ?> <table class="references">
$id = $row['source_id']; echo '<tr>'; if ($friendly) { echo td(paren(to_url($_SERVER['PHP_SELF'], array('node' => $id), $_Select) . ' / ' . to_url('./forms/source_edit.php', array('person' => 0, 'source' => $id), $_Edit))); echo td_numeric(square_brace($row['sort_order'])); echo td(paren($row[$label])); } else { echo td_numeric(square_brace(to_url($_SERVER['PHP_SELF'], array('node' => $id), $id, $_goto))); echo td_numeric(square_brace($row['sort_order'])); echo td(paren(to_url('./forms/source_edit.php', array('person' => 0, 'source' => $id), $row[$label], $_edit))); } if ($row['e'] || $row['r'] || $row['s']) { echo td(square_brace(italic($row['source_date'])) . ' ' . $row['txt'] . node_details($row['e'], $row['r'], $row['s'], $row['u'])); } else { // source is unused, print with gray text if ($show_delete) { // show link for source deletion echo td(span_type(square_brace(italic($row['source_date'])) . conc($row['txt']), "faded") . conc(paren(to_url('./forms/source_delete.php', array('node' => $self, 'id' => $id), bold($_delete))))); } else { echo td(span_type(square_brace(italic($row['source_date'])) . conc($row['txt']), "faded")); } } echo "</tr>\n"; } echo "</table>\n"; } if ($props['is_leaf'] == "f") { echo para(to_url('./forms/source_add.php', array('node' => $self), $_Add_source)); } echo "</div>\n"; include "./footer.php";
hidden_input('qtype', $qtype); if ($qtype == 'update') { hidden_input('relation', $relation); hidden_input('oldparent', $parent); } person_id_input($parent, 'parent', $pprompt); checkbox('bsource', $_Use_source_for_birth_event); select_surety($surety); source_input(); form_submit(); form_end(); if ($qtype == 'update') { echo "<h3>{$_References}</h3>\n"; $handle = pg_query("\n SELECT\n source_fk,\n get_source_text(source_fk) AS source_text\n FROM\n relation_citations\n WHERE\n relation_fk = {$relation}\n "); while ($row = pg_fetch_assoc($handle)) { echo para($row['source_fk'] . ' ' . $row['source_text']); } } echo "</body>\n</html>\n"; } else { // do action $person = $_POST['person']; $surety = $_POST['surety']; $_POST['parent'] ? $parent = $_POST['parent'] : ($parent = 0); pg_query("BEGIN"); if ($_POST['qtype'] == 'update') { // update existing relation $relation = $_POST['relation']; $oldparent = $_POST['oldparent']; $oldsurety = fetch_val("\n SELECT surety_fk\n FROM relations\n WHERE relation_id = {$relation}\n "); // change parent or surety