mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
use et2-tree-dropdown for TZ selection in general preferences
This commit is contained in:
parent
8de6bd0c25
commit
42f8124242
@ -85,7 +85,7 @@ export class Et2SelectCategory extends Et2StaticSelectMixin(Et2Select)
|
|||||||
{
|
{
|
||||||
super.willUpdate(changedProperties);
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
if(changedProperties.has("global_categories") || changedProperties.has("application") || changedProperties.has("parentCat"))
|
if(changedProperties.has("globalCategories") || changedProperties.has("application") || changedProperties.has("parentCat"))
|
||||||
{
|
{
|
||||||
this.fetchComplete = so.cat(this).then(options =>
|
this.fetchComplete = so.cat(this).then(options =>
|
||||||
{
|
{
|
||||||
|
@ -243,7 +243,7 @@ class Select extends Etemplate\Widget
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'select-timezone':
|
case 'select-timezone':
|
||||||
if (!calendar_timezones::tz2id($val))
|
if (!calendar_timezones::tz2id($val) && !in_array($val, $allowed))
|
||||||
{
|
{
|
||||||
self::set_validation_error($form_name, lang("'%1' is NOT a valid timezone!", $val));
|
self::set_validation_error($form_name, lang("'%1' is NOT a valid timezone!", $val));
|
||||||
}
|
}
|
||||||
|
@ -320,20 +320,6 @@ class Tree extends Etemplate\Widget
|
|||||||
self::setElementAttribute($form_name, 'no_lang', $no_lang);
|
self::setElementAttribute($form_name, 'no_lang', $no_lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure s, etc. are properly encoded when sent, and not double-encoded
|
|
||||||
foreach(self::$request->sel_options[$form_name] as &$label)
|
|
||||||
{
|
|
||||||
if(!is_array($label))
|
|
||||||
{
|
|
||||||
$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
|
|
||||||
}
|
|
||||||
elseif(!empty($label['label']))
|
|
||||||
{
|
|
||||||
$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,28 +251,6 @@ class calendar_hooks
|
|||||||
$freebusy_url = '<a href="' . $freebusy_url . '" target="_blank">' . $freebusy_url . '</a>';
|
$freebusy_url = '<a href="' . $freebusy_url . '" target="_blank">' . $freebusy_url . '</a>';
|
||||||
$freebusy_help = lang('Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is');
|
$freebusy_help = lang('Should not loged in persons be able to see your freebusy information? You can set an extra password, different from your normal password, to protect this informations. The freebusy information is in iCal format and only include the times when you are busy. It does not include the event-name, description or locations. The URL to your freebusy information is');
|
||||||
$freebusy_help .= ' ' . $freebusy_url;
|
$freebusy_help .= ' ' . $freebusy_url;
|
||||||
|
|
||||||
// Timezone for file exports
|
|
||||||
$export_tzs = array(['value' => '0', 'label' => lang('Use Event TZ')]);
|
|
||||||
$tz_list = Api\DateTime::getTimezones();
|
|
||||||
|
|
||||||
// Format for select
|
|
||||||
$format = function ($key, $value) use (&$format, &$tzs)
|
|
||||||
{
|
|
||||||
if(is_array($value))
|
|
||||||
{
|
|
||||||
$value = [
|
|
||||||
'label' => $key,
|
|
||||||
'value' => array_map($format, array_keys($value), array_values($value))
|
|
||||||
];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$value = ['label' => $value, 'value' => $key];
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
};
|
|
||||||
$export_tzs = array_merge($export_tzs, array_map($format, array_keys($tz_list), array_values($tz_list)));
|
|
||||||
}
|
}
|
||||||
$link_title_options = calendar_bo::get_link_options();
|
$link_title_options = calendar_bo::get_link_options();
|
||||||
$settings = array(
|
$settings = array(
|
||||||
@ -694,10 +672,13 @@ class calendar_hooks
|
|||||||
|
|
||||||
$settings += array(
|
$settings += array(
|
||||||
'export_timezone' => array(
|
'export_timezone' => array(
|
||||||
'type' => 'select',
|
'type' => 'et2-select-timezone',
|
||||||
'label' => 'Timezone of event iCal file import/export',
|
'label' => 'Timezone of event iCal file import/export',
|
||||||
'name' => 'export_timezone',
|
'name' => 'export_timezone',
|
||||||
'values' => $export_tzs,
|
'values' => [
|
||||||
|
'' => preferences_settings::defaultLabel($hook_data['type']),
|
||||||
|
'0' => lang('Use event timezone'),
|
||||||
|
],
|
||||||
'help' => 'Use this timezone to import/export calendar data.',
|
'help' => 'Use this timezone to import/export calendar data.',
|
||||||
'xmlrpc' => True,
|
'xmlrpc' => True,
|
||||||
'admin' => False,
|
'admin' => False,
|
||||||
|
@ -54,8 +54,9 @@ class preferences_hooks
|
|||||||
if(is_array($value))
|
if(is_array($value))
|
||||||
{
|
{
|
||||||
$value = [
|
$value = [
|
||||||
'label' => $key,
|
'label' => $key ?: '',
|
||||||
'value' => array_map($format, array_keys($value), array_values($value))
|
'value' => $key ?: '',
|
||||||
|
'children' => array_map($format, array_keys($value), array_values($value))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -369,7 +370,7 @@ class preferences_hooks
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
'tz' => array(
|
'tz' => array(
|
||||||
'type' => 'select',
|
'type' => 'et2-tree-dropdown',
|
||||||
'label' => 'Time zone',
|
'label' => 'Time zone',
|
||||||
'name' => 'tz',
|
'name' => 'tz',
|
||||||
'values' => $tzs,
|
'values' => $tzs,
|
||||||
@ -378,11 +379,12 @@ class preferences_hooks
|
|||||||
'admin' => False,
|
'admin' => False,
|
||||||
'default'=> date_default_timezone_get(),
|
'default'=> date_default_timezone_get(),
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'search' => true
|
'search' => true,
|
||||||
|
'leafOnly' => true, // don't allow to select continents
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'tz_selection' => array(
|
'tz_selection' => array(
|
||||||
'type' => 'multiselect',
|
'type' => 'et2-tree-dropdown',
|
||||||
'label' => 'Permanent time zone selection',
|
'label' => 'Permanent time zone selection',
|
||||||
'name' => 'tz_selection',
|
'name' => 'tz_selection',
|
||||||
'values' => $tzs,
|
'values' => $tzs,
|
||||||
@ -391,7 +393,9 @@ class preferences_hooks
|
|||||||
'admin' => False,
|
'admin' => False,
|
||||||
'forced' => date_default_timezone_get(),
|
'forced' => date_default_timezone_get(),
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'search' => true
|
'search' => true,
|
||||||
|
'multiple' => true,
|
||||||
|
'leafOnly' => true,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'dateformat' => array(
|
'dateformat' => array(
|
||||||
|
@ -411,6 +411,21 @@ class preferences_settings
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function defaultLabel(string $type='user')
|
||||||
|
{
|
||||||
|
switch($type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 'user':
|
||||||
|
return lang('Use default');
|
||||||
|
case 'default':
|
||||||
|
case 'group':
|
||||||
|
return lang('No default');
|
||||||
|
case 'forced';
|
||||||
|
return lang('Users choice');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get content, sel_options and readonlys for given appname and type
|
* Get content, sel_options and readonlys for given appname and type
|
||||||
*
|
*
|
||||||
@ -540,40 +555,40 @@ class preferences_settings
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// move values/options to sel_options array
|
// move values/options to sel_options array
|
||||||
if (isset($setting['values']) && is_array($setting['values']) && !$setting['no_sel_options'])
|
if (isset($setting['values']) && is_array($setting['values']) && empty($setting['no_sel_options']))
|
||||||
{
|
{
|
||||||
Select::fix_encoded_options($setting['values'], true);
|
// if you use an et2-* widget as type, it's your responsibility to encode options correct!
|
||||||
if ($old_type != 'multiselect' && $old_type != 'notify')
|
if (str_starts_with($old_type, 'et2-'))
|
||||||
{
|
{
|
||||||
switch($type)
|
$setting['attributes']['placeholder'] = self::defaultLabel($type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Select::fix_encoded_options($setting['values'], true);
|
||||||
|
|
||||||
|
if ($old_type != 'multiselect' && $old_type != 'notify' && $old_type != 'et2-tree-dropdown')
|
||||||
{
|
{
|
||||||
case 'user':
|
if($type === 'forced')
|
||||||
|
{
|
||||||
$setting['values'] = array_merge(
|
$setting['values'] = array_merge(
|
||||||
array(['value' => '', 'label' => lang('Use default')]),
|
array(['value' => '**NULL**', 'label' => self::defaultLabel($type)]),
|
||||||
$setting['values']
|
$setting['values']
|
||||||
);
|
);
|
||||||
break;
|
}
|
||||||
case 'default':
|
else
|
||||||
case 'group':
|
{
|
||||||
$setting['values'] = array_merge(
|
$setting['values'] = array_merge(
|
||||||
array(['value' => '', 'label' => lang('No default')]),
|
array(['value' => '', 'label' => self::defaultLabel($type)]),
|
||||||
$setting['values']
|
$setting['values']
|
||||||
);
|
);
|
||||||
break;
|
}
|
||||||
case 'forced';
|
|
||||||
$setting['values'] = array_merge(
|
|
||||||
array(['value' => '**NULL**', 'label' => lang('Users choice')]),
|
|
||||||
$setting['values']
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sel_options[$setting['name']] = $setting['values'];
|
$sel_options[$setting['name']] = $setting['values'];
|
||||||
}
|
}
|
||||||
if ($type == 'user')
|
if ($type == 'user')
|
||||||
{
|
{
|
||||||
$default = $GLOBALS['egw']->preferences->group[$appname][$setting['name']] ?
|
$default = $GLOBALS['egw']->preferences->group[$appname][$setting['name']] ?:
|
||||||
$GLOBALS['egw']->preferences->group[$appname][$setting['name']] :
|
|
||||||
$GLOBALS['egw']->preferences->default[$appname][$setting['name']];
|
$GLOBALS['egw']->preferences->default[$appname][$setting['name']];
|
||||||
|
|
||||||
// replace default value(s) for selectboxes with selectbox labels
|
// replace default value(s) for selectboxes with selectbox labels
|
||||||
|
Loading…
Reference in New Issue
Block a user