diff --git a/fuel/app/classes/extension/date.php b/fuel/app/classes/extension/date.php index d1c6538..e4198a3 100644 --- a/fuel/app/classes/extension/date.php +++ b/fuel/app/classes/extension/date.php @@ -13,6 +13,30 @@ class Date extends \Date { + /** + * get real timezone value (example Asia/Bangkok) from timezone number (example (UTC+07:00) Bangkok)
+ * by match timezone number to timezone configuration. + * + * @param string $timezone_num + * @return string timezone value for php. + */ + public static function getRealTimezoneValue($timezone_num) + { + \Config::load('timezone', 'timezone'); + $timezone_list = \Config::get('timezone.timezone', array()); + + if (is_array($timezone_list) && array_key_exists($timezone_num, $timezone_list)) { + $timezone = $timezone_list[$timezone_num]; + unset($timezone_list); + return $timezone; + } + + unset($timezone, $timezone_list); + // in case that it cannot found any value matched. use UTC (+0.00). + return 'UTC'; + }// getRealTimezoneValue + + /** * gmt date. the timezone up to current user data. * @@ -36,12 +60,17 @@ public static function gmtDate($date_format = '%Y-%m-%d %H:%M:%S', $timestamp = $timestamp = strtotime($timestamp); } } + + // make very sure that selected timezone is in the timezone list or converted to real timezone. + if ($timezone != null) { + $timezone = static::isValidTimezone($timezone); + } // check timezone if ($timezone == null) { $account_model = new \Model_Accounts(); $cookie = $account_model->getAccountCookie(); - $site_timezone = \Model_Config::getval('site_timezone'); + $site_timezone = static::getRealTimezoneValue(\Model_Config::getval('site_timezone')); if (!isset($cookie['account_id'])) { // not member or not log in. use default config timezone. @@ -51,7 +80,7 @@ public static function gmtDate($date_format = '%Y-%m-%d %H:%M:%S', $timestamp = $row = \Model_Accounts::find($cookie['account_id']); if (!empty($row)) { - $timezone = $row->account_timezone; + $timezone = static::getRealTimezoneValue($row->account_timezone); } else { $timezone = $site_timezone; } @@ -89,6 +118,29 @@ public static function isValidTimeStamp($timestamp) { }// isValidTimeStamp + /** + * is valid timezone.
+ * check and return real timezone value. + * + * @param string $timezone check timezone + * @return string return checked and get timezone value. if found that this is invalid then return null. + */ + public static function isValidTimezone($timezone) { + \Config::load('timezone', 'timezone'); + $timezone_list = \Config::get('timezone.timezone', array()); + if (array_key_exists($timezone, $timezone_list)) { + // found in timezone list key. convert to timezone list value. + $timezone = static::getRealTimezoneValue($timezone); + } elseif (\Arr::search($timezone_list, $timezone) === null) { + // not found in the timezone list value. this is not the timezone key and not even timezone value.! + $timezone = null; + } + unset($timezone_list); + + return $timezone; + }// isValidTimezone + + /** * get gmt timestamp from local timestamp * diff --git a/public/public/themes/system/admin/templates/account/account_form_v.php b/public/public/themes/system/admin/templates/account/account_form_v.php index 31aac41..62f09a6 100644 --- a/public/public/themes/system/admin/templates/account/account_form_v.php +++ b/public/public/themes/system/admin/templates/account/account_form_v.php @@ -4,200 +4,200 @@

'form-horizontal', 'role' => 'form')); ?> -
- -
- -
- +
+ +
+ +
+ - + -
- -
- 'account_username', 'maxlength' => '255', 'class' => 'form-control', (\Uri::segment(3) == 'edit' ? 'disabled' : 'required'))); ?> -
-
-
- -
- 'account_email', 'maxlength' => '255', 'class' => 'form-control', 'required' => '')); ?> -
-
+
+ +
+ 'account_username', 'maxlength' => '255', 'class' => 'form-control', (\Uri::segment(3) == 'edit' ? 'readonly' : 'required'))); ?> +
+
+
+ +
+ 'account_email', 'maxlength' => '255', 'class' => 'form-control', 'required' => '')); ?> +
+
-
- -
- -
- 'account_password', 'maxlength' => '70', 'class' => 'form-control')); ?> -
-
- -
- -
- 'account_new_password', 'maxlength' => '70', 'class' => 'form-control')); ?> -
-
- -
+
+ +
+ +
+ 'account_password', 'maxlength' => '70', 'class' => 'form-control')); ?> +
+
+ +
+ +
+ 'account_new_password', 'maxlength' => '70', 'class' => 'form-control')); ?> +
+
+ +
-
- -
- -
- 'account_display_name', 'maxlength' => '255', 'class' => 'form-control', 'required' => '')); ?> -
-
-
-
- -
- -
- - - -
- - - 'account_avatar')); ?> -
$avatar_size)); ?> - str_replace('|', ', ', $avatar_allowed_types))); ?> -
-
-
-
- -
- + 'account_avatar')); ?> +
$avatar_size)); ?> + str_replace('|', ', ', $avatar_allowed_types))); ?> +
+
+
+
+ +
+ -
\Extension\Date::gmtDate('%Y-%m-%d %H:%M:%S', (string)time(), $tmp_account_timezone))); ?>
-
-
-
+ // selected, no more another selected because this list have many duplicate key. + if (isset($account_timezone) && $account_timezone == $tznum) { + unset($account_timezone); + } + } + unset($timezone_list, $tznum, $tzval); + ?> + +
\Extension\Date::gmtDate('%Y-%m-%d %H:%M:%S', (string)time(), $tmp_account_timezone))); ?>
+ + + -
- -
- -
- 'account_firstname', 'maxlength' => '255', 'class' => 'form-control')); ?> -
-
-
- -
- 'account_lastname', 'maxlength' => '255', 'class' => 'form-control')); ?> -
-
-
- -
-
-
- 'account_birthdate', 'maxlength' => '10', 'class' => 'form-control')); ?> -
-
-
-
-
-
+
+ +
+ +
+ 'account_firstname', 'maxlength' => '255', 'class' => 'form-control')); ?> +
+
+
+ +
+ 'account_lastname', 'maxlength' => '255', 'class' => 'form-control')); ?> +
+
+
+ +
+
+
+ 'account_birthdate', 'maxlength' => '10', 'class' => 'form-control')); ?> +
+
+
+
+
+
-
- -
- -
- -
-
-
- -
- -
-
-
style="display: block;"> - -
- 'account_status_text', 'maxlength' => '255', 'class' => 'form-control')); ?> -
-
-
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
style="display: block;"> + +
+ 'account_status_text', 'maxlength' => '255', 'class' => 'form-control')); ?> +
+
+
- - Example custom field -
- -
- 'ex_af_phone', 'maxlength' => '20', 'class' => 'form-control')); ?> -
-
-
- -
- 'ex_af_homepage', 'maxlength' => '20', 'class' => 'form-control')); ?> -
-
- choice main:
- a1 - a2
-
- choice sub of a2:
- a2.1 - a2.2 - a2.3 - */ ?> + + Example custom field +
+ +
+ 'ex_af_phone', 'maxlength' => '20', 'class' => 'form-control')); ?> +
+
+
+ +
+ 'ex_af_homepage', 'maxlength' => '20', 'class' => 'form-control')); ?> +
+
+ choice main:
+ a1 + a2
+
+ choice sub of a2:
+ a2.1 + a2.2 + a2.3 + */ ?> -
-
- - - - - - - -
-
- +
+
+ + + + + + + +
+
+ \ No newline at end of file diff --git a/public/public/themes/system/admin/templates/config/config_v.php b/public/public/themes/system/admin/templates/config/config_v.php index 7e4bb84..5a73c92 100644 --- a/public/public/themes/system/admin/templates/config/config_v.php +++ b/public/public/themes/system/admin/templates/config/config_v.php @@ -1,376 +1,376 @@

