@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | * @param string $newfolderid id of the destination folder |
1306 | 1306 | * @param ContentParameters $contentParameters |
1307 | 1307 | * |
1308 | - * @return boolean status of the operation |
|
1308 | + * @return string status of the operation |
|
1309 | 1309 | * @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions |
1310 | 1310 | */ |
1311 | 1311 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
@@ -1832,7 +1832,7 @@ discard block |
||
1832 | 1832 | * @param string $displayname => new folder name (to be created, or to be renamed to) |
1833 | 1833 | * @param string $type folder type, ignored in IMAP |
1834 | 1834 | * |
1835 | - * @return array|boolean stat array or false on error |
|
1835 | + * @return boolean stat array or false on error |
|
1836 | 1836 | */ |
1837 | 1837 | public function ChangeFolder($id, $oldid, $displayname, $type) |
1838 | 1838 | { |
@@ -1847,7 +1847,7 @@ discard block |
||
1847 | 1847 | * @param string $id of the folder to delete |
1848 | 1848 | * |
1849 | 1849 | * @return |
1850 | - * @TODO check what is to be returned |
|
1850 | + boolean @TODO check what is to be returned |
|
1851 | 1851 | */ |
1852 | 1852 | public function DeleteFolder($parentid, $id) |
1853 | 1853 | { |
@@ -296,44 +296,44 @@ discard block |
||
296 | 296 | return $folderlist; |
297 | 297 | } |
298 | 298 | |
299 | - /** |
|
300 | - * Sends a message which is passed as rfc822. You basically can do two things |
|
301 | - * 1) Send the message to an SMTP server as-is |
|
302 | - * 2) Parse the message yourself, and send it some other way |
|
303 | - * It is up to you whether you want to put the message in the sent items folder. If you |
|
304 | - * want it in 'sent items', then the next sync on the 'sent items' folder should return |
|
305 | - * the new message as any other new message in a folder. |
|
306 | - * |
|
307 | - * @param array $smartdata = IMAP-SendMail: SyncSendMail ( |
|
308 | - * (S) clientid => SendMail-30722448149304 |
|
309 | - * (S) saveinsent => empty |
|
310 | - * (S) replacemime => null |
|
311 | - * (S) accountid => null |
|
312 | - * (S) source => SyncSendMailSource ( |
|
313 | - * (S) folderid => 101000000000 |
|
314 | - * (S) itemid => 33776 |
|
315 | - * (S) longid => null |
|
316 | - * (S) instanceid => null |
|
317 | - * unsetVars(Array) size: 0 |
|
318 | - * flags => false |
|
319 | - * content => null |
|
320 | - * ) |
|
321 | - * (S) mime => Date: Tue, 23 Jun 2015 14:13:23 +0200 |
|
322 | - *Subject: AW: Blauer himmel |
|
323 | - *.... |
|
324 | - * (S) replyflag => true |
|
325 | - * (S) forwardflag => null |
|
326 | - * unsetVars(Array) size: 0 |
|
327 | - * flags => false |
|
328 | - * content => null |
|
329 | - *) |
|
299 | + /** |
|
300 | + * Sends a message which is passed as rfc822. You basically can do two things |
|
301 | + * 1) Send the message to an SMTP server as-is |
|
302 | + * 2) Parse the message yourself, and send it some other way |
|
303 | + * It is up to you whether you want to put the message in the sent items folder. If you |
|
304 | + * want it in 'sent items', then the next sync on the 'sent items' folder should return |
|
305 | + * the new message as any other new message in a folder. |
|
306 | + * |
|
307 | + * @param array $smartdata = IMAP-SendMail: SyncSendMail ( |
|
308 | + * (S) clientid => SendMail-30722448149304 |
|
309 | + * (S) saveinsent => empty |
|
310 | + * (S) replacemime => null |
|
311 | + * (S) accountid => null |
|
312 | + * (S) source => SyncSendMailSource ( |
|
313 | + * (S) folderid => 101000000000 |
|
314 | + * (S) itemid => 33776 |
|
315 | + * (S) longid => null |
|
316 | + * (S) instanceid => null |
|
317 | + * unsetVars(Array) size: 0 |
|
318 | + * flags => false |
|
319 | + * content => null |
|
320 | + * ) |
|
321 | + * (S) mime => Date: Tue, 23 Jun 2015 14:13:23 +0200 |
|
322 | + *Subject: AW: Blauer himmel |
|
323 | + *.... |
|
324 | + * (S) replyflag => true |
|
325 | + * (S) forwardflag => null |
|
326 | + * unsetVars(Array) size: 0 |
|
327 | + * flags => false |
|
328 | + * content => null |
|
329 | + *) |
|
330 | 330 | * |
331 | - * @return boolean true on success, false on error |
|
332 | - * |
|
333 | - * @see eg. BackendIMAP::SendMail() |
|
334 | - * @todo implement either here or in mail backend |
|
335 | - * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
|
336 | - */ |
|
331 | + * @return boolean true on success, false on error |
|
332 | + * |
|
333 | + * @see eg. BackendIMAP::SendMail() |
|
334 | + * @todo implement either here or in mail backend |
|
335 | + * (maybe sending here and storing to sent folder in plugin, as sending is supposed to always work in EGroupware) |
|
336 | + */ |
|
337 | 337 | public function SendMail($smartdata) |
338 | 338 | { |
339 | 339 | //$this->debugLevel=2; |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
457 | 457 | // if this is a multipart message with a boundary, we must use the original body |
458 | 458 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
459 | - if ($use_orgbody) { |
|
460 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
459 | + if ($use_orgbody) { |
|
460 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
461 | 461 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
462 | 462 | if (($cal_body = $mailObject->findBody('calendar')) && |
463 | 463 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
470 | 470 | $ClientSideMeetingRequest = true; |
471 | 471 | } |
472 | - } |
|
472 | + } |
|
473 | 473 | // now handle the addressee list |
474 | 474 | $toCount = 0; |
475 | 475 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
560 | 560 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
561 | 561 | if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
562 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
562 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
563 | 563 | // may be html |
564 | 564 | if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
565 | 565 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $this->splitID($smartdata->source->folderid, $account, $folder); |
607 | 607 | |
608 | 608 | $this->mail->reopen($folder); |
609 | - // receive entire mail (header + body) |
|
609 | + // receive entire mail (header + body) |
|
610 | 610 | // get message headers for specified message |
611 | 611 | $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
612 | 612 | // build a new mime message, forward entire old mail as file |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | //advanced debugging |
692 | 692 | // Horde SMTP Class uses utf-8 by default. |
693 | - //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
693 | + //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
|
694 | 694 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
695 | 695 | |
696 | 696 | // set a higher timeout for big messages |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | //$asf = false; |
784 | 784 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
785 | 785 | } |
786 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
786 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
787 | 787 | } |
788 | 788 | //$this->mail->closeConnection(); |
789 | 789 | } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | $output->asbody->type = 1; |
992 | 992 | $output->nativebodytype = 1; |
993 | 993 | if(isset($truncsize) && |
994 | - strlen($plainBody) > $truncsize) |
|
994 | + strlen($plainBody) > $truncsize) |
|
995 | 995 | { |
996 | 996 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
997 | 997 | $output->asbody->truncated = 1; |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | // end handle Attachments |
1126 | 1126 | unset($attachments); |
1127 | 1127 | |
1128 | - // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
|
1129 | - $output->internetcpid = INTERNET_CPID_UTF8; |
|
1128 | + // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
|
1129 | + $output->internetcpid = INTERNET_CPID_UTF8; |
|
1130 | 1130 | |
1131 | 1131 | if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
1132 | 1132 | //$this->debugLevel=0; |
@@ -1184,8 +1184,8 @@ discard block |
||
1184 | 1184 | * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should |
1185 | 1185 | * encode any information you need to find the attachment in that 'attname' property. |
1186 | 1186 | * |
1187 | - * @param string $fid - id |
|
1188 | - * @param string $attname - should contain (folder)id |
|
1187 | + * @param string $fid - id |
|
1188 | + * @param string $attname - should contain (folder)id |
|
1189 | 1189 | * @return true, prints the content of the attachment |
1190 | 1190 | */ |
1191 | 1191 | function GetAttachmentData($fid,$attname) { |
@@ -1199,16 +1199,16 @@ discard block |
||
1199 | 1199 | |
1200 | 1200 | $this->mail->reopen($folder); |
1201 | 1201 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
1202 | - $SIOattachment = new SyncItemOperationsAttachment(); |
|
1202 | + $SIOattachment = new SyncItemOperationsAttachment(); |
|
1203 | 1203 | fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
1204 | - $SIOattachment->data = $attachment['attachment']; |
|
1204 | + $SIOattachment->data = $attachment['attachment']; |
|
1205 | 1205 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
1206 | - if (isset($attachment['type']) ) |
|
1207 | - $SIOattachment->contenttype = $attachment['type']; |
|
1206 | + if (isset($attachment['type']) ) |
|
1207 | + $SIOattachment->contenttype = $attachment['type']; |
|
1208 | 1208 | |
1209 | 1209 | unset($attachment); |
1210 | 1210 | |
1211 | - return $SIOattachment; |
|
1211 | + return $SIOattachment; |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | * the exact string that is returned in the 'AttName' property of an SyncAttachment. So, you should |
1218 | 1218 | * encode any information you need to find the attachment in that 'attname' property. |
1219 | 1219 | * |
1220 | - * @param string $fid - id |
|
1221 | - * @param string $attname - should contain (folder)id |
|
1220 | + * @param string $fid - id |
|
1221 | + * @param string $attname - should contain (folder)id |
|
1222 | 1222 | * @return SyncItemOperationsAttachment-object |
1223 | 1223 | */ |
1224 | 1224 | function ItemOperationsGetAttachmentData($fid,$attname) { |
@@ -1232,15 +1232,15 @@ discard block |
||
1232 | 1232 | |
1233 | 1233 | $this->mail->reopen($folder); |
1234 | 1234 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
1235 | - $SIOattachment = new SyncItemOperationsAttachment(); |
|
1235 | + $SIOattachment = new SyncItemOperationsAttachment(); |
|
1236 | 1236 | fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
1237 | - $SIOattachment->data = $attachment['attachment']; |
|
1238 | - if (isset($attachment['type']) ) |
|
1239 | - $SIOattachment->contenttype = $attachment['type']; |
|
1237 | + $SIOattachment->data = $attachment['attachment']; |
|
1238 | + if (isset($attachment['type']) ) |
|
1239 | + $SIOattachment->contenttype = $attachment['type']; |
|
1240 | 1240 | |
1241 | 1241 | unset($attachment); |
1242 | 1242 | |
1243 | - return $SIOattachment; |
|
1243 | + return $SIOattachment; |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | /** |
@@ -1702,21 +1702,21 @@ discard block |
||
1702 | 1702 | $account = $folder = null; |
1703 | 1703 | $this->splitID($folderid, $account, $folder); |
1704 | 1704 | if (is_numeric($account)) $type = 'mail'; |
1705 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid -> $folder ($account) type: ". $type); |
|
1705 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid -> $folder ($account) type: ". $type); |
|
1706 | 1706 | if ($type != 'mail') return false; |
1707 | 1707 | |
1708 | 1708 | if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
1709 | 1709 | |
1710 | 1710 | $changes = array(); |
1711 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid ($folder) stat: ". $syncstate); |
|
1712 | - $this->mail->reopen($folder); |
|
1713 | - $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1714 | - if (!$status) { |
|
1715 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
1716 | - return false; |
|
1717 | - } else { |
|
1718 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1719 | - } |
|
1711 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid ($folder) stat: ". $syncstate); |
|
1712 | + $this->mail->reopen($folder); |
|
1713 | + $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1714 | + if (!$status) { |
|
1715 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
1716 | + return false; |
|
1717 | + } else { |
|
1718 | + $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1719 | + } |
|
1720 | 1720 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' called with ('.$folderid.', ....) returning '.array2string($syncstate)); |
1721 | 1721 | return $changes; |
1722 | 1722 | } |
@@ -1735,22 +1735,22 @@ discard block |
||
1735 | 1735 | return $id; |
1736 | 1736 | } |
1737 | 1737 | |
1738 | - /** |
|
1739 | - * Called when the user has requested to delete (really delete) a message. Usually |
|
1740 | - * this means just unlinking the file its in or somesuch. After this call has succeeded, a call to |
|
1741 | - * GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile |
|
1742 | - * as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to |
|
1743 | - * delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile |
|
1744 | - * |
|
1745 | - * @param string $folderid id of the folder |
|
1746 | - * @param string $id id of the message |
|
1747 | - * @param ContentParameters $contentParameters |
|
1748 | - * |
|
1749 | - * @access public |
|
1750 | - * @return boolean status of the operation |
|
1751 | - * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
1752 | - */ |
|
1753 | - public function DeleteMessage($folderid, $id, $contentParameters) |
|
1738 | + /** |
|
1739 | + * Called when the user has requested to delete (really delete) a message. Usually |
|
1740 | + * this means just unlinking the file its in or somesuch. After this call has succeeded, a call to |
|
1741 | + * GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile |
|
1742 | + * as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to |
|
1743 | + * delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile |
|
1744 | + * |
|
1745 | + * @param string $folderid id of the folder |
|
1746 | + * @param string $id id of the message |
|
1747 | + * @param ContentParameters $contentParameters |
|
1748 | + * |
|
1749 | + * @access public |
|
1750 | + * @return boolean status of the operation |
|
1751 | + * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
1752 | + */ |
|
1753 | + public function DeleteMessage($folderid, $id, $contentParameters) |
|
1754 | 1754 | { |
1755 | 1755 | unset($contentParameters); // not used, but required by function signature |
1756 | 1756 | debugLog("IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
@@ -1792,24 +1792,24 @@ discard block |
||
1792 | 1792 | return $rv; |
1793 | 1793 | } |
1794 | 1794 | |
1795 | - /** |
|
1796 | - * Changes the 'read' flag of a message on disk. The $flags |
|
1797 | - * parameter can only be '1' (read) or '0' (unread). After a call to |
|
1798 | - * SetReadFlag(), GetMessageList() should return the message with the |
|
1799 | - * new 'flags' but should not modify the 'mod' parameter. If you do |
|
1800 | - * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
1801 | - * a full resync of the item from the server. |
|
1802 | - * |
|
1803 | - * @param string $folderid id of the folder |
|
1804 | - * @param string $id id of the message |
|
1805 | - * @param int $flags read flag of the message |
|
1806 | - * @param ContentParameters $contentParameters |
|
1807 | - * |
|
1808 | - * @access public |
|
1809 | - * @return boolean status of the operation |
|
1810 | - * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
1811 | - */ |
|
1812 | - public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
|
1795 | + /** |
|
1796 | + * Changes the 'read' flag of a message on disk. The $flags |
|
1797 | + * parameter can only be '1' (read) or '0' (unread). After a call to |
|
1798 | + * SetReadFlag(), GetMessageList() should return the message with the |
|
1799 | + * new 'flags' but should not modify the 'mod' parameter. If you do |
|
1800 | + * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
1801 | + * a full resync of the item from the server. |
|
1802 | + * |
|
1803 | + * @param string $folderid id of the folder |
|
1804 | + * @param string $id id of the message |
|
1805 | + * @param int $flags read flag of the message |
|
1806 | + * @param ContentParameters $contentParameters |
|
1807 | + * |
|
1808 | + * @access public |
|
1809 | + * @return boolean status of the operation |
|
1810 | + * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
1811 | + */ |
|
1812 | + public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
|
1813 | 1813 | { |
1814 | 1814 | unset($contentParameters); // not used, but required by function signature |
1815 | 1815 | // debugLog("IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
@@ -87,23 +87,23 @@ discard block |
||
87 | 87 | $this->backend = $backend; |
88 | 88 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
89 | 89 | { |
90 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
90 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
91 | 91 | // globals preferences add appname varname value |
92 | - $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
|
92 | + $GLOBALS['egw']->preferences->add('activesync', 'mail-ActiveSyncProfileID', 0, 'user'); |
|
93 | 93 | // save prefs |
94 | 94 | $GLOBALS['egw']->preferences->save_repository(true); |
95 | 95 | } |
96 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
96 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
97 | 97 | |
98 | 98 | if (is_null(self::$profileID)) |
99 | 99 | { |
100 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
101 | - self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
|
102 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
100 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
101 | + self::$profileID = & Api\Cache::getSession('mail', 'activeSyncProfileID'); |
|
102 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
103 | 103 | } |
104 | 104 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
105 | 105 | { |
106 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
106 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
107 | 107 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
108 | 108 | { |
109 | 109 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
114 | 114 | } |
115 | 115 | } |
116 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
116 | + if ($this->debugLevel > 1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
117 | 117 | |
118 | 118 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
119 | 119 | if (!isset($GLOBALS['egw_setup'])) |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | try { |
122 | 122 | Mail\Account::read(self::$profileID); |
123 | 123 | } |
124 | - catch(Exception $e) { |
|
124 | + catch (Exception $e) { |
|
125 | 125 | unset($e); |
126 | 126 | self::$profileID = Mail\Account::get_default_acc_id(); |
127 | 127 | } |
128 | 128 | } |
129 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
129 | + if ($this->debugLevel > 0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
130 | 130 | //$this->debugLevel=0; |
131 | 131 | } |
132 | 132 | |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | $this->__construct($this->backend); |
199 | 199 | |
200 | 200 | try { |
201 | - $this->_connect(0,true); |
|
201 | + $this->_connect(0, true); |
|
202 | 202 | $this->_disconnect(); |
203 | 203 | |
204 | 204 | if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
205 | 205 | if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
206 | 206 | } |
207 | - catch(Exception $e) { |
|
207 | + catch (Exception $e) { |
|
208 | 208 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
209 | 209 | } |
210 | 210 | if ($errors) |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param int $account integer id of account to use |
223 | 223 | * @todo support different accounts |
224 | 224 | */ |
225 | - private function _connect($account=0) |
|
225 | + private function _connect($account = 0) |
|
226 | 226 | { |
227 | 227 | if (!$account) $account = self::$profileID ? self::$profileID : 0; |
228 | 228 | if ($this->mail && $this->account != $account) $this->_disconnect(); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $this->account = $account; |
236 | 236 | // todo: tell mail which account to use |
237 | 237 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
238 | - $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
238 | + $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
239 | 239 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
240 | 240 | } |
241 | 241 | else |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
244 | 244 | if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
245 | 245 | } |
246 | - $this->mail->openConnection(self::$profileID,false); |
|
246 | + $this->mail->openConnection(self::$profileID, false); |
|
247 | 247 | |
248 | 248 | $this->_wasteID = $this->mail->getTrashFolder(false); |
249 | 249 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | private function _disconnect() |
260 | 260 | { |
261 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
261 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__); |
|
262 | 262 | if ($this->mail) $this->mail->closeConnection(); |
263 | 263 | |
264 | 264 | unset($this->mail); |
@@ -274,24 +274,24 @@ discard block |
||
274 | 274 | public function GetFolderList() |
275 | 275 | { |
276 | 276 | $folderlist = array(); |
277 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
277 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__); |
|
278 | 278 | /*foreach($available_accounts as $account)*/ $account = 0; |
279 | 279 | { |
280 | 280 | $this->_connect($account); |
281 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
282 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
281 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false, $_alwaysGetDefaultFolders = true); |
|
282 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($this->folders)); |
|
283 | 283 | |
284 | 284 | foreach ($this->folders as $folder => $folderObj) { |
285 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
285 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' folder='.$folder); |
|
286 | 286 | $folderlist[] = $f = array( |
287 | - 'id' => $this->createID($account,$folder), |
|
287 | + 'id' => $this->createID($account, $folder), |
|
288 | 288 | 'mod' => $folderObj->shortDisplayName, |
289 | - 'parent' => $this->getParentID($account,$folder), |
|
289 | + 'parent' => $this->getParentID($account, $folder), |
|
290 | 290 | ); |
291 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
291 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($f)); |
|
292 | 292 | } |
293 | 293 | } |
294 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
294 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() returning ".array2string($folderlist)); |
|
295 | 295 | |
296 | 296 | return $folderlist; |
297 | 297 | } |
@@ -340,59 +340,59 @@ discard block |
||
340 | 340 | $ClientSideMeetingRequest = false; |
341 | 341 | $allowSendingInvitations = 'sendifnocalnotif'; |
342 | 342 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
343 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='nosend') |
|
343 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'nosend') |
|
344 | 344 | { |
345 | 345 | $allowSendingInvitations = false; |
346 | 346 | } |
347 | 347 | elseif (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && |
348 | - $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']!='nosend') |
|
348 | + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] != 'nosend') |
|
349 | 349 | { |
350 | 350 | $allowSendingInvitations = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']; |
351 | 351 | } |
352 | - $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
|
352 | + $smartdata_task = ($smartdata->replyflag ? 'reply' : ($smartdata->forwardflag ? 'forward' : 'new')); |
|
353 | 353 | |
354 | - 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 : "")); |
|
355 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
354 | + 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 : "")); |
|
355 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
356 | 356 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
357 | 357 | |
358 | 358 | // initialize our Mail |
359 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
359 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
360 | 360 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
361 | 361 | // use the standardIdentity |
362 | - $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
|
362 | + $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles, self::$profileID); |
|
363 | 363 | |
364 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
364 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
365 | 365 | |
366 | 366 | // initialize the new Api\Mailer object for sending |
367 | 367 | $mailObject = new Api\Mailer(self::$profileID); |
368 | - $this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime); |
|
368 | + $this->mail->parseRawMessageIntoMailObject($mailObject, $smartdata->mime); |
|
369 | 369 | // Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8 |
370 | - $mailObject->Sender = $activeMailProfile['ident_email']; |
|
371 | - $mailObject->From = $activeMailProfile['ident_email']; |
|
372 | - $mailObject->FromName = $mailObject->EncodeHeader(Mail::generateIdentityString($activeMailProfile,false)); |
|
370 | + $mailObject->Sender = $activeMailProfile['ident_email']; |
|
371 | + $mailObject->From = $activeMailProfile['ident_email']; |
|
372 | + $mailObject->FromName = $mailObject->EncodeHeader(Mail::generateIdentityString($activeMailProfile, false)); |
|
373 | 373 | $mailObject->AddCustomHeader('X-Mailer: mail-Activesync'); |
374 | 374 | |
375 | 375 | |
376 | 376 | // prepare addressee list; moved the adding of addresses to the mailobject down |
377 | 377 | // to |
378 | 378 | |
379 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
379 | + foreach (Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
380 | 380 | if (!$addressObject->valid) continue; |
381 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
|
381 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject)); |
|
382 | 382 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
383 | 383 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
384 | 384 | } |
385 | 385 | // CC |
386 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
386 | + foreach (Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
387 | 387 | if (!$addressObject->valid) continue; |
388 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
|
388 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject)); |
|
389 | 389 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
390 | 390 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
391 | 391 | } |
392 | 392 | // BCC |
393 | - foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
393 | + foreach (Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
394 | 394 | if (!$addressObject->valid) continue; |
395 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
|
395 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject)); |
|
396 | 396 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
397 | 397 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
398 | 398 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $use_orgbody = false; |
402 | 402 | |
403 | 403 | $k = 'Content-Type'; |
404 | - $ContentType =$mailObject->getHeader('Content-Type'); |
|
404 | + $ContentType = $mailObject->getHeader('Content-Type'); |
|
405 | 405 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
406 | 406 | // if the message is a multipart message, then we should use the sent body |
407 | 407 | if (preg_match("/multipart/i", $ContentType)) { |
@@ -421,43 +421,43 @@ discard block |
||
421 | 421 | $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
422 | 422 | $use_orgbody = true; |
423 | 423 | } |
424 | - $Body = $AltBody = ""; |
|
424 | + $Body = $AltBody = ""; |
|
425 | 425 | // get body of the transmitted message |
426 | 426 | // if this is a simple message, no structure at all |
427 | 427 | if (preg_match("/text/i", $ContentType)) |
428 | 428 | { |
429 | - $simpleBodyType = (preg_match("/html/i", $ContentType)?'text/html':'text/plain'); |
|
429 | + $simpleBodyType = (preg_match("/html/i", $ContentType) ? 'text/html' : 'text/plain'); |
|
430 | 430 | $bodyObj = $mailObject->findBody(preg_match("/html/i", $ContentType) ? 'html' : 'plain'); |
431 | - $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", $bodyObj ?$bodyObj->getContents() : null); |
|
432 | - if ($simpleBodyType == "text/plain") |
|
431 | + $body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", $bodyObj ? $bodyObj->getContents() : null); |
|
432 | + if ($simpleBodyType == "text/plain") |
|
433 | 433 | { |
434 | 434 | $Body = $body; |
435 | 435 | $AltBody = "<pre>".nl2br($body)."</pre>"; |
436 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created AltBody'); |
|
436 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created AltBody'); |
|
437 | 437 | } |
438 | 438 | else |
439 | 439 | { |
440 | 440 | $AltBody = $body; |
441 | - $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
442 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body'); |
|
441 | + $Body = trim(Api\Mail\Html::convertHTMLToText($body)); |
|
442 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as :".$simpleBodyType.'=> Created Body'); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | else |
446 | 446 | { |
447 | 447 | // if this is a structured message |
448 | 448 | // prefer plain over html |
449 | - $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
449 | + $Body = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
450 | 450 | ($text_body = $mailObject->findBody('plain')) ? $text_body->getContents() : null); |
451 | - $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
|
451 | + $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "[$2]", |
|
452 | 452 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
453 | 453 | } |
454 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
455 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
454 | + if ($this->debugLevel > 1 && $Body) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched Body as with MessageContentType:".$ContentType.'=>'.$Body); |
|
455 | + if ($this->debugLevel > 1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:".$ContentType.'=>'.$AltBody); |
|
456 | 456 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
457 | 457 | // if this is a multipart message with a boundary, we must use the original body |
458 | 458 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
459 | 459 | if ($use_orgbody) { |
460 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
460 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
|
461 | 461 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
462 | 462 | if (($cal_body = $mailObject->findBody('calendar')) && |
463 | 463 | ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) |
@@ -466,21 +466,21 @@ discard block |
||
466 | 466 | { |
467 | 467 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
468 | 468 | } |
469 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
469 | + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
470 | 470 | $ClientSideMeetingRequest = true; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | // now handle the addressee list |
474 | 474 | $toCount = 0; |
475 | 475 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
476 | - foreach((array)$toMailAddr as $address) { |
|
477 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
478 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
476 | + foreach ((array)$toMailAddr as $address) { |
|
477 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
478 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
479 | 479 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
480 | 480 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
481 | 481 | $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) |
482 | 482 | { |
483 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
483 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); |
|
484 | 484 | continue; |
485 | 485 | } |
486 | 486 | $mailObject->AddAddress($emailAddress, $addressObject->personal); |
@@ -488,29 +488,29 @@ discard block |
||
488 | 488 | } |
489 | 489 | } |
490 | 490 | $ccCount = 0; |
491 | - foreach((array)$ccMailAddr as $address) { |
|
492 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
493 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
491 | + foreach ((array)$ccMailAddr as $address) { |
|
492 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
493 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
494 | 494 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
495 | 495 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
496 | 496 | $ccCount++; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | $bccCount = 0; |
500 | - foreach((array)$bccMailAddr as $address) { |
|
501 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
502 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
500 | + foreach ((array)$bccMailAddr as $address) { |
|
501 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
502 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
503 | 503 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
504 | 504 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
505 | 505 | $bccCount++; |
506 | 506 | } |
507 | 507 | } |
508 | 508 | // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above |
509 | - if ($toCount+$ccCount+$bccCount == 0) |
|
509 | + if ($toCount + $ccCount + $bccCount == 0) |
|
510 | 510 | { |
511 | 511 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
512 | 512 | } |
513 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
513 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations === false) return true; |
|
514 | 514 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
515 | 515 | /* |
516 | 516 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -518,29 +518,29 @@ discard block |
||
518 | 518 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body (modified):'.$body); |
519 | 519 | */ |
520 | 520 | // add signature!! ----------------------------------------------------------------- |
521 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
521 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ActiveMailProfile:'.array2string($activeMailProfile)); |
|
522 | 522 | try |
523 | 523 | { |
524 | 524 | $acc = Mail\Account::read($this->mail->icServer->ImapServerId); |
525 | 525 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
526 | - $_signature = Mail\Account::read_identity($acc['ident_id'],true); |
|
526 | + $_signature = Mail\Account::read_identity($acc['ident_id'], true); |
|
527 | 527 | } |
528 | 528 | catch (Exception $e) |
529 | 529 | { |
530 | - $_signature=array(); |
|
530 | + $_signature = array(); |
|
531 | 531 | } |
532 | 532 | $signature = $_signature['ident_signature']; |
533 | 533 | if ((isset($preferencesArray['disableRulerForSignatureSeparation']) && |
534 | 534 | $preferencesArray['disableRulerForSignatureSeparation']) || |
535 | - empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='') |
|
535 | + empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) == '') |
|
536 | 536 | { |
537 | 537 | $disableRuler = true; |
538 | 538 | } |
539 | 539 | $beforePlain = $beforeHtml = ""; |
540 | - $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
541 | - $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
542 | - $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
543 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
540 | + $beforeHtml = ($disableRuler ? ' <br>' : ' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
|
541 | + $beforePlain = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
542 | + $sigText = Mail::merge($signature, array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
543 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
544 | 544 | $sigTextHtml = $beforeHtml.$sigText; |
545 | 545 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
546 | 546 | $isreply = $isforward = false; |
@@ -552,26 +552,26 @@ discard block |
||
552 | 552 | { |
553 | 553 | // now get on, and fetch the original mail |
554 | 554 | $uid = $smartdata->source->itemid; |
555 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
555 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
556 | 556 | $this->splitID($smartdata->source->folderid, $account, $folder); |
557 | 557 | |
558 | 558 | $this->mail->reopen($folder); |
559 | 559 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
560 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
561 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
562 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
560 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
561 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
562 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
563 | 563 | // may be html |
564 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
564 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
565 | 565 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
566 | 566 | $isreply = true; |
567 | 567 | } |
568 | 568 | // plain text Message part |
569 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
569 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
570 | 570 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
571 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
572 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
573 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
574 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
571 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
572 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
573 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
574 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
575 | 575 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
576 | 576 | $isreply = true; |
577 | 577 | } |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | { |
580 | 580 | $isreply = true; |
581 | 581 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
582 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
582 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | 586 | // how to forward and other prefs |
587 | - $preferencesArray =& $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
587 | + $preferencesArray = & $GLOBALS['egw_info']['user']['preferences']['mail']; |
|
588 | 588 | |
589 | 589 | // forward ------------------------------------------------------------------------- |
590 | 590 | if ($smartdata_task == 'forward' && isset($smartdata->source->itemid) && |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | { |
595 | 595 | //force the default for the forwarding -> asmail |
596 | 596 | if (is_array($preferencesArray)) { |
597 | - if (!array_key_exists('message_forwarding',$preferencesArray) |
|
597 | + if (!array_key_exists('message_forwarding', $preferencesArray) |
|
598 | 598 | || !isset($preferencesArray['message_forwarding']) |
599 | 599 | || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
600 | 600 | } else { |
@@ -602,18 +602,18 @@ discard block |
||
602 | 602 | } |
603 | 603 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
604 | 604 | $uid = $smartdata->source->itemid; |
605 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
605 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.")IMAP Smartfordward is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
606 | 606 | $this->splitID($smartdata->source->folderid, $account, $folder); |
607 | 607 | |
608 | 608 | $this->mail->reopen($folder); |
609 | 609 | // receive entire mail (header + body) |
610 | 610 | // get message headers for specified message |
611 | - $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
611 | + $headers = $this->mail->getMessageEnvelope($uid, $_partID, true, $folder); |
|
612 | 612 | // build a new mime message, forward entire old mail as file |
613 | 613 | if ($preferencesArray['message_forwarding'] == 'asmail') |
614 | 614 | { |
615 | - $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder); |
|
616 | - $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder); |
|
615 | + $rawHeader = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID, $folder); |
|
616 | + $rawBody = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID, $folder); |
|
617 | 617 | $mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822'); |
618 | 618 | $AltBody = $AltBody."</br>".lang("See Attachments for Content of the Orignial Mail").$sigTextHtml; |
619 | 619 | $Body = $Body."\r\n".lang("See Attachments for Content of the Orignial Mail").$sigTextPlain; |
@@ -623,50 +623,50 @@ discard block |
||
623 | 623 | { |
624 | 624 | // now get on, and fetch the original mail |
625 | 625 | $uid = $smartdata->source->itemid; |
626 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
626 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP Smartreply is called with FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
627 | 627 | $this->splitID($smartdata->source->folderid, $account, $folder); |
628 | 628 | |
629 | 629 | $this->mail->reopen($folder); |
630 | 630 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
631 | - $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
632 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
633 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
631 | + $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
632 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
633 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
634 | 634 | // may be html |
635 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
635 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
636 | 636 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
637 | 637 | $isforward = true; |
638 | 638 | } |
639 | 639 | // plain text Message part |
640 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
640 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
641 | 641 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
642 | - $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
|
643 | - $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
644 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
645 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
642 | + $bodyStruct = $this->mail->getMessageBody($uid, 'never_display'); //'never_display'); |
|
643 | + $bodyBUFF = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
644 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/plain')) { |
|
645 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
646 | 646 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
647 | 647 | $isforward = true; |
648 | 648 | } |
649 | 649 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
650 | 650 | { |
651 | 651 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
652 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
652 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
653 | 653 | $isforward = true; |
654 | 654 | } |
655 | 655 | // get all the attachments and add them too. |
656 | 656 | // start handle Attachments |
657 | 657 | // $_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folderName='' |
658 | - $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true , $folder); |
|
658 | + $attachments = $this->mail->getMessageAttachments($uid, null, null, true, false, true, $folder); |
|
659 | 659 | $attachmentNames = false; |
660 | - if (is_array($attachments) && count($attachments)>0) |
|
660 | + if (is_array($attachments) && count($attachments) > 0) |
|
661 | 661 | { |
662 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
663 | - foreach((array)$attachments as $key => $attachment) |
|
662 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
|
663 | + foreach ((array)$attachments as $key => $attachment) |
|
664 | 664 | { |
665 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
665 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
666 | 666 | $attachmentNames .= $attachment['name']."\n"; |
667 | - $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
|
667 | + $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'], 0, false, false, $folder); |
|
668 | 668 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
669 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x); |
|
669 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' added part with number:'.$x); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | } |
@@ -680,36 +680,36 @@ discard block |
||
680 | 680 | // now set the body |
681 | 681 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
682 | 682 | { |
683 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
684 | - $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
683 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$AltBody); |
|
684 | + $html_body->setContents($AltBody, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
685 | 685 | } |
686 | 686 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
687 | 687 | { |
688 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
689 | - $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
688 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.$Body); |
|
689 | + $text_body->setContents($Body, array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
690 | 690 | } |
691 | 691 | //advanced debugging |
692 | 692 | // Horde SMTP Class uses utf-8 by default. |
693 | 693 | //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
694 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
694 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
695 | 695 | |
696 | 696 | // set a higher timeout for big messages |
697 | 697 | @set_time_limit(120); |
698 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.' about to send ....'); |
|
698 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> '.' about to send ....'); |
|
699 | 699 | // send |
700 | 700 | $send = true; |
701 | 701 | try { |
702 | 702 | $mailObject->Send(); |
703 | 703 | } |
704 | - catch(Exception $e) { |
|
705 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); |
|
704 | + catch (Exception $e) { |
|
705 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ".$e->getMessage()); |
|
706 | 706 | $send = false; |
707 | 707 | } |
708 | 708 | |
709 | - if (( $smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
709 | + if (($smartdata_task == 'reply' || $smartdata_task == 'forward') && $send == true) |
|
710 | 710 | { |
711 | 711 | $uid = $smartdata->source->itemid; |
712 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
712 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' tASK:'.$smartdata_task." FolderID:".$smartdata->source->folderid.' and ItemID:'.$smartdata->source->itemid); |
|
713 | 713 | $this->splitID($smartdata->source->folderid, $account, $folder); |
714 | 714 | //error_log(__METHOD__.__LINE__.' Folder:'.$folder.' Uid:'.$uid); |
715 | 715 | $this->mail->reopen($folder); |
@@ -717,89 +717,89 @@ discard block |
||
717 | 717 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
718 | 718 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
719 | 719 | { |
720 | - $this->mail->deleteMessages(array($uid),$folder); |
|
720 | + $this->mail->deleteMessages(array($uid), $folder); |
|
721 | 721 | } else { |
722 | - $this->mail->flagMessages("answered", array($uid),$folder); |
|
723 | - if ($smartdata_task== "forward") |
|
722 | + $this->mail->flagMessages("answered", array($uid), $folder); |
|
723 | + if ($smartdata_task == "forward") |
|
724 | 724 | { |
725 | - $this->mail->flagMessages("forwarded", array($uid),$folder); |
|
725 | + $this->mail->flagMessages("forwarded", array($uid), $folder); |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | } |
729 | 729 | |
730 | - $asf = ($send ? true:false); // initalize accordingly |
|
731 | - if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send==true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
730 | + $asf = ($send ? true : false); // initalize accordingly |
|
731 | + if (/*($smartdata->saveinsent==1 || !isset($smartdata->saveinsent)) && */ $send == true && $this->mail->mailPreferences['sendOptions'] != 'send_only') |
|
732 | 732 | { |
733 | 733 | $asf = false; |
734 | 734 | $sentFolder = $this->mail->getSentFolder(); |
735 | 735 | if ($this->_sentID) { |
736 | 736 | $folderArray[] = $this->_sentID; |
737 | 737 | } |
738 | - else if(isset($sentFolder) && $sentFolder != 'none') |
|
738 | + else if (isset($sentFolder) && $sentFolder != 'none') |
|
739 | 739 | { |
740 | 740 | $folderArray[] = $sentFolder; |
741 | 741 | } |
742 | 742 | // No Sent folder set, try defaults |
743 | 743 | else |
744 | 744 | { |
745 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
745 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__.") IMAP-SendMail: No Sent mailbox set"); |
|
746 | 746 | // we dont try guessing |
747 | 747 | $asf = true; |
748 | 748 | } |
749 | 749 | if (count($folderArray) > 0) { |
750 | - foreach((array)$bccMailAddr as $address) { |
|
751 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
752 | - $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
|
750 | + foreach ((array)$bccMailAddr as $address) { |
|
751 | + foreach (Mail::parseAddressList((get_magic_quotes_gpc() ? stripslashes($address) : $address)) as $addressObject) { |
|
752 | + $emailAddress = $addressObject->mailbox.($addressObject->host ? '@'.$addressObject->host : ''); |
|
753 | 753 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
754 | 754 | } |
755 | 755 | } |
756 | - $BCCmail=''; |
|
757 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
758 | - foreach($folderArray as $folderName) { |
|
759 | - if($this->mail->isSentFolder($folderName)) { |
|
756 | + $BCCmail = ''; |
|
757 | + if (count($mailAddr) > 0) $BCCmail = $mailObject->AddrAppend("Bcc", $mailAddr); |
|
758 | + foreach ($folderArray as $folderName) { |
|
759 | + if ($this->mail->isSentFolder($folderName)) { |
|
760 | 760 | $flags = '\\Seen'; |
761 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
761 | + } elseif ($this->mail->isDraftFolder($folderName)) { |
|
762 | 762 | $flags = '\\Draft'; |
763 | 763 | } else { |
764 | 764 | $flags = ''; |
765 | 765 | } |
766 | 766 | $asf = true; |
767 | 767 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
768 | - $this->mail->openConnection(self::$profileID,false); |
|
768 | + $this->mail->openConnection(self::$profileID, false); |
|
769 | 769 | if ($this->mail->folderExists($folderName)) { |
770 | 770 | try |
771 | 771 | { |
772 | - $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
|
772 | + $this->mail->appendMessage($folderName, $mailObject->getRaw(), null, |
|
773 | 773 | $flags); |
774 | 774 | } |
775 | 775 | catch (Api\Exception\WrongUserinput $e) |
776 | 776 | { |
777 | 777 | //$asf = false; |
778 | - 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())); |
|
778 | + 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())); |
|
779 | 779 | } |
780 | 780 | } |
781 | 781 | else |
782 | 782 | { |
783 | 783 | //$asf = false; |
784 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$mailObject->getHeader('Subject'),$folderName)); |
|
784 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $mailObject->getHeader('Subject'), $folderName)); |
|
785 | 785 | } |
786 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ". (($asf)?"success":"failed")); |
|
786 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(".__LINE__."): Outgoing mail saved in configured 'Sent' folder '".$folderName."': ".(($asf) ? "success" : "failed")); |
|
787 | 787 | } |
788 | 788 | //$this->mail->closeConnection(); |
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | - $this->debugLevel=0; |
|
792 | + $this->debugLevel = 0; |
|
793 | 793 | |
794 | 794 | if ($send && $asf) |
795 | 795 | { |
796 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> send successfully'); |
|
796 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' -> send successfully'); |
|
797 | 797 | return true; |
798 | 798 | } |
799 | 799 | else |
800 | 800 | { |
801 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ?" is ClientSideMeetingRequest (we ignore the failure)":"")); |
|
802 | - return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
801 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." returning ".($ClientSideMeetingRequest ? true : 120)." (MailSubmissionFailed)".($ClientSideMeetingRequest ? " is ClientSideMeetingRequest (we ignore the failure)" : "")); |
|
802 | + return ($ClientSideMeetingRequest ? true : 120); //MAIL Submission failed, see MS-ASCMD |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
@@ -817,48 +817,48 @@ discard block |
||
817 | 817 | public function GetMessage($folderid, $id, $contentparameters) |
818 | 818 | { |
819 | 819 | //$this->debugLevel=4; |
820 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
820 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' ContentParams='.array2string($contentparameters)); |
|
821 | 821 | $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
822 | 822 | $mimesupport = $contentparameters->GetMimeSupport(); |
823 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
823 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() truncsize=$truncsize, mimeSupport=".array2string($mimesupport)); |
|
824 | 824 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
825 | 825 | |
826 | 826 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
827 | 827 | if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
828 | 828 | |
829 | 829 | //$this->debugLevel=4; |
830 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
831 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
830 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
831 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
|
832 | 832 | $account = $_folderName = $xid = null; |
833 | - $this->splitID($folderid,$account,$_folderName,$xid); |
|
833 | + $this->splitID($folderid, $account, $_folderName, $xid); |
|
834 | 834 | $this->mail->reopen($_folderName); |
835 | 835 | $stat = $this->StatMessage($folderid, $id); |
836 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($stat)); |
|
836 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($stat)); |
|
837 | 837 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
838 | 838 | if ($stat) |
839 | 839 | { |
840 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." Message $id with stat ".array2string($stat)); |
|
840 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Message $id with stat ".array2string($stat)); |
|
841 | 841 | // initialize the object |
842 | 842 | $output = new SyncMail(); |
843 | - $headers = $this->mail->getMessageHeader($id,'',true,true,$_folderName); |
|
843 | + $headers = $this->mail->getMessageHeader($id, '', true, true, $_folderName); |
|
844 | 844 | if (empty($headers)) |
845 | 845 | { |
846 | 846 | error_log(__METHOD__.__LINE__.' Retrieval of Headers Failed! for .'.$this->account.'/'.$GLOBALS['egw_info']['user']['account_lid'].' ServerID:'.self::$profileID.'FolderID:'.$folderid.'/'.$_folderName.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference).' Stat was:'.array2string($stat)); |
847 | - return $output;//empty object |
|
847 | + return $output; //empty object |
|
848 | 848 | } |
849 | 849 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
850 | 850 | // simple style |
851 | 851 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
852 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
852 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
853 | 853 | |
854 | 854 | if ($bodypreference === false) { |
855 | - $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
|
856 | - $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
855 | + $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true, $_folderName); |
|
856 | + $raw_body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
857 | 857 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
858 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
858 | + if (stripos($raw_body, '<style') !== false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
859 | 859 | // remove all other html |
860 | 860 | $body = strip_tags($raw_body); |
861 | - if(strlen($body) > $truncsize) { |
|
861 | + if (strlen($body) > $truncsize) { |
|
862 | 862 | $body = Utils::Utf8_truncate($body, $truncsize); |
863 | 863 | $output->bodytruncated = 1; |
864 | 864 | } |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | else // style with bodypreferences |
873 | 873 | { |
874 | 874 | //Select body type preference |
875 | - $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
|
875 | + $bpReturnType = 1; //SYNC_BODYPREFERENCE_PLAIN; |
|
876 | 876 | if ($bodypreference !== false) { |
877 | 877 | // bodypreference can occur multiple times |
878 | 878 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -886,66 +886,66 @@ discard block |
||
886 | 886 | } |
887 | 887 | */ |
888 | 888 | } |
889 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
889 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." getBodyPreferenceBestMatch: ".array2string($bpReturnType)); |
|
890 | 890 | // set the protocoll class |
891 | 891 | $output->asbody = new SyncBaseBody(); |
892 | 892 | // fetch the body (try to gather data only once) |
893 | - $css =''; |
|
894 | - $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
|
895 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
896 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
|
897 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
898 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
893 | + $css = ''; |
|
894 | + $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true, $_folderName); |
|
895 | + if ($this->debugLevel > 2) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
896 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, true, false); |
|
897 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' html_only:'.$body); |
|
898 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType'] == 'text/html')) { |
|
899 | 899 | // may be html |
900 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
900 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
901 | 901 | $css = $this->mail->getStyles($bodyStruct); |
902 | - $output->nativebodytype=2; |
|
902 | + $output->nativebodytype = 2; |
|
903 | 903 | } else { |
904 | 904 | // plain text Message |
905 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
906 | - $output->nativebodytype=1; |
|
907 | - $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
908 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
909 | - $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
|
910 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
905 | + if ($this->debugLevel > 0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
906 | + $output->nativebodytype = 1; |
|
907 | + $bodyStruct = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
908 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
909 | + $body = $this->mail->getdisplayableBody($this->mail, $bodyStruct, false, false); |
|
910 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
911 | 911 | } |
912 | 912 | // whatever format decode (using the correct encoding) |
913 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
913 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype == 2 ? ' html ' : ' plain ').$body); |
|
914 | 914 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
915 | 915 | // prepare plaintextbody |
916 | - $plainBody=''; |
|
916 | + $plainBody = ''; |
|
917 | 917 | if ($output->nativebodytype == 2) |
918 | 918 | { |
919 | - $bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
|
920 | - if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1) |
|
919 | + $bodyStructplain = $this->mail->getMessageBody($id, 'never_display', '', null, true, $_folderName); //'only_if_no_text'); |
|
920 | + if (isset($bodyStructplain[0]) && isset($bodyStructplain[0]['error']) && $bodyStructplain[0]['error'] == 1) |
|
921 | 921 | { |
922 | 922 | $plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML |
923 | 923 | } |
924 | 924 | else |
925 | 925 | { |
926 | - $plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false); |
|
926 | + $plainBody = $this->mail->getdisplayableBody($this->mail, $bodyStructplain, false, false); |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | //if ($this->debugLevel>0) debugLog("MIME Body".$body); |
930 | - $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody)?$plainBody:$body)); |
|
930 | + $plainBody = preg_replace("/<style.*?<\/style>/is", "", (strlen($plainBody) ? $plainBody : $body)); |
|
931 | 931 | // remove all other html |
932 | - $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
|
932 | + $plainBody = preg_replace("/<br.*>/is", "\r\n", $plainBody); |
|
933 | 933 | $plainBody = strip_tags($plainBody); |
934 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
934 | + if ($this->debugLevel > 3 && $output->nativebodytype == 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
935 | 935 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
936 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME)//4)//$mimesupport==2 || $mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false) |
|
936 | + if ($bpReturnType == SYNC_BODYPREFERENCE_MIME)//4)//$mimesupport==2 || $mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false) |
|
937 | 937 | { |
938 | 938 | //SYNC_BODYPREFERENCE_MIME |
939 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4 requested"); |
|
940 | - $output->asbody->type = SYNC_BODYPREFERENCE_MIME;//4; |
|
939 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." bodypreference 4 requested"); |
|
940 | + $output->asbody->type = SYNC_BODYPREFERENCE_MIME; //4; |
|
941 | 941 | // use Api\Mailer::convert to convert charset of all text parts to utf-8, which is a z-push or AS requirement! |
942 | 942 | $Body = Api\Mailer::convert($this->mail->getMessageRawBody($id, '', $_folderName)); |
943 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Body); |
|
943 | + if ($this->debugLevel > 2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Body); |
|
944 | 944 | $output->asbody->data = $Body; |
945 | 945 | } |
946 | - else if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
946 | + else if ($bpReturnType == 2) //SYNC_BODYPREFERENCE_HTML |
|
947 | 947 | { |
948 | - if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
|
948 | + if ($this->debugLevel > 0) debugLog("HTML Body with requested pref 2"); |
|
949 | 949 | // Send HTML if requested and native type was html |
950 | 950 | $output->asbody->type = 2; |
951 | 951 | $htmlbody = '<html>'. |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | $css. |
956 | 956 | '</head>'. |
957 | 957 | '<body>'; |
958 | - if ($output->nativebodytype==2) |
|
958 | + if ($output->nativebodytype == 2) |
|
959 | 959 | { |
960 | 960 | // as we fetch html, and body is HTML, we may not need to handle this |
961 | 961 | $htmlbody .= $body; |
@@ -963,14 +963,14 @@ discard block |
||
963 | 963 | else |
964 | 964 | { |
965 | 965 | // html requested but got only plaintext, so fake html |
966 | - $htmlbody .= str_replace("\n","<BR>",str_replace("\r","<BR>", str_replace("\r\n","<BR>",$plainBody))); |
|
966 | + $htmlbody .= str_replace("\n", "<BR>", str_replace("\r", "<BR>", str_replace("\r\n", "<BR>", $plainBody))); |
|
967 | 967 | } |
968 | 968 | $htmlbody .= '</body>'. |
969 | 969 | '</html>'; |
970 | 970 | |
971 | - if(isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
971 | + if (isset($truncsize) && strlen($htmlbody) > $truncsize) |
|
972 | 972 | { |
973 | - $htmlbody = Utils::Utf8_truncate($htmlbody,$truncsize); |
|
973 | + $htmlbody = Utils::Utf8_truncate($htmlbody, $truncsize); |
|
974 | 974 | $output->asbody->truncated = 1; |
975 | 975 | } |
976 | 976 | // output->nativebodytype is used as marker that the original message was of type ... but is now converted to, as type 2 is requested. |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | else |
981 | 981 | { |
982 | 982 | // Send Plaintext as Fallback or if original body is plainttext |
983 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
983 | + if ($this->debugLevel > 0) debugLog("Plaintext Body:".$plainBody); |
|
984 | 984 | /* we use plainBody (set above) instead |
985 | 985 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
986 | 986 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | */ |
991 | 991 | $output->asbody->type = 1; |
992 | 992 | $output->nativebodytype = 1; |
993 | - if(isset($truncsize) && |
|
993 | + if (isset($truncsize) && |
|
994 | 994 | strlen($plainBody) > $truncsize) |
995 | 995 | { |
996 | 996 | $plainBody = Utils::Utf8_truncate($plainBody, $truncsize); |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $output->asbody->estimatedDataSize = strlen($output->asbody->data); |
1009 | 1009 | } |
1010 | 1010 | // end AS12 Stuff |
1011 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Header info:'.$headers['SUBJECT'].' from:'.$headers['DATE']); |
|
1011 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Header info:'.$headers['SUBJECT'].' from:'.$headers['DATE']); |
|
1012 | 1012 | $output->read = $stat["flags"]; |
1013 | 1013 | |
1014 | 1014 | $output->flag = new SyncMailFlags(); |
@@ -1028,20 +1028,19 @@ discard block |
||
1028 | 1028 | $output->lastverexecuted = AS_FORWARD; |
1029 | 1029 | } |
1030 | 1030 | $output->subject = $this->messages[$id]['subject']; |
1031 | - $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : |
|
1032 | - ($this->messages[$id]['priority'] < 3 ? 2 : 1) ; |
|
1033 | - $output->datereceived = $this->mail->_strtotime($headers['DATE'],'ts',true); |
|
1031 | + $output->importance = $this->messages[$id]['priority'] > 3 ? 0 : ($this->messages[$id]['priority'] < 3 ? 2 : 1); |
|
1032 | + $output->datereceived = $this->mail->_strtotime($headers['DATE'], 'ts', true); |
|
1034 | 1033 | //error_log(__METHOD__.__LINE__.' To:'.$headers['TO']); |
1035 | 1034 | $output->to = $headers['TO']; |
1036 | - if ($headers['TO']) $output->displayto = ($headers['TO'] ? $headers['TO']:null); //$stat['FETCHED_HEADER']['to_name'] |
|
1035 | + if ($headers['TO']) $output->displayto = ($headers['TO'] ? $headers['TO'] : null); //$stat['FETCHED_HEADER']['to_name'] |
|
1037 | 1036 | //error_log(__METHOD__.__LINE__.' From:'.$headers['FROM']); |
1038 | 1037 | $output->from = $headers['FROM']; |
1039 | - if (isset($headers['CC']) && $headers['CC']) $output->cc = ($headers['CC'] ? $headers['CC']:null); |
|
1040 | - if (isset($headers['REPLY_TO']) && $headers['REPLY_TO']) $output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null); |
|
1038 | + if (isset($headers['CC']) && $headers['CC']) $output->cc = ($headers['CC'] ? $headers['CC'] : null); |
|
1039 | + if (isset($headers['REPLY_TO']) && $headers['REPLY_TO']) $output->reply_to = ($headers['REPLY_TO'] ? $headers['REPLY_TO'] : null); |
|
1041 | 1040 | |
1042 | 1041 | $output->messageclass = "IPM.Note"; |
1043 | - if (stripos($this->messages[$id]['mimetype'],'multipart')!== false && |
|
1044 | - stripos($this->messages[$id]['mimetype'],'signed')!== false) |
|
1042 | + if (stripos($this->messages[$id]['mimetype'], 'multipart') !== false && |
|
1043 | + stripos($this->messages[$id]['mimetype'], 'signed') !== false) |
|
1045 | 1044 | { |
1046 | 1045 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
1047 | 1046 | } |
@@ -1050,20 +1049,20 @@ discard block |
||
1050 | 1049 | } |
1051 | 1050 | |
1052 | 1051 | // start handle Attachments (include text/calendar multipart alternative) |
1053 | - $attachments = $this->mail->getMessageAttachments($id, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true, true, $_folderName); |
|
1052 | + $attachments = $this->mail->getMessageAttachments($id, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true, true, $_folderName); |
|
1054 | 1053 | // Attachments should not needed for MIME messages, so skip this part if bpReturnType==4 |
1055 | - if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments)>0) |
|
1054 | + if (/*$bpReturnType != SYNC_BODYPREFERENCE_MIME &&*/ is_array($attachments) && count($attachments) > 0) |
|
1056 | 1055 | { |
1057 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
1056 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' gather Attachments for MessageID:'.$id.' found:'.count($attachments)); |
|
1058 | 1057 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
1059 | 1058 | foreach ($attachments as $key => $attach) |
1060 | 1059 | { |
1061 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1060 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1062 | 1061 | |
1063 | 1062 | // pass meeting requests to calendar plugin |
1064 | 1063 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
1065 | 1064 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
1066 | - ($attachment = $this->mail->getAttachment($id, $attach['partID'],0,false,false,$_folderName)) && |
|
1065 | + ($attachment = $this->mail->getAttachment($id, $attach['partID'], 0, false, false, $_folderName)) && |
|
1067 | 1066 | ($output->meetingrequest = calendar_zpush::meetingRequest($attachment['attachment']))) |
1068 | 1067 | { |
1069 | 1068 | //overwrite the globalobjId from calendar object, as: if you delete the mail, that is |
@@ -1073,7 +1072,7 @@ discard block |
||
1073 | 1072 | $output->messageclass = "IPM.Schedule.Meeting.Request"; |
1074 | 1073 | //$output->messageclass = "IPM.Schedule.Meeting"; |
1075 | 1074 | unset($attachment); |
1076 | - continue; // do NOT add attachment as attachment |
|
1075 | + continue; // do NOT add attachment as attachment |
|
1077 | 1076 | } |
1078 | 1077 | if (Request::GetProtocolVersion() >= 12.0) { |
1079 | 1078 | $attachment = new SyncBaseAttachment(); |
@@ -1081,33 +1080,33 @@ discard block |
||
1081 | 1080 | $output->asattachments = array(); |
1082 | 1081 | $attachment->estimatedDataSize = $attach['size']; |
1083 | 1082 | $attachment->method = 1; |
1084 | - $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
|
1083 | + $attachment->filereference = $folderid.":".$id.":".$attach['partID']; |
|
1085 | 1084 | } else { |
1086 | 1085 | $attachment = new SyncAttachment(); |
1087 | 1086 | if (!isset($output->attachments) || !is_array($output->attachments)) |
1088 | 1087 | $output->attachments = array(); |
1089 | 1088 | $attachment->attsize = $attach['size']; |
1090 | 1089 | $attachment->attmethod = 1; |
1091 | - $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
|
1090 | + $attachment->attname = $folderid.":".$id.":".$attach['partID']; //$key; |
|
1092 | 1091 | } |
1093 | 1092 | |
1094 | 1093 | $attachment->displayname = $attach['name']; |
1095 | 1094 | //error_log(__METHOD__.__LINE__.'->'.$folderid . ":" . $id . ":" . $attach['partID']); |
1096 | 1095 | |
1097 | - $attachment->attoid = "";//isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1096 | + $attachment->attoid = ""; //isset($part->headers['content-id']) ? trim($part->headers['content-id']) : ""; |
|
1098 | 1097 | //$attachment->isinline=0; // if not inline, do not use isinline |
1099 | - if (!empty($attach['cid']) && $attach['cid'] <> 'NIL' ) |
|
1098 | + if (!empty($attach['cid']) && $attach['cid'] <> 'NIL') |
|
1100 | 1099 | { |
1101 | 1100 | if ($bpReturnType != 4 && $attach['disposition'] == 'inline') |
1102 | 1101 | { |
1103 | 1102 | $attachment->isinline = true; |
1104 | 1103 | } |
1105 | 1104 | if (Request::GetProtocolVersion() >= 12.0) { |
1106 | - $attachment->method=1; |
|
1107 | - $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
|
1105 | + $attachment->method = 1; |
|
1106 | + $attachment->contentid = str_replace(array("<", ">"), "", $attach['cid']); |
|
1108 | 1107 | } else { |
1109 | - $attachment->attmethod=6; |
|
1110 | - $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
|
1108 | + $attachment->attmethod = 6; |
|
1109 | + $attachment->attoid = str_replace(array("<", ">"), "", $attach['cid']); |
|
1111 | 1110 | } |
1112 | 1111 | // debugLog("'".$part->headers['content-id']."' ".$attachment->contentid); |
1113 | 1112 | $attachment->contenttype = trim($attach['mimeType']); |
@@ -1128,7 +1127,7 @@ discard block |
||
1128 | 1127 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
1129 | 1128 | $output->internetcpid = INTERNET_CPID_UTF8; |
1130 | 1129 | |
1131 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
1130 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($output)); |
|
1132 | 1131 | //$this->debugLevel=0; |
1133 | 1132 | return $output; |
1134 | 1133 | } |
@@ -1151,30 +1150,30 @@ discard block |
||
1151 | 1150 | { |
1152 | 1151 | if (!class_exists('calendar_zpush')) |
1153 | 1152 | { |
1154 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(...) no EGroupware calendar installed!"); |
|
1153 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."(...) no EGroupware calendar installed!"); |
|
1155 | 1154 | return null; |
1156 | 1155 | } |
1157 | 1156 | if (!($stat = $this->StatMessage($folderid, $requestid))) |
1158 | 1157 | { |
1159 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
1158 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning FALSE (can NOT stat message)"); |
|
1160 | 1159 | return false; |
1161 | 1160 | } |
1162 | 1161 | $ret = false; |
1163 | - foreach($this->mail->getMessageAttachments($requestid, $_partID='', $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=true) as $key => $attach) |
|
1162 | + foreach ($this->mail->getMessageAttachments($requestid, $_partID = '', $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = true) as $key => $attach) |
|
1164 | 1163 | { |
1165 | 1164 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
1166 | - ($attachment = $this->mail->getAttachment($requestid, $attach['partID'],0,false))) |
|
1165 | + ($attachment = $this->mail->getAttachment($requestid, $attach['partID'], 0, false))) |
|
1167 | 1166 | { |
1168 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
1167 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) iCal found, calling now backend->MeetingResponse('$attachment[attachment]')"); |
|
1169 | 1168 | |
1170 | 1169 | // calling backend again with iCal attachment, to let calendar add the event |
1171 | 1170 | $ret = $this->backend->MeetingResponse($attachment['attachment'], |
1172 | - $this->backend->createID('calendar',$GLOBALS['egw_info']['user']['account_id']), |
|
1171 | + $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']), |
|
1173 | 1172 | $response); |
1174 | 1173 | break; |
1175 | 1174 | } |
1176 | 1175 | } |
1177 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
1176 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($requestid, '$folderid', $response) returning ".array2string($ret)); |
|
1178 | 1177 | return $ret; |
1179 | 1178 | } |
1180 | 1179 | |
@@ -1188,22 +1187,22 @@ discard block |
||
1188 | 1187 | * @param string $attname - should contain (folder)id |
1189 | 1188 | * @return true, prints the content of the attachment |
1190 | 1189 | */ |
1191 | - function GetAttachmentData($fid,$attname) { |
|
1192 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
1190 | + function GetAttachmentData($fid, $attname) { |
|
1191 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
1193 | 1192 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1194 | 1193 | list($folderid, $id, $part) = explode(":", $attname); |
1195 | 1194 | |
1196 | 1195 | $this->splitID($folderid, $account, $folder); |
1197 | 1196 | |
1198 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1197 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1199 | 1198 | |
1200 | 1199 | $this->mail->reopen($folder); |
1201 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
1200 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
1202 | 1201 | $SIOattachment = new SyncItemOperationsAttachment(); |
1203 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
1202 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
1204 | 1203 | $SIOattachment->data = $attachment['attachment']; |
1205 | 1204 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
1206 | - if (isset($attachment['type']) ) |
|
1205 | + if (isset($attachment['type'])) |
|
1207 | 1206 | $SIOattachment->contenttype = $attachment['type']; |
1208 | 1207 | |
1209 | 1208 | unset($attachment); |
@@ -1221,21 +1220,21 @@ discard block |
||
1221 | 1220 | * @param string $attname - should contain (folder)id |
1222 | 1221 | * @return SyncItemOperationsAttachment-object |
1223 | 1222 | */ |
1224 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
1225 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
1223 | + function ItemOperationsGetAttachmentData($fid, $attname) { |
|
1224 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
|
1226 | 1225 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1227 | 1226 | list($folderid, $id, $part) = explode(":", $attname); |
1228 | 1227 | |
1229 | 1228 | $this->splitID($folderid, $account, $folder); |
1230 | 1229 | |
1231 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1230 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1232 | 1231 | |
1233 | 1232 | $this->mail->reopen($folder); |
1234 | - $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
|
1233 | + $attachment = $this->mail->getAttachment($id, $part, 0, false, true, $folder); |
|
1235 | 1234 | $SIOattachment = new SyncItemOperationsAttachment(); |
1236 | - fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
1235 | + fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
|
1237 | 1236 | $SIOattachment->data = $attachment['attachment']; |
1238 | - if (isset($attachment['type']) ) |
|
1237 | + if (isset($attachment['type'])) |
|
1239 | 1238 | $SIOattachment->contenttype = $attachment['type']; |
1240 | 1239 | |
1241 | 1240 | unset($attachment); |
@@ -1278,17 +1277,17 @@ discard block |
||
1278 | 1277 | */ |
1279 | 1278 | function ChangeMessage($folderid, $id, $message, $contentParameters) |
1280 | 1279 | { |
1281 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
1280 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $folderid, $id,".array2string($message).",".array2string($contentParameters)); |
|
1282 | 1281 | //unset($folderid, $id, $message, $contentParameters); |
1283 | 1282 | $account = $folder = null; |
1284 | 1283 | $this->splitID($folderid, $account, $folder); |
1285 | 1284 | if (isset($message->flag)) { |
1286 | 1285 | if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
1287 | - $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
|
1288 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
1286 | + $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id, $folder); |
|
1287 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as ".(($message->flag->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
1289 | 1288 | } else { |
1290 | - $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
|
1291 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
|
1289 | + $rv = $this->mail->flagMessages("unflagged", $id, $folder); |
|
1290 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." -> set ".array2string($id).' in Folder '.$folder." as "."unflagged"."-->".$rv); |
|
1292 | 1291 | } |
1293 | 1292 | } |
1294 | 1293 | return $this->StatMessage($folderid, $id); |
@@ -1310,23 +1309,23 @@ discard block |
||
1310 | 1309 | */ |
1311 | 1310 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
1312 | 1311 | { |
1313 | - unset($contentParameters); // not used, but required by function signature |
|
1312 | + unset($contentParameters); // not used, but required by function signature |
|
1314 | 1313 | debugLog("IMAP-MoveMessage: (sfid: '$folderid' id: '$id' dfid: '$newfolderid' )"); |
1315 | 1314 | $account = $srcFolder = $destFolder = null; |
1316 | 1315 | $this->splitID($folderid, $account, $srcFolder); |
1317 | 1316 | $this->splitID($newfolderid, $account, $destFolder); |
1318 | 1317 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
1319 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1318 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1320 | 1319 | $this->mail->reopen($destFolder); |
1321 | 1320 | $status = $this->mail->getFolderStatus($destFolder); |
1322 | 1321 | $uidNext = $status['uidnext']; |
1323 | 1322 | $this->mail->reopen($srcFolder); |
1324 | 1323 | |
1325 | 1324 | // move message |
1326 | - $rv = $this->mail->moveMessages($destFolder,(array)$id,true,$srcFolder,true); |
|
1327 | - 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 |
|
1325 | + $rv = $this->mail->moveMessages($destFolder, (array)$id, true, $srcFolder, true); |
|
1326 | + 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 |
|
1328 | 1327 | // return the new id "as string" |
1329 | - return ($rv===true ? $uidNext : $rv[$id]) . ""; |
|
1328 | + return ($rv === true ? $uidNext : $rv[$id]).""; |
|
1330 | 1329 | } |
1331 | 1330 | |
1332 | 1331 | /** |
@@ -1334,87 +1333,87 @@ discard block |
||
1334 | 1333 | * |
1335 | 1334 | * @ToDo loop over available email accounts |
1336 | 1335 | */ |
1337 | - public function GetMessageList($folderid, $cutoffdate=NULL) |
|
1336 | + public function GetMessageList($folderid, $cutoffdate = NULL) |
|
1338 | 1337 | { |
1339 | - static $cutdate=null; |
|
1340 | - if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1341 | - debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
1338 | + static $cutdate = null; |
|
1339 | + if (!empty($cutoffdate) && $cutoffdate > 0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1340 | + debugLog(__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
|
1342 | 1341 | if (empty($cutdate)) |
1343 | 1342 | { |
1344 | - $cutdate = Api\DateTime::to('now','ts')-(3600*24*28*3); |
|
1345 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutdate)); |
|
1343 | + $cutdate = Api\DateTime::to('now', 'ts') - (3600 * 24 * 28 * 3); |
|
1344 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutdate)); |
|
1346 | 1345 | } |
1347 | 1346 | return $this->fetchMessages($folderid, $cutdate); |
1348 | 1347 | } |
1349 | 1348 | |
1350 | - private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
|
1349 | + private function fetchMessages($folderid, $cutoffdate = NULL, $_id = NULL) |
|
1351 | 1350 | { |
1352 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
1351 | + if ($this->debugLevel > 1) $gstarttime = microtime(true); |
|
1353 | 1352 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
1354 | 1353 | $rv_messages = array(); |
1355 | 1354 | // if the message is still available within the class, we use it instead of fetching it again |
1356 | - if (is_array($_id) && count($_id)==1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
1355 | + if (is_array($_id) && count($_id) == 1 && is_array($this->messages) && isset($this->messages[$_id[0]]) && is_array($this->messages[$_id[0]])) |
|
1357 | 1356 | { |
1358 | 1357 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." the message ".$_id[0]." is still available within the class, we use it instead of fetching it again"); |
1359 | 1358 | $rv_messages = array('header'=>array($this->messages[$_id[0]])); |
1360 | 1359 | } |
1361 | 1360 | if (empty($rv_messages)) |
1362 | 1361 | { |
1363 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1362 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1364 | 1363 | $this->_connect($this->account); |
1365 | - if ($this->debugLevel>1) |
|
1364 | + if ($this->debugLevel > 1) |
|
1366 | 1365 | { |
1367 | 1366 | $endtime = microtime(true) - $starttime; |
1368 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " connect took : ".$endtime.' for account:'.$this->account); |
|
1367 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." connect took : ".$endtime.' for account:'.$this->account); |
|
1369 | 1368 | } |
1370 | 1369 | $messagelist = $_filter = array(); |
1371 | 1370 | // if not connected, any further action must fail |
1372 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
1373 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1371 | + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'), 'range'=>"SINCE", 'date'=> date("d-M-Y", $cutoffdate)); |
|
1372 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1374 | 1373 | $account = $_folderName = $id = null; |
1375 | - $this->splitID($folderid,$account,$_folderName,$id); |
|
1376 | - if ($this->debugLevel>1) |
|
1374 | + $this->splitID($folderid, $account, $_folderName, $id); |
|
1375 | + if ($this->debugLevel > 1) |
|
1377 | 1376 | { |
1378 | 1377 | $endtime = microtime(true) - $starttime; |
1379 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1378 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." splitID took : ".$endtime.' for FolderID:'.$folderid); |
|
1380 | 1379 | } |
1381 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1382 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1383 | - $_numberOfMessages = (empty($cutoffdate)?250:99999); |
|
1384 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
|
1385 | - if ($this->debugLevel>1) |
|
1380 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1381 | + if ($this->debugLevel > 1) $starttime = microtime(true); |
|
1382 | + $_numberOfMessages = (empty($cutoffdate) ? 250 : 99999); |
|
1383 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = 1, $_numberOfMessages, $_sort = 0, $_reverse = false, $_filter, $_id); |
|
1384 | + if ($this->debugLevel > 1) |
|
1386 | 1385 | { |
1387 | 1386 | $endtime = microtime(true) - $starttime; |
1388 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1387 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
|
1389 | 1388 | } |
1390 | 1389 | } |
1391 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
1390 | + if ($_id == NULL && $this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." found :".count($rv_messages['header'])); |
|
1392 | 1391 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
1393 | 1392 | $messagelist = array(); |
1394 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
1393 | + if (!isset($rv_messages['header']) || empty($rv_messages['header'])) return $messagelist; |
|
1395 | 1394 | //if ($_returnModHash) $messageFolderHash = array(); |
1396 | 1395 | foreach ((array)$rv_messages['header'] as $k => $vars) |
1397 | 1396 | { |
1398 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1397 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1399 | 1398 | $this->messages[$vars['uid']] = $vars; |
1400 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1399 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1401 | 1400 | if (!empty($vars['deleted'])) continue; // cut of deleted messages |
1402 | 1401 | if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
1403 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1402 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1404 | 1403 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
1405 | 1404 | $mess["id"] = $vars['uid']; |
1406 | 1405 | // 'seen' aka 'read' is the only flag we want to know about |
1407 | 1406 | $mess["flags"] = 0; |
1408 | 1407 | // outlook supports additional flags, set them to 0 |
1409 | - if($vars["seen"]) $mess["flags"] = 1; |
|
1410 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
1408 | + if ($vars["seen"]) $mess["flags"] = 1; |
|
1409 | + if ($this->debugLevel > 3) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($mess)); |
|
1411 | 1410 | $messagelist[$vars['uid']] = $mess; |
1412 | 1411 | unset($mess); |
1413 | 1412 | } |
1414 | - if ($this->debugLevel>1) |
|
1413 | + if ($this->debugLevel > 1) |
|
1415 | 1414 | { |
1416 | 1415 | $endtime = microtime(true) - $gstarttime; |
1417 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1416 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." total time used : ".$endtime.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1418 | 1417 | } |
1419 | 1418 | return $messagelist; |
1420 | 1419 | } |
@@ -1465,32 +1464,32 @@ discard block |
||
1465 | 1464 | public function getSearchResultsMailbox($_searchquery) |
1466 | 1465 | { |
1467 | 1466 | //$this->debugLevel=1; |
1468 | - $searchquery=$_searchquery->GetDataArray(); |
|
1467 | + $searchquery = $_searchquery->GetDataArray(); |
|
1469 | 1468 | if (!is_array($searchquery)) return array(); |
1470 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
1469 | + if ($this->debugLevel > 0) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.array2string($searchquery)); |
|
1471 | 1470 | |
1472 | 1471 | if (isset($searchquery['searchrebuildresults'])) { |
1473 | 1472 | $rebuildresults = $searchquery['searchrebuildresults']; |
1474 | 1473 | } else { |
1475 | 1474 | $rebuildresults = false; |
1476 | 1475 | } |
1477 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1476 | + if ($this->debugLevel > 0) debugLog('RebuildResults ['.$rebuildresults.']'); |
|
1478 | 1477 | |
1479 | 1478 | if (isset($searchquery['deeptraversal'])) { |
1480 | 1479 | $deeptraversal = $searchquery['deeptraversal']; |
1481 | 1480 | } else { |
1482 | 1481 | $deeptraversal = false; |
1483 | 1482 | } |
1484 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1483 | + if ($this->debugLevel > 0) debugLog('DeepTraversal ['.$deeptraversal.']'); |
|
1485 | 1484 | |
1486 | 1485 | if (isset($searchquery['searchrange'])) { |
1487 | - $range = explode("-",$_searchquery->GetSearchRange()); |
|
1488 | - $start =$range[0] + 1; |
|
1486 | + $range = explode("-", $_searchquery->GetSearchRange()); |
|
1487 | + $start = $range[0] + 1; |
|
1489 | 1488 | $limit = $range[1] - $range[0] + 1; |
1490 | 1489 | } else { |
1491 | 1490 | $range = false; |
1492 | 1491 | } |
1493 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
1492 | + if ($this->debugLevel > 0) debugLog('Range ['.print_r($range, true).']'); |
|
1494 | 1493 | |
1495 | 1494 | //foreach($searchquery['query'] as $k => $value) { |
1496 | 1495 | // $query = $value; |
@@ -1513,15 +1512,15 @@ discard block |
||
1513 | 1512 | } |
1514 | 1513 | if (!$folderid) |
1515 | 1514 | { |
1516 | - $_folderName = ($this->mail->sessionData['mailbox']?$this->mail->sessionData['mailbox']:'INBOX'); |
|
1517 | - $folderid = $this->createID($account=0,$_folderName); |
|
1515 | + $_folderName = ($this->mail->sessionData['mailbox'] ? $this->mail->sessionData['mailbox'] : 'INBOX'); |
|
1516 | + $folderid = $this->createID($account = 0, $_folderName); |
|
1518 | 1517 | } |
1519 | - $rv = $this->splitID($folderid,$account,$_folderName,$id); |
|
1520 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
1518 | + $rv = $this->splitID($folderid, $account, $_folderName, $id); |
|
1519 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' ProfileID:'.self::$profileID.' FolderID:'.$folderid.' Foldername:'.$_folderName); |
|
1521 | 1520 | $this->_connect($account); |
1522 | 1521 | // this should not be needed ??? |
1523 | - Mail::$supportsORinQuery[self::$profileID]=true; // trigger quicksearch (if possible) |
|
1524 | - $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID]?'quick':'subject'), |
|
1522 | + Mail::$supportsORinQuery[self::$profileID] = true; // trigger quicksearch (if possible) |
|
1523 | + $_filter = array('type'=> (Mail::$supportsORinQuery[self::$profileID] ? 'quick' : 'subject'), |
|
1525 | 1524 | 'string'=> $searchText, |
1526 | 1525 | 'status'=>'any' |
1527 | 1526 | ); |
@@ -1536,22 +1535,22 @@ discard block |
||
1536 | 1535 | * [searchvalueless] => 2015-07-14T15:11:00.000Z , BEFORE |
1537 | 1536 | */ |
1538 | 1537 | $_filter['range'] = "BETWEEN"; |
1539 | - list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']); |
|
1540 | - list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']); |
|
1541 | - $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts')); |
|
1542 | - $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
|
1538 | + list($sincedate, $crap) = explode('T', $searchquery['searchvaluegreater']); |
|
1539 | + list($beforedate, $crap) = explode('T', $searchquery['searchvalueless']); |
|
1540 | + $_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate, 'ts')); |
|
1541 | + $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate, 'ts')); |
|
1543 | 1542 | } |
1544 | 1543 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1545 | - if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1546 | - $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
|
1544 | + if ($this->debugLevel > 1) debugLog(__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1545 | + $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage = ($range ? $start : 1), $_numberOfMessages = ($limit ? $limit : 9999999), $_sort = 0, $_reverse = false, $_filter, $_id = NULL); |
|
1547 | 1546 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
1548 | - $list=array(); |
|
1547 | + $list = array(); |
|
1549 | 1548 | |
1550 | 1549 | $cnt = count($rv_messages['header']); |
1551 | 1550 | //$list['status'] = 1; |
1552 | 1551 | $list['searchtotal'] = $cnt; |
1553 | 1552 | $list["range"] = $_searchquery->GetSearchRange(); |
1554 | - foreach((array)$rv_messages['header'] as $i => $vars) |
|
1553 | + foreach ((array)$rv_messages['header'] as $i => $vars) |
|
1555 | 1554 | { |
1556 | 1555 | $list[] = array( |
1557 | 1556 | "class" => "Email", |
@@ -1571,20 +1570,20 @@ discard block |
||
1571 | 1570 | * @param string $folder |
1572 | 1571 | * @return string |
1573 | 1572 | */ |
1574 | - private function getParentID($account,$folder) |
|
1573 | + private function getParentID($account, $folder) |
|
1575 | 1574 | { |
1576 | 1575 | $this->_connect($account); |
1577 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1576 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1578 | 1577 | |
1579 | 1578 | $mailFolder = $this->folders[$folder]; |
1580 | 1579 | if (!isset($mailFolder)) return false; |
1581 | - $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
|
1582 | - $parent = explode($delimiter,$folder); |
|
1580 | + $delimiter = (isset($mailFolder->delimiter) ? $mailFolder->delimiter : $this->mail->getHierarchyDelimiter()); |
|
1581 | + $parent = explode($delimiter, $folder); |
|
1583 | 1582 | array_pop($parent); |
1584 | - $parent = implode($delimiter,$parent); |
|
1583 | + $parent = implode($delimiter, $parent); |
|
1585 | 1584 | |
1586 | 1585 | $id = $parent ? $this->createID($account, $parent) : '0'; |
1587 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1586 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1588 | 1587 | return $id; |
1589 | 1588 | } |
1590 | 1589 | |
@@ -1604,48 +1603,48 @@ discard block |
||
1604 | 1603 | $account = $folder = null; |
1605 | 1604 | $this->splitID($id, $account, $folder); |
1606 | 1605 | } |
1607 | - catch(Exception $e) { |
|
1608 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
1609 | - return $folderObj=false; |
|
1606 | + catch (Exception $e) { |
|
1607 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' failed for '.$e->getMessage()); |
|
1608 | + return $folderObj = false; |
|
1610 | 1609 | } |
1611 | 1610 | $this->_connect($account); |
1612 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1611 | + if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true, false); |
|
1613 | 1612 | |
1614 | 1613 | $mailFolder = $this->folders[$folder]; |
1615 | - if (!isset($mailFolder)) return $folderObj=false; |
|
1614 | + if (!isset($mailFolder)) return $folderObj = false; |
|
1616 | 1615 | |
1617 | 1616 | $folderObj = new SyncFolder(); |
1618 | 1617 | $folderObj->serverid = $id; |
1619 | - $folderObj->parentid = $this->getParentID($account,$folder); |
|
1618 | + $folderObj->parentid = $this->getParentID($account, $folder); |
|
1620 | 1619 | $folderObj->displayname = $mailFolder->shortDisplayName; |
1621 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1620 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
1622 | 1621 | // get folder-type |
1623 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
1622 | + foreach ($this->folders as $inbox => $mailFolder) break; |
|
1624 | 1623 | if ($folder == $inbox) |
1625 | 1624 | { |
1626 | 1625 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
1627 | 1626 | } |
1628 | - elseif($this->mail->isDraftFolder($folder, false)) |
|
1627 | + elseif ($this->mail->isDraftFolder($folder, false)) |
|
1629 | 1628 | { |
1630 | 1629 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isDraft'); |
1631 | 1630 | $folderObj->type = SYNC_FOLDER_TYPE_DRAFTS; |
1632 | 1631 | $folderObj->parentid = 0; // required by devices |
1633 | 1632 | } |
1634 | - elseif($this->mail->isTrashFolder($folder, false)) |
|
1633 | + elseif ($this->mail->isTrashFolder($folder, false)) |
|
1635 | 1634 | { |
1636 | 1635 | $folderObj->type = SYNC_FOLDER_TYPE_WASTEBASKET; |
1637 | 1636 | $this->_wasteID = $folder; |
1638 | 1637 | //error_log(__METHOD__.__LINE__.' TrashFolder:'.$this->_wasteID); |
1639 | 1638 | $folderObj->parentid = 0; // required by devices |
1640 | 1639 | } |
1641 | - elseif($this->mail->isSentFolder($folder, false)) |
|
1640 | + elseif ($this->mail->isSentFolder($folder, false)) |
|
1642 | 1641 | { |
1643 | 1642 | $folderObj->type = SYNC_FOLDER_TYPE_SENTMAIL; |
1644 | 1643 | $folderObj->parentid = 0; // required by devices |
1645 | 1644 | $this->_sentID = $folder; |
1646 | 1645 | //error_log(__METHOD__.__LINE__.' SentFolder:'.$this->_sentID); |
1647 | 1646 | } |
1648 | - elseif($this->mail->isOutbox($folder, false)) |
|
1647 | + elseif ($this->mail->isOutbox($folder, false)) |
|
1649 | 1648 | { |
1650 | 1649 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' isOutbox'); |
1651 | 1650 | $folderObj->type = SYNC_FOLDER_TYPE_OUTBOX; |
@@ -1657,7 +1656,7 @@ discard block |
||
1657 | 1656 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
1658 | 1657 | } |
1659 | 1658 | |
1660 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1659 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
1661 | 1660 | return $folderObj; |
1662 | 1661 | } |
1663 | 1662 | |
@@ -1702,22 +1701,22 @@ discard block |
||
1702 | 1701 | $account = $folder = null; |
1703 | 1702 | $this->splitID($folderid, $account, $folder); |
1704 | 1703 | if (is_numeric($account)) $type = 'mail'; |
1705 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid -> $folder ($account) type: ". $type); |
|
1704 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": on $folderid -> $folder ($account) type: ".$type); |
|
1706 | 1705 | if ($type != 'mail') return false; |
1707 | 1706 | |
1708 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1707 | + if (!isset($this->mail)) $this->mail = Mail::getInstance(false, self::$profileID, true, false, true); |
|
1709 | 1708 | |
1710 | 1709 | $changes = array(); |
1711 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid ($folder) stat: ". $syncstate); |
|
1710 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": on $folderid ($folder) stat: ".$syncstate); |
|
1712 | 1711 | $this->mail->reopen($folder); |
1713 | - $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
|
1712 | + $status = $this->mail->getFolderStatus($folder, $ignoreStatusCache = true); |
|
1714 | 1713 | if (!$status) { |
1715 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
|
1714 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.": could not stat folder $folder "); |
|
1716 | 1715 | return false; |
1717 | 1716 | } else { |
1718 | - $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1717 | + $syncstate = "M:".$status['messages']."-R:".$status['recent']."-U:".$status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
|
1719 | 1718 | } |
1720 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' called with ('.$folderid.', ....) returning '.array2string($syncstate)); |
|
1719 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.' called with ('.$folderid.', ....) returning '.array2string($syncstate)); |
|
1721 | 1720 | return $changes; |
1722 | 1721 | } |
1723 | 1722 | |
@@ -1730,8 +1729,8 @@ discard block |
||
1730 | 1729 | function GetWasteBasket() |
1731 | 1730 | { |
1732 | 1731 | $this->_connect($this->account); |
1733 | - $id = $this->createID($account=0, $this->_wasteID); |
|
1734 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
1732 | + $id = $this->createID($account = 0, $this->_wasteID); |
|
1733 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__."() account=$this->account returned $id for folder $this->_wasteID"); |
|
1735 | 1734 | return $id; |
1736 | 1735 | } |
1737 | 1736 | |
@@ -1752,7 +1751,7 @@ discard block |
||
1752 | 1751 | */ |
1753 | 1752 | public function DeleteMessage($folderid, $id, $contentParameters) |
1754 | 1753 | { |
1755 | - unset($contentParameters); // not used, but required by function signature |
|
1754 | + unset($contentParameters); // not used, but required by function signature |
|
1756 | 1755 | debugLog("IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
1757 | 1756 | /* |
1758 | 1757 | $this->imap_reopenFolder($folderid); |
@@ -1763,7 +1762,7 @@ discard block |
||
1763 | 1762 | // we may have to split folderid |
1764 | 1763 | $account = $folder = null; |
1765 | 1764 | $this->splitID($folderid, $account, $folder); |
1766 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
1765 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__.' '.$folderid.'->'.$folder); |
|
1767 | 1766 | $_messageUID = (array)$id; |
1768 | 1767 | |
1769 | 1768 | $this->_connect($this->account); |
@@ -1775,9 +1774,9 @@ discard block |
||
1775 | 1774 | catch (Api\Exception $e) |
1776 | 1775 | { |
1777 | 1776 | $error = $e->getMessage(); |
1778 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
1777 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
|
1779 | 1778 | // if the server thinks the message does not exist report deletion as success |
1780 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
1779 | + if (stripos($error, '[NONEXISTENT]') !== false) return true; |
|
1781 | 1780 | return false; |
1782 | 1781 | } |
1783 | 1782 | |
@@ -1811,15 +1810,15 @@ discard block |
||
1811 | 1810 | */ |
1812 | 1811 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
1813 | 1812 | { |
1814 | - unset($contentParameters); // not used, but required by function signature |
|
1813 | + unset($contentParameters); // not used, but required by function signature |
|
1815 | 1814 | // debugLog("IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
1816 | 1815 | $account = $folder = null; |
1817 | 1816 | $this->splitID($folderid, $account, $folder); |
1818 | 1817 | |
1819 | 1818 | $_messageUID = (array)$id; |
1820 | 1819 | $this->_connect($this->account); |
1821 | - $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID,$folder); |
|
1822 | - debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags) ? "read" : "unread") . "-->". $rv); |
|
1820 | + $rv = $this->mail->flagMessages((($flags) ? "read" : "unread"), $_messageUID, $folder); |
|
1821 | + debugLog("IMAP-SetReadFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags) ? "read" : "unread")."-->".$rv); |
|
1823 | 1822 | |
1824 | 1823 | return $rv; |
1825 | 1824 | } |
@@ -1836,7 +1835,7 @@ discard block |
||
1836 | 1835 | */ |
1837 | 1836 | public function ChangeFolder($id, $oldid, $displayname, $type) |
1838 | 1837 | { |
1839 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!"); |
|
1838 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id', '$oldid', '$displayname', $type) NOT supported!"); |
|
1840 | 1839 | return false; |
1841 | 1840 | } |
1842 | 1841 | |
@@ -1851,7 +1850,7 @@ discard block |
||
1851 | 1850 | */ |
1852 | 1851 | public function DeleteFolder($parentid, $id) |
1853 | 1852 | { |
1854 | - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$parentid', '$id') NOT supported!"); |
|
1853 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$parentid', '$id') NOT supported!"); |
|
1855 | 1854 | return false; |
1856 | 1855 | } |
1857 | 1856 | |
@@ -1871,8 +1870,8 @@ discard block |
||
1871 | 1870 | $this->_connect($this->account); |
1872 | 1871 | $account = $folder = null; |
1873 | 1872 | $this->splitID($folderid, $account, $folder); |
1874 | - $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID,$folder); |
|
1875 | - debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as " . (($flags->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
|
1873 | + $rv = $this->mail->flagMessages((($flags->flagstatus == 2) ? "flagged" : "unflagged"), $_messageUID, $folder); |
|
1874 | + debugLog("IMAP-SetFlaggedFlag -> set ".array2string($_messageUID).' in Folder '.$folder." as ".(($flags->flagstatus == 2) ? "flagged" : "unflagged")."-->".$rv); |
|
1876 | 1875 | |
1877 | 1876 | return $rv; |
1878 | 1877 | } |
@@ -1886,17 +1885,17 @@ discard block |
||
1886 | 1885 | * @return string |
1887 | 1886 | * @throws Api\Exception\WrongParameter |
1888 | 1887 | */ |
1889 | - private function createID($account,$folder,$id=0) |
|
1888 | + private function createID($account, $folder, $id = 0) |
|
1890 | 1889 | { |
1891 | 1890 | if (!is_numeric($folder)) |
1892 | 1891 | { |
1893 | 1892 | // convert string $folder in numeric id |
1894 | - $folder = $this->folder2hash($account,$f=$folder); |
|
1893 | + $folder = $this->folder2hash($account, $f = $folder); |
|
1895 | 1894 | } |
1896 | 1895 | |
1897 | 1896 | $str = $this->backend->createID($account, $folder, $id); |
1898 | 1897 | |
1899 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
1898 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
1900 | 1899 | |
1901 | 1900 | return $str; |
1902 | 1901 | } |
@@ -1910,14 +1909,14 @@ discard block |
||
1910 | 1909 | * @param int &$id=null |
1911 | 1910 | * @throws Api\Exception\WrongParameter |
1912 | 1911 | */ |
1913 | - private function splitID($str,&$account,&$folder,&$id=null) |
|
1912 | + private function splitID($str, &$account, &$folder, &$id = null) |
|
1914 | 1913 | { |
1915 | 1914 | $this->backend->splitID($str, $account, $folder, $id); |
1916 | 1915 | |
1917 | 1916 | // convert numeric folder-id back to folder name |
1918 | - $folder = $this->hash2folder($account,$f=$folder); |
|
1917 | + $folder = $this->hash2folder($account, $f = $folder); |
|
1919 | 1918 | |
1920 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
1919 | + if ($this->debugLevel > 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$str','$account','$folder',$id)"); |
|
1921 | 1920 | } |
1922 | 1921 | |
1923 | 1922 | /** |
@@ -1934,9 +1933,9 @@ discard block |
||
1934 | 1933 | * @param string $folder |
1935 | 1934 | * @return int |
1936 | 1935 | */ |
1937 | - private function folder2hash($account,$folder) |
|
1936 | + private function folder2hash($account, $folder) |
|
1938 | 1937 | { |
1939 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1938 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1940 | 1939 | |
1941 | 1940 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
1942 | 1941 | { |
@@ -1957,9 +1956,9 @@ discard block |
||
1957 | 1956 | * @param int $index |
1958 | 1957 | * @return string NULL if not used so far |
1959 | 1958 | */ |
1960 | - private function hash2folder($account,$index) |
|
1959 | + private function hash2folder($account, $index) |
|
1961 | 1960 | { |
1962 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1961 | + if (!isset($this->folderHashes)) $this->readFolderHashes(); |
|
1963 | 1962 | |
1964 | 1963 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
1965 | 1964 | } |
@@ -1974,9 +1973,9 @@ discard block |
||
1974 | 1973 | if ((file_exists($file = $this->hashFile()) || file_exists($file = $this->hashFile(true))) && |
1975 | 1974 | ($hashes = file_get_contents($file))) |
1976 | 1975 | { |
1977 | - $this->folderHashes = json_decode($hashes,true); |
|
1976 | + $this->folderHashes = json_decode($hashes, true); |
|
1978 | 1977 | // fallback in case hashes have been serialized instead of being json-encoded |
1979 | - if (json_last_error()!=JSON_ERROR_NONE) |
|
1978 | + if (json_last_error() != JSON_ERROR_NONE) |
|
1980 | 1979 | { |
1981 | 1980 | //error_log(__METHOD__.__LINE__." error decoding with json"); |
1982 | 1981 | $this->folderHashes = unserialize($hashes); |
@@ -1996,7 +1995,7 @@ discard block |
||
1996 | 1995 | private function storeFolderHashes() |
1997 | 1996 | { |
1998 | 1997 | // make sure $this->folderHashes is an array otherwise json_encode may fail on decode for string,integer,float or boolean |
1999 | - return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes)?$this->folderHashes:array($this->folderHashes)))); |
|
1998 | + return file_put_contents($this->hashFile(), json_encode((is_array($this->folderHashes) ? $this->folderHashes : array($this->folderHashes)))); |
|
2000 | 1999 | } |
2001 | 2000 | |
2002 | 2001 | /** |
@@ -2008,9 +2007,9 @@ discard block |
||
2008 | 2007 | * @param boolean $old =false true: return old / pre-15 hash-file |
2009 | 2008 | * @throws Api\Exception\AssertionFailed |
2010 | 2009 | */ |
2011 | - private function hashFile($old=false) |
|
2010 | + private function hashFile($old = false) |
|
2012 | 2011 | { |
2013 | - if (!($dev_id=Request::GetDeviceID())) |
|
2012 | + if (!($dev_id = Request::GetDeviceID())) |
|
2014 | 2013 | { |
2015 | 2014 | throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!"); |
2016 | 2015 | } |
@@ -81,29 +81,47 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function __construct(activesync_backend $backend) |
83 | 83 | { |
84 | - if ($GLOBALS['egw_setup']) return; |
|
84 | + if ($GLOBALS['egw_setup']) |
|
85 | + { |
|
86 | + return; |
|
87 | + } |
|
85 | 88 | |
86 | 89 | //$this->debugLevel=2; |
87 | 90 | $this->backend = $backend; |
88 | 91 | if (!isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
89 | 92 | { |
90 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
93 | + if ($this->debugLevel>1) |
|
94 | + { |
|
95 | + error_log(__METHOD__.__LINE__.' Noprefs set: using 0 as default'); |
|
96 | + } |
|
91 | 97 | // globals preferences add appname varname value |
92 | 98 | $GLOBALS['egw']->preferences->add('activesync','mail-ActiveSyncProfileID',0,'user'); |
93 | 99 | // save prefs |
94 | 100 | $GLOBALS['egw']->preferences->save_repository(true); |
95 | 101 | } |
96 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
102 | + if ($this->debugLevel>1) |
|
103 | + { |
|
104 | + error_log(__METHOD__.__LINE__.' ActiveProfileID:'.array2string(self::$profileID)); |
|
105 | + } |
|
97 | 106 | |
98 | 107 | if (is_null(self::$profileID)) |
99 | 108 | { |
100 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
109 | + if ($this->debugLevel>1) |
|
110 | + { |
|
111 | + error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID)); |
|
112 | + } |
|
101 | 113 | self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID'); |
102 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
114 | + if ($this->debugLevel>1) |
|
115 | + { |
|
116 | + error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID)); |
|
117 | + } |
|
103 | 118 | } |
104 | 119 | if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])) |
105 | 120 | { |
106 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
121 | + if ($this->debugLevel>1) |
|
122 | + { |
|
123 | + error_log(__METHOD__.__LINE__.' Pref for ProfileID:'.array2string($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'])); |
|
124 | + } |
|
107 | 125 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] == 'G') |
108 | 126 | { |
109 | 127 | self::$profileID = 'G'; // this should trigger the fetch of the first negative profile (or if no negative profile is available the firstb there is) |
@@ -113,7 +131,10 @@ discard block |
||
113 | 131 | self::$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']; |
114 | 132 | } |
115 | 133 | } |
116 | - if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
134 | + if ($this->debugLevel>1) |
|
135 | + { |
|
136 | + error_log(__METHOD__.__LINE__.' Profile Selected (after reading Prefs):'.array2string(self::$profileID)); |
|
137 | + } |
|
117 | 138 | |
118 | 139 | // verify we are on an existing profile, if not running in setup (settings can not be static according to interface!) |
119 | 140 | if (!isset($GLOBALS['egw_setup'])) |
@@ -126,7 +147,10 @@ discard block |
||
126 | 147 | self::$profileID = Mail\Account::get_default_acc_id(); |
127 | 148 | } |
128 | 149 | } |
129 | - if ($this->debugLevel>0) error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
150 | + if ($this->debugLevel>0) |
|
151 | + { |
|
152 | + error_log(__METHOD__.'::'.__LINE__.' ProfileSelected:'.self::$profileID); |
|
153 | + } |
|
130 | 154 | //$this->debugLevel=0; |
131 | 155 | } |
132 | 156 | |
@@ -201,8 +225,14 @@ discard block |
||
201 | 225 | $this->_connect(0,true); |
202 | 226 | $this->_disconnect(); |
203 | 227 | |
204 | - if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
205 | - if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
228 | + if (!$this->_wasteID) |
|
229 | + { |
|
230 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('trash').'</b>'); |
|
231 | + } |
|
232 | + if (!$this->_sentID) |
|
233 | + { |
|
234 | + $errors[] = lang('No valid %1 folder configured!', '<b>'.lang('send').'</b>'); |
|
235 | + } |
|
206 | 236 | } |
207 | 237 | catch(Exception $e) { |
208 | 238 | $errors[] = lang('Can not open IMAP connection').': '.$e->getMessage(); |
@@ -224,8 +254,14 @@ discard block |
||
224 | 254 | */ |
225 | 255 | private function _connect($account=0) |
226 | 256 | { |
227 | - if (!$account) $account = self::$profileID ? self::$profileID : 0; |
|
228 | - if ($this->mail && $this->account != $account) $this->_disconnect(); |
|
257 | + if (!$account) |
|
258 | + { |
|
259 | + $account = self::$profileID ? self::$profileID : 0; |
|
260 | + } |
|
261 | + if ($this->mail && $this->account != $account) |
|
262 | + { |
|
263 | + $this->_disconnect(); |
|
264 | + } |
|
229 | 265 | |
230 | 266 | $this->_wasteID = false; |
231 | 267 | $this->_sentID = false; |
@@ -236,12 +272,18 @@ discard block |
||
236 | 272 | // todo: tell mail which account to use |
237 | 273 | //error_log(__METHOD__.__LINE__.' create object with ProfileID:'.array2string(self::$profileID)); |
238 | 274 | $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
239 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
275 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
276 | + { |
|
277 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
278 | + } |
|
240 | 279 | } |
241 | 280 | else |
242 | 281 | { |
243 | 282 | //error_log(__METHOD__.__LINE__." connect with profileID: ".self::$profileID); |
244 | - if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) self::$profileID = $this->mail->icServer->ImapServerId; |
|
283 | + if (self::$profileID == 0 && isset($this->mail->icServer->ImapServerId) && !empty($this->mail->icServer->ImapServerId)) |
|
284 | + { |
|
285 | + self::$profileID = $this->mail->icServer->ImapServerId; |
|
286 | + } |
|
245 | 287 | } |
246 | 288 | $this->mail->openConnection(self::$profileID,false); |
247 | 289 | |
@@ -258,8 +300,14 @@ discard block |
||
258 | 300 | */ |
259 | 301 | private function _disconnect() |
260 | 302 | { |
261 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
262 | - if ($this->mail) $this->mail->closeConnection(); |
|
303 | + if ($this->debugLevel>0) |
|
304 | + { |
|
305 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); |
|
306 | + } |
|
307 | + if ($this->mail) |
|
308 | + { |
|
309 | + $this->mail->closeConnection(); |
|
310 | + } |
|
263 | 311 | |
264 | 312 | unset($this->mail); |
265 | 313 | unset($this->account); |
@@ -274,24 +322,43 @@ discard block |
||
274 | 322 | public function GetFolderList() |
275 | 323 | { |
276 | 324 | $folderlist = array(); |
277 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
325 | + if ($this->debugLevel>0) |
|
326 | + { |
|
327 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
|
328 | + } |
|
278 | 329 | /*foreach($available_accounts as $account)*/ $account = 0; |
279 | 330 | { |
280 | 331 | $this->_connect($account); |
281 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
282 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
332 | + if (!isset($this->folders)) |
|
333 | + { |
|
334 | + $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); |
|
335 | + } |
|
336 | + if ($this->debugLevel>1) |
|
337 | + { |
|
338 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); |
|
339 | + } |
|
283 | 340 | |
284 | - foreach ($this->folders as $folder => $folderObj) { |
|
285 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
341 | + foreach ($this->folders as $folder => $folderObj) |
|
342 | + { |
|
343 | + if ($this->debugLevel>1) |
|
344 | + { |
|
345 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); |
|
346 | + } |
|
286 | 347 | $folderlist[] = $f = array( |
287 | 348 | 'id' => $this->createID($account,$folder), |
288 | 349 | 'mod' => $folderObj->shortDisplayName, |
289 | 350 | 'parent' => $this->getParentID($account,$folder), |
290 | 351 | ); |
291 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
352 | + if ($this->debugLevel>1) |
|
353 | + { |
|
354 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); |
|
355 | + } |
|
292 | 356 | } |
293 | 357 | } |
294 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
358 | + if ($this->debugLevel>0) |
|
359 | + { |
|
360 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); |
|
361 | + } |
|
295 | 362 | |
296 | 363 | return $folderlist; |
297 | 364 | } |
@@ -352,11 +419,17 @@ discard block |
||
352 | 419 | $smartdata_task = ($smartdata->replyflag?'reply':($smartdata->forwardflag?'forward':'new')); |
353 | 420 | |
354 | 421 | 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 : "")); |
355 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
422 | + if ($this->debugLevel>0) |
|
423 | + { |
|
424 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): Smartdata = ".array2string($smartdata)); |
|
425 | + } |
|
356 | 426 | //error_log("IMAP-Sendmail: Smartdata = ".array2string($smartdata)); |
357 | 427 | |
358 | 428 | // initialize our Mail |
359 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
429 | + if (!isset($this->mail)) |
|
430 | + { |
|
431 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
432 | + } |
|
360 | 433 | $activeMailProfiles = $this->mail->getAccountIdentities(self::$profileID); |
361 | 434 | // use the standardIdentity |
362 | 435 | $activeMailProfile = Mail::getStandardIdentityForProfile($activeMailProfiles,self::$profileID); |
@@ -376,22 +449,34 @@ discard block |
||
376 | 449 | // prepare addressee list; moved the adding of addresses to the mailobject down |
377 | 450 | // to |
378 | 451 | |
379 | - foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) { |
|
380 | - if (!$addressObject->valid) continue; |
|
452 | + foreach(Mail::parseAddressList($mailObject->getHeader("To")) as $addressObject) |
|
453 | + { |
|
454 | + if (!$addressObject->valid) |
|
455 | + { |
|
456 | + continue; |
|
457 | + } |
|
381 | 458 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail To: ".array2string($addressObject) ); |
382 | 459 | //$mailObject->AddAddress($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
383 | 460 | $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
384 | 461 | } |
385 | 462 | // CC |
386 | - foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) { |
|
387 | - if (!$addressObject->valid) continue; |
|
463 | + foreach(Mail::parseAddressList($mailObject->getHeader("Cc")) as $addressObject) |
|
464 | + { |
|
465 | + if (!$addressObject->valid) |
|
466 | + { |
|
467 | + continue; |
|
468 | + } |
|
388 | 469 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail CC: ".array2string($addressObject) ); |
389 | 470 | //$mailObject->AddCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
390 | 471 | $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
391 | 472 | } |
392 | 473 | // BCC |
393 | - foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) { |
|
394 | - if (!$addressObject->valid) continue; |
|
474 | + foreach(Mail::parseAddressList($mailObject->getHeader("Bcc")) as $addressObject) |
|
475 | + { |
|
476 | + if (!$addressObject->valid) |
|
477 | + { |
|
478 | + continue; |
|
479 | + } |
|
395 | 480 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") Header Sentmail BCC: ".array2string($addressObject) ); |
396 | 481 | //$mailObject->AddBCC($addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''),$addressObject->personal); |
397 | 482 | $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
@@ -404,12 +489,14 @@ discard block |
||
404 | 489 | $ContentType =$mailObject->getHeader('Content-Type'); |
405 | 490 | //error_log(__METHOD__.__LINE__." Header Sentmail original Header (filtered): " . $k. " = ".trim($ContentType)); |
406 | 491 | // if the message is a multipart message, then we should use the sent body |
407 | - if (preg_match("/multipart/i", $ContentType)) { |
|
492 | + if (preg_match("/multipart/i", $ContentType)) |
|
493 | + { |
|
408 | 494 | $use_orgbody = true; |
409 | 495 | } |
410 | 496 | |
411 | 497 | // save the original content-type header for the body part when forwarding |
412 | - if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) { |
|
498 | + if ($smartdata_task == 'forward' && $smartdata->source->itemid && !$use_orgbody) |
|
499 | + { |
|
413 | 500 | //continue; // ignore |
414 | 501 | } |
415 | 502 | // horde/egw_ mailer does everything as utf-8, the following should not be needed |
@@ -418,7 +505,8 @@ discard block |
||
418 | 505 | // if the message is a multipart message, then we should use the sent body |
419 | 506 | if (($smartdata_task == 'new' || $smartdata_task == 'reply' || $smartdata_task == 'forward') && |
420 | 507 | ((isset($smartdata->replacemime) && $smartdata->replacemime == true) || |
421 | - $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) { |
|
508 | + $k == "Content-Type" && preg_match("/multipart/i", $ContentType))) |
|
509 | + { |
|
422 | 510 | $use_orgbody = true; |
423 | 511 | } |
424 | 512 | $Body = $AltBody = ""; |
@@ -451,12 +539,19 @@ discard block |
||
451 | 539 | $AltBody = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","[$2]", |
452 | 540 | ($html_body = $mailObject->findBody('html')) ? $html_body->getContents() : null); |
453 | 541 | } |
454 | - if ($this->debugLevel>1 && $Body) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
455 | - if ($this->debugLevel>1 && $AltBody) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
542 | + if ($this->debugLevel>1 && $Body) |
|
543 | + { |
|
544 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as with MessageContentType:". $ContentType.'=>'.$Body); |
|
545 | + } |
|
546 | + if ($this->debugLevel>1 && $AltBody) |
|
547 | + { |
|
548 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched AltBody as with MessageContentType:". $ContentType.'=>'.$AltBody); |
|
549 | + } |
|
456 | 550 | //error_log(__METHOD__.__LINE__.array2string($mailObject)); |
457 | 551 | // if this is a multipart message with a boundary, we must use the original body |
458 | 552 | //if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' mailObject after Inital Parse:'.array2string($mailObject)); |
459 | - if ($use_orgbody) { |
|
553 | + if ($use_orgbody) |
|
554 | + { |
|
460 | 555 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); |
461 | 556 | // if it is a ClientSideMeetingRequest, we report it as send at all times |
462 | 557 | if (($cal_body = $mailObject->findBody('calendar')) && |
@@ -466,15 +561,20 @@ discard block |
||
466 | 561 | { |
467 | 562 | $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); |
468 | 563 | } |
469 | - if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
564 | + if ($this->debugLevel) |
|
565 | + { |
|
566 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); |
|
567 | + } |
|
470 | 568 | $ClientSideMeetingRequest = true; |
471 | 569 | } |
472 | 570 | } |
473 | 571 | // now handle the addressee list |
474 | 572 | $toCount = 0; |
475 | 573 | //error_log(__METHOD__.__LINE__.array2string($toMailAddr)); |
476 | - foreach((array)$toMailAddr as $address) { |
|
477 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
574 | + foreach((array)$toMailAddr as $address) |
|
575 | + { |
|
576 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
577 | + { |
|
478 | 578 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
479 | 579 | if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && |
480 | 580 | calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', |
@@ -488,19 +588,29 @@ discard block |
||
488 | 588 | } |
489 | 589 | } |
490 | 590 | $ccCount = 0; |
491 | - foreach((array)$ccMailAddr as $address) { |
|
492 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
591 | + foreach((array)$ccMailAddr as $address) |
|
592 | + { |
|
593 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
594 | + { |
|
493 | 595 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
494 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
596 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
597 | + { |
|
598 | + continue; |
|
599 | + } |
|
495 | 600 | $mailObject->AddCC($emailAddress, $addressObject->personal); |
496 | 601 | $ccCount++; |
497 | 602 | } |
498 | 603 | } |
499 | 604 | $bccCount = 0; |
500 | - foreach((array)$bccMailAddr as $address) { |
|
501 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
605 | + foreach((array)$bccMailAddr as $address) |
|
606 | + { |
|
607 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
608 | + { |
|
502 | 609 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
503 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; |
|
610 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) |
|
611 | + { |
|
612 | + continue; |
|
613 | + } |
|
504 | 614 | $mailObject->AddBCC($emailAddress, $addressObject->personal); |
505 | 615 | $bccCount++; |
506 | 616 | } |
@@ -510,7 +620,10 @@ discard block |
||
510 | 620 | { |
511 | 621 | return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to |
512 | 622 | } |
513 | - if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; |
|
623 | + if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) |
|
624 | + { |
|
625 | + return true; |
|
626 | + } |
|
514 | 627 | // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail |
515 | 628 | /* |
516 | 629 | if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' retrieved Body:'.$body); |
@@ -540,7 +653,10 @@ discard block |
||
540 | 653 | $beforeHtml = ($disableRuler ?' <br>':' <br><hr style="border:dotted 1px silver; width:90%; border:dotted 1px silver;">'); |
541 | 654 | $beforePlain = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
542 | 655 | $sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
543 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
656 | + if ($this->debugLevel>0) |
|
657 | + { |
|
658 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText); |
|
659 | + } |
|
544 | 660 | $sigTextHtml = $beforeHtml.$sigText; |
545 | 661 | $sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText); |
546 | 662 | $isreply = $isforward = false; |
@@ -558,10 +674,17 @@ discard block |
||
558 | 674 | $this->mail->reopen($folder); |
559 | 675 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
560 | 676 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
561 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
562 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
677 | + if ($this->debugLevel>3) |
|
678 | + { |
|
679 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
680 | + } |
|
681 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
682 | + { |
|
563 | 683 | // may be html |
564 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
684 | + if ($this->debugLevel>0) |
|
685 | + { |
|
686 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
687 | + } |
|
565 | 688 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
566 | 689 | $isreply = true; |
567 | 690 | } |
@@ -570,8 +693,12 @@ discard block |
||
570 | 693 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
571 | 694 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
572 | 695 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
573 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
574 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
696 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
697 | + { |
|
698 | + if ($this->debugLevel>0) |
|
699 | + { |
|
700 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
701 | + } |
|
575 | 702 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
576 | 703 | $isreply = true; |
577 | 704 | } |
@@ -579,7 +706,10 @@ discard block |
||
579 | 706 | { |
580 | 707 | $isreply = true; |
581 | 708 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
582 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
709 | + if ($this->debugLevel>0) |
|
710 | + { |
|
711 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
712 | + } |
|
583 | 713 | } |
584 | 714 | } |
585 | 715 | |
@@ -593,11 +723,17 @@ discard block |
||
593 | 723 | (isset($smartdata->replacemime) && $smartdata->replacemime == false))) |
594 | 724 | { |
595 | 725 | //force the default for the forwarding -> asmail |
596 | - if (is_array($preferencesArray)) { |
|
726 | + if (is_array($preferencesArray)) |
|
727 | + { |
|
597 | 728 | if (!array_key_exists('message_forwarding',$preferencesArray) |
598 | 729 | || !isset($preferencesArray['message_forwarding']) |
599 | - || empty($preferencesArray['message_forwarding'])) $preferencesArray['message_forwarding'] = 'asmail'; |
|
600 | - } else { |
|
730 | + || empty($preferencesArray['message_forwarding'])) |
|
731 | + { |
|
732 | + $preferencesArray['message_forwarding'] = 'asmail'; |
|
733 | + } |
|
734 | + } |
|
735 | + else |
|
736 | + { |
|
601 | 737 | $preferencesArray['message_forwarding'] = 'asmail'; |
602 | 738 | } |
603 | 739 | // construct the uid of the message out of the itemid - seems to be the uid, no construction needed |
@@ -629,27 +765,44 @@ discard block |
||
629 | 765 | $this->mail->reopen($folder); |
630 | 766 | $bodyStruct = $this->mail->getMessageBody($uid, 'html_only'); |
631 | 767 | $bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
632 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
633 | - if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
768 | + if ($this->debugLevel>0) |
|
769 | + { |
|
770 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml); |
|
771 | + } |
|
772 | + if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
773 | + { |
|
634 | 774 | // may be html |
635 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
775 | + if ($this->debugLevel>0) |
|
776 | + { |
|
777 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:html (fetched with html_only):'.$bodyBUFFHtml); |
|
778 | + } |
|
636 | 779 | $AltBody = $AltBody."</br>".$bodyBUFFHtml.$sigTextHtml; |
637 | 780 | $isforward = true; |
638 | 781 | } |
639 | 782 | // plain text Message part |
640 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
783 | + if ($this->debugLevel>0) |
|
784 | + { |
|
785 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:'); |
|
786 | + } |
|
641 | 787 | // if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain |
642 | 788 | $bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display'); |
643 | 789 | $bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
644 | - if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) { |
|
645 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
790 | + if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) |
|
791 | + { |
|
792 | + if ($this->debugLevel>0) |
|
793 | + { |
|
794 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF); |
|
795 | + } |
|
646 | 796 | $Body = $Body."\r\n".$bodyBUFF.$sigTextPlain; |
647 | 797 | $isforward = true; |
648 | 798 | } |
649 | 799 | if (!empty($bodyBUFF) && empty($bodyBUFFHtml) && !empty($AltBody)) |
650 | 800 | { |
651 | 801 | $AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml; |
652 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
802 | + if ($this->debugLevel>0) |
|
803 | + { |
|
804 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody); |
|
805 | + } |
|
653 | 806 | $isforward = true; |
654 | 807 | } |
655 | 808 | // get all the attachments and add them too. |
@@ -662,7 +815,10 @@ discard block |
||
662 | 815 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' gather Attachments for BodyCreation of/for MessageID:'.$uid.' found:'.count($attachments)); |
663 | 816 | foreach((array)$attachments as $key => $attachment) |
664 | 817 | { |
665 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
818 | + if ($this->debugLevel>0) |
|
819 | + { |
|
820 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment)); |
|
821 | + } |
|
666 | 822 | $attachmentNames .= $attachment['name']."\n"; |
667 | 823 | $attachmentData = $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder); |
668 | 824 | /*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']); |
@@ -680,18 +836,27 @@ discard block |
||
680 | 836 | // now set the body |
681 | 837 | if ($AltBody && ($html_body = $mailObject->findBody('html'))) |
682 | 838 | { |
683 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
839 | + if ($this->debugLevel>1) |
|
840 | + { |
|
841 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$AltBody); |
|
842 | + } |
|
684 | 843 | $html_body->setContents($AltBody,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
685 | 844 | } |
686 | 845 | if ($Body && ($text_body = $mailObject->findBody('plain'))) |
687 | 846 | { |
688 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
847 | + if ($this->debugLevel>1) |
|
848 | + { |
|
849 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' -> '.$Body); |
|
850 | + } |
|
689 | 851 | $text_body->setContents($Body,array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
690 | 852 | } |
691 | 853 | //advanced debugging |
692 | 854 | // Horde SMTP Class uses utf-8 by default. |
693 | 855 | //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1)); |
694 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
856 | + if ($this->debugLevel>2) |
|
857 | + { |
|
858 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__."): MailObject:".array2string($mailObject)); |
|
859 | + } |
|
695 | 860 | |
696 | 861 | // set a higher timeout for big messages |
697 | 862 | @set_time_limit(120); |
@@ -718,7 +883,9 @@ discard block |
||
718 | 883 | if ($this->mail->isDraftFolder($folder) && !$this->mail->isTemplateFolder($folder)) |
719 | 884 | { |
720 | 885 | $this->mail->deleteMessages(array($uid),$folder); |
721 | - } else { |
|
886 | + } |
|
887 | + else |
|
888 | + { |
|
722 | 889 | $this->mail->flagMessages("answered", array($uid),$folder); |
723 | 890 | if ($smartdata_task== "forward") |
724 | 891 | { |
@@ -732,7 +899,8 @@ discard block |
||
732 | 899 | { |
733 | 900 | $asf = false; |
734 | 901 | $sentFolder = $this->mail->getSentFolder(); |
735 | - if ($this->_sentID) { |
|
902 | + if ($this->_sentID) |
|
903 | + { |
|
736 | 904 | $folderArray[] = $this->_sentID; |
737 | 905 | } |
738 | 906 | else if(isset($sentFolder) && $sentFolder != 'none') |
@@ -746,27 +914,40 @@ discard block |
||
746 | 914 | // we dont try guessing |
747 | 915 | $asf = true; |
748 | 916 | } |
749 | - if (count($folderArray) > 0) { |
|
750 | - foreach((array)$bccMailAddr as $address) { |
|
751 | - foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { |
|
917 | + if (count($folderArray) > 0) |
|
918 | + { |
|
919 | + foreach((array)$bccMailAddr as $address) |
|
920 | + { |
|
921 | + foreach(Mail::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) |
|
922 | + { |
|
752 | 923 | $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); |
753 | 924 | $mailAddr[] = array($emailAddress, $addressObject->personal); |
754 | 925 | } |
755 | 926 | } |
756 | 927 | $BCCmail=''; |
757 | - if (count($mailAddr)>0) $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
758 | - foreach($folderArray as $folderName) { |
|
759 | - if($this->mail->isSentFolder($folderName)) { |
|
928 | + if (count($mailAddr)>0) |
|
929 | + { |
|
930 | + $BCCmail = $mailObject->AddrAppend("Bcc",$mailAddr); |
|
931 | + } |
|
932 | + foreach($folderArray as $folderName) |
|
933 | + { |
|
934 | + if($this->mail->isSentFolder($folderName)) |
|
935 | + { |
|
760 | 936 | $flags = '\\Seen'; |
761 | - } elseif($this->mail->isDraftFolder($folderName)) { |
|
937 | + } |
|
938 | + elseif($this->mail->isDraftFolder($folderName)) |
|
939 | + { |
|
762 | 940 | $flags = '\\Draft'; |
763 | - } else { |
|
941 | + } |
|
942 | + else |
|
943 | + { |
|
764 | 944 | $flags = ''; |
765 | 945 | } |
766 | 946 | $asf = true; |
767 | 947 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.array2string($this->mail->icServer)); |
768 | 948 | $this->mail->openConnection(self::$profileID,false); |
769 | - if ($this->mail->folderExists($folderName)) { |
|
949 | + if ($this->mail->folderExists($folderName)) |
|
950 | + { |
|
770 | 951 | try |
771 | 952 | { |
772 | 953 | $this->mail->appendMessage($folderName,$mailObject->getRaw(), null, |
@@ -824,16 +1005,25 @@ discard block |
||
824 | 1005 | $bodypreference = $contentparameters->GetBodyPreference(); /* fmbiete's contribution r1528, ZP-320 */ |
825 | 1006 | |
826 | 1007 | // fix for z-push bug returning additional bodypreference type 4, even if only 1 is requested and mimessupport = 0 |
827 | - if (!$mimesupport && ($key = array_search('4', $bodypreference))) unset($bodypreference[$key]); |
|
1008 | + if (!$mimesupport && ($key = array_search('4', $bodypreference))) |
|
1009 | + { |
|
1010 | + unset($bodypreference[$key]); |
|
1011 | + } |
|
828 | 1012 | |
829 | 1013 | //$this->debugLevel=4; |
830 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1014 | + if (!isset($this->mail)) |
|
1015 | + { |
|
1016 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1017 | + } |
|
831 | 1018 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' FolderID:'.$folderid.' ID:'.$id.' TruncSize:'.$truncsize.' Bodypreference: '.array2string($bodypreference)); |
832 | 1019 | $account = $_folderName = $xid = null; |
833 | 1020 | $this->splitID($folderid,$account,$_folderName,$xid); |
834 | 1021 | $this->mail->reopen($_folderName); |
835 | 1022 | $stat = $this->StatMessage($folderid, $id); |
836 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($stat)); |
|
1023 | + if ($this->debugLevel>3) |
|
1024 | + { |
|
1025 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($stat)); |
|
1026 | + } |
|
837 | 1027 | // StatMessage should reopen the folder in question, so we dont need folderids in the following statements. |
838 | 1028 | if ($stat) |
839 | 1029 | { |
@@ -849,16 +1039,25 @@ discard block |
||
849 | 1039 | //$rawHeaders = $this->mail->getMessageRawHeader($id); |
850 | 1040 | // simple style |
851 | 1041 | // start AS12 Stuff (bodypreference === false) case = old behaviour |
852 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
1042 | + if ($this->debugLevel>0) |
|
1043 | + { |
|
1044 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers)); |
|
1045 | + } |
|
853 | 1046 | |
854 | - if ($bodypreference === false) { |
|
1047 | + if ($bodypreference === false) |
|
1048 | + { |
|
855 | 1049 | $bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName); |
856 | 1050 | $raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
857 | 1051 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
858 | - if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part |
|
1052 | + if (stripos($raw_body,'<style')!==false) |
|
1053 | + { |
|
1054 | + $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); |
|
1055 | + } |
|
1056 | + // in case there is only a html part |
|
859 | 1057 | // remove all other html |
860 | 1058 | $body = strip_tags($raw_body); |
861 | - if(strlen($body) > $truncsize) { |
|
1059 | + if(strlen($body) > $truncsize) |
|
1060 | + { |
|
862 | 1061 | $body = Utils::Utf8_truncate($body, $truncsize); |
863 | 1062 | $output->bodytruncated = 1; |
864 | 1063 | } |
@@ -873,7 +1072,8 @@ discard block |
||
873 | 1072 | { |
874 | 1073 | //Select body type preference |
875 | 1074 | $bpReturnType = 1;//SYNC_BODYPREFERENCE_PLAIN; |
876 | - if ($bodypreference !== false) { |
|
1075 | + if ($bodypreference !== false) |
|
1076 | + { |
|
877 | 1077 | // bodypreference can occur multiple times |
878 | 1078 | // usually we would use Utils::GetBodyPreferenceBestMatch($bodypreference); |
879 | 1079 | $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference); |
@@ -892,25 +1092,49 @@ discard block |
||
892 | 1092 | // fetch the body (try to gather data only once) |
893 | 1093 | $css =''; |
894 | 1094 | $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName); |
895 | - if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
1095 | + if ($this->debugLevel>2) |
|
1096 | + { |
|
1097 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct)); |
|
1098 | + } |
|
896 | 1099 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false); |
897 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
898 | - if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) { |
|
1100 | + if ($this->debugLevel>3) |
|
1101 | + { |
|
1102 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body); |
|
1103 | + } |
|
1104 | + if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) |
|
1105 | + { |
|
899 | 1106 | // may be html |
900 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
1107 | + if ($this->debugLevel>0) |
|
1108 | + { |
|
1109 | + debugLog("MIME Body".' Type:html (fetched with html_only)'); |
|
1110 | + } |
|
901 | 1111 | $css = $this->mail->getStyles($bodyStruct); |
902 | 1112 | $output->nativebodytype=2; |
903 | - } else { |
|
1113 | + } |
|
1114 | + else |
|
1115 | + { |
|
904 | 1116 | // plain text Message |
905 | - if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
1117 | + if ($this->debugLevel>0) |
|
1118 | + { |
|
1119 | + debugLog("MIME Body".' Type:plain, fetch text (HTML, if no text available)'); |
|
1120 | + } |
|
906 | 1121 | $output->nativebodytype=1; |
907 | 1122 | $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text'); |
908 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
1123 | + if ($this->debugLevel>3) |
|
1124 | + { |
|
1125 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct)); |
|
1126 | + } |
|
909 | 1127 | $body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false); |
910 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
1128 | + if ($this->debugLevel>3) |
|
1129 | + { |
|
1130 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body); |
|
1131 | + } |
|
911 | 1132 | } |
912 | 1133 | // whatever format decode (using the correct encoding) |
913 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
1134 | + if ($this->debugLevel>3) |
|
1135 | + { |
|
1136 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__."MIME Body".' Type:'.($output->nativebodytype==2?' html ':' plain ').$body); |
|
1137 | + } |
|
914 | 1138 | //$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body)); |
915 | 1139 | // prepare plaintextbody |
916 | 1140 | $plainBody=''; |
@@ -931,21 +1155,33 @@ discard block |
||
931 | 1155 | // remove all other html |
932 | 1156 | $plainBody = preg_replace("/<br.*>/is","\r\n",$plainBody); |
933 | 1157 | $plainBody = strip_tags($plainBody); |
934 | - if ($this->debugLevel>3 && $output->nativebodytype==1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
1158 | + if ($this->debugLevel>3 && $output->nativebodytype==1) |
|
1159 | + { |
|
1160 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Plain Text:'.$plainBody); |
|
1161 | + } |
|
935 | 1162 | //$body = str_replace("\n","\r\n", str_replace("\r","",$body)); // do we need that? |
936 | - if ($bpReturnType==SYNC_BODYPREFERENCE_MIME)//4)//$mimesupport==2 || $mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false) |
|
1163 | + if ($bpReturnType==SYNC_BODYPREFERENCE_MIME) |
|
1164 | + { |
|
1165 | + //4)//$mimesupport==2 || $mimesupport ==1 && stristr($headers['CONTENT-TYPE'],'signed') !== false) |
|
937 | 1166 | { |
938 | 1167 | //SYNC_BODYPREFERENCE_MIME |
939 | 1168 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4 requested"); |
1169 | + } |
|
940 | 1170 | $output->asbody->type = SYNC_BODYPREFERENCE_MIME;//4; |
941 | 1171 | // use Api\Mailer::convert to convert charset of all text parts to utf-8, which is a z-push or AS requirement! |
942 | 1172 | $Body = Api\Mailer::convert($this->mail->getMessageRawBody($id, '', $_folderName)); |
943 | - if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Body); |
|
1173 | + if ($this->debugLevel>2) |
|
1174 | + { |
|
1175 | + debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Body); |
|
1176 | + } |
|
944 | 1177 | $output->asbody->data = $Body; |
945 | 1178 | } |
946 | - else if ($bpReturnType==2) //SYNC_BODYPREFERENCE_HTML |
|
1179 | + else if ($bpReturnType==2) |
|
1180 | + { |
|
1181 | + //SYNC_BODYPREFERENCE_HTML |
|
947 | 1182 | { |
948 | 1183 | if ($this->debugLevel>0) debugLog("HTML Body with requested pref 2"); |
1184 | + } |
|
949 | 1185 | // Send HTML if requested and native type was html |
950 | 1186 | $output->asbody->type = 2; |
951 | 1187 | $htmlbody = '<html>'. |
@@ -980,7 +1216,10 @@ discard block |
||
980 | 1216 | else |
981 | 1217 | { |
982 | 1218 | // Send Plaintext as Fallback or if original body is plainttext |
983 | - if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody); |
|
1219 | + if ($this->debugLevel>0) |
|
1220 | + { |
|
1221 | + debugLog("Plaintext Body:".$plainBody); |
|
1222 | + } |
|
984 | 1223 | /* we use plainBody (set above) instead |
985 | 1224 | $bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display'); |
986 | 1225 | $plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct); |
@@ -1016,7 +1255,9 @@ discard block |
||
1016 | 1255 | { |
1017 | 1256 | $output->flag->flagstatus = 2; |
1018 | 1257 | //$output->flag->flagtype = "Flag for Follow up"; |
1019 | - } else { |
|
1258 | + } |
|
1259 | + else |
|
1260 | + { |
|
1020 | 1261 | $output->flag->flagstatus = 0; |
1021 | 1262 | } |
1022 | 1263 | if ($this->messages[$id]['answered']) |
@@ -1033,11 +1274,21 @@ discard block |
||
1033 | 1274 | $output->datereceived = $this->mail->_strtotime($headers['DATE'],'ts',true); |
1034 | 1275 | //error_log(__METHOD__.__LINE__.' To:'.$headers['TO']); |
1035 | 1276 | $output->to = $headers['TO']; |
1036 | - if ($headers['TO']) $output->displayto = ($headers['TO'] ? $headers['TO']:null); //$stat['FETCHED_HEADER']['to_name'] |
|
1277 | + if ($headers['TO']) |
|
1278 | + { |
|
1279 | + $output->displayto = ($headers['TO'] ? $headers['TO']:null); |
|
1280 | + } |
|
1281 | + //$stat['FETCHED_HEADER']['to_name'] |
|
1037 | 1282 | //error_log(__METHOD__.__LINE__.' From:'.$headers['FROM']); |
1038 | 1283 | $output->from = $headers['FROM']; |
1039 | - if (isset($headers['CC']) && $headers['CC']) $output->cc = ($headers['CC'] ? $headers['CC']:null); |
|
1040 | - if (isset($headers['REPLY_TO']) && $headers['REPLY_TO']) $output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null); |
|
1284 | + if (isset($headers['CC']) && $headers['CC']) |
|
1285 | + { |
|
1286 | + $output->cc = ($headers['CC'] ? $headers['CC']:null); |
|
1287 | + } |
|
1288 | + if (isset($headers['REPLY_TO']) && $headers['REPLY_TO']) |
|
1289 | + { |
|
1290 | + $output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null); |
|
1291 | + } |
|
1041 | 1292 | |
1042 | 1293 | $output->messageclass = "IPM.Note"; |
1043 | 1294 | if (stripos($this->messages[$id]['mimetype'],'multipart')!== false && |
@@ -1045,7 +1296,8 @@ discard block |
||
1045 | 1296 | { |
1046 | 1297 | $output->messageclass = "IPM.Note.SMIME.MultipartSigned"; |
1047 | 1298 | } |
1048 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
1299 | + if (Request::GetProtocolVersion() >= 12.0) |
|
1300 | + { |
|
1049 | 1301 | $output->contentclass = "urn:content-classes:message"; |
1050 | 1302 | } |
1051 | 1303 | |
@@ -1058,7 +1310,10 @@ discard block |
||
1058 | 1310 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
1059 | 1311 | foreach ($attachments as $key => $attach) |
1060 | 1312 | { |
1061 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1313 | + if ($this->debugLevel>0) |
|
1314 | + { |
|
1315 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attach)); |
|
1316 | + } |
|
1062 | 1317 | |
1063 | 1318 | // pass meeting requests to calendar plugin |
1064 | 1319 | if (strtolower($attach['mimeType']) == 'text/calendar' && strtolower($attach['method']) == 'request' && |
@@ -1075,17 +1330,24 @@ discard block |
||
1075 | 1330 | unset($attachment); |
1076 | 1331 | continue; // do NOT add attachment as attachment |
1077 | 1332 | } |
1078 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
1333 | + if (Request::GetProtocolVersion() >= 12.0) |
|
1334 | + { |
|
1079 | 1335 | $attachment = new SyncBaseAttachment(); |
1080 | 1336 | if (!isset($output->asattachments) || !is_array($output->asattachments)) |
1081 | - $output->asattachments = array(); |
|
1337 | + { |
|
1338 | + $output->asattachments = array(); |
|
1339 | + } |
|
1082 | 1340 | $attachment->estimatedDataSize = $attach['size']; |
1083 | 1341 | $attachment->method = 1; |
1084 | 1342 | $attachment->filereference = $folderid . ":" . $id . ":" . $attach['partID']; |
1085 | - } else { |
|
1343 | + } |
|
1344 | + else |
|
1345 | + { |
|
1086 | 1346 | $attachment = new SyncAttachment(); |
1087 | 1347 | if (!isset($output->attachments) || !is_array($output->attachments)) |
1088 | - $output->attachments = array(); |
|
1348 | + { |
|
1349 | + $output->attachments = array(); |
|
1350 | + } |
|
1089 | 1351 | $attachment->attsize = $attach['size']; |
1090 | 1352 | $attachment->attmethod = 1; |
1091 | 1353 | $attachment->attname = $folderid . ":" . $id . ":" . $attach['partID'];//$key; |
@@ -1102,10 +1364,13 @@ discard block |
||
1102 | 1364 | { |
1103 | 1365 | $attachment->isinline = true; |
1104 | 1366 | } |
1105 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
1367 | + if (Request::GetProtocolVersion() >= 12.0) |
|
1368 | + { |
|
1106 | 1369 | $attachment->method=1; |
1107 | 1370 | $attachment->contentid= str_replace(array("<",">"), "",$attach['cid']); |
1108 | - } else { |
|
1371 | + } |
|
1372 | + else |
|
1373 | + { |
|
1109 | 1374 | $attachment->attmethod=6; |
1110 | 1375 | $attachment->attoid = str_replace(array("<",">"), "",$attach['cid']); |
1111 | 1376 | } |
@@ -1113,9 +1378,12 @@ discard block |
||
1113 | 1378 | $attachment->contenttype = trim($attach['mimeType']); |
1114 | 1379 | // debugLog("'".$part->headers['content-type']."' ".$attachment->contentid); |
1115 | 1380 | } |
1116 | - if (Request::GetProtocolVersion() >= 12.0) { |
|
1381 | + if (Request::GetProtocolVersion() >= 12.0) |
|
1382 | + { |
|
1117 | 1383 | array_push($output->asattachments, $attachment); |
1118 | - } else { |
|
1384 | + } |
|
1385 | + else |
|
1386 | + { |
|
1119 | 1387 | array_push($output->attachments, $attachment); |
1120 | 1388 | } |
1121 | 1389 | unset($attachment); |
@@ -1128,8 +1396,11 @@ discard block |
||
1128 | 1396 | // Language Code Page ID: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx |
1129 | 1397 | $output->internetcpid = INTERNET_CPID_UTF8; |
1130 | 1398 | |
1131 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
1132 | -//$this->debugLevel=0; |
|
1399 | + if ($this->debugLevel>3) |
|
1400 | + { |
|
1401 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($output)); |
|
1402 | + } |
|
1403 | + //$this->debugLevel=0; |
|
1133 | 1404 | return $output; |
1134 | 1405 | } |
1135 | 1406 | //$this->debugLevel=0; |
@@ -1188,14 +1459,18 @@ discard block |
||
1188 | 1459 | * @param string $attname - should contain (folder)id |
1189 | 1460 | * @return true, prints the content of the attachment |
1190 | 1461 | */ |
1191 | - function GetAttachmentData($fid,$attname) { |
|
1462 | + function GetAttachmentData($fid,$attname) |
|
1463 | + { |
|
1192 | 1464 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
1193 | 1465 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1194 | 1466 | list($folderid, $id, $part) = explode(":", $attname); |
1195 | 1467 | |
1196 | 1468 | $this->splitID($folderid, $account, $folder); |
1197 | 1469 | |
1198 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1470 | + if (!isset($this->mail)) |
|
1471 | + { |
|
1472 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1473 | + } |
|
1199 | 1474 | |
1200 | 1475 | $this->mail->reopen($folder); |
1201 | 1476 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
@@ -1204,7 +1479,9 @@ discard block |
||
1204 | 1479 | $SIOattachment->data = $attachment['attachment']; |
1205 | 1480 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname') Data:".$attachment['attachment']); |
1206 | 1481 | if (isset($attachment['type']) ) |
1207 | - $SIOattachment->contenttype = $attachment['type']; |
|
1482 | + { |
|
1483 | + $SIOattachment->contenttype = $attachment['type']; |
|
1484 | + } |
|
1208 | 1485 | |
1209 | 1486 | unset($attachment); |
1210 | 1487 | |
@@ -1221,14 +1498,18 @@ discard block |
||
1221 | 1498 | * @param string $attname - should contain (folder)id |
1222 | 1499 | * @return SyncItemOperationsAttachment-object |
1223 | 1500 | */ |
1224 | - function ItemOperationsGetAttachmentData($fid,$attname) { |
|
1501 | + function ItemOperationsGetAttachmentData($fid,$attname) |
|
1502 | + { |
|
1225 | 1503 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": $fid (attname: '$attname')".function_backtrace()); |
1226 | 1504 | //error_log(__METHOD__.__LINE__." Fid: $fid (attname: '$attname')"); |
1227 | 1505 | list($folderid, $id, $part) = explode(":", $attname); |
1228 | 1506 | |
1229 | 1507 | $this->splitID($folderid, $account, $folder); |
1230 | 1508 | |
1231 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1509 | + if (!isset($this->mail)) |
|
1510 | + { |
|
1511 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1512 | + } |
|
1232 | 1513 | |
1233 | 1514 | $this->mail->reopen($folder); |
1234 | 1515 | $attachment = $this->mail->getAttachment($id,$part,0,false,true,$folder); |
@@ -1236,7 +1517,9 @@ discard block |
||
1236 | 1517 | fseek($attachment['attachment'], 0, SEEK_SET); // z-push requires stream seeked to start |
1237 | 1518 | $SIOattachment->data = $attachment['attachment']; |
1238 | 1519 | if (isset($attachment['type']) ) |
1239 | - $SIOattachment->contenttype = $attachment['type']; |
|
1520 | + { |
|
1521 | + $SIOattachment->contenttype = $attachment['type']; |
|
1522 | + } |
|
1240 | 1523 | |
1241 | 1524 | unset($attachment); |
1242 | 1525 | |
@@ -1282,11 +1565,15 @@ discard block |
||
1282 | 1565 | //unset($folderid, $id, $message, $contentParameters); |
1283 | 1566 | $account = $folder = null; |
1284 | 1567 | $this->splitID($folderid, $account, $folder); |
1285 | - if (isset($message->flag)) { |
|
1286 | - if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) { |
|
1568 | + if (isset($message->flag)) |
|
1569 | + { |
|
1570 | + if (isset($message->flag->flagstatus) && $message->flag->flagstatus == 2) |
|
1571 | + { |
|
1287 | 1572 | $rv = $this->mail->flagMessages((($message->flag->flagstatus == 2) ? "flagged" : "unflagged"), $id,$folder); |
1288 | 1573 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . (($message->flag->flagstatus == 2) ? "flagged" : "unflagged") . "-->". $rv); |
1289 | - } else { |
|
1574 | + } |
|
1575 | + else |
|
1576 | + { |
|
1290 | 1577 | $rv = $this->mail->flagMessages("unflagged", $id,$folder); |
1291 | 1578 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." -> set ".array2string($id).' in Folder '.$folder." as " . "unflagged" . "-->". $rv); |
1292 | 1579 | } |
@@ -1316,7 +1603,10 @@ discard block |
||
1316 | 1603 | $this->splitID($folderid, $account, $srcFolder); |
1317 | 1604 | $this->splitID($newfolderid, $account, $destFolder); |
1318 | 1605 | debugLog("IMAP-MoveMessage: (SourceFolder: '$srcFolder' id: '$id' DestFolder: '$destFolder' )"); |
1319 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1606 | + if (!isset($this->mail)) |
|
1607 | + { |
|
1608 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
1609 | + } |
|
1320 | 1610 | $this->mail->reopen($destFolder); |
1321 | 1611 | $status = $this->mail->getFolderStatus($destFolder); |
1322 | 1612 | $uidNext = $status['uidnext']; |
@@ -1337,7 +1627,10 @@ discard block |
||
1337 | 1627 | public function GetMessageList($folderid, $cutoffdate=NULL) |
1338 | 1628 | { |
1339 | 1629 | static $cutdate=null; |
1340 | - if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) $cutdate = $cutoffdate; |
|
1630 | + if (!empty($cutoffdate) && $cutoffdate >0 && (empty($cutdate) || $cutoffdate != $cutdate)) |
|
1631 | + { |
|
1632 | + $cutdate = $cutoffdate; |
|
1633 | + } |
|
1341 | 1634 | debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate)); |
1342 | 1635 | if (empty($cutdate)) |
1343 | 1636 | { |
@@ -1349,7 +1642,10 @@ discard block |
||
1349 | 1642 | |
1350 | 1643 | private function fetchMessages($folderid, $cutoffdate=NULL, $_id=NULL) |
1351 | 1644 | { |
1352 | - if ($this->debugLevel>1) $gstarttime = microtime (true); |
|
1645 | + if ($this->debugLevel>1) |
|
1646 | + { |
|
1647 | + $gstarttime = microtime (true); |
|
1648 | + } |
|
1353 | 1649 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); |
1354 | 1650 | $rv_messages = array(); |
1355 | 1651 | // if the message is still available within the class, we use it instead of fetching it again |
@@ -1360,7 +1656,10 @@ discard block |
||
1360 | 1656 | } |
1361 | 1657 | if (empty($rv_messages)) |
1362 | 1658 | { |
1363 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1659 | + if ($this->debugLevel>1) |
|
1660 | + { |
|
1661 | + $starttime = microtime (true); |
|
1662 | + } |
|
1364 | 1663 | $this->_connect($this->account); |
1365 | 1664 | if ($this->debugLevel>1) |
1366 | 1665 | { |
@@ -1369,8 +1668,14 @@ discard block |
||
1369 | 1668 | } |
1370 | 1669 | $messagelist = $_filter = array(); |
1371 | 1670 | // if not connected, any further action must fail |
1372 | - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
1373 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1671 | + if (!empty($cutoffdate)) |
|
1672 | + { |
|
1673 | + $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); |
|
1674 | + } |
|
1675 | + if ($this->debugLevel>1) |
|
1676 | + { |
|
1677 | + $starttime = microtime (true); |
|
1678 | + } |
|
1374 | 1679 | $account = $_folderName = $id = null; |
1375 | 1680 | $this->splitID($folderid,$account,$_folderName,$id); |
1376 | 1681 | if ($this->debugLevel>1) |
@@ -1378,8 +1683,14 @@ discard block |
||
1378 | 1683 | $endtime = microtime(true) - $starttime; |
1379 | 1684 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " splitID took : ".$endtime.' for FolderID:'.$folderid); |
1380 | 1685 | } |
1381 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1382 | - if ($this->debugLevel>1) $starttime = microtime (true); |
|
1686 | + if ($this->debugLevel>1) |
|
1687 | + { |
|
1688 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_id).'/'.$id); |
|
1689 | + } |
|
1690 | + if ($this->debugLevel>1) |
|
1691 | + { |
|
1692 | + $starttime = microtime (true); |
|
1693 | + } |
|
1383 | 1694 | $_numberOfMessages = (empty($cutoffdate)?250:99999); |
1384 | 1695 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=1, $_numberOfMessages, $_sort=0, $_reverse=false, $_filter, $_id); |
1385 | 1696 | if ($this->debugLevel>1) |
@@ -1388,26 +1699,55 @@ discard block |
||
1388 | 1699 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__. " getHeaders call took : ".$endtime.' for FolderID:'.$_folderName); |
1389 | 1700 | } |
1390 | 1701 | } |
1391 | - if ($_id == NULL && $this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
1702 | + if ($_id == NULL && $this->debugLevel>1) |
|
1703 | + { |
|
1704 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__." found :". count($rv_messages['header'])); |
|
1705 | + } |
|
1392 | 1706 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Result:'.array2string($rv_messages)); |
1393 | 1707 | $messagelist = array(); |
1394 | - if (!isset($rv_messages['header'])||empty($rv_messages['header'])) return $messagelist; |
|
1708 | + if (!isset($rv_messages['header'])||empty($rv_messages['header'])) |
|
1709 | + { |
|
1710 | + return $messagelist; |
|
1711 | + } |
|
1395 | 1712 | //if ($_returnModHash) $messageFolderHash = array(); |
1396 | 1713 | foreach ((array)$rv_messages['header'] as $k => $vars) |
1397 | 1714 | { |
1398 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1715 | + if ($this->debugLevel>3) |
|
1716 | + { |
|
1717 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to process:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1718 | + } |
|
1399 | 1719 | $this->messages[$vars['uid']] = $vars; |
1400 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1401 | - if (!empty($vars['deleted'])) continue; // cut of deleted messages |
|
1402 | - if ($cutoffdate && $vars['date'] < $cutoffdate) continue; // message is out of range for cutoffdate, ignore it |
|
1403 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1720 | + if ($this->debugLevel>3) |
|
1721 | + { |
|
1722 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' MailID:'.$k.'->'.array2string($vars)); |
|
1723 | + } |
|
1724 | + if (!empty($vars['deleted'])) |
|
1725 | + { |
|
1726 | + continue; |
|
1727 | + } |
|
1728 | + // cut of deleted messages |
|
1729 | + if ($cutoffdate && $vars['date'] < $cutoffdate) |
|
1730 | + { |
|
1731 | + continue; |
|
1732 | + } |
|
1733 | + // message is out of range for cutoffdate, ignore it |
|
1734 | + if ($this->debugLevel>0) |
|
1735 | + { |
|
1736 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' ID to report:'.$vars['uid'].' Subject:'.$vars['subject']); |
|
1737 | + } |
|
1404 | 1738 | $mess["mod"] = self::doFlagsMod($vars).$vars['date']; |
1405 | 1739 | $mess["id"] = $vars['uid']; |
1406 | 1740 | // 'seen' aka 'read' is the only flag we want to know about |
1407 | 1741 | $mess["flags"] = 0; |
1408 | 1742 | // outlook supports additional flags, set them to 0 |
1409 | - if($vars["seen"]) $mess["flags"] = 1; |
|
1410 | - if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
1743 | + if($vars["seen"]) |
|
1744 | + { |
|
1745 | + $mess["flags"] = 1; |
|
1746 | + } |
|
1747 | + if ($this->debugLevel>3) |
|
1748 | + { |
|
1749 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); |
|
1750 | + } |
|
1411 | 1751 | $messagelist[$vars['uid']] = $mess; |
1412 | 1752 | unset($mess); |
1413 | 1753 | } |
@@ -1432,9 +1772,18 @@ discard block |
||
1432 | 1772 | static function doFlagsMod($headerFlags) |
1433 | 1773 | { |
1434 | 1774 | $flags = 'nnn'; |
1435 | - if ($headerFlags['flagged']) $flags[0] = 'f'; |
|
1436 | - if ($headerFlags['answered']) $flags[1] = 'a'; |
|
1437 | - if ($headerFlags['forwarded']) $flags[2] = 'f'; |
|
1775 | + if ($headerFlags['flagged']) |
|
1776 | + { |
|
1777 | + $flags[0] = 'f'; |
|
1778 | + } |
|
1779 | + if ($headerFlags['answered']) |
|
1780 | + { |
|
1781 | + $flags[1] = 'a'; |
|
1782 | + } |
|
1783 | + if ($headerFlags['forwarded']) |
|
1784 | + { |
|
1785 | + $flags[2] = 'f'; |
|
1786 | + } |
|
1438 | 1787 | //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags)); |
1439 | 1788 | return $flags; |
1440 | 1789 | } |
@@ -1466,31 +1815,55 @@ discard block |
||
1466 | 1815 | { |
1467 | 1816 | //$this->debugLevel=1; |
1468 | 1817 | $searchquery=$_searchquery->GetDataArray(); |
1469 | - if (!is_array($searchquery)) return array(); |
|
1470 | - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
1818 | + if (!is_array($searchquery)) |
|
1819 | + { |
|
1820 | + return array(); |
|
1821 | + } |
|
1822 | + if ($this->debugLevel>0) |
|
1823 | + { |
|
1824 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($searchquery)); |
|
1825 | + } |
|
1471 | 1826 | |
1472 | - if (isset($searchquery['searchrebuildresults'])) { |
|
1827 | + if (isset($searchquery['searchrebuildresults'])) |
|
1828 | + { |
|
1473 | 1829 | $rebuildresults = $searchquery['searchrebuildresults']; |
1474 | - } else { |
|
1830 | + } |
|
1831 | + else |
|
1832 | + { |
|
1475 | 1833 | $rebuildresults = false; |
1476 | 1834 | } |
1477 | - if ($this->debugLevel>0) debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1835 | + if ($this->debugLevel>0) |
|
1836 | + { |
|
1837 | + debugLog( 'RebuildResults ['.$rebuildresults.']' ); |
|
1838 | + } |
|
1478 | 1839 | |
1479 | - if (isset($searchquery['deeptraversal'])) { |
|
1840 | + if (isset($searchquery['deeptraversal'])) |
|
1841 | + { |
|
1480 | 1842 | $deeptraversal = $searchquery['deeptraversal']; |
1481 | - } else { |
|
1843 | + } |
|
1844 | + else |
|
1845 | + { |
|
1482 | 1846 | $deeptraversal = false; |
1483 | 1847 | } |
1484 | - if ($this->debugLevel>0) debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1848 | + if ($this->debugLevel>0) |
|
1849 | + { |
|
1850 | + debugLog( 'DeepTraversal ['.$deeptraversal.']' ); |
|
1851 | + } |
|
1485 | 1852 | |
1486 | - if (isset($searchquery['searchrange'])) { |
|
1853 | + if (isset($searchquery['searchrange'])) |
|
1854 | + { |
|
1487 | 1855 | $range = explode("-",$_searchquery->GetSearchRange()); |
1488 | 1856 | $start =$range[0] + 1; |
1489 | 1857 | $limit = $range[1] - $range[0] + 1; |
1490 | - } else { |
|
1858 | + } |
|
1859 | + else |
|
1860 | + { |
|
1491 | 1861 | $range = false; |
1492 | 1862 | } |
1493 | - if ($this->debugLevel>0) debugLog( 'Range ['.print_r($range, true).']' ); |
|
1863 | + if ($this->debugLevel>0) |
|
1864 | + { |
|
1865 | + debugLog( 'Range ['.print_r($range, true).']' ); |
|
1866 | + } |
|
1494 | 1867 | |
1495 | 1868 | //foreach($searchquery['query'] as $k => $value) { |
1496 | 1869 | // $query = $value; |
@@ -1542,7 +1915,10 @@ discard block |
||
1542 | 1915 | $_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts')); |
1543 | 1916 | } |
1544 | 1917 | //$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
1545 | - if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1918 | + if ($this->debugLevel>1) |
|
1919 | + { |
|
1920 | + debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter)); |
|
1921 | + } |
|
1546 | 1922 | $rv_messages = $this->mail->getHeaders($_folderName, $_startMessage=($range?$start:1), $_numberOfMessages=($limit?$limit:9999999), $_sort=0, $_reverse=false, $_filter, $_id=NULL); |
1547 | 1923 | //ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($rv_messages)); |
1548 | 1924 | $list=array(); |
@@ -1574,17 +1950,26 @@ discard block |
||
1574 | 1950 | private function getParentID($account,$folder) |
1575 | 1951 | { |
1576 | 1952 | $this->_connect($account); |
1577 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
1953 | + if (!isset($this->folders)) |
|
1954 | + { |
|
1955 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
1956 | + } |
|
1578 | 1957 | |
1579 | 1958 | $mailFolder = $this->folders[$folder]; |
1580 | - if (!isset($mailFolder)) return false; |
|
1959 | + if (!isset($mailFolder)) |
|
1960 | + { |
|
1961 | + return false; |
|
1962 | + } |
|
1581 | 1963 | $delimiter = (isset($mailFolder->delimiter)?$mailFolder->delimiter:$this->mail->getHierarchyDelimiter()); |
1582 | 1964 | $parent = explode($delimiter,$folder); |
1583 | 1965 | array_pop($parent); |
1584 | 1966 | $parent = implode($delimiter,$parent); |
1585 | 1967 | |
1586 | 1968 | $id = $parent ? $this->createID($account, $parent) : '0'; |
1587 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1969 | + if ($this->debugLevel>1) |
|
1970 | + { |
|
1971 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$folder') --> parent=$parent --> $id"); |
|
1972 | + } |
|
1588 | 1973 | return $id; |
1589 | 1974 | } |
1590 | 1975 | |
@@ -1598,7 +1983,10 @@ discard block |
||
1598 | 1983 | { |
1599 | 1984 | static $last_id = null; |
1600 | 1985 | static $folderObj = null; |
1601 | - if (isset($last_id) && $last_id === $id) return $folderObj; |
|
1986 | + if (isset($last_id) && $last_id === $id) |
|
1987 | + { |
|
1988 | + return $folderObj; |
|
1989 | + } |
|
1602 | 1990 | |
1603 | 1991 | try { |
1604 | 1992 | $account = $folder = null; |
@@ -1609,18 +1997,30 @@ discard block |
||
1609 | 1997 | return $folderObj=false; |
1610 | 1998 | } |
1611 | 1999 | $this->_connect($account); |
1612 | - if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false); |
|
2000 | + if (!isset($this->folders)) |
|
2001 | + { |
|
2002 | + $this->folders = $this->mail->getFolderObjects(true,false); |
|
2003 | + } |
|
1613 | 2004 | |
1614 | 2005 | $mailFolder = $this->folders[$folder]; |
1615 | - if (!isset($mailFolder)) return $folderObj=false; |
|
2006 | + if (!isset($mailFolder)) |
|
2007 | + { |
|
2008 | + return $folderObj=false; |
|
2009 | + } |
|
1616 | 2010 | |
1617 | 2011 | $folderObj = new SyncFolder(); |
1618 | 2012 | $folderObj->serverid = $id; |
1619 | 2013 | $folderObj->parentid = $this->getParentID($account,$folder); |
1620 | 2014 | $folderObj->displayname = $mailFolder->shortDisplayName; |
1621 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
2015 | + if ($this->debugLevel>1) |
|
2016 | + { |
|
2017 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." ID: $id, Account:$account, Folder:$folder"); |
|
2018 | + } |
|
1622 | 2019 | // get folder-type |
1623 | - foreach($this->folders as $inbox => $mailFolder) break; |
|
2020 | + foreach($this->folders as $inbox => $mailFolder) |
|
2021 | + { |
|
2022 | + break; |
|
2023 | + } |
|
1624 | 2024 | if ($folder == $inbox) |
1625 | 2025 | { |
1626 | 2026 | $folderObj->type = SYNC_FOLDER_TYPE_INBOX; |
@@ -1657,7 +2057,10 @@ discard block |
||
1657 | 2057 | $folderObj->type = SYNC_FOLDER_TYPE_USER_MAIL; |
1658 | 2058 | } |
1659 | 2059 | |
1660 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
2060 | + if ($this->debugLevel>1) |
|
2061 | + { |
|
2062 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($id) --> $folder --> type=$folderObj->type, parentID=$folderObj->parentid, displayname=$folderObj->displayname"); |
|
2063 | + } |
|
1661 | 2064 | return $folderObj; |
1662 | 2065 | } |
1663 | 2066 | |
@@ -1701,20 +2104,32 @@ discard block |
||
1701 | 2104 | { |
1702 | 2105 | $account = $folder = null; |
1703 | 2106 | $this->splitID($folderid, $account, $folder); |
1704 | - if (is_numeric($account)) $type = 'mail'; |
|
2107 | + if (is_numeric($account)) |
|
2108 | + { |
|
2109 | + $type = 'mail'; |
|
2110 | + } |
|
1705 | 2111 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid -> $folder ($account) type: ". $type); |
1706 | - if ($type != 'mail') return false; |
|
2112 | + if ($type != 'mail') |
|
2113 | + { |
|
2114 | + return false; |
|
2115 | + } |
|
1707 | 2116 | |
1708 | - if (!isset($this->mail)) $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
2117 | + if (!isset($this->mail)) |
|
2118 | + { |
|
2119 | + $this->mail = Mail::getInstance(false,self::$profileID,true,false,true); |
|
2120 | + } |
|
1709 | 2121 | |
1710 | 2122 | $changes = array(); |
1711 | 2123 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": on $folderid ($folder) stat: ". $syncstate); |
1712 | 2124 | $this->mail->reopen($folder); |
1713 | 2125 | $status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true); |
1714 | - if (!$status) { |
|
2126 | + if (!$status) |
|
2127 | + { |
|
1715 | 2128 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.": could not stat folder $folder "); |
1716 | 2129 | return false; |
1717 | - } else { |
|
2130 | + } |
|
2131 | + else |
|
2132 | + { |
|
1718 | 2133 | $syncstate = "M:". $status['messages'] ."-R:". $status['recent'] ."-U:". $status['unseen']."-NUID:".$status['uidnext']."-UIDV:".$status['uidvalidity']; |
1719 | 2134 | } |
1720 | 2135 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' called with ('.$folderid.', ....) returning '.array2string($syncstate)); |
@@ -1751,7 +2166,7 @@ discard block |
||
1751 | 2166 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
1752 | 2167 | */ |
1753 | 2168 | public function DeleteMessage($folderid, $id, $contentParameters) |
1754 | - { |
|
2169 | + { |
|
1755 | 2170 | unset($contentParameters); // not used, but required by function signature |
1756 | 2171 | debugLog("IMAP-DeleteMessage: (fid: '$folderid' id: '$id' )"); |
1757 | 2172 | /* |
@@ -1777,7 +2192,10 @@ discard block |
||
1777 | 2192 | $error = $e->getMessage(); |
1778 | 2193 | ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error); |
1779 | 2194 | // if the server thinks the message does not exist report deletion as success |
1780 | - if (stripos($error,'[NONEXISTENT]')!==false) return true; |
|
2195 | + if (stripos($error,'[NONEXISTENT]')!==false) |
|
2196 | + { |
|
2197 | + return true; |
|
2198 | + } |
|
1781 | 2199 | return false; |
1782 | 2200 | } |
1783 | 2201 | |
@@ -1810,7 +2228,7 @@ discard block |
||
1810 | 2228 | * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
1811 | 2229 | */ |
1812 | 2230 | public function SetReadFlag($folderid, $id, $flags, $contentParameters) |
1813 | - { |
|
2231 | + { |
|
1814 | 2232 | unset($contentParameters); // not used, but required by function signature |
1815 | 2233 | // debugLog("IMAP-SetReadFlag: (fid: '$folderid' id: '$id' flags: '$flags' )"); |
1816 | 2234 | $account = $folder = null; |
@@ -1896,7 +2314,10 @@ discard block |
||
1896 | 2314 | |
1897 | 2315 | $str = $this->backend->createID($account, $folder, $id); |
1898 | 2316 | |
1899 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
2317 | + if ($this->debugLevel>1) |
|
2318 | + { |
|
2319 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."($account,'$f',$id) type=$account, folder=$folder --> '$str'"); |
|
2320 | + } |
|
1900 | 2321 | |
1901 | 2322 | return $str; |
1902 | 2323 | } |
@@ -1917,7 +2338,10 @@ discard block |
||
1917 | 2338 | // convert numeric folder-id back to folder name |
1918 | 2339 | $folder = $this->hash2folder($account,$f=$folder); |
1919 | 2340 | |
1920 | - if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
2341 | + if ($this->debugLevel>1) |
|
2342 | + { |
|
2343 | + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."('$str','$account','$folder',$id)"); |
|
2344 | + } |
|
1921 | 2345 | } |
1922 | 2346 | |
1923 | 2347 | /** |
@@ -1936,7 +2360,10 @@ discard block |
||
1936 | 2360 | */ |
1937 | 2361 | private function folder2hash($account,$folder) |
1938 | 2362 | { |
1939 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
2363 | + if(!isset($this->folderHashes)) |
|
2364 | + { |
|
2365 | + $this->readFolderHashes(); |
|
2366 | + } |
|
1940 | 2367 | |
1941 | 2368 | if (($index = array_search($folder, (array)$this->folderHashes[$account])) === false) |
1942 | 2369 | { |
@@ -1959,7 +2386,10 @@ discard block |
||
1959 | 2386 | */ |
1960 | 2387 | private function hash2folder($account,$index) |
1961 | 2388 | { |
1962 | - if(!isset($this->folderHashes)) $this->readFolderHashes(); |
|
2389 | + if(!isset($this->folderHashes)) |
|
2390 | + { |
|
2391 | + $this->readFolderHashes(); |
|
2392 | + } |
|
1963 | 2393 | |
1964 | 2394 | return isset($this->folderHashes[$account]) ? $this->folderHashes[$account][$index] : null; |
1965 | 2395 | } |
@@ -434,7 +434,7 @@ |
||
434 | 434 | * Sets backends that should be skipped even if the user |
435 | 435 | * defined them in its chain |
436 | 436 | * |
437 | - * @param array $_skip_backends array with names of the backends to be skipped |
|
437 | + * @param string[] $_skip_backends array with names of the backends to be skipped |
|
438 | 438 | * e.g. array('popup', 'winpopup') |
439 | 439 | */ |
440 | 440 | public function set_skip_backends(array $_skip_backends) { |
@@ -660,14 +660,14 @@ |
||
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
663 | - * returns notification chains based on admin prefs |
|
664 | - * @abstract the available chains can be retrieved in two different output formats: |
|
665 | - * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing) |
|
666 | - * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config) |
|
667 | - * |
|
668 | - * @param string $_output one of: 'routing' or 'human', defaults to 'routing' |
|
669 | - * @return array containing notification chains, output like given in $_output |
|
670 | - */ |
|
663 | + * returns notification chains based on admin prefs |
|
664 | + * @abstract the available chains can be retrieved in two different output formats: |
|
665 | + * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing) |
|
666 | + * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config) |
|
667 | + * |
|
668 | + * @param string $_output one of: 'routing' or 'human', defaults to 'routing' |
|
669 | + * @return array containing notification chains, output like given in $_output |
|
670 | + */ |
|
671 | 671 | public function get_available_chains($_output = 'routing') { |
672 | 672 | // determine enabled backends from Api\Config |
673 | 673 | $enabled_backends = array(); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * |
180 | 180 | */ |
181 | 181 | public function __construct() { |
182 | - $this->config = (object) Api\Config::read(self::_appname); |
|
182 | + $this->config = (object)Api\Config::read(self::_appname); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param boolean $reset =false true: reset all errors |
189 | 189 | * @return array |
190 | 190 | */ |
191 | - public static function errors($reset=false) |
|
191 | + public static function errors($reset = false) |
|
192 | 192 | { |
193 | 193 | $ret = self::$errors; |
194 | 194 | if ($reset) self::$errors = array(); |
@@ -203,19 +203,19 @@ discard block |
||
203 | 203 | * it's an int with the account id or the e-mail address of a non-eGW user |
204 | 204 | */ |
205 | 205 | public function set_sender($_sender) { |
206 | - if(is_object($_sender)) { |
|
206 | + if (is_object($_sender)) { |
|
207 | 207 | $this->sender = $_sender; |
208 | 208 | return true; |
209 | 209 | } else { |
210 | 210 | // no object atm, we have to handle this and make a pseudo-object |
211 | - if(is_numeric($_sender)) { |
|
212 | - $this->sender = (object) $GLOBALS['egw']->accounts->read($_sender); |
|
211 | + if (is_numeric($_sender)) { |
|
212 | + $this->sender = (object)$GLOBALS['egw']->accounts->read($_sender); |
|
213 | 213 | return true; |
214 | 214 | } |
215 | - if(is_string($_sender) && strpos($_sender,'@')) { |
|
216 | - $this->sender = (object) array ( |
|
217 | - 'account_email' => $this->get_addresspart($_sender,'email'), |
|
218 | - 'account_fullname' => $this->get_addresspart($_sender,'fullname'), |
|
215 | + if (is_string($_sender) && strpos($_sender, '@')) { |
|
216 | + $this->sender = (object)array( |
|
217 | + 'account_email' => $this->get_addresspart($_sender, 'email'), |
|
218 | + 'account_fullname' => $this->get_addresspart($_sender, 'fullname'), |
|
219 | 219 | ); |
220 | 220 | return true; |
221 | 221 | } |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | * it's an int with the account id or the e-mail address of a non-eGW user |
246 | 246 | */ |
247 | 247 | public function add_receiver($_receiver) { |
248 | - if(is_object($_receiver)) { |
|
248 | + if (is_object($_receiver)) { |
|
249 | 249 | $this->receivers[] = $_receiver; |
250 | 250 | return true; |
251 | 251 | } else { |
252 | 252 | // no object atm, we have to handle this and make a pseudo-object |
253 | - if(is_numeric($_receiver)) { |
|
254 | - $this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver); |
|
253 | + if (is_numeric($_receiver)) { |
|
254 | + $this->receivers[] = (object)$GLOBALS['egw']->accounts->read($_receiver); |
|
255 | 255 | return true; |
256 | 256 | } |
257 | - if(is_string($_receiver) && strpos($_receiver,'@')) { |
|
258 | - $this->receivers[] = (object) array ( |
|
259 | - 'account_email' => $this->get_addresspart($_receiver,'email'), |
|
260 | - 'account_fullname' => $this->get_addresspart($_receiver,'fullname'), |
|
257 | + if (is_string($_receiver) && strpos($_receiver, '@')) { |
|
258 | + $this->receivers[] = (object)array( |
|
259 | + 'account_email' => $this->get_addresspart($_receiver, 'email'), |
|
260 | + 'account_fullname' => $this->get_addresspart($_receiver, 'fullname'), |
|
261 | 261 | ); |
262 | 262 | return true; |
263 | 263 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param string $_message |
297 | 297 | */ |
298 | 298 | public function set_message($_message) { |
299 | - if(strlen($_message) == strlen(strip_tags($_message))) { |
|
299 | + if (strlen($_message) == strlen(strip_tags($_message))) { |
|
300 | 300 | $this->message_plain = $_message; |
301 | 301 | } else { |
302 | 302 | $this->message_html = $_message; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function set_popupmessage($_message) { |
316 | 316 | //popup requires html |
317 | - if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message); |
|
317 | + if (strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message); |
|
318 | 318 | $this->message_popup = $_message; |
319 | 319 | return true; |
320 | 320 | } |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function set_links(array $_links) { |
328 | 328 | $this->links = array(); // clear array if set |
329 | - foreach($_links as $link) { |
|
330 | - if(is_array($link)) { |
|
331 | - $this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']); |
|
329 | + foreach ($_links as $link) { |
|
330 | + if (is_array($link)) { |
|
331 | + $this->add_link($link['text'], $link['view'], $link['popup'], $link['app'], $link['id']); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | return true; |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function set_popuplinks(array $_links) { |
343 | 343 | $this->popup_links = array(); // clear array if set |
344 | - foreach($_links as $link) { |
|
345 | - if(is_array($link)) { |
|
344 | + foreach ($_links as $link) { |
|
345 | + if (is_array($link)) { |
|
346 | 346 | $this->add_popuplink($link['text'], $link['view'], $link['popup']); |
347 | 347 | } |
348 | 348 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param string $_id Application ID, to use link registry (popup & view ignored) |
360 | 360 | */ |
361 | 361 | public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) { |
362 | - if(!$_view || !$_text) { return false; } |
|
362 | + if (!$_view || !$_text) { return false; } |
|
363 | 363 | $this->links[] = (object)array( |
364 | 364 | 'text' => $_text, |
365 | 365 | 'view' => $_view, |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false |
379 | 379 | */ |
380 | 380 | public function add_popuplink($_text, $_view, $_popup = false) { |
381 | - if(!$_view || !$_text) { return false; } |
|
382 | - $this->popup_links[] = (object)array( 'text' => $_text, |
|
381 | + if (!$_view || !$_text) { return false; } |
|
382 | + $this->popup_links[] = (object)array('text' => $_text, |
|
383 | 383 | 'view' => $_view, |
384 | 384 | 'popup' => $_popup, |
385 | 385 | ); |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function set_attachments(array $_attachments) { |
395 | 395 | $this->attachments = array(); // clear array if set |
396 | - foreach($_attachments as $attachment) { |
|
397 | - if(is_array($attachment)) { |
|
396 | + foreach ($_attachments as $attachment) { |
|
397 | + if (is_array($attachment)) { |
|
398 | 398 | $this->add_attachment( |
399 | 399 | $attachment['string'], |
400 | 400 | $attachment['filename'], |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param string $_type File extension (MIME) type. |
419 | 419 | * @param string $_path optional path to attachment, if !$_string |
420 | 420 | */ |
421 | - public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) { |
|
422 | - if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false; |
|
421 | + public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path = null) { |
|
422 | + if (!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false; |
|
423 | 423 | $this->attachments[] = (object)array( |
424 | 424 | 'string' => $_string, |
425 | 425 | 'filename' => $_filename, |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | if (!is_array($this->receivers) || count($this->receivers) == 0) { |
452 | 452 | throw new Exception('Error: cannot send notifications. No receivers supplied'); |
453 | 453 | } |
454 | - if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) { |
|
454 | + if (!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) { |
|
455 | 455 | throw new Exception('Error: cannot send notifications. No valid messages supplied'); |
456 | 456 | } |
457 | 457 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | $backend_errors = array(); |
464 | 464 | try { |
465 | 465 | // system or non-system user |
466 | - if($receiver->account_id && is_numeric($receiver->account_id)) { |
|
466 | + if ($receiver->account_id && is_numeric($receiver->account_id)) { |
|
467 | 467 | // system user, collect data and check for Status and expire state, skip notification if expired or not active |
468 | 468 | $userData = $GLOBALS['egw']->accounts->read($receiver->account_id); |
469 | 469 | //error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#'); |
@@ -476,17 +476,17 @@ discard block |
||
476 | 476 | } |
477 | 477 | $receiver->handle = $receiver->account_lid; |
478 | 478 | // check if the receiver has rights to run the notifcation app |
479 | - $ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true); |
|
479 | + $ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id, true); |
|
480 | 480 | $ids[] = $receiver->account_id; |
481 | - if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) { |
|
481 | + if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids, 'run', 'notifications')) { |
|
482 | 482 | // read the users notification chain |
483 | 483 | $prefs = new Api\Preferences($receiver->account_id); |
484 | 484 | $preferences_all = $prefs->read(); |
485 | 485 | $preferences = (object)$preferences_all[self::_appname]; |
486 | - if($preferences->notification_chain) { |
|
486 | + if ($preferences->notification_chain) { |
|
487 | 487 | // fallback: admin disabled user-chosen chain |
488 | - if(!$notification_chain = $available_chains[$preferences->notification_chain]) { |
|
489 | - $prepend_message .= lang( 'This eGroupWare notification has been sent to you by mail because your' |
|
488 | + if (!$notification_chain = $available_chains[$preferences->notification_chain]) { |
|
489 | + $prepend_message .= lang('This eGroupWare notification has been sent to you by mail because your' |
|
490 | 490 | .' chosen notification-chain has been disabled by the administrator.' |
491 | 491 | .' Please choose another notification-chain in your preferences!'); |
492 | 492 | $notification_chain = $available_chains[self::_fallback]; |
@@ -503,28 +503,28 @@ discard block |
||
503 | 503 | $notification_chain = $available_chains[self::_fallback]; // fallback: non-system user |
504 | 504 | } |
505 | 505 | |
506 | - if($notification_chain == 'disable') { |
|
506 | + if ($notification_chain == 'disable') { |
|
507 | 507 | continue; //user disabled notifications |
508 | 508 | } |
509 | 509 | |
510 | - foreach($notification_chain as $backend => $action) { |
|
510 | + foreach ($notification_chain as $backend => $action) { |
|
511 | 511 | $notification_backend = null; |
512 | 512 | try { |
513 | 513 | // check if backend should be skipped |
514 | - if( in_array($backend, $this->skip_backends) ) { |
|
514 | + if (in_array($backend, $this->skip_backends)) { |
|
515 | 515 | // log as error just for the case too much skipping prevents user from being notified |
516 | 516 | $backend_errors[] = $backend.' will be skipped (as defined by calling application)'; |
517 | 517 | continue; |
518 | 518 | } |
519 | 519 | |
520 | 520 | $notification_backend = self::_appname.'_'.$backend; |
521 | - if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) { |
|
522 | - throw new Exception('file for '.$notification_backend. ' does not exist'); |
|
521 | + if (!file_exists(EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.'.$notification_backend.'.inc.php')) { |
|
522 | + throw new Exception('file for '.$notification_backend.' does not exist'); |
|
523 | 523 | } |
524 | - $obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences ); |
|
525 | - if ( !($obj instanceof notifications_iface) ) { |
|
526 | - unset ( $obj ); |
|
527 | - throw new Exception($notification_backend. ' is no implementation of notifications_iface'); |
|
524 | + $obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences); |
|
525 | + if (!($obj instanceof notifications_iface)) { |
|
526 | + unset ($obj); |
|
527 | + throw new Exception($notification_backend.' is no implementation of notifications_iface'); |
|
528 | 528 | } |
529 | 529 | $lsubject = $this->subject; |
530 | 530 | $llinks = $this->links; |
@@ -538,17 +538,17 @@ discard block |
||
538 | 538 | catch (Exception $exception) { |
539 | 539 | $backend_errors[] = $notification_backend.' failed: '.$exception->getMessage(); |
540 | 540 | // try next backend |
541 | - if($action == 'fail' || $action == 'continue') { |
|
541 | + if ($action == 'fail' || $action == 'continue') { |
|
542 | 542 | continue; |
543 | 543 | } |
544 | 544 | break; // stop running through chain |
545 | 545 | } |
546 | 546 | // backend sucseeded |
547 | 547 | $user_notified = true; |
548 | - if($action == 'stop' || $action == 'fail') { break; } // stop running through chain |
|
548 | + if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain |
|
549 | 549 | } |
550 | 550 | // check if the user has been notified at all |
551 | - if(!$user_notified) { |
|
551 | + if (!$user_notified) { |
|
552 | 552 | /*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:'); |
553 | 553 | foreach($backend_errors as $id=>$backend_error) { |
554 | 554 | error_log($backend_error); |
@@ -575,22 +575,22 @@ discard block |
||
575 | 575 | * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup'] |
576 | 576 | */ |
577 | 577 | private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') { |
578 | - if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set |
|
578 | + if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set |
|
579 | 579 | $messages = array(); |
580 | 580 | |
581 | 581 | // create the messages |
582 | - if(!empty($_message_plain)) { |
|
582 | + if (!empty($_message_plain)) { |
|
583 | 583 | $messages['plain'] = $_message_plain; |
584 | 584 | } else { |
585 | 585 | $messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true); |
586 | 586 | } |
587 | 587 | |
588 | - if(!empty($_message_html)) { |
|
588 | + if (!empty($_message_html)) { |
|
589 | 589 | $messages['html'] = $_message_html; |
590 | 590 | } else { |
591 | 591 | $messages['html'] = self::plain2html($_message_plain); |
592 | 592 | } |
593 | - if (!empty($_message_popup)) $messages['popup']=$_message_popup; |
|
593 | + if (!empty($_message_popup)) $messages['popup'] = $_message_popup; |
|
594 | 594 | return $messages; |
595 | 595 | } |
596 | 596 | |
@@ -613,9 +613,9 @@ discard block |
||
613 | 613 | * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html'] |
614 | 614 | */ |
615 | 615 | private function prepend_message(array $_messages, $_prepend = null) { |
616 | - if(strlen($_prepend) > 0) { |
|
617 | - foreach($_messages as $key => $value) { |
|
618 | - switch($key) { |
|
616 | + if (strlen($_prepend) > 0) { |
|
617 | + foreach ($_messages as $key => $value) { |
|
618 | + switch ($key) { |
|
619 | 619 | case 'plain': |
620 | 620 | $_messages[$key] = $_prepend."\n\n".$value; |
621 | 621 | break; |
@@ -639,17 +639,17 @@ discard block |
||
639 | 639 | * @param string $_part |
640 | 640 | * @return string chosen part of the address |
641 | 641 | */ |
642 | - private function get_addresspart($_address, $_part='email') |
|
642 | + private function get_addresspart($_address, $_part = 'email') |
|
643 | 643 | { |
644 | 644 | $parts = null; |
645 | - if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part |
|
646 | - $fullname = trim(trim($parts[1]),'\"'); |
|
645 | + if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part |
|
646 | + $fullname = trim(trim($parts[1]), '\"'); |
|
647 | 647 | $email = $parts[2]; |
648 | 648 | } else { |
649 | 649 | $fullname = false; |
650 | 650 | $email = $_address; |
651 | 651 | } |
652 | - switch($_part) { |
|
652 | + switch ($_part) { |
|
653 | 653 | case 'fullname': |
654 | 654 | return $fullname; |
655 | 655 | case 'email': |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | public function get_available_chains($_output = 'routing') { |
672 | 672 | // determine enabled backends from Api\Config |
673 | 673 | $enabled_backends = array(); |
674 | - foreach($this->backends as $backend) { |
|
675 | - switch($backend) { |
|
674 | + foreach ($this->backends as $backend) { |
|
675 | + switch ($backend) { |
|
676 | 676 | case 'email': |
677 | 677 | case 'popup': |
678 | 678 | case 'jpopup': |
@@ -687,15 +687,15 @@ discard block |
||
687 | 687 | |
688 | 688 | $enabled_chains = array(); |
689 | 689 | $disabled_chains = array(); |
690 | - foreach($this->notification_chains as $key => $chain) { |
|
690 | + foreach ($this->notification_chains as $key => $chain) { |
|
691 | 691 | $allow_chain = true; |
692 | - if(is_array($chain)) { |
|
693 | - foreach(array_keys($chain) as $name) { |
|
694 | - if(!$enabled_backends[$name]) { |
|
692 | + if (is_array($chain)) { |
|
693 | + foreach (array_keys($chain) as $name) { |
|
694 | + if (!$enabled_backends[$name]) { |
|
695 | 695 | $allow_chain = false; // disable whole chain if one backend is disabled |
696 | 696 | } |
697 | 697 | } |
698 | - if($allow_chain) { |
|
698 | + if ($allow_chain) { |
|
699 | 699 | $enabled_chains[$key] = $chain; |
700 | 700 | } else { |
701 | 701 | $disabled_chains[$key] = $chain; |
@@ -710,15 +710,15 @@ discard block |
||
710 | 710 | // create the 'all' chain from the enabled backends |
711 | 711 | $chain_all = array(); |
712 | 712 | $backend_count = 1; |
713 | - foreach($enabled_backends as $backend => $enabled) { |
|
714 | - if($enabled) { |
|
713 | + foreach ($enabled_backends as $backend => $enabled) { |
|
714 | + if ($enabled) { |
|
715 | 715 | $chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue'; |
716 | 716 | } |
717 | 717 | $backend_count++; |
718 | 718 | } |
719 | 719 | $common_chains['all'] = $chain_all; |
720 | 720 | |
721 | - switch($_output) { |
|
721 | + switch ($_output) { |
|
722 | 722 | case 'human': |
723 | 723 | $chain_groups = array( |
724 | 724 | lang('Common chains') => 'common_chains', |
@@ -727,10 +727,10 @@ discard block |
||
727 | 727 | ); |
728 | 728 | $suffix = '_human'; |
729 | 729 | // create descriptions for each chain key in each group |
730 | - foreach($chain_groups as $name => $arr_name) { |
|
730 | + foreach ($chain_groups as $name => $arr_name) { |
|
731 | 731 | ${$arr_name.$suffix} = array(); |
732 | - foreach(array_keys(${$arr_name}) as $key) { |
|
733 | - if($arr_name == 'disabled_chains') { |
|
732 | + foreach (array_keys(${$arr_name}) as $key) { |
|
733 | + if ($arr_name == 'disabled_chains') { |
|
734 | 734 | ${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]); |
735 | 735 | } else { |
736 | 736 | ${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]); |
@@ -739,8 +739,8 @@ discard block |
||
739 | 739 | } |
740 | 740 | // summarize all groups with minimum one chain to the final array |
741 | 741 | $chains_final = array(); |
742 | - foreach($chain_groups as $name => $arr_name) { |
|
743 | - if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) { |
|
742 | + foreach ($chain_groups as $name => $arr_name) { |
|
743 | + if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) { |
|
744 | 744 | $chains_final[$name] = ${$arr_name.$suffix}; |
745 | 745 | } |
746 | 746 | } |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * @param settings array with keys account_id and new_owner (new_owner is optional) |
761 | 761 | */ |
762 | 762 | public function deleteaccount($settings) { |
763 | - foreach($this->backends as $backend) { |
|
764 | - $backend_hook = array(self::_appname.'_'.$backend,'deleteaccount'); |
|
763 | + foreach ($this->backends as $backend) { |
|
764 | + $backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount'); |
|
765 | 765 | if (is_callable($backend_hook)) { |
766 | - call_user_func($backend_hook,$settings); |
|
766 | + call_user_func($backend_hook, $settings); |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | } |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | * called from this class. The backend's job is to deliver ONE message to ONE recipient. |
25 | 25 | * |
26 | 26 | */ |
27 | -final class notifications { |
|
27 | +final class notifications |
|
28 | +{ |
|
28 | 29 | |
29 | 30 | /** |
30 | 31 | * Appname |
@@ -178,7 +179,8 @@ discard block |
||
178 | 179 | * constructor of notifications |
179 | 180 | * |
180 | 181 | */ |
181 | - public function __construct() { |
|
182 | + public function __construct() |
|
183 | + { |
|
182 | 184 | $this->config = (object) Api\Config::read(self::_appname); |
183 | 185 | } |
184 | 186 | |
@@ -191,7 +193,10 @@ discard block |
||
191 | 193 | public static function errors($reset=false) |
192 | 194 | { |
193 | 195 | $ret = self::$errors; |
194 | - if ($reset) self::$errors = array(); |
|
196 | + if ($reset) |
|
197 | + { |
|
198 | + self::$errors = array(); |
|
199 | + } |
|
195 | 200 | return $ret; |
196 | 201 | } |
197 | 202 | |
@@ -202,17 +207,23 @@ discard block |
||
202 | 207 | * as long as the accounts class isn't a nice object, |
203 | 208 | * it's an int with the account id or the e-mail address of a non-eGW user |
204 | 209 | */ |
205 | - public function set_sender($_sender) { |
|
206 | - if(is_object($_sender)) { |
|
210 | + public function set_sender($_sender) |
|
211 | + { |
|
212 | + if(is_object($_sender)) |
|
213 | + { |
|
207 | 214 | $this->sender = $_sender; |
208 | 215 | return true; |
209 | - } else { |
|
216 | + } |
|
217 | + else |
|
218 | + { |
|
210 | 219 | // no object atm, we have to handle this and make a pseudo-object |
211 | - if(is_numeric($_sender)) { |
|
220 | + if(is_numeric($_sender)) |
|
221 | + { |
|
212 | 222 | $this->sender = (object) $GLOBALS['egw']->accounts->read($_sender); |
213 | 223 | return true; |
214 | 224 | } |
215 | - if(is_string($_sender) && strpos($_sender,'@')) { |
|
225 | + if(is_string($_sender) && strpos($_sender,'@')) |
|
226 | + { |
|
216 | 227 | $this->sender = (object) array ( |
217 | 228 | 'account_email' => $this->get_addresspart($_sender,'email'), |
218 | 229 | 'account_fullname' => $this->get_addresspart($_sender,'fullname'), |
@@ -230,9 +241,11 @@ discard block |
||
230 | 241 | * as long as the accounts class isn't a nice object, |
231 | 242 | * it's an array with the int of the account id or the e-mail address of a non-eGW user |
232 | 243 | */ |
233 | - public function set_receivers(array $_receivers) { |
|
244 | + public function set_receivers(array $_receivers) |
|
245 | + { |
|
234 | 246 | $this->receivers = array(); |
235 | - foreach ($_receivers as $receiver) { |
|
247 | + foreach ($_receivers as $receiver) |
|
248 | + { |
|
236 | 249 | $this->add_receiver($receiver); |
237 | 250 | } |
238 | 251 | } |
@@ -244,17 +257,23 @@ discard block |
||
244 | 257 | * as long as the accounts class isn't a nice object, |
245 | 258 | * it's an int with the account id or the e-mail address of a non-eGW user |
246 | 259 | */ |
247 | - public function add_receiver($_receiver) { |
|
248 | - if(is_object($_receiver)) { |
|
260 | + public function add_receiver($_receiver) |
|
261 | + { |
|
262 | + if(is_object($_receiver)) |
|
263 | + { |
|
249 | 264 | $this->receivers[] = $_receiver; |
250 | 265 | return true; |
251 | - } else { |
|
266 | + } |
|
267 | + else |
|
268 | + { |
|
252 | 269 | // no object atm, we have to handle this and make a pseudo-object |
253 | - if(is_numeric($_receiver)) { |
|
270 | + if(is_numeric($_receiver)) |
|
271 | + { |
|
254 | 272 | $this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver); |
255 | 273 | return true; |
256 | 274 | } |
257 | - if(is_string($_receiver) && strpos($_receiver,'@')) { |
|
275 | + if(is_string($_receiver) && strpos($_receiver,'@')) |
|
276 | + { |
|
258 | 277 | $this->receivers[] = (object) array ( |
259 | 278 | 'account_email' => $this->get_addresspart($_receiver,'email'), |
260 | 279 | 'account_fullname' => $this->get_addresspart($_receiver,'fullname'), |
@@ -270,7 +289,8 @@ discard block |
||
270 | 289 | * |
271 | 290 | * @param string $_subject |
272 | 291 | */ |
273 | - public function set_subject($_subject) { |
|
292 | + public function set_subject($_subject) |
|
293 | + { |
|
274 | 294 | $this->subject = $_subject; |
275 | 295 | return true; |
276 | 296 | } |
@@ -280,7 +300,8 @@ discard block |
||
280 | 300 | * |
281 | 301 | * @param string $_subject |
282 | 302 | */ |
283 | - public function set_popupsubject($_subject) { |
|
303 | + public function set_popupsubject($_subject) |
|
304 | + { |
|
284 | 305 | $this->popupsubject = $_subject; |
285 | 306 | return true; |
286 | 307 | } |
@@ -295,10 +316,14 @@ discard block |
||
295 | 316 | * |
296 | 317 | * @param string $_message |
297 | 318 | */ |
298 | - public function set_message($_message) { |
|
299 | - if(strlen($_message) == strlen(strip_tags($_message))) { |
|
319 | + public function set_message($_message) |
|
320 | + { |
|
321 | + if(strlen($_message) == strlen(strip_tags($_message))) |
|
322 | + { |
|
300 | 323 | $this->message_plain = $_message; |
301 | - } else { |
|
324 | + } |
|
325 | + else |
|
326 | + { |
|
302 | 327 | $this->message_html = $_message; |
303 | 328 | } |
304 | 329 | return true; |
@@ -312,9 +337,13 @@ discard block |
||
312 | 337 | * |
313 | 338 | * @param string $_message |
314 | 339 | */ |
315 | - public function set_popupmessage($_message) { |
|
340 | + public function set_popupmessage($_message) |
|
341 | + { |
|
316 | 342 | //popup requires html |
317 | - if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message); |
|
343 | + if(strlen($_message) == strlen(strip_tags($_message))) |
|
344 | + { |
|
345 | + $_message = self::plain2html($_message); |
|
346 | + } |
|
318 | 347 | $this->message_popup = $_message; |
319 | 348 | return true; |
320 | 349 | } |
@@ -324,10 +353,13 @@ discard block |
||
324 | 353 | * |
325 | 354 | * @param array $_links link array (like defined in $this->add_link) |
326 | 355 | */ |
327 | - public function set_links(array $_links) { |
|
356 | + public function set_links(array $_links) |
|
357 | + { |
|
328 | 358 | $this->links = array(); // clear array if set |
329 | - foreach($_links as $link) { |
|
330 | - if(is_array($link)) { |
|
359 | + foreach($_links as $link) |
|
360 | + { |
|
361 | + if(is_array($link)) |
|
362 | + { |
|
331 | 363 | $this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']); |
332 | 364 | } |
333 | 365 | } |
@@ -339,10 +371,13 @@ discard block |
||
339 | 371 | * |
340 | 372 | * @param array $_links link array (like defined in $this->add_link) |
341 | 373 | */ |
342 | - public function set_popuplinks(array $_links) { |
|
374 | + public function set_popuplinks(array $_links) |
|
375 | + { |
|
343 | 376 | $this->popup_links = array(); // clear array if set |
344 | - foreach($_links as $link) { |
|
345 | - if(is_array($link)) { |
|
377 | + foreach($_links as $link) |
|
378 | + { |
|
379 | + if(is_array($link)) |
|
380 | + { |
|
346 | 381 | $this->add_popuplink($link['text'], $link['view'], $link['popup']); |
347 | 382 | } |
348 | 383 | } |
@@ -358,8 +393,11 @@ discard block |
||
358 | 393 | * @param string $_app Application name, to use link registry (popup & view ignored) |
359 | 394 | * @param string $_id Application ID, to use link registry (popup & view ignored) |
360 | 395 | */ |
361 | - public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) { |
|
362 | - if(!$_view || !$_text) { return false; } |
|
396 | + public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) |
|
397 | + { |
|
398 | + if(!$_view || !$_text) |
|
399 | + { |
|
400 | +return false; } |
|
363 | 401 | $this->links[] = (object)array( |
364 | 402 | 'text' => $_text, |
365 | 403 | 'view' => $_view, |
@@ -377,8 +415,11 @@ discard block |
||
377 | 415 | * @param array $_view all params needed to view the link (name => value pairs) |
378 | 416 | * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false |
379 | 417 | */ |
380 | - public function add_popuplink($_text, $_view, $_popup = false) { |
|
381 | - if(!$_view || !$_text) { return false; } |
|
418 | + public function add_popuplink($_text, $_view, $_popup = false) |
|
419 | + { |
|
420 | + if(!$_view || !$_text) |
|
421 | + { |
|
422 | +return false; } |
|
382 | 423 | $this->popup_links[] = (object)array( 'text' => $_text, |
383 | 424 | 'view' => $_view, |
384 | 425 | 'popup' => $_popup, |
@@ -391,10 +432,13 @@ discard block |
||
391 | 432 | * |
392 | 433 | * @param array $_attachments attachment array (like defined in $this->add_attachment) |
393 | 434 | */ |
394 | - public function set_attachments(array $_attachments) { |
|
435 | + public function set_attachments(array $_attachments) |
|
436 | + { |
|
395 | 437 | $this->attachments = array(); // clear array if set |
396 | - foreach($_attachments as $attachment) { |
|
397 | - if(is_array($attachment)) { |
|
438 | + foreach($_attachments as $attachment) |
|
439 | + { |
|
440 | + if(is_array($attachment)) |
|
441 | + { |
|
398 | 442 | $this->add_attachment( |
399 | 443 | $attachment['string'], |
400 | 444 | $attachment['filename'], |
@@ -418,8 +462,12 @@ discard block |
||
418 | 462 | * @param string $_type File extension (MIME) type. |
419 | 463 | * @param string $_path optional path to attachment, if !$_string |
420 | 464 | */ |
421 | - public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) { |
|
422 | - if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false; |
|
465 | + public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) |
|
466 | + { |
|
467 | + if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) |
|
468 | + { |
|
469 | + return false; |
|
470 | + } |
|
423 | 471 | $this->attachments[] = (object)array( |
424 | 472 | 'string' => $_string, |
425 | 473 | 'filename' => $_filename, |
@@ -437,33 +485,40 @@ discard block |
||
437 | 485 | * @param array $_skip_backends array with names of the backends to be skipped |
438 | 486 | * e.g. array('popup', 'winpopup') |
439 | 487 | */ |
440 | - public function set_skip_backends(array $_skip_backends) { |
|
488 | + public function set_skip_backends(array $_skip_backends) |
|
489 | + { |
|
441 | 490 | $this->skip_backends = $_skip_backends; |
442 | 491 | } |
443 | 492 | |
444 | 493 | /** |
445 | 494 | * sends notifications |
446 | 495 | */ |
447 | - public function send() { |
|
448 | - if (!is_object($this->sender)) { |
|
496 | + public function send() |
|
497 | + { |
|
498 | + if (!is_object($this->sender)) |
|
499 | + { |
|
449 | 500 | throw new Exception('Error: cannot send notifications. No sender supplied'); |
450 | 501 | } |
451 | - if (!is_array($this->receivers) || count($this->receivers) == 0) { |
|
502 | + if (!is_array($this->receivers) || count($this->receivers) == 0) |
|
503 | + { |
|
452 | 504 | throw new Exception('Error: cannot send notifications. No receivers supplied'); |
453 | 505 | } |
454 | - if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) { |
|
506 | + if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) |
|
507 | + { |
|
455 | 508 | throw new Exception('Error: cannot send notifications. No valid messages supplied'); |
456 | 509 | } |
457 | 510 | |
458 | 511 | $available_chains = $this->get_available_chains('routing'); |
459 | 512 | |
460 | - foreach ($this->receivers as $receiver) { |
|
513 | + foreach ($this->receivers as $receiver) |
|
514 | + { |
|
461 | 515 | $user_notified = false; |
462 | 516 | $prepend_message = ''; |
463 | 517 | $backend_errors = array(); |
464 | 518 | try { |
465 | 519 | // system or non-system user |
466 | - if($receiver->account_id && is_numeric($receiver->account_id)) { |
|
520 | + if($receiver->account_id && is_numeric($receiver->account_id)) |
|
521 | + { |
|
467 | 522 | // system user, collect data and check for Status and expire state, skip notification if expired or not active |
468 | 523 | $userData = $GLOBALS['egw']->accounts->read($receiver->account_id); |
469 | 524 | //error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#'); |
@@ -478,51 +533,65 @@ discard block |
||
478 | 533 | // check if the receiver has rights to run the notifcation app |
479 | 534 | $ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true); |
480 | 535 | $ids[] = $receiver->account_id; |
481 | - if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) { |
|
536 | + if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) |
|
537 | + { |
|
482 | 538 | // read the users notification chain |
483 | 539 | $prefs = new Api\Preferences($receiver->account_id); |
484 | 540 | $preferences_all = $prefs->read(); |
485 | 541 | $preferences = (object)$preferences_all[self::_appname]; |
486 | - if($preferences->notification_chain) { |
|
542 | + if($preferences->notification_chain) |
|
543 | + { |
|
487 | 544 | // fallback: admin disabled user-chosen chain |
488 | - if(!$notification_chain = $available_chains[$preferences->notification_chain]) { |
|
545 | + if(!$notification_chain = $available_chains[$preferences->notification_chain]) |
|
546 | + { |
|
489 | 547 | $prepend_message .= lang( 'This eGroupWare notification has been sent to you by mail because your' |
490 | 548 | .' chosen notification-chain has been disabled by the administrator.' |
491 | 549 | .' Please choose another notification-chain in your preferences!'); |
492 | 550 | $notification_chain = $available_chains[self::_fallback]; |
493 | 551 | } |
494 | - } else { |
|
552 | + } |
|
553 | + else |
|
554 | + { |
|
495 | 555 | $notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs |
496 | 556 | } |
497 | - } else { |
|
557 | + } |
|
558 | + else |
|
559 | + { |
|
498 | 560 | $notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app |
499 | 561 | } |
500 | - } else { |
|
562 | + } |
|
563 | + else |
|
564 | + { |
|
501 | 565 | // non-system user |
502 | 566 | $receiver->handle = $receiver->account_email; |
503 | 567 | $notification_chain = $available_chains[self::_fallback]; // fallback: non-system user |
504 | 568 | } |
505 | 569 | |
506 | - if($notification_chain == 'disable') { |
|
570 | + if($notification_chain == 'disable') |
|
571 | + { |
|
507 | 572 | continue; //user disabled notifications |
508 | 573 | } |
509 | 574 | |
510 | - foreach($notification_chain as $backend => $action) { |
|
575 | + foreach($notification_chain as $backend => $action) |
|
576 | + { |
|
511 | 577 | $notification_backend = null; |
512 | 578 | try { |
513 | 579 | // check if backend should be skipped |
514 | - if( in_array($backend, $this->skip_backends) ) { |
|
580 | + if( in_array($backend, $this->skip_backends) ) |
|
581 | + { |
|
515 | 582 | // log as error just for the case too much skipping prevents user from being notified |
516 | 583 | $backend_errors[] = $backend.' will be skipped (as defined by calling application)'; |
517 | 584 | continue; |
518 | 585 | } |
519 | 586 | |
520 | 587 | $notification_backend = self::_appname.'_'.$backend; |
521 | - if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) { |
|
588 | + if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) |
|
589 | + { |
|
522 | 590 | throw new Exception('file for '.$notification_backend. ' does not exist'); |
523 | 591 | } |
524 | 592 | $obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences ); |
525 | - if ( !($obj instanceof notifications_iface) ) { |
|
593 | + if ( !($obj instanceof notifications_iface) ) |
|
594 | + { |
|
526 | 595 | unset ( $obj ); |
527 | 596 | throw new Exception($notification_backend. ' is no implementation of notifications_iface'); |
528 | 597 | } |
@@ -530,31 +599,44 @@ discard block |
||
530 | 599 | $llinks = $this->links; |
531 | 600 | if ($backend == 'popup') |
532 | 601 | { |
533 | - if (!empty($this->popupsubject)) $lsubject = $this->popupsubject; |
|
534 | - if ($this->popup_links) $llinks = $this->popup_links; |
|
602 | + if (!empty($this->popupsubject)) |
|
603 | + { |
|
604 | + $lsubject = $this->popupsubject; |
|
605 | + } |
|
606 | + if ($this->popup_links) |
|
607 | + { |
|
608 | + $llinks = $this->popup_links; |
|
609 | + } |
|
535 | 610 | } |
536 | 611 | $obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments); |
537 | 612 | } |
538 | 613 | catch (Exception $exception) { |
539 | 614 | $backend_errors[] = $notification_backend.' failed: '.$exception->getMessage(); |
540 | 615 | // try next backend |
541 | - if($action == 'fail' || $action == 'continue') { |
|
616 | + if($action == 'fail' || $action == 'continue') |
|
617 | + { |
|
542 | 618 | continue; |
543 | 619 | } |
544 | 620 | break; // stop running through chain |
545 | 621 | } |
546 | 622 | // backend sucseeded |
547 | 623 | $user_notified = true; |
548 | - if($action == 'stop' || $action == 'fail') { break; } // stop running through chain |
|
624 | + if($action == 'stop' || $action == 'fail') |
|
625 | + { |
|
626 | +break; } // stop running through chain |
|
549 | 627 | } |
550 | 628 | // check if the user has been notified at all |
551 | - if(!$user_notified) { |
|
629 | + if(!$user_notified) |
|
630 | + { |
|
552 | 631 | /*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:'); |
553 | 632 | foreach($backend_errors as $id=>$backend_error) { |
554 | 633 | error_log($backend_error); |
555 | 634 | }*/ |
556 | 635 | $error = implode(', ', $backend_errors); |
557 | - if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error; |
|
636 | + if (stripos($error, (string)$receiver->handle) !== false) |
|
637 | + { |
|
638 | + $error = $receiver->handle.': '.$error; |
|
639 | + } |
|
558 | 640 | self::$errors[] = $error; |
559 | 641 | } |
560 | 642 | } |
@@ -574,23 +656,35 @@ discard block |
||
574 | 656 | * @param string $_message_popup |
575 | 657 | * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup'] |
576 | 658 | */ |
577 | - private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') { |
|
578 | - if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set |
|
659 | + private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') |
|
660 | + { |
|
661 | + if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) |
|
662 | + { |
|
663 | +return false; } // no message set |
|
579 | 664 | $messages = array(); |
580 | 665 | |
581 | 666 | // create the messages |
582 | - if(!empty($_message_plain)) { |
|
667 | + if(!empty($_message_plain)) |
|
668 | + { |
|
583 | 669 | $messages['plain'] = $_message_plain; |
584 | - } else { |
|
670 | + } |
|
671 | + else |
|
672 | + { |
|
585 | 673 | $messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true); |
586 | 674 | } |
587 | 675 | |
588 | - if(!empty($_message_html)) { |
|
676 | + if(!empty($_message_html)) |
|
677 | + { |
|
589 | 678 | $messages['html'] = $_message_html; |
590 | - } else { |
|
679 | + } |
|
680 | + else |
|
681 | + { |
|
591 | 682 | $messages['html'] = self::plain2html($_message_plain); |
592 | 683 | } |
593 | - if (!empty($_message_popup)) $messages['popup']=$_message_popup; |
|
684 | + if (!empty($_message_popup)) |
|
685 | + { |
|
686 | + $messages['popup']=$_message_popup; |
|
687 | + } |
|
594 | 688 | return $messages; |
595 | 689 | } |
596 | 690 | |
@@ -612,10 +706,14 @@ discard block |
||
612 | 706 | * @param string $_prepend just a plain message to prepend, no html! |
613 | 707 | * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html'] |
614 | 708 | */ |
615 | - private function prepend_message(array $_messages, $_prepend = null) { |
|
616 | - if(strlen($_prepend) > 0) { |
|
617 | - foreach($_messages as $key => $value) { |
|
618 | - switch($key) { |
|
709 | + private function prepend_message(array $_messages, $_prepend = null) |
|
710 | + { |
|
711 | + if(strlen($_prepend) > 0) |
|
712 | + { |
|
713 | + foreach($_messages as $key => $value) |
|
714 | + { |
|
715 | + switch($key) |
|
716 | + { |
|
619 | 717 | case 'plain': |
620 | 718 | $_messages[$key] = $_prepend."\n\n".$value; |
621 | 719 | break; |
@@ -642,14 +740,19 @@ discard block |
||
642 | 740 | private function get_addresspart($_address, $_part='email') |
643 | 741 | { |
644 | 742 | $parts = null; |
645 | - if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part |
|
743 | + if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) |
|
744 | + { |
|
745 | +// _address contains a fullname part |
|
646 | 746 | $fullname = trim(trim($parts[1]),'\"'); |
647 | 747 | $email = $parts[2]; |
648 | - } else { |
|
748 | + } |
|
749 | + else |
|
750 | + { |
|
649 | 751 | $fullname = false; |
650 | 752 | $email = $_address; |
651 | 753 | } |
652 | - switch($_part) { |
|
754 | + switch($_part) |
|
755 | + { |
|
653 | 756 | case 'fullname': |
654 | 757 | return $fullname; |
655 | 758 | case 'email': |
@@ -668,11 +771,14 @@ discard block |
||
668 | 771 | * @param string $_output one of: 'routing' or 'human', defaults to 'routing' |
669 | 772 | * @return array containing notification chains, output like given in $_output |
670 | 773 | */ |
671 | - public function get_available_chains($_output = 'routing') { |
|
774 | + public function get_available_chains($_output = 'routing') |
|
775 | + { |
|
672 | 776 | // determine enabled backends from Api\Config |
673 | 777 | $enabled_backends = array(); |
674 | - foreach($this->backends as $backend) { |
|
675 | - switch($backend) { |
|
778 | + foreach($this->backends as $backend) |
|
779 | + { |
|
780 | + switch($backend) |
|
781 | + { |
|
676 | 782 | case 'email': |
677 | 783 | case 'popup': |
678 | 784 | case 'jpopup': |
@@ -687,17 +793,24 @@ discard block |
||
687 | 793 | |
688 | 794 | $enabled_chains = array(); |
689 | 795 | $disabled_chains = array(); |
690 | - foreach($this->notification_chains as $key => $chain) { |
|
796 | + foreach($this->notification_chains as $key => $chain) |
|
797 | + { |
|
691 | 798 | $allow_chain = true; |
692 | - if(is_array($chain)) { |
|
693 | - foreach(array_keys($chain) as $name) { |
|
694 | - if(!$enabled_backends[$name]) { |
|
799 | + if(is_array($chain)) |
|
800 | + { |
|
801 | + foreach(array_keys($chain) as $name) |
|
802 | + { |
|
803 | + if(!$enabled_backends[$name]) |
|
804 | + { |
|
695 | 805 | $allow_chain = false; // disable whole chain if one backend is disabled |
696 | 806 | } |
697 | 807 | } |
698 | - if($allow_chain) { |
|
808 | + if($allow_chain) |
|
809 | + { |
|
699 | 810 | $enabled_chains[$key] = $chain; |
700 | - } else { |
|
811 | + } |
|
812 | + else |
|
813 | + { |
|
701 | 814 | $disabled_chains[$key] = $chain; |
702 | 815 | } |
703 | 816 | } |
@@ -710,15 +823,18 @@ discard block |
||
710 | 823 | // create the 'all' chain from the enabled backends |
711 | 824 | $chain_all = array(); |
712 | 825 | $backend_count = 1; |
713 | - foreach($enabled_backends as $backend => $enabled) { |
|
714 | - if($enabled) { |
|
826 | + foreach($enabled_backends as $backend => $enabled) |
|
827 | + { |
|
828 | + if($enabled) |
|
829 | + { |
|
715 | 830 | $chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue'; |
716 | 831 | } |
717 | 832 | $backend_count++; |
718 | 833 | } |
719 | 834 | $common_chains['all'] = $chain_all; |
720 | 835 | |
721 | - switch($_output) { |
|
836 | + switch($_output) |
|
837 | + { |
|
722 | 838 | case 'human': |
723 | 839 | $chain_groups = array( |
724 | 840 | lang('Common chains') => 'common_chains', |
@@ -727,20 +843,27 @@ discard block |
||
727 | 843 | ); |
728 | 844 | $suffix = '_human'; |
729 | 845 | // create descriptions for each chain key in each group |
730 | - foreach($chain_groups as $name => $arr_name) { |
|
846 | + foreach($chain_groups as $name => $arr_name) |
|
847 | + { |
|
731 | 848 | ${$arr_name.$suffix} = array(); |
732 | - foreach(array_keys(${$arr_name}) as $key) { |
|
733 | - if($arr_name == 'disabled_chains') { |
|
849 | + foreach(array_keys(${$arr_name}) as $key) |
|
850 | + { |
|
851 | + if($arr_name == 'disabled_chains') |
|
852 | + { |
|
734 | 853 | ${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]); |
735 | - } else { |
|
854 | + } |
|
855 | + else |
|
856 | + { |
|
736 | 857 | ${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]); |
737 | 858 | } |
738 | 859 | } |
739 | 860 | } |
740 | 861 | // summarize all groups with minimum one chain to the final array |
741 | 862 | $chains_final = array(); |
742 | - foreach($chain_groups as $name => $arr_name) { |
|
743 | - if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) { |
|
863 | + foreach($chain_groups as $name => $arr_name) |
|
864 | + { |
|
865 | + if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) |
|
866 | + { |
|
744 | 867 | $chains_final[$name] = ${$arr_name.$suffix}; |
745 | 868 | } |
746 | 869 | } |
@@ -759,10 +882,13 @@ discard block |
||
759 | 882 | * |
760 | 883 | * @param settings array with keys account_id and new_owner (new_owner is optional) |
761 | 884 | */ |
762 | - public function deleteaccount($settings) { |
|
763 | - foreach($this->backends as $backend) { |
|
885 | + public function deleteaccount($settings) |
|
886 | + { |
|
887 | + foreach($this->backends as $backend) |
|
888 | + { |
|
764 | 889 | $backend_hook = array(self::_appname.'_'.$backend,'deleteaccount'); |
765 | - if (is_callable($backend_hook)) { |
|
890 | + if (is_callable($backend_hook)) |
|
891 | + { |
|
766 | 892 | call_user_func($backend_hook,$settings); |
767 | 893 | } |
768 | 894 | } |
@@ -131,7 +131,7 @@ |
||
131 | 131 | * @param array $_links |
132 | 132 | * @param boolean $_render_html |
133 | 133 | * @param boolean $_render_external |
134 | - * @return plain or html rendered link(s) as complete string |
|
134 | + * @return false|string or html rendered link(s) as complete string |
|
135 | 135 | */ |
136 | 136 | private function render_links($_links = false, $_render_html = false, $_render_external = true) { |
137 | 137 | if(!is_array($_links) || count($_links) == 0) { return false; } |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | * @param object $_preferences |
67 | 67 | */ |
68 | 68 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
69 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
70 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
69 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
70 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
71 | 71 | $this->sender = $_sender; |
72 | 72 | $this->recipient = $_recipient; |
73 | 73 | $this->config = $_config; |
74 | 74 | $this->preferences = $_preferences; |
75 | - if(is_object($this->mail)) |
|
75 | + if (is_object($this->mail)) |
|
76 | 76 | { |
77 | 77 | unset($this->mail); |
78 | 78 | } |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | $this->mail->setFrom($this->sender->account_email, $this->sender->account_fullname); |
105 | 105 | |
106 | 106 | $this->mail->addHeader('Subject', trim($_subject)); // trim the subject to avoid strange wrong encoding problem |
107 | - $this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ |
|
107 | + $this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ |
|
108 | 108 | $this->mail->setBody($body_plain); |
109 | 109 | |
110 | - if(is_array($_attachments) && count($_attachments) > 0) |
|
110 | + if (is_array($_attachments) && count($_attachments) > 0) |
|
111 | 111 | { |
112 | - foreach($_attachments as $attachment) |
|
112 | + foreach ($_attachments as $attachment) |
|
113 | 113 | { |
114 | 114 | if ($attachment->string) |
115 | 115 | { |
116 | 116 | $this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type); |
117 | 117 | } |
118 | - elseif($attachment->path) |
|
118 | + elseif ($attachment->path) |
|
119 | 119 | { |
120 | 120 | $this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type); |
121 | 121 | } |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | * @return plain or html rendered link(s) as complete string |
135 | 135 | */ |
136 | 136 | private function render_links($_links = false, $_render_html = false, $_render_external = true) { |
137 | - if(!is_array($_links) || count($_links) == 0) { return false; } |
|
137 | + if (!is_array($_links) || count($_links) == 0) { return false; } |
|
138 | 138 | |
139 | 139 | // provide defaults if given arguments are null |
140 | 140 | // php distinguishes between missing and present(null) arguments |
141 | - if(is_null($_render_html)) { $_render_html = false; } |
|
142 | - if(is_null($_render_external)) { $_render_external = true; } |
|
141 | + if (is_null($_render_html)) { $_render_html = false; } |
|
142 | + if (is_null($_render_external)) { $_render_external = true; } |
|
143 | 143 | $newline = $_render_html ? "<br />" : "\n"; |
144 | 144 | $hruler = $_render_html ? Api\Html::hr() : ''; |
145 | 145 | |
146 | 146 | $rendered_links = array(); |
147 | - foreach($_links as $link) { |
|
148 | - if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; } |
|
147 | + foreach ($_links as $link) { |
|
148 | + if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; } |
|
149 | 149 | // do not expose sensitive data |
150 | - $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view)); |
|
150 | + $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', Api\Html::link('/index.php', $link->view)); |
|
151 | 151 | // complete missing protocol and domain part if needed |
152 | 152 | if ($url{0} == '/' && $_render_external) { |
153 | 153 | $url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://'). |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $rendered_links[] = $_render_html ? $a_href : $url; |
158 | 158 | } |
159 | 159 | |
160 | - return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links); |
|
160 | + return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * User notification via email. |
17 | 17 | */ |
18 | -class notifications_email implements notifications_iface { |
|
18 | +class notifications_email implements notifications_iface |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Appname |
@@ -65,9 +66,14 @@ discard block |
||
65 | 66 | * @param object $_config |
66 | 67 | * @param object $_preferences |
67 | 68 | */ |
68 | - public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
|
69 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
70 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
69 | + public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
|
70 | + { |
|
71 | + if(!is_object($_sender)) |
|
72 | + { |
|
73 | +throw new Exception("no sender given."); } |
|
74 | + if(!is_object($_recipient)) |
|
75 | + { |
|
76 | +throw new Exception("no recipient given."); } |
|
71 | 77 | $this->sender = $_sender; |
72 | 78 | $this->recipient = $_recipient; |
73 | 79 | $this->config = $_config; |
@@ -133,23 +139,34 @@ discard block |
||
133 | 139 | * @param boolean $_render_external |
134 | 140 | * @return plain or html rendered link(s) as complete string |
135 | 141 | */ |
136 | - private function render_links($_links = false, $_render_html = false, $_render_external = true) { |
|
137 | - if(!is_array($_links) || count($_links) == 0) { return false; } |
|
142 | + private function render_links($_links = false, $_render_html = false, $_render_external = true) |
|
143 | + { |
|
144 | + if(!is_array($_links) || count($_links) == 0) |
|
145 | + { |
|
146 | +return false; } |
|
138 | 147 | |
139 | 148 | // provide defaults if given arguments are null |
140 | 149 | // php distinguishes between missing and present(null) arguments |
141 | - if(is_null($_render_html)) { $_render_html = false; } |
|
142 | - if(is_null($_render_external)) { $_render_external = true; } |
|
150 | + if(is_null($_render_html)) |
|
151 | + { |
|
152 | +$_render_html = false; } |
|
153 | + if(is_null($_render_external)) |
|
154 | + { |
|
155 | +$_render_external = true; } |
|
143 | 156 | $newline = $_render_html ? "<br />" : "\n"; |
144 | 157 | $hruler = $_render_html ? Api\Html::hr() : ''; |
145 | 158 | |
146 | 159 | $rendered_links = array(); |
147 | - foreach($_links as $link) { |
|
148 | - if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; } |
|
160 | + foreach($_links as $link) |
|
161 | + { |
|
162 | + if($_render_external || ! $link->popup) |
|
163 | + { |
|
164 | +$link->view['no_popup'] = 1; } |
|
149 | 165 | // do not expose sensitive data |
150 | 166 | $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view)); |
151 | 167 | // complete missing protocol and domain part if needed |
152 | - if ($url{0} == '/' && $_render_external) { |
|
168 | + if ($url{0} == '/' && $_render_external) |
|
169 | + { |
|
153 | 170 | $url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://'). |
154 | 171 | ($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$url; |
155 | 172 | } |
@@ -152,7 +152,6 @@ |
||
152 | 152 | * saves notification into database so that the client can fetch it from there |
153 | 153 | * |
154 | 154 | * @param string $_message |
155 | - * @param array $_user_sessions |
|
156 | 155 | */ |
157 | 156 | private function save( $_message ) { |
158 | 157 | $result = $this->db->insert( self::_notification_table, array( |
@@ -15,63 +15,63 @@ discard block |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | /** |
18 | - * Appname |
|
19 | - */ |
|
18 | + * Appname |
|
19 | + */ |
|
20 | 20 | const _appname = 'notifications'; |
21 | 21 | |
22 | 22 | /** |
23 | - * Notification table in SQL database |
|
24 | - */ |
|
23 | + * Notification table in SQL database |
|
24 | + */ |
|
25 | 25 | const _notification_table = 'egw_notificationpopup'; |
26 | 26 | |
27 | 27 | /** |
28 | - * Notification type |
|
29 | - */ |
|
28 | + * Notification type |
|
29 | + */ |
|
30 | 30 | const _type = 'jpopup'; |
31 | 31 | |
32 | 32 | /** |
33 | - * holds account object for user who sends the message |
|
34 | - * |
|
35 | - * @var object |
|
36 | - */ |
|
33 | + * holds account object for user who sends the message |
|
34 | + * |
|
35 | + * @var object |
|
36 | + */ |
|
37 | 37 | private $sender; |
38 | 38 | |
39 | 39 | /** |
40 | - * holds account object for user to notify |
|
41 | - * |
|
42 | - * @var object |
|
43 | - */ |
|
40 | + * holds account object for user to notify |
|
41 | + * |
|
42 | + * @var object |
|
43 | + */ |
|
44 | 44 | private $recipient; |
45 | 45 | |
46 | 46 | /** |
47 | - * holds config object (sitewide application config) |
|
48 | - * |
|
49 | - * @var object |
|
50 | - */ |
|
47 | + * holds config object (sitewide application config) |
|
48 | + * |
|
49 | + * @var object |
|
50 | + */ |
|
51 | 51 | private $config; |
52 | 52 | |
53 | 53 | /** |
54 | - * holds preferences object of user to notify |
|
55 | - * |
|
56 | - * @var object |
|
57 | - */ |
|
54 | + * holds preferences object of user to notify |
|
55 | + * |
|
56 | + * @var object |
|
57 | + */ |
|
58 | 58 | private $preferences; |
59 | 59 | |
60 | 60 | /** |
61 | - * holds db object of SQL database |
|
62 | - * |
|
63 | - * @var Api\Db |
|
64 | - */ |
|
61 | + * holds db object of SQL database |
|
62 | + * |
|
63 | + * @var Api\Db |
|
64 | + */ |
|
65 | 65 | private $db; |
66 | 66 | |
67 | 67 | /** |
68 | - * constructor of notifications_egwpopup |
|
69 | - * |
|
70 | - * @param object $_sender |
|
71 | - * @param object $_recipient |
|
72 | - * @param object $_config |
|
73 | - * @param object $_preferences |
|
74 | - */ |
|
68 | + * constructor of notifications_egwpopup |
|
69 | + * |
|
70 | + * @param object $_sender |
|
71 | + * @param object $_recipient |
|
72 | + * @param object $_config |
|
73 | + * @param object $_preferences |
|
74 | + */ |
|
75 | 75 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
76 | 76 | { |
77 | 77 | if( !is_object($_sender) ) { throw new Exception("no sender given."); } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | - * sends notification if user is online |
|
89 | - * |
|
90 | - * @param array $_messages |
|
91 | - * @param string $_subject |
|
92 | - * @param array $_links |
|
93 | - * @param array $_attachments |
|
94 | - */ |
|
88 | + * sends notification if user is online |
|
89 | + * |
|
90 | + * @param array $_messages |
|
91 | + * @param string $_subject |
|
92 | + * @param array $_links |
|
93 | + * @param array $_attachments |
|
94 | + */ |
|
95 | 95 | public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false) |
96 | 96 | { |
97 | 97 | unset($_attachments); // not used |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * renders additional infos from sender and subject |
|
137 | - * |
|
138 | - * @param string $_subject |
|
139 | - * @return string html rendered info as complete string |
|
140 | - */ |
|
136 | + * renders additional infos from sender and subject |
|
137 | + * |
|
138 | + * @param string $_subject |
|
139 | + * @return string html rendered info as complete string |
|
140 | + */ |
|
141 | 141 | private function render_infos($_subject = false) { |
142 | 142 | $infos = array(); |
143 | 143 | $newline = "<br />"; |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | - * saves notification into database so that the client can fetch it from there |
|
153 | - * |
|
154 | - * @param string $_message |
|
155 | - * @param array $_user_sessions |
|
156 | - */ |
|
152 | + * saves notification into database so that the client can fetch it from there |
|
153 | + * |
|
154 | + * @param string $_message |
|
155 | + * @param array $_user_sessions |
|
156 | + */ |
|
157 | 157 | private function save( $_message ) { |
158 | 158 | $result = $this->db->insert( self::_notification_table, array( |
159 | 159 | 'account_id' => $this->recipient->account_id, |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
76 | 76 | { |
77 | - if( !is_object($_sender) ) { throw new Exception("no sender given."); } |
|
78 | - if( !is_object($_recipient) ) { throw new Exception("no recipient given."); } |
|
77 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
78 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
79 | 79 | |
80 | 80 | $this->sender = $_sender; |
81 | - $this->recipient = $_recipient; |
|
81 | + $this->recipient = $_recipient; |
|
82 | 82 | $this->config = $_config; |
83 | - $this->preferences = $_preferences; |
|
84 | - $this->db = $GLOBALS['egw']->db; |
|
83 | + $this->preferences = $_preferences; |
|
84 | + $this->db = $GLOBALS['egw']->db; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @param array $_links |
93 | 93 | * @param array $_attachments |
94 | 94 | */ |
95 | - public function send(array $_messages, $_subject=false, $_links=false, $_attachments=false) |
|
95 | + public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) |
|
96 | 96 | { |
97 | - unset($_attachments); // not used |
|
97 | + unset($_attachments); // not used |
|
98 | 98 | |
99 | 99 | $jmessage = array(); |
100 | 100 | |
101 | 101 | // app-message |
102 | - if( ($_links != null) && (count($_links) > 0) ) |
|
102 | + if (($_links != null) && (count($_links) > 0)) |
|
103 | 103 | { |
104 | - $tlink = $_links[0]; |
|
105 | - $appname = ""; |
|
104 | + $tlink = $_links[0]; |
|
105 | + $appname = ""; |
|
106 | 106 | |
107 | - if( key_exists('menuaction', $tlink->view) ) |
|
107 | + if (key_exists('menuaction', $tlink->view)) |
|
108 | 108 | { |
109 | 109 | $tmp = explode(".", $tlink->view['menuaction']); |
110 | 110 | $appname = $tmp[0]; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | $link = array(); |
114 | 114 | |
115 | - foreach( $tlink->view as $pkey => $pvalue ) |
|
115 | + foreach ($tlink->view as $pkey => $pvalue) |
|
116 | 116 | { |
117 | - $link[] = $pkey . '=' . $pvalue; |
|
117 | + $link[] = $pkey.'='.$pvalue; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // TODO more links? |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | .Api\Html::hr() |
126 | 126 | .$_messages['html']; |
127 | 127 | |
128 | - $jmessage['msghtml'] = $message; |
|
129 | - $jmessage['app'] = $appname; |
|
128 | + $jmessage['msghtml'] = $message; |
|
129 | + $jmessage['app'] = $appname; |
|
130 | 130 | |
131 | 131 | |
132 | - $this->save( serialize($jmessage) ); |
|
132 | + $this->save(serialize($jmessage)); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | |
145 | 145 | $sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email; |
146 | 146 | $infos[] = lang('Message from').': '.$sender; |
147 | - if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); } |
|
148 | - return implode($newline,$infos); |
|
147 | + if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); } |
|
148 | + return implode($newline, $infos); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | * @param string $_message |
155 | 155 | * @param array $_user_sessions |
156 | 156 | */ |
157 | - private function save( $_message ) { |
|
158 | - $result = $this->db->insert( self::_notification_table, array( |
|
157 | + private function save($_message) { |
|
158 | + $result = $this->db->insert(self::_notification_table, array( |
|
159 | 159 | 'account_id' => $this->recipient->account_id, |
160 | 160 | 'notify_message' => $_message, |
161 | 161 | 'notify_type' => self::_type |
162 | - ), false,__LINE__,__FILE__,self::_appname); |
|
162 | + ), false, __LINE__, __FILE__, self::_appname); |
|
163 | 163 | if ($result === false) throw new Exception("Can't save notification into SQL table"); |
164 | 164 | } |
165 | 165 | } |
@@ -74,8 +74,12 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
76 | 76 | { |
77 | - if( !is_object($_sender) ) { throw new Exception("no sender given."); } |
|
78 | - if( !is_object($_recipient) ) { throw new Exception("no recipient given."); } |
|
77 | + if( !is_object($_sender) ) |
|
78 | + { |
|
79 | +throw new Exception("no sender given."); } |
|
80 | + if( !is_object($_recipient) ) |
|
81 | + { |
|
82 | +throw new Exception("no recipient given."); } |
|
79 | 83 | |
80 | 84 | $this->sender = $_sender; |
81 | 85 | $this->recipient = $_recipient; |
@@ -138,13 +142,16 @@ discard block |
||
138 | 142 | * @param string $_subject |
139 | 143 | * @return string html rendered info as complete string |
140 | 144 | */ |
141 | - private function render_infos($_subject = false) { |
|
145 | + private function render_infos($_subject = false) |
|
146 | + { |
|
142 | 147 | $infos = array(); |
143 | 148 | $newline = "<br />"; |
144 | 149 | |
145 | 150 | $sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email; |
146 | 151 | $infos[] = lang('Message from').': '.$sender; |
147 | - if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); } |
|
152 | + if(!empty($_subject)) |
|
153 | + { |
|
154 | +$infos[] = Api\Html::bold($_subject); } |
|
148 | 155 | return implode($newline,$infos); |
149 | 156 | } |
150 | 157 | |
@@ -154,12 +161,16 @@ discard block |
||
154 | 161 | * @param string $_message |
155 | 162 | * @param array $_user_sessions |
156 | 163 | */ |
157 | - private function save( $_message ) { |
|
164 | + private function save( $_message ) |
|
165 | + { |
|
158 | 166 | $result = $this->db->insert( self::_notification_table, array( |
159 | 167 | 'account_id' => $this->recipient->account_id, |
160 | 168 | 'notify_message' => $_message, |
161 | 169 | 'notify_type' => self::_type |
162 | 170 | ), false,__LINE__,__FILE__,self::_appname); |
163 | - if ($result === false) throw new Exception("Can't save notification into SQL table"); |
|
171 | + if ($result === false) |
|
172 | + { |
|
173 | + throw new Exception("Can't save notification into SQL table"); |
|
174 | + } |
|
164 | 175 | } |
165 | 176 | } |
@@ -121,7 +121,6 @@ |
||
121 | 121 | * saves notification into database so that the client can fetch it from there |
122 | 122 | * |
123 | 123 | * @param string $_message |
124 | - * @param array $_user_sessions |
|
125 | 124 | */ |
126 | 125 | private function save( $_message ) { |
127 | 126 | $result = $this->db->insert( self::_notification_table, array( |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
85 | 85 | //error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)'); |
86 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
87 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
86 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
87 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
88 | 88 | $this->sender = $_sender; |
89 | 89 | $this->recipient = $_recipient; |
90 | 90 | $this->config = $_config; |
@@ -102,19 +102,19 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) |
104 | 104 | { |
105 | - unset($_attachments); // not used |
|
105 | + unset($_attachments); // not used |
|
106 | 106 | // Check access log to see if user is still logged in |
107 | - if ( !Api\Session::notifications_active($this->recipient->account_id) ) |
|
107 | + if (!Api\Session::notifications_active($this->recipient->account_id)) |
|
108 | 108 | { |
109 | 109 | throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup"); |
110 | 110 | } |
111 | 111 | |
112 | - $message = $this->render_infos($_subject) |
|
112 | + $message = $this->render_infos($_subject) |
|
113 | 113 | .Api\Html::hr() |
114 | - .(isset($_messages['popup'])&&!empty($_messages['popup'])?$_messages['popup']:$_messages['html']) |
|
114 | + .(isset($_messages['popup']) && !empty($_messages['popup']) ? $_messages['popup'] : $_messages['html']) |
|
115 | 115 | .$this->render_links($_links); |
116 | 116 | |
117 | - $this->save( $message ); |
|
117 | + $this->save($message); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | * @param string $_message |
124 | 124 | * @param array $_user_sessions |
125 | 125 | */ |
126 | - private function save( $_message ) { |
|
127 | - $result = $this->db->insert( self::_notification_table, array( |
|
126 | + private function save($_message) { |
|
127 | + $result = $this->db->insert(self::_notification_table, array( |
|
128 | 128 | 'account_id' => $this->recipient->account_id, |
129 | 129 | 'notify_message' => $_message, |
130 | 130 | 'notify_type' => self::_type |
131 | - ), false,__LINE__,__FILE__,self::_appname); |
|
131 | + ), false, __LINE__, __FILE__, self::_appname); |
|
132 | 132 | if ($result === false) throw new Exception("Can't save notification into SQL table"); |
133 | 133 | } |
134 | 134 | |
@@ -140,25 +140,25 @@ discard block |
||
140 | 140 | * @return string html rendered link(s) as complete string with jspopup or a new window |
141 | 141 | */ |
142 | 142 | private function render_links($_links = false) { |
143 | - if(!is_array($_links) || count($_links) == 0) { return false; } |
|
143 | + if (!is_array($_links) || count($_links) == 0) { return false; } |
|
144 | 144 | $newline = "<br />"; |
145 | 145 | |
146 | 146 | $rendered_links = array(); |
147 | - foreach($_links as $link) { |
|
148 | - if(!$link->popup) { $link->view['no_popup'] = 1; } |
|
147 | + foreach ($_links as $link) { |
|
148 | + if (!$link->popup) { $link->view['no_popup'] = 1; } |
|
149 | 149 | |
150 | 150 | // do not expose sensitive data |
151 | - $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','', |
|
151 | + $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', |
|
152 | 152 | Api\Html::link('/index.php', $link->view)); |
153 | 153 | // extract application-icon from menuaction |
154 | - if($link->view['menuaction']) { |
|
155 | - $menuaction_arr = explode('.',$link->view['menuaction']); |
|
154 | + if ($link->view['menuaction']) { |
|
155 | + $menuaction_arr = explode('.', $link->view['menuaction']); |
|
156 | 156 | $application = $menuaction_arr[0]; |
157 | - $image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : ''; |
|
157 | + $image = $application ? Api\Html::image($application, 'navbar', $link->text, 'align="middle" style="width: 24px; margin-right: 0.5em;"') : ''; |
|
158 | 158 | } else { |
159 | 159 | $image = ''; |
160 | 160 | } |
161 | - if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient']) |
|
161 | + if ($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient']) |
|
162 | 162 | { |
163 | 163 | $data = array( |
164 | 164 | "data-app = '{$link->app}'", |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | "data-popup = '{$link->popup}'" |
168 | 168 | ); |
169 | 169 | |
170 | - $rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link'); |
|
170 | + $rendered_links[] = Api\Html::div($image.$link->text, implode(' ', $data), 'link'); |
|
171 | 171 | } else { |
172 | - $rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link'); |
|
172 | + $rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>', '', 'link'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | } |
176 | - if(count($rendered_links) > 0) { |
|
177 | - return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links); |
|
176 | + if (count($rendered_links) > 0) { |
|
177 | + return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline, $rendered_links); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param int $height =400 height of the window |
188 | 188 | * @return string javascript (using single quotes) |
189 | 189 | */ |
190 | - private function jspopup($link,$target='_blank',$width=750,$height=410) |
|
190 | + private function jspopup($link, $target = '_blank', $width = 750, $height = 410) |
|
191 | 191 | { |
192 | - if($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient']) |
|
192 | + if ($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient']) |
|
193 | 193 | { |
194 | 194 | return 'window.open('.($link == 'this.href' ? $link : "'".$link."'").','. |
195 | 195 | ($target == 'this.target' ? $target : "'".$target."'").",$width,$height,'yes')"; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | |
214 | 214 | $sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email; |
215 | 215 | $infos[] = lang('Message from').': '.$sender; |
216 | - if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); } |
|
217 | - return implode($newline,$infos); |
|
216 | + if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); } |
|
217 | + return implode($newline, $infos); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param settings array with keys account_id and new_owner (new_owner is optional) |
224 | 224 | */ |
225 | 225 | public static function deleteaccount($settings) { |
226 | - $GLOBALS['egw']->db->delete( self::_notification_table, array( |
|
226 | + $GLOBALS['egw']->db->delete(self::_notification_table, array( |
|
227 | 227 | 'account_id' => $settings['account_id'] |
228 | - ),__LINE__,__FILE__,self::_appname); |
|
228 | + ), __LINE__, __FILE__, self::_appname); |
|
229 | 229 | } |
230 | 230 | } |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | * out the table to look if there is a notificaton for this |
22 | 22 | * client. The second stage is done in class.notifications_ajax.inc.php |
23 | 23 | */ |
24 | -class notifications_popup implements notifications_iface { |
|
24 | +class notifications_popup implements notifications_iface |
|
25 | +{ |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * Appname |
@@ -81,10 +82,15 @@ discard block |
||
81 | 82 | * @param object $_config |
82 | 83 | * @param object $_preferences |
83 | 84 | */ |
84 | - public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
|
85 | + public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
|
86 | + { |
|
85 | 87 | //error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)'); |
86 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
87 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
88 | + if(!is_object($_sender)) |
|
89 | + { |
|
90 | +throw new Exception("no sender given."); } |
|
91 | + if(!is_object($_recipient)) |
|
92 | + { |
|
93 | +throw new Exception("no recipient given."); } |
|
88 | 94 | $this->sender = $_sender; |
89 | 95 | $this->recipient = $_recipient; |
90 | 96 | $this->config = $_config; |
@@ -123,13 +129,17 @@ discard block |
||
123 | 129 | * @param string $_message |
124 | 130 | * @param array $_user_sessions |
125 | 131 | */ |
126 | - private function save( $_message ) { |
|
132 | + private function save( $_message ) |
|
133 | + { |
|
127 | 134 | $result = $this->db->insert( self::_notification_table, array( |
128 | 135 | 'account_id' => $this->recipient->account_id, |
129 | 136 | 'notify_message' => $_message, |
130 | 137 | 'notify_type' => self::_type |
131 | 138 | ), false,__LINE__,__FILE__,self::_appname); |
132 | - if ($result === false) throw new Exception("Can't save notification into SQL table"); |
|
139 | + if ($result === false) |
|
140 | + { |
|
141 | + throw new Exception("Can't save notification into SQL table"); |
|
142 | + } |
|
133 | 143 | } |
134 | 144 | |
135 | 145 | /** |
@@ -139,23 +149,32 @@ discard block |
||
139 | 149 | * @param array $_links |
140 | 150 | * @return string html rendered link(s) as complete string with jspopup or a new window |
141 | 151 | */ |
142 | - private function render_links($_links = false) { |
|
143 | - if(!is_array($_links) || count($_links) == 0) { return false; } |
|
152 | + private function render_links($_links = false) |
|
153 | + { |
|
154 | + if(!is_array($_links) || count($_links) == 0) |
|
155 | + { |
|
156 | +return false; } |
|
144 | 157 | $newline = "<br />"; |
145 | 158 | |
146 | 159 | $rendered_links = array(); |
147 | - foreach($_links as $link) { |
|
148 | - if(!$link->popup) { $link->view['no_popup'] = 1; } |
|
160 | + foreach($_links as $link) |
|
161 | + { |
|
162 | + if(!$link->popup) |
|
163 | + { |
|
164 | +$link->view['no_popup'] = 1; } |
|
149 | 165 | |
150 | 166 | // do not expose sensitive data |
151 | 167 | $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','', |
152 | 168 | Api\Html::link('/index.php', $link->view)); |
153 | 169 | // extract application-icon from menuaction |
154 | - if($link->view['menuaction']) { |
|
170 | + if($link->view['menuaction']) |
|
171 | + { |
|
155 | 172 | $menuaction_arr = explode('.',$link->view['menuaction']); |
156 | 173 | $application = $menuaction_arr[0]; |
157 | 174 | $image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : ''; |
158 | - } else { |
|
175 | + } |
|
176 | + else |
|
177 | + { |
|
159 | 178 | $image = ''; |
160 | 179 | } |
161 | 180 | if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient']) |
@@ -168,12 +187,15 @@ discard block |
||
168 | 187 | ); |
169 | 188 | |
170 | 189 | $rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link'); |
171 | - } else { |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
172 | 193 | $rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link'); |
173 | 194 | } |
174 | 195 | |
175 | 196 | } |
176 | - if(count($rendered_links) > 0) { |
|
197 | + if(count($rendered_links) > 0) |
|
198 | + { |
|
177 | 199 | return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links); |
178 | 200 | } |
179 | 201 | } |
@@ -207,13 +229,16 @@ discard block |
||
207 | 229 | * @param string $_subject |
208 | 230 | * @return string html rendered info as complete string |
209 | 231 | */ |
210 | - private function render_infos($_subject = false) { |
|
232 | + private function render_infos($_subject = false) |
|
233 | + { |
|
211 | 234 | $infos = array(); |
212 | 235 | $newline = "<br />"; |
213 | 236 | |
214 | 237 | $sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email; |
215 | 238 | $infos[] = lang('Message from').': '.$sender; |
216 | - if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); } |
|
239 | + if(!empty($_subject)) |
|
240 | + { |
|
241 | +$infos[] = Api\Html::bold($_subject); } |
|
217 | 242 | return implode($newline,$infos); |
218 | 243 | } |
219 | 244 | |
@@ -222,7 +247,8 @@ discard block |
||
222 | 247 | * |
223 | 248 | * @param settings array with keys account_id and new_owner (new_owner is optional) |
224 | 249 | */ |
225 | - public static function deleteaccount($settings) { |
|
250 | + public static function deleteaccount($settings) |
|
251 | + { |
|
226 | 252 | $GLOBALS['egw']->db->delete( self::_notification_table, array( |
227 | 253 | 'account_id' => $settings['account_id'] |
228 | 254 | ),__LINE__,__FILE__,self::_appname); |
@@ -106,7 +106,7 @@ |
||
106 | 106 | // Check access log to see if user is still logged in |
107 | 107 | if ( !Api\Session::notifications_active($this->recipient->account_id) ) |
108 | 108 | { |
109 | - throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup"); |
|
109 | + throw new Exception("user {$this->recipient->account_lid} isn't online. Can't send notification via popup"); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $message = $this->render_infos($_subject) |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * checks for a valid IPv4-address without CIDR notation |
156 | 156 | * |
157 | 157 | * @param string $_ip |
158 | - * @return true or false |
|
158 | + * @return integer or false |
|
159 | 159 | */ |
160 | 160 | private function valid_ip($_ip) { |
161 | 161 | return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * renders additional info from subject |
166 | 166 | * |
167 | 167 | * @param string $_subject |
168 | - * @return plain rendered info as complete string |
|
168 | + * @return string|false rendered info as complete string |
|
169 | 169 | */ |
170 | 170 | private function render_infos($_subject = false) { |
171 | 171 | $newline = "\n"; |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | * @param object $_preferences |
82 | 82 | */ |
83 | 83 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
84 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
85 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
86 | - if(!$this->netbios_command) { |
|
87 | - throw new Exception( 'Winpopup plugin not configured yet. Skipped sending notification message. '. |
|
84 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
85 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
86 | + if (!$this->netbios_command) { |
|
87 | + throw new Exception('Winpopup plugin not configured yet. Skipped sending notification message. '. |
|
88 | 88 | 'Please check var "netbios_command" in winpopup backend '. |
89 | - '('.EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.notifications_winpopup.inc.php).'); |
|
89 | + '('.EGW_INCLUDE_ROOT.SEP.self::_appname.SEP.'inc'.SEP.'class.notifications_winpopup.inc.php).'); |
|
90 | 90 | } |
91 | 91 | $this->sender = $_sender; |
92 | 92 | $this->recipient = $_recipient; |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) |
106 | 106 | { |
107 | - unset($_links, $_attachments); // not used |
|
107 | + unset($_links, $_attachments); // not used |
|
108 | 108 | |
109 | 109 | $user_sessions = array(); |
110 | 110 | foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) { |
111 | - if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) { |
|
112 | - if($this->valid_ip($session['session_ip'])) { |
|
111 | + if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) { |
|
112 | + if ($this->valid_ip($session['session_ip'])) { |
|
113 | 113 | $user_sessions[] = $session['session_ip']; |
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | - if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
117 | + if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
118 | 118 | |
119 | - $this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions ); |
|
119 | + $this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions); |
|
120 | 120 | return true; |
121 | 121 | } |
122 | 122 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @param string $_message |
127 | 127 | * @param array $_user_sessions |
128 | 128 | */ |
129 | - private function send_winpopup( $_message, array $_user_sessions ) { |
|
130 | - foreach($_user_sessions as $user_session) { |
|
131 | - $ip_octets=explode(".",$user_session); |
|
129 | + private function send_winpopup($_message, array $_user_sessions) { |
|
130 | + foreach ($_user_sessions as $user_session) { |
|
131 | + $ip_octets = explode(".", $user_session); |
|
132 | 132 | // format the ip_octets to 3 digits each |
133 | - foreach($ip_octets as $id=>$ip_octet) { |
|
134 | - if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; } |
|
135 | - if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; } |
|
133 | + foreach ($ip_octets as $id=>$ip_octet) { |
|
134 | + if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; } |
|
135 | + if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; } |
|
136 | 136 | } |
137 | - $placeholders = array( '/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection |
|
137 | + $placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection |
|
138 | 138 | '/\[1\]/' => $ip_octets[0], |
139 | 139 | '/\[2\]/' => $ip_octets[1], |
140 | 140 | '/\[3\]/' => $ip_octets[2], |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | ); |
145 | 145 | $command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command); |
146 | 146 | $output = $returncode = null; |
147 | - exec($command,$output,$returncode); |
|
148 | - if($returncode != 0) { |
|
147 | + exec($command, $output, $returncode); |
|
148 | + if ($returncode != 0) { |
|
149 | 149 | throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command."); |
150 | 150 | } |
151 | 151 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return true or false |
159 | 159 | */ |
160 | 160 | private function valid_ip($_ip) { |
161 | - return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); |
|
161 | + return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function render_infos($_subject = false) { |
171 | 171 | $newline = "\n"; |
172 | - if(!empty($_subject)) { return $_subject.$newline; } |
|
172 | + if (!empty($_subject)) { return $_subject.$newline; } |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | \ No newline at end of file |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * User notification via winpopup. |
17 | 17 | */ |
18 | -class notifications_winpopup implements notifications_iface { |
|
18 | +class notifications_winpopup implements notifications_iface |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Appname |
@@ -80,10 +81,16 @@ discard block |
||
80 | 81 | * @param object $_config |
81 | 82 | * @param object $_preferences |
82 | 83 | */ |
83 | - public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
|
84 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
85 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
86 | - if(!$this->netbios_command) { |
|
84 | + public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
|
85 | + { |
|
86 | + if(!is_object($_sender)) |
|
87 | + { |
|
88 | +throw new Exception("no sender given."); } |
|
89 | + if(!is_object($_recipient)) |
|
90 | + { |
|
91 | +throw new Exception("no recipient given."); } |
|
92 | + if(!$this->netbios_command) |
|
93 | + { |
|
87 | 94 | throw new Exception( 'Winpopup plugin not configured yet. Skipped sending notification message. '. |
88 | 95 | 'Please check var "netbios_command" in winpopup backend '. |
89 | 96 | '('.EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.notifications_winpopup.inc.php).'); |
@@ -107,14 +114,20 @@ discard block |
||
107 | 114 | unset($_links, $_attachments); // not used |
108 | 115 | |
109 | 116 | $user_sessions = array(); |
110 | - foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) { |
|
111 | - if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) { |
|
112 | - if($this->valid_ip($session['session_ip'])) { |
|
117 | + foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) |
|
118 | + { |
|
119 | + if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) |
|
120 | + { |
|
121 | + if($this->valid_ip($session['session_ip'])) |
|
122 | + { |
|
113 | 123 | $user_sessions[] = $session['session_ip']; |
114 | 124 | } |
115 | 125 | } |
116 | 126 | } |
117 | - if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
127 | + if ( empty($user_sessions) ) |
|
128 | + { |
|
129 | + throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
130 | + } |
|
118 | 131 | |
119 | 132 | $this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions ); |
120 | 133 | return true; |
@@ -126,13 +139,20 @@ discard block |
||
126 | 139 | * @param string $_message |
127 | 140 | * @param array $_user_sessions |
128 | 141 | */ |
129 | - private function send_winpopup( $_message, array $_user_sessions ) { |
|
130 | - foreach($_user_sessions as $user_session) { |
|
142 | + private function send_winpopup( $_message, array $_user_sessions ) |
|
143 | + { |
|
144 | + foreach($_user_sessions as $user_session) |
|
145 | + { |
|
131 | 146 | $ip_octets=explode(".",$user_session); |
132 | 147 | // format the ip_octets to 3 digits each |
133 | - foreach($ip_octets as $id=>$ip_octet) { |
|
134 | - if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; } |
|
135 | - if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; } |
|
148 | + foreach($ip_octets as $id=>$ip_octet) |
|
149 | + { |
|
150 | + if(strlen($ip_octet)==1) |
|
151 | + { |
|
152 | +$ip_octets[$id] = '00'.$ip_octet; } |
|
153 | + if(strlen($ip_octet)==2) |
|
154 | + { |
|
155 | +$ip_octets[$id] = '0'.$ip_octet; } |
|
136 | 156 | } |
137 | 157 | $placeholders = array( '/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection |
138 | 158 | '/\[1\]/' => $ip_octets[0], |
@@ -145,7 +165,8 @@ discard block |
||
145 | 165 | $command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command); |
146 | 166 | $output = $returncode = null; |
147 | 167 | exec($command,$output,$returncode); |
148 | - if($returncode != 0) { |
|
168 | + if($returncode != 0) |
|
169 | + { |
|
149 | 170 | throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command."); |
150 | 171 | } |
151 | 172 | } |
@@ -157,7 +178,8 @@ discard block |
||
157 | 178 | * @param string $_ip |
158 | 179 | * @return true or false |
159 | 180 | */ |
160 | - private function valid_ip($_ip) { |
|
181 | + private function valid_ip($_ip) |
|
182 | + { |
|
161 | 183 | return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); |
162 | 184 | } |
163 | 185 | |
@@ -167,9 +189,12 @@ discard block |
||
167 | 189 | * @param string $_subject |
168 | 190 | * @return plain rendered info as complete string |
169 | 191 | */ |
170 | - private function render_infos($_subject = false) { |
|
192 | + private function render_infos($_subject = false) |
|
193 | + { |
|
171 | 194 | $newline = "\n"; |
172 | - if(!empty($_subject)) { return $_subject.$newline; } |
|
195 | + if(!empty($_subject)) |
|
196 | + { |
|
197 | +return $_subject.$newline; } |
|
173 | 198 | return false; |
174 | 199 | } |
175 | 200 | } |
176 | 201 | \ No newline at end of file |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * Overwritten to load our slider.js |
56 | 56 | * |
57 | 57 | * @param array $extra |
58 | - * @return type |
|
58 | + * @return string|null |
|
59 | 59 | */ |
60 | 60 | function header(array $extra=array()) |
61 | 61 | { |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param string $template ='pixelegg' name of the template |
43 | 43 | */ |
44 | - function __construct($template=self::APP) |
|
44 | + function __construct($template = self::APP) |
|
45 | 45 | { |
46 | - parent::__construct($template); // call the constructor of the extended class |
|
46 | + parent::__construct($template); // call the constructor of the extended class |
|
47 | 47 | |
48 | 48 | // search 'mobile' dirs first |
49 | - if (Api\Header\UserAgent::mobile()) array_unshift ($this->template_dirs, 'mobile'); |
|
49 | + if (Api\Header\UserAgent::mobile()) array_unshift($this->template_dirs, 'mobile'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $extra |
58 | 58 | * @return type |
59 | 59 | */ |
60 | - function header(array $extra=array()) |
|
60 | + function header(array $extra = array()) |
|
61 | 61 | { |
62 | 62 | // load our slider.js, but only if framework requested |
63 | 63 | if (!self::$header_done && $_GET['cd'] === 'yes' && |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | { |
80 | 80 | if ($color[0] == '#') $color = ltrim($color, '#'); |
81 | 81 | |
82 | - $R = hexdec(substr($color,0,2)); |
|
83 | - $G = hexdec(substr($color,2,2)); |
|
84 | - $B = hexdec(substr($color,4,2)); |
|
82 | + $R = hexdec(substr($color, 0, 2)); |
|
83 | + $G = hexdec(substr($color, 2, 2)); |
|
84 | + $B = hexdec(substr($color, 4, 2)); |
|
85 | 85 | |
86 | 86 | $Rs = round($R * (100 + $percent) / 100); |
87 | 87 | $Gs = round($G * (100 + $percent) / 100); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | $ret = parent::_get_css(); |
106 | 106 | // color to use |
107 | - $color = str_replace('custom',$GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'], |
|
107 | + $color = str_replace('custom', $GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'], |
|
108 | 108 | $GLOBALS['egw_info']['user']['preferences']['common']['template_color']); |
109 | 109 | |
110 | 110 | // Create a dark variant of the color |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $loginbox_color = $color_darker; |
130 | 130 | } |
131 | 131 | |
132 | - if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color)) // a little xss check |
|
132 | + if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i', $color)) // a little xss check |
|
133 | 133 | { |
134 | 134 | if (!Api\Header\UserAgent::mobile()) |
135 | 135 | { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @param string $extra_vars for login url |
207 | 207 | * @param string $change_passwd =null string with message to render input fields for password change |
208 | 208 | */ |
209 | - function login_screen($extra_vars, $change_passwd=null) |
|
209 | + function login_screen($extra_vars, $change_passwd = null) |
|
210 | 210 | { |
211 | 211 | if (empty($GLOBALS['loginscreenmessage'])) |
212 | 212 | { |
@@ -46,7 +46,10 @@ discard block |
||
46 | 46 | parent::__construct($template); // call the constructor of the extended class |
47 | 47 | |
48 | 48 | // search 'mobile' dirs first |
49 | - if (Api\Header\UserAgent::mobile()) array_unshift ($this->template_dirs, 'mobile'); |
|
49 | + if (Api\Header\UserAgent::mobile()) |
|
50 | + { |
|
51 | + array_unshift ($this->template_dirs, 'mobile'); |
|
52 | + } |
|
50 | 53 | } |
51 | 54 | |
52 | 55 | /** |
@@ -77,7 +80,10 @@ discard block |
||
77 | 80 | */ |
78 | 81 | function _color_shader($color, $percent) |
79 | 82 | { |
80 | - if ($color[0] == '#') $color = ltrim($color, '#'); |
|
83 | + if ($color[0] == '#') |
|
84 | + { |
|
85 | + $color = ltrim($color, '#'); |
|
86 | + } |
|
81 | 87 | |
82 | 88 | $R = hexdec(substr($color,0,2)); |
83 | 89 | $G = hexdec(substr($color,2,2)); |
@@ -87,9 +93,18 @@ discard block |
||
87 | 93 | $Gs = round($G * (100 + $percent) / 100); |
88 | 94 | $Bs = round($B * (100 + $percent) / 100); |
89 | 95 | |
90 | - if ($Rs > 255) $Rs = 255; |
|
91 | - if ($Gs > 255) $Gs = 255; |
|
92 | - if ($Bs > 255) $Bs = 255; |
|
96 | + if ($Rs > 255) |
|
97 | + { |
|
98 | + $Rs = 255; |
|
99 | + } |
|
100 | + if ($Gs > 255) |
|
101 | + { |
|
102 | + $Gs = 255; |
|
103 | + } |
|
104 | + if ($Bs > 255) |
|
105 | + { |
|
106 | + $Bs = 255; |
|
107 | + } |
|
93 | 108 | |
94 | 109 | return '#'.sprintf('%02X%02X%02X', $Rs, $Gs, $Bs); |
95 | 110 | } |
@@ -129,7 +144,9 @@ discard block |
||
129 | 144 | $loginbox_color = $color_darker; |
130 | 145 | } |
131 | 146 | |
132 | - if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color)) // a little xss check |
|
147 | + if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color)) |
|
148 | + { |
|
149 | + // a little xss check |
|
133 | 150 | { |
134 | 151 | if (!Api\Header\UserAgent::mobile()) |
135 | 152 | { |
@@ -168,6 +185,7 @@ discard block |
||
168 | 185 | |
169 | 186 | |
170 | 187 | "; |
188 | + } |
|
171 | 189 | if ($GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'traditional') |
172 | 190 | { |
173 | 191 | $ret['app_css'] .= ".dialogFooterToolbar {background-color: $color !important;}"; |
@@ -292,7 +292,7 @@ |
||
292 | 292 | * @param array &$sel_options |
293 | 293 | * @param array &$readonlys |
294 | 294 | * @param array &$types on return setting-name => setting-type |
295 | - * @param etemplate $tpl |
|
295 | + * @param Etemplate $tpl |
|
296 | 296 | * @throws Api\Exception\WrongParameter |
297 | 297 | * @return array content |
298 | 298 | */ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param array $content =null |
46 | 46 | * @param string $msg ='' |
47 | 47 | */ |
48 | - function index(array $content=null, $msg='') |
|
48 | + function index(array $content = null, $msg = '') |
|
49 | 49 | { |
50 | 50 | $tpl = new Etemplate('preferences.settings'); |
51 | 51 | if (!is_array($content)) |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | list($button) = each($content['button']); |
72 | 72 | $appname = $content['old_appname'] ? $content['old_appname'] : 'common'; |
73 | - switch($button) |
|
73 | + switch ($button) |
|
74 | 74 | { |
75 | 75 | case 'save': |
76 | 76 | case 'apply': |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | { |
80 | 80 | throw new Api\Exception\NoPermission\Admin; |
81 | 81 | } |
82 | - list($type,$account_id) = explode(':', $content['old_type']); |
|
82 | + list($type, $account_id) = explode(':', $content['old_type']); |
|
83 | 83 | // merge prefs of all tabs together again |
84 | 84 | $prefs = array(); |
85 | - foreach($content as $name => $val) |
|
85 | + foreach ($content as $name => $val) |
|
86 | 86 | { |
87 | 87 | if (is_array($val) && strpos($name, 'tab') === 0) |
88 | 88 | { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $old_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array_flip($require_reload)); |
101 | 101 | |
102 | 102 | $attribute = $type == 'group' ? 'user' : $type; |
103 | - if (!($msg=$this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute))) |
|
103 | + if (!($msg = $this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute))) |
|
104 | 104 | { |
105 | 105 | $msg_type = 'success'; |
106 | 106 | $msg = lang('Preferences saved.'); |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | // update client-side Api\Preferences in response |
125 | 125 | Framework::ajax_get_preference($appname); |
126 | 126 | } |
127 | - if (in_array($button, array('save','cancel'))) |
|
127 | + if (in_array($button, array('save', 'cancel'))) |
|
128 | 128 | { |
129 | 129 | Api\Json\Response::get()->call('egw.message', $msg, $msg_type); |
130 | 130 | Framework::window_close(); |
131 | 131 | } |
132 | 132 | } |
133 | 133 | $appname = $content['appname'] ? $content['appname'] : 'common'; |
134 | - list($type,$account_id) = explode(':', $content['type']); |
|
134 | + list($type, $account_id) = explode(':', $content['type']); |
|
135 | 135 | //_debug_array($prefs); |
136 | 136 | } |
137 | 137 | if ($account_id && $account_id != $GLOBALS['egw']->preferences->get_account_id()) |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $preserve['current_app'] = $content['current_app']; |
151 | 151 | $GLOBALS['egw_info']['flags']['currentapp'] = $content['current_app'] == 'common' ? |
152 | 152 | 'preferences' : $content['current_app']; |
153 | - Framework::includeCSS('preferences','app'); |
|
153 | + Framework::includeCSS('preferences', 'app'); |
|
154 | 154 | |
155 | 155 | // if not just saved, call validation before, to be able to show failed validation of current prefs |
156 | 156 | if (!isset($button)) |
@@ -182,17 +182,17 @@ discard block |
||
182 | 182 | * @param boolean $only_verify =false |
183 | 183 | * @return string with verification error or null on success |
184 | 184 | */ |
185 | - function process_array(array &$repository, array $values, array $types, $appname, $type, $only_verify=false) |
|
185 | + function process_array(array &$repository, array $values, array $types, $appname, $type, $only_verify = false) |
|
186 | 186 | { |
187 | 187 | //_debug_array($repository); |
188 | 188 | $prefs = &$repository[$appname]; |
189 | 189 | |
190 | 190 | unset($prefs['']); |
191 | 191 | //_debug_array($values);exit; |
192 | - foreach($values as $var => $value) |
|
192 | + foreach ($values as $var => $value) |
|
193 | 193 | { |
194 | 194 | // type specific validation |
195 | - switch((string)$types[$var]) |
|
195 | + switch ((string)$types[$var]) |
|
196 | 196 | { |
197 | 197 | case 'password': // dont write empty password-fields |
198 | 198 | if (empty($value)) continue 2; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // empty is always allowed |
206 | 206 | |
207 | 207 | // If forced, empty == not set |
208 | - if($type == 'forced') |
|
208 | + if ($type == 'forced') |
|
209 | 209 | { |
210 | 210 | unset($prefs[$var]); |
211 | 211 | // need to call preferences::delete, to also set affective prefs! |
@@ -217,19 +217,19 @@ discard block |
||
217 | 217 | { |
218 | 218 | if ($value[0] != '/' || !Vfs::stat($value) || Vfs::is_dir($value)) |
219 | 219 | { |
220 | - $error = lang('%1 is no existing vfs file!',htmlspecialchars($value)); |
|
220 | + $error = lang('%1 is no existing vfs file!', htmlspecialchars($value)); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | else |
224 | 224 | { |
225 | 225 | // split multiple comma or whitespace separated directories |
226 | 226 | // to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split |
227 | - foreach($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir) |
|
227 | + foreach ($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir) |
|
228 | 228 | { |
229 | - if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split |
|
229 | + if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split |
|
230 | 230 | if ($dir[0] != '/' || !Vfs::stat($dir) || !Vfs::is_dir($dir)) |
231 | 231 | { |
232 | - $error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!',$dir); |
|
232 | + $error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!', $dir); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | if (isset($value) && $value !== '' && $value !== '**NULL**' && $value !== array()) |
243 | 243 | { |
244 | - if (is_array($value)) $value = implode(',',$value); // multiselect |
|
244 | + if (is_array($value)) $value = implode(',', $value); // multiselect |
|
245 | 245 | |
246 | 246 | $prefs[$var] = $value; |
247 | 247 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // if you return something else than False, it is treated as an error-msg and |
262 | 262 | // displayed to the user (the prefs are not saved) |
263 | 263 | // |
264 | - if(($error .= Api\Hooks::single(array( |
|
264 | + if (($error .= Api\Hooks::single(array( |
|
265 | 265 | 'location' => 'verify_settings', |
266 | 266 | 'prefs' => &$repository[$appname], |
267 | 267 | 'type' => $type, |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | return $error; |
274 | 274 | } |
275 | 275 | |
276 | - if (!$only_verify) $GLOBALS['egw']->preferences->save_repository(True,$type); |
|
276 | + if (!$only_verify) $GLOBALS['egw']->preferences->save_repository(True, $type); |
|
277 | 277 | |
278 | 278 | // certain common prefs (language, template, ...) require the session to be re-created |
279 | 279 | if ($appname == 'common' && !$only_verify) |
@@ -309,19 +309,19 @@ discard block |
||
309 | 309 | $sel_options = $readonlys = $content = $tabs = array(); |
310 | 310 | // disable all but first tab and name current tab "tab1", for apps not using sections |
311 | 311 | $tab = 'tab1'; |
312 | - foreach($this->settings as $setting) |
|
312 | + foreach ($this->settings as $setting) |
|
313 | 313 | { |
314 | 314 | if (!is_array($setting)) continue; |
315 | 315 | if ($type != 'forced' && (string)$GLOBALS['egw']->preferences->forced[$appname][$setting['name']] !== '') |
316 | 316 | { |
317 | - continue; // forced preferences are not displayed, unless we edit them |
|
317 | + continue; // forced preferences are not displayed, unless we edit them |
|
318 | 318 | } |
319 | 319 | $types[$setting['name']] = $old_type = $setting['type']; |
320 | 320 | |
321 | - switch($old_type) |
|
321 | + switch ($old_type) |
|
322 | 322 | { |
323 | 323 | case 'section': |
324 | - $tab = 'tab'.(1+count($tabs)); |
|
324 | + $tab = 'tab'.(1 + count($tabs)); |
|
325 | 325 | $tabs[] = array( |
326 | 326 | 'id' => $tab, |
327 | 327 | 'template' => 'preferences.settings.tab1', |
@@ -336,24 +336,24 @@ discard block |
||
336 | 336 | if (is_array($setting['values'])) $vars += $setting['values']; |
337 | 337 | $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']] = |
338 | 338 | $GLOBALS['egw']->preferences->lang_notify($GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']], $vars); |
339 | - $types[$setting['name']] = $vars; // store vars for re-translation, instead type "notify" |
|
339 | + $types[$setting['name']] = $vars; // store vars for re-translation, instead type "notify" |
|
340 | 340 | if ($setting['help'] && ($setting['run_lang'] || !isset($setting['run_lang']))) |
341 | 341 | { |
342 | 342 | $setting['help'] = lang($setting['help']); |
343 | 343 | } |
344 | 344 | $setting['help'] .= '<p><b>'.lang('Substitutions and their meanings:').'</b>'; |
345 | - foreach($vars as $var => $var_help) |
|
345 | + foreach ($vars as $var => $var_help) |
|
346 | 346 | { |
347 | 347 | $lname = ($lname = lang($var)) == $var.'*' ? $var : $lname; |
348 | 348 | $setting['help'] .= "<br>\n".'<b>$$'.$lname.'$$</b>: '.$var_help; |
349 | 349 | } |
350 | 350 | $setting['help'] .= "</p>\n"; |
351 | - $setting['run_lang'] = false; // already done now |
|
351 | + $setting['run_lang'] = false; // already done now |
|
352 | 352 | // handle as textarea |
353 | 353 | case 'textarea': |
354 | 354 | $setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'textbox'; |
355 | 355 | $tpl->setElementAttribute($tab.'['.$setting['name'].']', 'multiline', 'true'); |
356 | - $tpl->setElementAttribute($tab. '[' . $setting['name'] . ']','width', '99%' ); |
|
356 | + $tpl->setElementAttribute($tab.'['.$setting['name'].']', 'width', '99%'); |
|
357 | 357 | // anyway setting via css: width: 99%, height: 5em |
358 | 358 | // for old eT use size attribute |
359 | 359 | if (is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows']))) |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | case 'multiselect': |
376 | 376 | $setting['type'] = 'select'; |
377 | 377 | $tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5); |
378 | - if (!isset($setting['size'])) $setting['size'] = '5'; // old eT |
|
378 | + if (!isset($setting['size'])) $setting['size'] = '5'; // old eT |
|
379 | 379 | break; |
380 | 380 | case 'color': |
381 | 381 | $setting['type'] = 'colorpicker'; |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | case 'date-duration': |
384 | 384 | if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1'; |
385 | 385 | $attrs = explode(',', $setting['size']); |
386 | - foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name) |
|
386 | + foreach (array("data_format", "display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name) |
|
387 | 387 | { |
388 | 388 | if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]); |
389 | 389 | } |
@@ -394,17 +394,17 @@ discard block |
||
394 | 394 | { |
395 | 395 | if ($old_type != 'multiselect' && $old_type != 'notify') |
396 | 396 | { |
397 | - switch($type) |
|
397 | + switch ($type) |
|
398 | 398 | { |
399 | 399 | case 'user': |
400 | - $setting['values'] = array('' => lang('Use default'))+$setting['values']; |
|
400 | + $setting['values'] = array('' => lang('Use default')) + $setting['values']; |
|
401 | 401 | break; |
402 | 402 | case 'default': |
403 | 403 | case 'group': |
404 | - $setting['values'] = array('' => lang('No default'))+$setting['values']; |
|
404 | + $setting['values'] = array('' => lang('No default')) + $setting['values']; |
|
405 | 405 | break; |
406 | 406 | case 'forced'; |
407 | - $setting['values'] = array('**NULL**' => lang('Users choice'))+$setting['values']; |
|
407 | + $setting['values'] = array('**NULL**' => lang('Users choice')) + $setting['values']; |
|
408 | 408 | break; |
409 | 409 | } |
410 | 410 | } |
@@ -413,8 +413,7 @@ discard block |
||
413 | 413 | if ($type == 'user') |
414 | 414 | { |
415 | 415 | $default = $GLOBALS['egw']->preferences->group[$appname][$setting['name']] ? |
416 | - $GLOBALS['egw']->preferences->group[$appname][$setting['name']] : |
|
417 | - $GLOBALS['egw']->preferences->default[$appname][$setting['name']]; |
|
416 | + $GLOBALS['egw']->preferences->group[$appname][$setting['name']] : $GLOBALS['egw']->preferences->default[$appname][$setting['name']]; |
|
418 | 417 | |
419 | 418 | // replace default value(s) for selectboxes with selectbox labels |
420 | 419 | if (isset($setting['values']) && is_array($setting['values'])) |
@@ -434,7 +433,7 @@ discard block |
||
434 | 433 | 'name' => $setting['name'], |
435 | 434 | 'type' => $setting['type'], |
436 | 435 | 'label' => preg_replace('|<br[ /]*>|i', "\n", $setting['label']), |
437 | - 'help' => lang($setting['help']), // is html |
|
436 | + 'help' => lang($setting['help']), // is html |
|
438 | 437 | //'size' => $setting['size'], // old eT |
439 | 438 | 'default' => !empty($default) ? lang('Default').': '.$default : null, |
440 | 439 | 'onchange' => $setting['onchange'], |
@@ -460,7 +459,7 @@ discard block |
||
460 | 459 | |
461 | 460 | $content['appname'] = $appname; |
462 | 461 | $sel_options['appname'] = array(); |
463 | - foreach(Api\Hooks::implemented('settings') as $app) |
|
462 | + foreach (Api\Hooks::implemented('settings') as $app) |
|
464 | 463 | { |
465 | 464 | if ($app != 'preferences' && $GLOBALS['egw_info']['user']['apps'][$app]) |
466 | 465 | { |
@@ -486,7 +485,7 @@ discard block |
||
486 | 485 | $user_apps = $GLOBALS['egw']->acl->get_user_applications($id); |
487 | 486 | $sel_options['appname'] = array_intersect_key($sel_options['appname'], $user_apps); |
488 | 487 | } |
489 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'order' => 'account_lid')) as $account_id => $group) |
|
488 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'order' => 'account_lid')) as $account_id => $group) |
|
490 | 489 | { |
491 | 490 | $sel_options['type']['group:'.$account_id] = lang('Preferences').' '.Api\Accounts::format_username($group['account_lid'], '', '', $account_id); |
492 | 491 | } |
@@ -509,7 +508,7 @@ discard block |
||
509 | 508 | * @param boolean $lang =true |
510 | 509 | * @return string comma-separated and translated labels |
511 | 510 | */ |
512 | - protected static function get_default_label($default, array $values, $lang=true) |
|
511 | + protected static function get_default_label($default, array $values, $lang = true) |
|
513 | 512 | { |
514 | 513 | // explode comma-separated multiple default values |
515 | 514 | if (!is_array($default) && !isset($values[$default]) && strpos($default, ',') !== false) |
@@ -520,7 +519,7 @@ discard block |
||
520 | 519 | { |
521 | 520 | $labels = (array)$default; |
522 | 521 | } |
523 | - foreach($labels as &$def) |
|
522 | + foreach ($labels as &$def) |
|
524 | 523 | { |
525 | 524 | if (isset($values[$def])) |
526 | 525 | { |
@@ -528,7 +527,7 @@ discard block |
||
528 | 527 | } |
529 | 528 | else // value could be in an optgroup |
530 | 529 | { |
531 | - foreach($values as $value) |
|
530 | + foreach ($values as $value) |
|
532 | 531 | { |
533 | 532 | if (is_array($value) && !isset($value['label']) && isset($value[$def])) |
534 | 533 | { |
@@ -554,16 +553,16 @@ discard block |
||
554 | 553 | * @param int|string $account_id =null account_id for user or group prefs, or "forced" or "default" |
555 | 554 | * @return boolean |
556 | 555 | */ |
557 | - protected function call_hook($appname, $type='user', $account_id=null) |
|
556 | + protected function call_hook($appname, $type = 'user', $account_id = null) |
|
558 | 557 | { |
559 | 558 | $this->appname = $appname == 'common' ? 'preferences' : $appname; |
560 | 559 | |
561 | 560 | // Set framework here to make sure we get the right settings for user's [newly] selected template |
562 | 561 | $GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw']->preferences->data['common']['template_set']; |
563 | 562 | Api\Translation::add_app($this->appname); |
564 | - if($this->appname != 'preferences') |
|
563 | + if ($this->appname != 'preferences') |
|
565 | 564 | { |
566 | - Api\Translation::add_app('preferences'); // we need the prefs translations too |
|
565 | + Api\Translation::add_app('preferences'); // we need the prefs translations too |
|
567 | 566 | } |
568 | 567 | |
569 | 568 | // make type available, to hooks from Egw\Applications can use it, eg. activesync |
@@ -572,7 +571,7 @@ discard block |
||
572 | 571 | 'type' => $type, |
573 | 572 | 'account_id' => $account_id, |
574 | 573 | ); |
575 | - $GLOBALS['type'] = $type; // old global variable |
|
574 | + $GLOBALS['type'] = $type; // old global variable |
|
576 | 575 | |
577 | 576 | // calling app specific settings hook |
578 | 577 | $settings = Api\Hooks::single($hook_data, $this->appname); |
@@ -581,30 +580,30 @@ discard block |
||
581 | 580 | { |
582 | 581 | $this->settings = array_merge($this->settings, $settings); |
583 | 582 | } |
584 | - elseif(isset($GLOBALS['settings']) && is_array($GLOBALS['settings']) && $GLOBALS['settings']) |
|
583 | + elseif (isset($GLOBALS['settings']) && is_array($GLOBALS['settings']) && $GLOBALS['settings']) |
|
585 | 584 | { |
586 | 585 | $this->settings = array_merge($this->settings, $GLOBALS['settings']); |
587 | 586 | } |
588 | 587 | else |
589 | 588 | { |
590 | - return False; // no settings returned |
|
589 | + return False; // no settings returned |
|
591 | 590 | } |
592 | 591 | |
593 | 592 | // calling settings hook all apps can answer (for a specific app) |
594 | 593 | $hook_data['location'] = 'settings_'.$this->appname; |
595 | - foreach(Api\Hooks::process($hook_data, $this->appname,true) as $settings) |
|
594 | + foreach (Api\Hooks::process($hook_data, $this->appname, true) as $settings) |
|
596 | 595 | { |
597 | 596 | if (isset($settings) && is_array($settings) && $settings) |
598 | 597 | { |
599 | - $this->settings = array_merge($this->settings,$settings); |
|
598 | + $this->settings = array_merge($this->settings, $settings); |
|
600 | 599 | } |
601 | 600 | } |
602 | 601 | /* Remove ui-only settings */ |
603 | - if($this->xmlrpc) |
|
602 | + if ($this->xmlrpc) |
|
604 | 603 | { |
605 | - foreach($this->settings as $key => $valarray) |
|
604 | + foreach ($this->settings as $key => $valarray) |
|
606 | 605 | { |
607 | - if(!$valarray['xmlrpc']) |
|
606 | + if (!$valarray['xmlrpc']) |
|
608 | 607 | { |
609 | 608 | unset($this->settings[$key]); |
610 | 609 | } |
@@ -616,10 +615,10 @@ discard block |
||
616 | 615 | This is not handled by the hooks class and is only valid if not using xml-rpc. |
617 | 616 | */ |
618 | 617 | $tmpl_settings = EGW_SERVER_ROOT.$GLOBALS['egw']->framework->template_dir.'/hook_settings.inc.php'; |
619 | - if($this->appname == 'preferences' && file_exists($tmpl_settings)) |
|
618 | + if ($this->appname == 'preferences' && file_exists($tmpl_settings)) |
|
620 | 619 | { |
621 | 620 | include($tmpl_settings); |
622 | - $this->settings = array_merge($this->settings,$GLOBALS['settings']); |
|
621 | + $this->settings = array_merge($this->settings, $GLOBALS['settings']); |
|
623 | 622 | } |
624 | 623 | } |
625 | 624 | // check if we have a default/forced value from the settings hook, |
@@ -640,9 +639,9 @@ discard block |
||
640 | 639 | } |
641 | 640 | if ($need_update) |
642 | 641 | { |
643 | - $GLOBALS['egw']->preferences->save_repository(false,'default',true); |
|
642 | + $GLOBALS['egw']->preferences->save_repository(false, 'default', true); |
|
644 | 643 | } |
645 | - if($this->debug) |
|
644 | + if ($this->debug) |
|
646 | 645 | { |
647 | 646 | _debug_array($this->settings); |
648 | 647 | } |
@@ -164,9 +164,15 @@ discard block |
||
164 | 164 | $data = $this->get_content($appname, $type, $sel_options, $readonlys, $preserve['types'], $tpl); |
165 | 165 | $preserve['appname'] = $preserve['old_appname'] = $data['appname']; |
166 | 166 | $preserve['type'] = $preserve['old_type'] = $data['type']; |
167 | - if (isset($old_tab)) $data['tabs'] = $old_tab; |
|
167 | + if (isset($old_tab)) |
|
168 | + { |
|
169 | + $data['tabs'] = $old_tab; |
|
170 | + } |
|
168 | 171 | |
169 | - if ($msg) Framework::message($msg, $msg_type ? $msg_type : 'error'); |
|
172 | + if ($msg) |
|
173 | + { |
|
174 | + Framework::message($msg, $msg_type ? $msg_type : 'error'); |
|
175 | + } |
|
170 | 176 | |
171 | 177 | $tpl->exec('preferences.preferences_settings.index', $data, $sel_options, $readonlys, $preserve, 2); |
172 | 178 | } |
@@ -195,7 +201,10 @@ discard block |
||
195 | 201 | switch((string)$types[$var]) |
196 | 202 | { |
197 | 203 | case 'password': // dont write empty password-fields |
198 | - if (empty($value)) continue 2; |
|
204 | + if (empty($value)) |
|
205 | + { |
|
206 | + continue 2; |
|
207 | + } |
|
199 | 208 | break; |
200 | 209 | case 'vfs_file': |
201 | 210 | case 'vfs_dir': |
@@ -209,7 +218,10 @@ discard block |
||
209 | 218 | { |
210 | 219 | unset($prefs[$var]); |
211 | 220 | // need to call preferences::delete, to also set affective prefs! |
212 | - if (!$only_verify) $GLOBALS['egw']->preferences->delete($appname, $var, $type); |
|
221 | + if (!$only_verify) |
|
222 | + { |
|
223 | + $GLOBALS['egw']->preferences->delete($appname, $var, $type); |
|
224 | + } |
|
213 | 225 | continue 2; |
214 | 226 | } |
215 | 227 | } |
@@ -226,7 +238,11 @@ discard block |
||
226 | 238 | // to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split |
227 | 239 | foreach($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir) |
228 | 240 | { |
229 | - if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split |
|
241 | + if ($n) |
|
242 | + { |
|
243 | + $dir = '/'.$dir; |
|
244 | + } |
|
245 | + // re-adding trailing slash removed by split |
|
230 | 246 | if ($dir[0] != '/' || !Vfs::stat($dir) || !Vfs::is_dir($dir)) |
231 | 247 | { |
232 | 248 | $error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!',$dir); |
@@ -241,19 +257,29 @@ discard block |
||
241 | 257 | |
242 | 258 | if (isset($value) && $value !== '' && $value !== '**NULL**' && $value !== array()) |
243 | 259 | { |
244 | - if (is_array($value)) $value = implode(',',$value); // multiselect |
|
260 | + if (is_array($value)) |
|
261 | + { |
|
262 | + $value = implode(',',$value); |
|
263 | + } |
|
264 | + // multiselect |
|
245 | 265 | |
246 | 266 | $prefs[$var] = $value; |
247 | 267 | |
248 | 268 | // need to call preferences::add, to also set affective prefs! |
249 | - if (!$only_verify) $GLOBALS['egw']->preferences->add($appname, $var, $prefs[$var], $type); |
|
269 | + if (!$only_verify) |
|
270 | + { |
|
271 | + $GLOBALS['egw']->preferences->add($appname, $var, $prefs[$var], $type); |
|
272 | + } |
|
250 | 273 | } |
251 | 274 | else |
252 | 275 | { |
253 | 276 | unset($prefs[$var]); |
254 | 277 | |
255 | 278 | // need to call preferences::delete, to also set affective prefs! |
256 | - if (!$only_verify) $GLOBALS['egw']->preferences->delete($appname, $var, $type); |
|
279 | + if (!$only_verify) |
|
280 | + { |
|
281 | + $GLOBALS['egw']->preferences->delete($appname, $var, $type); |
|
282 | + } |
|
257 | 283 | } |
258 | 284 | } |
259 | 285 | |
@@ -273,7 +299,10 @@ discard block |
||
273 | 299 | return $error; |
274 | 300 | } |
275 | 301 | |
276 | - if (!$only_verify) $GLOBALS['egw']->preferences->save_repository(True,$type); |
|
302 | + if (!$only_verify) |
|
303 | + { |
|
304 | + $GLOBALS['egw']->preferences->save_repository(True,$type); |
|
305 | + } |
|
277 | 306 | |
278 | 307 | // certain common prefs (language, template, ...) require the session to be re-created |
279 | 308 | if ($appname == 'common' && !$only_verify) |
@@ -311,7 +340,10 @@ discard block |
||
311 | 340 | $tab = 'tab1'; |
312 | 341 | foreach($this->settings as $setting) |
313 | 342 | { |
314 | - if (!is_array($setting)) continue; |
|
343 | + if (!is_array($setting)) |
|
344 | + { |
|
345 | + continue; |
|
346 | + } |
|
315 | 347 | if ($type != 'forced' && (string)$GLOBALS['egw']->preferences->forced[$appname][$setting['name']] !== '') |
316 | 348 | { |
317 | 349 | continue; // forced preferences are not displayed, unless we edit them |
@@ -333,7 +365,10 @@ discard block |
||
333 | 365 | |
334 | 366 | case 'notify': |
335 | 367 | $vars = $GLOBALS['egw']->preferences->vars; |
336 | - if (is_array($setting['values'])) $vars += $setting['values']; |
|
368 | + if (is_array($setting['values'])) |
|
369 | + { |
|
370 | + $vars += $setting['values']; |
|
371 | + } |
|
337 | 372 | $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']] = |
338 | 373 | $GLOBALS['egw']->preferences->lang_notify($GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']], $vars); |
339 | 374 | $types[$setting['name']] = $vars; // store vars for re-translation, instead type "notify" |
@@ -375,17 +410,27 @@ discard block |
||
375 | 410 | case 'multiselect': |
376 | 411 | $setting['type'] = 'select'; |
377 | 412 | $tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5); |
378 | - if (!isset($setting['size'])) $setting['size'] = '5'; // old eT |
|
413 | + if (!isset($setting['size'])) |
|
414 | + { |
|
415 | + $setting['size'] = '5'; |
|
416 | + } |
|
417 | + // old eT |
|
379 | 418 | break; |
380 | 419 | case 'color': |
381 | 420 | $setting['type'] = 'colorpicker'; |
382 | 421 | break; |
383 | 422 | case 'date-duration': |
384 | - if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1'; |
|
423 | + if (!isset($setting['size'])) |
|
424 | + { |
|
425 | + $setting['size'] = 'm,dhm,24,1'; |
|
426 | + } |
|
385 | 427 | $attrs = explode(',', $setting['size']); |
386 | 428 | foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name) |
387 | 429 | { |
388 | - if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]); |
|
430 | + if ((string)$attrs[$n] !== '') |
|
431 | + { |
|
432 | + $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]); |
|
433 | + } |
|
389 | 434 | } |
390 | 435 | break; |
391 | 436 | } |
@@ -421,10 +466,13 @@ discard block |
||
421 | 466 | { |
422 | 467 | $default = self::get_default_label($default, $setting['values']); |
423 | 468 | } |
424 | - if (is_array($types[$setting['name']])) // translate the substitution names |
|
469 | + if (is_array($types[$setting['name']])) |
|
470 | + { |
|
471 | + // translate the substitution names |
|
425 | 472 | { |
426 | 473 | $default = $GLOBALS['egw']->preferences->lang_notify($default, $types[$setting['name']]); |
427 | 474 | } |
475 | + } |
|
428 | 476 | } |
429 | 477 | if ($setting['help'] && ($setting['run_lang'] || !isset($setting['run_lang']))) |
430 | 478 | { |
@@ -537,7 +585,10 @@ discard block |
||
537 | 585 | } |
538 | 586 | } |
539 | 587 | } |
540 | - if ($lang) $def = lang($def); |
|
588 | + if ($lang) |
|
589 | + { |
|
590 | + $def = lang($def); |
|
591 | + } |
|
541 | 592 | } |
542 | 593 | $label = implode(', ', $labels); |
543 | 594 | //error_log(__METHOD__."(".array2string($default).', '.array2string($values).") returning $label"); |
@@ -24,6 +24,10 @@ |
||
24 | 24 | |
25 | 25 | if(!function_exists('html_entity_decode')) |
26 | 26 | { |
27 | + |
|
28 | + /** |
|
29 | + * @param integer $quote_style |
|
30 | + */ |
|
27 | 31 | function html_entity_decode($given_html, $quote_style = ENT_QUOTES) |
28 | 32 | { |
29 | 33 | $trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style)); |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | "<a href=\"$webserverURL/redirect.php?go=".htmlentities(urlencode('http://www.egroupware.org')).'">' |
23 | 23 | */ |
24 | 24 | |
25 | - if(!function_exists('html_entity_decode')) |
|
25 | + if (!function_exists('html_entity_decode')) |
|
26 | 26 | { |
27 | 27 | function html_entity_decode($given_html, $quote_style = ENT_QUOTES) |
28 | 28 | { |
29 | - $trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style)); |
|
29 | + $trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)); |
|
30 | 30 | $trans_table['''] = "'"; |
31 | 31 | return(strtr($given_html, $trans_table)); |
32 | 32 | } |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | /* Only allow redirects from inside this eGroupware installation. */ |
47 | 47 | $valid_referer = array(); |
48 | - $path = preg_replace('/\/[^\/]*$/','',$_SERVER['PHP_SELF']) . '/'; |
|
48 | + $path = preg_replace('/\/[^\/]*$/', '', $_SERVER['PHP_SELF']).'/'; |
|
49 | 49 | array_push($valid_referer, $path); |
50 | - array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $path); |
|
51 | - array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $path); |
|
50 | + array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$path); |
|
51 | + array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$path); |
|
52 | 52 | |
53 | 53 | $referrer = trim($_SERVER['HTTP_REFERER']); |
54 | 54 | if ((!isset($_SERVER['HTTP_REFERER'])) || (empty($referrer))) |
55 | 55 | { |
56 | 56 | echo "Only usable from within eGroupware.\n"; |
57 | 57 | } |
58 | - else if($_GET['go']) |
|
58 | + else if ($_GET['go']) |
|
59 | 59 | { |
60 | 60 | $allow = false; |
61 | 61 | foreach ($valid_referer as $urlRoot) |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | } |
70 | 70 | if ($allow) |
71 | 71 | { |
72 | - $url= html_entity_decode(urldecode($_GET['go'])); |
|
72 | + $url = html_entity_decode(urldecode($_GET['go'])); |
|
73 | 73 | unset($_GET['go']); |
74 | 74 | /* Only add "&" if there is something to append. */ |
75 | 75 | if (!empty($_GET)) |
76 | 76 | { |
77 | - $url=$url."&".http_build_query($_GET); |
|
77 | + $url = $url."&".http_build_query($_GET); |
|
78 | 78 | } |
79 | 79 | |
80 | - Header('Location: ' . html_entity_decode(urldecode($url))); |
|
80 | + Header('Location: '.html_entity_decode(urldecode($url))); |
|
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | else |