@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | /** |
| 252 | 252 | * Add one or multiple addresses to Cc |
| 253 | 253 | * |
| 254 | - * @param string|array|Horde_Mail_Rfc822_List $address |
|
| 254 | + * @param string $address |
|
| 255 | 255 | * @param string $personal ='' only used if $address is a string |
| 256 | 256 | */ |
| 257 | 257 | function addCc($address, $personal=null) |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | /** |
| 382 | 382 | * Adds an embedded image or other inline attachment |
| 383 | 383 | * |
| 384 | - * @param string|resource $data Path to the attachment or open file-descriptor |
|
| 384 | + * @param string $data Path to the attachment or open file-descriptor |
|
| 385 | 385 | * @param string $cid Content ID of the attachment. Use this to identify |
| 386 | 386 | * the Id for accessing the image in an HTML form. |
| 387 | 387 | * @param string $name Overrides the attachment name. |
@@ -490,24 +490,24 @@ discard block |
||
| 490 | 490 | * Log mails to log file specified in $GLOBALS['egw_info']['server']['log_mail'] |
| 491 | 491 | * or regular error_log for true (can be set either in DB or header.inc.php). |
| 492 | 492 | * |
| 493 | - * @param Horde_Mail_Transport $transport =null using transport from mail-account |
|
| 493 | + * @param Horde_Mail_Transport $transport =null using transport from mail-account |
|
| 494 | 494 | * specified in construct, or default one, if not specified |
| 495 | - * @param boolean $resend =true allways true in EGroupware! |
|
| 496 | - * @param boolean $flowed =null send message in flowed text format, |
|
| 495 | + * @param boolean $resend =true allways true in EGroupware! |
|
| 496 | + * @param boolean $flowed =null send message in flowed text format, |
|
| 497 | 497 | * default null used flowed by default for everything but multipart/encrypted, |
| 498 | 498 | * unless disabled in site configuration ("disable_rfc3676_flowed") |
| 499 | 499 | * * @param array $opts Additional options: |
| 500 | - * <pre> |
|
| 501 | - * - broken_rfc2231: (boolean) Attempt to work around non-RFC |
|
| 502 | - * 2231-compliant MUAs by generating both a RFC |
|
| 503 | - * 2047-like parameter name and also the correct RFC |
|
| 504 | - * 2231 parameter (@since 2.5.0). |
|
| 505 | - * DEFAULT: false |
|
| 506 | - * - encode: (integer) The encoding to use. A mask of self::ENCODE_* |
|
| 507 | - * values. |
|
| 508 | - * DEFAULT: Auto-determined based on transport driver. |
|
| 509 | - * </pre> |
|
| 510 | - * |
|
| 500 | + * <pre> |
|
| 501 | + * - broken_rfc2231: (boolean) Attempt to work around non-RFC |
|
| 502 | + * 2231-compliant MUAs by generating both a RFC |
|
| 503 | + * 2047-like parameter name and also the correct RFC |
|
| 504 | + * 2231 parameter (@since 2.5.0). |
|
| 505 | + * DEFAULT: false |
|
| 506 | + * - encode: (integer) The encoding to use. A mask of self::ENCODE_* |
|
| 507 | + * values. |
|
| 508 | + * DEFAULT: Auto-determined based on transport driver. |
|
| 509 | + * </pre> |
|
| 510 | + * |
|
| 511 | 511 | * @throws Exception\NotFound for no smtp account available |
| 512 | 512 | * @throws Horde_Mime_Exception |
| 513 | 513 | */ |
@@ -645,42 +645,42 @@ discard block |
||
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
| 648 | - * Sends this message. |
|
| 649 | - * |
|
| 650 | - * @param Mail $mailer A Mail object. |
|
| 651 | - * @param boolean $resend If true, the message id and date are re-used; |
|
| 652 | - * If false, they will be updated. |
|
| 653 | - * @param boolean $flowed Send message in flowed text format. |
|
| 648 | + * Sends this message. |
|
| 649 | + * |
|
| 650 | + * @param Mail $mailer A Mail object. |
|
| 651 | + * @param boolean $resend If true, the message id and date are re-used; |
|
| 652 | + * If false, they will be updated. |
|
| 653 | + * @param boolean $flowed Send message in flowed text format. |
|
| 654 | 654 | * * @param array $opts Additional options: |
| 655 | - * <pre> |
|
| 656 | - * - broken_rfc2231: (boolean) Attempt to work around non-RFC |
|
| 657 | - * 2231-compliant MUAs by generating both a RFC |
|
| 658 | - * 2047-like parameter name and also the correct RFC |
|
| 659 | - * 2231 parameter (@since 2.5.0). |
|
| 660 | - * DEFAULT: false |
|
| 661 | - * - encode: (integer) The encoding to use. A mask of self::ENCODE_* |
|
| 662 | - * values. |
|
| 663 | - * DEFAULT: Auto-determined based on transport driver. |
|
| 664 | - * </pre> |
|
| 665 | - * |
|
| 666 | - * |
|
| 667 | - * @throws Horde_Mime_Exception |
|
| 668 | - */ |
|
| 669 | - public function _send($mailer, $resend = false, $flowed = true, array $opts = array()) |
|
| 670 | - { |
|
| 655 | + * <pre> |
|
| 656 | + * - broken_rfc2231: (boolean) Attempt to work around non-RFC |
|
| 657 | + * 2231-compliant MUAs by generating both a RFC |
|
| 658 | + * 2047-like parameter name and also the correct RFC |
|
| 659 | + * 2231 parameter (@since 2.5.0). |
|
| 660 | + * DEFAULT: false |
|
| 661 | + * - encode: (integer) The encoding to use. A mask of self::ENCODE_* |
|
| 662 | + * values. |
|
| 663 | + * DEFAULT: Auto-determined based on transport driver. |
|
| 664 | + * </pre> |
|
| 665 | + * |
|
| 666 | + * |
|
| 667 | + * @throws Horde_Mime_Exception |
|
| 668 | + */ |
|
| 669 | + public function _send($mailer, $resend = false, $flowed = true, array $opts = array()) |
|
| 670 | + { |
|
| 671 | 671 | /* Add mandatory headers if missing. */ |
| 672 | 672 | if (!$resend || !isset($this->_headers['Message-ID'])) { |
| 673 | 673 | $this->_headers->addHeaderOb( |
| 674 | - Horde_Mime_Headers_MessageId::create() |
|
| 674 | + Horde_Mime_Headers_MessageId::create() |
|
| 675 | 675 | ); |
| 676 | 676 | } |
| 677 | 677 | if (!isset($this->_headers['User-Agent'])) { |
| 678 | 678 | $this->_headers->addHeaderOb( |
| 679 | - Horde_Mime_Headers_UserAgent::create() |
|
| 679 | + Horde_Mime_Headers_UserAgent::create() |
|
| 680 | 680 | ); |
| 681 | 681 | } |
| 682 | 682 | if (!$resend || !isset($this->_headers['Date'])) { |
| 683 | - $this->_headers->addHeaderOb(Horde_Mime_Headers_Date::create()); |
|
| 683 | + $this->_headers->addHeaderOb(Horde_Mime_Headers_Date::create()); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | if (isset($this->_base)) { |
@@ -699,9 +699,9 @@ discard block |
||
| 699 | 699 | $body = new Horde_Mime_Part(); |
| 700 | 700 | if (!empty($this->_body) && !empty($this->_htmlBody)) { |
| 701 | 701 | $body->setType('multipart/alternative'); |
| 702 | - $this->_body->setDescription(Horde_Mime_Translation::t("Plaintext Version of Message")); |
|
| 702 | + $this->_body->setDescription(Horde_Mime_Translation::t("Plaintext Version of Message")); |
|
| 703 | 703 | $body[] = $this->_body; |
| 704 | - $this->_htmlBody->setDescription(Horde_Mime_Translation::t("HTML Version of Message")); |
|
| 704 | + $this->_htmlBody->setDescription(Horde_Mime_Translation::t("HTML Version of Message")); |
|
| 705 | 705 | $body[] = $this->_htmlBody; |
| 706 | 706 | } elseif (!empty($this->_htmlBody)) { |
| 707 | 707 | $body = $this->_htmlBody; |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | |
| 746 | 746 | /* Remember the basepart */ |
| 747 | 747 | $this->_base = $basepart; |
| 748 | - } |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | 750 | /** |
| 751 | 751 | * Reset all Settings to send multiple Messages |
@@ -767,15 +767,15 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /** |
| 770 | - * Get the raw email data sent by this object. |
|
| 771 | - * |
|
| 770 | + * Get the raw email data sent by this object. |
|
| 771 | + * |
|
| 772 | 772 | * Reimplement to be able to call it for saveAsDraft by calling |
| 773 | 773 | * $this->send(new Horde_Mail_Transport_Null()), |
| 774 | 774 | * if no base-part is set, because send is not called before. |
| 775 | 775 | * |
| 776 | - * @param boolean $stream If true, return a stream resource, otherwise |
|
| 777 | - * @return stream|string The raw email data. |
|
| 778 | - */ |
|
| 776 | + * @param boolean $stream If true, return a stream resource, otherwise |
|
| 777 | + * @return stream|string The raw email data. |
|
| 778 | + */ |
|
| 779 | 779 | function getRaw($stream=true) |
| 780 | 780 | { |
| 781 | 781 | try { |
@@ -788,24 +788,24 @@ discard block |
||
| 788 | 788 | } |
| 789 | 789 | // code copied from Horde_Mime_Mail::getRaw(), as there is no way to inject charset in |
| 790 | 790 | // _headers->toString(), which is required to encode headers containing non-ascii chars correct |
| 791 | - if ($stream) { |
|
| 791 | + if ($stream) { |
|
| 792 | 792 | // Smime sign needs to be 7bit encoded to avoid any changes |
| 793 | 793 | $encode = $this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed')? |
| 794 | 794 | Horde_Mime_Part::ENCODE_7BIT : |
| 795 | 795 | (Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY); |
| 796 | - $hdr = new Horde_Stream(); |
|
| 797 | - $hdr->add($this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)), true); |
|
| 798 | - return Horde_Stream_Wrapper_Combine::getStream( |
|
| 799 | - array($hdr->stream, |
|
| 800 | - $this->getBasePart()->toString( |
|
| 801 | - array('stream' => true, 'canonical' => true, 'encode' => $encode)) |
|
| 802 | - ) |
|
| 803 | - ); |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - return $this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)) . |
|
| 796 | + $hdr = new Horde_Stream(); |
|
| 797 | + $hdr->add($this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)), true); |
|
| 798 | + return Horde_Stream_Wrapper_Combine::getStream( |
|
| 799 | + array($hdr->stream, |
|
| 800 | + $this->getBasePart()->toString( |
|
| 801 | + array('stream' => true, 'canonical' => true, 'encode' => $encode)) |
|
| 802 | + ) |
|
| 803 | + ); |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + return $this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)) . |
|
| 807 | 807 | $this->getBasePart()->toString(array('canonical' => true)); |
| 808 | - } |
|
| 808 | + } |
|
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | 811 | * Convert charset of text-parts of message to utf-8. non static AND include Bcc |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | * @return string|stream |
| 818 | 818 | */ |
| 819 | 819 | function convertMessageTextParts($message, $stream=false, $charset='utf-8', &$converted=false) |
| 820 | - { |
|
| 820 | + { |
|
| 821 | 821 | $headers = Horde_Mime_Headers::parseHeaders($message); |
| 822 | 822 | $this->addHeaders($headers); |
| 823 | 823 | $base = Horde_Mime_Part::parseMessage($message); |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | * false: no NOT initialise account and set other EGroupware specific headers, used to parse mails (not sending them!) |
| 70 | 70 | * initbasic: return $this |
| 71 | 71 | */ |
| 72 | - function __construct($account=null) |
|
| 72 | + function __construct($account = null) |
|
| 73 | 73 | { |
| 74 | 74 | // Horde use locale for translation of error messages |
| 75 | 75 | Preferences::setlocale(LC_MESSAGES); |
| 76 | 76 | |
| 77 | 77 | parent::__construct(); |
| 78 | - if ($account ==='initbasic') |
|
| 78 | + if ($account === 'initbasic') |
|
| 79 | 79 | { |
| 80 | 80 | $this->_headers = new Horde_Mime_Headers(); |
| 81 | 81 | $this->clearAllRecipients(); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param int|Mail\Account $account =null mail account to use, default use Mail\Account::get_default($smtp=true) |
| 115 | 115 | * @throws Exception\NotFound if account was not found (or not valid for current user) |
| 116 | 116 | */ |
| 117 | - function setAccount($account=null) |
|
| 117 | + function setAccount($account = null) |
|
| 118 | 118 | { |
| 119 | 119 | if ($account instanceof Mail\Account) |
| 120 | 120 | { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | $identity = Mail\Account::read_identity($this->account->ident_id, true, null, $this->account); |
| 138 | 138 | } |
| 139 | - catch(Exception $e) |
|
| 139 | + catch (Exception $e) |
|
| 140 | 140 | { |
| 141 | 141 | unset($e); |
| 142 | 142 | error_log(__METHOD__.__LINE__.' Could not read_identity for account:'.$account['acc_id'].' with IdentID:'.$account['ident_id']); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param string $address |
| 159 | 159 | * @param string $personal ='' |
| 160 | 160 | */ |
| 161 | - public function setFrom($address, $personal='') |
|
| 161 | + public function setFrom($address, $personal = '') |
|
| 162 | 162 | { |
| 163 | 163 | $this->addHeader('From', self::add_personal($address, $personal)); |
| 164 | 164 | } |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | * @param string $personal ='' only used if $address is a string |
| 171 | 171 | * @param string $type ='to' type of address to add "to", "cc", "bcc" or "replyto" |
| 172 | 172 | */ |
| 173 | - function addAddress($address, $personal='', $type='to') |
|
| 173 | + function addAddress($address, $personal = '', $type = 'to') |
|
| 174 | 174 | { |
| 175 | 175 | if (!isset(self::$type2header[$type])) |
| 176 | 176 | { |
| 177 | 177 | throw new Exception\WrongParameter("Unknown type '$type'!"); |
| 178 | 178 | } |
| 179 | - if ($personal) $address = self::add_personal ($address, $personal); |
|
| 179 | + if ($personal) $address = self::add_personal($address, $personal); |
|
| 180 | 180 | |
| 181 | 181 | // add to our local list |
| 182 | 182 | $this->$type->add($address); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @param string $type ='to' type of address to add "to", "cc", "bcc" or "replyto" |
| 192 | 192 | */ |
| 193 | - function clearAddresses($type='to') |
|
| 193 | + function clearAddresses($type = 'to') |
|
| 194 | 194 | { |
| 195 | 195 | $this->$type = new Horde_Mail_Rfc822_List(); |
| 196 | 196 | |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | * @param boolean $return_array =false true: return array of string, false: Horde_Mail_Rfc822_List |
| 205 | 205 | * @return array|Horde_Mail_Rfc822_List supporting arrayAccess and Iterable |
| 206 | 206 | */ |
| 207 | - function getAddresses($type='to', $return_array=false) |
|
| 207 | + function getAddresses($type = 'to', $return_array = false) |
|
| 208 | 208 | { |
| 209 | 209 | if ($return_array) |
| 210 | 210 | { |
| 211 | 211 | $addresses = array(); |
| 212 | - foreach($this->$type as $addr) |
|
| 212 | + foreach ($this->$type as $addr) |
|
| 213 | 213 | { |
| 214 | 214 | $addresses[] = (string)$addr; |
| 215 | 215 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | //if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal)) // that's how I read the rfc(2)822 |
| 251 | 251 | if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) // but quoting is never wrong, so quote more then necessary |
| 252 | 252 | { |
| 253 | - $personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"'; |
|
| 253 | + $personal = '"'.str_replace(array('\\', '"'), array('\\\\', '\\"'), $personal).'"'; |
|
| 254 | 254 | } |
| 255 | 255 | $address = ($personal ? $personal.' <' : '').$address.($personal ? '>' : ''); |
| 256 | 256 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string|array|Horde_Mail_Rfc822_List $address |
| 264 | 264 | * @param string $personal ='' only used if $address is a string |
| 265 | 265 | */ |
| 266 | - function addCc($address, $personal=null) |
|
| 266 | + function addCc($address, $personal = null) |
|
| 267 | 267 | { |
| 268 | 268 | $this->addAddress($address, $personal, 'cc'); |
| 269 | 269 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param string|array|Horde_Mail_Rfc822_List $address |
| 283 | 283 | * @param string $personal ='' only used if $address is a string |
| 284 | 284 | */ |
| 285 | - function addBcc($address, $personal=null) |
|
| 285 | + function addBcc($address, $personal = null) |
|
| 286 | 286 | { |
| 287 | 287 | $this->addAddress($address, $personal, 'bcc'); |
| 288 | 288 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param string|array|Horde_Mail_Rfc822_List $address |
| 302 | 302 | * @param string $personal ='' only used if $address is a string |
| 303 | 303 | */ |
| 304 | - function addReplyTo($address, $personal=null) |
|
| 304 | + function addReplyTo($address, $personal = null) |
|
| 305 | 305 | { |
| 306 | 306 | $this->addAddress($address, $personal, 'replyto'); |
| 307 | 307 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @return integer part-number |
| 337 | 337 | * @throws Exception\NotFound if $file could not be opened for reading |
| 338 | 338 | */ |
| 339 | - public function addAttachment($data, $name = null, $type = null, $old_type=null) |
|
| 339 | + public function addAttachment($data, $name = null, $type = null, $old_type = null) |
|
| 340 | 340 | { |
| 341 | 341 | // deprecated PHPMailer::AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') call |
| 342 | 342 | if ($type === 'base64') |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | // set content-type parameters, which get ignored by setType |
| 370 | 370 | if (preg_match_all('/;\s*([^=]+)=([^;]*)/', $type, $matches)) |
| 371 | 371 | { |
| 372 | - foreach($matches[1] as $n => $label) |
|
| 372 | + foreach ($matches[1] as $n => $label) |
|
| 373 | 373 | { |
| 374 | 374 | $part->setContentTypeParameter($label, $matches[2][$n]); |
| 375 | 375 | } |
@@ -471,11 +471,11 @@ discard block |
||
| 471 | 471 | * @param array $parameters =array() eg. array('method' => 'REQUEST') |
| 472 | 472 | * @param string $charset =null default to $this->_charset="utf-8" |
| 473 | 473 | */ |
| 474 | - function setAlternativBody($content, $type, $parameters=array(), $charset=null) |
|
| 474 | + function setAlternativBody($content, $type, $parameters = array(), $charset = null) |
|
| 475 | 475 | { |
| 476 | 476 | $this->_alternativBody = new Horde_Mime_Part(); |
| 477 | 477 | $this->_alternativBody->setType($type); |
| 478 | - foreach($parameters as $label => $data) |
|
| 478 | + foreach ($parameters as $label => $data) |
|
| 479 | 479 | { |
| 480 | 480 | $this->_alternativBody->setContentTypeParameter($label, $data); |
| 481 | 481 | } |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | * @throws Exception\NotFound for no smtp account available |
| 512 | 512 | * @throws Horde_Mime_Exception |
| 513 | 513 | */ |
| 514 | - function send(Horde_Mail_Transport $transport=null, $resend=true, $flowed=null, array $opts = array()) |
|
| 514 | + function send(Horde_Mail_Transport $transport = null, $resend = true, $flowed = null, array $opts = array()) |
|
| 515 | 515 | { |
| 516 | - unset($resend); // parameter is not used, but required by function signature |
|
| 516 | + unset($resend); // parameter is not used, but required by function signature |
|
| 517 | 517 | |
| 518 | 518 | if (!($message_id = $this->getHeader('Message-ID')) && |
| 519 | 519 | class_exists('Horde_Mime_Headers_MessageId')) // since 2.5.0 |
@@ -521,27 +521,27 @@ discard block |
||
| 521 | 521 | $message_id = Horde_Mime_Headers_MessageId::create('EGroupware'); |
| 522 | 522 | $this->addHeader('Message-ID', $message_id); |
| 523 | 523 | } |
| 524 | - $body_sha1 = null; // skip sha1, it requires whole mail in memory, which we traing to avoid now |
|
| 524 | + $body_sha1 = null; // skip sha1, it requires whole mail in memory, which we traing to avoid now |
|
| 525 | 525 | |
| 526 | 526 | // Smime sign needs to be 7bit encoded to avoid any changes during the transportation |
| 527 | 527 | if ($this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed')) $opts['encode'] = Horde_Mime_Part::ENCODE_7BIT; |
| 528 | 528 | |
| 529 | 529 | $mail_id = Hooks::process(array( |
| 530 | 530 | 'location' => 'send_mail', |
| 531 | - 'subject' => $subject=$this->getHeader('Subject'), |
|
| 531 | + 'subject' => $subject = $this->getHeader('Subject'), |
|
| 532 | 532 | 'from' => $this->getHeader('Return-Path') ? $this->getHeader('Return-Path') : $this->getHeader('From'), |
| 533 | - 'to' => $to=$this->getAddresses('to', true), |
|
| 534 | - 'cc' => $cc=$this->getAddresses('cc', true), |
|
| 535 | - 'bcc' => $bcc=$this->getAddresses('bcc', true), |
|
| 533 | + 'to' => $to = $this->getAddresses('to', true), |
|
| 534 | + 'cc' => $cc = $this->getAddresses('cc', true), |
|
| 535 | + 'bcc' => $bcc = $this->getAddresses('bcc', true), |
|
| 536 | 536 | 'body_sha1' => $body_sha1, |
| 537 | 537 | 'message_id' => (string)$message_id, |
| 538 | - ), array(), true); // true = call all apps |
|
| 538 | + ), array(), true); // true = call all apps |
|
| 539 | 539 | |
| 540 | 540 | // check if we are sending an html mail with inline images |
| 541 | 541 | if (!empty($this->_htmlBody) && count($this->_parts)) |
| 542 | 542 | { |
| 543 | 543 | $related = null; |
| 544 | - foreach($this->_parts as $n => $part) |
|
| 544 | + foreach ($this->_parts as $n => $part) |
|
| 545 | 545 | { |
| 546 | 546 | if ($part->getDisposition() == 'inline' && $part->getContentId()) |
| 547 | 547 | { |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $this->_body = $body; |
| 598 | 598 | $flowed = false; |
| 599 | 599 | } |
| 600 | - $this->_send($transport ? $transport : $this->account->smtpTransport(), true, $flowed, $opts); // true: keep Message-ID |
|
| 600 | + $this->_send($transport ? $transport : $this->account->smtpTransport(), true, $flowed, $opts); // true: keep Message-ID |
|
| 601 | 601 | } |
| 602 | 602 | catch (\Exception $e) { |
| 603 | 603 | // in case of errors/exceptions call hook again with previous returned mail_id and error-message to log |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | 'message_id' => (string)$message_id, |
| 613 | 613 | 'mail_id' => $mail_id, |
| 614 | 614 | 'error' => $e->getMessage(), |
| 615 | - ), array(), true); // true = call all apps |
|
| 615 | + ), array(), true); // true = call all apps |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | // log mails to file specified in $GLOBALS['egw_info']['server']['log_mail'] or error_log for true |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | $msg .= ' from instance '.$GLOBALS['egw_info']['user']['domain'].' and IP '.Session::getuser_ip(); |
| 626 | 626 | $msg .= ' from user #'.$GLOBALS['egw_info']['user']['account_id']; |
| 627 | 627 | |
| 628 | - if ($GLOBALS['egw_info']['user']['account_id'] && class_exists(__NAMESPACE__.'\\Accounts',false)) |
|
| 628 | + if ($GLOBALS['egw_info']['user']['account_id'] && class_exists(__NAMESPACE__.'\\Accounts', false)) |
|
| 629 | 629 | { |
| 630 | 630 | $msg .= ' ('.Accounts::username($GLOBALS['egw_info']['user']['account_id']).')'; |
| 631 | 631 | } |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | $msg .= ' cc='.implode(', ', $cc).', bcc='.implode(', ', $bcc); |
| 638 | 638 | if ($GLOBALS['egw_info']['server']['log_mail'] !== true) $msg .= "\n\n"; |
| 639 | 639 | |
| 640 | - error_log($msg,$GLOBALS['egw_info']['server']['log_mail'] === true ? 0 : 3, |
|
| 640 | + error_log($msg, $GLOBALS['egw_info']['server']['log_mail'] === true ? 0 : 3, |
|
| 641 | 641 | $GLOBALS['egw_info']['server']['log_mail']); |
| 642 | 642 | } |
| 643 | 643 | // rethrow error |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | */ |
| 764 | 764 | function getHeader($header) |
| 765 | 765 | { |
| 766 | - if(strtolower($header) === 'bcc') return $this->bcc->addresses; |
|
| 766 | + if (strtolower($header) === 'bcc') return $this->bcc->addresses; |
|
| 767 | 767 | return $this->_headers ? $this->_headers->getValue($header) : null; |
| 768 | 768 | } |
| 769 | 769 | |
@@ -777,23 +777,22 @@ discard block |
||
| 777 | 777 | * @param boolean $stream If true, return a stream resource, otherwise |
| 778 | 778 | * @return stream|string The raw email data. |
| 779 | 779 | */ |
| 780 | - function getRaw($stream=true) |
|
| 780 | + function getRaw($stream = true) |
|
| 781 | 781 | { |
| 782 | 782 | try { |
| 783 | 783 | $this->getBasePart(); |
| 784 | 784 | } |
| 785 | - catch(Horde_Mail_Exception $e) |
|
| 785 | + catch (Horde_Mail_Exception $e) |
|
| 786 | 786 | { |
| 787 | 787 | unset($e); |
| 788 | - parent::send(new Horde_Mail_Transport_Null(), true); // true: keep Message-ID |
|
| 788 | + parent::send(new Horde_Mail_Transport_Null(), true); // true: keep Message-ID |
|
| 789 | 789 | } |
| 790 | 790 | // code copied from Horde_Mime_Mail::getRaw(), as there is no way to inject charset in |
| 791 | 791 | // _headers->toString(), which is required to encode headers containing non-ascii chars correct |
| 792 | 792 | if ($stream) { |
| 793 | 793 | // Smime sign needs to be 7bit encoded to avoid any changes |
| 794 | - $encode = $this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed')? |
|
| 795 | - Horde_Mime_Part::ENCODE_7BIT : |
|
| 796 | - (Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY); |
|
| 794 | + $encode = $this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed') ? |
|
| 795 | + Horde_Mime_Part::ENCODE_7BIT : (Horde_Mime_Part::ENCODE_7BIT|Horde_Mime_Part::ENCODE_8BIT|Horde_Mime_Part::ENCODE_BINARY); |
|
| 797 | 796 | $hdr = new Horde_Stream(); |
| 798 | 797 | $hdr->add($this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)), true); |
| 799 | 798 | return Horde_Stream_Wrapper_Combine::getStream( |
@@ -804,7 +803,7 @@ discard block |
||
| 804 | 803 | ); |
| 805 | 804 | } |
| 806 | 805 | |
| 807 | - return $this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)) . |
|
| 806 | + return $this->_headers->toString(array('charset' => 'utf-8', 'canonical' => true)). |
|
| 808 | 807 | $this->getBasePart()->toString(array('canonical' => true)); |
| 809 | 808 | } |
| 810 | 809 | |
@@ -817,16 +816,16 @@ discard block |
||
| 817 | 816 | * @param boolean &$converted =false on return if conversation was necessary |
| 818 | 817 | * @return string|stream |
| 819 | 818 | */ |
| 820 | - function convertMessageTextParts($message, $stream=false, $charset='utf-8', &$converted=false) |
|
| 819 | + function convertMessageTextParts($message, $stream = false, $charset = 'utf-8', &$converted = false) |
|
| 821 | 820 | { |
| 822 | 821 | $headers = Horde_Mime_Headers::parseHeaders($message); |
| 823 | 822 | $this->addHeaders($headers); |
| 824 | 823 | $base = Horde_Mime_Part::parseMessage($message); |
| 825 | - foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 824 | + foreach ($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 826 | 825 | { |
| 827 | - foreach((array)$value as $val) |
|
| 826 | + foreach ((array)$value as $val) |
|
| 828 | 827 | { |
| 829 | - switch($header) |
|
| 828 | + switch ($header) |
|
| 830 | 829 | { |
| 831 | 830 | case 'Bcc': |
| 832 | 831 | case 'bcc': |
@@ -836,18 +835,18 @@ discard block |
||
| 836 | 835 | } |
| 837 | 836 | } |
| 838 | 837 | } |
| 839 | - foreach($base->partIterator() as $part) |
|
| 838 | + foreach ($base->partIterator() as $part) |
|
| 840 | 839 | { |
| 841 | - if ($part->getPrimaryType()== 'text') |
|
| 840 | + if ($part->getPrimaryType() == 'text') |
|
| 842 | 841 | { |
| 843 | 842 | $charset = $part->getContentTypeParameter('charset'); |
| 844 | 843 | if ($charset && $charset != 'utf-8') |
| 845 | 844 | { |
| 846 | 845 | $content = Translation::convert($part->toString(array( |
| 847 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 846 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 848 | 847 | )), $charset, 'utf-8'); |
| 849 | 848 | $part->setContents($content, array( |
| 850 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // $content is NOT encoded |
|
| 849 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // $content is NOT encoded |
|
| 851 | 850 | )); |
| 852 | 851 | $part->setContentTypeParameter('charset', 'utf-8'); |
| 853 | 852 | if ($part === $base) |
@@ -883,23 +882,23 @@ discard block |
||
| 883 | 882 | * @param boolean &$converted =false on return if conversation was necessary |
| 884 | 883 | * @return string|stream |
| 885 | 884 | */ |
| 886 | - static function convert($message, $stream=false, $charset='utf-8', &$converted=false) |
|
| 885 | + static function convert($message, $stream = false, $charset = 'utf-8', &$converted = false) |
|
| 887 | 886 | { |
| 888 | - $mailer = new Mailer(false); // false = no default headers and mail account |
|
| 887 | + $mailer = new Mailer(false); // false = no default headers and mail account |
|
| 889 | 888 | $mailer->addHeaders(Horde_Mime_Headers::parseHeaders($message)); |
| 890 | 889 | $base = Horde_Mime_Part::parseMessage($message); |
| 891 | - foreach($base->partIterator() as $part) |
|
| 890 | + foreach ($base->partIterator() as $part) |
|
| 892 | 891 | { |
| 893 | - if ($part->getPrimaryType()== 'text') |
|
| 892 | + if ($part->getPrimaryType() == 'text') |
|
| 894 | 893 | { |
| 895 | 894 | $charset = $part->getContentTypeParameter('charset'); |
| 896 | 895 | if ($charset && $charset != 'utf-8') |
| 897 | 896 | { |
| 898 | 897 | $content = Translation::convert($part->toString(array( |
| 899 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 898 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 900 | 899 | )), $charset, 'utf-8'); |
| 901 | 900 | $part->setContents($content, array( |
| 902 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // $content is NOT encoded |
|
| 901 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // $content is NOT encoded |
|
| 903 | 902 | )); |
| 904 | 903 | $part->setContentTypeParameter('charset', 'utf-8'); |
| 905 | 904 | if ($part === $base) |
@@ -932,7 +931,7 @@ discard block |
||
| 932 | 931 | * @param string $subtype =null |
| 933 | 932 | * @return Horde_Mime_Part part with body or null |
| 934 | 933 | */ |
| 935 | - function findBody($subtype=null) |
|
| 934 | + function findBody($subtype = null) |
|
| 936 | 935 | { |
| 937 | 936 | try { |
| 938 | 937 | $base = $this->getBasePart(); |
@@ -964,11 +963,11 @@ discard block |
||
| 964 | 963 | $this->_body = $this->_htmlBody = $this->_alternativBody = null; |
| 965 | 964 | $this->clearParts(); |
| 966 | 965 | |
| 967 | - foreach($base->partIterator() as $part) |
|
| 966 | + foreach ($base->partIterator() as $part) |
|
| 968 | 967 | { |
| 969 | 968 | $id = $part->getMimeId(); |
| 970 | 969 | //error_log(__METHOD__."() plain=$plain_id, html=$html_id: $id: ".$part->getType()); |
| 971 | - switch($id) |
|
| 970 | + switch ($id) |
|
| 972 | 971 | { |
| 973 | 972 | case '0': // base-part itself |
| 974 | 973 | continue 2; |
@@ -1012,11 +1011,11 @@ discard block |
||
| 1012 | 1011 | $this->_body = $this->_htmlBody = $this->_alternativBody = null; |
| 1013 | 1012 | $this->clearParts(); |
| 1014 | 1013 | |
| 1015 | - foreach($base->partIterator() as $part) |
|
| 1014 | + foreach ($base->partIterator() as $part) |
|
| 1016 | 1015 | { |
| 1017 | 1016 | $id = $part->getMimeId(); |
| 1018 | 1017 | //error_log(__METHOD__."() plain=$plain_id, html=$html_id: $id: ".$part->getType()); |
| 1019 | - switch($id) |
|
| 1018 | + switch ($id) |
|
| 1020 | 1019 | { |
| 1021 | 1020 | case '0': // base-part itself |
| 1022 | 1021 | continue 2; |
@@ -1088,7 +1087,7 @@ discard block |
||
| 1088 | 1087 | */ |
| 1089 | 1088 | function clearCustomHeaders() |
| 1090 | 1089 | { |
| 1091 | - foreach($this->_headers->toArray() as $header => $value) |
|
| 1090 | + foreach ($this->_headers->toArray() as $header => $value) |
|
| 1092 | 1091 | { |
| 1093 | 1092 | if (stripos($header, 'x-') === 0 || $header == 'Received') |
| 1094 | 1093 | { |
@@ -1130,10 +1129,10 @@ discard block |
||
| 1130 | 1129 | try { |
| 1131 | 1130 | $this->getBasePart(); |
| 1132 | 1131 | } |
| 1133 | - catch(Horde_Mail_Exception $e) |
|
| 1132 | + catch (Horde_Mail_Exception $e) |
|
| 1134 | 1133 | { |
| 1135 | 1134 | unset($e); |
| 1136 | - parent::send(new Horde_Mail_Transport_Null(), true); // true: keep Message-ID |
|
| 1135 | + parent::send(new Horde_Mail_Transport_Null(), true); // true: keep Message-ID |
|
| 1137 | 1136 | $this->getBasePart(); |
| 1138 | 1137 | } |
| 1139 | 1138 | |
@@ -1163,7 +1162,7 @@ discard block |
||
| 1163 | 1162 | } |
| 1164 | 1163 | |
| 1165 | 1164 | // parameters to pass on for sign mime part |
| 1166 | - $sign_params = array( |
|
| 1165 | + $sign_params = array( |
|
| 1167 | 1166 | 'type' => 'signature', |
| 1168 | 1167 | 'pubkey' => $params['senderPubKey'], |
| 1169 | 1168 | 'privkey' => $params['senderPrivKey'], |
@@ -126,10 +126,13 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | else |
| 128 | 128 | { |
| 129 | - if (!($this->account = Mail\Account::get_default(true))) // true = need an SMTP (not just IMAP) account |
|
| 129 | + if (!($this->account = Mail\Account::get_default(true))) |
|
| 130 | + { |
|
| 131 | + // true = need an SMTP (not just IMAP) account |
|
| 130 | 132 | { |
| 131 | 133 | throw new Exception\NotFound('SMTP: '.lang('Account not found!')); |
| 132 | 134 | } |
| 135 | + } |
|
| 133 | 136 | } |
| 134 | 137 | |
| 135 | 138 | try |
@@ -176,7 +179,10 @@ discard block |
||
| 176 | 179 | { |
| 177 | 180 | throw new Exception\WrongParameter("Unknown type '$type'!"); |
| 178 | 181 | } |
| 179 | - if ($personal) $address = self::add_personal ($address, $personal); |
|
| 182 | + if ($personal) |
|
| 183 | + { |
|
| 184 | + $address = self::add_personal ($address, $personal); |
|
| 185 | + } |
|
| 180 | 186 | |
| 181 | 187 | // add to our local list |
| 182 | 188 | $this->$type->add($address); |
@@ -248,10 +254,13 @@ discard block |
||
| 248 | 254 | if (is_string($address) && !empty($personal)) |
| 249 | 255 | { |
| 250 | 256 | //if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal)) // that's how I read the rfc(2)822 |
| 251 | - if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) // but quoting is never wrong, so quote more then necessary |
|
| 257 | + if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) |
|
| 258 | + { |
|
| 259 | + // but quoting is never wrong, so quote more then necessary |
|
| 252 | 260 | { |
| 253 | 261 | $personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"'; |
| 254 | 262 | } |
| 263 | + } |
|
| 255 | 264 | $address = ($personal ? $personal.' <' : '').$address.($personal ? '>' : ''); |
| 256 | 265 | } |
| 257 | 266 | return $address; |
@@ -354,7 +363,10 @@ discard block |
||
| 354 | 363 | throw new Exception\NotFound("File '$data' not found!"); |
| 355 | 364 | } |
| 356 | 365 | |
| 357 | - if (empty($type) && !is_resource($data)) $type = Vfs::mime_content_type($data); |
|
| 366 | + if (empty($type) && !is_resource($data)) |
|
| 367 | + { |
|
| 368 | + $type = Vfs::mime_content_type($data); |
|
| 369 | + } |
|
| 358 | 370 | |
| 359 | 371 | // set "text/calendar; method=*" as alternativ body |
| 360 | 372 | $matches = null; |
@@ -377,11 +389,17 @@ discard block |
||
| 377 | 389 | $part->setContents($resource); |
| 378 | 390 | |
| 379 | 391 | // setting name, also sets content-disposition attachment (!), therefore we have to do it after "text/calendar; method=" handling |
| 380 | - if ($name || !is_resource($data)) $part->setName($name ? $name : Vfs::basename($data)); |
|
| 392 | + if ($name || !is_resource($data)) |
|
| 393 | + { |
|
| 394 | + $part->setName($name ? $name : Vfs::basename($data)); |
|
| 395 | + } |
|
| 381 | 396 | |
| 382 | 397 | // this should not be necessary, because binary data get detected by mime-type, |
| 383 | 398 | // but at least Cyrus complains about NUL characters |
| 384 | - if (substr($type, 0, 5) != 'text/') $part->setTransferEncoding('base64', array('send' => true)); |
|
| 399 | + if (substr($type, 0, 5) != 'text/') |
|
| 400 | + { |
|
| 401 | + $part->setTransferEncoding('base64', array('send' => true)); |
|
| 402 | + } |
|
| 385 | 403 | $part->setDisposition('attachment'); |
| 386 | 404 | |
| 387 | 405 | return $this->addMimePart($part); |
@@ -516,15 +534,21 @@ discard block |
||
| 516 | 534 | unset($resend); // parameter is not used, but required by function signature |
| 517 | 535 | |
| 518 | 536 | if (!($message_id = $this->getHeader('Message-ID')) && |
| 519 | - class_exists('Horde_Mime_Headers_MessageId')) // since 2.5.0 |
|
| 537 | + class_exists('Horde_Mime_Headers_MessageId')) |
|
| 538 | + { |
|
| 539 | + // since 2.5.0 |
|
| 520 | 540 | { |
| 521 | 541 | $message_id = Horde_Mime_Headers_MessageId::create('EGroupware'); |
| 542 | + } |
|
| 522 | 543 | $this->addHeader('Message-ID', $message_id); |
| 523 | 544 | } |
| 524 | 545 | $body_sha1 = null; // skip sha1, it requires whole mail in memory, which we traing to avoid now |
| 525 | 546 | |
| 526 | 547 | // Smime sign needs to be 7bit encoded to avoid any changes during the transportation |
| 527 | - if ($this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed')) $opts['encode'] = Horde_Mime_Part::ENCODE_7BIT; |
|
| 548 | + if ($this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed')) |
|
| 549 | + { |
|
| 550 | + $opts['encode'] = Horde_Mime_Part::ENCODE_7BIT; |
|
| 551 | + } |
|
| 528 | 552 | |
| 529 | 553 | $mail_id = Hooks::process(array( |
| 530 | 554 | 'location' => 'send_mail', |
@@ -561,7 +585,10 @@ discard block |
||
| 561 | 585 | |
| 562 | 586 | try { |
| 563 | 587 | // no flowed for encrypted messages |
| 564 | - if (!isset($flowed)) $flowed = $this->_body && !in_array($this->_body->getType(), array('multipart/encrypted', 'multipart/signed')); |
|
| 588 | + if (!isset($flowed)) |
|
| 589 | + { |
|
| 590 | + $flowed = $this->_body && !in_array($this->_body->getType(), array('multipart/encrypted', 'multipart/signed')); |
|
| 591 | + } |
|
| 565 | 592 | |
| 566 | 593 | // check if flowed is disabled in mail site configuration |
| 567 | 594 | if (($config = Config::read('mail')) && $config['disable_rfc3676_flowed']) |
@@ -635,13 +662,19 @@ discard block |
||
| 635 | 662 | $msg .= 'ERROR '.$e->getMessage(); |
| 636 | 663 | } |
| 637 | 664 | $msg .= ' cc='.implode(', ', $cc).', bcc='.implode(', ', $bcc); |
| 638 | - if ($GLOBALS['egw_info']['server']['log_mail'] !== true) $msg .= "\n\n"; |
|
| 665 | + if ($GLOBALS['egw_info']['server']['log_mail'] !== true) |
|
| 666 | + { |
|
| 667 | + $msg .= "\n\n"; |
|
| 668 | + } |
|
| 639 | 669 | |
| 640 | 670 | error_log($msg,$GLOBALS['egw_info']['server']['log_mail'] === true ? 0 : 3, |
| 641 | 671 | $GLOBALS['egw_info']['server']['log_mail']); |
| 642 | 672 | } |
| 643 | 673 | // rethrow error |
| 644 | - if (isset($e)) throw $e; |
|
| 674 | + if (isset($e)) |
|
| 675 | + { |
|
| 676 | + throw $e; |
|
| 677 | + } |
|
| 645 | 678 | } |
| 646 | 679 | |
| 647 | 680 | /** |
@@ -669,25 +702,32 @@ discard block |
||
| 669 | 702 | public function _send($mailer, $resend = false, $flowed = true, array $opts = array()) |
| 670 | 703 | { |
| 671 | 704 | /* Add mandatory headers if missing. */ |
| 672 | - if (!$resend || !isset($this->_headers['Message-ID'])) { |
|
| 705 | + if (!$resend || !isset($this->_headers['Message-ID'])) |
|
| 706 | + { |
|
| 673 | 707 | $this->_headers->addHeaderOb( |
| 674 | 708 | Horde_Mime_Headers_MessageId::create() |
| 675 | 709 | ); |
| 676 | 710 | } |
| 677 | - if (!isset($this->_headers['User-Agent'])) { |
|
| 711 | + if (!isset($this->_headers['User-Agent'])) |
|
| 712 | + { |
|
| 678 | 713 | $this->_headers->addHeaderOb( |
| 679 | 714 | Horde_Mime_Headers_UserAgent::create() |
| 680 | 715 | ); |
| 681 | 716 | } |
| 682 | - if (!$resend || !isset($this->_headers['Date'])) { |
|
| 717 | + if (!$resend || !isset($this->_headers['Date'])) |
|
| 718 | + { |
|
| 683 | 719 | $this->_headers->addHeaderOb(Horde_Mime_Headers_Date::create()); |
| 684 | 720 | } |
| 685 | 721 | |
| 686 | - if (isset($this->_base)) { |
|
| 722 | + if (isset($this->_base)) |
|
| 723 | + { |
|
| 687 | 724 | $basepart = $this->_base; |
| 688 | - } else { |
|
| 725 | + } |
|
| 726 | + else |
|
| 727 | + { |
|
| 689 | 728 | /* Send in flowed format. */ |
| 690 | - if ($flowed && !empty($this->_body)) { |
|
| 729 | + if ($flowed && !empty($this->_body)) |
|
| 730 | + { |
|
| 691 | 731 | $flowed = new Horde_Text_Flowed($this->_body->getContents(), $this->_body->getCharset()); |
| 692 | 732 | $flowed->setDelSp(true); |
| 693 | 733 | $this->_body->setContentTypeParameter('format', 'flowed'); |
@@ -697,28 +737,38 @@ discard block |
||
| 697 | 737 | |
| 698 | 738 | /* Build mime message. */ |
| 699 | 739 | $body = new Horde_Mime_Part(); |
| 700 | - if (!empty($this->_body) && !empty($this->_htmlBody)) { |
|
| 740 | + if (!empty($this->_body) && !empty($this->_htmlBody)) |
|
| 741 | + { |
|
| 701 | 742 | $body->setType('multipart/alternative'); |
| 702 | 743 | $this->_body->setDescription(Horde_Mime_Translation::t("Plaintext Version of Message")); |
| 703 | 744 | $body[] = $this->_body; |
| 704 | 745 | $this->_htmlBody->setDescription(Horde_Mime_Translation::t("HTML Version of Message")); |
| 705 | 746 | $body[] = $this->_htmlBody; |
| 706 | - } elseif (!empty($this->_htmlBody)) { |
|
| 747 | + } |
|
| 748 | + elseif (!empty($this->_htmlBody)) |
|
| 749 | + { |
|
| 707 | 750 | $body = $this->_htmlBody; |
| 708 | - } elseif (!empty($this->_body)) { |
|
| 751 | + } |
|
| 752 | + elseif (!empty($this->_body)) |
|
| 753 | + { |
|
| 709 | 754 | $body = $this->_body; |
| 710 | 755 | } |
| 711 | - if (count($this->_parts)) { |
|
| 756 | + if (count($this->_parts)) |
|
| 757 | + { |
|
| 712 | 758 | $basepart = new Horde_Mime_Part(); |
| 713 | 759 | $basepart->setType('multipart/mixed'); |
| 714 | 760 | $basepart->isBasePart(true); |
| 715 | - if ($body) { |
|
| 761 | + if ($body) |
|
| 762 | + { |
|
| 716 | 763 | $basepart[] = $body; |
| 717 | 764 | } |
| 718 | - foreach ($this->_parts as $mime_part) { |
|
| 765 | + foreach ($this->_parts as $mime_part) |
|
| 766 | + { |
|
| 719 | 767 | $basepart[] = $mime_part; |
| 720 | 768 | } |
| 721 | - } else { |
|
| 769 | + } |
|
| 770 | + else |
|
| 771 | + { |
|
| 722 | 772 | $basepart = $body; |
| 723 | 773 | $basepart->isBasePart(true); |
| 724 | 774 | } |
@@ -727,12 +777,15 @@ discard block |
||
| 727 | 777 | |
| 728 | 778 | /* Build recipients. */ |
| 729 | 779 | $recipients = clone $this->_recipients; |
| 730 | - foreach (array('to', 'cc') as $header) { |
|
| 731 | - if ($h = $this->_headers[$header]) { |
|
| 780 | + foreach (array('to', 'cc') as $header) |
|
| 781 | + { |
|
| 782 | + if ($h = $this->_headers[$header]) |
|
| 783 | + { |
|
| 732 | 784 | $recipients->add($h->getAddressList()); |
| 733 | 785 | } |
| 734 | 786 | } |
| 735 | - if ($this->_bcc) { |
|
| 787 | + if ($this->_bcc) |
|
| 788 | + { |
|
| 736 | 789 | $recipients->add($this->_bcc); |
| 737 | 790 | } |
| 738 | 791 | |
@@ -763,7 +816,10 @@ discard block |
||
| 763 | 816 | */ |
| 764 | 817 | function getHeader($header) |
| 765 | 818 | { |
| 766 | - if(strtolower($header) === 'bcc') return $this->bcc->addresses; |
|
| 819 | + if(strtolower($header) === 'bcc') |
|
| 820 | + { |
|
| 821 | + return $this->bcc->addresses; |
|
| 822 | + } |
|
| 767 | 823 | return $this->_headers ? $this->_headers->getValue($header) : null; |
| 768 | 824 | } |
| 769 | 825 | |
@@ -789,7 +845,8 @@ discard block |
||
| 789 | 845 | } |
| 790 | 846 | // code copied from Horde_Mime_Mail::getRaw(), as there is no way to inject charset in |
| 791 | 847 | // _headers->toString(), which is required to encode headers containing non-ascii chars correct |
| 792 | - if ($stream) { |
|
| 848 | + if ($stream) |
|
| 849 | + { |
|
| 793 | 850 | // Smime sign needs to be 7bit encoded to avoid any changes |
| 794 | 851 | $encode = $this->_base && $this->_base->getMetadata('X-EGroupware-Smime-signed')? |
| 795 | 852 | Horde_Mime_Part::ENCODE_7BIT : |
@@ -818,7 +875,7 @@ discard block |
||
| 818 | 875 | * @return string|stream |
| 819 | 876 | */ |
| 820 | 877 | function convertMessageTextParts($message, $stream=false, $charset='utf-8', &$converted=false) |
| 821 | - { |
|
| 878 | + { |
|
| 822 | 879 | $headers = Horde_Mime_Headers::parseHeaders($message); |
| 823 | 880 | $this->addHeaders($headers); |
| 824 | 881 | $base = Horde_Mime_Part::parseMessage($message); |
@@ -936,7 +993,10 @@ discard block |
||
| 936 | 993 | { |
| 937 | 994 | try { |
| 938 | 995 | $base = $this->getBasePart(); |
| 939 | - if (!($part_id = $base->findBody($subtype))) return null; |
|
| 996 | + if (!($part_id = $base->findBody($subtype))) |
|
| 997 | + { |
|
| 998 | + return null; |
|
| 999 | + } |
|
| 940 | 1000 | return $base->getPart($part_id); |
| 941 | 1001 | } |
| 942 | 1002 | catch (Horde_Mail_Exception $e) { |
@@ -1050,7 +1110,10 @@ discard block |
||
| 1050 | 1110 | */ |
| 1051 | 1111 | public function addMimePart($part) |
| 1052 | 1112 | { |
| 1053 | - if ($this->_base) $this->parseBasePart(); |
|
| 1113 | + if ($this->_base) |
|
| 1114 | + { |
|
| 1115 | + $this->parseBasePart(); |
|
| 1116 | + } |
|
| 1054 | 1117 | |
| 1055 | 1118 | return parent::addMimePart($part); |
| 1056 | 1119 | } |
@@ -1150,7 +1213,10 @@ discard block |
||
| 1150 | 1213 | { |
| 1151 | 1214 | throw new Exception\WrongUserinput('no certificate found to sign the messase'); |
| 1152 | 1215 | } |
| 1153 | - if (Cache::getSession('mail', 'smime_passphrase')) $params['passphrase'] = Cache::getSession('mail', 'smime_passphrase'); |
|
| 1216 | + if (Cache::getSession('mail', 'smime_passphrase')) |
|
| 1217 | + { |
|
| 1218 | + $params['passphrase'] = Cache::getSession('mail', 'smime_passphrase'); |
|
| 1219 | + } |
|
| 1154 | 1220 | if (!$smime->verifyPassphrase($params['senderPrivKey'], $params['passphrase'])) |
| 1155 | 1221 | { |
| 1156 | 1222 | return false; |
@@ -324,44 +324,44 @@ discard block |
||
| 324 | 324 | return $folderlist; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - /** |
|
| 328 | - * Sends a message which is passed as rfc822. You basically can do two things |
|
| 329 | - * 1) Send the message to an SMTP server as-is |
|
| 330 | - * 2) Parse the message yourself, and send it some other way |
|
| 331 | - * It is up to you whether you want to put the message in the sent items folder. If you |
|
| 332 | - * want it in 'sent items', then the next sync on the 'sent items' folder should return |
|
| 333 | - * the new message as any other new message in a folder. |
|
| 334 | - * |
|
| 335 | - * @param array $smartdata = IMAP-SendMail: SyncSendMail ( |
|
| 336 | - * (S) clientid => SendMail-30722448149304 |
|
| 337 | - * (S) saveinsent => empty |
|
| 338 | - * (S) replacemime => null |
|
| 339 | - * (S) accountid => null |
|
| 340 | - * (S) source => SyncSendMailSource ( |
|
| 341 | - * (S) folderid => 101000000000 |
|
| 342 | - * (S) itemid => 33776 |
|
| 343 | - * (S) longid => null |
|
| 344 | - * (S) instanceid => null |
|
| 345 | - * unsetVars(Array) size: 0 |
|
| 346 | - * flags => false |
|
| 347 | - * content => null |
|
| 348 | - * ) |
|
| 349 | - * (S) mime => Date: Tue, 23 Jun 2015 14:13:23 +0200 |
|
| 350 | - *Subject: AW: Blauer himmel |
|
| 351 | - *.... |
|
| 352 | - * (S) replyflag => true |
|
| 353 | - * (S) forwardflag => null |
|
| 354 | - * unsetVars(Array) size: 0 |
|
| 355 | - * flags => false |
|
| 356 | - * content => null |
|
| 357 | - *) |
|
| 327 | + /** |
|
| 328 | + * Sends a message which is passed as rfc822. You basically can do two things |
|
| 329 | + * 1) Send the message to an SMTP server as-is |
|
| 330 | + * 2) Parse the message yourself, and send it some other way |
|
| 331 | + * It is up to you whether you want to put the message in the sent items folder. If you |
|
| 332 | + * want it in 'sent items', then the next sync on the 'sent items' folder should return |
|
| 333 | + * the new message as any other new message in a folder. |
|
| 334 | + * |
|
| 335 | + * @param array $smartdata = IMAP-SendMail: SyncSendMail ( |
|
| 336 | + * (S) clientid => SendMail-30722448149304 |
|
| 337 | + * (S) saveinsent => empty |
|
| 338 | + * (S) replacemime => null |
|
| 339 | + * (S) accountid => null |
|
| 340 | + * (S) source => SyncSendMailSource ( |
|
| 341 | + * (S) folderid => 101000000000 |
|
| 342 | + * (S) itemid => 33776 |
|
| 343 | + * (S) longid => null |
|
| 344 | + * (S) instanceid => null |
|
| 345 | + * unsetVars(Array) size: 0 |
|
| 346 | + * flags => false |
|
| 347 | + * content => null |
|
| 348 | + * ) |
|
| 349 | + * (S) mime => Date: Tue, 23 Jun 2015 14:13:23 +0200 |
|
| 350 | + *Subject: AW: Blauer himmel |
|
| 351 | + *.... |
|
| 352 | + * (S) replyflag => true |
|
| 353 | + * (S) forwardflag => null |
|
| 354 | + * unsetVars(Array) size: 0 |
|
| 355 | + * flags => false |
|
| 356 | + * content => null |
|
| 357 | + *) |
|
| 358 | + * |
|
| 359 | + * @return boolean true on success, false on error |
|
| 358 | 360 | * |
| 359 | - * @return boolean true on success, false on error |
|
| 360 | - * |
|
| 361 | - * @see eg. BackendIMAP::SendMail() |
|
| 362 | - * @todo implement either here or in mail backend |
|
| 363 | - * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
|
| 364 | - */ |
|
| 361 | + * @see eg. BackendIMAP::SendMail() |
|
| 362 | + * @todo implement either here or in mail backend |
|
| 363 | + * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
|
| 364 | + */ |
|
| 365 | 365 | public function SendMail($smartdata) |
| 366 | 366 | { |
| 367 | 367 | //$this->debugLevel=2; |
@@ -508,8 +508,8 @@ discard block |
||
| 508 | 508 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 509 | 509 | // if this is a multipart message with a boundary, we must use the original body |
| 510 | 510 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 511 | - if ($use_orgbody) { |
|
| 512 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 511 | + if ($use_orgbody) { |
|
| 512 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 513 | 513 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 514 | 514 | if (($cal_body = $mailObject->findBody('calendar')) && |
| 515 | 515 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
| 522 | 522 | $ClientSideMeetingRequest = true; |
| 523 | 523 | } |
| 524 | - } |
|
| 524 | + } |
|
| 525 | 525 | // now handle the addressee list |
| 526 | 526 | $toCount = 0; |
| 527 | 527 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 587 | 587 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 588 | 588 | if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
| 589 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 589 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 590 | 590 | // may be html |
| 591 | 591 | if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
| 592 | 592 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 634 | 634 | |
| 635 | 635 | $this->mail->reopen($folder); |
| 636 | - // receive entire mail (header + body) |
|
| 636 | + // receive entire mail (header + body) |
|
| 637 | 637 | // get message headers for specified message |
| 638 | 638 | $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
| 639 | 639 | // build a new mime message, forward entire old mail as file |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | } |
| 721 | 721 | //advanced debugging |
| 722 | 722 | // Horde SMTP Class uses utf-8 by default. |
| 723 | - //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
| 723 | + //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
| 724 | 724 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
| 725 | 725 | |
| 726 | 726 | // set a higher timeout for big messages |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | //$asf = false; |
| 815 | 815 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
| 816 | 816 | } |
| 817 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 817 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 818 | 818 | } |
| 819 | 819 | //$this->mail->closeConnection(); |
| 820 | 820 | } |
@@ -1157,8 +1157,8 @@ discard block |
||
| 1157 | 1157 | // end handle Attachments |
| 1158 | 1158 | unset($attachments); |
| 1159 | 1159 | |
| 1160 | - // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
|
| 1161 | - $output->internetcpid = INTERNET_CPID_UTF8; |
|
| 1160 | + // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
|
| 1161 | + $output->internetcpid = INTERNET_CPID_UTF8; |
|
| 1162 | 1162 | |
| 1163 | 1163 | if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
| 1164 | 1164 | //$this->debugLevel=0; |
@@ -1216,8 +1216,8 @@ discard block |
||
| 1216 | 1216 | * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should |
| 1217 | 1217 | * encode any information you need to find the attachment in that 'attname' property. |
| 1218 | 1218 | * |
| 1219 | - * @param string $fid - id |
|
| 1220 | - * @param string $attname - should contain (folder)id |
|
| 1219 | + * @param string $fid - id |
|
| 1220 | + * @param string $attname - should contain (folder)id |
|
| 1221 | 1221 | * @return SyncItemOperationsAttachment-object |
| 1222 | 1222 | */ |
| 1223 | 1223 | function GetAttachmentData($fid,$attname) { |
@@ -1231,8 +1231,8 @@ discard block |
||
| 1231 | 1231 | * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should |
| 1232 | 1232 | * encode any information you need to find the attachment in that 'attname' property. |
| 1233 | 1233 | * |
| 1234 | - * @param string $fid - id |
|
| 1235 | - * @param string $attname - should contain (folder)id |
|
| 1234 | + * @param string $fid - id |
|
| 1235 | + * @param string $attname - should contain (folder)id |
|
| 1236 | 1236 | * @return SyncItemOperationsAttachment-object |
| 1237 | 1237 | */ |
| 1238 | 1238 | function ItemOperationsGetAttachmentData($fid,$attname) { |
@@ -1245,8 +1245,8 @@ discard block |
||
| 1245 | 1245 | * -ItemOperationsGetAttachmentData |
| 1246 | 1246 | * -GetAttachmentData |
| 1247 | 1247 | * |
| 1248 | - * @param string $fid - id |
|
| 1249 | - * @param string $attname - should contain (folder)id |
|
| 1248 | + * @param string $fid - id |
|
| 1249 | + * @param string $attname - should contain (folder)id |
|
| 1250 | 1250 | * @return SyncItemOperationsAttachment-object |
| 1251 | 1251 | */ |
| 1252 | 1252 | private function _GetAttachmentData($fid,$attname) |
@@ -1800,22 +1800,22 @@ discard block |
||
| 1800 | 1800 | return $id; |
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | - /** |
|
| 1804 | - * Called when the user has requested to delete (really delete) a message. Usually |
|
| 1805 | - * this means just unlinking the file its in or somesuch. After this call has succeeded, a call to |
|
| 1806 | - * GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile |
|
| 1807 | - * as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to |
|
| 1808 | - * delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile |
|
| 1809 | - * |
|
| 1810 | - * @param string $folderid id of the folder |
|
| 1811 | - * @param string $id id of the message |
|
| 1812 | - * @param ContentParameters $contentParameters |
|
| 1813 | - * |
|
| 1814 | - * @access public |
|
| 1815 | - * @return boolean status of the operation |
|
| 1816 | - * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
| 1817 | - */ |
|
| 1818 | - public function DeleteMessage($folderid, $id, $contentParameters) |
|
| 1803 | + /** |
|
| 1804 | + * Called when the user has requested to delete (really delete) a message. Usually |
|
| 1805 | + * this means just unlinking the file its in or somesuch. After this call has succeeded, a call to |
|
| 1806 | + * GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile |
|
| 1807 | + * as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to |
|
| 1808 | + * delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile |
|
| 1809 | + * |
|
| 1810 | + * @param string $folderid id of the folder |
|
| 1811 | + * @param string $id id of the message |
|
| 1812 | + * @param ContentParameters $contentParameters |
|
| 1813 | + * |
|
| 1814 | + * @access public |
|
| 1815 | + * @return boolean status of the operation |
|
| 1816 | + * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
| 1817 | + */ |
|
| 1818 | + public function DeleteMessage($folderid, $id, $contentParameters) |
|
| 1819 | 1819 | { |
| 1820 | 1820 | unset($contentParameters); // not used, but required by function signature |
| 1821 | 1821 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
@@ -1857,24 +1857,24 @@ discard block |
||
| 1857 | 1857 | return $rv; |
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | - /** |
|
| 1861 | - * Changes the 'read' flag of a message on disk. The $flags |
|
| 1862 | - * parameter can only be '1' (read) or '0' (unread). After a call to |
|
| 1863 | - * SetReadFlag(), GetMessageList() should return the message with the |
|
| 1864 | - * new 'flags' but should not modify the 'mod' parameter. If you do |
|
| 1865 | - * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
| 1866 | - * a full resync of the item from the server. |
|
| 1867 | - * |
|
| 1868 | - * @param string $folderid id of the folder |
|
| 1869 | - * @param string $id id of the message |
|
| 1870 | - * @param int $flags read flag of the message |
|
| 1871 | - * @param ContentParameters $contentParameters |
|
| 1872 | - * |
|
| 1873 | - * @access public |
|
| 1874 | - * @return boolean status of the operation |
|
| 1875 | - * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
| 1876 | - */ |
|
| 1877 | - public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
|
| 1860 | + /** |
|
| 1861 | + * Changes the 'read' flag of a message on disk. The $flags |
|
| 1862 | + * parameter can only be '1' (read) or '0' (unread). After a call to |
|
| 1863 | + * SetReadFlag(), GetMessageList() should return the message with the |
|
| 1864 | + * new 'flags' but should not modify the 'mod' parameter. If you do |
|
| 1865 | + * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
| 1866 | + * a full resync of the item from the server. |
|
| 1867 | + * |
|
| 1868 | + * @param string $folderid id of the folder |
|
| 1869 | + * @param string $id id of the message |
|
| 1870 | + * @param int $flags read flag of the message |
|
| 1871 | + * @param ContentParameters $contentParameters |
|
| 1872 | + * |
|
| 1873 | + * @access public |
|
| 1874 | + * @return boolean status of the operation |
|
| 1875 | + * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
| 1876 | + */ |
|
| 1877 | + public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
|
| 1878 | 1878 | { |
| 1879 | 1879 | unset($contentParameters); // not used, but required by function signature |
| 1880 | 1880 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
@@ -84,29 +84,47 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function __construct(activesync_backend $backend) |
| 86 | 86 | { |
| 87 | - if ($GLOBALS['egw_setup']) return; |
|
| 87 | + if ($GLOBALS['egw_setup']) |
|
| 88 | + { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | //$this->debugLevel=2; |
| 90 | 93 | $this->backend = $backend; |
| 91 | 94 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 92 | 95 | { |
| 93 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 96 | + if ($this->debugLevel>1) |
|
| 97 | + { |
|
| 98 | + error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 99 | + } |
|
| 94 | 100 | // globals preferences add appname varname value |
| 95 | 101 | $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
| 96 | 102 | // save prefs |
| 97 | 103 | $GLOBALS['egw']->preferences->save_repository(true); |
| 98 | 104 | } |
| 99 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 105 | + if ($this->debugLevel>1) |
|
| 106 | + { |
|
| 107 | + error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 108 | + } |
|
| 100 | 109 | |
| 101 | 110 | if (is_null(self::$profileID)) |
| 102 | 111 | { |
| 103 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 112 | + if ($this->debugLevel>1) |
|
| 113 | + { |
|
| 114 | + error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 115 | + } |
|
| 104 | 116 | self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
| 105 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 117 | + if ($this->debugLevel>1) |
|
| 118 | + { |
|
| 119 | + error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 120 | + } |
|
| 106 | 121 | } |
| 107 | 122 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 108 | 123 | { |
| 109 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 124 | + if ($this->debugLevel>1) |
|
| 125 | + { |
|
| 126 | + error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 127 | + } |
|
| 110 | 128 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
| 111 | 129 | { |
| 112 | 130 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -116,7 +134,10 @@ discard block |
||
| 116 | 134 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
| 117 | 135 | } |
| 118 | 136 | } |
| 119 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 137 | + if ($this->debugLevel>1) |
|
| 138 | + { |
|
| 139 | + error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 140 | + } |
|
| 120 | 141 | |
| 121 | 142 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
| 122 | 143 | if (!isset($GLOBALS['egw_setup'])) |
@@ -129,7 +150,10 @@ discard block |
||
| 129 | 150 | self::$profileID = Mail\Account::get_default_acc_id(); |
| 130 | 151 | } |
| 131 | 152 | } |
| 132 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 153 | + if ($this->debugLevel>0) |
|
| 154 | + { |
|
| 155 | + error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 156 | + } |
|
| 133 | 157 | //$this->debugLevel=0; |
| 134 | 158 | } |
| 135 | 159 | |
@@ -245,8 +269,14 @@ discard block |
||
| 245 | 269 | $this->_connect(0,true); |
| 246 | 270 | $this->_disconnect(); |
| 247 | 271 | |
| 248 | - if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 249 | - if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 272 | + if (!$this->_wasteID) |
|
| 273 | + { |
|
| 274 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
| 275 | + } |
|
| 276 | + if (!$this->_sentID) |
|
| 277 | + { |
|
| 278 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
| 279 | + } |
|
| 250 | 280 | } |
| 251 | 281 | catch(Exception $e) { |
| 252 | 282 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
@@ -268,8 +298,14 @@ discard block |
||
| 268 | 298 | */ |
| 269 | 299 | private function _connect($account=0) |
| 270 | 300 | { |
| 271 | - if (!$account) $account = self::$profileID ? self::$profileID : 0; |
|
| 272 | - if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
| 301 | + if (!$account) |
|
| 302 | + { |
|
| 303 | + $account = self::$profileID ? self::$profileID : 0; |
|
| 304 | + } |
|
| 305 | + if ($this->mail && $this->account != $account) |
|
| 306 | + { |
|
| 307 | + $this->_disconnect(); |
|
| 308 | + } |
|
| 273 | 309 | |
| 274 | 310 | $this->_wasteID = false; |
| 275 | 311 | $this->_sentID = false; |
@@ -280,12 +316,18 @@ discard block |
||
| 280 | 316 | // todo: tell mail which account to use |
| 281 | 317 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 282 | 318 | $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
| 283 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 319 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 320 | + { |
|
| 321 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 322 | + } |
|
| 284 | 323 | } |
| 285 | 324 | else |
| 286 | 325 | { |
| 287 | 326 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 288 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 327 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
| 328 | + { |
|
| 329 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
| 330 | + } |
|
| 289 | 331 | } |
| 290 | 332 | $this->mail->openConnection(self::$profileID,false); |
| 291 | 333 | |
@@ -302,8 +344,14 @@ discard block |
||
| 302 | 344 | */ |
| 303 | 345 | private function _disconnect() |
| 304 | 346 | { |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 306 | - if ($this->mail) $this->mail->closeConnection(); |
|
| 347 | + if ($this->debugLevel>0) |
|
| 348 | + { |
|
| 349 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 350 | + } |
|
| 351 | + if ($this->mail) |
|
| 352 | + { |
|
| 353 | + $this->mail->closeConnection(); |
|
| 354 | + } |
|
| 307 | 355 | |
| 308 | 356 | unset($this->mail); |
| 309 | 357 | unset($this->account); |
@@ -318,24 +366,43 @@ discard block |
||
| 318 | 366 | public function GetFolderList() |
| 319 | 367 | { |
| 320 | 368 | $folderlist = array(); |
| 321 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 369 | + if ($this->debugLevel>0) |
|
| 370 | + { |
|
| 371 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 372 | + } |
|
| 322 | 373 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 323 | 374 | { |
| 324 | 375 | $this->_connect($account); |
| 325 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 326 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 376 | + if (!isset($this->folders)) |
|
| 377 | + { |
|
| 378 | + $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 379 | + } |
|
| 380 | + if ($this->debugLevel>1) |
|
| 381 | + { |
|
| 382 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 383 | + } |
|
| 327 | 384 | |
| 328 | - foreach ($this->folders as $folder => $folderObj) { |
|
| 329 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 385 | + foreach ($this->folders as $folder => $folderObj) |
|
| 386 | + { |
|
| 387 | + if ($this->debugLevel>1) |
|
| 388 | + { |
|
| 389 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 390 | + } |
|
| 330 | 391 | $folderlist[] = $f = array( |
| 331 | 392 | 'id' => $this->createID($account,$folder), |
| 332 | 393 | 'mod' => $folderObj->shortDisplayName, |
| 333 | 394 | 'parent' => $this->getParentID($account,$folder), |
| 334 | 395 | ); |
| 335 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 396 | + if ($this->debugLevel>1) |
|
| 397 | + { |
|
| 398 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 399 | + } |
|
| 336 | 400 | } |
| 337 | 401 | } |
| 338 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 402 | + if ($this->debugLevel>0) |
|
| 403 | + { |
|
| 404 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 405 | + } |
|
| 339 | 406 | |
| 340 | 407 | return $folderlist; |
| 341 | 408 | } |
@@ -396,11 +463,17 @@ discard block |
||
| 396 | 463 | $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
| 397 | 464 | |
| 398 | 465 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
| 399 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 466 | + if ($this->debugLevel>0) |
|
| 467 | + { |
|
| 468 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 469 | + } |
|
| 400 | 470 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 401 | 471 | |
| 402 | 472 | // initialize our Mail |
| 403 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 473 | + if (!isset($this->mail)) |
|
| 474 | + { |
|
| 475 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 476 | + } |
|
| 404 | 477 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 405 | 478 | // use the standardIdentity |
| 406 | 479 | $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
@@ -428,12 +501,18 @@ discard block |
||
| 428 | 501 | $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
| 429 | 502 | $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
| 430 | 503 | $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
| 431 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 504 | + if ($this->debugLevel>0) |
|
| 505 | + { |
|
| 506 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 507 | + } |
|
| 432 | 508 | $sigTextHtml = $beforeHtml.$sigText; |
| 433 | 509 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 434 | 510 | |
| 435 | 511 | $force8bit=false; |
| 436 | - if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
| 512 | + if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') |
|
| 513 | + { |
|
| 514 | + $force8bit=true; |
|
| 515 | + } |
|
| 437 | 516 | // beware. the section below might cause trouble regarding bcc and attachments, so maybe this is to be handeled differently |
| 438 | 517 | if ($force8bit) |
| 439 | 518 | { |
@@ -451,22 +530,34 @@ discard block |
||
| 451 | 530 | |
| 452 | 531 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 453 | 532 | // to |
| 454 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 455 | - if (!$addressObject->valid) continue; |
|
| 533 | + foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) |
|
| 534 | + { |
|
| 535 | + if (!$addressObject->valid) |
|
| 536 | + { |
|
| 537 | + continue; |
|
| 538 | + } |
|
| 456 | 539 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
| 457 | 540 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 458 | 541 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 459 | 542 | } |
| 460 | 543 | // CC |
| 461 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 462 | - if (!$addressObject->valid) continue; |
|
| 544 | + foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) |
|
| 545 | + { |
|
| 546 | + if (!$addressObject->valid) |
|
| 547 | + { |
|
| 548 | + continue; |
|
| 549 | + } |
|
| 463 | 550 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
| 464 | 551 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 465 | 552 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 466 | 553 | } |
| 467 | 554 | // BCC |
| 468 | - foreach($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 469 | - if (!$addressObject->valid) continue; |
|
| 555 | + foreach($mailObject->getAddresses('bcc') as $addressObject) |
|
| 556 | + { |
|
| 557 | + if (!$addressObject->valid) |
|
| 558 | + { |
|
| 559 | + continue; |
|
| 560 | + } |
|
| 470 | 561 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
| 471 | 562 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 472 | 563 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
@@ -479,12 +570,14 @@ discard block |
||
| 479 | 570 | $ContentType =$mailObject->getHeader('Content-Type'); |
| 480 | 571 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 481 | 572 | // if the message is a multipart message, then we should use the sent body |
| 482 | - if (preg_match("/multipart/i", $ContentType)) { |
|
| 573 | + if (preg_match("/multipart/i", $ContentType)) |
|
| 574 | + { |
|
| 483 | 575 | $use_orgbody = true; |
| 484 | 576 | } |
| 485 | 577 | |
| 486 | 578 | // save the original content-type header for the body part when forwarding |
| 487 | - if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) { |
|
| 579 | + if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) |
|
| 580 | + { |
|
| 488 | 581 | //continue; // ignore |
| 489 | 582 | } |
| 490 | 583 | // horde/egw_ mailer does everything as utf-8, the following should not be needed |
@@ -493,7 +586,8 @@ discard block |
||
| 493 | 586 | // if the message is a multipart message, then we should use the sent body |
| 494 | 587 | if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') && |
| 495 | 588 | ((isset($smartdata->replacemime) && $smartdata->replacemime == true) || |
| 496 | - $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
| 589 | + $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) |
|
| 590 | + { |
|
| 497 | 591 | $use_orgbody = true; |
| 498 | 592 | } |
| 499 | 593 | $Body = $AltBody = ""; |
@@ -526,12 +620,19 @@ discard block |
||
| 526 | 620 | $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
| 527 | 621 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 528 | 622 | } |
| 529 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 530 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 623 | + if ($this->debugLevel>1 && $Body) |
|
| 624 | + { |
|
| 625 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 626 | + } |
|
| 627 | + if ($this->debugLevel>1 && $AltBody) |
|
| 628 | + { |
|
| 629 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 630 | + } |
|
| 531 | 631 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 532 | 632 | // if this is a multipart message with a boundary, we must use the original body |
| 533 | 633 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 534 | - if ($use_orgbody) { |
|
| 634 | + if ($use_orgbody) |
|
| 635 | + { |
|
| 535 | 636 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
| 536 | 637 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 537 | 638 | if (($cal_body = $mailObject->findBody('calendar')) && |
@@ -541,15 +642,20 @@ discard block |
||
| 541 | 642 | { |
| 542 | 643 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 543 | 644 | } |
| 544 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 645 | + if ($this->debugLevel) |
|
| 646 | + { |
|
| 647 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 648 | + } |
|
| 545 | 649 | $ClientSideMeetingRequest = true; |
| 546 | 650 | } |
| 547 | 651 | } |
| 548 | 652 | // now handle the addressee list |
| 549 | 653 | $toCount = 0; |
| 550 | 654 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 551 | - foreach((array)$toMailAddr as $address) { |
|
| 552 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 655 | + foreach((array)$toMailAddr as $address) |
|
| 656 | + { |
|
| 657 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 658 | + { |
|
| 553 | 659 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 554 | 660 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 555 | 661 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
@@ -563,19 +669,29 @@ discard block |
||
| 563 | 669 | } |
| 564 | 670 | } |
| 565 | 671 | $ccCount = 0; |
| 566 | - foreach((array)$ccMailAddr as $address) { |
|
| 567 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 672 | + foreach((array)$ccMailAddr as $address) |
|
| 673 | + { |
|
| 674 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 675 | + { |
|
| 568 | 676 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 569 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 677 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 678 | + { |
|
| 679 | + continue; |
|
| 680 | + } |
|
| 570 | 681 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 571 | 682 | $ccCount++; |
| 572 | 683 | } |
| 573 | 684 | } |
| 574 | 685 | $bccCount = 0; |
| 575 | - foreach((array)$bccMailAddr as $address) { |
|
| 576 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 686 | + foreach((array)$bccMailAddr as $address) |
|
| 687 | + { |
|
| 688 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 689 | + { |
|
| 577 | 690 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 578 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
| 691 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
| 692 | + { |
|
| 693 | + continue; |
|
| 694 | + } |
|
| 579 | 695 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 580 | 696 | $bccCount++; |
| 581 | 697 | } |
@@ -585,7 +701,10 @@ discard block |
||
| 585 | 701 | { |
| 586 | 702 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 587 | 703 | } |
| 588 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 704 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) |
|
| 705 | + { |
|
| 706 | + return true; |
|
| 707 | + } |
|
| 589 | 708 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 590 | 709 | /* |
| 591 | 710 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -608,10 +727,17 @@ discard block |
||
| 608 | 727 | $this->mail->reopen($folder); |
| 609 | 728 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 610 | 729 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 611 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 612 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 730 | + if ($this->debugLevel>3) |
|
| 731 | + { |
|
| 732 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 733 | + } |
|
| 734 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 735 | + { |
|
| 613 | 736 | // may be html |
| 614 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 737 | + if ($this->debugLevel>0) |
|
| 738 | + { |
|
| 739 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 740 | + } |
|
| 615 | 741 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 616 | 742 | $isreply = true; |
| 617 | 743 | } |
@@ -620,8 +746,12 @@ discard block |
||
| 620 | 746 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 621 | 747 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 622 | 748 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 623 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 624 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 749 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 750 | + { |
|
| 751 | + if ($this->debugLevel>0) |
|
| 752 | + { |
|
| 753 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 754 | + } |
|
| 625 | 755 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 626 | 756 | $isreply = true; |
| 627 | 757 | } |
@@ -629,7 +759,10 @@ discard block |
||
| 629 | 759 | { |
| 630 | 760 | $isreply = true; |
| 631 | 761 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 632 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 762 | + if ($this->debugLevel>0) |
|
| 763 | + { |
|
| 764 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 765 | + } |
|
| 633 | 766 | } |
| 634 | 767 | } |
| 635 | 768 | |
@@ -643,11 +776,17 @@ discard block |
||
| 643 | 776 | (isset($smartdata->replacemime) && $smartdata->replacemime == false))) |
| 644 | 777 | { |
| 645 | 778 | //force the default for the forwarding -> asmail |
| 646 | - if (is_array($preferencesArray)) { |
|
| 779 | + if (is_array($preferencesArray)) |
|
| 780 | + { |
|
| 647 | 781 | if (!array_key_exists('message_forwarding',$preferencesArray) |
| 648 | 782 | || !isset($preferencesArray['message_forwarding']) |
| 649 | - || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 650 | - } else { |
|
| 783 | + || empty($preferencesArray['message_forwarding'])) |
|
| 784 | + { |
|
| 785 | + $preferencesArray['message_forwarding'] = 'asmail'; |
|
| 786 | + } |
|
| 787 | + } |
|
| 788 | + else |
|
| 789 | + { |
|
| 651 | 790 | $preferencesArray['message_forwarding'] = 'asmail'; |
| 652 | 791 | } |
| 653 | 792 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
@@ -679,27 +818,44 @@ discard block |
||
| 679 | 818 | $this->mail->reopen($folder); |
| 680 | 819 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 681 | 820 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 682 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 683 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 821 | + if ($this->debugLevel>0) |
|
| 822 | + { |
|
| 823 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 824 | + } |
|
| 825 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 826 | + { |
|
| 684 | 827 | // may be html |
| 685 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 828 | + if ($this->debugLevel>0) |
|
| 829 | + { |
|
| 830 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 831 | + } |
|
| 686 | 832 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 687 | 833 | $isforward = true; |
| 688 | 834 | } |
| 689 | 835 | // plain text Message part |
| 690 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 836 | + if ($this->debugLevel>0) |
|
| 837 | + { |
|
| 838 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 839 | + } |
|
| 691 | 840 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 692 | 841 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
| 693 | 842 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 694 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 695 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 843 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
| 844 | + { |
|
| 845 | + if ($this->debugLevel>0) |
|
| 846 | + { |
|
| 847 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 848 | + } |
|
| 696 | 849 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 697 | 850 | $isforward = true; |
| 698 | 851 | } |
| 699 | 852 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 700 | 853 | { |
| 701 | 854 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 702 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 855 | + if ($this->debugLevel>0) |
|
| 856 | + { |
|
| 857 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 858 | + } |
|
| 703 | 859 | $isforward = true; |
| 704 | 860 | } |
| 705 | 861 | // get all the attachments and add them too. |
@@ -712,7 +868,10 @@ discard block |
||
| 712 | 868 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
| 713 | 869 | foreach((array)$attachments as $key => $attachment) |
| 714 | 870 | { |
| 715 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 871 | + if ($this->debugLevel>0) |
|
| 872 | + { |
|
| 873 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 874 | + } |
|
| 716 | 875 | $attachmentNames .= $attachment['name']."\n"; |
| 717 | 876 | $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
| 718 | 877 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
@@ -731,20 +890,29 @@ discard block |
||
| 731 | 890 | // now set the body |
| 732 | 891 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 733 | 892 | { |
| 734 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 893 | + if ($this->debugLevel>1) |
|
| 894 | + { |
|
| 895 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 896 | + } |
|
| 735 | 897 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 736 | 898 | $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 737 | 899 | } |
| 738 | 900 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 739 | 901 | { |
| 740 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 902 | + if ($this->debugLevel>1) |
|
| 903 | + { |
|
| 904 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 905 | + } |
|
| 741 | 906 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 742 | 907 | $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
| 743 | 908 | } |
| 744 | 909 | //advanced debugging |
| 745 | 910 | // Horde SMTP Class uses utf-8 by default. |
| 746 | 911 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 747 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 912 | + if ($this->debugLevel>2) |
|
| 913 | + { |
|
| 914 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 915 | + } |
|
| 748 | 916 | |
| 749 | 917 | // set a higher timeout for big messages |
| 750 | 918 | @set_time_limit(120); |
@@ -771,7 +939,9 @@ discard block |
||
| 771 | 939 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 772 | 940 | { |
| 773 | 941 | $this->mail->deleteMessages(array($uid),$folder); |
| 774 | - } else { |
|
| 942 | + } |
|
| 943 | + else |
|
| 944 | + { |
|
| 775 | 945 | $this->mail->flagMessages("answered", array($uid),$folder); |
| 776 | 946 | if ($smartdata_task== "forward") |
| 777 | 947 | { |
@@ -785,7 +955,8 @@ discard block |
||
| 785 | 955 | { |
| 786 | 956 | $asf = false; |
| 787 | 957 | $sentFolder = $this->mail->getSentFolder(); |
| 788 | - if ($this->_sentID) { |
|
| 958 | + if ($this->_sentID) |
|
| 959 | + { |
|
| 789 | 960 | $folderArray[] = $this->_sentID; |
| 790 | 961 | } |
| 791 | 962 | else if(isset($sentFolder) && $sentFolder != 'none') |
@@ -799,28 +970,41 @@ discard block |
||
| 799 | 970 | // we dont try guessing |
| 800 | 971 | $asf = true; |
| 801 | 972 | } |
| 802 | - if (count($folderArray) > 0) { |
|
| 803 | - foreach((array)$bccMailAddr as $address) { |
|
| 804 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 973 | + if (count($folderArray) > 0) |
|
| 974 | + { |
|
| 975 | + foreach((array)$bccMailAddr as $address) |
|
| 976 | + { |
|
| 977 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
| 978 | + { |
|
| 805 | 979 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
| 806 | 980 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 807 | 981 | } |
| 808 | 982 | } |
| 809 | 983 | //$BCCmail=''; |
| 810 | - if (count($mailAddr)>0) $mailObject->forceBccHeader(); |
|
| 984 | + if (count($mailAddr)>0) |
|
| 985 | + { |
|
| 986 | + $mailObject->forceBccHeader(); |
|
| 987 | + } |
|
| 811 | 988 | //$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
| 812 | - foreach($folderArray as $folderName) { |
|
| 813 | - if($this->mail->isSentFolder($folderName)) { |
|
| 989 | + foreach($folderArray as $folderName) |
|
| 990 | + { |
|
| 991 | + if($this->mail->isSentFolder($folderName)) |
|
| 992 | + { |
|
| 814 | 993 | $flags = '\\Seen'; |
| 815 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 994 | + } |
|
| 995 | + elseif($this->mail->isDraftFolder($folderName)) |
|
| 996 | + { |
|
| 816 | 997 | $flags = '\\Draft'; |
| 817 | - } else { |
|
| 998 | + } |
|
| 999 | + else |
|
| 1000 | + { |
|
| 818 | 1001 | $flags = ''; |
| 819 | 1002 | } |
| 820 | 1003 | $asf = true; |
| 821 | 1004 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 822 | 1005 | $this->mail->openConnection(self::$profileID,false); |
| 823 | - if ($this->mail->folderExists($folderName)) { |
|
| 1006 | + if ($this->mail->folderExists($folderName)) |
|
| 1007 | + { |
|
| 824 | 1008 | try |
| 825 | 1009 | { |
| 826 | 1010 | $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
@@ -878,17 +1062,26 @@ discard block |
||
| 878 | 1062 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 879 | 1063 | |
| 880 | 1064 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 881 | - if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
|
| 1065 | + if (!$mimesupport && ($key = array_search('4', $bodypreference))) |
|
| 1066 | + { |
|
| 1067 | + unset($bodypreference[$key]); |
|
| 1068 | + } |
|
| 882 | 1069 | |
| 883 | 1070 | //$this->debugLevel=4; |
| 884 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1071 | + if (!isset($this->mail)) |
|
| 1072 | + { |
|
| 1073 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1074 | + } |
|
| 885 | 1075 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
| 886 | 1076 | $account = $_folderName = $xid = null; |
| 887 | 1077 | $this->splitID($folderid,$account,$_folderName,$xid); |
| 888 | 1078 | $this->mail->reopen($_folderName); |
| 889 | 1079 | $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
| 890 | 1080 | $headers = $messages[$id]; |
| 891 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1081 | + if ($this->debugLevel>3) |
|
| 1082 | + { |
|
| 1083 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 1084 | + } |
|
| 892 | 1085 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 893 | 1086 | if ($headers) |
| 894 | 1087 | { |
@@ -898,16 +1091,25 @@ discard block |
||
| 898 | 1091 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 899 | 1092 | // simple style |
| 900 | 1093 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 901 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1094 | + if ($this->debugLevel>0) |
|
| 1095 | + { |
|
| 1096 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 1097 | + } |
|
| 902 | 1098 | |
| 903 | - if ($bodypreference === false) { |
|
| 1099 | + if ($bodypreference === false) |
|
| 1100 | + { |
|
| 904 | 1101 | $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
| 905 | 1102 | $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 906 | 1103 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 907 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 1104 | + if (stripos($raw_body,'<style')!==false) |
|
| 1105 | + { |
|
| 1106 | + $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); |
|
| 1107 | + } |
|
| 1108 | + // in case there is only a html part |
|
| 908 | 1109 | // remove all other html |
| 909 | 1110 | $body = strip_tags($raw_body); |
| 910 | - if(strlen($body) > $truncsize) { |
|
| 1111 | + if(strlen($body) > $truncsize) |
|
| 1112 | + { |
|
| 911 | 1113 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 912 | 1114 | $output->bodytruncated = 1; |
| 913 | 1115 | } |
@@ -922,7 +1124,8 @@ discard block |
||
| 922 | 1124 | { |
| 923 | 1125 | //Select body type preference |
| 924 | 1126 | $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
| 925 | - if ($bodypreference !== false) { |
|
| 1127 | + if ($bodypreference !== false) |
|
| 1128 | + { |
|
| 926 | 1129 | // bodypreference can occur multiple times |
| 927 | 1130 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
| 928 | 1131 | $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -956,25 +1159,49 @@ discard block |
||
| 956 | 1159 | // fetch the body (try to gather data only once) |
| 957 | 1160 | $css =''; |
| 958 | 1161 | $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
| 959 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1162 | + if ($this->debugLevel>2) |
|
| 1163 | + { |
|
| 1164 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 1165 | + } |
|
| 960 | 1166 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
| 961 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 962 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 1167 | + if ($this->debugLevel>3) |
|
| 1168 | + { |
|
| 1169 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 1170 | + } |
|
| 1171 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
| 1172 | + { |
|
| 963 | 1173 | // may be html |
| 964 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1174 | + if ($this->debugLevel>0) |
|
| 1175 | + { |
|
| 1176 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 1177 | + } |
|
| 965 | 1178 | $css = $this->mail->getStyles($bodyStruct); |
| 966 | 1179 | $output->nativebodytype=2; |
| 967 | - } else { |
|
| 1180 | + } |
|
| 1181 | + else |
|
| 1182 | + { |
|
| 968 | 1183 | // plain text Message |
| 969 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1184 | + if ($this->debugLevel>0) |
|
| 1185 | + { |
|
| 1186 | + ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 1187 | + } |
|
| 970 | 1188 | $output->nativebodytype=1; |
| 971 | 1189 | $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
| 972 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1190 | + if ($this->debugLevel>3) |
|
| 1191 | + { |
|
| 1192 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 1193 | + } |
|
| 973 | 1194 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
| 974 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1195 | + if ($this->debugLevel>3) |
|
| 1196 | + { |
|
| 1197 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 1198 | + } |
|
| 975 | 1199 | } |
| 976 | 1200 | // whatever format decode (using the correct encoding) |
| 977 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1201 | + if ($this->debugLevel>3) |
|
| 1202 | + { |
|
| 1203 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 1204 | + } |
|
| 978 | 1205 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 979 | 1206 | // prepare plaintextbody |
| 980 | 1207 | $plainBody=''; |
@@ -995,12 +1222,18 @@ discard block |
||
| 995 | 1222 | // remove all other html |
| 996 | 1223 | $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
| 997 | 1224 | $plainBody = strip_tags($plainBody); |
| 998 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1225 | + if ($this->debugLevel>3 && $output->nativebodytype==1) |
|
| 1226 | + { |
|
| 1227 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 1228 | + } |
|
| 999 | 1229 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 1000 | 1230 | |
| 1001 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 1231 | + if ($bpReturnType==2) |
|
| 1232 | + { |
|
| 1233 | + //SYNC_BODYPREFERENCE_HTML |
|
| 1002 | 1234 | { |
| 1003 | 1235 | if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
| 1236 | + } |
|
| 1004 | 1237 | // Send HTML if requested and native type was html |
| 1005 | 1238 | $output->asbody->type = 2; |
| 1006 | 1239 | $htmlbody = '<html>'. |
@@ -1012,7 +1245,10 @@ discard block |
||
| 1012 | 1245 | '<body>'; |
| 1013 | 1246 | if ($output->nativebodytype==2) |
| 1014 | 1247 | { |
| 1015 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1248 | + if ($css) |
|
| 1249 | + { |
|
| 1250 | + Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1251 | + } |
|
| 1016 | 1252 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1017 | 1253 | $htmlbody .= $body; |
| 1018 | 1254 | } |
@@ -1037,7 +1273,10 @@ discard block |
||
| 1037 | 1273 | else |
| 1038 | 1274 | { |
| 1039 | 1275 | // Send Plaintext as Fallback or if original body is plainttext |
| 1040 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1276 | + if ($this->debugLevel>0) |
|
| 1277 | + { |
|
| 1278 | + ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1279 | + } |
|
| 1041 | 1280 | /* we use plainBody (set above) instead |
| 1042 | 1281 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1043 | 1282 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1074,7 +1313,9 @@ discard block |
||
| 1074 | 1313 | { |
| 1075 | 1314 | $output->flag->flagstatus = 2; |
| 1076 | 1315 | //$output->flag->flagtype = "Flag for Follow up"; |
| 1077 | - } else { |
|
| 1316 | + } |
|
| 1317 | + else |
|
| 1318 | + { |
|
| 1078 | 1319 | $output->flag->flagstatus = 0; |
| 1079 | 1320 | } |
| 1080 | 1321 | if ($headers['answered']) |
@@ -1090,10 +1331,20 @@ discard block |
||
| 1090 | 1331 | ($headers['priority'] < 3 ? 2 : 1) ; |
| 1091 | 1332 | $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
| 1092 | 1333 | $output->to = $headers['to_address']; |
| 1093 | - if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
|
| 1334 | + if ($headers['to']) |
|
| 1335 | + { |
|
| 1336 | + $output->displayto = $headers['to_address']; |
|
| 1337 | + } |
|
| 1338 | + //$headers['FETCHED_HEADER']['to_name'] |
|
| 1094 | 1339 | $output->from = $headers['sender_address']; |
| 1095 | - if (isset($headers['cc_addresses']) && $headers['cc_addresses']) $output->cc = $headers['cc_addresses']; |
|
| 1096 | - if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
|
| 1340 | + if (isset($headers['cc_addresses']) && $headers['cc_addresses']) |
|
| 1341 | + { |
|
| 1342 | + $output->cc = $headers['cc_addresses']; |
|
| 1343 | + } |
|
| 1344 | + if (isset($headers['reply_to_address']) && $headers['reply_to_address']) |
|
| 1345 | + { |
|
| 1346 | + $output->reply_to = $headers['reply_to_address']; |
|
| 1347 | + } |
|
| 1097 | 1348 | |
| 1098 | 1349 | $output->messageclass = "IPM.Note"; |
| 1099 | 1350 | if (stripos($headers['mimetype'],'multipart')!== false && |
@@ -1101,7 +1352,8 @@ discard block |
||
| 1101 | 1352 | { |
| 1102 | 1353 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1103 | 1354 | } |
| 1104 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1355 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1356 | + { |
|
| 1105 | 1357 | $output->contentclass = "urn:content-classes:message"; |
| 1106 | 1358 | } |
| 1107 | 1359 | |
@@ -1114,7 +1366,10 @@ discard block |
||
| 1114 | 1366 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1115 | 1367 | foreach ($attachments as $key => $attach) |
| 1116 | 1368 | { |
| 1117 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1369 | + if ($this->debugLevel>0) |
|
| 1370 | + { |
|
| 1371 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1372 | + } |
|
| 1118 | 1373 | |
| 1119 | 1374 | // pass meeting requests to calendar plugin |
| 1120 | 1375 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1131,17 +1386,24 @@ discard block |
||
| 1131 | 1386 | unset($attachment); |
| 1132 | 1387 | continue; // do NOT add attachment as attachment |
| 1133 | 1388 | } |
| 1134 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1389 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1390 | + { |
|
| 1135 | 1391 | $attachment = new SyncBaseAttachment(); |
| 1136 | 1392 | if (!isset($output->asattachments) || !is_array($output->asattachments)) |
| 1137 | - $output->asattachments = array(); |
|
| 1393 | + { |
|
| 1394 | + $output->asattachments = array(); |
|
| 1395 | + } |
|
| 1138 | 1396 | $attachment->estimatedDataSize = $attach['size']; |
| 1139 | 1397 | $attachment->method = 1; |
| 1140 | 1398 | $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
| 1141 | - } else { |
|
| 1399 | + } |
|
| 1400 | + else |
|
| 1401 | + { |
|
| 1142 | 1402 | $attachment = new SyncAttachment(); |
| 1143 | 1403 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1144 | - $output->attachments = array(); |
|
| 1404 | + { |
|
| 1405 | + $output->attachments = array(); |
|
| 1406 | + } |
|
| 1145 | 1407 | $attachment->attsize = $attach['size']; |
| 1146 | 1408 | $attachment->attmethod = 1; |
| 1147 | 1409 | $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
@@ -1158,10 +1420,13 @@ discard block |
||
| 1158 | 1420 | { |
| 1159 | 1421 | $attachment->isinline = true; |
| 1160 | 1422 | } |
| 1161 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1423 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1424 | + { |
|
| 1162 | 1425 | $attachment->method=1; |
| 1163 | 1426 | $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
| 1164 | - } else { |
|
| 1427 | + } |
|
| 1428 | + else |
|
| 1429 | + { |
|
| 1165 | 1430 | $attachment->attmethod=6; |
| 1166 | 1431 | $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
| 1167 | 1432 | } |
@@ -1169,9 +1434,12 @@ discard block |
||
| 1169 | 1434 | $attachment->contenttype = trim($attach['mimeType']); |
| 1170 | 1435 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-type']."' ".$attachment->contentid); |
| 1171 | 1436 | } |
| 1172 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
| 1437 | + if (Request::GetProtocolVersion() >= 12.0) |
|
| 1438 | + { |
|
| 1173 | 1439 | array_push($output->asattachments, $attachment); |
| 1174 | - } else { |
|
| 1440 | + } |
|
| 1441 | + else |
|
| 1442 | + { |
|
| 1175 | 1443 | array_push($output->attachments, $attachment); |
| 1176 | 1444 | } |
| 1177 | 1445 | unset($attachment); |
@@ -1184,8 +1452,11 @@ discard block |
||
| 1184 | 1452 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1185 | 1453 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1186 | 1454 | |
| 1187 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1188 | -//$this->debugLevel=0; |
|
| 1455 | + if ($this->debugLevel>3) |
|
| 1456 | + { |
|
| 1457 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1458 | + } |
|
| 1459 | + //$this->debugLevel=0; |
|
| 1189 | 1460 | return $output; |
| 1190 | 1461 | } |
| 1191 | 1462 | //$this->debugLevel=0; |
@@ -1244,7 +1515,8 @@ discard block |
||
| 1244 | 1515 | * @param string $attname - should contain (folder)id |
| 1245 | 1516 | * @return SyncItemOperationsAttachment-object |
| 1246 | 1517 | */ |
| 1247 | - function GetAttachmentData($fid,$attname) { |
|
| 1518 | + function GetAttachmentData($fid,$attname) |
|
| 1519 | + { |
|
| 1248 | 1520 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1249 | 1521 | return $this->_GetAttachmentData($fid,$attname); |
| 1250 | 1522 | } |
@@ -1259,7 +1531,8 @@ discard block |
||
| 1259 | 1531 | * @param string $attname - should contain (folder)id |
| 1260 | 1532 | * @return SyncItemOperationsAttachment-object |
| 1261 | 1533 | */ |
| 1262 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1534 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
| 1535 | + { |
|
| 1263 | 1536 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
| 1264 | 1537 | return $this->_GetAttachmentData($fid,$attname); |
| 1265 | 1538 | } |
@@ -1281,7 +1554,10 @@ discard block |
||
| 1281 | 1554 | |
| 1282 | 1555 | $this->splitID($folderid, $account, $folder); |
| 1283 | 1556 | |
| 1284 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1557 | + if (!isset($this->mail)) |
|
| 1558 | + { |
|
| 1559 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1560 | + } |
|
| 1285 | 1561 | |
| 1286 | 1562 | $this->mail->reopen($folder); |
| 1287 | 1563 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
@@ -1290,7 +1566,9 @@ discard block |
||
| 1290 | 1566 | $SIOattachment->data = $attachment['attachment']; |
| 1291 | 1567 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1292 | 1568 | if (isset($attachment['type']) ) |
| 1293 | - $SIOattachment->contenttype = $attachment['type']; |
|
| 1569 | + { |
|
| 1570 | + $SIOattachment->contenttype = $attachment['type']; |
|
| 1571 | + } |
|
| 1294 | 1572 | |
| 1295 | 1573 | unset($attachment); |
| 1296 | 1574 | |
@@ -1336,11 +1614,15 @@ discard block |
||
| 1336 | 1614 | //unset($folderid, $id, $message, $contentParameters); |
| 1337 | 1615 | $account = $folder = null; |
| 1338 | 1616 | $this->splitID($folderid, $account, $folder); |
| 1339 | - if (isset($message->flag)) { |
|
| 1340 | - if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
|
| 1617 | + if (isset($message->flag)) |
|
| 1618 | + { |
|
| 1619 | + if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) |
|
| 1620 | + { |
|
| 1341 | 1621 | $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
| 1342 | 1622 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
| 1343 | - } else { |
|
| 1623 | + } |
|
| 1624 | + else |
|
| 1625 | + { |
|
| 1344 | 1626 | $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
| 1345 | 1627 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
| 1346 | 1628 | } |
@@ -1370,7 +1652,10 @@ discard block |
||
| 1370 | 1652 | $this->splitID($folderid, $account, $srcFolder); |
| 1371 | 1653 | $this->splitID($newfolderid, $account, $destFolder); |
| 1372 | 1654 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1373 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1655 | + if (!isset($this->mail)) |
|
| 1656 | + { |
|
| 1657 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1658 | + } |
|
| 1374 | 1659 | $this->mail->reopen($destFolder); |
| 1375 | 1660 | $status = $this->mail->getFolderStatus($destFolder); |
| 1376 | 1661 | $uidNext = $status['uidnext']; |
@@ -1402,11 +1687,15 @@ discard block |
||
| 1402 | 1687 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1403 | 1688 | } |
| 1404 | 1689 | $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
| 1405 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1690 | + if (is_numeric($maximumSyncRangeInDays)) |
|
| 1691 | + { |
|
| 1692 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1693 | + } |
|
| 1406 | 1694 | } |
| 1407 | 1695 | try { |
| 1408 | 1696 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1409 | - } catch (Exception $e) |
|
| 1697 | + } |
|
| 1698 | + catch (Exception $e) |
|
| 1410 | 1699 | { |
| 1411 | 1700 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details?$e->details:'')); |
| 1412 | 1701 | return array(); |
@@ -1430,7 +1719,10 @@ discard block |
||
| 1430 | 1719 | { |
| 1431 | 1720 | static $headers = array(); |
| 1432 | 1721 | |
| 1433 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1722 | + if ($this->debugLevel>1) |
|
| 1723 | + { |
|
| 1724 | + $gstarttime = microtime (true); |
|
| 1725 | + } |
|
| 1434 | 1726 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1435 | 1727 | $rv_messages = array(); |
| 1436 | 1728 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1443,7 +1735,10 @@ discard block |
||
| 1443 | 1735 | { |
| 1444 | 1736 | $headers = array(); // clear cache to not use too much memory |
| 1445 | 1737 | |
| 1446 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1738 | + if ($this->debugLevel>1) |
|
| 1739 | + { |
|
| 1740 | + $starttime = microtime (true); |
|
| 1741 | + } |
|
| 1447 | 1742 | $this->_connect($this->account); |
| 1448 | 1743 | if ($this->debugLevel>1) |
| 1449 | 1744 | { |
@@ -1452,8 +1747,14 @@ discard block |
||
| 1452 | 1747 | } |
| 1453 | 1748 | $messagelist = $_filter = array(); |
| 1454 | 1749 | // if not connected, any further action must fail |
| 1455 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1456 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1750 | + if (!empty($cutoffdate)) |
|
| 1751 | + { |
|
| 1752 | + $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1753 | + } |
|
| 1754 | + if ($this->debugLevel>1) |
|
| 1755 | + { |
|
| 1756 | + $starttime = microtime (true); |
|
| 1757 | + } |
|
| 1457 | 1758 | $account = $_folderName = $id = null; |
| 1458 | 1759 | $this->splitID($folderid,$account,$_folderName,$id); |
| 1459 | 1760 | if ($this->debugLevel>1) |
@@ -1461,8 +1762,14 @@ discard block |
||
| 1461 | 1762 | $endtime = microtime(true) - $starttime; |
| 1462 | 1763 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
| 1463 | 1764 | } |
| 1464 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1465 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1765 | + if ($this->debugLevel>1) |
|
| 1766 | + { |
|
| 1767 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1768 | + } |
|
| 1769 | + if ($this->debugLevel>1) |
|
| 1770 | + { |
|
| 1771 | + $starttime = microtime (true); |
|
| 1772 | + } |
|
| 1466 | 1773 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
| 1467 | 1774 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
| 1468 | 1775 | if ($this->debugLevel>1) |
@@ -1471,27 +1778,56 @@ discard block |
||
| 1471 | 1778 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
| 1472 | 1779 | } |
| 1473 | 1780 | } |
| 1474 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1781 | + if ($_id == NULL && $this->debugLevel>1) |
|
| 1782 | + { |
|
| 1783 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1784 | + } |
|
| 1475 | 1785 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1476 | 1786 | $messagelist = array(); |
| 1477 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1787 | + if (!isset($rv_messages['header'])||empty($rv_messages['header'])) |
|
| 1788 | + { |
|
| 1789 | + return $messagelist; |
|
| 1790 | + } |
|
| 1478 | 1791 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1479 | 1792 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1480 | 1793 | { |
| 1481 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1794 | + if ($this->debugLevel>3) |
|
| 1795 | + { |
|
| 1796 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1797 | + } |
|
| 1482 | 1798 | $headers[$vars['uid']] = $vars; |
| 1483 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1484 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
| 1485 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
| 1486 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1799 | + if ($this->debugLevel>3) |
|
| 1800 | + { |
|
| 1801 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1802 | + } |
|
| 1803 | + if (!empty($vars['deleted'])) |
|
| 1804 | + { |
|
| 1805 | + continue; |
|
| 1806 | + } |
|
| 1807 | + // cut of deleted messages |
|
| 1808 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
| 1809 | + { |
|
| 1810 | + continue; |
|
| 1811 | + } |
|
| 1812 | + // message is out of range for cutoffdate, ignore it |
|
| 1813 | + if ($this->debugLevel>0) |
|
| 1814 | + { |
|
| 1815 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1816 | + } |
|
| 1487 | 1817 | $mess = $return_all_headers ? $vars : array(); |
| 1488 | 1818 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1489 | 1819 | $mess["id"] = $vars['uid']; |
| 1490 | 1820 | // 'seen' aka 'read' is the only flag we want to know about |
| 1491 | 1821 | $mess["flags"] = 0; |
| 1492 | 1822 | // outlook supports additional flags, set them to 0 |
| 1493 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1494 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1823 | + if($vars["seen"]) |
|
| 1824 | + { |
|
| 1825 | + $mess["flags"] = 1; |
|
| 1826 | + } |
|
| 1827 | + if ($this->debugLevel>3) |
|
| 1828 | + { |
|
| 1829 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1830 | + } |
|
| 1495 | 1831 | $messagelist[$vars['uid']] = $mess; |
| 1496 | 1832 | unset($mess); |
| 1497 | 1833 | } |
@@ -1516,9 +1852,18 @@ discard block |
||
| 1516 | 1852 | static function doFlagsMod($headerFlags) |
| 1517 | 1853 | { |
| 1518 | 1854 | $flags = 'nnn'; |
| 1519 | - if ($headerFlags['flagged']) $flags[0] = 'f'; |
|
| 1520 | - if ($headerFlags['answered']) $flags[1] = 'a'; |
|
| 1521 | - if ($headerFlags['forwarded']) $flags[2] = 'f'; |
|
| 1855 | + if ($headerFlags['flagged']) |
|
| 1856 | + { |
|
| 1857 | + $flags[0] = 'f'; |
|
| 1858 | + } |
|
| 1859 | + if ($headerFlags['answered']) |
|
| 1860 | + { |
|
| 1861 | + $flags[1] = 'a'; |
|
| 1862 | + } |
|
| 1863 | + if ($headerFlags['forwarded']) |
|
| 1864 | + { |
|
| 1865 | + $flags[2] = 'f'; |
|
| 1866 | + } |
|
| 1522 | 1867 | //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags)); |
| 1523 | 1868 | return $flags; |
| 1524 | 1869 | } |
@@ -1550,31 +1895,55 @@ discard block |
||
| 1550 | 1895 | { |
| 1551 | 1896 | //$this->debugLevel=1; |
| 1552 | 1897 | $searchquery=$_searchquery->GetDataArray(); |
| 1553 | - if (!is_array($searchquery)) return array(); |
|
| 1554 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1898 | + if (!is_array($searchquery)) |
|
| 1899 | + { |
|
| 1900 | + return array(); |
|
| 1901 | + } |
|
| 1902 | + if ($this->debugLevel>0) |
|
| 1903 | + { |
|
| 1904 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1905 | + } |
|
| 1555 | 1906 | |
| 1556 | - if (isset($searchquery['searchrebuildresults'])) { |
|
| 1907 | + if (isset($searchquery['searchrebuildresults'])) |
|
| 1908 | + { |
|
| 1557 | 1909 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1558 | - } else { |
|
| 1910 | + } |
|
| 1911 | + else |
|
| 1912 | + { |
|
| 1559 | 1913 | $rebuildresults = false; |
| 1560 | 1914 | } |
| 1561 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1915 | + if ($this->debugLevel>0) |
|
| 1916 | + { |
|
| 1917 | + ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1918 | + } |
|
| 1562 | 1919 | |
| 1563 | - if (isset($searchquery['deeptraversal'])) { |
|
| 1920 | + if (isset($searchquery['deeptraversal'])) |
|
| 1921 | + { |
|
| 1564 | 1922 | $deeptraversal = $searchquery['deeptraversal']; |
| 1565 | - } else { |
|
| 1923 | + } |
|
| 1924 | + else |
|
| 1925 | + { |
|
| 1566 | 1926 | $deeptraversal = false; |
| 1567 | 1927 | } |
| 1568 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1928 | + if ($this->debugLevel>0) |
|
| 1929 | + { |
|
| 1930 | + ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1931 | + } |
|
| 1569 | 1932 | |
| 1570 | - if (isset($searchquery['searchrange'])) { |
|
| 1933 | + if (isset($searchquery['searchrange'])) |
|
| 1934 | + { |
|
| 1571 | 1935 | $range = explode("-",$_searchquery->GetSearchRange()); |
| 1572 | 1936 | $start =$range[0] + 1; |
| 1573 | 1937 | $limit = $range[1] - $range[0] + 1; |
| 1574 | - } else { |
|
| 1938 | + } |
|
| 1939 | + else |
|
| 1940 | + { |
|
| 1575 | 1941 | $range = false; |
| 1576 | 1942 | } |
| 1577 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1943 | + if ($this->debugLevel>0) |
|
| 1944 | + { |
|
| 1945 | + ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1946 | + } |
|
| 1578 | 1947 | |
| 1579 | 1948 | //foreach($searchquery['query'] as $k => $value) { |
| 1580 | 1949 | // $query = $value; |
@@ -1626,7 +1995,10 @@ discard block |
||
| 1626 | 1995 | $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
| 1627 | 1996 | } |
| 1628 | 1997 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1629 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1998 | + if ($this->debugLevel>1) |
|
| 1999 | + { |
|
| 2000 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 2001 | + } |
|
| 1630 | 2002 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
| 1631 | 2003 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1632 | 2004 | $list=array(); |
@@ -1658,17 +2030,26 @@ discard block |
||
| 1658 | 2030 | private function getParentID($account,$folder) |
| 1659 | 2031 | { |
| 1660 | 2032 | $this->_connect($account); |
| 1661 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2033 | + if (!isset($this->folders)) |
|
| 2034 | + { |
|
| 2035 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2036 | + } |
|
| 1662 | 2037 | |
| 1663 | 2038 | $mailFolder = $this->folders[$folder]; |
| 1664 | - if (!isset($mailFolder)) return false; |
|
| 2039 | + if (!isset($mailFolder)) |
|
| 2040 | + { |
|
| 2041 | + return false; |
|
| 2042 | + } |
|
| 1665 | 2043 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
| 1666 | 2044 | $parent = explode($delimiter,$folder); |
| 1667 | 2045 | array_pop($parent); |
| 1668 | 2046 | $parent = implode($delimiter,$parent); |
| 1669 | 2047 | |
| 1670 | 2048 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1671 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2049 | + if ($this->debugLevel>1) |
|
| 2050 | + { |
|
| 2051 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 2052 | + } |
|
| 1672 | 2053 | return $id; |
| 1673 | 2054 | } |
| 1674 | 2055 | |
@@ -1682,7 +2063,10 @@ discard block |
||
| 1682 | 2063 | { |
| 1683 | 2064 | static $last_id = null; |
| 1684 | 2065 | static $folderObj = null; |
| 1685 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
| 2066 | + if (isset($last_id) && $last_id === $id) |
|
| 2067 | + { |
|
| 2068 | + return $folderObj; |
|
| 2069 | + } |
|
| 1686 | 2070 | |
| 1687 | 2071 | try { |
| 1688 | 2072 | $account = $folder = null; |
@@ -1693,18 +2077,30 @@ discard block |
||
| 1693 | 2077 | return $folderObj=false; |
| 1694 | 2078 | } |
| 1695 | 2079 | $this->_connect($account); |
| 1696 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2080 | + if (!isset($this->folders)) |
|
| 2081 | + { |
|
| 2082 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 2083 | + } |
|
| 1697 | 2084 | |
| 1698 | 2085 | $mailFolder = $this->folders[$folder]; |
| 1699 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 2086 | + if (!isset($mailFolder)) |
|
| 2087 | + { |
|
| 2088 | + return $folderObj=false; |
|
| 2089 | + } |
|
| 1700 | 2090 | |
| 1701 | 2091 | $folderObj = new SyncFolder(); |
| 1702 | 2092 | $folderObj->serverid = $id; |
| 1703 | 2093 | $folderObj->parentid = $this->getParentID($account,$folder); |
| 1704 | 2094 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1705 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2095 | + if ($this->debugLevel>1) |
|
| 2096 | + { |
|
| 2097 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 2098 | + } |
|
| 1706 | 2099 | // get folder-type |
| 1707 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 2100 | + foreach($this->folders as $inbox => $mailFolder) |
|
| 2101 | + { |
|
| 2102 | + break; |
|
| 2103 | + } |
|
| 1708 | 2104 | if ($folder == $inbox) |
| 1709 | 2105 | { |
| 1710 | 2106 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1741,7 +2137,10 @@ discard block |
||
| 1741 | 2137 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1742 | 2138 | } |
| 1743 | 2139 | |
| 1744 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2140 | + if ($this->debugLevel>1) |
|
| 2141 | + { |
|
| 2142 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 2143 | + } |
|
| 1745 | 2144 | return $folderObj; |
| 1746 | 2145 | } |
| 1747 | 2146 | |
@@ -1785,11 +2184,20 @@ discard block |
||
| 1785 | 2184 | { |
| 1786 | 2185 | $account = $folder = null; |
| 1787 | 2186 | $this->splitID($folderid, $account, $folder); |
| 1788 | - if (is_numeric($account)) $type = 'mail'; |
|
| 2187 | + if (is_numeric($account)) |
|
| 2188 | + { |
|
| 2189 | + $type = 'mail'; |
|
| 2190 | + } |
|
| 1789 | 2191 | |
| 1790 | - if ($type != 'mail') return false; |
|
| 2192 | + if ($type != 'mail') |
|
| 2193 | + { |
|
| 2194 | + return false; |
|
| 2195 | + } |
|
| 1791 | 2196 | |
| 1792 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2197 | + if (!isset($this->mail)) |
|
| 2198 | + { |
|
| 2199 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 2200 | + } |
|
| 1793 | 2201 | if (!$this->mail->folderIsSelectable($folder)) |
| 1794 | 2202 | { |
| 1795 | 2203 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not select folder $folder returning fake state"); |
@@ -1840,7 +2248,7 @@ discard block |
||
| 1840 | 2248 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1841 | 2249 | */ |
| 1842 | 2250 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1843 | - { |
|
| 2251 | + { |
|
| 1844 | 2252 | unset($contentParameters); // not used, but required by function signature |
| 1845 | 2253 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1846 | 2254 | /* |
@@ -1866,7 +2274,10 @@ discard block |
||
| 1866 | 2274 | $error = $e->getMessage(); |
| 1867 | 2275 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
| 1868 | 2276 | // if the server thinks the message does not exist report deletion as success |
| 1869 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 2277 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
| 2278 | + { |
|
| 2279 | + return true; |
|
| 2280 | + } |
|
| 1870 | 2281 | return false; |
| 1871 | 2282 | } |
| 1872 | 2283 | |
@@ -1899,7 +2310,7 @@ discard block |
||
| 1899 | 2310 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
| 1900 | 2311 | */ |
| 1901 | 2312 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1902 | - { |
|
| 2313 | + { |
|
| 1903 | 2314 | unset($contentParameters); // not used, but required by function signature |
| 1904 | 2315 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1905 | 2316 | $account = $folder = null; |
@@ -1983,10 +2394,16 @@ discard block |
||
| 1983 | 2394 | $account = $parent_id = $app = null; |
| 1984 | 2395 | $this->splitID($id, $account, $folder, $app); |
| 1985 | 2396 | $old_hash = $this->folder2hash($account, $folder); |
| 1986 | - if ($parentid) $this->splitID($parentid, $account, $parentfolder, $app); |
|
| 2397 | + if ($parentid) |
|
| 2398 | + { |
|
| 2399 | + $this->splitID($parentid, $account, $parentfolder, $app); |
|
| 2400 | + } |
|
| 1987 | 2401 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."( '$id (-> $folder)','$parentid ".($parentid?'(->'.$parentfolder.')':'')."') called!"); |
| 1988 | 2402 | $ret = $this->mail->deleteFolder($folder); |
| 1989 | - if ($ret) $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
|
| 2403 | + if ($ret) |
|
| 2404 | + { |
|
| 2405 | + $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
|
| 2406 | + } |
|
| 1990 | 2407 | $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true,false); |
| 1991 | 2408 | return $ret; |
| 1992 | 2409 | } |
@@ -2032,7 +2449,10 @@ discard block |
||
| 2032 | 2449 | |
| 2033 | 2450 | $str = $this->backend->createID($account, $folder, $id); |
| 2034 | 2451 | |
| 2035 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2452 | + if ($this->debugLevel>1) |
|
| 2453 | + { |
|
| 2454 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2455 | + } |
|
| 2036 | 2456 | |
| 2037 | 2457 | return $str; |
| 2038 | 2458 | } |
@@ -2053,7 +2473,10 @@ discard block |
||
| 2053 | 2473 | // convert numeric folder-id back to folder name |
| 2054 | 2474 | $folder = $this->hash2folder($account,$f=$folder); |
| 2055 | 2475 | |
| 2056 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2476 | + if ($this->debugLevel>1) |
|
| 2477 | + { |
|
| 2478 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2479 | + } |
|
| 2057 | 2480 | } |
| 2058 | 2481 | |
| 2059 | 2482 | /** |
@@ -2072,7 +2495,10 @@ discard block |
||
| 2072 | 2495 | */ |
| 2073 | 2496 | private function folder2hash($account,$folder) |
| 2074 | 2497 | { |
| 2075 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2498 | + if(!isset($this->folderHashes)) |
|
| 2499 | + { |
|
| 2500 | + $this->readFolderHashes(); |
|
| 2501 | + } |
|
| 2076 | 2502 | |
| 2077 | 2503 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2078 | 2504 | { |
@@ -2095,7 +2521,10 @@ discard block |
||
| 2095 | 2521 | */ |
| 2096 | 2522 | private function hash2folder($account,$index) |
| 2097 | 2523 | { |
| 2098 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2524 | + if(!isset($this->folderHashes)) |
|
| 2525 | + { |
|
| 2526 | + $this->readFolderHashes(); |
|
| 2527 | + } |
|
| 2099 | 2528 | |
| 2100 | 2529 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2101 | 2530 | } |
@@ -90,23 +90,23 @@ discard block |
||
| 90 | 90 | $this->backend = $backend; |
| 91 | 91 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 92 | 92 | { |
| 93 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 93 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
| 94 | 94 | // globals preferences add appname varname value |
| 95 | - $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
|
| 95 | + $GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user'); |
|
| 96 | 96 | // save prefs |
| 97 | 97 | $GLOBALS['egw']->preferences->save_repository(true); |
| 98 | 98 | } |
| 99 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 99 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
| 100 | 100 | |
| 101 | 101 | if (is_null(self::$profileID)) |
| 102 | 102 | { |
| 103 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 104 | - self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
|
| 105 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 103 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
| 104 | + self::$profileID = & Api\Cache::getSession('mail', 'activeSyncProfileID'); |
|
| 105 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
| 106 | 106 | } |
| 107 | 107 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
| 108 | 108 | { |
| 109 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 109 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
| 110 | 110 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
| 111 | 111 | { |
| 112 | 112 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 119 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
| 120 | 120 | |
| 121 | 121 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
| 122 | 122 | if (!isset($GLOBALS['egw_setup'])) |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | try { |
| 125 | 125 | Mail\Account::read(self::$profileID); |
| 126 | 126 | } |
| 127 | - catch(Exception $e) { |
|
| 127 | + catch (Exception $e) { |
|
| 128 | 128 | unset($e); |
| 129 | 129 | self::$profileID = Mail\Account::get_default_acc_id(); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 132 | + if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
| 133 | 133 | //$this->debugLevel=0; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | $this->__construct($this->backend); |
| 243 | 243 | |
| 244 | 244 | try { |
| 245 | - $this->_connect(0,true); |
|
| 245 | + $this->_connect(0, true); |
|
| 246 | 246 | $this->_disconnect(); |
| 247 | 247 | |
| 248 | 248 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
| 249 | 249 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
| 250 | 250 | } |
| 251 | - catch(Exception $e) { |
|
| 251 | + catch (Exception $e) { |
|
| 252 | 252 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
| 253 | 253 | } |
| 254 | 254 | if ($errors) |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param int $account integer id of account to use |
| 267 | 267 | * @todo support different accounts |
| 268 | 268 | */ |
| 269 | - private function _connect($account=0) |
|
| 269 | + private function _connect($account = 0) |
|
| 270 | 270 | { |
| 271 | 271 | if (!$account) $account = self::$profileID ? self::$profileID : 0; |
| 272 | 272 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $this->account = $account; |
| 280 | 280 | // todo: tell mail which account to use |
| 281 | 281 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
| 282 | - $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 282 | + $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 283 | 283 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 284 | 284 | } |
| 285 | 285 | else |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
| 288 | 288 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
| 289 | 289 | } |
| 290 | - $this->mail->openConnection(self::$profileID,false); |
|
| 290 | + $this->mail->openConnection(self::$profileID, false); |
|
| 291 | 291 | |
| 292 | 292 | $this->_wasteID = $this->mail->getTrashFolder(false); |
| 293 | 293 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | private function _disconnect() |
| 304 | 304 | { |
| 305 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
| 305 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__); |
|
| 306 | 306 | if ($this->mail) $this->mail->closeConnection(); |
| 307 | 307 | |
| 308 | 308 | unset($this->mail); |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | public function GetFolderList() |
| 319 | 319 | { |
| 320 | 320 | $folderlist = array(); |
| 321 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
| 321 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__); |
|
| 322 | 322 | /*foreach($available_accounts as $account)*/ $account = 0; |
| 323 | 323 | { |
| 324 | 324 | $this->_connect($account); |
| 325 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
| 326 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
| 325 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
| 326 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders)); |
|
| 327 | 327 | |
| 328 | 328 | foreach ($this->folders as $folder => $folderObj) { |
| 329 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
| 329 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder); |
|
| 330 | 330 | $folderlist[] = $f = array( |
| 331 | - 'id' => $this->createID($account,$folder), |
|
| 331 | + 'id' => $this->createID($account, $folder), |
|
| 332 | 332 | 'mod' => $folderObj->shortDisplayName, |
| 333 | - 'parent' => $this->getParentID($account,$folder), |
|
| 333 | + 'parent' => $this->getParentID($account, $folder), |
|
| 334 | 334 | ); |
| 335 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
| 335 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f)); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
| 338 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist)); |
|
| 339 | 339 | |
| 340 | 340 | return $folderlist; |
| 341 | 341 | } |
@@ -384,90 +384,90 @@ discard block |
||
| 384 | 384 | $ClientSideMeetingRequest = false; |
| 385 | 385 | $allowSendingInvitations = 'sendifnocalnotif'; |
| 386 | 386 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 387 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
| 387 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
| 388 | 388 | { |
| 389 | 389 | $allowSendingInvitations = false; |
| 390 | 390 | } |
| 391 | 391 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
| 392 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
| 392 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
| 393 | 393 | { |
| 394 | 394 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
| 395 | 395 | } |
| 396 | - $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
|
| 396 | + $smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new')); |
|
| 397 | 397 | |
| 398 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__ . (isset($smartdata->mime) ? $smartdata->mime : ""). "task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
|
| 399 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 398 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.(isset($smartdata->mime) ? $smartdata->mime : "")."task: ".(isset($smartdata_task) ? $smartdata_task : "")." itemid: ".(isset($smartdata->source->itemid) ? $smartdata->source->itemid : "")." folder: ".(isset($smartdata->source->folderid) ? $smartdata->source->folderid : "")); |
|
| 399 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
| 400 | 400 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
| 401 | 401 | |
| 402 | 402 | // initialize our Mail |
| 403 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 403 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 404 | 404 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
| 405 | 405 | // use the standardIdentity |
| 406 | - $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
| 406 | + $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
| 407 | 407 | |
| 408 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 408 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
| 409 | 409 | // collect identity / signature for later usage, and to determine if we may have to manipulate TransferEncoding and Charset |
| 410 | 410 | try |
| 411 | 411 | { |
| 412 | 412 | $acc = Mail\Account::read($this->mail->icServer->ImapServerId); |
| 413 | 413 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
| 414 | - $_signature = Mail\Account::read_identity($acc['ident_id'],true); |
|
| 414 | + $_signature = Mail\Account::read_identity($acc['ident_id'], true); |
|
| 415 | 415 | } |
| 416 | 416 | catch (Exception $e) |
| 417 | 417 | { |
| 418 | - $_signature=array(); |
|
| 418 | + $_signature = array(); |
|
| 419 | 419 | } |
| 420 | 420 | $signature = $_signature['ident_signature']; |
| 421 | 421 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
| 422 | 422 | $preferencesArray['disableRulerForSignatureSeparation']) || |
| 423 | - empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='') |
|
| 423 | + empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '') |
|
| 424 | 424 | { |
| 425 | 425 | $disableRuler = true; |
| 426 | 426 | } |
| 427 | 427 | $beforePlain = $beforeHtml = ""; |
| 428 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 429 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
| 430 | - $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
| 431 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 428 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
| 429 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
| 430 | + $sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
| 431 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
| 432 | 432 | $sigTextHtml = $beforeHtml.$sigText; |
| 433 | 433 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
| 434 | 434 | |
| 435 | - $force8bit=false; |
|
| 436 | - if (Api\Translation::detect_encoding($sigTextPlain)!='ascii') $force8bit=true; |
|
| 435 | + $force8bit = false; |
|
| 436 | + if (Api\Translation::detect_encoding($sigTextPlain) != 'ascii') $force8bit = true; |
|
| 437 | 437 | // beware. the section below might cause trouble regarding bcc and attachments, so maybe this is to be handeled differently |
| 438 | 438 | if ($force8bit) |
| 439 | 439 | { |
| 440 | - $converterObj = new Api\Mailer('initbasic'); |
|
| 441 | - $smartdata->mime = $converterObj->convertMessageTextParts($smartdata->mime,false,'utf-8'); |
|
| 440 | + $converterObj = new Api\Mailer('initbasic'); |
|
| 441 | + $smartdata->mime = $converterObj->convertMessageTextParts($smartdata->mime, false, 'utf-8'); |
|
| 442 | 442 | } |
| 443 | 443 | // initialize the new Api\Mailer object for sending |
| 444 | 444 | $mailObject = new Api\Mailer(self::$profileID); |
| 445 | 445 | |
| 446 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); |
|
| 446 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime, $force8bit); |
|
| 447 | 447 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
| 448 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 449 | - $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); |
|
| 448 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 449 | + $mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false)); |
|
| 450 | 450 | $mailObject->addHeader('X-Mailer', 'mail-Activesync'); |
| 451 | 451 | |
| 452 | 452 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 453 | 453 | // to |
| 454 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 454 | + foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 455 | 455 | if (!$addressObject->valid) continue; |
| 456 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
| 456 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
| 457 | 457 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 458 | 458 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 459 | 459 | } |
| 460 | 460 | // CC |
| 461 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 461 | + foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 462 | 462 | if (!$addressObject->valid) continue; |
| 463 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
| 463 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
| 464 | 464 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 465 | 465 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 466 | 466 | } |
| 467 | 467 | // BCC |
| 468 | - foreach($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 468 | + foreach ($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 469 | 469 | if (!$addressObject->valid) continue; |
| 470 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
| 470 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
| 471 | 471 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 472 | 472 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 473 | 473 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $use_orgbody = false; |
| 477 | 477 | |
| 478 | 478 | $k = 'Content-Type'; |
| 479 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
| 479 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
| 480 | 480 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 481 | 481 | // if the message is a multipart message, then we should use the sent body |
| 482 | 482 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -496,43 +496,43 @@ discard block |
||
| 496 | 496 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
| 497 | 497 | $use_orgbody = true; |
| 498 | 498 | } |
| 499 | - $Body = $AltBody = ""; |
|
| 499 | + $Body = $AltBody = ""; |
|
| 500 | 500 | // get body of the transmitted message |
| 501 | 501 | // if this is a simple message, no structure at all |
| 502 | 502 | if (preg_match("/text/i", $ContentType)) |
| 503 | 503 | { |
| 504 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
| 504 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
| 505 | 505 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
| 506 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
| 507 | - if ($simpleBodyType == "text/plain") |
|
| 506 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
| 507 | + if ($simpleBodyType == "text/plain") |
|
| 508 | 508 | { |
| 509 | 509 | $Body = $body; |
| 510 | 510 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 511 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
| 511 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
| 512 | 512 | } |
| 513 | 513 | else |
| 514 | 514 | { |
| 515 | 515 | $AltBody = $body; |
| 516 | - $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 517 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
| 516 | + $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 517 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | else |
| 521 | 521 | { |
| 522 | 522 | // if this is a structured message |
| 523 | 523 | // prefer plain over html |
| 524 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 524 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 525 | 525 | ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
| 526 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 526 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 527 | 527 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 528 | 528 | } |
| 529 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 530 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 529 | + if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
| 530 | + if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
| 531 | 531 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 532 | 532 | // if this is a multipart message with a boundary, we must use the original body |
| 533 | 533 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 534 | 534 | if ($use_orgbody) { |
| 535 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 535 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 536 | 536 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 537 | 537 | if (($cal_body = $mailObject->findBody('calendar')) && |
| 538 | 538 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -541,21 +541,21 @@ discard block |
||
| 541 | 541 | { |
| 542 | 542 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 543 | 543 | } |
| 544 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 544 | + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 545 | 545 | $ClientSideMeetingRequest = true; |
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | // now handle the addressee list |
| 549 | 549 | $toCount = 0; |
| 550 | 550 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 551 | - foreach((array)$toMailAddr as $address) { |
|
| 552 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 553 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 551 | + foreach ((array)$toMailAddr as $address) { |
|
| 552 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ?stripslashes($address) : $address)) as $addressObject) { |
|
| 553 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 554 | 554 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 555 | 555 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
| 556 | 556 | $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
| 557 | 557 | { |
| 558 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 558 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 559 | 559 | continue; |
| 560 | 560 | } |
| 561 | 561 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
@@ -563,29 +563,29 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | $ccCount = 0; |
| 566 | - foreach((array)$ccMailAddr as $address) { |
|
| 567 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 568 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 566 | + foreach ((array)$ccMailAddr as $address) { |
|
| 567 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ?stripslashes($address) : $address)) as $addressObject) { |
|
| 568 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 569 | 569 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 570 | 570 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 571 | 571 | $ccCount++; |
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | $bccCount = 0; |
| 575 | - foreach((array)$bccMailAddr as $address) { |
|
| 576 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 577 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 575 | + foreach ((array)$bccMailAddr as $address) { |
|
| 576 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ?stripslashes($address) : $address)) as $addressObject) { |
|
| 577 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 578 | 578 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 579 | 579 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 580 | 580 | $bccCount++; |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
| 584 | - if ($toCount+$ccCount+$bccCount == 0) |
|
| 584 | + if ($toCount + $ccCount + $bccCount == 0) |
|
| 585 | 585 | { |
| 586 | 586 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 587 | 587 | } |
| 588 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 588 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
| 589 | 589 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 590 | 590 | /* |
| 591 | 591 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -602,26 +602,26 @@ discard block |
||
| 602 | 602 | { |
| 603 | 603 | // now get on, and fetch the original mail |
| 604 | 604 | $uid = $smartdata->source->itemid; |
| 605 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 605 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 606 | 606 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 607 | 607 | |
| 608 | 608 | $this->mail->reopen($folder); |
| 609 | 609 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 610 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 611 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 612 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 610 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 611 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 612 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 613 | 613 | // may be html |
| 614 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 614 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 615 | 615 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 616 | 616 | $isreply = true; |
| 617 | 617 | } |
| 618 | 618 | // plain text Message part |
| 619 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 619 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 620 | 620 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 621 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 622 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 623 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 624 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 621 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 622 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 623 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 624 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 625 | 625 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 626 | 626 | $isreply = true; |
| 627 | 627 | } |
@@ -629,12 +629,12 @@ discard block |
||
| 629 | 629 | { |
| 630 | 630 | $isreply = true; |
| 631 | 631 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 632 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 632 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // how to forward and other prefs |
| 637 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 637 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 638 | 638 | |
| 639 | 639 | // forward ------------------------------------------------------------------------- |
| 640 | 640 | if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | { |
| 645 | 645 | //force the default for the forwarding -> asmail |
| 646 | 646 | if (is_array($preferencesArray)) { |
| 647 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
| 647 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
| 648 | 648 | || !isset($preferencesArray['message_forwarding']) |
| 649 | 649 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
| 650 | 650 | } else { |
@@ -652,18 +652,18 @@ discard block |
||
| 652 | 652 | } |
| 653 | 653 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
| 654 | 654 | $uid = $smartdata->source->itemid; |
| 655 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 655 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 656 | 656 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 657 | 657 | |
| 658 | 658 | $this->mail->reopen($folder); |
| 659 | 659 | // receive entire mail (header + body) |
| 660 | 660 | // get message headers for specified message |
| 661 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 661 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 662 | 662 | // build a new mime message, forward entire old mail as file |
| 663 | 663 | if ($preferencesArray['message_forwarding'] == 'asmail') |
| 664 | 664 | { |
| 665 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
| 666 | - $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
| 665 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
| 666 | + $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
| 667 | 667 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
| 668 | 668 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
| 669 | 669 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -673,49 +673,49 @@ discard block |
||
| 673 | 673 | { |
| 674 | 674 | // now get on, and fetch the original mail |
| 675 | 675 | $uid = $smartdata->source->itemid; |
| 676 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 676 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 677 | 677 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 678 | 678 | |
| 679 | 679 | $this->mail->reopen($folder); |
| 680 | 680 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 681 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 682 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 683 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 681 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 682 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 683 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 684 | 684 | // may be html |
| 685 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 685 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 686 | 686 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 687 | 687 | $isforward = true; |
| 688 | 688 | } |
| 689 | 689 | // plain text Message part |
| 690 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 690 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 691 | 691 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 692 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 693 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 694 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 695 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 692 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 693 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 694 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 695 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 696 | 696 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 697 | 697 | $isforward = true; |
| 698 | 698 | } |
| 699 | 699 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 700 | 700 | { |
| 701 | 701 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 702 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 702 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 703 | 703 | $isforward = true; |
| 704 | 704 | } |
| 705 | 705 | // get all the attachments and add them too. |
| 706 | 706 | // start handle Attachments |
| 707 | - $attachments = $this->mail->getMessageAttachments($uid,null,null,true,false,true,$folder); |
|
| 707 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
| 708 | 708 | $attachmentNames = false; |
| 709 | - if (is_array($attachments) && count($attachments)>0) |
|
| 709 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 710 | 710 | { |
| 711 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 712 | - foreach((array)$attachments as $key => $attachment) |
|
| 711 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 712 | + foreach ((array)$attachments as $key => $attachment) |
|
| 713 | 713 | { |
| 714 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 714 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 715 | 715 | $attachmentNames .= $attachment['name']."\n"; |
| 716 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
| 716 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
| 717 | 717 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
| 718 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
| 718 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | } |
@@ -730,38 +730,38 @@ discard block |
||
| 730 | 730 | // now set the body |
| 731 | 731 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 732 | 732 | { |
| 733 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 733 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
| 734 | 734 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 735 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 735 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 736 | 736 | } |
| 737 | 737 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 738 | 738 | { |
| 739 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 739 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
| 740 | 740 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 741 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 741 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 742 | 742 | } |
| 743 | 743 | //advanced debugging |
| 744 | 744 | // Horde SMTP Class uses utf-8 by default. |
| 745 | 745 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 746 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 746 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 747 | 747 | |
| 748 | 748 | // set a higher timeout for big messages |
| 749 | 749 | @set_time_limit(120); |
| 750 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 750 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 751 | 751 | // send |
| 752 | 752 | $send = true; |
| 753 | 753 | try { |
| 754 | 754 | $mailObject->Send(); |
| 755 | 755 | } |
| 756 | - catch(Exception $e) { |
|
| 757 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
| 756 | + catch (Exception $e) { |
|
| 757 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
| 758 | 758 | $send = false; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 761 | + if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 762 | 762 | { |
| 763 | 763 | $uid = $smartdata->source->itemid; |
| 764 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 764 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 765 | 765 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 766 | 766 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
| 767 | 767 | $this->mail->reopen($folder); |
@@ -769,90 +769,90 @@ discard block |
||
| 769 | 769 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 770 | 770 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 771 | 771 | { |
| 772 | - $this->mail->deleteMessages(array($uid),$folder); |
|
| 772 | + $this->mail->deleteMessages(array($uid), $folder); |
|
| 773 | 773 | } else { |
| 774 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
| 775 | - if ($smartdata_task== "forward") |
|
| 774 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
| 775 | + if ($smartdata_task == "forward") |
|
| 776 | 776 | { |
| 777 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
| 777 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
| 778 | 778 | } |
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | $asf = ($send ? true:false); // initalize accordingly |
| 783 | - if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 783 | + if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 784 | 784 | { |
| 785 | 785 | $asf = false; |
| 786 | 786 | $sentFolder = $this->mail->getSentFolder(); |
| 787 | 787 | if ($this->_sentID) { |
| 788 | 788 | $folderArray[] = $this->_sentID; |
| 789 | 789 | } |
| 790 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
| 790 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
| 791 | 791 | { |
| 792 | 792 | $folderArray[] = $sentFolder; |
| 793 | 793 | } |
| 794 | 794 | // No Sent folder set, try defaults |
| 795 | 795 | else |
| 796 | 796 | { |
| 797 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 797 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 798 | 798 | // we dont try guessing |
| 799 | 799 | $asf = true; |
| 800 | 800 | } |
| 801 | 801 | if (count($folderArray) > 0) { |
| 802 | - foreach((array)$bccMailAddr as $address) { |
|
| 803 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 804 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 802 | + foreach ((array)$bccMailAddr as $address) { |
|
| 803 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ?stripslashes($address) : $address)) as $addressObject) { |
|
| 804 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 805 | 805 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | //$BCCmail=''; |
| 809 | - if (count($mailAddr)>0) $mailObject->forceBccHeader(); |
|
| 809 | + if (count($mailAddr) > 0) $mailObject->forceBccHeader(); |
|
| 810 | 810 | //$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
| 811 | - foreach($folderArray as $folderName) { |
|
| 812 | - if($this->mail->isSentFolder($folderName)) { |
|
| 811 | + foreach ($folderArray as $folderName) { |
|
| 812 | + if ($this->mail->isSentFolder($folderName)) { |
|
| 813 | 813 | $flags = '\\Seen'; |
| 814 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 814 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
| 815 | 815 | $flags = '\\Draft'; |
| 816 | 816 | } else { |
| 817 | 817 | $flags = ''; |
| 818 | 818 | } |
| 819 | 819 | $asf = true; |
| 820 | 820 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 821 | - $this->mail->openConnection(self::$profileID,false); |
|
| 821 | + $this->mail->openConnection(self::$profileID, false); |
|
| 822 | 822 | if ($this->mail->folderExists($folderName)) { |
| 823 | 823 | try |
| 824 | 824 | { |
| 825 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
| 825 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
| 826 | 826 | $flags); |
| 827 | 827 | } |
| 828 | 828 | catch (Api\Exception\WrongUserinput $e) |
| 829 | 829 | { |
| 830 | 830 | //$asf = false; |
| 831 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage())); |
|
| 831 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $mailObject->getHeader('Subject'), $folderName, $e->getMessage())); |
|
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | else |
| 835 | 835 | { |
| 836 | 836 | //$asf = false; |
| 837 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
| 837 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
| 838 | 838 | } |
| 839 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 839 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
| 840 | 840 | } |
| 841 | 841 | //$this->mail->closeConnection(); |
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - $this->debugLevel=0; |
|
| 845 | + $this->debugLevel = 0; |
|
| 846 | 846 | |
| 847 | 847 | if ($send && $asf) |
| 848 | 848 | { |
| 849 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
| 849 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
| 850 | 850 | return true; |
| 851 | 851 | } |
| 852 | 852 | else |
| 853 | 853 | { |
| 854 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
| 855 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 854 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
| 855 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | |
@@ -870,43 +870,43 @@ discard block |
||
| 870 | 870 | public function GetMessage($folderid, $id, $contentparameters) |
| 871 | 871 | { |
| 872 | 872 | //$this->debugLevel=4; |
| 873 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 873 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 874 | 874 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 875 | 875 | $mimesupport = $contentparameters->GetMimeSupport(); |
| 876 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 876 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 877 | 877 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 878 | 878 | |
| 879 | 879 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 880 | 880 | if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
| 881 | 881 | |
| 882 | 882 | //$this->debugLevel=4; |
| 883 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 884 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 883 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 884 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 885 | 885 | $account = $_folderName = $xid = null; |
| 886 | - $this->splitID($folderid,$account,$_folderName,$xid); |
|
| 886 | + $this->splitID($folderid, $account, $_folderName, $xid); |
|
| 887 | 887 | $this->mail->reopen($_folderName); |
| 888 | - $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 888 | + $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 889 | 889 | $headers = $messages[$id]; |
| 890 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 890 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers)); |
|
| 891 | 891 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 892 | 892 | if ($headers) |
| 893 | 893 | { |
| 894 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 894 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 895 | 895 | // initialize the object |
| 896 | 896 | $output = new SyncMail(); |
| 897 | 897 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 898 | 898 | // simple style |
| 899 | 899 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 900 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 900 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 901 | 901 | |
| 902 | 902 | if ($bodypreference === false) { |
| 903 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
| 904 | - $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 903 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
| 904 | + $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 905 | 905 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 906 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 906 | + if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 907 | 907 | // remove all other html |
| 908 | 908 | $body = strip_tags($raw_body); |
| 909 | - if(strlen($body) > $truncsize) { |
|
| 909 | + if (strlen($body) > $truncsize) { |
|
| 910 | 910 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 911 | 911 | $output->bodytruncated = 1; |
| 912 | 912 | } |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | else // style with bodypreferences |
| 921 | 921 | { |
| 922 | 922 | //Select body type preference |
| 923 | - $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
| 923 | + $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
| 924 | 924 | if ($bodypreference !== false) { |
| 925 | 925 | // bodypreference can occur multiple times |
| 926 | 926 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -934,12 +934,12 @@ discard block |
||
| 934 | 934 | } |
| 935 | 935 | */ |
| 936 | 936 | } |
| 937 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 937 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 938 | 938 | // set the protocoll class |
| 939 | 939 | $output->asbody = new SyncBaseBody(); |
| 940 | 940 | |
| 941 | 941 | // return full mime-message without any (charset) conversation directly as stream |
| 942 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
| 942 | + if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) |
|
| 943 | 943 | { |
| 944 | 944 | //SYNC_BODYPREFERENCE_MIME |
| 945 | 945 | $output->asbody->type = SYNC_BODYPREFERENCE_MIME; |
@@ -948,58 +948,58 @@ discard block |
||
| 948 | 948 | fseek($stream, 0, SEEK_SET); |
| 949 | 949 | $output->asbody->data = $stream; |
| 950 | 950 | $output->asbody->estimatedDataSize = $fstat['size']; |
| 951 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 951 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 952 | 952 | } |
| 953 | 953 | else |
| 954 | 954 | { |
| 955 | 955 | // fetch the body (try to gather data only once) |
| 956 | - $css =''; |
|
| 957 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
| 958 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 959 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 960 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 961 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 956 | + $css = ''; |
|
| 957 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
| 958 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 959 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 960 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
| 961 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 962 | 962 | // may be html |
| 963 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 963 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 964 | 964 | $css = $this->mail->getStyles($bodyStruct); |
| 965 | - $output->nativebodytype=2; |
|
| 965 | + $output->nativebodytype = 2; |
|
| 966 | 966 | } else { |
| 967 | 967 | // plain text Message |
| 968 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 969 | - $output->nativebodytype=1; |
|
| 970 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 971 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 972 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 973 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 968 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 969 | + $output->nativebodytype = 1; |
|
| 970 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 971 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 972 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 973 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 974 | 974 | } |
| 975 | 975 | // whatever format decode (using the correct encoding) |
| 976 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 976 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
| 977 | 977 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 978 | 978 | // prepare plaintextbody |
| 979 | - $plainBody=''; |
|
| 979 | + $plainBody = ''; |
|
| 980 | 980 | if ($output->nativebodytype == 2) |
| 981 | 981 | { |
| 982 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 983 | - if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
| 982 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 983 | + if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
| 984 | 984 | { |
| 985 | 985 | $plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
| 986 | 986 | } |
| 987 | 987 | else |
| 988 | 988 | { |
| 989 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
| 989 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | //if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body); |
| 993 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
| 993 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
| 994 | 994 | // remove all other html |
| 995 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
| 995 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
| 996 | 996 | $plainBody = strip_tags($plainBody); |
| 997 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 997 | + if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 998 | 998 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 999 | 999 | |
| 1000 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 1000 | + if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
| 1001 | 1001 | { |
| 1002 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 1002 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 1003 | 1003 | // Send HTML if requested and native type was html |
| 1004 | 1004 | $output->asbody->type = 2; |
| 1005 | 1005 | $htmlbody = '<html>'. |
@@ -1009,23 +1009,23 @@ discard block |
||
| 1009 | 1009 | $css. |
| 1010 | 1010 | '</head>'. |
| 1011 | 1011 | '<body>'; |
| 1012 | - if ($output->nativebodytype==2) |
|
| 1012 | + if ($output->nativebodytype == 2) |
|
| 1013 | 1013 | { |
| 1014 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1014 | + if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style'); |
|
| 1015 | 1015 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1016 | 1016 | $htmlbody .= $body; |
| 1017 | 1017 | } |
| 1018 | 1018 | else |
| 1019 | 1019 | { |
| 1020 | 1020 | // html requested but got only plaintext, so fake html |
| 1021 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
| 1021 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | $htmlbody .= '</body>'. |
| 1024 | 1024 | '</html>'; |
| 1025 | 1025 | |
| 1026 | - if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1026 | + if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1027 | 1027 | { |
| 1028 | - $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
| 1028 | + $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
| 1029 | 1029 | $output->asbody->truncated = 1; |
| 1030 | 1030 | } |
| 1031 | 1031 | // output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | else |
| 1037 | 1037 | { |
| 1038 | 1038 | // Send Plaintext as Fallback or if original body is plainttext |
| 1039 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1039 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1040 | 1040 | /* we use plainBody (set above) instead |
| 1041 | 1041 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1042 | 1042 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | */ |
| 1047 | 1047 | $output->asbody->type = 1; |
| 1048 | 1048 | $output->nativebodytype = 1; |
| 1049 | - if(isset($truncsize) && |
|
| 1049 | + if (isset($truncsize) && |
|
| 1050 | 1050 | strlen($plainBody) > $truncsize) |
| 1051 | 1051 | { |
| 1052 | 1052 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | 1067 | // end AS12 Stuff |
| 1068 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1068 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1069 | 1069 | $output->read = $headers["flags"]; |
| 1070 | 1070 | |
| 1071 | 1071 | $output->flag = new SyncMailFlags(); |
@@ -1085,9 +1085,8 @@ discard block |
||
| 1085 | 1085 | $output->lastverexecuted = AS_FORWARD; |
| 1086 | 1086 | } |
| 1087 | 1087 | $output->subject = $headers['subject']; |
| 1088 | - $output->importance = $headers['priority'] > 3 ? 0 : |
|
| 1089 | - ($headers['priority'] < 3 ? 2 : 1) ; |
|
| 1090 | - $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
|
| 1088 | + $output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1); |
|
| 1089 | + $output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true); |
|
| 1091 | 1090 | $output->to = $headers['to_address']; |
| 1092 | 1091 | if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
| 1093 | 1092 | $output->from = $headers['sender_address']; |
@@ -1095,8 +1094,8 @@ discard block |
||
| 1095 | 1094 | if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
| 1096 | 1095 | |
| 1097 | 1096 | $output->messageclass = "IPM.Note"; |
| 1098 | - if (stripos($headers['mimetype'],'multipart')!== false && |
|
| 1099 | - stripos($headers['mimetype'],'signed')!== false) |
|
| 1097 | + if (stripos($headers['mimetype'], 'multipart') !== false && |
|
| 1098 | + stripos($headers['mimetype'], 'signed') !== false) |
|
| 1100 | 1099 | { |
| 1101 | 1100 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1102 | 1101 | } |
@@ -1105,20 +1104,20 @@ discard block |
||
| 1105 | 1104 | } |
| 1106 | 1105 | |
| 1107 | 1106 | // start handle Attachments (include text/calendar multipart alternative) |
| 1108 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
| 1107 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
| 1109 | 1108 | // Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
| 1110 | - if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
| 1109 | + if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
| 1111 | 1110 | { |
| 1112 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1111 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1113 | 1112 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1114 | 1113 | foreach ($attachments as $key => $attach) |
| 1115 | 1114 | { |
| 1116 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1115 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1117 | 1116 | |
| 1118 | 1117 | // pass meeting requests to calendar plugin |
| 1119 | 1118 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1120 | 1119 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 1121 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
| 1120 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
| 1122 | 1121 | ($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
| 1123 | 1122 | { |
| 1124 | 1123 | //overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
@@ -1128,7 +1127,7 @@ discard block |
||
| 1128 | 1127 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1129 | 1128 | //$output->messageclass = "IPM.Schedule.Meeting"; |
| 1130 | 1129 | unset($attachment); |
| 1131 | - continue; // do NOT add attachment as attachment |
|
| 1130 | + continue; // do NOT add attachment as attachment |
|
| 1132 | 1131 | } |
| 1133 | 1132 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1134 | 1133 | $attachment = new SyncBaseAttachment(); |
@@ -1136,33 +1135,33 @@ discard block |
||
| 1136 | 1135 | $output->asattachments = array(); |
| 1137 | 1136 | $attachment->estimatedDataSize = $attach['size']; |
| 1138 | 1137 | $attachment->method = 1; |
| 1139 | - $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
| 1138 | + $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
| 1140 | 1139 | } else { |
| 1141 | 1140 | $attachment = new SyncAttachment(); |
| 1142 | 1141 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1143 | 1142 | $output->attachments = array(); |
| 1144 | 1143 | $attachment->attsize = $attach['size']; |
| 1145 | 1144 | $attachment->attmethod = 1; |
| 1146 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
| 1145 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
| 1147 | 1146 | } |
| 1148 | 1147 | |
| 1149 | 1148 | $attachment->displayname = $attach['name']; |
| 1150 | 1149 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
| 1151 | 1150 | |
| 1152 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1151 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1153 | 1152 | //$attachment->isinline=0; // if not inline, do not use isinline |
| 1154 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
| 1153 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
| 1155 | 1154 | { |
| 1156 | 1155 | if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
| 1157 | 1156 | { |
| 1158 | 1157 | $attachment->isinline = true; |
| 1159 | 1158 | } |
| 1160 | 1159 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1161 | - $attachment->method=1; |
|
| 1162 | - $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
| 1160 | + $attachment->method = 1; |
|
| 1161 | + $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1163 | 1162 | } else { |
| 1164 | - $attachment->attmethod=6; |
|
| 1165 | - $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
| 1163 | + $attachment->attmethod = 6; |
|
| 1164 | + $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1166 | 1165 | } |
| 1167 | 1166 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1168 | 1167 | $attachment->contenttype = trim($attach['mimeType']); |
@@ -1183,7 +1182,7 @@ discard block |
||
| 1183 | 1182 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1184 | 1183 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1185 | 1184 | |
| 1186 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1185 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
| 1187 | 1186 | //$this->debugLevel=0; |
| 1188 | 1187 | return $output; |
| 1189 | 1188 | } |
@@ -1206,30 +1205,30 @@ discard block |
||
| 1206 | 1205 | { |
| 1207 | 1206 | if (!class_exists('calendar_zpush')) |
| 1208 | 1207 | { |
| 1209 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1208 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1210 | 1209 | return null; |
| 1211 | 1210 | } |
| 1212 | 1211 | if (!($stat = $this->StatMessage($folderid, $requestid))) |
| 1213 | 1212 | { |
| 1214 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1213 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1215 | 1214 | return false; |
| 1216 | 1215 | } |
| 1217 | 1216 | $ret = false; |
| 1218 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
| 1217 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
| 1219 | 1218 | { |
| 1220 | 1219 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1221 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
| 1220 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
| 1222 | 1221 | { |
| 1223 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1222 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1224 | 1223 | |
| 1225 | 1224 | // calling backend again with iCal attachment, to let calendar add the event |
| 1226 | 1225 | $ret = $this->backend->MeetingResponse($attachment['attachment'], |
| 1227 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
| 1226 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
| 1228 | 1227 | $response); |
| 1229 | 1228 | break; |
| 1230 | 1229 | } |
| 1231 | 1230 | } |
| 1232 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1231 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1233 | 1232 | return $ret; |
| 1234 | 1233 | } |
| 1235 | 1234 | |
@@ -1243,9 +1242,9 @@ discard block |
||
| 1243 | 1242 | * @param string $attname - should contain (folder)id |
| 1244 | 1243 | * @return SyncItemOperationsAttachment-object |
| 1245 | 1244 | */ |
| 1246 | - function GetAttachmentData($fid,$attname) { |
|
| 1247 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1248 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1245 | + function GetAttachmentData($fid, $attname) { |
|
| 1246 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1247 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1249 | 1248 | } |
| 1250 | 1249 | |
| 1251 | 1250 | /** |
@@ -1258,9 +1257,9 @@ discard block |
||
| 1258 | 1257 | * @param string $attname - should contain (folder)id |
| 1259 | 1258 | * @return SyncItemOperationsAttachment-object |
| 1260 | 1259 | */ |
| 1261 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1262 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1263 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1260 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
| 1261 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1262 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1264 | 1263 | } |
| 1265 | 1264 | |
| 1266 | 1265 | /** |
@@ -1272,23 +1271,23 @@ discard block |
||
| 1272 | 1271 | * @param string $attname - should contain (folder)id |
| 1273 | 1272 | * @return SyncItemOperationsAttachment-object |
| 1274 | 1273 | */ |
| 1275 | - private function _GetAttachmentData($fid,$attname) |
|
| 1274 | + private function _GetAttachmentData($fid, $attname) |
|
| 1276 | 1275 | { |
| 1277 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1276 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1278 | 1277 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1279 | 1278 | list($folderid, $id, $part) = explode(":", $attname); |
| 1280 | 1279 | |
| 1281 | 1280 | $this->splitID($folderid, $account, $folder); |
| 1282 | 1281 | |
| 1283 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1282 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1284 | 1283 | |
| 1285 | 1284 | $this->mail->reopen($folder); |
| 1286 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
| 1285 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
| 1287 | 1286 | $SIOattachment = new SyncItemOperationsAttachment(); |
| 1288 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1287 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1289 | 1288 | $SIOattachment->data = $attachment['attachment']; |
| 1290 | 1289 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1291 | - if (isset($attachment['type']) ) |
|
| 1290 | + if (isset($attachment['type'])) |
|
| 1292 | 1291 | $SIOattachment->contenttype = $attachment['type']; |
| 1293 | 1292 | |
| 1294 | 1293 | unset($attachment); |
@@ -1331,17 +1330,17 @@ discard block |
||
| 1331 | 1330 | */ |
| 1332 | 1331 | function ChangeMessage($folderid, $id, $message, $contentParameters) |
| 1333 | 1332 | { |
| 1334 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1333 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1335 | 1334 | //unset($folderid, $id, $message, $contentParameters); |
| 1336 | 1335 | $account = $folder = null; |
| 1337 | 1336 | $this->splitID($folderid, $account, $folder); |
| 1338 | 1337 | if (isset($message->flag)) { |
| 1339 | 1338 | if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
| 1340 | - $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
| 1341 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1339 | + $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
| 1340 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1342 | 1341 | } else { |
| 1343 | - $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
| 1344 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
| 1342 | + $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
| 1343 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
| 1345 | 1344 | } |
| 1346 | 1345 | } |
| 1347 | 1346 | return $this->StatMessage($folderid, $id); |
@@ -1363,23 +1362,23 @@ discard block |
||
| 1363 | 1362 | */ |
| 1364 | 1363 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
| 1365 | 1364 | { |
| 1366 | - unset($contentParameters); // not used, but required by function signature |
|
| 1365 | + unset($contentParameters); // not used, but required by function signature |
|
| 1367 | 1366 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
| 1368 | 1367 | $account = $srcFolder = $destFolder = null; |
| 1369 | 1368 | $this->splitID($folderid, $account, $srcFolder); |
| 1370 | 1369 | $this->splitID($newfolderid, $account, $destFolder); |
| 1371 | 1370 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1372 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1371 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1373 | 1372 | $this->mail->reopen($destFolder); |
| 1374 | 1373 | $status = $this->mail->getFolderStatus($destFolder); |
| 1375 | 1374 | $uidNext = $status['uidnext']; |
| 1376 | 1375 | $this->mail->reopen($srcFolder); |
| 1377 | 1376 | |
| 1378 | 1377 | // move message |
| 1379 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
| 1380 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine |
|
| 1378 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
| 1379 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.": New Status of $destFolder :".array2string($status).", ReturnValOf moveMessage".array2string($rv)); // this may be true, so try using the nextUID value by examine |
|
| 1381 | 1380 | // return the new id "as string" |
| 1382 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
| 1381 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
| 1383 | 1382 | } |
| 1384 | 1383 | |
| 1385 | 1384 | /** |
@@ -1387,7 +1386,7 @@ discard block |
||
| 1387 | 1386 | * |
| 1388 | 1387 | * @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks |
| 1389 | 1388 | */ |
| 1390 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
| 1389 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
| 1391 | 1390 | { |
| 1392 | 1391 | if ($cutoffdate > 0) |
| 1393 | 1392 | { |
@@ -1400,14 +1399,14 @@ discard block |
||
| 1400 | 1399 | { |
| 1401 | 1400 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1402 | 1401 | } |
| 1403 | - $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
|
| 1404 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1402 | + $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null); |
|
| 1403 | + if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1405 | 1404 | } |
| 1406 | 1405 | try { |
| 1407 | 1406 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1408 | 1407 | } catch (Exception $e) |
| 1409 | 1408 | { |
| 1410 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details?$e->details:'')); |
|
| 1409 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details ? $e->details : '')); |
|
| 1411 | 1410 | return array(); |
| 1412 | 1411 | } |
| 1413 | 1412 | } |
@@ -1425,11 +1424,11 @@ discard block |
||
| 1425 | 1424 | * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject" |
| 1426 | 1425 | * @return array uid => array StatMessage($folderid, $_id) |
| 1427 | 1426 | */ |
| 1428 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false) |
|
| 1427 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false) |
|
| 1429 | 1428 | { |
| 1430 | 1429 | static $headers = array(); |
| 1431 | 1430 | |
| 1432 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1431 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
| 1433 | 1432 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1434 | 1433 | $rv_messages = array(); |
| 1435 | 1434 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1440,64 +1439,64 @@ discard block |
||
| 1440 | 1439 | } |
| 1441 | 1440 | else |
| 1442 | 1441 | { |
| 1443 | - $headers = array(); // clear cache to not use too much memory |
|
| 1442 | + $headers = array(); // clear cache to not use too much memory |
|
| 1444 | 1443 | |
| 1445 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1444 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1446 | 1445 | $this->_connect($this->account); |
| 1447 | - if ($this->debugLevel>1) |
|
| 1446 | + if ($this->debugLevel > 1) |
|
| 1448 | 1447 | { |
| 1449 | 1448 | $endtime = microtime(true) - $starttime; |
| 1450 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
| 1449 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
| 1451 | 1450 | } |
| 1452 | 1451 | $messagelist = $_filter = array(); |
| 1453 | 1452 | // if not connected, any further action must fail |
| 1454 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1455 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1453 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1454 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1456 | 1455 | $account = $_folderName = $id = null; |
| 1457 | - $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1458 | - if ($this->debugLevel>1) |
|
| 1456 | + $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1457 | + if ($this->debugLevel > 1) |
|
| 1459 | 1458 | { |
| 1460 | 1459 | $endtime = microtime(true) - $starttime; |
| 1461 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1460 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1462 | 1461 | } |
| 1463 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1464 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1465 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
| 1466 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
| 1467 | - if ($this->debugLevel>1) |
|
| 1462 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1463 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1464 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
| 1465 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
| 1466 | + if ($this->debugLevel > 1) |
|
| 1468 | 1467 | { |
| 1469 | 1468 | $endtime = microtime(true) - $starttime; |
| 1470 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1469 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1471 | 1470 | } |
| 1472 | 1471 | } |
| 1473 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1472 | + if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
| 1474 | 1473 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1475 | 1474 | $messagelist = array(); |
| 1476 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1475 | + if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
| 1477 | 1476 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1478 | 1477 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1479 | 1478 | { |
| 1480 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1479 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1481 | 1480 | $headers[$vars['uid']] = $vars; |
| 1482 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1481 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1483 | 1482 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
| 1484 | 1483 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
| 1485 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1484 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1486 | 1485 | $mess = $return_all_headers ? $vars : array(); |
| 1487 | 1486 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1488 | 1487 | $mess["id"] = $vars['uid']; |
| 1489 | 1488 | // 'seen' aka 'read' is the only flag we want to know about |
| 1490 | 1489 | $mess["flags"] = 0; |
| 1491 | 1490 | // outlook supports additional flags, set them to 0 |
| 1492 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1493 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1491 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
| 1492 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
| 1494 | 1493 | $messagelist[$vars['uid']] = $mess; |
| 1495 | 1494 | unset($mess); |
| 1496 | 1495 | } |
| 1497 | - if ($this->debugLevel>1) |
|
| 1496 | + if ($this->debugLevel > 1) |
|
| 1498 | 1497 | { |
| 1499 | 1498 | $endtime = microtime(true) - $gstarttime; |
| 1500 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1499 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1501 | 1500 | } |
| 1502 | 1501 | return $messagelist; |
| 1503 | 1502 | } |
@@ -1548,32 +1547,32 @@ discard block |
||
| 1548 | 1547 | public function getSearchResultsMailbox($_searchquery) |
| 1549 | 1548 | { |
| 1550 | 1549 | //$this->debugLevel=1; |
| 1551 | - $searchquery=$_searchquery->GetDataArray(); |
|
| 1550 | + $searchquery = $_searchquery->GetDataArray(); |
|
| 1552 | 1551 | if (!is_array($searchquery)) return array(); |
| 1553 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1552 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
| 1554 | 1553 | |
| 1555 | 1554 | if (isset($searchquery['searchrebuildresults'])) { |
| 1556 | 1555 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1557 | 1556 | } else { |
| 1558 | 1557 | $rebuildresults = false; |
| 1559 | 1558 | } |
| 1560 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1559 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']'); |
|
| 1561 | 1560 | |
| 1562 | 1561 | if (isset($searchquery['deeptraversal'])) { |
| 1563 | 1562 | $deeptraversal = $searchquery['deeptraversal']; |
| 1564 | 1563 | } else { |
| 1565 | 1564 | $deeptraversal = false; |
| 1566 | 1565 | } |
| 1567 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1566 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']'); |
|
| 1568 | 1567 | |
| 1569 | 1568 | if (isset($searchquery['searchrange'])) { |
| 1570 | - $range = explode("-",$_searchquery->GetSearchRange()); |
|
| 1571 | - $start =$range[0] + 1; |
|
| 1569 | + $range = explode("-", $_searchquery->GetSearchRange()); |
|
| 1570 | + $start = $range[0] + 1; |
|
| 1572 | 1571 | $limit = $range[1] - $range[0] + 1; |
| 1573 | 1572 | } else { |
| 1574 | 1573 | $range = false; |
| 1575 | 1574 | } |
| 1576 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1575 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']'); |
|
| 1577 | 1576 | |
| 1578 | 1577 | //foreach($searchquery['query'] as $k => $value) { |
| 1579 | 1578 | // $query = $value; |
@@ -1596,15 +1595,15 @@ discard block |
||
| 1596 | 1595 | } |
| 1597 | 1596 | if (!$folderid) |
| 1598 | 1597 | { |
| 1599 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
| 1600 | - $folderid = $this->createID($account=0,$_folderName); |
|
| 1598 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
| 1599 | + $folderid = $this->createID($account = 0, $_folderName); |
|
| 1601 | 1600 | } |
| 1602 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1603 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1601 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1602 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1604 | 1603 | $this->_connect($account); |
| 1605 | 1604 | // this should not be needed ??? |
| 1606 | - Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
| 1607 | - $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
| 1605 | + Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
| 1606 | + $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
| 1608 | 1607 | 'string'=> $searchText, |
| 1609 | 1608 | 'status'=>'any' |
| 1610 | 1609 | ); |
@@ -1619,22 +1618,22 @@ discard block |
||
| 1619 | 1618 | * [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
| 1620 | 1619 | */ |
| 1621 | 1620 | $_filter['range'] = "BETWEEN"; |
| 1622 | - list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
| 1623 | - list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
| 1624 | - $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
| 1625 | - $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
| 1621 | + list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
| 1622 | + list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
| 1623 | + $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
| 1624 | + $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
| 1626 | 1625 | } |
| 1627 | 1626 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1628 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1629 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
| 1627 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1628 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
| 1630 | 1629 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1631 | - $list=array(); |
|
| 1630 | + $list = array(); |
|
| 1632 | 1631 | |
| 1633 | 1632 | $cnt = count($rv_messages['header']); |
| 1634 | 1633 | //$list['status'] = 1; |
| 1635 | 1634 | $list['searchtotal'] = $cnt; |
| 1636 | 1635 | $list["range"] = $_searchquery->GetSearchRange(); |
| 1637 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
| 1636 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
| 1638 | 1637 | { |
| 1639 | 1638 | $list[] = array( |
| 1640 | 1639 | "class" => "Email", |
@@ -1654,20 +1653,20 @@ discard block |
||
| 1654 | 1653 | * @param string $folder |
| 1655 | 1654 | * @return string |
| 1656 | 1655 | */ |
| 1657 | - private function getParentID($account,$folder) |
|
| 1656 | + private function getParentID($account, $folder) |
|
| 1658 | 1657 | { |
| 1659 | 1658 | $this->_connect($account); |
| 1660 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1659 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1661 | 1660 | |
| 1662 | 1661 | $mailFolder = $this->folders[$folder]; |
| 1663 | 1662 | if (!isset($mailFolder)) return false; |
| 1664 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
| 1665 | - $parent = explode($delimiter,$folder); |
|
| 1663 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
| 1664 | + $parent = explode($delimiter, $folder); |
|
| 1666 | 1665 | array_pop($parent); |
| 1667 | - $parent = implode($delimiter,$parent); |
|
| 1666 | + $parent = implode($delimiter, $parent); |
|
| 1668 | 1667 | |
| 1669 | 1668 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1670 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1669 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1671 | 1670 | return $id; |
| 1672 | 1671 | } |
| 1673 | 1672 | |
@@ -1687,48 +1686,48 @@ discard block |
||
| 1687 | 1686 | $account = $folder = null; |
| 1688 | 1687 | $this->splitID($id, $account, $folder); |
| 1689 | 1688 | } |
| 1690 | - catch(Exception $e) { |
|
| 1691 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1692 | - return $folderObj=false; |
|
| 1689 | + catch (Exception $e) { |
|
| 1690 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1691 | + return $folderObj = false; |
|
| 1693 | 1692 | } |
| 1694 | 1693 | $this->_connect($account); |
| 1695 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1694 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1696 | 1695 | |
| 1697 | 1696 | $mailFolder = $this->folders[$folder]; |
| 1698 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 1697 | + if (!isset($mailFolder)) return $folderObj = false; |
|
| 1699 | 1698 | |
| 1700 | 1699 | $folderObj = new SyncFolder(); |
| 1701 | 1700 | $folderObj->serverid = $id; |
| 1702 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
| 1701 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
| 1703 | 1702 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1704 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1703 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1705 | 1704 | // get folder-type |
| 1706 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 1705 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
| 1707 | 1706 | if ($folder == $inbox) |
| 1708 | 1707 | { |
| 1709 | 1708 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
| 1710 | 1709 | } |
| 1711 | - elseif($this->mail->isDraftFolder($folder, false, true)) |
|
| 1710 | + elseif ($this->mail->isDraftFolder($folder, false, true)) |
|
| 1712 | 1711 | { |
| 1713 | 1712 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
| 1714 | 1713 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
| 1715 | 1714 | $folderObj->parentid = 0; // required by devices |
| 1716 | 1715 | } |
| 1717 | - elseif($this->mail->isTrashFolder($folder, false, true)) |
|
| 1716 | + elseif ($this->mail->isTrashFolder($folder, false, true)) |
|
| 1718 | 1717 | { |
| 1719 | 1718 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
| 1720 | 1719 | $this->_wasteID = $folder; |
| 1721 | 1720 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
| 1722 | 1721 | $folderObj->parentid = 0; // required by devices |
| 1723 | 1722 | } |
| 1724 | - elseif($this->mail->isSentFolder($folder, false, true)) |
|
| 1723 | + elseif ($this->mail->isSentFolder($folder, false, true)) |
|
| 1725 | 1724 | { |
| 1726 | 1725 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
| 1727 | 1726 | $folderObj->parentid = 0; // required by devices |
| 1728 | 1727 | $this->_sentID = $folder; |
| 1729 | 1728 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
| 1730 | 1729 | } |
| 1731 | - elseif($this->mail->isOutbox($folder, false, true)) |
|
| 1730 | + elseif ($this->mail->isOutbox($folder, false, true)) |
|
| 1732 | 1731 | { |
| 1733 | 1732 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
| 1734 | 1733 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1740,7 +1739,7 @@ discard block |
||
| 1740 | 1739 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1741 | 1740 | } |
| 1742 | 1741 | |
| 1743 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1742 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1744 | 1743 | return $folderObj; |
| 1745 | 1744 | } |
| 1746 | 1745 | |
@@ -1788,24 +1787,24 @@ discard block |
||
| 1788 | 1787 | |
| 1789 | 1788 | if ($type != 'mail') return false; |
| 1790 | 1789 | |
| 1791 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1790 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1792 | 1791 | if (!$this->mail->folderIsSelectable($folder)) |
| 1793 | 1792 | { |
| 1794 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not select folder $folder returning fake state"); |
|
| 1793 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not select folder $folder returning fake state"); |
|
| 1795 | 1794 | $syncstate = "M:".'0'."-R:".'0'."-U:".'0'."-NUID:".'0'."-UIDV:".'0'; |
| 1796 | 1795 | return array(); |
| 1797 | 1796 | } |
| 1798 | 1797 | |
| 1799 | 1798 | $this->mail->reopen($folder); |
| 1800 | 1799 | |
| 1801 | - if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true))) |
|
| 1800 | + if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true))) |
|
| 1802 | 1801 | { |
| 1803 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
| 1802 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
| 1804 | 1803 | return false; |
| 1805 | 1804 | } |
| 1806 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1805 | + $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1807 | 1806 | |
| 1808 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1807 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1809 | 1808 | return array(); |
| 1810 | 1809 | } |
| 1811 | 1810 | |
@@ -1818,8 +1817,8 @@ discard block |
||
| 1818 | 1817 | function GetWasteBasket() |
| 1819 | 1818 | { |
| 1820 | 1819 | $this->_connect($this->account); |
| 1821 | - $id = $this->createID($account=0, $this->_wasteID); |
|
| 1822 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1820 | + $id = $this->createID($account = 0, $this->_wasteID); |
|
| 1821 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1823 | 1822 | return $id; |
| 1824 | 1823 | } |
| 1825 | 1824 | |
@@ -1840,7 +1839,7 @@ discard block |
||
| 1840 | 1839 | */ |
| 1841 | 1840 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1842 | 1841 | { |
| 1843 | - unset($contentParameters); // not used, but required by function signature |
|
| 1842 | + unset($contentParameters); // not used, but required by function signature |
|
| 1844 | 1843 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1845 | 1844 | /* |
| 1846 | 1845 | $this->imap_reopenFolder($folderid); |
@@ -1851,7 +1850,7 @@ discard block |
||
| 1851 | 1850 | // we may have to split folderid |
| 1852 | 1851 | $account = $folder = null; |
| 1853 | 1852 | $this->splitID($folderid, $account, $folder); |
| 1854 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1853 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1855 | 1854 | $_messageUID = (array)$id; |
| 1856 | 1855 | |
| 1857 | 1856 | $this->_connect($this->account); |
@@ -1863,9 +1862,9 @@ discard block |
||
| 1863 | 1862 | catch (Api\Exception $e) |
| 1864 | 1863 | { |
| 1865 | 1864 | $error = $e->getMessage(); |
| 1866 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1865 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1867 | 1866 | // if the server thinks the message does not exist report deletion as success |
| 1868 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 1867 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
| 1869 | 1868 | return false; |
| 1870 | 1869 | } |
| 1871 | 1870 | |
@@ -1899,15 +1898,15 @@ discard block |
||
| 1899 | 1898 | */ |
| 1900 | 1899 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1901 | 1900 | { |
| 1902 | - unset($contentParameters); // not used, but required by function signature |
|
| 1901 | + unset($contentParameters); // not used, but required by function signature |
|
| 1903 | 1902 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1904 | 1903 | $account = $folder = null; |
| 1905 | 1904 | $this->splitID($folderid, $account, $folder); |
| 1906 | 1905 | |
| 1907 | 1906 | $_messageUID = (array)$id; |
| 1908 | 1907 | $this->_connect($this->account); |
| 1909 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
| 1910 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
| 1908 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
| 1909 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
| 1911 | 1910 | |
| 1912 | 1911 | return $rv; |
| 1913 | 1912 | } |
@@ -1925,7 +1924,7 @@ discard block |
||
| 1925 | 1924 | */ |
| 1926 | 1925 | public function ChangeFolder($id, $oldid, $displayname, $type) |
| 1927 | 1926 | { |
| 1928 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
| 1927 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
| 1929 | 1928 | $account = $parent_id = null; |
| 1930 | 1929 | $this->splitID($id, $account, $parentFolder, $app); |
| 1931 | 1930 | |
@@ -1942,17 +1941,17 @@ discard block |
||
| 1942 | 1941 | $this->splitID($oldid, $account, $oldFolder, $app); |
| 1943 | 1942 | $old_hash = $this->folder2hash($account, $oldFolder); |
| 1944 | 1943 | } |
| 1945 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid?"=>($oldFolder ($old_hash))":'').", '$displayname', $type)"); |
|
| 1944 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid ? "=>($oldFolder ($old_hash))" : '').", '$displayname', $type)"); |
|
| 1946 | 1945 | $this->_connect($this->account); |
| 1947 | 1946 | try |
| 1948 | 1947 | { |
| 1949 | - if ($action=='rename') |
|
| 1948 | + if ($action == 'rename') |
|
| 1950 | 1949 | { |
| 1951 | 1950 | $newFolderName = $this->mail->renameFolder($oldFolder, $parentFolder, $displayname); |
| 1952 | 1951 | } |
| 1953 | - elseif ($action=='create') |
|
| 1952 | + elseif ($action == 'create') |
|
| 1954 | 1953 | { |
| 1955 | - $error=null; |
|
| 1954 | + $error = null; |
|
| 1956 | 1955 | $newFolderName = $this->mail->createFolder($parentFolder, $displayname, $error); |
| 1957 | 1956 | } |
| 1958 | 1957 | } |
@@ -1963,8 +1962,8 @@ discard block |
||
| 1963 | 1962 | } |
| 1964 | 1963 | $newHash = $this->rename_folder_hash($account, $old_hash, $newFolderName); |
| 1965 | 1964 | $newID = $this->createID($account, $newHash); |
| 1966 | - $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true,false); |
|
| 1967 | - ZLog::Write(LOGLEVEL_DEBUG,":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid?"=>($oldFolder)":'').", '$displayname' => $newFolderName (ID:$newID))"); |
|
| 1965 | + $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true, false); |
|
| 1966 | + ZLog::Write(LOGLEVEL_DEBUG, ":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid ? "=>($oldFolder)" : '').", '$displayname' => $newFolderName (ID:$newID))"); |
|
| 1968 | 1967 | return $this->StatFolder($newID); |
| 1969 | 1968 | } |
| 1970 | 1969 | |
@@ -1977,16 +1976,16 @@ discard block |
||
| 1977 | 1976 | * @throws StatusException could throw specific SYNC_FSSTATUS_* exceptions |
| 1978 | 1977 | * @return boolean true or false on error |
| 1979 | 1978 | */ |
| 1980 | - public function DeleteFolder($id, $parentid=false) |
|
| 1979 | + public function DeleteFolder($id, $parentid = false) |
|
| 1981 | 1980 | { |
| 1982 | 1981 | $account = $parent_id = $app = null; |
| 1983 | 1982 | $this->splitID($id, $account, $folder, $app); |
| 1984 | 1983 | $old_hash = $this->folder2hash($account, $folder); |
| 1985 | 1984 | if ($parentid) $this->splitID($parentid, $account, $parentfolder, $app); |
| 1986 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."( '$id (-> $folder)','$parentid ".($parentid?'(->'.$parentfolder.')':'')."') called!"); |
|
| 1985 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."( '$id (-> $folder)','$parentid ".($parentid ? '(->'.$parentfolder.')' : '')."') called!"); |
|
| 1987 | 1986 | $ret = $this->mail->deleteFolder($folder); |
| 1988 | 1987 | if ($ret) $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
| 1989 | - $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true,false); |
|
| 1988 | + $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true, false); |
|
| 1990 | 1989 | return $ret; |
| 1991 | 1990 | } |
| 1992 | 1991 | |
@@ -2006,8 +2005,8 @@ discard block |
||
| 2006 | 2005 | $this->_connect($this->account); |
| 2007 | 2006 | $account = $folder = null; |
| 2008 | 2007 | $this->splitID($folderid, $account, $folder); |
| 2009 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
| 2010 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 2008 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
| 2009 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 2011 | 2010 | |
| 2012 | 2011 | return $rv; |
| 2013 | 2012 | } |
@@ -2021,17 +2020,17 @@ discard block |
||
| 2021 | 2020 | * @return string |
| 2022 | 2021 | * @throws Api\Exception\WrongParameter |
| 2023 | 2022 | */ |
| 2024 | - private function createID($account,$folder,$id=0) |
|
| 2023 | + private function createID($account, $folder, $id = 0) |
|
| 2025 | 2024 | { |
| 2026 | 2025 | if (!is_numeric($folder)) |
| 2027 | 2026 | { |
| 2028 | 2027 | // convert string $folder in numeric id |
| 2029 | - $folder = $this->folder2hash($account,$f=$folder); |
|
| 2028 | + $folder = $this->folder2hash($account, $f = $folder); |
|
| 2030 | 2029 | } |
| 2031 | 2030 | |
| 2032 | 2031 | $str = $this->backend->createID($account, $folder, $id); |
| 2033 | 2032 | |
| 2034 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2033 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2035 | 2034 | |
| 2036 | 2035 | return $str; |
| 2037 | 2036 | } |
@@ -2045,14 +2044,14 @@ discard block |
||
| 2045 | 2044 | * @param int &$appid=null (for mail=mail is to be expected) |
| 2046 | 2045 | * @throws Api\Exception\WrongParameter |
| 2047 | 2046 | */ |
| 2048 | - private function splitID($str,&$account,&$folder,&$appid=null) |
|
| 2047 | + private function splitID($str, &$account, &$folder, &$appid = null) |
|
| 2049 | 2048 | { |
| 2050 | 2049 | $this->backend->splitID($str, $account, $folder, $appid); |
| 2051 | 2050 | |
| 2052 | 2051 | // convert numeric folder-id back to folder name |
| 2053 | - $folder = $this->hash2folder($account,$f=$folder); |
|
| 2052 | + $folder = $this->hash2folder($account, $f = $folder); |
|
| 2054 | 2053 | |
| 2055 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2054 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2056 | 2055 | } |
| 2057 | 2056 | |
| 2058 | 2057 | /** |
@@ -2069,9 +2068,9 @@ discard block |
||
| 2069 | 2068 | * @param string $folder |
| 2070 | 2069 | * @return int |
| 2071 | 2070 | */ |
| 2072 | - private function folder2hash($account,$folder) |
|
| 2071 | + private function folder2hash($account, $folder) |
|
| 2073 | 2072 | { |
| 2074 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2073 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2075 | 2074 | |
| 2076 | 2075 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2077 | 2076 | { |
@@ -2092,9 +2091,9 @@ discard block |
||
| 2092 | 2091 | * @param int $index |
| 2093 | 2092 | * @return string NULL if not used so far |
| 2094 | 2093 | */ |
| 2095 | - private function hash2folder($account,$index) |
|
| 2094 | + private function hash2folder($account, $index) |
|
| 2096 | 2095 | { |
| 2097 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2096 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2098 | 2097 | |
| 2099 | 2098 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2100 | 2099 | } |
@@ -2150,9 +2149,9 @@ discard block |
||
| 2150 | 2149 | if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
| 2151 | 2150 | ($hashes = file_get_contents($file))) |
| 2152 | 2151 | { |
| 2153 | - $this->folderHashes = json_decode($hashes,true); |
|
| 2152 | + $this->folderHashes = json_decode($hashes, true); |
|
| 2154 | 2153 | // fallback in case hashes have been serialized instead of being json-encoded |
| 2155 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
| 2154 | + if (json_last_error() != JSON_ERROR_NONE) |
|
| 2156 | 2155 | { |
| 2157 | 2156 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
| 2158 | 2157 | $this->folderHashes = unserialize($hashes); |
@@ -2198,9 +2197,9 @@ discard block |
||
| 2198 | 2197 | * @param boolean $old =false true: return old / pre-15 hash-file |
| 2199 | 2198 | * @throws Api\Exception\AssertionFailed |
| 2200 | 2199 | */ |
| 2201 | - private function hashFile($old=false) |
|
| 2200 | + private function hashFile($old = false) |
|
| 2202 | 2201 | { |
| 2203 | - if (!($dev_id=Request::GetDeviceID())) |
|
| 2202 | + if (!($dev_id = Request::GetDeviceID())) |
|
| 2204 | 2203 | { |
| 2205 | 2204 | throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
| 2206 | 2205 | } |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | * @param string $folderid folder of meeting request mail |
| 1201 | 1201 | * @param int|string $requestid uid of mail with meeting request |
| 1202 | 1202 | * @param int $response 1=accepted, 2=tentative, 3=decline |
| 1203 | - * @return int|boolean id of calendar item, false on error |
|
| 1203 | + * @return null|boolean id of calendar item, false on error |
|
| 1204 | 1204 | */ |
| 1205 | 1205 | function MeetingResponse($folderid, $requestid, $response) |
| 1206 | 1206 | { |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | * @param string $newfolderid id of the destination folder |
| 1359 | 1359 | * @param ContentParameters $contentParameters |
| 1360 | 1360 | * |
| 1361 | - * @return boolean status of the operation |
|
| 1361 | + * @return string status of the operation |
|
| 1362 | 1362 | * @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions |
| 1363 | 1363 | */ |
| 1364 | 1364 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
@@ -1755,6 +1755,7 @@ discard block |
||
| 1755 | 1755 | * the folder has not changed. In practice this means that 'mod' can be equal to the folder name |
| 1756 | 1756 | * as this is the only thing that ever changes in folders. (the type is normally constant) |
| 1757 | 1757 | * |
| 1758 | + * @param string $id |
|
| 1758 | 1759 | * @return array with values for keys 'id', 'mod' and 'parent' |
| 1759 | 1760 | */ |
| 1760 | 1761 | public function StatFolder($id) |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | 'flags' => array( |
| 25 | 25 | 'noheader' => True, |
| 26 | 26 | 'currentapp' => 'mail', |
| 27 | - 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
| 27 | + 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
| 28 | 28 | 'autocreate_session_callback' => 'EGroupware\\Api\\Header\\Authenticate::autocreate_session_callback', |
| 29 | 29 | // use same REALM as CalDAV/CardDAV eM Client already uses |
| 30 | - 'auth_realm' => 'EGroupware CalDAV/CardDAV/GroupDAV server', // cant use groupdav::REALM as autoloading and include path not yet setup! |
|
| 30 | + 'auth_realm' => 'EGroupware CalDAV/CardDAV/GroupDAV server', // cant use groupdav::REALM as autoloading and include path not yet setup! |
|
| 31 | 31 | ) |
| 32 | 32 | ); |
| 33 | 33 | // if you move this file somewhere else, you need to adapt the path to the header! |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | $xml->startDocument('1.0', 'UTF-8'); |
| 43 | 43 | $xml->startElement('signatures'); |
| 44 | 44 | |
| 45 | -foreach(Api\Mail\Account::search(true, false) as $acc_id => $account) |
|
| 45 | +foreach (Api\Mail\Account::search(true, false) as $acc_id => $account) |
|
| 46 | 46 | { |
| 47 | - foreach($account->identities($account, true, 'params') as $ident_id => $identity) |
|
| 47 | + foreach ($account->identities($account, true, 'params') as $ident_id => $identity) |
|
| 48 | 48 | { |
| 49 | 49 | // dont write empty signatures |
| 50 | 50 | if (strlen(trim(strip_tags($identity['ident_signature']))) < 10) continue; |
| 51 | 51 | |
| 52 | 52 | // check if we have an non-empty email address |
| 53 | - foreach(array($identity['ident_email'], $account->ident_email, $account->acc_imap_username, |
|
| 53 | + foreach (array($identity['ident_email'], $account->ident_email, $account->acc_imap_username, |
|
| 54 | 54 | $GLOBALS['egw_info']['user']['account_email']) as $email) |
| 55 | 55 | { |
| 56 | 56 | if (strpos($email, '@')) break; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | if (!strpos($email, '@')) continue; |
| 59 | 59 | |
| 60 | 60 | $xml->startElement('signature'); |
| 61 | - $xml->writeAttribute('name', Api\Mail\Account::identity_name($identity+$account->params, true)); |
|
| 61 | + $xml->writeAttribute('name', Api\Mail\Account::identity_name($identity + $account->params, true)); |
|
| 62 | 62 | $xml->writeAttribute('allow-edit', 'true'); |
| 63 | 63 | $xml->writeAttribute('overwrite', 'true'); |
| 64 | 64 | $xml->writeAttribute('targetMail', $email.' <mailto:'.$email.'>'); |
@@ -47,15 +47,24 @@ |
||
| 47 | 47 | foreach($account->identities($account, true, 'params') as $ident_id => $identity) |
| 48 | 48 | { |
| 49 | 49 | // dont write empty signatures |
| 50 | - if (strlen(trim(strip_tags($identity['ident_signature']))) < 10) continue; |
|
| 50 | + if (strlen(trim(strip_tags($identity['ident_signature']))) < 10) |
|
| 51 | + { |
|
| 52 | + continue; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | // check if we have an non-empty email address |
| 53 | 56 | foreach(array($identity['ident_email'], $account->ident_email, $account->acc_imap_username, |
| 54 | 57 | $GLOBALS['egw_info']['user']['account_email']) as $email) |
| 55 | 58 | { |
| 56 | - if (strpos($email, '@')) break; |
|
| 59 | + if (strpos($email, '@')) |
|
| 60 | + { |
|
| 61 | + break; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + if (!strpos($email, '@')) |
|
| 65 | + { |
|
| 66 | + continue; |
|
| 57 | 67 | } |
| 58 | - if (!strpos($email, '@')) continue; |
|
| 59 | 68 | |
| 60 | 69 | $xml->startElement('signature'); |
| 61 | 70 | $xml->writeAttribute('name', Api\Mail\Account::identity_name($identity+$account->params, true)); |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | function __construct() |
| 28 | 28 | { |
| 29 | 29 | $this->i18n = true; |
| 30 | - $this->arguments = array(); // get's set in get_user_interface |
|
| 30 | + $this->arguments = array(); // get's set in get_user_interface |
|
| 31 | 31 | $this->title = lang('Contactform'); |
| 32 | 32 | $this->description = lang('This module displays a contactform, that stores direct into the addressbook.'); |
| 33 | 33 | |
| 34 | 34 | $this->etemplate_method = 'addressbook.addressbook_contactform.display'; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - function get_content (&$arguments,$properties) |
|
| 37 | + function get_content(&$arguments, $properties) |
|
| 38 | 38 | { |
| 39 | 39 | $parent = parent::get_content($arguments, $properties); |
| 40 | 40 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | 'adr_one_locality' => lang('city').' + '.lang('zip code'), |
| 77 | 77 | 'sep3' => '----------------------------', |
| 78 | 78 | ); |
| 79 | - foreach($uicontacts->customfields as $name => $data) |
|
| 79 | + foreach ($uicontacts->customfields as $name => $data) |
|
| 80 | 80 | { |
| 81 | 81 | $fields['#'.$name] = $data['label']; |
| 82 | 82 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | 'label' => lang('Addressbook the contact should be saved to').' ('.lang('The anonymous user needs add rights for it!').')', |
| 94 | 94 | 'options' => array( |
| 95 | 95 | '' => lang('None'), |
| 96 | - )+$uicontacts->get_addressbooks(Acl::ADD) // add to not show the accounts! |
|
| 96 | + ) + $uicontacts->get_addressbooks(Acl::ADD) // add to not show the accounts! |
|
| 97 | 97 | ), |
| 98 | 98 | 'arg4' => array( |
| 99 | 99 | 'type' => 'textfield', |
@@ -89,6 +89,7 @@ |
||
| 89 | 89 | * @param int $weekend weekend option |
| 90 | 90 | * @param int $min_days min_days option |
| 91 | 91 | * @param int $unit unit option |
| 92 | + * @param integer $end_range |
|
| 92 | 93 | * |
| 93 | 94 | */ |
| 94 | 95 | public function process_days(&$events_log, &$week_sum, &$day,$day_index, $events, $cat_id, $holidays, $weekend, $min_days, $unit, $start_range, $end_range) |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * of time (hour|minute|second). |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | -class calendar_category_report extends calendar_ui{ |
|
| 29 | +class calendar_category_report extends calendar_ui |
|
| 30 | +{ |
|
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | 33 | * Public functions allowed to get called |
@@ -71,7 +72,10 @@ discard block |
||
| 71 | 72 | $date = date('Ymd', $_date); |
| 72 | 73 | foreach ($holidays[$date] as $holiday) |
| 73 | 74 | { |
| 74 | - if (is_array($holiday) && !$holiday['birthyear']) return true; |
|
| 75 | + if (is_array($holiday) && !$holiday['birthyear']) |
|
| 76 | + { |
|
| 77 | + return true; |
|
| 78 | + } |
|
| 75 | 79 | } |
| 76 | 80 | return false; |
| 77 | 81 | } |
@@ -98,10 +102,16 @@ discard block |
||
| 98 | 102 | foreach ($event['participants'] as $user_id => $status) |
| 99 | 103 | { |
| 100 | 104 | // if the participant has not accepted the event, not a chair or not an user then skip. |
| 101 | - if (!($status == 'A' || $status == 'ACHAIR') || preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$user_id)) continue; |
|
| 105 | + if (!($status == 'A' || $status == 'ACHAIR') || preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$user_id)) |
|
| 106 | + { |
|
| 107 | + continue; |
|
| 108 | + } |
|
| 102 | 109 | |
| 103 | 110 | $categories = explode(',', $event['category']); |
| 104 | - if (!in_array($cat_id, $categories)) continue; |
|
| 111 | + if (!in_array($cat_id, $categories)) |
|
| 112 | + { |
|
| 113 | + continue; |
|
| 114 | + } |
|
| 105 | 115 | |
| 106 | 116 | // processing day as timestamp |
| 107 | 117 | $day_timestamp = strtotime($day_index); |
@@ -169,10 +179,13 @@ discard block |
||
| 169 | 179 | { |
| 170 | 180 | $amount = $event['end'] - $start_range; |
| 171 | 181 | } |
| 172 | - else if ($is_over_end_range) // over end range multidays event |
|
| 182 | + else if ($is_over_end_range) |
|
| 183 | + { |
|
| 184 | + // over end range multidays event |
|
| 173 | 185 | { |
| 174 | 186 | $amount = $end_range - $event['start']; |
| 175 | 187 | } |
| 188 | + } |
|
| 176 | 189 | else |
| 177 | 190 | { |
| 178 | 191 | $amount = $event['end'] - $event['start']; |
@@ -205,7 +218,8 @@ discard block |
||
| 205 | 218 | * @param array $days array of days |
| 206 | 219 | * @return int returns sum of amount of events |
| 207 | 220 | */ |
| 208 | - public static function add_days ($days) { |
|
| 221 | + public static function add_days ($days) |
|
| 222 | + { |
|
| 209 | 223 | $sum = 0; |
| 210 | 224 | foreach ($days as $val) |
| 211 | 225 | { |
@@ -379,7 +393,10 @@ discard block |
||
| 379 | 393 | $cats_row [$cat_id] = ceil($cats_data[$cat_id]['amount']? |
| 380 | 394 | ($cats_data[$cat_id]['amount'] - $events_log['reductions'][$user_id][$cat_id]) / |
| 381 | 395 | $cats_data[$cat_id]['unit']: 0); |
| 382 | - if ($cats_data[$cat_id]['unit'] == 86400) $cats_row [$cat_id] = $cats_data[$cat_id]['days']; |
|
| 396 | + if ($cats_data[$cat_id]['unit'] == 86400) |
|
| 397 | + { |
|
| 398 | + $cats_row [$cat_id] = $cats_data[$cat_id]['days']; |
|
| 399 | + } |
|
| 383 | 400 | } |
| 384 | 401 | // first name |
| 385 | 402 | $n_given = array('n_given' => Api\Accounts::id2name($user_id, 'account_firstname')) ? |
@@ -390,8 +407,10 @@ discard block |
||
| 390 | 407 | $raw_csv[] = $n_family + $n_given+ $cats_row; |
| 391 | 408 | } |
| 392 | 409 | // comparision function for usort |
| 393 | - function compareByFamily ($key='n_family') { |
|
| 394 | - return function ($a, $b) use ($key){ |
|
| 410 | + function compareByFamily ($key='n_family') |
|
| 411 | + { |
|
| 412 | + return function ($a, $b) use ($key) |
|
| 413 | + { |
|
| 395 | 414 | return strcasecmp($a[$key], $b[$key]); |
| 396 | 415 | }; |
| 397 | 416 | } |
@@ -405,7 +424,10 @@ discard block |
||
| 405 | 424 | $check_row += $val; |
| 406 | 425 | } |
| 407 | 426 | //check if all values of the row is zero then escape the row |
| 408 | - if (!$check_row) continue; |
|
| 427 | + if (!$check_row) |
|
| 428 | + { |
|
| 429 | + continue; |
|
| 430 | + } |
|
| 409 | 431 | |
| 410 | 432 | // printout each row into file |
| 411 | 433 | fputcsv($fp, array_values($row)); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * of time (hour|minute|second). |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | -class calendar_category_report extends calendar_ui{ |
|
| 29 | +class calendar_category_report extends calendar_ui { |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Public functions allowed to get called |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | function __construct() |
| 44 | 44 | { |
| 45 | - parent::__construct(true); // call the parent's constructor |
|
| 45 | + parent::__construct(true); // call the parent's constructor |
|
| 46 | 46 | $this->tmpl = new Api\Etemplate('calendar.category_report'); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public static function isWeekend($date) |
| 57 | 57 | { |
| 58 | - return (date('N',$date) >= 6); |
|
| 58 | + return (date('N', $date) >= 6); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function isHoliday($_date) |
| 69 | 69 | { |
| 70 | - $holidays = $this->bo->read_holidays(date('Y', $_date)); |
|
| 70 | + $holidays = $this->bo->read_holidays(date('Y', $_date)); |
|
| 71 | 71 | $date = date('Ymd', $_date); |
| 72 | 72 | foreach ($holidays[$date] as $holiday) |
| 73 | 73 | { |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | * @param int $unit unit option |
| 92 | 92 | * |
| 93 | 93 | */ |
| 94 | - public function process_days(&$events_log, &$week_sum, &$day,$day_index, $events, $cat_id, $holidays, $weekend, $min_days, $unit, $start_range, $end_range) |
|
| 94 | + public function process_days(&$events_log, &$week_sum, &$day, $day_index, $events, $cat_id, $holidays, $weekend, $min_days, $unit, $start_range, $end_range) |
|
| 95 | 95 | { |
| 96 | 96 | foreach ($events as &$event) |
| 97 | 97 | { |
| 98 | 98 | foreach ($event['participants'] as $user_id => $status) |
| 99 | 99 | { |
| 100 | 100 | // if the participant has not accepted the event, not a chair or not an user then skip. |
| 101 | - if (!($status == 'A' || $status == 'ACHAIR') || preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$user_id)) continue; |
|
| 101 | + if (!($status == 'A' || $status == 'ACHAIR') || preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $user_id)) continue; |
|
| 102 | 102 | |
| 103 | 103 | $categories = explode(',', $event['category']); |
| 104 | 104 | if (!in_array($cat_id, $categories)) continue; |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | // week number |
| 110 | 110 | $week_number = ltrim(date('W', $day_timestamp), '0'); |
| 111 | 111 | |
| 112 | - $previous_week_number = $week_number == 1? ($events_log[$user_id]['53']? 53: 52): $week_number -1; |
|
| 112 | + $previous_week_number = $week_number == 1 ? ($events_log[$user_id]['53'] ? 53 : 52) : $week_number - 1; |
|
| 113 | 113 | // check if multidays event starts before start range |
| 114 | - $is_over_range_event = $day_timestamp< $event['end'] && $start_range > $event['start']; |
|
| 114 | + $is_over_range_event = $day_timestamp < $event['end'] && $start_range > $event['start']; |
|
| 115 | 115 | // check if multidays event ends after end range |
| 116 | - $is_over_end_range = $day_timestamp< $event['end'] && $end_range < $event['end']; |
|
| 116 | + $is_over_end_range = $day_timestamp < $event['end'] && $end_range < $event['end']; |
|
| 117 | 117 | |
| 118 | - $is_multiple_days_event = $event['start']< $day_timestamp && $day_timestamp< $event['end']; |
|
| 118 | + $is_multiple_days_event = $event['start'] < $day_timestamp && $day_timestamp < $event['end']; |
|
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | if (($weekend && self::isWeekend($day_timestamp)) || (!$holidays && $this->isHoliday($day_timestamp))) |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | if ($is_multiple_days_event) |
| 126 | 126 | { |
| 127 | 127 | $day_diff_to_end = $event['end'] - $day_timestamp; |
| 128 | - $reduction_amount = $day_diff_to_end > 86400? 86400: $day_diff_to_end; |
|
| 128 | + $reduction_amount = $day_diff_to_end > 86400 ? 86400 : $day_diff_to_end; |
|
| 129 | 129 | $events_log['reductions'][$user_id][$cat_id] = $events_log['reductions'][$user_id][$cat_id] + $reduction_amount; |
| 130 | 130 | } |
| 131 | 131 | continue; |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | // Mark multidays event as counted after the first day of event, therefore |
| 135 | 135 | // we can procced calculating the amount of the event via the first day |
| 136 | 136 | // and mark as counted for the rest of the days to avoid miscalculation. |
| 137 | - if ($event['start']< $day_timestamp && $day_timestamp< $event['end'] && |
|
| 137 | + if ($event['start'] < $day_timestamp && $day_timestamp < $event['end'] && |
|
| 138 | 138 | ($events_log[$user_id][$week_number][$event['id']]['counted'] || |
| 139 | 139 | $events_log[$user_id][$previous_week_number][$event['id']]['counted'])) |
| 140 | 140 | { |
| 141 | 141 | $events_log[$user_id][$week_number][$event['id']]['counted'] = true; |
| 142 | - $events_log[$user_id][$week_number][$event['id']]['over_range'] = $is_over_range_event? true: false; |
|
| 142 | + $events_log[$user_id][$week_number][$event['id']]['over_range'] = $is_over_range_event ? true: false; |
|
| 143 | 143 | } |
| 144 | 144 | // In case of start range is in middle of multidays event, we need to calculate the |
| 145 | 145 | // amount base on the part of event on the range and keep track of counting to avoid |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | else if ($is_over_range_event) |
| 169 | 169 | { |
| 170 | - $amount = $event['end'] - $start_range; |
|
| 170 | + $amount = $event['end'] - $start_range; |
|
| 171 | 171 | } |
| 172 | 172 | else if ($is_over_end_range) // over end range multidays event |
| 173 | 173 | { |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $events_log[$user_id][$week_number][$event['id']]['counted'] = true; |
| 181 | 181 | } |
| 182 | 182 | // store day |
| 183 | - $day[$user_id][$cat_id][$event['id']] = array ( |
|
| 183 | + $day[$user_id][$cat_id][$event['id']] = array( |
|
| 184 | 184 | 'weekN' => date('W', $event['start']), |
| 185 | 185 | 'cat_id' => $cat_id, |
| 186 | 186 | 'event_id' => $event['id'], |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @param array $days array of days |
| 206 | 206 | * @return int returns sum of amount of events |
| 207 | 207 | */ |
| 208 | - public static function add_days ($days) { |
|
| 208 | + public static function add_days($days) { |
|
| 209 | 209 | $sum = 0; |
| 210 | 210 | foreach ($days as $val) |
| 211 | 211 | { |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @param type $content |
| 221 | 221 | */ |
| 222 | - public function index ($content = null) |
|
| 222 | + public function index($content = null) |
|
| 223 | 223 | { |
| 224 | - $api_cats = new Api\Categories($GLOBALS['egw_info']['user']['account_id'],'calendar'); |
|
| 224 | + $api_cats = new Api\Categories($GLOBALS['egw_info']['user']['account_id'], 'calendar'); |
|
| 225 | 225 | if (is_null($content)) |
| 226 | 226 | { |
| 227 | - $cats = $api_cats->return_sorted_array($start=0, false, '', 'ASC', 'cat_name', true, 0, true); |
|
| 227 | + $cats = $api_cats->return_sorted_array($start = 0, false, '', 'ASC', 'cat_name', true, 0, true); |
|
| 228 | 228 | $cats_status = $GLOBALS['egw_info']['user']['preferences']['calendar']['category_report']; |
| 229 | 229 | foreach ($cats as &$value) |
| 230 | 230 | { |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | else |
| 247 | 247 | { |
| 248 | 248 | list($button) = @each($content['button']); |
| 249 | - $result = $categories = $content_rows = array (); |
|
| 249 | + $result = $categories = $content_rows = array(); |
|
| 250 | 250 | $users = array_keys($GLOBALS['egw']->accounts->search(array('type'=>'accounts', active=>true))); |
| 251 | 251 | |
| 252 | 252 | // report button pressed |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | // shift the grid content by one because of the reserved first row |
| 256 | 256 | // for the header. |
| 257 | 257 | array_shift($content['grid']); |
| 258 | - Api\Framework::ajax_set_preference('calendar', 'category_report',$content['grid']); |
|
| 258 | + Api\Framework::ajax_set_preference('calendar', 'category_report', $content['grid']); |
|
| 259 | 259 | |
| 260 | 260 | foreach ($content['grid'] as $key => $row) |
| 261 | 261 | { |
@@ -268,14 +268,14 @@ discard block |
||
| 268 | 268 | // query calendar for events |
| 269 | 269 | $events = $this->bo->search(array( |
| 270 | 270 | 'start' => $content['start'], |
| 271 | - 'end' => $content['end']+86399, // range till midnight of the sele3cted end date |
|
| 271 | + 'end' => $content['end'] + 86399, // range till midnight of the sele3cted end date |
|
| 272 | 272 | 'users' => $users, |
| 273 | 273 | 'cat_id' => $categories, |
| 274 | 274 | 'daywise' => true |
| 275 | 275 | )); |
| 276 | - $days_sum = $weeks_sum = $events_log = array (); |
|
| 276 | + $days_sum = $weeks_sum = $events_log = array(); |
|
| 277 | 277 | // iterate over found events |
| 278 | - foreach($events as $day_index => $day_events) |
|
| 278 | + foreach ($events as $day_index => $day_events) |
|
| 279 | 279 | { |
| 280 | 280 | if (is_array($day_events)) |
| 281 | 281 | { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $content['grid'][$row_id]['min_days'], |
| 294 | 294 | $content['grid'][$row_id]['unit'], |
| 295 | 295 | $content['start'], |
| 296 | - $content['end']+86399 // range till midnight of the selected end date |
|
| 296 | + $content['end'] + 86399 // range till midnight of the selected end date |
|
| 297 | 297 | ); |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | asort($days_sum); |
| 303 | 303 | ksort($days_sum); |
| 304 | - $days_output = $min_days_output = array (); |
|
| 304 | + $days_output = $min_days_output = array(); |
|
| 305 | 305 | |
| 306 | - foreach($days_sum as $day_index => $users) |
|
| 306 | + foreach ($days_sum as $day_index => $users) |
|
| 307 | 307 | { |
| 308 | 308 | foreach ($users as $user_id => $cat_ids) |
| 309 | 309 | { |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | $days = $weeks_sum[$user_id][$week_id][$cat_id][$event_id]; |
| 334 | 334 | $min_days_output[$user_id][$cat_id]['amount'] = |
| 335 | 335 | $min_days_output[$user_id][$cat_id]['amount'] + |
| 336 | - (count($days) >= (int)$events['min_days']?self::add_days($days):0); |
|
| 336 | + (count($days) >= (int)$events['min_days'] ?self::add_days($days) : 0); |
|
| 337 | 337 | $min_days_output[$user_id][$cat_id]['days'] = |
| 338 | 338 | $min_days_output[$user_id][$cat_id]['days'] + |
| 339 | - (count($days) >= (int)$events['min_days']?count($days):0); |
|
| 339 | + (count($days) >= (int)$events['min_days'] ?count($days) : 0); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | // ] |
| 353 | 353 | // |
| 354 | 354 | $result = array_replace_recursive($days_output, $min_days_output); |
| 355 | - $raw_csv = $csv_header = array (); |
|
| 355 | + $raw_csv = $csv_header = array(); |
|
| 356 | 356 | |
| 357 | 357 | // create csv header |
| 358 | 358 | foreach ($categories as $cat_id) |
@@ -379,22 +379,22 @@ discard block |
||
| 379 | 379 | $cats_row = array(); |
| 380 | 380 | foreach ($categories as $cat_id) |
| 381 | 381 | { |
| 382 | - $cats_row [$cat_id] = ceil($cats_data[$cat_id]['amount']? |
|
| 382 | + $cats_row [$cat_id] = ceil($cats_data[$cat_id]['amount'] ? |
|
| 383 | 383 | ($cats_data[$cat_id]['amount'] - $events_log['reductions'][$user_id][$cat_id]) / |
| 384 | - $cats_data[$cat_id]['unit']: 0); |
|
| 384 | + $cats_data[$cat_id]['unit'] : 0); |
|
| 385 | 385 | if ($cats_data[$cat_id]['unit'] == 86400) $cats_row [$cat_id] = $cats_data[$cat_id]['days']; |
| 386 | 386 | } |
| 387 | 387 | // first name |
| 388 | - $n_given = array('n_given' => Api\Accounts::id2name($user_id, 'account_firstname')) ? |
|
| 388 | + $n_given = array('n_given' => Api\Accounts::id2name($user_id, 'account_firstname')) ? |
|
| 389 | 389 | array('n_given' => Api\Accounts::id2name($user_id, 'account_firstname')) : array(); |
| 390 | 390 | // last name |
| 391 | 391 | $n_family = array('n_family' => Api\Accounts::id2name($user_id, 'account_lastname')) ? |
| 392 | 392 | array('n_family' => Api\Accounts::id2name($user_id, 'account_lastname')) : array(); |
| 393 | - $raw_csv[] = $n_family + $n_given+ $cats_row; |
|
| 393 | + $raw_csv[] = $n_family + $n_given + $cats_row; |
|
| 394 | 394 | } |
| 395 | 395 | // comparision function for usort |
| 396 | - function compareByFamily ($key='n_family') { |
|
| 397 | - return function ($a, $b) use ($key){ |
|
| 396 | + function compareByFamily($key = 'n_family') { |
|
| 397 | + return function($a, $b) use ($key){ |
|
| 398 | 398 | return strcasecmp($a[$key], $b[$key]); |
| 399 | 399 | }; |
| 400 | 400 | } |
@@ -420,14 +420,14 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // unit selectbox options |
| 423 | - $sel_options['unit'] = array ( |
|
| 423 | + $sel_options['unit'] = array( |
|
| 424 | 424 | 86400 => array('label' => lang('day'), 'title'=>'Output value in day'), |
| 425 | 425 | 3600 => array('label' => lang('hour'), 'title'=>'Output value in hour'), |
| 426 | 426 | 60 => array('label' => lang('minute'), 'title'=>'Output value in minute'), |
| 427 | 427 | 1 => array('label' => lang('second'), 'title'=>'Output value in second') |
| 428 | 428 | ); |
| 429 | 429 | // Add an extra row for the grid header |
| 430 | - array_unshift($content['grid'],array(''=> '')); |
|
| 430 | + array_unshift($content['grid'], array(''=> '')); |
|
| 431 | 431 | $preserv = $content; |
| 432 | 432 | $this->tmpl->exec('calendar.calendar_category_report.index', $content, $sel_options, array(), $preserv, 2); |
| 433 | 433 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $etag = '"'.md5($holidays).'"'; |
| 38 | 38 | |
| 39 | 39 | // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header |
| 40 | -Api\Session::cache_control(86400); // cache for one day |
|
| 40 | +Api\Session::cache_control(86400); // cache for one day |
|
| 41 | 41 | Header('Content-Type: application/json; charset=utf-8'); |
| 42 | 42 | Header('ETag: '.$etag); |
| 43 | 43 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | function timesheet_upgrade0_1_001() |
| 17 | 17 | { |
| 18 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet','pl_id',array( |
|
| 18 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet', 'pl_id', array( |
|
| 19 | 19 | 'type' => 'int', |
| 20 | 20 | 'precision' => '4', |
| 21 | 21 | 'default' => '0' |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | function timesheet_upgrade0_2_001() |
| 29 | 29 | { |
| 30 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_timesheet_extra',array( |
|
| 30 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_timesheet_extra', array( |
|
| 31 | 31 | 'fd' => array( |
| 32 | - 'ts_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 33 | - 'ts_extra_name' => array('type' => 'varchar','precision' => '32','nullable' => False), |
|
| 34 | - 'ts_extra_value' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '') |
|
| 32 | + 'ts_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 33 | + 'ts_extra_name' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False), |
|
| 34 | + 'ts_extra_value' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '') |
|
| 35 | 35 | ), |
| 36 | - 'pk' => array('ts_id','ts_extra_name'), |
|
| 36 | + 'pk' => array('ts_id', 'ts_extra_name'), |
|
| 37 | 37 | 'fk' => array(), |
| 38 | 38 | 'ix' => array(), |
| 39 | 39 | 'uc' => array() |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | function timesheet_upgrade1_4() |
| 53 | 53 | { |
| 54 | 54 | // delete empty cf's generated by 1.4 |
| 55 | - $GLOBALS['egw_setup']->db->delete('egw_timesheet_extra',"ts_extra_value=''",__LINE__,__FILE__,'timesheet'); |
|
| 55 | + $GLOBALS['egw_setup']->db->delete('egw_timesheet_extra', "ts_extra_value=''", __LINE__, __FILE__, 'timesheet'); |
|
| 56 | 56 | |
| 57 | 57 | return $GLOBALS['setup_info']['timesheet']['currentver'] = '1.6'; |
| 58 | 58 | } |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | function timesheet_upgrade1_6() |
| 62 | 62 | { |
| 63 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet','ts_status',array( |
|
| 63 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet', 'ts_status', array( |
|
| 64 | 64 | 'type' => 'int', |
| 65 | 65 | 'precision' => '4' |
| 66 | 66 | )); |
| 67 | 67 | |
| 68 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_timesheet','ts_status'); |
|
| 68 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_timesheet', 'ts_status'); |
|
| 69 | 69 | |
| 70 | 70 | return $GLOBALS['setup_info']['timesheet']['currentver'] = '1.7.001'; |
| 71 | 71 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | function timesheet_upgrade1_9_001() |
| 94 | 94 | { |
| 95 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_project',array( |
|
| 95 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet', 'ts_project', array( |
|
| 96 | 96 | 'type' => 'varchar', |
| 97 | 97 | 'precision' => '255', |
| 98 | 98 | 'comment' => 'project title' |
| 99 | 99 | )); |
| 100 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_title',array( |
|
| 100 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet', 'ts_title', array( |
|
| 101 | 101 | 'type' => 'varchar', |
| 102 | 102 | 'precision' => '255', |
| 103 | 103 | 'nullable' => False, |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | // returns NULL, if there are no rows! |
| 109 | 109 | if ((int)$max_description_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384) |
| 110 | 110 | { |
| 111 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_description',array( |
|
| 111 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet', 'ts_description', array( |
|
| 112 | 112 | 'type' => 'varchar', |
| 113 | 113 | 'precision' => '16384', |
| 114 | 114 | 'comment' => 'description of the timesheet entry' |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | function timesheet_upgrade16_1() |
| 136 | 136 | { |
| 137 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet','ts_created',array( |
|
| 137 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet', 'ts_created', array( |
|
| 138 | 138 | 'type' => 'int', |
| 139 | 139 | 'meta' => 'timestamp', |
| 140 | 140 | 'precision' => '8', |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | // Initialize to start |
| 144 | 144 | $GLOBALS['egw']->db->query('UPDATE egw_timesheet set ts_created = ts_start'); |
| 145 | 145 | |
| 146 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet','ts_created',array( |
|
| 146 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet', 'ts_created', array( |
|
| 147 | 147 | 'type' => 'int', |
| 148 | 148 | 'meta' => 'timestamp', |
| 149 | 149 | 'precision' => '8', |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | function timesheet_upgrade17_1() |
| 157 | 157 | { |
| 158 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet_extra','ts_extra_name',array( |
|
| 158 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet_extra', 'ts_extra_name', array( |
|
| 159 | 159 | 'type' => 'varchar', |
| 160 | 160 | 'meta' => 'cfname', |
| 161 | 161 | 'precision' => '64', |
| 162 | 162 | 'nullable' => False |
| 163 | 163 | )); |
| 164 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet_extra','ts_extra_value',array( |
|
| 164 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_timesheet_extra', 'ts_extra_value', array( |
|
| 165 | 165 | 'type' => 'varchar', |
| 166 | 166 | 'meta' => 'cfvalue', |
| 167 | 167 | 'precision' => '16384', |
@@ -14,34 +14,34 @@ |
||
| 14 | 14 | $phpgw_baseline = array( |
| 15 | 15 | 'egw_timesheet' => array( |
| 16 | 16 | 'fd' => array( |
| 17 | - 'ts_id' => array('type' => 'auto','nullable' => False,'comment' => 'id of the timesheet entry'), |
|
| 18 | - 'ts_project' => array('type' => 'varchar','precision' => '255','comment' => 'project title'), |
|
| 19 | - 'ts_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'title of the timesheet entry'), |
|
| 20 | - 'ts_description' => array('type' => 'varchar','precision' => '16384','comment' => 'description of the timesheet entry'), |
|
| 21 | - 'ts_start' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'timestamp of the startdate'), |
|
| 22 | - 'ts_duration' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'duration of the timesheet-entry'), |
|
| 23 | - 'ts_quantity' => array('type' => 'float','precision' => '8','nullable' => False,'comment' => 'quantity'), |
|
| 24 | - 'ts_unitprice' => array('type' => 'float','precision' => '4','comment' => 'unitprice'), |
|
| 25 | - 'cat_id' => array('type' => 'int','meta' => 'category','precision' => '4','default' => '0','comment' => 'category'), |
|
| 26 | - 'ts_owner' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'owner of the timesheet'), |
|
| 27 | - 'ts_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'date modified ot the timesheet'), |
|
| 28 | - 'ts_modifier' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'account id of the last modifier'), |
|
| 29 | - 'pl_id' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'id of the linked project'), |
|
| 30 | - 'ts_status' => array('type' => 'int','precision' => '4','comment' => 'status of the timesheet-entry'), |
|
| 31 | - 'ts_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'Creation date of the timesheet') |
|
| 17 | + 'ts_id' => array('type' => 'auto', 'nullable' => False, 'comment' => 'id of the timesheet entry'), |
|
| 18 | + 'ts_project' => array('type' => 'varchar', 'precision' => '255', 'comment' => 'project title'), |
|
| 19 | + 'ts_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'comment' => 'title of the timesheet entry'), |
|
| 20 | + 'ts_description' => array('type' => 'varchar', 'precision' => '16384', 'comment' => 'description of the timesheet entry'), |
|
| 21 | + 'ts_start' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'timestamp of the startdate'), |
|
| 22 | + 'ts_duration' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0', 'comment' => 'duration of the timesheet-entry'), |
|
| 23 | + 'ts_quantity' => array('type' => 'float', 'precision' => '8', 'nullable' => False, 'comment' => 'quantity'), |
|
| 24 | + 'ts_unitprice' => array('type' => 'float', 'precision' => '4', 'comment' => 'unitprice'), |
|
| 25 | + 'cat_id' => array('type' => 'int', 'meta' => 'category', 'precision' => '4', 'default' => '0', 'comment' => 'category'), |
|
| 26 | + 'ts_owner' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False, 'comment' => 'owner of the timesheet'), |
|
| 27 | + 'ts_modified' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'date modified ot the timesheet'), |
|
| 28 | + 'ts_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False, 'comment' => 'account id of the last modifier'), |
|
| 29 | + 'pl_id' => array('type' => 'int', 'precision' => '4', 'default' => '0', 'comment' => 'id of the linked project'), |
|
| 30 | + 'ts_status' => array('type' => 'int', 'precision' => '4', 'comment' => 'status of the timesheet-entry'), |
|
| 31 | + 'ts_created' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'Creation date of the timesheet') |
|
| 32 | 32 | ), |
| 33 | 33 | 'pk' => array('ts_id'), |
| 34 | 34 | 'fk' => array(), |
| 35 | - 'ix' => array('ts_project','ts_owner','ts_status'), |
|
| 35 | + 'ix' => array('ts_project', 'ts_owner', 'ts_status'), |
|
| 36 | 36 | 'uc' => array() |
| 37 | 37 | ), |
| 38 | 38 | 'egw_timesheet_extra' => array( |
| 39 | 39 | 'fd' => array( |
| 40 | - 'ts_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 41 | - 'ts_extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '64','nullable' => False), |
|
| 42 | - 'ts_extra_value' => array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '') |
|
| 40 | + 'ts_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 41 | + 'ts_extra_name' => array('type' => 'varchar', 'meta' => 'cfname', 'precision' => '64', 'nullable' => False), |
|
| 42 | + 'ts_extra_value' => array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '16384', 'nullable' => False, 'default' => '') |
|
| 43 | 43 | ), |
| 44 | - 'pk' => array('ts_id','ts_extra_name'), |
|
| 44 | + 'pk' => array('ts_id', 'ts_extra_name'), |
|
| 45 | 45 | 'fk' => array(), |
| 46 | 46 | 'ix' => array(), |
| 47 | 47 | 'uc' => array() |
@@ -101,8 +101,7 @@ |
||
| 101 | 101 | /** |
| 102 | 102 | * imports entries according to given definition object. |
| 103 | 103 | * @param resource $_stream |
| 104 | - * @param string $_charset |
|
| 105 | - * @param definition $_definition |
|
| 104 | + * @param importexport_definition $_definition |
|
| 106 | 105 | */ |
| 107 | 106 | public function import( $_stream, importexport_definition $_definition ) { |
| 108 | 107 | |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | * import ical for infolog |
| 16 | 16 | * Not a lot of options for this, just uses the ical class |
| 17 | 17 | */ |
| 18 | -class infolog_import_ical implements importexport_iface_import_plugin { |
|
| 18 | +class infolog_import_ical implements importexport_iface_import_plugin { |
|
| 19 | 19 | |
| 20 | 20 | private static $plugin_options = array( |
| 21 | - 'conditions', /* => array containing condition arrays: |
|
| 21 | + 'conditions', /* => array containing condition arrays: |
|
| 22 | 22 | 'type' => exists, // exists |
| 23 | 23 | 'string' => '#kundennummer', |
| 24 | 24 | 'true' => array( |
@@ -79,19 +79,19 @@ discard block |
||
| 79 | 79 | * @param string $_charset |
| 80 | 80 | * @param definition $_definition |
| 81 | 81 | */ |
| 82 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 82 | + public function import($_stream, importexport_definition $_definition) { |
|
| 83 | 83 | |
| 84 | 84 | $this->definition = $_definition; |
| 85 | 85 | |
| 86 | 86 | // dry run? |
| 87 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
| 87 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
| 88 | 88 | |
| 89 | 89 | $success = 0; |
| 90 | 90 | |
| 91 | 91 | // Failures |
| 92 | 92 | $this->errors = array(); |
| 93 | 93 | |
| 94 | - @set_time_limit(0); // try switching execution time limit off |
|
| 94 | + @set_time_limit(0); // try switching execution time limit off |
|
| 95 | 95 | |
| 96 | 96 | $infolog_ical = new infolog_ical(); |
| 97 | 97 | if (!$infolog_ical->importVTODO(stream_get_contents($_stream))) |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * preserv => array, |
| 148 | 148 | * ) |
| 149 | 149 | */ |
| 150 | - public function get_options_etpl(importexport_definition &$definition=null) |
|
| 150 | + public function get_options_etpl(importexport_definition &$definition = null) |
|
| 151 | 151 | { |
| 152 | 152 | // lets do it! |
| 153 | 153 | } |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | * import ical for infolog |
| 16 | 16 | * Not a lot of options for this, just uses the ical class |
| 17 | 17 | */ |
| 18 | -class infolog_import_ical implements importexport_iface_import_plugin { |
|
| 18 | +class infolog_import_ical implements importexport_iface_import_plugin |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | private static $plugin_options = array( |
| 21 | 22 | 'conditions', /* => array containing condition arrays: |
@@ -79,7 +80,8 @@ discard block |
||
| 79 | 80 | * @param string $_charset |
| 80 | 81 | * @param definition $_definition |
| 81 | 82 | */ |
| 82 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 83 | + public function import( $_stream, importexport_definition $_definition ) |
|
| 84 | + { |
|
| 83 | 85 | |
| 84 | 86 | $this->definition = $_definition; |
| 85 | 87 | |
@@ -113,7 +115,8 @@ discard block |
||
| 113 | 115 | * |
| 114 | 116 | * @return string name |
| 115 | 117 | */ |
| 116 | - public static function get_name() { |
|
| 118 | + public static function get_name() |
|
| 119 | + { |
|
| 117 | 120 | return lang('Infolog iCal import'); |
| 118 | 121 | } |
| 119 | 122 | |
@@ -122,7 +125,8 @@ discard block |
||
| 122 | 125 | * |
| 123 | 126 | * @return string descriprion |
| 124 | 127 | */ |
| 125 | - public static function get_description() { |
|
| 128 | + public static function get_description() |
|
| 129 | + { |
|
| 126 | 130 | return lang("Imports TODOs into Infolog from an iCal File."); |
| 127 | 131 | } |
| 128 | 132 | |
@@ -131,7 +135,8 @@ discard block |
||
| 131 | 135 | * |
| 132 | 136 | * @return string suffix (comma seperated) |
| 133 | 137 | */ |
| 134 | - public static function get_filesuffix() { |
|
| 138 | + public static function get_filesuffix() |
|
| 139 | + { |
|
| 135 | 140 | return 'ics'; |
| 136 | 141 | } |
| 137 | 142 | |
@@ -157,7 +162,8 @@ discard block |
||
| 157 | 162 | * |
| 158 | 163 | * @return string etemplate name |
| 159 | 164 | */ |
| 160 | - public function get_selectors_etpl() { |
|
| 165 | + public function get_selectors_etpl() |
|
| 166 | + { |
|
| 161 | 167 | // lets do it! |
| 162 | 168 | } |
| 163 | 169 | |
@@ -169,7 +175,8 @@ discard block |
||
| 169 | 175 | * record_# => warning message |
| 170 | 176 | * ) |
| 171 | 177 | */ |
| 172 | - public function get_warnings() { |
|
| 178 | + public function get_warnings() |
|
| 179 | + { |
|
| 173 | 180 | return $this->warnings; |
| 174 | 181 | } |
| 175 | 182 | |
@@ -181,7 +188,8 @@ discard block |
||
| 181 | 188 | * record_# => error message |
| 182 | 189 | * ) |
| 183 | 190 | */ |
| 184 | - public function get_errors() { |
|
| 191 | + public function get_errors() |
|
| 192 | + { |
|
| 185 | 193 | return $this->errors; |
| 186 | 194 | } |
| 187 | 195 | |
@@ -193,7 +201,8 @@ discard block |
||
| 193 | 201 | * action => record count |
| 194 | 202 | * ) |
| 195 | 203 | */ |
| 196 | - public function get_results() { |
|
| 204 | + public function get_results() |
|
| 205 | + { |
|
| 197 | 206 | return $this->results; |
| 198 | 207 | } |
| 199 | 208 | } |