Merge pull request #1495 from d-bro/timezone

Feature request 1312: Added configuration option for setting the timezone of the current database connection
This commit is contained in:
Marc Delisle 2015-02-10 12:52:54 -05:00
commit 80da5e5e9a
3 changed files with 45 additions and 0 deletions

View File

@ -904,6 +904,18 @@ Server connection settings
rows in :config:option:`$cfg['Servers'][$i]['table_uiprefs']` and automatically
delete older rows.
.. config:option:: $cfg['Servers'][$i]['SessionTimeZone']
:type: string
:default: ``''``
Sets the time zone used by phpMyAdmin. Leave blank to use the time zone of your
database server. Possible values are explained at
http://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html
This is useful when your database server uses a time zone which is different from the
time zone you want to use in phpMyAdmin.
.. config:option:: $cfg['Servers'][$i]['AllowRoot']
:type: boolean

View File

@ -981,6 +981,31 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$cfg['Server']['user'], $cfg['Server']['password'], false
);
// Set timestamp for the session, if required.
if ($cfg['Server']['SessionTimeZone'] != '') {
$sql_query_tz = 'SET ' . PMA_Util::backquote('time_zone') . ' = '
. '\'' . PMA_Util::sqlAddSlashes($cfg['Server']['SessionTimeZone']) . '\'';
if(! $userlink->query($sql_query_tz)) {
$error_message_tz = sprintf(__('Unable to use timezone %s for server %d. '
. 'Please check your configuration setting for '
. '[em]$cfg[\'Servers\'][%d][\'SessionTimeZone\'][/em]. '
. 'phpMyAdmin is currently using the default time zone of the database server.'),
$cfg['Servers'][$GLOBALS['server']]['SessionTimeZone'],
$GLOBALS['server'],
$GLOBALS['server']
);
$GLOBALS['error_handler']->addError(
$error_message_tz,
E_USER_WARNING,
'',
'',
false
);
}
}
if (! $controllink) {
$controllink = $userlink;
}

View File

@ -493,6 +493,14 @@ $cfg['Servers'][$i]['central_columns'] = '';
*/
$cfg['Servers'][$i]['MaxTableUiprefs'] = 100;
/**
* Sets the time zone used by phpMyAdmin. Possible values are explained at
* http://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html
*
* @global string $cfg['Servers'][$i]['SessionTimeZone'] = ''
*/
$cfg['Servers'][$i]['SessionTimeZone'] = '';
/**
* whether to allow root login
*