X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fgroup.php;h=da4d41748b31c61e8061ba1188babd8380b7efbe;hb=d28d2ff440efba47ad65cf28eab4be96e0ea05b2;hp=585b2eab931561b1025557aebfd45501edee5295;hpb=83dc89d8594e5de56f7bdc173048e93a5c73d488;p=friendica.git diff --git a/include/group.php b/include/group.php index 585b2eab93..da4d41748b 100644 --- a/include/group.php +++ b/include/group.php @@ -2,7 +2,7 @@ function group_add($uid,$name) { -dbg(2); + $ret = false; if(x($uid) && x($name)) { $r = group_byname($uid,$name); // check for dups @@ -38,7 +38,7 @@ function group_rmv($uid,$name) { ); // remove group - $r = q("DELETE FROM `group` WHERE `uid` = %d AND `id` = %d LIMIT 1", + $r = q("UPDATE `group` SET `deleted` = 1 WHERE `uid` = %d AND `name` = '%s' LIMIT 1", intval($uid), dbesc($name) ); @@ -46,7 +46,6 @@ function group_rmv($uid,$name) { $ret = $r; } - // TODO!! remove this group from all content ACL's !! return $ret; } @@ -104,35 +103,99 @@ function group_add_member($uid,$name,$member) { return $r; } +function group_get_members($gid) { + $ret = array(); + if(intval($gid)) { + $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` + LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ", + intval($gid), + intval(local_user()) + ); + if(count($r)) + $ret = $r; + } + return $ret; +} + +function group_public_members($gid) { + $ret = 0; + if(intval($gid)) { + $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` + LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d + AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' AND `contact`.`network` != 'face' ", + intval($gid), + intval(local_user()) + ); + if(count($r)) + $ret = count($r); + } + return $ret; +} + -function group_side() { +function group_side($every="contacts",$each="group",$edit = false, $group_id = 0) { + + $o = ''; if(! local_user()) - return; + return ''; + + $createtext = t('Create a new group'); + $linktext= t('Everybody'); + $selected = (($group_id == 0) ? ' class="group-selected" ' : ''); $o .= <<< EOT
"; return $o; -} \ No newline at end of file +} + +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; + +} +