X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Fgroup.php;h=8866104fca54a58ad49bfded919bb220e6633158;hb=a5e0190f23a9b3ee840e98f9a819d688f6326781;hp=598d09c2ea1ed086c283c650facff8e77d4018da;hpb=7a21a000a2b02e7dd443fd0f3ee09172de825b08;p=friendica.git diff --git a/include/group.php b/include/group.php index 598d09c2ea..8866104fca 100644 --- a/include/group.php +++ b/include/group.php @@ -8,7 +8,7 @@ function group_add($uid,$name) { $r = group_byname($uid,$name); // check for dups if($r !== false) return true; - $r = q("INSERT INTO `group` ( `uid`', `name` ) + $r = q("INSERT INTO `group` ( `uid`, `name` ) VALUES( %d, '%s' ) ", intval($uid), dbesc($name) @@ -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,34 +103,85 @@ 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) { + + $o = ''; if(! local_user()) - return; + return ''; + + $createtext = t('Create a new group'); + $linktext= t('Everybody'); + $o .= <<< EOT
'; + $o .= " \r\n \r\n"; 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; +}