Moving help files from pl to pl_PL
[squirrelmail.git] / functions / imap_general.php
index 593187bc0f4603bb9a72d91ec6f584d4c16a2406..9333f177fb8755c6ce067fe08ba85b3d611eebe4 100755 (executable)
@@ -1,14 +1,14 @@
 <?php
 
 /**
- *   imap.php
+ * imap.php
  *
- *   Copyright (c) 1999-2001 The SquirrelMail Development Team
- *   Licensed under the GNU GPL. For full terms see the file COPYING.
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
- *   This implements all functions that do general imap functions.
+ * This implements all functions that do general imap functions.
  *
- *   $Id$
+ * $Id$
  */
 
 require_once('../functions/page_header.php');
@@ -334,32 +334,30 @@ function sqimap_find_email ($string) {
 
 
 /*
-*  Takes the From: field, and creates a displayable name.
-*    Luke Ehresman <lkehresman@yahoo.com>
-*           becomes:   Luke Ehresman
-*    <lkehresman@yahoo.com>
-*           becomes:   lkehresman@yahoo.com
-*/
+ *  Takes the From: field, and creates a displayable name.
+ *    Luke Ehresman   <lkehresman@yahoo.com>
+ *    "Luke Ehresman" <lkehresman@yahoo.com>
+ *    lkehresman@yahoo.com (Luke Ehresman)
+ *           become:   Luke Ehresman
+ *    <lkehresman@yahoo.com>
+ *           becomes:   lkehresman@yahoo.com
+ */
 function sqimap_find_displayable_name ($string) {
-    $string = ' '.trim($string);
-    $orig_string = $string;
-    if (strpos($string, '<') && strpos($string, '>')) {
-        if (strpos($string, '<') == 1) {
-            $string = sqimap_find_email($string);
-        } else {
-            $string = trim($string);
-            $string = substr($string, 0, strpos($string, '<'));
-            $string = ereg_replace ('"', '', $string);
-        }
-        
-        if (trim($string) == '') {
-            $string = sqimap_find_email($orig_string);
-        }
+    $string = trim($string);
+    
+    if ( ereg('^(.+)<.*>', $string, $regs) ) {
+        $string = ereg_replace ('"', '', $regs[1] );
+    }
+    elseif ( ereg('\((.*)\)', $string, $regs) ) {
+        $string = $regs[1];
+    }
+    else {
+        $string = sqimap_find_email($string);
     }
-    return $string;
-}
-
 
+    return trim($string);
+}
+    
 /*
 *  Returns the number of unseen messages in this folder
 */
@@ -385,4 +383,4 @@ function sqimap_append_done ($imap_stream) {
     $tmp = fgets ($imap_stream, 1024);
 }
    
-?>
\ No newline at end of file
+?>