Odyssey
hcuProfileRequire.prg
1 <?php
2  /*
3  * File: hcuProfileRequire
4  *
5  * Purpose: Handle the client-side setting up of the user's profile information. Gather it all
6  * at once and then submit it. Allow the user to test the Alias if there is one. System
7  * flags will be tested to see what needs to be updated. If the flag specifies it is necessary
8  * then that item/entry is required. All need to pass validation for any to be updated.
9  *
10  * Note: Don't show the menu buttons because the user should not do anything else until they are
11  * set up successfully.
12  */
13 
14  // ** SET SCRIPT LEVEL VARIABLES
15  $serviceShowInfo = true;
16  $serviceLoadMenu = true;
17  $serviceShowMenu = false;
18  $serviceSkipSecurity = true; // so hcuService doesn't try to call us again
19 
20  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
21  require_once(dirname(__FILE__) . '/../library/hcuService.i');
22 
23  // ** INSERT BUSINESS LOGIC FOR THIS FORM
24  // see if retry cookie has run out or expired
25  $securePass = HCU_array_key_exists("securePass", $_COOKIE) ? $_COOKIE["securePass"] : "";
26  $bailout = "{$HB_ENV["loginscript"]}?{$HB_ENV["cuquery"]}";
27 
28  $remainTries = null;
29  $timeExpires = null;
30  $testValidity = null;
31  $parts = array("remain" => "", "until" => "", "check" => "");
32  if ( !strlen( $securePass ) ) {
33  // remove the securePass cookie since they are done with it
34  HCU_setcookie_env($HB_ENV['SYSENV'], "securePass", "", time() - 60);
35 
36  // parse the parts
37  parse_str( $securePass, $parts );
38  $remainTries = HCU_array_key_exists("remain", $parts) ? $parts["remain"] : "";
39  $timeExpires = HCU_array_key_exists("until", $parts) ? $parts["until"] : "";
40  $testValidity = md5( $remainTries . $timeExpires . $HB_ENV["secret"] );
41  }
42 
43 
44  if ( (!$remainTries) || ($timeExpires < time()) || ( $testValidity != $parts["check"] ) ) {
45  // remove the securePass cookie since they are done with it
46  HCU_setcookie_env($HB_ENV['SYSENV'], "securePass", "", time() - 60);
47  }
48 
49 
50  // get any passed variables
51  $dms_ok = array( "action" => "string", "chkSecure" => "string", "emailAddress" => "string", "emailValid" => "string",
52  "profileEgenl" => "string", "profileEmailAlerts" => "string", "security_confidence" => "string",
53  "challengeQuestion" => "prefix_s", "response" => "prefix_s", "estatementStart" => "string",
54  "profilePasswordCurr" => "string", "profilePasswordNew1" => "string", "profilePasswordNew2" => "string",
55  "profileAlias1" => "string", "profileAlias2" => "string", "estatementNoticeId" => "string", "security_phones" => "string" );
56 
57  HCU_ImportVars($HB_ENV, 'HCUPOST', $dms_ok);
58 
59  $returnScript = $HB_ENV["loginpath"] . "/hcuAccounts.prg?" . $HB_ENV["cuquery"];
60 
61  $action = HCU_array_key_value('action', $HB_ENV["HCUPOST"]);
62  // handle any AJAX requests (before any output)
63  if ( $action == "test_alias" ) {
64  header('Content-Type: application/json');
65 
66  // get the user alias to test
67  $userAlias = $_POST["alias"];
68 
69  // some basic tests
70  $aryReply = array( "result" => FALSE, "message" => $MC->msg( "Error" , HCU_DISPLAY_AS_JS) );
71 
72  // * Validate user alias length
73  if ( strlen( $userAlias ) >= 0 && strlen( $userAlias ) < 6 ) {
74  $aryReply = array( "result" => FALSE, "message" => $MC->msg('Username too short', HCU_DISPLAY_AS_JS) );
75  } else if ( strlen( $userAlias ) > 5 && !check_alias_format( $userAlias ) ) {
76  // * Validate the useralias is correct format
77  $aryReply = array( "result" => FALSE, "message" => $MC->msg('Username appears invalid', HCU_DISPLAY_AS_JS) );
78  } else if ( check_alias_available( $dbh, $HB_ENV, $userAlias ) ) {
79  $aryReply = array( "result" => TRUE, "message" => $MC->msg( "Available", HCU_DISPLAY_AS_JS) );
80  } else {
81  $aryReply = array( "result" => FALSE, "message" => $MC->msg( "Username not available" , HCU_DISPLAY_AS_JS) );
82  }
83 
84  print HCU_JsonEncode($aryReply);
85 
86  exit;
87  } else if ( $action == "cancel_profile" ) {
88  // * Set the sC ticket value (2 = update later)
89  $option = "sC=2";
90  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'], $option );
91  $_COOKIE['Ticket'] = $newTicket;
92 
93  // remove the securePass cookie since they gave up on their attempt
94  HCU_setcookie_env($HB_ENV['SYSENV'], "securePass", "", time() - 60);
95 
96  if ( $HB_ENV["platform"] == "APP" || $HB_ENV["platform"] == "ADA" ) {
97  // set up the parameters based on what changed
98  if ( $newTicket != "" ) {
99  $paramsForApps = array( "newTicket" => urlencode( $newTicket ) );
100 
101  $paramsJSON = HCU_JsonEncode($paramsForApps);
102  ?>
103  <html>
104  <head>
105  <script type="text/javascript">
106  var appInfo = '<?php echo $paramsJSON; ?>';
107 
108  <?php if ( $HB_ENV["platform"] == "ADA" ) : ?>
109  AndroidController.notifyCommand("NEW_TICKET_COOKIE", appInfo);
110  <?php elseif ( $HB_ENV["platform"] == "APP" ) : ?>
111  var postObject = {
112  body: {
113  cmd: "NEW_TICKET_COOKIE",
114  params: appInfo
115  }
116  };
117  window.webkit.messageHandlers.interOp.postMessage(postObject);
118  <?php endif ?>
119 
120  </script>
121  </head>
122  <body>
123  <form method="post" id="formCancelContinue" name="formCancelContinue" action='<?php echo $returnScript ?>'>
124  </form>
125  <script type="text/javascript">
126  // set up a re-direct
127  document.formCancelContinue.submit();
128  </script>
129  </body>
130  </html>
131  <?php
132  }
133  } else {
134  header("Location: {$returnScript}");
135  }
136 
137  exit;
138  }
139 
140  // ** INCLUDE PRE CONTENT SCRIPT
141  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
142 
143  // set up defaults
144  $rulesURLNoticeOnly = "";
145 
146  // Is the user alias required? Only ask for it if required.
147  $aliasRequired = ($HB_ENV['Fset2'] & GetFlagsetValue("CU2_ALIAS_REQ")) == GetFlagsetValue("CU2_ALIAS_REQ");
148 
149  // only update the password if it is required
150  $pwdRequired = ($HB_ENV['Ffchg'] == "Y");
151 
152  $pwdRequirements = array();
153  $pwdConfigJSON = "{}"; // Set to empty json array by default
154  if ( $pwdRequired ) {
155  // allowed special characters (this needs to also match in hucProfile.data and hcuProfileRequire)
156  $specialCharacters = Get_PwdSpecialCharacters();
157 
158  // read the password requirements, if any
159  $pwdConfigAry = Get_PwdRules( $dbh, $HB_ENV );
160  $pwdConfigJSON = HCU_JsonEncode( $pwdConfigAry );
161  $hasPwdRequirements = count($pwdConfigAry) > 0;
162 
163  // flag if using password requirements
164  /*$hasPwdRequirements = 1;
165  if ( $hasPwdRequirements ) {
166  $pwdConfigJSON = HCU_JsonEncode( $pwdConfigAry );
167  } else {
168  $pwdConfigJSON = "{}";
169  }*/
170 
171  // set up the messages regarding what is being checked
172  if (HCU_array_key_value("len", $pwdConfigAry) > 0) {
173  $text = ( $pwdConfigAry["len"] > 1 ) ? $MC->msg("Characters", HCU_DISPLAY_AS_HTML) : $MC->msg("Character", HCU_DISPLAY_AS_HTML);
174  $pwdRequirements[] = array( "which"=>"len", "text"=>"{$pwdConfigAry["len"]} {$text}" );
175  }
176  if (HCU_array_key_value("upper", $pwdConfigAry) > 0) {
177  $text = ( $pwdConfigAry["upper"] > 1 ) ? $MC->msg("UPPER letters", HCU_DISPLAY_AS_HTML) : $MC->msg("UPPER letter", HCU_DISPLAY_AS_HTML);
178  $pwdRequirements[] = array( "which"=>"upper", "text"=>"{$pwdConfigAry["upper"]} {$text}" );
179  }
180  if (HCU_array_key_value("lower", $pwdConfigAry) > 0) {
181  $text = ( $pwdConfigAry["lower"] > 1 ) ? $MC->msg("lower letters", HCU_DISPLAY_AS_HTML) : $MC->msg("lower letter", HCU_DISPLAY_AS_HTML);
182  $pwdRequirements[] = array( "which"=>"lower", "text"=>"{$pwdConfigAry["lower"]} {$text}" );
183  }
184  if (HCU_array_key_value("spec", $pwdConfigAry) > 0) {
185  $text = ( $pwdConfigAry["spec"] > 1 ) ? $MC->msg("Special characters", HCU_DISPLAY_AS_HTML) : $MC->msg("Special character", HCU_DISPLAY_AS_HTML);
186  $pwdRequirements[] = array( "which"=>"spec", "text"=>"{$pwdConfigAry["spec"]} {$text} <span class='fa fa-question-circle-o' style='color: #333' id='specialTip'></span>" );
187  }
188  if (HCU_array_key_value("digit", $pwdConfigAry) > 0) {
189  $text = ( $pwdConfigAry["digit"] > 1 ) ? $MC->msg("Numbers", HCU_DISPLAY_AS_HTML) : $MC->msg("Number", HCU_DISPLAY_AS_HTML);
190  $pwdRequirements[] = array( "which"=>"digit", "text"=>"{$pwdConfigAry["digit"]} {$text}" );
191  }
192  } else {
193  $hasPwdRequirements = false;
194  $specialCharacters = "";
195  }
196 
197  // if email needs verification then it is required
198  $emailRequired = ($HB_ENV['Fmsg_tx'] & GetMsgTxValue('MSGTX_FORCE_EM'));
199 
200  // get list of security phone numbers for user
201  // default empty list
202  $aryPhones = array( "mobile"=>array() );
203  $sql = "SELECT phones FROM {$HB_ENV['Cu']}usercontact c LEFT JOIN {$HB_ENV['Cu']}user u ON u.contact = c.contact_id WHERE u.user_name = '{$HB_ENV['Cn']}'";
204  $sqlRs = db_query($sql, $dbh);
205  if ($sqlRs) {
206  $rowPhones = db_fetch_assoc($sqlRs, 0);
207  $hasPhones = HCU_array_key_value("phones", $rowPhones);
208  if ($hasPhones) {
209  $aryPhones = HCU_JsonDecode($hasPhones);
210  }
211  }
212 
213  // update the challenge questions / phone list if required or missing
214  $questTest = GetChallengeQuestions("CURRENT", $dbh, $HB_ENV, $MC, $HB_ENV['Cn']);
215 
216  /**
217  * Show the MFA Tab for any of the following conditions
218  * Force Security is set for the user
219  * CU is setup for Challenge Questions and no challenge questions are configured
220  * CU is setup for SAC and no mobile numbers are configured
221  */
222  $challengeRequired = ($HB_ENV['Ffreset'] > 0) ||
223  ((intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) === 0) && (empty( $questTest ) || $questTest["mfacount"] == 0)) ||
224  ((intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) > 0) && empty( $aryPhones['mobile']));
225 
226  /*
227  * ** START CONTENT
228  */
229  $errorList = array();
230  $es_warnings = [];
231 
232  $act = "auth"; // default to first screen
233  if (HCU_array_key_value('action', $HB_ENV['HCUPOST']) == 'submit') {
234  // ** GET THE Current Member Info --- This is at least needed for username
235  $mbrInfo = GetUserInfo($dbh, $HB_ENV, $MC, Array("user_id" => $HB_ENV['Uid'], "cu" => $HB_ENV['Cu']));
236 
237  // get the passed information into variables in case need to re-show on error
238  $paramChkSecure = $HB_ENV["HCUPOST"]["chkSecure"] == "Y" ? "Y" : "N";
239  $paramEmailAddress = $HB_ENV["HCUPOST"]["emailAddress"];
240  $paramEmailValid = $HB_ENV["HCUPOST"]["emailValid"] == "true" ? "Y" : "N";
241  $paramProfileEgenl = $HB_ENV["HCUPOST"]["profileEgenl"] == "true" ? "Y" : "N";
242  $paramEstatementStart = $HB_ENV["HCUPOST"]["estatementStart"] == "true" ? "Y" : "N";
243  $paramProfileEmailAlerts = $HB_ENV["HCUPOST"]["profileEmailAlerts"];
244  $paramSecurityConfidence = $HB_ENV["HCUPOST"]["security_confidence"];
245 
246  $paramChallengeQuestions = array();
247  $paramResponses = array();
248  if (intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) === 0) {
249  // NOTE: this should create invalid entries if the user didn't send enough question/response pairs
250  for ( $i = 0; $i < $HB_ENV['cu_chgqst_count']; $i++ ) {
251  $paramChallengeQuestions[$HB_ENV["HCUPOST"]["challengeQuestion{$i}"]] = $HB_ENV["HCUPOST"]["response{$i}"];
252  }
253  }
254 
255  $paramProfileAlias1 = $HB_ENV["HCUPOST"]["profileAlias1"];
256  $paramProfileAlias2 = $HB_ENV["HCUPOST"]["profileAlias2"];
257  $paramProfilePasswordCurr = $HB_ENV["HCUPOST"]["profilePasswordCurr"];
258  $paramProfilePasswordNew1 = $HB_ENV["HCUPOST"]["profilePasswordNew1"];
259  $paramProfilePasswordNew2 = $HB_ENV["HCUPOST"]["profilePasswordNew2"];
260 
261  $errorList = array();
262 
263  // set up all the possible things being validated/updated
264  $bolUseTransaction = false;
265  // ** SET FIELDS FOR UPDATE
266  // * Go in the upd_fields array -- then call Update_Settings
267  $updFields['settings_password']['current'] = $paramProfilePasswordCurr;
268  if ( $pwdRequired ) {
269  // ** Include password with the information
270  $updFields['settings_password']['newpasswd'] = $paramProfilePasswordNew1;
271  $updFields['settings_password']['confpasswd'] = $paramProfilePasswordNew2;
272  $updFields['settings_password']['review_guidelines'] = "Y"; // hard-code this for now as the requirement is going away
273 
274  // see if password requirements are set
275  $aryResult = Validate_PwdRules( $dbh, $HB_ENV, $updFields, $MC );
276 
277  // check if the requirements were met
278  if ( $aryResult["status"]["code"] != '000' ) {
279  for ( $e = 0; $e < count( $aryResult["status"]["errors"] ); $e++ ) {
280  $errorList[] = array( "id" => "", "message" => $aryResult["status"]["errors"][$e] );
281  }
282  }
283  }
284 
285  // ** Include useralias? Only if required AND the current alias is empty.
286  // ** This matches the logic for showing the username step
287  /*
288  * Prior to Odyssey user alias was a separate field. It could easily be identified as 'NOT SET'
289  * Now in Odyssey the user_name is ALWAYS the login, when an alias is set or not it will have a value
290  * At this time I am going to identify the Alias as 'NOT SET' IF the user_name is all digits. We will
291  * still have the rule where an ALIAS may NOT be all digits mws 4/5/2016
292  */
293  if ($aliasRequired && is_numeric($mbrInfo["data"]["cuusers_user_name"])) {
294  // ** Include information for member username
295  $updFields['settings_alias']['username'] = $HB_ENV['HCUPOST']['profileAlias1'];
296  $updFields['settings_alias']['username_confirm'] = $HB_ENV['HCUPOST']['profileAlias2'];
297  $bolUseTransaction = true;
298  }
299 
300  if ( $challengeRequired ) {
301  // ** Confidence word
302  $updFields['settings_confidence']['confword'] = $paramSecurityConfidence;
303 
304  if (HCU_array_key_exists('cuusers_userflags', $mbrInfo['data'])) {
305  // * data structure exists for mbrInfo -- reset the field if 'userflags' EXISTS
306  // ** Userflags -- Reset the MEM_FORCE_RESET flag?
307 
308  $tmpVal = (int) HCU_array_key_value('cuusers_userflags', $mbrInfo['data']);
309  // ** NEGATE the MEM_FORCE_RESET value
310  $tmpVal = ~(~$tmpVal | GetUserFlagsValue('MEM_FORCE_RESET'));
311 
312  $updFields['settings_confidence']['userflags'] = $tmpVal;
313  }
314 
315  if (intval($HB_ENV['flagset3'] & GetFlagsetValue('CU3_MFA_AUTHCODE'))) {
316  // ** get update for phone numbers
317  if (HCU_array_key_exists("security_phones", $HB_ENV['HCUPOST'])) {
318  $phonesJson = $HB_ENV['HCUPOST']['security_phones'];
319  $phonesJson = html_entity_decode($phonesJson);
320  $phonesAry = HCU_JsonDecode($phonesJson);
321 
322  $mobile = HCU_array_key_value('mobile', $phonesAry);
323 
324  $updFields['settings_phones']['mobile'] = $mobile === false ? array() : $mobile;
325  }
326  } else {
327  // ** Challenge Questions / Responses
328  // ** loop through the questions
329  $arrayKeys = array_keys( $paramChallengeQuestions );
330  for ( $i = 0; $i < count( $arrayKeys ); $i++ ) {
331  $updFields['settings_questions'][] = Array( 'cqid' => $arrayKeys[$i], 'display' => $paramChallengeQuestions[$arrayKeys[$i]] );
332  }
333  }
334  }
335 
336  // ** email
337  if ( $emailRequired || $challengeRequired ) {
338 
339  if ( strlen( $paramEmailAddress ) ) {
340  $updFields['settings_email']['email'] = $paramEmailAddress;
341  $updFields['settings_email']['egenl'] = $paramProfileEgenl;
342 
343  $updFields['settings_email']['verify'] = $emailRequired;
344  $updFields['settings_email']['valid'] = $paramEmailValid;
345  } else {
346  $errorList[] = array( "id" => "", "message" => $MC->msg( "EMail Missing", HCU_DISPLAY_AS_HTML ) );
347  }
348  }
349 
350  // ** We have create our list of fields to update --
351  // ** VALIDATE -- OR PUT VALIDATION IN UPDATE
352  // * are we verifying the email address
353  $aryUpdate = Validate_Settings($dbh, $HB_ENV, $updFields, $MC);
354 
355  if ($aryUpdate['status']['code'] != '000') {
356  for ( $i = 0; $i < count( $aryUpdate["status"]["errors"] ); $i++ ) {
357  $errorList[] = array( "id" => "", "message" => $aryUpdate["status"]["errors"][$i] );
358  }
359 
360  // if failed the current password, update the cookie retries
361  // failed_curr_pass is only set when password validation fails,
362  // otherwise the index is not present with all errors
363 
364  // if( $aryUpdate['status']['failed_curr_pass'] ) {
365  if( !empty ( $aryUpdate['status']['failed_curr_pass'] ) ) {
366  $remainTries--;
367  // these values were obtained on entry
368  $hashedValue = md5( $remainTries . $timeExpires . $HB_ENV["secret"] );
369  $profileCookie = "remain=$remainTries&until=$timeExpires&check=$hashedValue";
370  HCU_setcookie_env($HB_ENV['SYSENV'], "securePass", "", time() - 60);
371  }
372  }
373 
374  if ( !count( $errorList ) ) {
375 
376  // see if we ask the member to start eStatements
377  $userNeedsEstatements = false;
378  $accountNumbers = array();
379  if ($HB_ENV["flagset3"] & GetFlagsetValue("CU3_ESTMNT_SIGNUP")) {
380  // This value doesn't not change. If it is false, then I don't even need to check anything else.
381  // Needs to loop to see if any estatements are "N"s. Gets accountnumbers where the user has Desktop Estatement access to.
382  // Profile Require is not used in the apps.
383  $sql = "select accountnumber from " . $HB_ENV["Cu"] . "memberacctrights where whichright = 'ES' and platform::jsonb ? 'D' and user_id = " . $HB_ENV["Uid"];
384  $sth = db_query($sql, $dbh);
385 
386  $hasEsPositive = false;
387  $hasEsNegative = false;
388  for($i = 0; list($accountnumber) = db_fetch_row($sth, $i); $i++) {
389  $retEstmtStatus = Get_EstmtEnrollStatus($dbh, $HB_ENV, $MC, trim($accountnumber));
390  $accountNumbers[] = $accountnumber;
391 
392  if ($retEstmtStatus['status']['code'] == '000') {
393  $hasEsPositive = $hasEsPositive || $retEstmtStatus["status"]["estmt"] == "Y";
394  $hasEsNegative = $hasEsNegative || $retEstmtStatus["status"]["estmt"] == "N";
395  }
396  }
397 
398  $userNeedsEstatements = $hasEsNegative && !$hasEsPositive;
399  // If the user has Estatements that have not been turned AND does not have estatements that have been turned on.
400  }
401 
402  if ( $userNeedsEstatements && $paramEstatementStart == "Y" ) {
403  // start the estatement
404  $HB_ENV['esProcessMode'] = "start";
405 
406  foreach($accountNumbers as $accountnumber) { // Loop through accountnumbers found and try to set up estatements per accountnumber.
407  $esResults = Post_CUEStmt($dbh, $HB_ENV, $MC, trim($accountnumber));
408  if ( $esResults["status"]["code"] != "000" ) {
409  for ( $i = 0; $i < count( $esResults["status"]["errors"] ); $i++ ) {
410  //$retStatus_ary is undefined.
411  //for ( $i = 0; $i < count( $retStatus_ary["status"]["errors"] ); $i++ ) {
412  // $errorList[] = array( "id" => "", "message" => $esResults["status"]["errors"][$i] );
413  $es_warnings[] = $esResults["status"]["errors"][$i];
414  }
415  break;
416  }
417  }
418 
419  // check for errors
420  if ( $esResults["status"]["code"] == "000" ) {
421  // don't show the result message because there isn't a good place to show it
422 
423  // now set the notification
424 
425  // build up a response to the notice so the member doesn't see again
426  $HB_ENV["HCUPOST"]["notice_type"] = "C";
427  $HB_ENV["HCUPOST"]["notice_id"] = intval( $HB_ENV["HCUPOST"]["estatementNoticeId"] );
428  $HB_ENV["HCUPOST"]["notice_device"] = "M"; // mobile
429  $HB_ENV["HCUPOST"]["notice_response"] = array( "answer" => 1 ); // something non-zero but numeric
430  $HB_ENV["HCUPOST"]["notice_cancel"] = "0";
431 
432  // Need to insert a record in the response table for every accountnumber.
433  foreach ($accountNumbers as $accountnumber) {
434  $HB_ENV["HCUPOST"]["notice_accountnumber"] = $accountnumber;
435  $retStatus_ary = Update_NoticeInfo($dbh, $HB_ENV, $MC);
436  }
437 
438  if ( $retStatus_ary["status"]["code"] != "000" ) {
439  for ( $i = 0; $i < count( $retStatus_ary["status"]["errors"] ); $i++ ) {
440  $errorList[] = array( "id" => "", "message" => $retStatus_ary["status"]["errors"][$i] );
441  }
442  }
443  }
444  }
445 
446  if (intval($HB_ENV['flagset3'] & GetFlagsetValue('CU3_MFA_AUTHCODE'))) {
447  if (HCU_array_key_exists("settings_phones", $updFields)) {
448  // since the security phone number are part of a different table
449  // we must update them separately from the Update_User_Settings
450  // function.
451  $aryUpdate = Update_User_Security($dbh, $HB_ENV, $MC, $updFields);
452  if ($aryUpdate['status']['code'] != '000') {
453  // an error occurred, convert the error into an id:message pair, if we know the id (field name)
454  for ( $e = 0; $e < count( $aryUpdate["status"]["errors"] ); $e++ ) {
455  $aryErrors[] = array( "message" => $aryUpdate["status"]["errors"][$e] );
456  }
457 
458  throw new Exception (HCU_JsonEncode($aryErrors));
459  }
460  }
461  }
462 
463  // Always use a transaction so we know if anything didn't complete that nothing completed.
464  // This is mostly in case the user_name wasn't unique (e.g. conflict after validation and before actual update).
465  $bolUseTransaction = true;
466  $aryUpdate = Update_User_Settings($dbh, $HB_ENV, $MC, $updFields, $bolUseTransaction);
467 
468  if ($aryUpdate['status']['code'] != '000') {
469  // * AN ERROR OCCURRED
470  // ** Stay on this screen list the errors.
471  for ( $i = 0; $i < count( $aryUpdate["status"]["errors"] ); $i++ ) {
472  $errorList[] = array( "id" => "", "message" => $aryUpdate["status"]["errors"][$i] );
473  }
474  } else {
475  // * SUCCESSFUL
476 
477  // ** BE sure to set the GLOBAL Ticket cookie to the new value
478  // * being returned by SetTicket
479  $newTicket = "";
480 
481  // ** If the Ffchg flag is set to Y -- Then reset to N
482  if ( $pwdRequired ) {
483  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'],"Ffchg=N");
484  $_COOKIE['Ticket'] = $newTicket;
485  }
486  // * RESET THE EMAIL
487  // NOTE: resetting the verify email even if not verified so user won't get caught in a loop, verifying the email
488  if ( $emailRequired ) {
489  // ** OLD $_COOKIE['Ticket'] = SetTicket($HB_ENV, $_COOKIE['Ticket'],"Ml=$paramEmailAddress&Fmsg_tx=" . ($HB_ENV['Fmsg_tx'] ^ $EMAIL_FLAG));
490  // * Changed to logic to not simply negate the EMAIL_FLAG. This is because the logic above changed for emailRequired where we ALWAYS
491  // * require the email .. Now it needs to properly negate only when it is already set
492  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'],"Ml=$paramEmailAddress&Fmsg_tx=" . ~(~(int)$HB_ENV['Fmsg_tx'] | GetMsgTxValue("MSGTX_FORCE_EM")));
493  $_COOKIE['Ticket'] = $newTicket;
494  }
495 
496  // * SET USER NAME COOKIE IF CHANGED
497  // ** ENSURE profileAlias variable is set. If the field is empty they did not Change
498  if ( $mbrInfo["data"]["cuusers_user_name"] != $paramProfileAlias1 && $paramProfileAlias1 != '') {
499  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'], "Cn=$paramProfileAlias1");
500  $_COOKIE['Ticket'] = $newTicket;
501  // ** Update the HB_ENV Cn (username) -- This will be used later when updating the device cookie
502  $HB_ENV['Cn'] = $paramProfileAlias1;
503  }
504  // * RESET THE USERNAME
505  if (($HB_ENV['Fset2'] & GetFlagsetValue("CU2_ALIAS_REQ")) == GetFlagsetValue("CU2_ALIAS_REQ")) {
506  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'],"Fset2=" . ($HB_ENV['Fset2'] ^ GetFlagsetValue("CU2_ALIAS_REQ")));
507  $_COOKIE['Ticket'] = $newTicket;
508  }
509  if ( $challengeRequired ) {
510  // ** RESET THE Force Reset of Challenge Questions: Ffreset - be sure it is 0
511  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'],"Ffreset=0");
512  $_COOKIE['Ticket'] = $newTicket;
513  }
514 
515  $newDeviceCookie = "";
516  $newPassword = "";
517  if ( $HB_ENV["platform"] == "APP" || $HB_ENV["platform"] == "ADA" ) {
518  // build a new device cookie to give to the apps (the apps will check if it is needed)
519  $usrInfo = GetUserbyName($HB_ENV['dbh'], $HB_ENV['Cu'], $HB_ENV['Cn']);
520 
521  // Get the MFA mode (authcode or not) flag
522  $mfaMode = (intval($HB_ENV['Fset3'] & GetFlagsetValue('CU3_MFA_AUTHCODE')));
523 
524  // Get the mfadate from the UserRec
525  $mfaDate = HCU_array_key_value("mfadate", $usrInfo);
526 
527 
528  $cookieParams = array ( "cu" => $HB_ENV["cu"],
529  "user_name" => $usrInfo["user_name"],
530  "saved_pass" => $usrInfo["passwd"],
531  "saved_email" => $usrInfo['email'],
532  "saved_confidence" => $usrInfo['confidence'],
533  "mfa_mode" => $mfaMode,
534  "mfa_date" => $mfaDate,
535  "persists_time" => $HB_ENV['SYSENV']['ticket']['persists']
536  );
537 
538  // This will start working with with issue 3126
539  $cookieInfo = CreateDeviceCookie( $cookieParams);
540 
541  $newDeviceCookie = $cookieInfo["name"] . "|" . $cookieInfo["content"] . "|" . $cookieInfo["expire"];
542 
543  // if the password was updated, get a copy to give to the apps in case of fingerprint signing
544  if ( pwdRequired ) {
545  $newPassword = $paramProfilePasswordNew1;
546  }
547  } else {
548  // * Check to see if I want to rebuild the cookie
549  if ( $paramChkSecure == 'Y' ) {
550  // ** refetch the member information
551  $mbrInfo = GetUserInfo($dbh, $HB_ENV, $MC, Array("user_id" => $HB_ENV['Uid'], "cu" => $HB_ENV['Cu']));
552  // ** if we were able to retrieve the member data
553  if ($mbrInfo['status']['code'] == '000') {
554  // * Set fields for setting the
555  $HB_ENV['cu'] = $HB_ENV['Cu'];
556  $HB_ENV['username'] = $HB_ENV['Cn'];
557  $HB_ENV['savepass'] = trim($mbrInfo['data']['cuusers_passwd']);
558  $HB_ENV['savemail'] = trim($mbrInfo['data']['cuusers_email']);
559  $HB_ENV['confidence'] = trim($mbrInfo['data']['cuusers_confidence']);
560  SetDeviceCookie($HB_ENV, $mbrInfo['data']);
561  }
562  }
563  }
564  // now try to update the alerts - any in the list get updated
565  if ( strlen( $paramProfileEmailAlerts ) > 0 ) {
566  // get the alerts
567  $alertInfo = Get_AlertsDetailed( $dbh, $HB_ENV["Cu"], $HB_ENV["Uid"], $HB_ENV["Fset3"]);
568  $alertList = $alertInfo["data"];
569 
570  $emailList = explode( "|", $paramProfileEmailAlerts );
571  // go through the alerts
572  for ( $a = 0; $a < count( $alertList ); $a++ ) {
573  if ( $alertList[$a]["emailtype"] == "E" &&
574  in_array( $alertList[$a]["notifyto"], $emailList ) ) {
575 
576  $sql = "UPDATE cu_alerts
577  SET notifyto = '{$paramEmailAddress}'
578  WHERE user_id = {$HB_ENV["Uid"]}
579  AND id = {$alertList[$a]["id"]}";
580 
581  db_query($sql, $dbh);
582 
583  }
584  }
585 
586  }
587 
588  // fall through to show the "done" screen
589  }
590  } else {
591  // ** VALIDATE FAILED -- RELOAD SCREEN
592  }
593 
594  if ( count( $errorList ) == 0 ) {
595  // set up to show the "Done" screen
596  $act = "done";
597 
598  // Need to pass $newDeviceCookie back to the apps
599  // and possibly newPassword
600  // Need to pass $newTicket back to the apps
601  }
602  }
603 
604  /*
605  * DECLARE DEFAULT VALUES
606  */
607  $needPasswordUpdate = FALSE;
608  $neededSteps = array();
609  $currStep = 1;
610  $needsChallenge = false;
611  $needsEmail = false;
612  $overrideTest = false;
613  $esNoticeId = "";
614  $esTermsText = "";
615  $esAccept = "";
616  $userNeedsEstatements = false;
617 
618  if ( $act == "auth" ) {
619  // see what all the user needs to update
620 
621  // this gets info that is used in several places
622  $mbrInfo = GetUserInfo($dbh, $HB_ENV, $MC, Array("user_id" => $HB_ENV['Uid'], "cu" => $HB_ENV['Cu']));
623 
624  // start page
625  $neededSteps[] = array( "step" => $currStep++,
626  "name" => "Start",
627  "title" => "{$MC->msg('Start', HCU_DISPLAY_AS_RAW)}",
628  "visibility" => "progressStart" );
629 
630  // see if needing update of email (or verification if challengeRequired)
631  if ( $emailRequired || $challengeRequired || $overrideTest ) {
632  $needsEmail = true;
633  $neededSteps[] = array( "step" => $currStep++,
634  "name" => "Email",
635  "title" => "{$MC->msg('EMAIL', HCU_DISPLAY_AS_RAW)}",
636  "visibility" => "progressEmail" );
637 
638  // see if we ask the member to start eStatements
639  if ($HB_ENV["flagset3"] & GetFlagsetValue("CU3_ESTMNT_SIGNUP")) { // This value doesn't not change. If it is false, then I don't even need to check anything else.
640 
641  // Needs to loop to see if any estatements are "N"s. Gets accountnumbers where the user has Desktop Estatement access to. Profile Require is not used in the apps.
642  $sql = "select accountnumber from " . $HB_ENV["Cu"] . "memberacctrights where whichright = 'ES' and platform::jsonb ? 'D' and user_id = " . $HB_ENV["Uid"];
643  $sth = db_query($sql, $dbh);
644 
645  $hasEsPositive = false;
646  $hasEsNegative = false;
647  for($i = 0; list($accountnumber) = db_fetch_row($sth, $i); $i++) {
648  $retEstmtStatus = Get_EstmtEnrollStatus($dbh, $HB_ENV, $MC, trim($accountnumber));
649 
650  if ($retEstmtStatus['status']['code'] == '000') {
651  $hasEsPositive = $hasEsPositive || $retEstmtStatus["status"]["estmt"] == "Y";
652  $hasEsNegative = $hasEsNegative || $retEstmtStatus["status"]["estmt"] == "N";
653  }
654  }
655 
656  $userNeedsEstatements = $hasEsNegative && !$hasEsPositive;
657  // If the user has Estatements that have not been turned AND does not have estatements that have been turned on.
658  }
659 
660  if ( $userNeedsEstatements ) {
661  // get the notice info to start the estatements
662  // ** Lookup the Current Terms for the Credit Union
663  $esTermsArray = Get_NoticeInfo($dbh, $HB_ENV, $MC, 'D', "esTermsStart");
664  // ** Check to make sure the Terms are returned.
665  if ($esTermsArray['status']['code'] == '000' && strlen( $esTermsArray['notice'][0]['notice_text'] ) > 0 ) {
666  // get the terms
667  $esTermsText = $esTermsArray['notice'][0]['notice_text'];
668  $esAccept = $MC->msg( "Yes start e-statements", HCU_DISPLAY_AS_JS );
669  $esNoticeId = $esTermsArray['notice'][0]['notice_id'];
670  }
671  }
672  }
673 
674  // only ask for alias if required and not currently set up (i.e. user name is all digits)
675  if ( ($aliasRequired && is_numeric( $mbrInfo["data"]["cuusers_user_name"] )) || $overrideTest ) {
676  $neededSteps[] = array( "step" => $currStep++,
677  "name" => "Alias",
678  "title" => "{$MC->msg('Username', HCU_DISPLAY_AS_RAW)}",
679  "visibility" => "progressAlias" );
680  }
681 
682  if ( $challengeRequired || $overrideTest ) {
683  $needsChallenge = true;
684  $neededSteps[] = array( "step" => $currStep++,
685  "name" => "Challenge",
686  "title" => "{$MC->msg('Security Settings', HCU_DISPLAY_AS_RAW)}",
687  "visibility" => "progressChallenge" );
688  }
689 
690  // the password confirmation is always a step (the last step) but need to
691  // see if password is being forced
692  $neededSteps[] = array( "step" => $currStep++,
693  "name" => "Password",
694  "title" => "{$MC->msg('Password', HCU_DISPLAY_AS_RAW)}",
695  "visibility" => "progressPassword" );
696 
697  if( $pwdRequired || $overrideTest ) {
698  $needPasswordUpdate = TRUE;
699 
700  // only get the help if needing to update password
701  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "pwdRules", false);
702  $hasRules = false;
703 
704  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry["notice"]) && HCU_array_key_exists('notice_id', $noticesAry["notice"][0]) ) {
705  $hasRules = true;
706  $noticeOption = $noticesAry['notice'][0];
707 
708  $noticeOptions = Array (
709  'docsid' => $noticeOption['notice_id'],
710  'docstype' => $noticeOption['notice_type'],
711  'device' => 'D',
712  'noticeOnly' => '1',
713  'expireTime' => time() + 86400,
714  );
715 
716  $encryptedRulesNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
717 
718  // build the url encoded string
719  $rulesURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedRulesNoticeOnly);
720  }
721  }
722 
723  // done page - always last
724  $neededSteps[] = array( "step" => $currStep++,
725  "name" => "Done",
726  "title" => "{$MC->msg('Done', HCU_DISPLAY_AS_RAW)}",
727  "visibility" => "progressDone" );
728  }
729 
730  // set up default values
731  if ( $needsChallenge ) {
732  // get the confidence word
733  $mbrConfidence = $mbrInfo["data"]["cuusers_confidence"];
734 
735  // gather the challenge questions
736  $aryChallengeQuestions = GetChallengeQuestions("DISPLAY", $dbh, $HB_ENV, $MC);
737  /*
738  * Challenge questions are stored in the database as &#HEX;
739  * The way we are displaying these, we need to first get them back to their
740  * original entity
741  *
742  */
743  foreach ($aryChallengeQuestions as $chgKey => $chgValue) {
744  $chgValue['display'] = html_entity_decode($chgValue['display'], ENT_QUOTES, 'UTF-8');
745  $aryChallengeQuestions[$chgKey] = $chgValue;
746  }
747  reset($aryChallengeQuestions);
748 
749  $currChallengeQuestions = array();
750  if (isset($paramChallengeQuestions) && count( $paramChallengeQuestions ) > 0 &&
751  count( $paramChallengeQuestions ) == $HB_ENV['cu_chgqst_count'] ) {
752  // use the parameters
753  $list = $paramChallengeQuestions;
754 
755  $arrayKeys = array_keys( $list );
756  for ( $i = 0; $i < count( $arrayKeys ); $i++ ) {
757  $currChallengeQuestions[] = array( "cqid" => $arrayKeys[$i], "response" => $list[$arrayKeys[$i]] );
758  }
759  } else {
760  // get from the database
761  $list = Get_MemberChallengeResponses($dbh, $HB_ENV, $HB_ENV['Cn']);
762  // force user to start over
763  for ( $i = 0; $i < $HB_ENV['cu_chgqst_count']; $i++ ) {
764  $currChallengeQuestions[] = array( "cqid" => $aryChallengeQuestions[0]["cqid"], "response" => "" );
765  }
766  }
767  } else {
768  // set defaults
769  $mbrConfidence = "";
770  $aryChallengeQuestions = array();
771  $currChallengeQuestions = array();
772  for ( $i = 0; $i < $HB_ENV['cu_chgqst_count']; $i++ ) {
773  $currChallengeQuestions[] = array( "cqid" => 0, "response" => "" );
774  }
775  }
776 
777  $currEmailAlerts = "";
778  if ( $needsEmail ) {
779  // read the emails used in the alerts
780  $emailAlertList = array();
781  $alertInfo = Get_AlertsDetailed( $dbh, $HB_ENV["Cu"], $HB_ENV["Uid"], $HB_ENV["Fset3"], $MC);
782  $alertList = $alertInfo["data"];
783 
784  for ( $i = 0; $i < count( $alertList ); $i++ ) {
785  if ( $alertList[$i]["emailtype"] == "E" ) {
786  // see if already have this email address
787  $found = false;
788  for ( $e = 0; $e < count( $emailAlertList ); $e++ ) {
789  if ( $emailAlertList[$e]["email"] == $alertList[$i]["notifyto"] ) {
790  $found = true;
791 
792  // see if a different type of alert was found for this email
793  if ( $emailAlertList[$e]["type"] != $alertList[$i]["type_name"] ) {
794  // change it to "Multiple"
795  $emailAlertList[$e]["type"] = $MC->msg('Multiple', HCU_DISPLAY_AS_JS);
796  }
797  }
798  }
799 
800  // fix the email type name to what will be displayed
801  if ( !$found ) {
802  $emailAlertList[] = array( "id" => $i,
803  "type" => $alertList[$i]["type_name"],
804  "email" => $alertList[$i]["notifyto"],
805  "choice" => $alertList[$i]["notifyto"] == $HB_ENV["Ml"] ? "Y" : "N" );
806  }
807  }
808  }
809 
810  $hasAlertEmail = count( $emailAlertList ) > 0;
811 
812  for ( $i = 0; $i < count( $emailAlertList ); $i++ ) {
813  if ( $emailAlertList[$i]["choice"] == "Y" ) {
814  if ( strlen( $currEmailAlerts ) > 0 ) $currEmailAlerts .= "|";
815  $currEmailAlerts .= $emailAlertList[$i]["email"];
816  }
817  }
818  } else {
819  $hasAlertEmail = false;
820  }
821 
822  if (!isset($paramEmailAddress) || $paramEmailAddress == "" ) {
823  $currEmail = $HB_ENV["Ml"];
824  } else {
825  $currEmail = $paramEmailAddress;
826  }
827 
828  // Flag stored as "Y"/"N" but need a boolean to set it correctly in javascript
829  if (isset($paramEmailAddress) && $paramProfileEgenl != "" ) {
830  $currEgenl = $paramProfileEgenl == "Y";
831  } else {
832  $currEgenl = $mbrInfo["data"]["cuusers_egenl_flag"] == "Y";
833  }
834 
835  $currUserAlias = "";
836  if ( $aliasRequired && isset($paramProfileAlias1)) {
837  $currUserAlias = $paramProfileAlias1;
838  }
839 
840  if (!isset($paramSecurityConfidence) || $paramSecurityConfidence == "" ) {
841  $currConfidence = $mbrConfidence;
842  } else {
843  $currConfidence = $paramSecurityConfidence;
844  }
845 
846  $currCheckSecure = "";
847  if (isset($paramChkSecure)) {
848  // user currently selected value (if coming back from error)
849  $currCheckSecure = $paramChkSecure;
850  }
851 
852 ?>
853 <script type="text/javascript">
854 
855  var hcuChallengeQuestions = <?php echo HCU_JsonEncode($aryChallengeQuestions) ?>;
856 
857  var hcuPhonesList = <?php print HCU_JsonEncode($aryPhones); ?>;
858  var hcuPhonesData = [];
859 
860  <?php if (intval($HB_ENV['flagset3'] & GetFlagsetValue('CU3_MFA_AUTHCODE'))): ?>
861  if (hcuPhonesList && hcuPhonesList.mobile) {
862  for (var i = 0; i < hcuPhonesList.mobile.length; i++) {
863  var phone = hcuPhonesList.mobile[i];
864  var phoneParts = hcuPhonesList.mobile[i].split(/[-\s]/);
865  var phone = "";
866 
867  if (phoneParts.length === 3) {
868  phone += "(" + phoneParts[0].replace(/\D/g, '') + ") ";
869  phone += phoneParts[1] + "-";
870  phone += phoneParts[2];
871  } else {
872  phone += phoneParts[0] + "-";
873  phone += phoneParts[1];
874  }
875 
876  hcuPhonesData.push({
877  id: i+1,
878  value: phone,
879  new: false
880  });
881  }
882  }
883 
884  if (hcuPhonesData.length < 5) {
885  hcuPhonesData.push({
886  value: null,
887  id: -1,
888  new: false
889  });
890  }
891  <?php endif; ?>
892  var stepsData = <?php echo HCU_JsonEncode($neededSteps) ?>;
893 
894  <?php if ( $hasAlertEmail ) { ?>
895  var emailAlertList = <?php echo HCU_JsonEncode( $emailAlertList ) ?>;
896  <?php } ?>
897 
898  var viewModel;
899  var infoWindow;
900  var pwdRequirements = <?php echo $pwdConfigJSON; ?>;
901  var pwdSpecial = <?php echo HCU_JsonEncode(explode(",", $specialCharacters )); ?>;
902  $(document).ready(function() {
903  <?php
904  if ( $act == "done" ) {
905  // show "done" screen
906  ?>
907  var viewModel = kendo.observable({
908 
909  progressStart: false,
910  progressEmail: false,
911  progressChallenge: false,
912  progressAlias: false,
913  progressPassword: false,
914  progressDone: true,
915  continueClick: function( e ) {
916  e.preventDefault();
917 
918  window.location.href = "<?php echo $returnScript; ?>";
919  }
920  });
921 
922  kendo.bind($("#profile"), viewModel);
923 
924  // set up the progress bar
925  $("#progressBar").kendoProgressBar({
926  type: "value",
927  min: 0,
928  max: 1,
929  value: 1
930  });
931  var progressSteps = $("#progressBar").data("kendoProgressBar");
932 
933  progressSteps.progressStatus.text( "<?php echo $MC->msg('Done', HCU_DISPLAY_AS_JS); ?>" );
934 
935  $("#progressDoneMessage").css("visibility", "visible");
936 
937  <?php
938  if ( $HB_ENV["platform"] == "APP" || $HB_ENV["platform"] == "ADA" ) {
939  // set up the parameters based on what changed
940  if ( $newTicket != "" ) {
941  $paramsForApps = array( "newTicket" => urlencode( $newTicket ) );
942 
943  $paramsJSON = HCU_JsonEncode($paramsForApps);
944  ?>
945  var appInfo = '<?php echo $paramsJSON; ?>';
946 
947  <?php if ( $HB_ENV["platform"] == "ADA" ) : ?>
948  AndroidController.notifyCommand("NEW_TICKET_COOKIE", appInfo);
949  <?php elseif ( $HB_ENV["platform"] == "APP" ) : ?>
950  var postObject = {
951  body: {
952  cmd: "NEW_TICKET_COOKIE",
953  params: appInfo
954  }
955  };
956  window.webkit.messageHandlers.interOp.postMessage(postObject);
957  <?php endif ?>
958  <?php
959  }
960 
961  if ( $newDeviceCookie != "" ) {
962  $paramsForApps = array( "deviceKey" => $newDeviceCookie );
963  if( $newPassword != "" ) {
964  $paramsForApps["newPassword"] = $newPassword;
965  }
966 
967  $paramsJSON = HCU_JsonEncode($paramsForApps);
968 
969  ?>
970  var appInfo = '<?php echo $paramsJSON; ?>';
971 
972  <?php if ( $HB_ENV["platform"] == "ADA" ) : ?>
973  AndroidController.notifyCommand("NEW_DEVICE_KEY", appInfo);
974  <?php elseif ( $HB_ENV["platform"] == "APP" ) : ?>
975  var postObject = {
976  body: {
977  cmd: "NEW_DEVICE_KEY",
978  params: appInfo
979  }
980  };
981  window.webkit.messageHandlers.interOp.postMessage(postObject);
982  <?php endif ?>
983  <?php
984  }
985  }
986  ?>
987  <?php
988  // let apps know we did an update to profile info
989  if ( $HB_ENV["platform"] == "APP" || $HB_ENV["platform"] == "ADA" ) {
990  $paramsForApps = array( "script" => "ProfileRequire" );
991  $paramsJSON = HCU_JsonEncode($paramsForApps);
992  ?>
993  var appInfo = '<?php echo $paramsJSON; ?>';
994 
995  <?php if ( $HB_ENV["platform"] == "ADA" ) : ?>
996  AndroidController.notifyCommand("PROFILE_UPDATE", appInfo);
997  <?php elseif ( $HB_ENV["platform"] == "APP" ) : ?>
998  var postObject = {
999  body: {
1000  cmd: "PROFILE_UPDATE",
1001  params: appInfo
1002  }
1003  };
1004  window.webkit.messageHandlers.interOp.postMessage(postObject);
1005  <?php endif ?>
1006  <?php
1007  }
1008  ?>
1009  <?php
1010  } else if ( $act == "auth" ) {
1011  ?>
1012 
1013  homecuTooltip.bind({
1014  confidenceTip: "<?php echo $MC->msg("Set Config Conf Msg", HCU_DISPLAY_AS_JS); ?>",
1015  reenterPassTip: "<?php echo $MC->msg("Tip Re-enter Password", HCU_DISPLAY_AS_JS); ?>",
1016  newPassTip1: "<?php echo $MC->msg( "New password requirements", HCU_DISPLAY_AS_JS ) . "<br />" . $MC->msg('Case Sensitive', HCU_DISPLAY_AS_JS); ?>",
1017  newPassTip2: "<?php echo $MC->msg("Enter NEW password again to confirm", HCU_DISPLAY_AS_JS); ?>",
1018  phoneTip: "<?php echo $MC->msg("TXT Enabled Tip", HCU_DISPLAY_AS_JS); ?>",
1019  showTooltipPrivate: "<?php echo $MC->msg('Remember Me Secure Only', HCU_DISPLAY_AS_JS); ?>"
1020  });
1021 
1022  viewModel = kendo.observable({
1023  chksecure: "<?php echo $currCheckSecure; ?>",
1024  email: "<?php echo $currEmail; ?>",
1025  emailValid: false,
1026  egenl: <?php echo $currEgenl ? "true" : "false"; ?>,
1027  emailAlerts: "<?php echo $currEmailAlerts; ?>",
1028  estatementStart: <?php echo $userNeedsEstatements ? "true" : "false"; ?>,
1029  profileAlias1: "<?php echo $currUserAlias; ?>",
1030  profileAlias2: "",
1031  confidence: "<?php echo $currConfidence; ?>",
1032  phones: "",
1033  phoneSource: new kendo.data.DataSource({
1034  data: hcuPhonesData,
1035  schema: {
1036  model: {
1037  id: "id",
1038  fields: {
1039  id: { type: "number" },
1040  value: { type: "string" },
1041  new: { type: "boolean", default: true }
1042  }
1043  }
1044  },
1045  sort: [
1046  { field: "new", dir: "asc" },
1047  { field: "id", dir: "desc" }
1048  ]
1049  }),
1050  phoneBind: function() {
1051  var grid = $("#phoneGrid").data("kendoGrid");
1052  var data = grid.dataSource.data();
1053 
1054  if (data.length >= 6) {
1055  $(".addRow").hide();
1056  } else {
1057  $(".addRow").show();
1058  }
1059  },
1060 
1061  <?php
1062  for ( $i = 0; $i < $HB_ENV['cu_chgqst_count']; $i++ ) {
1063  print "questionList{$i}: hcuChallengeQuestions,\n";
1064  print "selectedQuestion{$i}: {$currChallengeQuestions[$i]["cqid"]},\n";
1065  print "response{$i}: \"{$currChallengeQuestions[$i]["response"]}\",\n";
1066  }
1067  ?>
1068  profilePasswordCurr: "",
1069  profilePasswordNew1: "",
1070  profilePasswordNew2: "",
1071 
1072  progressStart: true,
1073  progressEmail: false,
1074  progressChallenge: false,
1075  progressAlias: false,
1076  progressPassword: false,
1077  progressDone: false,
1078  continueClick: function(e) {
1079  e.preventDefault();
1080 
1081  // clear out any current message
1082  $.homecuValidator.displayMessage( "", $.homecuValidator.settings.statusError );
1083 
1084  // figure out the next step
1085  var currStep = progressSteps.value();
1086 
1087  $.homecuValidator.setup({
1088  formValidate: "formProgress" + stepsData[currStep].name,
1089  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"
1090  });
1091  // validate the data for the current step
1092  if ( currStep > 0 ) {
1093  // validate user name
1094  if (this.progressAlias) {
1095  // this validation cannot return true of false easily becausei t uses ajax,
1096  // the step progress will be handlled inside this function.
1097  validateFormUsername(true);
1098  } else if (this.progressChallenge) {
1099  // have to validate somewhat differently on step two since a
1100  // grid does have required fields.
1101  if (validateFormStepTwo()) {
1102  // add the phone number values to the array
1103  // add phones list to hidden input as json string
1104  var security_phones = {
1105  mobile: hcuPhonesList.mobile
1106  };
1107 
1108  <?php if (intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) > 0) { ?>
1109  security_phones.mobile = [];
1110 
1111  var grid = $("#phoneGrid").data("kendoGrid");
1112  var data = grid.dataSource.data();
1113  for (var i = 0; i < data.length; i++) {
1114  if (data[i].id === -1) {
1115  continue;
1116  }
1117  var value = data[i].value;
1118  value = value.replace(/[\)\(]/g, '');
1119  value = value.replace(/\s/g, '-');
1120  security_phones.mobile.push(value);
1121  }
1122  <?php } ?>
1123 
1124  this.set("phones", JSON.stringify(security_phones));
1125 
1126  progressSteps.value( currStep + 1);
1127  } else {
1128  // there was an error so scroll to the top
1129  $("#content-wrapper").animate({ scrollTop: $("#formStatus").offset().top }, { duration: 500 } );
1130  }
1131  } else if (this.progressPassword) {
1132  var needPasswordUpdate = <?php echo HCU_JsonEncode($needPasswordUpdate); ?>;
1133  var hasPwdRequirements = <?php echo HCU_JsonEncode($hasPwdRequirements); ?>;
1134 
1135  if (needPasswordUpdate && hasPwdRequirements) {
1136  if (validateFormStepThree()) {
1137  progressSteps.value( currStep + 1);
1138  } else {
1139  // there was an error scroll to the top
1140  $("#content-wrapper").animate({ scrollTop: $("#formStatus").offset().top }, { duration: 500 } );
1141  }
1142  } else {
1143  if ($.homecuValidator.validate()) {
1144  progressSteps.value( currStep + 1 );
1145  } else {
1146  // there was an error so scroll to the top
1147  $("#content-wrapper").animate({ scrollTop: $("#formStatus").offset().top }, { duration: 500 } );
1148  }
1149  }
1150 
1151  } else if ( $.homecuValidator.validate() ) {
1152  progressSteps.value( currStep + 1 );
1153  } else {
1154  // there was an error so scroll to the top
1155  $("#content-wrapper").animate({ scrollTop: $("#formStatus").offset().top }, { duration: 500 } );
1156  }
1157  } else {
1158  // validate step 1
1159  if ($.homecuValidator.validate()) {
1160  progressSteps.value( currStep + 1 );
1161  }
1162  }
1163 
1164  if (progressSteps.value() > currStep) {
1165  // make sure back button is visible
1166  // only make visible when form is valid (mostly for first step)
1167  $("#backBtn").css( "visibility", "visible" );
1168  $("#backBtn").css( "display", "block" );
1169  }
1170  },
1171  backClick: function( e ) {
1172  e.preventDefault();
1173 
1174  $.homecuValidator.displayMessage( "", $.homecuValidator.settings.statusError );
1175 
1176  // validate the data on each step
1177  var currStep = progressSteps.value();
1178  if ( currStep > 0 ) {
1179  $.homecuValidator.setup({formValidate: "formProgress" + stepsData[currStep].name,
1180  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
1181  progressSteps.value( currStep - 1 );
1182 
1183  if ( currStep === 1 ) {
1184  // hide the back button
1185  width = $(window).width();
1186 
1187  if (width >= 768) {
1188  $("#backBtn").css( "visibility", "hidden" );
1189  } else {
1190  $("#backBtn").css( "display", "none" );
1191  }
1192  }
1193  }
1194  },
1195  cancel: function( e ) {
1196  e.preventDefault();
1197 
1198  <?php
1199  // let the apps know about the new cookie
1200  if ( $HB_ENV["platform"] == "APP" || $HB_ENV["platform"] == "ADA" ) {
1201  // Create the sC ticket value for the apps (2 = update later) (web-based is done later)
1202  $option = "sC=2";
1203  $newTicket = SetTicket($HB_ENV, $_COOKIE['Ticket'], $option );
1204 
1205  // set up the parameters based on what changed
1206  if ( $newTicket != "" ) {
1207  $paramsForApps = array( "newTicket" => $newTicket );
1208  $paramsJSON = HCU_JsonEncode($paramsForApps);
1209  ?>
1210  var appInfo = '<?php echo $paramsJSON; ?>';
1211 
1212  <?php if ( $HB_ENV["platform"] == "ADA" ) : ?>
1213  AndroidController.notifyCommand("NEW_TICKET_COOKIE", appInfo);
1214  <?php elseif ( $HB_ENV["platform"] == "APP" ) : ?>
1215  var postObject = {
1216  body: {
1217  cmd: "NEW_TICKET_COOKIE",
1218  params: appInfo
1219  }
1220  };
1221  window.webkit.messageHandlers.interOp.postMessage(postObject);
1222  <?php endif ?>
1223  <?php
1224  }
1225  }
1226 
1227  // go to self so can set correct cookie
1228  ?>
1229  document.formCancel.submit();
1230  }
1231  });
1232 
1233  kendo.bind($("#profile"), viewModel);
1234 
1235  <?php
1236  // show any errors
1237  if ( ( HCU_array_key_value('action', $HB_ENV["HCUPOST"]) == "submit" ) && count( $errorList ) ) {
1238  ?>
1239  $.homecuValidator.setup({formValidate: "formProgressStart",
1240  formErrorTitle: "<?php echo $MC->msg("Error Occurred", HCU_DISPLAY_AS_JS) ?>"});
1241 
1242  var error = <?php echo HCU_JsonEncode($errorList); ?>;
1243  $.homecuValidator.displayMessage(error, $.homecuValidator.settings.statusError);
1244  <?php
1245  }
1246  ?>
1247 
1248  // set up the submit window
1249  var submitWindow = $("<div />").kendoWindow({
1250  title: "",
1251  resizable: false,
1252  modal: true,
1253  draggable: false,
1254  actions: []
1255  });
1256 
1257 
1258  // set up the progress bar
1259  $("#progressBar").kendoProgressBar({
1260  type: "value",
1261  min: 0,
1262  max: <?php echo count( $neededSteps ) - 1; ?>,
1263  value: 0,
1264  change: function( e ) {
1265  var currStep = progressSteps.value();
1266  var stepLabel = stepsData[currStep].title;
1267  if ( currStep > 0 ) {
1268  stepLabel = stepLabel + " (" + currStep + "/" + <?php echo count( $neededSteps ) - 1; ?> + ")";
1269  }
1270  progressSteps.progressStatus.text( stepLabel );
1271  ChangeStep( currStep );
1272  },
1273  complete: function( e ) {
1274  if ( $.homecuValidator.validate({formValidate: progressPassword}) ) {
1275  ShowWaitWindow();
1276  document.formProfile.submit();
1277  }
1278  }
1279  });
1280  var progressSteps = $("#progressBar").data("kendoProgressBar");
1281 
1282  function ChangeStep( step ) {
1283  for ( var i = 0; i < stepsData.length; i++ ) {
1284  var active = ( i == step );
1285  viewModel.set( "progress" + stepsData[i]["name"], active );
1286  }
1287  }
1288 
1289  progressSteps.progressStatus.text( stepsData[0].title );
1290 
1291  <?php
1292  if ( $hasAlertEmail ) {
1293  ?>
1294  $("#updateAlertEmails").css( "display", "inline" );
1295 
1296  // MOBILE COLUMN TEMPLATE
1297  var mobile_column_data = "";
1298  mobile_column_data += "<div class=\"account_cell_desc\"><strong><?php echo $MC->msg("Alert Type", HCU_DISPLAY_AS_JS); ?>:</strong></div> <div class=\"account_cell_value\">#= type #</div>";
1299 
1300  mobile_column_data += "<div class=\"account_cell_desc\"><strong><?php echo $MC->msg("Alert Email Address", HCU_DISPLAY_AS_JS); ?>:</strong></div> <div class=\"account_cell_value\">#= email #</div>";
1301 
1302  $('#gridAlertEmails').kendoGrid({
1303  dataSource: emailAlertList,
1304  sortable: {
1305  mode: "single",
1306  allowUnsort: false
1307  },
1308  pageable: false,
1309  autoBind: true,
1310  editable: false,
1311  selectable: "row",
1312  columns: [
1313  { field: "type", title: "<?php echo $MC->msg("Alert Type", HCU_DISPLAY_AS_JS); ?>", editable: false, minScreenWidth: 768 },
1314  { field: "email", title: "<?php echo $MC->msg("Alert Email Address", HCU_DISPLAY_AS_JS); ?>", editable: false, minScreenWidth: 768 },
1315  { title: "<?php echo $MC->msg("Alerts", HCU_DISPLAY_AS_JS); ?>", template: mobile_column_data
1316  },
1317  { field: "choice", title: "<?php echo $MC->msg("Update to above email", HCU_DISPLAY_AS_JS); ?>", width: 65,
1318  template: "<input type='checkbox' id='email#=id#' #= choice === 'Y' ? 'checked=checked' : '' #></input>",
1319  editable: false
1320  }
1321  ],
1322  change: function(e) {
1323  e.preventDefault();
1324 
1325  var selectedRow = this.dataItem(this.select());
1326 
1327  // cause the check box to be clicked
1328  // NOTE: the onclick handler will return "false" to prevent a "double click" when clicking on the checkbox itself
1329  $("#email"+selectedRow["id"]).prop("checked", !$("#email"+selectedRow["id"]).prop("checked"));
1330  updateEmailAlerts();
1331  return false;
1332  },
1333  dataBound: function () {
1334  $("table tbody tr").hover(
1335  function() {
1336  $(this).toggleClass("k-state-hover");
1337  }
1338 
1339  );
1340  }
1341  });
1342 
1343  // handlers for any possible checked checkbox
1344  <?php
1345  }
1346  ?>
1347 
1348  <?php
1349  // only need password fields if updating password
1350  if ( $needPasswordUpdate ) {
1351  if ( $hasPwdRequirements ) {
1352  ?>
1353 
1354  homecuTooltip.bind({specialTip: "<?php echo $MC->msg("Special characters allowed", HCU_DISPLAY_AS_JS); ?>: <?php echo implode( " ", explode( ",", $specialCharacters ) ); ?>"});
1355 
1356  $("#profilePasswordNew1").keyup(function () {
1357  // see which requirements are passing or failing
1358  var testVal = $("#profilePasswordNew1").val();
1359  var testLength = false;
1360  var testUpper = false;
1361  var testLower = false;
1362  var testDigit = false;
1363  var testSpeciel = false;
1364 
1365  testLength = testVal.length >= pwdRequirements['len'];
1366 
1367  testUpper = RegExp("([A-Z].*){" + pwdRequirements['upper'] + "}");
1368  testUpper = testUpper.test(testVal);
1369 
1370  testLower = RegExp("([a-z].*){" + pwdRequirements['lower'] + "}");
1371  testLower = testLower.test(testVal);
1372 
1373  testDigit = RegExp("(\\d.*){" + pwdRequirements['digit'] + "}");
1374  testDigit = testDigit.test(testVal);
1375 
1376  testSpecial = pwdSpecial.join("|");
1377  testSpecial = testSpecial.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
1378  testSpecial = RegExp("([" + testSpecial + "].*){" + pwdRequirements['spec'] + "}");
1379  testSpecial = testSpecial.test(testVal);
1380 
1381  // test overal length requirement
1382  if (pwdRequirements["len"] > 0) {
1383  if ( testLength ) {
1384  $("#len .fa").removeClass("fa-times").addClass("fa-check");
1385  $("#len").css("color", "green");
1386  viewModel.progressPassword = true;
1387  } else {
1388  $("#len .fa").removeClass("fa-check").addClass("fa-times");
1389  $("#len").css("color", "red");
1390  viewModel.progressPassword = false;
1391  }
1392  }
1393 
1394  if ( pwdRequirements["upper"] > 0 ) {
1395  if ( testUpper ) {
1396  $("#upper .fa").removeClass("fa-times").addClass("fa-check");
1397  $("#upper").css("color", "green");
1398  viewModel.progressPassword = true;
1399  } else {
1400  $("#upper .fa").removeClass("fa-check").addClass("fa-times");
1401  $("#upper").css("color", "red");
1402  viewModel.progressPassword = false;
1403  }
1404  }
1405 
1406  if ( pwdRequirements["lower"] > 0 ) {
1407  if ( testLower ) {
1408  $("#lower .fa").removeClass("fa-times").addClass("fa-check");
1409  $("#lower").css("color", "green");
1410  viewModel.progressPassword = true;
1411  } else {
1412  $("#lower .fa").removeClass("fa-check").addClass("fa-times");
1413  $("#lower").css("color", "red");
1414  viewModel.progressPassword = false;
1415  }
1416  }
1417 
1418  if ( pwdRequirements["digit"] > 0 ) {
1419  if ( testDigit ) {
1420  $("#digit .fa").removeClass("fa-times").addClass("fa-check");
1421  $("#digit").css("color", "green");
1422  viewModel.progressPassword = true;
1423  } else {
1424  $("#digit .fa").removeClass("fa-check").addClass("fa-times");
1425  $("#digit").css("color", "red");
1426  viewModel.progressPassword = false;
1427  }
1428  }
1429 
1430  if ( pwdRequirements["spec"] > 0 ) {
1431  if ( testSpecial ) {
1432  $("#spec .fa").removeClass("fa-times").addClass("fa-check");
1433  $("#spec").css("color", "green");
1434  viewModel.progressPassword = true;
1435  } else {
1436  $("#spec .fa").removeClass("fa-check").addClass("fa-times");
1437  $("#spec").css("color", "red");
1438  viewModel.progressPassword = false;
1439  }
1440  }
1441  });
1442  <?php
1443  }
1444  ?>
1445 
1446  function revertPassword() {
1447  $("#showPasswordText").val( "" );
1448  $("#showPasswordText").css( "display", "none" );
1449  $("#profilePasswordNew1").css( "display", "inline" );
1450  }
1451 
1452  $("#showPassword").click(function() {
1453  $("#showPasswordText").val( $("#profilePasswordNew1").val() )
1454  $("#profilePasswordNew1").css( "display", "none" );
1455  $("#showPasswordText").css( "display", "inline" );
1456  setTimeout(revertPassword, 1000);
1457  });
1458  <?php
1459  }
1460  ?>
1461 
1462  $('#testAlias').click(function() {
1463  validateFormUsername(false);
1464  });
1465 
1466  // set up a window for showing public computer info
1467  infoWindow = $('#publicInfo');
1468  infoWindow.kendoWindow({
1469  modal: true,
1470  maxWidth: "500px",
1471  visible: false,
1472  resizable: false
1473  });
1474 
1475  <?php
1476  } else {
1477  ?>
1478  window.location.href = "<?php echo $_COOKIE[$HB_ENV['loginscript']]; ?>";
1479  <?php
1480  }
1481  ?>
1482  // not let <enter> submit anything
1483  $(window).keydown(function(e){
1484  if(e.keyCode == 13) {
1485  e.preventDefault();
1486  return false;
1487  }
1488  });
1489 
1490 <?php
1491  if ( $hasAlertEmail ) {
1492 ?>
1493  // CHECK SIZE TO HIDE LAST COLUMN, LAST COLUMN ONLY VISIBLE IN MOBILE
1494  var width = $(window).width();
1495  var grid = $("#gridAlertEmails").data("kendoGrid");
1496 
1497  // INITIAL CHECK IN PAGE OPEN
1498  if ($(window).width() >= 768) {
1499  grid.hideColumn(2);
1500 
1501  // hide but save space as placeholder
1502  $("#backBtn").css( "visibility", "hidden" );
1503  } else {
1504  grid.showColumn(2);
1505 
1506  // remove from dom
1507  $("#backBtn").css( "display", "none" );
1508  }
1509 
1510  // CHECK ON PAGE RESIZE
1511  $(window).resize(function() {
1512  width = $(window).width();
1513 
1514  if (width >= 768) {
1515  grid.hideColumn(2);
1516  } else {
1517  grid.showColumn(2);
1518  }
1519  });
1520 <?php
1521  }
1522 ?>
1523  <?php if (intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) > 0) { ?>
1524  var phoneGrid = $("#phoneGrid").data("kendoGrid");
1525  $.each(phoneGrid.columns, function(idx, column) {
1526  if (column.field === "value")
1527  column.editor = phoneEdit;
1528  });
1529 
1530  $("#phoneGrid").on("click", ".removeBtn", function() {
1531  var row = $(this).closest("tr");
1532  var grid = $("#phoneGrid").data("kendoGrid");
1533  var data = grid.dataSource.data();
1534 
1535  grid.removeRow(row);
1536  return false;
1537  });
1538 
1539  $("#phoneGrid").on("click", ".addRow", function() {
1540  var row = $(this).closest("tr");
1541  var grid = $("#phoneGrid").data("kendoGrid");
1542  var data = grid.dataSource.data();
1543 
1544  grid.addRow();
1545  return false;
1546  });
1547  <?php } ?>
1548 
1549  // Must hide confirmation email until
1550  // the user makes a change to the original
1551  // email
1552 
1553  // On change, display the email field
1554  // add required and homecu validator fields
1555 
1556  // Also if email is required, disable the checkbox
1557  // after checking.
1558  $("#emailConfirmSection").hide();
1559  $("#emailAddress").change(function(){
1560  $("#profileEmailValid").prop("checked", true);
1561  $("#profileEmailValid").prop("disabled", true);
1562  $("#emailConfirmSection").show();
1563  $("#emailAddressConfirm").attr("required", "required");
1564  $("#emailAddressConfirm").attr("homecu-match", "email");
1565  $("#emailAddressConfirm").attr("homecu-equals", "email_match");
1566  });
1567  });
1568 
1569  function validateFormStepThree() {
1570  var formValid = $.homecuValidator.validate();
1571 
1572  var testStepThree = false;
1573  var testVal = $("#profilePasswordNew1").val();
1574  var testLength = testVal.length >= pwdRequirements['len'];
1575 
1576  var testUpper = RegExp("([A-Z].*){" + pwdRequirements['upper'] + "}");
1577  testUpper = testUpper.test(testVal);
1578 
1579  var testLower = RegExp("([a-z].*){" + pwdRequirements['lower'] + "}");
1580  testLower = testLower.test(testVal);
1581 
1582  var testDigit = RegExp("(\\d.*){" + pwdRequirements['digit'] + "}");
1583  testDigit = testDigit.test(testVal);
1584 
1585  var testSpecial = pwdSpecial.join("|");
1586  testSpecial = testSpecial.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
1587  testSpecial = RegExp("([" + testSpecial + "].*){" + pwdRequirements['spec'] + "}");
1588  testSpecial = testSpecial.test(testVal);
1589 
1590  if (pwdRequirements['len'] > 0 && testLength == false) { testStepThree = false; }
1591  else if (pwdRequirements['upper'] > 0 && testUpper == false) { testStepThree = false; }
1592  else if (pwdRequirements['lower'] > 0 && testLower == false) { testStepThree = false; }
1593  else if (pwdRequirements['digit'] > 0 && testDigit == false) { testStepThree = false; }
1594  else if (pwdRequirements['spec'] > 0 && testSpecial == false) { testStepThree = false; }
1595  else { testStepThree = true; }
1596 
1597  var stepThreeError = "<?php echo $MC->msg('New password requirements', HCU_DISPLAY_AS_HTML) ?>";
1598  var errors = $.homecuValidator.homecuKendoValidator.errors();
1599 
1600  // strip the first message if length is 0
1601  if (!testLength) {
1602  var index = $.inArray(stepThreeError, errors);
1603  if (index > -1) {
1604  errors.splice(index, 1);
1605  }
1606  }
1607 
1608  if (!testStepThree) {
1609  errors.push(stepThreeError);
1610  $.homecuValidator.displayMessage(errors, $.homecuValidator.settings.statusError);
1611  }
1612 
1613  return formValid && testStepThree;
1614  }
1615 
1616  function validateFormStepTwo() {
1617  // validate other fields first
1618  var valid = $.homecuValidator.validate();
1619 
1620  <?php if (intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) > 0) { ?>
1621  var grid = $("#phoneGrid").data("kendoGrid");
1622  var data = grid.dataSource.data();
1623  var regex = new RegExp(/^[2-9]\d{2}-\d{3}-\d{4}$/);
1624 
1625  for (var i = 0; i < data.length; i++) {
1626  var id = data[i].id;
1627 
1628  if (id === -1) {
1629  continue;
1630  }
1631 
1632  var phone = data[i].value;
1633  phone = phone.replace(/[_\(\)]/g, '');
1634  phone = phone.replace(/\s/g, '-');
1635  var phoneValid = regex.test(phone);
1636 
1637  // if invalid, append this message onto current errors
1638  if (phoneValid === false) {
1639  valid = false;
1640  var message = "<?php echo $MC->msg("Phone Invalid", HCU_DISPLAY_AS_JS); ?>";
1641  var errors = $.homecuValidator.homecuKendoValidator.errors();
1642  var show = errors.concat(message);
1643 
1644  $.homecuValidator.displayMessage(show, $.homecuValidator.settings.statusError);
1645  }
1646  }
1647  <?php } ?>
1648 
1649  return valid;
1650  }
1651 
1652  // this function is used by the test username button and the continue button
1653  // the updateStep variable tells where the call came frome.
1654  // updateStep = true means it came from the continue button and needs to validatet
1655  // the form as well
1656  function validateFormUsername(updateStep) {
1657  var userAlias = viewModel.profileAlias1;
1658 
1659  // disable the button
1660  $("#testAlias").prop("disabled","disabled");
1661  $("#testAliasResult").html( "" );
1662  $("#testAliasResult").css( "display", "inline" );
1663 
1664  // start AJAX
1665  var parameters = { "action": "test_alias",
1666  "alias": userAlias };
1667  $.ajax({
1668  url: "<?php echo $HB_ENV['loginpath'] . "/" . $HB_ENV['currentscript'] . "?" . $HB_ENV['cuquery']; ?>",
1669  type: "post",
1670  data: parameters
1671  })
1672  .done(function( data, textStatus, jqXHR ) {
1673  // Show the result
1674  var message = null;
1675  if (data.result) {
1676 
1677  // only progress the steps if username is valid
1678  if (updateStep) {
1679 
1680  // only validate form if username is valid
1681  if ($.homecuValidator.validate()) {
1682  var step = $("#progressBar").data("kendoProgressBar").value();
1683  $("#progressBar").data("kendoProgressBar").value( step+1 );
1684  }
1685  } else {
1686  message = "<i class='fa fa-check-circle fa-2x' style='color:green;'></i>";
1687  $.homecuValidator.hideMessage();
1688  }
1689  } else {
1690  // only display no sign if not updating steps
1691  // this means it came from test button
1692  if (updateStep) {
1693 
1694  } else {
1695  message = "<i class='fa fa-ban fa-2x' style='color:red;'></i>";
1696  }
1697  $.homecuValidator.displayMessage(data.message, $.homecuValidator.settings.statusError);
1698  }
1699 
1700  $("#testAliasResult").html( message );
1701  })
1702  .fail(function(jqXHR, textStatus, errorThrown) {
1703  $("#testAliasResult").html( "<?php echo $MC->msg( "Error" , HCU_DISPLAY_AS_HTML); ?>" );
1704  $("#testAliasResult").css("color", "red");
1705  })
1706  .always(function(jqXHR, textStatus, errorThrown) {
1707  $("#testAlias").removeProp("disabled");
1708  $("#testAliasResult").delay(5000).fadeOut(100);
1709  });
1710 
1711  }
1712 
1713  function phoneEdit(container, options) {
1714  var maskedTextBox = $("<input name=\"" + options.field + "\">")
1715  .appendTo(container)
1716  .kendoMaskedTextBox({
1717  mask: "(000) 000-0000",
1718  change: function() {
1719  var value = this.value();
1720  var valueStrip = value.replace(/_/g, '');
1721  valueStrip = valueStrip.replace(/\s/g, '-');
1722  valueStrip = valueStrip.replace(/[\(\)]/g, '');
1723 
1724  options.model.phone = valueStrip;
1725  }
1726  })
1727  .data("kendoMaskedTextBox");
1728  }
1729 
1730  function show_help()
1731  {
1732  ShowNotice('<?php echo $rulesURLNoticeOnly; ?>');
1733  }
1734 
1735 <?php
1736  if ( $hasAlertEmail ) {
1737 ?>
1738  function updateEmailAlerts() {
1739  var alertEmails = "";
1740  var total = emailAlertList.length;
1741  for ( var i = 0; i < total; i++ ) {
1742  // get the row
1743  var row = emailAlertList[i];
1744 
1745  // test if selected to update
1746  var test = $("#email"+i);
1747  if ( $("#email"+i).prop('checked') ) {
1748  if ( alertEmails.length > 0 )
1749  alertEmails = alertEmails + "|";
1750  alertEmails = alertEmails + row["email"];
1751  }
1752  }
1753 
1754  // set the observable value
1755  viewModel.set( "emailAlerts", alertEmails );
1756  }
1757 <?php
1758  }
1759 ?>
1760 </script>
1761 <style>
1762 #profileEdit {
1763  min-width: 300px;
1764  max-width: 700px;
1765 }
1766 .k-tooltip-content { text-align: left; max-width: 300px; }
1767 #progressStart a {text-decoration: underline !important; cursor: pointer; color: blue; }
1768 #passRequirements {
1769  display: inline-block;
1770  vertical-align: top;
1771  width: 210px;
1772  margin: 10px;
1773  background-color: #F0F0F0;
1774  padding: 5px 5px 5px 5px;
1775  min-height: 50px;
1776  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
1777  border: 1px solid rgba(255,255,255,0.2);
1778  -moz-border-radius: 3px;
1779  -webkit-border-radius: 3px;
1780  }
1781 // get the dropdowns to resize to a small width
1782 .k-dropdown .k-input,.k-selectbox .k-input {
1783  white-space: normal;
1784 }
1785 
1786 .pwd-fail {color:red}
1787 .pwd-pass {color: green}
1788 #profileHolder .row {
1789  margin-top: 1em;
1790 }
1791 .profile-margin-when-narrow {
1792  margin-top: 1em;
1793 }
1794 
1795 #phoneGrid .k-grid-header {
1796  display: none;
1797 }
1798 
1799 #phoneGrid .removeBtn {
1800  color: #A00;
1801 }
1802 
1803 #phoneGrid .addBtn {
1804  color: #507f50;
1805 }
1806 /* Small devices @screen-sm-min (tablets, 768px and up) */
1807 @media (min-width: 768px) {
1808  .profile-margin-when-narrow {
1809  margin-top: 0;
1810  }
1811 }
1812 .account_cell_desc {
1813  width: 50%;
1814  float: left;
1815 
1816  text-align: left;
1817 }
1818 
1819 .account_cell_value {
1820  width: 50%;
1821  float: left;
1822 
1823  text-align: right;
1824 }
1825 
1826 @media only screen and (max-width: 500px) {
1827  .account_cell_desc {
1828  width: 100%;
1829  text-align: left;
1830  }
1831 
1832  .account_cell_value {
1833  width: 100%;
1834  text-align: left;
1835  }
1836 }
1837 
1838 .local-container-margin {
1839  margin: 15px 0;
1840 }
1841 </style>
1842 <?php // Common outer part for consistency: div, form, div, div, span, span
1843 ?>
1844 <div class="k-content container-fluid" id="profile">
1845  <form method="post" id="formCancel" name="formCancel" action='<?php echo $HB_ENV["loginpath"] . "/{$HB_ENV['currentscript']}?" . $HB_ENV["cuquery"] ?>'>
1846  <input type='hidden' name='action' value='cancel_profile' />
1847  </form>
1848  <form method='post' id='formProfile' name='formProfile' action='<?php echo $HB_ENV["loginpath"] . "/{$HB_ENV['currentscript']}?" . $HB_ENV["cuquery"] ?>'>
1849  <input type='hidden' name='action' value='submit' />
1850  <input type='hidden' name='chkSecure' data-bind="value: chksecure" />
1851  <input type="hidden" name='emailAddress' data-bind="value: email" />
1852  <input type="hidden" name='emailValid' data-bind="value: emailValid" />
1853  <input type='hidden' name='profileEgenl' data-bind="value: egenl" />
1854  <input type='hidden' name='profileEmailAlerts' data-bind="value: emailAlerts" />
1855  <input type='hidden' name='estatementStart' data-bind="value: estatementStart" />
1856  <input type='hidden' name='estatementNoticeId' value='<?php echo $esNoticeId ?>' />
1857  <input type="hidden" name="security_confidence" data-bind="value: confidence" />
1858  <input type="hidden" name="security_phones" data-bind="value: phones" />
1859  <?php
1860  // set up a question "set" for each one configured
1861  for ( $i = 0; $i < $HB_ENV['cu_chgqst_count']; $i++ )
1862  {
1863  ?>
1864  <input type='hidden' name="challengeQuestion<?php echo $i ?>" data-bind="value: selectedQuestion<?php echo $i; ?>" />
1865  <input type="hidden" name="response<?php echo $i; ?>" data-bind="value: response<?php echo $i; ?>" />
1866  <?php
1867  }
1868  ?>
1869  <input type="hidden" name="profileAlias1" data-bind="value: profileAlias1" />
1870  <input type="hidden" name="profileAlias2" data-bind="value: profileAlias2" />
1871  <input type="hidden" name="profilePasswordCurr" data-bind="value: profilePasswordCurr" />
1872  <input type="hidden" name="profilePasswordNew1" data-bind="value: profilePasswordNew1" />
1873  <input type="hidden" name="profilePasswordNew2" data-bind="value: profilePasswordNew2" />
1874  </form>
1875  <div id='publicInfo' style='display:none;'>
1876  <?php echo $MC->combo_msg('Public Computer Is', HCU_DISPLAY_AS_HTML); ?>
1877  </div>
1878 
1879  <div id="profileEdit" class="k-content">
1880  <div class='col-xs-12'>
1881  <div id="profileHolder" style='width:100%;' class="hcuSpacer">
1882  <div id="progressBar" style='width:100%;'></div>
1883  <?php
1884  // Step First - Explain
1885  ?>
1886  <div id='progressStart' data-bind="visible: progressStart">
1887  <form id='formProgressStart'>
1888  <div class="row">
1889  <div class="col-xs-12">
1890  <span style='font-style: italic; font-size: large;'><?php echo $MC->msg('Update account settings.', HCU_DISPLAY_AS_HTML); ?></span>
1891  </div>
1892  </div>
1893  <?php
1894  // see if a change is being forced
1895  if ($HB_ENV['Ffchg'] == 'Y'): ?>
1896  <div class="row">
1897  <div class="col-xs-12">
1898  <span style='font-weight:bold; color:red;'>
1899  <?php if ($HB_ENV['Ffremain'] > 1): ?>
1900  <?php echo $MC->combo_msg("Login Expiring", HCU_DISPLAY_AS_HTML, "#REMAIN#", $HB_ENV['Ffremain']); ?>
1901  <?php else: ?>
1902  <?php echo $MC->msg('Login Expired Profile', HCU_DISPLAY_AS_HTML); ?>
1903  <?php endif; ?>
1904  </span>
1905  </div>
1906  </div>
1907  <?php endif;
1908  // see if a change is being forced
1909  if ( ($HB_ENV['Ffreset'] & $MEM_FORCE_RESET) > 0 ): ?>
1910  <div class="row">
1911  <div class="col-xs-12">
1912  <span style='font-weight:bold; color:red;'>
1913  <?php if ($HB_ENV['Ffremain'] > 1): ?>
1914  <?php echo $MC->combo_msg("Challenge Update", HCU_DISPLAY_AS_HTML, "#REMAIN#", $HB_ENV['Ffremain']); ?>
1915  <?php else: ?>
1916  <?php echo $MC->msg('Challenge Expired Profile', HCU_DISPLAY_AS_HTML); ?>
1917  <?php endif; ?>
1918  </span>
1919  </div>
1920  </div>
1921  <?php endif;
1922  // don't show the remembering of the device if coming from the apps
1923  if ( $HB_ENV["platform"] != "APP" && $HB_ENV["platform"] != "ADA" ): ?>
1924  <div class="row">
1925  <div class="col-xs-12">
1926  <h4 class="h4"><?php echo $MC->msg('Should We Remember This', HCU_DISPLAY_AS_HTML); ?></h4>
1927  <div class="radio">
1928  <label for="chksecureY">
1929  <input type="radio" name="chksecure" id="chksecureY" value="Y" data-bind="checked: chksecure" required data-homecuCustomRadio-msg="<?php echo $MC->msg('Remember Error', HCU_DISPLAY_AS_HTML); ?>">
1930  <span><?php echo $MC->msg('Remember Yes', HCU_DISPLAY_AS_HTML); ?></span><br>
1931  <span class="hcu-secondary"><span class="hcu-secondary-text"><?php echo $MC->msg('Remember Yes Message', HCU_DISPLAY_AS_HTML); ?></span></span>
1932  </label>
1933  </div>
1934  <div class="radio">
1935  <label for="chksecureN">
1936  <input type="radio" name="chksecure" id="chksecureN" value="N" data-bind="checked: chksecure" required data-homecuCustomRadio-msg="<?php echo $MC->msg('Remember Error', HCU_DISPLAY_AS_HTML); ?>">
1937  <span><?php echo $MC->msg('Remember No', HCU_DISPLAY_AS_HTML); ?></span><br>
1938  <span class="hcu-secondary"><span class="hcu-secondary-text"><?php echo $MC->msg('Remember No Message', HCU_DISPLAY_AS_HTML); ?></span></span>
1939  </label>
1940  </div>
1941  </div>
1942  </div>
1943  <?php endif; ?>
1944  <script language='javascript'>
1945  <!--
1946  function whatpub() {
1947  infoWindow.data("kendoWindow").center().open();
1948  }
1949  // -->
1950  </script>
1951  </form>
1952  </div>
1953  <?php
1954  // Step - Enter Email address
1955  ?>
1956  <div id='progressEmail' data-bind="visible: progressEmail">
1957  <form id="formProgressEmail" class='formInputx'>
1958  <div class="row">
1959  <div class="col-xs-12 col-sm-6 local-container-margin">
1960 
1961  <label for="emailAddress">
1962  <?php echo $MC->msg('Email Address', HCU_DISPLAY_AS_HTML); ?>:
1963  </label>
1964 
1965  <input type="email" name='emailAddress'
1966  id='emailAddress'
1967  class="k-textbox hcu-all-100 email_match"
1968  placeholder="<?php echo $MC->msg('Email Address', HCU_DISPLAY_AS_HTML); ?>"
1969  data-bind="value: email"
1970  homecu-match="email"
1971  data-email-msg="<?php echo $MC->msg('Email appears invalid', HCU_DISPLAY_AS_HTML) ?>"
1972  data-homecuCustomMatch-msg="<?php echo $MC->msg('Email appears invalid', HCU_DISPLAY_AS_HTML) ?>"
1973  data-required-msg="<?php echo $MC->msg('EMail Missing', HCU_DISPLAY_AS_HTML) ?>"
1974  required />
1975  </div>
1976 
1977  <div class="col-xs-12 col-sm-6 local-container-margin" id="emailConfirmSection">
1978 
1979  <label for="emailAddressConfirm">
1980  <?php echo $MC->msg('Confirm Email Address', HCU_DISPLAY_AS_HTML); ?>:
1981  </label>
1982 
1983  <input type="email" name='emailAddressConfirm'
1984  id='emailAddressConfirm'
1985  class="k-textbox hcu-all-100 email_match"
1986  placeholder="<?php echo $MC->msg('Email Address', HCU_DISPLAY_AS_HTML); ?>"
1987  data-email-msg="<?php echo $MC->msg('Email appears invalid', HCU_DISPLAY_AS_HTML) ?>"
1988  data-homecuCustomMatch-msg="<?php echo $MC->msg('Email appears invalid', HCU_DISPLAY_AS_HTML) ?>"
1989  data-homecuCustomEquals-msg="<?php echo $MC->msg('Email Confirm Mismatch', HCU_DISPLAY_AS_HTML); ?>"
1990  data-required-msg="<?php echo $MC->msg('Please confirm email', HCU_DISPLAY_AS_HTML) ?>"/>
1991  </div>
1992  </div>
1993  <?php
1994  // Only require the email validation if the member needs to validate email. Email could be asked
1995  // for as part of the forced security challenge, too.
1996  if ( $emailRequired ) {
1997  ?>
1998  <div class="row">
1999  <div class="col-xs-12 checkbox">
2000  <label>
2001  <input type='checkbox'
2002  name='profileEmailValid'
2003  id='profileEmailValid'
2004  value='Y'
2005  required
2006  data-required-msg="<?php echo $MC->msg("Please confirm email", HCU_DISPLAY_AS_HTML); ?>."
2007  data-bind="checked: emailValid" />
2008  <?php echo $MC->msg('Bad Email Flag 2', HCU_DISPLAY_AS_HTML); ?>
2009  </label>
2010  </div>
2011  </div>
2012  <?php
2013  }
2014  ?>
2015  <div class="row">
2016  <div class="col-xs-12 checkbox">
2017  <label>
2018  <input type='checkbox' name='profileEgenl' id='profileEgenl' value='Y' data-bind="checked: egenl" />
2019  <?php echo $MC->msg('Yes Email List', HCU_DISPLAY_AS_HTML); ?>
2020  </label>
2021  </div>
2022  </div>
2023  </form>
2024 
2025  <div id="updateAlertEmails" style="display: none;">
2026  <span style='text-align: center; width:100%;'><hr style='width:65%;' /></span>
2027  <div class="row">
2028  <div class="col-xs-12">
2029  <i><?php echo $MC->msg( "Alert email message.", HCU_DISPLAY_AS_HTML ); ?></i>
2030  <div id="gridAlertEmails"></div>
2031  </div>
2032  </div>
2033  </div>
2034 
2035  <?php
2036  // only allow the user to start eStatements if the CU supports them and the member isn't signed up yet
2037  if ( $userNeedsEstatements ) {
2038  ?>
2039  <span style='text-align: center; width:100%;'><hr /></span>
2040  <div class="well">
2041  <form class='formInputx'>
2042  <label><?php echo $MC->msg('Start e-Statements', HCU_DISPLAY_AS_HTML); ?>:</label>
2043  <div class="k-block" style="max-height: 150px;overflow: auto; background-color: white;">
2044  <?php echo $esTermsText; ?>
2045  </div>
2046  <div class="checkbox">
2047  <label>
2048  <input type='checkbox'
2049  name='estatementStart'
2050  id='estatementStart'
2051  value='Y'
2052  data-bind="checked: estatementStart" /> <?php echo $esAccept ?>
2053  </label>
2054  </div>
2055  </form>
2056  </div>
2057  <?php
2058  }
2059  ?>
2060  </div>
2061  <?php
2062  // Step - Enter Confidence Word and Security Challenge Answers
2063  ?>
2064  <div id='progressChallenge' data-bind="visible: progressChallenge">
2065  <form id="formProgressChallenge" class='formInputx'>
2066  <div class="row">
2067  <div class="col-xs-12">
2068  <label for="security_confidence"><?php echo $MC->msg('Set Config Conf Label', HCU_DISPLAY_AS_HTML); ?>: <span class="fa fa-question-circle-o" id="confidenceTip"></span></label>
2069  </div>
2070  <div class="col-xs-12">
2071  <input type="text"
2072  id="security_confidence"
2073  name="security_confidence"
2074  placeholder="<?php echo $MC->msg('Set Config Conf Label', HCU_DISPLAY_AS_HTML); ?>"
2075  maxlength=20
2076  data-bind="value: confidence"
2077  required
2078  data-required-msg="<?php echo $MC->msg('Set Config Enter Word', HCU_DISPLAY_AS_HTML); ?>"
2079  class="k-textbox hcu-all-100"
2080  style="max-width: 400px;"/>
2081  </div>
2082  </div>
2083 
2084 
2085  <!-- if use mfa confidence word flag is set, do not show mfa questions -->
2086  <?php if (intval($HB_ENV['flagset3'] & GetFlagsetValue("CU3_MFA_AUTHCODE")) === 0) {?>
2087  <?php
2088  if ( $HB_ENV['cu_chgqst_count'] > 0 ) {
2089  echo "<hr style='text-align:left; margin-left:0; width:100%; color:gray; height:1px;'>";
2090 
2091  echo $MC->msg('Set Config Challenge Label', HCU_DISPLAY_AS_HTML);
2092  }
2093 
2094  // set up a question "set" for each one configured
2095  for ( $i = 0; $i < $HB_ENV['cu_chgqst_count']; $i++ )
2096  {
2097  // TODO: Need to put two new messages in dictionary.
2098  ?>
2099  <div class="row">
2100  <div class="col-xs-12 col-sm-3">
2101  <label for="challenge<?php echo $i; ?>"><?php echo $MC->msg('Set Config Question', HCU_DISPLAY_AS_HTML) . " " . ($i+1); ?>:</label>
2102  </div>
2103  <div class="col-xs-12 col-sm-8">
2104  <select id="challengeQuestion<?php echo $i ?>"
2105  name="challengeQuestion<?php echo $i ?>"
2106  class="unique_select"
2107  data-role="dropdownlist"
2108  data-text-field="display"
2109  data-value-field="cqid"
2110  data-bind="source: questionList<?php echo $i; ?>, value: selectedQuestion<?php echo $i; ?>"
2111  homecu-distinct="unique_select"
2112  data-homecuCustomDistinct-msg="<?php echo $MC->msg("Challenge questions once", HCU_DISPLAY_AS_HTML); ?>."
2113  style='width:100%;'></select><span class="k-invalid-msg" data-for="challengeQuestion<?php echo $i ?>"></span>
2114  <div style="height: 5px;"></div>
2115  <input type="text"
2116  id="challenge<?php echo $i; ?>"
2117  name="challenge<?php echo $i; ?>"
2118  placeholder="<?php echo $MC->msg('Set Config Response', HCU_DISPLAY_AS_HTML); ?>"
2119  data-bind="value: response<?php echo $i; ?>"
2120  required
2121  data-required-msg="<?php echo $MC->msg("Challenge answer blank", HCU_DISPLAY_AS_HTML); ?>."
2122  class="k-textbox"
2123  style='width:100%;'/>
2124  </div>
2125  </div>
2126  <?php
2127  }
2128  ?>
2129  <?php } else { ?>
2130  <div class="row">
2131  <div class="col-xs-12">
2132  <label for="security_phone">
2133  <span><?php echo $MC->msg('TXT Enabled', HCU_DISPLAY_AS_HTML); ?>:</span>
2134  <span class="fa fa-question-circle-o" id="phoneTip"></span>
2135  </label>
2136 
2137  <div id="phoneGrid" class="hcu-all-100" style="max-width: 400px;"
2138  data-role="grid"
2139  data-row-template="phoneRow"
2140  data-editable="{
2141  confirmation: false
2142  }"
2143  data-columns="[
2144  { width: 30 },
2145  { title: 'Mobile', field: 'value' }
2146  ]"
2147  data-bind="
2148  source: phoneSource,
2149  events: { dataBound: phoneBind }"
2150  ></div>
2151  </div>
2152  </div>
2153  <?php } ?>
2154  </form>
2155  <br/>
2156  </div>
2157  <?php
2158  // Step - Alias/Nickname
2159  ?>
2160  <div id='progressAlias' data-bind="visible: progressAlias">
2161  <form id="formProgressAlias" class='formInputx'>
2162 
2163  <div class="row">
2164  <div class="col-xs-12">
2165  <label for="profileAlias1"><?php echo $MC->msg('Username', HCU_DISPLAY_AS_HTML); ?>:</label>
2166  </div>
2167  <span class="hcu-secondary col-xs-12"><span class="hcu-secondary-text"><?php echo $MC->combo_msg('Username Set',HCU_DISPLAY_AS_HTML,'#MAYMUST#',"must"); ?></span></span>
2168  <div class="col-xs-12">
2169  <input type="text"
2170  id="profileAlias1"
2171  name="profileAlias1"
2172  placeholder="<?php echo $MC->msg('Username', HCU_DISPLAY_AS_HTML); ?>"
2173  data-bind="value: profileAlias1"
2174  <?php echo ( $aliasRequired ? "required" : "") ?>
2175  data-required-msg="<?php echo $MC->msg('Username Required', HCU_DISPLAY_AS_HTML) ?>"
2176  homecu-minlen="6"
2177  data-homecuCustomMinLen-msg="<?php echo $MC->msg('Username too short', HCU_DISPLAY_AS_HTML) ?>"
2178  class="k-textbox must_equal_alias"
2179  style='width:100%; max-width:400px;'/>
2180  </div>
2181  </div>
2182  <div class="row">
2183  <div class="col-xs-12 col-sm-6">
2184  <a id='testAlias' class='k-button'><?php echo $MC->msg("Test Username", HCU_DISPLAY_AS_HTML); ?></a>
2185  </div>
2186  <div class="col-xs-12 col-sm-5">
2187  <span id='testAliasResult'>&nbsp;</span>
2188  </div>
2189  </div>
2190 
2191  <div class="row">
2192  <div class="col-xs-12">
2193  <label for="profileAlias2"><?php echo $MC->msg('Confirm Username', HCU_DISPLAY_AS_HTML); ?>:</label>
2194  </div>
2195  <span class="hcu-secondary col-xs-12"><span class="hcu-secondary-text"><?php echo $MC->msg("Username again to confirm", HCU_DISPLAY_AS_HTML); ?></span></span>
2196  <div class="col-xs-12">
2197  <input type="text"
2198  id="profileAlias2"
2199  name="profileAlias2"
2200  placeholder="<?php echo $MC->msg('Confirm Username', HCU_DISPLAY_AS_HTML); ?>"
2201  data-bind="value: profileAlias2"
2202  <?php echo ( $aliasRequired ? "required" : "") ?>
2203  data-required-msg="<?php echo $MC->msg('Username Required', HCU_DISPLAY_AS_HTML) ?>"
2204  homecu-minlen="6"
2205  data-homecuCustomMinLen-msg="<?php echo $MC->msg('Username too short', HCU_DISPLAY_AS_HTML) ?>"
2206  homecu-equals="must_equal_alias"
2207  data-homecuCustomEquals-msg="<?php echo $MC->msg('Username nomatch', HCU_DISPLAY_AS_HTML) ?>"
2208  class="k-textbox must_equal_alias"
2209  style='width:100%; max-width:400px;'/>
2210  </div>
2211  </div>
2212  </form>
2213  </div>
2214  <?php
2215  // Step - Password - always get confirmation, but a new password isn't always required
2216  ?>
2217  <div id='progressPassword' data-bind="visible: progressPassword">
2218  <form id="formProgressPassword" class='formInputx'>
2219 
2220  <div class="row">
2221  <div class="col-xs-12">
2222  <label for="profilePasswordCurr"><?php echo $MC->msg('Re-enter Password', HCU_DISPLAY_AS_HTML); ?>: <span class="fa fa-question-circle-o" id="reenterPassTip"></span></label>
2223  </div>
2224  <div class="col-xs-12 col-sm-6">
2225  <input type="password"
2226  id="profilePasswordCurr"
2227  name="profilePasswordCurr"
2228  placeholder="<?php echo $MC->msg('Re-enter Password', HCU_DISPLAY_AS_HTML); ?>"
2229  value=""
2230  required
2231  data-bind="value: profilePasswordCurr"
2232  data-required-msg="<?php echo $MC->msg('Invalid Authentication', HCU_DISPLAY_AS_HTML) ?>"
2233  class="k-textbox"
2234  style='width:100%; max-width:320px;'/>
2235  </div>
2236  </div>
2237  <?php
2238  if ( $needPasswordUpdate ) {
2239  if ( $hasRules ) {
2240  ?>
2241  <div class="row">
2242  <div class="col-xs-12" style='font-size:smaller;'>
2243  <?php echo $MC->combo_msg('Password Hints Doc', HCU_DISPLAY_AS_HTML, "#link#", "javascript:show_help();"); ?>
2244  </div>
2245  </div>
2246  <?php
2247  }
2248  ?>
2249 
2250  <div class="row">
2251  <div class="col-xs-12">
2252  <label for="profilePasswordNew1"><?php echo $MC->msg('New Password', HCU_DISPLAY_AS_HTML); ?>: <span class="fa fa-question-circle-o" id="newPassTip1"></span></label>
2253  </div>
2254  <div class="col-xs-12 col-sm-6">
2255  <input type='text' id='showPasswordText' class='k-textbox' value='' style='width: 100%; max-width:320px; display: none;' />
2256  <input type="password"
2257  id="profilePasswordNew1"
2258  name="profilePasswordNew1"
2259  placeholder="<?php echo $MC->msg('New Password', HCU_DISPLAY_AS_HTML); ?>"
2260  value=""
2261  required
2262  maxlength=20
2263  data-bind="value: profilePasswordNew1"
2264  homecu-minlen="6"
2265  data-required-msg="<?php echo $MC->msg('New password requirements', HCU_DISPLAY_AS_HTML) ?>"
2266  data-homecuCustomMinLen-msg="<?php echo $MC->msg('New password must be from 4 to 8 characters long', HCU_DISPLAY_AS_HTML) ?>"
2267  homecu-maxlen="20"
2268  data-homecuCustomMaxLen-msg="<?php echo $MC->msg('New password must be from 4 to 8 characters long', HCU_DISPLAY_AS_HTML) ?>"
2269  class="k-textbox must_equal"
2270  style='width: 100%; max-width:320px;'/>
2271  </div>
2272  <div class="col-xs-12 col-sm-5">
2273  <button type='button' id='showPassword' class='k-button'><?php echo $MC->msg( "Show", HCU_DISPLAY_AS_HTML ); ?></button>
2274  </div>
2275  </div>
2276  <div class="row">
2277  <div class="col-xs-12 col-sm-6" style="padding:0;">
2278  <div class="col-xs-12">
2279  <label for="profilePasswordNew2"><?php echo $MC->msg('Confirm New Password', HCU_DISPLAY_AS_HTML); ?>: <span class="fa fa-question-circle-o" id="newPassTip2"></span></label>
2280  </div>
2281  <div class="col-xs-12">
2282  <input type="password"
2283  id="profilePasswordNew2"
2284  name="profilePasswordNew2"
2285  placeholder="<?php echo $MC->msg('Confirm New Password', HCU_DISPLAY_AS_HTML); ?>"
2286  value=""
2287  required
2288  maxlength=20
2289  data-bind="value: profilePasswordNew2"
2290  data-required-msg="<?php echo $MC->msg('New passwords do not match', HCU_DISPLAY_AS_HTML) ?>"
2291  homecu-equals="must_equal"
2292  data-homecuCustomEquals-msg="<?php echo $MC->msg('New passwords do not match', HCU_DISPLAY_AS_HTML) ?>"
2293  class="k-textbox must_equal"
2294  style='width: 100%; max-width:320px;'/>
2295  </div>
2296  </div>
2297  <div class="col-xs-12 col-sm-5" style="padding:0;">
2298  <?php
2299  if ( $hasPwdRequirements ) {
2300  ?>
2301  <div class="profile-margin-when-narrow">
2302  <div class="col-xs-12">
2303  <label for="passRequirements"><?php echo $MC->msg("Password Requirements", HCU_DISPLAY_AS_HTML); ?>:</label>
2304  </div>
2305  <div class="col-xs-12">
2306  <div id="passRequirements" style="width: 200px;">
2307  <?php
2308  for ( $i = 0; $i < count( $pwdRequirements ); $i++ ) {
2309  print "
2310  <span id='{$pwdRequirements[$i]["which"]}' style='color: red;'>
2311  <span class='fa fa-times'></span>
2312  <span>{$pwdRequirements[$i]["text"]}</span>
2313  </span><br />";
2314  }
2315  ?>
2316  </div>
2317  </div>
2318  </div>
2319  <?php
2320  }
2321  ?>
2322  </div>
2323  </div>
2324 
2325  <?php
2326  }
2327  ?>
2328  </form>
2329  </div>
2330  <?php
2331  // Step Last - Done!
2332  ?>
2333  <div id='progressDone' data-bind="visible: progressDone">
2334  <div id='progressDoneMessage'>
2335  <p style='margin: 20px;'>
2336  <?php
2337  // only show "back" and "cancel" during authentication
2338  if ( $act == "done" ) {
2339  print $MC->msg('Update Completed', HCU_DISPLAY_AS_HTML)
2340  . warningMessages($es_warnings);
2341 
2342  }
2343  ?>
2344  </p>
2345  </div>
2346  </div>
2347  </div>
2348 
2349  <?php // buttons to go Back, Cancel, or Next/Submit as needed
2350  ?>
2351 
2352  <div class="homecuForm hcu-template">
2353  <div class="hcu-edit-buttons k-state-default">
2354  <?php if ( $act == "auth" ) { ?>
2355  <span class="hcu-icon-delete" style="visibility: hidden;">
2356  <a href="##" id="backBtn" data-bind="events:{ click: backClick }">
2357  <?php echo $MC->msg('Back', HCU_DISPLAY_AS_HTML) ?>
2358  </a>
2359  </span>
2360  <?php if ( $HB_ENV['Ffremain'] > 1 ) { ?>
2361  <a href="##" id="lnkCancel" data-bind="events:{ click: cancel }">
2362  <?php echo $MC->msg("Cancel", HCU_DISPLAY_AS_HTML); ?>
2363  </a>
2364  <?php } ?>
2365  &nbsp;
2366  <a href="##" id="continueBtn" class="k-button k-primary" data-bind="events:{ click: continueClick }">
2367  <i class="fa fa-arrow-right fa-lg"></i><?php echo $MC->msg("Continue", HCU_DISPLAY_AS_HTML); ?>
2368  </a>
2369  <?php } else { ?>
2370  &nbsp;
2371  <a href="##" id="continueBtn" class="k-button k-primary" data-bind="events:{ click: continueClick }">
2372  <i class="fa fa-arrow-right fa-lg"></i><?php echo $MC->msg("Continue", HCU_DISPLAY_AS_HTML); ?>
2373  </a>
2374  <?php } ?>
2375  </div>
2376  </div>
2377  </div>
2378  </div>
2379 </div>
2380 
2381 <script type="text/x-kendo-template" id="phoneRow">
2382  # if (id === -1) { #
2383  <tr data-uid="#: uid #" class="addRow">
2384  <td class="addBtn"><span class="fa fa-plus-circle"></span></td>
2385  <td>Add Phone</td>
2386  </tr>
2387  # } else { #
2388  <tr data-uid="#: uid #">
2389  <td class="removeBtn"><span class="fa fa-minus-circle"></span></td>
2390  <td>#: value #</td>
2391  </tr>
2392  # } #
2393 </script>
2394 <?php
2395  /*
2396  * ** END CONTENT
2397  */
2398 
2399  // ** INCLUDE POST CONTENT SCRIPT
2400  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
2401 
2402 // Set the give alert email for the correct email type.
2403 function SetAlertEmail( $dbh, $id, $type, $newEmail ) {
2404  $sql = "UPDATE cualert{$type} SET notifyto = '$newEmail' WHERE id = {$id}";
2405  db_query( $sql, $dbh );
2406 } // end SetAlertEmail
2407 
2408 
2409 function warningMessages($warnings) {
2410 
2411  if (count($warnings) == 0) {
2412  return '';
2413  }
2414 
2415  $msgs = '<ul class="hcu-warning-color" style=" max-width: 500px;
2416  padding: 20px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;">';
2417  foreach ($warnings as $warn) {
2418  $msgs .= "<li>$warn</li>\n";
2419  }
2420  $msgs .= '</ul>';
2421 
2422  return $msgs;
2423 }