phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] felamimail inc/class.bocompose.inc.php inc/clas...


From: Sigurd Nes
Subject: [Phpgroupware-cvs] felamimail inc/class.bocompose.inc.php inc/clas...
Date: Fri, 23 Feb 2007 14:45:08 +0000

CVSROOT:        /sources/phpgroupware
Module name:    felamimail
Changes by:     Sigurd Nes <sigurdne>   07/02/23 14:45:08

Modified files:
        inc            : class.bocompose.inc.php 
                         class.bofelamimail.inc.php 
                         class.uidisplay.inc.php 
        templates/base : config.tpl 

Log message:
        more fixes

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/felamimail/inc/class.bocompose.inc.php?cvsroot=phpgroupware&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/felamimail/inc/class.bofelamimail.inc.php?cvsroot=phpgroupware&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/felamimail/inc/class.uidisplay.inc.php?cvsroot=phpgroupware&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/felamimail/templates/base/config.tpl?cvsroot=phpgroupware&r1=1.4&r2=1.5

Patches:
Index: inc/class.bocompose.inc.php
===================================================================
RCS file: /sources/phpgroupware/felamimail/inc/class.bocompose.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- inc/class.bocompose.inc.php 23 Feb 2007 08:51:51 -0000      1.11
+++ inc/class.bocompose.inc.php 23 Feb 2007 14:45:08 -0000      1.12
@@ -11,7 +11,7 @@
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
-       /* $Id: class.bocompose.inc.php,v 1.11 2007/02/23 08:51:51 sigurdne Exp 
$ */
+       /* $Id: class.bocompose.inc.php,v 1.12 2007/02/23 14:45:08 sigurdne Exp 
$ */
 
        class bocompose
        {
@@ -148,7 +148,7 @@
                        
                        $this->sessionData['body']       = "                  
-----------".lang('Forwarded Message')."-----------\n\n";
                        $this->sessionData['body']      .= lang('subject').": 
".$bofelamimail->decode_header($headers->Subject)."\n";
-                       $this->sessionData['body']      .= lang('to').": 
".$bofelamimail->decode_header($headers->toaddress)."\n";
+                       $this->sessionData['body']      .= lang('to').": 
".$bofelamimail->decode_header(isset($headers->toaddress)?$headers->toaddress:'')."\n";
                        $this->sessionData['body']      .= lang('from').": 
".$bofelamimail->decode_header($headers->fromaddress)."\n\n";
                
                        // iterate through message parts

Index: inc/class.bofelamimail.inc.php
===================================================================
RCS file: /sources/phpgroupware/felamimail/inc/class.bofelamimail.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- inc/class.bofelamimail.inc.php      22 Feb 2007 15:43:04 -0000      1.20
+++ inc/class.bofelamimail.inc.php      23 Feb 2007 14:45:08 -0000      1.21
@@ -11,7 +11,7 @@
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
-       /* $Id: class.bofelamimail.inc.php,v 1.20 2007/02/22 15:43:04 sigurdne 
Exp $ */
+       /* $Id: class.bofelamimail.inc.php,v 1.21 2007/02/23 14:45:08 sigurdne 
Exp $ */
 
        class bofelamimail
        {
@@ -705,7 +705,6 @@
 
                        $structure = imap_fetchstructure($this->mbox, $_uid, 
FT_UID);
                        $sections = $this->parseMessage($structure);
-
                        if(is_array($sections['body']) && 
!isset($sections['body']['0']))
                        {
                                reset($sections['body']);
@@ -735,7 +734,7 @@
                                                                                
$newPart = utf8_encode(imap_qprint($newPart));
                                                                                
break;
                                                                        default:
-                                                       $newPart = 
imap_qprint($newPart);
+                                                                               
$newPart = utf8_encode(imap_qprint($newPart));
                                                        break;
                                                                }
                                                                break;
@@ -772,8 +771,13 @@
                                                // not sure if this needs 
decoding at all
                                                break;
                                        default:
-                                               $newPart = 
stripslashes(trim(imap_body($this->mbox, $_uid, FT_UID)));
+                                       //      $newPart = 
stripslashes(trim(imap_body($this->mbox, $_uid, FT_UID)));
                                                $newPart = 
imap_body($this->mbox, $_uid, FT_UID);
+                                       //      
_debug_array($structure->parameters[0]->value);
+                                               
if(strtolower($structure->parameters[0]->value != 'utf-8'))
+                                               {
+                                                       $newPart = 
utf8_encode($newPart);
+                                               }
                                                // it is either not encoded or 
we don't know about it
                                }
                                if(strtolower($structure->subtype) == 'html')

Index: inc/class.uidisplay.inc.php
===================================================================
RCS file: /sources/phpgroupware/felamimail/inc/class.uidisplay.inc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- inc/class.uidisplay.inc.php 9 Feb 2007 12:37:54 -0000       1.12
+++ inc/class.uidisplay.inc.php 23 Feb 2007 14:45:08 -0000      1.13
@@ -11,7 +11,7 @@
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/
-       /* $Id: class.uidisplay.inc.php,v 1.12 2007/02/09 12:37:54 sigurdne Exp 
$ */
+       /* $Id: class.uidisplay.inc.php,v 1.13 2007/02/23 14:45:08 sigurdne Exp 
$ */
 
        class uidisplay
        {
@@ -64,6 +64,7 @@
                {
                        $transformdate  = 
CreateObject('felamimail.transformdate');
                        $htmlFilter     = CreateObject('felamimail.htmlfilter');
+                       $webserverURL   = 
$GLOBALS['phpgw_info']['server']['webserver_url'];
 
                        $headers        = 
$this->bofelamimail->getMessageHeader($this->uid);
                        $rawheaders     = 
$this->bofelamimail->getMessageRawHeader($this->uid);
@@ -74,7 +75,7 @@
                        $filter         = 
(isset($filterList[$activeFilter])?$filterList[$activeFilter]:'');
                        $nextMessage    = 
$this->bocaching->getNextMessage($this->uid, $this->sort, $filter);
 
-                       #print "<pre>";print_r($rawheaders);print"</pre>";exit;
+                       //print "<pre>";print_r($rawheaders);print"</pre>";exit;
 
                        // add line breaks to $rawheaders
                        $newRawHeaders = explode("\n",$rawheaders);
@@ -289,7 +290,7 @@
                        }
                        
                        // parse the to header
-                       $toAddress = 
$this->emailAddressToHTML($headers->toaddress);
+                       $toAddress = isset($headers->toaddress) ? 
$this->emailAddressToHTML($headers->toaddress) : '';
                        $this->t->set_var("to_data",$toAddress);
                        
                        // parse the cc header
@@ -462,19 +463,34 @@
                                // add line breaks to $bodyParts
                                #$newBody       = 
wordwrap($bodyParts[$i],90,"\n",1);
                                #$newBody       = 
wordwrap($bodyParts[$i],90,"<br>",1);
-                               if($this->mailPreferences['encoding'] =='utf8')
-                               {
-                                       $bodyParts[$i]['body'] = 
utf8_encode($bodyParts[$i]['body']);
-                               }
                                
                                if($bodyParts[$i]['mimeType'] == 'text/plain')
                                {
-                                       #$newBody       = 
ereg_replace("\n","<br>",$bodyParts[$i]['body']);
-                                       
                                        $newBody        = 
wordwrap($bodyParts[$i]['body'],90,"\n",1);
-                                       $newBody        = 
htmlspecialchars($newBody,ENT_QUOTES);
-                                       $newBody        = 
"<pre>".$newBody."</pre>";
+                                       $newBody        = 
htmlspecialchars($newBody,ENT_QUOTES,'UTF-8');
+
+                                       // search http[s] links and make them 
as links available again
+                                       // to understand what's going on here, 
have a look at 
+                                       // 
http://www.php.net/manual/en/function.preg-replace.php
+
+                                       // create links for websites
+                                       $newBody = 
preg_replace("/((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,!&gt;,\%,@,\*,#,:,~,\+]+)/ie",
 
+                                               "'<a 
href=\"$webserverURL/redirect.php?go='address@hidden(urlencode('http$3://$4$5'),ENT_QUOTES,'UTF-8').'\"
 target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody);
+                       
+                                       // create links for ftp sites
+                                       $newBody = 
preg_replace("/((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&amp;]+)/i", 
+                                               "<a href=\"ftp://$3$4\"; 
target=\"_blank\"><font color=\"blue\">ftp://$3$4</font></a>", $newBody);
+
+                                       // create links for email addresses
+                                       $linkData = array
+                                       (
+                                               'menuaction'    => 
'felamimail.uicompose.compose'
+                                       );
+                                       $link = 
$GLOBALS['phpgw']->link('/index.php',$linkData);
+                                       $newBody = 
preg_replace("/(?<=\s{1}|&lt;)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie",
 
+                                               "'<a 
href=\"$link&send_to='.base64_encode('$0').'\"><font 
color=\"blue\">$0</font></a>'", $newBody);
                                        
+                                       $newBody        = nl2br($newBody);
                                }
                                else
                                {
@@ -484,30 +500,51 @@
                                                                $tag_list, 
$rm_tags_with_content,
                                                                
$self_closing_tags, $force_tag_closing,
                                                                $rm_attnames, 
$bad_attvals, $add_attr_to_tag);
-                               }
-                               $body .= $newBody;
-                               #print "<hr><pre>$body</pre><hr>";
-                       }
                        
