Quantcast

r40129 - in /trunk: egw-pear/Net/IMAP.php felamimail/inc/class.felamimail_bo.inc.php

classic Classic list List threaded Threaded
1 message Options
leithoff leithoff
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

r40129 - in /trunk: egw-pear/Net/IMAP.php felamimail/inc/class.felamimail_bo.inc.php

Author: leithoff
Date: Tue Aug 14 10:26:58 2012
New Revision: 40129

URL: http://svn.stylite.de/viewvc/egroupware?rev=40129&view=rev
Log:
some servers seem to sent their responses for the content not with the first EXT section, so we loop through the parsed response until we find some matching content; second attempt

Modified:
    trunk/egw-pear/Net/IMAP.php
    trunk/felamimail/inc/class.felamimail_bo.inc.php

Modified: trunk/egw-pear/Net/IMAP.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egw-pear/Net/IMAP.php?rev=40129&r1=40128&r2=40129&view=diff
==============================================================================
--- trunk/egw-pear/Net/IMAP.php (original)
+++ trunk/egw-pear/Net/IMAP.php Tue Aug 14 10:26:58 2012
@@ -560,7 +560,12 @@
         if(strtoupper($ret["RESPONSE"]["CODE"]) != "OK"){
             return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]);
         }
-        $ret=$ret["PARSED"][0]["EXT"]["BODY[TEXT]"]["CONTENT"];
+        $found = 0;
+        foreach($ret["PARSED"] as $key => $value)
+        {
+            if (isset($ret["PARSED"][$key]["EXT"]["BODY[TEXT]"]["CONTENT"])) {$found = $key; break;}
+        }
+        $ret=$ret["PARSED"][$found]["EXT"]["BODY[TEXT]"]["CONTENT"];
         //$ret=$resp["PARSED"][0]["EXT"]["RFC822"]["CONTENT"];
         return $ret;
     }
@@ -624,23 +629,29 @@
         } else {
           $ret=$this->cmdFetch($msg_id,"BODYSTRUCTURE");
         }
- #_debug_array($ret);
+        #_debug_array($ret);
         if (PEAR::isError($ret)) {
             return $ret;
         }
         if(strtoupper($ret["RESPONSE"]["CODE"]) != "OK"){
             return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]);
         }
-        $ret2=$ret["PARSED"][0]["EXT"]["BODYSTRUCTURE"][0];
- // sometimes we get an [COMMAND] => OK with $ret["PARSED"][0] and no $ret["PARSED"][0]["EXT"]["BODYSTRUCTURE"]
- if (is_array($ret) && empty($ret2) && isset($ret["PARSED"])) {
- foreach($ret["PARSED"] as $substruct) {
- if ($substruct["COMMAND"] == "FETCH") {
- $ret2=$substruct["EXT"]["BODYSTRUCTURE"][0];
- break;
- }
- }
- }
+        $found = 0;
+        foreach($ret["PARSED"] as $key => $value)
+        {
+            if (isset($ret["PARSED"][$key]["EXT"]["BODYSTRUCTURE"][0])) {$found = $key; break;}
+        }
+        $ret2=$ret["PARSED"][$found]["EXT"]["BODYSTRUCTURE"][0];
+        // sometimes we get an [COMMAND] => OK with $ret["PARSED"][0] and no $ret["PARSED"][0]["EXT"]["BODYSTRUCTURE"]
+        // should not happen anymore
+        if (is_array($ret) && empty($ret2) && isset($ret["PARSED"])) {
+            foreach($ret["PARSED"] as $substruct) {
+                if ($substruct["COMMAND"] == "FETCH") {
+                    $ret2=$substruct["EXT"]["BODYSTRUCTURE"][0];
+                    break;
+                }
+            }
+        }
         $structure = array();
 
         $mimeParts = array();

Modified: trunk/felamimail/inc/class.felamimail_bo.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/felamimail/inc/class.felamimail_bo.inc.php?rev=40129&r1=40128&r2=40129&view=diff
==============================================================================
--- trunk/felamimail/inc/class.felamimail_bo.inc.php (original)
+++ trunk/felamimail/inc/class.felamimail_bo.inc.php Tue Aug 14 10:26:58 2012
@@ -1149,9 +1149,13 @@
  function _getStructure($_uid, $byUid=true, $_ignoreCache=false)
  {
  static $structure;
- $_folder = $this->sessionData['mailbox'];
+ $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
+ //error_log(__METHOD__.__LINE__." UID: $_uid, ".$this->icServer->ImapServerId.','.$_folder);
+ $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
  if (is_null($structure)) $structure = egw_cache::getCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
- if (isset($structure[$this->icServer->ImapServerId][$_folder][$_uid]))
+ if (isset($structure[$this->icServer->ImapServerId]) && !empty($structure[$this->icServer->ImapServerId]) &&
+ isset($structure[$this->icServer->ImapServerId][$_folder]) && !empty($structure[$this->icServer->ImapServerId][$_folder]) &&
+ isset($structure[$this->icServer->ImapServerId][$_folder][$_uid]) && !empty($structure[$this->icServer->ImapServerId][$_folder][$_uid]))
  {
  if ($_ignoreCache===false)
  {
@@ -2305,7 +2309,7 @@
  return false;
  }
  //_debug_array($mimePartBody);
- //error_log(__METHOD__.__LINE__.' UID:'.$_uid.' PartID:'.$partID.' HTMLMode:'.$_htmlMode.' ->'.array2string($_structure).array2string($mimePartBody));
+ //error_log(__METHOD__.__LINE__.' UID:'.$_uid.' PartID:'.$partID.' HTMLMode:'.$_htmlMode.' ->'.array2string($_structure).' body:'.array2string($mimePartBody));
  if (empty($mimePartBody)) return array(
  'body' => '',
  'mimeType'  => ($_structure->type == 'TEXT' && $_structure->subType == 'HTML') ? 'text/html' : 'text/plain',
@@ -3197,7 +3201,6 @@
  }
  }
  if (self::$debug) _debug_array($structure);
-
  switch($structure->type) {
  case 'APPLICATION':
  return array(


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
eGroupWare-cvs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs
Loading...