Doc fix
[squirrelmail.git] / functions / imap_general.php
index d1c18d9701c0483ca29bbf6c7cff3fff342aaf0a..2ed19901b0d70c9a1f22e1b704f09ba791d6af9d 100755 (executable)
@@ -748,15 +748,20 @@ function sqimap_create_stream($server,$port,$tls=0) {
 
 /**
  * Logs the user into the IMAP server.  If $hide is set, no error messages
- * will be displayed.  This function returns the IMAP connection handle.
+ * will be displayed (if set to 1, just exits, if set to 2, returns FALSE).  
+ * This function returns the IMAP connection handle.
  * @param string $username user name
  * @param string $password password encrypted with onetimepad. Since 1.5.2
  *  function can use internal password functions, if parameter is set to
  *  boolean false.
  * @param string $imap_server_address address of imap server
  * @param integer $imap_port port of imap server
- * @param boolean $hide controls display connection errors
- * @return stream
+ * @param int $hide controls display connection errors:
+ *                  0 = do not hide
+ *                  1 = show no errors (just exit)
+ *                  2 = show no errors (return FALSE)
+ * @return mixed The IMAP connection stream, or FALSE if $hide is set to 2 
+ *               and the connection fails.
  */
 function sqimap_login ($username, $password, $imap_server_address, $imap_port, $hide) {
     global $color, $squirrelmail_language, $onetimepad, $use_imap_tls,
@@ -936,6 +941,7 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $
                 exit;
             }
         } else {
+            if ($hide == 2) return FALSE;
             exit;
         }
     }
@@ -1118,9 +1124,14 @@ function sqimap_parse_namespace(&$input) {
                 if($c = preg_match_all('/\((?:(.*?)\s*?)\)/', $ns, $regs2)) {
                     $namespace[$ns_strings[$i]] = array();
                     for($j=0; $j<sizeof($regs2[1]); $j++) {
-                        preg_match('/"(.*)"\s+"(.*)"/', $regs2[1][$j], $regs3);
+                        preg_match('/"(.*)"\s+("(.*)"|NIL)/', $regs2[1][$j], $regs3);
                         $namespace[$ns_strings[$i]][$j]['prefix'] = $regs3[1];
-                        $namespace[$ns_strings[$i]][$j]['delimiter'] = $regs3[2];
+                        if($regs3[2] == 'NIL') {
+                            $namespace[$ns_strings[$i]][$j]['delimiter'] = null;
+                        } else {
+                            // $regs[3] is $regs[2] without the quotes
+                            $namespace[$ns_strings[$i]][$j]['delimiter'] = $regs3[3];
+                        }
                         unset($regs3);
                     }
                 }