From f3a6fecab6ac29f60185cf73ff139fdd95ec19ae Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 7 Nov 2015 09:14:48 +0000 Subject: [PATCH] Time zone for self service --- lam/HISTORY | 1 + lam/lib/account.inc | 11 +++++++---- lam/lib/modules/sambaSamAccount.inc | 12 ++++++++---- lam/lib/selfService.inc | 3 +++ lam/templates/config/confmain.php | 21 +++++++++++---------- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 84db0271..690a0f06 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -5,6 +5,7 @@ December 2015 5.2 - IMAP: allow to specify initial folders to create - LAM Pro: -> Users: allow to manage IP addresses with ipHost module + -> Self Service: added time zone setting in self service profile 31.08.2015 5.1 diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 7644a142..d1e053ec 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -1293,11 +1293,14 @@ function getTimeZoneOffsetHours() { * @return DateTimeZone time zone */ function getTimeZone() { - if (empty($_SESSION['config'])) { - return new DateTimeZone('UTC'); + $timeZoneName = 'UTC'; + if (!empty($_SESSION['config'])) { + $timeZoneName = $_SESSION['config']->getTimeZone(); } - $timeZone = $_SESSION['config']->getTimeZone(); - return new DateTimeZone($timeZone); + elseif (!empty($_SESSION['selfServiceProfile']->timeZone)) { + $timeZoneName = $_SESSION['selfServiceProfile']->timeZone; + } + return new DateTimeZone($timeZoneName); } /** diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 4275d8bd..fb62f323 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -1133,7 +1133,8 @@ class sambaSamAccount extends baseModule implements passwordService { if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideSambaPwdLastSet')) { $sambaPwdLastSet = ''; if (!empty($this->attributes['sambaPwdLastSet'][0])) { - $time = new DateTime('@' . $this->attributes['sambaPwdLastSet'][0], getTimeZone()); + $time = new DateTime('@' . $this->attributes['sambaPwdLastSet'][0], new DateTimeZone('UTC')); + $time->setTimezone(getTimeZone()); $sambaPwdLastSet = $time->format('d.m.Y H:i'); } $return->addElement(new htmlOutputText(_('Last password change'))); @@ -2252,7 +2253,8 @@ class sambaSamAccount extends baseModule implements passwordService { if (in_array('sambaPwdLastSet', $fields)) { $sambaPwdLastSet = ''; if (isset($attributes['sambaPwdLastSet'][0])) { - $time = new DateTime('@' . $attributes['sambaPwdLastSet'][0], getTimeZone()); + $time = new DateTime('@' . $attributes['sambaPwdLastSet'][0], new DateTimeZone('UTC')); + $time->setTimezone(getTimeZone()); $sambaPwdLastSet = $time->format('d.m.Y H:i'); } $row = new htmlResponsiveRow(); @@ -2437,7 +2439,8 @@ class sambaSamAccount extends baseModule implements passwordService { return $return; } $timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->maxPwdAge; - $time = new DateTime('@' . $timeVal, getTimeZone()); + $time = new DateTime('@' . $timeVal, new DateTimeZone('UTC')); + $time->setTimezone(getTimeZone()); return $time->format('d.m.Y H:i'); } } @@ -2466,7 +2469,8 @@ class sambaSamAccount extends baseModule implements passwordService { return $return; } $timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->minPwdAge; - $time = new DateTime('@' . $timeVal, getTimeZone()); + $time = new DateTime('@' . $timeVal, new DateTimeZone('UTC')); + $time->setTimezone(getTimeZone()); return $time->format('d.m.Y H:i'); } } diff --git a/lam/lib/selfService.inc b/lam/lib/selfService.inc index 5389e0be..e3a79371 100644 --- a/lam/lib/selfService.inc +++ b/lam/lib/selfService.inc @@ -374,6 +374,8 @@ class selfServiceProfile { public $followReferrals = 0; + public $timeZone = 'Europe/London'; + /** * Constructor * @@ -410,6 +412,7 @@ class selfServiceProfile { $this->language = 'en_GB.utf8'; $this->enforceLanguage = true; $this->followReferrals = 0; + $this->timeZone = 'Europe/London'; } } diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index f4c66137..dcddfd99 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -201,7 +201,7 @@ echo "
\n"; echo ""; echo ""; echo "
\n"; - + // tabs echo '
'; @@ -326,6 +326,7 @@ $timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone: $timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::EUROPE)); $timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::INDIAN)); $timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::PACIFIC)); +$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::UTC)); $languageSettingsContent->addElement(new htmlTableExtendedSelect('timeZone', $timezones, array($conf->getTimeZone()), _('Time zone'), '213'), true); $languageSettings = new htmlFieldset($languageSettingsContent, _("Language settings"), '../../graphics/language.png'); $container->addElement($languageSettings, true); @@ -367,31 +368,31 @@ $container->addElement(new htmlSpacer(null, '10px'), true); // LAM Pro settings if (isLAMProVersion()) { $pwdMailContent = new htmlTable(); - + $pwdMailFrom = new htmlTableExtendedInputField(_('From address'), 'pwdResetMail_from', $conf->getLamProMailFrom(), '550'); $pwdMailContent->addElement($pwdMailFrom, true); - + $pwdMailReplyTo = new htmlTableExtendedInputField(_('Reply-to address'), 'pwdResetMail_replyTo', $conf->getLamProMailReplyTo(), '554'); $pwdMailContent->addElement($pwdMailReplyTo, true); - + $pwdMailSubject = new htmlTableExtendedInputField(_('Subject'), 'pwdResetMail_subject', $conf->getLamProMailSubject(), '551'); $pwdMailContent->addElement($pwdMailSubject, true); - + $pwdMailIsHTML = false; if ($conf->getLamProMailIsHTML() == 'true') { $pwdMailIsHTML = true; } $pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_isHTML',$pwdMailIsHTML , _('HTML format'), '553'), true); - + $pwdMailAllowAlternate = true; if ($conf->getLamProMailAllowAlternateAddress() == 'false') { $pwdMailAllowAlternate = false; } $pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_allowAlternate',$pwdMailAllowAlternate , _('Allow alternate address'), '555'), true); - + $pwdMailBody = new htmlTableExtendedInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552'); $pwdMailContent->addElement($pwdMailBody, true); - + $pwdMailFieldset = new htmlFieldset($pwdMailContent, _("Password mail settings"), '../../graphics/mailBig.png'); $container->addElement($pwdMailFieldset, true); $container->addElement(new htmlSpacer(null, '10px'), true); @@ -583,7 +584,7 @@ function checkInput() { $conf->setLoginSearchSuffix($_POST['loginSearchSuffix']); $conf->setLoginSearchPassword($_POST['loginSearchPassword']); $conf->setLoginSearchDN($_POST['loginSearchDN']); - if ($_POST['loginMethod'] == LAMConfig::LOGIN_SEARCH) { // check only if search method + if ($_POST['loginMethod'] == LAMConfig::LOGIN_SEARCH) { // check only if search method if (!$conf->setLoginSearchDN($_POST['loginSearchDN'])) { $errors[] = array("ERROR", _("Please enter a valid bind user.")); } @@ -638,7 +639,7 @@ function checkInput() { $toolSettings[$toolConfigID] = 'false'; } } - $conf->setToolSettings($toolSettings); + $conf->setToolSettings($toolSettings); // check if password was changed if (isset($_POST['passwd1']) && ($_POST['passwd1'] != '')) { if ($_POST['passwd1'] != $_POST['passwd2']) {