9 require_once(
"$admLibrary/addUser.i");
10 $string = array(
"filter" => FILTER_DEFAULT);
11 HCU_ImportVars($parameters,
"a", array(
"operation" => $string,
"payload" => $string,
"ft" => $string,
"userId" => $string));
12 extract($parameters[
"a"]);
14 $operation = is_null($operation) ?
"" : trim($operation);
16 if ($operation !=
"") {
19 $returnArray = saveStatus($dbh, $Cu, $Cn);
22 $returnArray = array(
"error" => array(
"Operation not specified: '$operation'"),
"record" => array());
25 header(
'Content-type: application/json');
26 print HCU_JsonEncode($returnArray);
29 $userId = HCU_PayloadDecode($Cu, $payload);
30 }
catch(exception $e) { ?>
31 <div
class=
'noUserFound'><div>No
User Found</div></div>
34 printPage(
"$menu_link?ft=$ft", $userId[
"user_id"], getUserData($dbh, $Cu, $userId[
"user_id"]));
48 function getUserData($dbh, $Cu, $userId) {
51 $usePhonesInsteadOfMFA = getUsePhonesInsteadOfMFA($dbh, $Cu);
52 $EMAIL_FLAG = GetMsgTxValue(
'MSGTX_FORCE_EM');
57 u.user_id, u.user_name, u.name AS realname, u.lastlogin, t.last_txt, coalesce(ca.retrylimit,5) AS retry, coalesce(ca.gracelimit,5) AS grace, u.email, 59 u.egenl_flag, u.failedremain, u.forcechange, u.forceremain, u.employee, msg_tx & $EMAIL_FLAG::int2 AS ask_email, u.userflags, u.failedlogin, ca.pwdconfig, u.ip, 60 u.confidence, uc.phones, u.mfaquest, ca.min_chlng_qst AS mfa_num_req 63 SELECT ucuc.user_id, max(st.yearmo) AS last_txt 65 INNER JOIN ${Cu}useraccounts ucuc ON st.cu = '$Cu' AND ucuc.accountnumber = st.accountnumber 67 ) t ON u.user_id = t.user_id 68 LEFT JOIN ${Cu}usercontact uc ON u.contact = uc.contact_id 69 LEFT JOIN cuadmin ca ON ca.cu = '$Cu' 70 WHERE u.user_id = $userId";
72 $sth = db_query($sql,$dbh);
74 throw new exception(
"User query failed.", 1);
76 $array = db_num_rows($sth) > 0 ? db_fetch_assoc($sth, 0) : array();
78 foreach($array as $key => $value) {
79 $array[$key] = trim($value);
82 $array[
"booleanVerifyEmail"] = $array[
"ask_email"] != 0;
83 $array[
"booleanForceChange"] = $array[
"forcechange"] ==
"Y";
84 $array[
"booleanForceSecurity"] = ($array[
"userflags"] & 2) != 0;
85 $array[
"booleanEmployee"] = $array[
"employee"] ==
"Y";
86 $array[
"booleanLockAccount"] = $array[
"failedremain"] < 1 || (($array[
"booleanForceChange"] || $array[
"booleanForceSecurity"]) && $array[
"forceremain"] < 1);
87 $array[
"booleanOptin"] = $array[
"egenl_flag"] ==
"Y";
92 $array[
"textLockout"] = $array[
"failedremain"] == -1 ?
"Locked By CU" : $array[
"failedremain"];
93 $array[
"numRemaining"] = $array[
"booleanForceSecurity"] ? $array[
"forceremain"] : $array[
"grace"];
95 $userflags = intval($array[
"userflags"]);
96 $array[
"failreason"] = $userflags & GetUserFlagsValue(
"MEM_LOGIN_FAILED_EMAIL") ?
"Email" :
97 ($userflags & GetUserFlagsValue(
"MEM_LOGIN_FAILED_QST") ?
"Challenge Response" :
98 ($userflags & GetUserFlagsValue(
"MEM_LOGIN_FAILED_PWD") ?
"Password" : ($userflags & GetUserFlagsValue(
"MEM_LOGIN_FAILED_ALIAS") ?
"Username" :
99 ($userflags & GetUserFlagsValue(
"MEM_LOGIN_FAILED_SAC") ?
"Secure Access Code" :
""))));
101 if ($usePhonesInsteadOfMFA) {
102 $mfaquest = HCU_JsonDecode($array[
"mfaquest"]);
103 $authexpires = HCU_array_key_exists(
"authexpires", $mfaquest) ? intval($mfaquest[
"authexpires"]) : 0;
104 $timeExpires = $authexpires == 0 ? null : dateTime::createFromFormat(
"U", $authexpires);
105 if (isset($timeExpires)) {
106 $sql =
"select trim(tz) from cuadmin where cu='$Cu'";
107 $sth = db_query($sql, $dbh);
109 throw new exception(
"timezone query failed.", 4);
111 if (!db_num_rows($sth)) {
112 throw new exception(
"no CU found.", 5);
114 list($tz) = db_fetch_array($sth, 0);
116 $tz = (
"$tz" ==
"" ?
"Mountain" : $tz);
117 if (strpos(
"$tz",
"/") ===
false) $tz =
"US/$tz";
119 $timeExpires->setTimezone(
new DateTimeZone($tz));
120 $timeExpires = $timeExpires->format(
"m/d/Y h:i:s A");
122 $newMFA = array(
"date" => $timeExpires,
"expired" => $authexpires <= gmdate(
"U"),
123 "code" => HCU_array_key_exists(
"authcode", $mfaquest) ? trim($mfaquest[
"authcode"]) :
"",
126 $newMFA = array(
"date" =>
"",
"expired" =>
false,
"code" =>
"",
"isset" =>
false);
129 $array[
"mfaquest"] = $newMFA;
131 $challengeQuestions = getAdmChallengeQuestions($dbh, $Cu, $array[
"user_name"],
"admin display",
true);
132 $array[
"mfaquest"] = $challengeQuestions[
"data"];
135 if ($array[
"ip"] ==
"") {
136 $array[
"cuIps"] = array();
138 $cuIps = explode(
";", $array[
"ip"]);
139 foreach($cuIps as $ip) {
140 $validate = explode(
".", $ip);
141 if (count($validate) != 4) {
142 throw new exception(
"IP addresses are not valid.", 6);
144 foreach($validate as $num) {
145 if (!is_numeric($num)) {
146 throw new exception(
"IP addresses are not valid.", 7);
148 if ($num < 0 || $num > 256) {
149 throw new exception(
"IP addresses are not valid.", 8);
153 $array[
"cuIps"] = $cuIps;
157 if ($usePhonesInsteadOfMFA) {
158 $phones = HCU_JsonDecode($array[
"phones"]);
159 $newPhones = array();
160 foreach($phones as $type => $value) {
161 if ($type ==
"mobile") {
162 $array[
"phones"] = $value;
169 $returnArray = array(
"code" => 0,
"error" => array(),
"record" => $records,
"usePhonesInsteadOfMFA" => $usePhonesInsteadOfMFA);
170 }
catch(exception $e) {
171 $returnArray = array(
"code" => $e->getCode(),
"error" => array($e->getMessage()),
"usePhonesInsteadOfMFA" =>
false);
187 function saveStatus($dbh, $Cu, $user) {
188 $parameters = array(
"BOTTOM_LEVEL" => array(
"forceSecurity" =>
"",
"forcePassword" =>
"",
"lockAccount" =>
"",
"optin" =>
"",
"ipAddress" =>
"",
"isEmployee" =>
"",
189 "verifyEmail" =>
"",
"billpay" =>
"",
"password" =>
"",
"forceChangesAmount" =>
"",
"username" =>
"",
"emailAddress" =>
"",
"phones" =>
"",
"phoneWasChanged" =>
""));
190 $string = array(
"filter" => HCUFILTER_INPUT_STRING);
192 HCU_ImportVars($parameters,
"BOTTOM_LEVEL", array(
"forceSecurity" => $string,
"forcePassword" => $string,
"lockAccount" => $string,
"optin" => $string,
"ipAddress" => $string,
193 "isEmployee" => $string,
"verifyEmail" => $string,
"billpay" => $string,
"password" => $string,
"forceChangesAmount" => $string,
"username" => $string,
194 "emailAddress" => $string,
"phones" => $string,
"phoneWasChanged" => $string));
196 extract($parameters[
"BOTTOM_LEVEL"]);
198 $data = saveUserData($dbh, $Cu, $username, $forceSecurity, $forcePassword, $lockAccount, $optin, $verifyEmail, $isEmployee, $billpay, $password, $forceChangesAmount, $emailAddress,
199 $ipAddress, $phones, $phoneWasChanged, $user);
228 function saveUserData($dbh, $cuCode, $userId, $forceSecurity, $forcePassword, $lockAccount, $optin, $verifyEmail, $isEmployee, $billpay, $password,
229 $forceChangesAmount, $emailAddress, $ipAddress, $phones, $phoneWasChanged, $loggedInUser) {
230 $forceSecurity = !isset($forceSecurity) || trim($forceSecurity) ==
"" ? null : strtoupper(trim($forceSecurity)) ==
"Y";
231 $forcePassword = !isset($forcePassword) || trim($forcePassword) ==
"" ? null : strtoupper(trim($forcePassword)) ==
"Y";
232 $lockAccount = !isset($lockAccount) || trim($lockAccount) ==
"" ? null : strtoupper(trim($lockAccount)) ==
"Y";
233 $optin = !isset($optin) || trim($optin) ==
"" ? null : strtoupper(trim($optin)) ==
"Y";
234 $isEmployee = !isset($isEmployee) || trim($isEmployee) ==
"" ? null : strtoupper(trim($isEmployee)) ==
"Y";
235 $billpay = !isset($billpay) || trim($billpay) ==
"" ? null : strtoupper(trim($billpay)) ==
"Y";
236 $password = !isset($password) ? null : trim($password);
237 $password = $password ==
"" ? null : $password;
238 $forceChangesAmount = !isset($forceChangesAmount) ? null : trim($forceChangesAmount);
239 $verifyEmail = !isset($verifyEmail) || trim($verifyEmail) ==
"" ? null : strtoupper(trim($verifyEmail)) ==
"Y";
240 $userId = !isset($userId) ? null : trim($userId);
241 $emailAddress = !isset($emailAddress) ? null : trim($emailAddress);
242 $ipAddress = !isset($ipAddress) ? null : trim($ipAddress);
243 $phones = !isset($phones) ? null : trim($phones);
245 $phoneWasChanged = isset($phoneWasChanged) ? $phoneWasChanged ==
"true" :
false;
248 $EMAIL_FLAG = GetMsgTxValue(
'MSGTX_FORCE_EM');
249 $updateTable = array(
"_action" =>
"update",
"user_id" => $userId);
250 $userHasChanges =
false;
251 $saveUserFlags =
false;
253 if ($forceChangesAmount ==
"") {
254 $forceChangesAmount =
null;
256 if (!is_numeric($forceChangesAmount)) {
257 throw new exception(
"Force Changes Amount is not numeric.", 1);
259 if ($forceChangesAmount < 0 || $forceChangesAmount > 99) {
260 throw new exception(
"Force Changes needs to be in the range 0-99.", 2);
263 $updateTable[
"forceremain"] = intval($forceChangesAmount);
264 $userHasChanges =
true;
268 throw new exception(
"User Id is required.", 3);
271 $sql =
"select userflags, msg_tx, contact from ${cuCode}user where user_id = $userId";
272 $sth = db_query($sql, $dbh);
274 throw new exception(
"userflags query failed.", 4);
277 $row = db_fetch_row($sth);
278 $userFlags = isset($row[0]) ? intval($row[0]) & 92 : 0;
279 $originalUserFlags = $userFlags;
280 $msgTxt = isset($row[1]) ? intval($row[1]) : 0;
281 $originalMsgTxt = $msgTxt;
282 $contactId = isset($row[2]) ? intval($row[2]) : 0;
285 if (isset($password)) {
287 if (strlen($password) < 4) {
288 throw new exception(
"Password needs to be four characters or greater", 34);
291 $hash = password_hash($password, PASSWORD_DEFAULT);
292 $updateTable[
"passwd"] =
"$hash";
293 $updateTable[
"pwchange"] = DBTIMESTAMP_USENOW;
294 $userHasChanges =
true;
296 if (isset($forceSecurity)) {
297 if ($forceSecurity) {
302 $saveUserFlags =
true;
304 if (isset($forcePassword)) {
305 $updateTable[
"forcechange"] = $forcePassword ?
"Y" :
"N";
306 $userHasChanges =
true;
308 if (isset($lockAccount)) {
309 $sql =
"select coalesce(retrylimit,5), coalesce(gracelimit,5) from cuadmin where cu = '$cuCode' limit 1";
310 $sth = db_query($sql,$dbh);
312 throw new exception(
"retrylimit query failed.", 6);
314 $row = db_fetch_row($sth);
315 $retry = trim($row[0]);
316 $retry = !isset($retry) || $retry ==
"" ? 5 : $retry;
317 $grace = trim($row[1]);
318 $grace = !isset($grace) || $grace ==
"" ? 5 : $grace;
319 $updateTable[
"failedremain"] = $lockAccount ? -1 : $retry;
320 $updateTable[
"forceremain"] = $grace;
323 $updateTable[
"egenl_flag"] = $optin ?
"Y" :
"N";
324 $userHasChanges =
true;
326 if (isset($isEmployee)) {
327 $updateTable[
"employee"] = $isEmployee ?
"Y" :
"N";
328 $userHasChanges =
true;
330 if (isset($billpay)) {
336 $saveUserFlags =
true;
338 if (isset($forceChangesAmount)) {
339 $updateTable[
"forceremain"] = intval($forceChangesAmount);
340 $userHasChanges =
true;
342 if (isset($verifyEmail)) {
344 $msgTxt |= $EMAIL_FLAG;
346 $msgTxt &= ~$EMAIL_FLAG;
348 $updateTable[
"msg_tx"] = $msgTxt;
350 if (isset($emailAddress)) {
351 $updateTable[
"email"] =
"$emailAddress";
353 if ($saveUserFlags) {
354 $updateTable[
"userflags"] =
"$userFlags";
357 if (isset($ipAddress)) {
358 if ($ipAddress !==
"") {
359 $ips = explode(
";", $ipAddress);
360 foreach($ips as $ip) {
361 $parts = explode(
".", $ip);
362 if (count($parts) != 4) {
363 throw new exception(
"IP Address isn't formatted correctly.", 8);
365 foreach($parts as $part) {
366 if (!is_numeric($part) || intval($part) > 255) {
367 throw new exception(
"IP Address isn't formatted correctly.", 9);
372 $updateTable[
"ip"] = $ipAddress;
375 $phoneRecord = array();
376 if ($phoneWasChanged) {
377 $sql =
"select uc.phones from ${cuCode}usercontact uc inner join ${cuCode}user u on uc.contact_id = u.contact and u.user_id = $userId";
378 $sth = db_query($sql, $dbh);
380 throw new exception(
"phone query failed.", 33);
383 $oldPhones = db_num_rows($sth) > 0 ? HCU_JsonDecode(db_fetch_row($sth, 0)[0]) : array();
385 if ($phones ==
"" || $phones ==
"[]") {
386 $oldPhones[
"mobile"]= array();
388 $phones = HCU_JsonDecode($phones);
389 $oldPhones[
"mobile"] = array();
390 if (!is_array($phones)) {
391 throw new exception(
"Phones are malformed.", 22);
393 foreach($phones as $phone) {
394 $value = trim($phone);
396 if (!is_numeric($value) || $value <= 0 || strlen($value) != 10) {
397 throw new exception(
"Phones are malformed.", 25);
399 $value = substr($value, 0, 3) .
"-" . substr($value, 3, 3) .
"-" . substr($value, 6);
400 $oldPhones[
"mobile"][] = $value;
405 $phoneRecord = array(
"contact_id" => $contactId,
"phones" => HCU_JsonEncode($oldPhones));
406 if ($contactId == 0) {
407 $sql =
"select nextval('${cuCode}usercontact_contact_id_seq'::regclass)";
408 $sth = db_query($sql, $dbh);
411 throw new exception(
"Nextval query failed.", 26);
413 $contactId = intval(db_fetch_row($sth, 0)[0]);
415 $updateTable[
"contact"] = $contactId;
416 $phoneRecord[
"_action"] =
"create";
417 $phoneRecord[
"contact_id"] = $contactId;
418 $userHasChanges =
true;
420 $phoneRecord[
"_action"] =
"update";
424 $updateTable = array(
"user" => array($updateTable));
425 $phoneRecord = array(
"usercontact" => array($phoneRecord));
427 $envVars = array(
"cu" => $cuCode);
430 $script =
"userSupport.prg";
432 $sql =
"select email from cuadminusers where user_name = '$loggedInUser' and cu = '$cuCode'";
433 $sth = db_query($sql, $dbh);
435 throw new exception(
"email query failed.", 7);
437 $email = db_fetch_row($sth)[0];
439 if (!db_work ($dbh, HOMECU_WORK_BEGIN)) {
440 throw new exception(
"begin query failed.", 32);
443 $userHasChanges = $userHasChanges || $originalUserFlags != $userFlags || $originalMsgTxt != $msgTxt;
445 if ($userHasChanges && DataUserTableUpdate($dbh, $envVars,
null, $updateTable, $userId,
"U_UPD", $context, $script,
"A",
"Status Update", $loggedInUser, $email,
446 trim($_SERVER[
"REMOTE_ADDR"])) ===
false) {
447 throw new exception(
"The update failed.", 110);
450 if ($phoneWasChanged && DataUserTableUpdate($dbh, $envVars,
null, $phoneRecord, $userId,
"UC_UPD", $context, $script,
"A",
"Status Update", $loggedInUser, $email,
451 trim($_SERVER[
"REMOTE_ADDR"])) ===
false) {
452 throw new exception(
"Contact update failed.", 133);
455 if (!db_work($dbh, HOMECU_WORK_COMMIT)) {
456 throw new exception(
"commit work failed.", 134);
459 return array(
"code" => 0,
"error" => array(),
"wasForced" => $wasForced,
"updateInfoBar" => isset($emailAddress) || $phoneWasChanged,
"email" => $emailAddress);
460 }
catch(exception $e) {
461 if ($e->getCode() >= 100) {
462 db_work($dbh, HOMECU_WORK_ROLLBACK);
464 return array(
"code" => $e->getCode(),
"error" => array($e->getMessage()));
476 function printPage($self, $userId, $readData) { ?>
477 <script type=
"text/javascript">
479 <?php printJavascriptHashCode(); ?>
481 var userSupportContents = {};
482 userSupportContents.tabs =
null;
491 var previousParameters = {};
492 $(
"#externalTabWindow").data(
"preferredHeight",
"auto");
493 userSupportContents.tabs = {
496 template: $(
"#infoTemplate").html(),
497 setupValidator:
function() {
498 $.homecuValidator.setup({formValidate:
'infoForm', formStatusField:
'formValidateDiv'});
500 init:
function(record) {},
501 getSaveParameters:
function(setPrevious) {
504 postChanges:
function() {}
508 template: $(
"#securityTemplate").html(),
509 setupValidator:
function() {
510 $.homecuValidator.setup({formValidate:
'securityForm', formStatusField:
'formValidateDiv', homecuCustomRules: {
511 validatepassword:
function(input) {
512 if (!input.is(
"[name='password']")) {
515 var password = $(input).val();
516 if (password.length > 0 && password.length < 4) {
517 $(input).attr(
"data-validatepassword-msg",
"Password must be four or more characters.");
520 var invalidMatches = password.match(/[
'"\s]/g); 521 if (invalidMatches != null && invalidMatches.length > 0) { 522 $(input).attr("data-validatepassword-msg", "Password has illegal characters."); 527 <?php printMatchPasswords(); ?> 529 $.homecuValidator.passwordRules = this.passwordRules; 531 init: function(record) { 532 var forceChanges = null; 533 $(".fullTab input[type='password
']").val(null); 534 $(".lockAccount a").click(function() { 535 var lockAccount = $("#securityForm .lockAccount"); 536 if ($(lockAccount).hasClass("currentLocked")) { 537 $(lockAccount).removeClass("currentLocked").addClass("currentUnlocked").removeClass("notRealChange"); 538 forceChanges.value(forceChanges.value() == 0 ? record.retry : forceChanges.value()); 540 $(lockAccount).removeClass("currentUnlocked").addClass("currentLocked").removeClass("notRealChange"); 545 this.passwordRules = record.pwdconfig; 546 var thisDoesUnlock = record.failedremain > 0; <?php // If the failedremain is zero (or less), then changing the forcedremain value wouldn't unlock the user. ?>
547 forceChanges = $(
"#forcePasswordChangeNTB").kendoNumericTextBox({
554 if (thisDoesUnlock) {
555 var value = this.value();
556 var isLocked = $(
"#securityForm .lockAccount").hasClass(
"currentLocked");
557 if (value < 1 && !isLocked) {
558 $(
"#securityForm .lockAccount").addClass(
"currentLocked").removeClass(
"currentUnlocked").addClass(
"notRealChange");
559 } else if (value >= 1 && isLocked) {
560 $(
"#securityForm .lockAccount").removeClass(
"currentLocked").addClass(
"currentUnlocked").addClass(
"notRealChange");
564 }).data(
"kendoNumericTextBox");
566 var isChecked = $(
"[name='forcePassword']").prop(
"checked") || $(
"[name='forceSecurity']").prop(
"checked");
567 forceChanges.enable(isChecked);
568 var opacity = isChecked ?
"1.00" :
"0.38";
569 $(
".force-descriptor").css({
"opacity": opacity});
571 $(
"[name='forcePassword'],[name='forceSecurity']").click(
function() {
572 var isChecked = $(
"[name='forcePassword']").prop(
"checked") || $(
"[name='forceSecurity']").prop(
"checked");
573 $(
"[name='forceChangesNTB']").prop(
"required", isChecked);
576 forceChanges.value($(
"#forcePasswordChangeNTB").data(
"previous"));
578 forceChanges.enable(isChecked);
579 var opacity = isChecked ?
"1.00" :
"0.38";
580 $(
".force-descriptor").css({
"opacity": opacity});
583 $(
"#userMFAShowBtn").click(
function() {
584 if ($(
this).text().trim() ==
"Show") {
585 $(
this).text(
"Hide");
586 $(
".userMFASection").show();
588 $(
this).text(
"Show");
589 $(
".userMFASection").hide();
593 getSaveParameters:
function(setPrevious, alwaysGetValue) {
596 var lockAccount = $(
"#securityForm .lockAccount").hasClass(
"currentLocked") ?
597 ($(
"#securityForm .lockAccount").hasClass(
"originalLocked") ? undefined :
"Y") :
598 ($(
"#securityForm .lockAccount").hasClass(
"originalUnlocked") ? undefined :
"N");
600 var notRealChange = $(
"#securityForm .lockAccount").hasClass(
"notRealChange");
602 if ($(
"[name='password']").val().trim() !=
"")
603 parameters.password = $(
"[name='password']").val().trim();
605 var forceSecurity = $(
"[name='forceSecurity']").prop(
"checked") ?
"Y" :
"N";
606 var forcePassword = $(
"[name='forcePassword']").prop(
"checked") ?
"Y" :
"N";
607 var forceChangesAmount = $(
"#forcePasswordChangeNTB").data(
"kendoNumericTextBox").value();
609 if (!notRealChange && (!alwaysGetValue || (lockAccount != previousParameters.lockAccount))) {
610 parameters.lockAccount = lockAccount;
612 previousParameters.lockAccount = lockAccount;
615 if (!alwaysGetValue || forceSecurity != previousParameters.forceSecurity) {
616 parameters.forceSecurity = forceSecurity;
618 previousParameters.forceSecurity = forceSecurity;
622 if (!alwaysGetValue || forcePassword != previousParameters.forcePassword) {
623 parameters.forcePassword = forcePassword;
625 previousParameters.forcePassword;
629 if ((!alwaysGetValue || forceChangesAmount != previousParameters.forceChangesAmount) && (forcePassword ==
"Y" || forceSecurity ==
"Y")) {
630 parameters.forceChangesAmount = forceChangesAmount;
632 previousParameters.forceChangesAmount;
638 postChanges:
function() {
639 var record = loadTab.data.record[0];
640 record.booleanLockAccount = $(
"#securityForm .lockAccount").hasClass(
"currentLocked");
641 record.booleanForceChange = $(
"[name='forcePassword']").prop(
"checked");
642 record.booleanForceSecurity = $(
"[name='forceSecurity']").prop(
"checked");
643 record.numRemaining = $(
"#forcePasswordChangeNTB").data(
"kendoNumericTextBox").value();
644 $(
".fullTab input[type='password']").val(
null);
649 template: $(
"#optionsTemplate").html(),
650 setupValidator:
function() {
651 $.homecuValidator.setup({formValidate:
'optionsForm', formStatusField:
'formValidateDiv', homecuCustomRules: {
652 <?php
if ($readData[
"usePhonesInsteadOfMFA"]) { ?>
653 <?php printValidatePhones(
'optionsForm'); ?>
656 $.homecuValidator.validate();
658 init:
function(record) {
659 <?php
if ($readData[
"usePhonesInsteadOfMFA"]) { ?>
660 <?php printInitPhoneGrid(
"optionsForm",
"record.phones"); ?>
663 getSaveParameters:
function(setPrevious, alwaysGetValue) {
666 var emailAddress = $(
"[name='emailAddress']").val().trim();
667 var optin = $(
"[name='booleanOptin']").prop(
"checked") ?
"Y" :
"N";
668 var isEmployee = $(
"[name='booleanEmployee']").prop(
"checked") ?
"Y" :
"N";
669 var verifyEmail = $(
"[name='booleanVerifyEmail']").prop(
"checked") ?
"Y" :
"N";
670 var billpay = $(
"[name='booleanBillPay']").prop(
"checked") ?
"Y" :
"N";
672 <?php
if ($readData[
"usePhonesInsteadOfMFA"]) { ?>
673 var phonesChanged = $(
"#phoneGrid").data(
"phonesChanged");
675 if (!alwaysGetValue || phonesChanged) {
676 var phoneData = $(
"#phoneGrid").data(
"kendoGrid").dataSource.data();
678 for(var i = 0; i != phoneData.length; i++) {
679 if (!phoneData[i].isAdd) {
680 phoneArray.push(phoneData[i].value.trim().replace(/\D+/g,
""));
683 parameters.phones = kendo.stringify(phoneArray);
684 parameters.phoneWasChanged = phonesChanged;
688 if (!alwaysGetValue || emailAddress != previousParameters.emailAddress) {
689 parameters.emailAddress = emailAddress;
691 previousParameters.emailAddress = emailAddress;
694 if (!alwaysGetValue || optin != previousParameters.optin) {
695 parameters.optin = optin;
697 previousParameters.optin = optin;
700 if (!alwaysGetValue || isEmployee != previousParameters.isEmployee) {
701 parameters.isEmployee = isEmployee;
703 previousParameters.isEmployee = isEmployee;
706 if (!alwaysGetValue || verifyEmail != previousParameters.verifyEmail) {
707 parameters.verifyEmail = verifyEmail;
709 previousParameters.verifyEmail = verifyEmail;
712 if (!alwaysGetValue || billpay != previousParameters.billpay) {
713 parameters.billpay = billpay;
715 previousParameters.billpay = billpay;
721 postChanges:
function() {
722 var record = loadTab.data.record[0];
723 record.email = $(
"[name='emailAddress']").val().trim();
724 record.booleanOptin = $(
"[name='booleanOptin']").prop(
"checked");
725 record.booleanEmployee = $(
"[name='booleanEmployee']").prop(
"checked");
726 record.booleanVerifyEmail = $(
"[name='booleanVerifyEmail']").prop(
"checked");
727 record.booleanBillPay = $(
"[name='booleanBillPay']").prop(
"checked");
729 <?php
if ($readData[
"usePhonesInsteadOfMFA"]) { ?>
730 $(
"#phoneGrid").data(
"phonesChanged",
false);
736 template: $(
"#accessTemplate").html(),
737 setupValidator:
function() {
738 $.homecuValidator.setup({formValidate:
'accessForm', formStatusField:
'formValidateDiv', homecuCustomRules: {
739 <?php printCheckip(); ?>
742 init:
function(record) {
743 var toolbarTemplate =
"<a href='\\#' class='k-grid-del k-button checkIfChange " + (record.cuIps.length == 0 ?
"k-state-disabled" :
"") +
"'>Delete Selected</a>";
746 for(var i = 0; i != record.cuIps.length; i++) {
747 cuIps.push({ip: record.cuIps[i], checked:
false});
750 var cuIpGrid = $(
"#ipGrid").kendoGrid({
756 ip: {type:
"string"},
757 checked: {type:
"boolean"}
762 {headerTemplate:
"<input type='checkbox' class='allCheckbox'>", width:
"45px"},
763 {field:
"ip", headerTemplate:
"IP"}
765 rowTemplate:
"<tr data-uid='#: uid #'><td class='checkboxTD'><input type='checkbox' class='rowCheckbox' value='#: checked #'>\ 766 <td>#: ip #</td></tr>",
767 toolbar: toolbarTemplate,
769 template:
"<tr><td colspan='5'><span class='hcu-secondary'><span class='vsgSecondary'>No Records Found</span></span></td></tr>" 772 }).data(
"kendoGrid");
774 <?php printCheckboxEvents(
"#ipGrid",
".k-grid-del"); ?>
776 $(
"#ipGrid").on(
"click",
".k-grid-del",
function() {
777 var data = cuIpGrid.dataSource.data();
778 data = $.grep(data,
function(n,i) {
return !n.checked; });
779 if (data.length == 0) {
780 $(
"#ipGrid .allCheckbox").prop(
"checked",
false);
782 cuIpGrid.dataSource.data(data);
786 $(
"#addCuIpBtn").click(
function() {
787 if ($(
"[name='addCuIpInput']").val().trim() !=
"" && $(
"[name='addCuIpInput'].k-invalid:visible").length == 0) {
788 cuIpGrid.dataSource.add({ip: $(
"[name='addCuIpInput']").val(), checked:
false});
789 $(
"[name='addCuIpInput']").val(
null);
794 getSaveParameters:
function(setPrevious, alwaysGetValue) {
798 if ($(
"#ipGrid").length > 0) {
799 var data = $(
"#ipGrid").data(
"kendoGrid").dataSource.data();
801 for(var i = 0; i != data.length; i++) {
802 ipAddress.push(data[i].ip.trim());
804 ipAddress = ipAddress.join(
";");
807 if (!alwaysGetValue || ipAddress != previousParameters.ipAddress) {
808 parameters.ipAddress = ipAddress;
810 previousParameters.ipAddress = ipAddress;
816 postChanges:
function() {
817 var record = loadTab.data.record[0];
818 var parameters = this.getSaveParameters(record);
819 record.cuIps = parameters.ipAddress.split(
";");
824 delete userSupportContents.tabs.access; <?php
826 <?php printFullTabClickEvents($userId,
true); ?>
827 loadTabs(userSupportContents.tabs);
830 $(
"[name='password']").val(
null);
831 $(
"[name='confirm']").val(
null);
833 $.homecuValidator.setup({formValidate:
'infoForm', formStatusField:
'formValidateDiv'});
835 if (loadData.error.length > 0) {
837 $.homecuValidator.displayMessage(loadData.error, $.homecuValidator.settings.statusError );
838 userSupportContents.tabs.info.getSaveParameters =
function() {
return {}; };
839 userSupportContents.tabs.security.getSaveParameters =
function() {
return {}; };
840 userSupportContents.tabs.options.getSaveParameters =
function() {
return {}; };
841 userSupportContents.tabs.info.postChanges =
function() {};
842 userSupportContents.tabs.security.postChanges =
function() {};
843 userSupportContents.tabs.options.postChanges =
function() {};
844 userSupportContents.tabs.info.setupValidator =
function() {};
845 userSupportContents.tabs.security.setupValidator =
function() {};
846 userSupportContents.tabs.options.setupValidator =
function() {};
849 loadData = undefined;
860 function tabsCancelLogic(tabs) {
861 $(
"#externalTabWindow").data(
"isClosing",
true);
862 $(
"#externalTabWindow").data(
"kendoWindow").close();
863 $(
"#externalTabWindow").data(
"isClosing",
false);
874 function postSaveTabs(tabs, data) {
875 if (data.updateInfoBar) {
876 updateInfoBar({email: data.email});
879 $(
"#externalTabWindow").data(
"isClosing",
true);
880 $(
"#externalTabWindow").data(
"kendoWindow").close();
881 $(
"#externalTabWindow").data(
"isClosing",
false);
890 function userSupportDoOnClose() {
891 potentiallyCancelChanges(userSupportContents.tabs);
892 $(
"#externalTabWindow").data(
"shouldClose",
false);
904 function loadTabs(tabs) {
905 var tabTemplate = kendo.template($(
"#tabTemplate").html());
906 $(
".fullTab").html(tabTemplate({tabname:
"info"}));
908 loadData = <?php echo HCU_JsonEncode($readData); ?>;
910 if (loadData.error.length == 0) {
912 for(var tabname in tabs) {
913 if (tabs.hasOwnProperty(tabname)) {
914 var tab = tabs[tabname];
915 var
template = kendo.template(tab.template);
916 $(
".tabContents[data-name='" + tab.name +
"']").html(
template(loadData.record[0]));
917 tab.init(loadData.record[0]);
921 for(var tabname in tabs) {
922 if (tabs.hasOwnProperty(tabname)) {
923 var tab = tabs[tabname];
924 var parameters = tab.getSaveParameters(
true);
925 tab.oldHash = kendo.stringify(parameters).hashCode();
926 oldHash.push(parameters);
929 tabs.oldHash = kendo.stringify(oldHash).hashCode();
931 $(
".tabTitles [data-name='info']").addClass(
"selected");
932 $(
".tabContents[data-name='info']").show();
933 tabs.info.setupValidator();
935 var maxWidth = $(
".fullTab .tabContents:visible").width();
936 $(
".fullTab .tabContents").each(
function() {
937 $(
this).width(maxWidth);
942 <?php printTabFunctions($self, $userId,
"",
true); ?>
944 function userSupportDoOnActivate() {
945 var width = $(
".kWindowCard").width();
946 $(
"#externalTabWindow .tabContents").css(
"width", width <= 710 ? width - 40 : 700);
959 function updateInfoBar(updateArray) {
960 var unencrypted = $(
"#cardContainerDiv").data(
"unencrypted");
961 $.extend(unencrypted, updateArray);
963 var
template = kendo.template($(
"#userInfoTemplate").html());
964 $(
"#cardContainerDiv .infoDiv").html(
template({unencrypted: unencrypted}));
968 <script type=
"text/x-kendo-template" id=
"infoTemplate">
969 # var lockMode = booleanLockAccount ? "Locked" : "Unlocked"; # 970 <div
class=
"container hcu-all-100"><div
class=
"row">
971 <?php $array = array(
972 "User" =>
"# if (user_name == '') { # # } else { # #: user_name # # } #",
973 "Name" =>
"# if (realname == '') { # # } else { # #: realname # # } #",
974 "Last Successful Login" =>
"# if (lastlogin == '') { # # } else { # #: lastlogin # # } #",
975 "Last Failed Login" =>
"# if(failedlogin == '') { # # } else { # #: failedlogin # # } #",
976 "Last TXT" =>
"# if (last_txt == '') { # # } else { # #: last_txt # # } #",
977 "Last Failed Reason" =>
"# if (failreason == '') { # # } else { # #: failreason # # } #",
978 "Login Tries Before Lockout" =>
"# if (textLockout == '') { # # } else { # #: textLockout # # } #",
979 "Opt-in list" =>
"# if (booleanOptin) { # Yes # } else { # No # } #",
980 "CU Employee" =>
"# if (booleanEmployee) { # Yes # } else { # No # } #",
981 "Lock User" =>
"<div class='lockAccount original#: lockMode # current#: lockMode # admAlignBottom'><span class='text'></span></div>");
982 printStatusLabelBlock($array); ?>
985 <script type=
"text/x-kendo-template" id=
"securityTemplate">
986 <div
class=
"container hcu-all-100"><div
class=
"row">
987 # var lockMode = booleanLockAccount ? "Locked" : "Unlocked"; # 989 <div
class=
"col-xs-12">
990 <div
class=
"row wellPadding">
991 <div
class=
"row hcuSpacer">
992 <label
class=
"col-xs-4">Lock
User</label>
993 <div
class=
"col-xs-7">
994 <div
class=
"lockAccount original#: lockMode # current#: lockMode # admAlignBottom">
995 <span
class=
"text col-xs-4 col-md-3 hcu-no-padding"></span> <span
class=
"col-xs-5 col-md-1 hcu-no-padding">(<a href=
"\\#" class=
"checkIfChange"></a>)</span>
1001 <div
class=
"col-xs-12"><div
class=
"hcuSpacer"></div></div>
1002 <div
class=
'col-xs-12'>
1003 <div
class=
'well well-sm row'>
1004 <?php printHeader(
"Password");
1005 dialogPrintInputLine(
"Enter Password",
"",
"password", 255,
false,
"password",
true,
"matchPasswords nonEmptyIsChange checkIfChange",
false);
1006 dialogPrintInputLine(
"Confirm",
"",
"confirm", 255,
false,
"password",
true,
"matchPasswords",
false); ?>
1009 <div
class=
"col-xs-12"><div
class=
"hcuSpacer"></div></div>
1010 <div
class=
'col-xs-12'>
1011 <div
class=
'well well-sm row'>
1012 <?php printHeader(
"Options");
1013 dialogPrintCheckboxLine(
"forceSecurity",
"Force Security",
"# if (booleanForceSecurity) { # checked # } #",
"checkIfChange",
true,
true,
false);
1014 dialogPrintCheckboxLine(
"forcePassword",
"Force Password",
"# if (booleanForceChange) { # checked # } #",
"checkIfChange",
true,
true,
false); ?>
1016 <div
class=
"row hcuSpacer">
1017 <div
class=
"col-xs-4"> </div>
1018 <div
class=
"col-xs-7 force-descriptor">Force changes within next
1019 <input
id=
"forcePasswordChangeNTB" name=
"forceChangesNTB" value=
"#: forceremain #" style=
"width: 40px;" class=
"checkIfChange" data-previous=
"#: forceremain #">
1022 <div
class=
"col-xs-1"><span data-
for=
"forceChangesNTB" class=
"k-invalid-msg"></span></div>
1026 <div
class=
"col-xs-12"><div
class=
"hcuSpacer"></div></div>
1027 <div
class=
"col-xs-12">
1028 <div
class=
"well well-sm row">
1029 <?php printHeader(
"User MFA (<a href='\\#' id='userMFAShowBtn'>Show</a>)"); ?>
1030 <div
class=
"userMFASection" style=
"display:none;">
1031 <?php
if ($readData[
"usePhonesInsteadOfMFA"]) { ?>
1032 # if (!mfaquest.isset) { # 1033 <?php printMessage(
"N/A"); ?>
1035 <div
class=
"row form-group col-xs-12"><div
class=
"k-block col-xs-12">
1036 <div
class=
"col-xs-12 col-sm-12 hcuSpacer">
1037 <div
class=
"col-xs-12">Requested Secure Access Code Expired.</div>
1039 <div
class=
"col-xs-12 col-sm-6 hcuSpacer">
1040 <label
class=
"col-xs-12">Code</label>
1041 <div
class=
"col-xs-12 admIndent">#: mfaquest.code #</div>
1043 <div
class=
"col-xs-12 col-sm-6 hcuSpacer">
1044 <label
class=
"col-xs-12">Expiration Date</label>
1045 <div
class=
"col-xs-12 admIndent # if (mfaquest.expired) { # expired # } #">#: mfaquest.date #</div>
1055 # if (mfaquest.length >= 1 || (mfaquest.length == 0 && mfa_num_req == 0)) { # 1056 <?php printStatusLabelBlock(array(
"Confidence Word" =>
"#: confidence #")); ?>
1058 # if (mfaquest.length > 0) { # 1059 <div
class=
"row form-group col-xs-12"><div
class=
"k-block col-xs-12">
1060 # for (var i = 0, count = mfaquest.length; i != count; i++) { # 1061 <div
class=
"col-xs-12 col-sm-6 hcuSpacer">
1062 <label
class=
"col-xs-12">#: mfaquest[i].quest_text # </label>
1063 <div
class=
"col-xs-12 admIndent">#: mfaquest[i].answer #</div>
1068 <div
class=
"col-xs-12">
1069 Credit Union is not configured
for challenge questions.
1073 <?php printMessage(
"User needs to set up MFA."); ?>
1081 <script type=
"text/x-kendo-template" id=
"optionsTemplate">
1082 <div
class=
"container hcu-all-100"><div>
1083 <?php dialogPrintInputLine(
"Email Address",
"#: email #",
"emailAddress", 255,
"required data-required-msg=\"Email is required\" data-email-msg=\"Email is invalid\"",
1084 "email",
true,
"checkIfChange",
false);
1085 dialogPrintCheckboxLine(
"booleanOptin",
"Opt-in list",
"# if (booleanOptin) { # checked # } #",
"checkIfChange",
true,
true,
false);
1086 dialogPrintCheckboxLine(
"booleanEmployee",
"CU Employee",
"# if (booleanEmployee) { # checked # } #",
"checkIfChange",
true,
true,
false);
1087 dialogPrintCheckboxLine(
"booleanVerifyEmail",
"Verify Email",
"# if (booleanVerifyEmail) { # checked # } #",
"checkIfChange",
true,
true,
false);
1094 <?php
if ($readData[
"usePhonesInsteadOfMFA"]) { ?>
1095 <div
class=
"row hcuSpacer"><span
class=
"h3">Phones</span></div>
1096 <div
class=
"row hcuSpacer"><div
id=
"phoneGrid"></div></div>
1097 <input type=
"hidden" name=
"validatePhonesHidden">
1101 <script type=
"text/x-kendo-template" id=
"accessTemplate">
1102 <div
class=
"container hcu-all-100"><div
class=
"row">
1103 <div
class=
"wellPadding">
1104 <div
class=
"row hcuSpacer">
1105 <label
class=
"col-xs-2">Add IP</label>
1106 <div
class=
"col-xs-9">
1107 <div
class=
"col-xs-9 hcu-no-padding">
1108 <input name=
"addCuIpInput" class=
"hcu-all-100 k-input k-textbox" type=
"text" data-checkip-msg=
"IP is not valid.">
1110 <div
class=
"col-xs-3 hcu-no-padding">
1111 <a href=
'\\#' id=
"addCuIpBtn" class=
"k-button hcu-all-100 checkIfChange">Add</a>
1114 <div
class=
"col-xs-1">
1115 <span data-
for=
'addCuIpInput' class=
'k-invalid-msg'></span>
1118 <div
class=
"row hcuSpacer">
1119 <div
class=
"col-xs-11">
1120 <div
id=
"ipGrid" class=
"hcu-all-100 ipGrid"></div>
1126 <script type=
"text/x-kendo-template" id=
"tabTemplate">
1127 # var spacing = "col-xs-3"; var infoSelected = ""; var securitySelected = ""; var optionsSelected = ""; var accessSelected = ""; 1128 var tabAsterisk =
"<div class='tabAsterisk' style='display:none;'><i class='fa fa-asterisk fa-6'></i></div>";
1132 infoSelected =
"selected";
1135 securitySelected =
"selected";
1138 optionsSelected =
"selected";
1141 accessSelected =
"selected";
1144 <div
class=
"hcu-template">
1145 <div
class=
"tabSuccessfulDiv"></div>
1146 <div
class=
"tabTitles">
1147 <div
class=
"#: spacing # #: infoSelected #" data-name=
"info"><div><i
class=
"fa fa-info-circle fa-6">
1148 <div
class=
"hidden-xs hidden-sm text"> Info</div>#= tabAsterisk #</i></div></div>
1149 <div
class=
"#: spacing # #: securitySelected #" data-name=
"security"><div><i
class=
"fa fa-lock fa-6">
1150 <div
class=
"hidden-xs hidden-sm text"> Security</div>#= tabAsterisk #</i></div></div>
1152 <div
class=
"#: spacing # #: optionsSelected # lastChild" data-name=
"options"><div><i
class=
"fa fa-check-square fa-6">
1153 <div
class=
"hidden-xs hidden-sm text"> Options</div>#= tabAsterisk #</i></div></div>
1155 <div
class=
"#: spacing # #: accessSelected # lastChild" data-name=
"access"><div><i
class=
"fa fa-map-marker fa-6">
1156 <div
class=
"hidden-xs hidden-sm text"> Access</div>#= tabAsterisk #</i></div></div>
1160 <form
id=
"infoForm">
1161 <div
class=
"form-group tabContents" data-name=
"info" style=
"display:none;"></div>
1163 <form
id=
"securityForm">
1164 <div
class=
"form-group tabContents" data-name=
"security" style=
"display:none;"></div>
1166 <form
id=
"optionsForm">
1167 <div
class=
"form-group tabContents" data-name=
"options" style=
"display:none;"></div>
1169 <form
id=
"accessForm">
1170 <div
class=
"form-group tabContents" data-name=
"access" style=
"display:none;"></div>
1173 <div
class=
"hcu-edit-buttons k-state-default tabFooter">
1174 <a
class=
"tabCancelBtn" href=
"\\#">Cancel</a>
1176 <a
class=
"tabSaveBtn k-button k-primary" href=
"\\#">Update</a>
1181 <div
class=
"container-fluid">
1183 <div
id=
"formValidateDiv" class=
"k-block k-error-colored formValidateDiv" style=
"display:none"></div>
1185 <div
class=
"fullTab"></div>
1195 function printStatusLabelBlock($labelArray)
1197 <div
class=
"row form-group col-xs-12"><div
class=
"k-block col-xs-12">
1198 <?php
foreach($labelArray as $label => $value) { ?>
1199 <div
class=
"col-xs-12 col-sm-6 hcuSpacer">
1200 <label
class=
"col-xs-12"><?php echo $label; ?> </label>
1201 <div
class=
"col-xs-12 admIndent"><?php echo trim(str_replace(
'\\',
'\\\\', $value)); ?></div>