Esempio n. 1
0
/**
 * Custom validation rule for timezone
 *
 * @param string $rule String of rule name
 * @param array $ruleParams Parameter of validation
 * @return boolean Success
 *
 */
function custom_validation_timezone($rule, $ruleParams)
{
    global $_CONF;
    require_once $_CONF['path_system'] . 'classes/timezoneconfig.class.php';
    $timezones = array_flip(TimeZoneConfig::listAvailableTimeZones());
    $ret = false;
    if (isset($ruleParams[0]['timezone']) && in_array($ruleParams[0]['timezone'], $timezones)) {
        $ret = true;
    }
    return $ret;
}
Esempio n. 2
0
 /**
  * Provide a dropdown menu of the available timezones
  *
  * @param    string  $selected   (optional) currently selected timezone
  * @param    array   $attributes (optional) extra attributes for select tag
  * @return   string              HTML for the dropdown
  * @static
  *
  */
 public static function getTimeZoneDropDown($selected = '', $attributes = array())
 {
     $timezones = TimeZoneConfig::listAvailableTimeZones();
     $selection = '<select';
     foreach ($attributes as $name => $value) {
         $selection .= sprintf(' %s="%s"', $name, $value);
     }
     $selection .= '>' . LB;
     foreach ($timezones as $tzid => $tzdisplay) {
         $selection .= '<option value="' . $tzid . '"';
         if (!empty($selected) && $selected == $tzid) {
             $selection .= ' selected="selected"';
         }
         $selection .= ">{$tzdisplay}</option>" . LB;
     }
     $selection .= '</select>';
     return $selection;
 }
Esempio n. 3
0
/**
* Helper function: Provide timezone dropdown
*
* @return   array   Array of (timezone-long-name, timezone-short-name) pairs
*
*/
function configmanager_select_timezone_helper()
{
    global $_CONF;
    require_once $_CONF['path_system'] . 'classes/timezoneconfig.class.php';
    return array_flip(TimeZoneConfig::listAvailableTimeZones());
}