Odyssey
hcu_custom_mntc.prg
1 <?php
2 /*
3  * This function will allow the maintenance of the cucsmdocs table. It will also let the user create/edit
4  * the skeleton file for the given Custom Content.
5  *
6  * The skeleton files for Custom Content are saved in /home/httpd/hcuadm/skeleton/<language> where
7  * <language> can be en_US, es_US, pl_US, etc. The skeleton files all have the same name (no extension)
8  * but are just in different directories based on the language. Skeleton files reside on the server with Monitor.
9  *
10  * Default document files are skeleton files, but they exist on each server (www3, www5, www6) to aid in performance. A
11  * default file is updated by updating the skeleton and exporting it.
12  *
13  * NOTE: If a non-English skeleton doesn't exist and the English skeleton does, load that the first time
14  * but provide the user with a warning.
15  */
16 
17  $monLibrary = dirname(__FILE__) . "/../library";
18  $monIncludes = dirname(__FILE__) . "/../includes";
19  require_once("$monLibrary/cu_top.i");
20  require_once("$monLibrary/ck_hticket.i");
21  require_once("$monIncludes/cu_remote_top.prg");
22 
23  $numColumns = 15; // For colspans of table row that go across grid
24 
25  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
26  // ** Permissions failed
27  // ** redirect to new page
28  header("Location: /hcuadm/hcu_noperm.prg");
29  exit;
30  }
31 
32  // languages available
33  $availableLanguages = array();
34  $availableLanguages[] = array( "lang" => "en_US", "display" => "English" );
35  $availableLanguages[] = array( "lang" => "es_US", "display" => "Spanish" );
36  $availableLanguages[] = array( "lang" => "pl_US", "display" => "Polish" );
37 
38  $dms_ok = array("act"=>"digits","docsid"=>"string","docsname"=>"string","language"=>"string",
39  "docsdesc"=>"string", "docstitle"=>"string", "docstype"=>"string", "docsdisplaylink"=>"string",
40  "docsdisplaytext"=>"string", "docsdefaultavail"=>"string", "docsresponsetype"=>"string",
41  'docsmaintsection'=>'string', 'docsmaintsort'=>'digits', "docstarget" => "string", "docstargetname" => "string",
42  "Remote_Update"=>"array",'script_doc'=>'string',"skeleton_file"=>"string",
43  "o"=>"digits", "d"=>"digits", 'msg'=>'string');
44  dms_import($dms_ok);
45 
46  $o = isset($o) ? $o : 0;
47  $language = isset($language) ? $language : "";
48  $docsdisplaylink = isset($docsdisplaylink) ? $docsdisplaylink : "";
49  $docsdefaultavail = isset($docsdefaultavail) ? $docsdefaultavail : "";
50 
51  $error_msg = "";
52 
53  // make sure have a language
54  if ( $language == "" ) $language = "en_US";
55 
56 
57  $sectionMaster = Array(
58  'General',
59  'Products',
60  'Promos',
61  'Member Forms',
62  '3rd Party',
63  'Mobile',
64  'Secure Forms',
65  'App'
66  );
67 
68  $self = $_SERVER['SCRIPT_NAME'];
69 
70  if (!isset($act)) $act = "2";
71 
72  if ($act == "3") {
73  // Perform the validate for saving here,
74  // Upon failure send back to the edit page,
75  // upon success go to the save code
76 
77  // make sure the document name is unique
78  $error_msg = "";
79  if (!strlen(trim($docsname))) {
80  $error_msg .= "<li>A document name is needed.<br></li>";
81  }
82 
83  // if a Terms or Disclaimer, needs a docsdisplaytext
84  if ( ( $docsresponsetype == "D" ||
85  $docsresponsetype == "T" ) &&
86  strlen( trim( $docsdisplaytext ) ) == 0 ) {
87  $error_msg .= "<li>Display link text is needed for this Document Response Type (the Allow Display Link is optional).<br></li>";
88  }
89 
90  if ($error_msg == '') {
91  // Everything was validated, we now need to save the information, either insert for new or update for edited.
92 
93  $num_rows = 0;
94  if (isset($docsid)) {
95  $save_sql = "SELECT docsname FROM cucmsdocs WHERE docsid = '$docsid'";
96  // Execute the query and find out how many rows are in the query
97  $db_result = db_query($save_sql, $link);
98  $num_rows = db_num_rows($db_result);
99  }
100 
101  // Setup the expires on date
102  if ($num_rows > 0 ) {
103  // UPDATE the information into the table
104  $qry_stmt = "UPDATE cucmsdocs
105  SET docsname = '" . prep_save($docsname, 50) . "',
106  docsdesc = '" . prep_save($docsdesc, 250) . "',
107  docstitle = '" . prep_save($docstitle, 100) . "',
108  docstype = $docstype,
109  docsdisplaylink = '$docsdisplaylink',
110  docsdisplaytext = '" . prep_save($docsdisplaytext, 100) . "',
111  docsdefaultavail = '$docsdefaultavail',
112  docsresponsetype = '$docsresponsetype',
113  docsmaintsection = '" . prep_save($docsmaintsection, 30) . "',
114  docsmaintsort = '" . intval($docsmaintsort) . "',
115  docstarget = '" . prep_save($docstarget, 20) . "',
116  docstargetname = '" . prep_save($docstargetname, 100) . "'
117  WHERE docsid = '" . intval($docsid) . "' ";
118  } else {
119  // make sure the name is unique
120  $testSql = "SELECT docsid FROM cucmsdocs WHERE docsname = '$docsname'";
121  $testRS = db_query($testSql, $link);
122  list($testId) = db_fetch_array($testRS);
123  db_free_result($testRS);
124  if ( $testId > 0 ) {
125  $error_msg = "Your Custom Content File Name is already used. Please choose a different one.";
126  } else {
127  $idsql = "SELECT nextval('cucmsdocs_docsid_seq');";
128  $idrs = db_query($idsql, $link);
129  list($save_id) = db_fetch_array($idrs);
130  db_free_result($idrs);
131 
132  $qry_stmt = "INSERT INTO cucmsdocs
133  (docsid, docsname, docsdesc, docstitle, docstype, docsdisplaylink,
134  docsdisplaytext, docsdefaultavail, docsresponsetype,
135  docsmaintsection, docsmaintsort, docstarget, docstargetname)
136  VALUES
137  ( $save_id,
138  '" . prep_save($docsname, 50) . "',
139  '" . prep_save($docsdesc, 250) . "',
140  '" . prep_save($docstitle, 100) . "',
141  $docstype,
142  '" . $docsdisplaylink . "',
143  '" . prep_save($docsdisplaytext, 100) . "',
144  '" . $docsdefaultavail . "',
145  '" . $docsresponsetype . "',
146  '" . prep_save($docsmaintsection, 30) . "',
147  '" . intval($docsmaintsort) . "',
148  '" . prep_save($docstarget, 20) . "',
149  '" . prep_save($docstargetname, 100) . "') ";
150  }
151  }
152 
153  // Now pass the query to the Database
154  if ($error_msg == '') {
155  if (!($db_result=db_query($qry_stmt, $link))) {
156  $error_msg = "A problem occurred while saving your information, you may want to try later .";
157  $act = 1;
158  } else {
159  $Remote_Results = "";
160  // Only need to do this if at least one remote server was selected
161  if (Remote_Update_Selected()) {
162  if ($num_rows == 0) {
163  $remote_doc_id = intval($save_id);
164  } else {
165  $remote_doc_id = intval($docsid);
166  }
167 
168  // ** NOW CHECK FOR SAVING TO A REMOTE SERVER
169  // ** Add Each field that will be updated
170  Remote_Field_Add("cucmsdocs", "docsid", $remote_doc_id);
171  Remote_Field_Add("cucmsdocs", "docsname", $docsname);
172  Remote_Field_Add("cucmsdocs", "docsdesc", $docsdesc);
173  Remote_Field_Add("cucmsdocs", "docstitle", $docstitle);
174  Remote_Field_Add("cucmsdocs", "docstype", $docstype);
175  Remote_Field_Add("cucmsdocs", "docsdisplaylink", $docsdisplaylink);
176  Remote_Field_Add("cucmsdocs", "docsdisplaytext", $docsdisplaytext);
177  Remote_Field_Add("cucmsdocs", "docsdefaultavail", $docsdefaultavail);
178  Remote_Field_Add("cucmsdocs", "docsresponsetype", $docsresponsetype);
179  Remote_Field_Add("cucmsdocs", "docsmaintsection", $docsmaintsection);
180  Remote_Field_Add("cucmsdocs", "docsmaintsort", $docsmaintsort);
181  Remote_Field_Add("cucmsdocs", "docstarget", $docstarget);
182  Remote_Field_Add("cucmsdocs", "docstargetname", $docstargetname);
183 
184  // ** Need to create the url I am going to send to the remote server
185  $Remote_Results = Remote_Update_Send("U", "cucmsdocs");
186 
187  }
188 
189  // Successful
190  header ("Location: $self?msg=" . urlencode("The information was saved!<br>$Remote_Results"));
191  exit;
192  }
193  }
194  }
195 
196  if ( strlen( $error_msg ) > 0 ) {
197  // Error found go back to edit screen
198  $error_msg = "The following problems were found with the information given.<br>Please correct this and try again.<br><br>$error_msg";
199  $act = 1;
200  }
201 
202  } elseif ($act == "5") {
203  $sql = "DELETE FROM cucmsdocs
204  WHERE docsid = '" . intval($docsid) . "' ";
205 
206  if (!($db_result=db_query($sql, $link))) {
207  header ("Location: $self?msg=" . urlencode("A problem occurred while deleting the custom file entry, you may want to try later."));
208  exit;
209  } else {
210  // ** DELETE on remote servers
211  if (Remote_Update_Selected()) {
212  // ** NOW CHECK FOR SAVING TO A REMOTE SERVER
213  // ** Add Each field that will be updated
214  Remote_Field_Add("cucmsdocs", "docsid", intval($docsid));
215 
216  // ** Need to create the url I am going to send to the remote server
217  $Remote_Results = Remote_Update_Send("D", "cucmsdocs");
218 
219  }
220  // Successful
221  header ("Location: $self?msg=" . urlencode("The entry was deleted!"));
222  exit;
223  }
224  }
225 
226 
227  switch ($act):
228  case "1": // Add/Edit Admin Messages
229  cu_header("Credit Union Custom Content");
230 ?>
231  <form action="<?php echo $self; ?>?act=3" method="post">
232  <?php
233  // Connect to the database - get the team information from the database
234  // Docs ID will not exist for ADD custom content
235  $docsRow = null;
236  $num_rows = 0;
237  if (isset($docsid)) {
238  $query = "select * from cucmsdocs where docsid = '$docsid' and docstype in (1,2,3)"; // 4 is used for Estatements.
239  $result = db_query($query, $link);
240  // Now fetch the row
241  $docsRow = db_fetch_object($result);
242  $num_rows = db_num_rows($result);
243  }
244  ?>
245  <p>&nbsp;
246  <p>
247  <?php
248  if (isset($form_err) && strlen($form_err) > 0)
249  printf("\n<font color=\"red\">Errors found before saving the information. Please review errors at bottom of screen.\n<p></font>");
250  ?>
251  <center>
252  <table width="80%" cellpadding="2" cellspacing="0" border="0" class="dmsbg"><tr><td>
253  <table width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor=white>
254  <tr>
255  <td colspan="2" class="bar" align="center">
256  <?php if($num_rows > 0): ?>
257  EDIT CUSTOM FILE
258  <input type="hidden" name="docsid" value="<?php echo $docsRow->docsid; ?>">
259  <?php else: ?>
260  ADD CUSTOM FILE
261  <?php endif; ?>
262  </td>
263  </tr>
264  <?php if ($error_msg != ''): ?>
265  <tr>
266  <td colspan="2" align="center" class="err">
267  <?php echo $error_msg; ?>
268  </td>
269  </tr>
270  <?php endif; ?>
271  <tr>
272  <td nowrap align="right" class="hdr">
273  Document File Name:
274  </td>
275  <td nowrap class="dtl">
276  <?php
277  $cu_info = "";
278  if ( isset($docsname))
279  $cu_info = trim($docsname);
280  elseif ($num_rows > 0)
281  $cu_info = htmlspecialchars(trim($docsRow->docsname));
282  ?>
283  <input type="text" name="docsname" size="50" maxlength="50" value="<?php echo $cu_info ?>">
284  </td>
285  </tr>
286  <tr>
287  <td nowrap align="right" class="hdr" valign="top">
288  Document Description:
289  </td>
290  <td nowrap class="dtl">
291  <?php
292  $cu_info = "";
293  if ( isset($docsdesc))
294  $cu_info = set_string($docsdesc);
295  else if ($num_rows > 0)
296  $cu_info = htmlspecialchars(trim($docsRow->docsdesc));
297  ?>
298  <textarea name="docsdesc" rows="10" cols="40"><?php echo $cu_info; ?></textarea>
299  (If a Notice, used in CU Admin "Reset Popups and Promos" so it needs to be understandable and not changing.)
300  </td>
301  </tr>
302  <tr>
303  <td nowrap align="right" class="hdr">
304  Document Title:
305  </td>
306  <td nowrap class="dtl">
307  <?php
308  $cu_info = "";
309  if ( isset($docstitle))
310  $cu_info = trim($docstitle);
311  else if ($num_rows > 0)
312  $cu_info = htmlspecialchars(trim($docsRow->docstitle));
313  ?>
314  <input type='text' name='docstitle' value='<?php echo $cu_info ?>'> (If a Notice or Terms, used in Disclosures page; needs to be in the Dictionary)
315  </td>
316  </tr>
317  <tr>
318  <td nowrap align="right" class="hdr">
319  Doc Type:
320  </td>
321  <td nowrap class="dtl">
322  <?php
323  $cu_info = "";
324  if ( isset($docstype))
325  $cu_info = $docstype;
326  else if ($num_rows > 0)
327  $cu_info = $docsRow->docstype;
328  ?>
329  <select name='docstype'>
330  <option value='1' <?php echo ($cu_info == '1' ? "SELECTED" : "") ?>>Stand Alone</option>
331  <option value='2' <?php echo ($cu_info == '2' ? "SELECTED" : "") ?>>Fragment</option>
332  <option value='3' <?php echo ($cu_info == '3' ? "SELECTED" : "") ?>>Complex Form</option>
333  </select>
334  <?php // NOTE: If there is ever a new docstype, skip 4. It is used for Estatements. ?>
335  (Stand Alone is a complete HTML document; complex form causes TinyMCE editor to not be used; mobile template places it in CU's mobile directory.)
336  </td>
337  </tr>
338  <tr>
339  <td nowrap align="right" class="hdr">
340  Allow Display Link:
341  </td>
342  <td nowrap class="dtl">
343  <?php
344  $cu_info = "";
345  if ($num_rows > 0)
346  $cu_info = $docsRow->docsdisplaylink == "Y" ? "checked='CHECKED'" : "";
347  else if (isset($docsdisplaylink))
348  $cu_info = $docsdisplaylink == "Y" ? "checked='CHECKED'" : "";
349  ?>
350  <input type='checkbox' value='Y' name='docsdisplaylink' <?php echo $cu_info ?>> Allow
351  </td>
352  </tr>
353  <tr>
354  <td nowrap align="right" class="hdr">
355  Display Link:
356  </td>
357  <td nowrap class="dtl">
358  <?php
359  $cu_info = "";
360  if ( isset($docsdisplaytext))
361  $cu_info = trim($docsdisplaytext);
362  else if ($num_rows > 0)
363  $cu_info = htmlspecialchars(trim($docsRow->docsdisplaytext));
364 
365  ?>
366  <input type='text' name='docsdisplaytext' value='<?php echo $cu_info ?>'> (Link phrase needs to be in the Dictionary)
367  </td>
368  </tr>
369  <tr>
370  <td nowrap align="right" class="hdr">
371  Default Script Available?:
372  </td>
373  <td nowrap class="dtl">
374  <?php
375  $cu_info = "";
376  if ($num_rows > 0)
377  $cu_info = $docsRow->docsdefaultavail == "Y" ? "checked='CHECKED'" : "";
378  else if (isset($docsdefaultavail))
379  $cu_info = $docsdefaultavail == "Y" ? "checked='CHECKED'" : "";
380  ?>
381  <input type='checkbox' value='Y' name='docsdefaultavail' <?php echo $cu_info ?>> Available
382  </td>
383  </tr>
384  <tr>
385  <td nowrap align="right" class="hdr">
386  Response Type:
387  </td>
388  <td nowrap class="dtl">
389  <?php
390  $cu_info = "";
391  if ( isset($docsresponsetype))
392  $cu_info = $docsresponsetype;
393  else if ($num_rows > 0)
394  $cu_info = $docsRow->docsresponsetype;
395  ?>
396  <select name='docsresponsetype'>
397  <option value='N' <?php echo ($cu_info == 'N' ? "SELECTED" : "") ?>>None</option>
398  <option value='T' <?php echo ($cu_info == 'T' ? "SELECTED" : "") ?>>Terms of Use</option>
399  <option value='D' <?php echo ($cu_info == 'D' ? "SELECTED" : "") ?>>Notice/Disclaimer</option>
400  <option value='A' <?php echo ($cu_info == 'A' ? "SELECTED" : "") ?>>Promo/All Members</option>
401  <option value='E' <?php echo ($cu_info == 'E' ? "SELECTED" : "") ?>>Promo/No E-Statements</option>
402  <option value='P' <?php echo ($cu_info == 'P' ? "SELECTED" : "") ?>>Promo/Persistent</option>
403  </select>
404  </td>
405  </tr>
406  <tr>
407  <td nowrap align="right" class="hdr">
408  Content Maintenance Section
409  </td>
410  <td nowrap class="dtl">
411  <?php
412  $cu_info = "";
413  if ( isset($docsmaintsection))
414  $cu_info = set_string($docsmaintsection);
415  else if ($num_rows > 0)
416  $cu_info = htmlspecialchars(trim($docsRow->docsmaintsection));
417 
418  $cu_info = ($cu_info == '' ? $sectionMaster[0] : $cu_info);
419  ?>
420  <select name="docsmaintsection" size=1>
421  <?php foreach ($sectionMaster as $sectionValue) : ?>
422  <option value="<?php echo $sectionValue; ?>" <?php echo ($cu_info == $sectionValue ? "SELECTED" : ""); ?>><?php echo $sectionValue; ?></option>
423  <?php endforeach; ?>
424  </select>
425  </td>
426  </tr>
427  <tr>
428  <td nowrap align="right" class="hdr">
429  Content Maintenance Sort Value:
430  </td>
431  <td nowrap class="dtl">
432  <?php
433  $cu_info = "";
434  if ( isset($docsmaintsort))
435  $cu_info = $docsmaintsort;
436  else if ($num_rows > 0)
437  $cu_info = $docsRow->docsmaintsort;
438  ?>
439  <input type='number' name='docsmaintsort' value='<?php echo $cu_info ?>' min='0' max='500'>
440  </td>
441  </tr>
442  <tr>
443  <td nowrap align="right" class="hdr">Target Directory:</td>
444  <td nowrap class="dtl">
445  <select name='docstarget'>
446  <?php
447  $cu_info = "";
448  if (isset($docstarget))
449  $cu_info = trim($docstarget);
450  else if ($num_rows > 0)
451  $cu_info = htmlspecialchars(trim($docsRow->docstarget));
452  ?>
453  <option value='' <?php echo ($cu_info == "" ? "SELECTED" : ""); ?>>(Default)</option>
454  <option value='public_html' <?php echo ($cu_info == "public_html" ? "SELECTED" : ""); ?>>Public HTML</option>
455  <option value='mobile' <?php echo ($cu_info == "mobile" ? "SELECTED" : ""); ?>>Mobile</option>
456  </select>
457 
458  (Default goes to /home/CUCODE/public_html/bankingIncludes/, public HTML: /home/CUCODE/public_html/ and mobile: /home/CUCODE/public_html/mobile.)
459  </tr>
460  <tr>
461  <td nowrap align="right" class="hdr">Target Name:</td>
462  <td nowrap class="dtl">
463  <?php
464  if (isset($docstargetname))
465  $cu_info = trim($docstargetname);
466  else if ($num_rows > 0)
467  $cu_info = htmlspecialchars(trim($docsRow->docstargetname));
468  ?>
469  <input type="string" name="docstargetname" value='<?php echo $cu_info; ?>'>
470  </td>
471  </tr>
472  <tr>
473  <td class='dtl'>&nbsp;</td>
474  <td nowrap class='dtl'>
475  <tr>
476  <td class='dtl'>&nbsp;</td>
477  <td nowrap class='dtl'>
478  <?php remote_update_list(); ?>
479  </td>
480  </tr>
481  <tr>
482  <td class='dtl'>&nbsp;</td>
483  <td nowrap class='dtl' colspan="1">
484  <input type="submit" name="Save" Value="Save">
485  <input type="button" name="Cancel" Value="Cancel" onClick="document.location='<?php echo $self; ?>'">
486  </td>
487  </tr>
488  </table>
489 
490  <?php // If the error value is here then print it at the end
491  if (isset($form_err)) {
492  echo $form_err;
493  }
494 
495  echo "</td></tr></table>";
496  break;
497  case "2":
498  cu_header("CU Message List");
499  ?>
500  <form>
501 
502  <?php
503  $order_by = "";
504  $o_desc = "";
505  switch ($o) {
506  case 2:
507  $order_by = "lower(docsdesc)";
508  if (!isset($d))
509  $o_desc = "&d=1";
510  break;
511  case 3:
512  $order_by = "docstype";
513  if (!isset($d))
514  $o_desc = "&d=1";
515  break;
516  case 4:
517  $order_by = "lower(docsdisplaytext)";
518  if (!isset($d))
519  $o_desc = "&d=1";
520  break;
521  case 5:
522  $order_by = "lower(docsresponsetype)";
523  if (!isset($d))
524  $o_desc = "&d=1";
525  break;
526  default:
527  $order_by = "lower(docsname)";
528  if (!isset($d))
529  $o_desc = "&d=1";
530  break;
531  }
532  if (isset($d)) {
533  $order_by .= " desc";
534  }
535 
536 
537  reset($sectionMaster);
538  $order_by = "CASE WHEN coalesce(docsmaintsection, '') = '' THEN 0 ";
539  foreach ($sectionMaster as $sectionKey => $sectionValue) {
540  $order_by .= " WHEN docsmaintsection = '$sectionValue' THEN $sectionKey ";
541  }
542  $order_by .= "ELSE 0 END, docsmaintsort, lower(docsname)";
543 
544  $query = "SELECT *, case when coalesce(docsmaintsection, '') = '' then '{$sectionMaster[0]}' else docsmaintsection end as docssectionname
545  FROM cucmsdocs where docstype in (1,2,3)
546  ORDER BY $order_by "; // 4 is used in Estatements
547  $prod_result = db_query($query, $link);
548 
549  ?>
550 
551  <!-- Print out the top of the table -->
552 
553  <table border="0" cellpadding="2" callspacing="0" align="center" width="80%" class="dmsbg"><tr><td>
554  <table border="0" cellpadding=2 cellspacing="0" align="center" width="100%">
555  <tr>
556  <td colspan="<?php echo $numColumns; ?>" class="bar" align="center">
557  CU Admin Custom Content File List
558  </td>
559  </tr>
560  <?php if (isset($msg)): ?>
561  <tr>
562  <td colspan="<?php echo $numColumns; ?>" class="err" align="center">
563  <font color="#FF8080"><?php echo $msg; ?></font>
564  </td>
565  </tr>
566  <?php endif; ?>
567  <tr>
568  <td colspan="<?php echo $numColumns; ?>" class="dtl">
569  <a href="<?php echo $self; ?>?act=1" target="_parent">Add Custom Content File</a>
570  &nbsp;|&nbsp;
571  <a href="<?php echo $infourl ?>/hcuadm/cuilist.prg" target="_parent">Credit Union List</a>
572  </td>
573  </tr>
574  <tr>
575  <td class="hdr" align="left" valign="top" nowrap>
576  Doc Name
577  </td>
578  <td class="hdr" align="left" valign="top" nowrap>
579  Sort
580  </td>
581  <td class="hdr" align="left" valign="top" nowrap>
582  Description
583  </td>
584  <td class="hdr" align="left" valign="top" nowrap>
585  Title
586  </td>
587  <td class="hdr" align="left" valign="top">
588  Type
589  </td>
590  <td class="hdr" align="left" valign="top">
591  Disp Link?
592  </td>
593  <td class="hdr" align="left" valign="top">
594  Link Text
595  </td>
596  <td class="hdr" align="left" valign="top">
597  Default Avail
598  </td>
599  <td class="hdr" align="left" valign="top">
600  Response
601  </td>
602  <td class="hdr" align="left" valign="top">
603  Target
604  </td>
605  <td class="hdr" align="left" valign="top">
606  Target Name
607  </td>
608  <td class="hdr" align="center" valign="top">
609  Select
610  </td>
611  <td class="hdr" align="center" valign="top">
612  Skeleton<br>Create/Edit
613  </td>
614  <td class="hdr" align="center" valign="top">
615  Skel
616  </td>
617  <td class="hdr" align="center" valign="top">
618  Export<br>Default
619  </td>
620  </tr>
621  <?php
622  $RGB = "odd";
623  $row = 0;
624  $currentSection = '';
625  while ($prod_row = db_fetch_object($prod_result, $row)):
626  $row++;
627  if ($currentSection != $prod_row->docssectionname) :
628  $currentSection = $prod_row->docssectionname;
629  // ** Create a section row to identify the section ?>
630  <tr class="" style='background:#fff;'>
631  <td colspan='<?php echo $numColumns; ?>' style='padding:5px 0 5px 0;text-align:center;'>
632  <span style='color: #333; font-size: 14pt;'>Content Section: <?php echo $currentSection; ?></span>
633  </td>
634  </tr>
635  <?php endif; ?>
636  <tr class="<?php echo $RGB; ?>_small">
637  <td nowrap valign="top">
638  <?php echo trim($prod_row->docsname) ?>
639  </td>
640  <td valign="top" style="max-width:50px;">
641  <?php echo trim($prod_row->docsmaintsort); ?>
642  </td>
643  <td valign="top" style="max-width:250px;">
644  <?php echo trim($prod_row->docsdesc); ?>
645  </td>
646  <td valign="top">
647  <?php
648  echo trim($prod_row->docstitle);
649  ?>
650  </td>
651  <td nowrap valign="top">
652  <?php
653  switch ($prod_row->docstype) {
654  case 1:
655  echo "Stand Alone";
656  break;
657  case 2:
658  echo "Fragment";
659  break;
660  case 3:
661  echo "Complex Form";
662  break;
663  }
664  ?>
665  </td>
666  <td valign="top">
667  <?php echo trim($prod_row->docsdisplaylink) ?>
668  </td>
669  <td valign="top">
670  <?php echo trim($prod_row->docsdisplaytext) ?>
671  </td>
672  <td valign="top">
673  <?php echo ( trim($prod_row->docsdefaultavail) == "Y" ? "Y" : "" ) ?>
674  </td>
675  <td nowrap valign="top">
676  <?php
677  switch ($prod_row->docsresponsetype) {
678  case "N":
679  echo "-";
680  break;
681  case "D":
682  echo "Notice";
683  break;
684  case "T":
685  echo "Terms";
686  break;
687  case "A":
688  echo "Promo/All Members";
689  break;
690  case "E":
691  echo "Promo/No E-Statements";
692  break;
693  case "P":
694  echo "Promo/Persistent";
695  break;
696  }
697  ?>
698  </td>
699  <td valign="top">
700  <?php echo(trim($prod_row->docstarget) == "" ? "-" : trim($prod_row->docstarget)); ?>
701  </td>
702  <td valign="top">
703  <?php echo(trim($prod_row->docstargetname) == "" ? "-" : trim($prod_row->docstargetname)); ?>
704  </td>
705  <td nowrap valign="top">
706  <a href="<?php echo $self; ?>?act=1&docsid=<?php echo trim($prod_row->docsid) ?>">Edit</a>
707  &nbsp;|&nbsp;
708  <a href="<?php echo $self; ?>?act=4&docsid=<?php echo trim($prod_row->docsid) ?>">Delete</a>
709  </td>
710  <td nowrap valign="top">
711  <select onchange='if (this.value) { location.href="<?php echo $self; ?>?act=33&docsid=<?php echo trim($prod_row->docsid) ?>&language="+this.value; }'>
712  <option value="">Language...</option>
713  <?php
714  for ( $i = 0; $i < count( $availableLanguages ); $i++ ) {
715  print "<option value='{$availableLanguages[$i]["lang"]}'>{$availableLanguages[$i]["display"]}</option>";
716  }
717  ?>
718  </select>
719  </td>
720  <td>
721  <?php
722  // this variable is to determine if something exists to export
723  $canExportSkeleton = false;
724  for ( $i = 0; $i < count( $availableLanguages ); $i++ ) {
725  // see if a skeleton exists
726  $skelFile = "skel_" . trim($prod_row->docsname);
727 
728  // does it exist
729  $hasSkeleton = false;
730 
731  if ( file_exists("$skeletonLocation/{$availableLanguages[$i]["lang"]}/$skelFile") ) {
732  $hasSkeleton = true;
733  $canExportSkeleton = true;
734  }
735  $color = $hasSkeleton ? "green" : "red";
736  $letter = substr( $availableLanguages[$i]["display"], 0 , 1 );
737  print "<span style='background-color:{$color}'>{$letter}</span>";
738  }
739  ?>
740  </td>
741  <td nowrap valign="top">
742  <?php
743  if ( $prod_row->docsdefaultavail == "Y" ) {
744  if ( $canExportSkeleton ) {
745  ?>
746  <button type='button' onClick='location.href="<?php echo $self; ?>?act=55&docsid=<?php echo trim($prod_row->docsid) ?>"'>Export</button>
747  <?php
748  } else {
749  print "<span style='font-size:smaller; color:darkgray;'>Need<br>Skeleton</span>";
750  }
751  } else {
752  print "&nbsp;";
753  }
754  ?>
755  </td>
756  </tr>
757  <?php
758  /* Special NOTE for Persistent Promos. Create awareness to fully implement the logic.
759  *
760  */
761  if ( $prod_row->docsresponsetype == "P" ) {
762  print "<tr class='{$RGB}_small'><td colspan='$numColumns' style='color:red'>NOTE: To fully implement a Persistent Promo the logic in the Admin to exclude members needs to be added and this note needs to be removed.</td></tr>";
763  }
764  $RGB = ($RGB == "odd" ? "even" : "odd");
765  endwhile; ?>
766 
767  <tr>
768  <td colspan="<?php echo $numColumns; ?>" class="dtl">
769  <a href="<?php echo $self; ?>?act=1" target="_parent">Add Custom Content File</a>
770  &nbsp;|&nbsp;
771  <a href="<?php echo $infourl ?>/hcuadm/cuilist.prg" target="_parent">Credit Union List</a>
772  </td>
773  </tr>
774  </table>
775  </td></tr></table>
776 <?php
777  break;
778  case "4":
779  cu_header ("Delete Custom Content File");
780 ?>
781  <?php
782  // Connect to the database
783  $query = "select * from cucmsdocs
784  where docsid = '$docsid'";
785  $result = db_query($query, $link);
786  // Now fetch the row
787  $docsRow = db_fetch_array($result);
788  $num_rows = db_num_rows($result);
789 
790  echo "<center><table width=\"40%\" cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"dmsbg\"><tr><td>";
791  if ($num_rows > 0): ?>
792  <form action="<?php echo $self; ?>?act=5" method="post">
793  <input type="hidden" name="act" value="5">
794  <table width="100%" cellpadding="1" cellspacing="1" border="0">
795  <tr>
796  <td class="bar" align="center">
797  DELETE CUSTOM CONTENT FILE
798  <input type="hidden" name="docsid" value="<?php echo $docsRow['docsid']; ?>">
799  </td>
800  </tr>
801  <tr>
802  <td align="center" class="dtl">
803  Howdy Pardner, you have selected to delete an Custom Content file.<br>
804  The file is named <b><?php echo htmlspecialchars(trim($docsRow['docsname'])); ?></b>.<br><br>
805  Please verify this before deleting. After deleting this file <br>you will need to reenter it if you didn't
806  mean to delete it.
807  </td>
808  </tr>
809  <tr>
810  <td nowrap class='dtl'>
811  <table width="250" align='center'><tr><td>
812  <?php remote_update_list(); ?>
813  </td></tr></table>
814  </td>
815  </tr>
816  <tr>
817  <td align="right" class="hdr" nowrap>
818  <input type='submit' name='btnSubmit' value="Please delete this message">
819  &nbsp;&nbsp;
820  <input type="button" name="btnCancel" value="I don't want to do this" onclick="document.location='<?php echo $self; ?>'">
821  </td>
822  </tr>
823  </table>
824  <?php else: ?>
825  <table width="100%" cellpadding="1" cellspacing="1" border="0">
826  <tr>
827  <td class="bar" align="center">
828  DELETE CUSTOM CONTENT FILE - Problem Encountered
829  </td>
830  </tr>
831  <tr>
832  <td class="dtl" align="center">
833  Problem deleting the Custom Content File. <br>
834  It appears the file has already been deleted or never existed.<br>
835  Please return to the <a href="<?php echo $self; ?>">menu</a> and try again.
836  </td>
837  </tr>
838  </table>
839  <?php endif;
840 
841  echo "</td></tr></table>";
842  break;
843  case "33":
844  cu_header("CU Custom Content Skeleton File Edit");
845  // build the skeleton file name
846  $sql = "SELECT docsname, docstype FROM cucmsdocs WHERE docsid = '$docsid'";
847  $dbResult = db_query($sql, $link);
848  list($skelName, $docstype) = db_fetch_array($dbResult);
849  $newFile = true;
850  if ( strlen( $skelName ) > 0 ) {
851  $skelFile = "skel_" . $skelName;
852 
853  // insert the user security stuff in the url
854  $infourl = str_replace("//","//nobody:no1home@",$infourl);
855  // Now read the file into memory
856  $userWarning = "";
857  if ($fp = fopen("$skeletonLocation/$language/$skelFile", "r")) {
858  $newFile = false;
859  while (!feof($fp)) {
860  $contents .= fread($fp, 1024);
861  }
862  fclose($fp);
863  } else if ( $language != "en_US" ) {
864  // if looking for a non-english skeleton and didn't find it, get the English one but give warning
865  if ($fp = fopen("$skeletonLocation/en_US/$skelFile", "r")) {
866  $newFile = false;
867  while (!feof($fp)) {
868  $contents .= fread($fp, 1024);
869  }
870  fclose($fp);
871  $userWarning = "Skeleton file missing. Using English skeleton file as a starting point.";
872  } else {
873  $contents = "";
874  }
875  } else {
876  $contents = "";
877  }
878 
879  $showcontents=htmlspecialchars($contents);
880 
881  $textarea_TinyMCE = "";
882 
883  if ( $userWarning ) {
884  print "<h4><span style='background-color:yellow;'>$userWarning</span></h4>";
885  }
886 
887  if ( $docstype != 3 && $docstype != 4 ) {
888  print <<< set_TinyMCE
889  <script type="text/javascript" src="https://{$cloudfrontDomainName}/homecu/js/tinymce/{$tinyMceVersion}/tinymce.min.js"></script>
890  <script type="text/javascript">
891  tinyMCE.init({
892  // General options
893  doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
894  selector : "textarea",
895  plugins : ["autolink autosave link image lists charmap preview hr anchor spellchecker searchreplace wordcount visualchars code fullscreen insertdatetime nonbreaking save table contextmenu directionality emoticons textcolor paste textcolor"],
896  menubar: false,
897  toolbar_items_size: 'small',
898  // Theme options
899  toolbar1 : "save preview code | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
900  toolbar2 : "cut copy paste pastetext pasteword | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image | insertdatetime inserttime | forecolor backcolor",
901  toolbar3 : "table | hr removeformat visualaid | subscript superscript | charmap emoticons | spellchecker | visualchars nonbreaking | insertfile ",
902  relative_urls: false,
903  remove_script_host : false,
904  // Skin options
905  save_enablewhendirty : true,
906  save_onsavecallback : "savefile",
907  insertdatetime_formats: ["%Y.%m.%d", "%H:%M"],
908 
909  // allow it to keep <style> tags
910  valid_children : "+body[style]"
911  });
912  function savefile () {
913 
914  document.forms[0].submit();
915  }
916  </script>
917 set_TinyMCE;
918  }
919 
920  print <<< print_html
921  <script language="javascript">
922  <!--
923  var win=null;
924  function Preview() {
925  win = window.open("","htmlWin","scrollbars=1,menubar=1,status=1")
926  //win.document.write("<BASE HREF='" + document.Tag.baseHref.value + "'>")
927  win.document.write("<P>")
928  win.document.write(document.preview.script_doc.value)
929  win.document.write("</P>")
930  }
931  // -->
932  </script>
933 print_html;
934  if ( $newFile ) {
935  print "<h3>File $skelName is new and will be created at the Save.</h3>\n";
936  } else {
937  print "<h3>Editing file $skelName.</h3>\n";
938  }
939  print <<< print_html
940  <form name="savefile" action="$self?act=44" method="post">
941  <input type="hidden" name="act" value="44">
942  <input type="hidden" name="docsid" value="$docsid">
943  <input type="hidden" name="language" value="$language">
944  <input type="submit" name="btnSubmit" value="Save my Changes">
945  <input type="button" name="btnCanc" value="Don't save my Changes" onclick="document.location='$self'">
946  <br>
947  <textarea name="script_doc" rows=50 cols=90>$showcontents</textarea>
948  </form>
949 print_html;
950  } else {
951  // Problem opening the file
952  print '
953  <table align=center border=0 cellpadding=0 cellspacing=0 width="60%" class="dmsbg"><tr><td>
954  <table border=0 cellpadding=0 cellspacing=0 width="100%">
955  <tr>
956  <td class="dtl">
957  An incorrect selection was made, please go back to the <a href="' . $self . '">menu</a><br>
958  and select again.
959  </td>
960  </tr>
961  </table>
962  </td></tr></table>';
963  }
964  break;
965  case "44":
966  cu_header("CU Custom Content Skeleton File Save");
967  // build the skeleton file name
968  $sql = "SELECT docsname FROM cucmsdocs WHERE docsid = '$docsid'";
969  $dbResult = db_query($sql, $link);
970  list($skelName) = db_fetch_array($dbResult);
971  if ( strlen( $skelName ) > 0 ) {
972  $skelFile = "skel_" . $skelName;
973 
974  // insert the user security stuff in the url
975  $infourl = str_replace("//","//nobody:no1home@",$infourl);
976  $contents = $script_doc;
977 
978  $save_as = "$skeletonLocation/$language/$skelFile";
979 
980  $file_save = false;
981  // First if the file already exists, make sure it is readable by the owner "nobody"
982  if (file_exists($save_as))
983  chmod($save_as, 0666);
984 
985 
986  // Make sure the file opens and saves before saying it was saved correctly
987  if ($save_fp = fopen($save_as, "w")) {
988  if (fwrite($save_fp, $contents)) {
989  $file_save = true;
990  }
991  fclose ($save_fp);
992  // save the filepermisssions
993  chmod($save_as, 0644);
994  }
995 
996  print <<< print_html
997  <table width="100%" border=0 cellpadding=0 cellspacing=1>
998  <tr>
999  <td class="bar" align="center">
1000  Skeleton File Save Confirmation
1001  </td>
1002  </tr>
1003  <tr>
1004  <td class="dtlc" >
1005 print_html;
1006  if ($file_save == true) {
1007  print <<< print_html
1008  The skeleton file, $skelName was saved <b>successfully</b>.<br><br>
1009  Click here to return to the <a href="$self">menu</a>.
1010 print_html;
1011  } else {
1012  // Failed to open and write the file
1013  print <<< print_html
1014  An error occurred, the script was NOT saved successfully.<br>
1015  Please try again before <a href="$self">screaming</a>.<br>
1016  (Your changes will be lost unless you use the 'Back' button.)
1017 print_html;
1018  }
1019  print <<< print_html
1020  </td>
1021  </tr>
1022  </table>
1023 print_html;
1024  } else {
1025  print '
1026  <table border=0 cellpadding=0 cellspacing=0 width="100%">
1027  <tr>
1028  <td class="dtl">
1029  An incorrect selection was made, please go back to the <a href="' . $self . '">menu</a><br>
1030  and select again.
1031  </td>
1032  </tr>
1033  </table>';
1034  }
1035  echo "</td></tr></table>";
1036  break;
1037  case "55":
1038  cu_header("CU Custom Content Skeleton File Export To Default Content File");
1039 
1040  // read the docs name
1041  $sql = "SELECT docsname FROM cucmsdocs WHERE docsid = '$docsid'";
1042  $dbResult = db_query($sql, $link);
1043  list($docName) = db_fetch_array($dbResult);
1044 
1045  print "
1046  <table border=0 cellpadding=0 cellspacing=0 width='100%' class='dmsbg'>
1047  <tr><td class='bar' style='text-align:center;'>Exporting $docName</td></tr>";
1048 
1049  // what we do depends on where we are running
1050  $host = substr($_SERVER['SERVER_NAME'], 0,strpos($_SERVER['SERVER_NAME'], "."));
1051  if ( $host === "www" ) {
1052  // on Monitor, so this is the real thing
1053  print "<tr><td class='dtlc'>On MONITOR</td></tr>";
1054 
1055  for ( $i = 0; $i < count( $availableLanguages ); $i++ ) {
1056  // see if a skeleton exists
1057  $skelFile = "skel_" . trim($docName);
1058 
1059  // does it exist?
1060  $hasSkeleton = false;
1061  if ( file_exists("$skeletonLocation/{$availableLanguages[$i]["lang"]}/$skelFile") ) {
1062  $hasSkeleton = true;
1063  }
1064 
1065  if ( $hasSkeleton ) {
1066  $message = "Skeleton found - " . $availableLanguages[$i]["display"];
1067  } else {
1068  $message = "Skeleton <span style='background-color:red;'>NOT</span> found - " . $availableLanguages[$i]["display"];
1069  }
1070 
1071  // do the copy
1072  if ( $hasSkeleton ) {
1073  $source = "$skeletonLocation/{$availableLanguages[$i]["lang"]}/";
1074  $dest = "$exportLocation/{$availableLanguages[$i]["lang"]}/";
1075 
1076  // batch server
1077  $copyString = "scp -i /home/ubuntu/.ssh/aws.key $source$skelFile ubuntu@int5.homecu.net:$dest";
1078 
1079  // due to rights issues, at this time not doing actual copy but instead just printing instructions
1080 
1081  $resultMessage5 = "<br><span style='background-color:red;'>NOTE:</span> For Batch server copy please run in terminal window: $copyString";
1082 
1083  // live server (NOTE: there are now two of them)
1084  $copyString = "scp -i /home/ubuntu/.ssh/aws.key $source$skelFile ubuntu@int6.homecu.net:$dest";
1085 
1086  $resultMessage6 = "<br><span style='background-color:red;'>NOTE:</span> For Live (www6) server copy please run in terminal window: $copyString";
1087 
1088  $copyString = "scp -i /home/ubuntu/.ssh/aws.key $source$skelFile ubuntu@int3.homecu.net:$dest";
1089 
1090  $resultMessage6 .= "<br><span style='background-color:red;'>NOTE:</span> For Live (www3) server copy please run in terminal window: $copyString";
1091  } else {
1092  $resultMessage5 = "No Copy Peformed";
1093  $resultMessage6 = "";
1094  }
1095 
1096  print "<tr><td class='dtlc'>$message: $resultMessage5 $resultMessage6</td></tr>";
1097  }
1098  } else {
1099  // on dev
1100  print "<tr><td class='dtlc'>On DEV</td></tr>";
1101 
1102  for ( $i = 0; $i < count( $availableLanguages ); $i++ ) {
1103  // see if a skeleton exists
1104  $skelFile = "skel_" . trim($docName);
1105 
1106  // does it exist?
1107  $hasSkeleton = false;
1108  if ( file_exists("$skeletonLocation/{$availableLanguages[$i]["lang"]}/$skelFile") ) {
1109  $hasSkeleton = true;
1110  }
1111 
1112  if ( $hasSkeleton ) {
1113  $message = "Skeleton found - " . $availableLanguages[$i]["display"];
1114  } else {
1115  $message = "Skeleton <span style='background-color:red;'>NOT</span> found - " . $availableLanguages[$i]["display"];
1116  }
1117 
1118  // do the copy
1119  if ( $hasSkeleton ) {
1120  $source = "$skeletonLocation/{$availableLanguages[$i]["lang"]}/";
1121  $dest = "$exportLocation/{$availableLanguages[$i]["lang"]}/";
1122 
1123  $result = copy( $source . $skelFile, $dest . $skelFile );
1124 
1125  $resultMessage = $result ? "Success" : "Failed";
1126  } else {
1127  $resultMessage = "No Copy Peformed";
1128  }
1129 
1130  print "<tr><td class='dtlc'>$message: $resultMessage</td></tr>";
1131  }
1132  }
1133 
1134 
1135  // copy the given skeleton file from the source directory to the three servers (dev, batch, live)
1136  print "<tr><td class='dtlc'>When ready, please go back to the <a href='$self'>menu</a></td></tr>";
1137  print "</table>";
1138  break;
1139  default:
1140  cu_header("Error Displaying Form");
1141  print ("<form>");
1142  printError("Requested form not found!<br>Cancelling action.");
1143  endswitch;
1144  ?>
1145  </form>
1146  </body>
1147 </html>
1148