Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
timesheet/index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@
 block discarded – undo
28 28
 {
29 29
 	Framework::render('<p style="text-align: center; color:red; font-weight: bold;">'.
30 30
 		lang('Your database is NOT up to date (%1 vs. %2), please run %3setup%4 to update your database.',
31
-		$ts_version,$GLOBALS['egw_info']['apps'][TIMESHEET_APP]['version'],
32
-		'<a href="../setup/">','</a>')."</p>\n", null, true);
31
+		$ts_version, $GLOBALS['egw_info']['apps'][TIMESHEET_APP]['version'],
32
+		'<a href="../setup/">', '</a>')."</p>\n", null, true);
33 33
 	exit();
34 34
 }
35 35
 
36
-Framework::redirect_link('/index.php',array('menuaction'=>TIMESHEET_APP.'.timesheet_ui.index'));
36
+Framework::redirect_link('/index.php', array('menuaction'=>TIMESHEET_APP.'.timesheet_ui.index'));
Please login to merge, or discard this patch.
notifications/download.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	)
21 21
 );
22 22
 
23
-ini_set('zlib.output_compression',0);
23
+ini_set('zlib.output_compression', 0);
24 24
 include('../header.inc.php');
25 25
 
26 26
 ob_start();
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 check_load_extension('zip', true);
29 29
 
30 30
 $document = EGW_SERVER_ROOT.'/notifications/java/full-eGwNotifier.jar';
31
-$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document,'.jar').'-').'.jar';
32
-$ret=copy($document, $archive);
31
+$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document, '.jar').'-').'.jar';
32
+$ret = copy($document, $archive);
33 33
 error_log("copy('$document', '$archive' returned ".array2string($ret));
34 34
 $document = 'zip://'.$archive.'#'.($config_file = 'lib/conf/egwnotifier.const.xml');
35 35
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 function replace_callback($matches)
40 40
 {
41 41
 	$replacement = $matches[3];
42
-	switch($matches[1])
42
+	switch ($matches[1])
43 43
 	{
44 44
 		case 'egw_dc_url':
45 45
 			$replacement = $GLOBALS['egw_info']['server']['webserver_url'];
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		case 'egw_debuging_level':
61 61
 			break;
62 62
 		default:
63
-			$replacement = lang($r=$replacement);
63
+			$replacement = lang($r = $replacement);
64 64
 			/* uncomment this to have missing translations add to en langfile
65 65
 			// if no translation found, check if en langfile is writable and add phrase, if not already there
66 66
 			if ($r === $replacement)
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 	if (is_string($htmlscflags))
91 91
 	{
92
-		$htmlscflags = 16;	// #define ENT_XML1		16
92
+		$htmlscflags = 16; // #define ENT_XML1		16
93 93
 	}
94 94
 
95 95
 	return '<'.$matches[1].'>'.htmlspecialchars($replacement, $htmlscflags, Api\Translation::charset()).'</'.$matches[1].'>';
@@ -118,6 +118,6 @@  discard block
 block discarded – undo
118 118
 ob_end_clean();
119 119
 
120 120
 Api\Header\Content::type('egroupware-notifier-'.$GLOBALS['egw_info']['user']['account_lid'].'.jar', 'application/x-java-archive', filesize($archive));
121
-readfile($archive,'rb');
121
+readfile($archive, 'rb');
122 122
 
123 123
 @unlink($archive);
Please login to merge, or discard this patch.
notifications/inc/class.notifications_push.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public static function get()
41 41
 	{
42
-		$already_send =& Api\Cache::getSession(__CLASS__, 'already_send');
42
+		$already_send = & Api\Cache::getSession(__CLASS__, 'already_send');
43 43
 		$max_id = Api\Cache::getInstance(__CLASS__, 'max_id');
44 44
 
45 45
 		if (!isset($already_send))
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		{
58 58
 			$response = Json\Response::get();
59 59
 
60
-			foreach(self::$db->select(self::TABLE, '*', array(
60
+			foreach (self::$db->select(self::TABLE, '*', array(
61 61
 				'account_id' => array(0, $GLOBALS['egw_info']['user']['account_id']),
62 62
 				'notify_type' => self::TYPE,
63 63
 				'notify_id > '.(int)$already_send,
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public static function init_static()
123 123
 	{
124
-		self::$db =& $GLOBALS['egw']->db;
124
+		self::$db = & $GLOBALS['egw']->db;
125 125
 	}
126 126
 }
127 127
 notifications_push::init_static();
Please login to merge, or discard this patch.
notifications/inc/class.notifications_jdesk_ajax.inc.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	{
134 134
 		if ($notify_id)
135 135
 		{
136
-			$this->db->delete(self::_notification_table,array(
136
+			$this->db->delete(self::_notification_table, array(
137 137
 				'notify_id' => $notify_id,
138 138
 				'account_id' => $this->recipient->account_id,
139 139
 				'notify_type' => self::_type
140
-			),__LINE__,__FILE__,self::_appname);
140
+			), __LINE__, __FILE__, self::_appname);
141 141
 		}
142 142
 	}
143 143
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	private function get_egwpopup($browserNotify = false)
150 150
 	{
151
-		unset($browserNotify);	// not used
151
+		unset($browserNotify); // not used
152 152
 
153 153
 		$message = '';
154 154
 
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 				'account_id' => $this->recipient->account_id,
157 157
 				'notify_type' => self::_type
158 158
 			),
159
-			__LINE__,__FILE__,false,'',self::_appname);
159
+			__LINE__, __FILE__, false, '', self::_appname);
160 160
 
161
-		if( $rs->NumRows() > 0 )
161
+		if ($rs->NumRows() > 0)
162 162
 		{
163 163
 			foreach ($rs as $notification)
164 164
 			{
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 				$this->response->data($jmessage);
171 171
 			}
172 172
 
173
-			switch( $this->preferences[self::_appname]['egwpopup_verbosity'] )
173
+			switch ($this->preferences[self::_appname]['egwpopup_verbosity'])
174 174
 			{
175 175
 				case 'low':
176 176
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * jdesk Json methods for notifications
16 16
  */
17
-class notifications_jdesk_ajax {
17
+class notifications_jdesk_ajax
18
+{
18 19
 
19 20
 	public $public_functions = array(
20 21
 		'get_notification'	=> true
@@ -92,7 +93,9 @@  discard block
 block discarded – undo
92 93
 	 * destructor
93 94
 	 *
94 95
 	 */
95
-	public function __destruct() {}
96
+	public function __destruct()
97
+	{
98
+}
96 99
 
97 100
 	/**
98 101
 	 * public AJAX trigger function to be called by the JavaScript client
Please login to merge, or discard this patch.
notifications/inc/hook_admin.inc.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@
 block discarded – undo
11 11
 
12 12
 use EGroupware\Api\Egw;
13 13
 
14
-$file = Array(	'Site Configuration' => Egw::link('/index.php', array(
14
+$file = Array('Site Configuration' => Egw::link('/index.php', array(
15 15
 	'menuaction'	=> 'admin.admin_config.index',
16 16
 	'appname'		=> $appname,
17 17
 	'ajax'          => 'true',
18 18
 )));
19
-display_section($appname,$file);
19
+display_section($appname, $file);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 use EGroupware\Api\Egw;
13 13
 
14
-$file = Array(	'Site Configuration' => Egw::link('/index.php', array(
14
+$file = array(	'Site Configuration' => Egw::link('/index.php', array(
15 15
 	'menuaction'	=> 'admin.admin_config.index',
16 16
 	'appname'		=> $appname,
17 17
 	'ajax'          => 'true',
Please login to merge, or discard this patch.
status.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
webdav.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 {
38 38
 	if (isset($_GET['auth']))
39 39
 	{
40
-		list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2);
40
+		list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($_GET['auth']), 2);
41 41
 	}
42 42
 	return Api\Header\Authenticate::autocreate_session_callback($account);
43 43
 }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 		'noheader'  => True,
49 49
 		'currentapp' => preg_match('|/webdav.php/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager',
50 50
 		'autocreate_session_callback' => 'check_access',
51
-		'no_exception_handler' => 'basic_auth',	// we use a basic auth exception handler (sends exception message as basic auth realm)
52
-		'auth_realm' => 'EGroupware WebDAV server',	// cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup!
51
+		'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm)
52
+		'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup!
53 53
 	)
54 54
 );
55 55
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
  * Create a session or if the user has no account return authenticate header and 401 Unauthorized
29 29
  *
30 30
  * @param array &$account
31
- * @return int session-id
31
+ * @return string session-id
32 32
  */
33 33
 function check_access(&$account)
34 34
 {
Please login to merge, or discard this patch.
mail/inc/class.mail_wizard.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 		parent::__construct();
33 33
 
34 34
 		// need emailadmin's app.css file
35
-		Framework::includeCSS('admin','app');
35
+		Framework::includeCSS('admin', 'app');
36 36
 
37 37
 		// and translations
38 38
 		Api\Translation::add_app('admin');
Please login to merge, or discard this patch.
mail/inc/class.mail_compose.inc.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2126,11 +2126,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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']);
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1600,6 +1600,10 @@  discard block
 block discarded – undo
1600 1600
 	// $_mode can be:
1601 1601
 	// single: for a reply to one address
1602 1602
 	// all: for a reply to all
1603
+
1604
+	/**
1605
+	 * @param Mail\Imap $_icServer
1606
+	 */
1603 1607
 	function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL)
1604 1608
 	{
1605 1609
 		unset($_icServer);	// not used
@@ -1800,6 +1804,9 @@  discard block
 block discarded – undo
1800 1804
 		return false;
1801 1805
 	}
1802 1806
 
1807
+	/**
1808
+	 * @param Mail\Imap $_icServer
1809
+	 */
1803 1810
 	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false)
1804 1811
 	{
1805 1812
 		if ($_mode)
@@ -2072,7 +2079,7 @@  discard block
 block discarded – undo
2072 2079
 	/**
2073 2080
 	 * Gather the replyData and save it with the session, to be used then
2074 2081
 	 *
2075
-	 * @param $_mode can be:
2082
+	 * @param string $_mode can be:
2076 2083
 	 * 		single: for a reply to one address
2077 2084
 	 * 		all: for a reply to all
2078 2085
 	 * 		forward: inlineforwarding of a message with its attachments
@@ -3625,7 +3632,7 @@  discard block
 block discarded – undo
3625 3632
 	 * The results are limited to 10 each of group lists and normal lists
3626 3633
 	 *
3627 3634
 	 * @param String $_searchString
3628
-	 * @param Contacts $contacts_obj
3635
+	 * @param Api\Contacts $contacts_obj
3629 3636
 	 * @return array
3630 3637
 	 */
3631 3638
 	protected static function get_lists($_searchString, &$contacts_obj)
Please login to merge, or discard this patch.
Braces   +823 added lines, -275 removed lines patch added patch discarded remove patch
@@ -82,7 +82,10 @@  discard block
 block discarded – undo
82 82
 		{
83 83
 			$this->mailPreferences['message_forwarding'] = 'asmail';
84 84
 		}
85
-		if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail');
85
+		if (is_null(Mail::$mailConfig))
86
+		{
87
+			Mail::$mailConfig = Api\Config::read('mail');
88
+		}
86 89
 
87 90
 		$this->mailPreferences  =& $this->mail_bo->mailPreferences;
88 91
 	}
@@ -96,11 +99,21 @@  discard block
 block discarded – undo
96 99
 	{
97 100
 		if ($this->mail_bo->profileID!=$_icServerID)
98 101
 		{
99
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID);
102
+			if (Mail::$debug)
103
+			{
104
+				error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID);
105
+			}
100 106
 			$this->mail_bo = Mail::getInstance(false,$_icServerID);
101
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
107
+			if (Mail::$debug)
108
+			{
109
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
110
+			}
102 111
 			// no icServer Object: something failed big time
103
-			if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
112
+			if (!isset($this->mail_bo->icServer))
113
+			{
114
+				exit;
115
+			}
116
+			// ToDo: Exception or the dialog for setting up a server config
104 117
 			$this->mail_bo->openConnection($this->mail_bo->profileID);
105 118
 			$this->mailPreferences  =& $this->mail_bo->mailPreferences;
106 119
 		}
@@ -265,13 +278,17 @@  discard block
 block discarded – undo
265 278
 		{
266 279
 			foreach (array_keys($actions) as $key)
267 280
 			{
268
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
281
+				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' )))
282
+				{
269 283
 					$actions[$key]['toolbarDefault'] = false;
270 284
 				}
271 285
 			}
272 286
 			unset($actions['pgp']);
273 287
 		}
274
-		if ($GLOBALS['egw_info']['server']['disable_pgp_encryption']) unset($actions['pgp']);
288
+		if ($GLOBALS['egw_info']['server']['disable_pgp_encryption'])
289
+		{
290
+			unset($actions['pgp']);
291
+		}
275 292
 		// remove vfs actions if the user has no run access to filemanager
276 293
 		if (!$GLOBALS['egw_info']['user']['apps']['filemanager'])
277 294
 		{
@@ -292,7 +309,10 @@  discard block
 block discarded – undo
292 309
 	 */
293 310
 	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
294 311
 	{
295
-		if ($msg) Framework::message($msg);
312
+		if ($msg)
313
+		{
314
+			Framework::message($msg);
315
+		}
296 316
 
297 317
 		if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
298 318
 		{
@@ -328,7 +348,8 @@  discard block
 block discarded – undo
328 348
 				{
329 349
 					$_content['attachments'] = array_merge_recursive((array)$_content['attachments'], $attched_uids);
330 350
 				}
331
-			} catch (Exception $ex) {
351
+			}
352
+			catch (Exception $ex) {
332 353
 				Framework::message($ex->getMessage(), 'error');
333 354
 			}
334 355
 			$suppressSigOnTop = true;
@@ -336,8 +357,14 @@  discard block
 block discarded – undo
336 357
 			$_content['appendix_data'] = '';
337 358
 		}
338 359
 
339
-		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
340
-		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
360
+		if (isset($_GET['reply_id']))
361
+		{
362
+			$replyID = $_GET['reply_id'];
363
+		}
364
+		if (!$replyID && isset($_GET['id']))
365
+		{
366
+			$replyID = $_GET['id'];
367
+		}
341 368
 
342 369
 		// Process different places we can use as a start for composing an email
343 370
 		$actionToProcess = 'compose';
@@ -351,7 +378,10 @@  discard block
 block discarded – undo
351 378
 			));
352 379
 			if (Mail\Smime::get_acc_smime($this->mail_bo->profileID))
353 380
 			{
354
-				if (isset($_GET['smime_type'])) $smime_type = $_GET['smime_type'];
381
+				if (isset($_GET['smime_type']))
382
+				{
383
+					$smime_type = $_GET['smime_type'];
384
+				}
355 385
 				// pre set smime_sign and smime_encrypt actions if the original
356 386
 				// message is smime.
357 387
 				$_content['smime_sign'] = $smime_type == (Mail\Smime::TYPE_SIGN ||
@@ -414,7 +444,10 @@  discard block
 block discarded – undo
414 444
 			$suppressSigOnTop = true;
415 445
 			foreach ($_content['uploadForCompose'] as $i => &$upload)
416 446
 			{
417
-				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
447
+				if (!isset($upload['file']))
448
+				{
449
+					$upload['file'] = $upload['tmp_name'];
450
+				}
418 451
 				try
419 452
 				{
420 453
 					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
@@ -448,9 +481,15 @@  discard block
 block discarded – undo
448 481
 				$remove=false;
449 482
 				foreach(array_keys($toDelete) as $k)
450 483
 				{
451
-					if ($att['tmp_name']==$k) $remove=true;
484
+					if ($att['tmp_name']==$k)
485
+					{
486
+						$remove=true;
487
+					}
488
+				}
489
+				if (!$remove)
490
+				{
491
+					$_content['attachments'][] = $att;
452 492
 				}
453
-				if (!$remove) $_content['attachments'][] = $att;
454 493
 			}
455 494
 		}
456 495
 		// someone clicked something like send, or saveAsDraft
@@ -465,8 +504,7 @@  discard block
 block discarded – undo
465 504
 		//error_log(__METHOD__.__LINE__.array2string($_content));
466 505
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
467 506
 			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
468
-		)
469
-		{
507
+		) {
470 508
 			$this->changeProfile($_content['serverID']);
471 509
 			$composeProfile = $this->mail_bo->profileID;
472 510
 		}
@@ -546,7 +584,10 @@  discard block
 block discarded – undo
546 584
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
547 585
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
548 586
 							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
549
-							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
587
+							if (!empty($fhA['folder']))
588
+							{
589
+								$workingFolder = $fhA['folder'];
590
+							}
550 591
 						}
551 592
 					}
552 593
 					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
@@ -597,7 +638,10 @@  discard block
 block discarded – undo
597 638
 			}
598 639
 		}
599 640
 
600
-		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
641
+		if ($activeProfile != $composeProfile)
642
+		{
643
+			$this->changeProfile($activeProfile);
644
+		}
601 645
 		$insertSigOnTop = false;
602 646
 		$content = (is_array($_content)?$_content:array());
603 647
 		if ($_contentHasMimeType)
@@ -626,7 +670,10 @@  discard block
 block discarded – undo
626 670
 				{
627 671
 					foreach ($contentArr as $k =>&$elem)
628 672
 					{
629
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
673
+						if (stripos($elem,'<pre>')!==false)
674
+						{
675
+							$elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
676
+						}
630 677
 					}
631 678
 					$content['mail_htmltext'] = implode('',$contentArr);
632 679
 				}
@@ -668,8 +715,7 @@  discard block
 block discarded – undo
668 715
 		if ( !empty($content['body']) &&
669 716
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
670 717
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
671
-		)
672
-		{
718
+		) {
673 719
 			$buttonClicked = true;
674 720
 			$suppressSigOnTop = true;
675 721
 			if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount'])
@@ -685,7 +731,10 @@  discard block
 block discarded – undo
685 731
 				else
686 732
 				{
687 733
 					$newSig = $this->mail_bo->getDefaultIdentity();
688
-					if ($newSig === false) $newSig = -2;
734
+					if ($newSig === false)
735
+					{
736
+						$newSig = -2;
737
+					}
689 738
 				}
690 739
 			}
691 740
 			$_oldSig = $composeCache['mailidentity'];
@@ -693,7 +742,10 @@  discard block
 block discarded – undo
693 742
 
694 743
 			if ($_oldSig != $_signatureid)
695 744
 			{
696
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
745
+				if($this->_debug)
746
+				{
747
+					error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
748
+				}
697 749
 				// prepare signatures, the selected sig may be used on top of the body
698 750
 				try
699 751
 				{
@@ -723,7 +775,10 @@  discard block
 block discarded – undo
723 775
 				{
724 776
 					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
725 777
 					$sigText = $this->convertHTMLToText($sigText,true,true);
726
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
778
+					if($this->_debug)
779
+					{
780
+						error_log(__METHOD__." Old signature:".$oldSigText);
781
+					}
727 782
 				}
728 783
 
729 784
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -739,7 +794,11 @@  discard block
 block discarded – undo
739 794
 				{
740 795
 					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
741 796
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
742
-					if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags
797
+					if (stripos($content['body'],'style')!==false)
798
+					{
799
+						Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true);
800
+					}
801
+					// clean out empty or pagewide style definitions / left over tags
743 802
 				}
744 803
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
745 804
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -784,8 +843,14 @@  discard block
 block discarded – undo
784 843
 
785 844
 				if ($found === false)
786 845
 				{
787
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
788
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
846
+					if($this->_debug)
847
+					{
848
+						error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
849
+					}
850
+					if($this->_debug)
851
+					{
852
+						error_log(__METHOD__." Compare content:".$content['body']);
853
+					}
789 854
 				}
790 855
 				else
791 856
 				{
@@ -803,7 +868,10 @@  discard block
 block discarded – undo
803 868
 		$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
804 869
 
805 870
 		// do not double insert a signature on a server roundtrip
806
-		if ($buttonClicked) $suppressSigOnTop = true;
871
+		if ($buttonClicked)
872
+		{
873
+			$suppressSigOnTop = true;
874
+		}
807 875
 
808 876
 		// On submit reads external_vcard widget's value and addes them as attachments.
809 877
 		// this happens when we send vcards from addressbook to an opened compose
@@ -855,7 +923,8 @@  discard block
 block discarded – undo
855 923
 							}
856 924
 						}
857 925
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
858
-						foreach(array('subject','body','mimetype') as $name) {
926
+						foreach(array('subject','body','mimetype') as $name)
927
+						{
859 928
 							$sName = $name;
860 929
 							if ($name=='mimetype'&&$res[$name])
861 930
 							{
@@ -864,7 +933,10 @@  discard block
 block discarded – undo
864 933
 							}
865 934
 							else
866 935
 							{
867
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
936
+								if ($res[$name])
937
+								{
938
+									$content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
939
+								}
868 940
 							}
869 941
 						}
870 942
 					}
@@ -875,7 +947,8 @@  discard block
 block discarded – undo
875 947
 			{
876 948
 				$alreadyProcessed=array();
877 949
 				//_debug_array($_REQUEST);
878
-				if ($_REQUEST['preset']['mailto']) {
950
+				if ($_REQUEST['preset']['mailto'])
951
+				{
879 952
 					// handle mailto strings such as
880 953
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
881 954
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
@@ -883,10 +956,12 @@  discard block
 block discarded – undo
883 956
 					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
884 957
 					// check if there is more than the to address
885 958
 					$mailtoArray = explode('?',$tmp_send_to,2);
886
-					if ($mailtoArray[1]) {
959
+					if ($mailtoArray[1])
960
+					{
887 961
 						// check if there are more than one requests
888 962
 						$addRequests = explode('&',$mailtoArray[1]);
889
-						foreach ($addRequests as $key => $reqval) {
963
+						foreach ($addRequests as $key => $reqval)
964
+						{
890 965
 							// the additional requests should have a =, to separate key from value.
891 966
 							$reqval = preg_replace('/__AMPERSAND__/i', "&", $reqval);
892 967
 							$keyValuePair = explode('=',$reqval,2);
@@ -896,17 +971,24 @@  discard block
 block discarded – undo
896 971
 					$content['to']= preg_replace('/__AMPERSAND__/i', "&", $mailtoArray[0]);
897 972
 					$alreadyProcessed['to']='to';
898 973
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
899
-					foreach(array('cc','bcc','subject','body') as $name) {
974
+					foreach(array('cc','bcc','subject','body') as $name)
975
+					{
900 976
 						$alreadyProcessed[$name]=$name;
901
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
977
+						if ($_REQUEST[$name])
978
+						{
979
+							$content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
980
+						}
902 981
 					}
903 982
 				}
904 983
 
905
-				if ($_REQUEST['preset']['mailtocontactbyid']) {
906
-					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
984
+				if ($_REQUEST['preset']['mailtocontactbyid'])
985
+				{
986
+					if ($GLOBALS['egw_info']['user']['apps']['addressbook'])
987
+					{
907 988
 						$contacts_obj = new Api\Contacts();
908 989
 						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
909
-						if (method_exists($contacts_obj,'search')) {
990
+						if (method_exists($contacts_obj,'search'))
991
+						{
910 992
 
911 993
 							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
912 994
 							foreach ((array)$addressArray as $id => $addressID)
@@ -947,21 +1029,28 @@  discard block
 block discarded – undo
947 1029
 									unset($accounts);
948 1030
 								}
949 1031
 							}
950
-							if(is_array($contacts)) {
1032
+							if(is_array($contacts))
1033
+							{
951 1034
 								$mailtoArray = array();
952 1035
 								$primary = $addressbookprefs['distributionListPreferredMail'];
953
-								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
1036
+								if ($primary != 'email' && $primary != 'email_home')
1037
+								{
1038
+									$primary = 'email';
1039
+								}
954 1040
 								$secondary = ($primary == 'email'?'email_home':'email');
955 1041
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
956
-								foreach($contacts as $contact) {
1042
+								foreach($contacts as $contact)
1043
+								{
957 1044
 									$innerCounter=0;
958
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
1045
+									foreach(array($contact[$primary],$contact[$secondary]) as $email)
1046
+									{
959 1047
 										// use pref distributionListPreferredMail for the primary address
960 1048
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
961 1049
 										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
962 1050
 										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
963 1051
 										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
964
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
1052
+										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false)
1053
+										{
965 1054
 											$i++;
966 1055
 											$innerCounter++;
967 1056
 											$mailtoArray[$i] = $completeMailString;
@@ -995,7 +1084,10 @@  discard block
 block discarded – undo
995 1084
 							}
996 1085
 						}
997 1086
 					}
998
-					if(!empty($remember)) $content = array_merge($content,$remember);
1087
+					if(!empty($remember))
1088
+					{
1089
+						$content = array_merge($content,$remember);
1090
+					}
999 1091
 				}
1000 1092
 				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
1001 1093
 				{
@@ -1005,9 +1097,15 @@  discard block
 block discarded – undo
1005 1097
 						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
1006 1098
 					}
1007 1099
 					//skip if already processed by "preset Routines"
1008
-					if ($alreadyProcessed[$name]) continue;
1100
+					if ($alreadyProcessed[$name])
1101
+					{
1102
+						continue;
1103
+					}
1009 1104
 					//error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]);
1010
-					if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name];
1105
+					if ($_REQUEST['preset'][$name])
1106
+					{
1107
+						$content[$name] = $_REQUEST['preset'][$name];
1108
+					}
1011 1109
 				}
1012 1110
 			}
1013 1111
 			// is the to address set already?
@@ -1015,7 +1113,10 @@  discard block
 block discarded – undo
1015 1113
 			{
1016 1114
 				$content['to'] = base64_decode($_REQUEST['send_to']);
1017 1115
 				// first check if there is a questionmark or ampersand
1018
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1116
+				if (strpos($content['to'],'?')!== false)
1117
+				{
1118
+					list($content['to'],$rest) = explode('?',$content['to'],2);
1119
+				}
1019 1120
 				$content['to'] = html_entity_decode($content['to']);
1020 1121
 				if (($at_pos = strpos($content['to'],'@')) !== false)
1021 1122
 				{
@@ -1028,9 +1129,15 @@  discard block
 block discarded – undo
1028 1129
 						$content['to'] = $email;
1029 1130
 					}
1030 1131
 				}
1031
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1132
+				if (strpos($content['to'],'%40')!== false)
1133
+				{
1134
+					$content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1135
+				}
1032 1136
 				$rarr = array(Api\Html::purify($rest));
1033
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1137
+				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false)
1138
+				{
1139
+					$rarr = explode('&',$rest);
1140
+				}
1034 1141
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1035 1142
 				$karr = array();
1036 1143
 				foreach ($rarr as &$rval)
@@ -1046,9 +1153,15 @@  discard block
 block discarded – undo
1046 1153
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1047 1154
 				foreach(array('cc','bcc','subject','body') as $name)
1048 1155
 				{
1049
-					if ($karr[$name]) $content[$name] = $karr[$name];
1156
+					if ($karr[$name])
1157
+					{
1158
+						$content[$name] = $karr[$name];
1159
+					}
1160
+				}
1161
+				if (!empty($_REQUEST['subject']))
1162
+				{
1163
+					$content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1050 1164
 				}
1051
-				if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1052 1165
 			}
1053 1166
 		}
1054 1167
 		//error_log(__METHOD__.__LINE__.array2string($content));
@@ -1066,7 +1179,10 @@  discard block
 block discarded – undo
1066 1179
 				$_content['mimeType'] = $content['mimeType']  = 'html';
1067 1180
 				$content['body'] = "<pre>".$content['body']."</pre>";
1068 1181
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1069
-				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);
1182
+				if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1183
+				{
1184
+					$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1185
+				}
1070 1186
 			}
1071 1187
 		}
1072 1188
 		else
@@ -1086,7 +1202,10 @@  discard block
 block discarded – undo
1086 1202
 					$_content['mimeType'] = $content['mimeType']  = 'html';
1087 1203
 					$content['body'] = "<pre>".$content['body']."</pre>";
1088 1204
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1089
-					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);
1205
+					if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1206
+					{
1207
+						$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1208
+					}
1090 1209
 				}
1091 1210
 			}
1092 1211
 		}
@@ -1126,24 +1245,33 @@  discard block
 block discarded – undo
1126 1245
 			$disableRuler = true;
1127 1246
 		}
1128 1247
 		$font_span = $font_part = '';
1129
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1248
+		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/)
1249
+		{
1130 1250
 			// User preferences for style
1131 1251
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1132 1252
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1133 1253
 			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1134 1254
 			$font_span = $font_part.'&#8203;</span>';
1135
-			if (empty($font) && empty($font_size)) $font_span = '';
1255
+			if (empty($font) && empty($font_size))
1256
+			{
1257
+				$font_span = '';
1258
+			}
1136 1259
 		}
1137 1260
 		// 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
1138
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1261
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false)
1262
+		{
1263
+			$font_span = '';
1264
+		}
1139 1265
 		//remove possible html header stuff
1140
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1266
+		if (stripos($content['body'],'<html><head></head><body>')!==false)
1267
+		{
1268
+			$content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1269
+		}
1141 1270
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1142 1271
 		$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');
1143 1272
 		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1144 1273
 			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1145
