From 2f7d9ec3631d96fd673c2f6cee3dda7acfaa86ee Mon Sep 17 00:00:00 2001 From: octo Date: Fri, 6 May 2005 07:53:52 +0000 Subject: [PATCH] The mutt-script now displays groups as extra info Groups can now be choosen when editing a person. Group management to follow. Stricter error-handling in the lib.. --- lib/LiCoM/Person.pm | 2 ++ licom.cgi | 27 ++++++++++++++++++++++++++- mutt-licom.pl | 16 +++++++++++++--- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/lib/LiCoM/Person.pm b/lib/LiCoM/Person.pm index 564d208..d9453ff 100644 --- a/lib/LiCoM/Person.pm +++ b/lib/LiCoM/Person.pm @@ -75,6 +75,8 @@ sub connect my $msg; + die unless ($bind_dn and $base_dn and $uri and defined ($passwd)); + $Ldap = Net::LDAP->new ($uri); $msg = $Ldap->bind ($bind_dn, password => $passwd); diff --git a/licom.cgi b/licom.cgi index 58c88cc..59eddd6 100755 --- a/licom.cgi +++ b/licom.cgi @@ -482,7 +482,7 @@ EOF my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field; my @values = @{$contacts->{$field}}; - next if (!$UserID and $field eq 'group'); + next if ($field eq 'group'); push (@values, ''); @@ -499,6 +499,31 @@ EOF } } + if ($UserID) + { + my %c_groups = map { $_ => 1 } (@{$contacts->{'group'}}); + my %a_groups = (); + my @a_persons = LiCoM::Person->search (); + + for (@a_persons) + { + $a_groups{$_} = 1 for ($_->get ('group')); + } + + print "\t\t\t\n", + "\t\t\t\t", $FieldNames{'group'}, "\n", + qq(\t\t\t\t\n", + "\t\t\t\n"; + } + print < diff --git a/mutt-licom.pl b/mutt-licom.pl index 08c2502..e7fbcbd 100755 --- a/mutt-licom.pl +++ b/mutt-licom.pl @@ -24,6 +24,12 @@ else $Config = get_config (); } +if ($ENV{'DEBUG'}) +{ + require Data::Dumper; + print STDERR Data::Dumper->Dump ([$Config], ['Config']); +} + unless (defined ($Config->{'uri'}) and defined ($Config->{'bind_dn'}) and defined ($Config->{'password'})) { @@ -61,15 +67,19 @@ our @Matches = LiCoM::Person->search (@Patterns, [[mail => '*']]); print STDOUT scalar (@Matches), ' ', (scalar (@Matches) == 1 ? 'entry' : 'entries'), " found.\n"; -for (@Matches) +for (sort { $a->name () cmp $b->name () } (@Matches)) { my $person = $_; my $cn = $person->name (); my @mail = $person->get ('mail'); + my @groups = $person->get ('group'); + my $info = join (', ', sort (@groups)); + + $info = "($info)" if ($info); - for (@mail) + for (sort (@mail)) { - print "$_\t$cn\tFound by LiCoM\n"; + print "$_\t$cn\t$info\n"; } } -- 2.11.0