integrated patch 403567 (from januar 2001 !!)
authorcentaurix <centaurix@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 19 Jul 2002 22:20:17 +0000 (22:20 +0000)
committercentaurix <centaurix@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 19 Jul 2002 22:20:17 +0000 (22:20 +0000)
it enables sysadmins to specify a function in $imap_server_address.
This function gets the users imapserver. There is an example function map_yp_alias that gets the server from yellowpages (NIS)
thanks to karenb@cc.gatech.edu.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3106 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_general.php

index a672b574e303d2a0391fb6d3554f056191323ad7..11586a1853888a134669a487fa59ffbba099aad1 100755 (executable)
@@ -155,6 +155,8 @@ function sqimap_read_data ($imap_stream, $pre, $handle_errors, &$response, &$mes
 function sqimap_login ($username, $password, $imap_server_address, $imap_port, $hide) {
     global $color, $squirrelmail_language, $HTTP_ACCEPT_LANGUAGE, $onetimepad;
 
 function sqimap_login ($username, $password, $imap_server_address, $imap_port, $hide) {
     global $color, $squirrelmail_language, $HTTP_ACCEPT_LANGUAGE, $onetimepad;
 
+    $imap_server_address = sqimap_get_user_server($imap_server_address, $username);
+
     $imap_stream = fsockopen ( $imap_server_address, $imap_port, $error_number, $error_string, 15);
     if ( !$imap_stream ) {
         return false;
     $imap_stream = fsockopen ( $imap_server_address, $imap_port, $error_number, $error_string, 15);
     if ( !$imap_stream ) {
         return false;
@@ -396,4 +398,24 @@ function sqimap_append_done ($imap_stream) {
     $tmp = fgets ($imap_stream, 1024);
 }
 
     $tmp = fgets ($imap_stream, 1024);
 }
 
+function sqimap_get_user_server ($imap_server, $username) {
+
+   if (substr($imap_server, 0, 4) != "map:") {
+       return $imap_server;
+   }
+
+   $function = substr($imap_server, 4);
+   return $function($username);
+}
+
+/* This is an example that gets imapservers from yellowpages (NIS).
+ * you can simple put map:map_yp_alias in your $imap_server_address 
+ * in config.php use your own function instead map_yp_alias to map your
+ * LDAP whatever way to find the users imapserver. */
+
+function map_yp_alias($username) {
+   $yp = `ypmatch $username aliases`;
+   return chop(substr($yp, strlen($username)+1));
+} 
+
 ?>
 ?>