added time zone setting to server profile

This commit is contained in:
Roland Gruber 2015-06-08 18:33:38 +00:00
parent b9d1c64398
commit 5930ef17b5
8 changed files with 75 additions and 42 deletions

View File

@ -8,6 +8,7 @@ June 2015
- Personal: allow to add ou=addressbook subentry for users (RFE 117)
- Unix: support auto-UID/GID with msSFU30DomainInfo
- Windows groups: support editing of member of
- Central time zone setting in server profile
- LAM Pro:
-> Password Self Reset: added 389 Directory Server schema file
-> Support for groupOfMembers (RFE 121)

View File

@ -987,7 +987,15 @@ Have fun!
<title>Version specific upgrade instructions</title>
<section>
<title>4.5 -&gt; 5.0</title>
<title>4.9 -&gt; 5.0</title>
<para>Samba 3: If you used logon hours then you need to set the
correct time zone on tab "Generel settings" in server
profile.</para>
</section>
<section>
<title>4.5 -&gt; 4.9</title>
<para>No special actions needed.</para>
</section>
@ -1594,6 +1602,8 @@ Have fun!
select the default language for this server profile. The language
setting may be overriden at the LAM login page.</para>
<para>Please also set your time zone here.</para>
<screenshot>
<mediaobject>
<imageobject>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Michael Duergner
2003 - 2014 Roland Gruber
2003 - 2015 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -104,6 +104,8 @@ $helpArray = array (
"Text" => _("If enabled then the default language will be enforced and cannot be chosen by the user.")),
"212" => array ("Headline" => _("Change password"),
"Text" => _("If you want to change the current preferences password, please enter it here.")),
"213" => array ("Headline" => _('Time zone'),
"Text" => _('Please select your local time zone.')),
"214" => array ("Headline" => _("Cache timeout"),
"Text" => _("This is the time in minutes which LAM caches its LDAP searches. Shorter times will stress LDAP more but decrease the possibility that changes are not identified.")),
"215" => array ("Headline" => _("Access level"),

View File

@ -1256,4 +1256,15 @@ function getCallingURL() {
return $url;
}
/**
* Returns the offset in hours from configured time zone to GMT.
*
* @return int offset
*/
function getTimeZoneOffsetHours() {
$timeZone = $_SESSION['config']->getTimeZone();
$dtz = new DateTimeZone($timeZone);
return round($dtz->getOffset(new DateTime('UTC')) / 3600);
}
?>

View File

@ -431,6 +431,8 @@ class LAMConfig {
/** Default language */
private $defaultLanguage;
/** time zone */
private $timeZone = 'Europe/London';
/** module settings */
private $moduleSettings = array();
@ -519,7 +521,7 @@ class LAMConfig {
"modules", "activeTypes", "types", "tools", "accessLevel", 'loginMethod', 'loginSearchSuffix',
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailReplyTo', 'lamProMailSubject',
'lamProMailText', 'lamProMailIsHTML', 'lamProMailAllowAlternateAddress', 'httpAuthentication', 'loginSearchDN',
'loginSearchPassword');
'loginSearchPassword', 'timeZone');
/**
@ -691,6 +693,7 @@ class LAMConfig {
if (!in_array("treesuffix", $saved)) array_push($file_array, "\n\n# suffix of tree view\n" .
"# e.g. dc=yourdomain,dc=org\n" . "treesuffix: " . $this->treesuffix . "\n");
if (!in_array("defaultLanguage", $saved)) array_push($file_array, "\n\n# default language (a line from config/language)\n" . "defaultLanguage: " . $this->defaultLanguage . "\n");
if (!in_array("timeZone", $saved)) array_push($file_array, "\n\n# time zone\n" . "timeZone: " . $this->timeZone . "\n");
if (!in_array("scriptPath", $saved)) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath . "\n");
if (!in_array("scriptServer", $saved)) array_push($file_array, "\n\n# Servers of external script\n" . "scriptServer: " . $this->scriptServer . "\n");
if (!in_array("scriptRights", $saved)) array_push($file_array, "\n\n# Access rights for home directories\n" . "scriptRights: " . $this->scriptRights . "\n");
@ -1022,6 +1025,29 @@ class LAMConfig {
return true;
}
/**
* Returns the time zone name.
*
* @return string time zone
*/
public function getTimeZone() {
return ($this->timeZone == null) ? 'Europe/London' : $this->timeZone;
}
/**
* Sets the time zone name.
*
* @param string $value new time zone
* @return boolean true if $value has correct format
*/
public function setTimeZone($value) {
if (is_string($value)) {
$this->timeZone = $value;
return true;
}
return false;
}
/**
* Returns the path to the external script
*

View File

@ -549,42 +549,13 @@ class sambaSamAccount extends baseModule implements passwordService {
);
}
// configuration options
$timezones = array(
"GMT-12: " . _("Eniwetok, Kwajalein") => '-12',
"GMT-11: " . _("Midway Island, Samoa") => '-11',
"GMT-10: " . _("Hawaii") => '-10',
"GMT-09: " . _("Alaska") => '-9',
"GMT-08: " . _("Pacific Time (US & Canada)") => '-8',
"GMT-07: " . _("Mountain Time (US & Canada)") => '-7',
"GMT-06: " . _("Central Time (US & Canada), Mexico City") => '-6',
"GMT-05: " . _("Eastern Time (US & Canada), Bogota") => '-5',
"GMT-04: " . _("Atlantic time (Canada), Caracas") => '-4',
"GMT-03: " . _("Brazil, Buenos Aires") => '-3',
"GMT-02: " . _("Mid-Atlantic") => '-2',
"GMT-01: " . _("Azores, Cape Verde Islands") => '-1',
'GMT: ' . _("Western Europe Time, London, Lisbon") => '0',
"GMT+01: " . _("Central Europe Time, Paris, Berlin") => '1',
"GMT+02: " . _("Eastern Europe Time, South Africa") => '2',
"GMT+03: " . _("Baghdad, Riyadh, Moscow") => '3',
"GMT+04: " . _("Abu Dhabi, Muscat, Baku") => '4',
"GMT+05: " . _("Islamabad, Karachi") => '5',
"GMT+06: " . _("Almaty, Dhaka, Colombo") => '6',
"GMT+07: " . _("Bangkok, Hanoi, Jakarta") => '7',
"GMT+08: " . _("Beijing, Perth, Singapore") => '8',
"GMT+09: " . _("Tokyo, Seoul, Osaka, Yakutsk") => '9',
"GMT+10: " . _("East Australian Standard, Guam") => '10',
"GMT+11: " . _("Magadan, Solomon Islands") => '11',
"GMT+12: " . _("Auckland, Fiji, Kamchatka") => '12',
);
$configContainer = new htmlTable();
$timezoneSelect = new htmlTableExtendedSelect('sambaSamAccount_timeZone', $timezones, array('0'), _("Time zone"), 'timeZone');
$timezoneSelect->setHasDescriptiveElements(true);
$timezoneSelect->setSortElements(false);
$configContainer->addElement($timezoneSelect, true);
$disableLM = new htmlTable();
$yesNo = array(_('yes') => 'yes', _('no') => 'no');
$yesNoSelect = new htmlTableExtendedSelect('sambaSamAccount_lmHash', $yesNo, array('yes'), _("Disable LM hashes"), 'lmHash');
$yesNoSelect->setHasDescriptiveElements(true);
$configContainer->addElement($yesNoSelect, true);
$disableLM->addElement($yesNoSelect, true);
$configContainer->addElement($disableLM, true);
$configContainer->addElement(new htmlSpacer(null, '10px'), true);
$configHiddenLabelGroup = new htmlGroup();
$configHiddenLabelGroup->addElement(new htmlOutputText(_('Hidden options') . ' '));
@ -975,9 +946,9 @@ class sambaSamAccount extends baseModule implements passwordService {
$logonHoursNew = '';
for ($i = 0; $i < 21; $i++) {
$part = strrev(substr($logonHours, $i * 8, 8));
$byte[hi] = substr($part,0,4);
$byte[low] = substr($part,4,4);
$hex = $bitstring2hex[$byte[hi]].$bitstring2hex[$byte[low]];
$byte['hi'] = substr($part,0,4);
$byte['low'] = substr($part,4,4);
$hex = $bitstring2hex[$byte['hi']].$bitstring2hex[$byte['low']];
$logonHoursNew = $logonHoursNew . $hex;
}
$this->attributes['sambaLogonHours'][0] = $logonHoursNew;
@ -1373,10 +1344,7 @@ class sambaSamAccount extends baseModule implements passwordService {
*/
function display_html_logonHours() {
$return = new htmlTable();
$timeZone = 0;
if (isset($this->moduleSettings['sambaSamAccount_timeZone']) && is_array($this->moduleSettings['sambaSamAccount_timeZone'])) {
$timeZone = $this->moduleSettings['sambaSamAccount_timeZone'][0];
}
$timeZone = getTimeZoneOffsetHours();
$days = array(1 => _('Monday'), 2 => _('Tuesday'), 3 => _('Wednesday'), 4 => _('Thursday'),
5 => _('Friday'), 6 => _('Saturday'), 0 => _('Sunday'));
if (!isset($this->attributes['sambaLogonHours'][0]) || ($this->attributes['sambaLogonHours'][0] == '')) {

View File

@ -303,8 +303,22 @@ if(!empty($possibleLanguages)) {
else {
$languageSettingsContent->addElement(new htmlStatusMessage('ERROR', "Unable to load available languages. Setting English as default language."));
}
$timezones = array();
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::AFRICA));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::AMERICA));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::ANTARCTICA));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::ARCTIC));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::ASIA));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::ATLANTIC));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::AUSTRALIA));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::EUROPE));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::INDIAN));
$timezones = array_merge($timezones, DateTimeZone::listIdentifiers(DateTimeZone::PACIFIC));
$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);
$container->addElement(new htmlSpacer(null, '10px'), true);
// lamdaemon settings
@ -577,6 +591,7 @@ function checkInput() {
if (!$conf->set_defaultLanguage($_POST['lang'])) {
$errors[] = array("ERROR", _("Language is not defined!"));
}
$conf->setTimeZone($_POST['timeZone']);
if (!$conf->set_scriptpath($_POST['scriptpath'])) {
$errors[] = array("ERROR", _("Script path is invalid!"));
}