Example #1
0
 /**
  * Verifies if the user timezone is valid. 
  * If the timezone is invalid, the board default is used.
  *
  * @return boolean True when timezone was valid, false otherwise
  */
 function verify_timezone()
 {
     $user =& $this->data;
     $timezones = get_supported_timezones();
     if (!array_key_exists($user['timezone'], $timezones)) {
         $user['timezone'] = $mybb->settings['timezoneoffset'];
         return false;
     }
     return true;
 }
Example #2
0
/**
 * Build a time zone selection list.
 *
 * @param string $name The name of the select
 * @param int $selected The selected time zone (defaults to GMT)
 * @param boolean $short True to generate a "short" list with just timezone and current time
 * @return string
 */
function build_timezone_select($name, $selected = 0, $short = false)
{
    global $mybb, $lang, $templates;
    $timezones = get_supported_timezones();
    $selected = str_replace("+", "", $selected);
    foreach ($timezones as $timezone => $label) {
        $selected_add = "";
        if ($selected == $timezone) {
            $selected_add = " selected=\"selected\"";
        }
        if ($short == true) {
            $label = '';
            if ($timezone != 0) {
                $label = $timezone;
                if ($timezone > 0) {
                    $label = "+{$label}";
                }
                if (strpos($timezone, ".") !== false) {
                    $label = str_replace(".", ":", $label);
                    $label = str_replace(":5", ":30", $label);
                    $label = str_replace(":75", ":45", $label);
                } else {
                    $label .= ":00";
                }
            }
            $time_in_zone = my_date($mybb->settings['timeformat'], TIME_NOW, $timezone);
            $label = $lang->sprintf($lang->timezone_gmt_short, $label . " ", $time_in_zone);
        }
        eval("\$timezone_option .= \"" . $templates->get("usercp_options_timezone_option") . "\";");
    }
    eval("\$select = \"" . $templates->get("usercp_options_timezone") . "\";");
    return $select;
}