The mutt-script now displays groups as extra info
[licom.git] / licom.cgi
index 8a52ef4..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}};
 
-               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<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">
@@ -698,12 +723,12 @@ sub action_verify
        $mail ||= '';
 
        my $message;
-       my $password = $person->password ();
+       my $password = $person->get ('password');
 
        if (!$password)
        {
                $password = pwgen ();
-               $person->password ($password);
+               $person->set ('password', $password);
        }
 
        $message = qq(The password for the record &quot;$cn&quot; is &quot;$password&quot;.);
@@ -749,10 +774,10 @@ sub action_verify_send_mail
        my $person_name = $person->name ();
        my ($person_mail) = $person->get ('mail');
        my $person_gn = $person->firstname ();
-       my $password = $person->password ();
+       my $password = $person->get ('password');
 
        my $host = $ENV{'HTTP_HOST'};
-       my $url = 'http://' . $host . $MySelf;
+       my $url = (defined ($ENV{'HTTPS'}) ? 'https://' : 'http://') . $host . $MySelf;
        
        open ($smh, "| /usr/sbin/sendmail -t -f $owner_mail") or die ("open pipe to sendmail: $!");
        print $smh <<EOM;
@@ -778,12 +803,17 @@ EOM
        print $smh <<EOM;
 
 If this entry is outdated or incomplete, please take a minute and correct it.
-  Address:  $url
+  Address: $url
  Username: $person_name
  Password: $password
 
-Thank you very much :) Regards,
+Thank you very much :)
+
+Regards,
 $UserCN
+--
+This message was automatically generated by LiCoM,
+http://verplant.org/licom/
 EOM
        close ($smh);
 
@@ -1049,6 +1079,7 @@ Content-Type: text/html; charset=UTF-8
 
        <body>
 EOF
+
        if ($UserID)
        {
                my $search = param ('search') || '';