-		)
1146
-		{
1274
+		) {
1147 1275
 			// ON tOP OR BELOW? pREF CAN TELL
1148 1276
 			/*
1149 1277
 				Signature behavior preference changed. New default, if not set -> 0
@@ -1158,14 +1286,23 @@  discard block
 block discarded – undo
1158 1286
 				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1159 1287
 				foreach($blockElements as $e)
1160 1288
 				{
1161
-					if ($sigTextStartsWithBlockElement) break;
1162
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1289
+					if ($sigTextStartsWithBlockElement)
1290
+					{
1291
+						break;
1292
+					}
1293
+					if (stripos(trim($sigText),'<'.$e)===0)
1294
+					{
1295
+						$sigTextStartsWithBlockElement = true;
1296
+					}
1163 1297
 				}
1164 1298
 			}
1165
-			if($content['mimeType'] == 'html') {
1299
+			if($content['mimeType'] == 'html')
1300
+			{
1166 1301
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1167 1302
 				$inbetween = '';
1168
-			} else {
1303
+			}
1304
+			else
1305
+			{
1169 1306
 				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1170 1307
 				$inbetween = "\r\n";
1171 1308
 			}
@@ -1199,7 +1336,10 @@  discard block
 block discarded – undo
1199 1336
 		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1200 1337
 		{
1201 1338
 			// do NOT add SMTP only accounts as identities
1202
-			if (!$account->is_imap(false)) continue;
1339
+			if (!$account->is_imap(false))
1340
+			{
1341
+				continue;
1342
+			}
1203 1343
 
1204 1344
 			foreach($account->identities($acc_id) as $ident_id => $identity)
1205 1345
 			{
@@ -1212,16 +1352,24 @@  discard block
 block discarded – undo
1212 1352
 		//$content['bcc'] = array('[email protected]','[email protected]');
1213 1353
 		// address stuff like from, to, cc, replyto
1214 1354
 		$destinationRows = 0;
1215
-		foreach(self::$destinations as $destination) {
1355
+		foreach(self::$destinations as $destination)
1356
+		{
1216 1357
 			if (!is_array($content[$destination]))
1217 1358
 			{
1218
-				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
1359
+				if (!empty($content[$destination]))
1360
+				{
1361
+					$content[$destination] = (array)$content[$destination];
1362
+				}
1219 1363
 			}
1220 1364
 			$addr_content = $content[strtolower($destination)];
1221 1365
 			// we clear the given address array and rebuild it
1222 1366
 			unset($content[strtolower($destination)]);
1223
-			foreach((array)$addr_content as $key => $value) {
1224
-				if ($value=="NIL@NIL") continue;
1367
+			foreach((array)$addr_content as $key => $value)
1368
+			{
1369
+				if ($value=="NIL@NIL")
1370
+				{
1371
+					continue;
1372
+				}
1225 1373
 				if ($destination=='replyto' && str_replace('"','',$value) ==
1226 1374
 					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1227 1375
 				{
@@ -1231,8 +1379,12 @@  discard block
 block discarded – undo
1231 1379
 				}
1232 1380
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1233 1381
 				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1234
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1235
-					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1382
+				foreach(Mail::parseAddressList($value) as $addressObject)
1383
+				{
1384
+					if ($addressObject->host == '.SYNTAX-ERROR.')
1385
+					{
1386
+						continue;
1387
+					}
1236 1388
 					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1237 1389
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1238 1390
 					$content[strtolower($destination)][]=$address;
@@ -1243,11 +1395,20 @@  discard block
 block discarded – undo
1243 1395
 		if ($_content)
1244 1396
 		{
1245 1397
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1246
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1398
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content))
1399
+			{
1400
+				unset($_content['mailidentity']);
1401
+			}
1247 1402
 			$content = array_merge($content,$_content);
1248 1403
 
1249
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1250
-			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1404
+			if (!empty($content['folder']))
1405
+			{
1406
+				$sel_options['folder']=$this->ajax_searchFolder(0,true);
1407
+			}
1408
+			if (empty($content['mailaccount']))
1409
+			{
1410
+				$content['mailaccount'] = $this->mail_bo->profileID;
1411
+			}
1251 1412
 		}
1252 1413
 		else
1253 1414
 		{
@@ -1290,11 +1451,17 @@  discard block
 block discarded – undo
1290 1451
 		//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
1291 1452
 		$preserv['is_html'] = $content['is_html'];
1292 1453
 		$preserv['is_plain'] = $content['is_plain'];
1293
-		if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
1454
+		if (isset($content['mimeType']))
1455
+		{
1456
+			$preserv['mimeType'] = $content['mimeType'];
1457
+		}
1294 1458
 		$sel_options['mimeType'] = self::$mimeTypes;
1295 1459
 		$sel_options['priority'] = self::$priorities;
1296 1460
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1297
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1461
+		if (!isset($content['priority']) || empty($content['priority']))
1462
+		{
1463
+			$content['priority']=3;
1464
+		}
1298 1465
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1299 1466
 		$etpl = new Etemplate('mail.compose');
1300 1467
 
@@ -1341,9 +1508,12 @@  discard block
 block discarded – undo
1341 1508
 		$preserv['list-id'] = $content['list-id'];
1342 1509
 		$preserv['mode'] = $content['mode'];
1343 1510
 		// convert it back to checkbox expectations
1344
-		if($content['mimeType'] == 'html') {
1511
+		if($content['mimeType'] == 'html')
1512
+		{
1345 1513
 			$content['mimeType']=1;
1346
-		} else {
1514
+		}
1515
+		else
1516
+		{
1347 1517
 			$content['mimeType']=0;
1348 1518
 		}
1349 1519
 		// set the current selected mailaccount as param for folderselection
@@ -1368,7 +1538,10 @@  discard block
 block discarded – undo
1368 1538
 		// Resolve distribution list before send content to client
1369 1539
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1370 1540
 		{
1371
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1541
+			if (is_array($content[$f]))
1542
+			{
1543
+				$content[$f]= self::resolveEmailAddressList ($content[$f]);
1544
+			}
1372 1545
 		}
1373 1546
 
1374 1547
 		$content['to'] = self::resolveEmailAddressList($content['to']);
@@ -1511,7 +1684,10 @@  discard block
 block discarded – undo
1511 1684
 				case 'composefromdraft':
1512 1685
 				case 'composeasnew':
1513 1686
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1514
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1687
+					if ($from =='composefromdraft')
1688
+					{
1689
+						$content['mode'] = 'composefromdraft';
1690
+					}
1515 1691
 					$content['processedmail_id'] = $mail_id;
1516 1692
 
1517 1693
 					$_focusElement = 'body';
@@ -1559,7 +1735,10 @@  discard block
 block discarded – undo
1559 1735
 			$document_merge = new $merge_class();
1560 1736
 			$this->mail_bo->openConnection();
1561 1737
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1562
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1738
+			if (!is_array($merge_ids))
1739
+			{
1740
+				$merge_ids = explode(',',$merge_ids);
1741
+			}
1563 1742
 			try
1564 1743
 			{
1565 1744
 				$merged_mail_id = '';
@@ -1590,7 +1769,10 @@  discard block
 block discarded – undo
1590 1769
 				{
1591 1770
 					$success = implode(', ',$results['success']);
1592 1771
 					$fail = implode(', ', $results['failed']);
1593
-					if($success) Framework::message($success, 'success');
1772
+					if($success)
1773
+					{
1774
+						Framework::message($success, 'success');
1775
+					}
1594 1776
 					Framework::window_close($fail);
1595 1777
 				}
1596 1778
 			}
@@ -1622,17 +1804,25 @@  discard block
 block discarded – undo
1622 1804
 	{
1623 1805
 		$stripalltags = true;
1624 1806
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1625
-		if (!$sourceishtml) $stripalltags=false;
1807
+		if (!$sourceishtml)
1808
+		{
1809
+			$stripalltags=false;
1810
+		}
1626 1811
 		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags, $noRepEmailAddr);
1627 1812
 	}
1628 1813
 
1629 1814
 	function generateRFC822Address($_addressObject)
1630 1815
 	{
1631
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1816
+		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host)
1817
+		{
1632 1818
 			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1633
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1819
+		}
1820
+		elseif($_addressObject->mailbox && $_addressObject->host)
1821
+		{
1634 1822
 			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1635
-		} else {
1823
+		}
1824
+		else
1825
+		{
1636 1826
 			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1637 1827
 		}
1638 1828
 	}
@@ -1666,16 +1856,28 @@  discard block
 block discarded – undo
1666 1856
 		//if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC'];
1667 1857
 
1668 1858
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1669
-		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1670
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1859
+		if (!empty($addHeadInfo['X-MAILFOLDER']))
1860
+		{
1861
+			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val )
1862
+			{
1671 1863
 				$fval=$val;
1672 1864
 				$icServerID = $mail_bo->icServer->ImapServerId;
1673
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1674
-				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1675
-				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1865
+				if (stripos($val,'::')!==false)
1866
+				{
1867
+					list($icServerID,$fval) = explode('::',$val,2);
1868
+				}
1869
+				if ($icServerID != $mail_bo->icServer->ImapServerId)
1870
+				{
1871
+					continue;
1872
+				}
1873
+				if ($mail_bo->folderExists($fval))
1874
+				{
1875
+					$this->sessionData['folder'][] = $val;
1876
+				}
1676 1877
 			}
1677 1878
 		}
1678
-		if (!empty($addHeadInfo['X-MAILIDENTITY'])) {
1879
+		if (!empty($addHeadInfo['X-MAILIDENTITY']))
1880
+		{
1679 1881
 			// with the new system it would be the identity
1680 1882
 			try
1681 1883
 			{
@@ -1691,7 +1893,8 @@  discard block
 block discarded – undo
1691 1893
 			$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
1692 1894
 		}
1693 1895
 		*/
1694
-		if (!empty($addHeadInfo['X-MAILACCOUNT'])) {
1896
+		if (!empty($addHeadInfo['X-MAILACCOUNT']))
1897
+		{
1695 1898
 			// with the new system it would the identity is the account id
1696 1899
 			try
1697 1900
 			{
@@ -1706,27 +1909,38 @@  discard block
 block discarded – undo
1706 1909
 			}
1707 1910
 		}
1708 1911
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1709
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1912
+		if ($mail_bo->isDraftFolder($_folder))
1913
+		{
1914
+			$this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);
1915
+		}
1916
+		//array('uid'=>$_uid,'folder'=>$_folder);
1710 1917
 		$this->sessionData['uid'] = $_uid;
1711 1918
 		$this->sessionData['messageFolder'] = $_folder;
1712 1919
 		$this->sessionData['isDraft'] = true;
1713 1920
 		$foundAddresses = array();
1714
-		foreach((array)$headers['CC'] as $val) {
1921
+		foreach((array)$headers['CC'] as $val)
1922
+		{
1715 1923
 			$rfcAddr=Mail::parseAddressList($val);
1716 1924
 			$_rfcAddr = $rfcAddr[0];
1717
-			if (!$_rfcAddr->valid) continue;
1718
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1925
+			if (!$_rfcAddr->valid)
1926
+			{
1927
+				continue;
1928
+			}
1929
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1930
+			{
1719 1931
 				continue;
1720 1932
 			}
1721 1933
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1722
-			if(!$foundAddresses[$keyemail]) {
1934
+			if(!$foundAddresses[$keyemail])
1935
+			{
1723 1936
 				$address = $this->mail_bo->decode_header($val,true);
1724 1937
 				$this->sessionData['cc'][] = $val;
1725 1938
 				$foundAddresses[$keyemail] = true;
1726 1939
 			}
1727 1940
 		}
1728 1941
 
1729
-		foreach((array)$headers['TO'] as $val) {
1942
+		foreach((array)$headers['TO'] as $val)
1943
+		{
1730 1944
 			if(!is_array($val))
1731 1945
 			{
1732 1946
 				$this->sessionData['to'][] = $val;
@@ -1734,12 +1948,17 @@  discard block
 block discarded – undo
1734 1948
 			}
1735 1949
 			$rfcAddr=Mail::parseAddressList($val);
1736 1950
 			$_rfcAddr = $rfcAddr[0];
1737
-			if (!$_rfcAddr->valid) continue;
1738
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1951
+			if (!$_rfcAddr->valid)
1952
+			{
1953
+				continue;
1954
+			}
1955
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1956
+			{
1739 1957
 				continue;
1740 1958
 			}
1741 1959
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1742
-			if(!$foundAddresses[$keyemail]) {
1960
+			if(!$foundAddresses[$keyemail])
1961
+			{
1743 1962
 				$address = $this->mail_bo->decode_header($val,true);
1744 1963
 				$this->sessionData['to'][] = $val;
1745 1964
 				$foundAddresses[$keyemail] = true;
@@ -1747,30 +1966,42 @@  discard block
 block discarded – undo
1747 1966
 		}
1748 1967
 
1749 1968
 		$fromAddr = Mail::parseAddressList($addHeadInfo['FROM'])[0];
1750
-		foreach((array)$headers['REPLY-TO'] as $val) {
1969
+		foreach((array)$headers['REPLY-TO'] as $val)
1970
+		{
1751 1971
 			$rfcAddr=Mail::parseAddressList($val);
1752 1972
 			$_rfcAddr = $rfcAddr[0];
1753
-			if (!$_rfcAddr->valid || ($_rfcAddr->mailbox == $fromAddr->mailbox && $_rfcAddr->host == $fromAddr->host)) continue;
1754
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1973
+			if (!$_rfcAddr->valid || ($_rfcAddr->mailbox == $fromAddr->mailbox && $_rfcAddr->host == $fromAddr->host))
1974
+			{
1975
+				continue;
1976
+			}
1977
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1978
+			{
1755 1979
 				continue;
1756 1980
 			}
1757 1981
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1758
-			if(!$foundAddresses[$keyemail]) {
1982
+			if(!$foundAddresses[$keyemail])
1983
+			{
1759 1984
 				$address = $this->mail_bo->decode_header($val,true);
1760 1985
 				$this->sessionData['replyto'][] = $val;
1761 1986
 				$foundAddresses[$keyemail] = true;
1762 1987
 			}
1763 1988
 		}
1764 1989
 
1765
-		foreach((array)$headers['BCC'] as $val) {
1990
+		foreach((array)$headers['BCC'] as $val)
1991
+		{
1766 1992
 			$rfcAddr=Mail::parseAddressList($val);
1767 1993
 			$_rfcAddr = $rfcAddr[0];
1768
-			if (!$_rfcAddr->valid) continue;
1769
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1994
+			if (!$_rfcAddr->valid)
1995
+			{
1996
+				continue;
1997
+			}
1998
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1999
+			{
1770 2000
 				continue;
1771 2001
 			}
1772 2002
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1773
-			if(!$foundAddresses[$keyemail]) {
2003
+			if(!$foundAddresses[$keyemail])
2004
+			{
1774 2005
 				$address = $this->mail_bo->decode_header($val,true);
1775 2006
 				$this->sessionData['bcc'][] = $val;
1776 2007
 				$foundAddresses[$keyemail] = true;
@@ -1784,32 +2015,46 @@  discard block
 block discarded – undo
1784 2015
 		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1785 2016
 		//_debug_array($bodyParts);
1786 2017
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1787
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2018
+		if($bodyParts['0']['mimeType'] == 'text/html')
2019
+		{
1788 2020
 			$this->sessionData['mimeType'] 	= 'html';
1789 2021
 
1790
-			for($i=0; $i<count($bodyParts); $i++) {
1791
-				if($i>0) {
2022
+			for($i=0; $i<count($bodyParts); $i++)
2023
+			{
2024
+				if($i>0)
2025
+				{
1792 2026
 					$this->sessionData['body'] .= '<hr>';
1793 2027
 				}
1794
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2028
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2029
+				{
1795 2030
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1796 2031
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1797 2032
 				}
1798
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2033
+				if ($bodyParts[$i]['charSet']===false)
2034
+				{
2035
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2036
+				}
1799 2037
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1800 2038
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1801 2039
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1802 2040
 			}
1803 2041
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1804 2042
 
1805
-		} else {
2043
+		}
2044
+		else
2045
+		{
1806 2046
 			$this->sessionData['mimeType']	= 'plain';
1807 2047
 
1808
-			for($i=0; $i<count($bodyParts); $i++) {
1809
-				if($i>0) {
2048
+			for($i=0; $i<count($bodyParts); $i++)
2049
+			{
2050
+				if($i>0)
2051
+				{
1810 2052
 					$this->sessionData['body'] .= "<hr>";
1811 2053
 				}
1812
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2054
+				if ($bodyParts[$i]['charSet']===false)
2055
+				{
2056
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2057
+				}
1813 2058
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1814 2059
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1815 2060
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
@@ -1817,8 +2062,10 @@  discard block
 block discarded – undo
1817 2062
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1818 2063
 		}
1819 2064
 
1820
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1821
-			foreach($attachments as $attachment) {
2065
+		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
2066
+		{
2067
+			foreach($attachments as $attachment)
2068
+			{
1822 2069
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1823 2070
 				$cid = $attachment['cid'];
1824 2071
 				$match=null;
@@ -1841,7 +2088,8 @@  discard block
 block discarded – undo
1841 2088
 
1842 2089
 	function getErrorInfo()
1843 2090
 	{
1844
-		if(isset($this->errorInfo)) {
2091
+		if(isset($this->errorInfo))
2092
+		{
1845 2093
 			$errorInfo = $this->errorInfo;
1846 2094
 			unset($this->errorInfo);
1847 2095
 			return $errorInfo;
@@ -1856,7 +2104,8 @@  discard block
 block discarded – undo
1856 2104
 			$modebuff = $this->mailPreferences['message_forwarding'];
1857 2105
 			$this->mailPreferences['message_forwarding'] = $_mode;
1858 2106
 		}
1859
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
2107
+		if  ($this->mailPreferences['message_forwarding'] == 'inline')
2108
+		{
1860 2109
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1861 2110
 		}
1862 2111
 		$mail_bo    = $this->mail_bo;
@@ -1873,12 +2122,16 @@  discard block
 block discarded – undo
1873 2122
 		//$this->sessionData['sourceFolder']=$_folder;
1874 2123
 		//$this->sessionData['forwardFlag']='forwarded';
1875 2124
 		//$this->sessionData['forwardedUID']=$_uid;
1876
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
2125
+		if  ($this->mailPreferences['message_forwarding'] == 'asmail')
2126
+		{
1877 2127
 			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1878 2128
 			if($headers['SIZE'])
1879
-				$size				= $headers['SIZE'];
1880
-			else
1881
-				$size				= lang('unknown');
2129
+			{
2130
+							$size				= $headers['SIZE'];
2131
+			}
2132
+			else {
2133
+							$size				= lang('unknown');
2134
+			}
1882 2135
 
1883 2136
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1884 2137
 				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
@@ -1891,9 +2144,11 @@  discard block
 block discarded – undo
1891 2144
 			unset($this->sessionData['cc']);
1892 2145
 			try
1893 2146
 			{
1894
-				if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
2147
+				if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false)))
2148
+				{
1895 2149
 					//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1896
-					foreach($attachments as $attachment) {
2150
+					foreach($attachments as $attachment)
2151
+					{
1897 2152
 						if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1898 2153
 						{
1899 2154
 							$this->addMessageAttachment($_uid, $attachment['partID'],
@@ -1959,7 +2214,10 @@  discard block
 block discarded – undo
1959 2214
 			{
1960 2215
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1961 2216
 					strtolower($_formData['type'])== strtolower($attach['type']) &&
1962
-					stripos($_formData['file'],'vfs://') !== false) return;
2217
+					stripos($_formData['file'],'vfs://') !== false)
2218
+				{
2219
+					return;
2220
+				}
1963 2221
 			}
1964 2222
 		}
1965 2223
 		if ($attachfailed === false)
@@ -1971,7 +2229,10 @@  discard block
 block discarded – undo
1971 2229
 				'tmp_name'	=> $tmpFileName,
1972 2230
 				'size'	=> $_formData['size']
1973 2231
 			);
1974
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
2232
+			if (!is_array($_content['attachments']))
2233
+			{
2234
+				$_content['attachments']=array();
2235
+			}
1975 2236
 			$_content['attachments'][] = $buffer;
1976 2237
 			unset($buffer);
1977 2238
 		}
@@ -2002,7 +2263,10 @@  discard block
 block discarded – undo
2002 2263
 		{
2003 2264
 			foreach($request->preserv['attachments'] as $attachment)
2004 2265
 			{
2005
-				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2266
+				if ($_GET['tmpname'] === $attachment['tmp_name'])
2267
+				{
2268
+					break;
2269
+				}
2006 2270
 			}
2007 2271
 		}
2008 2272
 		if (!$request || $_GET['tmpname'] !== $attachment['tmp_name'])
@@ -2036,10 +2300,20 @@  discard block
 block discarded – undo
2036 2300
 				$sfxMimeType = $attachment['type'];
2037 2301
 				$buff = explode('.',$attachment['tmp_name']);
2038 2302
 				$suffix = '';
2039
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2040
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2303
+				if (is_array($buff))
2304
+				{
2305
+					$suffix = array_pop($buff);
2306
+				}
2307
+				// take the last extension to check with ext2mime
2308
+				if (!empty($suffix))
2309
+				{
2310
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2311
+				}
2041 2312
 				$attachment['type'] = $sfxMimeType;
2042
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2313
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2314
+				{
2315
+					$attachment['type'] = strtoupper($sfxMimeType);
2316
+				}
2043 2317
 			}
2044 2318
 			//error_log(__METHOD__.print_r($attachment,true));
2045 2319
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2048,7 +2322,10 @@  discard block
 block discarded – undo
2048 2322
 				$calendar_ical = new calendar_ical();
2049 2323
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2050 2324
 				//error_log(__METHOD__.array2string($eventid));
2051
-				if (!$eventid) $eventid = -1;
2325
+				if (!$eventid)
2326
+				{
2327
+					$eventid = -1;
2328
+				}
2052 2329
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
2053 2330
 				//error_log(__METHOD__.$event);
2054 2331
 				if ((int)$event > 0)
@@ -2074,7 +2351,10 @@  discard block
 block discarded – undo
2074 2351
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2075 2352
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2076 2353
 				}
2077
-				if (!$contact) $contact = null;
2354
+				if (!$contact)
2355
+				{
2356
+					$contact = null;
2357
+				}
2078 2358
 				// 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))
2079 2359
 				if ($contact || count($vcard)>2)
2080 2360
 				{
@@ -2105,7 +2385,8 @@  discard block
 block discarded – undo
2105 2385
 	 * @param string haystack
2106 2386
 	 * @return boolean
2107 2387
 	 */
2108
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2388
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack)
2389
+	{
2109 2390
 		foreach (array_keys($arrayToTestAgainst) as $k)
2110 2391
 		{
2111 2392
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
@@ -2162,21 +2443,34 @@  discard block
 block discarded – undo
2162 2443
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
2163 2444
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
2164 2445
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
2165
-		if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2166
-		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2446
+		if ($headers['THREAD-INDEX'])
2447
+		{
2448
+			$this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2449
+		}
2450
+		if ($headers['LIST-ID'])
2451
+		{
2452
+			$this->sessionData['list-id'] = $headers['LIST-ID'];
2453
+		}
2167 2454
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2168 2455
 		// check for Reply-To: header and use if available
2169
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2170
-			foreach($headers['REPLY-TO'] as $val) {
2171
-				if(!$foundAddresses[$val]) {
2456
+		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM']))
2457
+		{
2458
+			foreach($headers['REPLY-TO'] as $val)
2459
+			{
2460
+				if(!$foundAddresses[$val])
2461
+				{
2172 2462
 					$oldTo[] = $val;
2173 2463
 					$foundAddresses[$val] = true;
2174 2464
 				}
2175 2465
 			}
2176 2466
 			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2177
-		} else {
2178
-			foreach($headers['FROM'] as $val) {
2179
-				if(!$foundAddresses[$val]) {
2467
+		}
2468
+		else
2469
+		{
2470
+			foreach($headers['FROM'] as $val)
2471
+			{
2472
+				if(!$foundAddresses[$val])
2473
+				{
2180 2474
 					$oldTo[] = $val;
2181 2475
 					$foundAddresses[$val] = true;
2182 2476
 				}
@@ -2184,18 +2478,23 @@  discard block
 block discarded – undo
2184 2478
 			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2185 2479
 		}
2186 2480
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2187
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2481
+		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) )
2482
+		{
2188 2483
 			$this->sessionData['to'] = $oldTo;
2189 2484
 		}
2190 2485
 
2191
-		if($_mode == 'all') {
2486
+		if($_mode == 'all')
2487
+		{
2192 2488
 			// reply to any address which is cc, but not to my self
2193 2489
 			#if($headers->cc) {
2194
-				foreach($headers['CC'] as $val) {
2195
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2490
+				foreach($headers['CC'] as $val)
2491
+				{
2492
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2493
+					{
2196 2494
 						continue;
2197 2495
 					}
2198
-					if(!$foundAddresses[$val]) {
2496
+					if(!$foundAddresses[$val])
2497
+					{
2199 2498
 						$this->sessionData['cc'][] = $val;
2200 2499
 						$foundAddresses[$val] = true;
2201 2500
 					}
@@ -2204,11 +2503,14 @@  discard block
 block discarded – undo
2204 2503
 
2205 2504
 			// reply to any address which is to, but not to my self
2206 2505
 			#if($headers->to) {
2207
-				foreach($headers['TO'] as $val) {
2208
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2506
+				foreach($headers['TO'] as $val)
2507
+				{
2508
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2509
+					{
2209 2510
 						continue;
2210 2511
 					}
2211
-					if(!$foundAddresses[$val]) {
2512
+					if(!$foundAddresses[$val])
2513
+					{
2212 2514
 						$this->sessionData['to'][] = $val;
2213 2515
 						$foundAddresses[$val] = true;
2214 2516
 					}
@@ -2216,12 +2518,15 @@  discard block
 block discarded – undo
2216 2518
 			#}
2217 2519
 
2218 2520
 			#if($headers->from) {
2219
-				foreach($headers['FROM'] as $val) {
2220
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2521
+				foreach($headers['FROM'] as $val)
2522
+				{
2523
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2524
+					{
2221 2525
 						continue;
2222 2526
 					}
2223 2527
 					//error_log(__METHOD__.__LINE__.' '.$val);
2224
-					if(!$foundAddresses[$val]) {
2528
+					if(!$foundAddresses[$val])
2529
+					{
2225 2530
 						$this->sessionData['to'][] = $val;
2226 2531
 						$foundAddresses[$val] = true;
2227 2532
 					}
@@ -2230,9 +2535,12 @@  discard block
 block discarded – undo
2230 2535
 		}
2231 2536
 
2232 2537
 		// check for Re: in subject header
2233
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2538
+		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:")
2539
+		{
2234 2540
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2235
-		} else {
2541
+		}
2542
+		else
2543
+		{
2236 2544
 			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2237 2545
 		}
2238 2546
 
@@ -2258,7 +2566,8 @@  discard block
 block discarded – undo
2258 2566
 
2259 2567
 		$toAddressA = array();
2260 2568
 		$toAddress = '';
2261
-		foreach ($headers['TO'] as $mailheader) {
2569
+		foreach ($headers['TO'] as $mailheader)
2570
+		{
2262 2571
 			$toAddressA[] =  $mailheader;
2263 2572
 		}
2264 2573
 		if (count($toAddressA)>0)
@@ -2268,7 +2577,8 @@  discard block
 block discarded – undo
2268 2577
 		}
2269 2578
 		$ccAddressA = array();
2270 2579
 		$ccAddress = '';
2271
-		foreach ($headers['CC'] as $mailheader) {
2580
+		foreach ($headers['CC'] as $mailheader)
2581
+		{
2272 2582
 			$ccAddressA[] =  $mailheader;
2273 2583
 		}
2274 2584
 		if (count($ccAddressA)>0)
@@ -2276,25 +2586,35 @@  discard block
 block discarded – undo
2276 2586
 			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2277 2587
 			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2278 2588
 		}
2279
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2589
+		if($bodyParts['0']['mimeType'] == 'text/html')
2590
+		{
2280 2591
 			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2281 2592
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2282 2593
 				$toAddress.$ccAddress.
2283 2594
 				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2284 2595
 				'----------------------------------------------------------'."</div>";
2285 2596
 			$this->sessionData['mimeType'] 	= 'html';
2286
-			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2597
+			if (!empty($styles))
2598
+			{
2599
+				$this->sessionData['body'] .= $styles;
2600
+			}
2287 2601
 			$this->sessionData['body']	.= '<blockquote type="cite">';
2288 2602
 
2289
-			for($i=0; $i<count($bodyParts); $i++) {
2290
-				if($i>0) {
2603
+			for($i=0; $i<count($bodyParts); $i++)
2604
+			{
2605
+				if($i>0)
2606
+				{
2291 2607
 					$this->sessionData['body'] .= '<hr>';
2292 2608
 				}
2293
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2609
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2610
+				{
2294 2611
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2295 2612
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2296 2613
 				}
2297
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2614
+				if ($bodyParts[$i]['charSet']===false)
2615
+				{
2616
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2617
+				}
2298 2618
 
2299 2619
 				$_htmlConfig = Mail::$htmLawed_config;
2300 2620
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2306,7 +2626,9 @@  discard block
 block discarded – undo
2306 2626
 
2307 2627
 			$this->sessionData['body']	.= '</blockquote><br>';
2308 2628
 			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2309
-		} else {
2629
+		}
2630
+		else
2631
+		{
2310 2632
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2311 2633
 			// 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)
2312 2634
             $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
@@ -2316,8 +2638,10 @@  discard block
 block discarded – undo
2316 2638
                 '-------------------------------------------------'."\r\n \r\n ";
2317 2639
 			$this->sessionData['mimeType']	= 'plain';
2318 2640
 
2319
-			for($i=0; $i<count($bodyParts); $i++) {
2320
-				if($i>0) {
2641
+			for($i=0; $i<count($bodyParts); $i++)
2642
+			{
2643
+				if($i>0)
2644
+				{
2321 2645
 					$this->sessionData['body'] .= "<hr>";
2322 2646
 				}
2323 2647
 
@@ -2328,7 +2652,8 @@  discard block
 block discarded – undo
2328 2652
 				$this->sessionData['body'] .= "\r\n";
2329 2653
 				$hasSignature = false;
2330 2654
 				// create body new, with good line breaks and indention
2331
-				foreach(explode("\n",$newBody) as $value) {
2655
+				foreach(explode("\n",$newBody) as $value)
2656
+				{
2332 2657
 					// the explode is removing the character
2333 2658
 					//$value .= 'ee';
2334 2659
 
@@ -2344,9 +2669,12 @@  discard block
 block discarded – undo
2344 2669
 
2345 2670
 					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2346 2671
 
2347
-					if($bodyAppend[0] == '>') {
2672
+					if($bodyAppend[0] == '>')
2673
+					{
2348 2674
 						$bodyAppend = '>'. $bodyAppend;
2349
-					} else {
2675
+					}
2676
+					else
2677
+					{
2350 2678
 						$bodyAppend = '> '. $bodyAppend;
2351 2679
 					}
2352 2680
 
@@ -2395,9 +2723,12 @@  discard block
 block discarded – undo
2395 2723
 
2396 2724
 	static function _getHostName()
2397 2725
 	{
2398
-		if (isset($_SERVER['SERVER_NAME'])) {
2726
+		if (isset($_SERVER['SERVER_NAME']))
2727
+		{
2399 2728
 			$result = $_SERVER['SERVER_NAME'];
2400
-		} else {
2729
+		}
2730
+		else
2731
+		{
2401 2732
 			$result = 'localhost.localdomain';
2402 2733
 		}
2403 2734
 		return $result;
@@ -2435,11 +2766,16 @@  discard block
 block discarded – undo
2435 2766
 
2436 2767
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2437 2768
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2438
-		if(!empty($_formData['in-reply-to'])) {
2439
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2769
+		if(!empty($_formData['in-reply-to']))
2770
+		{
2771
+			if (stripos($_formData['in-reply-to'],'<')===false)
2772
+			{
2773
+				$_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2774
+			}
2440 2775
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2441 2776
 		}
2442
-		if(!empty($_formData['references'])) {
2777
+		if(!empty($_formData['references']))
2778
+		{
2443 2779
 			if (stripos($_formData['references'],'<')===false)
2444 2780
 			{
2445 2781
 				$_formData['references']='<'.trim($_formData['references']).'>';
@@ -2447,28 +2783,38 @@  discard block
 block discarded – undo
2447 2783
 			$_mailObject->addHeader('References', $_formData['references']);
2448 2784
 		}
2449 2785
 
2450
-		if(!empty($_formData['thread-index'])) {
2786
+		if(!empty($_formData['thread-index']))
2787
+		{
2451 2788
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2452 2789
 		}
2453
-		if(!empty($_formData['list-id'])) {
2790
+		if(!empty($_formData['list-id']))
2791
+		{
2454 2792
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2455 2793
 		}
2456
-		if($_formData['disposition']=='on') {
2794
+		if($_formData['disposition']=='on')
2795
+		{
2457 2796
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2458 2797
 		}
2459 2798
 
2460 2799
 		// Expand any mailing lists
2461 2800
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2462 2801
 		{
2463
-			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2802
+			if ($field != 'replyto')
2803
+			{
2804
+				$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2805
+			}
2464 2806
 
2465
-			if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field);
2807
+			if ($_formData[$field])
2808
+			{
2809
+				$_mailObject->addAddress($_formData[$field], '', $field);
2810
+			}
2466 2811
 		}
2467 2812
 
2468 2813
 		$_mailObject->addHeader('Subject', $_formData['subject']);
2469 2814
 
2470 2815
 		// this should never happen since we come from the edit dialog
2471
-		if (Mail::detect_qp($_formData['body'])) {
2816
+		if (Mail::detect_qp($_formData['body']))
2817
+		{
2472 2818
 			$_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']);
2473 2819
 			$_formData['body'] = quoted_printable_decode($_formData['body']);
2474 2820
 		}
@@ -2522,7 +2868,10 @@  discard block
 block discarded – undo
2522 2868
 					$_mailObject->setBody($this->convertHTMLToText($body, true, true));
2523 2869
 				}
2524 2870
 				// convert URL Images to inline images - if possible
2525
-				if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2871
+				if (!$_autosaving)
2872
+				{
2873
+					$inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2874
+				}
2526 2875
 				if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2527 2876
 				{
2528 2877
 					$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@@ -2535,10 +2884,14 @@  discard block
 block discarded – undo
2535 2884
 			default:
2536 2885
 				$body = $this->convertHTMLToText($_formData['body'],false, false, true, true);
2537 2886
 
2538
-				if ($attachment_links) $body .= $attachment_links;
2887
+				if ($attachment_links)
2888
+				{
2889
+					$body .= $attachment_links;
2890
+				}
2539 2891
 
2540 2892
 				#$_mailObject->Body = $_formData['body'];
2541
-				if(!empty($signature)) {
2893
+				if(!empty($signature))
2894
+				{
2542 2895
 					$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2543 2896
 						$this->convertHTMLToText($signature,true,true);
2544 2897
 				}
@@ -2549,10 +2902,12 @@  discard block
 block discarded – undo
2549 2902
 		{
2550 2903
 			$connection_opened = false;
2551 2904
 			$tnfattachments = null;
2552
-			foreach((array)$_formData['attachments'] as $attachment) {
2905
+			foreach((array)$_formData['attachments'] as $attachment)
2906
+			{
2553 2907
 				if(is_array($attachment))
2554 2908
 				{
2555
-					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2909
+					if (!empty($attachment['uid']) && !empty($attachment['folder']))
2910
+					{
2556 2911
 						/* Example:
2557 2912
 						Array([0] => Array(
2558 2913
 						[uid] => 21178
@@ -2568,14 +2923,18 @@  discard block
 block discarded – undo
2568 2923
 							$connection_opened = true;
2569 2924
 						}
2570 2925
 						$mail_bo->reopen($attachment['folder']);
2571
-						switch(strtoupper($attachment['type'])) {
2926
+						switch(strtoupper($attachment['type']))
2927
+						{
2572 2928
 							case 'MESSAGE/RFC':
2573 2929
 							case 'MESSAGE/RFC822':
2574 2930
 								$rawBody='';
2575
-								if (isset($attachment['partID'])) {
2931
+								if (isset($attachment['partID']))
2932
+								{
2576 2933
 									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2577 2934
 									$rawBody=$eml['attachment'];
2578
-								} else {
2935
+								}
2936
+								else
2937
+								{
2579 2938
 									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2580 2939
 								}
2581 2940
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
@@ -2584,7 +2943,10 @@  discard block
 block discarded – undo
2584 2943
 								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2585 2944
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2586 2945
 								{
2587
-									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2946
+									if (!is_array($tnfattachments))
2947
+									{
2948
+										$tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2949
+									}
2588 2950
 									foreach ($tnfattachments as $k)
2589 2951
 									{
2590 2952
 										if ($k['name'] == $attachment['name'])
@@ -2619,7 +2981,10 @@  discard block
 block discarded – undo
2619 2981
 					}
2620 2982
 				}
2621 2983
 			}
2622
-			if ($connection_opened) $mail_bo->closeConnection();
2984
+			if ($connection_opened)
2985
+			{
2986
+				$mail_bo->closeConnection();
2987
+			}
2623 2988
 		}
2624 2989
 		return is_array($inline_images)?$inline_images:array();
2625 2990
 	}
@@ -2639,13 +3004,20 @@  discard block
 block discarded – undo
2639 3004
 	 */
2640 3005
 	protected function _getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2641 3006
 	{
2642
-		if ($filemode == Vfs\Sharing::ATTACH) return '';
3007
+		if ($filemode == Vfs\Sharing::ATTACH)
3008
+		{
3009
+			return '';
3010
+		}
2643 3011
 
2644 3012
 		$links = array();
2645 3013
 		foreach($attachments as $attachment)
2646 3014
 		{
2647 3015
 			$path = $attachment['file'];
2648
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
3016
+			if (empty($path))
3017
+			{
3018
+				continue;
3019
+			}
3020
+			// we only care about file attachments, not forwarded messages or parts
2649 3021
 			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2650 3022
 			{
2651 3023
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
@@ -2748,13 +3120,19 @@  discard block
 block discarded – undo
2748 3120
 								$success = false;
2749 3121
 								error_log(__METHOD__.__LINE__.$msg);
2750 3122
 							}
2751
-						} else {
3123
+						}
3124
+						else
3125
+						{
2752 3126
 							error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former');
2753 3127
 						}
2754
-					} else {
3128
+					}
3129
+					else
3130
+					{
2755 3131
 						error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)");
2756 3132
 					}
2757
-				} else {
3133
+				}
3134
+				else
3135
+				{
2758 3136
 					error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)");
2759 3137
 				}
2760 3138
 			}
@@ -2770,7 +3148,10 @@  discard block
 block discarded – undo
2770 3148
 			$success = false;
2771 3149
 		}
2772 3150
 
2773
-		if ($success) $msg = lang('Message saved successfully.');
3151
+		if ($success)
3152
+		{
3153
+			$msg = lang('Message saved successfully.');
3154
+		}
2774 3155
 
2775 3156
 		// Include new information to json respose, because we need them in client-side callback
2776 3157
 		$response->data(array(
@@ -2794,7 +3175,10 @@  discard block
 block discarded – undo
2794 3175
 		{
2795 3176
 			if(is_int($address))
2796 3177
 			{
2797
-				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
3178
+				if (!isset($contacts_obs))
3179
+				{
3180
+					$contacts_obj = new Api\Contacts();
3181
+				}
2798 3182
 				// List was selected, expand to addresses
2799 3183
 				unset($_emailAddressList[$ak]);
2800 3184
 				$list = $contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address));
@@ -2809,7 +3193,10 @@  discard block
 block discarded – undo
2809 3193
 		{
2810 3194
 			foreach ($addrFromList as $addr)
2811 3195
 			{
2812
-				if (!empty($addr)) $_emailAddressList[]=$addr;
3196
+				if (!empty($addr))
3197
+				{
3198
+					$_emailAddressList[]=$addr;
3199
+				}
2813 3200
 			}
2814 3201
 		}
2815 3202
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2863,7 +3250,10 @@  discard block
 block discarded – undo
2863 3250
 		// decide where to save the message (default to draft folder, if we find nothing else)
2864 3251
 		// if the current folder is in draft or template folder save it there
2865 3252
 		// if it is called from printview then save it with the draft folder
2866
-		if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder();
3253
+		if (empty($savingDestination))
3254
+		{
3255
+			$savingDestination = $mail_bo->getDraftFolder();
3256
+		}
2867 3257
 		if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox']))
2868 3258
 		{
2869 3259
 			$this->sessionData['messageFolder'] = $this->sessionData['mailbox'];
@@ -2874,13 +3264,17 @@  discard block
 block discarded – undo
2874 3264
 			$savingDestination = $this->sessionData['messageFolder'];
2875 3265
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2876 3266
 		}
2877
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
3267
+		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 )
3268
+		{
3269
+			$savingDestination = $mail_bo->getDraftFolder();
3270
+		}
2878 3271
 
2879 3272
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2880 3273
 		$mail->forceBccHeader();
2881 3274
 
2882 3275
 		$mail_bo->openConnection();
2883
-		if ($mail_bo->folderExists($savingDestination,true)) {
3276
+		if ($mail_bo->folderExists($savingDestination,true))
3277
+		{
2884 3278
 			try
2885 3279
 			{
2886 3280
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
@@ -2891,7 +3285,9 @@  discard block
 block discarded – undo
2891 3285
 				return false;
2892 3286
 			}
2893 3287
 
2894
-		} else {
3288
+		}
3289
+		else
3290
+		{
2895 3291
 			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2896 3292
 			return false;
2897 3293
 		}
@@ -2941,7 +3337,10 @@  discard block
 block discarded – undo
2941 3337
 					$fhA = mail_ui::splitRowID($rowid);
2942 3338
 					$this->sessionData['uid'][] = $fhA['msgUID'];
2943 3339
 					$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
2944
-					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
3340
+					if (!empty($fhA['folder']))
3341
+					{
3342
+						$this->sessionData['sourceFolder'] = $fhA['folder'];
3343
+					}
2945 3344
 				}
2946 3345
 			}
2947 3346
 			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
@@ -2973,7 +3372,8 @@  discard block
 block discarded – undo
2973 3372
 			#error_log($this->sessionData['body']);
2974 3373
 		}
2975 3374
 		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2976
-		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
3375
+		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder']))
3376
+		{
2977 3377
 		   	$messageIsDraft = true;
2978 3378
 		}
2979 3379
 		try
@@ -2989,7 +3389,11 @@  discard block
 block discarded – undo
2989 3389
 		// create the messages and store inline images
2990 3390
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2991 3391
 		// remember the identity
2992
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
3392
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3393
+		{
3394
+			$fromAddress = $mail->From;
3395
+		}
3396
+		//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2993 3397
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2994 3398
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2995 3399
 		#exit;
@@ -3002,7 +3406,10 @@  discard block
 block discarded – undo
3002 3406
 		{
3003 3407
 			$fval=$f;
3004 3408
 			$icServerID = $_formData['serverID'];//folders always assumed with serverID
3005
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3409
+			if (stripos($f,'::')!==false)
3410
+			{
3411
+				list($icServerID,$fval) = explode('::',$f,2);
3412
+			}
3006 3413
 			if ($_formData['serverID']!=$_formData['mailaccount'])
3007 3414
 			{
3008 3415
 				if ($icServerID == $_formData['serverID'] )
@@ -3043,13 +3450,19 @@  discard block
 block discarded – undo
3043 3450
 			// sentFolder is account specific
3044 3451
 			$sentFolder = $this->mail_bo->getSentFolder();
3045 3452
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
3046
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3453
+			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true))
3454
+			{
3455
+				$sentFolder=false;
3456
+			}
3047 3457
 		}
3048 3458
 		else
3049 3459
 		{
3050 3460
 			$sentFolder = $mail_bo->getSentFolder();
3051 3461
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
3052
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3462
+			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true))
3463
+			{
3464
+				$sentFolder=false;
3465
+			}
3053 3466
 		}
3054 3467
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
3055 3468
 
@@ -3085,19 +3498,30 @@  discard block
 block discarded – undo
3085 3498
 		{
3086 3499
 			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
3087 3500
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
3088
-				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3501
+				$sentFolder != 'none'))
3502
+			{
3503
+				$this->errorInfo = lang("No Send Folder set in preferences");
3504
+			}
3089 3505
 		}
3090 3506
 		// draftFolder is on Server we start from
3091
-		if($messageIsDraft == true) {
3507
+		if($messageIsDraft == true)
3508
+		{
3092 3509
 			$draftFolder = $mail_bo->getDraftFolder();
3093
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3510
+			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true))
3511
+			{
3094 3512
 				$this->sessionData['folder'] = array($draftFolder);
3095 3513
 				$folderOnServerID[] = $draftFolder;
3096 3514
 				$folder[$draftFolder] = $draftFolder;
3097 3515
 			}
3098 3516
 		}
3099
-		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
3100
-		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3517
+		if ($folderOnServerID)
3518
+		{
3519
+			$folderOnServerID = array_unique($folderOnServerID);
3520
+		}
3521
+		if ($folderOnMailAccount)
3522
+		{
3523
+			$folderOnMailAccount = array_unique($folderOnMailAccount);
3524
+		}
3101 3525
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
3102 3526
 			!( count($folder) > 0) &&
3103 3527
 			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
@@ -3113,7 +3537,8 @@  discard block
 block discarded – undo
3113 3537
 			try	{
3114 3538
 				if ($_formData['smime_sign'] == 'on')
3115 3539
 				{
3116
-					if ($_formData['smime_passphrase'] != '') {
3540
+					if ($_formData['smime_passphrase'] != '')
3541
+					{
3117 3542
 						Api\Cache::setSession(
3118 3543
 							'mail',
3119 3544
 							'smime_passphrase',
@@ -3160,7 +3585,8 @@  discard block
 block discarded – undo
3160 3585
 		@set_time_limit(120);
3161 3586
 		//$mail->SMTPDebug = 10;
3162 3587
 		//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']));
3163
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3588
+		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0)
3589
+		{
3164 3590
 			try {
3165 3591
 				// do no close the session before sending, if we have to store the send text for infolog or other integration in the session
3166 3592
 				if (!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ))
@@ -3175,10 +3601,15 @@  discard block
 block discarded – undo
3175 3601
 				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
3176 3602
 				return false;
3177 3603
 			}
3178
-		} else {
3179
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3604
+		}
3605
+		else
3606
+		{
3607
+			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder']))
3608
+			{
3180 3609
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
3181
-			} else {
3610
+			}
3611
+			else
3612
+			{
3182 3613
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
3183 3614
 				//error_log(__METHOD__.__LINE__.$this->errorInfo);
3184 3615
 				return false;
@@ -3188,14 +3619,16 @@  discard block
 block discarded – undo
3188 3619
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
3189 3620
 		//error_log(__METHOD__.__LINE__.array2string($folder));
3190 3621
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3191
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3622
+            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3623
+		{
3192 3624
 			$mail_bo = $this->mail_bo;
3193 3625
 			$mail_bo->openConnection();
3194 3626
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
3195 3627
 			#error_log("(re)opened Connection");
3196 3628
 		}
3197 3629
 		// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
3198
-		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
3630
+		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3631
+		{
3199 3632
 			//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
3200 3633
 
3201 3634
 			// normaly Bcc is only added to recipients, but not as header visible to all recipients
@@ -3204,17 +3637,28 @@  discard block
 block discarded – undo
3204 3637
 		// copying mail to folder
3205 3638
 		if (count($folder) > 0)
3206 3639
 		{
3207
-			foreach($folderOnServerID as $folderName) {
3208
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3640
+			foreach($folderOnServerID as $folderName)
3641
+			{
3642
+				if (is_array($folderName))
3643
+				{
3644
+					$folderName = array_shift($folderName);
3645
+				}
3646
+				// should not happen at all
3209 3647
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3210 3648
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3211 3649
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3212
-				if ($mail_bo->folderExists($folderName,true)) {
3213
-					if($mail_bo->isSentFolder($folderName)) {
3650
+				if ($mail_bo->folderExists($folderName,true))
3651
+				{
3652
+					if($mail_bo->isSentFolder($folderName))
3653
+					{
3214 3654
 						$flags = '\\Seen';
3215
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3655
+					}
3656
+					elseif($mail_bo->isDraftFolder($folderName))
3657
+					{
3216 3658
 						$flags = '\\Draft';
3217
-					} else {
3659
+					}
3660
+					else
3661
+					{
3218 3662
 						$flags = '\\Seen';
3219 3663
 					}
3220 3664
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3237,18 +3681,32 @@  discard block
 block discarded – undo
3237 3681
 				}
3238 3682
 			}
3239 3683
 			// if we choose to send from a differing profile
3240
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3241
-			foreach($folderOnMailAccount as $folderName) {
3242
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3684
+			if ($folderOnMailAccount)
3685
+			{
3686
+				$this->changeProfile($_formData['mailaccount']);
3687
+			}
3688
+			foreach($folderOnMailAccount as $folderName)
3689
+			{
3690
+				if (is_array($folderName))
3691
+				{
3692
+					$folderName = array_shift($folderName);
3693
+				}
3694
+				// should not happen at all
3243 3695
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3244 3696
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3245 3697
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3246
-				if ($this->mail_bo->folderExists($folderName,true)) {
3247
-					if($this->mail_bo->isSentFolder($folderName)) {
3698
+				if ($this->mail_bo->folderExists($folderName,true))
3699
+				{
3700
+					if($this->mail_bo->isSentFolder($folderName))
3701
+					{
3248 3702
 						$flags = '\\Seen';
3249
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3703
+					}
3704
+					elseif($this->mail_bo->isDraftFolder($folderName))
3705
+					{
3250 3706
 						$flags = '\\Draft';
3251
-					} else {
3707
+					}
3708
+					else
3709
+					{
3252 3710
 						$flags = '\\Seen';
3253 3711
 					}
3254 3712
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3270,7 +3728,10 @@  discard block
 block discarded – undo
3270 3728
 					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3271 3729
 				}
3272 3730
 			}
3273
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
3731
+			if ($folderOnMailAccount)
3732
+			{
3733
+				$this->changeProfile($_formData['serverID']);
3734
+			}
3274 3735
 
3275 3736
 			//$mail_bo->closeConnection();
3276 3737
 		}
@@ -3282,10 +3743,16 @@  discard block
 block discarded – undo
3282 3743
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3283 3744
 			$lastDrafted['uid'] = $dhA['msgUID'];
3284 3745
 			$lastDrafted['folder'] = $dhA['folder'];
3285
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3746
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid']))
3747
+			{
3748
+				$lastDrafted['uid']=trim($lastDrafted['uid']);
3749
+			}
3286 3750
 			// manually drafted, do not delete
3287 3751
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3288
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3752
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid']))
3753
+			{
3754
+				$lastDrafted=false;
3755
+			}
3289 3756
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3290 3757
 		}
3291 3758
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
@@ -3311,7 +3778,8 @@  discard block
 block discarded – undo
3311 3778
 
3312 3779
 		//error_log("handling draft messages, flagging and such");
3313 3780
 		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3314
-			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3781
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3782
+		{
3315 3783
 			// mark message as answered
3316 3784
 			$mail_bo->openConnection();
3317 3785
 			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
@@ -3333,7 +3801,9 @@  discard block
 block discarded – undo
3333 3801
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
3334 3802
 					unset($e);
3335 3803
 				}
3336
-			} else {
3804
+			}
3805
+			else
3806
+			{
3337 3807
 				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3338 3808
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3339 3809
 				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
@@ -3352,7 +3822,10 @@  discard block
 block discarded – undo
3352 3822
 			}
3353 3823
 			//$mail_bo->closeConnection();
3354 3824
 		}
3355
-		if ($mail_bo) $mail_bo->closeConnection();
3825
+		if ($mail_bo)
3826
+		{
3827
+			$mail_bo->closeConnection();
3828
+		}
3356 3829
 		//error_log("performing Infolog Stuff");
3357 3830
 		//error_log(print_r($this->sessionData['to'],true));
3358 3831
 		//error_log(print_r($this->sessionData['cc'],true));
@@ -3365,9 +3838,18 @@  discard block
 block discarded – undo
3365 3838
 		{
3366 3839
 			$mailaddresses = array();
3367 3840
 		}
3368
-		if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
3369
-		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3370
-		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3841
+		if (is_array($this->sessionData['cc']))
3842
+		{
3843
+			$mailaddresses['cc'] = $this->sessionData['cc'];
3844
+		}
3845
+		if (is_array($this->sessionData['bcc']))
3846
+		{
3847
+			$mailaddresses['bcc'] = $this->sessionData['bcc'];
3848
+		}
3849
+		if (!empty($mailaddresses))
3850
+		{
3851
+			$mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3852
+		}
3371 3853
 
3372 3854
 		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3373 3855
 		{
@@ -3399,7 +3881,10 @@  discard block
 block discarded – undo
3399 3881
 							$_formData['serverID']),true),
3400 3882
 						'app' => $app_name
3401 3883
 					);
3402
-					if ($entryid) $target['entry_id'] = $entryid;
3884
+					if ($entryid)
3885
+					{
3886
+						$target['entry_id'] = $entryid;
3887
+					}
3403 3888
 					// Open the app called for integration in a popup
3404 3889
 					// and store the mail raw data as egw_data, in order to
3405 3890
 					// be stored from registered app method later
@@ -3410,8 +3895,11 @@  discard block
 block discarded – undo
3410 3895
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3411 3896
 		elseif(is_array($this->sessionData['attachments']))
3412 3897
 		{
3413
-			foreach($this->sessionData['attachments'] as $value) {
3414
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3898
+			foreach($this->sessionData['attachments'] as $value)
3899
+			{
3900
+				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs')
3901
+				{
3902
+// happens when forwarding mails
3415 3903
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3416 3904
 				}
3417 3905
 			}
@@ -3448,7 +3936,10 @@  discard block
 block discarded – undo
3448 3936
 				$default_identity = null;
3449 3937
 				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3450 3938
 				{
3451
-					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3939
+					if (!isset($default_identity))
3940
+					{
3941
+						$default_identity = $identity['ident_id'];
3942
+					}
3452 3943
 					if (!empty($identity['ident_signature']))
3453 3944
 					{
3454 3945
 						$content['mailidentity'] = $identity['ident_id'];
@@ -3456,12 +3947,18 @@  discard block
 block discarded – undo
3456 3947
 					}
3457 3948
 				}
3458 3949
 			}
3459
-			if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity;
3950
+			if (empty($content['mailidentity']))
3951
+			{
3952
+				$content['mailidentity'] = $default_identity;
3953
+			}
3460 3954
 		}
3461 3955
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3462 3956
 		{
3463 3957
 			$content['mimeType'] = 'html';
3464
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3958
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text")
3959
+			{
3960
+				$content['mimeType']  = 'plain';
3961
+			}
3465 3962
 		}
3466 3963
 		return $content;
3467 3964
 
@@ -3469,9 +3966,12 @@  discard block
 block discarded – undo
3469 3966
 
3470 3967
 	function stripSlashes($_string)
3471 3968
 	{
3472
-		if (get_magic_quotes_gpc()) {
3969
+		if (get_magic_quotes_gpc())
3970
+		{
3473 3971
 			return stripslashes($_string);
3474
-		} else {
3972
+		}
3973
+		else
3974
+		{
3475 3975
 			return $_string;
3476 3976
 		}
3477 3977
 	}
@@ -3484,15 +3984,25 @@  discard block
 block discarded – undo
3484 3984
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3485 3985
 	 * @return type
3486 3986
 	 */
3487
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3987
+	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
3988
+	{
3488 3989
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3489 3990
 		static $useCacheIfPossible = null;
3490
-		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
3991
+		if (is_null($useCacheIfPossible))
3992
+		{
3993
+			$useCacheIfPossible = true;
3994
+		}
3491 3995
 		$_searchString = trim($_REQUEST['query']);
3492 3996
 		$results = array();
3493 3997
 		$rememberServerID = $this->mail_bo->icServer->ImapServerId;
3494
-		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount'];
3495
-		if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3998
+		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount']))
3999
+		{
4000
+			$_mailaccountToSearch = $_REQUEST['mailaccount'];
4001
+		}
4002
+		if (empty($_mailaccountToSearch))
4003
+		{
4004
+			$_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
4005
+		}
3496 4006
 		if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch)
3497 4007
 		{
3498 4008
 			$this->changeProfile($_mailaccountToSearch);
@@ -3503,7 +4013,8 @@  discard block
 block discarded – undo
3503 4013
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3504 4014
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3505 4015
 			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3506
-			if (count($folderObjects)<=1) {
4016
+			if (count($folderObjects)<=1)
4017
+			{
3507 4018
 				$useCacheIfPossible = false;
3508 4019
 			}
3509 4020
 			else
@@ -3554,7 +4065,8 @@  discard block
 block discarded – undo
3554 4065
 		exit();
3555 4066
 	}
3556 4067
 
3557
-	public static function ajax_searchAddress($_searchStringLength=2) {
4068
+	public static function ajax_searchAddress($_searchStringLength=2)
4069
+	{
3558 4070
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3559 4071
 		$_searchString = trim($_REQUEST['query']);
3560 4072
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3575,7 +4087,10 @@  discard block
 block discarded – undo
3575 4087
 			$search = explode(' ', $_searchString);
3576 4088
 			foreach ($search as $k => $v)
3577 4089
 			{
3578
-				if (mb_strlen($v) < 3) unset($search[$k]);
4090
+				if (mb_strlen($v) < 3)
4091
+				{
4092
+					unset($search[$k]);
4093
+				}
3579 4094
 			}
3580 4095
 			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3581 4096
 			//error_log(__METHOD__.__LINE__.$_searchString);
@@ -3606,10 +4121,13 @@  discard block
 block discarded – undo
3606 4121
 			}
3607 4122
 		}
3608 4123
 
3609
-		if(is_array($contacts)) {
3610
-			foreach($contacts as $contact) {
4124
+		if(is_array($contacts))
4125
+		{
4126
+			foreach($contacts as $contact)
4127
+			{
3611 4128
 				$cf_emails = (array)array_values(array_values($contacts_obj->read_customfields($contact['id'], $cfs_type_email))[0]);
3612
-				foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email) {
4129
+				foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email)
4130
+				{
3613 4131
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3614 4132
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3615 4133
 					$rfcAddr = Mail::parseAddressList($email);
@@ -3623,10 +4141,22 @@  discard block
 block discarded – undo
3623 4141
 					if (method_exists($contacts_obj,'search'))
3624 4142
 					{
3625 4143
 						$contact['n_fn']='';
3626
-						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3627
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3628
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3629
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
4144
+						if (!empty($contact['n_prefix']))
4145
+						{
4146
+							$contact['n_fn'] = $contact['n_prefix'];
4147
+						}
4148
+						if (!empty($contact['n_given']))
4149
+						{
4150
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
4151
+						}
4152
+						if (!empty($contact['n_family']))
4153
+						{
4154
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
4155
+						}
4156
+						if (!empty($contact['org_name']))
4157
+						{
4158
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
4159
+						}
3630 4160
 						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3631 4161
 					}
3632 4162
 					else
@@ -3636,7 +4166,8 @@  discard block
 block discarded – undo
3636 4166
 					$args = explode('@', trim($email));
3637 4167
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3638 4168
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3639
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
4169
+					if(!empty($email) && in_array($completeMailString ,$results) === false)
4170
+					{
3640 4171
 						$results[] = array(
3641 4172
 							'id'=>$completeMailString,
3642 4173
 							'label' => $completeMailString,
@@ -3655,7 +4186,10 @@  discard block
 block discarded – undo
3655 4186
 		foreach($groups as $g_id => $name)
3656 4187
 		{
3657 4188
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3658
-			if(!$group['account_email']) continue;
4189
+			if(!$group['account_email'])
4190
+			{
4191
+				continue;
4192
+			}
3659 4193
 			$args = explode('@', trim($group['account_email']));
3660 4194
 			$args[] = $name;
3661 4195
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3691,7 +4225,8 @@  discard block
 block discarded – undo
3691 4225
 		$manual_lists = array();
3692 4226
 		$lists = array_filter(
3693 4227
 			$contacts_obj->get_lists(Acl::READ),
3694
-			function($element) use($_searchString) {
4228
+			function($element) use($_searchString)
4229
+			{
3695 4230
 				return (stripos($element, $_searchString) !== false);
3696 4231
 			}
3697 4232
 		);
@@ -3709,9 +4244,13 @@  discard block
 block discarded – undo
3709 4244
 			);
3710 4245
 			${"${type}_lists"}[] = $list;
3711 4246
 		}
3712
-		$trim = function($list) {
4247
+		$trim = function($list)
4248
+		{
3713 4249
 			$limit = 10;
3714
-			if(count($list) <= $limit) return $list;
4250
+			if(count($list) <= $limit)
4251
+			{
4252
+				return $list;
4253
+			}
3715 4254
 			$list[$limit-1]['class'].= ' more_results';
3716 4255
 			$list[$limit-1]['title'] .= '  (' . lang('%1 more', count($list) - $limit) . ')';
3717 4256
 			return array_slice($list, 0, $limit);
@@ -3814,7 +4353,10 @@  discard block
 block discarded – undo
3814 4353
 		try
3815 4354
 		{
3816 4355
 			$sender_cert = $AB->get_smime_keys($sender);
3817
-			if (!$sender_cert)	throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: " . $sender);
4356
+			if (!$sender_cert)
4357
+			{
4358
+				throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: " . $sender);
4359
+			}
3818 4360
 			$params['senderPubKey'] = $sender_cert[$sender];
3819 4361
 
3820 4362
 			if (isset($sender) && ($type == Mail\Smime::TYPE_SIGN || $type == Mail\Smime::TYPE_SIGN_ENCRYPT))
@@ -3829,9 +4371,15 @@  discard block
 block discarded – undo
3829 4371
 				$params['recipientsCerts'] = $AB->get_smime_keys($recipients);
3830 4372
 				foreach ($recipients as &$recipient)
3831 4373
 				{
3832
-					if (!$params['recipientsCerts'][$recipient]) $missingCerts []= $recipient;
4374
+					if (!$params['recipientsCerts'][$recipient])
4375
+					{
4376
+						$missingCerts []= $recipient;
4377
+					}
4378
+				}
4379
+				if (is_array($missingCerts))
4380
+				{
4381
+					throw new Exception ('S/MIME Encryption failed because no certificate has been found for following addresses: '. implode ('|', $missingCerts));
3833 4382
 				}
3834
-				if (is_array($missingCerts)) throw new Exception ('S/MIME Encryption failed because no certificate has been found for following addresses: '. implode ('|', $missingCerts));
3835 4383
 			}
3836 4384
 
3837 4385
 			return $mail->smimeEncrypt($type, $params);
Please login to merge, or discard this patch.
Spacing   +634 added lines, -636 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class mail_compose
26 26
 {
27
-	var $public_functions = array
28
-	(
27
+	var $public_functions = array(
29 28
 		'compose'		=> True,
30 29
 		'getAttachment'		=> True,
31 30
 	);
@@ -34,8 +33,8 @@  discard block
 block discarded – undo
34 33
 	 * class vars for destination, priorities, mimeTypes
35 34
 	 */
36 35
 	static $destinations = array(
37
-		'to' 		=> 'to',  // lang('to')
38
-		'cc'		=> 'cc',  // lang('cc')
36
+		'to' 		=> 'to', // lang('to')
37
+		'cc'		=> 'cc', // lang('cc')
39 38
 		'bcc'		=> 'bcc', // lang('bcc')
40 39
 		'replyto'	=> 'replyto', // lang('replyto')
41 40
 		'folder'	=> 'folder'  // lang('folder')
@@ -63,20 +62,20 @@  discard block
 block discarded – undo
63 62
 	 * @var array
64 63
 	 */
65 64
 	var $mailPreferences;
66
-	var $attachments;	// Array of attachments
65
+	var $attachments; // Array of attachments
67 66
 	var $displayCharset;
68 67
 	var $composeID;
69 68
 	var $sessionData;
70 69
 
71 70
 	function __construct()
72 71
 	{
73
-		$this->displayCharset   = Api\Translation::charset();
72
+		$this->displayCharset = Api\Translation::charset();
74 73
 
75 74
 		$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
76
-		$this->mail_bo	= Mail::getInstance(true,$profileID);
75
+		$this->mail_bo = Mail::getInstance(true, $profileID);
77 76
 		$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->mail_bo->profileID;
78 77
 
79
-		$this->mailPreferences	=& $this->mail_bo->mailPreferences;
78
+		$this->mailPreferences = & $this->mail_bo->mailPreferences;
80 79
 		//force the default for the forwarding -> asmail
81 80
 		if (!is_array($this->mailPreferences) || empty($this->mailPreferences['message_forwarding']))
82 81
 		{
@@ -84,7 +83,7 @@  discard block
 block discarded – undo
84 83
 		}
85 84
 		if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail');
86 85
 
87
-		$this->mailPreferences  =& $this->mail_bo->mailPreferences;
86
+		$this->mailPreferences = & $this->mail_bo->mailPreferences;
88 87
 	}
89 88
 
90 89
 	/**
@@ -94,15 +93,15 @@  discard block
 block discarded – undo
94 93
 	 */
95 94
 	function changeProfile($_icServerID)
96 95
 	{
97
-		if ($this->mail_bo->profileID!=$_icServerID)
96
+		if ($this->mail_bo->profileID != $_icServerID)
98 97
 		{
99 98
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID);
100
-			$this->mail_bo = Mail::getInstance(false,$_icServerID);
99
+			$this->mail_bo = Mail::getInstance(false, $_icServerID);
101 100
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
102 101
 			// no icServer Object: something failed big time
103 102
 			if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
104 103
 			$this->mail_bo->openConnection($this->mail_bo->profileID);
105
-			$this->mailPreferences  =& $this->mail_bo->mailPreferences;
104
+			$this->mailPreferences = & $this->mail_bo->mailPreferences;
106 105
 		}
107 106
 	}
108 107
 
@@ -140,7 +139,7 @@  discard block
 block discarded – undo
140 139
 				'onExecute' => 'javaScript:app.mail.saveAsDraft',
141 140
 				'hint' => 'Save as Draft and Print'
142 141
 			),
143
-			'save2vfs' => array (
142
+			'save2vfs' => array(
144 143
 				'caption' => 'Save to filemanager',
145 144
 				'icon' => 'filesave',
146 145
 				'group' => $group,
@@ -179,7 +178,7 @@  discard block
 block discarded – undo
179 178
 				'checkbox' => true,
180 179
 				'hint' => 'check to save as tracker entry on send',
181 180
 				'onExecute' => 'javaScript:app.mail.compose_setToggle',
182
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
181
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
183 182
 			),
184 183
 			'to_calendar' => array(
185 184
 				'caption' => 'Calendar',
@@ -219,7 +218,7 @@  discard block
 block discarded – undo
219 218
 		if ($acc_smime['acc_smime_password'])
220 219
 		{
221 220
 			$actions = array_merge($actions, array(
222
-				'smime_sign' => array (
221
+				'smime_sign' => array(
223 222
 					'caption' => 'SMIME Sign',
224 223
 					'icon' => 'smime_sign',
225 224
 					'group' => ++$group,
@@ -227,7 +226,7 @@  discard block
 block discarded – undo
227 226
 					'checkbox' => true,
228 227
 					'hint' => 'Sign your message with smime certificate'
229 228
 				),
230
-				'smime_encrypt' => array (
229
+				'smime_encrypt' => array(
231 230
 					'caption' => 'SMIME Encryption',
232 231
 					'icon' => 'smime_encrypt',
233 232
 					'group' => $group,
@@ -265,7 +264,7 @@  discard block
 block discarded – undo
265 264
 		{
266 265
 			foreach (array_keys($actions) as $key)
267 266
 			{
268
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
267
+				if (!in_array($key, array('send', 'button[saveAsDraft]', 'uploadForCompose'))) {
269 268
 					$actions[$key]['toolbarDefault'] = false;
270 269
 				}
271 270
 			}
@@ -290,7 +289,7 @@  discard block
 block discarded – undo
290 289
 	 * @var boolean $suppressSigOnTop =false
291 290
 	 * @var boolean $isReply =false
292 291
 	 */
293
-	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
292
+	function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false)
294 293
 	{
295 294
 		if ($msg) Framework::message($msg);
296 295
 
@@ -311,8 +310,8 @@  discard block
 block discarded – undo
311 310
 		//lang('compose'),lang('from') // needed to be found by translationtools
312 311
 		//error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace());
313 312
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
314
-		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
315
-		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
313
+		$_contentHasSigID = $_content ?array_key_exists('mailidentity', (array)$_content) : false;
314
+		$_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false;
316 315
 
317 316
 		// fetch appendix data which is an assistance input value consisiting of json data
318 317
 		if ($_content['appendix_data'])
@@ -341,7 +340,7 @@  discard block
 block discarded – undo
341 340
 
342 341
 		// Process different places we can use as a start for composing an email
343 342
 		$actionToProcess = 'compose';
344
-		if($_GET['from'] && $replyID)
343
+		if ($_GET['from'] && $replyID)
345 344
 		{
346 345
 			$_content = array_merge((array)$_content, $this->getComposeFrom(
347 346
 				// Parameters needed for fetching appropriate data
@@ -369,10 +368,10 @@  discard block
 block discarded – undo
369 368
 		}
370 369
 
371 370
 		$composeCache = array();
372
-		if (isset($_content['composeID'])&&!empty($_content['composeID']))
371
+		if (isset($_content['composeID']) && !empty($_content['composeID']))
373 372
 		{
374 373
 			$isFirstLoad = false;
375
-			$composeCache = Api\Cache::getCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2);
374
+			$composeCache = Api\Cache::getCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'], $callback = null, $callback_params = array(), $expiration = 60 * 60 * 2);
376 375
 			$this->composeID = $_content['composeID'];
377 376
 			//error_log(__METHOD__.__LINE__.array2string($composeCache));
378 377
 		}
@@ -382,7 +381,7 @@  discard block
 block discarded – undo
382 381
 			// respect that composeasnew may not want that, as we assume there
383 382
 			// is some style already set and our initalStyle always adds a span with &nbsp;
384 383
 			// and we want to avoid that
385
-			$isFirstLoad = !($actionToProcess=='composeasnew');//true;
384
+			$isFirstLoad = !($actionToProcess == 'composeasnew'); //true;
386 385
 			$this->composeID = $_content['composeID'] = $this->generateComposeID();
387 386
 			if (!is_array($_content))
388 387
 			{
@@ -417,7 +416,7 @@  discard block
 block discarded – undo
417 416
 				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
418 417
 				try
419 418
 				{
420
-					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
419
+					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload, $this->composeID, false);
421 420
 				}
422 421
 				catch (Api\Exception\WrongUserinput $e)
423 422
 				{
@@ -443,12 +442,12 @@  discard block
 block discarded – undo
443 442
 			unset($_content['attachments']['delete']);
444 443
 			$attachments = $_content['attachments'];
445 444
 			unset($_content['attachments']);
446
-			foreach($attachments as $i => $att)
445
+			foreach ($attachments as $i => $att)
447 446
 			{
448
-				$remove=false;
449
-				foreach(array_keys($toDelete) as $k)
447
+				$remove = false;
448
+				foreach (array_keys($toDelete) as $k)
450 449
 				{
451
-					if ($att['tmp_name']==$k) $remove=true;
450
+					if ($att['tmp_name'] == $k) $remove = true;
452 451
 				}
453 452
 				if (!$remove) $_content['attachments'][] = $att;
454 453
 			}
@@ -456,7 +455,7 @@  discard block
 block discarded – undo
456 455
 		// someone clicked something like send, or saveAsDraft
457 456
 		// make sure, we are connected to the correct server for sending and storing the send message
458 457
 		$activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose
459
-		$activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
458
+		$activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10);
460 459
 		if (!empty($activeFolderCache[$this->mail_bo->profileID]))
461 460
 		{
462 461
 			//error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]);
@@ -464,7 +463,7 @@  discard block
 block discarded – undo
464 463
 		}
465 464
 		//error_log(__METHOD__.__LINE__.array2string($_content));
466 465
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
467
-			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
466
+			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint'])
468 467
 		)
469 468
 		{
470 469
 			$this->changeProfile($_content['serverID']);
@@ -478,19 +477,19 @@  discard block
 block discarded – undo
478 477
 		{
479 478
 			$buttonClicked = $suppressSigOnTop = true;
480 479
 			$sendOK = true;
481
-			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']);
480
+			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
482 481
 			/*
483 482
 			perform some simple checks, before trying to send on:
484 483
 			$_content['to'];$_content['cc'];$_content['bcc'];
485 484
 			trim($_content['subject']);
486 485
 			trim(strip_tags(str_replace('&nbsp;','',$_content['body'])));
487 486
 			*/
488
-			if (strlen(trim(strip_tags(str_replace('&nbsp;','',$_content['body']))))==0 && count($_content['attachments'])==0)
487
+			if (strlen(trim(strip_tags(str_replace('&nbsp;', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0)
489 488
 			{
490 489
 				$sendOK = false;
491 490
 				$_content['msg'] = $message = lang("no message body supplied");
492 491
 			}
493
-			if ($sendOK && strlen(trim($_content['subject']))==0)
492
+			if ($sendOK && strlen(trim($_content['subject'])) == 0)
494 493
 			{
495 494
 				$sendOK = false;
496 495
 				$_content['msg'] = $message = lang("no subject supplied");
@@ -505,15 +504,15 @@  discard block
 block discarded – undo
505 504
 				try
506 505
 				{
507 506
 					$success = $this->send($_content);
508
-					if ($success==false)
507
+					if ($success == false)
509 508
 					{
510
-						$sendOK=false;
509
+						$sendOK = false;
511 510
 						$message = $this->errorInfo;
512 511
 					}
513 512
 					if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID])
514 513
 					{
515
-						$sigPref[$this->mail_bo->profileID]=$_content['mailidentity'];
516
-						$GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user');
514
+						$sigPref[$this->mail_bo->profileID] = $_content['mailidentity'];
515
+						$GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user');
517 516
 						// save prefs
518 517
 						$GLOBALS['egw']->preferences->save_repository(true);
519 518
 					}
@@ -537,23 +536,23 @@  discard block
 block discarded – undo
537 536
 				if (isset($_content['mode']) && !empty($_content['mode']))
538 537
 				{
539 538
 					$mode = $_content['mode'];
540
-					if ($_content['mode']=='forward' && !empty($_content['processedmail_id']))
539
+					if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id']))
541 540
 					{
542
-						$_content['processedmail_id'] = explode(',',$_content['processedmail_id']);
541
+						$_content['processedmail_id'] = explode(',', $_content['processedmail_id']);
543 542
 						foreach ($_content['processedmail_id'] as $k =>$rowid)
544 543
 						{
545 544
 							$fhA = mail_ui::splitRowID($rowid);
546 545
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
547 546
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
548
-							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
547
+							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false);
549 548
 							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
550 549
 						}
551 550
 					}
552
-					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
551
+					if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id']))
553 552
 					{
554 553
 						$rhA = mail_ui::splitRowID($_content['processedmail_id']);
555 554
 						//$this->sessionData['uid'] = $rhA['msgUID'];
556
-						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
555
+						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
557 556
 						$workingFolder = $rhA['folder'];
558 557
 					}
559 558
 				}
@@ -561,30 +560,30 @@  discard block
 block discarded – undo
561 560
 				if (empty($idsForRefresh) && !empty($_content['processedmail_id']))
562 561
 				{
563 562
 					$rhA = mail_ui::splitRowID($_content['processedmail_id']);
564
-					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
563
+					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
565 564
 				}
566 565
 				$response = Api\Json\Response::get();
567 566
 				if ($activeProfile != $composeProfile)
568 567
 				{
569 568
 					// we need a message only, when account ids (composeProfile vs. activeProfile) differ
570
-					$response->call('opener.egw_message',lang('Message send successfully.'));
569
+					$response->call('opener.egw_message', lang('Message send successfully.'));
571 570
 				}
572
-				elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder['mailbox'] && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)))
571
+				elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder['mailbox'] && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)))
573 572
 				{
574
-					if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))
573
+					if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))
575 574
 					{
576 575
 						// we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action
577
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail');
576
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail');
578 577
 					}
579 578
 					else
580 579
 					{
581 580
 						//error_log(__METHOD__.__LINE__.array2string($idsForRefresh));
582
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update');
581
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update');
583 582
 					}
584 583
 				}
585 584
 				else
586 585
 				{
587
-					$response->call('opener.egw_message',lang('Message send successfully.'));
586
+					$response->call('opener.egw_message', lang('Message send successfully.'));
588 587
 				}
589 588
 				//egw_framework::refresh_opener(lang('Message send successfully.'),'mail');
590 589
 				Framework::window_close();
@@ -592,60 +591,60 @@  discard block
 block discarded – undo
592 591
 			if ($sendOK == false)
593 592
 			{
594 593
 				$response = Api\Json\Response::get();
595
-				Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate
594
+				Framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate
596 595
 				$response->call('app.mail.clearIntevals');
597 596
 			}
598 597
 		}
599 598
 
600 599
 		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
601 600
 		$insertSigOnTop = false;
602
-		$content = (is_array($_content)?$_content:array());
601
+		$content = (is_array($_content) ? $_content : array());
603 602
 		if ($_contentHasMimeType)
604 603
 		{
605 604
 			// mimeType is now a checkbox; convert it here to match expectations
606 605
 			// ToDo: match Code to meet checkbox value
607
-			if ($content['mimeType']==1)
606
+			if ($content['mimeType'] == 1)
608 607
 			{
609
-				$_content['mimeType'] = $content['mimeType']='html';
608
+				$_content['mimeType'] = $content['mimeType'] = 'html';
610 609
 			}
611 610
 			else
612 611
 			{
613
-				$_content['mimeType'] = $content['mimeType']='plain';
612
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
614 613
 			}
615 614
 
616 615
 		}
617 616
 		// user might have switched desired mimetype, so we should convert
618
-		if ($content['is_html'] && $content['mimeType']=='plain')
617
+		if ($content['is_html'] && $content['mimeType'] == 'plain')
619 618
 		{
620 619
 			//error_log(__METHOD__.__LINE__.$content['mail_htmltext']);
621 620
 			$suppressSigOnTop = true;
622
-			if (stripos($content['mail_htmltext'],'<pre>')!==false)
621
+			if (stripos($content['mail_htmltext'], '<pre>') !== false)
623 622
 			{
624 623
 				$contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']);
625 624
 				if (is_array($contentArr))
626 625
 				{
627 626
 					foreach ($contentArr as $k =>&$elem)
628 627
 					{
629
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
628
+						if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem);
630 629
 					}
631
-					$content['mail_htmltext'] = implode('',$contentArr);
630
+					$content['mail_htmltext'] = implode('', $contentArr);
632 631
 				}
633 632
 			}
634 633
 			$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']);
635
-			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
634
+			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true);
636 635
 
637 636
 			$content['body'] = $content['mail_htmltext'];
638 637
 			unset($content['mail_htmltext']);
639 638
 			$content['is_html'] = false;
640 639
 			$content['is_plain'] = true;
641 640
 		}
642
-		if ($content['is_plain'] && $content['mimeType']=='html')
641
+		if ($content['is_plain'] && $content['mimeType'] == 'html')
643 642
 		{
644 643
 			// the possible font span should only be applied on first load or on switch plain->html
645 644
 			$isFirstLoad = "switchedplaintohtml";
646 645
 			//error_log(__METHOD__.__LINE__.$content['mail_plaintext']);
647 646
 			$suppressSigOnTop = true;
648
-			$content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']);
647
+			$content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']);
649 648
 			//$this->replaceEmailAdresses($content['mail_plaintext']);
650 649
 			$content['body'] = $content['mail_plaintext'];
651 650
 			unset($content['mail_plaintext']);
@@ -653,7 +652,7 @@  discard block
 block discarded – undo
653 652
 			$content['is_plain'] = false;
654 653
 		}
655 654
 
656
-		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']);
655
+		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
657 656
 		unset($_content['body']);
658 657
 		unset($_content['mail_htmltext']);
659 658
 		unset($_content['mail_plaintext']);
@@ -665,7 +664,7 @@  discard block
 block discarded – undo
665 664
 
666 665
 		// form was submitted either by clicking a button or by changing one of the triggering selectboxes
667 666
 		// identity and signatureid; this might trigger that the signature in mail body may have to be altered
668
-		if ( !empty($content['body']) &&
667
+		if (!empty($content['body']) &&
669 668
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
670 669
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
671 670
 		)
@@ -676,7 +675,7 @@  discard block
 block discarded – undo
676 675
 			{
677 676
 				$acc = Mail\Account::read($_content['mailaccount']);
678 677
 				//error_log(__METHOD__.__LINE__.array2string($acc));
679
-				$Identities = Mail\Account::read_identity($acc['ident_id'],true);
678
+				$Identities = Mail\Account::read_identity($acc['ident_id'], true);
680 679
 				//error_log(__METHOD__.__LINE__.array2string($Identities));
681 680
 				if ($Identities['ident_id'])
682 681
 				{
@@ -689,41 +688,41 @@  discard block
 block discarded – undo
689 688
 				}
690 689
 			}
691 690
 			$_oldSig = $composeCache['mailidentity'];
692
-			$_signatureid = ($newSig?$newSig:$_content['mailidentity']);
691
+			$_signatureid = ($newSig ? $newSig : $_content['mailidentity']);
693 692
 
694 693
 			if ($_oldSig != $_signatureid)
695 694
 			{
696
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
695
+				if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
697 696
 				// prepare signatures, the selected sig may be used on top of the body
698 697
 				try
699 698
 				{
700
-					$oldSignature = Mail\Account::read_identity($_oldSig,true);
699
+					$oldSignature = Mail\Account::read_identity($_oldSig, true);
701 700
 					//error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#');
702 701
 					$oldSigText = $oldSignature['ident_signature'];
703 702
 				}
704 703
 				catch (Exception $e)
705 704
 				{
706
-					$oldSignature=array();
705
+					$oldSignature = array();
707 706
 					$oldSigText = null;
708 707
 				}
709 708
 				try
710 709
 				{
711
-					$signature = Mail\Account::read_identity($_signatureid,true);
710
+					$signature = Mail\Account::read_identity($_signatureid, true);
712 711
 					//error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#');
713 712
 					$sigText = $signature['ident_signature'];
714 713
 				}
715 714
 				catch (Exception $e)
716 715
 				{
717
-					$signature=array();
716
+					$signature = array();
718 717
 					$sigText = null;
719 718
 				}
720 719
 				//error_log(__METHOD__.'Old:'.$oldSigText.'#');
721 720
 				//error_log(__METHOD__.'New:'.$sigText.'#');
722 721
 				if ($_currentMode == 'plain')
723 722
 				{
724
-					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
725
-					$sigText = $this->convertHTMLToText($sigText,true,true);
726
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
723
+					$oldSigText = $this->convertHTMLToText($oldSigText, true, true);
724
+					$sigText = $this->convertHTMLToText($sigText, true, true);
725
+					if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
727 726
 				}
728 727
 
729 728
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -737,9 +736,9 @@  discard block
 block discarded – undo
737 736
 				//error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#');
738 737
 				if ($_currentMode == 'html')
739 738
 				{
740
-					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
739
+					$content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace
741 740
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
742
-					if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags
741
+					if (stripos($content['body'], 'style') !== false) Api\Mail\Html::replaceTagsCompletley($content['body'], 'style', $endtag = '', true); // clean out empty or pagewide style definitions / left over tags
743 742
 				}
744 743
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
745 744
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -747,9 +746,9 @@  discard block
 block discarded – undo
747 746
 				if ($_currentMode == 'html')
748 747
 				{
749 748
 					$replaced = null;
750
-					$content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u',
751
-						$rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced);
752
-					$content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'&ndash;','&mdash;','&euro;'),$content['body']);
749
+					$content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u',
750
+						$rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced);
751
+					$content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '&ndash;', '&mdash;', '&euro;'), $content['body']);
753 752
 					//error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced");
754 753
 					unset($rep, $in);
755 754
 					if ($replaced)
@@ -760,32 +759,32 @@  discard block
 block discarded – undo
760 759
 					else
761 760
 					{
762 761
 						// try the old way
763
-						$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
762
+						$found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false);
764 763
 					}
765 764
 				}
766 765
 				else
767 766
 				{
768
-					$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
767
+					$found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false);
769 768
 				}
770 769
 
771
-				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
770
+				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
772 771
 				{
773 772
 					//error_log(__METHOD__.'Old Content:'.$content['body'].'#');
774
-					$_oldSigText = preg_quote($oldSigTextCleaned,'~');
773
+					$_oldSigText = preg_quote($oldSigTextCleaned, '~');
775 774
 					//error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#');
776
-					$content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1);
775
+					$content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1);
777 776
 					//error_log(__METHOD__.'new Content:'.$content['body'].'#');
778 777
 				}
779 778
 
780
-				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
779
+				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
781 780
 				{
782 781
 					// if there is no sig selected, there is no way to replace a signature
783 782
 				}
784 783
 
785 784
 				if ($found === false)
786 785
 				{
787
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
788
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
786
+					if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
787
+					if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
789 788
 				}
790 789
 				else
791 790
 				{
@@ -820,7 +819,7 @@  discard block
 block discarded – undo
820 819
 		if ($isFirstLoad)
821 820
 		{
822 821
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
823
-			if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
822
+			if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
824 823
 				$this->mailPreferences['attachVCardAtCompose']))
825 824
 			{
826 825
 				$alwaysAttachVCardAtCompose = true;
@@ -829,7 +828,7 @@  discard block
 block discarded – undo
829 828
 					$f = $_REQUEST['preset']['file'];
830 829
 					$_REQUEST['preset']['file'] = array($f);
831 830
 				}
832
-				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry";
831
+				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry";
833 832
 			}
834 833
 			// an app passed the request for fetching and mailing an entry
835 834
 			if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))
@@ -838,33 +837,33 @@  discard block
 block discarded – undo
838 837
 				$mt = $_REQUEST['method'];
839 838
 				$id = $_REQUEST['id'];
840 839
 				// passed method MUST be registered
841
-				$method = Link::get_registry($app,$mt);
840
+				$method = Link::get_registry($app, $mt);
842 841
 				//error_log(__METHOD__.__LINE__.array2string($method));
843 842
 				if ($method)
844 843
 				{
845
-					$res = ExecMethod($method,array($id,'html'));
844
+					$res = ExecMethod($method, array($id, 'html'));
846 845
 					//error_log(__METHOD__.__LINE__.array2string($res));
847 846
 					if (!empty($res))
848 847
 					{
849 848
 						$insertSigOnTop = 'below';
850 849
 						if (isset($res['attachments']) && is_array($res['attachments']))
851 850
 						{
852
-							foreach($res['attachments'] as $f)
851
+							foreach ($res['attachments'] as $f)
853 852
 							{
854 853
 								$_REQUEST['preset']['file'][] = $f;
855 854
 							}
856 855
 						}
857 856
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
858
-						foreach(array('subject','body','mimetype') as $name) {
857
+						foreach (array('subject', 'body', 'mimetype') as $name) {
859 858
 							$sName = $name;
860
-							if ($name=='mimetype'&&$res[$name])
859
+							if ($name == 'mimetype' && $res[$name])
861 860
 							{
862 861
 								$sName = 'mimeType';
863 862
 								$content[$sName] = $res[$name];
864 863
 							}
865 864
 							else
866 865
 							{
867
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
866
+								if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name];
868 867
 							}
869 868
 						}
870 869
 					}
@@ -873,46 +872,46 @@  discard block
 block discarded – undo
873 872
 			// handle preset info/values
874 873
 			if (is_array($_REQUEST['preset']))
875 874
 			{
876
-				$alreadyProcessed=array();
875
+				$alreadyProcessed = array();
877 876
 				//_debug_array($_REQUEST);
878 877
 				if ($_REQUEST['preset']['mailto']) {
879 878
 					// handle mailto strings such as
880 879
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
881 880
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
882 881
 					// first, strip the mailto: string out of the mailto URL
883
-					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
882
+					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7)));
884 883
 					// check if there is more than the to address
885
-					$mailtoArray = explode('?',$tmp_send_to,2);
884
+					$mailtoArray = explode('?', $tmp_send_to, 2);
886 885
 					if ($mailtoArray[1]) {
887 886
 						// check if there are more than one requests
888
-						$addRequests = explode('&',$mailtoArray[1]);
887
+						$addRequests = explode('&', $mailtoArray[1]);
889 888
 						foreach ($addRequests as $key => $reqval) {
890 889
 							// the additional requests should have a =, to separate key from value.
891 890
 							$reqval = preg_replace('/__AMPERSAND__/i', "&", $reqval);
892
-							$keyValuePair = explode('=',$reqval,2);
893
-							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
891
+							$keyValuePair = explode('=', $reqval, 2);
892
+							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1];
894 893
 						}
895 894
 					}
896
-					$content['to']= preg_replace('/__AMPERSAND__/i', "&", $mailtoArray[0]);
897
-					$alreadyProcessed['to']='to';
895
+					$content['to'] = preg_replace('/__AMPERSAND__/i', "&", $mailtoArray[0]);
896
+					$alreadyProcessed['to'] = 'to';
898 897
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
899
-					foreach(array('cc','bcc','subject','body') as $name) {
900
-						$alreadyProcessed[$name]=$name;
901
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
898
+					foreach (array('cc', 'bcc', 'subject', 'body') as $name) {
899
+						$alreadyProcessed[$name] = $name;
900
+						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name];
902 901
 					}
903 902
 				}
904 903
 
905 904
 				if ($_REQUEST['preset']['mailtocontactbyid']) {
906 905
 					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
907 906
 						$contacts_obj = new Api\Contacts();
908
-						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
909
-						if (method_exists($contacts_obj,'search')) {
907
+						$addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook'];
908
+						if (method_exists($contacts_obj, 'search')) {
910 909
 
911
-							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
910
+							$addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']);
912 911
 							foreach ((array)$addressArray as $id => $addressID)
913 912
 							{
914
-								$addressID = (int) $addressID;
915
-								if (!($addressID>0))
913
+								$addressID = (int)$addressID;
914
+								if (!($addressID > 0))
916 915
 								{
917 916
 									unset($addressArray[$id]);
918 917
 								}
@@ -921,47 +920,47 @@  discard block
 block discarded – undo
921 920
 							{
922 921
 								$_searchCond = array('contact_id'=>$addressArray);
923 922
 								//error_log(__METHOD__.__LINE__.$_searchString);
924
-								$showAccounts= $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
925
-								$filter = ($showAccounts?array():array('account_id' => null));
926
-								$filter['cols_to_search']=array('n_fn','email','email_home');
927
-								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
923
+								$showAccounts = $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
924
+								$filter = ($showAccounts ? array() : array('account_id' => null));
925
+								$filter['cols_to_search'] = array('n_fn', 'email', 'email_home');
926
+								$contacts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
928 927
 								// additionally search the accounts, if the contact storage is not the account storage
929 928
 								if ($showAccounts &&
930 929
 									$GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
931 930
 									$GLOBALS['egw_info']['server']['contact_repository'] == 'sql')
932 931
 								{
933
-									$accounts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0));
932
+									$accounts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0));
934 933
 
935 934
 									if ($contacts && $accounts)
936 935
 									{
937
-										$contacts = array_merge($contacts,$accounts);
936
+										$contacts = array_merge($contacts, $accounts);
938 937
 										usort($contacts, function($a, $b)
939 938
 										{
940 939
 											return strcasecmp($a['n_fn'], $b['n_fn']);
941 940
 										});
942 941
 									}
943
-									elseif($accounts)
942
+									elseif ($accounts)
944 943
 									{
945
-										$contacts =& $accounts;
944
+										$contacts = & $accounts;
946 945
 									}
947 946
 									unset($accounts);
948 947
 								}
949 948
 							}
950
-							if(is_array($contacts)) {
949
+							if (is_array($contacts)) {
951 950
 								$mailtoArray = array();
952 951
 								$primary = $addressbookprefs['distributionListPreferredMail'];
953 952
 								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
954
-								$secondary = ($primary == 'email'?'email_home':'email');
953
+								$secondary = ($primary == 'email' ? 'email_home' : 'email');
955 954
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
956
-								foreach($contacts as $contact) {
957
-									$innerCounter=0;
958
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
955
+								foreach ($contacts as $contact) {
956
+									$innerCounter = 0;
957
+									foreach (array($contact[$primary], $contact[$secondary]) as $email) {
959 958
 										// use pref distributionListPreferredMail for the primary address
960 959
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
961
-										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
962
-										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
963
-										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
964
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
960
+										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email);
961
+										$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
962
+										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>');
963
+										if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) {
965 964
 											$i++;
966 965
 											$innerCounter++;
967 966
 											$mailtoArray[$i] = $completeMailString;
@@ -970,8 +969,8 @@  discard block
 block discarded – undo
970 969
 								}
971 970
 							}
972 971
 							//error_log(__METHOD__.__LINE__.array2string($mailtoArray));
973
-							$alreadyProcessed['to']='to';
974
-							$content['to']=$mailtoArray;
972
+							$alreadyProcessed['to'] = 'to';
973
+							$content['to'] = $mailtoArray;
975 974
 						}
976 975
 					}
977 976
 				}
@@ -986,23 +985,23 @@  discard block
 block discarded – undo
986 985
 					$remember = array();
987 986
 					if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])))
988 987
 					{
989
-						foreach(array_keys($content) as $k)
988
+						foreach (array_keys($content) as $k)
990 989
 						{
991
-							if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k]))
990
+							if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k]))
992 991
 							{
993
-								$alreadyProcessed[$k]=$k;
992
+								$alreadyProcessed[$k] = $k;
994 993
 								$remember[$k] = $this->sessionData[$k];
995 994
 							}
996 995
 						}
997 996
 					}
998
-					if(!empty($remember)) $content = array_merge($content,$remember);
997
+					if (!empty($remember)) $content = array_merge($content, $remember);
999 998
 				}
1000
-				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
999
+				foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name)
1001 1000
 				{
1002 1001
 					//always handle mimeType
1003
-					if ($name=='mimeType' && $_REQUEST['preset'][$name])
1002
+					if ($name == 'mimeType' && $_REQUEST['preset'][$name])
1004 1003
 					{
1005
-						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
1004
+						$_content[$name] = $content[$name] = $_REQUEST['preset'][$name];
1006 1005
 					}
1007 1006
 					//skip if already processed by "preset Routines"
1008 1007
 					if ($alreadyProcessed[$name]) continue;
@@ -1015,36 +1014,36 @@  discard block
 block discarded – undo
1015 1014
 			{
1016 1015
 				$content['to'] = base64_decode($_REQUEST['send_to']);
1017 1016
 				// first check if there is a questionmark or ampersand
1018
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1017
+				if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2);
1019 1018
 				$content['to'] = html_entity_decode($content['to']);
1020
-				if (($at_pos = strpos($content['to'],'@')) !== false)
1019
+				if (($at_pos = strpos($content['to'], '@')) !== false)
1021 1020
 				{
1022
-					if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false)
1021
+					if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false)
1023 1022
 					{
1024 1023
 						//list($email,$addoptions) = explode('&',$value,2);
1025
-						$email = substr($content['to'],0,$amp_pos+$at_pos);
1026
-						$rest = substr($content['to'], $amp_pos+$at_pos+1);
1024
+						$email = substr($content['to'], 0, $amp_pos + $at_pos);
1025
+						$rest = substr($content['to'], $amp_pos + $at_pos + 1);
1027 1026
 						//error_log(__METHOD__.__LINE__.$email.' '.$rest);
1028 1027
 						$content['to'] = $email;
1029 1028
 					}
1030 1029
 				}
1031
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1030
+				if (strpos($content['to'], '%40') !== false) $content['to'] = Api\Html::purify(str_replace('%40', '@', $content['to']));
1032 1031
 				$rarr = array(Api\Html::purify($rest));
1033
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1032
+				if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest);
1034 1033
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1035 1034
 				$karr = array();
1036 1035
 				foreach ($rarr as &$rval)
1037 1036
 				{
1038 1037
 					//must contain =
1039
-					if (strpos($rval,'=')!== false)
1038
+					if (strpos($rval, '=') !== false)
1040 1039
 					{
1041
-						list($k,$v) = explode('=',$rval,2);
1040
+						list($k, $v) = explode('=', $rval, 2);
1042 1041
 						$karr[$k] = (string)$v;
1043
-						unset($k,$v);
1042
+						unset($k, $v);
1044 1043
 					}
1045 1044
 				}
1046 1045
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1047
-				foreach(array('cc','bcc','subject','body') as $name)
1046
+				foreach (array('cc', 'bcc', 'subject', 'body') as $name)
1048 1047
 				{
1049 1048
 					if ($karr[$name]) $content[$name] = $karr[$name];
1050 1049
 				}
@@ -1056,17 +1055,17 @@  discard block
 block discarded – undo
1056 1055
 		if ($isFirstLoad && !empty($_REQUEST['mimeType']))
1057 1056
 		{
1058 1057
 			$_content['mimeType'] = $content['mimeType'];
1059
-			if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html')
1058
+			if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html')
1060 1059
 			{
1061
-				$_content['mimeType'] = $content['mimeType']  = 'plain';
1062
-				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1060
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
1061
+				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1063 1062
 			}
1064
-			if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html')
1063
+			if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html')
1065 1064
 			{
1066
-				$_content['mimeType'] = $content['mimeType']  = 'html';
1065
+				$_content['mimeType'] = $content['mimeType'] = 'html';
1067 1066
 				$content['body'] = "<pre>".$content['body']."</pre>";
1068 1067
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1069
-				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);
1068
+				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);
1070 1069
 			}
1071 1070
 		}
1072 1071
 		else
@@ -1074,24 +1073,24 @@  discard block
 block discarded – undo
1074 1073
 			// try to enforce a mimeType on reply ( if type is not of the wanted type )
1075 1074
 			if ($isReply)
1076 1075
 			{
1077
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" &&
1076
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" &&
1078 1077
 					$content['mimeType'] == 'html')
1079 1078
 				{
1080
-					$_content['mimeType'] = $content['mimeType']  = 'plain';
1081
-					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1079
+					$_content['mimeType'] = $content['mimeType'] = 'plain';
1080
+					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1082 1081
 				}
1083
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" &&
1082
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" &&
1084 1083
 					$content['mimeType'] != 'html')
1085 1084
 				{
1086
-					$_content['mimeType'] = $content['mimeType']  = 'html';
1085
+					$_content['mimeType'] = $content['mimeType'] = 'html';
1087 1086
 					$content['body'] = "<pre>".$content['body']."</pre>";
1088 1087
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1089
-					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);
1088
+					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);
1090 1089
 				}
1091 1090
 			}
1092 1091
 		}
1093 1092
 
1094
-		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false)
1093
+		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible() === false)
1095 1094
 		{
1096 1095
 			$_content['mimeType'] = $content['mimeType'] = 'plain';
1097 1096
 			$content['body'] = $this->convertHTMLToText($content['body']);
@@ -1110,38 +1109,38 @@  discard block
 block discarded – undo
1110 1109
 		//_debug_array(($presetSig ? $presetSig : $content['mailidentity']));
1111 1110
 		try
1112 1111
 		{
1113
-			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true);
1112
+			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true);
1114 1113
 		}
1115 1114
 		catch (Exception $e)
1116 1115
 		{
1117 1116
 			//PROBABLY NOT FOUND
1118
-			$signature=array();
1117
+			$signature = array();
1119 1118
 		}
1120 1119
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
1121 1120
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
1122 1121
 			empty($signature['ident_signature']) ||
1123
-			trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='' ||
1122
+			trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '' ||
1124 1123
 			$this->mailPreferences['insertSignatureAtTopOfMessage'] == '1')
1125 1124
 		{
1126 1125
 			$disableRuler = true;
1127 1126
 		}
1128 1127
 		$font_span = $font_part = '';
1129
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1128
+		if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1130 1129
 			// User preferences for style
1131 1130
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1132 1131
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1133
-			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1132
+			$font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">';
1134 1133
 			$font_span = $font_part.'&#8203;</span>';
1135 1134
 			if (empty($font) && empty($font_size)) $font_span = '';
1136 1135
 		}
1137 1136
 		// 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
1138
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1137
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = '';
1139 1138
 		//remove possible html header stuff
1140
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1139
+		if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']);
1141 1140
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1142
-		$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');
1143
-		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1144
-			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1141
+		$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');
1142
+		if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' &&
1143
+			!(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop
1145 1144
 		)
1146 1145
 		{
1147 1146
 			// ON tOP OR BELOW? pREF CAN TELL
@@ -1151,57 +1150,57 @@  discard block
 block discarded – undo
1151 1150
 						'1' => 'before reply, visible during compose',
1152 1151
 						'no_belowaftersend'  => 'appended after reply before sending',
1153 1152
 			*/
1154
-			$insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below'));
1155
-			$sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
1153
+			$insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below'));
1154
+			$sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
1156 1155
 			if ($content['mimeType'] == 'html')
1157 1156
 			{
1158
-				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1159
-				foreach($blockElements as $e)
1157
+				$sigTextStartsWithBlockElement = ($disableRuler ?false:true);
1158
+				foreach ($blockElements as $e)
1160 1159
 				{
1161 1160
 					if ($sigTextStartsWithBlockElement) break;
1162
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1161
+					if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true;
1163 1162
 				}
1164 1163
 			}
1165
-			if($content['mimeType'] == 'html') {
1164
+			if ($content['mimeType'] == 'html') {
1166 1165
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1167 1166
 				$inbetween = '';
1168 1167
 			} else {
1169
-				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1168
+				$before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
1170 1169
 				$inbetween = "\r\n";
1171 1170
 			}
1172 1171
 			if ($content['mimeType'] == 'html')
1173 1172
 			{
1174
-				$sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>");
1173
+				$sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>");
1175 1174
 			}
1176 1175
 
1177 1176
 			if ($insertSigOnTop === 'below')
1178 1177
 			{
1179
-				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true));
1178
+				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true));
1180 1179
 			}
1181 1180
 			else
1182 1181
 			{
1183
-				$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
1182
+				$content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body'];
1184 1183
 			}
1185 1184
 		}
1186 1185
 		else
1187 1186
 		{
1188
-			$content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":"");
1187
+			$content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : "");
1189 1188
 		}
1190 1189
 		//error_log(__METHOD__.__LINE__.$content['body']);
1191 1190
 
1192 1191
 		// prepare body
1193 1192
 		// 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
1194
-		$content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8');
1193
+		$content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8');
1195 1194
 		//error_log(__METHOD__.__LINE__.array2string($content));
1196 1195
 
1197 1196
 		// get identities of all accounts as "$acc_id:$ident_id" => $identity
1198 1197
 		$sel_options['mailaccount'] = $identities = array();
1199
-		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1198
+		foreach (Mail\Account::search(true, false) as $acc_id => $account)
1200 1199
 		{
1201 1200
 			// do NOT add SMTP only accounts as identities
1202 1201
 			if (!$account->is_imap(false)) continue;
1203 1202
 
1204
-			foreach($account->identities($acc_id) as $ident_id => $identity)
1203
+			foreach ($account->identities($acc_id) as $ident_id => $identity)
1205 1204
 			{
1206 1205
 				$sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity;
1207 1206
 				$identities[$ident_id] = $identity;
@@ -1212,7 +1211,7 @@  discard block
 block discarded – undo
1212 1211
 		//$content['bcc'] = array('[email protected]','[email protected]');
1213 1212
 		// address stuff like from, to, cc, replyto
1214 1213
 		$destinationRows = 0;
1215
-		foreach(self::$destinations as $destination) {
1214
+		foreach (self::$destinations as $destination) {
1216 1215
 			if (!is_array($content[$destination]))
1217 1216
 			{
1218 1217
 				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
@@ -1220,22 +1219,22 @@  discard block
 block discarded – undo
1220 1219
 			$addr_content = $content[strtolower($destination)];
1221 1220
 			// we clear the given address array and rebuild it
1222 1221
 			unset($content[strtolower($destination)]);
1223
-			foreach((array)$addr_content as $key => $value) {
1224
-				if ($value=="NIL@NIL") continue;
1225
-				if ($destination=='replyto' && str_replace('"','',$value) ==
1226
-					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1222
+			foreach ((array)$addr_content as $key => $value) {
1223
+				if ($value == "NIL@NIL") continue;
1224
+				if ($destination == 'replyto' && str_replace('"', '', $value) ==
1225
+					str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()]))
1227 1226
 				{
1228 1227
 					// preserve/restore the value to content.
1229
-					$content[strtolower($destination)][]=$value;
1228
+					$content[strtolower($destination)][] = $value;
1230 1229
 					continue;
1231 1230
 				}
1232 1231
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1233
-				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1234
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1232
+				$value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT));
1233
+				foreach (Mail::parseAddressList($value) as $addressObject) {
1235 1234
 					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1236
-					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1235
+					$address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
1237 1236
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1238
-					$content[strtolower($destination)][]=$address;
1237
+					$content[strtolower($destination)][] = $address;
1239 1238
 					$destinationRows++;
1240 1239
 				}
1241 1240
 			}
@@ -1243,10 +1242,10 @@  discard block
 block discarded – undo
1243 1242
 		if ($_content)
1244 1243
 		{
1245 1244
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1246
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1247
-			$content = array_merge($content,$_content);
1245
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']);
1246
+			$content = array_merge($content, $_content);
1248 1247
 
1249
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1248
+			if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true);
1250 1249
 			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1251 1250
 		}
1252 1251
 		else
@@ -1255,12 +1254,12 @@  discard block
 block discarded – undo
1255 1254
 			$content['mailaccount'] = $this->mail_bo->profileID;
1256 1255
 			//error_log(__METHOD__.__LINE__.$content['body']);
1257 1256
 		}
1258
-		$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
1259
-		$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
1260
-		$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body'];
1261
-		$content['showtempname']=0;
1257
+		$content['is_html'] = ($content['mimeType'] == 'html' ?true:'');
1258
+		$content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true);
1259
+		$content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body'];
1260
+		$content['showtempname'] = 0;
1262 1261
 		//if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments']));
1263
-		$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)));
1262
+		$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)));
1264 1263
 		//if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0;
1265 1264
 		$content['no_griddata'] = empty($content['attachments']);
1266 1265
 		$preserv['attachments'] = $content['attachments'];
@@ -1294,12 +1293,12 @@  discard block
 block discarded – undo
1294 1293
 		$sel_options['mimeType'] = self::$mimeTypes;
1295 1294
 		$sel_options['priority'] = self::$priorities;
1296 1295
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1297
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1296
+		if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3;
1298 1297
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1299 1298
 		$etpl = new Etemplate('mail.compose');
1300 1299
 
1301 1300
 		$etpl->setElementAttribute('composeToolbar', 'actions', self::getToolbarActions($content));
1302
-		if ($content['mimeType']=='html')
1301
+		if ($content['mimeType'] == 'html')
1303 1302
 		{
1304 1303
 			//mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]"
1305 1304
 			$_htmlConfig = Mail::$htmLawed_config;
@@ -1309,23 +1308,23 @@  discard block
 block discarded – undo
1309 1308
 			// and not the eGroupware wide pref to prevent users from trying things that will potentially not work
1310 1309
 			// or not work as expected, as a full featured editor that may be wanted in other apps
1311 1310
 			// is way overloading the "normal" needs for composing mails
1312
-			$content['rtfEditorFeatures']='simple-withimage';//Api\Html\CkEditorConfig::get_ckeditor_config();
1311
+			$content['rtfEditorFeatures'] = 'simple-withimage'; //Api\Html\CkEditorConfig::get_ckeditor_config();
1313 1312
 			//$content['rtfEditorFeatures']='advanced';//Api\Html\CkEditorConfig::get_ckeditor_config();
1314
-			$content['validation_rules']= json_encode(Mail::$htmLawed_config);
1315
-			$etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']);
1316
-			$etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']);
1313
+			$content['validation_rules'] = json_encode(Mail::$htmLawed_config);
1314
+			$etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']);
1315
+			$etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']);
1317 1316
 			Mail::$htmLawed_config = $_htmlConfig;
1318 1317
 		}
1319 1318
 
1320
-		if (isset($content['composeID'])&&!empty($content['composeID']))
1319
+		if (isset($content['composeID']) && !empty($content['composeID']))
1321 1320
 		{
1322 1321
 			$composeCache = $content;
1323 1322
 			unset($composeCache['body']);
1324 1323
 			unset($composeCache['mail_htmltext']);
1325 1324
 			unset($composeCache['mail_plaintext']);
1326
-			Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2);
1325
+			Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2);
1327 1326
 		}
1328
-		if (!isset($_content['serverID'])||empty($_content['serverID']))
1327
+		if (!isset($_content['serverID']) || empty($_content['serverID']))
1329 1328
 		{
1330 1329
 			$content['serverID'] = $this->mail_bo->profileID;
1331 1330
 		}
@@ -1341,13 +1340,13 @@  discard block
 block discarded – undo
1341 1340
 		$preserv['list-id'] = $content['list-id'];
1342 1341
 		$preserv['mode'] = $content['mode'];
1343 1342
 		// convert it back to checkbox expectations
1344
-		if($content['mimeType'] == 'html') {
1345
-			$content['mimeType']=1;
1343
+		if ($content['mimeType'] == 'html') {
1344
+			$content['mimeType'] = 1;
1346 1345
 		} else {
1347
-			$content['mimeType']=0;
1346
+			$content['mimeType'] = 0;
1348 1347
 		}
1349 1348
 		// set the current selected mailaccount as param for folderselection
1350
-		$etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount']));
1349
+		$etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount']));
1351 1350
 		// join again mailaccount and identity
1352 1351
 		$content['mailaccount'] .= ':'.$content['mailidentity'];
1353 1352
 		//Try to set the initial selected account to the first identity match found
@@ -1366,14 +1365,14 @@  discard block
 block discarded – undo
1366 1365
 			}
1367 1366
 		}
1368 1367
 		// Resolve distribution list before send content to client
1369
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1368
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $f)
1370 1369
 		{
1371
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1370
+			if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]);
1372 1371
 		}
1373 1372
 
1374 1373
 		$content['to'] = self::resolveEmailAddressList($content['to']);
1375 1374
 		//error_log(__METHOD__.__LINE__.array2string($content));
1376
-		$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
1375
+		$etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2);
1377 1376
 	}
1378 1377
 
1379 1378
 	/**
@@ -1388,7 +1387,7 @@  discard block
 block discarded – undo
1388 1387
 	 * @param string $_insertSigOnTop
1389 1388
 	 * @param boolean $_eliminateDoubleAttachments
1390 1389
 	 */
1391
-	function addPresetFiles (&$_content, &$_insertSigOnTop, $_eliminateDoubleAttachments)
1390
+	function addPresetFiles(&$_content, &$_insertSigOnTop, $_eliminateDoubleAttachments)
1392 1391
 	{
1393 1392
 		// check if JSON was used
1394 1393
 		if (!is_array($_REQUEST['preset']['file']) &&
@@ -1410,19 +1409,19 @@  discard block
 block discarded – undo
1410 1409
 				(array)$_REQUEST['preset']['name'] : array();
1411 1410
 		}
1412 1411
 
1413
-		foreach($files as $k => $path)
1412
+		foreach ($files as $k => $path)
1414 1413
 		{
1415
-			if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false)
1414
+			if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false)
1416 1415
 			{
1417 1416
 				$_insertSigOnTop = 'below';
1418 1417
 			}
1419 1418
 			//error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs')));
1420
-			if (($scheme = parse_url($path,PHP_URL_SCHEME)) === 'vfs')
1419
+			if (($scheme = parse_url($path, PHP_URL_SCHEME)) === 'vfs')
1421 1420
 			{
1422 1421
 				$type = Vfs::mime_content_type($path);
1423 1422
 				// special handling for attaching vCard of iCal --> use their link-title as name
1424
-				if (substr($path,-7) != '/.entry' ||
1425
-					!(list($app,$id) = array_slice(explode('/',$path),-3)) ||
1423
+				if (substr($path, -7) != '/.entry' ||
1424
+					!(list($app, $id) = array_slice(explode('/', $path), -3)) ||
1426 1425
 					!($name = Link::title($app, $id)))
1427 1426
 				{
1428 1427
 					$name = Vfs::decodePath(Vfs::basename($path));
@@ -1436,7 +1435,7 @@  discard block
 block discarded – undo
1436 1435
 				{
1437 1436
 					$type = $types[$k];
1438 1437
 				}
1439
-				$path = str_replace('+','%2B',$path);
1438
+				$path = str_replace('+', '%2B', $path);
1440 1439
 				$formData = array(
1441 1440
 					'name' => $name,
1442 1441
 					'type' => $type,
@@ -1454,7 +1453,7 @@  discard block
 block discarded – undo
1454 1453
 			{
1455 1454
 				error_log(__METHOD__."() Attaching '$path' outside configured temp. directory '{$GLOBALS['egw_info']['server']['temp_dir']}' denied!");
1456 1455
 			}
1457
-			elseif(is_readable($path))
1456
+			elseif (is_readable($path))
1458 1457
 			{
1459 1458
 				$formData = array(
1460 1459
 					'name' => isset($names[$k]) ? $names[$k] : basename($path),
@@ -1467,7 +1466,7 @@  discard block
 block discarded – undo
1467 1466
 			{
1468 1467
 				continue;
1469 1468
 			}
1470
-			$this->addAttachment($formData,$_content, $_eliminateDoubleAttachments);
1469
+			$this->addAttachment($formData, $_content, $_eliminateDoubleAttachments);
1471 1470
 		}
1472 1471
 	}
1473 1472
 
@@ -1489,9 +1488,9 @@  discard block
 block discarded – undo
1489 1488
 		$content = array();
1490 1489
 		//error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply");
1491 1490
 		// on forward we may have to support multiple ids
1492
-		if ($from=='forward')
1491
+		if ($from == 'forward')
1493 1492
 		{
1494
-			$replyIds = explode(',',$mail_id);
1493
+			$replyIds = explode(',', $mail_id);
1495 1494
 			$mail_id = $replyIds[0];
1496 1495
 		}
1497 1496
 		$hA = mail_ui::splitRowID($mail_id);
@@ -1503,15 +1502,15 @@  discard block
 block discarded – undo
1503 1502
 			$this->changeProfile($icServerID);
1504 1503
 		}
1505 1504
 		$icServer = $this->mail_bo->icServer;
1506
-		if (!empty($folder) && !empty($msgUID) )
1505
+		if (!empty($folder) && !empty($msgUID))
1507 1506
 		{
1508 1507
 			// this fill the session data with the values from the original email
1509
-			switch($from)
1508
+			switch ($from)
1510 1509
 			{
1511 1510
 				case 'composefromdraft':
1512 1511
 				case 'composeasnew':
1513 1512
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1514
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1513
+					if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft';
1515 1514
 					$content['processedmail_id'] = $mail_id;
1516 1515
 
1517 1516
 					$_focusElement = 'body';
@@ -1527,7 +1526,7 @@  discard block
 block discarded – undo
1527 1526
 					$isReply = true;
1528 1527
 					break;
1529 1528
 				case 'forward':
1530
-					$mode  = ($_GET['mode']=='forwardinline'?'inline':'asmail');
1529
+					$mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail');
1531 1530
 					// this fill the session data with the values from the original email
1532 1531
 					foreach ($replyIds as &$mail_id)
1533 1532
 					{
@@ -1537,14 +1536,14 @@  discard block
 block discarded – undo
1537 1536
 						$folder = $hA['folder'];
1538 1537
 						$content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode);
1539 1538
 					}
1540
-					$content['processedmail_id'] = implode(',',$replyIds);
1539
+					$content['processedmail_id'] = implode(',', $replyIds);
1541 1540
 					$content['mode'] = 'forward';
1542
-					$isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline');
1543
-					$suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution
1541
+					$isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline');
1542
+					$suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution
1544 1543
 					$_focusElement = 'to';
1545 1544
 					break;
1546 1545
 				default:
1547
-					error_log('Unhandled compose source: ' . $from);
1546
+					error_log('Unhandled compose source: '.$from);
1548 1547
 			}
1549 1548
 		}
1550 1549
 		else if ($from == 'merge' && $_REQUEST['document'])
@@ -1559,12 +1558,12 @@  discard block
 block discarded – undo
1559 1558
 			$document_merge = new $merge_class();
1560 1559
 			$this->mail_bo->openConnection();
1561 1560
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1562
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1561
+			if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids);
1563 1562
 			try
1564 1563
 			{
1565 1564
 				$merged_mail_id = '';
1566 1565
 				$folder = '';
1567
-				if(($error = $document_merge->check_document($_REQUEST['document'],'')))
1566
+				if (($error = $document_merge->check_document($_REQUEST['document'], '')))
1568 1567
 				{
1569 1568
 					$content['msg'] = $error;
1570 1569
 					return $content;
@@ -1574,10 +1573,10 @@  discard block
 block discarded – undo
1574 1573
 				//$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
1575 1574
 
1576 1575
 				// Actually do the merge
1577
-				if(count($merge_ids) <= 1)
1576
+				if (count($merge_ids) <= 1)
1578 1577
 				{
1579 1578
 					$results = $this->mail_bo->importMessageToMergeAndSend(
1580
-						$document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1579
+						$document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1581 1580
 					);
1582 1581
 
1583 1582
 					// Open compose
@@ -1588,9 +1587,9 @@  discard block
 block discarded – undo
1588 1587
 				}
1589 1588
 				else
1590 1589
 				{
1591
-					$success = implode(', ',$results['success']);
1590
+					$success = implode(', ', $results['success']);
1592 1591
 					$fail = implode(', ', $results['failed']);
1593
-					if($success) Framework::message($success, 'success');
1592
+					if ($success) Framework::message($success, 'success');
1594 1593
 					Framework::window_close($fail);
1595 1594
 				}
1596 1595
 			}
@@ -1618,22 +1617,22 @@  discard block
 block discarded – undo
1618 1617
 		return 1;
1619 1618
 	}
1620 1619
 
1621
-	function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false, $noRepEmailAddr = false)
1620
+	function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false, $noRepEmailAddr = false)
1622 1621
 	{
1623 1622
 		$stripalltags = true;
1624 1623
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1625
-		if (!$sourceishtml) $stripalltags=false;
1626
-		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags, $noRepEmailAddr);
1624
+		if (!$sourceishtml) $stripalltags = false;
1625
+		return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags, $noRepEmailAddr);
1627 1626
 	}
1628 1627
 
1629 1628
 	function generateRFC822Address($_addressObject)
1630 1629
 	{
1631
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1632
-			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1633
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1634
-			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1630
+		if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1631
+			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1632
+		} elseif ($_addressObject->mailbox && $_addressObject->host) {
1633
+			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1635 1634
 		} else {
1636
-			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1635
+			return $this->mail_bo->decode_header($_addressObject->mailbox, true);
1637 1636
 		}
1638 1637
 	}
1639 1638
 
@@ -1648,9 +1647,9 @@  discard block
 block discarded – undo
1648 1647
 	// $_mode can be:
1649 1648
 	// single: for a reply to one address
1650 1649
 	// all: for a reply to all
1651
-	function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL)
1650
+	function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL)
1652 1651
 	{
1653
-		unset($_icServer);	// not used
1652
+		unset($_icServer); // not used
1654 1653
 		$this->sessionData['to'] = array();
1655 1654
 
1656 1655
 		$mail_bo = $this->mail_bo;
@@ -1659,7 +1658,7 @@  discard block
 block discarded – undo
1659 1658
 
1660 1659
 		// get message headers for specified message
1661 1660
 		#$headers	= $mail_bo->getMessageHeader($_folder, $_uid);
1662
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID);
1661
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
1663 1662
 		$addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID);
