]> git.mxchange.org Git - friendica.git/blobdiff - include/group.php
better (more consistent) handling of ostatus contacts
[friendica.git] / include / group.php
index d1b3369469fef8694a7dc898c00cc06f3f11a483..da4d41748b31c61e8061ba1188babd8380b7efbe 100644 (file)
@@ -136,7 +136,7 @@ function group_public_members($gid) {
 
 
 
-function group_side($every="contacts",$each="group",$edit = false) {
+function group_side($every="contacts",$each="group",$edit = false, $group_id = 0) {
 
        $o = '';
 
@@ -145,7 +145,7 @@ function group_side($every="contacts",$each="group",$edit = false) {
 
        $createtext = t('Create a new group');
        $linktext= t('Everybody');
-
+       $selected = (($group_id == 0) ? ' class="group-selected" ' : '');
 $o .= <<< EOT
 
 <div id="group-sidebar">
@@ -157,7 +157,7 @@ $o .= <<< EOT
 
 <div id="sidebar-group-list">
        <ul id="sidebar-group-ul">
-       <li class="sidebar-group-li" ><a href="$every" >$linktext</a></li>
+       <li class="sidebar-group-li" ><a href="$every" $selected >$linktext</a></li>
 
 EOT;
 
@@ -165,8 +165,10 @@ EOT;
                intval($_SESSION['uid'])
        );
        if(count($r)) {
-               foreach($r as $rr)
-                       $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";
+               foreach($r as $rr) {
+                       $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : '');
+                       $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']}\" $selected >{$rr['name']}</a></li>\r\n";
+               }
        }
        $o .= " </ul>\r\n       </div>\r\n</div>";      
 
@@ -185,3 +187,15 @@ function expand_groups($a) {
                        $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;
+
+}
+