diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php
index 0078680572..37d9d47cfe 100644
--- a/addressbook/inc/class.addressbook_ui.inc.php
+++ b/addressbook/inc/class.addressbook_ui.inc.php
@@ -348,6 +348,12 @@ class addressbook_ui extends addressbook_bo
}
$content['nm']['grouped_view_label'] = $sel_options['grouped_view'][(string) $content['nm']['grouped_view']];
+ // allow to also filter by (not) shared contacts
+ $sel_options['shared_with'] = [
+ 'not' => lang('not shared'),
+ 'shared' => lang('shared'),
+ ];
+
$this->tmpl->read('addressbook.index');
return $this->tmpl->exec('addressbook.addressbook_ui.index',
$content,$sel_options,array(),$preserv);
diff --git a/addressbook/lang/egw_de.lang b/addressbook/lang/egw_de.lang
index def63ce122..d794c773a4 100644
--- a/addressbook/lang/egw_de.lang
+++ b/addressbook/lang/egw_de.lang
@@ -379,6 +379,7 @@ no categories selected addressbook de keine Kategorien ausgewählt
no distribution list addressbook de Keine Verteilerliste
no fallback addressbook de Keine Ausweichlösung
no vcard addressbook de Keine vCard
+not shared addressbook de nicht geteilt
number addressbook de Nummer
number of records to read (%1) addressbook de Anzahl der einzulesenden Datensätze (%1)
open %1 crm view addressbook de Öffnet %1 in der CRM-Ansicht
@@ -458,6 +459,7 @@ set full name and file as field in contacts of all users (either all or only emp
set only full name addressbook de Nur vollen Namen setzen
share into addressbook addressbook de Teilen in Adressbuch
share writable addressbook de Bearbeitbar teilen
+shared addressbook de geteilt
shared by me addressbook de Von mir geteilt
shared into addressbook %1 addressbook de geteilt in Adressbuch %1
shared with addressbook de Geteilt mit
diff --git a/addressbook/lang/egw_en.lang b/addressbook/lang/egw_en.lang
index e0b73e70b0..c5dfa0c890 100644
--- a/addressbook/lang/egw_en.lang
+++ b/addressbook/lang/egw_en.lang
@@ -379,6 +379,7 @@ no categories selected addressbook en No categories selected
no distribution list addressbook en No distribution list
no fallback addressbook en No fallback
no vcard addressbook en No vCard
+not shared addressbook en not shared
number addressbook en Number
number of records to read (%1) addressbook en Number of records to read (%1)
open %1 crm view addressbook en Open %1 CRM view
@@ -458,6 +459,7 @@ set full name and file as field in contacts of all users (either all or only emp
set only full name addressbook en Set only full name
share into addressbook addressbook en Share into addressbook
share writable addressbook en Share writable
+shared addressbook en shared
shared by me addressbook en Shared by me
shared into addressbook %1 addressbook en shared into addressbook %1
shared with addressbook en Shared with
diff --git a/addressbook/templates/default/index.xet b/addressbook/templates/default/index.xet
index 3ee795b54b..03df664cf4 100644
--- a/addressbook/templates/default/index.xet
+++ b/addressbook/templates/default/index.xet
@@ -87,7 +87,7 @@
-
+
diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php
index adb481e329..8e40ddde9e 100644
--- a/api/src/Contacts/Sql.php
+++ b/api/src/Contacts/Sql.php
@@ -668,17 +668,29 @@ class Sql extends Api\Storage
}
}
}
+ // shared with column and filter
if (!is_array($extra_cols)) $extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
+ $shared_with = '(SELECT '.$this->db->group_concat('DISTINCT shared_with').' FROM '.self::SHARED_TABLE.
+ ' WHERE '.self::SHARED_TABLE.'.contact_id='.$this->table_name.'.contact_id AND shared_deleted IS NULL)';
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 AND shared_deleted IS NULL) AS shared_with';
+ $extra_cols[$key] = "$shared_with AS shared_with";
}
- if (!empty($filter['shared_with']))
+ switch ((string)$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';
+ case '': // filter not set
+ break;
+ case 'not':
+ $filter[] = $shared_with.' IS NULL';
+ break;
+ case 'shared':
+ $filter[] = $shared_with.' IS NOT NULL';
+ break;
+ default:
+ $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';
+ break;
}
unset($filter['shared_with']);