+ print qq(\t\t<div class="menu">\n);
+ if ($group)
+ {
+ my $group_esc = uri_escape ($group);
+ print qq(\t\t\t[<a href="$MySelf?action=list&group=$group_esc">List</a>]\n),
+ qq(\t\t\t[<a href="$MySelf?action=browse">Back</a>]\n);
+ }
+ else
+ {
+ print qq(\t\t\t[<a href="$MySelf?action=list">List</a>]\n);
+ }
+ print qq(\t\t</div>\n);
+}
+
+sub action_list
+{
+ my $group = param ('group');
+ $group = shift if (@_);
+ $group ||= '';
+
+ my $title = $group ? "List of group "$group"" : 'List of all addresses';
+ my @fields = (qw(address homephone cellphone officephone fax mail));
+
+ my @all = ();
+ if ($group)
+ {
+ @all = Person->search ([[group => $group]]);
+ }
+ else
+ {
+ @all = Person->search ();
+ }
+
+ print <<EOF;
+ <h2>$title</h2>
+
+ <table class="list">
+ <tr>
+ <th>Name</th>
+EOF
+ for (@fields)
+ {
+ print "\t\t\t\t<th>" . (defined ($FieldNames{$_}) ? $FieldNames{$_} : $_) . "</th>\n";
+ }
+ print "\t\t\t</tr>\n";
+
+ for (sort { $a->name () cmp $b->name () } (@all))
+ {
+ my $person = $_;
+ my $sn = $person->lastname ();
+ my $gn = $person->firstname ();
+
+ print "\t\t\t<tr>\n",
+ "\t\t\t\t<td>$sn, $gn</td>\n";
+
+ for (@fields)
+ {
+ my $field = $_;
+ my @values = $person->get ($field);
+ print "\t\t\t\t<td>" . join ('<br />', @values) . "</td>\n";
+ }
+
+ print "\t\t\t</tr>\n";
+ }
+ print "\t\t</table>\n\n";
+
+ if ($group)
+ {
+ my $group_esc = uri_escape ($group);
+ print qq(\t\t<div class="menu">[<a href="$MySelf?action=browse&group=$group_esc">Back</a>]</div>\n);
+ }
+ else
+ {
+ print qq(\t\t<div class="menu">[<a href="$MySelf?action=browse">Back</a>]</div>\n);
+ }