4 function group_add($uid,$name) {
7 if(x($uid) && x($name)) {
8 $r = group_byname($uid,$name); // check for dups
11 $r = q("INSERT INTO `group` ( `uid`', `name` )
22 function group_rmv($uid,$name) {
24 if(x($uid) && x($name)) {
25 $r = q("SELECT * FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
30 $group_id = $r[0]['id'];
35 $r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d ",
41 $r = q("DELETE FROM `group` WHERE `uid` = %d AND `id` = %d LIMIT 1",
49 // TODO!! remove this group from all content ACL's !!
54 function group_byname($uid,$name) {
55 if((! $uid) || (! strlen($name)))
57 $r = q("SELECT * FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
66 function group_rmv_member($uid,$name,$member) {
67 $gid = group_byname($uid,$name);
70 if(! ( $uid && $gid && $member))
72 $r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `contact-id` = %d LIMIT 1 ",
83 function group_add_member($uid,$name,$member) {
84 $gid = group_byname($uid,$name);
85 if((! $gid) || (! $uid) || (! $member))
88 $r = q("SELECT * FROM `group_member` WHERE `uid` = %d AND `id` = %d AND `contact-id` = %d LIMIT 1",
94 return true; // You might question this, but
95 // we indicate success because the group was in fact created
96 // -- It was just created at another time
98 $r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
99 VALUES( %d, %d, %d ) ",