Merge pull request #6732 from MrPetovan/bug/1777-fix-blocked-contact-group

Allow to remove blocked contact from groups
This commit is contained in:
Michael Vogel
2019-02-24 14:30:36 +01:00
committed by GitHub
10 changed files with 406 additions and 372 deletions

View File

@@ -232,6 +232,11 @@ class Contact extends BaseObject
}
DBA::update('user-contact', ['blocked' => $blocked], ['cid' => $cdata['public'], 'uid' => $uid], true);
if ($blocked) {
// Blocked contact can't be in any group
self::removeFromGroups($cid);
}
}
/**
@@ -2220,4 +2225,9 @@ class Contact extends BaseObject
return $redirect;
}
public static function removeFromGroups($contact_id)
{
return DBA::delete('group_member', ['contact-id' => $contact_id]);
}
}

View File

@@ -16,6 +16,26 @@ use Friendica\Database\DBA;
*/
class Group extends BaseObject
{
/**
*
*
* @param int $group_id
* @return bool
* @throws \Exception
*/
public static function exists($group_id, $uid = null)
{
$condition = ['id' => $group_id, 'deleted' => false];
if (isset($uid)) {
$condition = [
'uid' => $uid
];
}
return DBA::exists('group', $condition);
}
/**
* @brief Create a new contact group
*