From: Florian Forster Date: Sun, 11 Jun 2006 20:18:23 +0000 (+0200) Subject: Fix the group-list action. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8c9104d144ad4aa72e0d97be057189bbcd7ac832;p=licom.git Fix the group-list action. It was broken: It used LiCoM::search to search for group-members, which is a dumb idea.. --- diff --git a/licom.cgi b/licom.cgi index 68e3581..78270c8 100755 --- a/licom.cgi +++ b/licom.cgi @@ -193,21 +193,46 @@ EOF sub action_list { - my $group = param ('group'); - $group = shift if (@_); - $group ||= ''; + my $group_name = param ('group'); + $group_name = shift if (@_); + $group_name ||= ''; - my $title = $group ? "List of group "$group"" : 'List of all addresses'; + my $group_name_html = encode_entities ($group_name || ''); + + my $title = $group_name + ? "List of group "$group_name_html"" + : 'List of all addresses'; my @fields = (qw(address homephone cellphone officephone fax mail)); my @all = (); - if ($group) + if ($group_name) { - @all = LiCoM::Person->search ([[group => $group]]); + my $group_obj = LiCoM::Group->load ($group_name); + if (!$group_obj) + { + print < + Unable to load group "$group_name_html". + +HTML + return; + } + for ($group_obj->get_members ()) + { + my $cn = $_; + my $person_obj = LiCoM::Person->load ($cn); + + if (!$person_obj) + { + print STDERR "Unable to load cn = $cn;\n"; + next; + } + push (@all, $person_obj); + } } else { - @all = LiCoM::Person->search (); + @all = LiCoM::Person->search ([[group => $group_name]]); } print <name () cmp $b->name () } (@all)) { my $person = $_; + my $cn = $person->name (); my $sn = $person->lastname (); my $gn = $person->firstname (); + my $cn_uri = uri_escape ($cn); + my $cn_html = encode_entities ("$sn, $gn"); + print "\t\t\t\n", - "\t\t\t\t$sn, $gn\n"; + qq(\t\t\t\t$cn_html\n); for (@fields) { @@ -243,9 +272,9 @@ EOF } print "\t\t\n\n"; - if ($group) + if ($group_name) { - my $group_esc = uri_escape ($group); + my $group_esc = uri_escape ($group_name); print qq(\t\t\n); } else