@@ -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' )"); |
@@ -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,83 +384,83 @@ 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 | // initialize the new Api\Mailer object for sending |
| 438 | 438 | $mailObject = new Api\Mailer(self::$profileID); |
| 439 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime,$force8bit); |
|
| 439 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime, $force8bit); |
|
| 440 | 440 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
| 441 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 442 | - $mailObject->setFrom($activeMailProfile['ident_email'],Mail::generateIdentityString($activeMailProfile,false)); |
|
| 441 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
| 442 | + $mailObject->setFrom($activeMailProfile['ident_email'], Mail::generateIdentityString($activeMailProfile, false)); |
|
| 443 | 443 | $mailObject->addHeader('X-Mailer', 'mail-Activesync'); |
| 444 | 444 | |
| 445 | 445 | // prepare addressee list; moved the adding of addresses to the mailobject down |
| 446 | 446 | // to |
| 447 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 447 | + foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
| 448 | 448 | if (!$addressObject->valid) continue; |
| 449 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
| 449 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
| 450 | 450 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 451 | 451 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 452 | 452 | } |
| 453 | 453 | // CC |
| 454 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 454 | + foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
| 455 | 455 | if (!$addressObject->valid) continue; |
| 456 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
| 456 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
| 457 | 457 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 458 | 458 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 459 | 459 | } |
| 460 | 460 | // BCC |
| 461 | - foreach($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 461 | + foreach ($mailObject->getAddresses('bcc') as $addressObject) { |
|
| 462 | 462 | if (!$addressObject->valid) continue; |
| 463 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
| 463 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
| 464 | 464 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
| 465 | 465 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
| 466 | 466 | } |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | $use_orgbody = false; |
| 470 | 470 | |
| 471 | 471 | $k = 'Content-Type'; |
| 472 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
| 472 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
| 473 | 473 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
| 474 | 474 | // if the message is a multipart message, then we should use the sent body |
| 475 | 475 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -489,43 +489,43 @@ discard block |
||
| 489 | 489 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
| 490 | 490 | $use_orgbody = true; |
| 491 | 491 | } |
| 492 | - $Body = $AltBody = ""; |
|
| 492 | + $Body = $AltBody = ""; |
|
| 493 | 493 | // get body of the transmitted message |
| 494 | 494 | // if this is a simple message, no structure at all |
| 495 | 495 | if (preg_match("/text/i", $ContentType)) |
| 496 | 496 | { |
| 497 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
| 497 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
| 498 | 498 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
| 499 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
| 500 | - if ($simpleBodyType == "text/plain") |
|
| 499 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
| 500 | + if ($simpleBodyType == "text/plain") |
|
| 501 | 501 | { |
| 502 | 502 | $Body = $body; |
| 503 | 503 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
| 504 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
| 504 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
| 505 | 505 | } |
| 506 | 506 | else |
| 507 | 507 | { |
| 508 | 508 | $AltBody = $body; |
| 509 | - $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 510 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
| 509 | + $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
| 510 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | else |
| 514 | 514 | { |
| 515 | 515 | // if this is a structured message |
| 516 | 516 | // prefer plain over html |
| 517 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 517 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 518 | 518 | ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
| 519 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
| 519 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
| 520 | 520 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
| 521 | 521 | } |
| 522 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
| 523 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
| 522 | + if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
| 523 | + if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
| 524 | 524 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
| 525 | 525 | // if this is a multipart message with a boundary, we must use the original body |
| 526 | 526 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
| 527 | 527 | if ($use_orgbody) { |
| 528 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 528 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
| 529 | 529 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
| 530 | 530 | if (($cal_body = $mailObject->findBody('calendar')) && |
| 531 | 531 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -534,21 +534,21 @@ discard block |
||
| 534 | 534 | { |
| 535 | 535 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
| 536 | 536 | } |
| 537 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 537 | + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
| 538 | 538 | $ClientSideMeetingRequest = true; |
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | // now handle the addressee list |
| 542 | 542 | $toCount = 0; |
| 543 | 543 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
| 544 | - foreach((array)$toMailAddr as $address) { |
|
| 545 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 546 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 544 | + foreach ((array)$toMailAddr as $address) { |
|
| 545 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 546 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 547 | 547 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
| 548 | 548 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
| 549 | 549 | $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
| 550 | 550 | { |
| 551 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 551 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
| 552 | 552 | continue; |
| 553 | 553 | } |
| 554 | 554 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
@@ -556,29 +556,29 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | $ccCount = 0; |
| 559 | - foreach((array)$ccMailAddr as $address) { |
|
| 560 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 561 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 559 | + foreach ((array)$ccMailAddr as $address) { |
|
| 560 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 561 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 562 | 562 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 563 | 563 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
| 564 | 564 | $ccCount++; |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | $bccCount = 0; |
| 568 | - foreach((array)$bccMailAddr as $address) { |
|
| 569 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 570 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 568 | + foreach ((array)$bccMailAddr as $address) { |
|
| 569 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 570 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 571 | 571 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
| 572 | 572 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
| 573 | 573 | $bccCount++; |
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
| 577 | - if ($toCount+$ccCount+$bccCount == 0) |
|
| 577 | + if ($toCount + $ccCount + $bccCount == 0) |
|
| 578 | 578 | { |
| 579 | 579 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
| 580 | 580 | } |
| 581 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
| 581 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
| 582 | 582 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
| 583 | 583 | /* |
| 584 | 584 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -595,26 +595,26 @@ discard block |
||
| 595 | 595 | { |
| 596 | 596 | // now get on, and fetch the original mail |
| 597 | 597 | $uid = $smartdata->source->itemid; |
| 598 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 598 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 599 | 599 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 600 | 600 | |
| 601 | 601 | $this->mail->reopen($folder); |
| 602 | 602 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 603 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 604 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 605 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 603 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 604 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 605 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 606 | 606 | // may be html |
| 607 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 607 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 608 | 608 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 609 | 609 | $isreply = true; |
| 610 | 610 | } |
| 611 | 611 | // plain text Message part |
| 612 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 612 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 613 | 613 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 614 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 615 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 616 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 617 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 614 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 615 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 616 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 617 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 618 | 618 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 619 | 619 | $isreply = true; |
| 620 | 620 | } |
@@ -622,12 +622,12 @@ discard block |
||
| 622 | 622 | { |
| 623 | 623 | $isreply = true; |
| 624 | 624 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 625 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 625 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 626 | 626 | } |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | // how to forward and other prefs |
| 630 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 630 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
| 631 | 631 | |
| 632 | 632 | // forward ------------------------------------------------------------------------- |
| 633 | 633 | if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | { |
| 638 | 638 | //force the default for the forwarding -> asmail |
| 639 | 639 | if (is_array($preferencesArray)) { |
| 640 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
| 640 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
| 641 | 641 | || !isset($preferencesArray['message_forwarding']) |
| 642 | 642 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
| 643 | 643 | } else { |
@@ -645,18 +645,18 @@ discard block |
||
| 645 | 645 | } |
| 646 | 646 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
| 647 | 647 | $uid = $smartdata->source->itemid; |
| 648 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 648 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 649 | 649 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 650 | 650 | |
| 651 | 651 | $this->mail->reopen($folder); |
| 652 | 652 | // receive entire mail (header + body) |
| 653 | 653 | // get message headers for specified message |
| 654 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 654 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
| 655 | 655 | // build a new mime message, forward entire old mail as file |
| 656 | 656 | if ($preferencesArray['message_forwarding'] == 'asmail') |
| 657 | 657 | { |
| 658 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
| 659 | - $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
| 658 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
| 659 | + $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
| 660 | 660 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
| 661 | 661 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
| 662 | 662 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -666,50 +666,50 @@ discard block |
||
| 666 | 666 | { |
| 667 | 667 | // now get on, and fetch the original mail |
| 668 | 668 | $uid = $smartdata->source->itemid; |
| 669 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 669 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 670 | 670 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 671 | 671 | |
| 672 | 672 | $this->mail->reopen($folder); |
| 673 | 673 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
| 674 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 675 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 676 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 674 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 675 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
| 676 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 677 | 677 | // may be html |
| 678 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 678 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
| 679 | 679 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
| 680 | 680 | $isforward = true; |
| 681 | 681 | } |
| 682 | 682 | // plain text Message part |
| 683 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 683 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
| 684 | 684 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
| 685 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
| 686 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 687 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
| 688 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 685 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
| 686 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 687 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
| 688 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
| 689 | 689 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
| 690 | 690 | $isforward = true; |
| 691 | 691 | } |
| 692 | 692 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
| 693 | 693 | { |
| 694 | 694 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
| 695 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 695 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
| 696 | 696 | $isforward = true; |
| 697 | 697 | } |
| 698 | 698 | // get all the attachments and add them too. |
| 699 | 699 | // start handle Attachments |
| 700 | 700 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
| 701 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
| 701 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
| 702 | 702 | $attachmentNames = false; |
| 703 | - if (is_array($attachments) && count($attachments)>0) |
|
| 703 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 704 | 704 | { |
| 705 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 706 | - foreach((array)$attachments as $key => $attachment) |
|
| 705 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
| 706 | + foreach ((array)$attachments as $key => $attachment) |
|
| 707 | 707 | { |
| 708 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 708 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
| 709 | 709 | $attachmentNames .= $attachment['name']."\n"; |
| 710 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
| 710 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
| 711 | 711 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $attachment['name'], $attachment['mimeType']); |
| 712 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
| 712 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
| 713 | 713 | } |
| 714 | 714 | } |
| 715 | 715 | } |
@@ -724,38 +724,38 @@ discard block |
||
| 724 | 724 | // now set the body |
| 725 | 725 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
| 726 | 726 | { |
| 727 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
| 727 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
| 728 | 728 | //error_log(__METHOD__.__LINE__.' html:'.$AltBody); |
| 729 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 729 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 730 | 730 | } |
| 731 | 731 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
| 732 | 732 | { |
| 733 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
| 733 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
| 734 | 734 | //error_log(__METHOD__.__LINE__.' text:'.$Body); |
| 735 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 735 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 736 | 736 | } |
| 737 | 737 | //advanced debugging |
| 738 | 738 | // Horde SMTP Class uses utf-8 by default. |
| 739 | 739 | //ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SendMail: parsed message: ". print_r($message,1)); |
| 740 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 740 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
| 741 | 741 | |
| 742 | 742 | // set a higher timeout for big messages |
| 743 | 743 | @set_time_limit(120); |
| 744 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 744 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
| 745 | 745 | // send |
| 746 | 746 | $send = true; |
| 747 | 747 | try { |
| 748 | 748 | $mailObject->Send(); |
| 749 | 749 | } |
| 750 | - catch(Exception $e) { |
|
| 751 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
| 750 | + catch (Exception $e) { |
|
| 751 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
| 752 | 752 | $send = false; |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 755 | + if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
| 756 | 756 | { |
| 757 | 757 | $uid = $smartdata->source->itemid; |
| 758 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 758 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
| 759 | 759 | $this->splitID($smartdata->source->folderid, $account, $folder); |
| 760 | 760 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
| 761 | 761 | $this->mail->reopen($folder); |
@@ -763,90 +763,90 @@ discard block |
||
| 763 | 763 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
| 764 | 764 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
| 765 | 765 | { |
| 766 | - $this->mail->deleteMessages(array($uid),$folder); |
|
| 766 | + $this->mail->deleteMessages(array($uid), $folder); |
|
| 767 | 767 | } else { |
| 768 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
| 769 | - if ($smartdata_task== "forward") |
|
| 768 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
| 769 | + if ($smartdata_task == "forward") |
|
| 770 | 770 | { |
| 771 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
| 771 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - $asf = ($send ? true:false); // initalize accordingly |
|
| 777 | - if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 776 | + $asf = ($send ? true : false); // initalize accordingly |
|
| 777 | + if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
| 778 | 778 | { |
| 779 | 779 | $asf = false; |
| 780 | 780 | $sentFolder = $this->mail->getSentFolder(); |
| 781 | 781 | if ($this->_sentID) { |
| 782 | 782 | $folderArray[] = $this->_sentID; |
| 783 | 783 | } |
| 784 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
| 784 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
| 785 | 785 | { |
| 786 | 786 | $folderArray[] = $sentFolder; |
| 787 | 787 | } |
| 788 | 788 | // No Sent folder set, try defaults |
| 789 | 789 | else |
| 790 | 790 | { |
| 791 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 791 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
| 792 | 792 | // we dont try guessing |
| 793 | 793 | $asf = true; |
| 794 | 794 | } |
| 795 | 795 | if (count($folderArray) > 0) { |
| 796 | - foreach((array)$bccMailAddr as $address) { |
|
| 797 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
| 798 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 796 | + foreach ((array)$bccMailAddr as $address) { |
|
| 797 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
| 798 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
| 799 | 799 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
| 800 | 800 | } |
| 801 | 801 | } |
| 802 | 802 | //$BCCmail=''; |
| 803 | - if (count($mailAddr)>0) $mailObject->forceBccHeader(); |
|
| 803 | + if (count($mailAddr) > 0) $mailObject->forceBccHeader(); |
|
| 804 | 804 | //$BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
| 805 | - foreach($folderArray as $folderName) { |
|
| 806 | - if($this->mail->isSentFolder($folderName)) { |
|
| 805 | + foreach ($folderArray as $folderName) { |
|
| 806 | + if ($this->mail->isSentFolder($folderName)) { |
|
| 807 | 807 | $flags = '\\Seen'; |
| 808 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
| 808 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
| 809 | 809 | $flags = '\\Draft'; |
| 810 | 810 | } else { |
| 811 | 811 | $flags = ''; |
| 812 | 812 | } |
| 813 | 813 | $asf = true; |
| 814 | 814 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
| 815 | - $this->mail->openConnection(self::$profileID,false); |
|
| 815 | + $this->mail->openConnection(self::$profileID, false); |
|
| 816 | 816 | if ($this->mail->folderExists($folderName)) { |
| 817 | 817 | try |
| 818 | 818 | { |
| 819 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
| 819 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
| 820 | 820 | $flags); |
| 821 | 821 | } |
| 822 | 822 | catch (Api\Exception\WrongUserinput $e) |
| 823 | 823 | { |
| 824 | 824 | //$asf = false; |
| 825 | - 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())); |
|
| 825 | + 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())); |
|
| 826 | 826 | } |
| 827 | 827 | } |
| 828 | 828 | else |
| 829 | 829 | { |
| 830 | 830 | //$asf = false; |
| 831 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
| 831 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
| 832 | 832 | } |
| 833 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
| 833 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
| 834 | 834 | } |
| 835 | 835 | //$this->mail->closeConnection(); |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | - $this->debugLevel=0; |
|
| 839 | + $this->debugLevel = 0; |
|
| 840 | 840 | |
| 841 | 841 | if ($send && $asf) |
| 842 | 842 | { |
| 843 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
| 843 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
| 844 | 844 | return true; |
| 845 | 845 | } |
| 846 | 846 | else |
| 847 | 847 | { |
| 848 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
| 849 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 848 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
| 849 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
| 850 | 850 | } |
| 851 | 851 | } |
| 852 | 852 | |
@@ -864,43 +864,43 @@ discard block |
||
| 864 | 864 | public function GetMessage($folderid, $id, $contentparameters) |
| 865 | 865 | { |
| 866 | 866 | //$this->debugLevel=4; |
| 867 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 867 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
| 868 | 868 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
| 869 | 869 | $mimesupport = $contentparameters->GetMimeSupport(); |
| 870 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 870 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
| 871 | 871 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
| 872 | 872 | |
| 873 | 873 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
| 874 | 874 | if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
| 875 | 875 | |
| 876 | 876 | //$this->debugLevel=4; |
| 877 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 878 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 877 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 878 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
| 879 | 879 | $account = $_folderName = $xid = null; |
| 880 | - $this->splitID($folderid,$account,$_folderName,$xid); |
|
| 880 | + $this->splitID($folderid, $account, $_folderName, $xid); |
|
| 881 | 881 | $this->mail->reopen($_folderName); |
| 882 | - $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 882 | + $messages = $this->fetchMessages($folderid, NULL, $id, true); // true: return all headers |
|
| 883 | 883 | $headers = $messages[$id]; |
| 884 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($headers)); |
|
| 884 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($headers)); |
|
| 885 | 885 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
| 886 | 886 | if ($headers) |
| 887 | 887 | { |
| 888 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 888 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($headers)); |
|
| 889 | 889 | // initialize the object |
| 890 | 890 | $output = new SyncMail(); |
| 891 | 891 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
| 892 | 892 | // simple style |
| 893 | 893 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
| 894 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 894 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
| 895 | 895 | |
| 896 | 896 | if ($bodypreference === false) { |
| 897 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
| 898 | - $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 897 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
| 898 | + $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 899 | 899 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 900 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 900 | + if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
| 901 | 901 | // remove all other html |
| 902 | 902 | $body = strip_tags($raw_body); |
| 903 | - if(strlen($body) > $truncsize) { |
|
| 903 | + if (strlen($body) > $truncsize) { |
|
| 904 | 904 | $body = Utils::Utf8_truncate($body, $truncsize); |
| 905 | 905 | $output->bodytruncated = 1; |
| 906 | 906 | } |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | else // style with bodypreferences |
| 915 | 915 | { |
| 916 | 916 | //Select body type preference |
| 917 | - $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
| 917 | + $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
| 918 | 918 | if ($bodypreference !== false) { |
| 919 | 919 | // bodypreference can occur multiple times |
| 920 | 920 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -928,12 +928,12 @@ discard block |
||
| 928 | 928 | } |
| 929 | 929 | */ |
| 930 | 930 | } |
| 931 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 931 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
| 932 | 932 | // set the protocoll class |
| 933 | 933 | $output->asbody = new SyncBaseBody(); |
| 934 | 934 | |
| 935 | 935 | // return full mime-message without any (charset) conversation directly as stream |
| 936 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
| 936 | + if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) |
|
| 937 | 937 | { |
| 938 | 938 | //SYNC_BODYPREFERENCE_MIME |
| 939 | 939 | $output->asbody->type = SYNC_BODYPREFERENCE_MIME; |
@@ -942,58 +942,58 @@ discard block |
||
| 942 | 942 | fseek($stream, 0, SEEK_SET); |
| 943 | 943 | $output->asbody->data = $stream; |
| 944 | 944 | $output->asbody->estimatedDataSize = $fstat['size']; |
| 945 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 945 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4=SYNC_BODYPREFERENCE_MIME=full mime message requested, size=$fstat[size]"); |
|
| 946 | 946 | } |
| 947 | 947 | else |
| 948 | 948 | { |
| 949 | 949 | // fetch the body (try to gather data only once) |
| 950 | - $css =''; |
|
| 951 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
| 952 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 953 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
| 954 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
| 955 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
| 950 | + $css = ''; |
|
| 951 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
| 952 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
| 953 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
| 954 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
| 955 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
| 956 | 956 | // may be html |
| 957 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 957 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:html (fetched with html_only)'); |
|
| 958 | 958 | $css = $this->mail->getStyles($bodyStruct); |
| 959 | - $output->nativebodytype=2; |
|
| 959 | + $output->nativebodytype = 2; |
|
| 960 | 960 | } else { |
| 961 | 961 | // plain text Message |
| 962 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 963 | - $output->nativebodytype=1; |
|
| 964 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 965 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 966 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
| 967 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 962 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
| 963 | + $output->nativebodytype = 1; |
|
| 964 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 965 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
| 966 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
| 967 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
| 968 | 968 | } |
| 969 | 969 | // whatever format decode (using the correct encoding) |
| 970 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
| 970 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
| 971 | 971 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
| 972 | 972 | // prepare plaintextbody |
| 973 | - $plainBody=''; |
|
| 973 | + $plainBody = ''; |
|
| 974 | 974 | if ($output->nativebodytype == 2) |
| 975 | 975 | { |
| 976 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
| 977 | - if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
| 976 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
| 977 | + if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
| 978 | 978 | { |
| 979 | 979 | $plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
| 980 | 980 | } |
| 981 | 981 | else |
| 982 | 982 | { |
| 983 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
| 983 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | //if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "MIME Body".$body); |
| 987 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
| 987 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
| 988 | 988 | // remove all other html |
| 989 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
| 989 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
| 990 | 990 | $plainBody = strip_tags($plainBody); |
| 991 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 991 | + if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
| 992 | 992 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
| 993 | 993 | |
| 994 | - if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
| 994 | + if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
| 995 | 995 | { |
| 996 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 996 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "HTML Body with requested pref 2"); |
|
| 997 | 997 | // Send HTML if requested and native type was html |
| 998 | 998 | $output->asbody->type = 2; |
| 999 | 999 | $htmlbody = '<html>'. |
@@ -1003,23 +1003,23 @@ discard block |
||
| 1003 | 1003 | $css. |
| 1004 | 1004 | '</head>'. |
| 1005 | 1005 | '<body>'; |
| 1006 | - if ($output->nativebodytype==2) |
|
| 1006 | + if ($output->nativebodytype == 2) |
|
| 1007 | 1007 | { |
| 1008 | - if ($css) Api\Mail\Html::replaceTagsCompletley($body,'style'); |
|
| 1008 | + if ($css) Api\Mail\Html::replaceTagsCompletley($body, 'style'); |
|
| 1009 | 1009 | // as we fetch html, and body is HTML, we may not need to handle this |
| 1010 | 1010 | $htmlbody .= $body; |
| 1011 | 1011 | } |
| 1012 | 1012 | else |
| 1013 | 1013 | { |
| 1014 | 1014 | // html requested but got only plaintext, so fake html |
| 1015 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
| 1015 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | $htmlbody .= '</body>'. |
| 1018 | 1018 | '</html>'; |
| 1019 | 1019 | |
| 1020 | - if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1020 | + if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
| 1021 | 1021 | { |
| 1022 | - $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
| 1022 | + $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
| 1023 | 1023 | $output->asbody->truncated = 1; |
| 1024 | 1024 | } |
| 1025 | 1025 | // output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | else |
| 1031 | 1031 | { |
| 1032 | 1032 | // Send Plaintext as Fallback or if original body is plainttext |
| 1033 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1033 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, "Plaintext Body:".$plainBody); |
|
| 1034 | 1034 | /* we use plainBody (set above) instead |
| 1035 | 1035 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
| 1036 | 1036 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | */ |
| 1041 | 1041 | $output->asbody->type = 1; |
| 1042 | 1042 | $output->nativebodytype = 1; |
| 1043 | - if(isset($truncsize) && |
|
| 1043 | + if (isset($truncsize) && |
|
| 1044 | 1044 | strlen($plainBody) > $truncsize) |
| 1045 | 1045 | { |
| 1046 | 1046 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | } |
| 1060 | 1060 | } |
| 1061 | 1061 | // end AS12 Stuff |
| 1062 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1062 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['subject'].' from:'.$headers['date']); |
|
| 1063 | 1063 | $output->read = $headers["flags"]; |
| 1064 | 1064 | |
| 1065 | 1065 | $output->flag = new SyncMailFlags(); |
@@ -1079,9 +1079,8 @@ discard block |
||
| 1079 | 1079 | $output->lastverexecuted = AS_FORWARD; |
| 1080 | 1080 | } |
| 1081 | 1081 | $output->subject = $headers['subject']; |
| 1082 | - $output->importance = $headers['priority'] > 3 ? 0 : |
|
| 1083 | - ($headers['priority'] < 3 ? 2 : 1) ; |
|
| 1084 | - $output->datereceived = $this->mail->_strtotime($headers['date'],'ts',true); |
|
| 1082 | + $output->importance = $headers['priority'] > 3 ? 0 : ($headers['priority'] < 3 ? 2 : 1); |
|
| 1083 | + $output->datereceived = $this->mail->_strtotime($headers['date'], 'ts', true); |
|
| 1085 | 1084 | $output->to = $headers['to_address']; |
| 1086 | 1085 | if ($headers['to']) $output->displayto = $headers['to_address']; //$headers['FETCHED_HEADER']['to_name'] |
| 1087 | 1086 | $output->from = $headers['sender_address']; |
@@ -1089,8 +1088,8 @@ discard block |
||
| 1089 | 1088 | if (isset($headers['reply_to_address']) && $headers['reply_to_address']) $output->reply_to = $headers['reply_to_address']; |
| 1090 | 1089 | |
| 1091 | 1090 | $output->messageclass = "IPM.Note"; |
| 1092 | - if (stripos($headers['mimetype'],'multipart')!== false && |
|
| 1093 | - stripos($headers['mimetype'],'signed')!== false) |
|
| 1091 | + if (stripos($headers['mimetype'], 'multipart') !== false && |
|
| 1092 | + stripos($headers['mimetype'], 'signed') !== false) |
|
| 1094 | 1093 | { |
| 1095 | 1094 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
| 1096 | 1095 | } |
@@ -1099,20 +1098,20 @@ discard block |
||
| 1099 | 1098 | } |
| 1100 | 1099 | |
| 1101 | 1100 | // start handle Attachments (include text/calendar multipart alternative) |
| 1102 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
| 1101 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
| 1103 | 1102 | // Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
| 1104 | - if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
| 1103 | + if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
| 1105 | 1104 | { |
| 1106 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1105 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
| 1107 | 1106 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1108 | 1107 | foreach ($attachments as $key => $attach) |
| 1109 | 1108 | { |
| 1110 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1109 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
| 1111 | 1110 | |
| 1112 | 1111 | // pass meeting requests to calendar plugin |
| 1113 | 1112 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1114 | 1113 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 1115 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
| 1114 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
| 1116 | 1115 | ($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
| 1117 | 1116 | { |
| 1118 | 1117 | //overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
@@ -1122,7 +1121,7 @@ discard block |
||
| 1122 | 1121 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
| 1123 | 1122 | //$output->messageclass = "IPM.Schedule.Meeting"; |
| 1124 | 1123 | unset($attachment); |
| 1125 | - continue; // do NOT add attachment as attachment |
|
| 1124 | + continue; // do NOT add attachment as attachment |
|
| 1126 | 1125 | } |
| 1127 | 1126 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1128 | 1127 | $attachment = new SyncBaseAttachment(); |
@@ -1130,33 +1129,33 @@ discard block |
||
| 1130 | 1129 | $output->asattachments = array(); |
| 1131 | 1130 | $attachment->estimatedDataSize = $attach['size']; |
| 1132 | 1131 | $attachment->method = 1; |
| 1133 | - $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
| 1132 | + $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
| 1134 | 1133 | } else { |
| 1135 | 1134 | $attachment = new SyncAttachment(); |
| 1136 | 1135 | if (!isset($output->attachments) || !is_array($output->attachments)) |
| 1137 | 1136 | $output->attachments = array(); |
| 1138 | 1137 | $attachment->attsize = $attach['size']; |
| 1139 | 1138 | $attachment->attmethod = 1; |
| 1140 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
| 1139 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
| 1141 | 1140 | } |
| 1142 | 1141 | |
| 1143 | 1142 | $attachment->displayname = $attach['name']; |
| 1144 | 1143 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
| 1145 | 1144 | |
| 1146 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1145 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
| 1147 | 1146 | //$attachment->isinline=0; // if not inline, do not use isinline |
| 1148 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
| 1147 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
| 1149 | 1148 | { |
| 1150 | 1149 | if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
| 1151 | 1150 | { |
| 1152 | 1151 | $attachment->isinline = true; |
| 1153 | 1152 | } |
| 1154 | 1153 | if (Request::GetProtocolVersion() >= 12.0) { |
| 1155 | - $attachment->method=1; |
|
| 1156 | - $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
| 1154 | + $attachment->method = 1; |
|
| 1155 | + $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1157 | 1156 | } else { |
| 1158 | - $attachment->attmethod=6; |
|
| 1159 | - $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
| 1157 | + $attachment->attmethod = 6; |
|
| 1158 | + $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
| 1160 | 1159 | } |
| 1161 | 1160 | // ZLog::Write(LOGLEVEL_DEBUG, "'".$part->headers['content-id']."' ".$attachment->contentid); |
| 1162 | 1161 | $attachment->contenttype = trim($attach['mimeType']); |
@@ -1177,7 +1176,7 @@ discard block |
||
| 1177 | 1176 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
| 1178 | 1177 | $output->internetcpid = INTERNET_CPID_UTF8; |
| 1179 | 1178 | |
| 1180 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
| 1179 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
| 1181 | 1180 | //$this->debugLevel=0; |
| 1182 | 1181 | return $output; |
| 1183 | 1182 | } |
@@ -1200,30 +1199,30 @@ discard block |
||
| 1200 | 1199 | { |
| 1201 | 1200 | if (!class_exists('calendar_zpush')) |
| 1202 | 1201 | { |
| 1203 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1202 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
| 1204 | 1203 | return null; |
| 1205 | 1204 | } |
| 1206 | 1205 | if (!($stat = $this->StatMessage($folderid, $requestid))) |
| 1207 | 1206 | { |
| 1208 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1207 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
| 1209 | 1208 | return false; |
| 1210 | 1209 | } |
| 1211 | 1210 | $ret = false; |
| 1212 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
| 1211 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
| 1213 | 1212 | { |
| 1214 | 1213 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
| 1215 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
| 1214 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
| 1216 | 1215 | { |
| 1217 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1216 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
| 1218 | 1217 | |
| 1219 | 1218 | // calling backend again with iCal attachment, to let calendar add the event |
| 1220 | 1219 | $ret = $this->backend->MeetingResponse($attachment['attachment'], |
| 1221 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
| 1220 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
| 1222 | 1221 | $response); |
| 1223 | 1222 | break; |
| 1224 | 1223 | } |
| 1225 | 1224 | } |
| 1226 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1225 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
| 1227 | 1226 | return $ret; |
| 1228 | 1227 | } |
| 1229 | 1228 | |
@@ -1237,9 +1236,9 @@ discard block |
||
| 1237 | 1236 | * @param string $attname - should contain (folder)id |
| 1238 | 1237 | * @return SyncItemOperationsAttachment-object |
| 1239 | 1238 | */ |
| 1240 | - function GetAttachmentData($fid,$attname) { |
|
| 1241 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1242 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1239 | + function GetAttachmentData($fid, $attname) { |
|
| 1240 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1241 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1243 | 1242 | } |
| 1244 | 1243 | |
| 1245 | 1244 | /** |
@@ -1252,9 +1251,9 @@ discard block |
||
| 1252 | 1251 | * @param string $attname - should contain (folder)id |
| 1253 | 1252 | * @return SyncItemOperationsAttachment-object |
| 1254 | 1253 | */ |
| 1255 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
| 1256 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')"); |
|
| 1257 | - return $this->_GetAttachmentData($fid,$attname); |
|
| 1254 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
| 1255 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')"); |
|
| 1256 | + return $this->_GetAttachmentData($fid, $attname); |
|
| 1258 | 1257 | } |
| 1259 | 1258 | |
| 1260 | 1259 | /** |
@@ -1266,23 +1265,23 @@ discard block |
||
| 1266 | 1265 | * @param string $attname - should contain (folder)id |
| 1267 | 1266 | * @return SyncItemOperationsAttachment-object |
| 1268 | 1267 | */ |
| 1269 | - private function _GetAttachmentData($fid,$attname) |
|
| 1268 | + private function _GetAttachmentData($fid, $attname) |
|
| 1270 | 1269 | { |
| 1271 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1270 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
| 1272 | 1271 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
| 1273 | 1272 | list($folderid, $id, $part) = explode(":", $attname); |
| 1274 | 1273 | |
| 1275 | 1274 | $this->splitID($folderid, $account, $folder); |
| 1276 | 1275 | |
| 1277 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1276 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1278 | 1277 | |
| 1279 | 1278 | $this->mail->reopen($folder); |
| 1280 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
| 1279 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
| 1281 | 1280 | $SIOattachment = new SyncItemOperationsAttachment(); |
| 1282 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1281 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
| 1283 | 1282 | $SIOattachment->data = $attachment['attachment']; |
| 1284 | 1283 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
| 1285 | - if (isset($attachment['type']) ) |
|
| 1284 | + if (isset($attachment['type'])) |
|
| 1286 | 1285 | $SIOattachment->contenttype = $attachment['type']; |
| 1287 | 1286 | |
| 1288 | 1287 | unset($attachment); |
@@ -1325,17 +1324,17 @@ discard block |
||
| 1325 | 1324 | */ |
| 1326 | 1325 | function ChangeMessage($folderid, $id, $message, $contentParameters) |
| 1327 | 1326 | { |
| 1328 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1327 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
| 1329 | 1328 | //unset($folderid, $id, $message, $contentParameters); |
| 1330 | 1329 | $account = $folder = null; |
| 1331 | 1330 | $this->splitID($folderid, $account, $folder); |
| 1332 | 1331 | if (isset($message->flag)) { |
| 1333 | 1332 | if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
| 1334 | - $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
| 1335 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 1333 | + $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
| 1334 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 1336 | 1335 | } else { |
| 1337 | - $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
| 1338 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
| 1336 | + $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
| 1337 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
| 1339 | 1338 | } |
| 1340 | 1339 | } |
| 1341 | 1340 | return $this->StatMessage($folderid, $id); |
@@ -1357,23 +1356,23 @@ discard block |
||
| 1357 | 1356 | */ |
| 1358 | 1357 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
| 1359 | 1358 | { |
| 1360 | - unset($contentParameters); // not used, but required by function signature |
|
| 1359 | + unset($contentParameters); // not used, but required by function signature |
|
| 1361 | 1360 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
| 1362 | 1361 | $account = $srcFolder = $destFolder = null; |
| 1363 | 1362 | $this->splitID($folderid, $account, $srcFolder); |
| 1364 | 1363 | $this->splitID($newfolderid, $account, $destFolder); |
| 1365 | 1364 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
| 1366 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1365 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1367 | 1366 | $this->mail->reopen($destFolder); |
| 1368 | 1367 | $status = $this->mail->getFolderStatus($destFolder); |
| 1369 | 1368 | $uidNext = $status['uidnext']; |
| 1370 | 1369 | $this->mail->reopen($srcFolder); |
| 1371 | 1370 | |
| 1372 | 1371 | // move message |
| 1373 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
| 1374 | - 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 |
|
| 1372 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
| 1373 | + 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 |
|
| 1375 | 1374 | // return the new id "as string" |
| 1376 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
| 1375 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
| 1377 | 1376 | } |
| 1378 | 1377 | |
| 1379 | 1378 | /** |
@@ -1381,7 +1380,7 @@ discard block |
||
| 1381 | 1380 | * |
| 1382 | 1381 | * @param int $cutoffdate =null timestamp with cutoffdate, default 12 weeks |
| 1383 | 1382 | */ |
| 1384 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
| 1383 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
| 1385 | 1384 | { |
| 1386 | 1385 | if ($cutoffdate > 0) |
| 1387 | 1386 | { |
@@ -1394,14 +1393,14 @@ discard block |
||
| 1394 | 1393 | { |
| 1395 | 1394 | $maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']; |
| 1396 | 1395 | } |
| 1397 | - $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null); |
|
| 1398 | - if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1396 | + $cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now', 'ts') - (3600 * 24 * $maximumSyncRangeInDays) : null); |
|
| 1397 | + if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate)); |
|
| 1399 | 1398 | } |
| 1400 | 1399 | try { |
| 1401 | 1400 | return $this->fetchMessages($folderid, $cutoffdate); |
| 1402 | 1401 | } catch (Exception $e) |
| 1403 | 1402 | { |
| 1404 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details?$e->details:'')); |
|
| 1403 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage().($e->details ? $e->details : '')); |
|
| 1405 | 1404 | return array(); |
| 1406 | 1405 | } |
| 1407 | 1406 | } |
@@ -1419,11 +1418,11 @@ discard block |
||
| 1419 | 1418 | * @param boolean $return_all_headers =false true: additinal contain all headers eg. "subject" |
| 1420 | 1419 | * @return array uid => array StatMessage($folderid, $_id) |
| 1421 | 1420 | */ |
| 1422 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL, $return_all_headers=false) |
|
| 1421 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL, $return_all_headers = false) |
|
| 1423 | 1422 | { |
| 1424 | 1423 | static $headers = array(); |
| 1425 | 1424 | |
| 1426 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
| 1425 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
| 1427 | 1426 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
| 1428 | 1427 | $rv_messages = array(); |
| 1429 | 1428 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1434,64 +1433,64 @@ discard block |
||
| 1434 | 1433 | } |
| 1435 | 1434 | else |
| 1436 | 1435 | { |
| 1437 | - $headers = array(); // clear cache to not use too much memory |
|
| 1436 | + $headers = array(); // clear cache to not use too much memory |
|
| 1438 | 1437 | |
| 1439 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1438 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1440 | 1439 | $this->_connect($this->account); |
| 1441 | - if ($this->debugLevel>1) |
|
| 1440 | + if ($this->debugLevel > 1) |
|
| 1442 | 1441 | { |
| 1443 | 1442 | $endtime = microtime(true) - $starttime; |
| 1444 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
| 1443 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
| 1445 | 1444 | } |
| 1446 | 1445 | $messagelist = $_filter = array(); |
| 1447 | 1446 | // if not connected, any further action must fail |
| 1448 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1449 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1447 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
| 1448 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1450 | 1449 | $account = $_folderName = $id = null; |
| 1451 | - $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1452 | - if ($this->debugLevel>1) |
|
| 1450 | + $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1451 | + if ($this->debugLevel > 1) |
|
| 1453 | 1452 | { |
| 1454 | 1453 | $endtime = microtime(true) - $starttime; |
| 1455 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1454 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
| 1456 | 1455 | } |
| 1457 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1458 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
| 1459 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
| 1460 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
| 1461 | - if ($this->debugLevel>1) |
|
| 1456 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1457 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
| 1458 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
| 1459 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
| 1460 | + if ($this->debugLevel > 1) |
|
| 1462 | 1461 | { |
| 1463 | 1462 | $endtime = microtime(true) - $starttime; |
| 1464 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1463 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
| 1465 | 1464 | } |
| 1466 | 1465 | } |
| 1467 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
| 1466 | + if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
| 1468 | 1467 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
| 1469 | 1468 | $messagelist = array(); |
| 1470 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
| 1469 | + if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
| 1471 | 1470 | //if ($_returnModHash) $messageFolderHash = array(); |
| 1472 | 1471 | foreach ((array)$rv_messages['header'] as $k => $vars) |
| 1473 | 1472 | { |
| 1474 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1473 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1475 | 1474 | $headers[$vars['uid']] = $vars; |
| 1476 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1475 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
| 1477 | 1476 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
| 1478 | 1477 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
| 1479 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1478 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
| 1480 | 1479 | $mess = $return_all_headers ? $vars : array(); |
| 1481 | 1480 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
| 1482 | 1481 | $mess["id"] = $vars['uid']; |
| 1483 | 1482 | // 'seen' aka 'read' is the only flag we want to know about |
| 1484 | 1483 | $mess["flags"] = 0; |
| 1485 | 1484 | // outlook supports additional flags, set them to 0 |
| 1486 | - if($vars["seen"]) $mess["flags"] = 1; |
|
| 1487 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
| 1485 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
| 1486 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
| 1488 | 1487 | $messagelist[$vars['uid']] = $mess; |
| 1489 | 1488 | unset($mess); |
| 1490 | 1489 | } |
| 1491 | - if ($this->debugLevel>1) |
|
| 1490 | + if ($this->debugLevel > 1) |
|
| 1492 | 1491 | { |
| 1493 | 1492 | $endtime = microtime(true) - $gstarttime; |
| 1494 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1493 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
| 1495 | 1494 | } |
| 1496 | 1495 | return $messagelist; |
| 1497 | 1496 | } |
@@ -1542,32 +1541,32 @@ discard block |
||
| 1542 | 1541 | public function getSearchResultsMailbox($_searchquery) |
| 1543 | 1542 | { |
| 1544 | 1543 | //$this->debugLevel=1; |
| 1545 | - $searchquery=$_searchquery->GetDataArray(); |
|
| 1544 | + $searchquery = $_searchquery->GetDataArray(); |
|
| 1546 | 1545 | if (!is_array($searchquery)) return array(); |
| 1547 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
| 1546 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
| 1548 | 1547 | |
| 1549 | 1548 | if (isset($searchquery['searchrebuildresults'])) { |
| 1550 | 1549 | $rebuildresults = $searchquery['searchrebuildresults']; |
| 1551 | 1550 | } else { |
| 1552 | 1551 | $rebuildresults = false; |
| 1553 | 1552 | } |
| 1554 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']' ); |
|
| 1553 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'RebuildResults ['.$rebuildresults.']'); |
|
| 1555 | 1554 | |
| 1556 | 1555 | if (isset($searchquery['deeptraversal'])) { |
| 1557 | 1556 | $deeptraversal = $searchquery['deeptraversal']; |
| 1558 | 1557 | } else { |
| 1559 | 1558 | $deeptraversal = false; |
| 1560 | 1559 | } |
| 1561 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']' ); |
|
| 1560 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'DeepTraversal ['.$deeptraversal.']'); |
|
| 1562 | 1561 | |
| 1563 | 1562 | if (isset($searchquery['searchrange'])) { |
| 1564 | - $range = explode("-",$_searchquery->GetSearchRange()); |
|
| 1565 | - $start =$range[0] + 1; |
|
| 1563 | + $range = explode("-", $_searchquery->GetSearchRange()); |
|
| 1564 | + $start = $range[0] + 1; |
|
| 1566 | 1565 | $limit = $range[1] - $range[0] + 1; |
| 1567 | 1566 | } else { |
| 1568 | 1567 | $range = false; |
| 1569 | 1568 | } |
| 1570 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']' ); |
|
| 1569 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, 'Range ['.print_r($range, true).']'); |
|
| 1571 | 1570 | |
| 1572 | 1571 | //foreach($searchquery['query'] as $k => $value) { |
| 1573 | 1572 | // $query = $value; |
@@ -1590,15 +1589,15 @@ discard block |
||
| 1590 | 1589 | } |
| 1591 | 1590 | if (!$folderid) |
| 1592 | 1591 | { |
| 1593 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
| 1594 | - $folderid = $this->createID($account=0,$_folderName); |
|
| 1592 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
| 1593 | + $folderid = $this->createID($account = 0, $_folderName); |
|
| 1595 | 1594 | } |
| 1596 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
| 1597 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1595 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
| 1596 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
| 1598 | 1597 | $this->_connect($account); |
| 1599 | 1598 | // this should not be needed ??? |
| 1600 | - Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
| 1601 | - $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
| 1599 | + Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
| 1600 | + $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
| 1602 | 1601 | 'string'=> $searchText, |
| 1603 | 1602 | 'status'=>'any' |
| 1604 | 1603 | ); |
@@ -1613,22 +1612,22 @@ discard block |
||
| 1613 | 1612 | * [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
| 1614 | 1613 | */ |
| 1615 | 1614 | $_filter['range'] = "BETWEEN"; |
| 1616 | - list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
| 1617 | - list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
| 1618 | - $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
| 1619 | - $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
| 1615 | + list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
| 1616 | + list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
| 1617 | + $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
| 1618 | + $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
| 1620 | 1619 | } |
| 1621 | 1620 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
| 1622 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1623 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
| 1621 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
| 1622 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
| 1624 | 1623 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
| 1625 | - $list=array(); |
|
| 1624 | + $list = array(); |
|
| 1626 | 1625 | |
| 1627 | 1626 | $cnt = count($rv_messages['header']); |
| 1628 | 1627 | //$list['status'] = 1; |
| 1629 | 1628 | $list['searchtotal'] = $cnt; |
| 1630 | 1629 | $list["range"] = $_searchquery->GetSearchRange(); |
| 1631 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
| 1630 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
| 1632 | 1631 | { |
| 1633 | 1632 | $list[] = array( |
| 1634 | 1633 | "class" => "Email", |
@@ -1648,20 +1647,20 @@ discard block |
||
| 1648 | 1647 | * @param string $folder |
| 1649 | 1648 | * @return string |
| 1650 | 1649 | */ |
| 1651 | - private function getParentID($account,$folder) |
|
| 1650 | + private function getParentID($account, $folder) |
|
| 1652 | 1651 | { |
| 1653 | 1652 | $this->_connect($account); |
| 1654 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1653 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1655 | 1654 | |
| 1656 | 1655 | $mailFolder = $this->folders[$folder]; |
| 1657 | 1656 | if (!isset($mailFolder)) return false; |
| 1658 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
| 1659 | - $parent = explode($delimiter,$folder); |
|
| 1657 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
| 1658 | + $parent = explode($delimiter, $folder); |
|
| 1660 | 1659 | array_pop($parent); |
| 1661 | - $parent = implode($delimiter,$parent); |
|
| 1660 | + $parent = implode($delimiter, $parent); |
|
| 1662 | 1661 | |
| 1663 | 1662 | $id = $parent && $this->folders[$parent] ? $this->createID($account, $parent) : '0'; |
| 1664 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1663 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
| 1665 | 1664 | return $id; |
| 1666 | 1665 | } |
| 1667 | 1666 | |
@@ -1681,48 +1680,48 @@ discard block |
||
| 1681 | 1680 | $account = $folder = null; |
| 1682 | 1681 | $this->splitID($id, $account, $folder); |
| 1683 | 1682 | } |
| 1684 | - catch(Exception $e) { |
|
| 1685 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1686 | - return $folderObj=false; |
|
| 1683 | + catch (Exception $e) { |
|
| 1684 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
| 1685 | + return $folderObj = false; |
|
| 1687 | 1686 | } |
| 1688 | 1687 | $this->_connect($account); |
| 1689 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
| 1688 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
| 1690 | 1689 | |
| 1691 | 1690 | $mailFolder = $this->folders[$folder]; |
| 1692 | - if (!isset($mailFolder)) return $folderObj=false; |
|
| 1691 | + if (!isset($mailFolder)) return $folderObj = false; |
|
| 1693 | 1692 | |
| 1694 | 1693 | $folderObj = new SyncFolder(); |
| 1695 | 1694 | $folderObj->serverid = $id; |
| 1696 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
| 1695 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
| 1697 | 1696 | $folderObj->displayname = $mailFolder->shortDisplayName; |
| 1698 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1697 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
| 1699 | 1698 | // get folder-type |
| 1700 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
| 1699 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
| 1701 | 1700 | if ($folder == $inbox) |
| 1702 | 1701 | { |
| 1703 | 1702 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
| 1704 | 1703 | } |
| 1705 | - elseif($this->mail->isDraftFolder($folder, false, true)) |
|
| 1704 | + elseif ($this->mail->isDraftFolder($folder, false, true)) |
|
| 1706 | 1705 | { |
| 1707 | 1706 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
| 1708 | 1707 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
| 1709 | 1708 | $folderObj->parentid = 0; // required by devices |
| 1710 | 1709 | } |
| 1711 | - elseif($this->mail->isTrashFolder($folder, false, true)) |
|
| 1710 | + elseif ($this->mail->isTrashFolder($folder, false, true)) |
|
| 1712 | 1711 | { |
| 1713 | 1712 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
| 1714 | 1713 | $this->_wasteID = $folder; |
| 1715 | 1714 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
| 1716 | 1715 | $folderObj->parentid = 0; // required by devices |
| 1717 | 1716 | } |
| 1718 | - elseif($this->mail->isSentFolder($folder, false, true)) |
|
| 1717 | + elseif ($this->mail->isSentFolder($folder, false, true)) |
|
| 1719 | 1718 | { |
| 1720 | 1719 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
| 1721 | 1720 | $folderObj->parentid = 0; // required by devices |
| 1722 | 1721 | $this->_sentID = $folder; |
| 1723 | 1722 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
| 1724 | 1723 | } |
| 1725 | - elseif($this->mail->isOutbox($folder, false, true)) |
|
| 1724 | + elseif ($this->mail->isOutbox($folder, false, true)) |
|
| 1726 | 1725 | { |
| 1727 | 1726 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
| 1728 | 1727 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1734,7 +1733,7 @@ discard block |
||
| 1734 | 1733 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
| 1735 | 1734 | } |
| 1736 | 1735 | |
| 1737 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1736 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
| 1738 | 1737 | return $folderObj; |
| 1739 | 1738 | } |
| 1740 | 1739 | |
@@ -1782,24 +1781,24 @@ discard block |
||
| 1782 | 1781 | |
| 1783 | 1782 | if ($type != 'mail') return false; |
| 1784 | 1783 | |
| 1785 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
| 1784 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
| 1786 | 1785 | if (!$this->mail->folderIsSelectable($folder)) |
| 1787 | 1786 | { |
| 1788 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not select folder $folder returning fake state"); |
|
| 1787 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not select folder $folder returning fake state"); |
|
| 1789 | 1788 | $syncstate = "M:".'0'."-R:".'0'."-U:".'0'."-NUID:".'0'."-UIDV:".'0'; |
| 1790 | 1789 | return array(); |
| 1791 | 1790 | } |
| 1792 | 1791 | |
| 1793 | 1792 | $this->mail->reopen($folder); |
| 1794 | 1793 | |
| 1795 | - if (!($status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true))) |
|
| 1794 | + if (!($status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true))) |
|
| 1796 | 1795 | { |
| 1797 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
| 1796 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
| 1798 | 1797 | return false; |
| 1799 | 1798 | } |
| 1800 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1799 | + $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
| 1801 | 1800 | |
| 1802 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1801 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, ...) $folder ($account) returning ".array2string($syncstate)); |
|
| 1803 | 1802 | return array(); |
| 1804 | 1803 | } |
| 1805 | 1804 | |
@@ -1812,8 +1811,8 @@ discard block |
||
| 1812 | 1811 | function GetWasteBasket() |
| 1813 | 1812 | { |
| 1814 | 1813 | $this->_connect($this->account); |
| 1815 | - $id = $this->createID($account=0, $this->_wasteID); |
|
| 1816 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1814 | + $id = $this->createID($account = 0, $this->_wasteID); |
|
| 1815 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
| 1817 | 1816 | return $id; |
| 1818 | 1817 | } |
| 1819 | 1818 | |
@@ -1834,7 +1833,7 @@ discard block |
||
| 1834 | 1833 | */ |
| 1835 | 1834 | public function DeleteMessage($folderid, $id, $contentParameters) |
| 1836 | 1835 | { |
| 1837 | - unset($contentParameters); // not used, but required by function signature |
|
| 1836 | + unset($contentParameters); // not used, but required by function signature |
|
| 1838 | 1837 | ZLog::Write(LOGLEVEL_DEBUG, "IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
| 1839 | 1838 | /* |
| 1840 | 1839 | $this->imap_reopenFolder($folderid); |
@@ -1845,7 +1844,7 @@ discard block |
||
| 1845 | 1844 | // we may have to split folderid |
| 1846 | 1845 | $account = $folder = null; |
| 1847 | 1846 | $this->splitID($folderid, $account, $folder); |
| 1848 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1847 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
| 1849 | 1848 | $_messageUID = (array)$id; |
| 1850 | 1849 | |
| 1851 | 1850 | $this->_connect($this->account); |
@@ -1857,9 +1856,9 @@ discard block |
||
| 1857 | 1856 | catch (Api\Exception $e) |
| 1858 | 1857 | { |
| 1859 | 1858 | $error = $e->getMessage(); |
| 1860 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1859 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
| 1861 | 1860 | // if the server thinks the message does not exist report deletion as success |
| 1862 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
| 1861 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
| 1863 | 1862 | return false; |
| 1864 | 1863 | } |
| 1865 | 1864 | |
@@ -1893,15 +1892,15 @@ discard block |
||
| 1893 | 1892 | */ |
| 1894 | 1893 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
| 1895 | 1894 | { |
| 1896 | - unset($contentParameters); // not used, but required by function signature |
|
| 1895 | + unset($contentParameters); // not used, but required by function signature |
|
| 1897 | 1896 | // ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
| 1898 | 1897 | $account = $folder = null; |
| 1899 | 1898 | $this->splitID($folderid, $account, $folder); |
| 1900 | 1899 | |
| 1901 | 1900 | $_messageUID = (array)$id; |
| 1902 | 1901 | $this->_connect($this->account); |
| 1903 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
| 1904 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
| 1902 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
| 1903 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
| 1905 | 1904 | |
| 1906 | 1905 | return $rv; |
| 1907 | 1906 | } |
@@ -1919,7 +1918,7 @@ discard block |
||
| 1919 | 1918 | */ |
| 1920 | 1919 | public function ChangeFolder($id, $oldid, $displayname, $type) |
| 1921 | 1920 | { |
| 1922 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
| 1921 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type)"); |
|
| 1923 | 1922 | $account = $parent_id = null; |
| 1924 | 1923 | $this->splitID($id, $account, $parentFolder, $app); |
| 1925 | 1924 | |
@@ -1936,17 +1935,17 @@ discard block |
||
| 1936 | 1935 | $this->splitID($oldid, $account, $oldFolder, $app); |
| 1937 | 1936 | $old_hash = $this->folder2hash($account, $oldFolder); |
| 1938 | 1937 | } |
| 1939 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid?"=>($oldFolder ($old_hash))":'').", '$displayname', $type)"); |
|
| 1938 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.":{$action}Folder('$id'=>($parentFolder ($parent_id)), '$oldid'".($oldid ? "=>($oldFolder ($old_hash))" : '').", '$displayname', $type)"); |
|
| 1940 | 1939 | $this->_connect($this->account); |
| 1941 | 1940 | try |
| 1942 | 1941 | { |
| 1943 | - if ($action=='rename') |
|
| 1942 | + if ($action == 'rename') |
|
| 1944 | 1943 | { |
| 1945 | 1944 | $newFolderName = $this->mail->renameFolder($oldFolder, $parentFolder, $displayname); |
| 1946 | 1945 | } |
| 1947 | - elseif ($action=='create') |
|
| 1946 | + elseif ($action == 'create') |
|
| 1948 | 1947 | { |
| 1949 | - $error=null; |
|
| 1948 | + $error = null; |
|
| 1950 | 1949 | $newFolderName = $this->mail->createFolder($parentFolder, $displayname, $error); |
| 1951 | 1950 | } |
| 1952 | 1951 | } |
@@ -1958,7 +1957,7 @@ discard block |
||
| 1958 | 1957 | $newHash = $this->rename_folder_hash($account, $old_hash, $newFolderName); |
| 1959 | 1958 | $newID = $this->createID($account, $newHash); |
| 1960 | 1959 | |
| 1961 | - ZLog::Write(LOGLEVEL_DEBUG,":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid?"=>($oldFolder)":'').", '$displayname' => $newFolderName (ID:$newID))"); |
|
| 1960 | + ZLog::Write(LOGLEVEL_DEBUG, ":{$action}Folder('$id'=>($parentFolder), '$oldid'".($oldid ? "=>($oldFolder)" : '').", '$displayname' => $newFolderName (ID:$newID))"); |
|
| 1962 | 1961 | return $this->StatFolder($newID); |
| 1963 | 1962 | } |
| 1964 | 1963 | |
@@ -1971,13 +1970,13 @@ discard block |
||
| 1971 | 1970 | * @throws StatusException could throw specific SYNC_FSSTATUS_* exceptions |
| 1972 | 1971 | * @return boolean true or false on error |
| 1973 | 1972 | */ |
| 1974 | - public function DeleteFolder($id, $parentid=false) |
|
| 1973 | + public function DeleteFolder($id, $parentid = false) |
|
| 1975 | 1974 | { |
| 1976 | 1975 | $account = $parent_id = $app = null; |
| 1977 | 1976 | $this->splitID($id, $account, $folder, $app); |
| 1978 | 1977 | $old_hash = $this->folder2hash($account, $folder); |
| 1979 | 1978 | if ($parentid) $this->splitID($parentid, $account, $parentfolder, $app); |
| 1980 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."( '$id (-> $folder)','$parentid ".($parentid?'(->'.$parentfolder.')':'')."') called!"); |
|
| 1979 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."( '$id (-> $folder)','$parentid ".($parentid ? '(->'.$parentfolder.')' : '')."') called!"); |
|
| 1981 | 1980 | $ret = $this->mail->deleteFolder($folder); |
| 1982 | 1981 | if ($ret) $newHash = $this->rename_folder_hash($account, $old_hash, "##Dele#edFolder#$folder##"); |
| 1983 | 1982 | return $ret; |
@@ -1999,8 +1998,8 @@ discard block |
||
| 1999 | 1998 | $this->_connect($this->account); |
| 2000 | 1999 | $account = $folder = null; |
| 2001 | 2000 | $this->splitID($folderid, $account, $folder); |
| 2002 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
| 2003 | - ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
| 2001 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
| 2002 | + ZLog::Write(LOGLEVEL_DEBUG, "IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
| 2004 | 2003 | |
| 2005 | 2004 | return $rv; |
| 2006 | 2005 | } |
@@ -2014,17 +2013,17 @@ discard block |
||
| 2014 | 2013 | * @return string |
| 2015 | 2014 | * @throws Api\Exception\WrongParameter |
| 2016 | 2015 | */ |
| 2017 | - private function createID($account,$folder,$id=0) |
|
| 2016 | + private function createID($account, $folder, $id = 0) |
|
| 2018 | 2017 | { |
| 2019 | 2018 | if (!is_numeric($folder)) |
| 2020 | 2019 | { |
| 2021 | 2020 | // convert string $folder in numeric id |
| 2022 | - $folder = $this->folder2hash($account,$f=$folder); |
|
| 2021 | + $folder = $this->folder2hash($account, $f = $folder); |
|
| 2023 | 2022 | } |
| 2024 | 2023 | |
| 2025 | 2024 | $str = $this->backend->createID($account, $folder, $id); |
| 2026 | 2025 | |
| 2027 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2026 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
| 2028 | 2027 | |
| 2029 | 2028 | return $str; |
| 2030 | 2029 | } |
@@ -2038,14 +2037,14 @@ discard block |
||
| 2038 | 2037 | * @param int &$appid=null (for mail=mail is to be expected) |
| 2039 | 2038 | * @throws Api\Exception\WrongParameter |
| 2040 | 2039 | */ |
| 2041 | - private function splitID($str,&$account,&$folder,&$appid=null) |
|
| 2040 | + private function splitID($str, &$account, &$folder, &$appid = null) |
|
| 2042 | 2041 | { |
| 2043 | 2042 | $this->backend->splitID($str, $account, $folder, $appid); |
| 2044 | 2043 | |
| 2045 | 2044 | // convert numeric folder-id back to folder name |
| 2046 | - $folder = $this->hash2folder($account,$f=$folder); |
|
| 2045 | + $folder = $this->hash2folder($account, $f = $folder); |
|
| 2047 | 2046 | |
| 2048 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2047 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$appid)"); |
|
| 2049 | 2048 | } |
| 2050 | 2049 | |
| 2051 | 2050 | /** |
@@ -2062,9 +2061,9 @@ discard block |
||
| 2062 | 2061 | * @param string $folder |
| 2063 | 2062 | * @return int |
| 2064 | 2063 | */ |
| 2065 | - private function folder2hash($account,$folder) |
|
| 2064 | + private function folder2hash($account, $folder) |
|
| 2066 | 2065 | { |
| 2067 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2066 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2068 | 2067 | |
| 2069 | 2068 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
| 2070 | 2069 | { |
@@ -2085,9 +2084,9 @@ discard block |
||
| 2085 | 2084 | * @param int $index |
| 2086 | 2085 | * @return string NULL if not used so far |
| 2087 | 2086 | */ |
| 2088 | - private function hash2folder($account,$index) |
|
| 2087 | + private function hash2folder($account, $index) |
|
| 2089 | 2088 | { |
| 2090 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2089 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
| 2091 | 2090 | |
| 2092 | 2091 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
| 2093 | 2092 | } |
@@ -2143,9 +2142,9 @@ discard block |
||
| 2143 | 2142 | if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
| 2144 | 2143 | ($hashes = file_get_contents($file))) |
| 2145 | 2144 | { |
| 2146 | - $this->folderHashes = json_decode($hashes,true); |
|
| 2145 | + $this->folderHashes = json_decode($hashes, true); |
|
| 2147 | 2146 | // fallback in case hashes have been serialized instead of being json-encoded |
| 2148 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
| 2147 | + if (json_last_error() != JSON_ERROR_NONE) |
|
| 2149 | 2148 | { |
| 2150 | 2149 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
| 2151 | 2150 | $this->folderHashes = unserialize($hashes); |
@@ -2191,9 +2190,9 @@ discard block |
||
| 2191 | 2190 | * @param boolean $old =false true: return old / pre-15 hash-file |
| 2192 | 2191 | * @throws Api\Exception\AssertionFailed |
| 2193 | 2192 | */ |
| 2194 | - private function hashFile($old=false) |
|
| 2193 | + private function hashFile($old = false) |
|
| 2195 | 2194 | { |
| 2196 | - if (!($dev_id=Request::GetDeviceID())) |
|
| 2195 | + if (!($dev_id = Request::GetDeviceID())) |
|
| 2197 | 2196 | { |
| 2198 | 2197 | throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
| 2199 | 2198 | } |