Odyssey
ContentMntc.prg
1 <?php
2 
3 
4 /*
5  * This file maintains the Custom Content files listed in cucmsdocs for the current credit union.
6  * The actual content is in cucmsfrags, which is what this file helps maintain.
7  *
8  * If no content exists for a given fragment the user has two choices: select from a list to import,
9  * or use the default script as a basis, if one is available.
10 
11  Template --
12  The fragment template is always stored on live in the /hcuadm directory.
13  The name given to the template file is "skel_" + script name
14  This is then used when a new fragment is added for a credit union to start as a template
15  */
16 
17  /*
18  * AMAZON CONFIG *
19 
20  * Changes: SPB 10/30/2015-- Now uses monitorView.i
21  */
22 
23  $monLibrary = dirname(__FILE__) . "/../library";
24  require_once("$monLibrary/cu_top.i");
25  require_once("$monLibrary/ck_hticket.i");
26  require_once("$monLibrary/monitorView.i");
27 
28  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
29  // ** Permissions failed
30  // ** redirect to new page
31  header("Location: /hcuadm/hcu_noperm.prg");
32  exit;
33  }
34 
35 $dms_ok = array('user_name'=>'string','cu_name'=>'string','act'=>'string','f'=>'string',
36  'cu_mxcu'=>'string','script_doc'=>'string', "language"=>"string",
37  "import_file"=>"string", "doc_id"=>"digits", "useDefault"=>"string", "showLink"=>"string",
38  "responseLasts"=>"digits", "startDate"=>"string", "endDate"=>"string", "showTab"=>"string");
39 
40 dms_import($dms_ok);
41 
42  if (isset($act)) {
43  switch($act) {
44  case "validateXML":
45  $doc = isset($script_doc) ? trim($script_doc) : "";
46  $returnArray = ValidateXML($doc);
47  header('Content-type: application/json');
48  print HCU_JsonEncode($returnArray);
49  exit;
50  break;
51  }
52  }
53 
54  function ValidateXML($script_doc) {
55  libxml_use_internal_errors(true); // Just checking if it is valid, no need to throw an error...
56  $xmlValid = simplexml_load_string($script_doc) !== false;
57 
58  libxml_use_internal_errors(false); // Back to normal...
59  return array("xmlValid" => $xmlValid);
60  }
61 
62 
63  $sectionMaster = Array(
64  'General',
65  'Products',
66  'Promos',
67  'Member Forms',
68  '3rd Party',
69  'Mobile',
70  "Secure Forms",
71  "App"
72  );
73 
74  $self = $_SERVER['SCRIPT_NAME'] . "?user_name={$user_name}&cu_name=" . urlencode($cu_name);
75 
76  $act = isset($act) ? $act : "";
77  $language = isset($language) ? $language : "en_US";
78  $showTab = isset($showTab) ? $showTab : '';
79  $selfShowTab = $showTab == "" ? "" : "&showTab=$showTab";
80  $responseLasts = isset($responseLasts) ? $responseLasts : 0;
81 
82  $baseURL = $_SERVER["SCRIPT_NAME"];
83  // Connect to the database - get the team information from the database
84  $query = "select *
85  from cuadmin
86  where user_name = '{$user_name}'";
87  $result = db_query($query, $link);
88  // Now fetch the row
89  $cuinfo_row = db_fetch_object($result);
90  $num_rows = db_num_rows($result);
91 
92  $sql = "select trim(addr1) \"cuAddrLine1\", trim(addr2) \"cuAddrLine2\",
93  trim(city) \"cuCity\", trim(state) \"cuState\", trim(zip) \"cuZip\", trim(main_phone) \"cuPhone\"
94  from cuinfo
95  where user_name = '" . prep_save($user_name, 12) . "'";
96  $sth = db_query($sql, $link);
97  $addrPhRow = db_num_rows($sth) > 0 ? db_fetch_assoc($sth, 0) : array();
98 
99  function substituteKeywords($textIn, $cu, $cuName, $server, $mxcu, $dir, $addrPhRow)
100  {
101  // Replace all occurrences of CULOGIN with user_name
102  $textIn = str_replace("CULOGIN", $cu, $textIn);
103  $textIn = str_replace("CUNAME", $cuName, $textIn);
104  $textIn = str_replace("CUSERVER", $server, $textIn);
105  $textIn = str_replace("CUMXCU", $mxcu, $textIn);
106  $textIn = str_replace("DBPREFIX", strtoupper($cu), $textIn);
107  $textIn = str_replace("HCUDIR", $dir, $textIn);
108  $textIn = str_replace("RECAPTCHASITEKEY", GetCaptchaSiteKey(), $textIn);
109 
110  $phone = HCU_array_key_value("cuPhone", $addrPhRow);
111  $addr1 = HCU_array_key_value("cuAddrLine1", $addrPhRow);
112  $addr2 = HCU_array_key_value("cuAddrLine2", $addrPhRow);
113  $city = HCU_array_key_value("cuCity", $addrPhRow);
114  $state = HCU_array_key_value("cuState", $addrPhRow);
115  $zip = HCU_array_key_value("cuZip", $addrPhRow);
116 
117  // Change from 555-555-5555 to (555) 555-5555
118  if (!empty($phone)) {
119  $phoneParts = explode("-", $phone);
120  $phone = "(" . $phoneParts[0] . ") " . $phoneParts[1] . "-" . $phoneParts[2];
121  }
122 
123  // Construct address according to signupDisclosure.
124  // If there are other uses, then we can expand how it shows up.
125  $address = array();
126  if (!empty($addr1)) {
127  $address[] = $addr1;
128  }
129  if (!empty($addr2)) {
130  $address[] = $addr2;
131  }
132  if (!(empty($city) && empty($state) && empty($zip))) {
133  $addr3 = "";
134  if (!empty($city)) {
135  $addr3 .= $city;
136  }
137  if (!empty($state)) {
138  if (!empty($addr3)) {
139  $addr3 .= ", ";
140  }
141  $addr3 .= $state;
142  }
143  if (!empty($zip)) {
144  if (!empty($addr3)) {
145  $addr3 .= " ";
146  }
147  $addr3 .= $zip;
148  }
149 
150  $address[] = $addr3;
151  }
152  $address = implode(", ", $address);
153 
154  $textIn = str_replace("CUPHONE", $phone, $textIn);
155  $textIn = str_replace("CUADDRESS", $address, $textIn);
156  return $textIn;
157  }
158 
159  function getFilePath($docInfo, $cu, $cuName, $server, $mxcu, $dir, $language, $addrPhRow)
160  {
161  $target= trim($docInfo["docstarget"]);
162  $targetName= trim($docInfo["docstargetname"]);
163  $regularName= HCU_array_key_exists("name", $docInfo) ? trim($docInfo["name"]) : ""; // There is an alias for the entry when looking up files.
164  if ($regularName == "")
165  $regularName= trim($docInfo["docsname"]);
166  $filePath= "/home/$cu/public_html/"; // All paths start with this
167  $langExt= $language == "en_US" ? "" : "_" . substr( $language, 0, 2 );
168  $substitutedName = substituteKeywords($targetName, $cu, $cuName, $server, $mxcu, $dir, $addrPhRow);
169  // Can use all the keywords that the directory system uses.
170 
171  switch($target)
172  {
173  case "public_html":
174  break; // nothing added to filepath
175  case "mobile":
176  $filePath .= "mobile/";
177  break;
178  case "": // Default directory
179  $filePath .= "bankingIncludes/$language/";
180  break;
181  default: // For now assume that anything that doesn't match public_html, mobile, or empty string goes to the default directory. That might change if we need custom file directory mappings.
182  $filePath .= "bankingIncludes/$language/";
183  }
184  if ($targetName != "")
185  {
186  if ($target == "public_html" || $target == "mobile")
187  {
188  // Find extension and insert lang ext in it.
189  $pos = strrpos($substitutedName, ".");
190  $filePath .= $pos === false ? $substitutedName . $langExt : substr_replace ($substitutedName, $langExt, $pos, 0);
191  }
192  else
193  $filePath .= $substitutedName;
194  }
195  else
196  {
197  $filePath .= $target == "public_html" || $target == "mobile" ? "$regularName${langExt}.html" : "$regularName.html";
198  }
199  return $filePath;
200  }
201 
202  /*
203  * Create an array to join the NEW content ID NAME with the CLASSIC FRAG MNTC
204  * NAME. This will be used to lookup the classic fragment and show that info
205  * on the screen as well. So it is easier for copy/paste
206  *
207  * Each Content Mntc form that will have a corresponding fragment will have an
208  * array entry. The array will consist of
209  * fragName - This the core fragment name that would be found in public_html
210  * fragESExt - this is the extension for Spanish as Polish was not setup with
211  * fragment forms. Certain forms may not have a Spanish couterpart
212  */
213  $contentFragList = Array(
214  "AddChangeAdmin" => Array("fragName" => "addchangefrm2", "fragESExt" => ""),
215  "AddChangeForm" => Array("fragName" => "addchangefrm", "fragESExt" => "_es"),
216  "AddChangeThanks" => Array("fragName" => "thanks_ac", "fragESExt" => "_es"),
217  "alertNotice" => "",
218  "alertTerms" => Array("fragName" => "alertfrag", "fragESExt" => "_es"),
219  "bpPSCUNotice" => "",
220  "ccPaymentTnx" => "",
221  "ConnectNoService" => Array("fragName" => "nobillpayfrag", "fragESExt" => "_es"),
222  "ConnectSpeedbump" => "",
223  "esNotice" => Array("fragName" => "EStatement", "fragESExt" => "_es"),
224  "esTermsStart" => Array("fragName" => "agreefrag", "fragESExt" => "_es"),
225  "esTermsStop" => Array("fragName" => "unagreefrag", "fragESExt" => "_es"),
226  "loginNotice" => Array("fragName" => "LoginNotice", "fragESExt" => "_es"),
227  "LoginPromo" => "",
228  "LogoutScreen" => "",
229  "MWI_Pagetop" => "",
230  "profileDescNotice" => "",
231  "Promo ES" => Array("fragName" => "Promo", "fragESExt" => "_es"),
232  "pwdRules" => Array("fragName" => "pwdRules", "fragESExt" => "_es"),
233  "resetMemberPwd" => Array("fragName" => "unlockfrag", "fragESExt" => "_es"),
234  "rptTransferTerms" => Array("fragName" => "repeattxfrag", "fragESExt" => "_es"),
235  "SecureForms" => "",
236  "signupfrm" => Array("fragName" => "signupfrm", "fragESExt" => "_es"),
237  "smsHelp" => Array("fragName" => "sms_helpfrag", "fragESExt" => "_es"),
238  "smsTerms" => Array("fragName" => "sms_agree", "fragESExt" => "_es"),
239  "transferNotice" => Array("fragName" => "Transfer", "fragESExt" => "_es"),
240  "TxnDownloadHelp" => Array("fragName" => "TxnDownloadHelp", "fragESExt" => "_es")
241  );
242 
243  if (true) :
244  $user_name = trim($cuinfo_row->user_name);
245  $cu_name = trim($cu_name);
246  $cu_mxcu = trim($cuinfo_row->mxcu);
247  $hcu_dir = 'banking';
248  switch (strtoupper(trim($act))):
249  case "CREATE":
250  print_top();
251  // Find the script in the array
252  $docInfo = SearchDocs( $f );
253  if ( $docInfo != null) {
254  print <<< print_html
255  <form action="$self&act=New" method="post">
256  <input type="hidden" name="f" value="{$f}">
257  <input type="hidden" name="language" value="$language">
258  <input type="hidden" name="user_name" value="$user_name">
259  <input type="hidden" name="cu_name" value="$cu_name">
260  <input type="hidden" name="cu_mxcu" value="$cu_mxcu">
261  <input type="hidden" name="hcu_dir" value="$hcu_dir">
262  <input type="hidden" name="showTab" value="$showTab">
263  <div class='k-block k-shadow content-info'>
264  <div class='k-header'>Custom Content Confirmation</div>
265  <div class='content-text'>
266  <ul>
267  <li>
268  This will create the file '{$docInfo['docsname']}'<br>
269  that is described as: {$docInfo['docsdesc']}.<br><br>
270  Are you sure this is what you want to do?
271  </li>
272  <li>
273  <input type="submit" name="btnSub" class='k-button k-primary' value="Create this">
274  <input type="button" name="btnCan" class='k-button' value="Yikes! I don't know what I am doing here!" onclick="document.location='$self$selfShowTab'">
275  </li>
276  </ul>
277  </div>
278  </div>
279  </form>
280 print_html;
281  } else {
282  print print_error();
283  }
284  print_bottom();
285  break;
286  case "UPDATE":
287  /* This action is called by an AJAX call to update the cucmsfrags file. Make sure it sends back
288  * XML in a JSON object.
289  */
290  // make sure the inputs are valid
291  if ( $useDefault != "Y" ) $useDefault = "N";
292  if ( $showLink != "Y" ) $showLink = "N";
293  if ( !ctype_digit($responseLasts) ) $responseLasts = 0;
294 
295  if ( $responseLasts > 365 ) {
296  $responseLasts = 365;
297  }
298  if (trim($startDate) == '' || trim($startDate) == 'null') {
299  $saveStartDate = 'NULL';
300  } else {
301  $testDate = date('m/d/Y', strtotime($startDate));
302  if (isdate($testDate)) {
303  $saveStartDate = " '$testDate' ";
304  } else{
305  $saveStartDate = 'NULL';
306  }
307  }
308  if (trim($endDate) == '' || trim($endDate) == 'null') {
309  $saveEndDate = 'NULL';
310  } else {
311  $testDate = date('m/d/Y', strtotime($endDate));
312  if (isdate($testDate)) {
313  $saveEndDate = " '$testDate' ";
314  } else{
315  $saveEndDate = 'NULL';
316  }
317  }
318 
319  // get the credit union for the queries
320  $cuName = strtoupper($user_name);
321 
322  // see if this is an insert or update
323  $query = "SELECT * FROM cucmsfrags WHERE docsid = $doc_id AND cu = '$cuName'";
324  $result = db_query($query, $link);
325  $row = db_fetch_assoc($result);
326 
327  if ( $row["docsid"] > 0 ) {
328  // update
329  $query = "UPDATE cucmsfrags SET fragusedefault = '$useDefault', fraguselink = '$showLink',
330  fragclearresponse = $responseLasts, fragstartdate = {$saveStartDate},
331  fragenddate = {$saveEndDate} WHERE docsid = $doc_id AND cu = '$cuName'";
332  } else {
333  // insert
334  $query = "INSERT INTO cucmsfrags (docsid, cu, fragusedefault, fraglocation, fraguselink, fragclearresponse, fragstartdate, fragenddate)
335  VALUES ($doc_id, '$cuName', '$useDefault', '', '$showLink', $responseLasts, {$saveStartDate}, {$saveEndDate})";
336  }
337 
338  db_query($query, $link);
339 
340  header('Content-Type: application/json');
341  print json_encode("");
342 
343  break;
344  case "DELETEROW":
345  /* This action is called by an AJAX call to delete an entry in the cucmsfrags file. Make sure it sends back
346  * XML in a JSON object.
347  */
348 
349  // get the credit union for the queries
350  $cuName = strtoupper($user_name);
351 
352  // do it
353  $query = "DELETE FROM cucmsfrags WHERE docsid = $doc_id AND cu = '$cuName'";
354  db_query($query, $link);
355 
356  header('Content-Type: application/json');
357  print json_encode("");
358 
359  break;
360  case "IMPORT":
361  $currFragList = array();
362  $currFragList[] = array("script"=>"alertfrag.html", "desc"=>"Alerts Terms of Use");
363  $currFragList[] = array("script"=>"nobillpayfrag.html", "desc"=>"Bill Pay ID not Found");
364  $currFragList[] = array("script"=>"agreefrag.html", "desc"=>"E-Statement START");
365  $currFragList[] = array("script"=>"unagreefrag.html", "desc"=>"E-Statement STOP");
366  $currFragList[] = array("script"=>"noestmntfrag.html", "desc"=>"E-Statement Flag Not Set");
367  $currFragList[] = array("script"=>"EStatement.html", "desc"=>"E-Statement Message");
368  $currFragList[] = array("script"=>"disclosure.html", "desc"=>"Home Banking Terms (BATCH)");
369  $currFragList[] = array("script"=>"signupfrm.html", "desc"=>"Home Banking Signup Form");
370  $currFragList[] = array("script"=>"onlinereply.html", "desc"=>"Home Banking Signup Reply");
371  $currFragList[] = array("script"=>"ipayenrollfrag.html", "desc"=>"iPay SSO Auto-Enroll Message");
372  $currFragList[] = array("script"=>"LoginNotice.html", "desc"=>"Login NCUA Notice");
373  $currFragList[] = array("script"=>"Promo.html", "desc"=>"Login Promo Page", "odd"=>"#eeeeee");
374  $currFragList[] = array("script"=>"NDTPromo.html", "desc"=>"CU-Dismissable Login Promo Page");
375  $currFragList[] = array("script"=>"memsettingsfrag.html", "desc"=>"Member Settings (BATCH)");
376  $currFragList[] = array("script"=>"addchangefrm.html", "desc"=>"Member Address Change Form");
377  $currFragList[] = array("script"=>"addchangefrm2.html", "desc"=>"Member Address Change Secure Form output");
378  $currFragList[] = array("script"=>"thanks_ac.html", "desc"=>"Member Address Change Thanks page");
379  $currFragList[] = array("script"=>"MemberActfrag.html", "desc"=>"Member Auto-Activate authentication form");
380  $currFragList[] = array("script"=>"MemberActThxfrag.html", "desc"=>"Member Auto-Activate Display new Password");
381  $currFragList[] = array("script"=>"unlockfrag.html", "desc"=>"Member Password Reset");
382  $currFragList[] = array("script"=>"lmenu.html", "desc"=>"Mobile Banking Embedded Menu");
383  $currFragList[] = array("script"=>"onldepositdisclosure.html", "desc"=>"On-Line Deposit Terms of Use");
384  $currFragList[] = array("script"=>"onldepositaddr.html", "desc"=>"On-Line Deposit Deposit Address");
385  $currFragList[] = array("script"=>"lnappCuPortal.html", "desc"=>"On-Line Loan App Portal Menu");
386  $currFragList[] = array("script"=>"pwdRules.html", "desc"=>"Password selection hints");
387 
388  // This option is NOT intended for live, but does not cause any problems to be there
389  $currFragList[] = array("script"=>"repeattxfrag.html", "desc"=>"Repeating Transfers Terms of Use");
390  $currFragList[] = array("script"=>"noRDCfrag.html", "desc"=>"Remote Deposit Capture Terms of Use / Enroll Request");
391  $currFragList[] = array("script"=>"sms_agree.html", "desc"=>"SMS Terms of Use");
392  $currFragList[] = array("script"=>"sms_helpfrag.html", "desc"=>"SMS User Help Fragment");
393  $currFragList[] = array("script"=>"Stopformfrag.html", "desc"=>"Stop Payment terms");
394  $currFragList[] = array("script"=>"TxnDownloadHelp.html", "desc"=>"Transaction Download Help");
395  $currFragList[] = array("script"=>"Transfer.html", "desc"=>"Transfer Message");
396  $currFragList[] = array("script"=>"appconfig.xml", "desc"=>"App Config file for mobile devices");
397  $currFragList[] = array("script"=>"mblnav.html", "desc"=>"MBL Navigation Menu");
398  $currFragList[] = array("script"=>"mblnav_test.html", "desc"=>"MBL Navigation Menu TEST");
399  $currFragList[] = array("script"=>"mblfooter.html", "desc"=>"MBL Footer Content");
400  $currFragList[] = array("script"=>"mblEStatement.html", "desc"=>"MBL E-Statement Message");
401  $currFragList[] = array("script"=>"mblLoginNotice.html", "desc"=>"MBL Login NCUA Notice");
402  $currFragList[] = array("script"=>"mblPromo.html", "desc"=>"MBL Login Promo Page");
403  $currFragList[] = array("script"=>"mblNDTPromo.html", "desc"=>"MBL CU-Dismissable Login Promo Page");
404  $currFragList[] = array("script"=>"mblpwdRules.html", "desc"=>"MBL Password selection hints");
405  $currFragList[] = array("script"=>"mblTxnDownloadHelp.html", "desc"=>"MBL Transaction Download Help");
406  $currFragList[] = array("script"=>"mblTransfer.html", "desc"=>"MBL Transfer Message");
407  $currFragList[] = array("script"=>"alertfrag_es.html", "desc"=>"(Spanish) Alerts Terms of Use");
408  $currFragList[] = array("script"=>"agreefrag_es.html", "desc"=>"(Spanish) E-Statement START");
409  $currFragList[] = array("script"=>"unagreefrag_es.html", "desc"=>"(Spanish)E-Statement STOP");
410  $currFragList[] = array("script"=>"noestmntfrag_es.html", "desc"=>"(Spanish) E-Statement Flag Not Set");
411  $currFragList[] = array("script"=>"EStatement_es.html", "desc"=>"(Spanish) E-Statement Message");
412  $currFragList[] = array("script"=>"mmenu_es.html", "desc"=>"(Spanish) Home Banking Menu");
413  $currFragList[] = array("script"=>"mindex_es.html", "desc"=>"(Spanish) Home Banking mindex_es.html");
414  $currFragList[] = array("script"=>"disclosure_es.html", "desc"=>"(Spanish) Home Banking Terms (BATCH)");
415  $currFragList[] = array("script"=>"signupfrm_es.html", "desc"=>"(Spanish) Home Banking Signup Form");
416  $currFragList[] = array("script"=>"onlinereply_es.html", "desc"=>"(Spanish) Home Banking Signup Reply");
417  $currFragList[] = array("script"=>"LoginNotice_es.html", "desc"=>"(Spanish) Login NCUA Notice");
418  $currFragList[] = array("script"=>"Promo_es.html", "desc"=>"(Spanish) Login Promo Page", "odd"=>"#d7e1cc");
419  $currFragList[] = array("script"=>"NDTPromo_es.html", "desc"=>"(Spanish) CU-Dismissable Login Promo Page");
420  $currFragList[] = array("script"=>"memsettingsfrag_es.html", "desc"=>"(Spanish) Member Settings (BATCH)");
421  $currFragList[] = array("script"=>"addchangefrm_es.html", "desc"=>"(Spanish) Member Address Change Form (uses English output)");
422  $currFragList[] = array("script"=>"thanks_ac_es.html", "desc"=>"(Spanish) Member Address Change Thanks page");
423  $currFragList[] = array("script"=>"MemberActfrag_es.html", "desc"=>"(Spanish) Member Auto-Activate authentication form");
424  $currFragList[] = array("script"=>"MemberActThxfrag_es.html", "desc"=>"(Spanish) Member Auto-Activate Display new Password");
425  $currFragList[] = array("script"=>"unlockfrag_es.html", "desc"=>"(Spanish) Member Password Reset");
426  $currFragList[] = array("script"=>"lmenu_es.html", "desc"=>"(Spanish) Mobile Banking Embedded Menu");
427  $currFragList[] = array("script"=>"pwdRules_es.html", "desc"=>"(Spanish) Password selection hints");
428  $currFragList[] = array("script"=>"repeattxfrag_es.html", "desc"=>"(Spanish) Repeating Transfers Terms of Use");
429  $currFragList[] = array("script"=>"sms_agree_es.html", "desc"=>"(Spanish) SMS Terms of Use");
430  $currFragList[] = array("script"=>"sms_helpfrag_es.html", "desc"=>"(Spanish) SMS User Help Fragment");
431  $currFragList[] = array("script"=>"TxnDownloadHelp_es.html", "desc"=>"(Spanish) Transaction Download Help");
432  $currFragList[] = array("script"=>"Transfer_es.html", "desc"=>"(Spanish) Transfer Message");
433  $currFragList[] = array("script"=>"mblnav_es.html", "desc"=>"(Spanish) MBL Navigation Menu");
434  $currFragList[] = array("script"=>"mblnav_es_test.html", "desc"=>"(Spanish) MBL Navigation Menu TEST");
435  $currFragList[] = array("script"=>"mblfooter_es.html", "desc"=>"(Spanish) MBL Footer Content");
436  $currFragList[] = array("script"=>"mblEStatement_es.html", "desc"=>"(Spanish) MBL E-Statement Message");
437  $currFragList[] = array("script"=>"mblLoginNotice_es.html", "desc"=>"(Spanish) MBL Login NCUA Notice");
438  $currFragList[] = array("script"=>"mblPromo_es.html", "desc"=>"(Spanish) MBL Login Promo Page", "odd"=>"#d5dfe8");
439  $currFragList[] = array("script"=>"mblNDTPromo_es.html", "desc"=>"(Spanish) MBL CU-Dismissable Login Promo Page");
440  $currFragList[] = array("script"=>"mblpwdRules_es.html", "desc"=>"(Spanish) MBL Password selection hints");
441  $currFragList[] = array("script"=>"mblTxnDownloadHelp_es.html", "desc"=>"(Spanish) MBL Transaction Download Help");
442  $currFragList[] = array("script"=>"mblTransfer_es.html", "desc"=>"(Spanish) MBL Transfer Message");
443 
444  // see which files actually exist for this credit union
445  $importList = array();
446  $importList[] = array("script"=>"", "desc"=>"Select File...");
447 
448  for ( $i = 0; $i < count( $currFragList ); $i++ ) {
449  if (file_exists($fragBasePath . $currFragList[$i]["script"])) {
450  $importList[] = $currFragList[$i];
451  }
452  }
453  print_top();
454  // show all the existing fragment files
455  print <<< print_html
456  <form action="$self&act=FileImport" method="post">
457  <input type="hidden" name="f" value="{$f}">
458  <input type="hidden" name="language" value="$language">
459  <input type="hidden" name="user_name" value="$user_name">
460  <div class='k-block k-shadow content-info'>
461  <div class='k-header'>Choose Import File</div>
462  <div class='content-text'>
463  <ul>
464  <li>
465  <select name="import_file" id="import_file">
466 print_html;
467  for ( $i = 0; $i < count( $importList ); $i++ ) {
468  print "<option value={$importList[$i]["script"]}>{$importList[$i]["desc"]}</option>";
469  }
470  print <<< print_html
471  </select>
472  </li>
473  <li>
474  <input type="submit" id="btnImportFile" class='k-button k-primary' name="btnSub" value="Import File">
475  </li>
476  </ul>
477  </div>
478  </div>
479  </form>
480 print_html;
481 
482  print_bottom();
483  break;
484  case "REFRESH":
485  print_top();
486  // Find the script in the array
487  $docInfo = SearchDocs( $f );
488  if ( $docInfo != null) {
489  print <<< print_html
490  <form action="$self&act=CreateScript" method="post">
491  <input type="hidden" name="f" value="{$f}">
492  <input type="hidden" name="language" value="$language">
493  <input type="hidden" name="user_name" value="$user_name">
494  <input type="hidden" name="cu_name" value="$cu_name">
495  <input type="hidden" name="cu_mxcu" value="$cu_mxcu">
496  <input type="hidden" name="hcu_dir" value="$hcu_dir">
497  <input type="hidden" name="showTab" value="$showTab">
498  <div class='k-block k-shadow content-info'>
499  <div class='k-header'>Refresh Custom Content Confirmation</div>
500  <div class='content-text'>
501  <ul>
502  <li>
503  This will overwrite the existing file '{$docInfo['docsname']}'<br>
504  that is described as: {$docInfo['docsdesc']}.<br><br>
505  Are you sure this is what you want to do?
506  </li>
507  <li>
508  <input type="submit" name="btnSub" class='k-button k-primary' value="Overwrite file">
509  <input type="button" name="btnCan" class='k-button' value="I changed my mind" onclick="document.location='$self$selfShowTab'">
510  </li>
511  </ul>
512  </div>
513  </div>
514  </form>
515 print_html;
516  } else {
517  print print_error();
518  }
519  print_bottom();
520  break;
521  case "CREATESCRIPT":
522  print_top();
523  // Find the script in the array
524  $docInfo = SearchDocs( $f );
525 
526  if ( $docInfo != null) {
527  $skel_file = "skel_" . $docInfo['docsname'];
528 
529  // insert the user security stuff in the url
530  $infourl = str_replace("//","//nobody:no1home@",$infourl);
531 
532  // Now read the file into memory
533  $contents = "";
534  if ($fp = fopen("$skeletonLocation/$language/$skel_file", "r")) {
535  while (!feof($fp)) {
536  $contents .= fread($fp, 1024);
537  }
538  fclose($fp);
539  }
540 
541  $contents = substituteKeywords($contents, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $addrPhRow);
542  $save_as = getFilePath($docInfo, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $language, $addrPhRow);
543 
544  $file_save = false;
545  // First if the file already exists, make sure it is readable by the owner "nobody"
546  if (file_exists($save_as))
547  chmod($save_as, 0666);
548 
549  // Make sure the file opens and saves before saying it was saved correctly
550  if ($save_fp = fopen($save_as, "w")) {
551  if (fwrite($save_fp, $contents)) {
552  $file_save = true;
553  }
554  fclose ($save_fp);
555  // Now make sure the file is read only by all, including the owner
556  chmod($save_as, 0644);
557  }
558 
559  print <<< print_html
560  <div class='k-block k-shadow content-info'>
561  <div class='k-header'>Custom Content Script Confirmation</div>
562  <div class='content-text'>
563  <ul>
564  <li>
565 print_html;
566  if ($file_save == true) {
567  print <<< print_html
568  The custom content file {$docInfo['docsname']} was refreshed and saved <b>successfully</b>.<br><br>
569  To do this choose the edit option from the <a href="$self">menu</a>.<br><br>
570  This screen will refresh in 4 seconds.
571  <script>
572  setTimeout(function(){
573  document.location = '$self$selfShowTab';
574  }, 4000);
575  </script>
576 print_html;
577  } else {
578  // Failed to open and write the file
579  print <<< print_html
580  An error occurred, the script was NOT saved successfully.<br>
581  Please try again before screaming.
582 print_html;
583  }
584  print <<< print_html
585  </li>
586  <li>
587  <input type="button" name="btnCan" class='k-button k-primary' value="Continue" onclick="document.location='$self$selfShowTab'">
588  </li>
589  </ul>
590  </div>
591  </div>
592 print_html;
593  } else {
594  print print_error();
595  }
596  print_bottom();
597  break;
598  case "DELETE":
599  print_top();
600  // Find the script in the array
601  $docInfo = SearchDocs( $f );
602  if ( $docInfo != null) {
603  print <<< print_html
604  <form action="$self&act=FileDelete" method="post">
605  <input type="hidden" name="f" value="{$f}">
606  <input type="hidden" name="language" value="$language">
607  <input type="hidden" name="user_name" value="$user_name">
608  <input type="hidden" name="cu_name" value="$cu_name">
609  <input type="hidden" name="cu_mxcu" value="$cu_mxcu">
610  <input type="hidden" name="hcu_dir" value="$hcu_dir">
611  <input type="hidden" name="showTab" value="$showTab">
612  <div class='k-block k-shadow content-info'>
613  <div class='k-header'>Delete Custom Content Confirmation</div>
614  <div class='content-text'>
615  <ul>
616  <li>
617  This will delete the existing custom content file '{$docInfo['docsname']}'<br>
618  that is described as: {$docInfo['docsdesc']}.<br><br>
619  Are you sure this is what you want to do?
620  </li>
621  <li>
622  <input type="submit" name="btnSub" class='k-button k-primary' value="Please Delete">
623  <input type="button" name="btnCan" class='k-button' value="I changed my mind" onclick="document.location='$self$selfShowTab'">
624  </li>
625  </ul>
626  </div>
627  </div>
628  </form>
629 print_html;
630  } else {
631  print print_error();
632  }
633  print_bottom();
634  break;
635  case "FILEDELETE":
636  print_top();
637  // Find the script in the array
638  $docInfo = SearchDocs( $f );
639  if ( $docInfo != null) {
640  $skel_file = "skel_" . $docInfo['docsname'];
641 
642  $delete = getFilePath($docInfo, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $language, $addrPhRow);
643 
644  $file_del = false;
645  // First if the file already exists, make sure it is readable by the owner "nobody"
646  if (file_exists($delete)) {
647  if (unlink($delete)) {
648  $file_del = true;
649  }
650  }
651 
652  print <<< print_html
653  <div class='k-block k-shadow content-info'>
654  <div class='k-header'>Delete Custom Content File</div>
655  <div class='content-text'>
656  <ul>
657  <li>
658  This will delete the existing custom content file '{$docInfo['docsname']}'<br>
659  that is described as: {$docInfo['docsdesc']}.<br><br>
660  Are you sure this is what you want to do?
661 print_html;
662  if ($file_del == true) {
663  print <<< print_html
664  The custom content file {$docInfo['docsname']} was deleted <b>successfully</b>.<br><br>
665 print_html;
666  } else {
667  // Failed to open and write the file
668  print <<< print_html
669  An error occurred, the Custom Content file was NOT deleted successfully.<br>
670  Please try again before screaming.
671 print_html;
672  }
673  print <<< print_html
674  <br/>Screen will refresh in 4 seconds.
675  </li>
676  <li>
677  <input type="button" name="btnCan" class='k-button k-primary' value="Continue" onclick="document.location='$self$selfShowTab'">
678  </li>
679  </ul>
680  </div>
681  </div>
682  <script>
683  setTimeout(function(){
684  document.location = '$self$selfShowTab';
685  }, 4000);
686  </script>
687 print_html;
688  } else {
689  print print_error();
690  }
691  print_bottom();
692  break;
693  case "PREVIEW":
694  // Find the script in the array
695  $docInfo = SearchDocs( $f );
696 
697  // get info about the credit union's content
698  $cuName = strtoupper($user_name);
699 
700  $fragInfo = SearchFrags( $f, $cuName );
701 
702  if ( $docInfo != null && $fragInfo != null ) {
703  // see if reading the default or the credit union specific file
704  if ( $fragInfo["fragusedefault"] == "Y" ) {
705  // read from the default location
706  $cu_file = "$exportLocation/$language/skel_{$docInfo['docsname']}";
707  } else {
708  $cu_file = getFilePath($docInfo, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $language, $addrPhRow);
709  }
710  $file_opened = false;
711  if (file_exists($cu_file)) {
712  printMonitorPageTop('', $homecuKendoVersion, $cloudfrontDomainName, '', '', true);
713  print <<< HTML_DEPS
714  <body id="fixedBody">
715 HTML_DEPS;
716  readfile($cu_file);
717  print <<< HTML_DEPS
718  </body>
719 HTML_DEPS;
720  } else {
721  print "File not found.";
722  }
723 
724  } else {
725  print_top();
726  // Problem opening the file
727  print print_error();
728  print_bottom();
729  }
730  break;
731  case "NEW":
732  case "EDIT":
733  case "FILEIMPORT":
734  print_top();
735 
736  $set_file = $f;
737 
738  // Find the script in the array
739  $docInfo = SearchDocs( $f );
740 
741  if ( $docInfo != null) {
742  $userWarning = "";
743  $contents = "";
744  if (strtoupper($act) == "NEW") {
745  $skel_file = "skel_" . $docInfo['docsname'];
746 
747  // insert the user security stuff in the url
748  $infourl = str_replace("//","//nobody:no1home@",$infourl);
749  // Now read the file into memory
750  if (file_exists("$skeletonLocation/$language/$skel_file")) {
751  if ($fp = fopen("$skeletonLocation/$language/$skel_file", "r")) {
752  while (!feof($fp)) {
753  $contents .= fread($fp, 1024);
754  }
755  $file_opened = true;
756  fclose($fp);
757 
758  $contents = substituteKeywords($contents, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $addrPhRow);
759  }
760  } else {
761  // if no non-English skeleton, open the English skeleton but give a warning
762  if ( $language != "en_US" ) {
763  if ($fp = fopen("$skeletonLocation/en_US/$skel_file", "r")) {
764  while (!feof($fp)) {
765  $contents .= fread($fp, 1024);
766  }
767  $file_opened = true;
768  fclose($fp);
769  $userWarning = "Language-specific skeleton file missing. Using English file as a starting point.";
770 
771  $contents = substituteKeywords($contents, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $addrPhRow);
772  } else {
773  // just give the user a blank file
774  $userWarning = "No skeleton found. Starting new file for non-English.";
775  $file_opened = TRUE;
776  }
777  } else {
778  // just give the user a blank file
779  $userWarning = "No skeleton found. Starting new file.";
780  $file_opened = TRUE;
781  }
782  }
783 
784  } else if (strtoupper($act) == "FILEIMPORT") {
785 
786  if ($fp = fopen("/home/$user_name/public_html/$import_file", "r")) {
787  while (!feof($fp)) {
788  $contents .= fread($fp, 1024);
789  }
790  $file_opened = true;
791  fclose($fp);
792  }
793 
794  } else {
795 
796  $cu_file = getFilePath($docInfo, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $language, $addrPhRow);
797 
798  $file_opened = false;
799 
800  if (file_exists($cu_file)) {
801  if ($fp = fopen($cu_file, "r")) {
802  $file_opened = true;
803  $contents = fread($fp, filesize($cu_file));
804  }
805  }
806  }
807 
808  if ($file_opened == true) {
809  $includeFragClassicText = "";
810  $fragFileName = "";
811  $showFragContents = "";
812  $bolFragFound = false;
813 
814  $showcontents = htmlspecialchars($contents);
815 
816  $textarea_TinyMCE = "";
817 
818  $www = "";
819  $mammothScript = "";
820  $sql = "select www_server from cuinfo where user_name = '" . prep_save(strtolower($user_name), 12) . "'";
821  $sth = db_query($sql, $link);
822  $www = $sth !== false ? (db_num_rows($sth) > 0 ? trim(db_fetch_row($sth, 0)[0]) : "") : "";
823  $isMammoth = in_array($www, array("www", "www4", "www3", "www5", "www6"));
824 
825  if ($isMammoth) {
826  $oldLoc = "https://$www.homecu.net/hcuadm/ContentMntc";
827  $url = "$oldLoc?user_name=" . urlencode($user_name) . "&cu_name=" . urlencode($cu_name) . "&act=edit&f=" . urlencode($f) . "&language="
828  . urlencode($language) . "&showTab=" . urlencode($showTab);
829 
830  $ch = curl_init($url);
831  curl_setopt($ch,CURLOPT_COOKIE,"HCUTicket=" . urlencode($_COOKIE['HCUTicket']));
832  curl_setopt($ch,CURLOPT_USERPWD,"nobody:no1home");
833  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); # get response as string
834 
835  $rawresp = curl_exec($ch);
836  curl_close($ch);
837 
838  $start = "<textarea id=\"script_doc\" name=\"script_doc\" rows=50 cols=90 class='mceCustomContent'>";
839  $end = "</textarea>";
840  $startPos = strpos($rawresp, $start);
841  $endPos = strpos($rawresp, $end, $startPos);
842 
843  if ($startPos !== false && $endPos !== false && $endPos > $startPos) {
844  $startMid = $startPos + strlen($start);
845  $lenMid = $endPos - $startMid;
846  $mammothScript = substr($rawresp, $startMid, $lenMid);
847  }
848 
849  $includeFragClassicText = '<textarea name="script_doc_CLASSIC" rows=50 cols=90 class="mceFragMntc" disabled="true">'
850  . $mammothScript . '</textarea></div>';
851  }
852 
853 
854  if ( $userWarning ) {
855  print "<h4><span style='background-color:yellow;'>$userWarning</span></h4>";
856  }
857 
858  if ( $docInfo["docstype"] != 3 ) {
859 
860  $contentAreaHeight = ($isMammoth ? 400 : 800);
861 
862  $kendoStyle = GetMonitorDefaultKendoStyle();
863  print <<< set_TinyMCE
864  <style>
865  .mce-btn-small button {
866  height: 22px;
867  }
868  </style>
869  <script type="text/javascript" src="https://{$cloudfrontDomainName}/homecu/js/tinymce/{$tinyMceVersion}/tinymce.min.js"></script>
870  <script type="text/javascript">
871  tinyMCE.init({
872  // General options
873  doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
874  selector : "textarea.mceCustomContent",
875  max_height: 800,
876  min_height: 160,
877  height : {$contentAreaHeight},
878  content_css: ["https://$cloudfrontDomainName/homecu/css/reset.4085.min.css","https://$cloudfrontDomainName/homecu/css/layout.4110.min.css",
879  "https://$cloudfrontDomainName/homecu/css/monitorCustom.tinyMCE.css","https://$cloudfrontDomainName/homecu/css/KendoUI/$homecuKendoVersion/kendo.common.min.css",
880  "https://$cloudfrontDomainName/homecu/css/KendoUI/$homecuKendoVersion/kendo.$kendoStyle.min.css"],
881  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"],
882  menubar: false,
883  toolbar_items_size: 'small',
884  // Theme options
885  toolbar1 : "save preview code | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
886  toolbar2 : "cut copy paste pastetext pasteword | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image | insertdatetime inserttime | forecolor backcolor",
887  toolbar3 : "table | hr removeformat visualaid | subscript superscript | charmap emoticons | spellchecker | visualchars nonbreaking | insertfile ",
888  relative_urls: false,
889  remove_script_host : false,
890  // Skin options
891  save_enablewhendirty : true,
892  save_onsavecallback : "savefile",
893  insertdatetime_formats: ["%Y.%m.%d", "%H:%M"],
894  // allow it to keep <style> tags
895  valid_children : "+body[style]",
896  valid_elements : "+*[*]"
897 
898  });
899  tinyMCE.init({
900  // General options
901  doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
902  selector : "textarea.mceFragMntc",
903  max_height: 400,
904  min_height: 160,
905  height : 300,
906  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"],
907  menubar: false,
908  toolbar_items_size: 'small',
909  // Theme options
910  toolbar1 : "code",
911  relative_urls: false,
912  remove_script_host : false,
913  // Skin options
914  save_enablewhendirty : true,
915  save_onsavecallback : "savefile",
916  insertdatetime_formats: ["%Y.%m.%d", "%H:%M"],
917 
918  // allow it to keep <style> tags
919  valid_children : "+body[style]",
920  valid_elements : "+*[*]",
921  readonly : 1
922 
923  });
924 
925  function savefile () {
926 
927  document.forms[0].submit();
928  }
929  </script>
930 set_TinyMCE;
931  }
932  $fragFileStyle = (!$isMammoth ? ';display:none' : '');
933 
934  $mammothHeader = $isMammoth && $docInfo["docstype"] != 3 ? "<div style='margin-top:20px;margin-bottom:20px;'>
935  <h6>Mammoth Script</h6>
936  </div>" : "";
937 
938  $printPreviewButton = "";
939  if ( $docInfo["docstype"] == 3 ) {
940  $printPreviewButton = '<input type="button" class="k-button" name="btnCanc" value="Preview" onclick="Preview();">';
941  }
942 
943  // If the docsname ends with XML, add functionality to validate XML. Otherwise, do the same thing: clicking on the submit submits the form.
944  $isXML = substr(trim($docInfo["docsname"]), -4) == ".xml";
945  $buttonType = $isXML ? "button" : "submit"; // Need to change this or it will submit without validation.
946 
947  print <<< print_html
948  <script language="javascript">
949  <!--
950  var win=null;
951  function Preview() {
952  $('#savefile').attr('target', '_blank');
953  var initFormAction = $('#savefile').attr('action');
954  var initAct = $('#act').val();
955  $('#savefile').attr('action', '$self&act=PREVIEWEDIT');
956  $('#act').val('PREVIEWEDIT');
957 
958  $('#savefile').submit();
959 
960  $('#savefile').attr('action', initFormAction);
961  $('#savefile').attr('target', '');
962  $('#act').val(initAct);
963 
964  }
965 print_html;
966 
967 if ($isXML) { ?>
968  var validateDS = null;
969  function InitValidateDS() {
970  validateDS = new kendo.data.DataSource({
971  transport: {
972  read: {
973  url: "<?php echo $baseURL; ?>",
974  dataType: "json",
975  type: "POST",
976  data: {
977  act: "validateXML"
978  }
979  },
980  parameterMap: function(data, type) {
981  return data;
982  }
983  },
984  schema: {
985  parse: function(results) {
986  <?php // Invalid case: open up the dialog. ?>
987  if (!results.xmlValid) {
988  var validDialog = $("#validDialog").data("kendoDialog");
989  if (validDialog == null) {
990  validDialog = $("<div id='validDialog'></div>").appendTo("body").kendoDialog({
991  title: "Invalid XML",
992  content: "Your document has invalid XML. Please correct and try again.",
993  actions: [
994  {text: "Okay", primary: true}
995  ],
996  open: function() {
997  if (window.activeWindows != null) {
998  window.activeWindows.push(this);
999  }
1000  },
1001  close: function() {
1002  if (window.activeWindows != null) {
1003  window.activeWindows.pop();
1004  }
1005  },
1006  visible: false,
1007  modal: true,
1008  width: 300
1009  }).data("kendoDialog");
1010  }
1011 
1012  validDialog.open();
1013 
1014  <?php // Valid case: go ahead and submit the form. (The default behavior of the button.) ?>
1015  } else {
1016  $("[name='savefile']").submit();
1017  }
1018  return [];
1019  }
1020  }
1021  });
1022  }
1023 
1024  var activeWindows = [];
1025  $(document).ready(function() {
1026  $("body").on("click", ".k-overlay", function() { if (activeWindows.length > 0) activeWindows[activeWindows.length - 1].close(); return false; });
1027  InitValidateDS();
1028 
1029  $("[name='btnSubmit']").click(function() {
1030  validateDS.read({script_doc: $("[name='script_doc']").val()});
1031  });
1032  });
1033 <?php }
1034 
1035 print <<< print_html
1036  // -->
1037  </script>
1038 
1039  <form name="savefile" id='savefile' action="$self&act=SaveEdit" method="post">
1040  <input type="hidden" id='act' name="act" value="SaveEdit">
1041  <input type="hidden" name="f" value="$set_file">
1042  <input type="hidden" name="showTab" value="$showTab">
1043  <input type="hidden" name="language" value="$language">
1044  <input type="$buttonType" name="btnSubmit" class='k-button k-primary' value="Save my Changes">
1045  <input type="button" name="btnCanc" class='k-button' value="Don't save my Changes" onclick="document.location='$self$selfShowTab'">
1046  {$printPreviewButton}
1047  <span style='font-weight:300; padding-left: 100px;'>File: {$docInfo['docsname']}</span>
1048  <br>
1049  <textarea id="script_doc" name="script_doc" rows=50 cols=90 class='mceCustomContent'>$showcontents</textarea>
1050  $mammothHeader
1051  {$includeFragClassicText}
1052  </form>
1053 print_html;
1054  } else {
1055  // Problem opening the file
1056  print print_error("The file could not be found ($act).");
1057  }
1058  } else {
1059  // Problem opening the file
1060  print print_error();
1061  }
1062  print_bottom();
1063  break;
1064  case "SAVEEDIT":
1065  print_top();
1066  // Find the script in the array
1067  $docInfo = SearchDocs( $f );
1068  if ( $docInfo != null) {
1069 
1070  libxml_use_internal_errors(true); // Just checking if it is valid, no need to throw an error...
1071 
1072  // If the document is a XML, validate the XML.
1073  $xmlValid = true;
1074  if (substr(trim($docInfo["docsname"]), -4) == ".xml") {
1075  $xmlValid = simplexml_load_string($script_doc) !== false;
1076  }
1077 
1078  libxml_use_internal_errors(false); // Back to normal...
1079 
1080  if ($xmlValid) {
1081  $save_as = getFilePath($docInfo, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $language, $addrPhRow);
1082 
1083  $contents = $script_doc;
1084 
1085  $file_save = false;
1086  // First if the file already exists, make sure it is readable by the owner "nobody"
1087  if (file_exists($save_as))
1088  chmod($save_as, 0666);
1089 
1090  // Make sure the file opens and saves before saying it was saved correctly
1091  if ($save_fp = fopen($save_as, "w")) {
1092  if (fwrite($save_fp, $contents)) {
1093  $file_save = true;
1094  }
1095  fclose ($save_fp);
1096  // Now make sure the file is read only by all, including the owner
1097  //chmod($save_as, 0444);
1098  // save the filepermisssions according to the way it was setup in the file information
1099  chmod($save_as, 0644);
1100  }
1101  }
1102 
1103  print <<< print_html
1104  <div class='k-block k-shadow content-info'>
1105  <div class='k-header'>Custom Content Confirmation</div>
1106  <div class='content-text'>
1107  <ul>
1108  <li>
1109 
1110 print_html;
1111  if (!$xmlValid) {
1112  print trim($docInfo["docsname"]) . "'s XML was not valid.<br><br>";
1113  } else if ($file_save == true) {
1114  print <<< print_html
1115  The script {$docInfo['docsname']} was saved <b>successfully</b>.<br><br>
1116  To do this choose the edit option from the <a href="$self$selfShowTab">menu</a></br>
1117  Screen will refresh in 4 seconds.
1118  <script>
1119  setTimeout(function(){
1120  document.location = '$self$selfShowTab';
1121  }, 4000);
1122  </script>
1123 print_html;
1124 
1125  } else {
1126  // Failed to open and write the file
1127  print <<< print_html
1128  An error occurred, the script was NOT saved successfully.<br>
1129  Please try again before screaming.
1130 print_html;
1131  }
1132  print <<< print_html
1133  </li>
1134  <li>
1135  <input type="button" name="btnCan" class='k-button k-primary' value="Continue" onclick="document.location='$self$selfShowTab'">
1136  </li>
1137  </ul>
1138  </div>
1139  </div>
1140 print_html;
1141  } else {
1142  print print_error();
1143  }
1144  print_bottom();
1145  break;
1146  case "PREVIEWEDIT":
1147 
1148  // Find the script in the array
1149  $docInfo = SearchDocs( $f );
1150 
1151  // ** DISABLE XSS Cross Site Scripting -- The script posts from previous page, without this disabled. The javascript code will not execute
1152  header("X-XSS-Protection:0");
1153  // This will allow the edit screen to have a preview, but with the credit union styles
1154 
1155  printMonitorPageTop('', $homecuKendoVersion, $cloudfrontDomainName, '', '', true);
1156  print <<< HTML_DEPS
1157  <body id="fixedBody">
1158 HTML_DEPS;
1159  print $script_doc;
1160  print <<< HTML_DEPS
1161  </body>
1162 HTML_DEPS;
1163 
1164  break;
1165  default:
1166  print_top();
1167 
1168  // figure out which lanugages to support
1169  $cuSettings = Array( "language" => Array( "en_US" => "English" ) );
1170  if ($user_name != '') {
1171  // get the settings file
1172  $loadSettingsFile = "/home/{$user_name}/public_html/bankingIncludes/production/hcuSettings.i";
1173 
1174  if (is_readable($loadSettingsFile)) {
1175  // found - Load into an array
1176  $fileContent = file_get_contents($loadSettingsFile);
1177  // decode it
1178  $cuSettings = json_decode($fileContent, true);
1179 
1180  if (json_last_error() != JSON_ERROR_NONE) {
1181  // something went wrong
1182  $cuSettings = Array( "language" => Array( "en_US" => "English" ) );
1183  }
1184  }
1185  }
1186 
1187  $cuName = strtoupper($user_name);
1188  $languages = $cuSettings["language"];
1189  $languageKeys = array_keys( $languages );
1190 
1191  // Connect to the data and retrieve the current list of custom content files
1192  $order_by = "CASE WHEN coalesce(docsmaintsection, '') = '' THEN 0 ";
1193  foreach ($sectionMaster as $sectionKey => $sectionValue) {
1194  $order_by .= " WHEN docsmaintsection = '$sectionValue' THEN $sectionKey ";
1195  }
1196  $order_by .= "ELSE 0 END, CASE WHEN cucmsfrags.docsid is null then 1 else 0 end, cucmsdocs.docsmaintsort, lower(cucmsdocs.docsname)";
1197 
1198  $query = "SELECT CASE WHEN cucmsfrags.docsid is null then 1 else 0 end, cucmsdocs.*,
1199  case when coalesce(cucmsdocs.docsmaintsection, '') = '' then '{$sectionMaster[0]}' else cucmsdocs.docsmaintsection end as docssectionname
1200  FROM cucmsdocs
1201  LEFT JOIN cucmsfrags on
1202  cucmsdocs.docsid = cucmsfrags.docsid
1203  AND cucmsfrags.cu = '$cuName'
1204  where cucmsdocs.docstype in (1,2,3)
1205  ORDER BY $order_by"; // 4 is used for estatements
1206 
1207  $result = db_query($query, $link);
1208 
1209  // loop through the choices
1210  $row = 0;
1211  $dataForGrid = array();
1212  $dataSectionGrid = array();
1213  while ($contentRow = db_fetch_assoc($result, $row)) {
1214  $row++;
1215 
1216  $entry = array();
1217  // Prepare each row for the information
1218  $entry["doc_id"] = $contentRow["docsid"];
1219 
1220  $docsName = $contentRow['docsname'];
1221  $entry["name"] = $docsName;
1222  $entry['responseType'] = $contentRow['docsresponsetype'];
1223  $entry["docstype"] = $contentRow["docstype"];
1224 
1225  $entry["desc"] = $contentRow["docsdesc"];
1226  $entry["docsmaintsection"] = $contentRow["docsmaintsection"];
1227 
1228  // see if there is an entry in the cucmsfrags file for this CU
1229  $query = "SELECT *, to_char(fragstartdate, 'mm/dd/yyyy') as formstartdate, to_char(fragenddate, 'mm/dd/yyyy') as formenddate FROM cucmsfrags WHERE docsid = {$contentRow["docsid"]} AND cu = '$cuName'";
1230  $resultFragEntry = db_query($query, $link);
1231 
1232  $fragRow = db_fetch_assoc( $resultFragEntry );
1233 
1234  if ( $fragRow["docsid"] > 0 ) {
1235  $entry["frag"] = true;
1236  $entry["useDefault"] = $fragRow["fragusedefault"];
1237  $entry["showLink"] = $fragRow["fraguselink"];
1238  $entry["responseLasts"] = $fragRow["fragclearresponse"];
1239  $entry["startDate"] = $fragRow["formstartdate"];
1240  $entry["endDate"] = $fragRow["formenddate"];
1241  } else {
1242  $entry["frag"] = false;
1243  $entry["useDefault"] = "";
1244  $entry["showLink"] = "";
1245  $entry["responseLasts"] = "";
1246  $entry["startDate"] = "";
1247  $entry["endDate"] = "";
1248  }
1249 
1250  // New options
1251  $entry["docstarget"]= $contentRow["docstarget"];
1252  $entry["docstargetname"]= $contentRow["docstargetname"];
1253 
1254  // loop through the language choices to see if file exists
1255  $langList = array();
1256  for ( $i = 0; $i < count( $languageKeys ); $i++ ) {
1257  $lang = $languageKeys[$i];
1258 
1259  $filePathName = getFilePath($entry, $user_name, $cu_name, $home_host, $cu_mxcu, $hcu_dir, $lang, $addrPhRow);
1260 
1261  $fileExists = file_exists( $filePathName );
1262 
1263  $entry[$lang] = $fileExists;
1264  }
1265 
1266  // add to the JSON object to hold this info
1267  $dataForGrid[] = $entry;
1268  $dataSectionGrid[$contentRow['docssectionname']][] = $entry;
1269  }
1270 
1271  // order the grid alphabetically, case insensitive
1272  usort( $dataForGrid, "cmp" );
1273 
1274 /*
1275  * Set up javascript for the grid. Use a funcation template for the language field and supply links based on
1276  * whether the file exists or not. The number of language fields depends on the $languages array.
1277  *
1278  */
1279  ?>
1280  <!-- KENDO UI CSS Includes -->
1281  <link rel="stylesheet" media="all" type="text/css" href="https://<?php echo $cloudfrontDomainName; ?>/homecu/css/reset.css" />
1282 
1283  <link href="https://<?php echo $cloudfrontDomainName; ?>/homecu/css/KendoUI/<?php echo $homecuKendoVersion; ?>/kendo.common.min.css" rel="stylesheet">
1284  <link href="https://<?php echo $cloudfrontDomainName; ?>/homecu/css/KendoUI/<?php echo $homecuKendoVersion; ?>/kendo.<?php echo GetMonitorDefaultKendoStyle(); ?>.min.css" rel="stylesheet">
1285  <link href="/monitor/css/monitor-core.css" rel="stylesheet">
1286 
1287  <!-- Required Jquery min -->
1288  <script type="text/javascript" src="https://<?php echo $cloudfrontDomainName; ?>/jquery/js/jquery-1.10.2.min.js.gz"></script>
1289 
1290  <!-- KENDO UI JS scripts -->
1291  <script src="https://<?php echo $cloudfrontDomainName; ?>/homecu/js/KendoUI/<?php echo $homecuKendoVersion; ?>/kendo.web.min.js.gz"></script>
1292 
1293  <div style='font-size:12px; width:1000px; overflow: hidden;'>
1294 
1295  <div id="contentStrip">
1296  <ul>
1297  <?php reset($sectionMaster);
1298  foreach ($sectionMaster as $sectionKey => $sectionValue) : ?>
1299  <li <?php if ($sectionKey == 0) { echo 'class="k-state-active"'; } ?>>
1300  <?php echo $sectionValue; ?>
1301  </li>
1302  <?php endforeach; ?>
1303  </ul>
1304  </div>
1305  <div id="contentFiles" class="k-content"></div>
1306  <div id="progressShow" style="z-index:20000;"></div>
1307 
1308  </div>
1309  <script type="text/javascript">
1310  var gridSource = <?php echo json_encode($dataForGrid); ?>;
1311  var gridSectionSource = <?php echo json_encode($dataSectionGrid); ?>;
1312  var wnd;
1313 
1314  var containsFilter =
1315  {
1316  extra : false,
1317  operators : { string : { contains : "Contains"}},
1318  ui : function( element )
1319  {
1320  var parent = element.parent();
1321  while( parent.children().length > 1 )
1322  $(parent.children()[0]).remove( );
1323 
1324  parent.prepend( "<input data-bind=\"value:filters[0].value\" class=\"k-textbox\" type=\"text\">" );
1325  }
1326  }
1327  var gridColumnList = [
1328  { title: "", width: "80px", scrollable: false },
1329  { field: "name", title: "Doc Name", width: "120px", filterable: containsFilter, scrollable: false },
1330  { field: "desc", title: "Description", width: "200px", filterable: containsFilter },
1331  { field: "useDefault", title: "Use Def", width: "50px", filterable: false },
1332  { field: "showLink", title: "Show Link", width: "50px", filterable: false },
1333  { field: "responseLasts", title: "Clear", width: "50px", filterable: false },
1334  <?php
1335  // put in a field for each language
1336  for ( $i = 0; $i < count( $languageKeys ); $i++ ) {
1337  $fieldName = $languageKeys[$i];
1338  $title = $languages[$languageKeys[$i]];
1339  ?>
1340  { field: "<?php echo $fieldName ?>", title: "<?php echo $title ?>", width:"95px", filterable: false },
1341  <?php
1342  }
1343  ?>
1344  { field: "startDate", title: "Start Date", format: "{0:MM/dd/yyyy}", hidden: true},
1345  { field: "endDate", title: "End Date", format: "{0:MM/dd/yyyy}", hidden: true},
1346  { field: "responseType", hidden: true },
1347  { title: "", width: "90px" }
1348  ];
1349 
1350  var initTables = function(e) {
1351  <?php reset($sectionMaster);
1352  foreach ($sectionMaster as $sectionKey => $sectionValue) : ?>
1353 
1354  $('#<?php echo str_replace(' ', '_', $sectionValue); ?>-grid').kendoGrid({
1355  dataSource: gridSectionSource['<?php echo $sectionValue; ?>'],
1356  sortable: {
1357  mode: "single",
1358  allowUnsort: true
1359  },
1360  scrollable: true,
1361  selectable: false,
1362  editable: {
1363  mode: "popup",
1364  confirmation: "Are you sure you want to delete this record?",
1365  template: kendo.template($("#popup-editor").html())
1366  },
1367  filterable: { contains: true },
1368  columns: gridColumnList,
1369  change: function(e) {
1370  var selectedRow = this.dataItem(this.select());
1371  // allow the user to edit the row
1372  this.editRow(this.select());
1373  },
1374  remove: function(e) {
1375  var that = this;
1376  var rowData = JSON.parse(JSON.stringify(e.model));
1377  var postData = {};
1378  postData["act"] = "DELETEROW";
1379  postData["showTab"] = '<?php echo $sectionKey; ?>';
1380  postData["user_name"] = "<?php echo $user_name ?>";
1381  postData["doc_id"] = rowData["doc_id"];
1382  postData["cu_name"] = "<?php echo $cu_name ?>";
1383 
1384  var parameters = "";
1385  $.each(postData, function( index, object ) {
1386  if ( parameters.length > 0 ) parameters += "&";
1387  parameters += index + "=" + object;
1388  });
1389 
1390  kendo.ui.progress($('#progressShow'), true);
1391  $.ajax({
1392  url: '<?php echo $baseURL ?>',
1393  type: 'POST',
1394  data: parameters,
1395  success: function (data) {
1396 
1397  location.href = "<?php echo $self ?>&showTab=<?php echo $sectionKey; ?>";
1398  },
1399  error: function (data) {
1400  kendo.ui.progress($('#progressShow'), false);
1401  alert('Some error happened.');
1402  that.cancelRow();
1403  }
1404  });
1405  },
1406 
1407  save: function(e) {
1408  // ** Validate some things
1409 
1410  switch (e.model.responseType) {
1411  case "A":
1412  case "E":
1413  case "P":
1414  if ((e.model.endDate === null ? 0 : e.model.endDate.toString().length) !== 0
1415  || (e.model.startDate === null ? 0 : e.model.startDate.toString().length) !== 0) {
1416 
1417  // Dates are visible, verify the values
1418  if ((e.model.endDate === null ? 0 : e.model.endDate.toString().length) === 0
1419  || (e.model.startDate === null ? 0 : e.model.startDate.toString().length) === 0) {
1420  alert("When setting date values, both dates must be entered.");
1421  e.preventDefault();
1422  return false;
1423  } else if (e.model.endDate <= e.model.startDate) {
1424  alert("The ending date must be greater than start date.");
1425  e.preventDefault();
1426  return false;
1427  }
1428  }
1429  break;
1430  }
1431 
1432  var that = this;
1433  var postData = JSON.parse(JSON.stringify(e.model));
1434  postData["act"] = "UPDATE";
1435  postData["showTab"] = '<?php echo $sectionKey; ?>';
1436  postData["user_name"] = "<?php echo $user_name ?>";
1437  postData["cu_name"] = "<?php echo $cu_name ?>";
1438 
1439  // make sure the values are accurate
1440  if ( postData["responseLasts"] > 365 ) postData["reponseLasts"] = 365;
1441 
1442  var idUpdated = postData["doc_id"];
1443  var parameters = "";
1444  $.each(postData, function( index, object ) {
1445  if ( parameters.length > 0 ) parameters += "&";
1446  parameters += index + "=" + object;
1447  });
1448 
1449  kendo.ui.progress($('#progressShow'), true);
1450 
1451  $.ajax({
1452  url: '<?php echo $baseURL ?>',
1453  type: 'POST',
1454  data: parameters,
1455  success: function (data, status, xhr) {
1456  // find the document and update the changes
1457  $.each(gridSectionSource['<?php echo $sectionValue; ?>'], function( index, object ) {
1458  if ( object["doc_id"] == idUpdated ) {
1459  object["useDefault"] = postData["useDefault"];
1460  object["showLink"] = postData["showLink"];
1461  object["responseLasts"] = postData["responseLasts"];
1462  // since found it, stop looking
1463  return false;
1464  }
1465  });
1466 
1467  // if a new item, refresh
1468  if ( !postData["frag"] ) {
1469  location.href = "<?php echo $self ?>&showTab=<?php echo $sectionKey; ?>";
1470  } else {
1471  that.refresh();
1472  }
1473  },
1474  error: function (xhr, status, error) {
1475  alert('Some error happened:' + error);
1476  that.cancelRow();
1477  },
1478  complete: function( xhr, status ) {
1479  kendo.ui.progress($('#progressShow'), false);
1480  }
1481  });
1482  },
1483  dataBound: function () {
1484  $("table tbody tr").hover(
1485  function() {
1486  $(this).toggleClass("k-state-hover");
1487  }
1488 
1489  );
1490  },
1491  rowTemplate: kendo.template($("#rowTemplate").html()),
1492  altRowTemplate: kendo.template($("#altRowTemplate").html())
1493 
1494 
1495 
1496  });
1497 
1498  <?php endforeach; ?>
1499 }
1500  $(document).ready(function() {
1501  $('#contentStrip').kendoTabStrip({
1502  animation: { open: { effects: "fadeIn" } },
1503  dataTextField: "sectionValue",
1504  dataContentField: "sectionContent",
1505  dataSource: [
1506  <?php reset($sectionMaster);
1507  foreach ($sectionMaster as $sectionKey => $sectionValue) : ?>
1508  <?php echo ($sectionKey > 0 ? ', ' : ''); ?>
1509  {
1510  sectionValue: "<?php echo $sectionValue; ?>",
1511  sectionContent: '<div id="<?php echo str_replace(' ', '_', $sectionValue); ?>-grid"></div>'
1512  }
1513  <?php endforeach; ?>
1514  ],
1515  select: initTables
1516 
1517  }).data('kendoTabStrip').select(0);
1518 
1519 
1520 
1521  wnd = $("#modalDeleteWindow").kendoWindow({
1522  title: "Delete confirmation",
1523  modal: true,
1524  visible: false,
1525  resizable: false,
1526  width: 300
1527  }).data("kendoWindow");
1528 
1529  <?php if ($showTab != ''): ?>
1530  $('#contentStrip').data('kendoTabStrip').select(<?php echo $showTab; ?>);
1531 
1532  <?php endif; ?>
1533  });
1534  function HandleActions(selectObject, action, docId, language) {
1535  var cu = "<?php echo trim($user_name) ?>";
1536 
1537  if ( action === "edit" ) {
1538  location.href="<?php echo $self?>&act=edit&f=" + docId + "&user_name=" + cu + "&language=" + language + "&showTab=" + $('#contentStrip').data('kendoTabStrip').select().index();
1539  }
1540  else if ( action === "preview" ) {
1541  OpenPreview("<?php echo $self?>&act=preview&f=" + docId + "&user_name=" + cu + "&language=" + language);
1542 
1543  // reset the action
1544  $(selectObject).val( '' );
1545  var test = this;
1546  var dropdownlist = $("#dropdownlist").data("kendoDropDownList");
1547 
1548  var test2 = 'string';
1549  }
1550  else if ( action === "refresh" ) {
1551  location.href="<?php echo $self?>&act=refresh&f=" + docId + "&user_name=" + cu + "&language=" + language + "&showTab=" + $('#contentStrip').data('kendoTabStrip').select().index();
1552  }
1553  else if ( action === "delete" ) {
1554  location.href="<?php echo $self?>&act=delete&f=" + docId + "&user_name=" + cu + "&language=" + language + "&showTab=" + $('#contentStrip').data('kendoTabStrip').select().index();
1555  }
1556  else if ( action === "create" ) {
1557  location.href="<?php echo $self?>&act=create&f=" + docId + "&user_name=" + cu + "&language=" + language + "&showTab=" + $('#contentStrip').data('kendoTabStrip').select().index();
1558  }
1559  else if ( action === "import" ) {
1560  location.href="<?php echo $self?>&act=import&f=" + docId + "&user_name=" + cu + "&language=" + language + "&showTab=" + $('#contentStrip').data('kendoTabStrip').select().index();
1561  }
1562  return;
1563  }
1564 
1565  function OpenPreview(url) {
1566  $(document.body).append('<div id="previewWindow"></div>');
1567  $('#previewWindow').kendoWindow({
1568  visible: false,
1569  actions: [ "Close" ],
1570  iframe: true,
1571  modal: true,
1572  title: "Preview",
1573  resizable: true,
1574  width: 800,
1575  height: 600,
1576  close: function(e) {
1577  var dialog = $("#previewWindow").data("kendoWindow");
1578  dialog.destroy();
1579  },
1580  content: url
1581  });
1582  // doing it this way for IE8
1583  var dialog = $("#previewWindow").data('kendoWindow');
1584  dialog.center().open();
1585  }
1586 
1587  function StartImport(url) {
1588  $(document.body).append('<div id="importWindow"></div>');
1589  $('#importWindow').kendoWindow({
1590  visible: false,
1591  actions: [ "Close" ],
1592  iframe: true,
1593  modal: true,
1594  title: "Import existing Fragment file",
1595  resizable: true,
1596  width: 700,
1597  height: 450,
1598  close: function(e) {
1599  var dialog = $("#importWindow").data("kendoWindow");
1600  dialog.destroy();
1601  },
1602  content: url
1603  });
1604  // doing it this way for IE8
1605  var dialog = $("#importWindow").data('kendoWindow');
1606  dialog.center().open();
1607  }
1608  </script>
1609  <script id="rowTemplate" type="text/x-kendo-tmpl">
1610  # var rowBgColor = (!frag ? 'background-color: \#CBCBCB;' : (name.substring(0, 3) == 'NOTmbl' ? 'background-color: \#E0EAFF;' : '')); #
1611  # var btnText = (!frag ? 'Add' : 'Edit'); #
1612  <tr data-uid="#= uid #" style="#= rowBgColor #">
1613  <td # if ( !frag) { # style="background-color: \#FFF0F0;" # } #>
1614  <a class="k-button k-button-icontext k-grid-edit" href="\#">
1615  <span class="k-icon k-i-edit"></span>#= btnText #
1616  </a>
1617  </td>
1618  <td>#= name #</td>
1619  <td>#= desc #</td>
1620  <td>#= useDefault #</td>
1621  <td>#= showLink #</td>
1622  <td>#= responseLasts #</td>
1623 <?php
1624  // variable number of fields based on languages found
1625  for ( $i = 0; $i < count( $languageKeys ); $i++ ) {
1626 ?>
1627  <td>
1628  # if ( frag && useDefault == "Y" ) { #
1629  <select onchange='if (this.value) { HandleActions( this, this.value, "#: doc_id #", "<?php echo $languageKeys[$i] ?>" ); }'>
1630  <option value="">Action...</option>
1631  <option value="preview">Preview</option>
1632  </select>
1633  # } else if ( frag && <?php echo $languageKeys[$i] ?> ) { #
1634  <select onchange='if (this.value) { HandleActions( this, this.value, "#: doc_id #", "<?php echo $languageKeys[$i] ?>" ); }'>
1635  <option value="">Action...</option>
1636  <option value="edit">Edit</option>
1637  <option value="preview">Preview</option>
1638  <option value="refresh">Refresh</option>
1639  <option value="delete">Delete</option>
1640  </select>
1641  # } else if ( frag ) { #
1642  <select onchange='if (this.value) { HandleActions( this, this.value, "#: doc_id #", "<?php echo $languageKeys[$i] ?>" ); }'>
1643  <option value="">Missing...</option>
1644  <option value='create'>Create</option>
1645  <option value='import'>Import</option>
1646  </select>
1647  # } else { #
1648  &nbsp;
1649  # } #
1650  </td>
1651 <?php
1652  }
1653 ?>
1654  <td>
1655  # if ( frag ) { #
1656  <a class="k-button k-button-icontext k-grid-delete" href="\#">
1657  <span class="k-icon k-i-delete"></span>Delete
1658  </a>
1659  # } else { #
1660  &nbsp;
1661  # } #
1662  </td>
1663  </tr>
1664  </script>
1665  <script id="altRowTemplate" type="text/x-kendo-tmpl">
1666  # var rowBgColor = (!frag ? 'background-color: \#CBCBCB;' : (name.substring(0, 3) == 'NOTmbl' ? 'background-color: \#BBCCF0;' : '')); #
1667  # var btnText = (!frag ? 'Add' : 'Edit'); #
1668  <tr class="k-alt" data-uid="#= uid #" style="#= rowBgColor #">
1669  <td # if ( !frag ) { # style="background-color: \#FFF0F0;" # } #>
1670  <a class="k-button k-button-icontext k-grid-edit" href="\#">
1671  <span class="k-icon k-i-edit"></span>#= btnText #
1672  </a>
1673  </td>
1674  <td>#= name #</td>
1675  <td>#= desc #</td>
1676  <td>#= useDefault #</td>
1677  <td>#= showLink #</td>
1678  <td>#= responseLasts #</td>
1679 <?php
1680  // variable number of fields based on languages found
1681  for ( $i = 0; $i < count( $languageKeys ); $i++ ) {
1682 ?>
1683  <td>
1684  # if ( frag && useDefault == "Y" ) { #
1685  <select onchange='if (this.value) { HandleActions( this, this.value, "#: doc_id #", "<?php echo $languageKeys[$i] ?>" ); }'>
1686  <option value="">Action...</option>
1687  <option value="preview">Preview</option>
1688  </select>
1689  # } else if ( frag && <?php echo $languageKeys[$i] ?> ) { #
1690  <select onchange='if (this.value) { HandleActions( this, this.value, "#: doc_id #", "<?php echo $languageKeys[$i] ?>" ); }'>
1691  <option value="">Action...</option>
1692  <option value="edit">Edit</option>
1693  <option value="preview">Preview</option>
1694  <option value="refresh">Refresh</option>
1695  <option value="delete">Delete</option>
1696  </select>
1697  # } else if ( frag ) { #
1698  <select onchange='if (this.value) { HandleActions( this, this.value, "#: doc_id #", "<?php echo $languageKeys[$i] ?>" ); }'>
1699  <option value="">Missing...</option>
1700  <option value='create'>Create</option>
1701  <option value='import'>Import</option>
1702  </select>
1703  # } else { #
1704  &nbsp;
1705  # } #
1706  </td>
1707 <?php
1708  }
1709 ?>
1710  <td>
1711  # if ( frag ) { #
1712  <a class="k-button k-button-icontext k-grid-delete" href="\#">
1713  <span class="k-icon k-i-delete"></span>Delete
1714  </a>
1715  # } else { #
1716  &nbsp;
1717  # } #
1718  </td>
1719  </tr>
1720  </script>
1721  <script id="popup-editor" type="text/x-kendo-template">
1722  <h3 style='text-align:center;'>Edit Custom Content Entry</h3>
1723  <span style='text-align:center;'>
1724  <table style='width:100%;'>
1725  <tr>
1726  <td class="edit_label"><label>Name:</td><td class='edit_entry'><input name="name" readonly /></label></td>
1727  </tr>
1728  <tr>
1729  <td class="edit_label"><label for="useDefault">Use Default:</label></td><td class='edit_entry'><input type="radio" name="useDefault" id="useDefault" value="Y" />Yes <input type="radio" name="useDefault" id="useDefault" value="N" />No </td>
1730  </tr>
1731  <tr>
1732  <td class="edit_label"><label for="showLink">Show Button Link:</label></td><td class='edit_entry'><input type="radio" name="showLink" id="showLink" value="Y" />Yes <input type="radio" name="showLink" id="showLink" value="N" />No </td>
1733  </tr>
1734  <tr>
1735  <td class="edit_label"><label for="responseLasts">Auto-Clear Response:</label></td><td class='edit_entry'><input data-role="numerictextbox" data-decimals=0 data-format="\\#" min='0' max='365' name="responseLasts" id="responseLasts" style="width:75px"/></td>
1736  </tr>
1737  # var localResponseType = data.responseType; #
1738  # switch (data.responseType) {
1739  case "E":
1740  case "A":
1741  case "P": #
1742  <tr>
1743  <td class="edit_label"><label for="startDate">Start Date:</label></td><td class='edit_entry'><input data-role="datepicker" data-format="MM/dd/yyyy" name="startDate" id="startDate" /></td>
1744  </tr>
1745  <tr>
1746  <td class="edit_label"><label for="endDate">End Date:</label></td><td class='edit_entry'><input data-role="datepicker" data-format="MM/dd/yyyy" name="endDate" id="endDate" /></td>
1747  </tr>
1748  # break; #
1749  # } #
1750 
1751  </table>
1752  </span>
1753  </script>
1754  <style>
1755  .edit_label { text-align: right; font-weight: bold; width: 50%; }
1756  .edit_entry { text-align: left; }
1757  </style>
1758 <?php
1759 
1760 
1761  print_bottom();
1762  endswitch;
1763  else:
1764  print <<< print_html
1765 
1766 print_html;
1767  endif;
1768 
1769 
1770 
1771  function print_top() {
1772  $title= "Custom Content Management";
1773  global $homecuKendoVersion, $cloudfrontDomainName; // From cu_top
1774  printMonitorPageTop($title, $homecuKendoVersion, $cloudfrontDomainName);
1775 ?>
1776  <style>
1777  .content-info {
1778  min-width: 250px;
1779  max-width: 500px;
1780  min-height: 150px;
1781  font-size: 1.2em;
1782  margin: 0 auto;
1783  }
1784  .content-info ul,
1785  .content-info li {
1786  list-style: none;
1787  padding: 0;
1788  margin: 0;
1789  }
1790  .content-info .content-text {
1791  padding: 10px
1792  }
1793 
1794  .content-info .k-header {
1795  text-align: center;
1796  }
1797  </style>
1798  <?php
1799  printMonitorPageMiddle($title, null, true);
1800  }
1801 
1802 
1803  function print_bottom() {
1804  printMonitorPageBottom();
1805  }
1806  function print_error($optionalMsg = "") {
1807  global $self, $selfShowTab;
1808 
1809  $optionalMsg .= ($optionalMsg != '' ? '<br/>' : '');
1810  $printError = <<< print_html
1811  <div class='k-block k-shadow content-info'>
1812  <div class='k-header'>Custom Content Error</div>
1813  <div class='content-text'>
1814  <ul>
1815  <li>
1816  $optionalMsg
1817  An unexpected error was raised when processing your selection. Please go back to the <a href="$self$selfShowTab">menu</a><br>
1818  and select again.<br/>
1819  Screen will refresh in 4 seconds.
1820  </li>
1821  </ul>
1822  </div>
1823  </div>
1824  <script>
1825  setTimeout(function(){
1826  document.location = '$self$selfShowTab';
1827  }, 4000);
1828  </script>
1829 print_html;
1830  return $printError;
1831  }
1832  function SearchDocs( $docId ) {
1833  global $link;
1834 
1835  // Connect to the data and retrieve the current list of custom content files
1836  $query = "SELECT *
1837  FROM cucmsdocs d
1838  WHERE docsid = $docId";
1839 
1840  $result = db_query($query, $link);
1841 
1842  $contentRow = db_fetch_assoc($result);
1843  if ( $contentRow["docsid"] > 0 )
1844  return $contentRow;
1845 
1846  return null;
1847  }
1848 
1849  function SearchFrags( $docId, $cuCode ) {
1850  global $link;
1851 
1852  // Connect to the data and retrieve the current list of custom content files
1853  $query = "SELECT *
1854  FROM cucmsfrags f
1855  WHERE docsid = $docId
1856  AND cu = '$cuCode'";
1857 
1858  $result = db_query($query, $link);
1859 
1860  $contentRow = db_fetch_assoc($result);
1861  if ( $contentRow["docsid"] > 0 )
1862  return $contentRow;
1863 
1864  return null;
1865  }
1866 
1867 function cmp($a, $b)
1868 {
1869  return strcasecmp($a["name"], $b["name"]);
1870 }