WIP addressbook sharing: action to unshare contacts shared by user (only in shared_by_me view)

This commit is contained in:
Ralf Becker 2020-10-19 18:34:11 +02:00
parent 496c168db4
commit 9c8f76d150
3 changed files with 44 additions and 2 deletions

View File

@ -587,7 +587,16 @@ class addressbook_ui extends addressbook_bo
'id' => 'writable', 'id' => 'writable',
'caption' => 'Share writable', 'caption' => 'Share writable',
'checkbox' => true, 'checkbox' => true,
]] + $share2addressbooks, ]] + $share2addressbooks + [
'unshare' => [
'icon' => 'delete',
'caption' => 'Unshare',
'group' => $group,
'enableClass' => 'unshare_contact',
'hideOnDisabled' => true,
'hideOnMobile' => true
]
],
'prefix' => 'shared_with_', 'prefix' => 'shared_with_',
'group' => $group, 'group' => $group,
'hideOnMobile' => true 'hideOnMobile' => true
@ -1210,7 +1219,7 @@ class addressbook_ui extends addressbook_bo
{ {
//echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n"; //echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n";
$success = $failed = 0; $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 // get the whole selection
$query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name); $query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name);
@ -1467,6 +1476,30 @@ class addressbook_ui extends addressbook_bo
} }
break; break;
case 'shared_with': 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)); $action_msg = lang('shared into addressbook %1', Accounts::username($shared_with));
if (($Ok = !!($contact = $this->read($id)))) 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']); $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']; $rows['no_distribution_list'] = (bool)$query['filter2'];

View File

@ -512,6 +512,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 (uid) addressbook de Eindeutige ID (UID)
unique id<br />(to update existing records) addressbook de Eindeutige ID<br />(um existierende Datensätze zu aktualisieren) unique id<br />(to update existing records) addressbook de Eindeutige ID<br />(um existierende Datensätze zu aktualisieren)
unknown type %1, imported as %2 addressbook de Unbekannter Typ %!, als %2 importiert 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 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? update fields by edited organisations? admin de Welche Felder sollen beim Bearbeiten von Organisationen aktualisiert werden?
updated addressbook de Aktualisiert updated addressbook de Aktualisiert

View File

@ -512,6 +512,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 (uid) addressbook en Unique ID (UID)
unique id<br />(to update existing records) addressbook en Unique ID<br />to update existing records unique id<br />(to update existing records) addressbook en Unique ID<br />to update existing records
unknown type %1, imported as %2 addressbook en Unknown type %1, imported as %2 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 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 update fields by edited organisations? admin en Fields to update of edited organizations
updated addressbook en Updated updated addressbook en Updated