Fix: Messages forwarded as attachments from message list were not getting flagged...
[squirrelmail.git] / functions / identity.php
index d5692566bb92240fb17f9599aae3a3b992474d2d..f389ce44cfb25a120cbb53192dfc583468a0e36c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * This contains utility functions for dealing with multiple identities
  *
- * @copyright © 1999-2007 The SquirrelMail Project Team
+ * @copyright © 1999-2009 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -135,7 +135,8 @@ function sqfixidentities( $identities, $id, $action ) {
                     $fixed[0] = $ident;
 
                     // inform plugins about renumbering of ids
-                    do_hook('options_identities_renumber', $temp=array(&$id, 'default'));
+                    $temp = array(&$id, 'default');
+                    do_hook('options_identities_renumber', $temp);
 
                     continue 2;
                 } else {
@@ -149,7 +150,8 @@ function sqfixidentities( $identities, $id, $action ) {
                     $tmp_hold = $ident;
 
                     // inform plugins about renumbering of ids
-                    do_hook('options_identities_renumber', $temp=array(&$id , $id - 1));
+                    $temp = array(&$id , $id - 1);
+                    do_hook('options_identities_renumber', $temp);
 
                     continue 2;
                 } else {
@@ -166,7 +168,8 @@ function sqfixidentities( $identities, $id, $action ) {
 
                 if ($key == $id) {
                     // inform plugins about deleted id
-                    do_hook('options_identities_process', $temp=array(&$action, &$id));
+                    $temp = array(&$action, &$id);
+                    do_hook('options_identities_process', $temp);
 
                     continue 2;
                 } else {
@@ -182,7 +185,8 @@ function sqfixidentities( $identities, $id, $action ) {
                  * be used to detect modified hook. Older hook does not
                  * provide information that can be useful for plugins.
                  */
-                do_hook('options_identities_process', $temp=array(&$action, &$id));
+                $temp = array(&$action, &$id);
+                do_hook('options_identities_process', $temp);
 
                 $fixed[$i] = $ident;
 
@@ -221,6 +225,9 @@ function empty_identity($ident) {
  * @since 1.5.2
  */
 function build_from_header($identity = 0) {
+
+    global $domain;
+
     $idents = get_identities();
 
     if (! isset($idents[$identity]) ) $identity = 0;
@@ -230,13 +237,15 @@ function build_from_header($identity = 0) {
     }
 
     $from_mail = $idents[$identity]['email_address'];
+    if (strpos($from_mail, '@') === FALSE)
+        $from_mail .= '@' . $domain;
     
     if ( isset($from_name) ) {
         $from_name_encoded = encodeHeader($from_name);
         if ($from_name_encoded != $from_name) {
-            return $from_name_encoded .' <'.$from_mail.'>';
+            return '"' . $from_name_encoded . '" <' . $from_mail . '>';
         }
-        return '"'.$from_name .'" <'.$from_mail.'>';
+        return '"' . $from_name . '" <' . $from_mail . '>';
     }
     return $from_mail;
 }