The mutt-script now displays groups as extra info
authorocto <octo>
Fri, 6 May 2005 07:53:52 +0000 (07:53 +0000)
committerocto <octo>
Fri, 6 May 2005 07:53:52 +0000 (07:53 +0000)
Groups can now be choosen when editing a person. Group management to follow.
Stricter error-handling in the lib..

lib/LiCoM/Person.pm
licom.cgi
mutt-licom.pl

index 564d208..d9453ff 100644 (file)
@@ -75,6 +75,8 @@ sub connect
 
        my $msg;
 
 
        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);
        $Ldap = Net::LDAP->new ($uri);
 
        $msg = $Ldap->bind ($bind_dn, password => $passwd);
index 58c88cc..59eddd6 100755 (executable)
--- a/licom.cgi
+++ b/licom.cgi
@@ -482,7 +482,7 @@ EOF
                my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
                my @values = @{$contacts->{$field}};
 
                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, '');
                
 
                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<tr>\n",
+               "\t\t\t\t<th>", $FieldNames{'group'}, "</th>\n",
+               qq(\t\t\t\t<td><select name="group" multiple="multiple">\n);
+               for (sort (keys %a_groups))
+               {
+                       my $group = $_;
+                       my $selec = defined ($c_groups{$group}) ? ' selected="selected"' : '';
+
+                       print qq(\t\t\t\t\t<option value="$group"$selec>$group</option>\n);
+               }
+               print "\t\t\t\t</select></td>\n",
+               "\t\t\t</tr>\n";
+       }
+
        print <<EOF;
                        <tr>
                                <th colspan="2" class="menu">
        print <<EOF;
                        <tr>
                                <th colspan="2" class="menu">
index 08c2502..e7fbcbd 100755 (executable)
@@ -24,6 +24,12 @@ else
        $Config = get_config ();
 }
 
        $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'}))
 {
 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";
 
 
 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 $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";
        }
 }
 
        }
 }