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
- 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

View File

@ -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);
}
/**

View File

@ -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');
}
}

View File

@ -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';
}
}

View File

@ -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);