If a value is not defined, only return an empty list if this is actually a list value.
[licom.git] / licom.cgi
index 015c34b..70e1e72 100755 (executable)
--- a/licom.cgi
+++ b/licom.cgi
@@ -1,5 +1,21 @@
 #!/usr/bin/perl
 
+# LiCoM - Lightweight contact manager
+# Copyright (c) 2005-2006  Florian octo Forster <octo at verplant.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; only version 2 of the License is applicable.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software # Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
 use strict;
 use warnings;
 use lib (qw(lib));
@@ -123,7 +139,7 @@ sub action_browse
                        my $group_esc  = uri_escape ($group_name);
                        my $desc = $group->description ();
 
-                       print qq#\t\t\t<li><a href="$MySelf?action=browse&group=$group_esc">$group_name</a> ($members Members)#;
+                       print qq#\t\t\t<li><a href="$MySelf?action=browse&group=$group_esc">$group_name</a> ($members Member#, ($members == 1 ? ')' : 's)');
                        print qq(<br />\n\t\t\t\t<span class="description">$desc</span>) if ($desc);
                        print "</li>\n";
                }
@@ -296,6 +312,25 @@ EOF
                        "\t\t\t</tr>\n";
                }
        }
+
+       my @groups = LiCoM::Group->load_by_member ($cn);
+       if (@groups)
+       {
+               my $num = scalar (@groups);
+               print "\t\t\t<tr>\n",
+               "\t\t\t\t<th", ($num == 1 ? '' : qq( rowspan="$num")), ">Group", ($num == 1 ? '' : 's'), "</th>\n";
+               for (my $i = 0; $i < $num; $i++)
+               {
+                       my $group = $groups[$i];
+                       my $group_name = $group->name ();
+                       my $group_esc = uri_escape ($group_name);
+
+                       print "\t\t\t<tr>\n" if ($i != 0);
+                       print qq(\t\t\t\t<td><a href="$MySelf?action=browse&group=$group_esc">$group_name</a></td>\n),
+                       "\t\t\t</tr>\n";
+               }
+       }
+       
        print <<EOF;
                </table>
 
@@ -1152,7 +1187,7 @@ sub html_end
        print <<EOF;
                <div class="foot">
                        &quot;Lightweight Contact Manager&quot;,
-                       written 2005 by <a href="http://verplant.org/">Florian octo Forster</a>
+                       written 2005-2006 by <a href="http://verplant.org/">Florian octo Forster</a>
                        &lt;octo at verplant.org&gt;
                </div>
        </body>