Groups

"; $o .= <<< EOT EOT; return $o; } function expand_groups($a) { if(! (is_array($a) && count($a))) return array(); $groups = implode(',', $a); $groups = dbesc($groups); $r = q("SELECT `contact-id` FROM `group_member` WHERE `gid` IN ( $groups )"); $ret = array(); if(count($r)) foreach($r as $rr) $ret[] = $rr['contact-id']; return $ret; } function member_of($c) { $r = q("SELECT `group`.`name`, `group`.`id` FROM `group` LEFT JOIN `group_member` ON `group_member`.`gid` = `group`.`id` WHERE `group_member`.`contact-id` = %d AND `group`.`deleted` = 0 ORDER BY `group`.`name` ASC ", intval($c) ); return $r; } function groups_containing($uid,$c) { $r = q("SELECT `gid` FROM `group_member` WHERE `uid` = %d AND `group_member`.`contact-id` = %d ", intval($uid), intval($c) ); $ret = array(); if(count($r)) { foreach($r as $rr) $ret[] = $rr['gid']; } return $ret; }