-                       // search http[s] links and make them as links 
available again
-                       // to understand what's going on here, have a look at 
-                       // 
http://www.php.net/manual/en/function.preg-replace.php
+                                       $this->displayCharset = 'utf-8'; // 
temporary - fix this below
+                                       // create links for websites
+                                       #$newBody = 
preg_replace("/(?<!\>)((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\*,#,:,~,\+]+)/ie",
 
+                                       #       "'<a 
href=\"$webserverURL/redirect.php?go='.htmlentities(urlencode('http$3://$4$5'),ENT_QUOTES,\"$this->displayCharset\").'\"
 target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody);
+                                       $newBody = 
preg_replace("/(?<!>|\/|\")((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\*,#,:,~,\+]+)/ie",
 
+                                               "'<a 
href=\"$webserverURL/redirect.php?go='address@hidden(urlencode('http$3://$4$5'),ENT_QUOTES,\"$this->displayCharset\").'\"
 target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody);
                        
-                       #$body = preg_replace("/(\&gt\;)/", 
-                       #       "<font color=\"blue\">$1</font>", $body);
+                                       // create links for websites
+                                       $newBody = 
preg_replace("/href=(\"|\')((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\(,\),\*,#,:,~,\+]+)(\"|\')/ie",
 
+                                               
"'href=\"$webserverURL/redirect.php?go='address@hidden(urlencode('http$4://$5$6'),ENT_QUOTES,\"$this->displayCharset\").'\"
 target=\"_blank\"'", $newBody);
                        