1664 1663
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1665 1664
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
@@ -1667,10 +1666,10 @@  discard block
 block discarded – undo
1667 1666
 
1668 1667
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1669 1668
 		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1670
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1671
-				$fval=$val;
1669
+			foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) {
1670
+				$fval = $val;
1672 1671
 				$icServerID = $mail_bo->icServer->ImapServerId;
1673
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1672
+				if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2);
1674 1673
 				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1675 1674
 				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1676 1675
 			}
@@ -1706,72 +1705,72 @@  discard block
 block discarded – undo
1706 1705
 			}
1707 1706
 		}
1708 1707
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1709
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1708
+		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder);
1710 1709
 		$this->sessionData['uid'] = $_uid;
1711 1710
 		$this->sessionData['messageFolder'] = $_folder;
1712 1711
 		$this->sessionData['isDraft'] = true;
1713 1712
 		$foundAddresses = array();
1714
-		foreach((array)$headers['CC'] as $val) {
1715
-			$rfcAddr=Mail::parseAddressList($val);
1713
+		foreach ((array)$headers['CC'] as $val) {
1714
+			$rfcAddr = Mail::parseAddressList($val);
1716 1715
 			$_rfcAddr = $rfcAddr[0];
1717 1716
 			if (!$_rfcAddr->valid) continue;
1718
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1717
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1719 1718
 				continue;
1720 1719
 			}
1721
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1722
-			if(!$foundAddresses[$keyemail]) {
1723
-				$address = $this->mail_bo->decode_header($val,true);
1720
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1721
+			if (!$foundAddresses[$keyemail]) {
1722
+				$address = $this->mail_bo->decode_header($val, true);
1724 1723
 				$this->sessionData['cc'][] = $val;
1725 1724
 				$foundAddresses[$keyemail] = true;
1726 1725
 			}
1727 1726
 		}
1728 1727
 
1729
-		foreach((array)$headers['TO'] as $val) {
1730
-			if(!is_array($val))
1728
+		foreach ((array)$headers['TO'] as $val) {
1729
+			if (!is_array($val))
1731 1730
 			{
1732 1731
 				$this->sessionData['to'][] = $val;
1733 1732
 				continue;
1734 1733
 			}
1735
-			$rfcAddr=Mail::parseAddressList($val);
1734
+			$rfcAddr = Mail::parseAddressList($val);
1736 1735
 			$_rfcAddr = $rfcAddr[0];
1737 1736
 			if (!$_rfcAddr->valid) continue;
1738
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1737
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1739 1738
 				continue;
1740 1739
 			}
1741
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1742
-			if(!$foundAddresses[$keyemail]) {
1743
-				$address = $this->mail_bo->decode_header($val,true);
1740
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1741
+			if (!$foundAddresses[$keyemail]) {
1742
+				$address = $this->mail_bo->decode_header($val, true);
1744 1743
 				$this->sessionData['to'][] = $val;
1745 1744
 				$foundAddresses[$keyemail] = true;
1746 1745
 			}
1747 1746
 		}
1748 1747
 
1749 1748
 		$fromAddr = Mail::parseAddressList($addHeadInfo['FROM'])[0];
1750
-		foreach((array)$headers['REPLY-TO'] as $val) {
1751
-			$rfcAddr=Mail::parseAddressList($val);
1749
+		foreach ((array)$headers['REPLY-TO'] as $val) {
1750
+			$rfcAddr = Mail::parseAddressList($val);
1752 1751
 			$_rfcAddr = $rfcAddr[0];
1753 1752
 			if (!$_rfcAddr->valid || ($_rfcAddr->mailbox == $fromAddr->mailbox && $_rfcAddr->host == $fromAddr->host)) continue;
1754
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1753
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1755 1754
 				continue;
1756 1755
 			}
1757
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1758
-			if(!$foundAddresses[$keyemail]) {
1759
-				$address = $this->mail_bo->decode_header($val,true);
1756
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1757
+			if (!$foundAddresses[$keyemail]) {
1758
+				$address = $this->mail_bo->decode_header($val, true);
1760 1759
 				$this->sessionData['replyto'][] = $val;
1761 1760
 				$foundAddresses[$keyemail] = true;
1762 1761
 			}
1763 1762
 		}
1764 1763
 
1765
-		foreach((array)$headers['BCC'] as $val) {
1766
-			$rfcAddr=Mail::parseAddressList($val);
1764
+		foreach ((array)$headers['BCC'] as $val) {
1765
+			$rfcAddr = Mail::parseAddressList($val);
1767 1766
 			$_rfcAddr = $rfcAddr[0];
1768 1767
 			if (!$_rfcAddr->valid) continue;
1769
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1768
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1770 1769
 				continue;
1771 1770
 			}
1772
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1773
-			if(!$foundAddresses[$keyemail]) {
1774
-				$address = $this->mail_bo->decode_header($val,true);
1771
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1772
+			if (!$foundAddresses[$keyemail]) {
1773
+				$address = $this->mail_bo->decode_header($val, true);
1775 1774
 				$this->sessionData['bcc'][] = $val;
1776 1775
 				$foundAddresses[$keyemail] = true;
1777 1776
 			}
@@ -1780,48 +1779,48 @@  discard block
 block discarded – undo
1780 1779
 		$this->sessionData['subject']	= $mail_bo->decode_header($headers['SUBJECT']);
1781 1780
 		// remove a printview tag if composing
1782 1781
 		$searchfor = '/^\['.lang('printview').':\]/';
1783
-		$this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']);
1784
-		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1782
+		$this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']);
1783
+		$bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID);
1785 1784
 		//_debug_array($bodyParts);
1786 1785
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1787
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1788
-			$this->sessionData['mimeType'] 	= 'html';
1786
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
1787
+			$this->sessionData['mimeType'] = 'html';
1789 1788
 
1790
-			for($i=0; $i<count($bodyParts); $i++) {
1791
-				if($i>0) {
1789
+			for ($i = 0; $i < count($bodyParts); $i++) {
1790
+				if ($i > 0) {
1792 1791
 					$this->sessionData['body'] .= '<hr>';
1793 1792
 				}
1794
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1793
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
1795 1794
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1796 1795
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1797 1796
 				}
1798
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1797
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1799 1798
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1800 1799
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1801
-				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1800
+				$this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body'];
1802 1801
 			}
1803 1802
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1804 1803
 
1805 1804
 		} else {
1806
-			$this->sessionData['mimeType']	= 'plain';
1805
+			$this->sessionData['mimeType'] = 'plain';
1807 1806
 
1808
-			for($i=0; $i<count($bodyParts); $i++) {
1809
-				if($i>0) {
1807
+			for ($i = 0; $i < count($bodyParts); $i++) {
1808
+				if ($i > 0) {
1810 1809
 					$this->sessionData['body'] .= "<hr>";
1811 1810
 				}
1812
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1811
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1813 1812
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1814 1813
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1815
-				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
1814
+				$this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body'];
1816 1815
 			}
1817
-			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1816
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain');
1818 1817
 		}
1819 1818
 
1820
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1821
-			foreach($attachments as $attachment) {
1819
+		if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1820
+			foreach ($attachments as $attachment) {
1822 1821
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1823 1822
 				$cid = $attachment['cid'];
1824
-				$match=null;
1823
+				$match = null;
1825 1824
 				preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match);
1826 1825
 				//error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match));
1827 1826
 				if (!$match || !$attachment['cid'])
@@ -1841,7 +1840,7 @@  discard block
 block discarded – undo
1841 1840
 
1842 1841
 	function getErrorInfo()
1843 1842
 	{
1844
-		if(isset($this->errorInfo)) {
1843
+		if (isset($this->errorInfo)) {
1845 1844
 			$errorInfo = $this->errorInfo;
1846 1845
 			unset($this->errorInfo);
1847 1846
 			return $errorInfo;
@@ -1849,39 +1848,39 @@  discard block
 block discarded – undo
1849 1848
 		return false;
1850 1849
 	}
1851 1850
 
1852
-	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false)
1851
+	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false)
1853 1852
 	{
1854 1853
 		if ($_mode)
1855 1854
 		{
1856 1855
 			$modebuff = $this->mailPreferences['message_forwarding'];
1857 1856
 			$this->mailPreferences['message_forwarding'] = $_mode;
1858 1857
 		}
1859
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1858
+		if ($this->mailPreferences['message_forwarding'] == 'inline') {
1860 1859
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1861 1860
 		}
1862
-		$mail_bo    = $this->mail_bo;
1861
+		$mail_bo = $this->mail_bo;
1863 1862
 		$mail_bo->openConnection();
1864 1863
 		$mail_bo->reopen($_folder);
1865 1864
 
1866 1865
 		// get message headers for specified message
1867
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder);
1866
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder);
1868 1867
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1869 1868
 		//_debug_array($headers); exit;
1870 1869
 		// check for Re: in subject header
1871
-		$this->sessionData['subject'] 	= "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']);
1870
+		$this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']);
1872 1871
 		// the three attributes below are substituted by processedmail_id and mode
1873 1872
 		//$this->sessionData['sourceFolder']=$_folder;
1874 1873
 		//$this->sessionData['forwardFlag']='forwarded';
1875 1874
 		//$this->sessionData['forwardedUID']=$_uid;
1876
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1877
-			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1878
-			if($headers['SIZE'])
1875
+		if ($this->mailPreferences['message_forwarding'] == 'asmail') {
1876
+			$this->sessionData['mimeType'] = $this->mailPreferences['composeOptions'];
1877
+			if ($headers['SIZE'])
1879 1878
 				$size				= $headers['SIZE'];
1880 1879
 			else
1881 1880
 				$size				= lang('unknown');
1882 1881
 
1883 1882
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1884
-				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
1883
+				$mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml',
1885 1884
 				'MESSAGE/RFC822', $size);
1886 1885
 		}
1887 1886
 		else
@@ -1891,10 +1890,10 @@  discard block
 block discarded – undo
1891 1890
 			unset($this->sessionData['cc']);
1892 1891
 			try
1893 1892
 			{
1894
-				if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
1893
+				if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID, null, true, false, false))) {
1895 1894
 					//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1896
-					foreach($attachments as $attachment) {
1897
-						if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1895
+					foreach ($attachments as $attachment) {
1896
+						if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1898 1897
 						{
1899 1898
 							$this->addMessageAttachment($_uid, $attachment['partID'],
1900 1899
 								$_folder,
@@ -1912,7 +1911,7 @@  discard block
 block discarded – undo
1912 1911
 						' because the content of this message seems to be encrypted'.
1913 1912
 						' and can not be decrypted properly. If you still wish to'.
1914 1913
 						' forward content of this encrypted message, you may try'.
1915
-						' to use forward as attachment instead.'),'error');
1914
+						' to use forward as attachment instead.'), 'error');
1916 1915
 			}
1917 1916
 		}
1918 1917
 		$mail_bo->closeConnection();
@@ -1933,7 +1932,7 @@  discard block
 block discarded – undo
1933 1932
 	 * @param array $_content the content passed to the function and to be modified
1934 1933
 	 * @return void
1935 1934
 	 */
1936
-	function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false)
1935
+	function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false)
1937 1936
 	{
1938 1937
 		//error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content));
1939 1938
 
@@ -1942,7 +1941,7 @@  discard block
 block discarded – undo
1942 1941
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
1943 1942
 		try
1944 1943
 		{
1945
-			$tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false);
1944
+			$tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false);
1946 1945
 		}