'form-horizontal', 'role' => 'form')); ?> -
- -
- -
- +
+ +
+ +
+ -
- - - - -
-
-
-
-
- -
- '255', 'id' => 'cfg-site_name', 'class' => 'form-control', 'required' => '')); ?> -
-
-
- -
- '20', 'id' => 'cfg-page_title_separator', 'class' => 'form-control')); ?> -
-
-
- -
- + + $tzval) { + echo '' . "\n"; - // selected, no more another selected because this list have many duplicate key. - if (isset($site_timezone_selectbox) && $site_timezone_selectbox == $key) { - unset($site_timezone_selectbox); - } - } - unset($key, $timezone_list, $val); - ?> - - -
-
-
-
-
- - -
-
-
-

-
-
- -
-
-
-
- -
-
-
- -
- \Lang::get('config_member_verification_not_verify'), - '1' => \Lang::get('config_member_verification_by_email'), - '2' => \Lang::get('config_member_verification_by_admin'), - ), - array( - 'id' => 'cfg-member_verification', - 'class' => 'form-control chosen-select' - ) - ); - ?> -
-
-
- -
- '255', 'id' => 'cfg-member_admin_verify_emails', 'class' => 'form-control', 'required' => '')); ?> -
-
-
-
- -
- '255', 'id' => 'cfg-member_disallow_username', 'class' => 'form-control')); ?> -
-
-
- -

