Update wrt update.cgi
[mirror/userdir-ldap-cgi.git] / search.cgi
index 3afb03a..3151399 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/perl
 
-# $Id: search.cgi,v 1.4 2000/01/11 04:52:53 tausq Exp $
+# $Id: search.cgi,v 1.12 2004/12/04 18:48:07 joey Exp $
 # (c) 1999 Randolph Chung. Licensed under the GPL. <tausq@debian.org>
+# (c) 2004 Martin Schulze. Licensed under the GPL. <joey@debian.org>
 
 use lib '.';
 use strict vars;
@@ -71,8 +72,8 @@ if (!$dosearch) {
     }
   }
   
-  # Vacation is a special case
-  $filter .= "(onvacation=*)" if ($query->param('vacation'));
+  # Vacation is a special case, support it only when user is authenticated
+  $filter .= "(onvacation=*)" if ($query->param('vacation') && $authtoken && $id);
 
   # AND all the search terms together
   $filter = "(&$filter)";
@@ -116,13 +117,14 @@ if (!$dosearch) {
     $data = $entries->{$dn};
 
     # These are local variables.. i have enough global vars as it is... <sigh>
-    my ($ufdn, $login, $name, $email, $fingerprint, $address, $latlong, $vacation, $created, $modified, $lastseen) = undef;
+    my ($ufdn, $login, $name, $icquin, $jabberjid, $email, $fingerprint,
+       $address, $latlong, $vacation, $created, $modified, $lastseen) = undef;
     
     $ufdn = $dn; # Net::LDAP does not have a dn2ufn function, but this is close enough :)
     
     # Assemble name, attach web page link if present.
     $name = $data->{cn}->[0]." ".$data->{mn}->[0]." ".$data->{sn}->[0];
-    if (my $url = $data->{labeledurl}->[0]) {
+    if (my $url = $data->{labeleduri}->[0]) {
       $name = "<a href=\"$url\">$name</a>";
     }
     
@@ -132,6 +134,11 @@ if (!$dosearch) {
       $email .= "<a href=\"mailto:$_\">$_</a>";
     }
 
+    # ICQ 
+    if ($data->{icquin}->[0]) {
+      $icquin = sprintf("<a href=\"http://wwp.icq.com/%s\">%s</a>", $data->{icquin}->[0], $data->{icquin}->[0]);
+    }
+    
     # Format PGP/GPG key fingerprints
     my $fi;
     foreach (@{$data->{keyfingerprint}}) {
@@ -154,15 +161,15 @@ if (!$dosearch) {
     $created =  &Util::FormatTimestamp($data->{createtimestamp}->[0]);
 
     # Last seen information (Echelon)
-    $lastseen = &Util::FormatLastSeen($data->{"activity-pgp"}->[0] || 
+    $lastseen = &Util::FormatLastSeen($data->{"activity-pgp"}->[0],
                                       $data->{"activity-from"}->[0]);
 
     # Link in the debian login id 
     $login = $data->{uid}->[0]."\@debian.org";
     $login = "<a href=\"mailto:$login\">$login</a>";
     
-    # See if the user has a vacation message
-    $vacation = $data->{onvacation}->[0];
+    # See if the user has a vacation message, non-public
+    $vacation = $data->{onvacation}->[0] if ($authtoken && $id);
 
     # OK, now generate output... (i.e. put the output into the buffer )
     $outsub{searchresults} .= '<table border=2 cellpadding=2 cellspacing=0 bgcolor="#DDDDDD" width="80%">';
@@ -175,8 +182,12 @@ if (!$dosearch) {
 
     $outsub{searchresults} .= FormatEntry($dataspecref->{uid}, $login);
     $outsub{searchresults} .= FormatEntry($dataspecref->{ircnick}, $data->{ircnick}->[0]);
+    $outsub{searchresults} .= FormatEntry($dataspecref->{jabberjid}, $data->{jabberjid}->[0]);
     $outsub{searchresults} .= FormatEntry($dataspecref->{loginshell}, $data->{loginshell}->[0]);
     $outsub{searchresults} .= FormatEntry($dataspecref->{fingerprint}, $fingerprint);
+    if ($icquin) {
+      $outsub{searchresults} .= FormatEntry($dataspecref->{icquin}, $icquin);
+    }
     
     if ($auth) {
       # Some data should only be available to authorized users...