PM-3793 "Alert/update user profile if browser/computer..." SOLVED

Issue:
    Alert/update user profile if browser/computer timezone is different to profile timezone
Cause:
    New feature
Solution:
    Added functionality
This commit is contained in:
Victor Saisa Lopez
2015-11-27 15:38:27 -04:00
parent 626cfd55fe
commit d6052f0593
16 changed files with 392 additions and 118 deletions

View File

@@ -24,6 +24,15 @@
*/
try {
$usr = '';
$pwd = '';
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
$urlLogin = '../home/login';
} else {
$urlLogin = (substr(SYS_SKIN, 0, 2) !== 'ux')? 'login' : '../main/login';
}
if (!$RBAC->singleSignOn) {
if (!isset($_POST['form']) ) {
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error');
@@ -32,8 +41,6 @@ try {
}
$frm = $_POST['form'];
$usr = '';
$pwd = '';
if (isset($frm['USR_USERNAME'])) {
$usr = mb_strtolower(trim($frm['USR_USERNAME']), 'UTF-8');
@@ -142,20 +149,14 @@ try {
}
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
$d = serialize(array('u'=>$usr, 'p'=>$pwd, 'm'=>G::LoadTranslation($errLabel)));
$loginUrl = '../home/login?d='.base64_encode($d);
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => G::LoadTranslation($errLabel)]);
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
} else {
G::SendTemporalMessage($errLabel, "warning");
if (substr(SYS_SKIN, 0, 2) !== 'ux') {
$loginUrl = 'login';
} else {
$loginUrl = '../main/login';
}
}
G::header("location: $loginUrl");
die;
G::header('Location: ' . $urlLogin);
exit(0);
}
if (!isset( $_SESSION['WORKSPACE'] ) ) {
@@ -180,6 +181,12 @@ try {
$_SESSION['USR_USERNAME'] = $usr;
}
//Update User Time Zone
if (isset($_POST['form']['BROWSER_TIME_ZONE'])) {
$user = new Users();
$user->update(['USR_UID' => $_SESSION['USER_LOGGED'], 'USR_TIME_ZONE' => $_POST['form']['BROWSER_TIME_ZONE']]);
}
//Set User Time Zone
$user = UsersPeer::retrieveByPK($_SESSION['USER_LOGGED']);
@@ -195,6 +202,28 @@ try {
$_SESSION['USR_TIME_ZONE'] = $userTimeZone;
}
if (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) {
$dateTime = new \ProcessMaker\Util\DateTime();
$timeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($_SESSION['USR_TIME_ZONE']);
if ($timeZoneOffset === false || $timeZoneOffset != (int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET'])) {
$_SESSION['__TIME_ZONE_FAILED__'] = true;
$_SESSION['USR_USERNAME'] = $usr;
$_SESSION['USR_PASSWORD'] = $pwd;
$_SESSION['BROWSER_TIME_ZONE'] = $dateTime->getTimeZoneIdByTimeZoneOffset((int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET']));
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => '', 'timeZoneFailed' => 1, 'userTimeZone' => $_SESSION['USR_TIME_ZONE'], 'browserTimeZone' => $_SESSION['BROWSER_TIME_ZONE']]);
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
}
G::header('Location: ' . $urlLogin);
exit(0);
}
}
//Set data
$aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']);
$RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']);