-
-
- -
-
-
- -
-
- '2', 'id' => 'cfg-member_max_login_fail', 'class' => 'form-control')); ?> - -
-
-
-
- -
-
- '3', 'id' => 'cfg-member_login_fail_wait_time', 'class' => 'form-control')); ?> - -
-
-
-
- -
-
- '3', 'id' => 'cfg-member_login_remember_length', 'class' => 'form-control')); ?> - -
-
-
-
- -
-
- '5', 'id' => 'cfg-member_confirm_wait_time', 'class' => 'form-control')); ?> - -
-
-
-
-
- -
-
-
-
-

-
-
- -
-
-
- -
-
- '3', 'id' => 'cfg-avatar_size', 'class' => 'form-control')); ?> - -
-
-
-
- -
- '255', 'id' => 'cfg-avatar_allowed_types', 'class' => 'form-control')); ?> -
-
-
-
- -
- '255', 'id' => 'cfg-avatar_path', 'class' => 'form-control')); ?> -
-
-
-
-
-
- - -
-
-
-
- -
- \Lang::get('config_mail_protocol_mail'), - 'sendmail' => \Lang::get('config_mail_protocol_sendmail'), - 'smtp' => \Lang::get('config_mail_protocol_smtp'), - ), - array( - 'id' => 'cfg-mail_protocol', - 'class' => 'form-control chosen-select' - ) - ); - ?> -
-
-
- -
- '255', 'id' => 'cfg-mail_mailpath', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-mail_smtp_host', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-mail_smtp_user', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-mail_smtp_pass', 'class' => 'form-control')); ?> -
-
-
- -
- '3', 'id' => 'cfg-mail_smtp_port', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-mail_sender_email', 'class' => 'form-control', 'required' => '')); ?> -
-
-
-
-
-
- - -
-
-
-
- -
- '3', 'id' => 'cfg-content_items_perpage', 'class' => 'form-control', 'required' => '')); ?> -
-
-
- -
- '3', 'id' => 'cfg-content_admin_items_perpage', 'class' => 'form-control', 'required' => '')); ?> -
-
-
-
-
- - -
-
-
-
- -
- '255', 'id' => 'cfg-media_allowed_types', 'class' => 'form-control')); ?> -
-
-
-
-
-
- - -
-
-
-
- -
- '255', 'id' => 'cfg-ftp_host', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-ftp_username', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-ftp_password', 'class' => 'form-control')); ?> -
-
-
- -
- '255', 'id' => 'cfg-ftp_port', 'class' => 'form-control')); ?> -
-
-
- -
- \Lang::get('admin_yes'), - 'false' => \Lang::get('admin_no'), - ), - array( - 'id' => 'cfg-ftp_passive', - 'class' => 'form-control chosen-select' - ) - ); - ?> -
-
-
- -
- '255', 'id' => 'cfg-ftp_basepath', 'class' => 'form-control')); ?> -
-
-
-
-
- -
-
-
-
-
-
-
-
- -
-
- - 'btn btn-default')); ?> -
-
+ // selected, no more another selected because this list have many duplicate key. + if (isset($site_timezone_selectbox) && $site_timezone_selectbox == $tznum) { + unset($site_timezone_selectbox); + } + } + unset($timezone_list, $tznum, $tzval); + ?> + + + + + + + + + +
+
+
+

