);
// 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)
);
$ret = $r;
}
- // TODO!! remove this group from all content ACL's !!
return $ret;
}
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",
+ WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ",
intval($gid),
- intval($_SESSION['uid'])
+ 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($every="contacts",$each="group",$edit = false) {
-function group_side() {
+ $o = '';
if(! local_user())
- return;
+ return '';
+
+ $createtext = t('Create a new group');
+ $linktext= t('Everybody');
+
$o .= <<< EOT
<div id="group-sidebar">
<h3>Groups</h3>
<div id="sidebar-new-group">
-<a href="group/new">Create a new group</a>
+<a href="group/new">$createtext</a>
</div>
<div id="sidebar-group-list">
<ul id="sidebar-group-ul">
- <li class="sidebar-group-li" ><a href="contacts">Everybody</a></li>
+ <li class="sidebar-group-li" ><a href="$every" >$linktext</a></li>
EOT;
- $r = q("SELECT * FROM `group` WHERE `uid` = %d",
+ $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d",
intval($_SESSION['uid'])
);
if(count($r)) {
foreach($r as $rr)
- $o .= " <li class=\"sidebar-group-li\"><a href=\"group/{$rr['id']}\">{$rr['name']}</a></li>\r\n";
+ $o .= ' <li class="sidebar-group-li">' . (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit') . "\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "") . "<a href=\"$each/{$rr['id']}\">{$rr['name']}</a></li>\r\n";
}
$o .= " </ul>\r\n </div>\r\n</div>";
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;
+}