1947 1946
 		catch (Api\Exception\WrongUserinput $e)
1948 1947
 		{
@@ -1958,8 +1957,8 @@  discard block
 block discarded – undo
1958 1957
 			foreach ((array)$_content['attachments'] as $attach)
1959 1958
 			{
1960 1959
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1961
-					strtolower($_formData['type'])== strtolower($attach['type']) &&
1962
-					stripos($_formData['file'],'vfs://') !== false) return;
1960
+					strtolower($_formData['type']) == strtolower($attach['type']) &&
1961
+					stripos($_formData['file'], 'vfs://') !== false) return;
1963 1962
 			}
1964 1963
 		}
1965 1964
 		if ($attachfailed === false)
@@ -1971,7 +1970,7 @@  discard block
 block discarded – undo
1971 1970
 				'tmp_name'	=> $tmpFileName,
1972 1971
 				'size'	=> $_formData['size']
1973 1972
 			);
1974
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
1973
+			if (!is_array($_content['attachments'])) $_content['attachments'] = array();
1975 1974
 			$_content['attachments'][] = $buffer;
1976 1975
 			unset($buffer);
1977 1976
 		}
@@ -1981,9 +1980,9 @@  discard block
 block discarded – undo
1981 1980
 		}
1982 1981
 	}
1983 1982
 
1984
-	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail= null)
1983
+	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail = null)
1985 1984
 	{
1986
-		$this->sessionData['attachments'][]=array (
1985
+		$this->sessionData['attachments'][] = array(
1987 1986
 			'uid'		=> $_uid,
1988 1987
 			'partID'	=> $_partID,
1989 1988
 			'name'		=> $_name,
@@ -1991,7 +1990,7 @@  discard block
 block discarded – undo
1991 1990
 			'size'		=> $_size,
1992 1991
 			'folder'	=> $_folder,
1993 1992
 			'winmailFlag' => $_is_winmail,
1994
-			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1),
1993
+			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1),
1995 1994
 		);
1996 1995
 	}
1997 1996
 
@@ -2000,7 +1999,7 @@  discard block
 block discarded – undo
2000 1999
 		// read attachment data from etemplate request, use tmpname only to identify it
2001 2000
 		if (($request = Etemplate\Request::read($_GET['etemplate_exec_id'])))
2002 2001
 		{
2003
-			foreach($request->preserv['attachments'] as $attachment)
2002
+			foreach ($request->preserv['attachments'] as $attachment)
2004 2003
 			{
2005 2004
 				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2006 2005
 			}
@@ -2012,7 +2011,7 @@  discard block
 block discarded – undo
2012 2011
 		}
2013 2012
 
2014 2013
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
2015
-		if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs')
2014
+		if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs')
2016 2015
 		{
2017 2016
 			Vfs::load_wrapper('vfs');
2018 2017
 		}
@@ -2021,7 +2020,7 @@  discard block
 block discarded – undo
2021 2020
 		{
2022 2021
 			$attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['tmp_name']);
2023 2022
 		}
2024
-		if(!file_exists($attachment['tmp_name']))
2023
+		if (!file_exists($attachment['tmp_name']))
2025 2024
 		{
2026 2025
 			header('HTTP/1.1 404 Not found');
2027 2026
 			die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!');
@@ -2034,7 +2033,7 @@  discard block
 block discarded – undo
2034 2033
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY')
2035 2034
 			{
2036 2035
 				$sfxMimeType = $attachment['type'];
2037
-				$buff = explode('.',$attachment['tmp_name']);
2036
+				$buff = explode('.', $attachment['tmp_name']);
2038 2037
 				$suffix = '';
2039 2038
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2040 2039
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2046,10 +2045,10 @@  discard block
 block discarded – undo
2046 2045
 			{
2047 2046
 				//error_log(__METHOD__."about to call calendar_ical");
2048 2047
 				$calendar_ical = new calendar_ical();
2049
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2048
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2050 2049
 				//error_log(__METHOD__.array2string($eventid));
2051 2050
 				if (!$eventid) $eventid = -1;
2052
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
2051
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true);
2053 2052
 				//error_log(__METHOD__.$event);
2054 2053
 				if ((int)$event > 0)
2055 2054
 				{
@@ -2057,7 +2056,7 @@  discard block
 block discarded – undo
2057 2056
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2058 2057
 						'cal_id'      => $event,
2059 2058
 					);
2060
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
2059
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
2061 2060
 				}
2062 2061
 				//Import failed, download content anyway
2063 2062
 			}
@@ -2072,13 +2071,13 @@  discard block
 block discarded – undo
2072 2071
 				{
2073 2072
 					$vcard['uid'] = trim($vcard['uid']);
2074 2073
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2075
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2074
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2076 2075
 				}
2077 2076
 				if (!$contact) $contact = null;
2078 2077
 				// 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))
2079
-				if ($contact || count($vcard)>2)
2078
+				if ($contact || count($vcard) > 2)
2080 2079
 				{
2081
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true);
2080
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ?array_shift($contact) : $contact), true);
2082 2081
 				}
2083 2082
 				if ((int)$contact > 0)
2084 2083
 				{
@@ -2086,13 +2085,13 @@  discard block
 block discarded – undo
2086 2085
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2087 2086
 						'contact_id'	=> $contact,
2088 2087
 					);
2089
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
2088
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
2090 2089
 				}
2091 2090
 				//Import failed, download content anyway
2092 2091
 			}
2093 2092
 		}
2094 2093
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2095
-		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
2094
+		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save");
2096 2095
 		echo $attachment['attachment'];
2097 2096
 
2098 2097
 		exit();
@@ -2105,11 +2104,11 @@  discard block
 block discarded – undo
2105 2104
 	 * @param string haystack
2106 2105
 	 * @return boolean
2107 2106
 	 */
2108
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2107
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) {
2109 2108
 		foreach (array_keys($arrayToTestAgainst) as $k)
2110 2109
 		{
2111 2110
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
2112
-			if (stripos($haystack,$k)!==false)
2111
+			if (stripos($haystack, $k) !== false)
2113 2112
 			{
2114 2113
 				//error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace());
2115 2114
 				return true;
@@ -2132,10 +2131,10 @@  discard block
 block discarded – undo
2132 2131
 	 */
2133 2132
 	function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID)
2134 2133
 	{
2135
-		unset($_icServer);	// not used
2134
+		unset($_icServer); // not used
2136 2135
 		$foundAddresses = array();
2137 2136
 
2138
-		$mail_bo  = $this->mail_bo;
2137
+		$mail_bo = $this->mail_bo;
2139 2138
 		$mail_bo->openConnection();
2140 2139
 		$mail_bo->reopen($_folder);
2141 2140
 
@@ -2143,20 +2142,20 @@  discard block
 block discarded – undo
2143 2142
 
2144 2143
 		// get message headers for specified message
2145 2144
 		//print "AAAA: $_folder, $_uid, $_partID<br>";
2146
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true);
2145
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true);
2147 2146
 		//$headers	= $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder);
2148 2147
 		$this->sessionData['uid'] = $_uid;
2149 2148
 		$this->sessionData['messageFolder'] = $_folder;
2150
-		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']);
2151
-		$this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']);
2149
+		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']);
2150
+		$this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']);
2152 2151
 
2153 2152
 		// break reference into multiple lines if they're greater than 998 chars
2154 2153
 		// and remove comma seperation. Fix error serer does not support binary
2155 2154
 		// data due to long references.
2156
-		if (strlen($this->sessionData['references'])> 998)
2155
+		if (strlen($this->sessionData['references']) > 998)
2157 2156
 		{
2158
-			$temp_refs = explode(',',$this->sessionData['references']);
2159
-			$this->sessionData['references'] = implode(" ",$temp_refs);
2157
+			$temp_refs = explode(',', $this->sessionData['references']);
2158
+			$this->sessionData['references'] = implode(" ", $temp_refs);
2160 2159
 		}
2161 2160
 
2162 2161
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
@@ -2166,36 +2165,36 @@  discard block
 block discarded – undo
2166 2165
 		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2167 2166
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2168 2167
 		// check for Reply-To: header and use if available
2169
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2170
-			foreach($headers['REPLY-TO'] as $val) {
2171
-				if(!$foundAddresses[$val]) {
2168
+		if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2169
+			foreach ($headers['REPLY-TO'] as $val) {
2170
+				if (!$foundAddresses[$val]) {
2172 2171
 					$oldTo[] = $val;
2173 2172
 					$foundAddresses[$val] = true;
2174 2173
 				}
2175 2174
 			}
2176
-			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2175
+			$oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']);
2177 2176
 		} else {
2178
-			foreach($headers['FROM'] as $val) {
2179
-				if(!$foundAddresses[$val]) {
2177
+			foreach ($headers['FROM'] as $val) {
2178
+				if (!$foundAddresses[$val]) {
2180 2179
 					$oldTo[] = $val;
2181 2180
 					$foundAddresses[$val] = true;
2182 2181
 				}
2183 2182
 			}
2184
-			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2183
+			$oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']);
2185 2184
 		}
2186 2185
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2187
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2186
+		if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) {
2188 2187
 			$this->sessionData['to'] = $oldTo;
2189 2188
 		}
2190 2189
 
2191
-		if($_mode == 'all') {
2190
+		if ($_mode == 'all') {
2192 2191
 			// reply to any address which is cc, but not to my self
2193 2192
 			#if($headers->cc) {
2194
-				foreach($headers['CC'] as $val) {
2195
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2193
+				foreach ($headers['CC'] as $val) {
2194
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2196 2195
 						continue;
2197 2196
 					}
2198
-					if(!$foundAddresses[$val]) {
2197
+					if (!$foundAddresses[$val]) {
2199 2198
 						$this->sessionData['cc'][] = $val;
2200 2199
 						$foundAddresses[$val] = true;
2201 2200
 					}
@@ -2204,11 +2203,11 @@  discard block
 block discarded – undo
2204 2203
 
2205 2204
 			// reply to any address which is to, but not to my self
2206 2205
 			#if($headers->to) {
2207
-				foreach($headers['TO'] as $val) {
2208
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2206
+				foreach ($headers['TO'] as $val) {
2207
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2209 2208
 						continue;
2210 2209
 					}
2211
-					if(!$foundAddresses[$val]) {
2210
+					if (!$foundAddresses[$val]) {
2212 2211
 						$this->sessionData['to'][] = $val;
2213 2212
 						$foundAddresses[$val] = true;
2214 2213
 					}
@@ -2216,12 +2215,12 @@  discard block
 block discarded – undo
2216 2215
 			#}
2217 2216
 
2218 2217
 			#if($headers->from) {
2219
-				foreach($headers['FROM'] as $val) {
2220
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2218
+				foreach ($headers['FROM'] as $val) {
2219
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2221 2220
 						continue;
2222 2221
 					}
2223 2222
 					//error_log(__METHOD__.__LINE__.' '.$val);
2224
-					if(!$foundAddresses[$val]) {
2223
+					if (!$foundAddresses[$val]) {
2225 2224
 						$this->sessionData['to'][] = $val;
2226 2225
 						$foundAddresses[$val] = true;
2227 2226
 					}
@@ -2230,16 +2229,16 @@  discard block
 block discarded – undo
2230 2229
 		}
2231 2230
 
2232 2231
 		// check for Re: in subject header
2233
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2232
+		if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2234 2233
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2235 2234
 		} else {
2236
-			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2235
+			$this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']);
2237 2236
 		}
2238 2237
 
2239 2238
 		//_debug_array($headers);
2240 2239
 		//error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions']));
2241 2240
 		try {
2242
-			$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID);
2241
+			$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID);
2243 2242
 		}
2244 2243
 		catch (Mail\Smime\PassphraseMissing $e)
2245 2244
 		{
@@ -2249,52 +2248,52 @@  discard block
 block discarded – undo
2249 2248
 				' because the content of this message seems to be encrypted'.
2250 2249
 				' and can not be decrypted properly. If you still wish to include'.
2251 2250
 				' content of this encrypted message, you may try to use forward as'.
2252
-				' attachment instead.'),'error');
2251
+				' attachment instead.'), 'error');
2253 2252
 		}
2254 2253
 		//_debug_array($bodyParts);
2255 2254
 		$styles = Mail::getStyles($bodyParts);
2256 2255
 
2257
-		$fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM']));
2256
+		$fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM']));
2258 2257
 
2259 2258
 		$toAddressA = array();
2260 2259
 		$toAddress = '';
2261 2260
 		foreach ($headers['TO'] as $mailheader) {
2262
-			$toAddressA[] =  $mailheader;
2261
+			$toAddressA[] = $mailheader;
2263 2262
 		}
2264
-		if (count($toAddressA)>0)
2263
+		if (count($toAddressA) > 0)
2265 2264
 		{
2266
-			$toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA));
2267
-			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2265
+			$toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA));
2266
+			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2268 2267
 		}
2269 2268
 		$ccAddressA = array();
2270 2269
 		$ccAddress = '';
2271 2270
 		foreach ($headers['CC'] as $mailheader) {
2272
-			$ccAddressA[] =  $mailheader;
2271
+			$ccAddressA[] = $mailheader;
2273 2272
 		}
2274
-		if (count($ccAddressA)>0)
2273
+		if (count($ccAddressA) > 0)
2275 2274
 		{
2276
-			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2277
-			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2275
+			$ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA));
2276
+			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2278 2277
 		}
2279
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2280
-			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2278
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
2279
+			$this->sessionData['body'] = /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2281 2280
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2282 2281
 				$toAddress.$ccAddress.
2283
-				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2282
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>".
2284 2283
 				'----------------------------------------------------------'."</div>";
2285
-			$this->sessionData['mimeType'] 	= 'html';
2284
+			$this->sessionData['mimeType'] = 'html';
2286 2285
 			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2287
-			$this->sessionData['body']	.= '<blockquote type="cite">';
2286
+			$this->sessionData['body'] .= '<blockquote type="cite">';
2288 2287
 
2289
-			for($i=0; $i<count($bodyParts); $i++) {
2290
-				if($i>0) {
2288
+			for ($i = 0; $i < count($bodyParts); $i++) {
2289
+				if ($i > 0) {
2291 2290
 					$this->sessionData['body'] .= '<hr>';
2292 2291
 				}
2293
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2292
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
2294 2293
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2295 2294
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2296 2295
 				}
2297
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2296
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2298 2297
 
2299 2298
 				$_htmlConfig = Mail::$htmLawed_config;
2300 2299
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2304,37 +2303,37 @@  discard block
 block discarded – undo
2304 2303
 				#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2305 2304
 			}
2306 2305
 
2307
-			$this->sessionData['body']	.= '</blockquote><br>';
2308
-			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2306
+			$this->sessionData['body'] .= '</blockquote><br>';
2307
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2309 2308
 		} else {
2310 2309
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2311 2310
 			// 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)
2312
-            $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2311
+            $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2313 2312
                 @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2314 2313
 				$toAddress.$ccAddress.
2315
-				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
2314
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n".
2316 2315
                 '-------------------------------------------------'."\r\n \r\n ";
2317
-			$this->sessionData['mimeType']	= 'plain';
2316
+			$this->sessionData['mimeType'] = 'plain';
2318 2317
 
2319
-			for($i=0; $i<count($bodyParts); $i++) {
2320
-				if($i>0) {
2318
+			for ($i = 0; $i < count($bodyParts); $i++) {
2319
+				if ($i > 0) {
2321 2320
 					$this->sessionData['body'] .= "<hr>";
2322 2321
 				}
2323 2322
 
2324 2323
 				// add line breaks to $bodyParts
2325
-				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
2324
+				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
2326 2325
 				#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2327 2326
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2328 2327
 				$this->sessionData['body'] .= "\r\n";
2329 2328
 				$hasSignature = false;
2330 2329
 				// create body new, with good line breaks and indention
2331
-				foreach(explode("\n",$newBody) as $value) {
2330
+				foreach (explode("\n", $newBody) as $value) {
2332 2331
 					// the explode is removing the character
2333 2332
 					//$value .= 'ee';
2334 2333
 
2335 2334
 					// Try to remove signatures from qouted parts to avoid multiple
2336 2335
 					// signatures problem in reply (rfc3676#section-4.3).
2337
-					if ($_mode != 'forward' && ($hasSignature || ($hasSignature = preg_match("/^--\s[\r\n]$/",$value))))
2336
+					if ($_mode != 'forward' && ($hasSignature || ($hasSignature = preg_match("/^--\s[\r\n]$/", $value))))
2338 2337
 					{
2339 2338
 						continue;
2340 2339
 					}
@@ -2342,12 +2341,12 @@  discard block
 block discarded – undo
2342 2341
 					$numberOfChars = strspn(trim($value), ">");
2343 2342
 					$appendString = str_repeat('>', $numberOfChars + 1);
2344 2343
 
2345
-					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2344
+					$bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>');
2346 2345
 
2347
-					if($bodyAppend[0] == '>') {
2348
-						$bodyAppend = '>'. $bodyAppend;
2346
+					if ($bodyAppend[0] == '>') {
2347
+						$bodyAppend = '>'.$bodyAppend;
2349 2348
 					} else {
2350
-						$bodyAppend = '> '. $bodyAppend;
2349
+						$bodyAppend = '> '.$bodyAppend;
2351 2350
 					}
2352 2351
 
2353 2352
 					$this->sessionData['body'] .= $bodyAppend;
@@ -2370,16 +2369,16 @@  discard block
 block discarded – undo
2370 2369
 	 */
2371 2370
 	static function _getCleanHTML($_body, $_useTidy = false)
2372 2371
 	{
2373
-		static $nonDisplayAbleCharacters = array('[\016]','[\017]',
2374
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2375
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2372
+		static $nonDisplayAbleCharacters = array('[\016]', '[\017]',
2373
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2374
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2376 2375
 
2377
-		if ($_useTidy && extension_loaded('tidy') )
2376
+		if ($_useTidy && extension_loaded('tidy'))
2378 2377
 		{
2379 2378
 			$tidy = new tidy();
2380
-			$cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8');
2379
+			$cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8');
2381 2380
 			// Found errors. Strip it all so there's some output
2382
-			if($tidy->getStatus() == 2)
2381
+			if ($tidy->getStatus() == 2)
2383 2382
 			{
2384 2383
 				error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
2385 2384
 			}
@@ -2413,13 +2412,13 @@  discard block
 block discarded – undo
2413 2412
 	 *
2414 2413
 	 * @return array returns found inline images as attachment structure
2415 2414
 	 */
2416
-	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
2415
+	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false)
2417 2416
 	{
2418 2417
 		if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----')
2419 2418
 		{
2420 2419
 			$_formData['mimeType'] = 'openpgp';
2421 2420
 		}
2422
-		$mail_bo	= $this->mail_bo;
2421
+		$mail_bo = $this->mail_bo;
2423 2422
 		$activeMailProfile = Mail\Account::read($this->mail_bo->profileID);
2424 2423
 
2425 2424
 		// you need to set the sender, if you work with different identities, since most smtp servers, dont allow
@@ -2428,37 +2427,37 @@  discard block
 block discarded – undo
2428 2427
 		{
2429 2428
 			error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity));
2430 2429
 		}
2431
-		$email_From =  $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
2430
+		$email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
2432 2431
 		// Try to fix identity email with no domain part set
2433 2432
 		$_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From),
2434
-			Mail::generateIdentityString($_identity,false));
2433
+			Mail::generateIdentityString($_identity, false));
2435 2434
 
2436 2435
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2437 2436
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2438
-		if(!empty($_formData['in-reply-to'])) {
2439
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2437
+		if (!empty($_formData['in-reply-to'])) {
2438
+			if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>';
2440 2439
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2441 2440
 		}
2442
-		if(!empty($_formData['references'])) {
2443
-			if (stripos($_formData['references'],'<')===false)
2441
+		if (!empty($_formData['references'])) {
2442
+			if (stripos($_formData['references'], '<') === false)
2444 2443
 			{
2445
-				$_formData['references']='<'.trim($_formData['references']).'>';
2444
+				$_formData['references'] = '<'.trim($_formData['references']).'>';
2446 2445
 			}
2447 2446
 			$_mailObject->addHeader('References', $_formData['references']);
2448 2447
 		}
2449 2448
 
2450
-		if(!empty($_formData['thread-index'])) {
2449
+		if (!empty($_formData['thread-index'])) {
2451 2450
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2452 2451
 		}
2453
-		if(!empty($_formData['list-id'])) {
2452
+		if (!empty($_formData['list-id'])) {
2454 2453
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2455 2454
 		}
2456
-		if($_formData['disposition']=='on') {
2455
+		if ($_formData['disposition'] == 'on') {
2457 2456
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2458 2457
 		}
2459 2458
 
2460 2459
 		// Expand any mailing lists
2461
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2460
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $field)
2462 2461
 		{
2463 2462
 			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2464 2463
 
@@ -2474,7 +2473,7 @@  discard block
 block discarded – undo
2474 2473
 		}
2475 2474
 		$disableRuler = false;
2476 2475
 		$signature = $_identity['ident_signature'];
2477
-		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0;
2476
+		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0;
2478 2477
 		if ($sigAlreadyThere)
2479 2478
 		{
2480 2479
 			// note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature
@@ -2483,7 +2482,7 @@  discard block
 block discarded – undo
2483 2482
 		}
2484 2483
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
2485 2484
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
2486
-			empty($signature) || trim($this->convertHTMLToText($signature)) =='')
2485
+			empty($signature) || trim($this->convertHTMLToText($signature)) == '')
2487 2486
 		{
2488 2487
 			$disableRuler = true;
2489 2488
 		}
@@ -2509,13 +2508,13 @@  discard block
 block discarded – undo
2509 2508
 						$body .= $attachment_links;
2510 2509
 					}
2511 2510
 				}
2512
-				if(!empty($signature))
2511
+				if (!empty($signature))
2513 2512
 				{
2514 2513
 					$_mailObject->setBody($this->convertHTMLToText($body, true, true).
2515 2514
 						($disableRuler ? "\r\n" : "\r\n-- \r\n").
2516 2515
 						$this->convertHTMLToText($signature, true, true));
2517 2516
 
2518
-					$body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature;
2517
+					$body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature;
2519 2518
 				}
2520 2519
 				else
2521 2520
 				{
@@ -2523,24 +2522,24 @@  discard block
 block discarded – undo
2523 2522
 				}
2524 2523
 				// convert URL Images to inline images - if possible
2525 2524
 				if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2526
-				if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2525
+				if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false)
2527 2526
 				{
2528
-					$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
2527
+					$body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body);
2529 2528
 				}
2530
-				$_mailObject->setHtmlBody($body, null, false);	// false = no automatic alternative, we called setBody()
2529
+				$_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody()
2531 2530
 				break;
2532 2531
 			case 'openpgp':
2533 2532
 				$_mailObject->setOpenPgpBody($_formData['body']);
2534 2533
 				break;
2535 2534
 			default:
2536
-				$body = $this->convertHTMLToText($_formData['body'],false, false, true, true);
2535
+				$body = $this->convertHTMLToText($_formData['body'], false, false, true, true);
2537 2536
 
2538 2537
 				if ($attachment_links) $body .= $attachment_links;
2539 2538
 
2540 2539
 				#$_mailObject->Body = $_formData['body'];
2541
-				if(!empty($signature)) {
2542
-					$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2543
-						$this->convertHTMLToText($signature,true,true);
2540
+				if (!empty($signature)) {
2541
+					$body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n").
2542
+						$this->convertHTMLToText($signature, true, true);
2544 2543
 				}
2545 2544
 				$_mailObject->setBody($body);
2546 2545
 		}
@@ -2549,8 +2548,8 @@  discard block
 block discarded – undo
2549 2548
 		{
2550 2549
 			$connection_opened = false;
2551 2550
 			$tnfattachments = null;
2552
-			foreach((array)$_formData['attachments'] as $attachment) {
2553
-				if(is_array($attachment))
2551
+			foreach ((array)$_formData['attachments'] as $attachment) {
2552
+				if (is_array($attachment))
2554 2553
 				{
2555 2554
 					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2556 2555
 						/* Example:
@@ -2568,20 +2567,20 @@  discard block
 block discarded – undo
2568 2567
 							$connection_opened = true;
2569 2568
 						}
2570 2569
 						$mail_bo->reopen($attachment['folder']);
2571
-						switch(strtoupper($attachment['type'])) {
2570
+						switch (strtoupper($attachment['type'])) {
2572 2571
 							case 'MESSAGE/RFC':
2573 2572
 							case 'MESSAGE/RFC822':
2574
-								$rawBody='';
2573
+								$rawBody = '';
2575 2574
 								if (isset($attachment['partID'])) {
2576
-									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2577
-									$rawBody=$eml['attachment'];
2575
+									$eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']);
2576
+									$rawBody = $eml['attachment'];
2578 2577
 								} else {
2579
-									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2578
+									$rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']);
2580 2579
 								}
2581 2580
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
2582 2581
 								break;
2583 2582
 							default:
2584
-								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2583
+								$attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false);
2585 2584
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2586 2585
 								{
2587 2586
 									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
@@ -2589,7 +2588,7 @@  discard block
 block discarded – undo
2589 2588
 									{
2590 2589
 										if ($k['name'] == $attachment['name'])
2591 2590
 										{
2592
-											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']);
2591
+											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']);
2593 2592
 											$attachmentData['attachment'] = $tnfpart['attachment'];
2594 2593
 											break;
2595 2594
 										}
@@ -2602,7 +2601,7 @@  discard block
 block discarded – undo
2602 2601
 					// attach files not for autosaving
2603 2602
 					elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving)
2604 2603
 					{
2605
-						if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
2604
+						if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs')
2606 2605
 						{
2607 2606
 							Vfs::load_wrapper('vfs');
2608 2607
 							$tmp_path = $attachment['file'];
@@ -2611,7 +2610,7 @@  discard block
 block discarded – undo
2611 2610
 						{
2612 2611
 							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['file']);
2613 2612
 						}
2614
-						$_mailObject->addAttachment (
2613
+						$_mailObject->addAttachment(
2615 2614
 							$tmp_path,
2616 2615
 							$attachment['name'],
2617 2616
 							$attachment['type']
@@ -2621,7 +2620,7 @@  discard block
 block discarded – undo
2621 2620
 			}
2622 2621
 			if ($connection_opened) $mail_bo->closeConnection();
2623 2622
 		}
2624
-		return is_array($inline_images)?$inline_images:array();
2623
+		return is_array($inline_images) ? $inline_images : array();
2625 2624
 	}
2626 2625
 
2627 2626
 	/**
@@ -2637,16 +2636,16 @@  discard block
 block discarded – undo
2637 2636
 	 * @param string $password =null
2638 2637
 	 * @return string might be empty if no file attachments found
2639 2638
 	 */
2640
-	protected function _getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2639
+	protected function _getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null)
2641 2640
 	{
2642 2641
 		if ($filemode == Vfs\Sharing::ATTACH) return '';
2643 2642
 
2644 2643
 		$links = array();
2645
-		foreach($attachments as $attachment)
2644
+		foreach ($attachments as $attachment)
2646 2645
 		{
2647 2646
 			$path = $attachment['file'];
2648
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2649
-			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2647
+			if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts
2648
+			if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs')
2650 2649
 			{
2651 2650
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
2652 2651
 			}
@@ -2676,7 +2675,7 @@  discard block
 block discarded – undo
2676 2675
 		}
2677 2676
 		if (!$links)
2678 2677
 		{
2679
-			return null;	// no file attachments found
2678
+			return null; // no file attachments found
2680 2679
 		}
2681 2680
 		elseif ($html)
2682 2681
 		{
@@ -2691,7 +2690,7 @@  discard block
 block discarded – undo
2691 2690
 	 * @param array $content content sent from client-side
2692 2691
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2693 2692
 	 */
2694
-	public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
2693
+	public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]')
2695 2694
 	{
2696 2695
 		//error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)");
2697 2696
 		$response = Api\Json\Response::get();
@@ -2705,8 +2704,8 @@  discard block
 block discarded – undo
2705 2704
 
2706 2705
 		$formData = array_merge($content, array(
2707 2706
 			'isDrafted' => 1,
2708
-			'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')],
2709
-			'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value
2707
+			'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')],
2708
+			'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value
2710 2709
 		));
2711 2710
 
2712 2711
 		//Saving draft procedure
@@ -2718,8 +2717,8 @@  discard block
 block discarded – undo
2718 2717
 			if (($messageUid = $this->saveAsDraft($formData, $folder, $action)))
2719 2718
 			{
2720 2719
 				// saving as draft, does not mean closing the message
2721
-				$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
2722
-				if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder)))
2720
+				$messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid);
2721
+				if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder)))
2723 2722
 				{
2724 2723
 					$draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid);
2725 2724
 					if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted']))
@@ -2728,7 +2727,7 @@  discard block
 block discarded – undo
2728 2727
 						$duid = $dhA['msgUID'];
2729 2728
 						$dmailbox = $dhA['folder'];
2730 2729
 						// beware: do not delete the original mail as found in processedmail_id
2731
-						$pMuid='';
2730
+						$pMuid = '';
2732 2731
 						if ($content['processedmail_id'])
2733 2732
 						{
2734 2733
 							$pMhA = mail_ui::splitRowID($content['processedmail_id']);
@@ -2736,15 +2735,15 @@  discard block
 block discarded – undo
2736 2735
 						}
2737 2736
 						//error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments']));
2738 2737
 						// do not delete the original message if attachments are present
2739
-						if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments']))
2738
+						if (empty($pMuid) || $pMuid != $duid || empty($content['attachments']))
2740 2739
 						{
2741 2740
 							try
2742 2741
 							{
2743
-								$this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately');
2742
+								$this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately');
2744 2743
 							}
2745 2744
 							catch (Api\Exception $e)
2746 2745
 							{
2747
-								$msg = str_replace('"',"'",$e->getMessage());
2746
+								$msg = str_replace('"', "'", $e->getMessage());
2748 2747
 								$success = false;
2749 2748
 								error_log(__METHOD__.__LINE__.$msg);
2750 2749
 							}
@@ -2765,7 +2764,7 @@  discard block
 block discarded – undo
2765 2764
 		}
2766 2765
 		catch (Api\Exception\WrongUserinput $e)
2767 2766
 		{
2768
-			$msg = str_replace('"',"'",$e->getMessage());
2767
+			$msg = str_replace('"', "'", $e->getMessage());
2769 2768
 			error_log(__METHOD__.__LINE__.$msg);
2770 2769
 			$success = false;
2771 2770
 		}
@@ -2789,17 +2788,17 @@  discard block
 block discarded – undo
2789 2788
 	static function resolveEmailAddressList($_emailAddressList)
2790 2789
 	{
2791 2790
 		$contacts_obs = null;
2792
-		$addrFromList=array();
2793
-		foreach((array)$_emailAddressList as $ak => $address)
2791
+		$addrFromList = array();
2792
+		foreach ((array)$_emailAddressList as $ak => $address)
2794 2793
 		{
2795
-			if(is_int($address))
2794
+			if (is_int($address))
2796 2795
 			{
2797 2796
 				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
2798 2797
 				// List was selected, expand to addresses
2799 2798
 				unset($_emailAddressList[$ak]);
2800
-				$list = $contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address));
2799
+				$list = $contacts_obj->search('', array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'), '', '', '', False, 'AND', false, array('list' =>(int)$address));
2801 2800
 				// Just add email addresses, they'll be checked below
2802
-				foreach($list as $email)
2801
+				foreach ($list as $email)
2803 2802
 				{
2804 2803
 					$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
2805 2804
 				}
@@ -2809,7 +2808,7 @@  discard block
 block discarded – undo
2809 2808
 		{
2810 2809
 			foreach ($addrFromList as $addr)
2811 2810
 			{
2812
-				if (!empty($addr)) $_emailAddressList[]=$addr;
2811
+				if (!empty($addr)) $_emailAddressList[] = $addr;
2813 2812
 			}
2814 2813
 		}
2815 2814
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2823,15 +2822,15 @@  discard block
 block discarded – undo
2823 2822
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2824 2823
 	 * @return boolean return messageUID| false due to an error
2825 2824
 	 */
2826
-	function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]')
2825
+	function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]')
2827 2826
 	{
2828 2827
 		//error_log(__METHOD__."(..., $savingDestination, action=$action)");
2829
-		$mail_bo	= $this->mail_bo;
2830
-		$mail		= new Api\Mailer($this->mail_bo->profileID);
2828
+		$mail_bo = $this->mail_bo;
2829
+		$mail = new Api\Mailer($this->mail_bo->profileID);
2831 2830
 
2832 2831
 		// preserve the bcc and if possible the save to folder information
2833
-		$this->sessionData['folder']    = $_formData['folder'];
2834
-		$this->sessionData['bcc']   = $_formData['bcc'];
2832
+		$this->sessionData['folder'] = $_formData['folder'];
2833
+		$this->sessionData['bcc'] = $_formData['bcc'];
2835 2834
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2836 2835
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2837 2836
 		$this->sessionData['mailaccount']  = $_formData['mailaccount'];
@@ -2840,11 +2839,11 @@  discard block
 block discarded – undo
2840 2839
 		{
2841 2840
 			$acc = Mail\Account::read($this->sessionData['mailaccount']);
2842 2841
 			//error_log(__METHOD__.__LINE__.array2string($acc));
2843
-			$identity = Mail\Account::read_identity($acc['ident_id'],true);
2842
+			$identity = Mail\Account::read_identity($acc['ident_id'], true);
2844 2843
 		}
2845 2844
 		catch (Exception $e)
2846 2845
 		{
2847
-			$identity=array();
2846
+			$identity = array();
2848 2847
 		}
2849 2848
 
2850 2849
 		$flags = '\\Seen \\Draft';
@@ -2854,7 +2853,7 @@  discard block
 block discarded – undo
2854 2853
 		// folder list as Customheader
2855 2854
 		if (!empty($this->sessionData['folder']))
2856 2855
 		{
2857
-			$folders = implode('|',array_unique($this->sessionData['folder']));
2856
+			$folders = implode('|', array_unique($this->sessionData['folder']));
2858 2857
 			$mail->addHeader('X-Mailfolder', $folders);
2859 2858
 		}
2860 2859
 		$mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']);
@@ -2874,25 +2873,25 @@  discard block
 block discarded – undo
2874 2873
 			$savingDestination = $this->sessionData['messageFolder'];
2875 2874
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2876 2875
 		}
2877
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
2876
+		if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder();
2878 2877
 
2879 2878
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2880 2879
 		$mail->forceBccHeader();
2881 2880
 
2882 2881
 		$mail_bo->openConnection();
2883
-		if ($mail_bo->folderExists($savingDestination,true)) {
2882
+		if ($mail_bo->folderExists($savingDestination, true)) {
2884 2883
 			try
2885 2884
 			{
2886 2885
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
2887 2886
 			}
2888 2887
 			catch (Api\Exception\WrongUserinput $e)
2889 2888
 			{
2890
-				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage()));
2889
+				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage()));
2891 2890
 				return false;
2892 2891
 			}
2893 2892
 
2894 2893
 		} else {
2895
-			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2894
+			error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server."));
2896 2895
 			return false;
2897 2896
 		}
2898 2897
 		$mail_bo->closeConnection();
@@ -2901,28 +2900,28 @@  discard block
 block discarded – undo
2901 2900
 
2902 2901
 	function send($_formData)
2903 2902
 	{
2904
-		$mail_bo	= $this->mail_bo;
2905
-		$mail 		= new Api\Mailer($mail_bo->profileID);
2906
-		$messageIsDraft	=  false;
2903
+		$mail_bo = $this->mail_bo;
2904
+		$mail = new Api\Mailer($mail_bo->profileID);
2905
+		$messageIsDraft = false;
2907 2906
 
2908
-		$this->sessionData['mailaccount']	= $_formData['mailaccount'];
2907
+		$this->sessionData['mailaccount'] = $_formData['mailaccount'];
2909 2908
 		$this->sessionData['to']	= self::resolveEmailAddressList($_formData['to']);
2910 2909
 		$this->sessionData['cc']	= self::resolveEmailAddressList($_formData['cc']);
2911
-		$this->sessionData['bcc']	= self::resolveEmailAddressList($_formData['bcc']);
2912
-		$this->sessionData['folder']	= $_formData['folder'];
2910
+		$this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']);
2911
+		$this->sessionData['folder'] = $_formData['folder'];
2913 2912
 		$this->sessionData['replyto']	= $_formData['replyto'];
2914 2913
 		$this->sessionData['subject']	= trim($_formData['subject']);
2915
-		$this->sessionData['body']	= $_formData['body'];
2916
-		$this->sessionData['priority']	= $_formData['priority'];
2914
+		$this->sessionData['body'] = $_formData['body'];
2915
+		$this->sessionData['priority'] = $_formData['priority'];
2917 2916
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2918 2917
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2919 2918
 		$this->sessionData['disposition'] = $_formData['disposition'];
2920
-		$this->sessionData['mimeType']	= $_formData['mimeType'];
2919
+		$this->sessionData['mimeType'] = $_formData['mimeType'];
2921 2920
 		$this->sessionData['to_infolog'] = $_formData['to_infolog'];
2922 2921
 		$this->sessionData['to_tracker'] = $_formData['to_tracker'];
2923
-		$this->sessionData['attachments']  = $_formData['attachments'];
2924
-		$this->sessionData['smime_sign']  = $_formData['smime_sign'];
2925
-		$this->sessionData['smime_encrypt']  = $_formData['smime_encrypt'];
2922
+		$this->sessionData['attachments'] = $_formData['attachments'];
2923
+		$this->sessionData['smime_sign'] = $_formData['smime_sign'];
2924
+		$this->sessionData['smime_encrypt'] = $_formData['smime_encrypt'];
2926 2925
 
2927 2926
 		if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted']))
2928 2927
 		{
@@ -2931,11 +2930,11 @@  discard block
 block discarded – undo
2931 2930
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']);
2932 2931
 		if (isset($_formData['mode']) && !empty($_formData['mode']))
2933 2932
 		{
2934
-			if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id']))
2933
+			if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id']))
2935 2934
 			{
2936
-				$this->sessionData['forwardFlag']='forwarded';
2937
-				$_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']);
2938
-				$this->sessionData['uid']=array();
2935
+				$this->sessionData['forwardFlag'] = 'forwarded';
2936
+				$_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']);
2937
+				$this->sessionData['uid'] = array();
2939 2938
 				foreach ($_formData['processedmail_id'] as $k =>$rowid)
2940 2939
 				{
2941 2940
 					$fhA = mail_ui::splitRowID($rowid);
@@ -2944,13 +2943,13 @@  discard block
 block discarded – undo
2944 2943
 					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
2945 2944
 				}
2946 2945
 			}
2947
-			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
2946
+			if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id']))
2948 2947
 			{
2949 2948
 				$rhA = mail_ui::splitRowID($_formData['processedmail_id']);
2950 2949
 				$this->sessionData['uid'] = $rhA['msgUID'];
2951 2950
 				$this->sessionData['messageFolder'] = $rhA['folder'];
2952 2951
 			}
2953
-			if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id']))
2952
+			if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id']))
2954 2953
 			{
2955 2954
 				$dhA = mail_ui::splitRowID($_formData['processedmail_id']);
2956 2955
 				$this->sessionData['uid'] = $dhA['msgUID'];
@@ -2959,26 +2958,26 @@  discard block
 block discarded – undo
2959 2958
 		}
2960 2959
 		// if the body is empty, maybe someone pasted something with scripts, into the message body
2961 2960
 		// this should not happen anymore, unless you call send directly, since the check was introduced with the action command
2962
-		if(empty($this->sessionData['body']))
2961
+		if (empty($this->sessionData['body']))
2963 2962
 		{
2964 2963
 			// this is to be found with the egw_unset_vars array for the _POST['body'] array
2965
-			$name='_POST';
2966
-			$key='body';
2964
+			$name = '_POST';
2965
+			$key = 'body';
2967 2966
 			#error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2968 2967
 			if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']']))
2969 2968
 			{
2970
-				$this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2971
-				$_formData['body']=$this->sessionData['body'];
2969
+				$this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2970
+				$_formData['body'] = $this->sessionData['body'];
2972 2971
 			}
2973 2972
 			#error_log($this->sessionData['body']);
2974 2973
 		}
2975
-		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2974
+		if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2976 2975
 		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
2977 2976
 		   	$messageIsDraft = true;
2978 2977
 		}
2979 2978
 		try
2980 2979
 		{
2981
-			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true);
2980
+			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true);
2982 2981
 		}
2983 2982
 		catch (Exception $e)
2984 2983
 		{
@@ -2989,7 +2988,7 @@  discard block
 block discarded – undo
2989 2988
 		// create the messages and store inline images
2990 2989
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2991 2990
 		// remember the identity
2992
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2991
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2993 2992
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2994 2993
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2995 2994
 		#exit;
@@ -3000,12 +2999,12 @@  discard block
 block discarded – undo
3000 2999
 		$folderOnMailAccount = array();
3001 3000
 		foreach ($folderToCheck as $k => $f)
3002 3001
 		{
3003
-			$fval=$f;
3004
-			$icServerID = $_formData['serverID'];//folders always assumed with serverID
3005
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3006
-			if ($_formData['serverID']!=$_formData['mailaccount'])
3002
+			$fval = $f;
3003
+			$icServerID = $_formData['serverID']; //folders always assumed with serverID
3004
+			if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2);
3005
+			if ($_formData['serverID'] != $_formData['mailaccount'])
3007 3006
 			{
3008
-				if ($icServerID == $_formData['serverID'] )
3007
+				if ($icServerID == $_formData['serverID'])
3009 3008
 				{
3010 3009
 					$folder[$fval] = $fval;
3011 3010
 					$folderOnServerID[] = $fval;
@@ -3018,7 +3017,7 @@  discard block
 block discarded – undo
3018 3017
 			}
3019 3018
 			else
3020 3019
 			{
3021
-				if ($icServerID == $_formData['serverID'] )
3020
+				if ($icServerID == $_formData['serverID'])
3022 3021
 				{
3023 3022
 					$folder[$fval] = $fval;
3024 3023
 					$folderOnServerID[] = $fval;
@@ -3035,7 +3034,7 @@  discard block
 block discarded – undo
3035 3034
 		// we use the sentFolder settings of the choosen mailaccount
3036 3035
 		// sentFolder is account specific
3037 3036
 		$changeProfileOnSentFolderNeeded = false;
3038
-		if ($_formData['serverID']!=$_formData['mailaccount'])
3037
+		if ($_formData['serverID'] != $_formData['mailaccount'])
3039 3038
 		{
3040 3039
 			$this->changeProfile($_formData['mailaccount']);
3041 3040
 			//error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#');
@@ -3043,30 +3042,30 @@  discard block
 block discarded – undo
3043 3042
 			// sentFolder is account specific
3044 3043
 			$sentFolder = $this->mail_bo->getSentFolder();
3045 3044
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
3046
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3045
+			if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
3047 3046
 		}
3048 3047
 		else
3049 3048
 		{
3050 3049
 			$sentFolder = $mail_bo->getSentFolder();
3051 3050
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
3052
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3051
+			if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
3053 3052
 		}
3054 3053
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
3055 3054
 
3056 3055
 		// we switch $this->mail_bo back to the account we used to work on
3057
-		if ($_formData['serverID']!=$_formData['mailaccount'])
3056
+		if ($_formData['serverID'] != $_formData['mailaccount'])
3058 3057
 		{
3059 3058
 			$this->changeProfile($_formData['serverID']);
3060 3059
 		}
3061 3060
 
3062 3061
 
3063
-		if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
3062
+		if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
3064 3063
 			$this->mailPreferences['sendOptions'] != 'send_only' &&
3065 3064
 			$messageIsDraft == false)
3066 3065
 		{
3067 3066
 			if ($sentFolder)
3068 3067
 			{
3069
-				if ($_formData['serverID']!=$_formData['mailaccount'])
3068
+				if ($_formData['serverID'] != $_formData['mailaccount'])
3070 3069
 				{
3071 3070
 					$folderOnMailAccount[] = $sentFolder;
3072 3071
 				}
@@ -3083,14 +3082,14 @@  discard block
 block discarded – undo
3083 3082
 		}
3084 3083
 		else
3085 3084
 		{
3086
-			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
3085
+			if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
3087 3086
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
3088 3087
 				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3089 3088
 		}
3090 3089
 		// draftFolder is on Server we start from
3091
-		if($messageIsDraft == true) {
3090
+		if ($messageIsDraft == true) {
3092 3091
 			$draftFolder = $mail_bo->getDraftFolder();
3093
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3092
+			if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) {
3094 3093
 				$this->sessionData['folder'] = array($draftFolder);
3095 3094
 				$folderOnServerID[] = $draftFolder;
3096 3095
 				$folder[$draftFolder] = $draftFolder;
@@ -3099,18 +3098,18 @@  discard block
 block discarded – undo
3099 3098
 		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
3100 3099
 		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3101 3100
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
3102
-			!( count($folder) > 0) &&
3103
-			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
3101
+			!(count($folder) > 0) &&
3102
+			!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on'))
3104 3103
 		{
3105
-			$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:'');
3104
+			$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 : '');
3106 3105
 			#error_log($this->errorInfo);
3107 3106
 			return false;
3108 3107
 		}
3109 3108
 		// SMIME SIGN/ENCRYPTION
3110
-		if ($_formData['smime_sign'] == 'on' || $_formData['smime_encrypt'] == 'on' )
3109
+		if ($_formData['smime_sign'] == 'on' || $_formData['smime_encrypt'] == 'on')
3111 3110
 		{
3112
-			$recipients = array_merge($_formData['to'], (array) $_formData['cc'], (array) $_formData['bcc']);
3113
-			try	{
3111
+			$recipients = array_merge($_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc']);
3112
+			try {
3114 3113
 				if ($_formData['smime_sign'] == 'on')
3115 3114
 				{
3116 3115
 					if ($_formData['smime_passphrase'] != '') {
@@ -3123,7 +3122,7 @@  discard block
 block discarded – undo
3123 3122
 					}
3124 3123
 					$smime_success = $this->_encrypt(
3125 3124
 						$mail,
3126
-						$_formData['smime_encrypt'] == 'on'? Mail\Smime::TYPE_SIGN_ENCRYPT: Mail\Smime::TYPE_SIGN,
3125
+						$_formData['smime_encrypt'] == 'on' ? Mail\Smime::TYPE_SIGN_ENCRYPT : Mail\Smime::TYPE_SIGN,
3127 3126
 						Mail::stripRFC822Addresses($recipients),
3128 3127
 						$identity['ident_email'],
3129 3128
 						$_formData['smime_passphrase']
@@ -3131,16 +3130,15 @@  discard block
 block discarded – undo
3131 3130
 					if (!$smime_success)
3132 3131
 					{
3133 3132
 						$response = Api\Json\Response::get();
3134
-						$this->errorInfo = $_formData['smime_passphrase'] == ''?
3135
-								lang('You need to enter your S/MIME passphrase to send this message.'):
3136
-								lang('The entered passphrase is not correct! Please try again.');
3133
+						$this->errorInfo = $_formData['smime_passphrase'] == '' ?
3134
+								lang('You need to enter your S/MIME passphrase to send this message.') : lang('The entered passphrase is not correct! Please try again.');
3137 3135
 						$response->call('app.mail.smimePassDialog', $this->errorInfo);
3138 3136
 						return false;
3139 3137
 					}
3140 3138
 				}
3141 3139
 				elseif ($_formData['smime_sign'] == 'off' && $_formData['smime_encrypt'] == 'on')
3142 3140
 				{
3143
-					$smime_success =  $this->_encrypt(
3141
+					$smime_success = $this->_encrypt(
3144 3142
 						$mail,
3145 3143
 						Mail\Smime::TYPE_ENCRYPT,
3146 3144
 						Mail::stripRFC822Addresses($recipients),
@@ -3160,23 +3158,23 @@  discard block
 block discarded – undo
3160 3158
 		@set_time_limit(120);
3161 3159
 		//$mail->SMTPDebug = 10;
3162 3160
 		//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']));
3163
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3161
+		if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3164 3162
 			try {
3165 3163
 				// do no close the session before sending, if we have to store the send text for infolog or other integration in the session
3166
-				if (!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ))
3164
+				if (!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on'))
3167 3165
 				{
3168 3166
 					$GLOBALS['egw']->session->commit_session();
3169 3167
 				}
3170 3168
 				$mail->send();
3171 3169
 			}
3172
-			catch(Exception $e) {
3170
+			catch (Exception $e) {
3173 3171
 				_egw_log_exception($e);
3174 3172
 				//if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details));
3175
-				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
3173
+				$this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : '');
3176 3174
 				return false;
3177 3175
 			}
3178 3176
 		} else {
3179
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3177
+			if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) {
3180 3178
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
3181 3179
 			} else {
3182 3180
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
@@ -3204,15 +3202,15 @@  discard block
 block discarded – undo
3204 3202
 		// copying mail to folder
3205 3203
 		if (count($folder) > 0)
3206 3204
 		{
3207
-			foreach($folderOnServerID as $folderName) {
3205
+			foreach ($folderOnServerID as $folderName) {
3208 3206
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3209 3207
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3210 3208
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3211 3209
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3212
-				if ($mail_bo->folderExists($folderName,true)) {
3213
-					if($mail_bo->isSentFolder($folderName)) {
3210
+				if ($mail_bo->folderExists($folderName, true)) {
3211
+					if ($mail_bo->isSentFolder($folderName)) {
3214 3212
 						$flags = '\\Seen';
3215
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3213
+					} elseif ($mail_bo->isDraftFolder($folderName)) {
3216 3214
 						$flags = '\\Draft';
3217 3215
 					} else {
3218 3216
 						$flags = '\\Seen';
@@ -3228,25 +3226,25 @@  discard block
 block discarded – undo
3228 3226
 					}
3229 3227
 					catch (Api\Exception\WrongUserinput $e)
3230 3228
 					{
3231
-						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()));
3229
+						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()));
3232 3230
 					}
3233 3231
 				}
3234 3232
 				else
3235 3233
 				{
3236
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3234
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3237 3235
 				}
3238 3236
 			}
3239 3237
 			// if we choose to send from a differing profile
3240 3238
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3241
-			foreach($folderOnMailAccount as $folderName) {
3239
+			foreach ($folderOnMailAccount as $folderName) {
3242 3240
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3243 3241
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3244 3242
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3245 3243
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3246
-				if ($this->mail_bo->folderExists($folderName,true)) {
3247
-					if($this->mail_bo->isSentFolder($folderName)) {
3244
+				if ($this->mail_bo->folderExists($folderName, true)) {
3245
+					if ($this->mail_bo->isSentFolder($folderName)) {
3248 3246
 						$flags = '\\Seen';
3249
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3247
+					} elseif ($this->mail_bo->isDraftFolder($folderName)) {
3250 3248
 						$flags = '\\Draft';
3251 3249
 					} else {
3252 3250
 						$flags = '\\Seen';
@@ -3262,12 +3260,12 @@  discard block
 block discarded – undo
3262 3260
 					}
3263 3261
 					catch (Api\Exception\WrongUserinput $e)
3264 3262
 					{
3265
-						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()));
3263
+						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()));
3266 3264
 					}
3267 3265
 				}
3268 3266
 				else
3269 3267
 				{
3270
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3268
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3271 3269
 				}
3272 3270
 			}
3273 3271
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
@@ -3278,27 +3276,27 @@  discard block
 block discarded – undo
3278 3276
 		$lastDrafted = false;
3279 3277
 		if (isset($this->sessionData['lastDrafted']))
3280 3278
 		{
3281
-			$lastDrafted=array();
3279
+			$lastDrafted = array();
3282 3280
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3283 3281
 			$lastDrafted['uid'] = $dhA['msgUID'];
3284 3282
 			$lastDrafted['folder'] = $dhA['folder'];
3285
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3283
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']);
3286 3284
 			// manually drafted, do not delete
3287 3285
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3288
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3286
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false;
3289 3287
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3290 3288
 		}
3291 3289
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
3292 3290
 		{
3293 3291
 			try
3294 3292
 			{
3295
-				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' &&
3296
-					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments']))
3293
+				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' &&
3294
+					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3297 3295
 				{
3298 3296
 					//error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData));
3299 3297
 					//error_log(__METHOD__.__LINE__."#".array2string($_formData));
3300 3298
 					//error_log(__METHOD__.__LINE__."#".array2string($this->sessionData));
3301
-					$mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately');
3299
+					$mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately');
3302 3300
 				}
3303 3301
 			}
3304 3302
 			catch (Api\Exception $e)
@@ -3310,22 +3308,22 @@  discard block
 block discarded – undo
3310 3308
 		unset($this->sessionData['lastDrafted']);
3311 3309
 
3312 3310
 		//error_log("handling draft messages, flagging and such");
3313
-		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3311
+		if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3314 3312
 			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3315 3313
 			// mark message as answered
3316 3314
 			$mail_bo->openConnection();
3317
-			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3315
+			$mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3318 3316
 			// if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send
3319 3317
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
3320 3318
 			if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder']))
3321 3319
 			{
3322 3320
 				try // message may be deleted already, as it maybe done by autosave
3323 3321
 				{
3324
-					if ($_formData['mode']=='composefromdraft' &&
3322
+					if ($_formData['mode'] == 'composefromdraft' &&
3325 3323
 						!(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3326 3324
 					{
3327 3325
 						//error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']);
3328
-						$mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder'], 'remove_immediately');
3326
+						$mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder'], 'remove_immediately');
3329 3327
 					}
3330 3328
 				}
3331 3329
 				catch (Api\Exception $e)
@@ -3334,14 +3332,14 @@  discard block
 block discarded – undo
3334 3332
 					unset($e);
3335 3333
 				}
3336 3334
 			} else {
3337
-				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3335
+				$mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3338 3336
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3339
-				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
3337
+				if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded')
3340 3338
 				{
3341 3339
 					try
3342 3340
 					{
3343 3341
 						//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3344
-						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']);
3342
+						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']);
3345 3343
 					}
3346 3344
 					catch (Api\Exception $e)
3347 3345
 					{
@@ -3369,49 +3367,49 @@  discard block
 block discarded – undo
3369 3367
 		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3370 3368
 		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3371 3369
 
3372
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3370
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on')
3373 3371
 		{
3374 3372
 			$this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images);
3375 3373
 
3376
-			foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
3374
+			foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key)
3377 3375
 			{
3378 3376
 				$entryid = $_formData['to_integrate_ids'][0][$app_key];
3379 3377
 				if ($_formData[$app_key] == 'on')
3380 3378
 				{
3381
-					$app_name = substr($app_key,3);
3379
+					$app_name = substr($app_key, 3);
3382 3380
 					// Get registered hook data of the app called for integration
3383
-					$hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name);
3381
+					$hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name);
3384 3382
 
3385 3383
 					// store mail / eml in temp. file to not have to download it from mail-server again
3386
-					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
3384
+					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate');
3387 3385
 					$eml_fp = fopen($eml, 'w');
3388 3386
 					stream_copy_to_stream($mail->getRaw(), $eml_fp);
3389 3387
 					fclose($eml_fp);
3390 3388
 					$target = array(
3391 3389
 						'menuaction' => $hook['menuaction'],
3392
-						'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
3390
+						'egw_data' => Link::set_data(null, 'mail_integration::integrate', array(
3393 3391
 							$mailaddresses,
3394 3392
 							$this->sessionData['subject'],
3395 3393
 							$this->convertHTMLToText($this->sessionData['body']),
3396 3394
 							$this->sessionData['attachments'],
3397 3395
 							false, // date
3398 3396
 							$eml,
3399
-							$_formData['serverID']),true),
3397
+							$_formData['serverID']), true),
3400 3398
 						'app' => $app_name
3401 3399
 					);
3402 3400
 					if ($entryid) $target['entry_id'] = $entryid;
3403 3401
 					// Open the app called for integration in a popup
3404 3402
 					// and store the mail raw data as egw_data, in order to
3405 3403
 					// be stored from registered app method later
3406
-					Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']);
3404
+					Framework::popup(Egw::link('/index.php', $target), '_blank', $hook['popup']);
3407 3405
 				}
3408 3406
 			}
3409 3407
 		}
3410 3408
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3411
-		elseif(is_array($this->sessionData['attachments']))
3409
+		elseif (is_array($this->sessionData['attachments']))
3412 3410
 		{
3413
-			foreach($this->sessionData['attachments'] as $value) {
3414
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3411
+			foreach ($this->sessionData['attachments'] as $value) {
3412
+				if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3415 3413
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3416 3414
 				}
3417 3415
 			}
@@ -3428,7 +3426,7 @@  discard block
 block discarded – undo
3428 3426
 	 * @param array $content
3429 3427
 	 * @return array - the input, enriched with some not set attributes
3430 3428
 	 */
3431
-	function setDefaults($content=array())
3429
+	function setDefaults($content = array())
3432 3430
 	{
3433 3431
 		// if there's not already an identity selected for current account
3434 3432
 		if (empty($content['mailidentity']))
@@ -3437,7 +3435,7 @@  discard block
 block discarded – undo
3437 3435
 			if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
3438 3436
 			{
3439 3437
 				$sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'];
3440
-				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0)
3438
+				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0)
3441 3439
 				{
3442 3440
 					$content['mailidentity'] = $sigPref[$this->mail_bo->profileID];
3443 3441
 				}
@@ -3446,7 +3444,7 @@  discard block
 block discarded – undo
3446 3444
 			if (empty($content['mailidentity']))
3447 3445
 			{
3448 3446
 				$default_identity = null;
3449
-				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3447
+				foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3450 3448
 				{
3451 3449
 					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3452 3450
 					if (!empty($identity['ident_signature']))
@@ -3461,7 +3459,7 @@  discard block
 block discarded – undo
3461 3459
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3462 3460
 		{
3463 3461
 			$content['mimeType'] = 'html';
3464
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3462
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain';
3465 3463
 		}
3466 3464
 		return $content;
3467 3465
 
@@ -3484,7 +3482,7 @@  discard block
 block discarded – undo
3484 3482
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3485 3483
 	 * @return type
3486 3484
 	 */
3487
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3485
+	function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) {
3488 3486
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3489 3487
 		static $useCacheIfPossible = null;
3490 3488
 		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
@@ -3497,36 +3495,36 @@  discard block
 block discarded – undo
3497 3495
 		{
3498 3496
 			$this->changeProfile($_mailaccountToSearch);
3499 3497
 		}
3500
-		if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer))
3498
+		if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer))
3501 3499
 		{
3502 3500
 			//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
3503 3501
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3504 3502
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3505
-			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3506
-			if (count($folderObjects)<=1) {
3503
+			$folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible);
3504
+			if (count($folderObjects) <= 1) {
3507 3505
 				$useCacheIfPossible = false;
3508 3506
 			}
3509 3507
 			else
3510 3508
 			{
3511 3509
 				$useCacheIfPossible = true;
3512 3510
 			}
3513
-			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
3511
+			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP');
3514 3512
 			foreach ($folderObjects as $k =>$fA)
3515 3513
 			{
3516 3514
 				//error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
3517
-				$f=false;
3518
-				$key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k;
3519
-				if ($_searchStringLength<=0)
3515
+				$f = false;
3516
+				$key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k;
3517
+				if ($_searchStringLength <= 0)
3520 3518
 				{
3521
-					$f=true;
3519
+					$f = true;
3522 3520
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3523 3521
 				}
3524
-				if ($f==false && stripos($fA->displayName,$_searchString)!==false)
3522
+				if ($f == false && stripos($fA->displayName, $_searchString) !== false)
3525 3523
 				{
3526
-					$f=true;
3524
+					$f = true;
3527 3525
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3528 3526
 				}
3529
-				if ($f==false && stripos($k,$searchString)!==false)
3527
+				if ($f == false && stripos($k, $searchString) !== false)
3530 3528
 				{
3531 3529
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3532 3530
 				}
@@ -3554,7 +3552,7 @@  discard block
 block discarded – undo
3554 3552
 		exit();
3555 3553
 	}
3556 3554
 
3557
-	public static function ajax_searchAddress($_searchStringLength=2) {
3555
+	public static function ajax_searchAddress($_searchStringLength = 2) {
3558 3556
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3559 3557
 		$_searchString = trim($_REQUEST['query']);
3560 3558
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3563,12 +3561,12 @@  discard block
 block discarded – undo
3563 3561
 		$results = array();
3564 3562
 
3565 3563
 		// Add up to 10 matching mailing lists, and 10 groups
3566
-		if($include_lists)
3564
+		if ($include_lists)
3567 3565
 		{
3568 3566
 			$results += static::get_lists($_searchString, $contacts_obj);
3569 3567
 		}
3570 3568
 
3571
-		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength)
3569
+		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength)
3572 3570
 		{
3573 3571
 			//error_log(__METHOD__.__LINE__.array2string($_searchString));
3574 3572
 			$showAccounts = $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
@@ -3577,66 +3575,66 @@  discard block
 block discarded – undo
3577 3575
 			{
3578 3576
 				if (mb_strlen($v) < 3) unset($search[$k]);
3579 3577
 			}
3580
-			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3578
+			$search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns
3581 3579
 			//error_log(__METHOD__.__LINE__.$_searchString);
3582 3580
 			$filter = $showAccounts ? array() : array('account_id' => null);
3583
-			$filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home', 'contact_id');
3584
-			$cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home', 'contact_id');
3585
-			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter);
3581
+			$filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home', 'contact_id');
3582
+			$cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home', 'contact_id');
3583
+			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3586 3584
 			$cfs_type_email = Api\Storage\Customfields::get_email_cfs('addressbook');
3587 3585
 			// additionally search the accounts, if the contact storage is not the account storage
3588 3586
 			if ($showAccounts && $contacts_obj->so_accounts)
3589 3587
 			{
3590 3588
 				$filter['owner'] = 0;
3591
-				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter);
3589
+				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3592 3590
 
3593 3591
 				if ($contacts && $accounts)
3594 3592
 				{
3595
-					$contacts = array_merge($contacts,$accounts);
3596
-					usort($contacts,function($a, $b)
3593
+					$contacts = array_merge($contacts, $accounts);
3594
+					usort($contacts, function($a, $b)
3597 3595
 					{
3598 3596
 						return strcasecmp($a['n_fn'], $b['n_fn']);
3599 3597
 					});
3600 3598
 				}
3601
-				elseif($accounts)
3599
+				elseif ($accounts)
3602 3600
 				{
3603
-					$contacts =& $accounts;
3601
+					$contacts = & $accounts;
3604 3602
 				}
3605 3603
 				unset($accounts);
3606 3604
 			}
3607 3605
 		}
3608 3606
 
3609
-		if(is_array($contacts)) {
3610
-			foreach($contacts as $contact) {
3607
+		if (is_array($contacts)) {
3608
+			foreach ($contacts as $contact) {
3611 3609
 				$cf_emails = (array)array_values(array_values($contacts_obj->read_customfields($contact['id'], $cfs_type_email))[0]);
3612
-				foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email) {
3610
+				foreach (array_merge(array($contact['email'], $contact['email_home']), $cf_emails) as $email) {
3613 3611
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3614 3612
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3615 3613
 					$rfcAddr = Mail::parseAddressList($email);
3616
-					$_rfcAddr=$rfcAddr->first();
3614
+					$_rfcAddr = $rfcAddr->first();
3617 3615
 					if (!$_rfcAddr->valid)
3618 3616
 					{
3619 3617
 						continue; // skip address if we encounter an error here
3620 3618
 					}
3621 3619
 					$email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
3622 3620
 
3623
-					if (method_exists($contacts_obj,'search'))
3621
+					if (method_exists($contacts_obj, 'search'))
3624 3622
 					{
3625
-						$contact['n_fn']='';
3623
+						$contact['n_fn'] = '';
3626 3624
 						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3627
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3628
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3629
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3630
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3625
+						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given'];
3626
+						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family'];
3627
+						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')';
3628
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3631 3629
 					}
3632 3630
 					else
3633 3631
 					{
3634
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3632
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3635 3633
 					}
3636 3634
 					$args = explode('@', trim($email));
3637 3635
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3638 3636
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3639
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3637
+					if (!empty($email) && in_array($completeMailString, $results) === false) {
3640 3638
 						$results[] = array(
3641 3639
 							'id'=>$completeMailString,
3642 3640
 							'label' => $completeMailString,
@@ -3652,10 +3650,10 @@  discard block
 block discarded – undo
3652 3650
 		// Add groups
3653 3651
 		$group_options = array('account_type' => 'groups');
3654 3652
 		$groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options);
3655
-		foreach($groups as $g_id => $name)
3653
+		foreach ($groups as $g_id => $name)
3656 3654
 		{
3657 3655
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3658
-			if(!$group['account_email']) continue;
3656
+			if (!$group['account_email']) continue;
3659 3657
 			$args = explode('@', trim($group['account_email']));
3660 3658
 			$args[] = $name;
3661 3659
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3696,14 +3694,14 @@  discard block
 block discarded – undo
3696 3694
 			}
3697 3695
 		);
3698 3696
 
3699
-		foreach($lists as $key => $list_name)
3697
+		foreach ($lists as $key => $list_name)
3700 3698
 		{
3701 3699
 			$type = $key > 0 ? 'manual' : 'group';
3702 3700
 			$list = array(
3703 3701
 				'id'	=> $key,
3704 3702
 				'name'	=> $list_name,
3705 3703
 				'label'	=> $list_name,
3706
-				'class' => 'mailinglist ' . "{$type}_list",
3704
+				'class' => 'mailinglist '."{$type}_list",
3707 3705
 				'title' => lang('Mailinglist'),
3708 3706
 				'data'	=> $key
3709 3707
 			);
@@ -3711,9 +3709,9 @@  discard block
 block discarded – undo
3711 3709
 		}
3712 3710
 		$trim = function($list) {
3713 3711
 			$limit = 10;
3714
-			if(count($list) <= $limit) return $list;
3715
-			$list[$limit-1]['class'].= ' more_results';
3716
-			$list[$limit-1]['title'] .= '  (' . lang('%1 more', count($list) - $limit) . ')';
3712
+			if (count($list) <= $limit) return $list;
3713
+			$list[$limit - 1]['class'] .= ' more_results';
3714
+			$list[$limit - 1]['title'] .= '  ('.lang('%1 more', count($list) - $limit).')';
3717 3715
 			return array_slice($list, 0, $limit);
3718 3716
 		};
3719 3717
 		return array_merge($trim($group_lists), $trim($manual_lists));
@@ -3727,7 +3725,7 @@  discard block
 block discarded – undo
3727 3725
 	public function ajax_merge($contact_id)
3728 3726
 	{
3729 3727
 		$response = Api\Json\Response::get();
3730
-		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3728
+		if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3731 3729
 		{
3732 3730
 			$document_merge = new $_REQUEST['merge']();
3733 3731
 		}
@@ -3737,7 +3735,7 @@  discard block
 block discarded – undo
3737 3735
 		}
3738 3736
 		$this->mail_bo->openConnection();
3739 3737
 
3740
-		if(($error = $document_merge->check_document($_REQUEST['document'],'')))
3738
+		if (($error = $document_merge->check_document($_REQUEST['document'], '')))
3741 3739
 		{
3742 3740
 			$response->error($error);
3743 3741
 			return;
@@ -3748,23 +3746,23 @@  discard block
 block discarded – undo
3748 3746
 		try
3749 3747
 		{
3750 3748
 			$results = $this->mail_bo->importMessageToMergeAndSend(
3751
-				$document_merge, Vfs::PREFIX . $_REQUEST['document'],
3749
+				$document_merge, Vfs::PREFIX.$_REQUEST['document'],
3752 3750
 				// Send an extra non-numeric ID to force actual send of document
3753 3751
 				// instead of save as draft
3754 3752
 				array((int)$contact_id, ''),
3755
-				$folder,$merged_mail_id
3753
+				$folder, $merged_mail_id
3756 3754
 			);
3757 3755
 
3758 3756
 			// Also save as infolog
3759
-			if($merged_mail_id && $_REQUEST['to_app'] && isset($GLOBALS['egw_info']['user']['apps'][$_REQUEST['to_app']]))
3757
+			if ($merged_mail_id && $_REQUEST['to_app'] && isset($GLOBALS['egw_info']['user']['apps'][$_REQUEST['to_app']]))
3760 3758
 			{
3761 3759
 				$rowid = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $merged_mail_id, true);
3762 3760
 				$data = mail_integration::get_integrate_data($rowid);
3763
-				if($data && $_REQUEST['to_app'] == 'infolog')
3761
+				if ($data && $_REQUEST['to_app'] == 'infolog')
3764 3762
 				{
3765 3763
 					$bo = new infolog_bo();
3766
-					$entry = $bo->import_mail($data['addresses'],$data['subject'],$data['message'],$data['attachments'],$data['date']);
3767
-					if($_REQUEST['info_type'] && isset($bo->enums['type'][$_REQUEST['info_type']]))
3764
+					$entry = $bo->import_mail($data['addresses'], $data['subject'], $data['message'], $data['attachments'], $data['date']);
3765
+					if ($_REQUEST['info_type'] && isset($bo->enums['type'][$_REQUEST['info_type']]))
3768 3766
 					{
3769 3767
 						$entry['info_type'] = $_REQUEST['info_type'];
3770 3768
 					}
@@ -3783,13 +3781,13 @@  discard block
 block discarded – undo
3783 3781
 			);
3784 3782
 		}
3785 3783
 
3786
-		if($results['success'])
3784
+		if ($results['success'])
3787 3785
 		{
3788
-			$response->data(implode(',',$results['success']));
3786
+			$response->data(implode(',', $results['success']));
3789 3787
 		}
3790
-		if($results['failed'])
3788
+		if ($results['failed'])
3791 3789
 		{
3792
-			$response->error(implode(',',$results['failed']));
3790
+			$response->error(implode(',', $results['failed']));
3793 3791
 		}
3794 3792
 	}
3795 3793
 
@@ -3805,7 +3803,7 @@  discard block
 block discarded – undo
3805 3803
 	 * @return boolean returns true if successful and false if passphrase required
3806 3804
 	 * @throws Api\Exception\WrongUserinput if no certificate found
3807 3805
 	 */
3808
-	protected function _encrypt($mail, $type, $recipients, $sender, $passphrase='')
3806
+	protected function _encrypt($mail, $type, $recipients, $sender, $passphrase = '')
3809 3807
 	{
3810 3808
 		$AB = new addressbook_bo();
3811 3809
 		 // passphrase of sender private key
@@ -3814,7 +3812,7 @@  discard block
 block discarded – undo
3814 3812
 		try
3815 3813
 		{
3816 3814
 			$sender_cert = $AB->get_smime_keys($sender);
3817
-			if (!$sender_cert)	throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: " . $sender);
3815
+			if (!$sender_cert)	throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: ".$sender);
3818 3816
 			$params['senderPubKey'] = $sender_cert[$sender];
3819 3817
 
3820 3818
 			if (isset($sender) && ($type == Mail\Smime::TYPE_SIGN || $type == Mail\Smime::TYPE_SIGN_ENCRYPT))
@@ -3829,14 +3827,14 @@  discard block
 block discarded – undo
3829 3827
 				$params['recipientsCerts'] = $AB->get_smime_keys($recipients);
3830 3828
 				foreach ($recipients as &$recipient)
3831 3829
 				{
3832
-					if (!$params['recipientsCerts'][$recipient]) $missingCerts []= $recipient;
3830
+					if (!$params['recipientsCerts'][$recipient]) $missingCerts [] = $recipient;
3833 3831
 				}
3834
-				if (is_array($missingCerts)) throw new Exception ('S/MIME Encryption failed because no certificate has been found for following addresses: '. implode ('|', $missingCerts));
3832
+				if (is_array($missingCerts)) throw new Exception('S/MIME Encryption failed because no certificate has been found for following addresses: '.implode('|', $missingCerts));
3835 3833
 			}
3836 3834
 
3837 3835
 			return $mail->smimeEncrypt($type, $params);
3838 3836
 		}
3839
-		catch(Api\Exception\WrongUserinput $e)
3837
+		catch (Api\Exception\WrongUserinput $e)
3840 3838
 		{
3841 3839
 			throw new $e;
3842 3840
 		}
@@ -3852,7 +3850,7 @@  discard block
 block discarded – undo
3852 3850
 	 *
3853 3851
 	 * @throws Exception throws exception on cross account attempt
3854 3852
 	 */
3855
-	function _get_uids_as_attachments ($_ids, $_serverID)
3853
+	function _get_uids_as_attachments($_ids, $_serverID)
3856 3854
 	{
3857 3855
 		$ids = is_array($_ids) ? $_ids : explode(',', $_ids);
3858 3856
 		if (is_array($ids) && $_serverID)
@@ -3866,12 +3864,12 @@  discard block
 block discarded – undo
3866 3864
 		foreach ($ids as &$id)
3867 3865
 		{
3868 3866
 			$parts = mail_ui::splitRowID($id);
3869
-			$mail_bo    = $this->mail_bo;
3867
+			$mail_bo = $this->mail_bo;
3870 3868
 			$mail_bo->openConnection();
3871 3869
 			$mail_bo->reopen($parts['folder']);
3872
-			$headers	= $mail_bo->getMessageEnvelope($parts['msgUID'], null,false,$parts['folder']);
3870
+			$headers = $mail_bo->getMessageEnvelope($parts['msgUID'], null, false, $parts['folder']);
3873 3871
 			$this->addMessageAttachment($parts['msgUID'], null, $parts['folder'],
3874
-					$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
3872
+					$mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml',
3875 3873
 					'MESSAGE/RFC822', $headers['SIZE'] ? $headers['SIZE'] : lang('unknown'));
3876 3874
 			$mail_bo->closeConnection();
3877 3875
 		}
Please login to merge, or discard this patch.