4 use Friendica\Database\DBA;
5 use Friendica\Model\Contact;
6 use Friendica\Model\Group;
8 function contactgroup_content(App $a)
15 if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
16 $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
20 if (DBA::isResult($r)) {
21 $change = intval($a->argv[2]);
25 if (($a->argc > 1) && (intval($a->argv[1]))) {
26 $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
30 if (!DBA::isResult($r)) {
35 $members = Contact::getByGroupId($group['id']);
37 if (count($members)) {
38 foreach ($members as $member) {
39 $preselected[] = $member['id'];
43 if (!empty($change)) {
44 if (in_array($change, $preselected)) {
45 Group::removeMember($group['id'], $change);
47 Group::addMember($group['id'], $change);