+                                       // create links for ftp sites
+                                       $newBody = 
preg_replace("/href=(\"|\')((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&amp;]+)(\"|\')/i",
 
+                                               "href=\"ftp://$4$5\"; 
target=\"_blank\"", $newBody);
+
+                                       // create links for inline images
+                                       $linkData = array (
+                                               'menuaction'    => 
'felamimail.uidisplay.displayImage',
+                                               'uid'           => $this->uid,
+                                       );
+                                       $imageURL = 
$GLOBALS['phpgw']->link('/index.php', $linkData);
+                                       $newBody = 
preg_replace("/(\"|\')cid:(.*)(\"|\')/iUe", 
+                                               
"'\"$imageURL&cid='.base64_encode('$2').'\"'", $newBody);
                        
-                       // create links for websites
-                       #$body = 
preg_replace("/((http(s?):\/\/)|(www\.))([\w\.,-.,\/.,\?.,\=.,&amp;]+)/ie", 
-                       #       "'<a 
href=\"/phpgroupware/redirect.php?go='.htmlentities(urlencode('http$3://$4$5')).'\"
 target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $body);
-               /*      $body = 
preg_replace("/((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\*,#,:,~,\+]+)/ie",
 
-                               "'<a 
href=\"/phpgroupware/redirect.php?go='.htmlentities(urlencode('http$3://$4$5')).'\"
 target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $body);
-               */      
-                       // create links for ftp sites -- not working
+                                       // create links for email addresses
+                                       $linkData = array
+                                       (
+                                               'menuaction'    => 
'felamimail.uicompose.compose'
+                                       );
+                                       $link = 
$GLOBALS['phpgw']->link('/index.php',$linkData);
+                                       $newBody = 
preg_replace("/href=(\"|\')mailto:([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\*,#,:,~,\+]+)(\"|\')/ie",
 
+                                               
"'href=\"$link&send_to='.base64_encode('$2').'\"'", $newBody);
+                                       #print 
"<pre>".htmlentities($newBody)."</pre><hr>";
+
+                                       $link = 
$GLOBALS['phpgw']->link('/index.php',$linkData);
+                                       #$newBody = 
preg_replace("/(?<!:)(?<=\s{1}|&lt;)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie",
 
+                                       $newBody = 
preg_replace("/(?<!:)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie", 
+                                               "'<a 
href=\"$link&send_to='.('$0').'\"><font color=\"blue\">$0</font></a>'", 
$newBody);
+
+                               }
+                               $body .= $newBody;
+                               #print "<hr><pre>$body</pre><hr>";
+                       }
                
