mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
display shared-with in addressbook column and allow to use it as filter
This commit is contained in:
parent
e98e91b9f3
commit
a3b17c5db7
@ -1906,19 +1906,25 @@ class addressbook_ui extends addressbook_bo
|
||||
unset($query['advanced_search']['meth_select']);
|
||||
}
|
||||
|
||||
$columsel = $this->prefs['nextmatch-addressbook.index.rows'];
|
||||
$columselection = $columsel ? explode(',',$columsel) : array();
|
||||
$extracols = [];
|
||||
if (in_array('owner_shared_with', $columselection))
|
||||
{
|
||||
$extracols[] = 'shared_with';
|
||||
}
|
||||
|
||||
$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only,
|
||||
$order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']);
|
||||
$order, $extracols, $wildcard,false, $op,[(int)$query['start'], (int)$query['num_rows']], $query['col_filter']);
|
||||
|
||||
// do we need to read the custom fields, depends on the column is enabled and customfields
|
||||
$columsel = $this->prefs['nextmatch-addressbook.index.rows'];
|
||||
$available_distib_lists=$this->get_lists(Acl::READ);
|
||||
$columselection = $columsel ? explode(',',$columsel) : array();
|
||||
$ids = $calendar_participants = array();
|
||||
if (!$id_only && $rows)
|
||||
{
|
||||
$show_custom_fields = (in_array('customfields',$columselection) || $this->config['index_load_cfs']) && $this->customfields;
|
||||
$show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar',$columselection);
|
||||
$show_distributionlist = in_array('distrib_lists',$columselection) || count($available_distib_lists);
|
||||
$show_distributionlist = in_array('distrib_lists', $columselection) ||
|
||||
is_array($available_distib_lists) && count($available_distib_lists);
|
||||
if ($show_calendar || $show_custom_fields || $show_distributionlist)
|
||||
{
|
||||
foreach($rows as $val)
|
||||
|
@ -85,7 +85,10 @@
|
||||
<nextmatch-customfields id="customfields"/>
|
||||
<nextmatch-header label="Note" id="note"/>
|
||||
<nextmatch-header label="Distribution lists" id="distribution_list"/>
|
||||
<nextmatch-header label="Addressbook" id="owner"/>
|
||||
<vbox>
|
||||
<nextmatch-header label="Addressbook" id="owner"/>
|
||||
<nextmatch-accountfilter empty_label="Shared with" id="shared_with"/>
|
||||
</vbox>
|
||||
<nextmatch-sortheader label="ID" id="contact_id"/>
|
||||
<vbox>
|
||||
<nextmatch-header label="Last date" id="calendar"/>
|
||||
@ -154,7 +157,10 @@
|
||||
<customfields-list id="$row" class="customfields"/>
|
||||
<textbox multiline="true" id="${row}[note]" no_lang="1" readonly="true"/>
|
||||
<description id="${row}[distrib_lists]"/>
|
||||
<select-account id="${row}[owner]" readonly="true"/>
|
||||
<vbox>
|
||||
<select-account id="${row}[owner]" readonly="true"/>
|
||||
<select-account id="${row}[shared_with]" readonly="true" multiple="true"/>
|
||||
</vbox>
|
||||
<description id="${row}[id]" class="contactid"/>
|
||||
<vbox>
|
||||
<link id="${row}[last_link]"/>
|
||||
|
@ -510,7 +510,7 @@ class Sql extends Api\Storage
|
||||
else
|
||||
{
|
||||
// SQL to get all shared contacts to be OR-ed into ACL filter
|
||||
$shared_sql = 'contact_id IN (SELECT contact_id FROM '.self::SHARED_TABLE.' WHERE '.
|
||||
$shared_sql = $this->table_name.'.contact_id IN (SELECT contact_id FROM '.self::SHARED_TABLE.' WHERE '.
|
||||
// $filter[tid] === null is used by sync-collection report, in which case we need to return deleted shares, to remove them from devices
|
||||
(array_key_exists('tid', $filter) && !isset($filter['tid']) ? '' : 'shared_deleted IS NULL AND ').
|
||||
$this->db->expression(self::SHARED_TABLE, ['shared_with' => $filter['owner'] ?? array_keys($this->grants)]).')';
|
||||
@ -668,6 +668,20 @@ class Sql extends Api\Storage
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_array($extra_cols)) $extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
|
||||
if (($key = array_search('shared_with', $extra_cols)) !== false)
|
||||
{
|
||||
$extra_cols[$key] = '(SELECT '.$this->db->group_concat('DISTINCT shared_with').' FROM '.self::SHARED_TABLE.
|
||||
' WHERE '.self::SHARED_TABLE.'.contact_id='.$this->table_name.'.contact_id) AS shared_with';
|
||||
}
|
||||
if (!empty($filter['shared_with']))
|
||||
{
|
||||
$join .= ' JOIN '.self::SHARED_TABLE.' sw ON '.$this->table_name.'.contact_id=sw.contact_id AND sw.'.
|
||||
$this->db->expression(self::SHARED_TABLE, ['shared_with' => $filter['shared_with']]).
|
||||
' AND sw.shared_deleted IS NULL';
|
||||
}
|
||||
unset($filter['shared_with']);
|
||||
|
||||
$rows =& parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
|
||||
|
||||
if ($start === false) $this->total = is_array($rows) ? count($rows) : 0; // so_sql sets total only for $start !== false!
|
||||
|
Loading…
Reference in New Issue
Block a user