forked from extern/egroupware
enable unshare action also when shared-with column is shown and fix some bugs arround unsharing and resharing
This commit is contained in:
parent
99305cb536
commit
42d000145f
@ -356,7 +356,7 @@ class addressbook_ui extends addressbook_bo
|
||||
/**
|
||||
* Get actions / context menu items
|
||||
*
|
||||
* @param string $tid_filter =null
|
||||
* @param ?string $tid_filter =null
|
||||
* @return array see Etemplate\Widget\Nextmatch::get_actions()
|
||||
*/
|
||||
public function get_actions($tid_filter=null)
|
||||
@ -1495,7 +1495,8 @@ class addressbook_ui extends addressbook_bo
|
||||
foreach($contact['shared'] as $key => $shared)
|
||||
{
|
||||
// only unshare contacts shared by current user
|
||||
if ($shared['shared_by'] == $this->user &&
|
||||
if (($shared['shared_by'] == $this->user ||
|
||||
$this->check_perms(ACL::EDIT, $contact)) &&
|
||||
// only unshare from given addressbook, or all
|
||||
(empty($query['filter']) || $shared['shared_with'] == (int)$query['filter']))
|
||||
{
|
||||
@ -1967,6 +1968,11 @@ class addressbook_ui extends addressbook_bo
|
||||
}
|
||||
$order = $query['order'];
|
||||
|
||||
$unshare_grants = [];
|
||||
foreach($this->grants as $grantee => $rights)
|
||||
{
|
||||
if ($rights & (ACL::EDIT|self::ACL_SHARED)) $unshare_grants[] = $grantee;
|
||||
}
|
||||
$readonlys = array();
|
||||
foreach($rows as $n => &$row)
|
||||
{
|
||||
@ -2076,7 +2082,8 @@ 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)
|
||||
if ($query['col_filter']['shared_by'] == $this->user || !empty($row['shared_with']) &&
|
||||
array_intersect($unshare_grants, explode(',', $row['shared_with'])))
|
||||
{
|
||||
$row['class'] .= 'unshare_contact ';
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ class Sql extends Api\Storage
|
||||
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';
|
||||
' WHERE '.self::SHARED_TABLE.'.contact_id='.$this->table_name.'.contact_id AND shared_deleted IS NULL) AS shared_with';
|
||||
}
|
||||
if (!empty($filter['shared_with']))
|
||||
{
|
||||
@ -1114,8 +1114,9 @@ class Sql extends Api\Storage
|
||||
}
|
||||
}
|
||||
$this->db->insert(self::SHARED_TABLE, $data,
|
||||
array_intersect_key($data, array_flip(['shared_by','shared_with','contact_id','share_id'])), __LINE__, __FILE__);
|
||||
$data['shared_id'] = $this->db->get_last_insert_id(self::SHARED_TABLE, 'share_id');
|
||||
$where = array_intersect_key($data, array_flip(['shared_by','shared_with','contact_id','share_id'])), __LINE__, __FILE__);
|
||||
// if we resurect a previous deleted share, we dont get the shared_id back, need to query it
|
||||
$data['shared_id'] = $this->db->select(self::SHARED_TABLE, 'shared_id', $where, __LINE__, __FILE__)->fetchColumn();
|
||||
}
|
||||
$ids[] = (int)$data['shared_id'];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user