<?php

// actions/mygroups.php
// written by Adrian Walmsley


function MyGroups($username,$al)
{
 $my_groups_count = 0;
foreach ($al as $group => $members)
{
$groupmembers = explode("\n", $members);
if (in_array ($username, $groupmembers)) {
    print "\n". $group . "<br>";
    $my_groups_count++;
} ;

}
return $my_groups_count;
};


if ($user = $this->GetUser())
{
  
$al = $this->config['aliases'];

print("<fieldset><legend>".$user["name"].", ".$this->GetResourceValue("MyGroups").":</legend>\n");

 
$groups_count = MyGroups($user["name"],$al);

 
   echo "<i>".$groups_count . " group(s)</i><br>\n";
   echo "</fieldset>\n";
}    

else
{
 echo $this->GetResourceValue("NotLoggedInThusNoGroups");
}



?>