-               /*      $body = 
preg_replace("/((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&amp;]+)/i", 
-                               "<a href=\"ftp://$3$4\"; target=\"_blank\"><font 
color=\"blue\">$1$3$4</font></a>", $body);
-               */
                        // create links for windows shares
                        // \\\\\\\\ == '\\' in real life!! :)
                        $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i", 
@@ -517,7 +554,7 @@
                        #$body = preg_replace("/(--)/im","<font 
color=\"grey\">$1</font>", $body);
                        
                        // create links for email addresses
-                       $linkData = array
+       /*              $linkData = array
                        (
                                'menuaction'    => 
'felamimail.uicompose.compose'
                        );
@@ -525,7 +562,7 @@
                
                        $body = 
preg_replace("/([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+)/i", 
                                "<a href=\"$link&send_to=$0\"><font 
color=\"blue\">$0</font></a>", $body);
-                               
+       */                      
                        $this->t->set_var("body",$body);
                        
$this->t->set_var("signature",(isset($sessionData['signature'])?$sessionData['signature']:''));
 

Index: templates/base/config.tpl
===================================================================
RCS file: /sources/phpgroupware/felamimail/templates/base/config.tpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- templates/base/config.tpl   9 Feb 2007 12:37:54 -0000       1.4
+++ templates/base/config.tpl   23 Feb 2007 14:45:08 -0000      1.5
@@ -10,23 +10,11 @@
     <td colspan="2">&nbsp;</td>
    </tr>
 
- 
     <tr bgcolor="{row_off}">
     <td colspan="2">&nbsp;<b>{lang_system_settings}</b></td>
    </tr>
 
    <tr bgcolor="{row_off}">
-    <td>{lang_Select_your_system_encoding}:</td>
-    <td>
-     <select name="newsettings[encoding]">
-      <option value="utf8" {selected_encoding_utf8}>utf-8</option>
-      <option value="LATIN1" {selected_encoding_LATIN1}>iso-8859-1</option>
-     </select>
-    </td>
-   </tr>
-
-  
-   <tr bgcolor="{row_off}">
     <td colspan="2">&nbsp;<b>{lang_Mail_settings}</b></td>
    </tr>
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]