Merge pull request #8006 from MrPetovan/bug/7991-remove-group-add-restrictions
Remove group add restrictions
This commit is contained in:
commit
d0c2d0e84b
2 changed files with 3 additions and 14 deletions
|
@ -406,11 +406,6 @@ class Contact extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::update('user-contact', ['blocked' => $blocked], ['cid' => $cdata['public'], 'uid' => $uid], true);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,34 +87,28 @@ class Group extends BaseModule
|
||||||
throw new \Exception(L10n::t('Unknown group.'), 404);
|
throw new \Exception(L10n::t('Unknown group.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = DBA::selectFirst('contact', ['pending', 'blocked', 'deleted'], ['id' => $contact_id, 'uid' => local_user()]);
|
$contact = DBA::selectFirst('contact', ['deleted'], ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
throw new \Exception(L10n::t('Contact not found.'), 404);
|
throw new \Exception(L10n::t('Contact not found.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['pending']) {
|
|
||||||
throw new \Exception(L10n::t('Contact is unavailable.'), 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($contact['deleted']) {
|
if ($contact['deleted']) {
|
||||||
throw new \Exception(L10n::t('Contact is deleted.'), 410);
|
throw new \Exception(L10n::t('Contact is deleted.'), 410);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($command) {
|
switch($command) {
|
||||||
case 'add':
|
case 'add':
|
||||||
if ($contact['blocked']) {
|
|
||||||
throw new \Exception(L10n::t('Contact is blocked, unable to add it to a group.'), 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Model\Group::addMember($group_id, $contact_id)) {
|
if (!Model\Group::addMember($group_id, $contact_id)) {
|
||||||
throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500);
|
throw new \Exception(L10n::t('Unable to add the contact to the group.'), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = L10n::t('Contact successfully added to group.');
|
$message = L10n::t('Contact successfully added to group.');
|
||||||
break;
|
break;
|
||||||
case 'remove':
|
case 'remove':
|
||||||
if (!Model\Group::removeMember($group_id, $contact_id)) {
|
if (!Model\Group::removeMember($group_id, $contact_id)) {
|
||||||
throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500);
|
throw new \Exception(L10n::t('Unable to remove the contact from the group.'), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = L10n::t('Contact successfully removed from group.');
|
$message = L10n::t('Contact successfully removed from group.');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue