@@ -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(); |
@@ -185,7 +185,6 @@ discard block |
||
185 | 185 | /** |
186 | 186 | * Return notification errors |
187 | 187 | * |
188 | - * @param boolean $reset=false true: reset all errors |
|
189 | 188 | * @return array |
190 | 189 | */ |
191 | 190 | public static function errors($reset=false) |
@@ -434,7 +433,7 @@ discard block |
||
434 | 433 | * Sets backends that should be skipped even if the user |
435 | 434 | * defined them in its chain |
436 | 435 | * |
437 | - * @param array $_skip_backends array with names of the backends to be skipped |
|
436 | + * @param string[] $_skip_backends array with names of the backends to be skipped |
|
438 | 437 | * e.g. array('popup', 'winpopup') |
439 | 438 | */ |
440 | 439 | public function set_skip_backends(array $_skip_backends) { |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @version $Id$ |
10 | 10 | */ |
11 | 11 | |
12 | -if (!defined('SEP')) define('SEP','/'); |
|
12 | +if (!defined('SEP')) define('SEP', '/'); |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Notifies users according to their preferences. |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * |
180 | 180 | */ |
181 | 181 | public function __construct() { |
182 | - $this->config = (object) config::read(self::_appname); |
|
182 | + $this->config = (object)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 preferences($receiver->account_id); |
484 | 484 | $preferences = $prefs->read(); |
485 | 485 | $preferences = (object)$preferences[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,27 +503,27 @@ 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 | try { |
512 | 512 | // check if backend should be skipped |
513 | - if( in_array($backend, $this->skip_backends) ) { |
|
513 | + if (in_array($backend, $this->skip_backends)) { |
|
514 | 514 | // log as error just for the case too much skipping prevents user from being notified |
515 | 515 | $backend_errors[] = $backend.' will be skipped (as defined by calling application)'; |
516 | 516 | continue; |
517 | 517 | } |
518 | 518 | |
519 | 519 | $notification_backend = self::_appname.'_'.$backend; |
520 | - if(!file_exists(EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.'. $notification_backend. '.inc.php')) { |
|
521 | - throw new Exception('file for '.$notification_backend. ' does not exist'); |
|
520 | + if (!file_exists(EGW_INCLUDE_ROOT.SEP.self::_appname.SEP.'inc'.SEP.'class.'.$notification_backend.'.inc.php')) { |
|
521 | + throw new Exception('file for '.$notification_backend.' does not exist'); |
|
522 | 522 | } |
523 | - $obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences ); |
|
524 | - if ( !($obj instanceof notifications_iface) ) { |
|
525 | - unset ( $obj ); |
|
526 | - throw new Exception($notification_backend. ' is no implementation of notifications_iface'); |
|
523 | + $obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences); |
|
524 | + if (!($obj instanceof notifications_iface)) { |
|
525 | + unset ($obj); |
|
526 | + throw new Exception($notification_backend.' is no implementation of notifications_iface'); |
|
527 | 527 | } |
528 | 528 | $lsubject = $this->subject; |
529 | 529 | $llinks = $this->links; |
@@ -537,17 +537,17 @@ discard block |
||
537 | 537 | catch (Exception $exception) { |
538 | 538 | $backend_errors[] = $notification_backend.' failed: '.$exception->getMessage(); |
539 | 539 | // try next backend |
540 | - if($action == 'fail' || $action == 'continue') { |
|
540 | + if ($action == 'fail' || $action == 'continue') { |
|
541 | 541 | continue; |
542 | 542 | } |
543 | 543 | break; // stop running through chain |
544 | 544 | } |
545 | 545 | // backend sucseeded |
546 | 546 | $user_notified = true; |
547 | - if($action == 'stop' || $action == 'fail') { break; } // stop running through chain |
|
547 | + if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain |
|
548 | 548 | } |
549 | 549 | // check if the user has been notified at all |
550 | - if(!$user_notified) { |
|
550 | + if (!$user_notified) { |
|
551 | 551 | /*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:'); |
552 | 552 | foreach($backend_errors as $id=>$backend_error) { |
553 | 553 | error_log($backend_error); |
@@ -574,22 +574,22 @@ discard block |
||
574 | 574 | * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup'] |
575 | 575 | */ |
576 | 576 | private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') { |
577 | - if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set |
|
577 | + if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set |
|
578 | 578 | $messages = array(); |
579 | 579 | |
580 | 580 | // create the messages |
581 | - if(!empty($_message_plain)) { |
|
581 | + if (!empty($_message_plain)) { |
|
582 | 582 | $messages['plain'] = $_message_plain; |
583 | 583 | } else { |
584 | 584 | $messages['plain'] = translation::convertHTMLToText($_message_html, false, true); |
585 | 585 | } |
586 | 586 | |
587 | - if(!empty($_message_html)) { |
|
587 | + if (!empty($_message_html)) { |
|
588 | 588 | $messages['html'] = $_message_html; |
589 | 589 | } else { |
590 | 590 | $messages['html'] = self::plain2html($_message_plain); |
591 | 591 | } |
592 | - if (!empty($_message_popup)) $messages['popup']=$_message_popup; |
|
592 | + if (!empty($_message_popup)) $messages['popup'] = $_message_popup; |
|
593 | 593 | return $messages; |
594 | 594 | } |
595 | 595 | |
@@ -612,9 +612,9 @@ discard block |
||
612 | 612 | * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html'] |
613 | 613 | */ |
614 | 614 | private function prepend_message(array $_messages, $_prepend = null) { |
615 | - if(strlen($_prepend) > 0) { |
|
616 | - foreach($_messages as $key => $value) { |
|
617 | - switch($key) { |
|
615 | + if (strlen($_prepend) > 0) { |
|
616 | + foreach ($_messages as $key => $value) { |
|
617 | + switch ($key) { |
|
618 | 618 | case 'plain': |
619 | 619 | $_messages[$key] = $_prepend."\n\n".$value; |
620 | 620 | break; |
@@ -638,15 +638,15 @@ discard block |
||
638 | 638 | * @param string $_part |
639 | 639 | * @return string chosen part of the address |
640 | 640 | */ |
641 | - private function get_addresspart($_address, $_part='email') { |
|
642 | - if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part |
|
643 | - $fullname = trim(trim($parts[1]),'\"'); |
|
641 | + private function get_addresspart($_address, $_part = 'email') { |
|
642 | + if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part |
|
643 | + $fullname = trim(trim($parts[1]), '\"'); |
|
644 | 644 | $email = $parts[2]; |
645 | 645 | } else { |
646 | 646 | $fullname = false; |
647 | 647 | $email = $_address; |
648 | 648 | } |
649 | - switch($_part) { |
|
649 | + switch ($_part) { |
|
650 | 650 | case 'fullname': |
651 | 651 | return $fullname; |
652 | 652 | break; |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | public function get_available_chains($_output = 'routing') { |
671 | 671 | // determine enabled backends from config |
672 | 672 | $enabled_backends = array(); |
673 | - foreach($this->backends as $id => $backend) { |
|
674 | - switch($backend) { |
|
673 | + foreach ($this->backends as $id => $backend) { |
|
674 | + switch ($backend) { |
|
675 | 675 | case 'email': |
676 | 676 | case 'popup': |
677 | 677 | case 'jpopup': |
@@ -686,15 +686,15 @@ discard block |
||
686 | 686 | |
687 | 687 | $enabled_chains = array(); |
688 | 688 | $disabled_chains = array(); |
689 | - foreach($this->notification_chains as $key => $chain) { |
|
689 | + foreach ($this->notification_chains as $key => $chain) { |
|
690 | 690 | $allow_chain = true; |
691 | - if(is_array($chain)) { |
|
692 | - foreach($chain as $name => $action) { |
|
693 | - if(!$enabled_backends[$name]) { |
|
691 | + if (is_array($chain)) { |
|
692 | + foreach ($chain as $name => $action) { |
|
693 | + if (!$enabled_backends[$name]) { |
|
694 | 694 | $allow_chain = false; // disable whole chain if one backend is disabled |
695 | 695 | } |
696 | 696 | } |
697 | - if($allow_chain) { |
|
697 | + if ($allow_chain) { |
|
698 | 698 | $enabled_chains[$key] = $chain; |
699 | 699 | } else { |
700 | 700 | $disabled_chains[$key] = $chain; |
@@ -709,15 +709,15 @@ discard block |
||
709 | 709 | // create the 'all' chain from the enabled backends |
710 | 710 | $chain_all = array(); |
711 | 711 | $backend_count = 1; |
712 | - foreach($enabled_backends as $backend => $enabled) { |
|
713 | - if($enabled) { |
|
712 | + foreach ($enabled_backends as $backend => $enabled) { |
|
713 | + if ($enabled) { |
|
714 | 714 | $chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue'; |
715 | 715 | } |
716 | 716 | $backend_count++; |
717 | 717 | } |
718 | 718 | $common_chains['all'] = $chain_all; |
719 | 719 | |
720 | - switch($_output) { |
|
720 | + switch ($_output) { |
|
721 | 721 | case 'human': |
722 | 722 | $chain_groups = array( |
723 | 723 | lang('Common chains') => 'common_chains', |
@@ -726,10 +726,10 @@ discard block |
||
726 | 726 | ); |
727 | 727 | $suffix = '_human'; |
728 | 728 | // create descriptions for each chain key in each group |
729 | - foreach($chain_groups as $name => $arr_name) { |
|
729 | + foreach ($chain_groups as $name => $arr_name) { |
|
730 | 730 | ${$arr_name.$suffix} = array(); |
731 | - foreach(${$arr_name} as $key => $value) { |
|
732 | - if($arr_name == 'disabled_chains') { |
|
731 | + foreach (${$arr_name} as $key => $value) { |
|
732 | + if ($arr_name == 'disabled_chains') { |
|
733 | 733 | ${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]); |
734 | 734 | } else { |
735 | 735 | ${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]); |
@@ -738,8 +738,8 @@ discard block |
||
738 | 738 | } |
739 | 739 | // summarize all groups with minimum one chain to the final array |
740 | 740 | $chains_final = array(); |
741 | - foreach($chain_groups as $name => $arr_name) { |
|
742 | - if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) { |
|
741 | + foreach ($chain_groups as $name => $arr_name) { |
|
742 | + if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) { |
|
743 | 743 | $chains_final[$name] = ${$arr_name.$suffix}; |
744 | 744 | } |
745 | 745 | } |
@@ -761,10 +761,10 @@ discard block |
||
761 | 761 | * @param settings array with keys account_id and new_owner (new_owner is optional) |
762 | 762 | */ |
763 | 763 | public function deleteaccount($settings) { |
764 | - foreach($this->backends as $backend) { |
|
765 | - $backend_hook = array(self::_appname.'_'.$backend,'deleteaccount'); |
|
764 | + foreach ($this->backends as $backend) { |
|
765 | + $backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount'); |
|
766 | 766 | if (is_callable($backend_hook)) { |
767 | - call_user_func($backend_hook,$settings); |
|
767 | + call_user_func($backend_hook, $settings); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
@@ -9,7 +9,10 @@ discard block |
||
9 | 9 | * @version $Id$ |
10 | 10 | */ |
11 | 11 | |
12 | -if (!defined('SEP')) define('SEP','/'); |
|
12 | +if (!defined('SEP')) |
|
13 | +{ |
|
14 | + define('SEP','/'); |
|
15 | +} |
|
13 | 16 | |
14 | 17 | /** |
15 | 18 | * Notifies users according to their preferences. |
@@ -24,7 +27,8 @@ discard block |
||
24 | 27 | * called from this class. The backend's job is to deliver ONE message to ONE recipient. |
25 | 28 | * |
26 | 29 | */ |
27 | -final class notifications { |
|
30 | +final class notifications |
|
31 | +{ |
|
28 | 32 | |
29 | 33 | /** |
30 | 34 | * Appname |
@@ -178,7 +182,8 @@ discard block |
||
178 | 182 | * constructor of notifications |
179 | 183 | * |
180 | 184 | */ |
181 | - public function __construct() { |
|
185 | + public function __construct() |
|
186 | + { |
|
182 | 187 | $this->config = (object) config::read(self::_appname); |
183 | 188 | } |
184 | 189 | |
@@ -191,7 +196,10 @@ discard block |
||
191 | 196 | public static function errors($reset=false) |
192 | 197 | { |
193 | 198 | $ret = self::$errors; |
194 | - if ($reset) self::$errors = array(); |
|
199 | + if ($reset) |
|
200 | + { |
|
201 | + self::$errors = array(); |
|
202 | + } |
|
195 | 203 | return $ret; |
196 | 204 | } |
197 | 205 | |
@@ -202,17 +210,23 @@ discard block |
||
202 | 210 | * as long as the accounts class isn't a nice object, |
203 | 211 | * it's an int with the account id or the e-mail address of a non-eGW user |
204 | 212 | */ |
205 | - public function set_sender($_sender) { |
|
206 | - if(is_object($_sender)) { |
|
213 | + public function set_sender($_sender) |
|
214 | + { |
|
215 | + if(is_object($_sender)) |
|
216 | + { |
|
207 | 217 | $this->sender = $_sender; |
208 | 218 | return true; |
209 | - } else { |
|
219 | + } |
|
220 | + else |
|
221 | + { |
|
210 | 222 | // no object atm, we have to handle this and make a pseudo-object |
211 | - if(is_numeric($_sender)) { |
|
223 | + if(is_numeric($_sender)) |
|
224 | + { |
|
212 | 225 | $this->sender = (object) $GLOBALS['egw']->accounts->read($_sender); |
213 | 226 | return true; |
214 | 227 | } |
215 | - if(is_string($_sender) && strpos($_sender,'@')) { |
|
228 | + if(is_string($_sender) && strpos($_sender,'@')) |
|
229 | + { |
|
216 | 230 | $this->sender = (object) array ( |
217 | 231 | 'account_email' => $this->get_addresspart($_sender,'email'), |
218 | 232 | 'account_fullname' => $this->get_addresspart($_sender,'fullname'), |
@@ -230,9 +244,11 @@ discard block |
||
230 | 244 | * as long as the accounts class isn't a nice object, |
231 | 245 | * it's an array with the int of the account id or the e-mail address of a non-eGW user |
232 | 246 | */ |
233 | - public function set_receivers(array $_receivers) { |
|
247 | + public function set_receivers(array $_receivers) |
|
248 | + { |
|
234 | 249 | $this->receivers = array(); |
235 | - foreach ($_receivers as $receiver) { |
|
250 | + foreach ($_receivers as $receiver) |
|
251 | + { |
|
236 | 252 | $this->add_receiver($receiver); |
237 | 253 | } |
238 | 254 | } |
@@ -244,17 +260,23 @@ discard block |
||
244 | 260 | * as long as the accounts class isn't a nice object, |
245 | 261 | * it's an int with the account id or the e-mail address of a non-eGW user |
246 | 262 | */ |
247 | - public function add_receiver($_receiver) { |
|
248 | - if(is_object($_receiver)) { |
|
263 | + public function add_receiver($_receiver) |
|
264 | + { |
|
265 | + if(is_object($_receiver)) |
|
266 | + { |
|
249 | 267 | $this->receivers[] = $_receiver; |
250 | 268 | return true; |
251 | - } else { |
|
269 | + } |
|
270 | + else |
|
271 | + { |
|
252 | 272 | // no object atm, we have to handle this and make a pseudo-object |
253 | - if(is_numeric($_receiver)) { |
|
273 | + if(is_numeric($_receiver)) |
|
274 | + { |
|
254 | 275 | $this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver); |
255 | 276 | return true; |
256 | 277 | } |
257 | - if(is_string($_receiver) && strpos($_receiver,'@')) { |
|
278 | + if(is_string($_receiver) && strpos($_receiver,'@')) |
|
279 | + { |
|
258 | 280 | $this->receivers[] = (object) array ( |
259 | 281 | 'account_email' => $this->get_addresspart($_receiver,'email'), |
260 | 282 | 'account_fullname' => $this->get_addresspart($_receiver,'fullname'), |
@@ -270,7 +292,8 @@ discard block |
||
270 | 292 | * |
271 | 293 | * @param string $_subject |
272 | 294 | */ |
273 | - public function set_subject($_subject) { |
|
295 | + public function set_subject($_subject) |
|
296 | + { |
|
274 | 297 | $this->subject = $_subject; |
275 | 298 | return true; |
276 | 299 | } |
@@ -280,7 +303,8 @@ discard block |
||
280 | 303 | * |
281 | 304 | * @param string $_subject |
282 | 305 | */ |
283 | - public function set_popupsubject($_subject) { |
|
306 | + public function set_popupsubject($_subject) |
|
307 | + { |
|
284 | 308 | $this->popupsubject = $_subject; |
285 | 309 | return true; |
286 | 310 | } |
@@ -295,10 +319,14 @@ discard block |
||
295 | 319 | * |
296 | 320 | * @param string $_message |
297 | 321 | */ |
298 | - public function set_message($_message) { |
|
299 | - if(strlen($_message) == strlen(strip_tags($_message))) { |
|
322 | + public function set_message($_message) |
|
323 | + { |
|
324 | + if(strlen($_message) == strlen(strip_tags($_message))) |
|
325 | + { |
|
300 | 326 | $this->message_plain = $_message; |
301 | - } else { |
|
327 | + } |
|
328 | + else |
|
329 | + { |
|
302 | 330 | $this->message_html = $_message; |
303 | 331 | } |
304 | 332 | return true; |
@@ -312,9 +340,13 @@ discard block |
||
312 | 340 | * |
313 | 341 | * @param string $_message |
314 | 342 | */ |
315 | - public function set_popupmessage($_message) { |
|
343 | + public function set_popupmessage($_message) |
|
344 | + { |
|
316 | 345 | //popup requires html |
317 | - if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message); |
|
346 | + if(strlen($_message) == strlen(strip_tags($_message))) |
|
347 | + { |
|
348 | + $_message = self::plain2html($_message); |
|
349 | + } |
|
318 | 350 | $this->message_popup = $_message; |
319 | 351 | return true; |
320 | 352 | } |
@@ -324,10 +356,13 @@ discard block |
||
324 | 356 | * |
325 | 357 | * @param array $_links link array (like defined in $this->add_link) |
326 | 358 | */ |
327 | - public function set_links(array $_links) { |
|
359 | + public function set_links(array $_links) |
|
360 | + { |
|
328 | 361 | $this->links = array(); // clear array if set |
329 | - foreach($_links as $link) { |
|
330 | - if(is_array($link)) { |
|
362 | + foreach($_links as $link) |
|
363 | + { |
|
364 | + if(is_array($link)) |
|
365 | + { |
|
331 | 366 | $this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']); |
332 | 367 | } |
333 | 368 | } |
@@ -339,10 +374,13 @@ discard block |
||
339 | 374 | * |
340 | 375 | * @param array $_links link array (like defined in $this->add_link) |
341 | 376 | */ |
342 | - public function set_popuplinks(array $_links) { |
|
377 | + public function set_popuplinks(array $_links) |
|
378 | + { |
|
343 | 379 | $this->popup_links = array(); // clear array if set |
344 | - foreach($_links as $link) { |
|
345 | - if(is_array($link)) { |
|
380 | + foreach($_links as $link) |
|
381 | + { |
|
382 | + if(is_array($link)) |
|
383 | + { |
|
346 | 384 | $this->add_popuplink($link['text'], $link['view'], $link['popup']); |
347 | 385 | } |
348 | 386 | } |
@@ -358,8 +396,11 @@ discard block |
||
358 | 396 | * @param string $_app Application name, to use link registry (popup & view ignored) |
359 | 397 | * @param string $_id Application ID, to use link registry (popup & view ignored) |
360 | 398 | */ |
361 | - public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) { |
|
362 | - if(!$_view || !$_text) { return false; } |
|
399 | + public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) |
|
400 | + { |
|
401 | + if(!$_view || !$_text) |
|
402 | + { |
|
403 | +return false; } |
|
363 | 404 | $this->links[] = (object)array( |
364 | 405 | 'text' => $_text, |
365 | 406 | 'view' => $_view, |
@@ -377,8 +418,11 @@ discard block |
||
377 | 418 | * @param array $_view all params needed to view the link (name => value pairs) |
378 | 419 | * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false |
379 | 420 | */ |
380 | - public function add_popuplink($_text, $_view, $_popup = false) { |
|
381 | - if(!$_view || !$_text) { return false; } |
|
421 | + public function add_popuplink($_text, $_view, $_popup = false) |
|
422 | + { |
|
423 | + if(!$_view || !$_text) |
|
424 | + { |
|
425 | +return false; } |
|
382 | 426 | $this->popup_links[] = (object)array( 'text' => $_text, |
383 | 427 | 'view' => $_view, |
384 | 428 | 'popup' => $_popup, |
@@ -391,10 +435,13 @@ discard block |
||
391 | 435 | * |
392 | 436 | * @param array $_attachments attachment array (like defined in $this->add_attachment) |
393 | 437 | */ |
394 | - public function set_attachments(array $_attachments) { |
|
438 | + public function set_attachments(array $_attachments) |
|
439 | + { |
|
395 | 440 | $this->attachments = array(); // clear array if set |
396 | - foreach($_attachments as $attachment) { |
|
397 | - if(is_array($attachment)) { |
|
441 | + foreach($_attachments as $attachment) |
|
442 | + { |
|
443 | + if(is_array($attachment)) |
|
444 | + { |
|
398 | 445 | $this->add_attachment( |
399 | 446 | $attachment['string'], |
400 | 447 | $attachment['filename'], |
@@ -418,8 +465,12 @@ discard block |
||
418 | 465 | * @param string $_type File extension (MIME) type. |
419 | 466 | * @param string $_path optional path to attachment, if !$_string |
420 | 467 | */ |
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; |
|
468 | + public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) |
|
469 | + { |
|
470 | + if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) |
|
471 | + { |
|
472 | + return false; |
|
473 | + } |
|
423 | 474 | $this->attachments[] = (object)array( |
424 | 475 | 'string' => $_string, |
425 | 476 | 'filename' => $_filename, |
@@ -437,33 +488,40 @@ discard block |
||
437 | 488 | * @param array $_skip_backends array with names of the backends to be skipped |
438 | 489 | * e.g. array('popup', 'winpopup') |
439 | 490 | */ |
440 | - public function set_skip_backends(array $_skip_backends) { |
|
491 | + public function set_skip_backends(array $_skip_backends) |
|
492 | + { |
|
441 | 493 | $this->skip_backends = $_skip_backends; |
442 | 494 | } |
443 | 495 | |
444 | 496 | /** |
445 | 497 | * sends notifications |
446 | 498 | */ |
447 | - public function send() { |
|
448 | - if (!is_object($this->sender)) { |
|
499 | + public function send() |
|
500 | + { |
|
501 | + if (!is_object($this->sender)) |
|
502 | + { |
|
449 | 503 | throw new Exception('Error: cannot send notifications. No sender supplied'); |
450 | 504 | } |
451 | - if (!is_array($this->receivers) || count($this->receivers) == 0) { |
|
505 | + if (!is_array($this->receivers) || count($this->receivers) == 0) |
|
506 | + { |
|
452 | 507 | throw new Exception('Error: cannot send notifications. No receivers supplied'); |
453 | 508 | } |
454 | - if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) { |
|
509 | + if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) |
|
510 | + { |
|
455 | 511 | throw new Exception('Error: cannot send notifications. No valid messages supplied'); |
456 | 512 | } |
457 | 513 | |
458 | 514 | $available_chains = $this->get_available_chains('routing'); |
459 | 515 | |
460 | - foreach ($this->receivers as $receiver) { |
|
516 | + foreach ($this->receivers as $receiver) |
|
517 | + { |
|
461 | 518 | $user_notified = false; |
462 | 519 | $prepend_message = ''; |
463 | 520 | $backend_errors = array(); |
464 | 521 | try { |
465 | 522 | // system or non-system user |
466 | - if($receiver->account_id && is_numeric($receiver->account_id)) { |
|
523 | + if($receiver->account_id && is_numeric($receiver->account_id)) |
|
524 | + { |
|
467 | 525 | // system user, collect data and check for Status and expire state, skip notification if expired or not active |
468 | 526 | $userData = $GLOBALS['egw']->accounts->read($receiver->account_id); |
469 | 527 | //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,50 +536,64 @@ discard block |
||
478 | 536 | // check if the receiver has rights to run the notifcation app |
479 | 537 | $ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true); |
480 | 538 | $ids[] = $receiver->account_id; |
481 | - if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) { |
|
539 | + if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) |
|
540 | + { |
|
482 | 541 | // read the users notification chain |
483 | 542 | $prefs = new preferences($receiver->account_id); |
484 | 543 | $preferences = $prefs->read(); |
485 | 544 | $preferences = (object)$preferences[self::_appname]; |
486 | - if($preferences->notification_chain) { |
|
545 | + if($preferences->notification_chain) |
|
546 | + { |
|
487 | 547 | // fallback: admin disabled user-chosen chain |
488 | - if(!$notification_chain = $available_chains[$preferences->notification_chain]) { |
|
548 | + if(!$notification_chain = $available_chains[$preferences->notification_chain]) |
|
549 | + { |
|
489 | 550 | $prepend_message .= lang( 'This eGroupWare notification has been sent to you by mail because your' |
490 | 551 | .' chosen notification-chain has been disabled by the administrator.' |
491 | 552 | .' Please choose another notification-chain in your preferences!'); |
492 | 553 | $notification_chain = $available_chains[self::_fallback]; |
493 | 554 | } |
494 | - } else { |
|
555 | + } |
|
556 | + else |
|
557 | + { |
|
495 | 558 | $notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs |
496 | 559 | } |
497 | - } else { |
|
560 | + } |
|
561 | + else |
|
562 | + { |
|
498 | 563 | $notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app |
499 | 564 | } |
500 | - } else { |
|
565 | + } |
|
566 | + else |
|
567 | + { |
|
501 | 568 | // non-system user |
502 | 569 | $receiver->handle = $receiver->account_email; |
503 | 570 | $notification_chain = $available_chains[self::_fallback]; // fallback: non-system user |
504 | 571 | } |
505 | 572 | |
506 | - if($notification_chain == 'disable') { |
|
573 | + if($notification_chain == 'disable') |
|
574 | + { |
|
507 | 575 | continue; //user disabled notifications |
508 | 576 | } |
509 | 577 | |
510 | - foreach($notification_chain as $backend => $action) { |
|
578 | + foreach($notification_chain as $backend => $action) |
|
579 | + { |
|
511 | 580 | try { |
512 | 581 | // check if backend should be skipped |
513 | - if( in_array($backend, $this->skip_backends) ) { |
|
582 | + if( in_array($backend, $this->skip_backends) ) |
|
583 | + { |
|
514 | 584 | // log as error just for the case too much skipping prevents user from being notified |
515 | 585 | $backend_errors[] = $backend.' will be skipped (as defined by calling application)'; |
516 | 586 | continue; |
517 | 587 | } |
518 | 588 | |
519 | 589 | $notification_backend = self::_appname.'_'.$backend; |
520 | - if(!file_exists(EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.'. $notification_backend. '.inc.php')) { |
|
590 | + if(!file_exists(EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.'. $notification_backend. '.inc.php')) |
|
591 | + { |
|
521 | 592 | throw new Exception('file for '.$notification_backend. ' does not exist'); |
522 | 593 | } |
523 | 594 | $obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences ); |
524 | - if ( !($obj instanceof notifications_iface) ) { |
|
595 | + if ( !($obj instanceof notifications_iface) ) |
|
596 | + { |
|
525 | 597 | unset ( $obj ); |
526 | 598 | throw new Exception($notification_backend. ' is no implementation of notifications_iface'); |
527 | 599 | } |
@@ -529,31 +601,44 @@ discard block |
||
529 | 601 | $llinks = $this->links; |
530 | 602 | if ($backend == 'popup') |
531 | 603 | { |
532 | - if (!empty($this->popupsubject)) $lsubject = $this->popupsubject; |
|
533 | - if ($this->popup_links) $llinks = $this->popup_links; |
|
604 | + if (!empty($this->popupsubject)) |
|
605 | + { |
|
606 | + $lsubject = $this->popupsubject; |
|
607 | + } |
|
608 | + if ($this->popup_links) |
|
609 | + { |
|
610 | + $llinks = $this->popup_links; |
|
611 | + } |
|
534 | 612 | } |
535 | 613 | $obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments); |
536 | 614 | } |
537 | 615 | catch (Exception $exception) { |
538 | 616 | $backend_errors[] = $notification_backend.' failed: '.$exception->getMessage(); |
539 | 617 | // try next backend |
540 | - if($action == 'fail' || $action == 'continue') { |
|
618 | + if($action == 'fail' || $action == 'continue') |
|
619 | + { |
|
541 | 620 | continue; |
542 | 621 | } |
543 | 622 | break; // stop running through chain |
544 | 623 | } |
545 | 624 | // backend sucseeded |
546 | 625 | $user_notified = true; |
547 | - if($action == 'stop' || $action == 'fail') { break; } // stop running through chain |
|
626 | + if($action == 'stop' || $action == 'fail') |
|
627 | + { |
|
628 | +break; } // stop running through chain |
|
548 | 629 | } |
549 | 630 | // check if the user has been notified at all |
550 | - if(!$user_notified) { |
|
631 | + if(!$user_notified) |
|
632 | + { |
|
551 | 633 | /*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:'); |
552 | 634 | foreach($backend_errors as $id=>$backend_error) { |
553 | 635 | error_log($backend_error); |
554 | 636 | }*/ |
555 | 637 | $error = implode(', ', $backend_errors); |
556 | - if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error; |
|
638 | + if (stripos($error, (string)$receiver->handle) !== false) |
|
639 | + { |
|
640 | + $error = $receiver->handle.': '.$error; |
|
641 | + } |
|
557 | 642 | self::$errors[] = $error; |
558 | 643 | } |
559 | 644 | } |
@@ -573,23 +658,35 @@ discard block |
||
573 | 658 | * @param string $_message_popup |
574 | 659 | * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup'] |
575 | 660 | */ |
576 | - private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') { |
|
577 | - if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set |
|
661 | + private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') |
|
662 | + { |
|
663 | + if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) |
|
664 | + { |
|
665 | +return false; } // no message set |
|
578 | 666 | $messages = array(); |
579 | 667 | |
580 | 668 | // create the messages |
581 | - if(!empty($_message_plain)) { |
|
669 | + if(!empty($_message_plain)) |
|
670 | + { |
|
582 | 671 | $messages['plain'] = $_message_plain; |
583 | - } else { |
|
672 | + } |
|
673 | + else |
|
674 | + { |
|
584 | 675 | $messages['plain'] = translation::convertHTMLToText($_message_html, false, true); |
585 | 676 | } |
586 | 677 | |
587 | - if(!empty($_message_html)) { |
|
678 | + if(!empty($_message_html)) |
|
679 | + { |
|
588 | 680 | $messages['html'] = $_message_html; |
589 | - } else { |
|
681 | + } |
|
682 | + else |
|
683 | + { |
|
590 | 684 | $messages['html'] = self::plain2html($_message_plain); |
591 | 685 | } |
592 | - if (!empty($_message_popup)) $messages['popup']=$_message_popup; |
|
686 | + if (!empty($_message_popup)) |
|
687 | + { |
|
688 | + $messages['popup']=$_message_popup; |
|
689 | + } |
|
593 | 690 | return $messages; |
594 | 691 | } |
595 | 692 | |
@@ -611,10 +708,14 @@ discard block |
||
611 | 708 | * @param string $_prepend just a plain message to prepend, no html! |
612 | 709 | * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html'] |
613 | 710 | */ |
614 | - private function prepend_message(array $_messages, $_prepend = null) { |
|
615 | - if(strlen($_prepend) > 0) { |
|
616 | - foreach($_messages as $key => $value) { |
|
617 | - switch($key) { |
|
711 | + private function prepend_message(array $_messages, $_prepend = null) |
|
712 | + { |
|
713 | + if(strlen($_prepend) > 0) |
|
714 | + { |
|
715 | + foreach($_messages as $key => $value) |
|
716 | + { |
|
717 | + switch($key) |
|
718 | + { |
|
618 | 719 | case 'plain': |
619 | 720 | $_messages[$key] = $_prepend."\n\n".$value; |
620 | 721 | break; |
@@ -638,15 +739,21 @@ discard block |
||
638 | 739 | * @param string $_part |
639 | 740 | * @return string chosen part of the address |
640 | 741 | */ |
641 | - private function get_addresspart($_address, $_part='email') { |
|
642 | - if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part |
|
742 | + private function get_addresspart($_address, $_part='email') |
|
743 | + { |
|
744 | + if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) |
|
745 | + { |
|
746 | +// _address contains a fullname part |
|
643 | 747 | $fullname = trim(trim($parts[1]),'\"'); |
644 | 748 | $email = $parts[2]; |
645 | - } else { |
|
749 | + } |
|
750 | + else |
|
751 | + { |
|
646 | 752 | $fullname = false; |
647 | 753 | $email = $_address; |
648 | 754 | } |
649 | - switch($_part) { |
|
755 | + switch($_part) |
|
756 | + { |
|
650 | 757 | case 'fullname': |
651 | 758 | return $fullname; |
652 | 759 | break; |
@@ -667,11 +774,14 @@ discard block |
||
667 | 774 | * @param string $_output one of: 'routing' or 'human', defaults to 'routing' |
668 | 775 | * @return array containing notification chains, output like given in $_output |
669 | 776 | */ |
670 | - public function get_available_chains($_output = 'routing') { |
|
777 | + public function get_available_chains($_output = 'routing') |
|
778 | + { |
|
671 | 779 | // determine enabled backends from config |
672 | 780 | $enabled_backends = array(); |
673 | - foreach($this->backends as $id => $backend) { |
|
674 | - switch($backend) { |
|
781 | + foreach($this->backends as $id => $backend) |
|
782 | + { |
|
783 | + switch($backend) |
|
784 | + { |
|
675 | 785 | case 'email': |
676 | 786 | case 'popup': |
677 | 787 | case 'jpopup': |
@@ -686,17 +796,24 @@ discard block |
||
686 | 796 | |
687 | 797 | $enabled_chains = array(); |
688 | 798 | $disabled_chains = array(); |
689 | - foreach($this->notification_chains as $key => $chain) { |
|
799 | + foreach($this->notification_chains as $key => $chain) |
|
800 | + { |
|
690 | 801 | $allow_chain = true; |
691 | - if(is_array($chain)) { |
|
692 | - foreach($chain as $name => $action) { |
|
693 | - if(!$enabled_backends[$name]) { |
|
802 | + if(is_array($chain)) |
|
803 | + { |
|
804 | + foreach($chain as $name => $action) |
|
805 | + { |
|
806 | + if(!$enabled_backends[$name]) |
|
807 | + { |
|
694 | 808 | $allow_chain = false; // disable whole chain if one backend is disabled |
695 | 809 | } |
696 | 810 | } |
697 | - if($allow_chain) { |
|
811 | + if($allow_chain) |
|
812 | + { |
|
698 | 813 | $enabled_chains[$key] = $chain; |
699 | - } else { |
|
814 | + } |
|
815 | + else |
|
816 | + { |
|
700 | 817 | $disabled_chains[$key] = $chain; |
701 | 818 | } |
702 | 819 | } |
@@ -709,15 +826,18 @@ discard block |
||
709 | 826 | // create the 'all' chain from the enabled backends |
710 | 827 | $chain_all = array(); |
711 | 828 | $backend_count = 1; |
712 | - foreach($enabled_backends as $backend => $enabled) { |
|
713 | - if($enabled) { |
|
829 | + foreach($enabled_backends as $backend => $enabled) |
|
830 | + { |
|
831 | + if($enabled) |
|
832 | + { |
|
714 | 833 | $chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue'; |
715 | 834 | } |
716 | 835 | $backend_count++; |
717 | 836 | } |
718 | 837 | $common_chains['all'] = $chain_all; |
719 | 838 | |
720 | - switch($_output) { |
|
839 | + switch($_output) |
|
840 | + { |
|
721 | 841 | case 'human': |
722 | 842 | $chain_groups = array( |
723 | 843 | lang('Common chains') => 'common_chains', |
@@ -726,20 +846,27 @@ discard block |
||
726 | 846 | ); |
727 | 847 | $suffix = '_human'; |
728 | 848 | // create descriptions for each chain key in each group |
729 | - foreach($chain_groups as $name => $arr_name) { |
|
849 | + foreach($chain_groups as $name => $arr_name) |
|
850 | + { |
|
730 | 851 | ${$arr_name.$suffix} = array(); |
731 | - foreach(${$arr_name} as $key => $value) { |
|
732 | - if($arr_name == 'disabled_chains') { |
|
852 | + foreach(${$arr_name} as $key => $value) |
|
853 | + { |
|
854 | + if($arr_name == 'disabled_chains') |
|
855 | + { |
|
733 | 856 | ${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]); |
734 | - } else { |
|
857 | + } |
|
858 | + else |
|
859 | + { |
|
735 | 860 | ${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]); |
736 | 861 | } |
737 | 862 | } |
738 | 863 | } |
739 | 864 | // summarize all groups with minimum one chain to the final array |
740 | 865 | $chains_final = array(); |
741 | - foreach($chain_groups as $name => $arr_name) { |
|
742 | - if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) { |
|
866 | + foreach($chain_groups as $name => $arr_name) |
|
867 | + { |
|
868 | + if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) |
|
869 | + { |
|
743 | 870 | $chains_final[$name] = ${$arr_name.$suffix}; |
744 | 871 | } |
745 | 872 | } |
@@ -760,10 +887,13 @@ discard block |
||
760 | 887 | * |
761 | 888 | * @param settings array with keys account_id and new_owner (new_owner is optional) |
762 | 889 | */ |
763 | - public function deleteaccount($settings) { |
|
764 | - foreach($this->backends as $backend) { |
|
890 | + public function deleteaccount($settings) |
|
891 | + { |
|
892 | + foreach($this->backends as $backend) |
|
893 | + { |
|
765 | 894 | $backend_hook = array(self::_appname.'_'.$backend,'deleteaccount'); |
766 | - if (is_callable($backend_hook)) { |
|
895 | + if (is_callable($backend_hook)) |
|
896 | + { |
|
767 | 897 | call_user_func($backend_hook,$settings); |
768 | 898 | } |
769 | 899 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * @version $Id$ |
15 | 15 | */ |
16 | 16 | // forward for not existing or empty header to setup |
17 | -if(!file_exists('header.inc.php') || !filesize('header.inc.php')) |
|
17 | +if (!file_exists('header.inc.php') || !filesize('header.inc.php')) |
|
18 | 18 | { |
19 | 19 | Header('Location: setup/index.php'); |
20 | 20 | exit; |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | Header('Content-Type: application/json; charset=utf-8'); |
63 | 63 | echo json_encode($times, JSON_PRETTY_PRINT); |
64 | 64 | |
65 | -function php_times($account, array &$times, $prefix='php_') |
|
65 | +function php_times($account, array &$times, $prefix = 'php_') |
|
66 | 66 | { |
67 | 67 | $starttime = microtime(true); |
68 | - switch($account->acc_imap_ssl & ~emailadmin_account::SSL_VERIFY) |
|
68 | + switch ($account->acc_imap_ssl&~emailadmin_account::SSL_VERIFY) |
|
69 | 69 | { |
70 | 70 | case emailadmin_account::SSL_SSL: |
71 | 71 | $schema = 'ssl'; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | $error_number = $error_string = null; |
82 | 82 | $stream = stream_socket_client( |
83 | - $schema . '://' . $account->acc_imap_host . ':' . $account->acc_imap_port, |
|
83 | + $schema.'://'.$account->acc_imap_host.':'.$account->acc_imap_port, |
|
84 | 84 | $error_number, |
85 | 85 | $error_string, |
86 | 86 | 20, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $connect_response = fgets($stream); |
99 | 99 | |
100 | 100 | // starttls (untested) |
101 | - if ($stream && ($account->acc_imap_ssl & ~emailadmin_account::SSL_VERIFY) == emailadmin_account::SSL_STARTTLS) |
|
101 | + if ($stream && ($account->acc_imap_ssl&~emailadmin_account::SSL_VERIFY) == emailadmin_account::SSL_STARTTLS) |
|
102 | 102 | { |
103 | 103 | fwrite($stream, "10 STARTTLS\r\n"); |
104 | 104 | stream_socket_enable_crypto($stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | unset($connect_response, $starttls_response, $login_response, $error_number, $error_string); |
129 | 129 | } |
130 | 130 | |
131 | -function mail_times($acc_id, array &$times, $prefix='mail_') |
|
131 | +function mail_times($acc_id, array &$times, $prefix = 'mail_') |
|
132 | 132 | { |
133 | 133 | global $cache; |
134 | 134 | $starttime = microtime(true); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $mail_ui->mail_bo->icServer->logout(); |
184 | 184 | } |
185 | 185 | |
186 | -function horde_times(emailadmin_account $account, array &$times, $prefix='horde_') |
|
186 | +function horde_times(emailadmin_account $account, array &$times, $prefix = 'horde_') |
|
187 | 187 | { |
188 | 188 | $starttime = microtime(true); |
189 | 189 | $imap = $account->imapServer(); |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | $imap->logout(); |
216 | 216 | } |
217 | 217 | |
218 | -function horde_fetch(Horde_Imap_Client_Socket $client, $mailbox='INBOX') |
|
218 | +function horde_fetch(Horde_Imap_Client_Socket $client, $mailbox = 'INBOX') |
|
219 | 219 | { |
220 | 220 | $squery = new Horde_Imap_Client_Search_Query(); |
221 | 221 | // using a date filter to limit returned uids, gives huge speed improvement on big mailboxes, because less uids returned |
222 | 222 | //$squery->dateSearch(new DateTime('-30days'), Horde_Imap_Client_Search_Query::DATE_SINCE, false, false); |
223 | - $squery->flag('DELETED', $set=false); |
|
223 | + $squery->flag('DELETED', $set = false); |
|
224 | 224 | $sorted = $client->search($mailbox, $squery, array( |
225 | 225 | 'sort' => array(Horde_Imap_Client::SORT_REVERSE, Horde_Imap_Client::SORT_SEQUENCE), |
226 | 226 | )); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $first20uids->add(array_slice($sorted['match']->ids, 0, 20)); |
230 | 230 | |
231 | 231 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
232 | - $fquery->headers('headers', array('Subject', 'From', 'To', 'Cc', 'Date'), array('peek' => true,'cache' => true)); |
|
232 | + $fquery->headers('headers', array('Subject', 'From', 'To', 'Cc', 'Date'), array('peek' => true, 'cache' => true)); |
|
233 | 233 | $fquery->structure(); |
234 | 234 | $fquery->flags(); |
235 | 235 | $fquery->imapDate(); |
@@ -43,7 +43,10 @@ discard block |
||
43 | 43 | // switching off caching by default |
44 | 44 | // if caching is enabled mail_times will always provit from previous running horde_times! |
45 | 45 | $cache = isset($_GET['cache']) && $_GET['cache']; |
46 | -if (!$cache) unset(emailadmin_imap::$default_params['cache']); |
|
46 | +if (!$cache) |
|
47 | +{ |
|
48 | + unset(emailadmin_imap::$default_params['cache']); |
|
49 | +} |
|
47 | 50 | |
48 | 51 | $accounttime = microtime(true); |
49 | 52 | |
@@ -106,7 +109,8 @@ discard block |
||
106 | 109 | } |
107 | 110 | stream_set_timeout($stream, 20); |
108 | 111 | |
109 | - if (function_exists('stream_set_read_buffer')) { |
|
112 | + if (function_exists('stream_set_read_buffer')) |
|
113 | + { |
|
110 | 114 | stream_set_read_buffer($stream, 0); |
111 | 115 | } |
112 | 116 | stream_set_write_buffer($stream, 0); |
@@ -24,8 +24,8 @@ |
||
24 | 24 | // if no rows/rights found, give Default group rights |
25 | 25 | if (!$GLOBALS['egw_setup']->db->affected_rows()) |
26 | 26 | { |
27 | - $defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); |
|
28 | - $GLOBALS['egw_setup']->add_acl('mail','run',$defaultgroup); |
|
27 | + $defaultgroup = $GLOBALS['egw_setup']->add_account('Default', 'Default', 'Group', False, False); |
|
28 | + $GLOBALS['egw_setup']->add_acl('mail', 'run', $defaultgroup); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // change common/default_app pref to mail, if it was felamimail |
@@ -2126,11 +2126,11 @@ discard block |
||
2126 | 2126 | } else { |
2127 | 2127 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
2128 | 2128 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
2129 | - $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2130 | - @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
|
2129 | + $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2130 | + @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
|
2131 | 2131 | $toAddress.$ccAddress. |
2132 | 2132 | @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n". |
2133 | - '-------------------------------------------------'."\r\n \r\n "; |
|
2133 | + '-------------------------------------------------'."\r\n \r\n "; |
|
2134 | 2134 | $this->sessionData['mimeType'] = 'plain'; |
2135 | 2135 | |
2136 | 2136 | for($i=0; $i<count($bodyParts); $i++) { |
@@ -2968,7 +2968,7 @@ discard block |
||
2968 | 2968 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
2969 | 2969 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
2970 | 2970 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
2971 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
2971 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
2972 | 2972 | $mail_bo = $this->mail_bo; |
2973 | 2973 | $mail_bo->openConnection(); |
2974 | 2974 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
@@ -1477,6 +1477,10 @@ discard block |
||
1477 | 1477 | // $_mode can be: |
1478 | 1478 | // single: for a reply to one address |
1479 | 1479 | // all: for a reply to all |
1480 | + |
|
1481 | + /** |
|
1482 | + * @param emailadmin_imap $_icServer |
|
1483 | + */ |
|
1480 | 1484 | function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL) |
1481 | 1485 | { |
1482 | 1486 | unset($_icServer); // not used |
@@ -1673,6 +1677,9 @@ discard block |
||
1673 | 1677 | return false; |
1674 | 1678 | } |
1675 | 1679 | |
1680 | + /** |
|
1681 | + * @param emailadmin_imap $_icServer |
|
1682 | + */ |
|
1676 | 1683 | function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false) |
1677 | 1684 | { |
1678 | 1685 | if ($_mode) |
@@ -1932,7 +1939,7 @@ discard block |
||
1932 | 1939 | /** |
1933 | 1940 | * Gather the replyData and save it with the session, to be used then |
1934 | 1941 | * |
1935 | - * @param $_mode can be: |
|
1942 | + * @param string $_mode can be: |
|
1936 | 1943 | * single: for a reply to one address |
1937 | 1944 | * all: for a reply to all |
1938 | 1945 | * forward: inlineforwarding of a message with its attachments |
@@ -15,8 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class mail_compose |
17 | 17 | { |
18 | - var $public_functions = array |
|
19 | - ( |
|
18 | + var $public_functions = array( |
|
20 | 19 | 'compose' => True, |
21 | 20 | 'getAttachment' => True, |
22 | 21 | ); |
@@ -25,8 +24,8 @@ discard block |
||
25 | 24 | * class vars for destination, priorities, mimeTypes |
26 | 25 | */ |
27 | 26 | static $destinations = array( |
28 | - 'to' => 'to', // lang('to') |
|
29 | - 'cc' => 'cc', // lang('cc') |
|
27 | + 'to' => 'to', // lang('to') |
|
28 | + 'cc' => 'cc', // lang('cc') |
|
30 | 29 | 'bcc' => 'bcc', // lang('bcc') |
31 | 30 | 'replyto' => 'replyto', // lang('replyto') |
32 | 31 | 'folder' => 'folder' // lang('folder') |
@@ -54,20 +53,20 @@ discard block |
||
54 | 53 | * @var array |
55 | 54 | */ |
56 | 55 | var $mailPreferences; |
57 | - var $attachments; // Array of attachments |
|
56 | + var $attachments; // Array of attachments |
|
58 | 57 | var $displayCharset; |
59 | 58 | var $composeID; |
60 | 59 | var $sessionData; |
61 | 60 | |
62 | 61 | function __construct() |
63 | 62 | { |
64 | - $this->displayCharset = translation::charset(); |
|
63 | + $this->displayCharset = translation::charset(); |
|
65 | 64 | |
66 | 65 | $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
67 | - $this->mail_bo = mail_bo::getInstance(true,$profileID); |
|
66 | + $this->mail_bo = mail_bo::getInstance(true, $profileID); |
|
68 | 67 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->mail_bo->profileID; |
69 | 68 | |
70 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
69 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
71 | 70 | //force the default for the forwarding -> asmail |
72 | 71 | if (!is_array($this->mailPreferences) || empty($this->mailPreferences['message_forwarding'])) |
73 | 72 | { |
@@ -75,7 +74,7 @@ discard block |
||
75 | 74 | } |
76 | 75 | if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail'); |
77 | 76 | |
78 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
77 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | /** |
@@ -85,15 +84,15 @@ discard block |
||
85 | 84 | */ |
86 | 85 | function changeProfile($_icServerID) |
87 | 86 | { |
88 | - if ($this->mail_bo->profileID!=$_icServerID) |
|
87 | + if ($this->mail_bo->profileID != $_icServerID) |
|
89 | 88 | { |
90 | 89 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
91 | - $this->mail_bo = mail_bo::getInstance(false,$_icServerID); |
|
90 | + $this->mail_bo = mail_bo::getInstance(false, $_icServerID); |
|
92 | 91 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
93 | 92 | // no icServer Object: something failed big time |
94 | 93 | if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
95 | 94 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
96 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
95 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
97 | 96 | } |
98 | 97 | } |
99 | 98 | |
@@ -189,7 +188,7 @@ discard block |
||
189 | 188 | 'hint' => 'Select the message priority tag', |
190 | 189 | |
191 | 190 | ), |
192 | - 'save2vfs' => array ( |
|
191 | + 'save2vfs' => array( |
|
193 | 192 | 'caption' => 'Save to VFS', |
194 | 193 | 'icon' => 'filesave', |
195 | 194 | 'group' => ++$group, |
@@ -235,7 +234,7 @@ discard block |
||
235 | 234 | * @var boolean $suppressSigOnTop =false |
236 | 235 | * @var boolean $isReply =false |
237 | 236 | */ |
238 | - function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
|
237 | + function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false) |
|
239 | 238 | { |
240 | 239 | if ($msg) egw_framework::message($msg); |
241 | 240 | |
@@ -256,14 +255,14 @@ discard block |
||
256 | 255 | //lang('compose'),lang('from') // needed to be found by translationtools |
257 | 256 | //error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace()); |
258 | 257 | //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); |
259 | - $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; |
|
260 | - $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; |
|
258 | + $_contentHasSigID = $_content ? array_key_exists('mailidentity', (array)$_content) : false; |
|
259 | + $_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false; |
|
261 | 260 | if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; |
262 | 261 | if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; |
263 | 262 | |
264 | 263 | // Process different places we can use as a start for composing an email |
265 | 264 | $actionToProcess = 'compose'; |
266 | - if($_GET['from'] && $replyID) |
|
265 | + if ($_GET['from'] && $replyID) |
|
267 | 266 | { |
268 | 267 | $_content = array_merge((array)$_content, $this->getComposeFrom( |
269 | 268 | // Parameters needed for fetching appropriate data |
@@ -281,10 +280,10 @@ discard block |
||
281 | 280 | } |
282 | 281 | |
283 | 282 | $composeCache = array(); |
284 | - if (isset($_content['composeID'])&&!empty($_content['composeID'])) |
|
283 | + if (isset($_content['composeID']) && !empty($_content['composeID'])) |
|
285 | 284 | { |
286 | 285 | $isFirstLoad = false; |
287 | - $composeCache = egw_cache::getCache(egw_cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2); |
|
286 | + $composeCache = egw_cache::getCache(egw_cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'], $callback = null, $callback_params = array(), $expiration = 60 * 60 * 2); |
|
288 | 287 | $this->composeID = $_content['composeID']; |
289 | 288 | //error_log(__METHOD__.__LINE__.array2string($composeCache)); |
290 | 289 | } |
@@ -294,7 +293,7 @@ discard block |
||
294 | 293 | // respect that composeasnew may not want that, as we assume there |
295 | 294 | // is some style already set and our initalStyle always adds a span with |
296 | 295 | // and we want to avoid that |
297 | - $isFirstLoad = !($actionToProcess=='composeasnew');//true; |
|
296 | + $isFirstLoad = !($actionToProcess == 'composeasnew'); //true; |
|
298 | 297 | $this->composeID = $_content['composeID'] = $this->generateComposeID(); |
299 | 298 | if (!is_array($_content)) |
300 | 299 | { |
@@ -329,7 +328,7 @@ discard block |
||
329 | 328 | if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
330 | 329 | try |
331 | 330 | { |
332 | - $upload['file'] = $upload['tmp_name'] = mail_bo::checkFileBasics($upload,$this->composeID,false); |
|
331 | + $upload['file'] = $upload['tmp_name'] = mail_bo::checkFileBasics($upload, $this->composeID, false); |
|
333 | 332 | } |
334 | 333 | catch (egw_exception_wrong_userinput $e) |
335 | 334 | { |
@@ -355,12 +354,12 @@ discard block |
||
355 | 354 | unset($_content['attachments']['delete']); |
356 | 355 | $attachments = $_content['attachments']; |
357 | 356 | unset($_content['attachments']); |
358 | - foreach($attachments as $i => $att) |
|
357 | + foreach ($attachments as $i => $att) |
|
359 | 358 | { |
360 | - $remove=false; |
|
361 | - foreach(array_keys($toDelete) as $k) |
|
359 | + $remove = false; |
|
360 | + foreach (array_keys($toDelete) as $k) |
|
362 | 361 | { |
363 | - if ($att['tmp_name']==$k) $remove=true; |
|
362 | + if ($att['tmp_name'] == $k) $remove = true; |
|
364 | 363 | } |
365 | 364 | if (!$remove) $_content['attachments'][] = $att; |
366 | 365 | } |
@@ -368,7 +367,7 @@ discard block |
||
368 | 367 | // someone clicked something like send, or saveAsDraft |
369 | 368 | // make sure, we are connected to the correct server for sending and storing the send message |
370 | 369 | $activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose |
371 | - $activeFolderCache = egw_cache::getCache(egw_cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10); |
|
370 | + $activeFolderCache = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10); |
|
372 | 371 | if (!empty($activeFolderCache[$this->mail_bo->profileID])) |
373 | 372 | { |
374 | 373 | //error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]); |
@@ -376,7 +375,7 @@ discard block |
||
376 | 375 | } |
377 | 376 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
378 | 377 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
379 | - ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
|
378 | + ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint']) |
|
380 | 379 | ) |
381 | 380 | { |
382 | 381 | $this->changeProfile($_content['serverID']); |
@@ -390,19 +389,19 @@ discard block |
||
390 | 389 | { |
391 | 390 | $buttonClicked = $suppressSigOnTop = true; |
392 | 391 | $sendOK = true; |
393 | - $_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']); |
|
392 | + $_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']); |
|
394 | 393 | /* |
395 | 394 | perform some simple checks, before trying to send on: |
396 | 395 | $_content['to'];$_content['cc'];$_content['bcc']; |
397 | 396 | trim($_content['subject']); |
398 | 397 | trim(strip_tags(str_replace(' ','',$_content['body']))); |
399 | 398 | */ |
400 | - if (strlen(trim(strip_tags(str_replace(' ','',$_content['body']))))==0 && count($_content['attachments'])==0) |
|
399 | + if (strlen(trim(strip_tags(str_replace(' ', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0) |
|
401 | 400 | { |
402 | 401 | $sendOK = false; |
403 | 402 | $_content['msg'] = $message = lang("no message body supplied"); |
404 | 403 | } |
405 | - if ($sendOK && strlen(trim($_content['subject']))==0) |
|
404 | + if ($sendOK && strlen(trim($_content['subject'])) == 0) |
|
406 | 405 | { |
407 | 406 | $sendOK = false; |
408 | 407 | $_content['msg'] = $message = lang("no subject supplied"); |
@@ -417,15 +416,15 @@ discard block |
||
417 | 416 | try |
418 | 417 | { |
419 | 418 | $success = $this->send($_content); |
420 | - if ($success==false) |
|
419 | + if ($success == false) |
|
421 | 420 | { |
422 | - $sendOK=false; |
|
421 | + $sendOK = false; |
|
423 | 422 | $message = $this->errorInfo; |
424 | 423 | } |
425 | 424 | if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID]) |
426 | 425 | { |
427 | - $sigPref[$this->mail_bo->profileID]=$_content['mailidentity']; |
|
428 | - $GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user'); |
|
426 | + $sigPref[$this->mail_bo->profileID] = $_content['mailidentity']; |
|
427 | + $GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user'); |
|
429 | 428 | // save prefs |
430 | 429 | $GLOBALS['egw']->preferences->save_repository(true); |
431 | 430 | } |
@@ -449,23 +448,23 @@ discard block |
||
449 | 448 | if (isset($_content['mode']) && !empty($_content['mode'])) |
450 | 449 | { |
451 | 450 | $mode = $_content['mode']; |
452 | - if ($_content['mode']=='forward' && !empty($_content['processedmail_id'])) |
|
451 | + if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id'])) |
|
453 | 452 | { |
454 | - $_content['processedmail_id'] = explode(',',$_content['processedmail_id']); |
|
453 | + $_content['processedmail_id'] = explode(',', $_content['processedmail_id']); |
|
455 | 454 | foreach ($_content['processedmail_id'] as $k =>$rowid) |
456 | 455 | { |
457 | 456 | $fhA = mail_ui::splitRowID($rowid); |
458 | 457 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
459 | 458 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
460 | - $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
|
459 | + $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false); |
|
461 | 460 | if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
462 | 461 | } |
463 | 462 | } |
464 | - if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
|
463 | + if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id'])) |
|
465 | 464 | { |
466 | 465 | $rhA = mail_ui::splitRowID($_content['processedmail_id']); |
467 | 466 | //$this->sessionData['uid'] = $rhA['msgUID']; |
468 | - $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false); |
|
467 | + $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false); |
|
469 | 468 | $workingFolder = $rhA['folder']; |
470 | 469 | } |
471 | 470 | } |
@@ -473,30 +472,30 @@ discard block |
||
473 | 472 | if (empty($idsForRefresh) && !empty($_content['processedmail_id'])) |
474 | 473 | { |
475 | 474 | $rhA = mail_ui::splitRowID($_content['processedmail_id']); |
476 | - $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false); |
|
475 | + $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false); |
|
477 | 476 | } |
478 | 477 | $response = egw_json_response::get(); |
479 | 478 | if ($activeProfile != $composeProfile) |
480 | 479 | { |
481 | 480 | // we need a message only, when account ids (composeProfile vs. activeProfile) differ |
482 | - $response->call('opener.egw_message',lang('Message send successfully.')); |
|
481 | + $response->call('opener.egw_message', lang('Message send successfully.')); |
|
483 | 482 | } |
484 | - elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))) |
|
483 | + elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))) |
|
485 | 484 | { |
486 | - if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)) |
|
485 | + if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)) |
|
487 | 486 | { |
488 | 487 | // we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action |
489 | - $response->call('opener.egw_refresh',lang('Message send successfully.'),'mail'); |
|
488 | + $response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail'); |
|
490 | 489 | } |
491 | 490 | else |
492 | 491 | { |
493 | 492 | //error_log(__METHOD__.__LINE__.array2string($idsForRefresh)); |
494 | - $response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update'); |
|
493 | + $response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update'); |
|
495 | 494 | } |
496 | 495 | } |
497 | 496 | else |
498 | 497 | { |
499 | - $response->call('opener.egw_message',lang('Message send successfully.')); |
|
498 | + $response->call('opener.egw_message', lang('Message send successfully.')); |
|
500 | 499 | } |
501 | 500 | //egw_framework::refresh_opener(lang('Message send successfully.'),'mail'); |
502 | 501 | egw_framework::window_close(); |
@@ -504,60 +503,60 @@ discard block |
||
504 | 503 | if ($sendOK == false) |
505 | 504 | { |
506 | 505 | $response = egw_json_response::get(); |
507 | - egw_framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate |
|
506 | + egw_framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate |
|
508 | 507 | $response->call('app.mail.clearIntevals'); |
509 | 508 | } |
510 | 509 | } |
511 | 510 | |
512 | 511 | if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
513 | 512 | $insertSigOnTop = false; |
514 | - $content = (is_array($_content)?$_content:array()); |
|
513 | + $content = (is_array($_content) ? $_content : array()); |
|
515 | 514 | if ($_contentHasMimeType) |
516 | 515 | { |
517 | 516 | // mimeType is now a checkbox; convert it here to match expectations |
518 | 517 | // ToDo: match Code to meet checkbox value |
519 | - if ($content['mimeType']==1) |
|
518 | + if ($content['mimeType'] == 1) |
|
520 | 519 | { |
521 | - $_content['mimeType'] = $content['mimeType']='html'; |
|
520 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
522 | 521 | } |
523 | 522 | else |
524 | 523 | { |
525 | - $_content['mimeType'] = $content['mimeType']='plain'; |
|
524 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
526 | 525 | } |
527 | 526 | |
528 | 527 | } |
529 | 528 | // user might have switched desired mimetype, so we should convert |
530 | - if ($content['is_html'] && $content['mimeType']=='plain') |
|
529 | + if ($content['is_html'] && $content['mimeType'] == 'plain') |
|
531 | 530 | { |
532 | 531 | //error_log(__METHOD__.__LINE__.$content['mail_htmltext']); |
533 | 532 | $suppressSigOnTop = true; |
534 | - if (stripos($content['mail_htmltext'],'<pre>')!==false) |
|
533 | + if (stripos($content['mail_htmltext'], '<pre>') !== false) |
|
535 | 534 | { |
536 | 535 | $contentArr = html::splithtmlByPRE($content['mail_htmltext']); |
537 | 536 | if (is_array($contentArr)) |
538 | 537 | { |
539 | 538 | foreach ($contentArr as $k =>&$elem) |
540 | 539 | { |
541 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
540 | + if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem); |
|
542 | 541 | } |
543 | - $content['mail_htmltext'] = implode('',$contentArr); |
|
542 | + $content['mail_htmltext'] = implode('', $contentArr); |
|
544 | 543 | } |
545 | 544 | } |
546 | 545 | $content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']); |
547 | - $content['mail_htmltext'] = translation::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true); |
|
546 | + $content['mail_htmltext'] = translation::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true); |
|
548 | 547 | |
549 | 548 | $content['body'] = $content['mail_htmltext']; |
550 | 549 | unset($content['mail_htmltext']); |
551 | 550 | $content['is_html'] = false; |
552 | 551 | $content['is_plain'] = true; |
553 | 552 | } |
554 | - if ($content['is_plain'] && $content['mimeType']=='html') |
|
553 | + if ($content['is_plain'] && $content['mimeType'] == 'html') |
|
555 | 554 | { |
556 | 555 | // the possible font span should only be applied on first load or on switch plain->html |
557 | 556 | $isFirstLoad = "switchedplaintohtml"; |
558 | 557 | //error_log(__METHOD__.__LINE__.$content['mail_plaintext']); |
559 | 558 | $suppressSigOnTop = true; |
560 | - $content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']); |
|
559 | + $content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']); |
|
561 | 560 | //$this->replaceEmailAdresses($content['mail_plaintext']); |
562 | 561 | $content['body'] = $content['mail_plaintext']; |
563 | 562 | unset($content['mail_plaintext']); |
@@ -565,14 +564,14 @@ discard block |
||
565 | 564 | $content['is_plain'] = false; |
566 | 565 | } |
567 | 566 | |
568 | - $content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']); |
|
567 | + $content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']); |
|
569 | 568 | unset($_content['body']); |
570 | 569 | unset($_content['mail_htmltext']); |
571 | 570 | unset($_content['mail_plaintext']); |
572 | 571 | |
573 | 572 | // form was submitted either by clicking a button or by changing one of the triggering selectboxes |
574 | 573 | // identity and signatureid; this might trigger that the signature in mail body may have to be altered |
575 | - if ( !empty($content['body']) && |
|
574 | + if (!empty($content['body']) && |
|
576 | 575 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
577 | 576 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
578 | 577 | ) |
@@ -583,7 +582,7 @@ discard block |
||
583 | 582 | { |
584 | 583 | $acc = emailadmin_account::read($_content['mailaccount']); |
585 | 584 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
586 | - $Identities = emailadmin_account::read_identity($acc['ident_id'],true); |
|
585 | + $Identities = emailadmin_account::read_identity($acc['ident_id'], true); |
|
587 | 586 | //error_log(__METHOD__.__LINE__.array2string($Identities)); |
588 | 587 | if ($Identities['ident_id']) |
589 | 588 | { |
@@ -596,41 +595,41 @@ discard block |
||
596 | 595 | } |
597 | 596 | } |
598 | 597 | $_oldSig = $composeCache['mailidentity']; |
599 | - $_signatureid = ($newSig?$newSig:$_content['mailidentity']); |
|
598 | + $_signatureid = ($newSig ? $newSig : $_content['mailidentity']); |
|
600 | 599 | $_currentMode = $_content['mimeType']; |
601 | 600 | if ($_oldSig != $_signatureid) |
602 | 601 | { |
603 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
602 | + if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
604 | 603 | // prepare signatures, the selected sig may be used on top of the body |
605 | 604 | try |
606 | 605 | { |
607 | - $oldSignature = emailadmin_account::read_identity($_oldSig,true); |
|
606 | + $oldSignature = emailadmin_account::read_identity($_oldSig, true); |
|
608 | 607 | //error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#'); |
609 | 608 | $oldSigText = $oldSignature['ident_signature']; |
610 | 609 | } |
611 | 610 | catch (Exception $e) |
612 | 611 | { |
613 | - $oldSignature=array(); |
|
612 | + $oldSignature = array(); |
|
614 | 613 | $oldSigText = null; |
615 | 614 | } |
616 | 615 | try |
617 | 616 | { |
618 | - $signature = emailadmin_account::read_identity($_signatureid,true); |
|
617 | + $signature = emailadmin_account::read_identity($_signatureid, true); |
|
619 | 618 | //error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#'); |
620 | 619 | $sigText = $signature['ident_signature']; |
621 | 620 | } |
622 | 621 | catch (Exception $e) |
623 | 622 | { |
624 | - $signature=array(); |
|
623 | + $signature = array(); |
|
625 | 624 | $sigText = null; |
626 | 625 | } |
627 | 626 | //error_log(__METHOD__.'Old:'.$oldSigText.'#'); |
628 | 627 | //error_log(__METHOD__.'New:'.$sigText.'#'); |
629 | 628 | if ($_currentMode == 'plain') |
630 | 629 | { |
631 | - $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
|
632 | - $sigText = $this->convertHTMLToText($sigText,true,true); |
|
633 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
630 | + $oldSigText = $this->convertHTMLToText($oldSigText, true, true); |
|
631 | + $sigText = $this->convertHTMLToText($sigText, true, true); |
|
632 | + if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
634 | 633 | } |
635 | 634 | |
636 | 635 | //$oldSigText = mail_bo::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -640,22 +639,22 @@ discard block |
||
640 | 639 | $_htmlConfig = mail_bo::$htmLawed_config; |
641 | 640 | mail_bo::$htmLawed_config['comment'] = 2; |
642 | 641 | mail_bo::$htmLawed_config['transform_anchor'] = false; |
643 | - $oldSigTextCleaned = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($oldSigText,null,array(),true):$oldSigText)); |
|
642 | + $oldSigTextCleaned = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), ($_currentMode == 'html' ? html::purify($oldSigText, null, array(), true) : $oldSigText)); |
|
644 | 643 | //error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#'); |
645 | 644 | if ($_currentMode == 'html') |
646 | 645 | { |
647 | - $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
|
646 | + $content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace |
|
648 | 647 | $styles = mail_bo::getStyles(array(array('body'=>$content['body']))); |
649 | - if (stripos($content['body'],'style')!==false) translation::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags |
|
648 | + if (stripos($content['body'], 'style') !== false) translation::replaceTagsCompletley($content['body'], 'style', $endtag = '', true); // clean out empty or pagewide style definitions / left over tags |
|
650 | 649 | } |
651 | - $content['body'] = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($content['body'],mail_bo::$htmLawed_config,array(),true):$content['body'])); |
|
650 | + $content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), ($_currentMode == 'html' ? html::purify($content['body'], mail_bo::$htmLawed_config, array(), true) : $content['body'])); |
|
652 | 651 | mail_bo::$htmLawed_config = $_htmlConfig; |
653 | 652 | if ($_currentMode == 'html') |
654 | 653 | { |
655 | 654 | $replaced = null; |
656 | - $content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u', |
|
657 | - $rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced); |
|
658 | - $content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'–','—','€'),$content['body']); |
|
655 | + $content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u', |
|
656 | + $rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced); |
|
657 | + $content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '–', '—', '€'), $content['body']); |
|
659 | 658 | //error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced"); |
660 | 659 | unset($rep, $in); |
661 | 660 | if ($replaced) |
@@ -666,32 +665,32 @@ discard block |
||
666 | 665 | else |
667 | 666 | { |
668 | 667 | // try the old way |
669 | - $found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false); |
|
668 | + $found = (strlen(trim($oldSigTextCleaned)) > 0 ? strpos($content['body'], trim($oldSigTextCleaned)) : false); |
|
670 | 669 | } |
671 | 670 | } |
672 | 671 | else |
673 | 672 | { |
674 | - $found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false); |
|
673 | + $found = (strlen(trim($oldSigTextCleaned)) > 0 ? strpos($content['body'], trim($oldSigTextCleaned)) : false); |
|
675 | 674 | } |
676 | 675 | |
677 | - if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) =='')) |
|
676 | + if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == '')) |
|
678 | 677 | { |
679 | 678 | //error_log(__METHOD__.'Old Content:'.$content['body'].'#'); |
680 | - $_oldSigText = preg_quote($oldSigTextCleaned,'~'); |
|
679 | + $_oldSigText = preg_quote($oldSigTextCleaned, '~'); |
|
681 | 680 | //error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#'); |
682 | - $content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1); |
|
681 | + $content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1); |
|
683 | 682 | //error_log(__METHOD__.'new Content:'.$content['body'].'#'); |
684 | 683 | } |
685 | 684 | |
686 | - if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) =='')) |
|
685 | + if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == '')) |
|
687 | 686 | { |
688 | 687 | // if there is no sig selected, there is no way to replace a signature |
689 | 688 | } |
690 | 689 | |
691 | 690 | if ($found === false) |
692 | 691 | { |
693 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
694 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
692 | + if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
693 | + if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
695 | 694 | } |
696 | 695 | else |
697 | 696 | { |
@@ -710,7 +709,7 @@ discard block |
||
710 | 709 | if ($isFirstLoad) |
711 | 710 | { |
712 | 711 | $alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached |
713 | - if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) && |
|
712 | + if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) && |
|
714 | 713 | $this->mailPreferences['attachVCardAtCompose'])) |
715 | 714 | { |
716 | 715 | $alwaysAttachVCardAtCompose = true; |
@@ -719,7 +718,7 @@ discard block |
||
719 | 718 | $f = $_REQUEST['preset']['file']; |
720 | 719 | $_REQUEST['preset']['file'] = array($f); |
721 | 720 | } |
722 | - $_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry"; |
|
721 | + $_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry"; |
|
723 | 722 | } |
724 | 723 | // an app passed the request for fetching and mailing an entry |
725 | 724 | if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])) |
@@ -728,33 +727,33 @@ discard block |
||
728 | 727 | $mt = $_REQUEST['method']; |
729 | 728 | $id = $_REQUEST['id']; |
730 | 729 | // passed method MUST be registered |
731 | - $method = egw_link::get_registry($app,$mt); |
|
730 | + $method = egw_link::get_registry($app, $mt); |
|
732 | 731 | //error_log(__METHOD__.__LINE__.array2string($method)); |
733 | 732 | if ($method) |
734 | 733 | { |
735 | - $res = ExecMethod($method,array($id,'html')); |
|
734 | + $res = ExecMethod($method, array($id, 'html')); |
|
736 | 735 | //error_log(__METHOD__.__LINE__.array2string($res)); |
737 | 736 | if (!empty($res)) |
738 | 737 | { |
739 | 738 | $insertSigOnTop = 'below'; |
740 | 739 | if (isset($res['attachments']) && is_array($res['attachments'])) |
741 | 740 | { |
742 | - foreach($res['attachments'] as $f) |
|
741 | + foreach ($res['attachments'] as $f) |
|
743 | 742 | { |
744 | 743 | $_REQUEST['preset']['file'][] = $f; |
745 | 744 | } |
746 | 745 | } |
747 | 746 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
748 | - foreach(array('subject','body','mimetype') as $name) { |
|
747 | + foreach (array('subject', 'body', 'mimetype') as $name) { |
|
749 | 748 | $sName = $name; |
750 | - if ($name=='mimetype'&&$res[$name]) |
|
749 | + if ($name == 'mimetype' && $res[$name]) |
|
751 | 750 | { |
752 | 751 | $sName = 'mimeType'; |
753 | 752 | $content[$sName] = $res[$name]; |
754 | 753 | } |
755 | 754 | else |
756 | 755 | { |
757 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
756 | + if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name]; |
|
758 | 757 | } |
759 | 758 | } |
760 | 759 | } |
@@ -763,44 +762,44 @@ discard block |
||
763 | 762 | // handle preset info/values |
764 | 763 | if (is_array($_REQUEST['preset'])) |
765 | 764 | { |
766 | - $alreadyProcessed=array(); |
|
765 | + $alreadyProcessed = array(); |
|
767 | 766 | //_debug_array($_REQUEST); |
768 | 767 | if ($_REQUEST['preset']['mailto']) { |
769 | 768 | // handle mailto strings such as |
770 | 769 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
771 | 770 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
772 | 771 | // first, strip the mailto: string out of the mailto URL |
773 | - $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
|
772 | + $tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7))); |
|
774 | 773 | // check if there is more than the to address |
775 | - $mailtoArray = explode('?',$tmp_send_to,2); |
|
774 | + $mailtoArray = explode('?', $tmp_send_to, 2); |
|
776 | 775 | if ($mailtoArray[1]) { |
777 | 776 | // check if there are more than one requests |
778 | - $addRequests = explode('&',$mailtoArray[1]); |
|
777 | + $addRequests = explode('&', $mailtoArray[1]); |
|
779 | 778 | foreach ($addRequests as $key => $reqval) { |
780 | 779 | // the additional requests should have a =, to separate key from value. |
781 | - $keyValuePair = explode('=',$reqval,2); |
|
782 | - $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1]; |
|
780 | + $keyValuePair = explode('=', $reqval, 2); |
|
781 | + $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1]; |
|
783 | 782 | } |
784 | 783 | } |
785 | - $content['to']=$mailtoArray[0]; |
|
786 | - $alreadyProcessed['to']='to'; |
|
784 | + $content['to'] = $mailtoArray[0]; |
|
785 | + $alreadyProcessed['to'] = 'to'; |
|
787 | 786 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
788 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
789 | - $alreadyProcessed[$name]=$name; |
|
790 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
787 | + foreach (array('cc', 'bcc', 'subject', 'body') as $name) { |
|
788 | + $alreadyProcessed[$name] = $name; |
|
789 | + if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name]; |
|
791 | 790 | } |
792 | 791 | } |
793 | 792 | |
794 | 793 | if ($_REQUEST['preset']['mailtocontactbyid']) { |
795 | 794 | if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
796 | - $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
797 | - if (method_exists($GLOBALS['egw']->contacts,'search')) { |
|
795 | + $addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
796 | + if (method_exists($GLOBALS['egw']->contacts, 'search')) { |
|
798 | 797 | |
799 | - $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
|
798 | + $addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']); |
|
800 | 799 | foreach ((array)$addressArray as $id => $addressID) |
801 | 800 | { |
802 | - $addressID = (int) $addressID; |
|
803 | - if (!($addressID>0)) |
|
801 | + $addressID = (int)$addressID; |
|
802 | + if (!($addressID > 0)) |
|
804 | 803 | { |
805 | 804 | unset($addressArray[$id]); |
806 | 805 | } |
@@ -809,44 +808,44 @@ discard block |
||
809 | 808 | { |
810 | 809 | $_searchCond = array('contact_id'=>$addressArray); |
811 | 810 | //error_log(__METHOD__.__LINE__.$_searchString); |
812 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false; |
|
813 | - $filter = ($showAccounts?array():array('account_id' => null)); |
|
814 | - $filter['cols_to_search']=array('n_fn','email','email_home'); |
|
815 | - $contacts = $GLOBALS['egw']->contacts->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); |
|
811 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts = false; |
|
812 | + $filter = ($showAccounts ? array() : array('account_id' => null)); |
|
813 | + $filter['cols_to_search'] = array('n_fn', 'email', 'email_home'); |
|
814 | + $contacts = $GLOBALS['egw']->contacts->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
816 | 815 | // additionally search the accounts, if the contact storage is not the account storage |
817 | 816 | if ($showAccounts && |
818 | 817 | $GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && |
819 | 818 | $GLOBALS['egw_info']['server']['contact_repository'] == 'sql') |
820 | 819 | { |
821 | - $accounts = $GLOBALS['egw']->contacts->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0)); |
|
820 | + $accounts = $GLOBALS['egw']->contacts->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0)); |
|
822 | 821 | |
823 | 822 | if ($contacts && $accounts) |
824 | 823 | { |
825 | - $contacts = array_merge($contacts,$accounts); |
|
826 | - usort($contacts,create_function('$a,$b','return strcasecmp($a["n_fn"],$b["n_fn"]);')); |
|
824 | + $contacts = array_merge($contacts, $accounts); |
|
825 | + usort($contacts, create_function('$a,$b', 'return strcasecmp($a["n_fn"],$b["n_fn"]);')); |
|
827 | 826 | } |
828 | - elseif($accounts) |
|
827 | + elseif ($accounts) |
|
829 | 828 | { |
830 | - $contacts =& $accounts; |
|
829 | + $contacts = & $accounts; |
|
831 | 830 | } |
832 | 831 | unset($accounts); |
833 | 832 | } |
834 | 833 | } |
835 | - if(is_array($contacts)) { |
|
834 | + if (is_array($contacts)) { |
|
836 | 835 | $mailtoArray = array(); |
837 | 836 | $primary = $addressbookprefs['distributionListPreferredMail']; |
838 | 837 | if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
839 | - $secondary = ($primary == 'email'?'email_home':'email'); |
|
838 | + $secondary = ($primary == 'email' ? 'email_home' : 'email'); |
|
840 | 839 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
841 | - foreach($contacts as $contact) { |
|
842 | - $innerCounter=0; |
|
843 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
840 | + foreach ($contacts as $contact) { |
|
841 | + $innerCounter = 0; |
|
842 | + foreach (array($contact[$primary], $contact[$secondary]) as $email) { |
|
844 | 843 | // use pref distributionListPreferredMail for the primary address |
845 | 844 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
846 | - $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
|
847 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
848 | - $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
|
849 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
845 | + $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email); |
|
846 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
847 | + $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>'); |
|
848 | + if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) { |
|
850 | 849 | $i++; |
851 | 850 | $innerCounter++; |
852 | 851 | $mailtoArray[$i] = $completeMailString; |
@@ -855,8 +854,8 @@ discard block |
||
855 | 854 | } |
856 | 855 | } |
857 | 856 | //error_log(__METHOD__.__LINE__.array2string($mailtoArray)); |
858 | - $alreadyProcessed['to']='to'; |
|
859 | - $content['to']=$mailtoArray; |
|
857 | + $alreadyProcessed['to'] = 'to'; |
|
858 | + $content['to'] = $mailtoArray; |
|
860 | 859 | } |
861 | 860 | } |
862 | 861 | } |
@@ -871,20 +870,20 @@ discard block |
||
871 | 870 | $types = (array)$_REQUEST['preset']['type']; |
872 | 871 | //if (!empty($types) && in_array('text/calendar; method=request',$types)) |
873 | 872 | $files = (array)$_REQUEST['preset']['file']; |
874 | - foreach($files as $k => $path) |
|
873 | + foreach ($files as $k => $path) |
|
875 | 874 | { |
876 | - if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false) |
|
875 | + if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false) |
|
877 | 876 | { |
878 | 877 | $insertSigOnTop = 'below'; |
879 | 878 | } |
880 | 879 | //error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs'))); |
881 | - if (parse_url($path,PHP_URL_SCHEME == 'vfs')) |
|
880 | + if (parse_url($path, PHP_URL_SCHEME == 'vfs')) |
|
882 | 881 | { |
883 | 882 | //egw_vfs::load_wrapper('vfs'); |
884 | 883 | $type = egw_vfs::mime_content_type($path); |
885 | 884 | // special handling for attaching vCard of iCal --> use their link-title as name |
886 | - if (substr($path,-7) != '/.entry' || |
|
887 | - !(list($app,$id) = array_slice(explode('/',$path),-3)) || |
|
885 | + if (substr($path, -7) != '/.entry' || |
|
886 | + !(list($app, $id) = array_slice(explode('/', $path), -3)) || |
|
888 | 887 | !($name = egw_link::title($app, $id))) |
889 | 888 | { |
890 | 889 | $name = egw_vfs::decodePath(egw_vfs::basename($path)); |
@@ -898,7 +897,7 @@ discard block |
||
898 | 897 | { |
899 | 898 | $type = $types[$k]; |
900 | 899 | } |
901 | - $path = str_replace('+','%2B',$path); |
|
900 | + $path = str_replace('+', '%2B', $path); |
|
902 | 901 | $formData = array( |
903 | 902 | 'name' => $name, |
904 | 903 | 'type' => $type, |
@@ -911,7 +910,7 @@ discard block |
||
911 | 910 | egw_framework::message(lang('Directories have to be shared.'), 'info'); |
912 | 911 | } |
913 | 912 | } |
914 | - elseif(is_readable($path)) |
|
913 | + elseif (is_readable($path)) |
|
915 | 914 | { |
916 | 915 | $formData = array( |
917 | 916 | 'name' => isset($names[$k]) ? $names[$k] : basename($path), |
@@ -924,28 +923,28 @@ discard block |
||
924 | 923 | { |
925 | 924 | continue; |
926 | 925 | } |
927 | - $this->addAttachment($formData,$content,($alwaysAttachVCardAtCompose?true:false)); |
|
926 | + $this->addAttachment($formData, $content, ($alwaysAttachVCardAtCompose ? true : false)); |
|
928 | 927 | } |
929 | 928 | $remember = array(); |
930 | 929 | if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))) |
931 | 930 | { |
932 | - foreach(array_keys($content) as $k) |
|
931 | + foreach (array_keys($content) as $k) |
|
933 | 932 | { |
934 | - if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k])) |
|
933 | + if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k])) |
|
935 | 934 | { |
936 | - $alreadyProcessed[$k]=$k; |
|
935 | + $alreadyProcessed[$k] = $k; |
|
937 | 936 | $remember[$k] = $this->sessionData[$k]; |
938 | 937 | } |
939 | 938 | } |
940 | 939 | } |
941 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
940 | + if (!empty($remember)) $content = array_merge($content, $remember); |
|
942 | 941 | } |
943 | - foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
|
942 | + foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name) |
|
944 | 943 | { |
945 | 944 | //always handle mimeType |
946 | - if ($name=='mimeType' && $_REQUEST['preset'][$name]) |
|
945 | + if ($name == 'mimeType' && $_REQUEST['preset'][$name]) |
|
947 | 946 | { |
948 | - $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
|
947 | + $_content[$name] = $content[$name] = $_REQUEST['preset'][$name]; |
|
949 | 948 | } |
950 | 949 | //skip if already processed by "preset Routines" |
951 | 950 | if ($alreadyProcessed[$name]) continue; |
@@ -958,36 +957,36 @@ discard block |
||
958 | 957 | { |
959 | 958 | $content['to'] = base64_decode($_REQUEST['send_to']); |
960 | 959 | // first check if there is a questionmark or ampersand |
961 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
960 | + if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2); |
|
962 | 961 | $content['to'] = html_entity_decode($content['to']); |
963 | - if (($at_pos = strpos($content['to'],'@')) !== false) |
|
962 | + if (($at_pos = strpos($content['to'], '@')) !== false) |
|
964 | 963 | { |
965 | - if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false) |
|
964 | + if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false) |
|
966 | 965 | { |
967 | 966 | //list($email,$addoptions) = explode('&',$value,2); |
968 | - $email = substr($content['to'],0,$amp_pos+$at_pos); |
|
969 | - $rest = substr($content['to'], $amp_pos+$at_pos+1); |
|
967 | + $email = substr($content['to'], 0, $amp_pos + $at_pos); |
|
968 | + $rest = substr($content['to'], $amp_pos + $at_pos + 1); |
|
970 | 969 | //error_log(__METHOD__.__LINE__.$email.' '.$rest); |
971 | 970 | $content['to'] = $email; |
972 | 971 | } |
973 | 972 | } |
974 | - if (strpos($content['to'],'%40')!== false) $content['to'] = html::purify(str_replace('%40','@',$content['to'])); |
|
973 | + if (strpos($content['to'], '%40') !== false) $content['to'] = html::purify(str_replace('%40', '@', $content['to'])); |
|
975 | 974 | $rarr = array(html::purify($rest)); |
976 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
975 | + if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest); |
|
977 | 976 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
978 | 977 | $karr = array(); |
979 | 978 | foreach ($rarr as &$rval) |
980 | 979 | { |
981 | 980 | //must contain = |
982 | - if (strpos($rval,'=')!== false) |
|
981 | + if (strpos($rval, '=') !== false) |
|
983 | 982 | { |
984 | - list($k,$v) = explode('=',$rval,2); |
|
983 | + list($k, $v) = explode('=', $rval, 2); |
|
985 | 984 | $karr[$k] = (string)$v; |
986 | - unset($k,$v); |
|
985 | + unset($k, $v); |
|
987 | 986 | } |
988 | 987 | } |
989 | 988 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
990 | - foreach(array('cc','bcc','subject','body') as $name) |
|
989 | + foreach (array('cc', 'bcc', 'subject', 'body') as $name) |
|
991 | 990 | { |
992 | 991 | if ($karr[$name]) $content[$name] = $karr[$name]; |
993 | 992 | } |
@@ -999,17 +998,17 @@ discard block |
||
999 | 998 | if ($isFirstLoad && !empty($_REQUEST['mimeType'])) |
1000 | 999 | { |
1001 | 1000 | $_content['mimeType'] = $content['mimeType']; |
1002 | - if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html') |
|
1001 | + if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html') |
|
1003 | 1002 | { |
1004 | - $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1005 | - $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body'])); |
|
1003 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1004 | + $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body'])); |
|
1006 | 1005 | } |
1007 | - if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html') |
|
1006 | + if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html') |
|
1008 | 1007 | { |
1009 | - $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1008 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1010 | 1009 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1011 | 1010 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1012 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1011 | + if (strpos($content['body'], "<pre> \r\n \r\n---") === 0) $content['body'] = substr_replace($content['body'], " <br>\r\n<pre>---", 0, strlen("<pre> \r\n \r\n---") - 1); |
|
1013 | 1012 | } |
1014 | 1013 | } |
1015 | 1014 | else |
@@ -1017,24 +1016,24 @@ discard block |
||
1017 | 1016 | // try to enforce a mimeType on reply ( if type is not of the wanted type ) |
1018 | 1017 | if ($isReply) |
1019 | 1018 | { |
1020 | - if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" && |
|
1019 | + if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" && |
|
1021 | 1020 | $content['mimeType'] == 'html') |
1022 | 1021 | { |
1023 | - $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1024 | - $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body'])); |
|
1022 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1023 | + $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body'])); |
|
1025 | 1024 | } |
1026 | - if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" && |
|
1025 | + if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" && |
|
1027 | 1026 | $content['mimeType'] != 'html') |
1028 | 1027 | { |
1029 | - $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1028 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1030 | 1029 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1031 | 1030 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1032 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1031 | + if (strpos($content['body'], "<pre> \r\n \r\n---") === 0) $content['body'] = substr_replace($content['body'], " <br>\r\n<pre>---", 0, strlen("<pre> \r\n \r\n---") - 1); |
|
1033 | 1032 | } |
1034 | 1033 | } |
1035 | 1034 | } |
1036 | 1035 | |
1037 | - if ($content['mimeType'] == 'html' && html::htmlarea_availible()===false) |
|
1036 | + if ($content['mimeType'] == 'html' && html::htmlarea_availible() === false) |
|
1038 | 1037 | { |
1039 | 1038 | $_content['mimeType'] = $content['mimeType'] = 'plain'; |
1040 | 1039 | $content['body'] = $this->convertHTMLToText($content['body']); |
@@ -1053,36 +1052,36 @@ discard block |
||
1053 | 1052 | //_debug_array(($presetSig ? $presetSig : $content['mailidentity'])); |
1054 | 1053 | try |
1055 | 1054 | { |
1056 | - $signature = emailadmin_account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true); |
|
1055 | + $signature = emailadmin_account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true); |
|
1057 | 1056 | } |
1058 | 1057 | catch (Exception $e) |
1059 | 1058 | { |
1060 | 1059 | //PROBABLY NOT FOUND |
1061 | - $signature=array(); |
|
1060 | + $signature = array(); |
|
1062 | 1061 | } |
1063 | 1062 | if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) && |
1064 | 1063 | $this->mailPreferences['disableRulerForSignatureSeparation']) || |
1065 | - empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='') |
|
1064 | + empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '') |
|
1066 | 1065 | { |
1067 | 1066 | $disableRuler = true; |
1068 | 1067 | } |
1069 | 1068 | $font_span = $font_part = ''; |
1070 | - if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
1069 | + if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
1071 | 1070 | // User preferences for style |
1072 | 1071 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
1073 | 1072 | $font_size = egw_ckeditor_config::font_size_from_prefs(); |
1074 | - $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
|
1073 | + $font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">'; |
|
1075 | 1074 | $font_span = $font_part.'​</span>'; |
1076 | 1075 | if (empty($font) && empty($font_size)) $font_span = ''; |
1077 | 1076 | } |
1078 | 1077 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
1079 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
1078 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = ''; |
|
1080 | 1079 | //remove possible html header stuff |
1081 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
1080 | + if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']); |
|
1082 | 1081 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
1083 | - $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
|
1084 | - if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
|
1085 | - !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
|
1082 | + $blockElements = array('address', 'blockquote', 'center', 'del', 'dir', 'div', 'dl', 'fieldset', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'ins', 'isindex', 'menu', 'noframes', 'noscript', 'ol', 'p', 'pre', 'table', 'ul'); |
|
1083 | + if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' && |
|
1084 | + !(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop |
|
1086 | 1085 | ) |
1087 | 1086 | { |
1088 | 1087 | // ON tOP OR BELOW? pREF CAN TELL |
@@ -1092,54 +1091,54 @@ discard block |
||
1092 | 1091 | '1' => 'before reply, visible during compose', |
1093 | 1092 | 'no_belowaftersend' => 'appended after reply before sending', |
1094 | 1093 | */ |
1095 | - $insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below')); |
|
1096 | - $sigText = mail_bo::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
1094 | + $insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below')); |
|
1095 | + $sigText = mail_bo::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
1097 | 1096 | if ($content['mimeType'] == 'html') |
1098 | 1097 | { |
1099 | - $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
|
1100 | - foreach($blockElements as $e) |
|
1098 | + $sigTextStartsWithBlockElement = ($disableRuler ? false : true); |
|
1099 | + foreach ($blockElements as $e) |
|
1101 | 1100 | { |
1102 | 1101 | if ($sigTextStartsWithBlockElement) break; |
1103 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
1102 | + if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true; |
|
1104 | 1103 | } |
1105 | 1104 | } |
1106 | - if($content['mimeType'] == 'html') { |
|
1105 | + if ($content['mimeType'] == 'html') { |
|
1107 | 1106 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
1108 | 1107 | $inbetween = ''; |
1109 | 1108 | } else { |
1110 | - $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
1109 | + $before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
1111 | 1110 | $inbetween = "\r\n"; |
1112 | 1111 | } |
1113 | 1112 | if ($content['mimeType'] == 'html') |
1114 | 1113 | { |
1115 | - $sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>"); |
|
1114 | + $sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>"); |
|
1116 | 1115 | } |
1117 | 1116 | |
1118 | 1117 | if ($insertSigOnTop === 'below') |
1119 | 1118 | { |
1120 | - $content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)); |
|
1119 | + $content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)); |
|
1121 | 1120 | } |
1122 | 1121 | else |
1123 | 1122 | { |
1124 | - $content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body']; |
|
1123 | + $content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body']; |
|
1125 | 1124 | } |
1126 | 1125 | } |
1127 | 1126 | else |
1128 | 1127 | { |
1129 | - $content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?' ':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":""); |
|
1128 | + $content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?' ':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : ""); |
|
1130 | 1129 | } |
1131 | 1130 | //error_log(__METHOD__.__LINE__.$content['body']); |
1132 | 1131 | |
1133 | 1132 | // prepare body |
1134 | 1133 | // in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct |
1135 | - $content['body'] = translation::convert_jsonsafe($content['body'],'utf-8'); |
|
1134 | + $content['body'] = translation::convert_jsonsafe($content['body'], 'utf-8'); |
|
1136 | 1135 | //error_log(__METHOD__.__LINE__.array2string($content)); |
1137 | 1136 | |
1138 | 1137 | // get identities of all accounts as "$acc_id:$ident_id" => $identity |
1139 | 1138 | $sel_options['mailaccount'] = $identities = array(); |
1140 | - foreach(emailadmin_account::search(true,false) as $acc_id => $account) |
|
1139 | + foreach (emailadmin_account::search(true, false) as $acc_id => $account) |
|
1141 | 1140 | { |
1142 | - foreach($account->identities($acc_id) as $ident_id => $identity) |
|
1141 | + foreach ($account->identities($acc_id) as $ident_id => $identity) |
|
1143 | 1142 | { |
1144 | 1143 | $sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity; |
1145 | 1144 | $identities[$ident_id] = $identity; |
@@ -1150,7 +1149,7 @@ discard block |
||
1150 | 1149 | //$content['bcc'] = array('[email protected]','[email protected]'); |
1151 | 1150 | // address stuff like from, to, cc, replyto |
1152 | 1151 | $destinationRows = 0; |
1153 | - foreach(self::$destinations as $destination) { |
|
1152 | + foreach (self::$destinations as $destination) { |
|
1154 | 1153 | if (!is_array($content[$destination])) |
1155 | 1154 | { |
1156 | 1155 | if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
@@ -1158,22 +1157,22 @@ discard block |
||
1158 | 1157 | $addr_content = $content[strtolower($destination)]; |
1159 | 1158 | // we clear the given address array and rebuild it |
1160 | 1159 | unset($content[strtolower($destination)]); |
1161 | - foreach((array)$addr_content as $key => $value) { |
|
1162 | - if ($value=="NIL@NIL") continue; |
|
1163 | - if ($destination=='replyto' && str_replace('"','',$value) == |
|
1164 | - str_replace('"','',$identities[$presetId ? $presetId : $this->mail_bo->getDefaultIdentity()])) |
|
1160 | + foreach ((array)$addr_content as $key => $value) { |
|
1161 | + if ($value == "NIL@NIL") continue; |
|
1162 | + if ($destination == 'replyto' && str_replace('"', '', $value) == |
|
1163 | + str_replace('"', '', $identities[$presetId ? $presetId : $this->mail_bo->getDefaultIdentity()])) |
|
1165 | 1164 | { |
1166 | 1165 | // preserve/restore the value to content. |
1167 | - $content[strtolower($destination)][]=$value; |
|
1166 | + $content[strtolower($destination)][] = $value; |
|
1168 | 1167 | continue; |
1169 | 1168 | } |
1170 | 1169 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
1171 | - $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
|
1172 | - foreach(emailadmin_imapbase::parseAddressList($value) as $addressObject) { |
|
1170 | + $value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT)); |
|
1171 | + foreach (emailadmin_imapbase::parseAddressList($value) as $addressObject) { |
|
1173 | 1172 | if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
1174 | - $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
|
1173 | + $address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
|
1175 | 1174 | //$address = mail_bo::htmlentities($address, $this->displayCharset); |
1176 | - $content[strtolower($destination)][]=$address; |
|
1175 | + $content[strtolower($destination)][] = $address; |
|
1177 | 1176 | $destinationRows++; |
1178 | 1177 | } |
1179 | 1178 | } |
@@ -1181,10 +1180,10 @@ discard block |
||
1181 | 1180 | if ($_content) |
1182 | 1181 | { |
1183 | 1182 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
1184 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
1185 | - $content = array_merge($content,$_content); |
|
1183 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']); |
|
1184 | + $content = array_merge($content, $_content); |
|
1186 | 1185 | |
1187 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
1186 | + if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true); |
|
1188 | 1187 | if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
1189 | 1188 | } |
1190 | 1189 | else |
@@ -1193,12 +1192,12 @@ discard block |
||
1193 | 1192 | $content['mailaccount'] = $this->mail_bo->profileID; |
1194 | 1193 | //error_log(__METHOD__.__LINE__.$content['body']); |
1195 | 1194 | } |
1196 | - $content['is_html'] = ($content['mimeType'] == 'html'?true:''); |
|
1197 | - $content['is_plain'] = ($content['mimeType'] == 'html'?'':true); |
|
1198 | - $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body']; |
|
1199 | - $content['showtempname']=0; |
|
1195 | + $content['is_html'] = ($content['mimeType'] == 'html' ? true : ''); |
|
1196 | + $content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true); |
|
1197 | + $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body']; |
|
1198 | + $content['showtempname'] = 0; |
|
1200 | 1199 | //if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments'])); |
1201 | - $content['attachments']=(is_array($content['attachments'])&&is_array($content['uploadForCompose'])?array_merge($content['attachments'],(!empty($content['uploadForCompose'])?$content['uploadForCompose']:array())):(is_array($content['uploadForCompose'])?$content['uploadForCompose']:(is_array($content['attachments'])?$content['attachments']:null))); |
|
1200 | + $content['attachments'] = (is_array($content['attachments']) && is_array($content['uploadForCompose']) ? array_merge($content['attachments'], (!empty($content['uploadForCompose']) ? $content['uploadForCompose'] : array())) : (is_array($content['uploadForCompose']) ? $content['uploadForCompose'] : (is_array($content['attachments']) ? $content['attachments'] : null))); |
|
1202 | 1201 | //if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0; |
1203 | 1202 | $content['no_griddata'] = empty($content['attachments']); |
1204 | 1203 | $preserv['attachments'] = $content['attachments']; |
@@ -1232,12 +1231,12 @@ discard block |
||
1232 | 1231 | $sel_options['mimeType'] = self::$mimeTypes; |
1233 | 1232 | $sel_options['priority'] = self::$priorities; |
1234 | 1233 | $sel_options['filemode'] = egw_sharing::$modes; |
1235 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
1234 | + if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3; |
|
1236 | 1235 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
1237 | 1236 | $etpl = new etemplate_new('mail.compose'); |
1238 | 1237 | |
1239 | 1238 | $etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content)); |
1240 | - if ($content['mimeType']=='html') |
|
1239 | + if ($content['mimeType'] == 'html') |
|
1241 | 1240 | { |
1242 | 1241 | //mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]" |
1243 | 1242 | $_htmlConfig = mail_bo::$htmLawed_config; |
@@ -1247,23 +1246,23 @@ discard block |
||
1247 | 1246 | // and not the eGroupware wide pref to prevent users from trying things that will potentially not work |
1248 | 1247 | // or not work as expected, as a full featured editor that may be wanted in other apps |
1249 | 1248 | // is way overloading the "normal" needs for composing mails |
1250 | - $content['rtfEditorFeatures']='simple-withimage';//egw_ckeditor_config::get_ckeditor_config(); |
|
1249 | + $content['rtfEditorFeatures'] = 'simple-withimage'; //egw_ckeditor_config::get_ckeditor_config(); |
|
1251 | 1250 | //$content['rtfEditorFeatures']='advanced';//egw_ckeditor_config::get_ckeditor_config(); |
1252 | - $content['validation_rules']= json_encode(mail_bo::$htmLawed_config); |
|
1253 | - $etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']); |
|
1254 | - $etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']); |
|
1251 | + $content['validation_rules'] = json_encode(mail_bo::$htmLawed_config); |
|
1252 | + $etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']); |
|
1253 | + $etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']); |
|
1255 | 1254 | mail_bo::$htmLawed_config = $_htmlConfig; |
1256 | 1255 | } |
1257 | 1256 | |
1258 | - if (isset($content['composeID'])&&!empty($content['composeID'])) |
|
1257 | + if (isset($content['composeID']) && !empty($content['composeID'])) |
|
1259 | 1258 | { |
1260 | 1259 | $composeCache = $content; |
1261 | 1260 | unset($composeCache['body']); |
1262 | 1261 | unset($composeCache['mail_htmltext']); |
1263 | 1262 | unset($composeCache['mail_plaintext']); |
1264 | - egw_cache::setCache(egw_cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2); |
|
1263 | + egw_cache::setCache(egw_cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2); |
|
1265 | 1264 | } |
1266 | - if (!isset($_content['serverID'])||empty($_content['serverID'])) |
|
1265 | + if (!isset($_content['serverID']) || empty($_content['serverID'])) |
|
1267 | 1266 | { |
1268 | 1267 | $content['serverID'] = $this->mail_bo->profileID; |
1269 | 1268 | } |
@@ -1279,25 +1278,25 @@ discard block |
||
1279 | 1278 | $preserv['list-id'] = $content['list-id']; |
1280 | 1279 | $preserv['mode'] = $content['mode']; |
1281 | 1280 | // convert it back to checkbox expectations |
1282 | - if($content['mimeType'] == 'html') { |
|
1283 | - $content['mimeType']=1; |
|
1281 | + if ($content['mimeType'] == 'html') { |
|
1282 | + $content['mimeType'] = 1; |
|
1284 | 1283 | } else { |
1285 | - $content['mimeType']=0; |
|
1284 | + $content['mimeType'] = 0; |
|
1286 | 1285 | } |
1287 | 1286 | // set the current selected mailaccount as param for folderselection |
1288 | - $etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount'])); |
|
1287 | + $etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount'])); |
|
1289 | 1288 | // join again mailaccount and identity |
1290 | 1289 | $content['mailaccount'] .= ':'.$content['mailidentity']; |
1291 | 1290 | |
1292 | 1291 | // Resolve distribution list before send content to client |
1293 | - foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
|
1292 | + foreach (array('to', 'cc', 'bcc', 'replyto') as $f) |
|
1294 | 1293 | { |
1295 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
1294 | + if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]); |
|
1296 | 1295 | } |
1297 | 1296 | |
1298 | 1297 | $content['to'] = self::resolveEmailAddressList($content['to']); |
1299 | 1298 | //error_log(__METHOD__.__LINE__.array2string($content)); |
1300 | - $etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2); |
|
1299 | + $etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2); |
|
1301 | 1300 | } |
1302 | 1301 | |
1303 | 1302 | /** |
@@ -1318,9 +1317,9 @@ discard block |
||
1318 | 1317 | $content = array(); |
1319 | 1318 | //error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply"); |
1320 | 1319 | // on forward we may have to support multiple ids |
1321 | - if ($from=='forward') |
|
1320 | + if ($from == 'forward') |
|
1322 | 1321 | { |
1323 | - $replyIds = explode(',',$mail_id); |
|
1322 | + $replyIds = explode(',', $mail_id); |
|
1324 | 1323 | $mail_id = $replyIds[0]; |
1325 | 1324 | } |
1326 | 1325 | $hA = mail_ui::splitRowID($mail_id); |
@@ -1332,15 +1331,15 @@ discard block |
||
1332 | 1331 | $this->changeProfile($icServerID); |
1333 | 1332 | } |
1334 | 1333 | $icServer = $this->mail_bo->icServer; |
1335 | - if (!empty($folder) && !empty($msgUID) ) |
|
1334 | + if (!empty($folder) && !empty($msgUID)) |
|
1336 | 1335 | { |
1337 | 1336 | // this fill the session data with the values from the original email |
1338 | - switch($from) |
|
1337 | + switch ($from) |
|
1339 | 1338 | { |
1340 | 1339 | case 'composefromdraft': |
1341 | 1340 | case 'composeasnew': |
1342 | 1341 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
1343 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
1342 | + if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft'; |
|
1344 | 1343 | $content['processedmail_id'] = $mail_id; |
1345 | 1344 | |
1346 | 1345 | $_focusElement = 'body'; |
@@ -1356,7 +1355,7 @@ discard block |
||
1356 | 1355 | $isReply = true; |
1357 | 1356 | break; |
1358 | 1357 | case 'forward': |
1359 | - $mode = ($_GET['mode']=='forwardinline'?'inline':'asmail'); |
|
1358 | + $mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail'); |
|
1360 | 1359 | // this fill the session data with the values from the original email |
1361 | 1360 | foreach ($replyIds as &$mail_id) |
1362 | 1361 | { |
@@ -1366,14 +1365,14 @@ discard block |
||
1366 | 1365 | $folder = $hA['folder']; |
1367 | 1366 | $content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode); |
1368 | 1367 | } |
1369 | - $content['processedmail_id'] = implode(',',$replyIds); |
|
1368 | + $content['processedmail_id'] = implode(',', $replyIds); |
|
1370 | 1369 | $content['mode'] = 'forward'; |
1371 | - $isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline'); |
|
1372 | - $suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution |
|
1370 | + $isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline'); |
|
1371 | + $suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution |
|
1373 | 1372 | $_focusElement = 'to'; |
1374 | 1373 | break; |
1375 | 1374 | default: |
1376 | - error_log('Unhandled compose source: ' . $from); |
|
1375 | + error_log('Unhandled compose source: '.$from); |
|
1377 | 1376 | } |
1378 | 1377 | } |
1379 | 1378 | else if ($from == 'merge' && $_REQUEST['document']) |
@@ -1388,12 +1387,12 @@ discard block |
||
1388 | 1387 | $document_merge = new $merge_class(); |
1389 | 1388 | $this->mail_bo->openConnection(); |
1390 | 1389 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
1391 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
1390 | + if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids); |
|
1392 | 1391 | try |
1393 | 1392 | { |
1394 | 1393 | $merged_mail_id = ''; |
1395 | 1394 | $folder = ''; |
1396 | - if(($error = $document_merge->check_document($_REQUEST['document'],''))) |
|
1395 | + if (($error = $document_merge->check_document($_REQUEST['document'], ''))) |
|
1397 | 1396 | { |
1398 | 1397 | $content['msg'] = $error; |
1399 | 1398 | return $content; |
@@ -1403,10 +1402,10 @@ discard block |
||
1403 | 1402 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; |
1404 | 1403 | |
1405 | 1404 | // Actually do the merge |
1406 | - if(count($merge_ids) <= 1) |
|
1405 | + if (count($merge_ids) <= 1) |
|
1407 | 1406 | { |
1408 | 1407 | $results = $this->mail_bo->importMessageToMergeAndSend( |
1409 | - $document_merge, egw_vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id |
|
1408 | + $document_merge, egw_vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id |
|
1410 | 1409 | ); |
1411 | 1410 | |
1412 | 1411 | // Open compose |
@@ -1417,9 +1416,9 @@ discard block |
||
1417 | 1416 | } |
1418 | 1417 | else |
1419 | 1418 | { |
1420 | - $success = implode(', ',$results['success']); |
|
1419 | + $success = implode(', ', $results['success']); |
|
1421 | 1420 | $fail = implode(', ', $results['failed']); |
1422 | - if($success) egw_framework::message($success, 'success'); |
|
1421 | + if ($success) egw_framework::message($success, 'success'); |
|
1423 | 1422 | egw_framework::window_close($fail); |
1424 | 1423 | } |
1425 | 1424 | } |
@@ -1447,22 +1446,22 @@ discard block |
||
1447 | 1446 | return 1; |
1448 | 1447 | } |
1449 | 1448 | |
1450 | - function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false) |
|
1449 | + function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false) |
|
1451 | 1450 | { |
1452 | 1451 | $stripalltags = true; |
1453 | 1452 | // third param is stripalltags, we may not need that, if the source is already in ascii |
1454 | - if (!$sourceishtml) $stripalltags=false; |
|
1455 | - return translation::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags); |
|
1453 | + if (!$sourceishtml) $stripalltags = false; |
|
1454 | + return translation::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags); |
|
1456 | 1455 | } |
1457 | 1456 | |
1458 | 1457 | function generateRFC822Address($_addressObject) |
1459 | 1458 | { |
1460 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
1461 | - return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
|
1462 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
1463 | - return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
|
1459 | + if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
1460 | + return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE')); |
|
1461 | + } elseif ($_addressObject->mailbox && $_addressObject->host) { |
|
1462 | + return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE')); |
|
1464 | 1463 | } else { |
1465 | - return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
|
1464 | + return $this->mail_bo->decode_header($_addressObject->mailbox, true); |
|
1466 | 1465 | } |
1467 | 1466 | } |
1468 | 1467 | |
@@ -1477,9 +1476,9 @@ discard block |
||
1477 | 1476 | // $_mode can be: |
1478 | 1477 | // single: for a reply to one address |
1479 | 1478 | // all: for a reply to all |
1480 | - function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL) |
|
1479 | + function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL) |
|
1481 | 1480 | { |
1482 | - unset($_icServer); // not used |
|
1481 | + unset($_icServer); // not used |
|
1483 | 1482 | $this->sessionData['to'] = array(); |
1484 | 1483 | |
1485 | 1484 | $mail_bo = $this->mail_bo; |
@@ -1488,7 +1487,7 @@ discard block |
||
1488 | 1487 | |
1489 | 1488 | // get message headers for specified message |
1490 | 1489 | #$headers = $mail_bo->getMessageHeader($_folder, $_uid); |
1491 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
1490 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
1492 | 1491 | $addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID); |
1493 | 1492 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
1494 | 1493 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
@@ -1496,10 +1495,10 @@ discard block |
||
1496 | 1495 | |
1497 | 1496 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
1498 | 1497 | if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
1499 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
1500 | - $fval=$val; |
|
1498 | + foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) { |
|
1499 | + $fval = $val; |
|
1501 | 1500 | $icServerID = $mail_bo->icServer->ImapServerId; |
1502 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
1501 | + if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2); |
|
1503 | 1502 | if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
1504 | 1503 | if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
1505 | 1504 | } |
@@ -1534,71 +1533,71 @@ discard block |
||
1534 | 1533 | } |
1535 | 1534 | } |
1536 | 1535 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
1537 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
1536 | + if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder); |
|
1538 | 1537 | $this->sessionData['uid'] = $_uid; |
1539 | 1538 | $this->sessionData['messageFolder'] = $_folder; |
1540 | 1539 | $this->sessionData['isDraft'] = true; |
1541 | 1540 | $foundAddresses = array(); |
1542 | - foreach((array)$headers['CC'] as $val) { |
|
1543 | - $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
|
1541 | + foreach ((array)$headers['CC'] as $val) { |
|
1542 | + $rfcAddr = emailadmin_imapbase::parseAddressList($val); |
|
1544 | 1543 | $_rfcAddr = $rfcAddr[0]; |
1545 | 1544 | if (!$_rfcAddr->valid) continue; |
1546 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1545 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) { |
|
1547 | 1546 | continue; |
1548 | 1547 | } |
1549 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1550 | - if(!$foundAddresses[$keyemail]) { |
|
1551 | - $address = $this->mail_bo->decode_header($val,true); |
|
1548 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1549 | + if (!$foundAddresses[$keyemail]) { |
|
1550 | + $address = $this->mail_bo->decode_header($val, true); |
|
1552 | 1551 | $this->sessionData['cc'][] = $val; |
1553 | 1552 | $foundAddresses[$keyemail] = true; |
1554 | 1553 | } |
1555 | 1554 | } |
1556 | 1555 | |
1557 | - foreach((array)$headers['TO'] as $val) { |
|
1558 | - if(!is_array($val)) |
|
1556 | + foreach ((array)$headers['TO'] as $val) { |
|
1557 | + if (!is_array($val)) |
|
1559 | 1558 | { |
1560 | 1559 | $this->sessionData['to'][] = $val; |
1561 | 1560 | continue; |
1562 | 1561 | } |
1563 | - $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
|
1562 | + $rfcAddr = emailadmin_imapbase::parseAddressList($val); |
|
1564 | 1563 | $_rfcAddr = $rfcAddr[0]; |
1565 | 1564 | if (!$_rfcAddr->valid) continue; |
1566 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1565 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) { |
|
1567 | 1566 | continue; |
1568 | 1567 | } |
1569 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1570 | - if(!$foundAddresses[$keyemail]) { |
|
1571 | - $address = $this->mail_bo->decode_header($val,true); |
|
1568 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1569 | + if (!$foundAddresses[$keyemail]) { |
|
1570 | + $address = $this->mail_bo->decode_header($val, true); |
|
1572 | 1571 | $this->sessionData['to'][] = $val; |
1573 | 1572 | $foundAddresses[$keyemail] = true; |
1574 | 1573 | } |
1575 | 1574 | } |
1576 | 1575 | |
1577 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
1578 | - $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
|
1576 | + foreach ((array)$headers['REPLY-TO'] as $val) { |
|
1577 | + $rfcAddr = emailadmin_imapbase::parseAddressList($val); |
|
1579 | 1578 | $_rfcAddr = $rfcAddr[0]; |
1580 | 1579 | if (!$_rfcAddr->valid) continue; |
1581 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1580 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) { |
|
1582 | 1581 | continue; |
1583 | 1582 | } |
1584 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1585 | - if(!$foundAddresses[$keyemail]) { |
|
1586 | - $address = $this->mail_bo->decode_header($val,true); |
|
1583 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1584 | + if (!$foundAddresses[$keyemail]) { |
|
1585 | + $address = $this->mail_bo->decode_header($val, true); |
|
1587 | 1586 | $this->sessionData['replyto'][] = $val; |
1588 | 1587 | $foundAddresses[$keyemail] = true; |
1589 | 1588 | } |
1590 | 1589 | } |
1591 | 1590 | |
1592 | - foreach((array)$headers['BCC'] as $val) { |
|
1593 | - $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
|
1591 | + foreach ((array)$headers['BCC'] as $val) { |
|
1592 | + $rfcAddr = emailadmin_imapbase::parseAddressList($val); |
|
1594 | 1593 | $_rfcAddr = $rfcAddr[0]; |
1595 | 1594 | if (!$_rfcAddr->valid) continue; |
1596 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1595 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) { |
|
1597 | 1596 | continue; |
1598 | 1597 | } |
1599 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1600 | - if(!$foundAddresses[$keyemail]) { |
|
1601 | - $address = $this->mail_bo->decode_header($val,true); |
|
1598 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1599 | + if (!$foundAddresses[$keyemail]) { |
|
1600 | + $address = $this->mail_bo->decode_header($val, true); |
|
1602 | 1601 | $this->sessionData['bcc'][] = $val; |
1603 | 1602 | $foundAddresses[$keyemail] = true; |
1604 | 1603 | } |
@@ -1607,47 +1606,47 @@ discard block |
||
1607 | 1606 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
1608 | 1607 | // remove a printview tag if composing |
1609 | 1608 | $searchfor = '/^\['.lang('printview').':\]/'; |
1610 | - $this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']); |
|
1611 | - $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
|
1609 | + $this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']); |
|
1610 | + $bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID); |
|
1612 | 1611 | //_debug_array($bodyParts); |
1613 | 1612 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
1614 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
1615 | - $this->sessionData['mimeType'] = 'html'; |
|
1613 | + if ($bodyParts['0']['mimeType'] == 'text/html') { |
|
1614 | + $this->sessionData['mimeType'] = 'html'; |
|
1616 | 1615 | |
1617 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1618 | - if($i>0) { |
|
1616 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
1617 | + if ($i > 0) { |
|
1619 | 1618 | $this->sessionData['body'] .= '<hr>'; |
1620 | 1619 | } |
1621 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
1620 | + if ($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
1622 | 1621 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
1623 | 1622 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
1624 | 1623 | } |
1625 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1624 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1626 | 1625 | $bodyParts[$i]['body'] = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1627 | 1626 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1628 | - $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
|
1627 | + $this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body']; |
|
1629 | 1628 | } |
1630 | 1629 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
1631 | 1630 | |
1632 | 1631 | } else { |
1633 | - $this->sessionData['mimeType'] = 'plain'; |
|
1632 | + $this->sessionData['mimeType'] = 'plain'; |
|
1634 | 1633 | |
1635 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1636 | - if($i>0) { |
|
1634 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
1635 | + if ($i > 0) { |
|
1637 | 1636 | $this->sessionData['body'] .= "<hr>"; |
1638 | 1637 | } |
1639 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1638 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1640 | 1639 | $bodyParts[$i]['body'] = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1641 | 1640 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1642 | - $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
|
1641 | + $this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body']; |
|
1643 | 1642 | } |
1644 | - $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
|
1643 | + $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain'); |
|
1645 | 1644 | } |
1646 | 1645 | |
1647 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
1648 | - foreach($attachments as $attachment) { |
|
1646 | + if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) { |
|
1647 | + foreach ($attachments as $attachment) { |
|
1649 | 1648 | $cid = $attachment['cid']; |
1650 | - $match=null; |
|
1649 | + $match = null; |
|
1651 | 1650 | preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match); |
1652 | 1651 | if (!$match || !$attachment['cid']) |
1653 | 1652 | { |
@@ -1665,7 +1664,7 @@ discard block |
||
1665 | 1664 | |
1666 | 1665 | function getErrorInfo() |
1667 | 1666 | { |
1668 | - if(isset($this->errorInfo)) { |
|
1667 | + if (isset($this->errorInfo)) { |
|
1669 | 1668 | $errorInfo = $this->errorInfo; |
1670 | 1669 | unset($this->errorInfo); |
1671 | 1670 | return $errorInfo; |
@@ -1673,39 +1672,39 @@ discard block |
||
1673 | 1672 | return false; |
1674 | 1673 | } |
1675 | 1674 | |
1676 | - function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false) |
|
1675 | + function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false) |
|
1677 | 1676 | { |
1678 | 1677 | if ($_mode) |
1679 | 1678 | { |
1680 | 1679 | $modebuff = $this->mailPreferences['message_forwarding']; |
1681 | 1680 | $this->mailPreferences['message_forwarding'] = $_mode; |
1682 | 1681 | } |
1683 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
1682 | + if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
1684 | 1683 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
1685 | 1684 | } |
1686 | - $mail_bo = $this->mail_bo; |
|
1685 | + $mail_bo = $this->mail_bo; |
|
1687 | 1686 | $mail_bo->openConnection(); |
1688 | 1687 | $mail_bo->reopen($_folder); |
1689 | 1688 | |
1690 | 1689 | // get message headers for specified message |
1691 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
1690 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
1692 | 1691 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
1693 | 1692 | //_debug_array($headers); exit; |
1694 | 1693 | // check for Re: in subject header |
1695 | - $this->sessionData['subject'] = "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']); |
|
1694 | + $this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']); |
|
1696 | 1695 | // the three attributes below are substituted by processedmail_id and mode |
1697 | 1696 | //$this->sessionData['sourceFolder']=$_folder; |
1698 | 1697 | //$this->sessionData['forwardFlag']='forwarded'; |
1699 | 1698 | //$this->sessionData['forwardedUID']=$_uid; |
1700 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
1701 | - $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
|
1702 | - if($headers['SIZE']) |
|
1699 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
1700 | + $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
|
1701 | + if ($headers['SIZE']) |
|
1703 | 1702 | $size = $headers['SIZE']; |
1704 | 1703 | else |
1705 | 1704 | $size = lang('unknown'); |
1706 | 1705 | |
1707 | 1706 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
1708 | - $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
|
1707 | + $mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml', |
|
1709 | 1708 | 'MESSAGE/RFC822', $size); |
1710 | 1709 | } |
1711 | 1710 | else |
@@ -1713,10 +1712,10 @@ discard block |
||
1713 | 1712 | unset($this->sessionData['in-reply-to']); |
1714 | 1713 | unset($this->sessionData['to']); |
1715 | 1714 | unset($this->sessionData['cc']); |
1716 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
1715 | + if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) { |
|
1717 | 1716 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
1718 | - foreach($attachments as $attachment) { |
|
1719 | - if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType']))) |
|
1717 | + foreach ($attachments as $attachment) { |
|
1718 | + if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType']))) |
|
1720 | 1719 | { |
1721 | 1720 | $this->addMessageAttachment($_uid, $attachment['partID'], |
1722 | 1721 | $_folder, |
@@ -1745,7 +1744,7 @@ discard block |
||
1745 | 1744 | * @param array $_content the content passed to the function and to be modified |
1746 | 1745 | * @return void |
1747 | 1746 | */ |
1748 | - function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false) |
|
1747 | + function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false) |
|
1749 | 1748 | { |
1750 | 1749 | //error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content)); |
1751 | 1750 | |
@@ -1754,7 +1753,7 @@ discard block |
||
1754 | 1753 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
1755 | 1754 | try |
1756 | 1755 | { |
1757 | - $tmpFileName = mail_bo::checkFileBasics($_formData,$this->composeID,false); |
|
1756 | + $tmpFileName = mail_bo::checkFileBasics($_formData, $this->composeID, false); |
|
1758 | 1757 | } |
1759 | 1758 | catch (egw_exception_wrong_userinput $e) |
1760 | 1759 | { |
@@ -1770,8 +1769,8 @@ discard block |
||
1770 | 1769 | foreach ((array)$_content['attachments'] as $attach) |
1771 | 1770 | { |
1772 | 1771 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
1773 | - strtolower($_formData['type'])== strtolower($attach['type']) && |
|
1774 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
1772 | + strtolower($_formData['type']) == strtolower($attach['type']) && |
|
1773 | + stripos($_formData['file'], 'vfs://') !== false) return; |
|
1775 | 1774 | } |
1776 | 1775 | } |
1777 | 1776 | if ($attachfailed === false) |
@@ -1783,7 +1782,7 @@ discard block |
||
1783 | 1782 | 'tmp_name' => $tmpFileName, |
1784 | 1783 | 'size' => $_formData['size'] |
1785 | 1784 | ); |
1786 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
1785 | + if (!is_array($_content['attachments'])) $_content['attachments'] = array(); |
|
1787 | 1786 | $_content['attachments'][] = $buffer; |
1788 | 1787 | unset($buffer); |
1789 | 1788 | } |
@@ -1795,14 +1794,14 @@ discard block |
||
1795 | 1794 | |
1796 | 1795 | function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size) |
1797 | 1796 | { |
1798 | - $this->sessionData['attachments'][]=array ( |
|
1797 | + $this->sessionData['attachments'][] = array( |
|
1799 | 1798 | 'uid' => $_uid, |
1800 | 1799 | 'partID' => $_partID, |
1801 | 1800 | 'name' => $_name, |
1802 | 1801 | 'type' => $_type, |
1803 | 1802 | 'size' => $_size, |
1804 | 1803 | 'folder' => $_folder, |
1805 | - 'tmp_name' => mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1), |
|
1804 | + 'tmp_name' => mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1), |
|
1806 | 1805 | ); |
1807 | 1806 | } |
1808 | 1807 | |
@@ -1811,7 +1810,7 @@ discard block |
||
1811 | 1810 | // read attachment data from etemplate request, use tmpname only to identify it |
1812 | 1811 | if (($request = etemplate_request::read($_GET['etemplate_exec_id']))) |
1813 | 1812 | { |
1814 | - foreach($request->preserv['attachments'] as $attachment) |
|
1813 | + foreach ($request->preserv['attachments'] as $attachment) |
|
1815 | 1814 | { |
1816 | 1815 | if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
1817 | 1816 | } |
@@ -1823,7 +1822,7 @@ discard block |
||
1823 | 1822 | } |
1824 | 1823 | |
1825 | 1824 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
1826 | - if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs') |
|
1825 | + if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs') |
|
1827 | 1826 | { |
1828 | 1827 | egw_vfs::load_wrapper('vfs'); |
1829 | 1828 | } |
@@ -1832,7 +1831,7 @@ discard block |
||
1832 | 1831 | { |
1833 | 1832 | $attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($attachment['tmp_name']); |
1834 | 1833 | } |
1835 | - if(!file_exists($attachment['tmp_name'])) |
|
1834 | + if (!file_exists($attachment['tmp_name'])) |
|
1836 | 1835 | { |
1837 | 1836 | header('HTTP/1.1 404 Not found'); |
1838 | 1837 | die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!'); |
@@ -1845,7 +1844,7 @@ discard block |
||
1845 | 1844 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY') |
1846 | 1845 | { |
1847 | 1846 | $sfxMimeType = $attachment['type']; |
1848 | - $buff = explode('.',$attachment['tmp_name']); |
|
1847 | + $buff = explode('.', $attachment['tmp_name']); |
|
1849 | 1848 | $suffix = ''; |
1850 | 1849 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
1851 | 1850 | if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix); |
@@ -1857,10 +1856,10 @@ discard block |
||
1857 | 1856 | { |
1858 | 1857 | //error_log(__METHOD__."about to call calendar_ical"); |
1859 | 1858 | $calendar_ical = new calendar_ical(); |
1860 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
1859 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
1861 | 1860 | //error_log(__METHOD__.array2string($eventid)); |
1862 | 1861 | if (!$eventid) $eventid = -1; |
1863 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
|
1862 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true); |
|
1864 | 1863 | //error_log(__METHOD__.$event); |
1865 | 1864 | if ((int)$event > 0) |
1866 | 1865 | { |
@@ -1868,7 +1867,7 @@ discard block |
||
1868 | 1867 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1869 | 1868 | 'cal_id' => $event, |
1870 | 1869 | ); |
1871 | - $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
1870 | + $GLOBALS['egw']->redirect_link('../index.php', $vars); |
|
1872 | 1871 | } |
1873 | 1872 | //Import failed, download content anyway |
1874 | 1873 | } |
@@ -1883,13 +1882,13 @@ discard block |
||
1883 | 1882 | { |
1884 | 1883 | $vcard['uid'] = trim($vcard['uid']); |
1885 | 1884 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
1886 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
1885 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
1887 | 1886 | } |
1888 | 1887 | if (!$contact) $contact = null; |
1889 | 1888 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
1890 | - if ($contact || count($vcard)>2) |
|
1889 | + if ($contact || count($vcard) > 2) |
|
1891 | 1890 | { |
1892 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true); |
|
1891 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true); |
|
1893 | 1892 | } |
1894 | 1893 | if ((int)$contact > 0) |
1895 | 1894 | { |
@@ -1897,13 +1896,13 @@ discard block |
||
1897 | 1896 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
1898 | 1897 | 'contact_id' => $contact, |
1899 | 1898 | ); |
1900 | - $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
1899 | + $GLOBALS['egw']->redirect_link('../index.php', $vars); |
|
1901 | 1900 | } |
1902 | 1901 | //Import failed, download content anyway |
1903 | 1902 | } |
1904 | 1903 | } |
1905 | 1904 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
1906 | - html::safe_content_header($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save"); |
|
1905 | + html::safe_content_header($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save"); |
|
1907 | 1906 | echo $attachment['attachment']; |
1908 | 1907 | |
1909 | 1908 | common::egw_exit(); |
@@ -1916,11 +1915,11 @@ discard block |
||
1916 | 1915 | * @param string haystack |
1917 | 1916 | * @return boolean |
1918 | 1917 | */ |
1919 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
1918 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) { |
|
1920 | 1919 | foreach (array_keys($arrayToTestAgainst) as $k) |
1921 | 1920 | { |
1922 | 1921 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
1923 | - if (stripos($haystack,$k)!==false) |
|
1922 | + if (stripos($haystack, $k) !== false) |
|
1924 | 1923 | { |
1925 | 1924 | //error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace()); |
1926 | 1925 | return true; |
@@ -1943,10 +1942,10 @@ discard block |
||
1943 | 1942 | */ |
1944 | 1943 | function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID) |
1945 | 1944 | { |
1946 | - unset($_icServer); // not used |
|
1945 | + unset($_icServer); // not used |
|
1947 | 1946 | $foundAddresses = array(); |
1948 | 1947 | |
1949 | - $mail_bo = $this->mail_bo; |
|
1948 | + $mail_bo = $this->mail_bo; |
|
1950 | 1949 | $mail_bo->openConnection(); |
1951 | 1950 | $mail_bo->reopen($_folder); |
1952 | 1951 | |
@@ -1954,12 +1953,12 @@ discard block |
||
1954 | 1953 | |
1955 | 1954 | // get message headers for specified message |
1956 | 1955 | //print "AAAA: $_folder, $_uid, $_partID<br>"; |
1957 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true); |
|
1956 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true); |
|
1958 | 1957 | //$headers = $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder); |
1959 | 1958 | $this->sessionData['uid'] = $_uid; |
1960 | 1959 | $this->sessionData['messageFolder'] = $_folder; |
1961 | - $this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']); |
|
1962 | - $this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']); |
|
1960 | + $this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']); |
|
1961 | + $this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']); |
|
1963 | 1962 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
1964 | 1963 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
1965 | 1964 | //if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC']; |
@@ -1967,36 +1966,36 @@ discard block |
||
1967 | 1966 | if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
1968 | 1967 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
1969 | 1968 | // check for Reply-To: header and use if available |
1970 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
1971 | - foreach($headers['REPLY-TO'] as $val) { |
|
1972 | - if(!$foundAddresses[$val]) { |
|
1969 | + if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
1970 | + foreach ($headers['REPLY-TO'] as $val) { |
|
1971 | + if (!$foundAddresses[$val]) { |
|
1973 | 1972 | $oldTo[] = $val; |
1974 | 1973 | $foundAddresses[$val] = true; |
1975 | 1974 | } |
1976 | 1975 | } |
1977 | - $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
|
1976 | + $oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']); |
|
1978 | 1977 | } else { |
1979 | - foreach($headers['FROM'] as $val) { |
|
1980 | - if(!$foundAddresses[$val]) { |
|
1978 | + foreach ($headers['FROM'] as $val) { |
|
1979 | + if (!$foundAddresses[$val]) { |
|
1981 | 1980 | $oldTo[] = $val; |
1982 | 1981 | $foundAddresses[$val] = true; |
1983 | 1982 | } |
1984 | 1983 | } |
1985 | - $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
|
1984 | + $oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']); |
|
1986 | 1985 | } |
1987 | 1986 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
1988 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
1987 | + if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) { |
|
1989 | 1988 | $this->sessionData['to'] = $oldTo; |
1990 | 1989 | } |
1991 | 1990 | |
1992 | - if($_mode == 'all') { |
|
1991 | + if ($_mode == 'all') { |
|
1993 | 1992 | // reply to any address which is cc, but not to my self |
1994 | 1993 | #if($headers->cc) { |
1995 | - foreach($headers['CC'] as $val) { |
|
1996 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
1994 | + foreach ($headers['CC'] as $val) { |
|
1995 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
1997 | 1996 | continue; |
1998 | 1997 | } |
1999 | - if(!$foundAddresses[$val]) { |
|
1998 | + if (!$foundAddresses[$val]) { |
|
2000 | 1999 | $this->sessionData['cc'][] = $val; |
2001 | 2000 | $foundAddresses[$val] = true; |
2002 | 2001 | } |
@@ -2005,11 +2004,11 @@ discard block |
||
2005 | 2004 | |
2006 | 2005 | // reply to any address which is to, but not to my self |
2007 | 2006 | #if($headers->to) { |
2008 | - foreach($headers['TO'] as $val) { |
|
2009 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2007 | + foreach ($headers['TO'] as $val) { |
|
2008 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
2010 | 2009 | continue; |
2011 | 2010 | } |
2012 | - if(!$foundAddresses[$val]) { |
|
2011 | + if (!$foundAddresses[$val]) { |
|
2013 | 2012 | $this->sessionData['to'][] = $val; |
2014 | 2013 | $foundAddresses[$val] = true; |
2015 | 2014 | } |
@@ -2017,12 +2016,12 @@ discard block |
||
2017 | 2016 | #} |
2018 | 2017 | |
2019 | 2018 | #if($headers->from) { |
2020 | - foreach($headers['FROM'] as $val) { |
|
2021 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2019 | + foreach ($headers['FROM'] as $val) { |
|
2020 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
2022 | 2021 | continue; |
2023 | 2022 | } |
2024 | 2023 | //error_log(__METHOD__.__LINE__.' '.$val); |
2025 | - if(!$foundAddresses[$val]) { |
|
2024 | + if (!$foundAddresses[$val]) { |
|
2026 | 2025 | $this->sessionData['to'][] = $val; |
2027 | 2026 | $foundAddresses[$val] = true; |
2028 | 2027 | } |
@@ -2031,59 +2030,59 @@ discard block |
||
2031 | 2030 | } |
2032 | 2031 | |
2033 | 2032 | // check for Re: in subject header |
2034 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
2033 | + if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
2035 | 2034 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
2036 | 2035 | } else { |
2037 | - $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
|
2036 | + $this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']); |
|
2038 | 2037 | } |
2039 | 2038 | |
2040 | 2039 | //_debug_array($headers); |
2041 | 2040 | //error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions'])); |
2042 | - $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID); |
|
2041 | + $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID); |
|
2043 | 2042 | //_debug_array($bodyParts); |
2044 | 2043 | $styles = mail_bo::getStyles($bodyParts); |
2045 | 2044 | |
2046 | - $fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM'])); |
|
2045 | + $fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM'])); |
|
2047 | 2046 | |
2048 | 2047 | $toAddressA = array(); |
2049 | 2048 | $toAddress = ''; |
2050 | 2049 | foreach ($headers['TO'] as $mailheader) { |
2051 | - $toAddressA[] = $mailheader; |
|
2050 | + $toAddressA[] = $mailheader; |
|
2052 | 2051 | } |
2053 | - if (count($toAddressA)>0) |
|
2052 | + if (count($toAddressA) > 0) |
|
2054 | 2053 | { |
2055 | - $toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA)); |
|
2056 | - $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
|
2054 | + $toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA)); |
|
2055 | + $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n"); |
|
2057 | 2056 | } |
2058 | 2057 | $ccAddressA = array(); |
2059 | 2058 | $ccAddress = ''; |
2060 | 2059 | foreach ($headers['CC'] as $mailheader) { |
2061 | - $ccAddressA[] = $mailheader; |
|
2060 | + $ccAddressA[] = $mailheader; |
|
2062 | 2061 | } |
2063 | - if (count($ccAddressA)>0) |
|
2062 | + if (count($ccAddressA) > 0) |
|
2064 | 2063 | { |
2065 | - $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
|
2066 | - $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
|
2064 | + $ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA)); |
|
2065 | + $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n"); |
|
2067 | 2066 | } |
2068 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
2069 | - $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
|
2067 | + if ($bodyParts['0']['mimeType'] == 'text/html') { |
|
2068 | + $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
|
2070 | 2069 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
2071 | 2070 | $toAddress.$ccAddress. |
2072 | - @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,mail_bo::$displayCharset, false)."<br>". |
|
2071 | + @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, mail_bo::$displayCharset, false)."<br>". |
|
2073 | 2072 | '----------------------------------------------------------'."</div>"; |
2074 | - $this->sessionData['mimeType'] = 'html'; |
|
2073 | + $this->sessionData['mimeType'] = 'html'; |
|
2075 | 2074 | if (!empty($styles)) $this->sessionData['body'] .= $styles; |
2076 | - $this->sessionData['body'] .= '<blockquote type="cite">'; |
|
2075 | + $this->sessionData['body'] .= '<blockquote type="cite">'; |
|
2077 | 2076 | |
2078 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2079 | - if($i>0) { |
|
2077 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
2078 | + if ($i > 0) { |
|
2080 | 2079 | $this->sessionData['body'] .= '<hr>'; |
2081 | 2080 | } |
2082 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2081 | + if ($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2083 | 2082 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
2084 | 2083 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
2085 | 2084 | } |
2086 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
2085 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
2087 | 2086 | |
2088 | 2087 | $_htmlConfig = mail_bo::$htmLawed_config; |
2089 | 2088 | mail_bo::$htmLawed_config['comment'] = 2; |
@@ -2093,30 +2092,30 @@ discard block |
||
2093 | 2092 | #error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
2094 | 2093 | } |
2095 | 2094 | |
2096 | - $this->sessionData['body'] .= '</blockquote><br>'; |
|
2097 | - $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
|
2095 | + $this->sessionData['body'] .= '</blockquote><br>'; |
|
2096 | + $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
|
2098 | 2097 | } else { |
2099 | 2098 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
2100 | 2099 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
2101 | - $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2100 | + $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2102 | 2101 | @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
2103 | 2102 | $toAddress.$ccAddress. |
2104 | - @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,mail_bo::$displayCharset, false)."\r\n". |
|
2103 | + @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, mail_bo::$displayCharset, false)."\r\n". |
|
2105 | 2104 | '-------------------------------------------------'."\r\n \r\n "; |
2106 | - $this->sessionData['mimeType'] = 'plain'; |
|
2105 | + $this->sessionData['mimeType'] = 'plain'; |
|
2107 | 2106 | |
2108 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2109 | - if($i>0) { |
|
2107 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
2108 | + if ($i > 0) { |
|
2110 | 2109 | $this->sessionData['body'] .= "<hr>"; |
2111 | 2110 | } |
2112 | 2111 | |
2113 | 2112 | // add line breaks to $bodyParts |
2114 | - $newBody = translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']); |
|
2113 | + $newBody = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
2115 | 2114 | #error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
2116 | 2115 | $newBody = mail_ui::resolve_inline_images($newBody, $_folder, $_uid, $_partID, 'plain'); |
2117 | 2116 | $this->sessionData['body'] .= "\r\n"; |
2118 | 2117 | // create body new, with good line breaks and indention |
2119 | - foreach(explode("\n",$newBody) as $value) { |
|
2118 | + foreach (explode("\n", $newBody) as $value) { |
|
2120 | 2119 | // the explode is removing the character |
2121 | 2120 | if (trim($value) != '') { |
2122 | 2121 | #if ($value != "\r") $value .= "\n"; |
@@ -2124,12 +2123,12 @@ discard block |
||
2124 | 2123 | $numberOfChars = strspn(trim($value), ">"); |
2125 | 2124 | $appendString = str_repeat('>', $numberOfChars + 1); |
2126 | 2125 | |
2127 | - $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
|
2126 | + $bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>'); |
|
2128 | 2127 | |
2129 | - if($bodyAppend[0] == '>') { |
|
2130 | - $bodyAppend = '>'. $bodyAppend; |
|
2128 | + if ($bodyAppend[0] == '>') { |
|
2129 | + $bodyAppend = '>'.$bodyAppend; |
|
2131 | 2130 | } else { |
2132 | - $bodyAppend = '> '. $bodyAppend; |
|
2131 | + $bodyAppend = '> '.$bodyAppend; |
|
2133 | 2132 | } |
2134 | 2133 | |
2135 | 2134 | $this->sessionData['body'] .= $bodyAppend; |
@@ -2152,16 +2151,16 @@ discard block |
||
2152 | 2151 | */ |
2153 | 2152 | static function _getCleanHTML($_body, $_useTidy = false) |
2154 | 2153 | { |
2155 | - static $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
2156 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
2157 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
2154 | + static $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
2155 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
2156 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
2158 | 2157 | |
2159 | - if ($_useTidy && extension_loaded('tidy') ) |
|
2158 | + if ($_useTidy && extension_loaded('tidy')) |
|
2160 | 2159 | { |
2161 | 2160 | $tidy = new tidy(); |
2162 | - $cleaned = $tidy->repairString($_body, mail_bo::$tidy_config,'utf8'); |
|
2161 | + $cleaned = $tidy->repairString($_body, mail_bo::$tidy_config, 'utf8'); |
|
2163 | 2162 | // Found errors. Strip it all so there's some output |
2164 | - if($tidy->getStatus() == 2) |
|
2163 | + if ($tidy->getStatus() == 2) |
|
2165 | 2164 | { |
2166 | 2165 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
2167 | 2166 | } |
@@ -2193,10 +2192,10 @@ discard block |
||
2193 | 2192 | * @param array $_identity |
2194 | 2193 | * @param boolean $_autosaving =false true: autosaving, false: save-as-draft or send |
2195 | 2194 | */ |
2196 | - function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false) |
|
2195 | + function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false) |
|
2197 | 2196 | { |
2198 | 2197 | //error_log(__METHOD__."(, formDate[filemode]=$_formData[filemode], _autosaving=".array2string($_autosaving).') '.function_backtrace()); |
2199 | - $mail_bo = $this->mail_bo; |
|
2198 | + $mail_bo = $this->mail_bo; |
|
2200 | 2199 | $activeMailProfile = emailadmin_account::read($this->mail_bo->profileID); |
2201 | 2200 | |
2202 | 2201 | // you need to set the sender, if you work with different identities, since most smtp servers, dont allow |
@@ -2206,17 +2205,17 @@ discard block |
||
2206 | 2205 | error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity)); |
2207 | 2206 | } |
2208 | 2207 | $_mailObject->setFrom($_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'], |
2209 | - mail_bo::generateIdentityString($_identity,false)); |
|
2208 | + mail_bo::generateIdentityString($_identity, false)); |
|
2210 | 2209 | |
2211 | 2210 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
2212 | 2211 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
2213 | - if(!empty($_formData['in-reply-to'])) { |
|
2214 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
2212 | + if (!empty($_formData['in-reply-to'])) { |
|
2213 | + if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>'; |
|
2215 | 2214 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(In-Reply-To', $_formData['in-reply-to'].")"); |
2216 | 2215 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
2217 | 2216 | } |
2218 | - if(!empty($_formData['references'])) { |
|
2219 | - if (stripos($_formData['references'],'<')===false) $_formData['references']='<'.trim($_formData['references']).'>'; |
|
2217 | + if (!empty($_formData['references'])) { |
|
2218 | + if (stripos($_formData['references'], '<') === false) $_formData['references'] = '<'.trim($_formData['references']).'>'; |
|
2220 | 2219 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(References', $_formData['references'].")"); |
2221 | 2220 | $_mailObject->addHeader('References', $_formData['references']); |
2222 | 2221 | } |
@@ -2227,16 +2226,16 @@ discard block |
||
2227 | 2226 | // $_mailObject->addHeader('Thread-Topic', $_formData['thread-topic']); |
2228 | 2227 | //} |
2229 | 2228 | |
2230 | - if(!empty($_formData['thread-index'])) { |
|
2229 | + if (!empty($_formData['thread-index'])) { |
|
2231 | 2230 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(Tread-Index', $_formData['thread-index'].")"); |
2232 | 2231 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
2233 | 2232 | } |
2234 | - if(!empty($_formData['list-id'])) { |
|
2233 | + if (!empty($_formData['list-id'])) { |
|
2235 | 2234 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(List-Id', $_formData['list-id'].")"); |
2236 | 2235 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
2237 | 2236 | } |
2238 | 2237 | //error_log(__METHOD__.__LINE__.' notify to:'.$_identity['ident_email'].'->'.array2string($_formData)); |
2239 | - if($_formData['disposition']=='on') { |
|
2238 | + if ($_formData['disposition'] == 'on') { |
|
2240 | 2239 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
2241 | 2240 | } |
2242 | 2241 | //error_log(__METHOD__.__LINE__.' Organization:'.array2string($_identity)); |
@@ -2245,7 +2244,7 @@ discard block |
||
2245 | 2244 | //} |
2246 | 2245 | |
2247 | 2246 | // Expand any mailing lists |
2248 | - foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
|
2247 | + foreach (array('to', 'cc', 'bcc', 'replyto') as $field) |
|
2249 | 2248 | { |
2250 | 2249 | if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
2251 | 2250 | |
@@ -2268,7 +2267,7 @@ discard block |
||
2268 | 2267 | '1' => 'before reply, visible during compose', |
2269 | 2268 | 'no_belowaftersend' => 'appended after reply before sending', |
2270 | 2269 | */ |
2271 | - $sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0; |
|
2270 | + $sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0; |
|
2272 | 2271 | if ($sigAlreadyThere) |
2273 | 2272 | { |
2274 | 2273 | // note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature |
@@ -2277,7 +2276,7 @@ discard block |
||
2277 | 2276 | } |
2278 | 2277 | if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) && |
2279 | 2278 | $this->mailPreferences['disableRulerForSignatureSeparation']) || |
2280 | - empty($signature) || trim($this->convertHTMLToText($signature)) =='') |
|
2279 | + empty($signature) || trim($this->convertHTMLToText($signature)) == '') |
|
2281 | 2280 | { |
2282 | 2281 | $disableRuler = true; |
2283 | 2282 | } |
@@ -2294,7 +2293,7 @@ discard block |
||
2294 | 2293 | array_unique(array_merge((array)$_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc'])), |
2295 | 2294 | $_formData['expiration'], $_formData['password']); |
2296 | 2295 | } |
2297 | - if($_formData['mimeType'] == 'html') |
|
2296 | + if ($_formData['mimeType'] == 'html') |
|
2298 | 2297 | { |
2299 | 2298 | $body = $_formData['body']; |
2300 | 2299 | if ($attachment_links) |
@@ -2308,13 +2307,13 @@ discard block |
||
2308 | 2307 | $body .= $attachment_links; |
2309 | 2308 | } |
2310 | 2309 | } |
2311 | - if(!empty($signature)) |
|
2310 | + if (!empty($signature)) |
|
2312 | 2311 | { |
2313 | 2312 | $_mailObject->setBody($this->convertHTMLToText($body, true, true). |
2314 | 2313 | ($disableRuler ? "\r\n" : "\r\n-- \r\n"). |
2315 | 2314 | $this->convertHTMLToText($signature, true, true)); |
2316 | 2315 | |
2317 | - $body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature; |
|
2316 | + $body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature; |
|
2318 | 2317 | } |
2319 | 2318 | else |
2320 | 2319 | { |
@@ -2322,22 +2321,22 @@ discard block |
||
2322 | 2321 | } |
2323 | 2322 | // convert URL Images to inline images - if possible |
2324 | 2323 | if (!$_autosaving) mail_bo::processURL2InlineImages($_mailObject, $body, $mail_bo); |
2325 | - if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
|
2324 | + if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false) |
|
2326 | 2325 | { |
2327 | - $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
|
2326 | + $body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body); |
|
2328 | 2327 | } |
2329 | - $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() |
|
2328 | + $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() |
|
2330 | 2329 | } |
2331 | 2330 | else |
2332 | 2331 | { |
2333 | - $body = $this->convertHTMLToText($_formData['body'],false); |
|
2332 | + $body = $this->convertHTMLToText($_formData['body'], false); |
|
2334 | 2333 | |
2335 | 2334 | if ($attachment_links) $body .= $attachment_links; |
2336 | 2335 | |
2337 | 2336 | #$_mailObject->Body = $_formData['body']; |
2338 | - if(!empty($signature)) { |
|
2339 | - $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
|
2340 | - $this->convertHTMLToText($signature,true,true); |
|
2337 | + if (!empty($signature)) { |
|
2338 | + $body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n"). |
|
2339 | + $this->convertHTMLToText($signature, true, true); |
|
2341 | 2340 | } |
2342 | 2341 | $_mailObject->setBody($body); |
2343 | 2342 | } |
@@ -2348,9 +2347,9 @@ discard block |
||
2348 | 2347 | $connection_opened = false; |
2349 | 2348 | //error_log(__METHOD__.__LINE__.array2string($_formData['attachments'])); |
2350 | 2349 | $tnfattachments = null; |
2351 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
2350 | + foreach ((array)$_formData['attachments'] as $attachment) { |
|
2352 | 2351 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
2353 | - if(is_array($attachment)) |
|
2352 | + if (is_array($attachment)) |
|
2354 | 2353 | { |
2355 | 2354 | if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
2356 | 2355 | /* Example: |
@@ -2368,20 +2367,20 @@ discard block |
||
2368 | 2367 | $connection_opened = true; |
2369 | 2368 | } |
2370 | 2369 | $mail_bo->reopen($attachment['folder']); |
2371 | - switch(strtoupper($attachment['type'])) { |
|
2370 | + switch (strtoupper($attachment['type'])) { |
|
2372 | 2371 | case 'MESSAGE/RFC': |
2373 | 2372 | case 'MESSAGE/RFC822': |
2374 | - $rawBody=''; |
|
2373 | + $rawBody = ''; |
|
2375 | 2374 | if (isset($attachment['partID'])) { |
2376 | - $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
|
2377 | - $rawBody=$eml['attachment']; |
|
2375 | + $eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']); |
|
2376 | + $rawBody = $eml['attachment']; |
|
2378 | 2377 | } else { |
2379 | - $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
|
2378 | + $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']); |
|
2380 | 2379 | } |
2381 | 2380 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
2382 | 2381 | break; |
2383 | 2382 | default: |
2384 | - $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
|
2383 | + $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false); |
|
2385 | 2384 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
2386 | 2385 | { |
2387 | 2386 | if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
@@ -2389,7 +2388,7 @@ discard block |
||
2389 | 2388 | { |
2390 | 2389 | if ($k['name'] == $attachment['name']) |
2391 | 2390 | { |
2392 | - $tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']); |
|
2391 | + $tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']); |
|
2393 | 2392 | $attachmentData['attachment'] = $tnfpart['attachment']; |
2394 | 2393 | //error_log(__METHOD__.__LINE__.$k['name'].'<->'.$attachment['name'].':'.array2string($attachmentData['attachment'])); |
2395 | 2394 | break; |
@@ -2403,7 +2402,7 @@ discard block |
||
2403 | 2402 | // attach files not for autosaving |
2404 | 2403 | elseif ($_formData['filemode'] == egw_sharing::ATTACH && !$_autosaving) |
2405 | 2404 | { |
2406 | - if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs') |
|
2405 | + if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs') |
|
2407 | 2406 | { |
2408 | 2407 | egw_vfs::load_wrapper('vfs'); |
2409 | 2408 | $tmp_path = $attachment['file']; |
@@ -2412,7 +2411,7 @@ discard block |
||
2412 | 2411 | { |
2413 | 2412 | $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($attachment['file']); |
2414 | 2413 | } |
2415 | - $_mailObject->addAttachment ( |
|
2414 | + $_mailObject->addAttachment( |
|
2416 | 2415 | $tmp_path, |
2417 | 2416 | $attachment['name'], |
2418 | 2417 | $attachment['type'] |
@@ -2437,16 +2436,16 @@ discard block |
||
2437 | 2436 | * @param string $password =null |
2438 | 2437 | * @return string might be empty if no file attachments found |
2439 | 2438 | */ |
2440 | - protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
|
2439 | + protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null) |
|
2441 | 2440 | { |
2442 | 2441 | if ($filemode == egw_sharing::ATTACH) return ''; |
2443 | 2442 | |
2444 | 2443 | $links = array(); |
2445 | - foreach($attachments as $attachment) |
|
2444 | + foreach ($attachments as $attachment) |
|
2446 | 2445 | { |
2447 | 2446 | $path = $attachment['file']; |
2448 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
2449 | - if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
|
2447 | + if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
2448 | + if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs') |
|
2450 | 2449 | { |
2451 | 2450 | $path = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($path); |
2452 | 2451 | } |
@@ -2476,7 +2475,7 @@ discard block |
||
2476 | 2475 | } |
2477 | 2476 | if (!$links) |
2478 | 2477 | { |
2479 | - return null; // no file attachments found |
|
2478 | + return null; // no file attachments found |
|
2480 | 2479 | } |
2481 | 2480 | elseif ($html) |
2482 | 2481 | { |
@@ -2491,7 +2490,7 @@ discard block |
||
2491 | 2490 | * @param array $content content sent from client-side |
2492 | 2491 | * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]' |
2493 | 2492 | */ |
2494 | - public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]') |
|
2493 | + public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]') |
|
2495 | 2494 | { |
2496 | 2495 | //error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)"); |
2497 | 2496 | $response = egw_json_response::get(); |
@@ -2505,8 +2504,8 @@ discard block |
||
2505 | 2504 | |
2506 | 2505 | $formData = array_merge($content, array( |
2507 | 2506 | 'isDrafted' => 1, |
2508 | - 'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')], |
|
2509 | - 'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value |
|
2507 | + 'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')], |
|
2508 | + 'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value |
|
2510 | 2509 | )); |
2511 | 2510 | |
2512 | 2511 | //Saving draft procedure |
@@ -2518,8 +2517,8 @@ discard block |
||
2518 | 2517 | if (($messageUid = $this->saveAsDraft($formData, $folder, $action))) |
2519 | 2518 | { |
2520 | 2519 | // saving as draft, does not mean closing the message |
2521 | - $messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid); |
|
2522 | - if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder))) |
|
2520 | + $messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid); |
|
2521 | + if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder))) |
|
2523 | 2522 | { |
2524 | 2523 | $draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid); |
2525 | 2524 | if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted'])) |
@@ -2528,7 +2527,7 @@ discard block |
||
2528 | 2527 | $duid = $dhA['msgUID']; |
2529 | 2528 | $dmailbox = $dhA['folder']; |
2530 | 2529 | // beware: do not delete the original mail as found in processedmail_id |
2531 | - $pMuid=''; |
|
2530 | + $pMuid = ''; |
|
2532 | 2531 | if ($content['processedmail_id']) |
2533 | 2532 | { |
2534 | 2533 | $pMhA = mail_ui::splitRowID($content['processedmail_id']); |
@@ -2536,15 +2535,15 @@ discard block |
||
2536 | 2535 | } |
2537 | 2536 | //error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments'])); |
2538 | 2537 | // do not delete the original message if attachments are present |
2539 | - if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments'])) |
|
2538 | + if (empty($pMuid) || $pMuid != $duid || empty($content['attachments'])) |
|
2540 | 2539 | { |
2541 | 2540 | try |
2542 | 2541 | { |
2543 | - $this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately'); |
|
2542 | + $this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately'); |
|
2544 | 2543 | } |
2545 | 2544 | catch (egw_exception $e) |
2546 | 2545 | { |
2547 | - $msg = str_replace('"',"'",$e->getMessage()); |
|
2546 | + $msg = str_replace('"', "'", $e->getMessage()); |
|
2548 | 2547 | $success = false; |
2549 | 2548 | error_log(__METHOD__.__LINE__.$msg); |
2550 | 2549 | } |
@@ -2559,7 +2558,7 @@ discard block |
||
2559 | 2558 | } |
2560 | 2559 | catch (egw_exception_wrong_userinput $e) |
2561 | 2560 | { |
2562 | - $msg = str_replace('"',"'",$e->getMessage()); |
|
2561 | + $msg = str_replace('"', "'", $e->getMessage()); |
|
2563 | 2562 | error_log(__METHOD__.__LINE__.$msg); |
2564 | 2563 | $success = false; |
2565 | 2564 | } |
@@ -2582,16 +2581,16 @@ discard block |
||
2582 | 2581 | */ |
2583 | 2582 | static function resolveEmailAddressList($_emailAddressList) |
2584 | 2583 | { |
2585 | - $addrFromList=array(); |
|
2586 | - foreach((array)$_emailAddressList as $ak => $address) |
|
2584 | + $addrFromList = array(); |
|
2585 | + foreach ((array)$_emailAddressList as $ak => $address) |
|
2587 | 2586 | { |
2588 | - if(is_int($address)) |
|
2587 | + if (is_int($address)) |
|
2589 | 2588 | { |
2590 | 2589 | // List was selected, expand to addresses |
2591 | 2590 | unset($_emailAddressList[$ak]); |
2592 | - $list = $GLOBALS['egw']->contacts->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address)); |
|
2591 | + $list = $GLOBALS['egw']->contacts->search('', array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'), '', '', '', False, 'AND', false, array('list' =>(int)$address)); |
|
2593 | 2592 | // Just add email addresses, they'll be checked below |
2594 | - foreach($list as $email) |
|
2593 | + foreach ($list as $email) |
|
2595 | 2594 | { |
2596 | 2595 | $addrFromList[] = $email['email'] ? $email['email'] : $email['email_home']; |
2597 | 2596 | } |
@@ -2601,7 +2600,7 @@ discard block |
||
2601 | 2600 | { |
2602 | 2601 | foreach ($addrFromList as $addr) |
2603 | 2602 | { |
2604 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
2603 | + if (!empty($addr)) $_emailAddressList[] = $addr; |
|
2605 | 2604 | } |
2606 | 2605 | } |
2607 | 2606 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2615,15 +2614,15 @@ discard block |
||
2615 | 2614 | * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]' |
2616 | 2615 | * @return boolean return messageUID| false due to an error |
2617 | 2616 | */ |
2618 | - function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]') |
|
2617 | + function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]') |
|
2619 | 2618 | { |
2620 | 2619 | //error_log(__METHOD__."(..., $savingDestination, action=$action)"); |
2621 | - $mail_bo = $this->mail_bo; |
|
2622 | - $mail = new egw_mailer($this->mail_bo->profileID); |
|
2620 | + $mail_bo = $this->mail_bo; |
|
2621 | + $mail = new egw_mailer($this->mail_bo->profileID); |
|
2623 | 2622 | |
2624 | 2623 | // preserve the bcc and if possible the save to folder information |
2625 | - $this->sessionData['folder'] = $_formData['folder']; |
|
2626 | - $this->sessionData['bcc'] = $_formData['bcc']; |
|
2624 | + $this->sessionData['folder'] = $_formData['folder']; |
|
2625 | + $this->sessionData['bcc'] = $_formData['bcc']; |
|
2627 | 2626 | $this->sessionData['mailidentity'] = $_formData['mailidentity']; |
2628 | 2627 | //$this->sessionData['stationeryID'] = $_formData['stationeryID']; |
2629 | 2628 | $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
@@ -2632,11 +2631,11 @@ discard block |
||
2632 | 2631 | { |
2633 | 2632 | $acc = emailadmin_account::read($this->sessionData['mailaccount']); |
2634 | 2633 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
2635 | - $identity = emailadmin_account::read_identity($acc['ident_id'],true); |
|
2634 | + $identity = emailadmin_account::read_identity($acc['ident_id'], true); |
|
2636 | 2635 | } |
2637 | 2636 | catch (Exception $e) |
2638 | 2637 | { |
2639 | - $identity=array(); |
|
2638 | + $identity = array(); |
|
2640 | 2639 | } |
2641 | 2640 | |
2642 | 2641 | $flags = '\\Seen \\Draft'; |
@@ -2646,7 +2645,7 @@ discard block |
||
2646 | 2645 | // folder list as Customheader |
2647 | 2646 | if (!empty($this->sessionData['folder'])) |
2648 | 2647 | { |
2649 | - $folders = implode('|',array_unique($this->sessionData['folder'])); |
|
2648 | + $folders = implode('|', array_unique($this->sessionData['folder'])); |
|
2650 | 2649 | $mail->addHeader('X-Mailfolder', $folders); |
2651 | 2650 | } |
2652 | 2651 | $mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']); |
@@ -2666,25 +2665,25 @@ discard block |
||
2666 | 2665 | $savingDestination = $this->sessionData['messageFolder']; |
2667 | 2666 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
2668 | 2667 | } |
2669 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
2668 | + if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder(); |
|
2670 | 2669 | |
2671 | 2670 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
2672 | 2671 | $mail->forceBccHeader(); |
2673 | 2672 | |
2674 | 2673 | $mail_bo->openConnection(); |
2675 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
2674 | + if ($mail_bo->folderExists($savingDestination, true)) { |
|
2676 | 2675 | try |
2677 | 2676 | { |
2678 | 2677 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
2679 | 2678 | } |
2680 | 2679 | catch (egw_exception_wrong_userinput $e) |
2681 | 2680 | { |
2682 | - error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage())); |
|
2681 | + error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage())); |
|
2683 | 2682 | return false; |
2684 | 2683 | } |
2685 | 2684 | |
2686 | 2685 | } else { |
2687 | - error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
|
2686 | + error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server.")); |
|
2688 | 2687 | return false; |
2689 | 2688 | } |
2690 | 2689 | $mail_bo->closeConnection(); |
@@ -2693,26 +2692,26 @@ discard block |
||
2693 | 2692 | |
2694 | 2693 | function send($_formData) |
2695 | 2694 | { |
2696 | - $mail_bo = $this->mail_bo; |
|
2697 | - $mail = new egw_mailer($mail_bo->profileID); |
|
2698 | - $messageIsDraft = false; |
|
2695 | + $mail_bo = $this->mail_bo; |
|
2696 | + $mail = new egw_mailer($mail_bo->profileID); |
|
2697 | + $messageIsDraft = false; |
|
2699 | 2698 | |
2700 | - $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
|
2699 | + $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
|
2701 | 2700 | $this->sessionData['to'] = self::resolveEmailAddressList($_formData['to']); |
2702 | 2701 | $this->sessionData['cc'] = self::resolveEmailAddressList($_formData['cc']); |
2703 | - $this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']); |
|
2704 | - $this->sessionData['folder'] = $_formData['folder']; |
|
2702 | + $this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']); |
|
2703 | + $this->sessionData['folder'] = $_formData['folder']; |
|
2705 | 2704 | $this->sessionData['replyto'] = $_formData['replyto']; |
2706 | 2705 | $this->sessionData['subject'] = trim($_formData['subject']); |
2707 | - $this->sessionData['body'] = $_formData['body']; |
|
2708 | - $this->sessionData['priority'] = $_formData['priority']; |
|
2706 | + $this->sessionData['body'] = $_formData['body']; |
|
2707 | + $this->sessionData['priority'] = $_formData['priority']; |
|
2709 | 2708 | $this->sessionData['mailidentity'] = $_formData['mailidentity']; |
2710 | 2709 | //$this->sessionData['stationeryID'] = $_formData['stationeryID']; |
2711 | 2710 | $this->sessionData['disposition'] = $_formData['disposition']; |
2712 | - $this->sessionData['mimeType'] = $_formData['mimeType']; |
|
2711 | + $this->sessionData['mimeType'] = $_formData['mimeType']; |
|
2713 | 2712 | $this->sessionData['to_infolog'] = $_formData['to_infolog']; |
2714 | 2713 | $this->sessionData['to_tracker'] = $_formData['to_tracker']; |
2715 | - $this->sessionData['attachments'] = $_formData['attachments']; |
|
2714 | + $this->sessionData['attachments'] = $_formData['attachments']; |
|
2716 | 2715 | |
2717 | 2716 | if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted'])) |
2718 | 2717 | { |
@@ -2721,11 +2720,11 @@ discard block |
||
2721 | 2720 | //error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']); |
2722 | 2721 | if (isset($_formData['mode']) && !empty($_formData['mode'])) |
2723 | 2722 | { |
2724 | - if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id'])) |
|
2723 | + if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id'])) |
|
2725 | 2724 | { |
2726 | - $this->sessionData['forwardFlag']='forwarded'; |
|
2727 | - $_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']); |
|
2728 | - $this->sessionData['uid']=array(); |
|
2725 | + $this->sessionData['forwardFlag'] = 'forwarded'; |
|
2726 | + $_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']); |
|
2727 | + $this->sessionData['uid'] = array(); |
|
2729 | 2728 | foreach ($_formData['processedmail_id'] as $k =>$rowid) |
2730 | 2729 | { |
2731 | 2730 | $fhA = mail_ui::splitRowID($rowid); |
@@ -2734,13 +2733,13 @@ discard block |
||
2734 | 2733 | if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
2735 | 2734 | } |
2736 | 2735 | } |
2737 | - if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
|
2736 | + if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id'])) |
|
2738 | 2737 | { |
2739 | 2738 | $rhA = mail_ui::splitRowID($_formData['processedmail_id']); |
2740 | 2739 | $this->sessionData['uid'] = $rhA['msgUID']; |
2741 | 2740 | $this->sessionData['messageFolder'] = $rhA['folder']; |
2742 | 2741 | } |
2743 | - if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id'])) |
|
2742 | + if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id'])) |
|
2744 | 2743 | { |
2745 | 2744 | $dhA = mail_ui::splitRowID($_formData['processedmail_id']); |
2746 | 2745 | $this->sessionData['uid'] = $dhA['msgUID']; |
@@ -2749,26 +2748,26 @@ discard block |
||
2749 | 2748 | } |
2750 | 2749 | // if the body is empty, maybe someone pasted something with scripts, into the message body |
2751 | 2750 | // this should not happen anymore, unless you call send directly, since the check was introduced with the action command |
2752 | - if(empty($this->sessionData['body'])) |
|
2751 | + if (empty($this->sessionData['body'])) |
|
2753 | 2752 | { |
2754 | 2753 | // this is to be found with the egw_unset_vars array for the _POST['body'] array |
2755 | - $name='_POST'; |
|
2756 | - $key='body'; |
|
2754 | + $name = '_POST'; |
|
2755 | + $key = 'body'; |
|
2757 | 2756 | #error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
2758 | 2757 | if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']'])) |
2759 | 2758 | { |
2760 | - $this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
|
2761 | - $_formData['body']=$this->sessionData['body']; |
|
2759 | + $this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
|
2760 | + $_formData['body'] = $this->sessionData['body']; |
|
2762 | 2761 | } |
2763 | 2762 | #error_log($this->sessionData['body']); |
2764 | 2763 | } |
2765 | - if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
|
2764 | + if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
|
2766 | 2765 | empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
2767 | 2766 | $messageIsDraft = true; |
2768 | 2767 | } |
2769 | 2768 | try |
2770 | 2769 | { |
2771 | - $identity = emailadmin_account::read_identity((int)$this->sessionData['mailidentity'],true); |
|
2770 | + $identity = emailadmin_account::read_identity((int)$this->sessionData['mailidentity'], true); |
|
2772 | 2771 | } |
2773 | 2772 | catch (Exception $e) |
2774 | 2773 | { |
@@ -2779,7 +2778,7 @@ discard block |
||
2779 | 2778 | // create the messages |
2780 | 2779 | $this->createMessage($mail, $_formData, $identity); |
2781 | 2780 | // remember the identity |
2782 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
2781 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
2783 | 2782 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
2784 | 2783 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
2785 | 2784 | #exit; |
@@ -2790,12 +2789,12 @@ discard block |
||
2790 | 2789 | $folderOnMailAccount = array(); |
2791 | 2790 | foreach ($folderToCheck as $k => $f) |
2792 | 2791 | { |
2793 | - $fval=$f; |
|
2794 | - $icServerID = $_formData['serverID'];//folders always assumed with serverID |
|
2795 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
2796 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
2792 | + $fval = $f; |
|
2793 | + $icServerID = $_formData['serverID']; //folders always assumed with serverID |
|
2794 | + if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2); |
|
2795 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
2797 | 2796 | { |
2798 | - if ($icServerID == $_formData['serverID'] ) |
|
2797 | + if ($icServerID == $_formData['serverID']) |
|
2799 | 2798 | { |
2800 | 2799 | $folder[$fval] = $fval; |
2801 | 2800 | $folderOnServerID[] = $fval; |
@@ -2808,7 +2807,7 @@ discard block |
||
2808 | 2807 | } |
2809 | 2808 | else |
2810 | 2809 | { |
2811 | - if ($icServerID == $_formData['serverID'] ) |
|
2810 | + if ($icServerID == $_formData['serverID']) |
|
2812 | 2811 | { |
2813 | 2812 | $folder[$fval] = $fval; |
2814 | 2813 | $folderOnServerID[] = $fval; |
@@ -2825,7 +2824,7 @@ discard block |
||
2825 | 2824 | // we use the sentFolder settings of the choosen mailaccount |
2826 | 2825 | // sentFolder is account specific |
2827 | 2826 | $changeProfileOnSentFolderNeeded = false; |
2828 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
2827 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
2829 | 2828 | { |
2830 | 2829 | $this->changeProfile($_formData['mailaccount']); |
2831 | 2830 | //error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#'); |
@@ -2833,30 +2832,30 @@ discard block |
||
2833 | 2832 | // sentFolder is account specific |
2834 | 2833 | $sentFolder = $this->mail_bo->getSentFolder(); |
2835 | 2834 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
2836 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
2835 | + if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false; |
|
2837 | 2836 | } |
2838 | 2837 | else |
2839 | 2838 | { |
2840 | 2839 | $sentFolder = $mail_bo->getSentFolder(); |
2841 | 2840 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
2842 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
2841 | + if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false; |
|
2843 | 2842 | } |
2844 | 2843 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
2845 | 2844 | |
2846 | 2845 | // we switch $this->mail_bo back to the account we used to work on |
2847 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
2846 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
2848 | 2847 | { |
2849 | 2848 | $this->changeProfile($_formData['serverID']); |
2850 | 2849 | } |
2851 | 2850 | |
2852 | 2851 | |
2853 | - if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' && |
|
2852 | + if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' && |
|
2854 | 2853 | $this->mailPreferences['sendOptions'] != 'send_only' && |
2855 | 2854 | $messageIsDraft == false) |
2856 | 2855 | { |
2857 | 2856 | if ($sentFolder) |
2858 | 2857 | { |
2859 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
2858 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
2860 | 2859 | { |
2861 | 2860 | $folderOnMailAccount[] = $sentFolder; |
2862 | 2861 | } |
@@ -2873,14 +2872,14 @@ discard block |
||
2873 | 2872 | } |
2874 | 2873 | else |
2875 | 2874 | { |
2876 | - if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
|
2875 | + if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
|
2877 | 2876 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
2878 | 2877 | $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
2879 | 2878 | } |
2880 | 2879 | // draftFolder is on Server we start from |
2881 | - if($messageIsDraft == true) { |
|
2880 | + if ($messageIsDraft == true) { |
|
2882 | 2881 | $draftFolder = $mail_bo->getDraftFolder(); |
2883 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
2882 | + if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) { |
|
2884 | 2883 | $this->sessionData['folder'] = array($draftFolder); |
2885 | 2884 | $folderOnServerID[] = $draftFolder; |
2886 | 2885 | $folder[$draftFolder] = $draftFolder; |
@@ -2889,10 +2888,10 @@ discard block |
||
2889 | 2888 | if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
2890 | 2889 | if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
2891 | 2890 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
2892 | - !( count($folder) > 0) && |
|
2893 | - !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
|
2891 | + !(count($folder) > 0) && |
|
2892 | + !($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')) |
|
2894 | 2893 | { |
2895 | - $this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo?' '.$this->errorInfo:''); |
|
2894 | + $this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo ? ' '.$this->errorInfo : ''); |
|
2896 | 2895 | #error_log($this->errorInfo); |
2897 | 2896 | return false; |
2898 | 2897 | } |
@@ -2901,17 +2900,17 @@ discard block |
||
2901 | 2900 | @set_time_limit(120); |
2902 | 2901 | //$mail->SMTPDebug = 10; |
2903 | 2902 | //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); |
2904 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
2903 | + if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
2905 | 2904 | try { |
2906 | 2905 | $mail->send(); |
2907 | 2906 | } |
2908 | - catch(Exception $e) { |
|
2907 | + catch (Exception $e) { |
|
2909 | 2908 | _egw_log_exception($e); |
2910 | - $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
|
2909 | + $this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : ''); |
|
2911 | 2910 | return false; |
2912 | 2911 | } |
2913 | 2912 | } else { |
2914 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
2913 | + if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) { |
|
2915 | 2914 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
2916 | 2915 | } else { |
2917 | 2916 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
@@ -2939,15 +2938,15 @@ discard block |
||
2939 | 2938 | // copying mail to folder |
2940 | 2939 | if (count($folder) > 0) |
2941 | 2940 | { |
2942 | - foreach($folderOnServerID as $folderName) { |
|
2941 | + foreach ($folderOnServerID as $folderName) { |
|
2943 | 2942 | if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
2944 | 2943 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
2945 | 2944 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
2946 | 2945 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
2947 | - if ($mail_bo->folderExists($folderName,true)) { |
|
2948 | - if($mail_bo->isSentFolder($folderName)) { |
|
2946 | + if ($mail_bo->folderExists($folderName, true)) { |
|
2947 | + if ($mail_bo->isSentFolder($folderName)) { |
|
2949 | 2948 | $flags = '\\Seen'; |
2950 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
2949 | + } elseif ($mail_bo->isDraftFolder($folderName)) { |
|
2951 | 2950 | $flags = '\\Draft'; |
2952 | 2951 | } else { |
2953 | 2952 | $flags = '\\Seen'; |
@@ -2963,25 +2962,25 @@ discard block |
||
2963 | 2962 | } |
2964 | 2963 | catch (egw_exception_wrong_userinput $e) |
2965 | 2964 | { |
2966 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage())); |
|
2965 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage())); |
|
2967 | 2966 | } |
2968 | 2967 | } |
2969 | 2968 | else |
2970 | 2969 | { |
2971 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
|
2970 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName)); |
|
2972 | 2971 | } |
2973 | 2972 | } |
2974 | 2973 | // if we choose to send from a differing profile |
2975 | 2974 | if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
2976 | - foreach($folderOnMailAccount as $folderName) { |
|
2975 | + foreach ($folderOnMailAccount as $folderName) { |
|
2977 | 2976 | if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
2978 | 2977 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
2979 | 2978 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
2980 | 2979 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
2981 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
2982 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
2980 | + if ($this->mail_bo->folderExists($folderName, true)) { |
|
2981 | + if ($this->mail_bo->isSentFolder($folderName)) { |
|
2983 | 2982 | $flags = '\\Seen'; |
2984 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
2983 | + } elseif ($this->mail_bo->isDraftFolder($folderName)) { |
|
2985 | 2984 | $flags = '\\Draft'; |
2986 | 2985 | } else { |
2987 | 2986 | $flags = '\\Seen'; |
@@ -2997,12 +2996,12 @@ discard block |
||
2997 | 2996 | } |
2998 | 2997 | catch (egw_exception_wrong_userinput $e) |
2999 | 2998 | { |
3000 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage())); |
|
2999 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage())); |
|
3001 | 3000 | } |
3002 | 3001 | } |
3003 | 3002 | else |
3004 | 3003 | { |
3005 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
|
3004 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName)); |
|
3006 | 3005 | } |
3007 | 3006 | } |
3008 | 3007 | if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
@@ -3013,27 +3012,27 @@ discard block |
||
3013 | 3012 | $lastDrafted = false; |
3014 | 3013 | if (isset($this->sessionData['lastDrafted'])) |
3015 | 3014 | { |
3016 | - $lastDrafted=array(); |
|
3015 | + $lastDrafted = array(); |
|
3017 | 3016 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
3018 | 3017 | $lastDrafted['uid'] = $dhA['msgUID']; |
3019 | 3018 | $lastDrafted['folder'] = $dhA['folder']; |
3020 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
3019 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']); |
|
3021 | 3020 | // manually drafted, do not delete |
3022 | 3021 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
3023 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
3022 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false; |
|
3024 | 3023 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
3025 | 3024 | } |
3026 | 3025 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
3027 | 3026 | { |
3028 | 3027 | try |
3029 | 3028 | { |
3030 | - if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' && |
|
3031 | - ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments'])) |
|
3029 | + if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' && |
|
3030 | + ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) |
|
3032 | 3031 | { |
3033 | 3032 | //error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData)); |
3034 | 3033 | //error_log(__METHOD__.__LINE__."#".array2string($_formData)); |
3035 | 3034 | //error_log(__METHOD__.__LINE__."#".array2string($this->sessionData)); |
3036 | - $mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately'); |
|
3035 | + $mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately'); |
|
3037 | 3036 | } |
3038 | 3037 | } |
3039 | 3038 | catch (egw_exception $e) |
@@ -3045,22 +3044,22 @@ discard block |
||
3045 | 3044 | unset($this->sessionData['lastDrafted']); |
3046 | 3045 | |
3047 | 3046 | //error_log("handling draft messages, flagging and such"); |
3048 | - if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
|
3047 | + if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
|
3049 | 3048 | || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
3050 | 3049 | // mark message as answered |
3051 | 3050 | $mail_bo->openConnection(); |
3052 | - $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
|
3051 | + $mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder'])); |
|
3053 | 3052 | // if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send |
3054 | 3053 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
3055 | 3054 | if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder'])) |
3056 | 3055 | { |
3057 | 3056 | try // message may be deleted already, as it maybe done by autosave |
3058 | 3057 | { |
3059 | - if ($_formData['mode']=='composefromdraft' && |
|
3058 | + if ($_formData['mode'] == 'composefromdraft' && |
|
3060 | 3059 | !(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) |
3061 | 3060 | { |
3062 | 3061 | //error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']); |
3063 | - $mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']); |
|
3062 | + $mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder']); |
|
3064 | 3063 | } |
3065 | 3064 | } |
3066 | 3065 | catch (egw_exception $e) |
@@ -3069,14 +3068,14 @@ discard block |
||
3069 | 3068 | unset($e); |
3070 | 3069 | } |
3071 | 3070 | } else { |
3072 | - $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
|
3071 | + $mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder'])); |
|
3073 | 3072 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
3074 | - if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
|
3073 | + if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded') |
|
3075 | 3074 | { |
3076 | 3075 | try |
3077 | 3076 | { |
3078 | 3077 | //error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
3079 | - $mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']); |
|
3078 | + $mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']); |
|
3080 | 3079 | } |
3081 | 3080 | catch (egw_exception $e) |
3082 | 3081 | { |
@@ -3104,18 +3103,18 @@ discard block |
||
3104 | 3103 | if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
3105 | 3104 | if (!empty($mailaddresses)) $mailaddresses['from'] = $GLOBALS['egw']->translation->decodeMailHeader($fromAddress); |
3106 | 3105 | |
3107 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
|
3106 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') |
|
3108 | 3107 | { |
3109 | - foreach(array('to_infolog','to_tracker','to_calendar') as $app_key) |
|
3108 | + foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key) |
|
3110 | 3109 | { |
3111 | 3110 | if ($_formData[$app_key] == 'on') |
3112 | 3111 | { |
3113 | - $app_name = substr($app_key,3); |
|
3112 | + $app_name = substr($app_key, 3); |
|
3114 | 3113 | // Get registered hook data of the app called for integration |
3115 | - $hook = $GLOBALS['egw']->hooks->single(array('location'=> 'mail_import'),$app_name); |
|
3114 | + $hook = $GLOBALS['egw']->hooks->single(array('location'=> 'mail_import'), $app_name); |
|
3116 | 3115 | |
3117 | 3116 | // store mail / eml in temp. file to not have to download it from mail-server again |
3118 | - $eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate'); |
|
3117 | + $eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate'); |
|
3119 | 3118 | $eml_fp = fopen($eml, 'w'); |
3120 | 3119 | stream_copy_to_stream($mail->getRaw(), $eml_fp); |
3121 | 3120 | fclose($eml_fp); |
@@ -3125,24 +3124,24 @@ discard block |
||
3125 | 3124 | // be stored from registered app method later |
3126 | 3125 | egw_framework::popup(egw::link('/index.php', array( |
3127 | 3126 | 'menuaction' => $hook['menuaction'], |
3128 | - 'egw_data' => egw_link::set_data(null,'mail_integration::integrate',array( |
|
3127 | + 'egw_data' => egw_link::set_data(null, 'mail_integration::integrate', array( |
|
3129 | 3128 | $mailaddresses, |
3130 | 3129 | $this->sessionData['subject'], |
3131 | 3130 | $this->convertHTMLToText($this->sessionData['body']), |
3132 | 3131 | $this->sessionData['attachments'], |
3133 | 3132 | false, // date |
3134 | 3133 | $eml, |
3135 | - $_formData['serverID']),true), |
|
3134 | + $_formData['serverID']), true), |
|
3136 | 3135 | 'app' => $app_name |
3137 | - )),'_blank',$hook['popup']); |
|
3136 | + )), '_blank', $hook['popup']); |
|
3138 | 3137 | } |
3139 | 3138 | } |
3140 | 3139 | } |
3141 | 3140 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
3142 | - elseif(is_array($this->sessionData['attachments'])) |
|
3141 | + elseif (is_array($this->sessionData['attachments'])) |
|
3143 | 3142 | { |
3144 | - foreach($this->sessionData['attachments'] as $value) { |
|
3145 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
3143 | + foreach ($this->sessionData['attachments'] as $value) { |
|
3144 | + if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
3146 | 3145 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
3147 | 3146 | } |
3148 | 3147 | } |
@@ -3159,7 +3158,7 @@ discard block |
||
3159 | 3158 | * @param array $content |
3160 | 3159 | * @return array - the input, enriched with some not set attributes |
3161 | 3160 | */ |
3162 | - function setDefaults($content=array()) |
|
3161 | + function setDefaults($content = array()) |
|
3163 | 3162 | { |
3164 | 3163 | // if there's not already an identity selected for current account |
3165 | 3164 | if (empty($content['mailidentity'])) |
@@ -3168,7 +3167,7 @@ discard block |
||
3168 | 3167 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
3169 | 3168 | { |
3170 | 3169 | $sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']; |
3171 | - if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0) |
|
3170 | + if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0) |
|
3172 | 3171 | { |
3173 | 3172 | $content['mailidentity'] = $sigPref[$this->mail_bo->profileID]; |
3174 | 3173 | } |
@@ -3177,7 +3176,7 @@ discard block |
||
3177 | 3176 | if (empty($content['mailidentity'])) |
3178 | 3177 | { |
3179 | 3178 | $default_identity = null; |
3180 | - foreach(emailadmin_account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
|
3179 | + foreach (emailadmin_account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
|
3181 | 3180 | { |
3182 | 3181 | if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
3183 | 3182 | if (!empty($identity['ident_signature'])) |
@@ -3192,7 +3191,7 @@ discard block |
||
3192 | 3191 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
3193 | 3192 | { |
3194 | 3193 | $content['mimeType'] = 'html'; |
3195 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
3194 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain'; |
|
3196 | 3195 | } |
3197 | 3196 | return $content; |
3198 | 3197 | |
@@ -3215,7 +3214,7 @@ discard block |
||
3215 | 3214 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
3216 | 3215 | * @return type |
3217 | 3216 | */ |
3218 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
3217 | + function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) { |
|
3219 | 3218 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
3220 | 3219 | static $useCacheIfPossible = null; |
3221 | 3220 | if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
@@ -3228,36 +3227,36 @@ discard block |
||
3228 | 3227 | { |
3229 | 3228 | $this->changeProfile($_mailaccountToSearch); |
3230 | 3229 | } |
3231 | - if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer)) |
|
3230 | + if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer)) |
|
3232 | 3231 | { |
3233 | 3232 | //error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId); |
3234 | 3233 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
3235 | 3234 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
3236 | - $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
|
3237 | - if (count($folderObjects)<=1) { |
|
3235 | + $folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible); |
|
3236 | + if (count($folderObjects) <= 1) { |
|
3238 | 3237 | $useCacheIfPossible = false; |
3239 | 3238 | } |
3240 | 3239 | else |
3241 | 3240 | { |
3242 | 3241 | $useCacheIfPossible = true; |
3243 | 3242 | } |
3244 | - $searchString = translation::convert($_searchString, mail_bo::$displayCharset,'UTF7-IMAP'); |
|
3243 | + $searchString = translation::convert($_searchString, mail_bo::$displayCharset, 'UTF7-IMAP'); |
|
3245 | 3244 | foreach ($folderObjects as $k =>$fA) |
3246 | 3245 | { |
3247 | 3246 | //error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName); |
3248 | - $f=false; |
|
3249 | - $key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k; |
|
3250 | - if ($_searchStringLength<=0) |
|
3247 | + $f = false; |
|
3248 | + $key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k; |
|
3249 | + if ($_searchStringLength <= 0) |
|
3251 | 3250 | { |
3252 | - $f=true; |
|
3251 | + $f = true; |
|
3253 | 3252 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
3254 | 3253 | } |
3255 | - if ($f==false && stripos($fA->displayName,$_searchString)!==false) |
|
3254 | + if ($f == false && stripos($fA->displayName, $_searchString) !== false) |
|
3256 | 3255 | { |
3257 | - $f=true; |
|
3256 | + $f = true; |
|
3258 | 3257 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
3259 | 3258 | } |
3260 | - if ($f==false && stripos($k,$searchString)!==false) |
|
3259 | + if ($f == false && stripos($k, $searchString) !== false) |
|
3261 | 3260 | { |
3262 | 3261 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
3263 | 3262 | } |
@@ -3285,12 +3284,12 @@ discard block |
||
3285 | 3284 | common::egw_exit(); |
3286 | 3285 | } |
3287 | 3286 | |
3288 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
3287 | + public static function ajax_searchAddress($_searchStringLength = 2) { |
|
3289 | 3288 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
3290 | 3289 | $_searchString = trim($_REQUEST['query']); |
3291 | 3290 | $include_lists = (boolean)$_REQUEST['include_lists']; |
3292 | 3291 | |
3293 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) |
|
3292 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength) |
|
3294 | 3293 | { |
3295 | 3294 | //error_log(__METHOD__.__LINE__.array2string($_searchString)); |
3296 | 3295 | $showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']); |
@@ -3299,64 +3298,64 @@ discard block |
||
3299 | 3298 | { |
3300 | 3299 | if (mb_strlen($v) < 3) unset($search[$k]); |
3301 | 3300 | } |
3302 | - $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
|
3301 | + $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
|
3303 | 3302 | //error_log(__METHOD__.__LINE__.$_searchString); |
3304 | 3303 | $filter = $showAccounts ? array() : array('account_id' => null); |
3305 | - $filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home'); |
|
3306 | - $cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'); |
|
3307 | - $contacts = $GLOBALS['egw']->contacts->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter); |
|
3304 | + $filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'); |
|
3305 | + $cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'); |
|
3306 | + $contacts = $GLOBALS['egw']->contacts->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
3308 | 3307 | // additionally search the accounts, if the contact storage is not the account storage |
3309 | 3308 | if ($showAccounts && $GLOBALS['egw']->contacts->so_accounts) |
3310 | 3309 | { |
3311 | 3310 | $filter['owner'] = 0; |
3312 | - $accounts = $GLOBALS['egw']->contacts->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter); |
|
3311 | + $accounts = $GLOBALS['egw']->contacts->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
3313 | 3312 | |
3314 | 3313 | if ($contacts && $accounts) |
3315 | 3314 | { |
3316 | - $contacts = array_merge($contacts,$accounts); |
|
3317 | - usort($contacts,function($a, $b) |
|
3315 | + $contacts = array_merge($contacts, $accounts); |
|
3316 | + usort($contacts, function($a, $b) |
|
3318 | 3317 | { |
3319 | 3318 | return strcasecmp($a['n_fn'], $b['n_fn']); |
3320 | 3319 | }); |
3321 | 3320 | } |
3322 | - elseif($accounts) |
|
3321 | + elseif ($accounts) |
|
3323 | 3322 | { |
3324 | - $contacts =& $accounts; |
|
3323 | + $contacts = & $accounts; |
|
3325 | 3324 | } |
3326 | 3325 | unset($accounts); |
3327 | 3326 | } |
3328 | 3327 | } |
3329 | 3328 | $results = array(); |
3330 | - if(is_array($contacts)) { |
|
3331 | - foreach($contacts as $contact) { |
|
3332 | - foreach(array($contact['email'],$contact['email_home']) as $email) { |
|
3329 | + if (is_array($contacts)) { |
|
3330 | + foreach ($contacts as $contact) { |
|
3331 | + foreach (array($contact['email'], $contact['email_home']) as $email) { |
|
3333 | 3332 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
3334 | 3333 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
3335 | 3334 | $rfcAddr = emailadmin_imapbase::parseAddressList($email); |
3336 | - $_rfcAddr=$rfcAddr->first(); |
|
3335 | + $_rfcAddr = $rfcAddr->first(); |
|
3337 | 3336 | if (!$_rfcAddr->valid) |
3338 | 3337 | { |
3339 | 3338 | continue; // skip address if we encounter an error here |
3340 | 3339 | } |
3341 | 3340 | $email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
3342 | 3341 | |
3343 | - if (method_exists($GLOBALS['egw']->contacts,'search')) |
|
3342 | + if (method_exists($GLOBALS['egw']->contacts, 'search')) |
|
3344 | 3343 | { |
3345 | - $contact['n_fn']=''; |
|
3344 | + $contact['n_fn'] = ''; |
|
3346 | 3345 | if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
3347 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
3348 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
3349 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
3350 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
3346 | + if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given']; |
|
3347 | + if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family']; |
|
3348 | + if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')'; |
|
3349 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
3351 | 3350 | } |
3352 | 3351 | else |
3353 | 3352 | { |
3354 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
3353 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
3355 | 3354 | } |
3356 | 3355 | $args = explode('@', trim($email)); |
3357 | 3356 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
3358 | 3357 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
3359 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
3358 | + if (!empty($email) && in_array($completeMailString, $results) === false) { |
|
3360 | 3359 | $results[] = array( |
3361 | 3360 | 'id'=>$completeMailString, |
3362 | 3361 | 'label' => $completeMailString, |
@@ -3372,10 +3371,10 @@ discard block |
||
3372 | 3371 | // Add groups |
3373 | 3372 | $group_options = array('account_type' => 'groups'); |
3374 | 3373 | $groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options); |
3375 | - foreach($groups as $g_id => $name) |
|
3374 | + foreach ($groups as $g_id => $name) |
|
3376 | 3375 | { |
3377 | 3376 | $group = $GLOBALS['egw']->accounts->read($g_id); |
3378 | - if(!$group['account_email']) continue; |
|
3377 | + if (!$group['account_email']) continue; |
|
3379 | 3378 | $args = explode('@', trim($group['account_email'])); |
3380 | 3379 | $args[] = $name; |
3381 | 3380 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
@@ -3388,7 +3387,7 @@ discard block |
||
3388 | 3387 | } |
3389 | 3388 | |
3390 | 3389 | // Add up to 5 matching mailing lists |
3391 | - if($include_lists) |
|
3390 | + if ($include_lists) |
|
3392 | 3391 | { |
3393 | 3392 | $lists = array_filter( |
3394 | 3393 | $GLOBALS['egw']->contacts->get_lists(EGW_ACL_READ), |
@@ -3397,7 +3396,7 @@ discard block |
||
3397 | 3396 | } |
3398 | 3397 | ); |
3399 | 3398 | $list_count = 0; |
3400 | - foreach($lists as $key => $list_name) |
|
3399 | + foreach ($lists as $key => $list_name) |
|
3401 | 3400 | { |
3402 | 3401 | $results[] = array( |
3403 | 3402 | 'id' => $key, |
@@ -3407,7 +3406,7 @@ discard block |
||
3407 | 3406 | 'title' => lang('Mailinglist'), |
3408 | 3407 | 'data' => $key |
3409 | 3408 | ); |
3410 | - if($list_count++ > 5) break; |
|
3409 | + if ($list_count++ > 5) break; |
|
3411 | 3410 | } |
3412 | 3411 | } |
3413 | 3412 | // switch regular JSON response handling off |
@@ -3428,7 +3427,7 @@ discard block |
||
3428 | 3427 | public function ajax_merge($contact_id) |
3429 | 3428 | { |
3430 | 3429 | $response = egw_json_response::get(); |
3431 | - if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'],'bo_merge')) |
|
3430 | + if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'bo_merge')) |
|
3432 | 3431 | { |
3433 | 3432 | $document_merge = new $_REQUEST['merge'](); |
3434 | 3433 | } |
@@ -3438,7 +3437,7 @@ discard block |
||
3438 | 3437 | } |
3439 | 3438 | $this->mail_bo->openConnection(); |
3440 | 3439 | |
3441 | - if(($error = $document_merge->check_document($_REQUEST['document'],''))) |
|
3440 | + if (($error = $document_merge->check_document($_REQUEST['document'], ''))) |
|
3442 | 3441 | { |
3443 | 3442 | $response->error($error); |
3444 | 3443 | return; |
@@ -3447,20 +3446,20 @@ discard block |
||
3447 | 3446 | // Actually do the merge |
3448 | 3447 | $folder = $merged_mail_id = null; |
3449 | 3448 | $results = $this->mail_bo->importMessageToMergeAndSend( |
3450 | - $document_merge, egw_vfs::PREFIX . $_REQUEST['document'], |
|
3449 | + $document_merge, egw_vfs::PREFIX.$_REQUEST['document'], |
|
3451 | 3450 | // Send an extra non-numeric ID to force actual send of document |
3452 | 3451 | // instead of save as draft |
3453 | 3452 | array((int)$contact_id, ''), |
3454 | - $folder,$merged_mail_id |
|
3453 | + $folder, $merged_mail_id |
|
3455 | 3454 | ); |
3456 | 3455 | |
3457 | - if($results['success']) |
|
3456 | + if ($results['success']) |
|
3458 | 3457 | { |
3459 | - $response->data(implode(',',$results['success'])); |
|
3458 | + $response->data(implode(',', $results['success'])); |
|
3460 | 3459 | } |
3461 | - if($results['failed']) |
|
3460 | + if ($results['failed']) |
|
3462 | 3461 | { |
3463 | - $response->error(implode(',',$results['failed'])); |
|
3462 | + $response->error(implode(',', $results['failed'])); |
|
3464 | 3463 | } |
3465 | 3464 | } |
3466 | 3465 |
@@ -73,7 +73,10 @@ discard block |
||
73 | 73 | { |
74 | 74 | $this->mailPreferences['message_forwarding'] = 'asmail'; |
75 | 75 | } |
76 | - if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail'); |
|
76 | + if (is_null(mail_bo::$mailConfig)) |
|
77 | + { |
|
78 | + mail_bo::$mailConfig = config::read('mail'); |
|
79 | + } |
|
77 | 80 | |
78 | 81 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
79 | 82 | } |
@@ -87,11 +90,21 @@ discard block |
||
87 | 90 | { |
88 | 91 | if ($this->mail_bo->profileID!=$_icServerID) |
89 | 92 | { |
90 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
93 | + if (mail_bo::$debug) |
|
94 | + { |
|
95 | + error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
96 | + } |
|
91 | 97 | $this->mail_bo = mail_bo::getInstance(false,$_icServerID); |
92 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
98 | + if (mail_bo::$debug) |
|
99 | + { |
|
100 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
101 | + } |
|
93 | 102 | // no icServer Object: something failed big time |
94 | - if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
|
103 | + if (!isset($this->mail_bo->icServer)) |
|
104 | + { |
|
105 | + exit; |
|
106 | + } |
|
107 | + // ToDo: Exception or the dialog for setting up a server config |
|
95 | 108 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
96 | 109 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
97 | 110 | } |
@@ -237,7 +250,10 @@ discard block |
||
237 | 250 | */ |
238 | 251 | function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
239 | 252 | { |
240 | - if ($msg) egw_framework::message($msg); |
|
253 | + if ($msg) |
|
254 | + { |
|
255 | + egw_framework::message($msg); |
|
256 | + } |
|
241 | 257 | |
242 | 258 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
243 | 259 | { |
@@ -258,8 +274,14 @@ discard block |
||
258 | 274 | //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); |
259 | 275 | $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; |
260 | 276 | $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; |
261 | - if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; |
|
262 | - if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; |
|
277 | + if (isset($_GET['reply_id'])) |
|
278 | + { |
|
279 | + $replyID = $_GET['reply_id']; |
|
280 | + } |
|
281 | + if (!$replyID && isset($_GET['id'])) |
|
282 | + { |
|
283 | + $replyID = $_GET['id']; |
|
284 | + } |
|
263 | 285 | |
264 | 286 | // Process different places we can use as a start for composing an email |
265 | 287 | $actionToProcess = 'compose'; |
@@ -326,7 +348,10 @@ discard block |
||
326 | 348 | $suppressSigOnTop = true; |
327 | 349 | foreach ($_content['uploadForCompose'] as $i => &$upload) |
328 | 350 | { |
329 | - if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
|
351 | + if (!isset($upload['file'])) |
|
352 | + { |
|
353 | + $upload['file'] = $upload['tmp_name']; |
|
354 | + } |
|
330 | 355 | try |
331 | 356 | { |
332 | 357 | $upload['file'] = $upload['tmp_name'] = mail_bo::checkFileBasics($upload,$this->composeID,false); |
@@ -360,9 +385,15 @@ discard block |
||
360 | 385 | $remove=false; |
361 | 386 | foreach(array_keys($toDelete) as $k) |
362 | 387 | { |
363 | - if ($att['tmp_name']==$k) $remove=true; |
|
388 | + if ($att['tmp_name']==$k) |
|
389 | + { |
|
390 | + $remove=true; |
|
391 | + } |
|
392 | + } |
|
393 | + if (!$remove) |
|
394 | + { |
|
395 | + $_content['attachments'][] = $att; |
|
364 | 396 | } |
365 | - if (!$remove) $_content['attachments'][] = $att; |
|
366 | 397 | } |
367 | 398 | } |
368 | 399 | // someone clicked something like send, or saveAsDraft |
@@ -377,8 +408,7 @@ discard block |
||
377 | 408 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
378 | 409 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
379 | 410 | ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
380 | - ) |
|
381 | - { |
|
411 | + ) { |
|
382 | 412 | $this->changeProfile($_content['serverID']); |
383 | 413 | $composeProfile = $this->mail_bo->profileID; |
384 | 414 | } |
@@ -458,7 +488,10 @@ discard block |
||
458 | 488 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
459 | 489 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
460 | 490 | $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
461 | - if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
|
491 | + if (!empty($fhA['folder'])) |
|
492 | + { |
|
493 | + $workingFolder = $fhA['folder']; |
|
494 | + } |
|
462 | 495 | } |
463 | 496 | } |
464 | 497 | if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
@@ -509,7 +542,10 @@ discard block |
||
509 | 542 | } |
510 | 543 | } |
511 | 544 | |
512 | - if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
|
545 | + if ($activeProfile != $composeProfile) |
|
546 | + { |
|
547 | + $this->changeProfile($activeProfile); |
|
548 | + } |
|
513 | 549 | $insertSigOnTop = false; |
514 | 550 | $content = (is_array($_content)?$_content:array()); |
515 | 551 | if ($_contentHasMimeType) |
@@ -538,7 +574,10 @@ discard block |
||
538 | 574 | { |
539 | 575 | foreach ($contentArr as $k =>&$elem) |
540 | 576 | { |
541 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
577 | + if (stripos($elem,'<pre>')!==false) |
|
578 | + { |
|
579 | + $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
580 | + } |
|
542 | 581 | } |
543 | 582 | $content['mail_htmltext'] = implode('',$contentArr); |
544 | 583 | } |
@@ -575,8 +614,7 @@ discard block |
||
575 | 614 | if ( !empty($content['body']) && |
576 | 615 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
577 | 616 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
578 | - ) |
|
579 | - { |
|
617 | + ) { |
|
580 | 618 | $buttonClicked = true; |
581 | 619 | $suppressSigOnTop = true; |
582 | 620 | if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) |
@@ -592,7 +630,10 @@ discard block |
||
592 | 630 | else |
593 | 631 | { |
594 | 632 | $newSig = $this->mail_bo->getDefaultIdentity(); |
595 | - if ($newSig === false) $newSig = -2; |
|
633 | + if ($newSig === false) |
|
634 | + { |
|
635 | + $newSig = -2; |
|
636 | + } |
|
596 | 637 | } |
597 | 638 | } |
598 | 639 | $_oldSig = $composeCache['mailidentity']; |
@@ -600,7 +641,10 @@ discard block |
||
600 | 641 | $_currentMode = $_content['mimeType']; |
601 | 642 | if ($_oldSig != $_signatureid) |
602 | 643 | { |
603 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
644 | + if($this->_debug) |
|
645 | + { |
|
646 | + error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
647 | + } |
|
604 | 648 | // prepare signatures, the selected sig may be used on top of the body |
605 | 649 | try |
606 | 650 | { |
@@ -630,7 +674,10 @@ discard block |
||
630 | 674 | { |
631 | 675 | $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
632 | 676 | $sigText = $this->convertHTMLToText($sigText,true,true); |
633 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
677 | + if($this->_debug) |
|
678 | + { |
|
679 | + error_log(__METHOD__." Old signature:".$oldSigText); |
|
680 | + } |
|
634 | 681 | } |
635 | 682 | |
636 | 683 | //$oldSigText = mail_bo::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -646,7 +693,11 @@ discard block |
||
646 | 693 | { |
647 | 694 | $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
648 | 695 | $styles = mail_bo::getStyles(array(array('body'=>$content['body']))); |
649 | - if (stripos($content['body'],'style')!==false) translation::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags |
|
696 | + if (stripos($content['body'],'style')!==false) |
|
697 | + { |
|
698 | + translation::replaceTagsCompletley($content['body'],'style',$endtag='',true); |
|
699 | + } |
|
700 | + // clean out empty or pagewide style definitions / left over tags |
|
650 | 701 | } |
651 | 702 | $content['body'] = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($content['body'],mail_bo::$htmLawed_config,array(),true):$content['body'])); |
652 | 703 | mail_bo::$htmLawed_config = $_htmlConfig; |
@@ -690,8 +741,14 @@ discard block |
||
690 | 741 | |
691 | 742 | if ($found === false) |
692 | 743 | { |
693 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
694 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
744 | + if($this->_debug) |
|
745 | + { |
|
746 | + error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
747 | + } |
|
748 | + if($this->_debug) |
|
749 | + { |
|
750 | + error_log(__METHOD__." Compare content:".$content['body']); |
|
751 | + } |
|
695 | 752 | } |
696 | 753 | else |
697 | 754 | { |
@@ -706,7 +763,10 @@ discard block |
||
706 | 763 | } |
707 | 764 | |
708 | 765 | // do not double insert a signature on a server roundtrip |
709 | - if ($buttonClicked) $suppressSigOnTop = true; |
|
766 | + if ($buttonClicked) |
|
767 | + { |
|
768 | + $suppressSigOnTop = true; |
|
769 | + } |
|
710 | 770 | if ($isFirstLoad) |
711 | 771 | { |
712 | 772 | $alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached |
@@ -745,7 +805,8 @@ discard block |
||
745 | 805 | } |
746 | 806 | } |
747 | 807 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
748 | - foreach(array('subject','body','mimetype') as $name) { |
|
808 | + foreach(array('subject','body','mimetype') as $name) |
|
809 | + { |
|
749 | 810 | $sName = $name; |
750 | 811 | if ($name=='mimetype'&&$res[$name]) |
751 | 812 | { |
@@ -754,7 +815,10 @@ discard block |
||
754 | 815 | } |
755 | 816 | else |
756 | 817 | { |
757 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
818 | + if ($res[$name]) |
|
819 | + { |
|
820 | + $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
821 | + } |
|
758 | 822 | } |
759 | 823 | } |
760 | 824 | } |
@@ -765,7 +829,8 @@ discard block |
||
765 | 829 | { |
766 | 830 | $alreadyProcessed=array(); |
767 | 831 | //_debug_array($_REQUEST); |
768 | - if ($_REQUEST['preset']['mailto']) { |
|
832 | + if ($_REQUEST['preset']['mailto']) |
|
833 | + { |
|
769 | 834 | // handle mailto strings such as |
770 | 835 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
771 | 836 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
@@ -773,10 +838,12 @@ discard block |
||
773 | 838 | $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
774 | 839 | // check if there is more than the to address |
775 | 840 | $mailtoArray = explode('?',$tmp_send_to,2); |
776 | - if ($mailtoArray[1]) { |
|
841 | + if ($mailtoArray[1]) |
|
842 | + { |
|
777 | 843 | // check if there are more than one requests |
778 | 844 | $addRequests = explode('&',$mailtoArray[1]); |
779 | - foreach ($addRequests as $key => $reqval) { |
|
845 | + foreach ($addRequests as $key => $reqval) |
|
846 | + { |
|
780 | 847 | // the additional requests should have a =, to separate key from value. |
781 | 848 | $keyValuePair = explode('=',$reqval,2); |
782 | 849 | $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1]; |
@@ -785,16 +852,23 @@ discard block |
||
785 | 852 | $content['to']=$mailtoArray[0]; |
786 | 853 | $alreadyProcessed['to']='to'; |
787 | 854 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
788 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
855 | + foreach(array('cc','bcc','subject','body') as $name) |
|
856 | + { |
|
789 | 857 | $alreadyProcessed[$name]=$name; |
790 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
858 | + if ($_REQUEST[$name]) |
|
859 | + { |
|
860 | + $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
861 | + } |
|
791 | 862 | } |
792 | 863 | } |
793 | 864 | |
794 | - if ($_REQUEST['preset']['mailtocontactbyid']) { |
|
795 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
|
865 | + if ($_REQUEST['preset']['mailtocontactbyid']) |
|
866 | + { |
|
867 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook']) |
|
868 | + { |
|
796 | 869 | $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
797 | - if (method_exists($GLOBALS['egw']->contacts,'search')) { |
|
870 | + if (method_exists($GLOBALS['egw']->contacts,'search')) |
|
871 | + { |
|
798 | 872 | |
799 | 873 | $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
800 | 874 | foreach ((array)$addressArray as $id => $addressID) |
@@ -809,7 +883,10 @@ discard block |
||
809 | 883 | { |
810 | 884 | $_searchCond = array('contact_id'=>$addressArray); |
811 | 885 | //error_log(__METHOD__.__LINE__.$_searchString); |
812 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false; |
|
886 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
887 | + { |
|
888 | + $showAccounts=false; |
|
889 | + } |
|
813 | 890 | $filter = ($showAccounts?array():array('account_id' => null)); |
814 | 891 | $filter['cols_to_search']=array('n_fn','email','email_home'); |
815 | 892 | $contacts = $GLOBALS['egw']->contacts->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); |
@@ -832,21 +909,28 @@ discard block |
||
832 | 909 | unset($accounts); |
833 | 910 | } |
834 | 911 | } |
835 | - if(is_array($contacts)) { |
|
912 | + if(is_array($contacts)) |
|
913 | + { |
|
836 | 914 | $mailtoArray = array(); |
837 | 915 | $primary = $addressbookprefs['distributionListPreferredMail']; |
838 | - if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
|
916 | + if ($primary != 'email' && $primary != 'email_home') |
|
917 | + { |
|
918 | + $primary = 'email'; |
|
919 | + } |
|
839 | 920 | $secondary = ($primary == 'email'?'email_home':'email'); |
840 | 921 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
841 | - foreach($contacts as $contact) { |
|
922 | + foreach($contacts as $contact) |
|
923 | + { |
|
842 | 924 | $innerCounter=0; |
843 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
925 | + foreach(array($contact[$primary],$contact[$secondary]) as $email) |
|
926 | + { |
|
844 | 927 | // use pref distributionListPreferredMail for the primary address |
845 | 928 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
846 | 929 | $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
847 | 930 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
848 | 931 | $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
849 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
932 | + if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) |
|
933 | + { |
|
850 | 934 | $i++; |
851 | 935 | $innerCounter++; |
852 | 936 | $mailtoArray[$i] = $completeMailString; |
@@ -938,7 +1022,10 @@ discard block |
||
938 | 1022 | } |
939 | 1023 | } |
940 | 1024 | } |
941 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
1025 | + if(!empty($remember)) |
|
1026 | + { |
|
1027 | + $content = array_merge($content,$remember); |
|
1028 | + } |
|
942 | 1029 | } |
943 | 1030 | foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
944 | 1031 | { |
@@ -948,9 +1035,15 @@ discard block |
||
948 | 1035 | $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
949 | 1036 | } |
950 | 1037 | //skip if already processed by "preset Routines" |
951 | - if ($alreadyProcessed[$name]) continue; |
|
1038 | + if ($alreadyProcessed[$name]) |
|
1039 | + { |
|
1040 | + continue; |
|
1041 | + } |
|
952 | 1042 | //error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]); |
953 | - if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name]; |
|
1043 | + if ($_REQUEST['preset'][$name]) |
|
1044 | + { |
|
1045 | + $content[$name] = $_REQUEST['preset'][$name]; |
|
1046 | + } |
|
954 | 1047 | } |
955 | 1048 | } |
956 | 1049 | // is the to address set already? |
@@ -958,7 +1051,10 @@ discard block |
||
958 | 1051 | { |
959 | 1052 | $content['to'] = base64_decode($_REQUEST['send_to']); |
960 | 1053 | // first check if there is a questionmark or ampersand |
961 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
1054 | + if (strpos($content['to'],'?')!== false) |
|
1055 | + { |
|
1056 | + list($content['to'],$rest) = explode('?',$content['to'],2); |
|
1057 | + } |
|
962 | 1058 | $content['to'] = html_entity_decode($content['to']); |
963 | 1059 | if (($at_pos = strpos($content['to'],'@')) !== false) |
964 | 1060 | { |
@@ -971,9 +1067,15 @@ discard block |
||
971 | 1067 | $content['to'] = $email; |
972 | 1068 | } |
973 | 1069 | } |
974 | - if (strpos($content['to'],'%40')!== false) $content['to'] = html::purify(str_replace('%40','@',$content['to'])); |
|
1070 | + if (strpos($content['to'],'%40')!== false) |
|
1071 | + { |
|
1072 | + $content['to'] = html::purify(str_replace('%40','@',$content['to'])); |
|
1073 | + } |
|
975 | 1074 | $rarr = array(html::purify($rest)); |
976 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
1075 | + if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) |
|
1076 | + { |
|
1077 | + $rarr = explode('&',$rest); |
|
1078 | + } |
|
977 | 1079 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
978 | 1080 | $karr = array(); |
979 | 1081 | foreach ($rarr as &$rval) |
@@ -989,9 +1091,15 @@ discard block |
||
989 | 1091 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
990 | 1092 | foreach(array('cc','bcc','subject','body') as $name) |
991 | 1093 | { |
992 | - if ($karr[$name]) $content[$name] = $karr[$name]; |
|
1094 | + if ($karr[$name]) |
|
1095 | + { |
|
1096 | + $content[$name] = $karr[$name]; |
|
1097 | + } |
|
1098 | + } |
|
1099 | + if (!empty($_REQUEST['subject'])) |
|
1100 | + { |
|
1101 | + $content['subject'] = html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
993 | 1102 | } |
994 | - if (!empty($_REQUEST['subject'])) $content['subject'] = html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
995 | 1103 | } |
996 | 1104 | } |
997 | 1105 | //error_log(__METHOD__.__LINE__.array2string($content)); |
@@ -1009,7 +1117,10 @@ discard block |
||
1009 | 1117 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
1010 | 1118 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1011 | 1119 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1012 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1120 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
1121 | + { |
|
1122 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1123 | + } |
|
1013 | 1124 | } |
1014 | 1125 | } |
1015 | 1126 | else |
@@ -1029,7 +1140,10 @@ discard block |
||
1029 | 1140 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
1030 | 1141 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1031 | 1142 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1032 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1143 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
1144 | + { |
|
1145 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1146 | + } |
|
1033 | 1147 | } |
1034 | 1148 | } |
1035 | 1149 | } |
@@ -1067,24 +1181,33 @@ discard block |
||
1067 | 1181 | $disableRuler = true; |
1068 | 1182 | } |
1069 | 1183 | $font_span = $font_part = ''; |
1070 | - if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) { |
|
1184 | + if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) |
|
1185 | + { |
|
1071 | 1186 | // User preferences for style |
1072 | 1187 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
1073 | 1188 | $font_size = egw_ckeditor_config::font_size_from_prefs(); |
1074 | 1189 | $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
1075 | 1190 | $font_span = $font_part.'​</span>'; |
1076 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
1191 | + if (empty($font) && empty($font_size)) |
|
1192 | + { |
|
1193 | + $font_span = ''; |
|
1194 | + } |
|
1077 | 1195 | } |
1078 | 1196 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
1079 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
1197 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) |
|
1198 | + { |
|
1199 | + $font_span = ''; |
|
1200 | + } |
|
1080 | 1201 | //remove possible html header stuff |
1081 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
1202 | + if (stripos($content['body'],'<html><head></head><body>')!==false) |
|
1203 | + { |
|
1204 | + $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
1205 | + } |
|
1082 | 1206 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
1083 | 1207 | $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
1084 | 1208 | if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
1085 | 1209 | !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
1086 | - ) |
|
1087 | - { |
|
1210 | + ) { |
|
1088 | 1211 | // ON tOP OR BELOW? pREF CAN TELL |
1089 | 1212 | /* |
1090 | 1213 | Signature behavior preference changed. New default, if not set -> 0 |
@@ -1099,14 +1222,23 @@ discard block |
||
1099 | 1222 | $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
1100 | 1223 | foreach($blockElements as $e) |
1101 | 1224 | { |
1102 | - if ($sigTextStartsWithBlockElement) break; |
|
1103 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
1225 | + if ($sigTextStartsWithBlockElement) |
|
1226 | + { |
|
1227 | + break; |
|
1228 | + } |
|
1229 | + if (stripos(trim($sigText),'<'.$e)===0) |
|
1230 | + { |
|
1231 | + $sigTextStartsWithBlockElement = true; |
|
1232 | + } |
|
1104 | 1233 | } |
1105 | 1234 | } |
1106 | - if($content['mimeType'] == 'html') { |
|
1235 | + if($content['mimeType'] == 'html') |
|
1236 | + { |
|
1107 | 1237 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
1108 | 1238 | $inbetween = ''; |
1109 | - } else { |
|
1239 | + } |
|
1240 | + else |
|
1241 | + { |
|
1110 | 1242 | $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
1111 | 1243 | $inbetween = "\r\n"; |
1112 | 1244 | } |
@@ -1150,16 +1282,24 @@ discard block |
||
1150 | 1282 | //$content['bcc'] = array('[email protected]','[email protected]'); |
1151 | 1283 | // address stuff like from, to, cc, replyto |
1152 | 1284 | $destinationRows = 0; |
1153 | - foreach(self::$destinations as $destination) { |
|
1285 | + foreach(self::$destinations as $destination) |
|
1286 | + { |
|
1154 | 1287 | if (!is_array($content[$destination])) |
1155 | 1288 | { |
1156 | - if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
|
1289 | + if (!empty($content[$destination])) |
|
1290 | + { |
|
1291 | + $content[$destination] = (array)$content[$destination]; |
|
1292 | + } |
|
1157 | 1293 | } |
1158 | 1294 | $addr_content = $content[strtolower($destination)]; |
1159 | 1295 | // we clear the given address array and rebuild it |
1160 | 1296 | unset($content[strtolower($destination)]); |
1161 | - foreach((array)$addr_content as $key => $value) { |
|
1162 | - if ($value=="NIL@NIL") continue; |
|
1297 | + foreach((array)$addr_content as $key => $value) |
|
1298 | + { |
|
1299 | + if ($value=="NIL@NIL") |
|
1300 | + { |
|
1301 | + continue; |
|
1302 | + } |
|
1163 | 1303 | if ($destination=='replyto' && str_replace('"','',$value) == |
1164 | 1304 | str_replace('"','',$identities[$presetId ? $presetId : $this->mail_bo->getDefaultIdentity()])) |
1165 | 1305 | { |
@@ -1169,8 +1309,12 @@ discard block |
||
1169 | 1309 | } |
1170 | 1310 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
1171 | 1311 | $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
1172 | - foreach(emailadmin_imapbase::parseAddressList($value) as $addressObject) { |
|
1173 | - if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
|
1312 | + foreach(emailadmin_imapbase::parseAddressList($value) as $addressObject) |
|
1313 | + { |
|
1314 | + if ($addressObject->host == '.SYNTAX-ERROR.') |
|
1315 | + { |
|
1316 | + continue; |
|
1317 | + } |
|
1174 | 1318 | $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
1175 | 1319 | //$address = mail_bo::htmlentities($address, $this->displayCharset); |
1176 | 1320 | $content[strtolower($destination)][]=$address; |
@@ -1181,11 +1325,20 @@ discard block |
||
1181 | 1325 | if ($_content) |
1182 | 1326 | { |
1183 | 1327 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
1184 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
1328 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) |
|
1329 | + { |
|
1330 | + unset($_content['mailidentity']); |
|
1331 | + } |
|
1185 | 1332 | $content = array_merge($content,$_content); |
1186 | 1333 | |
1187 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
1188 | - if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
|
1334 | + if (!empty($content['folder'])) |
|
1335 | + { |
|
1336 | + $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
1337 | + } |
|
1338 | + if (empty($content['mailaccount'])) |
|
1339 | + { |
|
1340 | + $content['mailaccount'] = $this->mail_bo->profileID; |
|
1341 | + } |
|
1189 | 1342 | } |
1190 | 1343 | else |
1191 | 1344 | { |
@@ -1228,11 +1381,17 @@ discard block |
||
1228 | 1381 | //error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']); |
1229 | 1382 | $preserv['is_html'] = $content['is_html']; |
1230 | 1383 | $preserv['is_plain'] = $content['is_plain']; |
1231 | - if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType']; |
|
1384 | + if (isset($content['mimeType'])) |
|
1385 | + { |
|
1386 | + $preserv['mimeType'] = $content['mimeType']; |
|
1387 | + } |
|
1232 | 1388 | $sel_options['mimeType'] = self::$mimeTypes; |
1233 | 1389 | $sel_options['priority'] = self::$priorities; |
1234 | 1390 | $sel_options['filemode'] = egw_sharing::$modes; |
1235 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
1391 | + if (!isset($content['priority']) || empty($content['priority'])) |
|
1392 | + { |
|
1393 | + $content['priority']=3; |
|
1394 | + } |
|
1236 | 1395 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
1237 | 1396 | $etpl = new etemplate_new('mail.compose'); |
1238 | 1397 | |
@@ -1279,9 +1438,12 @@ discard block |
||
1279 | 1438 | $preserv['list-id'] = $content['list-id']; |
1280 | 1439 | $preserv['mode'] = $content['mode']; |
1281 | 1440 | // convert it back to checkbox expectations |
1282 | - if($content['mimeType'] == 'html') { |
|
1441 | + if($content['mimeType'] == 'html') |
|
1442 | + { |
|
1283 | 1443 | $content['mimeType']=1; |
1284 | - } else { |
|
1444 | + } |
|
1445 | + else |
|
1446 | + { |
|
1285 | 1447 | $content['mimeType']=0; |
1286 | 1448 | } |
1287 | 1449 | // set the current selected mailaccount as param for folderselection |
@@ -1292,7 +1454,10 @@ discard block |
||
1292 | 1454 | // Resolve distribution list before send content to client |
1293 | 1455 | foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
1294 | 1456 | { |
1295 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
1457 | + if (is_array($content[$f])) |
|
1458 | + { |
|
1459 | + $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
1460 | + } |
|
1296 | 1461 | } |
1297 | 1462 | |
1298 | 1463 | $content['to'] = self::resolveEmailAddressList($content['to']); |
@@ -1340,7 +1505,10 @@ discard block |
||
1340 | 1505 | case 'composefromdraft': |
1341 | 1506 | case 'composeasnew': |
1342 | 1507 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
1343 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
1508 | + if ($from =='composefromdraft') |
|
1509 | + { |
|
1510 | + $content['mode'] = 'composefromdraft'; |
|
1511 | + } |
|
1344 | 1512 | $content['processedmail_id'] = $mail_id; |
1345 | 1513 | |
1346 | 1514 | $_focusElement = 'body'; |
@@ -1388,7 +1556,10 @@ discard block |
||
1388 | 1556 | $document_merge = new $merge_class(); |
1389 | 1557 | $this->mail_bo->openConnection(); |
1390 | 1558 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
1391 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
1559 | + if (!is_array($merge_ids)) |
|
1560 | + { |
|
1561 | + $merge_ids = explode(',',$merge_ids); |
|
1562 | + } |
|
1392 | 1563 | try |
1393 | 1564 | { |
1394 | 1565 | $merged_mail_id = ''; |
@@ -1419,7 +1590,10 @@ discard block |
||
1419 | 1590 | { |
1420 | 1591 | $success = implode(', ',$results['success']); |
1421 | 1592 | $fail = implode(', ', $results['failed']); |
1422 | - if($success) egw_framework::message($success, 'success'); |
|
1593 | + if($success) |
|
1594 | + { |
|
1595 | + egw_framework::message($success, 'success'); |
|
1596 | + } |
|
1423 | 1597 | egw_framework::window_close($fail); |
1424 | 1598 | } |
1425 | 1599 | } |
@@ -1451,17 +1625,25 @@ discard block |
||
1451 | 1625 | { |
1452 | 1626 | $stripalltags = true; |
1453 | 1627 | // third param is stripalltags, we may not need that, if the source is already in ascii |
1454 | - if (!$sourceishtml) $stripalltags=false; |
|
1628 | + if (!$sourceishtml) |
|
1629 | + { |
|
1630 | + $stripalltags=false; |
|
1631 | + } |
|
1455 | 1632 | return translation::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags); |
1456 | 1633 | } |
1457 | 1634 | |
1458 | 1635 | function generateRFC822Address($_addressObject) |
1459 | 1636 | { |
1460 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
1637 | + if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) |
|
1638 | + { |
|
1461 | 1639 | return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
1462 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
1640 | + } |
|
1641 | + elseif($_addressObject->mailbox && $_addressObject->host) |
|
1642 | + { |
|
1463 | 1643 | return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
1464 | - } else { |
|
1644 | + } |
|
1645 | + else |
|
1646 | + { |
|
1465 | 1647 | return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
1466 | 1648 | } |
1467 | 1649 | } |
@@ -1495,16 +1677,28 @@ discard block |
||
1495 | 1677 | //if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC']; |
1496 | 1678 | |
1497 | 1679 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
1498 | - if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
|
1499 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
1680 | + if (!empty($addHeadInfo['X-MAILFOLDER'])) |
|
1681 | + { |
|
1682 | + foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) |
|
1683 | + { |
|
1500 | 1684 | $fval=$val; |
1501 | 1685 | $icServerID = $mail_bo->icServer->ImapServerId; |
1502 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
1503 | - if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
|
1504 | - if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
|
1686 | + if (stripos($val,'::')!==false) |
|
1687 | + { |
|
1688 | + list($icServerID,$fval) = explode('::',$val,2); |
|
1689 | + } |
|
1690 | + if ($icServerID != $mail_bo->icServer->ImapServerId) |
|
1691 | + { |
|
1692 | + continue; |
|
1693 | + } |
|
1694 | + if ($mail_bo->folderExists($fval)) |
|
1695 | + { |
|
1696 | + $this->sessionData['folder'][] = $val; |
|
1697 | + } |
|
1505 | 1698 | } |
1506 | 1699 | } |
1507 | - if (!empty($addHeadInfo['X-MAILIDENTITY'])) { |
|
1700 | + if (!empty($addHeadInfo['X-MAILIDENTITY'])) |
|
1701 | + { |
|
1508 | 1702 | // with the new system it would be the identity |
1509 | 1703 | try |
1510 | 1704 | { |
@@ -1520,7 +1714,8 @@ discard block |
||
1520 | 1714 | $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; |
1521 | 1715 | } |
1522 | 1716 | */ |
1523 | - if (!empty($addHeadInfo['X-MAILACCOUNT'])) { |
|
1717 | + if (!empty($addHeadInfo['X-MAILACCOUNT'])) |
|
1718 | + { |
|
1524 | 1719 | // with the new system it would the identity is the account id |
1525 | 1720 | try |
1526 | 1721 | { |
@@ -1534,27 +1729,38 @@ discard block |
||
1534 | 1729 | } |
1535 | 1730 | } |
1536 | 1731 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
1537 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
1732 | + if ($mail_bo->isDraftFolder($_folder)) |
|
1733 | + { |
|
1734 | + $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); |
|
1735 | + } |
|
1736 | + //array('uid'=>$_uid,'folder'=>$_folder); |
|
1538 | 1737 | $this->sessionData['uid'] = $_uid; |
1539 | 1738 | $this->sessionData['messageFolder'] = $_folder; |
1540 | 1739 | $this->sessionData['isDraft'] = true; |
1541 | 1740 | $foundAddresses = array(); |
1542 | - foreach((array)$headers['CC'] as $val) { |
|
1741 | + foreach((array)$headers['CC'] as $val) |
|
1742 | + { |
|
1543 | 1743 | $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
1544 | 1744 | $_rfcAddr = $rfcAddr[0]; |
1545 | - if (!$_rfcAddr->valid) continue; |
|
1546 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1745 | + if (!$_rfcAddr->valid) |
|
1746 | + { |
|
1747 | + continue; |
|
1748 | + } |
|
1749 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
1750 | + { |
|
1547 | 1751 | continue; |
1548 | 1752 | } |
1549 | 1753 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1550 | - if(!$foundAddresses[$keyemail]) { |
|
1754 | + if(!$foundAddresses[$keyemail]) |
|
1755 | + { |
|
1551 | 1756 | $address = $this->mail_bo->decode_header($val,true); |
1552 | 1757 | $this->sessionData['cc'][] = $val; |
1553 | 1758 | $foundAddresses[$keyemail] = true; |
1554 | 1759 | } |
1555 | 1760 | } |
1556 | 1761 | |
1557 | - foreach((array)$headers['TO'] as $val) { |
|
1762 | + foreach((array)$headers['TO'] as $val) |
|
1763 | + { |
|
1558 | 1764 | if(!is_array($val)) |
1559 | 1765 | { |
1560 | 1766 | $this->sessionData['to'][] = $val; |
@@ -1562,42 +1768,59 @@ discard block |
||
1562 | 1768 | } |
1563 | 1769 | $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
1564 | 1770 | $_rfcAddr = $rfcAddr[0]; |
1565 | - if (!$_rfcAddr->valid) continue; |
|
1566 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1771 | + if (!$_rfcAddr->valid) |
|
1772 | + { |
|
1773 | + continue; |
|
1774 | + } |
|
1775 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
1776 | + { |
|
1567 | 1777 | continue; |
1568 | 1778 | } |
1569 | 1779 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1570 | - if(!$foundAddresses[$keyemail]) { |
|
1780 | + if(!$foundAddresses[$keyemail]) |
|
1781 | + { |
|
1571 | 1782 | $address = $this->mail_bo->decode_header($val,true); |
1572 | 1783 | $this->sessionData['to'][] = $val; |
1573 | 1784 | $foundAddresses[$keyemail] = true; |
1574 | 1785 | } |
1575 | 1786 | } |
1576 | 1787 | |
1577 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
1788 | + foreach((array)$headers['REPLY-TO'] as $val) |
|
1789 | + { |
|
1578 | 1790 | $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
1579 | 1791 | $_rfcAddr = $rfcAddr[0]; |
1580 | - if (!$_rfcAddr->valid) continue; |
|
1581 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1792 | + if (!$_rfcAddr->valid) |
|
1793 | + { |
|
1794 | + continue; |
|
1795 | + } |
|
1796 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
1797 | + { |
|
1582 | 1798 | continue; |
1583 | 1799 | } |
1584 | 1800 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1585 | - if(!$foundAddresses[$keyemail]) { |
|
1801 | + if(!$foundAddresses[$keyemail]) |
|
1802 | + { |
|
1586 | 1803 | $address = $this->mail_bo->decode_header($val,true); |
1587 | 1804 | $this->sessionData['replyto'][] = $val; |
1588 | 1805 | $foundAddresses[$keyemail] = true; |
1589 | 1806 | } |
1590 | 1807 | } |
1591 | 1808 | |
1592 | - foreach((array)$headers['BCC'] as $val) { |
|
1809 | + foreach((array)$headers['BCC'] as $val) |
|
1810 | + { |
|
1593 | 1811 | $rfcAddr=emailadmin_imapbase::parseAddressList($val); |
1594 | 1812 | $_rfcAddr = $rfcAddr[0]; |
1595 | - if (!$_rfcAddr->valid) continue; |
|
1596 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1813 | + if (!$_rfcAddr->valid) |
|
1814 | + { |
|
1815 | + continue; |
|
1816 | + } |
|
1817 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
1818 | + { |
|
1597 | 1819 | continue; |
1598 | 1820 | } |
1599 | 1821 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1600 | - if(!$foundAddresses[$keyemail]) { |
|
1822 | + if(!$foundAddresses[$keyemail]) |
|
1823 | + { |
|
1601 | 1824 | $address = $this->mail_bo->decode_header($val,true); |
1602 | 1825 | $this->sessionData['bcc'][] = $val; |
1603 | 1826 | $foundAddresses[$keyemail] = true; |
@@ -1611,32 +1834,46 @@ discard block |
||
1611 | 1834 | $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
1612 | 1835 | //_debug_array($bodyParts); |
1613 | 1836 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
1614 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
1837 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
1838 | + { |
|
1615 | 1839 | $this->sessionData['mimeType'] = 'html'; |
1616 | 1840 | |
1617 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1618 | - if($i>0) { |
|
1841 | + for($i=0; $i<count($bodyParts); $i++) |
|
1842 | + { |
|
1843 | + if($i>0) |
|
1844 | + { |
|
1619 | 1845 | $this->sessionData['body'] .= '<hr>'; |
1620 | 1846 | } |
1621 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
1847 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
1848 | + { |
|
1622 | 1849 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
1623 | 1850 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
1624 | 1851 | } |
1625 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1852 | + if ($bodyParts[$i]['charSet']===false) |
|
1853 | + { |
|
1854 | + $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1855 | + } |
|
1626 | 1856 | $bodyParts[$i]['body'] = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1627 | 1857 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1628 | 1858 | $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
1629 | 1859 | } |
1630 | 1860 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
1631 | 1861 | |
1632 | - } else { |
|
1862 | + } |
|
1863 | + else |
|
1864 | + { |
|
1633 | 1865 | $this->sessionData['mimeType'] = 'plain'; |
1634 | 1866 | |
1635 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1636 | - if($i>0) { |
|
1867 | + for($i=0; $i<count($bodyParts); $i++) |
|
1868 | + { |
|
1869 | + if($i>0) |
|
1870 | + { |
|
1637 | 1871 | $this->sessionData['body'] .= "<hr>"; |
1638 | 1872 | } |
1639 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1873 | + if ($bodyParts[$i]['charSet']===false) |
|
1874 | + { |
|
1875 | + $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
1876 | + } |
|
1640 | 1877 | $bodyParts[$i]['body'] = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1641 | 1878 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1642 | 1879 | $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
@@ -1644,8 +1881,10 @@ discard block |
||
1644 | 1881 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
1645 | 1882 | } |
1646 | 1883 | |
1647 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
1648 | - foreach($attachments as $attachment) { |
|
1884 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) |
|
1885 | + { |
|
1886 | + foreach($attachments as $attachment) |
|
1887 | + { |
|
1649 | 1888 | $cid = $attachment['cid']; |
1650 | 1889 | $match=null; |
1651 | 1890 | preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match); |
@@ -1665,7 +1904,8 @@ discard block |
||
1665 | 1904 | |
1666 | 1905 | function getErrorInfo() |
1667 | 1906 | { |
1668 | - if(isset($this->errorInfo)) { |
|
1907 | + if(isset($this->errorInfo)) |
|
1908 | + { |
|
1669 | 1909 | $errorInfo = $this->errorInfo; |
1670 | 1910 | unset($this->errorInfo); |
1671 | 1911 | return $errorInfo; |
@@ -1680,7 +1920,8 @@ discard block |
||
1680 | 1920 | $modebuff = $this->mailPreferences['message_forwarding']; |
1681 | 1921 | $this->mailPreferences['message_forwarding'] = $_mode; |
1682 | 1922 | } |
1683 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
1923 | + if ($this->mailPreferences['message_forwarding'] == 'inline') |
|
1924 | + { |
|
1684 | 1925 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
1685 | 1926 | } |
1686 | 1927 | $mail_bo = $this->mail_bo; |
@@ -1697,12 +1938,16 @@ discard block |
||
1697 | 1938 | //$this->sessionData['sourceFolder']=$_folder; |
1698 | 1939 | //$this->sessionData['forwardFlag']='forwarded'; |
1699 | 1940 | //$this->sessionData['forwardedUID']=$_uid; |
1700 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
1941 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') |
|
1942 | + { |
|
1701 | 1943 | $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
1702 | 1944 | if($headers['SIZE']) |
1703 | - $size = $headers['SIZE']; |
|
1704 | - else |
|
1705 | - $size = lang('unknown'); |
|
1945 | + { |
|
1946 | + $size = $headers['SIZE']; |
|
1947 | + } |
|
1948 | + else { |
|
1949 | + $size = lang('unknown'); |
|
1950 | + } |
|
1706 | 1951 | |
1707 | 1952 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
1708 | 1953 | $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
@@ -1713,9 +1958,11 @@ discard block |
||
1713 | 1958 | unset($this->sessionData['in-reply-to']); |
1714 | 1959 | unset($this->sessionData['to']); |
1715 | 1960 | unset($this->sessionData['cc']); |
1716 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
1961 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) |
|
1962 | + { |
|
1717 | 1963 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
1718 | - foreach($attachments as $attachment) { |
|
1964 | + foreach($attachments as $attachment) |
|
1965 | + { |
|
1719 | 1966 | if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType']))) |
1720 | 1967 | { |
1721 | 1968 | $this->addMessageAttachment($_uid, $attachment['partID'], |
@@ -1771,7 +2018,10 @@ discard block |
||
1771 | 2018 | { |
1772 | 2019 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
1773 | 2020 | strtolower($_formData['type'])== strtolower($attach['type']) && |
1774 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
2021 | + stripos($_formData['file'],'vfs://') !== false) |
|
2022 | + { |
|
2023 | + return; |
|
2024 | + } |
|
1775 | 2025 | } |
1776 | 2026 | } |
1777 | 2027 | if ($attachfailed === false) |
@@ -1783,7 +2033,10 @@ discard block |
||
1783 | 2033 | 'tmp_name' => $tmpFileName, |
1784 | 2034 | 'size' => $_formData['size'] |
1785 | 2035 | ); |
1786 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
2036 | + if (!is_array($_content['attachments'])) |
|
2037 | + { |
|
2038 | + $_content['attachments']=array(); |
|
2039 | + } |
|
1787 | 2040 | $_content['attachments'][] = $buffer; |
1788 | 2041 | unset($buffer); |
1789 | 2042 | } |
@@ -1813,7 +2066,10 @@ discard block |
||
1813 | 2066 | { |
1814 | 2067 | foreach($request->preserv['attachments'] as $attachment) |
1815 | 2068 | { |
1816 | - if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
|
2069 | + if ($_GET['tmpname'] === $attachment['tmp_name']) |
|
2070 | + { |
|
2071 | + break; |
|
2072 | + } |
|
1817 | 2073 | } |
1818 | 2074 | } |
1819 | 2075 | if (!$request || $_GET['tmpname'] !== $attachment['tmp_name']) |
@@ -1847,10 +2103,20 @@ discard block |
||
1847 | 2103 | $sfxMimeType = $attachment['type']; |
1848 | 2104 | $buff = explode('.',$attachment['tmp_name']); |
1849 | 2105 | $suffix = ''; |
1850 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
1851 | - if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix); |
|
2106 | + if (is_array($buff)) |
|
2107 | + { |
|
2108 | + $suffix = array_pop($buff); |
|
2109 | + } |
|
2110 | + // take the last extension to check with ext2mime |
|
2111 | + if (!empty($suffix)) |
|
2112 | + { |
|
2113 | + $sfxMimeType = mime_magic::ext2mime($suffix); |
|
2114 | + } |
|
1852 | 2115 | $attachment['type'] = $sfxMimeType; |
1853 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
2116 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
2117 | + { |
|
2118 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
2119 | + } |
|
1854 | 2120 | } |
1855 | 2121 | //error_log(__METHOD__.print_r($attachment,true)); |
1856 | 2122 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -1859,7 +2125,10 @@ discard block |
||
1859 | 2125 | $calendar_ical = new calendar_ical(); |
1860 | 2126 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
1861 | 2127 | //error_log(__METHOD__.array2string($eventid)); |
1862 | - if (!$eventid) $eventid = -1; |
|
2128 | + if (!$eventid) |
|
2129 | + { |
|
2130 | + $eventid = -1; |
|
2131 | + } |
|
1863 | 2132 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
1864 | 2133 | //error_log(__METHOD__.$event); |
1865 | 2134 | if ((int)$event > 0) |
@@ -1885,7 +2154,10 @@ discard block |
||
1885 | 2154 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
1886 | 2155 | $contact = $addressbook_vcal->find_contact($vcard,false); |
1887 | 2156 | } |
1888 | - if (!$contact) $contact = null; |
|
2157 | + if (!$contact) |
|
2158 | + { |
|
2159 | + $contact = null; |
|
2160 | + } |
|
1889 | 2161 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
1890 | 2162 | if ($contact || count($vcard)>2) |
1891 | 2163 | { |
@@ -1916,7 +2188,8 @@ discard block |
||
1916 | 2188 | * @param string haystack |
1917 | 2189 | * @return boolean |
1918 | 2190 | */ |
1919 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
2191 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) |
|
2192 | + { |
|
1920 | 2193 | foreach (array_keys($arrayToTestAgainst) as $k) |
1921 | 2194 | { |
1922 | 2195 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
@@ -1963,21 +2236,34 @@ discard block |
||
1963 | 2236 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
1964 | 2237 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
1965 | 2238 | //if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC']; |
1966 | - if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
1967 | - if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
2239 | + if ($headers['THREAD-INDEX']) |
|
2240 | + { |
|
2241 | + $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
2242 | + } |
|
2243 | + if ($headers['LIST-ID']) |
|
2244 | + { |
|
2245 | + $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
2246 | + } |
|
1968 | 2247 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
1969 | 2248 | // check for Reply-To: header and use if available |
1970 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
1971 | - foreach($headers['REPLY-TO'] as $val) { |
|
1972 | - if(!$foundAddresses[$val]) { |
|
2249 | + if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) |
|
2250 | + { |
|
2251 | + foreach($headers['REPLY-TO'] as $val) |
|
2252 | + { |
|
2253 | + if(!$foundAddresses[$val]) |
|
2254 | + { |
|
1973 | 2255 | $oldTo[] = $val; |
1974 | 2256 | $foundAddresses[$val] = true; |
1975 | 2257 | } |
1976 | 2258 | } |
1977 | 2259 | $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
1978 | - } else { |
|
1979 | - foreach($headers['FROM'] as $val) { |
|
1980 | - if(!$foundAddresses[$val]) { |
|
2260 | + } |
|
2261 | + else |
|
2262 | + { |
|
2263 | + foreach($headers['FROM'] as $val) |
|
2264 | + { |
|
2265 | + if(!$foundAddresses[$val]) |
|
2266 | + { |
|
1981 | 2267 | $oldTo[] = $val; |
1982 | 2268 | $foundAddresses[$val] = true; |
1983 | 2269 | } |
@@ -1985,18 +2271,23 @@ discard block |
||
1985 | 2271 | $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
1986 | 2272 | } |
1987 | 2273 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
1988 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
2274 | + if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) |
|
2275 | + { |
|
1989 | 2276 | $this->sessionData['to'] = $oldTo; |
1990 | 2277 | } |
1991 | 2278 | |
1992 | - if($_mode == 'all') { |
|
2279 | + if($_mode == 'all') |
|
2280 | + { |
|
1993 | 2281 | // reply to any address which is cc, but not to my self |
1994 | 2282 | #if($headers->cc) { |
1995 | - foreach($headers['CC'] as $val) { |
|
1996 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2283 | + foreach($headers['CC'] as $val) |
|
2284 | + { |
|
2285 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
2286 | + { |
|
1997 | 2287 | continue; |
1998 | 2288 | } |
1999 | - if(!$foundAddresses[$val]) { |
|
2289 | + if(!$foundAddresses[$val]) |
|
2290 | + { |
|
2000 | 2291 | $this->sessionData['cc'][] = $val; |
2001 | 2292 | $foundAddresses[$val] = true; |
2002 | 2293 | } |
@@ -2005,11 +2296,14 @@ discard block |
||
2005 | 2296 | |
2006 | 2297 | // reply to any address which is to, but not to my self |
2007 | 2298 | #if($headers->to) { |
2008 | - foreach($headers['TO'] as $val) { |
|
2009 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2299 | + foreach($headers['TO'] as $val) |
|
2300 | + { |
|
2301 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
2302 | + { |
|
2010 | 2303 | continue; |
2011 | 2304 | } |
2012 | - if(!$foundAddresses[$val]) { |
|
2305 | + if(!$foundAddresses[$val]) |
|
2306 | + { |
|
2013 | 2307 | $this->sessionData['to'][] = $val; |
2014 | 2308 | $foundAddresses[$val] = true; |
2015 | 2309 | } |
@@ -2017,12 +2311,15 @@ discard block |
||
2017 | 2311 | #} |
2018 | 2312 | |
2019 | 2313 | #if($headers->from) { |
2020 | - foreach($headers['FROM'] as $val) { |
|
2021 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2314 | + foreach($headers['FROM'] as $val) |
|
2315 | + { |
|
2316 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
2317 | + { |
|
2022 | 2318 | continue; |
2023 | 2319 | } |
2024 | 2320 | //error_log(__METHOD__.__LINE__.' '.$val); |
2025 | - if(!$foundAddresses[$val]) { |
|
2321 | + if(!$foundAddresses[$val]) |
|
2322 | + { |
|
2026 | 2323 | $this->sessionData['to'][] = $val; |
2027 | 2324 | $foundAddresses[$val] = true; |
2028 | 2325 | } |
@@ -2031,9 +2328,12 @@ discard block |
||
2031 | 2328 | } |
2032 | 2329 | |
2033 | 2330 | // check for Re: in subject header |
2034 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
2331 | + if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") |
|
2332 | + { |
|
2035 | 2333 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
2036 | - } else { |
|
2334 | + } |
|
2335 | + else |
|
2336 | + { |
|
2037 | 2337 | $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
2038 | 2338 | } |
2039 | 2339 | |
@@ -2047,7 +2347,8 @@ discard block |
||
2047 | 2347 | |
2048 | 2348 | $toAddressA = array(); |
2049 | 2349 | $toAddress = ''; |
2050 | - foreach ($headers['TO'] as $mailheader) { |
|
2350 | + foreach ($headers['TO'] as $mailheader) |
|
2351 | + { |
|
2051 | 2352 | $toAddressA[] = $mailheader; |
2052 | 2353 | } |
2053 | 2354 | if (count($toAddressA)>0) |
@@ -2057,7 +2358,8 @@ discard block |
||
2057 | 2358 | } |
2058 | 2359 | $ccAddressA = array(); |
2059 | 2360 | $ccAddress = ''; |
2060 | - foreach ($headers['CC'] as $mailheader) { |
|
2361 | + foreach ($headers['CC'] as $mailheader) |
|
2362 | + { |
|
2061 | 2363 | $ccAddressA[] = $mailheader; |
2062 | 2364 | } |
2063 | 2365 | if (count($ccAddressA)>0) |
@@ -2065,25 +2367,35 @@ discard block |
||
2065 | 2367 | $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
2066 | 2368 | $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
2067 | 2369 | } |
2068 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
2370 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
2371 | + { |
|
2069 | 2372 | $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
2070 | 2373 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
2071 | 2374 | $toAddress.$ccAddress. |
2072 | 2375 | @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,mail_bo::$displayCharset, false)."<br>". |
2073 | 2376 | '----------------------------------------------------------'."</div>"; |
2074 | 2377 | $this->sessionData['mimeType'] = 'html'; |
2075 | - if (!empty($styles)) $this->sessionData['body'] .= $styles; |
|
2378 | + if (!empty($styles)) |
|
2379 | + { |
|
2380 | + $this->sessionData['body'] .= $styles; |
|
2381 | + } |
|
2076 | 2382 | $this->sessionData['body'] .= '<blockquote type="cite">'; |
2077 | 2383 | |
2078 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2079 | - if($i>0) { |
|
2384 | + for($i=0; $i<count($bodyParts); $i++) |
|
2385 | + { |
|
2386 | + if($i>0) |
|
2387 | + { |
|
2080 | 2388 | $this->sessionData['body'] .= '<hr>'; |
2081 | 2389 | } |
2082 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2390 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
2391 | + { |
|
2083 | 2392 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
2084 | 2393 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
2085 | 2394 | } |
2086 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
2395 | + if ($bodyParts[$i]['charSet']===false) |
|
2396 | + { |
|
2397 | + $bodyParts[$i]['charSet'] = mail_bo::detect_encoding($bodyParts[$i]['body']); |
|
2398 | + } |
|
2087 | 2399 | |
2088 | 2400 | $_htmlConfig = mail_bo::$htmLawed_config; |
2089 | 2401 | mail_bo::$htmLawed_config['comment'] = 2; |
@@ -2095,7 +2407,9 @@ discard block |
||
2095 | 2407 | |
2096 | 2408 | $this->sessionData['body'] .= '</blockquote><br>'; |
2097 | 2409 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
2098 | - } else { |
|
2410 | + } |
|
2411 | + else |
|
2412 | + { |
|
2099 | 2413 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
2100 | 2414 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
2101 | 2415 | $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
@@ -2105,8 +2419,10 @@ discard block |
||
2105 | 2419 | '-------------------------------------------------'."\r\n \r\n "; |
2106 | 2420 | $this->sessionData['mimeType'] = 'plain'; |
2107 | 2421 | |
2108 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2109 | - if($i>0) { |
|
2422 | + for($i=0; $i<count($bodyParts); $i++) |
|
2423 | + { |
|
2424 | + if($i>0) |
|
2425 | + { |
|
2110 | 2426 | $this->sessionData['body'] .= "<hr>"; |
2111 | 2427 | } |
2112 | 2428 | |
@@ -2116,9 +2432,11 @@ discard block |
||
2116 | 2432 | $newBody = mail_ui::resolve_inline_images($newBody, $_folder, $_uid, $_partID, 'plain'); |
2117 | 2433 | $this->sessionData['body'] .= "\r\n"; |
2118 | 2434 | // create body new, with good line breaks and indention |
2119 | - foreach(explode("\n",$newBody) as $value) { |
|
2435 | + foreach(explode("\n",$newBody) as $value) |
|
2436 | + { |
|
2120 | 2437 | // the explode is removing the character |
2121 | - if (trim($value) != '') { |
|
2438 | + if (trim($value) != '') |
|
2439 | + { |
|
2122 | 2440 | #if ($value != "\r") $value .= "\n"; |
2123 | 2441 | } |
2124 | 2442 | $numberOfChars = strspn(trim($value), ">"); |
@@ -2126,9 +2444,12 @@ discard block |
||
2126 | 2444 | |
2127 | 2445 | $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
2128 | 2446 | |
2129 | - if($bodyAppend[0] == '>') { |
|
2447 | + if($bodyAppend[0] == '>') |
|
2448 | + { |
|
2130 | 2449 | $bodyAppend = '>'. $bodyAppend; |
2131 | - } else { |
|
2450 | + } |
|
2451 | + else |
|
2452 | + { |
|
2132 | 2453 | $bodyAppend = '> '. $bodyAppend; |
2133 | 2454 | } |
2134 | 2455 | |
@@ -2177,9 +2498,12 @@ discard block |
||
2177 | 2498 | |
2178 | 2499 | static function _getHostName() |
2179 | 2500 | { |
2180 | - if (isset($_SERVER['SERVER_NAME'])) { |
|
2501 | + if (isset($_SERVER['SERVER_NAME'])) |
|
2502 | + { |
|
2181 | 2503 | $result = $_SERVER['SERVER_NAME']; |
2182 | - } else { |
|
2504 | + } |
|
2505 | + else |
|
2506 | + { |
|
2183 | 2507 | $result = 'localhost.localdomain'; |
2184 | 2508 | } |
2185 | 2509 | return $result; |
@@ -2210,13 +2534,21 @@ discard block |
||
2210 | 2534 | |
2211 | 2535 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
2212 | 2536 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
2213 | - if(!empty($_formData['in-reply-to'])) { |
|
2214 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
2537 | + if(!empty($_formData['in-reply-to'])) |
|
2538 | + { |
|
2539 | + if (stripos($_formData['in-reply-to'],'<')===false) |
|
2540 | + { |
|
2541 | + $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
2542 | + } |
|
2215 | 2543 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(In-Reply-To', $_formData['in-reply-to'].")"); |
2216 | 2544 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
2217 | 2545 | } |
2218 | - if(!empty($_formData['references'])) { |
|
2219 | - if (stripos($_formData['references'],'<')===false) $_formData['references']='<'.trim($_formData['references']).'>'; |
|
2546 | + if(!empty($_formData['references'])) |
|
2547 | + { |
|
2548 | + if (stripos($_formData['references'],'<')===false) |
|
2549 | + { |
|
2550 | + $_formData['references']='<'.trim($_formData['references']).'>'; |
|
2551 | + } |
|
2220 | 2552 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(References', $_formData['references'].")"); |
2221 | 2553 | $_mailObject->addHeader('References', $_formData['references']); |
2222 | 2554 | } |
@@ -2227,16 +2559,19 @@ discard block |
||
2227 | 2559 | // $_mailObject->addHeader('Thread-Topic', $_formData['thread-topic']); |
2228 | 2560 | //} |
2229 | 2561 | |
2230 | - if(!empty($_formData['thread-index'])) { |
|
2562 | + if(!empty($_formData['thread-index'])) |
|
2563 | + { |
|
2231 | 2564 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(Tread-Index', $_formData['thread-index'].")"); |
2232 | 2565 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
2233 | 2566 | } |
2234 | - if(!empty($_formData['list-id'])) { |
|
2567 | + if(!empty($_formData['list-id'])) |
|
2568 | + { |
|
2235 | 2569 | //error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(List-Id', $_formData['list-id'].")"); |
2236 | 2570 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
2237 | 2571 | } |
2238 | 2572 | //error_log(__METHOD__.__LINE__.' notify to:'.$_identity['ident_email'].'->'.array2string($_formData)); |
2239 | - if($_formData['disposition']=='on') { |
|
2573 | + if($_formData['disposition']=='on') |
|
2574 | + { |
|
2240 | 2575 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
2241 | 2576 | } |
2242 | 2577 | //error_log(__METHOD__.__LINE__.' Organization:'.array2string($_identity)); |
@@ -2247,15 +2582,22 @@ discard block |
||
2247 | 2582 | // Expand any mailing lists |
2248 | 2583 | foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
2249 | 2584 | { |
2250 | - if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
2585 | + if ($field != 'replyto') |
|
2586 | + { |
|
2587 | + $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
2588 | + } |
|
2251 | 2589 | |
2252 | - if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field); |
|
2590 | + if ($_formData[$field]) |
|
2591 | + { |
|
2592 | + $_mailObject->addAddress($_formData[$field], '', $field); |
|
2593 | + } |
|
2253 | 2594 | } |
2254 | 2595 | |
2255 | 2596 | $_mailObject->addHeader('Subject', $_formData['subject']); |
2256 | 2597 | |
2257 | 2598 | // this should never happen since we come from the edit dialog |
2258 | - if (mail_bo::detect_qp($_formData['body'])) { |
|
2599 | + if (mail_bo::detect_qp($_formData['body'])) |
|
2600 | + { |
|
2259 | 2601 | //error_log("Error: bocompose::createMessage found QUOTED-PRINTABLE while Composing Message. Charset:$realCharset Message:".print_r($_formData['body'],true)); |
2260 | 2602 | $_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']); |
2261 | 2603 | $_formData['body'] = quoted_printable_decode($_formData['body']); |
@@ -2321,7 +2663,10 @@ discard block |
||
2321 | 2663 | $_mailObject->setBody($this->convertHTMLToText($body, true, true)); |
2322 | 2664 | } |
2323 | 2665 | // convert URL Images to inline images - if possible |
2324 | - if (!$_autosaving) mail_bo::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
2666 | + if (!$_autosaving) |
|
2667 | + { |
|
2668 | + mail_bo::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
2669 | + } |
|
2325 | 2670 | if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
2326 | 2671 | { |
2327 | 2672 | $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
@@ -2332,10 +2677,14 @@ discard block |
||
2332 | 2677 | { |
2333 | 2678 | $body = $this->convertHTMLToText($_formData['body'],false); |
2334 | 2679 | |
2335 | - if ($attachment_links) $body .= $attachment_links; |
|
2680 | + if ($attachment_links) |
|
2681 | + { |
|
2682 | + $body .= $attachment_links; |
|
2683 | + } |
|
2336 | 2684 | |
2337 | 2685 | #$_mailObject->Body = $_formData['body']; |
2338 | - if(!empty($signature)) { |
|
2686 | + if(!empty($signature)) |
|
2687 | + { |
|
2339 | 2688 | $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
2340 | 2689 | $this->convertHTMLToText($signature,true,true); |
2341 | 2690 | } |
@@ -2348,11 +2697,13 @@ discard block |
||
2348 | 2697 | $connection_opened = false; |
2349 | 2698 | //error_log(__METHOD__.__LINE__.array2string($_formData['attachments'])); |
2350 | 2699 | $tnfattachments = null; |
2351 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
2700 | + foreach((array)$_formData['attachments'] as $attachment) |
|
2701 | + { |
|
2352 | 2702 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
2353 | 2703 | if(is_array($attachment)) |
2354 | 2704 | { |
2355 | - if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
|
2705 | + if (!empty($attachment['uid']) && !empty($attachment['folder'])) |
|
2706 | + { |
|
2356 | 2707 | /* Example: |
2357 | 2708 | Array([0] => Array( |
2358 | 2709 | [uid] => 21178 |
@@ -2368,14 +2719,18 @@ discard block |
||
2368 | 2719 | $connection_opened = true; |
2369 | 2720 | } |
2370 | 2721 | $mail_bo->reopen($attachment['folder']); |
2371 | - switch(strtoupper($attachment['type'])) { |
|
2722 | + switch(strtoupper($attachment['type'])) |
|
2723 | + { |
|
2372 | 2724 | case 'MESSAGE/RFC': |
2373 | 2725 | case 'MESSAGE/RFC822': |
2374 | 2726 | $rawBody=''; |
2375 | - if (isset($attachment['partID'])) { |
|
2727 | + if (isset($attachment['partID'])) |
|
2728 | + { |
|
2376 | 2729 | $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
2377 | 2730 | $rawBody=$eml['attachment']; |
2378 | - } else { |
|
2731 | + } |
|
2732 | + else |
|
2733 | + { |
|
2379 | 2734 | $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
2380 | 2735 | } |
2381 | 2736 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
@@ -2384,7 +2739,10 @@ discard block |
||
2384 | 2739 | $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
2385 | 2740 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
2386 | 2741 | { |
2387 | - if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
2742 | + if (!is_array($tnfattachments)) |
|
2743 | + { |
|
2744 | + $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
2745 | + } |
|
2388 | 2746 | foreach ($tnfattachments as $k) |
2389 | 2747 | { |
2390 | 2748 | if ($k['name'] == $attachment['name']) |
@@ -2420,7 +2778,10 @@ discard block |
||
2420 | 2778 | } |
2421 | 2779 | } |
2422 | 2780 | } |
2423 | - if ($connection_opened) $mail_bo->closeConnection(); |
|
2781 | + if ($connection_opened) |
|
2782 | + { |
|
2783 | + $mail_bo->closeConnection(); |
|
2784 | + } |
|
2424 | 2785 | } |
2425 | 2786 | } |
2426 | 2787 | |
@@ -2439,13 +2800,20 @@ discard block |
||
2439 | 2800 | */ |
2440 | 2801 | protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
2441 | 2802 | { |
2442 | - if ($filemode == egw_sharing::ATTACH) return ''; |
|
2803 | + if ($filemode == egw_sharing::ATTACH) |
|
2804 | + { |
|
2805 | + return ''; |
|
2806 | + } |
|
2443 | 2807 | |
2444 | 2808 | $links = array(); |
2445 | 2809 | foreach($attachments as $attachment) |
2446 | 2810 | { |
2447 | 2811 | $path = $attachment['file']; |
2448 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
2812 | + if (empty($path)) |
|
2813 | + { |
|
2814 | + continue; |
|
2815 | + } |
|
2816 | + // we only care about file attachments, not forwarded messages or parts |
|
2449 | 2817 | if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
2450 | 2818 | { |
2451 | 2819 | $path = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($path); |
@@ -2564,7 +2932,10 @@ discard block |
||
2564 | 2932 | $success = false; |
2565 | 2933 | } |
2566 | 2934 | |
2567 | - if ($success) $msg = lang('Message saved successfully.'); |
|
2935 | + if ($success) |
|
2936 | + { |
|
2937 | + $msg = lang('Message saved successfully.'); |
|
2938 | + } |
|
2568 | 2939 | |
2569 | 2940 | // Include new information to json respose, because we need them in client-side callback |
2570 | 2941 | $response->data(array( |
@@ -2601,7 +2972,10 @@ discard block |
||
2601 | 2972 | { |
2602 | 2973 | foreach ($addrFromList as $addr) |
2603 | 2974 | { |
2604 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
2975 | + if (!empty($addr)) |
|
2976 | + { |
|
2977 | + $_emailAddressList[]=$addr; |
|
2978 | + } |
|
2605 | 2979 | } |
2606 | 2980 | } |
2607 | 2981 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2655,7 +3029,10 @@ discard block |
||
2655 | 3029 | // decide where to save the message (default to draft folder, if we find nothing else) |
2656 | 3030 | // if the current folder is in draft or template folder save it there |
2657 | 3031 | // if it is called from printview then save it with the draft folder |
2658 | - if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder(); |
|
3032 | + if (empty($savingDestination)) |
|
3033 | + { |
|
3034 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
3035 | + } |
|
2659 | 3036 | if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) |
2660 | 3037 | { |
2661 | 3038 | $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; |
@@ -2666,13 +3043,17 @@ discard block |
||
2666 | 3043 | $savingDestination = $this->sessionData['messageFolder']; |
2667 | 3044 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
2668 | 3045 | } |
2669 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
3046 | + if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) |
|
3047 | + { |
|
3048 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
3049 | + } |
|
2670 | 3050 | |
2671 | 3051 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
2672 | 3052 | $mail->forceBccHeader(); |
2673 | 3053 | |
2674 | 3054 | $mail_bo->openConnection(); |
2675 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
3055 | + if ($mail_bo->folderExists($savingDestination,true)) |
|
3056 | + { |
|
2676 | 3057 | try |
2677 | 3058 | { |
2678 | 3059 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
@@ -2683,7 +3064,9 @@ discard block |
||
2683 | 3064 | return false; |
2684 | 3065 | } |
2685 | 3066 | |
2686 | - } else { |
|
3067 | + } |
|
3068 | + else |
|
3069 | + { |
|
2687 | 3070 | error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
2688 | 3071 | return false; |
2689 | 3072 | } |
@@ -2731,7 +3114,10 @@ discard block |
||
2731 | 3114 | $fhA = mail_ui::splitRowID($rowid); |
2732 | 3115 | $this->sessionData['uid'][] = $fhA['msgUID']; |
2733 | 3116 | $this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
2734 | - if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
3117 | + if (!empty($fhA['folder'])) |
|
3118 | + { |
|
3119 | + $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
3120 | + } |
|
2735 | 3121 | } |
2736 | 3122 | } |
2737 | 3123 | if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
@@ -2763,7 +3149,8 @@ discard block |
||
2763 | 3149 | #error_log($this->sessionData['body']); |
2764 | 3150 | } |
2765 | 3151 | if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
2766 | - empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
|
3152 | + empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) |
|
3153 | + { |
|
2767 | 3154 | $messageIsDraft = true; |
2768 | 3155 | } |
2769 | 3156 | try |
@@ -2779,7 +3166,11 @@ discard block |
||
2779 | 3166 | // create the messages |
2780 | 3167 | $this->createMessage($mail, $_formData, $identity); |
2781 | 3168 | // remember the identity |
2782 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
3169 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
3170 | + { |
|
3171 | + $fromAddress = $mail->From; |
|
3172 | + } |
|
3173 | + //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
2783 | 3174 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
2784 | 3175 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
2785 | 3176 | #exit; |
@@ -2792,7 +3183,10 @@ discard block |
||
2792 | 3183 | { |
2793 | 3184 | $fval=$f; |
2794 | 3185 | $icServerID = $_formData['serverID'];//folders always assumed with serverID |
2795 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
3186 | + if (stripos($f,'::')!==false) |
|
3187 | + { |
|
3188 | + list($icServerID,$fval) = explode('::',$f,2); |
|
3189 | + } |
|
2796 | 3190 | if ($_formData['serverID']!=$_formData['mailaccount']) |
2797 | 3191 | { |
2798 | 3192 | if ($icServerID == $_formData['serverID'] ) |
@@ -2833,13 +3227,19 @@ discard block |
||
2833 | 3227 | // sentFolder is account specific |
2834 | 3228 | $sentFolder = $this->mail_bo->getSentFolder(); |
2835 | 3229 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
2836 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
3230 | + if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) |
|
3231 | + { |
|
3232 | + $sentFolder=false; |
|
3233 | + } |
|
2837 | 3234 | } |
2838 | 3235 | else |
2839 | 3236 | { |
2840 | 3237 | $sentFolder = $mail_bo->getSentFolder(); |
2841 | 3238 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
2842 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
3239 | + if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) |
|
3240 | + { |
|
3241 | + $sentFolder=false; |
|
3242 | + } |
|
2843 | 3243 | } |
2844 | 3244 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
2845 | 3245 | |
@@ -2875,19 +3275,30 @@ discard block |
||
2875 | 3275 | { |
2876 | 3276 | if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
2877 | 3277 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
2878 | - $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
|
3278 | + $sentFolder != 'none')) |
|
3279 | + { |
|
3280 | + $this->errorInfo = lang("No Send Folder set in preferences"); |
|
3281 | + } |
|
2879 | 3282 | } |
2880 | 3283 | // draftFolder is on Server we start from |
2881 | - if($messageIsDraft == true) { |
|
3284 | + if($messageIsDraft == true) |
|
3285 | + { |
|
2882 | 3286 | $draftFolder = $mail_bo->getDraftFolder(); |
2883 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
3287 | + if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) |
|
3288 | + { |
|
2884 | 3289 | $this->sessionData['folder'] = array($draftFolder); |
2885 | 3290 | $folderOnServerID[] = $draftFolder; |
2886 | 3291 | $folder[$draftFolder] = $draftFolder; |
2887 | 3292 | } |
2888 | 3293 | } |
2889 | - if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
|
2890 | - if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
3294 | + if ($folderOnServerID) |
|
3295 | + { |
|
3296 | + $folderOnServerID = array_unique($folderOnServerID); |
|
3297 | + } |
|
3298 | + if ($folderOnMailAccount) |
|
3299 | + { |
|
3300 | + $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
3301 | + } |
|
2891 | 3302 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
2892 | 3303 | !( count($folder) > 0) && |
2893 | 3304 | !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
@@ -2901,7 +3312,8 @@ discard block |
||
2901 | 3312 | @set_time_limit(120); |
2902 | 3313 | //$mail->SMTPDebug = 10; |
2903 | 3314 | //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); |
2904 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
3315 | + if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) |
|
3316 | + { |
|
2905 | 3317 | try { |
2906 | 3318 | $mail->send(); |
2907 | 3319 | } |
@@ -2910,10 +3322,15 @@ discard block |
||
2910 | 3322 | $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
2911 | 3323 | return false; |
2912 | 3324 | } |
2913 | - } else { |
|
2914 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
3325 | + } |
|
3326 | + else |
|
3327 | + { |
|
3328 | + if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) |
|
3329 | + { |
|
2915 | 3330 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
2916 | - } else { |
|
3331 | + } |
|
3332 | + else |
|
3333 | + { |
|
2917 | 3334 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
2918 | 3335 | //error_log(__METHOD__.__LINE__.$this->errorInfo); |
2919 | 3336 | return false; |
@@ -2923,14 +3340,16 @@ discard block |
||
2923 | 3340 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
2924 | 3341 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
2925 | 3342 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
2926 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
3343 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
3344 | + { |
|
2927 | 3345 | $mail_bo = $this->mail_bo; |
2928 | 3346 | $mail_bo->openConnection(); |
2929 | 3347 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
2930 | 3348 | #error_log("(re)opened Connection"); |
2931 | 3349 | } |
2932 | 3350 | // if copying mail to folder, or saving mail to infolog, we need to gather the needed information |
2933 | - if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') { |
|
3351 | + if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
3352 | + { |
|
2934 | 3353 | //error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc'])); |
2935 | 3354 | |
2936 | 3355 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
@@ -2939,17 +3358,28 @@ discard block |
||
2939 | 3358 | // copying mail to folder |
2940 | 3359 | if (count($folder) > 0) |
2941 | 3360 | { |
2942 | - foreach($folderOnServerID as $folderName) { |
|
2943 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
3361 | + foreach($folderOnServerID as $folderName) |
|
3362 | + { |
|
3363 | + if (is_array($folderName)) |
|
3364 | + { |
|
3365 | + $folderName = array_shift($folderName); |
|
3366 | + } |
|
3367 | + // should not happen at all |
|
2944 | 3368 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
2945 | 3369 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
2946 | 3370 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
2947 | - if ($mail_bo->folderExists($folderName,true)) { |
|
2948 | - if($mail_bo->isSentFolder($folderName)) { |
|
3371 | + if ($mail_bo->folderExists($folderName,true)) |
|
3372 | + { |
|
3373 | + if($mail_bo->isSentFolder($folderName)) |
|
3374 | + { |
|
2949 | 3375 | $flags = '\\Seen'; |
2950 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
3376 | + } |
|
3377 | + elseif($mail_bo->isDraftFolder($folderName)) |
|
3378 | + { |
|
2951 | 3379 | $flags = '\\Draft'; |
2952 | - } else { |
|
3380 | + } |
|
3381 | + else |
|
3382 | + { |
|
2953 | 3383 | $flags = '\\Seen'; |
2954 | 3384 | } |
2955 | 3385 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -2972,18 +3402,32 @@ discard block |
||
2972 | 3402 | } |
2973 | 3403 | } |
2974 | 3404 | // if we choose to send from a differing profile |
2975 | - if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
|
2976 | - foreach($folderOnMailAccount as $folderName) { |
|
2977 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
3405 | + if ($folderOnMailAccount) |
|
3406 | + { |
|
3407 | + $this->changeProfile($_formData['mailaccount']); |
|
3408 | + } |
|
3409 | + foreach($folderOnMailAccount as $folderName) |
|
3410 | + { |
|
3411 | + if (is_array($folderName)) |
|
3412 | + { |
|
3413 | + $folderName = array_shift($folderName); |
|
3414 | + } |
|
3415 | + // should not happen at all |
|
2978 | 3416 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
2979 | 3417 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
2980 | 3418 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
2981 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
2982 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
3419 | + if ($this->mail_bo->folderExists($folderName,true)) |
|
3420 | + { |
|
3421 | + if($this->mail_bo->isSentFolder($folderName)) |
|
3422 | + { |
|
2983 | 3423 | $flags = '\\Seen'; |
2984 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
3424 | + } |
|
3425 | + elseif($this->mail_bo->isDraftFolder($folderName)) |
|
3426 | + { |
|
2985 | 3427 | $flags = '\\Draft'; |
2986 | - } else { |
|
3428 | + } |
|
3429 | + else |
|
3430 | + { |
|
2987 | 3431 | $flags = '\\Seen'; |
2988 | 3432 | } |
2989 | 3433 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3005,7 +3449,10 @@ discard block |
||
3005 | 3449 | error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
3006 | 3450 | } |
3007 | 3451 | } |
3008 | - if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
|
3452 | + if ($folderOnMailAccount) |
|
3453 | + { |
|
3454 | + $this->changeProfile($_formData['serverID']); |
|
3455 | + } |
|
3009 | 3456 | |
3010 | 3457 | //$mail_bo->closeConnection(); |
3011 | 3458 | } |
@@ -3017,10 +3464,16 @@ discard block |
||
3017 | 3464 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
3018 | 3465 | $lastDrafted['uid'] = $dhA['msgUID']; |
3019 | 3466 | $lastDrafted['folder'] = $dhA['folder']; |
3020 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
3467 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) |
|
3468 | + { |
|
3469 | + $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
3470 | + } |
|
3021 | 3471 | // manually drafted, do not delete |
3022 | 3472 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
3023 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
3473 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) |
|
3474 | + { |
|
3475 | + $lastDrafted=false; |
|
3476 | + } |
|
3024 | 3477 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
3025 | 3478 | } |
3026 | 3479 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
@@ -3046,7 +3499,8 @@ discard block |
||
3046 | 3499 | |
3047 | 3500 | //error_log("handling draft messages, flagging and such"); |
3048 | 3501 | if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
3049 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
3502 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
3503 | + { |
|
3050 | 3504 | // mark message as answered |
3051 | 3505 | $mail_bo->openConnection(); |
3052 | 3506 | $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
@@ -3068,7 +3522,9 @@ discard block |
||
3068 | 3522 | //error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage())); |
3069 | 3523 | unset($e); |
3070 | 3524 | } |
3071 | - } else { |
|
3525 | + } |
|
3526 | + else |
|
3527 | + { |
|
3072 | 3528 | $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
3073 | 3529 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
3074 | 3530 | if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
@@ -3087,7 +3543,10 @@ discard block |
||
3087 | 3543 | } |
3088 | 3544 | //$mail_bo->closeConnection(); |
3089 | 3545 | } |
3090 | - if ($mail_bo) $mail_bo->closeConnection(); |
|
3546 | + if ($mail_bo) |
|
3547 | + { |
|
3548 | + $mail_bo->closeConnection(); |
|
3549 | + } |
|
3091 | 3550 | //error_log("performing Infolog Stuff"); |
3092 | 3551 | //error_log(print_r($this->sessionData['to'],true)); |
3093 | 3552 | //error_log(print_r($this->sessionData['cc'],true)); |
@@ -3100,9 +3559,18 @@ discard block |
||
3100 | 3559 | { |
3101 | 3560 | $mailaddresses = array(); |
3102 | 3561 | } |
3103 | - if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc']; |
|
3104 | - if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
3105 | - if (!empty($mailaddresses)) $mailaddresses['from'] = $GLOBALS['egw']->translation->decodeMailHeader($fromAddress); |
|
3562 | + if (is_array($this->sessionData['cc'])) |
|
3563 | + { |
|
3564 | + $mailaddresses['cc'] = $this->sessionData['cc']; |
|
3565 | + } |
|
3566 | + if (is_array($this->sessionData['bcc'])) |
|
3567 | + { |
|
3568 | + $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
3569 | + } |
|
3570 | + if (!empty($mailaddresses)) |
|
3571 | + { |
|
3572 | + $mailaddresses['from'] = $GLOBALS['egw']->translation->decodeMailHeader($fromAddress); |
|
3573 | + } |
|
3106 | 3574 | |
3107 | 3575 | if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
3108 | 3576 | { |
@@ -3141,8 +3609,11 @@ discard block |
||
3141 | 3609 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
3142 | 3610 | elseif(is_array($this->sessionData['attachments'])) |
3143 | 3611 | { |
3144 | - foreach($this->sessionData['attachments'] as $value) { |
|
3145 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
3612 | + foreach($this->sessionData['attachments'] as $value) |
|
3613 | + { |
|
3614 | + if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') |
|
3615 | + { |
|
3616 | +// happens when forwarding mails |
|
3146 | 3617 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
3147 | 3618 | } |
3148 | 3619 | } |
@@ -3179,7 +3650,10 @@ discard block |
||
3179 | 3650 | $default_identity = null; |
3180 | 3651 | foreach(emailadmin_account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
3181 | 3652 | { |
3182 | - if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
|
3653 | + if (!isset($default_identity)) |
|
3654 | + { |
|
3655 | + $default_identity = $identity['ident_id']; |
|
3656 | + } |
|
3183 | 3657 | if (!empty($identity['ident_signature'])) |
3184 | 3658 | { |
3185 | 3659 | $content['mailidentity'] = $identity['ident_id']; |
@@ -3187,12 +3661,18 @@ discard block |
||
3187 | 3661 | } |
3188 | 3662 | } |
3189 | 3663 | } |
3190 | - if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity; |
|
3664 | + if (empty($content['mailidentity'])) |
|
3665 | + { |
|
3666 | + $content['mailidentity'] = $default_identity; |
|
3667 | + } |
|
3191 | 3668 | } |
3192 | 3669 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
3193 | 3670 | { |
3194 | 3671 | $content['mimeType'] = 'html'; |
3195 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
3672 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") |
|
3673 | + { |
|
3674 | + $content['mimeType'] = 'plain'; |
|
3675 | + } |
|
3196 | 3676 | } |
3197 | 3677 | return $content; |
3198 | 3678 | |
@@ -3200,9 +3680,12 @@ discard block |
||
3200 | 3680 | |
3201 | 3681 | function stripSlashes($_string) |
3202 | 3682 | { |
3203 | - if (get_magic_quotes_gpc()) { |
|
3683 | + if (get_magic_quotes_gpc()) |
|
3684 | + { |
|
3204 | 3685 | return stripslashes($_string); |
3205 | - } else { |
|
3686 | + } |
|
3687 | + else |
|
3688 | + { |
|
3206 | 3689 | return $_string; |
3207 | 3690 | } |
3208 | 3691 | } |
@@ -3215,15 +3698,25 @@ discard block |
||
3215 | 3698 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
3216 | 3699 | * @return type |
3217 | 3700 | */ |
3218 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
3701 | + function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
|
3702 | + { |
|
3219 | 3703 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
3220 | 3704 | static $useCacheIfPossible = null; |
3221 | - if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
|
3705 | + if (is_null($useCacheIfPossible)) |
|
3706 | + { |
|
3707 | + $useCacheIfPossible = true; |
|
3708 | + } |
|
3222 | 3709 | $_searchString = trim($_REQUEST['query']); |
3223 | 3710 | $results = array(); |
3224 | 3711 | $rememberServerID = $this->mail_bo->icServer->ImapServerId; |
3225 | - if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
3226 | - if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
3712 | + if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) |
|
3713 | + { |
|
3714 | + $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
3715 | + } |
|
3716 | + if (empty($_mailaccountToSearch)) |
|
3717 | + { |
|
3718 | + $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
3719 | + } |
|
3227 | 3720 | if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch) |
3228 | 3721 | { |
3229 | 3722 | $this->changeProfile($_mailaccountToSearch); |
@@ -3234,7 +3727,8 @@ discard block |
||
3234 | 3727 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
3235 | 3728 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
3236 | 3729 | $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
3237 | - if (count($folderObjects)<=1) { |
|
3730 | + if (count($folderObjects)<=1) |
|
3731 | + { |
|
3238 | 3732 | $useCacheIfPossible = false; |
3239 | 3733 | } |
3240 | 3734 | else |
@@ -3285,7 +3779,8 @@ discard block |
||
3285 | 3779 | common::egw_exit(); |
3286 | 3780 | } |
3287 | 3781 | |
3288 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
3782 | + public static function ajax_searchAddress($_searchStringLength=2) |
|
3783 | + { |
|
3289 | 3784 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
3290 | 3785 | $_searchString = trim($_REQUEST['query']); |
3291 | 3786 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3297,7 +3792,10 @@ discard block |
||
3297 | 3792 | $search = explode(' ', $_searchString); |
3298 | 3793 | foreach ($search as $k => $v) |
3299 | 3794 | { |
3300 | - if (mb_strlen($v) < 3) unset($search[$k]); |
|
3795 | + if (mb_strlen($v) < 3) |
|
3796 | + { |
|
3797 | + unset($search[$k]); |
|
3798 | + } |
|
3301 | 3799 | } |
3302 | 3800 | $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
3303 | 3801 | //error_log(__METHOD__.__LINE__.$_searchString); |
@@ -3327,9 +3825,12 @@ discard block |
||
3327 | 3825 | } |
3328 | 3826 | } |
3329 | 3827 | $results = array(); |
3330 | - if(is_array($contacts)) { |
|
3331 | - foreach($contacts as $contact) { |
|
3332 | - foreach(array($contact['email'],$contact['email_home']) as $email) { |
|
3828 | + if(is_array($contacts)) |
|
3829 | + { |
|
3830 | + foreach($contacts as $contact) |
|
3831 | + { |
|
3832 | + foreach(array($contact['email'],$contact['email_home']) as $email) |
|
3833 | + { |
|
3333 | 3834 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
3334 | 3835 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
3335 | 3836 | $rfcAddr = emailadmin_imapbase::parseAddressList($email); |
@@ -3343,10 +3844,22 @@ discard block |
||
3343 | 3844 | if (method_exists($GLOBALS['egw']->contacts,'search')) |
3344 | 3845 | { |
3345 | 3846 | $contact['n_fn']=''; |
3346 | - if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
|
3347 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
3348 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
3349 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
3847 | + if (!empty($contact['n_prefix'])) |
|
3848 | + { |
|
3849 | + $contact['n_fn'] = $contact['n_prefix']; |
|
3850 | + } |
|
3851 | + if (!empty($contact['n_given'])) |
|
3852 | + { |
|
3853 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
3854 | + } |
|
3855 | + if (!empty($contact['n_family'])) |
|
3856 | + { |
|
3857 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
3858 | + } |
|
3859 | + if (!empty($contact['org_name'])) |
|
3860 | + { |
|
3861 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
3862 | + } |
|
3350 | 3863 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
3351 | 3864 | } |
3352 | 3865 | else |
@@ -3356,7 +3869,8 @@ discard block |
||
3356 | 3869 | $args = explode('@', trim($email)); |
3357 | 3870 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
3358 | 3871 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
3359 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
3872 | + if(!empty($email) && in_array($completeMailString ,$results) === false) |
|
3873 | + { |
|
3360 | 3874 | $results[] = array( |
3361 | 3875 | 'id'=>$completeMailString, |
3362 | 3876 | 'label' => $completeMailString, |
@@ -3375,7 +3889,10 @@ discard block |
||
3375 | 3889 | foreach($groups as $g_id => $name) |
3376 | 3890 | { |
3377 | 3891 | $group = $GLOBALS['egw']->accounts->read($g_id); |
3378 | - if(!$group['account_email']) continue; |
|
3892 | + if(!$group['account_email']) |
|
3893 | + { |
|
3894 | + continue; |
|
3895 | + } |
|
3379 | 3896 | $args = explode('@', trim($group['account_email'])); |
3380 | 3897 | $args[] = $name; |
3381 | 3898 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
@@ -3392,7 +3909,8 @@ discard block |
||
3392 | 3909 | { |
3393 | 3910 | $lists = array_filter( |
3394 | 3911 | $GLOBALS['egw']->contacts->get_lists(EGW_ACL_READ), |
3395 | - function($element) use($_searchString) { |
|
3912 | + function($element) use($_searchString) |
|
3913 | + { |
|
3396 | 3914 | return (stripos($element, $_searchString) !== false); |
3397 | 3915 | } |
3398 | 3916 | ); |
@@ -3407,7 +3925,10 @@ discard block |
||
3407 | 3925 | 'title' => lang('Mailinglist'), |
3408 | 3926 | 'data' => $key |
3409 | 3927 | ); |
3410 | - if($list_count++ > 5) break; |
|
3928 | + if($list_count++ > 5) |
|
3929 | + { |
|
3930 | + break; |
|
3931 | + } |
|
3411 | 3932 | } |
3412 | 3933 | } |
3413 | 3934 | // switch regular JSON response handling off |
@@ -11,4 +11,4 @@ |
||
11 | 11 | * @version $Id$ |
12 | 12 | */ |
13 | 13 | header('Location: ../index.php?menuaction=mail.mail_ui.index'. |
14 | - (isset($_GET['sessionid']) ? '&sessionid='.$_GET['sessionid'].'&kp3='.$_GET['kp3'] : '')); |
|
14 | + (isset($_GET['sessionid']) ? '&sessionid='.$_GET['sessionid'].'&kp3='.$_GET['kp3'] : '')); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $categories = new Api\Categories('', 'resources'); |
27 | 27 | $cat_list = $categories->return_sorted_array(); |
28 | 28 | $cat_options = array(); |
29 | - foreach($cat_list as $category) |
|
29 | + foreach ($cat_list as $category) |
|
30 | 30 | { |
31 | 31 | $cat_options[$category['id']] = $category['name']; |
32 | 32 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'email_message' => array( |
55 | 55 | 'type' => 'textarea', |
56 | 56 | 'large' => true, |
57 | - 'label' => lang('Confirmation email text').'<br />%1 = ' . lang('Event start').'<br/>%2 = link<br />%3 = '.lang('expiry'), |
|
57 | + 'label' => lang('Confirmation email text').'<br />%1 = '.lang('Event start').'<br/>%2 = link<br />%3 = '.lang('expiry'), |
|
58 | 58 | 'params' => array( |
59 | 59 | 'rows' => 8, |
60 | 60 | 'cols' => 110 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'label' => lang('Confirmed addressbook.').' ('.lang('The anonymous user needs add rights for it!').')', |
66 | 66 | 'options' => array( |
67 | 67 | '' => lang('None'), |
68 | - )+registration_bo::get_allowed_addressbooks(registration_bo::CONFIRMED) |
|
68 | + ) + registration_bo::get_allowed_addressbooks(registration_bo::CONFIRMED) |
|
69 | 69 | ), |
70 | 70 | 'include_group' => array( |
71 | 71 | 'type' => 'select', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // Add resources from selected category |
91 | 91 | $bo = new resources_bo(); |
92 | 92 | $bo->get_rows($query, $list, $readonlys); |
93 | - foreach($list as $resource) |
|
93 | + foreach ($list as $resource) |
|
94 | 94 | { |
95 | 95 | $this->arguments['resource']['options'][$resource['res_id']] = $resource['name']; |
96 | 96 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param array $properties |
106 | 106 | * @return string the Api\Html content |
107 | 107 | */ |
108 | - function get_content(&$arguments,$properties) |
|
108 | + function get_content(&$arguments, $properties) |
|
109 | 109 | { |
110 | - list($app) = explode('.',$this->etemplate_method); |
|
110 | + list($app) = explode('.', $this->etemplate_method); |
|
111 | 111 | Api\Translation::add_app($app); |
112 | 112 | |
113 | 113 | $extra = "<style type=\"text/css\">\n<!--\n@import url(".$GLOBALS['egw_info']['server']['webserver_url']. |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | $extra .= "-->\n</style>\n"; |
123 | 123 | $extra .= '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].'/etemplate/js/etemplate.js" type="text/javascript"></script>'."\n"; |
124 | 124 | $ret = false; |
125 | - if($_POST['etemplate_exec_id']) |
|
125 | + if ($_POST['etemplate_exec_id']) |
|
126 | 126 | { |
127 | 127 | $ret = ExecMethod('etemplate.etemplate.process_exec'); |
128 | 128 | } |
129 | - if($_GET['date']) $arguments['date'] = strtotime($_GET['date']); |
|
129 | + if ($_GET['date']) $arguments['date'] = strtotime($_GET['date']); |
|
130 | 130 | $arguments['link'] = $this->link(); |
131 | 131 | $arguments['sitemgr_version'] = $this->block->version; |
132 | - return $extra.($ret ? $ret : ExecMethod2($this->etemplate_method,null,$arguments)); |
|
132 | + return $extra.($ret ? $ret : ExecMethod2($this->etemplate_method, null, $arguments)); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
@@ -126,7 +126,10 @@ |
||
126 | 126 | { |
127 | 127 | $ret = ExecMethod('etemplate.etemplate.process_exec'); |
128 | 128 | } |
129 | - if($_GET['date']) $arguments['date'] = strtotime($_GET['date']); |
|
129 | + if($_GET['date']) |
|
130 | + { |
|
131 | + $arguments['date'] = strtotime($_GET['date']); |
|
132 | + } |
|
130 | 133 | $arguments['link'] = $this->link(); |
131 | 134 | $arguments['sitemgr_version'] = $this->block->version; |
132 | 135 | return $extra.($ret ? $ret : ExecMethod2($this->etemplate_method,null,$arguments)); |
@@ -96,13 +96,13 @@ |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * generate the module content AND process submitted forms |
|
100 | - * Overridden from parent to pass arguments |
|
101 | - * |
|
102 | - * @param array &$arguments $arguments['arg1']-$arguments['arg3'] will be passed for non-submitted forms (first call) |
|
103 | - * @param array $properties |
|
104 | - * @return string the html content |
|
105 | - */ |
|
99 | + * generate the module content AND process submitted forms |
|
100 | + * Overridden from parent to pass arguments |
|
101 | + * |
|
102 | + * @param array &$arguments $arguments['arg1']-$arguments['arg3'] will be passed for non-submitted forms (first call) |
|
103 | + * @param array $properties |
|
104 | + * @return string the html content |
|
105 | + */ |
|
106 | 106 | function get_content(&$arguments,$properties) |
107 | 107 | { |
108 | 108 | list($app) = explode('.',$this->etemplate_method); |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | $phpgw_baseline = array( |
15 | 15 | 'egw_resources' => array( |
16 | 16 | 'fd' => array( |
17 | - 'res_id' => array('type' => 'auto','nullable' => False), |
|
18 | - 'name' => array('type' => 'varchar','precision' => '100'), |
|
19 | - 'short_description' => array('type' => 'varchar','precision' => '100'), |
|
20 | - 'cat_id' => array('type' => 'int','meta' => 'category','precision' => '11','nullable' => False), |
|
21 | - 'quantity' => array('type' => 'int','precision' => '11','default' => '1'), |
|
22 | - 'useable' => array('type' => 'int','precision' => '11','default' => '1'), |
|
23 | - 'location' => array('type' => 'varchar','precision' => '100'), |
|
24 | - 'bookable' => array('type' => 'varchar','precision' => '1'), |
|
25 | - 'buyable' => array('type' => 'varchar','precision' => '1'), |
|
26 | - 'prize' => array('type' => 'varchar','precision' => '200'), |
|
17 | + 'res_id' => array('type' => 'auto', 'nullable' => False), |
|
18 | + 'name' => array('type' => 'varchar', 'precision' => '100'), |
|
19 | + 'short_description' => array('type' => 'varchar', 'precision' => '100'), |
|
20 | + 'cat_id' => array('type' => 'int', 'meta' => 'category', 'precision' => '11', 'nullable' => False), |
|
21 | + 'quantity' => array('type' => 'int', 'precision' => '11', 'default' => '1'), |
|
22 | + 'useable' => array('type' => 'int', 'precision' => '11', 'default' => '1'), |
|
23 | + 'location' => array('type' => 'varchar', 'precision' => '100'), |
|
24 | + 'bookable' => array('type' => 'varchar', 'precision' => '1'), |
|
25 | + 'buyable' => array('type' => 'varchar', 'precision' => '1'), |
|
26 | + 'prize' => array('type' => 'varchar', 'precision' => '200'), |
|
27 | 27 | 'long_description' => array('type' => 'longtext'), |
28 | - 'picture_src' => array('type' => 'varchar','precision' => '20'), |
|
29 | - 'accessory_of' => array('type' => 'int','precision' => '11','default' => '-1'), |
|
30 | - 'storage_info' => array('type' => 'varchar','precision' => '200'), |
|
31 | - 'inventory_number' => array('type' => 'varchar','precision' => '20'), |
|
32 | - 'deleted' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
33 | - 'res_creator' => array('type' => 'int','meta' => 'user','precision' => '11'), |
|
34 | - 'res_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
35 | - 'res_modifier' => array('type' => 'int','meta' => 'user','precision' => '11'), |
|
36 | - 'res_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8') |
|
28 | + 'picture_src' => array('type' => 'varchar', 'precision' => '20'), |
|
29 | + 'accessory_of' => array('type' => 'int', 'precision' => '11', 'default' => '-1'), |
|
30 | + 'storage_info' => array('type' => 'varchar', 'precision' => '200'), |
|
31 | + 'inventory_number' => array('type' => 'varchar', 'precision' => '20'), |
|
32 | + 'deleted' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
33 | + 'res_creator' => array('type' => 'int', 'meta' => 'user', 'precision' => '11'), |
|
34 | + 'res_created' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
35 | + 'res_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '11'), |
|
36 | + 'res_modified' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8') |
|
37 | 37 | ), |
38 | 38 | 'pk' => array('res_id'), |
39 | 39 | 'fk' => array(), |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | ), |
43 | 43 | 'egw_resources_extra' => array( |
44 | 44 | 'fd' => array( |
45 | - 'extra_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
46 | - 'extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '40','nullable' => False), |
|
47 | - 'extra_owner' => array('type' => 'int','meta' => 'account','precision' => '4','nullable' => False,'default' => '-1'), |
|
48 | - 'extra_value' => array('type' => 'varchar','meta' => 'cfvalue','precision' => '255','nullable' => False,'default' => '') |
|
45 | + 'extra_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
46 | + 'extra_name' => array('type' => 'varchar', 'meta' => 'cfname', 'precision' => '40', 'nullable' => False), |
|
47 | + 'extra_owner' => array('type' => 'int', 'meta' => 'account', 'precision' => '4', 'nullable' => False, 'default' => '-1'), |
|
48 | + 'extra_value' => array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '255', 'nullable' => False, 'default' => '') |
|
49 | 49 | ), |
50 | - 'pk' => array('extra_id','extra_name','extra_owner'), |
|
50 | + 'pk' => array('extra_id', 'extra_name', 'extra_owner'), |
|
51 | 51 | 'fk' => array(), |
52 | 52 | 'ix' => array(), |
53 | 53 | 'uc' => array() |
@@ -44,7 +44,7 @@ |
||
44 | 44 | 'long_description' => lang('Long description'), |
45 | 45 | 'inventory_number' => lang('inventory number'), |
46 | 46 | 'accessory_of' => lang('Accessory of') |
47 | - ); |
|
47 | + ); |
|
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | 50 | foreach($custom as $name => $data) { |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach ($custom as $name => $data) { |
|
51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 52 | } |
53 | 53 |
@@ -47,7 +47,8 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach($custom as $name => $data) |
|
51 | + { |
|
51 | 52 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 53 | } |
53 | 54 |