]> git.mxchange.org Git - friendica.git/blobdiff - include/group.php
wrong function name
[friendica.git] / include / group.php
index 1f48cdd56be83c20dba457d10012c96c8f24c1aa..793e854be046bc7f43db7572b249621e2dc19e8d 100644 (file)
@@ -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;
 }
@@ -121,33 +120,52 @@ function group_get_members($gid) {
 
 
 
-function group_side() {
+function group_side($every="contacts",$each="group") {
+
+       $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\"><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;
+}