4 use Friendica\Database\DBM;
5 use Friendica\Model\Contact;
6 use Friendica\Model\Group;
8 function contactgroup_content(App $a)
14 if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
15 $r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
19 if (DBM::is_result($r)) {
20 $change = intval($a->argv[2]);
24 if (($a->argc > 1) && (intval($a->argv[1]))) {
25 $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
29 if (!DBM::is_result($r)) {
34 $members = Contact::getByGroupId($group['id']);
35 $preselected = array();
36 if (count($members)) {
37 foreach ($members as $member) {
38 $preselected[] = $member['id'];
43 if (in_array($change, $preselected)) {
44 Group::removeMember($group['id'], $change);
46 Group::addMember($group['id'], $change);