/** * check given timezone * the timezone string must match a value in the table * * @access public * @param string $tz * @return boolean **/ public static function checkTZ($tz) { $timezone_table = CAT_Helper_DateTime::getTimezones(); if (in_array($tz, $timezone_table)) { return true; } return false; }
/** * **/ function getTimezones() { $timezone_table = CAT_Helper_DateTime::getTimezones(); $counter = 0; $data = array(); foreach ($timezone_table as $title) { $data[$counter] = array('NAME' => $title, 'SELECTED' => DEFAULT_TIMEZONE_STRING == $title ? true : false); $counter++; } return $data; }
} } else { $_SESSION['USE_DEFAULT_TIME_FORMAT'] = true; unset($_SESSION['CAT_TIME_FORMAT']); } if ($_SESSION['CAT_DATE_FORMAT'] != '') { if (isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); } } else { $_SESSION['USE_DEFAULT_DATE_FORMAT'] = true; unset($_SESSION['CAT_DATE_FORMAT']); } } if (count($errors) > 0) { $message = implode("<br />", $errors); } else { $message = $user->lang()->translate('Details saved successfully') . "!<br /><br />"; $show_form = false; } } unset($submit_ok); // get available languages, mark currently used $languages = CAT_Helper_Addons::get_addons(isset($language) && $language !== LANGUAGE ? $language : LANGUAGE, 'language'); global $parser; $parser->setPath(CAT_PATH . '/templates/' . DEFAULT_TEMPLATE . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT')); // if there's a template for this in the current frontend template $parser->setFallbackPath(dirname(__FILE__) . '/templates/default'); // fallback to default dir $parser->output('account_preferences_form', array('show_form' => $show_form, 'languages' => $languages, 'timezones' => CAT_Helper_DateTime::getTimezones(), 'current_tz' => CAT_Helper_DateTime::getTimezone(), 'date_formats' => CAT_Helper_DateTime::getDateFormats(), 'current_df' => CAT_Helper_DateTime::getDefaultDateFormatShort(), 'time_formats' => CAT_Helper_DateTime::getTimeFormats(), 'current_tf' => CAT_Helper_DateTime::getDefaultTimeFormat(), 'PREFERENCES_URL' => PREFERENCES_URL, 'USER_ID' => $user->get_user_id(), 'DISPLAY_NAME' => $user->get_display_name(), 'GET_EMAIL' => $user->get_email(), 'RESULT_MESSAGE' => $message, 'AUTH_MIN_LOGIN_LENGTH' => AUTH_MIN_LOGIN_LENGTH)); unset($_SESSION['result_message']);
$tpl_data['show_cmd_profile_edit'] = true; $tpl_data['show_cmd_profile_edit_block'] = true; } else { $tpl_data['show_cmd_profile_edit'] = true; $tpl_data['show_cmd_profile_edit_block'] = false; } // ============================================================================ // ! read available languages from table addons and assign it to the template // ============================================================================ $addons = CAT_Helper_Addons::getInstance(); $tpl_data['languages'] = $addons->get_addons(LANGUAGE, 'language', false, 'directory'); // ================================== // ! Insert default timezone values // ================================== $counter = 0; $timezone_table = CAT_Helper_DateTime::getTimezones(); $user_timezone = isset($_SESSION['TIMEZONE_STRING']) ? $_SESSION['TIMEZONE_STRING'] : CAT_Registry::get('DEFAULT_TIMEZONE_STRING'); foreach ($timezone_table as $title) { $tpl_data['timezones'][$counter]['NAME'] = $title; $tpl_data['timezones'][$counter]['SELECTED'] = $user_timezone == $title ? true : false; $counter++; } // =========================== // ! Insert date format list // =========================== $DATE_FORMATS = CAT_Helper_DateTime::getDateFormats(); $USE_DEFAULT = $val->fromSession('USE_DEFAULT_DATE_FORMAT'); $userformat = $val->fromSession('CAT_DATE_FORMAT'); $counter = 0; foreach ($DATE_FORMATS as $format => $title) { $format = str_replace('|', ' ', $format);