2 $monLibrary= dirname(__FILE__) .
"/../library";
3 $monIncludes= dirname(__FILE__) .
"/../includes";
4 require_once(
"$monLibrary/cu_top.i");
5 require_once(
"$monLibrary/ck_hticket.i");
6 require_once(
"$monIncludes/cu_remote_top.prg");
8 if (!CheckPerm($link, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
11 header(
"Location: /hcuadm/hcu_noperm.prg");
15 $dms_ok=array(
'act'=>
'digits',
'qid'=>
'string',
'qlang'=>
'string',
16 'form_qid'=>
'digits',
'form_lang'=>
'array',
'form_txt_'=>
'prefix_s',
17 'form_ex_txt_'=>
'prefix_s',
'btnSave'=>
'string',
'form_type_'=>
'prefix_s',
'Remote_Update'=>
'array');
21 $HCU_Lang_Codes = array(
"en_US"=>
"American English",
"es_US"=>
"American Spanish",
"pl_US"=>
"Polish");
23 $self = $_SERVER[
'PHP_SELF'];
25 $act = (isset($act) && intval($act) > 0 ? intval($act) : 2);
34 if ($act == 1 && isset($btnSave)) {
54 $save_lang = $form_lang;
56 if (isset($form_qid) && intval($form_qid) > 0) {
57 $save_qid = intval($form_qid);
59 $sql =
"SELECT nextval('cuquestmaster_quest_id_seq');";
60 $qid_rs = db_query($sql, $link);
61 list($save_qid) = db_fetch_array($qid_rs);
62 db_free_result($qid_rs);
66 foreach ($form_lang as $lang_key => $lang_value) {
67 $save_text = prep_save(trim(${
"form_txt_" . $lang_value}));
68 $save_ex_text = prep_save(trim(${
"form_ex_txt_" . $lang_value}));
69 $save_type = prep_save(trim(${
"form_type_" . $lang_value}));
73 $lkup_sql =
"SELECT count(quest_id) 75 WHERE quest_id = '$save_qid' 76 AND quest_lang = '$lang_value'; ";
77 $lookup_rs = db_query($lkup_sql, $link);
78 list($qid_count) = db_fetch_array($lookup_rs);
79 db_free_result($lookup_rs);
84 $sql .=
"UPDATE cuquestmaster SET 85 quest_text = '$save_text', 86 example_text = '$save_ex_text', 87 quest_type = '$save_type' 88 WHERE quest_id = '$save_qid' 89 AND quest_lang = '$lang_value'; ";
93 $sql .=
"INSERT INTO cuquestmaster 94 (quest_id, quest_lang, quest_text, example_text, quest_type) 105 if (Remote_Update_Selected()) {
109 Remote_Field_Add(
"cuquest",
"qst_id", $save_qid);
110 Remote_Field_Add(
"cuquest",
"qst_lang", $lang_value);
111 Remote_Field_Add(
"cuquest",
"qst_txt", trim(${
"form_txt_" . $lang_value}));
112 Remote_Field_Add(
"cuquest",
"qst_etxt", trim(${
"form_ex_txt_" . $lang_value}));
113 Remote_Field_Add(
"cuquest",
"qst_type", $save_type);
116 $Remote_Results .= Remote_Update_Send(
"U",
"cuquest") .
"<br>";
118 $Remote_Fields = array();
126 if (!$save_rs = db_query($sql, $link)) {
128 $form_err =
"Unable to Save Challenge Question!";
132 if ($save_qid == 0) {
135 $psql_lastoid = pg_last_oid($save_rs);
136 $sql =
"SELECT quest_id 138 WHERE oid = '" . intval($psql_lastoid) .
"'; ";
139 $oid_rs = db_query($sql, $link);
140 list($save_qid) = db_fetch_array($oid_rs);
141 db_free_result($oid_rs);
145 header (
"Location: $self?msg=" . urlencode(
"The Challenge Question was saved.<br>") . urlencode($Remote_Results));
162 $qst_ex_txt = array();
168 if (isset($form_qid)) {
172 foreach ($form_lang as $key=>$value) {
173 $qst_txt[$value] = ${
"form_txt_" . $value};
174 $qst_ex_txt[$value] = ${
"form_ex_txt_" . $value};
175 $qst_type[$value] = ${
"form_type_" . $value};
177 $use_form = $form_use;
178 } elseif (isset($qid)) {
185 where quest_id = '" . intval($qid) .
"'";
187 $result = db_query($query, $link);
190 while ($cuquest_row = db_fetch_object($result, $cnt)) {
191 $qst_id = $cuquest_row->quest_id;
192 $qst_txt[$cuquest_row->quest_lang] = trim($cuquest_row->quest_text);
193 $qst_ex_txt[$cuquest_row->quest_lang] = trim($cuquest_row->example_text);
194 $qst_type[$cuquest_row->quest_lang] = $cuquest_row->quest_type;
198 db_free_result($result);
203 foreach($HCU_Lang_Codes as $lang_key=>$lang_value) {
204 $qst_txt[$lang_key] =
"";
205 $qst_type[$lang_key] =
"";
206 $qst_ex_txt[$lang_key] =
"";
210 $use_form = ($use_form ==
"" ?
"Add" : $use_form);
211 cu_header(
"Edit Challenge Questions");
213 <form action=
"<?php echo $self; ?>?act=<?php echo $act; ?>" method=
"post">
216 if (strlen($form_err) > 0)
217 printf(
"\n<font color=\"red\">Errors found before saving the information. Please review errors at bottom of screen.\n<p></font>");
220 <table cellpadding=
"3" cellspacing=
"0" border=
"0" class=
"dmsbg" width=
"500"><tr><td>
221 <table cellpadding=
"2" cellspacing=
"0" border=
"0" bgcolor=white width=
"100%">
223 <td colspan=
"2" class=
"bar" align=
"center">
224 <?php echo strtoupper($use_form); ?> CHALLENGE QUESTION
228 <td nowrap align=
"right" class=
"hdr">
231 <td nowrap
class=
'dtl'>
232 <?php
if ($use_form ==
"Add"): ?>
237 <input type=
"hidden" name=
"form_qid" value=
"<?php echo $qst_id; ?>">
240 <?php
foreach($HCU_Lang_Codes as $lang_key=>$lang_value): ?>
242 <td nowrap align=
"right" class=
"hdr">
243 <input type=
"hidden" name=
"form_lang[]" value=
"<?php echo $lang_key; ?>">
246 <td nowrap align=
"left" class=
"hdr">
247 Question for <?php echo $lang_value; ?>
251 <td nowrap align=
"right" class=
"hdr">
254 <td nowrap
class=
'dtl'>
255 <input type=
"text" name=
"form_txt_<?php echo $lang_key; ?>" size=
"50" maxlength=
"80" value=
"<?php echo $qst_txt[$lang_key]; ?>">
259 <td nowrap align=
"right" class=
"hdr">
260 Question Answer Format:
262 <td nowrap
class=
'dtl'>
263 <select name=
"form_type_<?php echo $lang_key; ?>">
264 <option value=
"T" <?php echo ($qst_type[$lang_key] ==
"T" ?
"SELECTED" :
""); ?>>Text</option>
265 <option value=
"D" <?php echo ($qst_type[$lang_key] ==
"D" ?
"SELECTED" :
""); ?>>Date Format</option>
270 <td nowrap align=
"right" class=
"hdr">
273 <td nowrap
class=
'dtl'>
274 <input type=
"text" name=
"form_ex_txt_<?php echo $lang_key; ?>" size=
"20" maxlength=
"30" value=
"<?php echo $qst_ex_txt[$lang_key]; ?>">
279 <td
class=
'dtl'> </td>
280 <td nowrap
class=
'dtl'>
281 <?php remote_update_list(); ?>
285 <td
class=
'dtl'> </td>
286 <td nowrap
class=
'dtl'>
287 <input type=
"submit" name=
"btnSave" Value=
"Save">
288 <input type=
"button" name=
"Cancel" Value=
"Cancel" onClick=
"document.location='cuquest.prg'">
292 if (isset($form_err)) {
293 echo
"<tr><td colspan=2 class='err'>$form_err</td></tr>";
297 </td></tr></table> ";
300 cu_header(
"CU Challenge Questions");
305 $query =
"SELECT * FROM cuquestmaster ORDER BY quest_id, quest_lang, quest_text ";
306 $qst_result = db_query($query, $link);
310 <!-- Print out the top of the table -->
311 <table border=
"0" cellpadding=
"3" cellspacing=
"0" align=
"center" width=
"500" class=
"dmsbg"><tr><td>
312 <table border=
"0" cellpadding=
"2" cellspacing=
"0" align=
"center" width=
"100%" bgcolor=white>
314 <td colspan=
"4" class=
"bar" align=
"center">
315 CHALLENGE QUESTION LIST
318 <?php
if (isset($msg)): ?>
320 <td colspan=
"4" class=
"msg" align=
"center">
326 <td
class=
"hdr" align=
"center">
329 <td
class=
"hdr" align=
"center">
332 <td
class=
"hdr" align=
"center">
335 <td
class=
"hdr" align=
"center">
343 while ($qst_row = db_fetch_object($qst_result, $row)):
346 <tr
class=
"<?php echo $RGB; ?>">
347 <?php
if ($last_qid != $qst_row->quest_id): ?>
349 <?php echo trim($qst_row->quest_id) ?>
352 <?php echo trim($HCU_Lang_Codes[
"$qst_row->quest_lang"]) ?>
355 <?php echo trim($qst_row->quest_text) ?>
358 <a href=
"<?php echo $self; ?>?act=1&qid=<?php echo trim($qst_row->quest_id) ?>&qlang=<?php echo trim($qst_row->quest_lang); ?>">Edit</a>
364 $last_qid = $qst_row->quest_id;
370 <?php echo trim($HCU_Lang_Codes[
"$qst_row->quest_lang"]) ?>
373 <?php echo trim($qst_row->quest_text) ?>
381 $RGB = ($RGB ==
"odd" ?
"even" :
"odd");
383 db_free_result($qst_row);
388 <a href=
"<?php echo $self; ?>?act=1">Add Challenge Questions</a>
390 <a href=
"<?php echo $infourl ?>/hcuadm/cuilist.prg" target=
"parent">Credit Union List</a>
398 cu_header(
"Error Displaying Form");
400 printError(
"Requested form not found!<br>Cancelling action.");