[Kolab-devel] server/kolab/kolab/admin/user vacation.php,1.5.2.4,1.5.2.5 by tassilo at doto.intevation.de

root at intevation.de root at intevation.de
Mon Jun 23 23:23:47 CEST 2003


Update of /kolabrepository/server/kolab/kolab/admin/user
In directory doto:/tmp/cvs-serv1624/kolab/admin/user

Modified Files:
      Tag: KOLAB_1_0
	vacation.php 
Log Message:
Martin K.: Fix for the missing alias support with vacations


Index: vacation.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/user/vacation.php,v
retrieving revision 1.5.2.4
retrieving revision 1.5.2.5
diff -u -d -r1.5.2.4 -r1.5.2.5
--- vacation.php	12 Jun 2003 16:59:40 -0000	1.5.2.4
+++ vacation.php	23 Jun 2003 21:23:45 -0000	1.5.2.5
@@ -33,9 +33,33 @@
 if (!$errors && $group != "user" ) 
    array_push($errors, "Error: You don't have Permissions to access this Menue");
 
-// DEBUG:
-//print "HTTP_GET_VARS: ";
-//print_r($HTTP_GET_VARS);
+// get user's email addresses
+if (isset($_SESSION['ldap_server'])) $ldap_server = $_SESSION['ldap_server'];
+   else $ldap_server = '127.0.0.1';
+
+if (isset($_SESSION['ldap_port'])) $ldap_port = $_SESSION['ldap_port'];
+   else $ldap_port = 389;
+
+if (isset($_SESSION['base_dn'])) $base_dn = $_SESSION['base_dn'];
+   else $base_dn = 'k=kolab' ;
+
+if (!$errors && !($link = ldap_connect($ldap_server,$ldap_port)) || !ldap_bind($link,$bind_dn,$_SERVER["PHP_AUTH_PW"]))
+   array_push($errors, "Communication Error: could not query ldap://$ldap_server:$ldap_port ".ldap_error($link));
+
+// get list of email aliases for user
+$filter = "(uid=".$uid.")";
+$address_list = "\"$uid\", ";
+if (($result = ldap_search($link, $base_dn, $filter)) &&
+    ($entry = ldap_first_entry($link,$result)) &&
+    ($ldap_object = ldap_get_attributes($link,$entry))) {
+    for ($count = 0 ; $count < $ldap_object['alias']['count']; $count++) {
+       $address_list .= "\"".$ldap_object['alias'][$count]."\", ";
+    }
+    $address_list = rtrim($address_list); // get rid of whitespace
+    $address_list = rtrim($address_list,','); // get rid of extra comma
+    ldap_free_result($result);
+}
+ldap_close($link);
 
 // read selector for register display
 if (isset($HTTP_GET_VARS['action'])) $action = $HTTP_GET_VARS['action'];
@@ -87,46 +111,29 @@
    
    switch ($action) {
        case "create":
-//          print("\naction: $action.\n\n");
           if ($sieveactive == TRUE) {
              delete_script ($scriptname);
-//	     print "<tr><td><center>Deleted vacation or forward directive on server</center></td></tr>";
           }
-	  
           $newscript = "require \"vacation\";";
-//          $newscript .= "\n# keep next two lines:
-//                         \n# return date: ".$day."-".$month."-".$year."
-//                         \n# notification interval: ".$vacnotify;
 	  $newscript .= "\nvacation :days ".$vacnotify;
-//          $newscript .= ":mime \"MIME-Version: 1.0\nContent-type: text/plain; charset=utf-8\n";
-//          $newscript .= ":mime :text\n";
-//          $newscript .= "Content-Type: text/plain; charset=utf-8\n";
-//          $newscript .= "Content-Transfer-Encoding: 8bit\n";
-        
-//Content-Type: text/plain; charset=utf-8
-//Content-Transfer-Encoding: 8bit
-// :mime :text
-//	  $mesg = "\n\"Abwesenheitsnotiz bis zum ".$day.". ".$month." ".$year.".\n";
-//          $newscript .= " :mime\n\"Content-type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit";
-//	  $newscript .= $vacmsg."\";\n";
+	  $newscript .= "\n\t :addresses     [" .$address_list;
+	  $newscript .= "]\n";
+	  
           $vacmsg=str_replace("\'", "\\\'", $vacmsg);
           $vacmsg=str_replace("\\", "\\\\", $vacmsg);
           $vacmsg=str_replace("\"", "\\\"", $vacmsg);
-
-          $vacmsg_utf8=$vacmsg;
-
-          $vacmsg=str_replace('\"','"',$vacmsg);
+         
+	  $vacmsg_utf8=$vacmsg;
+         
+	  $vacmsg=str_replace('\"','"',$vacmsg);
           $vacmsg=str_replace("\'","´",$vacmsg);
           $vacmsg=stripslashes($vacmsg);
-
           $vacmsg_utf8=str_replace('\"',"''",$vacmsg_utf8);
           $vacmsg_utf8=str_replace("\'","'",$vacmsg_utf8);
-
-
           $vacmsg_utf8=utf8_encode($vacmsg_utf8);
+
           $newscript .= " \"".$vacmsg_utf8."\";\n";
-// works	  $newscript .= " \"".$vacmsg."\";\n";
-//          print $day."-".$month."-".$year." - vacnotify:".$vacnotify."\n";
+	  
           upload_script ($newscript,$scriptname);
 	  
     if (!($sieve->sieve_setactivescript($scriptname)))





More information about the devel mailing list