From 312439c694ff1cfd368337eef27819fc2361b579 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 19 Oct 2020 18:34:11 +0200 Subject: [PATCH] WIP addressbook sharing: action to unshare contacts shared by user (only in shared_by_me view) --- addressbook/inc/class.addressbook_ui.inc.php | 42 +++++++++++++++++++- addressbook/lang/egw_de.lang | 2 + addressbook/lang/egw_en.lang | 2 + 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 06966dffb9..f0a4e03016 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -587,7 +587,16 @@ class addressbook_ui extends addressbook_bo 'id' => 'writable', 'caption' => 'Share writable', 'checkbox' => true, - ]] + $share2addressbooks, + ]] + $share2addressbooks + [ + 'unshare' => [ + 'icon' => 'delete', + 'caption' => 'Unshare', + 'group' => $group, + 'enableClass' => 'unshare_contact', + 'hideOnDisabled' => true, + 'hideOnMobile' => true + ] + ], 'prefix' => 'shared_with_', 'group' => $group, 'hideOnMobile' => true @@ -1210,7 +1219,7 @@ class addressbook_ui extends addressbook_bo { //echo "

uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)

\n"; $success = $failed = 0; - if ($use_all || in_array($action,array('remove_from_list','delete_list'))) + if ($use_all || in_array($action,array('remove_from_list','delete_list','unshare'))) { // get the whole selection $query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name); @@ -1467,6 +1476,30 @@ class addressbook_ui extends addressbook_bo } break; case 'shared_with': + // as "unshare" is in "shared_with" submenu/children it uses "shared_with_unshare" + if ($shared_with === 'unshare') + { + $action_msg = lang('unshared'); + if (($Ok = !!($contact = $this->read($id)))) + { + $need_save = false; + foreach($contact['shared'] as $key => $shared) + { + // only unshare contacts shared by current user + if ($shared['shared_by'] == $this->user && + // only unshare from given addressbook, or all + (empty($query['filter']) || $shared['shared_with'] == (int)$query['filter'])) + { + $need_save = true; + unset($contact['shared'][$key]); + } + } + // we might need to ignore acl, as we are allowed to share with just read-rights + // setting user and update-time is explicitly desired for sync(-collection)! + $Ok = !$need_save || $this->save($contact, true); + } + break; + } $action_msg = lang('shared into addressbook %1', Accounts::username($shared_with)); if (($Ok = !!($contact = $this->read($id)))) { @@ -2025,6 +2058,11 @@ class addressbook_ui extends addressbook_bo { $row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']); } + + if ($query['col_filter']['shared_by'] == $this->user) + { + $row['class'] .= 'unshare_contact '; + } } $rows['no_distribution_list'] = (bool)$query['filter2']; diff --git a/addressbook/lang/egw_de.lang b/addressbook/lang/egw_de.lang index f0aba98101..2110815a42 100644 --- a/addressbook/lang/egw_de.lang +++ b/addressbook/lang/egw_de.lang @@ -513,6 +513,8 @@ unable to import into %1, using %2 addressbook de Import nach %1 ist nicht mögl unique id (uid) addressbook de Eindeutige ID (UID) unique id
(to update existing records) addressbook de Eindeutige ID
(um existierende Datensätze zu aktualisieren) unknown type %1, imported as %2 addressbook de Unbekannter Typ %!, als %2 importiert +unshare addressbook de Nicht mehr teilen +unshared addressbook de nicht mehr geteilt update a single entry by passing the fields. addressbook de Aktualisiert einen einzelnen Eintrag durch Übergabe seiner Felder. update fields by edited organisations? admin de Welche Felder sollen beim Bearbeiten von Organisationen aktualisiert werden? updated addressbook de Aktualisiert diff --git a/addressbook/lang/egw_en.lang b/addressbook/lang/egw_en.lang index bfd7aaab57..17c51a91aa 100644 --- a/addressbook/lang/egw_en.lang +++ b/addressbook/lang/egw_en.lang @@ -513,6 +513,8 @@ unable to import into %1, using %2 addressbook en Unable to import into %1, usin unique id (uid) addressbook en Unique ID (UID) unique id
(to update existing records) addressbook en Unique ID
to update existing records unknown type %1, imported as %2 addressbook en Unknown type %1, imported as %2 +unshare addressbook en Unshare +unshared addressbook en unshared update a single entry by passing the fields. addressbook en Update a single entry by passing the fields. update fields by edited organisations? admin en Fields to update of edited organizations updated addressbook en Updated