mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-24 17:04:14 +01:00
Calendar: Enable filtering by customfield in list view
This commit is contained in:
parent
134788efe9
commit
88e539f51d
@ -794,7 +794,37 @@ class calendar_so
|
||||
$where = array_merge($where, $params['sql_filter']);
|
||||
}
|
||||
}
|
||||
if(array_filter($where, fn($key) => str_contains($key, '#'), ARRAY_FILTER_USE_KEY))
|
||||
{
|
||||
$custom_fields = Api\Storage\Customfields::get('calendar');
|
||||
foreach($where as $col => $data)
|
||||
{
|
||||
if($col[0] == '#' && $data)
|
||||
{
|
||||
unset($where[$col]);
|
||||
$filtermethod = " $this->cal_table.cal_id IN (SELECT DISTINCT cal_id FROM $this->extra_table WHERE ";
|
||||
if($custom_fields[substr($col, 1)]['type'] == 'select' && $custom_fields[substr($col, 1)]['rows'] > 1)
|
||||
{
|
||||
// Multi-select - any entry with the filter value selected matches
|
||||
$filtermethod .= $this->db->expression($this->extra_table, array(
|
||||
'cal_extra_name' => substr($col, 1),
|
||||
$this->db->concat("','", 'cal_extra_value', "','") . ' ' . $this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE] . ' ' . $this->db->quote('%,' . $data . ',%'),
|
||||
)) . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filtermethod .= $this->db->expression($this->extra_table, array(
|
||||
'cal_extra_name' => substr($col, 1),
|
||||
'cal_extra_value' => $data,
|
||||
)) . ')';
|
||||
}
|
||||
$where[] = $filtermethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$useUnionQuery = $this->db->capabilities['distinct_on_text'] && $this->db->capabilities['union'];
|
||||
|
||||
if($users)
|
||||
{
|
||||
$users_by_type = array();
|
||||
|
@ -416,6 +416,10 @@ class calendar_uilist extends calendar_ui
|
||||
{
|
||||
$col_filter['cal_id'] = $val;
|
||||
}
|
||||
if($name[0] == '#')
|
||||
{
|
||||
$search_params['cfs'][] = $name;
|
||||
}
|
||||
}
|
||||
// Videocalls
|
||||
if(array_key_exists('include_videocalls',$params['col_filter']))
|
||||
|
Loading…
Reference in New Issue
Block a user