Time zone for self service

This commit is contained in:
Roland Gruber 2015-11-07 09:14:48 +00:00
parent 96ae5f85e2
commit f3a6fecab6
5 changed files with 30 additions and 18 deletions

View File

@ -5,6 +5,7 @@ December 2015 5.2
- IMAP: allow to specify initial folders to create - IMAP: allow to specify initial folders to create
- LAM Pro: - LAM Pro:
-> Users: allow to manage IP addresses with ipHost module -> Users: allow to manage IP addresses with ipHost module
-> Self Service: added time zone setting in self service profile
31.08.2015 5.1 31.08.2015 5.1

View File

@ -1293,11 +1293,14 @@ function getTimeZoneOffsetHours() {
* @return DateTimeZone time zone * @return DateTimeZone time zone
*/ */
function getTimeZone() { function getTimeZone() {
if (empty($_SESSION['config'])) { $timeZoneName = 'UTC';
return new DateTimeZone('UTC'); if (!empty($_SESSION['config'])) {
$timeZoneName = $_SESSION['config']->getTimeZone();
} }
$timeZone = $_SESSION['config']->getTimeZone(); elseif (!empty($_SESSION['selfServiceProfile']->timeZone)) {
return new DateTimeZone($timeZone); $timeZoneName = $_SESSION['selfServiceProfile']->timeZone;
}
return new DateTimeZone($timeZoneName);
} }
/** /**

View File

@ -1133,7 +1133,8 @@ class sambaSamAccount extends baseModule implements passwordService {
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideSambaPwdLastSet')) { if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideSambaPwdLastSet')) {
$sambaPwdLastSet = ''; $sambaPwdLastSet = '';
if (!empty($this->attributes['sambaPwdLastSet'][0])) { 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'); $sambaPwdLastSet = $time->format('d.m.Y H:i');
} }
$return->addElement(new htmlOutputText(_('Last password change'))); $return->addElement(new htmlOutputText(_('Last password change')));
@ -2252,7 +2253,8 @@ class sambaSamAccount extends baseModule implements passwordService {
if (in_array('sambaPwdLastSet', $fields)) { if (in_array('sambaPwdLastSet', $fields)) {
$sambaPwdLastSet = ''; $sambaPwdLastSet = '';
if (isset($attributes['sambaPwdLastSet'][0])) { 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'); $sambaPwdLastSet = $time->format('d.m.Y H:i');
} }
$row = new htmlResponsiveRow(); $row = new htmlResponsiveRow();
@ -2437,7 +2439,8 @@ class sambaSamAccount extends baseModule implements passwordService {
return $return; return $return;
} }
$timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->maxPwdAge; $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'); return $time->format('d.m.Y H:i');
} }
} }
@ -2466,7 +2469,8 @@ class sambaSamAccount extends baseModule implements passwordService {
return $return; return $return;
} }
$timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->minPwdAge; $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'); return $time->format('d.m.Y H:i');
} }
} }

View File

@ -374,6 +374,8 @@ class selfServiceProfile {
public $followReferrals = 0; public $followReferrals = 0;
public $timeZone = 'Europe/London';
/** /**
* Constructor * Constructor
* *
@ -410,6 +412,7 @@ class selfServiceProfile {
$this->language = 'en_GB.utf8'; $this->language = 'en_GB.utf8';
$this->enforceLanguage = true; $this->enforceLanguage = true;
$this->followReferrals = 0; $this->followReferrals = 0;
$this->timeZone = 'Europe/London';
} }
} }

View File

@ -201,7 +201,7 @@ echo "<div style=\"display: none;\">\n";
echo "<input name=\"moduleSettings\" type=\"submit\" value=\" \">"; echo "<input name=\"moduleSettings\" type=\"submit\" value=\" \">";
echo "<input name=\"jobs\" type=\"submit\" value=\" \">"; echo "<input name=\"jobs\" type=\"submit\" value=\" \">";
echo "</div>\n"; echo "</div>\n";
// tabs // tabs
echo '<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">'; echo '<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">';
@ -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::EUROPE));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::INDIAN)); $timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::INDIAN));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::PACIFIC)); $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); $languageSettingsContent->addElement(new htmlTableExtendedSelect('timeZone', $timezones, array($conf->getTimeZone()), _('Time zone'), '213'), true);
$languageSettings = new htmlFieldset($languageSettingsContent, _("Language settings"), '../../graphics/language.png'); $languageSettings = new htmlFieldset($languageSettingsContent, _("Language settings"), '../../graphics/language.png');
$container->addElement($languageSettings, true); $container->addElement($languageSettings, true);
@ -367,31 +368,31 @@ $container->addElement(new htmlSpacer(null, '10px'), true);
// LAM Pro settings // LAM Pro settings
if (isLAMProVersion()) { if (isLAMProVersion()) {
$pwdMailContent = new htmlTable(); $pwdMailContent = new htmlTable();
$pwdMailFrom = new htmlTableExtendedInputField(_('From address'), 'pwdResetMail_from', $conf->getLamProMailFrom(), '550'); $pwdMailFrom = new htmlTableExtendedInputField(_('From address'), 'pwdResetMail_from', $conf->getLamProMailFrom(), '550');
$pwdMailContent->addElement($pwdMailFrom, true); $pwdMailContent->addElement($pwdMailFrom, true);
$pwdMailReplyTo = new htmlTableExtendedInputField(_('Reply-to address'), 'pwdResetMail_replyTo', $conf->getLamProMailReplyTo(), '554'); $pwdMailReplyTo = new htmlTableExtendedInputField(_('Reply-to address'), 'pwdResetMail_replyTo', $conf->getLamProMailReplyTo(), '554');
$pwdMailContent->addElement($pwdMailReplyTo, true); $pwdMailContent->addElement($pwdMailReplyTo, true);
$pwdMailSubject = new htmlTableExtendedInputField(_('Subject'), 'pwdResetMail_subject', $conf->getLamProMailSubject(), '551'); $pwdMailSubject = new htmlTableExtendedInputField(_('Subject'), 'pwdResetMail_subject', $conf->getLamProMailSubject(), '551');
$pwdMailContent->addElement($pwdMailSubject, true); $pwdMailContent->addElement($pwdMailSubject, true);
$pwdMailIsHTML = false; $pwdMailIsHTML = false;
if ($conf->getLamProMailIsHTML() == 'true') { if ($conf->getLamProMailIsHTML() == 'true') {
$pwdMailIsHTML = true; $pwdMailIsHTML = true;
} }
$pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_isHTML',$pwdMailIsHTML , _('HTML format'), '553'), true); $pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_isHTML',$pwdMailIsHTML , _('HTML format'), '553'), true);
$pwdMailAllowAlternate = true; $pwdMailAllowAlternate = true;
if ($conf->getLamProMailAllowAlternateAddress() == 'false') { if ($conf->getLamProMailAllowAlternateAddress() == 'false') {
$pwdMailAllowAlternate = false; $pwdMailAllowAlternate = false;
} }
$pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_allowAlternate',$pwdMailAllowAlternate , _('Allow alternate address'), '555'), true); $pwdMailContent->addElement(new htmlTableExtendedInputCheckbox('pwdResetMail_allowAlternate',$pwdMailAllowAlternate , _('Allow alternate address'), '555'), true);
$pwdMailBody = new htmlTableExtendedInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552'); $pwdMailBody = new htmlTableExtendedInputTextarea('pwdResetMail_body', $conf->getLamProMailText(), 50, 4, _('Text'), '552');
$pwdMailContent->addElement($pwdMailBody, true); $pwdMailContent->addElement($pwdMailBody, true);
$pwdMailFieldset = new htmlFieldset($pwdMailContent, _("Password mail settings"), '../../graphics/mailBig.png'); $pwdMailFieldset = new htmlFieldset($pwdMailContent, _("Password mail settings"), '../../graphics/mailBig.png');
$container->addElement($pwdMailFieldset, true); $container->addElement($pwdMailFieldset, true);
$container->addElement(new htmlSpacer(null, '10px'), true); $container->addElement(new htmlSpacer(null, '10px'), true);
@ -583,7 +584,7 @@ function checkInput() {
$conf->setLoginSearchSuffix($_POST['loginSearchSuffix']); $conf->setLoginSearchSuffix($_POST['loginSearchSuffix']);
$conf->setLoginSearchPassword($_POST['loginSearchPassword']); $conf->setLoginSearchPassword($_POST['loginSearchPassword']);
$conf->setLoginSearchDN($_POST['loginSearchDN']); $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'])) { if (!$conf->setLoginSearchDN($_POST['loginSearchDN'])) {
$errors[] = array("ERROR", _("Please enter a valid bind user.")); $errors[] = array("ERROR", _("Please enter a valid bind user."));
} }
@ -638,7 +639,7 @@ function checkInput() {
$toolSettings[$toolConfigID] = 'false'; $toolSettings[$toolConfigID] = 'false';
} }
} }
$conf->setToolSettings($toolSettings); $conf->setToolSettings($toolSettings);
// check if password was changed // check if password was changed
if (isset($_POST['passwd1']) && ($_POST['passwd1'] != '')) { if (isset($_POST['passwd1']) && ($_POST['passwd1'] != '')) {
if ($_POST['passwd1'] != $_POST['passwd2']) { if ($_POST['passwd1'] != $_POST['passwd2']) {