+
+
+ +
+
+
+
+ +
+
+
+ +
+ \Lang::get('config_member_verification_not_verify'), + '1' => \Lang::get('config_member_verification_by_email'), + '2' => \Lang::get('config_member_verification_by_admin'), + ), + array( + 'id' => 'cfg-member_verification', + 'class' => 'form-control chosen-select' + ) + ); + ?> +
+
+
+ +
+ '255', 'id' => 'cfg-member_admin_verify_emails', 'class' => 'form-control', 'required' => '')); ?> +
+
+
+
+ +
+ '255', 'id' => 'cfg-member_disallow_username', 'class' => 'form-control')); ?> +
+
+
+ +

+
+
+ +
+
+
+ +
+
+ '2', 'id' => 'cfg-member_max_login_fail', 'class' => 'form-control')); ?> + +
+
+
+
+ +
+
+ '3', 'id' => 'cfg-member_login_fail_wait_time', 'class' => 'form-control')); ?> + +
+
+
+
+ +
+
+ '3', 'id' => 'cfg-member_login_remember_length', 'class' => 'form-control')); ?> + +
+
+
+
+ +
+
+ '5', 'id' => 'cfg-member_confirm_wait_time', 'class' => 'form-control')); ?> + +
+
+
+
+
+ +
+
+
+
+

+
+
+ +
+
+
+ +
+
+ '3', 'id' => 'cfg-avatar_size', 'class' => 'form-control')); ?> + +
+
+
+
+ +
+ '255', 'id' => 'cfg-avatar_allowed_types', 'class' => 'form-control')); ?> +
+
+
+
+ +
+ '255', 'id' => 'cfg-avatar_path', 'class' => 'form-control')); ?> +
+
+
+
+
+
+ + +
+
+
+
+ +
+ \Lang::get('config_mail_protocol_mail'), + 'sendmail' => \Lang::get('config_mail_protocol_sendmail'), + 'smtp' => \Lang::get('config_mail_protocol_smtp'), + ), + array( + 'id' => 'cfg-mail_protocol', + 'class' => 'form-control chosen-select' + ) + ); + ?> +
+
+
+ +
+ '255', 'id' => 'cfg-mail_mailpath', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-mail_smtp_host', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-mail_smtp_user', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-mail_smtp_pass', 'class' => 'form-control')); ?> +
+
+
+ +
+ '3', 'id' => 'cfg-mail_smtp_port', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-mail_sender_email', 'class' => 'form-control', 'required' => '')); ?> +
+
+
+
+
+
+ + +
+
+
+
+ +
+ '3', 'id' => 'cfg-content_items_perpage', 'class' => 'form-control', 'required' => '')); ?> +
+
+
+ +
+ '3', 'id' => 'cfg-content_admin_items_perpage', 'class' => 'form-control', 'required' => '')); ?> +
+
+
+
+
+ + +
+
+
+
+ +
+ '255', 'id' => 'cfg-media_allowed_types', 'class' => 'form-control')); ?> +
+
+
+
+
+
+ + +
+
+
+
+ +
+ '255', 'id' => 'cfg-ftp_host', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-ftp_username', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-ftp_password', 'class' => 'form-control')); ?> +
+
+
+ +
+ '255', 'id' => 'cfg-ftp_port', 'class' => 'form-control')); ?> +
+
+
+ +
+ \Lang::get('admin_yes'), + 'false' => \Lang::get('admin_no'), + ), + array( + 'id' => 'cfg-ftp_passive', + 'class' => 'form-control chosen-select' + ) + ); + ?> +
+
+
+ +
+ '255', 'id' => 'cfg-ftp_basepath', 'class' => 'form-control')); ?> +
+
+
+
+
+ +
+
+
+
+
+
+ + + +
+
+ + 'btn btn-default')); ?> +
+
@@ -380,44 +380,44 @@ ?> \ No newline at end of file