Completed
Push — 16.1 ( 7a42e7...c49bdc )
by Nathan
36:51 queued 17:35
created
infolog/inc/class.infolog_import_infologs_csv.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * imports entries according to given definition object.
110 110
 	 * @param resource $_stream
111
-	 * @param string $_charset
112
-	 * @param definition $_definition
111
+	 * @param importexport_definition $_definition
113 112
 	 */
114 113
 	public function import( $_stream, importexport_definition $_definition ) {
115 114
 		$import_csv = new importexport_import_csv( $_stream, array(
@@ -527,6 +526,7 @@  discard block
 block discarded – undo
527 526
 	 *
528 527
 	 * This is a copy of what's in importexport_basic_import_csv, and can go
529 528
 	 * away if this is changed to extend it
529
+	 * @param integer $record_num
530 530
 	 */
531 531
 	protected function link_by_cf($record_num, $app, $fieldname, $_value)
532 532
 	{
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	private $boinfolog;
75 75
 
76 76
 	/**
77
-	* For figuring out if a record has changed
78
-	*
79
-	* @var infolog_tracking::
80
-	*/
77
+	 * For figuring out if a record has changed
78
+	 *
79
+	 * @var infolog_tracking::
80
+	 */
81 81
 	protected $tracking;
82 82
 
83 83
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	protected $errors = array();
102 102
 
103 103
 	/**
104
- 	* List of actions, and how many times that action was taken
104
+	 * List of actions, and how many times that action was taken
105 105
 	 */
106 106
 	protected $results = array();
107 107
 
@@ -466,37 +466,37 @@  discard block
 block discarded – undo
466 466
 	}
467 467
 
468 468
 	/**
469
-	* Returns warnings that were encountered during importing
470
-	* Maximum of one warning message per record, but you can append if you need to
471
-	*
472
-	* @return Array (
473
-	*       record_# => warning message
474
-	*       )
475
-	*/
469
+	 * Returns warnings that were encountered during importing
470
+	 * Maximum of one warning message per record, but you can append if you need to
471
+	 *
472
+	 * @return Array (
473
+	 *       record_# => warning message
474
+	 *       )
475
+	 */
476 476
 	public function get_warnings() {
477 477
 		return $this->warnings;
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Returns errors that were encountered during importing
482
-	* Maximum of one error message per record, but you can append if you need to
483
-	*
484
-	* @return Array (
485
-	*       record_# => error message
486
-	*       )
487
-	*/
481
+	 * Returns errors that were encountered during importing
482
+	 * Maximum of one error message per record, but you can append if you need to
483
+	 *
484
+	 * @return Array (
485
+	 *       record_# => error message
486
+	 *       )
487
+	 */
488 488
 	public function get_errors() {
489 489
 		return $this->errors;
490 490
 	}
491 491
 
492 492
 	/**
493
-	* Returns a list of actions taken, and the number of records for that action.
494
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
-	*
496
-	* @return Array (
497
-	*       action => record count
498
-	* )
499
-	*/
493
+	 * Returns a list of actions taken, and the number of records for that action.
494
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
+	 *
496
+	 * @return Array (
497
+	 *       action => record count
498
+	 * )
499
+	 */
500 500
 	public function get_results() {
501 501
 		return $this->results;
502 502
 	}
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * class import_csv for infolog
18 18
  */
19
-class infolog_import_infologs_csv implements importexport_iface_import_plugin  {
19
+class infolog_import_infologs_csv implements importexport_iface_import_plugin {
20 20
 
21 21
 	private static $plugin_options = array(
22
-		'fieldsep', 		// char
23
-		'charset', 			// string
24
-		'contact_owner', 	// int
25
-		'update_cats', 			// string {override|add} overides record
22
+		'fieldsep', // char
23
+		'charset', // string
24
+		'contact_owner', // int
25
+		'update_cats', // string {override|add} overides record
26 26
 								// with cat(s) from csv OR add the cat from
27 27
 								// csv file to exeisting cat(s) of record
28 28
 		'num_header_lines', // int number of header lines
29 29
 		'field_conversion', // array( $csv_col_num => conversion)
30
-		'field_mapping',	// array( $csv_col_num => adb_filed)
31
-		'conditions',		/* => array containing condition arrays:
30
+		'field_mapping', // array( $csv_col_num => adb_filed)
31
+		'conditions', /* => array containing condition arrays:
32 32
 				'type' => exists, // exists
33 33
 				'string' => '#kundennummer',
34 34
 				'true' => array(
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * actions wich could be done to data entries
56 56
 	 */
57
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
57
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
58 58
 
59 59
 	/**
60 60
 	 * conditions for actions
61 61
 	 *
62 62
 	 * @var array
63 63
 	 */
64
-	protected static $conditions = array( 'exists' );
64
+	protected static $conditions = array('exists');
65 65
 
66 66
 	/**
67 67
 	 * @var definition
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 * @param string $_charset
112 112
 	 * @param definition $_definition
113 113
 	 */
114
-	public function import( $_stream, importexport_definition $_definition ) {
115
-		$import_csv = new importexport_import_csv( $_stream, array(
114
+	public function import($_stream, importexport_definition $_definition) {
115
+		$import_csv = new importexport_import_csv($_stream, array(
116 116
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
117 117
 			'charset' => $_definition->plugin_options['charset'],
118 118
 		));
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
123 123
 
124 124
 		// dry run?
125
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
125
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
126 126
 
127 127
 		// fetch the infolog bo
128 128
 		$this->boinfolog = new infolog_bo();
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 		$import_csv->conversion_class = $this;
144 144
 
145 145
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
146
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
147 147
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
148
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
149 149
 			// First method is preferred
150 150
 			$import_csv->skip_records(1);
151 151
 		}
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 		$this->errors = array();
171 171
 		$this->warnings = array();
172 172
 
173
-		while ( $record = $import_csv->get_record() ) {
173
+		while ($record = $import_csv->get_record()) {
174 174
 			$success = false;
175 175
 
176 176
 			// don't import empty records
177
-			if( count( array_unique( $record ) ) < 2 ) continue;
177
+			if (count(array_unique($record)) < 2) continue;
178 178
 
179 179
 			$lookups = $_lookups;
180 180
 
181 181
 			// Early detection of type, to load appropriate statuses
182
-			foreach(array($lookups['info_type'], array_map('strtolower',array_map('lang',$lookups['info_type']))) as $types)
182
+			foreach (array($lookups['info_type'], array_map('strtolower', array_map('lang', $lookups['info_type']))) as $types)
183 183
 			{
184
-				if($record['info_type'] && $key = array_search(strtolower($record['info_type']),$types))
184
+				if ($record['info_type'] && $key = array_search(strtolower($record['info_type']), $types))
185 185
 				{
186 186
 					$lookups['info_status'] = $this->boinfolog->status[$key];
187 187
 					break;
@@ -189,34 +189,34 @@  discard block
 block discarded – undo
189 189
 			}
190 190
 
191 191
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
192
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
192
+			if ($result) $this->warnings[$import_csv->get_current_position()] = $result;
193 193
 
194 194
 			// Make sure type is valid
195
-			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
195
+			if (!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
196 196
 			{
197 197
 				// Check for translated type
198
-				$un_trans = Api\Translation::get_message_id($record['info_type'],'infolog');
199
-				if($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
198
+				$un_trans = Api\Translation::get_message_id($record['info_type'], 'infolog');
199
+				if ($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
200 200
 				{
201 201
 					$record['info_type'] = $un_trans;
202 202
 				}
203 203
 				else
204 204
 				{
205
-					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n":'').
205
+					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n" : '').
206 206
 						lang('Unknown type: %1', $record['info_type']);
207 207
 				}
208 208
 			}
209 209
 
210 210
 			// Set default status for type, if not specified
211
-			if(!$record['info_status'] && $record['info_type'])
211
+			if (!$record['info_status'] && $record['info_type'])
212 212
 			{
213 213
 				$record['info_status'] = $this->boinfolog->status['defaults'][$record['info_type']];
214 214
 			}
215 215
 
216 216
 			// Set owner, unless it's supposed to come from CSV file
217
-			if($_definition->plugin_options['owner_from_csv'])
217
+			if ($_definition->plugin_options['owner_from_csv'])
218 218
 			{
219
-				if(!is_numeric($record['info_owner']))
219
+				if (!is_numeric($record['info_owner']))
220 220
 				{
221 221
 					$this->errors[$import_csv->get_current_position()] = lang(
222 222
 						'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
@@ -233,51 +233,51 @@  discard block
 block discarded – undo
233 233
 			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
234 234
 
235 235
 			// Responsible has to be an array
236
-			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
236
+			$record['info_responsible'] = $record['info_responsible'] ? explode(',', $record['info_responsible']) : 0;
237 237
 
238 238
 			// Special values
239 239
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
240 240
 			{
241
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
242
-				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname,$firstname,$org_name);
241
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
242
+				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname, $firstname, $org_name);
243 243
 			}
244 244
 			if ($record['projectmanager'] && !is_numeric($record['projectmanager']))
245 245
 			{
246 246
 				$record['projectmanager'] = self::project_id($record['projectmanager']);
247 247
 			}
248 248
 
249
-			if ( $_definition->plugin_options['conditions'] )
249
+			if ($_definition->plugin_options['conditions'])
250 250
 			{
251
-				foreach ( $_definition->plugin_options['conditions'] as $condition )
251
+				foreach ($_definition->plugin_options['conditions'] as $condition)
252 252
 				{
253 253
 					$results = array();
254
-					switch ( $condition['type'] )
254
+					switch ($condition['type'])
255 255
 					{
256 256
 						// exists
257 257
 						case 'exists' :
258
-							if($record[$condition['string']]) {
259
-								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
258
+							if ($record[$condition['string']]) {
259
+								$query['col_filter'] = array($condition['string'] => $record[$condition['string']],);
260 260
 								// Needed to query custom fields
261
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
261
+								if ($condition['string'][0] == '#') $query['custom_fields'] = true;
262 262
 								$results = $this->boinfolog->search($query);
263 263
 							}
264 264
 
265
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
265
+							if (is_array($results) && count(array_keys($results)) >= 1) {
266 266
 								// apply action to all records matching this exists condition
267 267
 								$action = $condition['true'];
268
-								foreach ( (array)$results as $contact ) {
268
+								foreach ((array)$results as $contact) {
269 269
 									$record['info_id'] = $contact['info_id'];
270 270
 									$record['info_owner'] = $contact['info_owner'];
271
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
272
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
273
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
274
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
271
+									if ($_definition->plugin_options['update_cats'] == 'add') {
272
+										if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
273
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
274
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $contact['cat_id'])));
275 275
 									}
276
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
276
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
277 277
 								}
278 278
 							} else {
279 279
 								$action = $condition['false'];
280
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
280
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
281 281
 							}
282 282
 							break;
283 283
 
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
 			else
293 293
 			{
294 294
 				// unconditional insert
295
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
295
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
296 296
 			}
297
-			if($success) $count++;
298
-			if($this->warnings[$import_csv->get_current_position()]) {
299
-				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
297
+			if ($success) $count++;
298
+			if ($this->warnings[$import_csv->get_current_position()]) {
299
+				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
300 300
 			}
301
-			if($this->errors[$import_csv->get_current_position()]) {
302
-				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
301
+			if ($this->errors[$import_csv->get_current_position()]) {
302
+				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
303 303
 			}
304 304
 		}
305 305
 		return $count;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @param array $_data contact data for the action
313 313
 	 * @return bool success or not
314 314
 	 */
315
-	private function action ( $_action, $_data, $record_num = 0 ) {
315
+	private function action($_action, $_data, $record_num = 0) {
316 316
 		$result = true;
317 317
 		switch ($_action) {
318 318
 			case 'none' :
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				// Only update if there are changes
322 322
 				$old = $this->boinfolog->read($_data['info_id']);
323 323
 
324
-				if(!$this->definition->plugin_options['change_owner']) {
324
+				if (!$this->definition->plugin_options['change_owner']) {
325 325
 					// Don't change addressbook of an existing contact
326 326
 					unset($_data['owner']);
327 327
 				}
@@ -329,19 +329,19 @@  discard block
 block discarded – undo
329 329
 				// Merge to deal with fields not in import record
330 330
 				$_data = array_merge($old, $_data);
331 331
 				$changed = $this->tracking->changed_fields($_data, $old);
332
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
332
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
333 333
 					break;
334 334
 				}
335 335
 
336 336
 				// Fall through
337 337
 			case 'insert' :
338
-				if ( $this->dry_run ) {
338
+				if ($this->dry_run) {
339 339
 					//print_r($_data);
340 340
 
341 341
 					// Check for link during dry run
342
-					if($_data['link_custom'])
342
+					if ($_data['link_custom'])
343 343
 					{
344
-						list($app, $app_id2) = explode(':', $_data['link_custom'],2);
344
+						list($app, $app_id2) = explode(':', $_data['link_custom'], 2);
345 345
 						$app_id = $this->link_by_cf($record_num, $app, $field, $app_id2);
346 346
 					}
347 347
 
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 					break;
350 350
 				} else {
351 351
 					$result = $this->boinfolog->write(
352
-						$_data, true, 2,true, 	// 2 = dont touch modification date
352
+						$_data, true, 2, true, // 2 = dont touch modification date
353 353
 						$this->definition->plugin_options['no_notification']
354 354
 					);
355
-					if(!$result)
355
+					if (!$result)
356 356
 					{
357
-						if($result === false)
357
+						if ($result === false)
358 358
 						{
359 359
 							$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
360 360
 								$GLOBALS['egw']->accounts->id2name($_data['info_owner']),
@@ -377,17 +377,17 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 
379 379
 		// Process some additional fields
380
-		if(!is_numeric($result)) {
380
+		if (!is_numeric($result)) {
381 381
 			return $result;
382 382
 		}
383 383
 		$info_link_id = $_data['info_link_id'];
384
-		foreach(array_keys(self::$special_fields) as $field) {
385
-			if(!$_data[$field]) continue;
386
-			if(strpos($field, 'link') === 0) {
387
-				list($app, $app_id) = explode(':', $_data[$field],2);
384
+		foreach (array_keys(self::$special_fields) as $field) {
385
+			if (!$_data[$field]) continue;
386
+			if (strpos($field, 'link') === 0) {
387
+				list($app, $app_id) = explode(':', $_data[$field], 2);
388 388
 
389 389
 				// Linking to another entry based on matching custom fields
390
-				if($field == 'link_custom')
390
+				if ($field == 'link_custom')
391 391
 				{
392 392
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
393 393
 				}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 			if ($app && $app_id) {
399 399
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
400 400
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
401
-				$link_id = Link::link('infolog',$id,$app,$app_id);
401
+				$link_id = Link::link('infolog', $id, $app, $app_id);
402 402
 				if ($link_id && !$info_link_id)
403 403
 				{
404 404
 					$to_write = array(
405 405
 						'info_id'      => $id,
406 406
 						'info_link_id' => $link_id,
407 407
 					);
408
-					$this->boinfolog->write($to_write,False,false,true,true);	// last true = no notifications, as no real change
408
+					$this->boinfolog->write($to_write, False, false, true, true); // last true = no notifications, as no real change
409 409
 					$info_link_id = $link_id;
410 410
 				}
411 411
 			}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	// Extra conversion functions - must be static
506 506
 	public static function project_id($num_or_title)
507 507
 	{
508
-		static $boprojects=null;
508
+		static $boprojects = null;
509 509
 
510 510
 		if (!$num_or_title) return false;
511 511
 
@@ -532,18 +532,18 @@  discard block
 block discarded – undo
532 532
 	{
533 533
 		$app_id = false;
534 534
 
535
-		list($custom_field, $value) = explode(':',$_value);
535
+		list($custom_field, $value) = explode(':', $_value);
536 536
 		// Find matching entry
537
-		if($app && $custom_field && $value)
537
+		if ($app && $custom_field && $value)
538 538
 		{
539 539
 			$cfs = Api\Storage\Customfields::get($app);
540 540
 			// Error if no custom fields, probably something wrong in definition
541
-			if(!$cfs[$custom_field])
541
+			if (!$cfs[$custom_field])
542 542
 			{
543 543
 				// Check for users specifing label instead of name
544
-				foreach($cfs as $name => $settings)
544
+				foreach ($cfs as $name => $settings)
545 545
 				{
546
-					if(strtolower($settings['label']) == strtolower($custom_field))
546
+					if (strtolower($settings['label']) == strtolower($custom_field))
547 547
 					{
548 548
 						$custom_field = $name;
549 549
 						break;
@@ -552,23 +552,23 @@  discard block
 block discarded – undo
552 552
 			}
553 553
 
554 554
 			// Couldn't find field, give an error - something's wrong
555
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
555
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
556 556
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
557 557
 					$custom_field, lang($app));
558 558
 				return false;
559 559
 			}
560
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
560
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
561 561
 
562 562
 			// Search
563
-			if(Link::get_registry($app, 'query'))
563
+			if (Link::get_registry($app, 'query'))
564 564
 			{
565
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
565
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
566 566
 				$result = Link::query($app, '', $options);
567 567
 
568 568
 				// Only one allowed
569
-				if(count($result) != 1)
569
+				if (count($result) != 1)
570 570
 				{
571
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
571
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
572 572
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
573 573
 						$custom_field, count($result), lang($app), $options['filter'][0]
574 574
 					);
Please login to merge, or discard this patch.
Braces   +112 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * class import_csv for infolog
18 18
  */
19
-class infolog_import_infologs_csv implements importexport_iface_import_plugin  {
19
+class infolog_import_infologs_csv implements importexport_iface_import_plugin
20
+{
20 21
 
21 22
 	private static $plugin_options = array(
22 23
 		'fieldsep', 		// char
@@ -111,7 +112,8 @@  discard block
 block discarded – undo
111 112
 	 * @param string $_charset
112 113
 	 * @param definition $_definition
113 114
 	 */
114
-	public function import( $_stream, importexport_definition $_definition ) {
115
+	public function import( $_stream, importexport_definition $_definition )
116
+	{
115 117
 		$import_csv = new importexport_import_csv( $_stream, array(
116 118
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
117 119
 			'charset' => $_definition->plugin_options['charset'],
@@ -143,9 +145,12 @@  discard block
 block discarded – undo
143 145
 		$import_csv->conversion_class = $this;
144 146
 
145 147
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
148
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
149
+		{
147 150
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
151
+		}
152
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
153
+		{
149 154
 			// First method is preferred
150 155
 			$import_csv->skip_records(1);
151 156
 		}
@@ -170,11 +175,15 @@  discard block
 block discarded – undo
170 175
 		$this->errors = array();
171 176
 		$this->warnings = array();
172 177
 
173
-		while ( $record = $import_csv->get_record() ) {
178
+		while ( $record = $import_csv->get_record() )
179
+		{
174 180
 			$success = false;
175 181
 
176 182
 			// don't import empty records
177
-			if( count( array_unique( $record ) ) < 2 ) continue;
183
+			if( count( array_unique( $record ) ) < 2 )
184
+			{
185
+				continue;
186
+			}
178 187
 
179 188
 			$lookups = $_lookups;
180 189
 
@@ -189,7 +198,10 @@  discard block
 block discarded – undo
189 198
 			}
190 199
 
191 200
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
192
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
201
+			if($result)
202
+			{
203
+				$this->warnings[$import_csv->get_current_position()] = $result;
204
+			}
193 205
 
194 206
 			// Make sure type is valid
195 207
 			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
@@ -230,7 +242,10 @@  discard block
 block discarded – undo
230 242
 			{
231 243
 				$record['info_owner'] = $_definition->plugin_options['record_owner'];
232 244
 			}
233
-			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
245
+			if (!isset($record['info_owner']))
246
+			{
247
+				$record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
248
+			}
234 249
 
235 250
 			// Responsible has to be an array
236 251
 			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
@@ -255,27 +270,42 @@  discard block
 block discarded – undo
255 270
 					{
256 271
 						// exists
257 272
 						case 'exists' :
258
-							if($record[$condition['string']]) {
273
+							if($record[$condition['string']])
274
+							{
259 275
 								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
260 276
 								// Needed to query custom fields
261
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
277
+								if($condition['string'][0] == '#')
278
+								{
279
+									$query['custom_fields'] = true;
280
+								}
262 281
 								$results = $this->boinfolog->search($query);
263 282
 							}
264 283
 
265
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
284
+							if ( is_array( $results ) && count( array_keys( $results )) >= 1)
285
+							{
266 286
 								// apply action to all records matching this exists condition
267 287
 								$action = $condition['true'];
268
-								foreach ( (array)$results as $contact ) {
288
+								foreach ( (array)$results as $contact )
289
+								{
269 290
 									$record['info_id'] = $contact['info_id'];
270 291
 									$record['info_owner'] = $contact['info_owner'];
271
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
272
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
273
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
292
+									if ( $_definition->plugin_options['update_cats'] == 'add' )
293
+									{
294
+										if ( !is_array( $contact['cat_id'] ) )
295
+										{
296
+											$contact['cat_id'] = explode( ',', $contact['cat_id'] );
297
+										}
298
+										if ( !is_array( $record['cat_id'] ) )
299
+										{
300
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
301
+										}
274 302
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
275 303
 									}
276 304
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
277 305
 								}
278
-							} else {
306
+							}
307
+							else
308
+							{
279 309
 								$action = $condition['false'];
280 310
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
281 311
 							}
@@ -286,7 +316,10 @@  discard block
 block discarded – undo
286 316
 							die('condition / action not supported!!!');
287 317
 							break;
288 318
 					}
289
-					if ($action['last']) break;
319
+					if ($action['last'])
320
+					{
321
+						break;
322
+					}
290 323
 				}
291 324
 			}
292 325
 			else
@@ -294,11 +327,16 @@  discard block
 block discarded – undo
294 327
 				// unconditional insert
295 328
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
296 329
 			}
297
-			if($success) $count++;
298
-			if($this->warnings[$import_csv->get_current_position()]) {
330
+			if($success)
331
+			{
332
+				$count++;
333
+			}
334
+			if($this->warnings[$import_csv->get_current_position()])
335
+			{
299 336
 				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
300 337
 			}
301
-			if($this->errors[$import_csv->get_current_position()]) {
338
+			if($this->errors[$import_csv->get_current_position()])
339
+			{
302 340
 				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
303 341
 			}
304 342
 		}
@@ -312,16 +350,19 @@  discard block
 block discarded – undo
312 350
 	 * @param array $_data contact data for the action
313 351
 	 * @return bool success or not
314 352
 	 */
315
-	private function action ( $_action, $_data, $record_num = 0 ) {
353
+	private function action ( $_action, $_data, $record_num = 0 )
354
+	{
316 355
 		$result = true;
317
-		switch ($_action) {
356
+		switch ($_action)
357
+		{
318 358
 			case 'none' :
319 359
 				return true;
320 360
 			case 'update' :
321 361
 				// Only update if there are changes
322 362
 				$old = $this->boinfolog->read($_data['info_id']);
323 363
 
324
-				if(!$this->definition->plugin_options['change_owner']) {
364
+				if(!$this->definition->plugin_options['change_owner'])
365
+				{
325 366
 					// Don't change addressbook of an existing contact
326 367
 					unset($_data['owner']);
327 368
 				}
@@ -329,13 +370,15 @@  discard block
 block discarded – undo
329 370
 				// Merge to deal with fields not in import record
330 371
 				$_data = array_merge($old, $_data);
331 372
 				$changed = $this->tracking->changed_fields($_data, $old);
332
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
373
+				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
374
+				{
333 375
 					break;
334 376
 				}
335 377
 
336 378
 				// Fall through
337 379
 			case 'insert' :
338
-				if ( $this->dry_run ) {
380
+				if ( $this->dry_run )
381
+				{
339 382
 					//print_r($_data);
340 383
 
341 384
 					// Check for link during dry run
@@ -347,7 +390,9 @@  discard block
 block discarded – undo
347 390
 
348 391
 					$this->results[$_action]++;
349 392
 					break;
350
-				} else {
393
+				}
394
+				else
395
+				{
351 396
 					$result = $this->boinfolog->write(
352 397
 						$_data, true, 2,true, 	// 2 = dont touch modification date
353 398
 						$this->definition->plugin_options['no_notification']
@@ -377,13 +422,19 @@  discard block
 block discarded – undo
377 422
 		}
378 423
 
379 424
 		// Process some additional fields
380
-		if(!is_numeric($result)) {
425
+		if(!is_numeric($result))
426
+		{
381 427
 			return $result;
382 428
 		}
383 429
 		$info_link_id = $_data['info_link_id'];
384
-		foreach(array_keys(self::$special_fields) as $field) {
385
-			if(!$_data[$field]) continue;
386
-			if(strpos($field, 'link') === 0) {
430
+		foreach(array_keys(self::$special_fields) as $field)
431
+		{
432
+			if(!$_data[$field])
433
+			{
434
+				continue;
435
+			}
436
+			if(strpos($field, 'link') === 0)
437
+			{
387 438
 				list($app, $app_id) = explode(':', $_data[$field],2);
388 439
 
389 440
 				// Linking to another entry based on matching custom fields
@@ -391,11 +442,14 @@  discard block
 block discarded – undo
391 442
 				{
392 443
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
393 444
 				}
394
-			} else {
445
+			}
446
+			else
447
+			{
395 448
 				$app = $field;
396 449
 				$app_id = $_data[$field];
397 450
 			}
398
-			if ($app && $app_id) {
451
+			if ($app && $app_id)
452
+			{
399 453
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
400 454
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
401 455
 				$link_id = Link::link('infolog',$id,$app,$app_id);
@@ -418,7 +472,8 @@  discard block
 block discarded – undo
418 472
 	 *
419 473
 	 * @return string name
420 474
 	 */
421
-	public static function get_name() {
475
+	public static function get_name()
476
+	{
422 477
 		return lang('Infolog CSV import');
423 478
 	}
424 479
 
@@ -427,7 +482,8 @@  discard block
 block discarded – undo
427 482
 	 *
428 483
 	 * @return string descriprion
429 484
 	 */
430
-	public static function get_description() {
485
+	public static function get_description()
486
+	{
431 487
 		return lang("Imports entries into the infolog from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
432 488
 	}
433 489
 
@@ -436,7 +492,8 @@  discard block
 block discarded – undo
436 492
 	 *
437 493
 	 * @return string suffix (comma seperated)
438 494
 	 */
439
-	public static function get_filesuffix() {
495
+	public static function get_filesuffix()
496
+	{
440 497
 		return 'csv';
441 498
 	}
442 499
 
@@ -452,7 +509,8 @@  discard block
 block discarded – undo
452 509
 	 * 		preserv		=> array,
453 510
 	 * )
454 511
 	 */
455
-	public function get_options_etpl() {
512
+	public function get_options_etpl()
513
+	{
456 514
 		// lets do it!
457 515
 	}
458 516
 
@@ -461,7 +519,8 @@  discard block
 block discarded – undo
461 519
 	 *
462 520
 	 * @return string etemplate name
463 521
 	 */
464
-	public function get_selectors_etpl() {
522
+	public function get_selectors_etpl()
523
+	{
465 524
 		// lets do it!
466 525
 	}
467 526
 
@@ -473,7 +532,8 @@  discard block
 block discarded – undo
473 532
 	*       record_# => warning message
474 533
 	*       )
475 534
 	*/
476
-	public function get_warnings() {
535
+	public function get_warnings()
536
+	{
477 537
 		return $this->warnings;
478 538
 	}
479 539
 
@@ -485,7 +545,8 @@  discard block
 block discarded – undo
485 545
 	*       record_# => error message
486 546
 	*       )
487 547
 	*/
488
-	public function get_errors() {
548
+	public function get_errors()
549
+	{
489 550
 		return $this->errors;
490 551
 	}
491 552
 
@@ -497,7 +558,8 @@  discard block
 block discarded – undo
497 558
 	*       action => record count
498 559
 	* )
499 560
 	*/
500
-	public function get_results() {
561
+	public function get_results()
562
+	{
501 563
 		return $this->results;
502 564
 	}
503 565
 	// end of iface_export_plugin
@@ -507,7 +569,10 @@  discard block
 block discarded – undo
507 569
 	{
508 570
 		static $boprojects=null;
509 571
 
510
-		if (!$num_or_title) return false;
572
+		if (!$num_or_title)
573
+		{
574
+			return false;
575
+		}
511 576
 
512 577
 		if (!is_object($boprojects))
513 578
 		{
@@ -552,12 +617,16 @@  discard block
 block discarded – undo
552 617
 			}
553 618
 
554 619
 			// Couldn't find field, give an error - something's wrong
555
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
620
+			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)])
621
+			{
556 622
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
557 623
 					$custom_field, lang($app));
558 624
 				return false;
559 625
 			}
560
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
626
+			if($custom_field[0] != '#')
627
+			{
628
+				$custom_field = '#' . $custom_field;
629
+			}
561 630
 
562 631
 			// Search
563 632
 			if(Link::get_registry($app, 'query'))
Please login to merge, or discard this patch.
infolog/inc/class.infolog_tracking.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,6 @@
 block discarded – undo
125 125
 	/**
126 126
 	 * Constructor
127 127
 	 *
128
-	 * @param botracker $botracker
129 128
 	 * @return tracker_tracking
130 129
 	 */
131 130
 	function __construct(&$infolog_bo)
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	function __construct(&$infolog_bo)
132 132
 	{
133
-		parent::__construct('infolog');	// add custom fields from infolog
133
+		parent::__construct('infolog'); // add custom fields from infolog
134 134
 
135
-		$this->infolog =& $infolog_bo;
135
+		$this->infolog = & $infolog_bo;
136 136
 	}
137 137
 
138 138
 	/**
@@ -144,23 +144,23 @@  discard block
 block discarded – undo
144 144
 	 * @param array $old
145 145
 	 * @return string
146 146
 	 */
147
-	function get_subject($data,$old)
147
+	function get_subject($data, $old)
148 148
 	{
149 149
 		if ($data['prefix'])
150 150
 		{
151
-			$prefix = $data['prefix'];	// async notification
151
+			$prefix = $data['prefix']; // async notification
152 152
 		}
153 153
 		elseif (!$old || $old['info_status'] == 'deleted')
154 154
 		{
155
-			$prefix = lang('New %1',lang($this->infolog->enums['type'][$data['info_type']]));
155
+			$prefix = lang('New %1', lang($this->infolog->enums['type'][$data['info_type']]));
156 156
 		}
157
-		elseif($data['info_status'] == 'deleted')
157
+		elseif ($data['info_status'] == 'deleted')
158 158
 		{
159
-			$prefix = lang('%1 deleted',lang($this->infolog->enums['type'][$data['info_type']]));
159
+			$prefix = lang('%1 deleted', lang($this->infolog->enums['type'][$data['info_type']]));
160 160
 		}
161 161
 		else
162 162
 		{
163
-			$prefix = lang('%1 modified',lang($this->infolog->enums['type'][$data['info_type']]));
163
+			$prefix = lang('%1 modified', lang($this->infolog->enums['type'][$data['info_type']]));
164 164
 		}
165 165
 		return $prefix.': '.$data['info_subject'];
166 166
 	}
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
 	 * @param array $old
173 173
 	 * @return string
174 174
 	 */
175
-	function get_message($data,$old)
175
+	function get_message($data, $old)
176 176
 	{
177
-		if ($data['message']) return $data['message'];	// async notification
177
+		if ($data['message']) return $data['message']; // async notification
178 178
 
179 179
 		if (!$old || $old['info_status'] == 'deleted')
180 180
 		{
181
-			return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
182
-				Api\Accounts::username($this->infolog->user),$this->datetime('now'));
181
+			return lang('New %1 created by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
182
+				Api\Accounts::username($this->infolog->user), $this->datetime('now'));
183 183
 		}
184
-		elseif($data['info_status'] == 'deleted')
184
+		elseif ($data['info_status'] == 'deleted')
185 185
 		{
186
-			return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
186
+			return lang('%1 deleted by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
187 187
 				Api\Accounts::username($data['info_modifier']),
188 188
 				$this->datetime($data['info_datemodified']));
189 189
 		}
190
-		return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
190
+		return lang('%1 modified by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
191 191
 			Api\Accounts::username($data['info_modifier']),
192 192
 			$this->datetime($data['info_datemodified']));
193 193
 	}
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	 * @param int|string $receiver nummeric account_id or email address
200 200
 	 * @return array of details as array with values for keys 'label','value','type'
201 201
 	 */
202
-	function get_details($data,$receiver=null)
202
+	function get_details($data, $receiver = null)
203 203
 	{
204
-		unset($receiver);	// not used, but required function signature
204
+		unset($receiver); // not used, but required function signature
205 205
 		//error_log(__METHOD__.__LINE__.' Data:'.array2string($data));
206 206
 		$responsible = array();
207 207
 		if ($data['info_responsible'])
208 208
 		{
209
-			foreach($data['info_responsible'] as $uid)
209
+			foreach ($data['info_responsible'] as $uid)
210 210
 			{
211 211
 				$responsible[] = Api\Accounts::username($uid);
212 212
 			}
@@ -215,39 +215,39 @@  discard block
 block discarded – undo
215 215
 		{
216 216
 			$id = ' #'.$data['info_id'];
217 217
 		}
218
-		foreach(array(
218
+		foreach (array(
219 219
 			'info_type'      => lang($this->infolog->enums['type'][$data['info_type']]).$id,
220 220
 			'info_from'      => $data['info_from'],
221 221
 			'info_addr'      => $data['info_addr'],
222 222
 			'info_cat'       => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '',
223 223
 			'info_priority'  => lang($this->infolog->enums['priority'][$data['info_priority']]),
224 224
 			'info_owner'     => Api\Accounts::username($data['info_owner']),
225
-			'info_status'    => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]),
225
+			'info_status'    => lang($data['info_status'] == 'deleted' ? 'deleted' : $this->infolog->status[$data['info_type']][$data['info_status']]),
226 226
 			'info_percent'   => (int)$data['info_percent'].'%',
227 227
 			'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '',
228 228
 			'info_location'  => $data['info_location'],
229
-			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'],null) : '',
230
-			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'],null) : '',
231
-			'info_responsible' => implode(', ',$responsible),
229
+			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'], null) : '',
230
+			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'], null) : '',
231
+			'info_responsible' => implode(', ', $responsible),
232 232
 			'info_subject'   => $data['info_subject'],
233 233
 		) as $name => $value)
234 234
 		{
235 235
 			//error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value));
236
-			if ($name=='info_from' && empty($value))
237
-				if(!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
236
+			if ($name == 'info_from' && empty($value))
237
+				if (!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
238 238
 				{
239 239
 					$lkeys = array_keys($data['link_to']['to_id']);
240
-					if (in_array($data['info_contact'],$lkeys))
240
+					if (in_array($data['info_contact'], $lkeys))
241 241
 					{
242
-						list($app,$id) = explode(':',$data['info_contact']);
243
-						if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
242
+						list($app, $id) = explode(':', $data['info_contact']);
243
+						if (!empty($app) && !empty($id)) $value = Link::title($app, $id);
244 244
 					}
245 245
 				}
246 246
 				else if ($data['info_link_id'])
247 247
 				{
248 248
 					$this->infolog->link_id2from($data);
249
-					list($app,$id) = explode(':',$data['info_contact']);
250
-					if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
249
+					list($app, $id) = explode(':', $data['info_contact']);
250
+					if (!empty($app) && !empty($id)) $value = Link::title($app, $id);
251 251
 				}
252 252
 			$details[$name] = array(
253 253
 				'label' => lang($this->field2label[$name]),
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @param boolean $skip_notification = false do NOT send any notification
279 279
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
280 280
 	 */
281
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
281
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
282 282
 	{
283 283
 		//error_log(__METHOD__.__LINE__.' notify?'.($skip_notification?'no':'yes').function_backtrace());
284 284
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 
288 288
 		if ($old && $this->field2history)
289 289
 		{
290
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
290
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
291 291
 		}
292 292
 
293 293
 		// Don't notify if the only change was to the modified date
294
-		if(is_null($changed_fields))
294
+		if (is_null($changed_fields))
295 295
 		{
296 296
 			$changed_fields = $this->changed_fields($data, $old);
297 297
 			$changes = count($changed_fields); // we need that since TRUE evaluates to 1
298 298
 		}
299 299
 		//error_log(__METHOD__.__LINE__.array2string($changed_fields));
300
-		if(is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
300
+		if (is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
301 301
 		{
302 302
 			return count($changes);
303 303
 		}
304 304
 
305 305
 		// do not run do_notifications if we have no changes
306
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
306
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
307 307
 		{
308 308
 			$changes = false;
309 309
 		}
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 	 * @param array $old = null old/last state of the entry or null for a new entry
322 322
 	 * @return mixed
323 323
 	 */
324
-	function get_config($name,$data,$old=null)
324
+	function get_config($name, $data, $old = null)
325 325
 	{
326
-		unset($old);	// not used, but required function signature
327
-		switch($name)
326
+		unset($old); // not used, but required function signature
327
+		switch ($name)
328 328
 		{
329 329
 			case 'copy':	// include the info_cc addresses
330
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
330
+				if ($data['info_access'] == 'private') return array(); // no copies for private entries
331 331
 				if ($data['info_cc'])
332 332
 				{
333
-					$config = preg_split('/, ?/',$data['info_cc']);
333
+					$config = preg_split('/, ?/', $data['info_cc']);
334 334
 				}
335 335
 				else
336 336
 				{
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 				break;
340 340
 			case self::CUSTOM_NOTIFICATION:
341 341
 				$info_config = Api\Config::read('infolog');
342
-				if(!$info_config[self::CUSTOM_NOTIFICATION])
342
+				if (!$info_config[self::CUSTOM_NOTIFICATION])
343 343
 				{
344 344
 					return '';
345 345
 				}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
349 349
 
350 350
 				// Disabled
351
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
351
+				if (!$type_config['use_custom'] && !$global['use_custom']) return '';
352 352
 
353 353
 				// Type or globabl
354 354
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
Braces   +29 added lines, -7 removed lines patch added patch discarded remove patch
@@ -174,7 +174,11 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	function get_message($data,$old)
176 176
 	{
177
-		if ($data['message']) return $data['message'];	// async notification
177
+		if ($data['message'])
178
+		{
179
+			return $data['message'];
180
+		}
181
+		// async notification
178 182
 
179 183
 		if (!$old || $old['info_status'] == 'deleted')
180 184
 		{
@@ -234,26 +238,37 @@  discard block
 block discarded – undo
234 238
 		{
235 239
 			//error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value));
236 240
 			if ($name=='info_from' && empty($value))
237
-				if(!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
241
+			{
242
+							if(!empty($data['info_contact']) && is_array($data['link_to']['to_id']))
238 243
 				{
239 244
 					$lkeys = array_keys($data['link_to']['to_id']);
245
+			}
240 246
 					if (in_array($data['info_contact'],$lkeys))
241 247
 					{
242 248
 						list($app,$id) = explode(':',$data['info_contact']);
243
-						if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
249
+						if (!empty($app)&&!empty($id))
250
+						{
251
+							$value = Link::title($app,$id);
252
+						}
244 253
 					}
245 254
 				}
246 255
 				else if ($data['info_link_id'])
247 256
 				{
248 257
 					$this->infolog->link_id2from($data);
249 258
 					list($app,$id) = explode(':',$data['info_contact']);
250
-					if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
259
+					if (!empty($app)&&!empty($id))
260
+					{
261
+						$value = Link::title($app,$id);
262
+					}
251 263
 				}
252 264
 			$details[$name] = array(
253 265
 				'label' => lang($this->field2label[$name]),
254 266
 				'value' => $value,
255 267
 			);
256
-			if ($name == 'info_subject') $details[$name]['type'] = 'summary';
268
+			if ($name == 'info_subject')
269
+			{
270
+				$details[$name]['type'] = 'summary';
271
+			}
257 272
 		}
258 273
 		$details['info_des'] = array(
259 274
 			'value' => $data['info_des'],
@@ -327,7 +342,11 @@  discard block
 block discarded – undo
327 342
 		switch($name)
328 343
 		{
329 344
 			case 'copy':	// include the info_cc addresses
330
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
345
+				if ($data['info_access'] == 'private')
346
+				{
347
+					return array();
348
+				}
349
+				// no copies for private entries
331 350
 				if ($data['info_cc'])
332 351
 				{
333 352
 					$config = preg_split('/, ?/',$data['info_cc']);
@@ -348,7 +367,10 @@  discard block
 block discarded – undo
348 367
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
349 368
 
350 369
 				// Disabled
351
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
370
+				if(!$type_config['use_custom'] && !$global['use_custom'])
371
+				{
372
+					return '';
373
+				}
352 374
 
353 375
 				// Type or globabl
354 376
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
json.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  * callback if the session-check fails, redirects to login.php, if no valid basic auth credentials given
19 19
  *
20 20
  * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
21
- * @return boolean|string true if we allow anon access and anon_account is set, a sessionid or false otherwise
21
+ * @return string|null true if we allow anon access and anon_account is set, a sessionid or false otherwise
22 22
  */
23 23
 function login_redirect(&$anon_account)
24 24
 {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		return $session_id;
30 30
 	}
31
-	Json\Request::isJSONRequest(true);	// because Api\Json\Request::parseRequest() is not (yet) called
31
+	Json\Request::isJSONRequest(true); // because Api\Json\Request::parseRequest() is not (yet) called
32 32
 	$response = Json\Response::get();
33 33
 	$response->redirect($GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10', true);
34 34
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	$message = null;
54 54
 	if (function_exists('_egw_log_exception'))
55 55
 	{
56
-		_egw_log_exception($e,$message);
56
+		_egw_log_exception($e, $message);
57 57
 	}
58 58
 	$response = Json\Response::get();
59 59
 	$message .= ($message ? "\n\n" : '').$e->getMessage();
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['menuaction']))
75 75
 {
76
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
76
+	if (strpos($_GET['menuaction'], '::') !== false && strpos($_GET['menuaction'], '.') === false)	// static method name app_something::method
77 77
 	{
78
-		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
78
+		@list($className, $functionName, $handler) = explode('::', $_GET['menuaction']);
79 79
 
80 80
 		if (substr($className, 0, 11) == 'EGroupware\\')
81 81
 		{
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		}
84 84
 		else
85 85
 		{
86
-			list($appName) = explode('_',$className);
86
+			list($appName) = explode('_', $className);
87 87
 		}
88 88
 	}
89 89
 	else
90 90
 	{
91
-		@list($appName, $className, $functionName, $handler) = explode('.',$_GET['menuaction']);
91
+		@list($appName, $className, $functionName, $handler) = explode('.', $_GET['menuaction']);
92 92
 	}
93 93
 	//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
94 94
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			'noheader'		=> True,
99 99
 			'disable_Template_class'	=> True,
100 100
 			'autocreate_session_callback' => 'login_redirect',
101
-			'no_exception_handler' => true,	// we already installed our own
101
+			'no_exception_handler' => true, // we already installed our own
102 102
 			// only log ajax requests which represent former GET requests or submits
103 103
 			// cuts down updates to egw_access_log table
104 104
 			'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']),
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	//Check whether the request data is set
114 114
 	if (isset($GLOBALS['egw_unset_vars']['_POST[json_data]']))
115 115
 	{
116
-		$json->isJSONRequest(true);	// otherwise exception is not send back to client, as we have not yet called parseRequest()
116
+		$json->isJSONRequest(true); // otherwise exception is not send back to client, as we have not yet called parseRequest()
117 117
 		throw new Json\Exception\ScriptTags("JSON Data contains script tags. Aborting...");
118 118
 	}
119 119
 	$json->parseRequest($_GET['menuaction'], $_REQUEST['json_data']);
@@ -121,4 +121,4 @@  discard block
 block discarded – undo
121 121
 	exit();
122 122
 }
123 123
 
124
-throw new Json\Exception($_SERVER['PHP_SELF'] . ' Invalid AJAX JSON Request');
124
+throw new Json\Exception($_SERVER['PHP_SELF'].' Invalid AJAX JSON Request');
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,9 +73,12 @@
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['menuaction']))
75 75
 {
76
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
76
+	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)
77
+	{
78
+		// static method name app_something::method
77 79
 	{
78 80
 		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
81
+	}
79 82
 
80 83
 		if (substr($className, 0, 11) == 'EGroupware\\')
81 84
 		{
Please login to merge, or discard this patch.
mail/inc/class.mail_acl.inc.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -277,8 +277,6 @@
 block discarded – undo
277 277
 	 * Update ACL rights of a folder or including subfolders for an account(s)
278 278
 	 *
279 279
 	 * @param array $content content including the acl rights
280
-	 * @param Boolean $recursive boolean flag FALSE|TRUE. If it is FALSE, only the folder take in to account, but in case of TRUE
281
-	 *		the mailbox including all its subfolders will be considered.
282 280
 	 * @param string $msg Message
283 281
 	 *
284 282
 	 */
Please login to merge, or discard this patch.
Braces   +28 added lines, -8 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 			//Todo: Implement autocomplete_url function with admin stuffs consideration
98 98
 		}
99 99
 		// Unset the content if folder is changed, in order to read acl rights for new selected folder
100
-		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete'])) unset($content);
100
+		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete']))
101
+		{
102
+			unset($content);
103
+		}
101 104
 
102 105
 		if (!is_array($content))
103 106
 		{
@@ -172,7 +175,9 @@  discard block
 block discarded – undo
172 175
 
173 176
 						//Add new row at the end
174 177
 						if ($content['grid'][count($content['grid'])]['acc_id'])
175
-							array_push($content['grid'], array('acc_id'=>''));
178
+						{
179
+													array_push($content['grid'], array('acc_id'=>''));
180
+						}
176 181
 					}
177 182
 					else
178 183
 					{
@@ -180,7 +185,10 @@  discard block
 block discarded – undo
180 185
 					}
181 186
 					//Send message
182 187
 					Framework::message($msg);
183
-					if ($button == "apply") break;
188
+					if ($button == "apply")
189
+					{
190
+						break;
191
+					}
184 192
 					Framework::window_close();
185 193
 					exit;
186 194
 
@@ -304,8 +312,16 @@  discard block
 block discarded – undo
304 312
 				if ($value[$key] == true)
305 313
 				{
306 314
 					$right = explode("acl_" ,$key);
307
-					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
308
-					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
315
+					if ($right[1] === 'c')
316
+					{
317
+						$right[1] = 'kx';
318
+					}
319
+					// c = kx , rfc 4314
320
+					if ($right[1] === 'd')
321
+					{
322
+						$right[1] = 'et';
323
+					}
324
+					// d = et , rfc 4314
309 325
 					$options['rights'] .=  $right[1];
310 326
 				}
311 327
 			}
@@ -351,7 +367,7 @@  discard block
 block discarded – undo
351 367
 	function retrieve_acl ($mailbox, &$msg)
352 368
 	{
353 369
 		if (($acl = $this->getACL($mailbox)))
354
-		 {
370
+		{
355 371
 			$msg = lang('ACL rights retrieved successfully');
356 372
 			return $acl;
357 373
 		 }
@@ -374,7 +390,10 @@  discard block
 block discarded – undo
374 390
 	function remove_acl($content, &$msg)
375 391
 	{
376 392
 		$row_num = array_keys($content['grid']['delete'],"pressed");
377
-		if ($row_num) $row_num = $row_num[0];
393
+		if ($row_num)
394
+		{
395
+			$row_num = $row_num[0];
396
+		}
378 397
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
379 398
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
380 399
 		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
@@ -514,7 +533,8 @@  discard block
 block discarded – undo
514 533
 		{
515 534
 			$acl = $this->imap->getACL($mailbox);
516 535
 			return $acl;
517
-		} catch (Exception $e) {
536
+		}
537
+		catch (Exception $e) {
518 538
 			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
519 539
 			return false;
520 540
 		}
Please login to merge, or discard this patch.
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 */
35 35
 	var $aclRightsAbbrvs = array(
36
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
37
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
-		'ilprsw'	=> array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
-		'aeiklprstwx'=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
36
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
37
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
+		'ilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
+		'aeiklprstwx'=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
42 42
 	);
43 43
 
44 44
 	/**
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	 * @param string $msg = ''
62 62
 	 *
63 63
 	 */
64
-	function edit(array $content=null ,$msg='')
64
+	function edit(array $content = null, $msg = '')
65 65
 	{
66 66
 		$tmpl = new Etemplate('mail.acl');
67 67
 		if (!is_array($content))
68 68
 		{
69
-			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
69
+			$acc_id = $_GET['acc_id'] ? $_GET['acc_id'] : $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
70 70
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
71 71
 			{
72 72
 				Framework::window_close(lang('Permission denied'));
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 		$account = Mail\Account::read($acc_id, $account_id);
82 82
 		$this->imap = $account->imapServer(isset($account_id) ? (int)$account_id : false);
83 83
 
84
-		$mailbox = $_GET['mailbox']? base64_decode($_GET['mailbox']):
85
-			preg_replace("/^".$acc_id."::/",'',$content['mailbox'][0]);
84
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : preg_replace("/^".$acc_id."::/", '', $content['mailbox'][0]);
86 85
 		if (empty($mailbox))
87 86
 		{
88 87
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($account_id) : 'INBOX';
@@ -113,14 +112,14 @@  discard block
 block discarded – undo
113 112
 
114 113
 					foreach ($rights as $right)
115 114
 					{
116
-						$content['grid'][$n]['acl_'. $right] = true;
115
+						$content['grid'][$n]['acl_'.$right] = true;
117 116
 					}
118
-					$virtualD = array('e','t');
119
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
120
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
117
+					$virtualD = array('e', 't');
118
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false: true; //c=kx more information rfc4314, Obsolote Rights
119
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false: true; //d=et more information rfc4314, Obsolote Rights
121 120
 
122 121
 					sort($rights);
123
-					$acl_abbrvs = implode('',$rights);
122
+					$acl_abbrvs = implode('', $rights);
124 123
 
125 124
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
126 125
 					{
@@ -161,7 +160,7 @@  discard block
 block discarded – undo
161 160
 				case 'apply':
162 161
 					if ($content)
163 162
 					{
164
-						$validation_err = $this->update_acl($content,$msg);
163
+						$validation_err = $this->update_acl($content, $msg);
165 164
 						if ($validation_err)
166 165
 						{
167 166
 							foreach ($validation_err as &$row)
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 					}
193 192
 					else
194 193
 					{
195
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
194
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
196 195
 					}
197 196
 					Framework::message($msg);
198 197
 			}
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
202 201
 
203 202
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
204
-		foreach($content['grid'] as $key => $fields)
203
+		foreach ($content['grid'] as $key => $fields)
205 204
 		{
206 205
 			if (self::_extract_acc_id($fields['acc_id']) == $this->imap->acc_imap_username ||
207 206
 					$this->imap->getMailBoxUserName(self::_extract_acc_id($fields['acc_id'])) == $this->imap->acc_imap_username)
@@ -240,7 +239,7 @@  discard block
 block discarded – undo
240 239
 			));
241 240
 		}
242 241
 
243
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
242
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
244 243
 	}
245 244
 
246 245
 	/**
@@ -259,7 +258,7 @@  discard block
 block discarded – undo
259 258
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
260 259
 
261 260
 		$folders = array();
262
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
261
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
263 262
 		{
264 263
 			if (stripos($folder, $_GET['query']) !== false)
265 264
 			{
@@ -287,7 +286,7 @@  discard block
 block discarded – undo
287 286
 	 * @param string $msg Message
288 287
 	 *
289 288
 	 */
290
-	function update_acl ($content, &$msg)
289
+	function update_acl($content, &$msg)
291 290
 	{
292 291
 		$validator = array();
293 292
 
@@ -303,10 +302,10 @@  discard block
 block discarded – undo
303 302
 			{
304 303
 				if ($value[$key] == true)
305 304
 				{
306
-					$right = explode("acl_" ,$key);
305
+					$right = explode("acl_", $key);
307 306
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
308 307
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
309
-					$options['rights'] .=  $right[1];
308
+					$options['rights'] .= $right[1];
310 309
 				}
311 310
 			}
312 311
 			$username = self::_extract_acc_id($content['grid'][$keys]['acc_id']);
@@ -319,7 +318,7 @@  discard block
 block discarded – undo
319 318
 			if (!empty($username))
320 319
 			{
321 320
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
322
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
321
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
323 322
 				{
324 323
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
325 324
 
@@ -331,7 +330,7 @@  discard block
 block discarded – undo
331 330
 			}
332 331
 			else
333 332
 			{
334
-				if($keys !== count($content['grid']))
333
+				if ($keys !== count($content['grid']))
335 334
 				{
336 335
 					array_push($validator, $keys);
337 336
 					$msg = lang("Error:Could not save the ACL! Because some names are empty!");
@@ -348,7 +347,7 @@  discard block
 block discarded – undo
348 347
 	 * Retrieve Folder ACL rights
349 348
 	 * @todo rights 'c' and 'd' should be fixed
350 349
 	 */
351
-	function retrieve_acl ($mailbox, &$msg)
350
+	function retrieve_acl($mailbox, &$msg)
352 351
 	{
353 352
 		if (($acl = $this->getACL($mailbox)))
354 353
 		 {
@@ -373,34 +372,34 @@  discard block
 block discarded – undo
373 372
 	 */
374 373
 	function remove_acl($content, &$msg)
375 374
 	{
376
-		$row_num = array_keys($content['grid']['delete'],"pressed");
375
+		$row_num = array_keys($content['grid']['delete'], "pressed");
377 376
 		if ($row_num) $row_num = $row_num[0];
378 377
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
379 378
 		$identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
380
-		$content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
379
+		$content['mailbox'] = is_array($content['mailbox']) ? $content['mailbox'][0] : $content['mailbox'];
381 380
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
382 381
 		{
383 382
 			$identifier = $u;
384 383
 		}
385 384
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
386
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
385
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
387 386
 		{
388 387
 			unset($content['grid'][$row_num]);
389 388
 			unset($content['grid']['delete']);
390 389
 			if ($recursive)
391 390
 			{
392
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
391
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
393 392
 			}
394 393
 			else
395 394
 			{
396
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
395
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
397 396
 			}
398 397
 
399 398
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
400 399
 		}
401 400
 		else
402 401
 		{
403
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
402
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
404 403
 			return false;
405 404
 		}
406 405
 	}
@@ -415,7 +414,7 @@  discard block
 block discarded – undo
415 414
 	 *
416 415
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
417 416
 	 */
418
-	function deleteACL ($mailbox, $identifier, $recursive)
417
+	function deleteACL($mailbox, $identifier, $recursive)
419 418
 	{
420 419
 		if ($recursive)
421 420
 		{
@@ -425,7 +424,7 @@  discard block
 block discarded – undo
425 424
 		{
426 425
 			$folders = (array)$mailbox;
427 426
 		}
428
-		foreach($folders as $sbFolders)
427
+		foreach ($folders as $sbFolders)
429 428
 		{
430 429
 			try
431 430
 			{
@@ -433,7 +432,7 @@  discard block
 block discarded – undo
433 432
 			}
434 433
 			catch (Exception $e)
435 434
 			{
436
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ."." .$e->getMessage());
435
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
437 436
 				return false;
438 437
 			}
439 438
 		}
@@ -476,7 +475,7 @@  discard block
 block discarded – undo
476 475
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
477 476
 	 *
478 477
 	 */
479
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
478
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
480 479
 	{
481 480
 		if ($recursive)
482 481
 		{
@@ -486,16 +485,16 @@  discard block
 block discarded – undo
486 485
 		{
487 486
 			$folders = (array)$mailbox;
488 487
 		}
489
-		foreach($folders as $sbFolders)
488
+		foreach ($folders as $sbFolders)
490 489
 		{
491 490
 			try
492 491
 			{
493
-				$this->imap->setACL($sbFolders,$identifier,$options);
492
+				$this->imap->setACL($sbFolders, $identifier, $options);
494 493
 			}
495 494
 			catch (Exception $e)
496 495
 			{
497 496
 				$msg = $e->getMessage();
498
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . "." .$e->getMessage());
497
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier.".".$e->getMessage());
499 498
 				return false;
500 499
 			}
501 500
 		}
@@ -508,14 +507,14 @@  discard block
 block discarded – undo
508 507
 	 * @param String $mailbox folder name that needs to be read
509 508
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
510 509
 	 */
511
-	function getACL ($mailbox)
510
+	function getACL($mailbox)
512 511
 	{
513 512
 		try
514 513
 		{
515 514
 			$acl = $this->imap->getACL($mailbox);
516 515
 			return $acl;
517 516
 		} catch (Exception $e) {
518
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . "." .$e->getMessage());
517
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox.".".$e->getMessage());
519 518
 			return false;
520 519
 		}
521 520
 	}
@@ -527,8 +526,8 @@  discard block
 block discarded – undo
527 526
 	 *
528 527
 	 * @return string returns acc_id in flat format
529 528
 	 */
530
-	private static function _extract_acc_id ($acc_id)
529
+	private static function _extract_acc_id($acc_id)
531 530
 	{
532
-		return is_array($acc_id)?$acc_id[0]:$acc_id;
531
+		return is_array($acc_id) ? $acc_id[0] : $acc_id;
533 532
 	}
534 533
 }
Please login to merge, or discard this patch.
mail/inc/class.mail_compose.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1960,7 +1960,7 @@
 block discarded – undo
1960 1960
 	/**
1961 1961
 	 * Gather the replyData and save it with the session, to be used then
1962 1962
 	 *
1963
-	 * @param $_mode can be:
1963
+	 * @param string $_mode can be:
1964 1964
 	 * 		single: for a reply to one address
1965 1965
 	 * 		all: for a reply to all
1966 1966
 	 * 		forward: inlineforwarding of a message with its attachments
Please login to merge, or discard this patch.
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.
Braces   +803 added lines, -269 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
 		}
@@ -242,7 +255,8 @@  discard block
 block discarded – undo
242 255
 		{
243 256
 			foreach (array_keys($actions) as $key)
244 257
 			{
245
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
258
+				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' )))
259
+				{
246 260
 					$actions[$key]['toolbarDefault'] = false;
247 261
 				}
248 262
 			}
@@ -268,7 +282,10 @@  discard block
 block discarded – undo
268 282
 	 */
269 283
 	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
270 284
 	{
271
-		if ($msg) Framework::message($msg);
285
+		if ($msg)
286
+		{
287
+			Framework::message($msg);
288
+		}
272 289
 
273 290
 		if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
274 291
 		{
@@ -289,8 +306,14 @@  discard block
 block discarded – undo
289 306
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
290 307
 		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
291 308
 		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
292
-		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
293
-		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
309
+		if (isset($_GET['reply_id']))
310
+		{
311
+			$replyID = $_GET['reply_id'];
312
+		}
313
+		if (!$replyID && isset($_GET['id']))
314
+		{
315
+			$replyID = $_GET['id'];
316
+		}
294 317
 
295 318
 		// Process different places we can use as a start for composing an email
296 319
 		$actionToProcess = 'compose';
@@ -357,7 +380,10 @@  discard block
 block discarded – undo
357 380
 			$suppressSigOnTop = true;
358 381
 			foreach ($_content['uploadForCompose'] as $i => &$upload)
359 382
 			{
360
-				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
383
+				if (!isset($upload['file']))
384
+				{
385
+					$upload['file'] = $upload['tmp_name'];
386
+				}
361 387
 				try
362 388
 				{
363 389
 					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
@@ -391,9 +417,15 @@  discard block
 block discarded – undo
391 417
 				$remove=false;
392 418
 				foreach(array_keys($toDelete) as $k)
393 419
 				{
394
-					if ($att['tmp_name']==$k) $remove=true;
420
+					if ($att['tmp_name']==$k)
421
+					{
422
+						$remove=true;
423
+					}
424
+				}
425
+				if (!$remove)
426
+				{
427
+					$_content['attachments'][] = $att;
395 428
 				}
396
-				if (!$remove) $_content['attachments'][] = $att;
397 429
 			}
398 430
 		}
399 431
 		// someone clicked something like send, or saveAsDraft
@@ -408,8 +440,7 @@  discard block
 block discarded – undo
408 440
 		//error_log(__METHOD__.__LINE__.array2string($_content));
409 441
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
410 442
 			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
411
-		)
412
-		{
443
+		) {
413 444
 			$this->changeProfile($_content['serverID']);
414 445
 			$composeProfile = $this->mail_bo->profileID;
415 446
 		}
@@ -489,7 +520,10 @@  discard block
 block discarded – undo
489 520
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
490 521
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
491 522
 							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
492
-							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
523
+							if (!empty($fhA['folder']))
524
+							{
525
+								$workingFolder = $fhA['folder'];
526
+							}
493 527
 						}
494 528
 					}
495 529
 					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
@@ -540,7 +574,10 @@  discard block
 block discarded – undo
540 574
 			}
541 575
 		}
542 576
 
543
-		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
577
+		if ($activeProfile != $composeProfile)
578
+		{
579
+			$this->changeProfile($activeProfile);
580
+		}
544 581
 		$insertSigOnTop = false;
545 582
 		$content = (is_array($_content)?$_content:array());
546 583
 		if ($_contentHasMimeType)
@@ -569,7 +606,10 @@  discard block
 block discarded – undo
569 606
 				{
570 607
 					foreach ($contentArr as $k =>&$elem)
571 608
 					{
572
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
609
+						if (stripos($elem,'<pre>')!==false)
610
+						{
611
+							$elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
612
+						}
573 613
 					}
574 614
 					$content['mail_htmltext'] = implode('',$contentArr);
575 615
 				}
@@ -611,8 +651,7 @@  discard block
 block discarded – undo
611 651
 		if ( !empty($content['body']) &&
612 652
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
613 653
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
614
-		)
615
-		{
654
+		) {
616 655
 			$buttonClicked = true;
617 656
 			$suppressSigOnTop = true;
618 657
 			if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount'])
@@ -628,7 +667,10 @@  discard block
 block discarded – undo
628 667
 				else
629 668
 				{
630 669
 					$newSig = $this->mail_bo->getDefaultIdentity();
631
-					if ($newSig === false) $newSig = -2;
670
+					if ($newSig === false)
671
+					{
672
+						$newSig = -2;
673
+					}
632 674
 				}
633 675
 			}
634 676
 			$_oldSig = $composeCache['mailidentity'];
@@ -636,7 +678,10 @@  discard block
 block discarded – undo
636 678
 
637 679
 			if ($_oldSig != $_signatureid)
638 680
 			{
639
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
681
+				if($this->_debug)
682
+				{
683
+					error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
684
+				}
640 685
 				// prepare signatures, the selected sig may be used on top of the body
641 686
 				try
642 687
 				{
@@ -666,7 +711,10 @@  discard block
 block discarded – undo
666 711
 				{
667 712
 					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
668 713
 					$sigText = $this->convertHTMLToText($sigText,true,true);
669
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
714
+					if($this->_debug)
715
+					{
716
+						error_log(__METHOD__." Old signature:".$oldSigText);
717
+					}
670 718
 				}
671 719
 
672 720
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -682,7 +730,11 @@  discard block
 block discarded – undo
682 730
 				{
683 731
 					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
684 732
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
685
-					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
733
+					if (stripos($content['body'],'style')!==false)
734
+					{
735
+						Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true);
736
+					}
737
+					// clean out empty or pagewide style definitions / left over tags
686 738
 				}
687 739
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
688 740
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -727,8 +779,14 @@  discard block
 block discarded – undo
727 779
 
728 780
 				if ($found === false)
729 781
 				{
730
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
731
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
782
+					if($this->_debug)
783
+					{
784
+						error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
785
+					}
786
+					if($this->_debug)
787
+					{
788
+						error_log(__METHOD__." Compare content:".$content['body']);
789
+					}
732 790
 				}
733 791
 				else
734 792
 				{
@@ -746,7 +804,10 @@  discard block
 block discarded – undo
746 804
 		$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
747 805
 
748 806
 		// do not double insert a signature on a server roundtrip
749
-		if ($buttonClicked) $suppressSigOnTop = true;
807
+		if ($buttonClicked)
808
+		{
809
+			$suppressSigOnTop = true;
810
+		}
750 811
 		if ($isFirstLoad)
751 812
 		{
752 813
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
@@ -785,7 +846,8 @@  discard block
 block discarded – undo
785 846
 							}
786 847
 						}
787 848
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
788
-						foreach(array('subject','body','mimetype') as $name) {
849
+						foreach(array('subject','body','mimetype') as $name)
850
+						{
789 851
 							$sName = $name;
790 852
 							if ($name=='mimetype'&&$res[$name])
791 853
 							{
@@ -794,7 +856,10 @@  discard block
 block discarded – undo
794 856
 							}
795 857
 							else
796 858
 							{
797
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
859
+								if ($res[$name])
860
+								{
861
+									$content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
862
+								}
798 863
 							}
799 864
 						}
800 865
 					}
@@ -805,7 +870,8 @@  discard block
 block discarded – undo
805 870
 			{
806 871
 				$alreadyProcessed=array();
807 872
 				//_debug_array($_REQUEST);
808
-				if ($_REQUEST['preset']['mailto']) {
873
+				if ($_REQUEST['preset']['mailto'])
874
+				{
809 875
 					// handle mailto strings such as
810 876
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
811 877
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
@@ -813,10 +879,12 @@  discard block
 block discarded – undo
813 879
 					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
814 880
 					// check if there is more than the to address
815 881
 					$mailtoArray = explode('?',$tmp_send_to,2);
816
-					if ($mailtoArray[1]) {
882
+					if ($mailtoArray[1])
883
+					{
817 884
 						// check if there are more than one requests
818 885
 						$addRequests = explode('&',$mailtoArray[1]);
819
-						foreach ($addRequests as $key => $reqval) {
886
+						foreach ($addRequests as $key => $reqval)
887
+						{
820 888
 							// the additional requests should have a =, to separate key from value.
821 889
 							$keyValuePair = explode('=',$reqval,2);
822 890
 							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
@@ -825,17 +893,24 @@  discard block
 block discarded – undo
825 893
 					$content['to']=$mailtoArray[0];
826 894
 					$alreadyProcessed['to']='to';
827 895
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
828
-					foreach(array('cc','bcc','subject','body') as $name) {
896
+					foreach(array('cc','bcc','subject','body') as $name)
897
+					{
829 898
 						$alreadyProcessed[$name]=$name;
830
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
899
+						if ($_REQUEST[$name])
900
+						{
901
+							$content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
902
+						}
831 903
 					}
832 904
 				}
833 905
 
834
-				if ($_REQUEST['preset']['mailtocontactbyid']) {
835
-					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
906
+				if ($_REQUEST['preset']['mailtocontactbyid'])
907
+				{
908
+					if ($GLOBALS['egw_info']['user']['apps']['addressbook'])
909
+					{
836 910
 						$contacts_obj = new Api\Contacts();
837 911
 						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
838
-						if (method_exists($contacts_obj,'search')) {
912
+						if (method_exists($contacts_obj,'search'))
913
+						{
839 914
 
840 915
 							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
841 916
 							foreach ((array)$addressArray as $id => $addressID)
@@ -850,7 +925,10 @@  discard block
 block discarded – undo
850 925
 							{
851 926
 								$_searchCond = array('contact_id'=>$addressArray);
852 927
 								//error_log(__METHOD__.__LINE__.$_searchString);
853
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
928
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
929
+								{
930
+									$showAccounts=false;
931
+								}
854 932
 								$filter = ($showAccounts?array():array('account_id' => null));
855 933
 								$filter['cols_to_search']=array('n_fn','email','email_home');
856 934
 								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
@@ -873,21 +951,28 @@  discard block
 block discarded – undo
873 951
 									unset($accounts);
874 952
 								}
875 953
 							}
876
-							if(is_array($contacts)) {
954
+							if(is_array($contacts))
955
+							{
877 956
 								$mailtoArray = array();
878 957
 								$primary = $addressbookprefs['distributionListPreferredMail'];
879
-								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
958
+								if ($primary != 'email' && $primary != 'email_home')
959
+								{
960
+									$primary = 'email';
961
+								}
880 962
 								$secondary = ($primary == 'email'?'email_home':'email');
881 963
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
882
-								foreach($contacts as $contact) {
964
+								foreach($contacts as $contact)
965
+								{
883 966
 									$innerCounter=0;
884
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
967
+									foreach(array($contact[$primary],$contact[$secondary]) as $email)
968
+									{
885 969
 										// use pref distributionListPreferredMail for the primary address
886 970
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
887 971
 										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
888 972
 										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
889 973
 										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
890
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
974
+										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false)
975
+										{
891 976
 											$i++;
892 977
 											$innerCounter++;
893 978
 											$mailtoArray[$i] = $completeMailString;
@@ -979,7 +1064,10 @@  discard block
 block discarded – undo
979 1064
 							}
980 1065
 						}
981 1066
 					}
982
-					if(!empty($remember)) $content = array_merge($content,$remember);
1067
+					if(!empty($remember))
1068
+					{
1069
+						$content = array_merge($content,$remember);
1070
+					}
983 1071
 				}
984 1072
 				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
985 1073
 				{
@@ -989,9 +1077,15 @@  discard block
 block discarded – undo
989 1077
 						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
990 1078
 					}
991 1079
 					//skip if already processed by "preset Routines"
992
-					if ($alreadyProcessed[$name]) continue;
1080
+					if ($alreadyProcessed[$name])
1081
+					{
1082
+						continue;
1083
+					}
993 1084
 					//error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]);
994
-					if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name];
1085
+					if ($_REQUEST['preset'][$name])
1086
+					{
1087
+						$content[$name] = $_REQUEST['preset'][$name];
1088
+					}
995 1089
 				}
996 1090
 			}
997 1091
 			// is the to address set already?
@@ -999,7 +1093,10 @@  discard block
 block discarded – undo
999 1093
 			{
1000 1094
 				$content['to'] = base64_decode($_REQUEST['send_to']);
1001 1095
 				// first check if there is a questionmark or ampersand
1002
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1096
+				if (strpos($content['to'],'?')!== false)
1097
+				{
1098
+					list($content['to'],$rest) = explode('?',$content['to'],2);
1099
+				}
1003 1100
 				$content['to'] = html_entity_decode($content['to']);
1004 1101
 				if (($at_pos = strpos($content['to'],'@')) !== false)
1005 1102
 				{
@@ -1012,9 +1109,15 @@  discard block
 block discarded – undo
1012 1109
 						$content['to'] = $email;
1013 1110
 					}
1014 1111
 				}
1015
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1112
+				if (strpos($content['to'],'%40')!== false)
1113
+				{
1114
+					$content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1115
+				}
1016 1116
 				$rarr = array(Api\Html::purify($rest));
1017
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1117
+				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false)
1118
+				{
1119
+					$rarr = explode('&',$rest);
1120
+				}
1018 1121
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1019 1122
 				$karr = array();
1020 1123
 				foreach ($rarr as &$rval)
@@ -1030,9 +1133,15 @@  discard block
 block discarded – undo
1030 1133
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1031 1134
 				foreach(array('cc','bcc','subject','body') as $name)
1032 1135
 				{
1033
-					if ($karr[$name]) $content[$name] = $karr[$name];
1136
+					if ($karr[$name])
1137
+					{
1138
+						$content[$name] = $karr[$name];
1139
+					}
1140
+				}
1141
+				if (!empty($_REQUEST['subject']))
1142
+				{
1143
+					$content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1034 1144
 				}
1035
-				if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1036 1145
 			}
1037 1146
 		}
1038 1147
 		//error_log(__METHOD__.__LINE__.array2string($content));
@@ -1050,7 +1159,10 @@  discard block
 block discarded – undo
1050 1159
 				$_content['mimeType'] = $content['mimeType']  = 'html';
1051 1160
 				$content['body'] = "<pre>".$content['body']."</pre>";
1052 1161
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1053
-				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);
1162
+				if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1163
+				{
1164
+					$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1165
+				}
1054 1166
 			}
1055 1167
 		}
1056 1168
 		else
@@ -1070,7 +1182,10 @@  discard block
 block discarded – undo
1070 1182
 					$_content['mimeType'] = $content['mimeType']  = 'html';
1071 1183
 					$content['body'] = "<pre>".$content['body']."</pre>";
1072 1184
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1073
-					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);
1185
+					if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1186
+					{
1187
+						$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1188
+					}
1074 1189
 				}
1075 1190
 			}
1076 1191
 		}
@@ -1108,24 +1223,33 @@  discard block
 block discarded – undo
1108 1223
 			$disableRuler = true;
1109 1224
 		}
1110 1225
 		$font_span = $font_part = '';
1111
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1226
+		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/)
1227
+		{
1112 1228
 			// User preferences for style
1113 1229
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1114 1230
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1115 1231
 			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1116 1232
 			$font_span = $font_part.'&#8203;</span>';
1117
-			if (empty($font) && empty($font_size)) $font_span = '';
1233
+			if (empty($font) && empty($font_size))
1234
+			{
1235
+				$font_span = '';
1236
+			}
1118 1237
 		}
1119 1238
 		// 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
1120
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1239
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false)
1240
+		{
1241
+			$font_span = '';
1242
+		}
1121 1243
 		//remove possible html header stuff
1122
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1244
+		if (stripos($content['body'],'<html><head></head><body>')!==false)
1245
+		{
1246
+			$content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1247
+		}
1123 1248
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1124 1249
 		$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');
1125 1250
 		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1126 1251
 			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1127
-		)
1128
-		{
1252
+		) {
1129 1253
 			// ON tOP OR BELOW? pREF CAN TELL
1130 1254
 			/*
1131 1255
 				Signature behavior preference changed. New default, if not set -> 0
@@ -1140,14 +1264,23 @@  discard block
 block discarded – undo
1140 1264
 				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1141 1265
 				foreach($blockElements as $e)
1142 1266
 				{
1143
-					if ($sigTextStartsWithBlockElement) break;
1144
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1267
+					if ($sigTextStartsWithBlockElement)
1268
+					{
1269
+						break;
1270
+					}
1271
+					if (stripos(trim($sigText),'<'.$e)===0)
1272
+					{
1273
+						$sigTextStartsWithBlockElement = true;
1274
+					}
1145 1275
 				}
1146 1276
 			}
1147
-			if($content['mimeType'] == 'html') {
1277
+			if($content['mimeType'] == 'html')
1278
+			{
1148 1279
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1149 1280
 				$inbetween = '';
1150
-			} else {
1281
+			}
1282
+			else
1283
+			{
1151 1284
 				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1152 1285
 				$inbetween = "\r\n";
1153 1286
 			}
@@ -1181,7 +1314,10 @@  discard block
 block discarded – undo
1181 1314
 		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1182 1315
 		{
1183 1316
 			// do NOT add SMTP only accounts as identities
1184
-			if (!$account->is_imap(false)) continue;
1317
+			if (!$account->is_imap(false))
1318
+			{
1319
+				continue;
1320
+			}
1185 1321
 
1186 1322
 			foreach($account->identities($acc_id) as $ident_id => $identity)
1187 1323
 			{
@@ -1194,16 +1330,24 @@  discard block
 block discarded – undo
1194 1330
 		//$content['bcc'] = array('[email protected]','[email protected]');
1195 1331
 		// address stuff like from, to, cc, replyto
1196 1332
 		$destinationRows = 0;
1197
-		foreach(self::$destinations as $destination) {
1333
+		foreach(self::$destinations as $destination)
1334
+		{
1198 1335
 			if (!is_array($content[$destination]))
1199 1336
 			{
1200
-				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
1337
+				if (!empty($content[$destination]))
1338
+				{
1339
+					$content[$destination] = (array)$content[$destination];
1340
+				}
1201 1341
 			}
1202 1342
 			$addr_content = $content[strtolower($destination)];
1203 1343
 			// we clear the given address array and rebuild it
1204 1344
 			unset($content[strtolower($destination)]);
1205
-			foreach((array)$addr_content as $key => $value) {
1206
-				if ($value=="NIL@NIL") continue;
1345
+			foreach((array)$addr_content as $key => $value)
1346
+			{
1347
+				if ($value=="NIL@NIL")
1348
+				{
1349
+					continue;
1350
+				}
1207 1351
 				if ($destination=='replyto' && str_replace('"','',$value) ==
1208 1352
 					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1209 1353
 				{
@@ -1213,8 +1357,12 @@  discard block
 block discarded – undo
1213 1357
 				}
1214 1358
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1215 1359
 				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1216
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1217
-					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1360
+				foreach(Mail::parseAddressList($value) as $addressObject)
1361
+				{
1362
+					if ($addressObject->host == '.SYNTAX-ERROR.')
1363
+					{
1364
+						continue;
1365
+					}
1218 1366
 					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1219 1367
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1220 1368
 					$content[strtolower($destination)][]=$address;
@@ -1225,11 +1373,20 @@  discard block
 block discarded – undo
1225 1373
 		if ($_content)
1226 1374
 		{
1227 1375
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1228
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1376
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content))
1377
+			{
1378
+				unset($_content['mailidentity']);
1379
+			}
1229 1380
 			$content = array_merge($content,$_content);
1230 1381
 
1231
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1232
-			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1382
+			if (!empty($content['folder']))
1383
+			{
1384
+				$sel_options['folder']=$this->ajax_searchFolder(0,true);
1385
+			}
1386
+			if (empty($content['mailaccount']))
1387
+			{
1388
+				$content['mailaccount'] = $this->mail_bo->profileID;
1389
+			}
1233 1390
 		}
1234 1391
 		else
1235 1392
 		{
@@ -1272,11 +1429,17 @@  discard block
 block discarded – undo
1272 1429
 		//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
1273 1430
 		$preserv['is_html'] = $content['is_html'];
1274 1431
 		$preserv['is_plain'] = $content['is_plain'];
1275
-		if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
1432
+		if (isset($content['mimeType']))
1433
+		{
1434
+			$preserv['mimeType'] = $content['mimeType'];
1435
+		}
1276 1436
 		$sel_options['mimeType'] = self::$mimeTypes;
1277 1437
 		$sel_options['priority'] = self::$priorities;
1278 1438
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1279
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1439
+		if (!isset($content['priority']) || empty($content['priority']))
1440
+		{
1441
+			$content['priority']=3;
1442
+		}
1280 1443
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1281 1444
 		$etpl = new Etemplate('mail.compose');
1282 1445
 
@@ -1323,9 +1486,12 @@  discard block
 block discarded – undo
1323 1486
 		$preserv['list-id'] = $content['list-id'];
1324 1487
 		$preserv['mode'] = $content['mode'];
1325 1488
 		// convert it back to checkbox expectations
1326
-		if($content['mimeType'] == 'html') {
1489
+		if($content['mimeType'] == 'html')
1490
+		{
1327 1491
 			$content['mimeType']=1;
1328
-		} else {
1492
+		}
1493
+		else
1494
+		{
1329 1495
 			$content['mimeType']=0;
1330 1496
 		}
1331 1497
 		// set the current selected mailaccount as param for folderselection
@@ -1336,7 +1502,10 @@  discard block
 block discarded – undo
1336 1502
 		// Resolve distribution list before send content to client
1337 1503
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1338 1504
 		{
1339
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1505
+			if (is_array($content[$f]))
1506
+			{
1507
+				$content[$f]= self::resolveEmailAddressList ($content[$f]);
1508
+			}
1340 1509
 		}
1341 1510
 
1342 1511
 		$content['to'] = self::resolveEmailAddressList($content['to']);
@@ -1384,7 +1553,10 @@  discard block
 block discarded – undo
1384 1553
 				case 'composefromdraft':
1385 1554
 				case 'composeasnew':
1386 1555
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1387
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1556
+					if ($from =='composefromdraft')
1557
+					{
1558
+						$content['mode'] = 'composefromdraft';
1559
+					}
1388 1560
 					$content['processedmail_id'] = $mail_id;
1389 1561
 
1390 1562
 					$_focusElement = 'body';
@@ -1432,7 +1604,10 @@  discard block
 block discarded – undo
1432 1604
 			$document_merge = new $merge_class();
1433 1605
 			$this->mail_bo->openConnection();
1434 1606
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1435
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1607
+			if (!is_array($merge_ids))
1608
+			{
1609
+				$merge_ids = explode(',',$merge_ids);
1610
+			}
1436 1611
 			try
1437 1612
 			{
1438 1613
 				$merged_mail_id = '';
@@ -1463,7 +1638,10 @@  discard block
 block discarded – undo
1463 1638
 				{
1464 1639
 					$success = implode(', ',$results['success']);
1465 1640
 					$fail = implode(', ', $results['failed']);
1466
-					if($success) Framework::message($success, 'success');
1641
+					if($success)
1642
+					{
1643
+						Framework::message($success, 'success');
1644
+					}
1467 1645
 					Framework::window_close($fail);
1468 1646
 				}
1469 1647
 			}
@@ -1495,17 +1673,25 @@  discard block
 block discarded – undo
1495 1673
 	{
1496 1674
 		$stripalltags = true;
1497 1675
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1498
-		if (!$sourceishtml) $stripalltags=false;
1676
+		if (!$sourceishtml)
1677
+		{
1678
+			$stripalltags=false;
1679
+		}
1499 1680
 		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1500 1681
 	}
1501 1682
 
1502 1683
 	function generateRFC822Address($_addressObject)
1503 1684
 	{
1504
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1685
+		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host)
1686
+		{
1505 1687
 			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1506
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1688
+		}
1689
+		elseif($_addressObject->mailbox && $_addressObject->host)
1690
+		{
1507 1691
 			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1508
-		} else {
1692
+		}
1693
+		else
1694
+		{
1509 1695
 			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1510 1696
 		}
1511 1697
 	}
@@ -1539,16 +1725,28 @@  discard block
 block discarded – undo
1539 1725
 		//if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC'];
1540 1726
 
1541 1727
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1542
-		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1543
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1728
+		if (!empty($addHeadInfo['X-MAILFOLDER']))
1729
+		{
1730
+			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val )
1731
+			{
1544 1732
 				$fval=$val;
1545 1733
 				$icServerID = $mail_bo->icServer->ImapServerId;
1546
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1547
-				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1548
-				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1734
+				if (stripos($val,'::')!==false)
1735
+				{
1736
+					list($icServerID,$fval) = explode('::',$val,2);
1737
+				}
1738
+				if ($icServerID != $mail_bo->icServer->ImapServerId)
1739
+				{
1740
+					continue;
1741
+				}
1742
+				if ($mail_bo->folderExists($fval))
1743
+				{
1744
+					$this->sessionData['folder'][] = $val;
1745
+				}
1549 1746
 			}
1550 1747
 		}
1551
-		if (!empty($addHeadInfo['X-MAILIDENTITY'])) {
1748
+		if (!empty($addHeadInfo['X-MAILIDENTITY']))
1749
+		{
1552 1750
 			// with the new system it would be the identity
1553 1751
 			try
1554 1752
 			{
@@ -1564,7 +1762,8 @@  discard block
 block discarded – undo
1564 1762
 			$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
1565 1763
 		}
1566 1764
 		*/
1567
-		if (!empty($addHeadInfo['X-MAILACCOUNT'])) {
1765
+		if (!empty($addHeadInfo['X-MAILACCOUNT']))
1766
+		{
1568 1767
 			// with the new system it would the identity is the account id
1569 1768
 			try
1570 1769
 			{
@@ -1579,27 +1778,38 @@  discard block
 block discarded – undo
1579 1778
 			}
1580 1779
 		}
1581 1780
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1582
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1781
+		if ($mail_bo->isDraftFolder($_folder))
1782
+		{
1783
+			$this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);
1784
+		}
1785
+		//array('uid'=>$_uid,'folder'=>$_folder);
1583 1786
 		$this->sessionData['uid'] = $_uid;
1584 1787
 		$this->sessionData['messageFolder'] = $_folder;
1585 1788
 		$this->sessionData['isDraft'] = true;
1586 1789
 		$foundAddresses = array();
1587
-		foreach((array)$headers['CC'] as $val) {
1790
+		foreach((array)$headers['CC'] as $val)
1791
+		{
1588 1792
 			$rfcAddr=Mail::parseAddressList($val);
1589 1793
 			$_rfcAddr = $rfcAddr[0];
1590
-			if (!$_rfcAddr->valid) continue;
1591
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1794
+			if (!$_rfcAddr->valid)
1795
+			{
1796
+				continue;
1797
+			}
1798
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1799
+			{
1592 1800
 				continue;
1593 1801
 			}
1594 1802
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1595
-			if(!$foundAddresses[$keyemail]) {
1803
+			if(!$foundAddresses[$keyemail])
1804
+			{
1596 1805
 				$address = $this->mail_bo->decode_header($val,true);
1597 1806
 				$this->sessionData['cc'][] = $val;
1598 1807
 				$foundAddresses[$keyemail] = true;
1599 1808
 			}
1600 1809
 		}
1601 1810
 
1602
-		foreach((array)$headers['TO'] as $val) {
1811
+		foreach((array)$headers['TO'] as $val)
1812
+		{
1603 1813
 			if(!is_array($val))
1604 1814
 			{
1605 1815
 				$this->sessionData['to'][] = $val;
@@ -1607,42 +1817,59 @@  discard block
 block discarded – undo
1607 1817
 			}
1608 1818
 			$rfcAddr=Mail::parseAddressList($val);
1609 1819
 			$_rfcAddr = $rfcAddr[0];
1610
-			if (!$_rfcAddr->valid) continue;
1611
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1820
+			if (!$_rfcAddr->valid)
1821
+			{
1822
+				continue;
1823
+			}
1824
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1825
+			{
1612 1826
 				continue;
1613 1827
 			}
1614 1828
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1615
-			if(!$foundAddresses[$keyemail]) {
1829
+			if(!$foundAddresses[$keyemail])
1830
+			{
1616 1831
 				$address = $this->mail_bo->decode_header($val,true);
1617 1832
 				$this->sessionData['to'][] = $val;
1618 1833
 				$foundAddresses[$keyemail] = true;
1619 1834
 			}
1620 1835
 		}
1621 1836
 
1622
-		foreach((array)$headers['REPLY-TO'] as $val) {
1837
+		foreach((array)$headers['REPLY-TO'] as $val)
1838
+		{
1623 1839
 			$rfcAddr=Mail::parseAddressList($val);
1624 1840
 			$_rfcAddr = $rfcAddr[0];
1625
-			if (!$_rfcAddr->valid) continue;
1626
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1841
+			if (!$_rfcAddr->valid)
1842
+			{
1843
+				continue;
1844
+			}
1845
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1846
+			{
1627 1847
 				continue;
1628 1848
 			}
1629 1849
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1630
-			if(!$foundAddresses[$keyemail]) {
1850
+			if(!$foundAddresses[$keyemail])
1851
+			{
1631 1852
 				$address = $this->mail_bo->decode_header($val,true);
1632 1853
 				$this->sessionData['replyto'][] = $val;
1633 1854
 				$foundAddresses[$keyemail] = true;
1634 1855
 			}
1635 1856
 		}
1636 1857
 
1637
-		foreach((array)$headers['BCC'] as $val) {
1858
+		foreach((array)$headers['BCC'] as $val)
1859
+		{
1638 1860
 			$rfcAddr=Mail::parseAddressList($val);
1639 1861
 			$_rfcAddr = $rfcAddr[0];
1640
-			if (!$_rfcAddr->valid) continue;
1641
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1862
+			if (!$_rfcAddr->valid)
1863
+			{
1864
+				continue;
1865
+			}
1866
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1867
+			{
1642 1868
 				continue;
1643 1869
 			}
1644 1870
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1645
-			if(!$foundAddresses[$keyemail]) {
1871
+			if(!$foundAddresses[$keyemail])
1872
+			{
1646 1873
 				$address = $this->mail_bo->decode_header($val,true);
1647 1874
 				$this->sessionData['bcc'][] = $val;
1648 1875
 				$foundAddresses[$keyemail] = true;
@@ -1656,32 +1883,46 @@  discard block
 block discarded – undo
1656 1883
 		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1657 1884
 		//_debug_array($bodyParts);
1658 1885
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1659
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1886
+		if($bodyParts['0']['mimeType'] == 'text/html')
1887
+		{
1660 1888
 			$this->sessionData['mimeType'] 	= 'html';
1661 1889
 
1662
-			for($i=0; $i<count($bodyParts); $i++) {
1663
-				if($i>0) {
1890
+			for($i=0; $i<count($bodyParts); $i++)
1891
+			{
1892
+				if($i>0)
1893
+				{
1664 1894
 					$this->sessionData['body'] .= '<hr>';
1665 1895
 				}
1666
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1896
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
1897
+				{
1667 1898
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1668 1899
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1669 1900
 				}
1670
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1901
+				if ($bodyParts[$i]['charSet']===false)
1902
+				{
1903
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1904
+				}
1671 1905
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1672 1906
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1673 1907
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1674 1908
 			}
1675 1909
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1676 1910
 
1677
-		} else {
1911
+		}
1912
+		else
1913
+		{
1678 1914
 			$this->sessionData['mimeType']	= 'plain';
1679 1915
 
1680
-			for($i=0; $i<count($bodyParts); $i++) {
1681
-				if($i>0) {
1916
+			for($i=0; $i<count($bodyParts); $i++)
1917
+			{
1918
+				if($i>0)
1919
+				{
1682 1920
 					$this->sessionData['body'] .= "<hr>";
1683 1921
 				}
1684
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1922
+				if ($bodyParts[$i]['charSet']===false)
1923
+				{
1924
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1925
+				}
1685 1926
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1686 1927
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1687 1928
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
@@ -1689,8 +1930,10 @@  discard block
 block discarded – undo
1689 1930
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1690 1931
 		}
1691 1932
 
1692
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1693
-			foreach($attachments as $attachment) {
1933
+		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1934
+		{
1935
+			foreach($attachments as $attachment)
1936
+			{
1694 1937
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1695 1938
 				$cid = $attachment['cid'];
1696 1939
 				$match=null;
@@ -1713,7 +1956,8 @@  discard block
 block discarded – undo
1713 1956
 
1714 1957
 	function getErrorInfo()
1715 1958
 	{
1716
-		if(isset($this->errorInfo)) {
1959
+		if(isset($this->errorInfo))
1960
+		{
1717 1961
 			$errorInfo = $this->errorInfo;
1718 1962
 			unset($this->errorInfo);
1719 1963
 			return $errorInfo;
@@ -1728,7 +1972,8 @@  discard block
 block discarded – undo
1728 1972
 			$modebuff = $this->mailPreferences['message_forwarding'];
1729 1973
 			$this->mailPreferences['message_forwarding'] = $_mode;
1730 1974
 		}
1731
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1975
+		if  ($this->mailPreferences['message_forwarding'] == 'inline')
1976
+		{
1732 1977
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1733 1978
 		}
1734 1979
 		$mail_bo    = $this->mail_bo;
@@ -1745,12 +1990,16 @@  discard block
 block discarded – undo
1745 1990
 		//$this->sessionData['sourceFolder']=$_folder;
1746 1991
 		//$this->sessionData['forwardFlag']='forwarded';
1747 1992
 		//$this->sessionData['forwardedUID']=$_uid;
1748
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1993
+		if  ($this->mailPreferences['message_forwarding'] == 'asmail')
1994
+		{
1749 1995
 			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1750 1996
 			if($headers['SIZE'])
1751
-				$size				= $headers['SIZE'];
1752
-			else
1753
-				$size				= lang('unknown');
1997
+			{
1998
+							$size				= $headers['SIZE'];
1999
+			}
2000
+			else {
2001
+							$size				= lang('unknown');
2002
+			}
1754 2003
 
1755 2004
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1756 2005
 				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
@@ -1761,9 +2010,11 @@  discard block
 block discarded – undo
1761 2010
 			unset($this->sessionData['in-reply-to']);
1762 2011
 			unset($this->sessionData['to']);
1763 2012
 			unset($this->sessionData['cc']);
1764
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
2013
+			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false)))
2014
+			{
1765 2015
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1766
-				foreach($attachments as $attachment) {
2016
+				foreach($attachments as $attachment)
2017
+				{
1767 2018
 					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1768 2019
 					{
1769 2020
 						$this->addMessageAttachment($_uid, $attachment['partID'],
@@ -1819,7 +2070,10 @@  discard block
 block discarded – undo
1819 2070
 			{
1820 2071
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1821 2072
 					strtolower($_formData['type'])== strtolower($attach['type']) &&
1822
-					stripos($_formData['file'],'vfs://') !== false) return;
2073
+					stripos($_formData['file'],'vfs://') !== false)
2074
+				{
2075
+					return;
2076
+				}
1823 2077
 			}
1824 2078
 		}
1825 2079
 		if ($attachfailed === false)
@@ -1831,7 +2085,10 @@  discard block
 block discarded – undo
1831 2085
 				'tmp_name'	=> $tmpFileName,
1832 2086
 				'size'	=> $_formData['size']
1833 2087
 			);
1834
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
2088
+			if (!is_array($_content['attachments']))
2089
+			{
2090
+				$_content['attachments']=array();
2091
+			}
1835 2092
 			$_content['attachments'][] = $buffer;
1836 2093
 			unset($buffer);
1837 2094
 		}
@@ -1862,7 +2119,10 @@  discard block
 block discarded – undo
1862 2119
 		{
1863 2120
 			foreach($request->preserv['attachments'] as $attachment)
1864 2121
 			{
1865
-				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2122
+				if ($_GET['tmpname'] === $attachment['tmp_name'])
2123
+				{
2124
+					break;
2125
+				}
1866 2126
 			}
1867 2127
 		}
1868 2128
 		if (!$request || $_GET['tmpname'] !== $attachment['tmp_name'])
@@ -1896,10 +2156,20 @@  discard block
 block discarded – undo
1896 2156
 				$sfxMimeType = $attachment['type'];
1897 2157
 				$buff = explode('.',$attachment['tmp_name']);
1898 2158
 				$suffix = '';
1899
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1900
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2159
+				if (is_array($buff))
2160
+				{
2161
+					$suffix = array_pop($buff);
2162
+				}
2163
+				// take the last extension to check with ext2mime
2164
+				if (!empty($suffix))
2165
+				{
2166
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2167
+				}
1901 2168
 				$attachment['type'] = $sfxMimeType;
1902
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2169
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2170
+				{
2171
+					$attachment['type'] = strtoupper($sfxMimeType);
2172
+				}
1903 2173
 			}
1904 2174
 			//error_log(__METHOD__.print_r($attachment,true));
1905 2175
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -1908,7 +2178,10 @@  discard block
 block discarded – undo
1908 2178
 				$calendar_ical = new calendar_ical();
1909 2179
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1910 2180
 				//error_log(__METHOD__.array2string($eventid));
1911
-				if (!$eventid) $eventid = -1;
2181
+				if (!$eventid)
2182
+				{
2183
+					$eventid = -1;
2184
+				}
1912 2185
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1913 2186
 				//error_log(__METHOD__.$event);
1914 2187
 				if ((int)$event > 0)
@@ -1934,7 +2207,10 @@  discard block
 block discarded – undo
1934 2207
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1935 2208
 					$contact = $addressbook_vcal->find_contact($vcard,false);
1936 2209
 				}
1937
-				if (!$contact) $contact = null;
2210
+				if (!$contact)
2211
+				{
2212
+					$contact = null;
2213
+				}
1938 2214
 				// 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))
1939 2215
 				if ($contact || count($vcard)>2)
1940 2216
 				{
@@ -1965,7 +2241,8 @@  discard block
 block discarded – undo
1965 2241
 	 * @param string haystack
1966 2242
 	 * @return boolean
1967 2243
 	 */
1968
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2244
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack)
2245
+	{
1969 2246
 		foreach (array_keys($arrayToTestAgainst) as $k)
1970 2247
 		{
1971 2248
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
@@ -2022,21 +2299,34 @@  discard block
 block discarded – undo
2022 2299
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
2023 2300
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
2024 2301
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
2025
-		if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2026
-		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2302
+		if ($headers['THREAD-INDEX'])
2303
+		{
2304
+			$this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2305
+		}
2306
+		if ($headers['LIST-ID'])
2307
+		{
2308
+			$this->sessionData['list-id'] = $headers['LIST-ID'];
2309
+		}
2027 2310
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2028 2311
 		// check for Reply-To: header and use if available
2029
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2030
-			foreach($headers['REPLY-TO'] as $val) {
2031
-				if(!$foundAddresses[$val]) {
2312
+		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM']))
2313
+		{
2314
+			foreach($headers['REPLY-TO'] as $val)
2315
+			{
2316
+				if(!$foundAddresses[$val])
2317
+				{
2032 2318
 					$oldTo[] = $val;
2033 2319
 					$foundAddresses[$val] = true;
2034 2320
 				}
2035 2321
 			}
2036 2322
 			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2037
-		} else {
2038
-			foreach($headers['FROM'] as $val) {
2039
-				if(!$foundAddresses[$val]) {
2323
+		}
2324
+		else
2325
+		{
2326
+			foreach($headers['FROM'] as $val)
2327
+			{
2328
+				if(!$foundAddresses[$val])
2329
+				{
2040 2330
 					$oldTo[] = $val;
2041 2331
 					$foundAddresses[$val] = true;
2042 2332
 				}
@@ -2044,18 +2334,23 @@  discard block
 block discarded – undo
2044 2334
 			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2045 2335
 		}
2046 2336
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2047
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2337
+		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) )
2338
+		{
2048 2339
 			$this->sessionData['to'] = $oldTo;
2049 2340
 		}
2050 2341
 
2051
-		if($_mode == 'all') {
2342
+		if($_mode == 'all')
2343
+		{
2052 2344
 			// reply to any address which is cc, but not to my self
2053 2345
 			#if($headers->cc) {
2054
-				foreach($headers['CC'] as $val) {
2055
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2346
+				foreach($headers['CC'] as $val)
2347
+				{
2348
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2349
+					{
2056 2350
 						continue;
2057 2351
 					}
2058
-					if(!$foundAddresses[$val]) {
2352
+					if(!$foundAddresses[$val])
2353
+					{
2059 2354
 						$this->sessionData['cc'][] = $val;
2060 2355
 						$foundAddresses[$val] = true;
2061 2356
 					}
@@ -2064,11 +2359,14 @@  discard block
 block discarded – undo
2064 2359
 
2065 2360
 			// reply to any address which is to, but not to my self
2066 2361
 			#if($headers->to) {
2067
-				foreach($headers['TO'] as $val) {
2068
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2362
+				foreach($headers['TO'] as $val)
2363
+				{
2364
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2365
+					{
2069 2366
 						continue;
2070 2367
 					}
2071
-					if(!$foundAddresses[$val]) {
2368
+					if(!$foundAddresses[$val])
2369
+					{
2072 2370
 						$this->sessionData['to'][] = $val;
2073 2371
 						$foundAddresses[$val] = true;
2074 2372
 					}
@@ -2076,12 +2374,15 @@  discard block
 block discarded – undo
2076 2374
 			#}
2077 2375
 
2078 2376
 			#if($headers->from) {
2079
-				foreach($headers['FROM'] as $val) {
2080
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2377
+				foreach($headers['FROM'] as $val)
2378
+				{
2379
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2380
+					{
2081 2381
 						continue;
2082 2382
 					}
2083 2383
 					//error_log(__METHOD__.__LINE__.' '.$val);
2084
-					if(!$foundAddresses[$val]) {
2384
+					if(!$foundAddresses[$val])
2385
+					{
2085 2386
 						$this->sessionData['to'][] = $val;
2086 2387
 						$foundAddresses[$val] = true;
2087 2388
 					}
@@ -2090,9 +2391,12 @@  discard block
 block discarded – undo
2090 2391
 		}
2091 2392
 
2092 2393
 		// check for Re: in subject header
2093
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2394
+		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:")
2395
+		{
2094 2396
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2095
-		} else {
2397
+		}
2398
+		else
2399
+		{
2096 2400
 			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2097 2401
 		}
2098 2402
 
@@ -2106,7 +2410,8 @@  discard block
 block discarded – undo
2106 2410
 
2107 2411
 		$toAddressA = array();
2108 2412
 		$toAddress = '';
2109
-		foreach ($headers['TO'] as $mailheader) {
2413
+		foreach ($headers['TO'] as $mailheader)
2414
+		{
2110 2415
 			$toAddressA[] =  $mailheader;
2111 2416
 		}
2112 2417
 		if (count($toAddressA)>0)
@@ -2116,7 +2421,8 @@  discard block
 block discarded – undo
2116 2421
 		}
2117 2422
 		$ccAddressA = array();
2118 2423
 		$ccAddress = '';
2119
-		foreach ($headers['CC'] as $mailheader) {
2424
+		foreach ($headers['CC'] as $mailheader)
2425
+		{
2120 2426
 			$ccAddressA[] =  $mailheader;
2121 2427
 		}
2122 2428
 		if (count($ccAddressA)>0)
@@ -2124,25 +2430,35 @@  discard block
 block discarded – undo
2124 2430
 			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2125 2431
 			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2126 2432
 		}
2127
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2433
+		if($bodyParts['0']['mimeType'] == 'text/html')
2434
+		{
2128 2435
 			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2129 2436
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2130 2437
 				$toAddress.$ccAddress.
2131 2438
 				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2132 2439
 				'----------------------------------------------------------'."</div>";
2133 2440
 			$this->sessionData['mimeType'] 	= 'html';
2134
-			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2441
+			if (!empty($styles))
2442
+			{
2443
+				$this->sessionData['body'] .= $styles;
2444
+			}
2135 2445
 			$this->sessionData['body']	.= '<blockquote type="cite">';
2136 2446
 
2137
-			for($i=0; $i<count($bodyParts); $i++) {
2138
-				if($i>0) {
2447
+			for($i=0; $i<count($bodyParts); $i++)
2448
+			{
2449
+				if($i>0)
2450
+				{
2139 2451
 					$this->sessionData['body'] .= '<hr>';
2140 2452
 				}
2141
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2453
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2454
+				{
2142 2455
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2143 2456
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2144 2457
 				}
2145
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2458
+				if ($bodyParts[$i]['charSet']===false)
2459
+				{
2460
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2461
+				}
2146 2462
 
2147 2463
 				$_htmlConfig = Mail::$htmLawed_config;
2148 2464
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2154,7 +2470,9 @@  discard block
 block discarded – undo
2154 2470
 
2155 2471
 			$this->sessionData['body']	.= '</blockquote><br>';
2156 2472
 			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2157
-		} else {
2473
+		}
2474
+		else
2475
+		{
2158 2476
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2159 2477
 			// 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)
2160 2478
             $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
@@ -2164,8 +2482,10 @@  discard block
 block discarded – undo
2164 2482
                 '-------------------------------------------------'."\r\n \r\n ";
2165 2483
 			$this->sessionData['mimeType']	= 'plain';
2166 2484
 
2167
-			for($i=0; $i<count($bodyParts); $i++) {
2168
-				if($i>0) {
2485
+			for($i=0; $i<count($bodyParts); $i++)
2486
+			{
2487
+				if($i>0)
2488
+				{
2169 2489
 					$this->sessionData['body'] .= "<hr>";
2170 2490
 				}
2171 2491
 
@@ -2175,9 +2495,11 @@  discard block
 block discarded – undo
2175 2495
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2176 2496
 				$this->sessionData['body'] .= "\r\n";
2177 2497
 				// create body new, with good line breaks and indention
2178
-				foreach(explode("\n",$newBody) as $value) {
2498
+				foreach(explode("\n",$newBody) as $value)
2499
+				{
2179 2500
 					// the explode is removing the character
2180
-					if (trim($value) != '') {
2501
+					if (trim($value) != '')
2502
+					{
2181 2503
 						#if ($value != "\r") $value .= "\n";
2182 2504
 					}
2183 2505
 					$numberOfChars = strspn(trim($value), ">");
@@ -2185,9 +2507,12 @@  discard block
 block discarded – undo
2185 2507
 
2186 2508
 					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2187 2509
 
2188
-					if($bodyAppend[0] == '>') {
2510
+					if($bodyAppend[0] == '>')
2511
+					{
2189 2512
 						$bodyAppend = '>'. $bodyAppend;
2190
-					} else {
2513
+					}
2514
+					else
2515
+					{
2191 2516
 						$bodyAppend = '> '. $bodyAppend;
2192 2517
 					}
2193 2518
 
@@ -2236,9 +2561,12 @@  discard block
 block discarded – undo
2236 2561
 
2237 2562
 	static function _getHostName()
2238 2563
 	{
2239
-		if (isset($_SERVER['SERVER_NAME'])) {
2564
+		if (isset($_SERVER['SERVER_NAME']))
2565
+		{
2240 2566
 			$result = $_SERVER['SERVER_NAME'];
2241
-		} else {
2567
+		}
2568
+		else
2569
+		{
2242 2570
 			$result = 'localhost.localdomain';
2243 2571
 		}
2244 2572
 		return $result;
@@ -2276,11 +2604,16 @@  discard block
 block discarded – undo
2276 2604
 
2277 2605
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2278 2606
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2279
-		if(!empty($_formData['in-reply-to'])) {
2280
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2607
+		if(!empty($_formData['in-reply-to']))
2608
+		{
2609
+			if (stripos($_formData['in-reply-to'],'<')===false)
2610
+			{
2611
+				$_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2612
+			}
2281 2613
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2282 2614
 		}
2283
-		if(!empty($_formData['references'])) {
2615
+		if(!empty($_formData['references']))
2616
+		{
2284 2617
 			if (stripos($_formData['references'],'<')===false)
2285 2618
 			{
2286 2619
 				$_formData['references']='<'.trim($_formData['references']).'>';
@@ -2288,28 +2621,38 @@  discard block
 block discarded – undo
2288 2621
 			$_mailObject->addHeader('References', $_formData['references']);
2289 2622
 		}
2290 2623
 
2291
-		if(!empty($_formData['thread-index'])) {
2624
+		if(!empty($_formData['thread-index']))
2625
+		{
2292 2626
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2293 2627
 		}
2294
-		if(!empty($_formData['list-id'])) {
2628
+		if(!empty($_formData['list-id']))
2629
+		{
2295 2630
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2296 2631
 		}
2297
-		if($_formData['disposition']=='on') {
2632
+		if($_formData['disposition']=='on')
2633
+		{
2298 2634
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2299 2635
 		}
2300 2636
 
2301 2637
 		// Expand any mailing lists
2302 2638
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2303 2639
 		{
2304
-			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2640
+			if ($field != 'replyto')
2641
+			{
2642
+				$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2643
+			}
2305 2644
 
2306
-			if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field);
2645
+			if ($_formData[$field])
2646
+			{
2647
+				$_mailObject->addAddress($_formData[$field], '', $field);
2648
+			}
2307 2649
 		}
2308 2650
 
2309 2651
 		$_mailObject->addHeader('Subject', $_formData['subject']);
2310 2652
 
2311 2653
 		// this should never happen since we come from the edit dialog
2312
-		if (Mail::detect_qp($_formData['body'])) {
2654
+		if (Mail::detect_qp($_formData['body']))
2655
+		{
2313 2656
 			$_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']);
2314 2657
 			$_formData['body'] = quoted_printable_decode($_formData['body']);
2315 2658
 		}
@@ -2362,7 +2705,10 @@  discard block
 block discarded – undo
2362 2705
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true));
2363 2706
 			}
2364 2707
 			// convert URL Images to inline images - if possible
2365
-			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2708
+			if (!$_autosaving)
2709
+			{
2710
+				$inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2711
+			}
2366 2712
 			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2367 2713
 			{
2368 2714
 				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@@ -2377,10 +2723,14 @@  discard block
 block discarded – undo
2377 2723
 		{
2378 2724
 			$body = $this->convertHTMLToText($_formData['body'],false);
2379 2725
 
2380
-			if ($attachment_links) $body .= $attachment_links;
2726
+			if ($attachment_links)
2727
+			{
2728
+				$body .= $attachment_links;
2729
+			}
2381 2730
 
2382 2731
 			#$_mailObject->Body = $_formData['body'];
2383
-			if(!empty($signature)) {
2732
+			if(!empty($signature))
2733
+			{
2384 2734
 				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2385 2735
 					$this->convertHTMLToText($signature,true,true);
2386 2736
 			}
@@ -2391,10 +2741,12 @@  discard block
 block discarded – undo
2391 2741
 		{
2392 2742
 			$connection_opened = false;
2393 2743
 			$tnfattachments = null;
2394
-			foreach((array)$_formData['attachments'] as $attachment) {
2744
+			foreach((array)$_formData['attachments'] as $attachment)
2745
+			{
2395 2746
 				if(is_array($attachment))
2396 2747
 				{
2397
-					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2748
+					if (!empty($attachment['uid']) && !empty($attachment['folder']))
2749
+					{
2398 2750
 						/* Example:
2399 2751
 						Array([0] => Array(
2400 2752
 						[uid] => 21178
@@ -2410,14 +2762,18 @@  discard block
 block discarded – undo
2410 2762
 							$connection_opened = true;
2411 2763
 						}
2412 2764
 						$mail_bo->reopen($attachment['folder']);
2413
-						switch(strtoupper($attachment['type'])) {
2765
+						switch(strtoupper($attachment['type']))
2766
+						{
2414 2767
 							case 'MESSAGE/RFC':
2415 2768
 							case 'MESSAGE/RFC822':
2416 2769
 								$rawBody='';
2417
-								if (isset($attachment['partID'])) {
2770
+								if (isset($attachment['partID']))
2771
+								{
2418 2772
 									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2419 2773
 									$rawBody=$eml['attachment'];
2420
-								} else {
2774
+								}
2775
+								else
2776
+								{
2421 2777
 									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2422 2778
 								}
2423 2779
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
@@ -2426,7 +2782,10 @@  discard block
 block discarded – undo
2426 2782
 								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2427 2783
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2428 2784
 								{
2429
-									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2785
+									if (!is_array($tnfattachments))
2786
+									{
2787
+										$tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2788
+									}
2430 2789
 									foreach ($tnfattachments as $k)
2431 2790
 									{
2432 2791
 										if ($k['name'] == $attachment['name'])
@@ -2461,7 +2820,10 @@  discard block
 block discarded – undo
2461 2820
 					}
2462 2821
 				}
2463 2822
 			}
2464
-			if ($connection_opened) $mail_bo->closeConnection();
2823
+			if ($connection_opened)
2824
+			{
2825
+				$mail_bo->closeConnection();
2826
+			}
2465 2827
 		}
2466 2828
 		return is_array($inline_images)?$inline_images:array();
2467 2829
 	}
@@ -2481,13 +2843,20 @@  discard block
 block discarded – undo
2481 2843
 	 */
2482 2844
 	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2483 2845
 	{
2484
-		if ($filemode == Vfs\Sharing::ATTACH) return '';
2846
+		if ($filemode == Vfs\Sharing::ATTACH)
2847
+		{
2848
+			return '';
2849
+		}
2485 2850
 
2486 2851
 		$links = array();
2487 2852
 		foreach($attachments as $attachment)
2488 2853
 		{
2489 2854
 			$path = $attachment['file'];
2490
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2855
+			if (empty($path))
2856
+			{
2857
+				continue;
2858
+			}
2859
+			// we only care about file attachments, not forwarded messages or parts
2491 2860
 			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2492 2861
 			{
2493 2862
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
@@ -2590,13 +2959,19 @@  discard block
 block discarded – undo
2590 2959
 								$success = false;
2591 2960
 								error_log(__METHOD__.__LINE__.$msg);
2592 2961
 							}
2593
-						} else {
2962
+						}
2963
+						else
2964
+						{
2594 2965
 							error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former');
2595 2966
 						}
2596
-					} else {
2967
+					}
2968
+					else
2969
+					{
2597 2970
 						error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)");
2598 2971
 					}
2599
-				} else {
2972
+				}
2973
+				else
2974
+				{
2600 2975
 					error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)");
2601 2976
 				}
2602 2977
 			}
@@ -2612,7 +2987,10 @@  discard block
 block discarded – undo
2612 2987
 			$success = false;
2613 2988
 		}
2614 2989
 
2615
-		if ($success) $msg = lang('Message saved successfully.');
2990
+		if ($success)
2991
+		{
2992
+			$msg = lang('Message saved successfully.');
2993
+		}
2616 2994
 
2617 2995
 		// Include new information to json respose, because we need them in client-side callback
2618 2996
 		$response->data(array(
@@ -2636,7 +3014,10 @@  discard block
 block discarded – undo
2636 3014
 		{
2637 3015
 			if(is_int($address))
2638 3016
 			{
2639
-				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
3017
+				if (!isset($contacts_obs))
3018
+				{
3019
+					$contacts_obj = new Api\Contacts();
3020
+				}
2640 3021
 				// List was selected, expand to addresses
2641 3022
 				unset($_emailAddressList[$ak]);
2642 3023
 				$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));
@@ -2651,7 +3032,10 @@  discard block
 block discarded – undo
2651 3032
 		{
2652 3033
 			foreach ($addrFromList as $addr)
2653 3034
 			{
2654
-				if (!empty($addr)) $_emailAddressList[]=$addr;
3035
+				if (!empty($addr))
3036
+				{
3037
+					$_emailAddressList[]=$addr;
3038
+				}
2655 3039
 			}
2656 3040
 		}
2657 3041
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2705,7 +3089,10 @@  discard block
 block discarded – undo
2705 3089
 		// decide where to save the message (default to draft folder, if we find nothing else)
2706 3090
 		// if the current folder is in draft or template folder save it there
2707 3091
 		// if it is called from printview then save it with the draft folder
2708
-		if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder();
3092
+		if (empty($savingDestination))
3093
+		{
3094
+			$savingDestination = $mail_bo->getDraftFolder();
3095
+		}
2709 3096
 		if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox']))
2710 3097
 		{
2711 3098
 			$this->sessionData['messageFolder'] = $this->sessionData['mailbox'];
@@ -2716,13 +3103,17 @@  discard block
 block discarded – undo
2716 3103
 			$savingDestination = $this->sessionData['messageFolder'];
2717 3104
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2718 3105
 		}
2719
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
3106
+		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 )
3107
+		{
3108
+			$savingDestination = $mail_bo->getDraftFolder();
3109
+		}
2720 3110
 
2721 3111
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2722 3112
 		$mail->forceBccHeader();
2723 3113
 
2724 3114
 		$mail_bo->openConnection();
2725
-		if ($mail_bo->folderExists($savingDestination,true)) {
3115
+		if ($mail_bo->folderExists($savingDestination,true))
3116
+		{
2726 3117
 			try
2727 3118
 			{
2728 3119
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
@@ -2733,7 +3124,9 @@  discard block
 block discarded – undo
2733 3124
 				return false;
2734 3125
 			}
2735 3126
 
2736
-		} else {
3127
+		}
3128
+		else
3129
+		{
2737 3130
 			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2738 3131
 			return false;
2739 3132
 		}
@@ -2781,7 +3174,10 @@  discard block
 block discarded – undo
2781 3174
 					$fhA = mail_ui::splitRowID($rowid);
2782 3175
 					$this->sessionData['uid'][] = $fhA['msgUID'];
2783 3176
 					$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
2784
-					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
3177
+					if (!empty($fhA['folder']))
3178
+					{
3179
+						$this->sessionData['sourceFolder'] = $fhA['folder'];
3180
+					}
2785 3181
 				}
2786 3182
 			}
2787 3183
 			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
@@ -2813,7 +3209,8 @@  discard block
 block discarded – undo
2813 3209
 			#error_log($this->sessionData['body']);
2814 3210
 		}
2815 3211
 		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2816
-		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
3212
+		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder']))
3213
+		{
2817 3214
 		   	$messageIsDraft = true;
2818 3215
 		}
2819 3216
 		try
@@ -2829,7 +3226,11 @@  discard block
 block discarded – undo
2829 3226
 		// create the messages and store inline images
2830 3227
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2831 3228
 		// remember the identity
2832
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
3229
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3230
+		{
3231
+			$fromAddress = $mail->From;
3232
+		}
3233
+		//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2833 3234
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2834 3235
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2835 3236
 		#exit;
@@ -2842,7 +3243,10 @@  discard block
 block discarded – undo
2842 3243
 		{
2843 3244
 			$fval=$f;
2844 3245
 			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2845
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3246
+			if (stripos($f,'::')!==false)
3247
+			{
3248
+				list($icServerID,$fval) = explode('::',$f,2);
3249
+			}
2846 3250
 			if ($_formData['serverID']!=$_formData['mailaccount'])
2847 3251
 			{
2848 3252
 				if ($icServerID == $_formData['serverID'] )
@@ -2883,13 +3287,19 @@  discard block
 block discarded – undo
2883 3287
 			// sentFolder is account specific
2884 3288
 			$sentFolder = $this->mail_bo->getSentFolder();
2885 3289
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2886
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3290
+			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true))
3291
+			{
3292
+				$sentFolder=false;
3293
+			}
2887 3294
 		}
2888 3295
 		else
2889 3296
 		{
2890 3297
 			$sentFolder = $mail_bo->getSentFolder();
2891 3298
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2892
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3299
+			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true))
3300
+			{
3301
+				$sentFolder=false;
3302
+			}
2893 3303
 		}
2894 3304
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2895 3305
 
@@ -2925,19 +3335,30 @@  discard block
 block discarded – undo
2925 3335
 		{
2926 3336
 			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2927 3337
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2928
-				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3338
+				$sentFolder != 'none'))
3339
+			{
3340
+				$this->errorInfo = lang("No Send Folder set in preferences");
3341
+			}
2929 3342
 		}
2930 3343
 		// draftFolder is on Server we start from
2931
-		if($messageIsDraft == true) {
3344
+		if($messageIsDraft == true)
3345
+		{
2932 3346
 			$draftFolder = $mail_bo->getDraftFolder();
2933
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3347
+			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true))
3348
+			{
2934 3349
 				$this->sessionData['folder'] = array($draftFolder);
2935 3350
 				$folderOnServerID[] = $draftFolder;
2936 3351
 				$folder[$draftFolder] = $draftFolder;
2937 3352
 			}
2938 3353
 		}
2939
-		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2940
-		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3354
+		if ($folderOnServerID)
3355
+		{
3356
+			$folderOnServerID = array_unique($folderOnServerID);
3357
+		}
3358
+		if ($folderOnMailAccount)
3359
+		{
3360
+			$folderOnMailAccount = array_unique($folderOnMailAccount);
3361
+		}
2941 3362
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2942 3363
 			!( count($folder) > 0) &&
2943 3364
 			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
@@ -2951,7 +3372,8 @@  discard block
 block discarded – undo
2951 3372
 		@set_time_limit(120);
2952 3373
 		//$mail->SMTPDebug = 10;
2953 3374
 		//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']));
2954
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3375
+		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0)
3376
+		{
2955 3377
 			try {
2956 3378
 				$mail->send();
2957 3379
 			}
@@ -2961,10 +3383,15 @@  discard block
 block discarded – undo
2961 3383
 				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2962 3384
 				return false;
2963 3385
 			}
2964
-		} else {
2965
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3386
+		}
3387
+		else
3388
+		{
3389
+			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder']))
3390
+			{
2966 3391
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2967
-			} else {
3392
+			}
3393
+			else
3394
+			{
2968 3395
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
2969 3396
 				//error_log(__METHOD__.__LINE__.$this->errorInfo);
2970 3397
 				return false;
@@ -2974,14 +3401,16 @@  discard block
 block discarded – undo
2974 3401
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
2975 3402
 		//error_log(__METHOD__.__LINE__.array2string($folder));
2976 3403
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
2977
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3404
+            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3405
+		{
2978 3406
 			$mail_bo = $this->mail_bo;
2979 3407
 			$mail_bo->openConnection();
2980 3408
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
2981 3409
 			#error_log("(re)opened Connection");
2982 3410
 		}
2983 3411
 		// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
2984
-		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
3412
+		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3413
+		{
2985 3414
 			//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
2986 3415
 
2987 3416
 			// normaly Bcc is only added to recipients, but not as header visible to all recipients
@@ -2990,17 +3419,28 @@  discard block
 block discarded – undo
2990 3419
 		// copying mail to folder
2991 3420
 		if (count($folder) > 0)
2992 3421
 		{
2993
-			foreach($folderOnServerID as $folderName) {
2994
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3422
+			foreach($folderOnServerID as $folderName)
3423
+			{
3424
+				if (is_array($folderName))
3425
+				{
3426
+					$folderName = array_shift($folderName);
3427
+				}
3428
+				// should not happen at all
2995 3429
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
2996 3430
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
2997 3431
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
2998
-				if ($mail_bo->folderExists($folderName,true)) {
2999
-					if($mail_bo->isSentFolder($folderName)) {
3432
+				if ($mail_bo->folderExists($folderName,true))
3433
+				{
3434
+					if($mail_bo->isSentFolder($folderName))
3435
+					{
3000 3436
 						$flags = '\\Seen';
3001
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3437
+					}
3438
+					elseif($mail_bo->isDraftFolder($folderName))
3439
+					{
3002 3440
 						$flags = '\\Draft';
3003
-					} else {
3441
+					}
3442
+					else
3443
+					{
3004 3444
 						$flags = '\\Seen';
3005 3445
 					}
3006 3446
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3023,18 +3463,32 @@  discard block
 block discarded – undo
3023 3463
 				}
3024 3464
 			}
3025 3465
 			// if we choose to send from a differing profile
3026
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3027
-			foreach($folderOnMailAccount as $folderName) {
3028
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3466
+			if ($folderOnMailAccount)
3467
+			{
3468
+				$this->changeProfile($_formData['mailaccount']);
3469
+			}
3470
+			foreach($folderOnMailAccount as $folderName)
3471
+			{
3472
+				if (is_array($folderName))
3473
+				{
3474
+					$folderName = array_shift($folderName);
3475
+				}
3476
+				// should not happen at all
3029 3477
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3030 3478
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3031 3479
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3032
-				if ($this->mail_bo->folderExists($folderName,true)) {
3033
-					if($this->mail_bo->isSentFolder($folderName)) {
3480
+				if ($this->mail_bo->folderExists($folderName,true))
3481
+				{
3482
+					if($this->mail_bo->isSentFolder($folderName))
3483
+					{
3034 3484
 						$flags = '\\Seen';
3035
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3485
+					}
3486
+					elseif($this->mail_bo->isDraftFolder($folderName))
3487
+					{
3036 3488
 						$flags = '\\Draft';
3037
-					} else {
3489
+					}
3490
+					else
3491
+					{
3038 3492
 						$flags = '\\Seen';
3039 3493
 					}
3040 3494
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3056,7 +3510,10 @@  discard block
 block discarded – undo
3056 3510
 					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3057 3511
 				}
3058 3512
 			}
3059
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
3513
+			if ($folderOnMailAccount)
3514
+			{
3515
+				$this->changeProfile($_formData['serverID']);
3516
+			}
3060 3517
 
3061 3518
 			//$mail_bo->closeConnection();
3062 3519
 		}
@@ -3068,10 +3525,16 @@  discard block
 block discarded – undo
3068 3525
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3069 3526
 			$lastDrafted['uid'] = $dhA['msgUID'];
3070 3527
 			$lastDrafted['folder'] = $dhA['folder'];
3071
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3528
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid']))
3529
+			{
3530
+				$lastDrafted['uid']=trim($lastDrafted['uid']);
3531
+			}
3072 3532
 			// manually drafted, do not delete
3073 3533
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3074
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3534
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid']))
3535
+			{
3536
+				$lastDrafted=false;
3537
+			}
3075 3538
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3076 3539
 		}
3077 3540
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
@@ -3097,7 +3560,8 @@  discard block
 block discarded – undo
3097 3560
 
3098 3561
 		//error_log("handling draft messages, flagging and such");
3099 3562
 		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3100
-			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3563
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3564
+		{
3101 3565
 			// mark message as answered
3102 3566
 			$mail_bo->openConnection();
3103 3567
 			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
@@ -3119,7 +3583,9 @@  discard block
 block discarded – undo
3119 3583
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
3120 3584
 					unset($e);
3121 3585
 				}
3122
-			} else {
3586
+			}
3587
+			else
3588
+			{
3123 3589
 				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3124 3590
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3125 3591
 				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
@@ -3138,7 +3604,10 @@  discard block
 block discarded – undo
3138 3604
 			}
3139 3605
 			//$mail_bo->closeConnection();
3140 3606
 		}
3141
-		if ($mail_bo) $mail_bo->closeConnection();
3607
+		if ($mail_bo)
3608
+		{
3609
+			$mail_bo->closeConnection();
3610
+		}
3142 3611
 		//error_log("performing Infolog Stuff");
3143 3612
 		//error_log(print_r($this->sessionData['to'],true));
3144 3613
 		//error_log(print_r($this->sessionData['cc'],true));
@@ -3151,9 +3620,18 @@  discard block
 block discarded – undo
3151 3620
 		{
3152 3621
 			$mailaddresses = array();
3153 3622
 		}
3154
-		if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
3155
-		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3156
-		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3623
+		if (is_array($this->sessionData['cc']))
3624
+		{
3625
+			$mailaddresses['cc'] = $this->sessionData['cc'];
3626
+		}
3627
+		if (is_array($this->sessionData['bcc']))
3628
+		{
3629
+			$mailaddresses['bcc'] = $this->sessionData['bcc'];
3630
+		}
3631
+		if (!empty($mailaddresses))
3632
+		{
3633
+			$mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3634
+		}
3157 3635
 
3158 3636
 		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3159 3637
 		{
@@ -3185,7 +3663,10 @@  discard block
 block discarded – undo
3185 3663
 							$_formData['serverID']),true),
3186 3664
 						'app' => $app_name
3187 3665
 					);
3188
-					if ($entryid) $target['entry_id'] = $entryid;
3666
+					if ($entryid)
3667
+					{
3668
+						$target['entry_id'] = $entryid;
3669
+					}
3189 3670
 					// Open the app called for integration in a popup
3190 3671
 					// and store the mail raw data as egw_data, in order to
3191 3672
 					// be stored from registered app method later
@@ -3196,8 +3677,11 @@  discard block
 block discarded – undo
3196 3677
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3197 3678
 		elseif(is_array($this->sessionData['attachments']))
3198 3679
 		{
3199
-			foreach($this->sessionData['attachments'] as $value) {
3200
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3680
+			foreach($this->sessionData['attachments'] as $value)
3681
+			{
3682
+				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs')
3683
+				{
3684
+// happens when forwarding mails
3201 3685
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3202 3686
 				}
3203 3687
 			}
@@ -3234,7 +3718,10 @@  discard block
 block discarded – undo
3234 3718
 				$default_identity = null;
3235 3719
 				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3236 3720
 				{
3237
-					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3721
+					if (!isset($default_identity))
3722
+					{
3723
+						$default_identity = $identity['ident_id'];
3724
+					}
3238 3725
 					if (!empty($identity['ident_signature']))
3239 3726
 					{
3240 3727
 						$content['mailidentity'] = $identity['ident_id'];
@@ -3242,12 +3729,18 @@  discard block
 block discarded – undo
3242 3729
 					}
3243 3730
 				}
3244 3731
 			}
3245
-			if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity;
3732
+			if (empty($content['mailidentity']))
3733
+			{
3734
+				$content['mailidentity'] = $default_identity;
3735
+			}
3246 3736
 		}
3247 3737
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3248 3738
 		{
3249 3739
 			$content['mimeType'] = 'html';
3250
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3740
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text")
3741
+			{
3742
+				$content['mimeType']  = 'plain';
3743
+			}
3251 3744
 		}
3252 3745
 		return $content;
3253 3746
 
@@ -3255,9 +3748,12 @@  discard block
 block discarded – undo
3255 3748
 
3256 3749
 	function stripSlashes($_string)
3257 3750
 	{
3258
-		if (get_magic_quotes_gpc()) {
3751
+		if (get_magic_quotes_gpc())
3752
+		{
3259 3753
 			return stripslashes($_string);
3260
-		} else {
3754
+		}
3755
+		else
3756
+		{
3261 3757
 			return $_string;
3262 3758
 		}
3263 3759
 	}
@@ -3270,15 +3766,25 @@  discard block
 block discarded – undo
3270 3766
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3271 3767
 	 * @return type
3272 3768
 	 */
3273
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3769
+	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
3770
+	{
3274 3771
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3275 3772
 		static $useCacheIfPossible = null;
3276
-		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
3773
+		if (is_null($useCacheIfPossible))
3774
+		{
3775
+			$useCacheIfPossible = true;
3776
+		}
3277 3777
 		$_searchString = trim($_REQUEST['query']);
3278 3778
 		$results = array();
3279 3779
 		$rememberServerID = $this->mail_bo->icServer->ImapServerId;
3280
-		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount'];
3281
-		if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3780
+		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount']))
3781
+		{
3782
+			$_mailaccountToSearch = $_REQUEST['mailaccount'];
3783
+		}
3784
+		if (empty($_mailaccountToSearch))
3785
+		{
3786
+			$_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3787
+		}
3282 3788
 		if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch)
3283 3789
 		{
3284 3790
 			$this->changeProfile($_mailaccountToSearch);
@@ -3289,7 +3795,8 @@  discard block
 block discarded – undo
3289 3795
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3290 3796
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3291 3797
 			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3292
-			if (count($folderObjects)<=1) {
3798
+			if (count($folderObjects)<=1)
3799
+			{
3293 3800
 				$useCacheIfPossible = false;
3294 3801
 			}
3295 3802
 			else
@@ -3340,7 +3847,8 @@  discard block
 block discarded – undo
3340 3847
 		exit();
3341 3848
 	}
3342 3849
 
3343
-	public static function ajax_searchAddress($_searchStringLength=2) {
3850
+	public static function ajax_searchAddress($_searchStringLength=2)
3851
+	{
3344 3852
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3345 3853
 		$_searchString = trim($_REQUEST['query']);
3346 3854
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3353,7 +3861,8 @@  discard block
 block discarded – undo
3353 3861
 		{
3354 3862
 			$lists = array_filter(
3355 3863
 				$contacts_obj->get_lists(Acl::READ),
3356
-				function($element) use($_searchString) {
3864
+				function($element) use($_searchString)
3865
+				{
3357 3866
 					return (stripos($element, $_searchString) !== false);
3358 3867
 				}
3359 3868
 			);
@@ -3368,7 +3877,10 @@  discard block
 block discarded – undo
3368 3877
 					'title' => lang('Mailinglist'),
3369 3878
 					'data'	=> $key
3370 3879
 				);
3371
-				if($list_count++ > 5) break;
3880
+				if($list_count++ > 5)
3881
+				{
3882
+					break;
3883
+				}
3372 3884
 			}
3373 3885
 		}
3374 3886
 
@@ -3379,7 +3891,10 @@  discard block
 block discarded – undo
3379 3891
 			$search = explode(' ', $_searchString);
3380 3892
 			foreach ($search as $k => $v)
3381 3893
 			{
3382
-				if (mb_strlen($v) < 3) unset($search[$k]);
3894
+				if (mb_strlen($v) < 3)
3895
+				{
3896
+					unset($search[$k]);
3897
+				}
3383 3898
 			}
3384 3899
 			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3385 3900
 			//error_log(__METHOD__.__LINE__.$_searchString);
@@ -3409,9 +3924,12 @@  discard block
 block discarded – undo
3409 3924
 			}
3410 3925
 		}
3411 3926
 		
3412
-		if(is_array($contacts)) {
3413
-			foreach($contacts as $contact) {
3414
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3927
+		if(is_array($contacts))
3928
+		{
3929
+			foreach($contacts as $contact)
3930
+			{
3931
+				foreach(array($contact['email'],$contact['email_home']) as $email)
3932
+				{
3415 3933
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3416 3934
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3417 3935
 					$rfcAddr = Mail::parseAddressList($email);
@@ -3425,10 +3943,22 @@  discard block
 block discarded – undo
3425 3943
 					if (method_exists($contacts_obj,'search'))
3426 3944
 					{
3427 3945
 						$contact['n_fn']='';
3428
-						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3429
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3430
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3431
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3946
+						if (!empty($contact['n_prefix']))
3947
+						{
3948
+							$contact['n_fn'] = $contact['n_prefix'];
3949
+						}
3950
+						if (!empty($contact['n_given']))
3951
+						{
3952
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3953
+						}
3954
+						if (!empty($contact['n_family']))
3955
+						{
3956
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3957
+						}
3958
+						if (!empty($contact['org_name']))
3959
+						{
3960
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3961
+						}
3432 3962
 						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3433 3963
 					}
3434 3964
 					else
@@ -3438,7 +3968,8 @@  discard block
 block discarded – undo
3438 3968
 					$args = explode('@', trim($email));
3439 3969
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3440 3970
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3441
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3971
+					if(!empty($email) && in_array($completeMailString ,$results) === false)
3972
+					{
3442 3973
 						$results[] = array(
3443 3974
 							'id'=>$completeMailString,
3444 3975
 							'label' => $completeMailString,
@@ -3457,7 +3988,10 @@  discard block
 block discarded – undo
3457 3988
 		foreach($groups as $g_id => $name)
3458 3989
 		{
3459 3990
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3460
-			if(!$group['account_email']) continue;
3991
+			if(!$group['account_email'])
3992
+			{
3993
+				continue;
3994
+			}
3461 3995
 			$args = explode('@', trim($group['account_email']));
3462 3996
 			$args[] = $name;
3463 3997
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
Please login to merge, or discard this patch.
Spacing   +604 added lines, -605 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
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 				'checkbox' => true,
181 180
 				'hint' => 'check to save as trackerentry on send',
182 181
 				'onExecute' => 'javaScript:app.mail.compose_setToggle',
183
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
182
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
184 183
 			),
185 184
 			'to_calendar' => array(
186 185
 				'caption' => 'Calendar',
@@ -205,7 +204,7 @@  discard block
 block discarded – undo
205 204
 				'children' => array(),
206 205
 				'hint' => 'Select the message priority tag',
207 206
 			),
208
-			'save2vfs' => array (
207
+			'save2vfs' => array(
209 208
 				'caption' => 'Save to filemanager',
210 209
 				'icon' => 'filesave',
211 210
 				'group' => ++$group,
@@ -242,7 +241,7 @@  discard block
 block discarded – undo
242 241
 		{
243 242
 			foreach (array_keys($actions) as $key)
244 243
 			{
245
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
244
+				if (!in_array($key, array('send', 'button[saveAsDraft]', 'uploadForCompose'))) {
246 245
 					$actions[$key]['toolbarDefault'] = false;
247 246
 				}
248 247
 			}
@@ -266,7 +265,7 @@  discard block
 block discarded – undo
266 265
 	 * @var boolean $suppressSigOnTop =false
267 266
 	 * @var boolean $isReply =false
268 267
 	 */
269
-	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
268
+	function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false)
270 269
 	{
271 270
 		if ($msg) Framework::message($msg);
272 271
 
@@ -287,14 +286,14 @@  discard block
 block discarded – undo
287 286
 		//lang('compose'),lang('from') // needed to be found by translationtools
288 287
 		//error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace());
289 288
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
290
-		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
291
-		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
289
+		$_contentHasSigID = $_content ?array_key_exists('mailidentity', (array)$_content) : false;
290
+		$_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false;
292 291
 		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
293 292
 		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
294 293
 
295 294
 		// Process different places we can use as a start for composing an email
296 295
 		$actionToProcess = 'compose';
297
-		if($_GET['from'] && $replyID)
296
+		if ($_GET['from'] && $replyID)
298 297
 		{
299 298
 			$_content = array_merge((array)$_content, $this->getComposeFrom(
300 299
 				// Parameters needed for fetching appropriate data
@@ -312,10 +311,10 @@  discard block
 block discarded – undo
312 311
 		}
313 312
 
314 313
 		$composeCache = array();
315
-		if (isset($_content['composeID'])&&!empty($_content['composeID']))
314
+		if (isset($_content['composeID']) && !empty($_content['composeID']))
316 315
 		{
317 316
 			$isFirstLoad = false;
318
-			$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);
317
+			$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);
319 318
 			$this->composeID = $_content['composeID'];
320 319
 			//error_log(__METHOD__.__LINE__.array2string($composeCache));
321 320
 		}
@@ -325,7 +324,7 @@  discard block
 block discarded – undo
325 324
 			// respect that composeasnew may not want that, as we assume there
326 325
 			// is some style already set and our initalStyle always adds a span with &nbsp;
327 326
 			// and we want to avoid that
328
-			$isFirstLoad = !($actionToProcess=='composeasnew');//true;
327
+			$isFirstLoad = !($actionToProcess == 'composeasnew'); //true;
329 328
 			$this->composeID = $_content['composeID'] = $this->generateComposeID();
330 329
 			if (!is_array($_content))
331 330
 			{
@@ -360,7 +359,7 @@  discard block
 block discarded – undo
360 359
 				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
361 360
 				try
362 361
 				{
363
-					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
362
+					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload, $this->composeID, false);
364 363
 				}
365 364
 				catch (Api\Exception\WrongUserinput $e)
366 365
 				{
@@ -386,12 +385,12 @@  discard block
 block discarded – undo
386 385
 			unset($_content['attachments']['delete']);
387 386
 			$attachments = $_content['attachments'];
388 387
 			unset($_content['attachments']);
389
-			foreach($attachments as $i => $att)
388
+			foreach ($attachments as $i => $att)
390 389
 			{
391
-				$remove=false;
392
-				foreach(array_keys($toDelete) as $k)
390
+				$remove = false;
391
+				foreach (array_keys($toDelete) as $k)
393 392
 				{
394
-					if ($att['tmp_name']==$k) $remove=true;
393
+					if ($att['tmp_name'] == $k) $remove = true;
395 394
 				}
396 395
 				if (!$remove) $_content['attachments'][] = $att;
397 396
 			}
@@ -399,7 +398,7 @@  discard block
 block discarded – undo
399 398
 		// someone clicked something like send, or saveAsDraft
400 399
 		// make sure, we are connected to the correct server for sending and storing the send message
401 400
 		$activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose
402
-		$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);
401
+		$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);
403 402
 		if (!empty($activeFolderCache[$this->mail_bo->profileID]))
404 403
 		{
405 404
 			//error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]);
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 		}
408 407
 		//error_log(__METHOD__.__LINE__.array2string($_content));
409 408
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
410
-			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
409
+			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint'])
411 410
 		)
412 411
 		{
413 412
 			$this->changeProfile($_content['serverID']);
@@ -421,19 +420,19 @@  discard block
 block discarded – undo
421 420
 		{
422 421
 			$buttonClicked = $suppressSigOnTop = true;
423 422
 			$sendOK = true;
424
-			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']);
423
+			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
425 424
 			/*
426 425
 			perform some simple checks, before trying to send on:
427 426
 			$_content['to'];$_content['cc'];$_content['bcc'];
428 427
 			trim($_content['subject']);
429 428
 			trim(strip_tags(str_replace('&nbsp;','',$_content['body'])));
430 429
 			*/
431
-			if (strlen(trim(strip_tags(str_replace('&nbsp;','',$_content['body']))))==0 && count($_content['attachments'])==0)
430
+			if (strlen(trim(strip_tags(str_replace('&nbsp;', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0)
432 431
 			{
433 432
 				$sendOK = false;
434 433
 				$_content['msg'] = $message = lang("no message body supplied");
435 434
 			}
436
-			if ($sendOK && strlen(trim($_content['subject']))==0)
435
+			if ($sendOK && strlen(trim($_content['subject'])) == 0)
437 436
 			{
438 437
 				$sendOK = false;
439 438
 				$_content['msg'] = $message = lang("no subject supplied");
@@ -448,15 +447,15 @@  discard block
 block discarded – undo
448 447
 				try
449 448
 				{
450 449
 					$success = $this->send($_content);
451
-					if ($success==false)
450
+					if ($success == false)
452 451
 					{
453
-						$sendOK=false;
452
+						$sendOK = false;
454 453
 						$message = $this->errorInfo;
455 454
 					}
456 455
 					if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID])
457 456
 					{
458
-						$sigPref[$this->mail_bo->profileID]=$_content['mailidentity'];
459
-						$GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user');
457
+						$sigPref[$this->mail_bo->profileID] = $_content['mailidentity'];
458
+						$GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user');
460 459
 						// save prefs
461 460
 						$GLOBALS['egw']->preferences->save_repository(true);
462 461
 					}
@@ -480,23 +479,23 @@  discard block
 block discarded – undo
480 479
 				if (isset($_content['mode']) && !empty($_content['mode']))
481 480
 				{
482 481
 					$mode = $_content['mode'];
483
-					if ($_content['mode']=='forward' && !empty($_content['processedmail_id']))
482
+					if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id']))
484 483
 					{
485
-						$_content['processedmail_id'] = explode(',',$_content['processedmail_id']);
484
+						$_content['processedmail_id'] = explode(',', $_content['processedmail_id']);
486 485
 						foreach ($_content['processedmail_id'] as $k =>$rowid)
487 486
 						{
488 487
 							$fhA = mail_ui::splitRowID($rowid);
489 488
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
490 489
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
491
-							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
490
+							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false);
492 491
 							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
493 492
 						}
494 493
 					}
495
-					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
494
+					if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id']))
496 495
 					{
497 496
 						$rhA = mail_ui::splitRowID($_content['processedmail_id']);
498 497
 						//$this->sessionData['uid'] = $rhA['msgUID'];
499
-						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
498
+						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
500 499
 						$workingFolder = $rhA['folder'];
501 500
 					}
502 501
 				}
@@ -504,30 +503,30 @@  discard block
 block discarded – undo
504 503
 				if (empty($idsForRefresh) && !empty($_content['processedmail_id']))
505 504
 				{
506 505
 					$rhA = mail_ui::splitRowID($_content['processedmail_id']);
507
-					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
506
+					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
508 507
 				}
509 508
 				$response = Api\Json\Response::get();
510 509
 				if ($activeProfile != $composeProfile)
511 510
 				{
512 511
 					// we need a message only, when account ids (composeProfile vs. activeProfile) differ
513
-					$response->call('opener.egw_message',lang('Message send successfully.'));
512
+					$response->call('opener.egw_message', lang('Message send successfully.'));
514 513
 				}
515
-				elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)))
514
+				elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)))
516 515
 				{
517
-					if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))
516
+					if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))
518 517
 					{
519 518
 						// we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action
520
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail');
519
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail');
521 520
 					}
522 521
 					else
523 522
 					{
524 523
 						//error_log(__METHOD__.__LINE__.array2string($idsForRefresh));
525
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update');
524
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update');
526 525
 					}
527 526
 				}
528 527
 				else
529 528
 				{
530
-					$response->call('opener.egw_message',lang('Message send successfully.'));
529
+					$response->call('opener.egw_message', lang('Message send successfully.'));
531 530
 				}
532 531
 				//egw_framework::refresh_opener(lang('Message send successfully.'),'mail');
533 532
 				Framework::window_close();
@@ -535,60 +534,60 @@  discard block
 block discarded – undo
535 534
 			if ($sendOK == false)
536 535
 			{
537 536
 				$response = Api\Json\Response::get();
538
-				Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate
537
+				Framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate
539 538
 				$response->call('app.mail.clearIntevals');
540 539
 			}
541 540
 		}
542 541
 
543 542
 		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
544 543
 		$insertSigOnTop = false;
545
-		$content = (is_array($_content)?$_content:array());
544
+		$content = (is_array($_content) ? $_content : array());
546 545
 		if ($_contentHasMimeType)
547 546
 		{
548 547
 			// mimeType is now a checkbox; convert it here to match expectations
549 548
 			// ToDo: match Code to meet checkbox value
550
-			if ($content['mimeType']==1)
549
+			if ($content['mimeType'] == 1)
551 550
 			{
552
-				$_content['mimeType'] = $content['mimeType']='html';
551
+				$_content['mimeType'] = $content['mimeType'] = 'html';
553 552
 			}
554 553
 			else
555 554
 			{
556
-				$_content['mimeType'] = $content['mimeType']='plain';
555
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
557 556
 			}
558 557
 
559 558
 		}
560 559
 		// user might have switched desired mimetype, so we should convert
561
-		if ($content['is_html'] && $content['mimeType']=='plain')
560
+		if ($content['is_html'] && $content['mimeType'] == 'plain')
562 561
 		{
563 562
 			//error_log(__METHOD__.__LINE__.$content['mail_htmltext']);
564 563
 			$suppressSigOnTop = true;
565
-			if (stripos($content['mail_htmltext'],'<pre>')!==false)
564
+			if (stripos($content['mail_htmltext'], '<pre>') !== false)
566 565
 			{
567 566
 				$contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']);
568 567
 				if (is_array($contentArr))
569 568
 				{
570 569
 					foreach ($contentArr as $k =>&$elem)
571 570
 					{
572
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
571
+						if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem);
573 572
 					}
574
-					$content['mail_htmltext'] = implode('',$contentArr);
573
+					$content['mail_htmltext'] = implode('', $contentArr);
575 574
 				}
576 575
 			}
577 576
 			$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']);
578
-			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
577
+			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true);
579 578
 
580 579
 			$content['body'] = $content['mail_htmltext'];
581 580
 			unset($content['mail_htmltext']);
582 581
 			$content['is_html'] = false;
583 582
 			$content['is_plain'] = true;
584 583
 		}
585
-		if ($content['is_plain'] && $content['mimeType']=='html')
584
+		if ($content['is_plain'] && $content['mimeType'] == 'html')
586 585
 		{
587 586
 			// the possible font span should only be applied on first load or on switch plain->html
588 587
 			$isFirstLoad = "switchedplaintohtml";
589 588
 			//error_log(__METHOD__.__LINE__.$content['mail_plaintext']);
590 589
 			$suppressSigOnTop = true;
591
-			$content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']);
590
+			$content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']);
592 591
 			//$this->replaceEmailAdresses($content['mail_plaintext']);
593 592
 			$content['body'] = $content['mail_plaintext'];
594 593
 			unset($content['mail_plaintext']);
@@ -596,7 +595,7 @@  discard block
 block discarded – undo
596 595
 			$content['is_plain'] = false;
597 596
 		}
598 597
 
599
-		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']);
598
+		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
600 599
 		unset($_content['body']);
601 600
 		unset($_content['mail_htmltext']);
602 601
 		unset($_content['mail_plaintext']);
@@ -608,7 +607,7 @@  discard block
 block discarded – undo
608 607
 
609 608
 		// form was submitted either by clicking a button or by changing one of the triggering selectboxes
610 609
 		// identity and signatureid; this might trigger that the signature in mail body may have to be altered
611
-		if ( !empty($content['body']) &&
610
+		if (!empty($content['body']) &&
612 611
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
613 612
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
614 613
 		)
@@ -619,7 +618,7 @@  discard block
 block discarded – undo
619 618
 			{
620 619
 				$acc = Mail\Account::read($_content['mailaccount']);
621 620
 				//error_log(__METHOD__.__LINE__.array2string($acc));
622
-				$Identities = Mail\Account::read_identity($acc['ident_id'],true);
621
+				$Identities = Mail\Account::read_identity($acc['ident_id'], true);
623 622
 				//error_log(__METHOD__.__LINE__.array2string($Identities));
624 623
 				if ($Identities['ident_id'])
625 624
 				{
@@ -632,41 +631,41 @@  discard block
 block discarded – undo
632 631
 				}
633 632
 			}
634 633
 			$_oldSig = $composeCache['mailidentity'];
635
-			$_signatureid = ($newSig?$newSig:$_content['mailidentity']);
634
+			$_signatureid = ($newSig ? $newSig : $_content['mailidentity']);
636 635
 
637 636
 			if ($_oldSig != $_signatureid)
638 637
 			{
639
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
638
+				if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
640 639
 				// prepare signatures, the selected sig may be used on top of the body
641 640
 				try
642 641
 				{
643
-					$oldSignature = Mail\Account::read_identity($_oldSig,true);
642
+					$oldSignature = Mail\Account::read_identity($_oldSig, true);
644 643
 					//error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#');
645 644
 					$oldSigText = $oldSignature['ident_signature'];
646 645
 				}
647 646
 				catch (Exception $e)
648 647
 				{
649
-					$oldSignature=array();
648
+					$oldSignature = array();
650 649
 					$oldSigText = null;
651 650
 				}
652 651
 				try
653 652
 				{
654
-					$signature = Mail\Account::read_identity($_signatureid,true);
653
+					$signature = Mail\Account::read_identity($_signatureid, true);
655 654
 					//error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#');
656 655
 					$sigText = $signature['ident_signature'];
657 656
 				}
658 657
 				catch (Exception $e)
659 658
 				{
660
-					$signature=array();
659
+					$signature = array();
661 660
 					$sigText = null;
662 661
 				}
663 662
 				//error_log(__METHOD__.'Old:'.$oldSigText.'#');
664 663
 				//error_log(__METHOD__.'New:'.$sigText.'#');
665 664
 				if ($_currentMode == 'plain')
666 665
 				{
667
-					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
668
-					$sigText = $this->convertHTMLToText($sigText,true,true);
669
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
666
+					$oldSigText = $this->convertHTMLToText($oldSigText, true, true);
667
+					$sigText = $this->convertHTMLToText($sigText, true, true);
668
+					if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
670 669
 				}
671 670
 
672 671
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -680,9 +679,9 @@  discard block
 block discarded – undo
680 679
 				//error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#');
681 680
 				if ($_currentMode == 'html')
682 681
 				{
683
-					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
682
+					$content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace
684 683
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
685
-					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
684
+					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
686 685
 				}
687 686
 				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"),
688 687
 					$_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']);
@@ -690,9 +689,9 @@  discard block
 block discarded – undo
690 689
 				if ($_currentMode == 'html')
691 690
 				{
692 691
 					$replaced = null;
693
-					$content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u',
694
-						$rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced);
695
-					$content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'&ndash;','&mdash;','&euro;'),$content['body']);
692
+					$content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u',
693
+						$rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced);
694
+					$content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '&ndash;', '&mdash;', '&euro;'), $content['body']);
696 695
 					//error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced");
697 696
 					unset($rep, $in);
698 697
 					if ($replaced)
@@ -703,32 +702,32 @@  discard block
 block discarded – undo
703 702
 					else
704 703
 					{
705 704
 						// try the old way
706
-						$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
705
+						$found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false);
707 706
 					}
708 707
 				}
709 708
 				else
710 709
 				{
711
-					$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
710
+					$found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false);
712 711
 				}
713 712
 
714
-				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
713
+				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
715 714
 				{
716 715
 					//error_log(__METHOD__.'Old Content:'.$content['body'].'#');
717
-					$_oldSigText = preg_quote($oldSigTextCleaned,'~');
716
+					$_oldSigText = preg_quote($oldSigTextCleaned, '~');
718 717
 					//error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#');
719
-					$content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1);
718
+					$content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1);
720 719
 					//error_log(__METHOD__.'new Content:'.$content['body'].'#');
721 720
 				}
722 721
 
723
-				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
722
+				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
724 723
 				{
725 724
 					// if there is no sig selected, there is no way to replace a signature
726 725
 				}
727 726
 
728 727
 				if ($found === false)
729 728
 				{
730
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
731
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
729
+					if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
730
+					if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
732 731
 				}
733 732
 				else
734 733
 				{
@@ -750,7 +749,7 @@  discard block
 block discarded – undo
750 749
 		if ($isFirstLoad)
751 750
 		{
752 751
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
753
-			if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
752
+			if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
754 753
 				$this->mailPreferences['attachVCardAtCompose']))
755 754
 			{
756 755
 				$alwaysAttachVCardAtCompose = true;
@@ -759,7 +758,7 @@  discard block
 block discarded – undo
759 758
 					$f = $_REQUEST['preset']['file'];
760 759
 					$_REQUEST['preset']['file'] = array($f);
761 760
 				}
762
-				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry";
761
+				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry";
763 762
 			}
764 763
 			// an app passed the request for fetching and mailing an entry
765 764
 			if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))
@@ -768,33 +767,33 @@  discard block
 block discarded – undo
768 767
 				$mt = $_REQUEST['method'];
769 768
 				$id = $_REQUEST['id'];
770 769
 				// passed method MUST be registered
771
-				$method = Link::get_registry($app,$mt);
770
+				$method = Link::get_registry($app, $mt);
772 771
 				//error_log(__METHOD__.__LINE__.array2string($method));
773 772
 				if ($method)
774 773
 				{
775
-					$res = ExecMethod($method,array($id,'html'));
774
+					$res = ExecMethod($method, array($id, 'html'));
776 775
 					//error_log(__METHOD__.__LINE__.array2string($res));
777 776
 					if (!empty($res))
778 777
 					{
779 778
 						$insertSigOnTop = 'below';
780 779
 						if (isset($res['attachments']) && is_array($res['attachments']))
781 780
 						{
782
-							foreach($res['attachments'] as $f)
781
+							foreach ($res['attachments'] as $f)
783 782
 							{
784 783
 								$_REQUEST['preset']['file'][] = $f;
785 784
 							}
786 785
 						}
787 786
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
788
-						foreach(array('subject','body','mimetype') as $name) {
787
+						foreach (array('subject', 'body', 'mimetype') as $name) {
789 788
 							$sName = $name;
790
-							if ($name=='mimetype'&&$res[$name])
789
+							if ($name == 'mimetype' && $res[$name])
791 790
 							{
792 791
 								$sName = 'mimeType';
793 792
 								$content[$sName] = $res[$name];
794 793
 							}
795 794
 							else
796 795
 							{
797
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
796
+								if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name];
798 797
 							}
799 798
 						}
800 799
 					}
@@ -803,45 +802,45 @@  discard block
 block discarded – undo
803 802
 			// handle preset info/values
804 803
 			if (is_array($_REQUEST['preset']))
805 804
 			{
806
-				$alreadyProcessed=array();
805
+				$alreadyProcessed = array();
807 806
 				//_debug_array($_REQUEST);
808 807
 				if ($_REQUEST['preset']['mailto']) {
809 808
 					// handle mailto strings such as
810 809
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
811 810
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
812 811
 					// first, strip the mailto: string out of the mailto URL
813
-					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
812
+					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7)));
814 813
 					// check if there is more than the to address
815
-					$mailtoArray = explode('?',$tmp_send_to,2);
814
+					$mailtoArray = explode('?', $tmp_send_to, 2);
816 815
 					if ($mailtoArray[1]) {
817 816
 						// check if there are more than one requests
818
-						$addRequests = explode('&',$mailtoArray[1]);
817
+						$addRequests = explode('&', $mailtoArray[1]);
819 818
 						foreach ($addRequests as $key => $reqval) {
820 819
 							// the additional requests should have a =, to separate key from value.
821
-							$keyValuePair = explode('=',$reqval,2);
822
-							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
820
+							$keyValuePair = explode('=', $reqval, 2);
821
+							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1];
823 822
 						}
824 823
 					}
825
-					$content['to']=$mailtoArray[0];
826
-					$alreadyProcessed['to']='to';
824
+					$content['to'] = $mailtoArray[0];
825
+					$alreadyProcessed['to'] = 'to';
827 826
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
828
-					foreach(array('cc','bcc','subject','body') as $name) {
829
-						$alreadyProcessed[$name]=$name;
830
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
827
+					foreach (array('cc', 'bcc', 'subject', 'body') as $name) {
828
+						$alreadyProcessed[$name] = $name;
829
+						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name];
831 830
 					}
832 831
 				}
833 832
 
834 833
 				if ($_REQUEST['preset']['mailtocontactbyid']) {
835 834
 					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
836 835
 						$contacts_obj = new Api\Contacts();
837
-						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
838
-						if (method_exists($contacts_obj,'search')) {
836
+						$addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook'];
837
+						if (method_exists($contacts_obj, 'search')) {
839 838
 
840
-							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
839
+							$addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']);
841 840
 							foreach ((array)$addressArray as $id => $addressID)
842 841
 							{
843
-								$addressID = (int) $addressID;
844
-								if (!($addressID>0))
842
+								$addressID = (int)$addressID;
843
+								if (!($addressID > 0))
845 844
 								{
846 845
 									unset($addressArray[$id]);
847 846
 								}
@@ -850,44 +849,44 @@  discard block
 block discarded – undo
850 849
 							{
851 850
 								$_searchCond = array('contact_id'=>$addressArray);
852 851
 								//error_log(__METHOD__.__LINE__.$_searchString);
853
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
854
-								$filter = ($showAccounts?array():array('account_id' => null));
855
-								$filter['cols_to_search']=array('n_fn','email','email_home');
856
-								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
852
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts = false;
853
+								$filter = ($showAccounts ? array() : array('account_id' => null));
854
+								$filter['cols_to_search'] = array('n_fn', 'email', 'email_home');
855
+								$contacts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
857 856
 								// additionally search the accounts, if the contact storage is not the account storage
858 857
 								if ($showAccounts &&
859 858
 									$GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
860 859
 									$GLOBALS['egw_info']['server']['contact_repository'] == 'sql')
861 860
 								{
862
-									$accounts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0));
861
+									$accounts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0));
863 862
 
864 863
 									if ($contacts && $accounts)
865 864
 									{
866
-										$contacts = array_merge($contacts,$accounts);
867
-										usort($contacts,create_function('$a,$b','return strcasecmp($a["n_fn"],$b["n_fn"]);'));
865
+										$contacts = array_merge($contacts, $accounts);
866
+										usort($contacts, create_function('$a,$b', 'return strcasecmp($a["n_fn"],$b["n_fn"]);'));
868 867
 									}
869
-									elseif($accounts)
868
+									elseif ($accounts)
870 869
 									{
871
-										$contacts =& $accounts;
870
+										$contacts = & $accounts;
872 871
 									}
873 872
 									unset($accounts);
874 873
 								}
875 874
 							}
876
-							if(is_array($contacts)) {
875
+							if (is_array($contacts)) {
877 876
 								$mailtoArray = array();
878 877
 								$primary = $addressbookprefs['distributionListPreferredMail'];
879 878
 								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
880
-								$secondary = ($primary == 'email'?'email_home':'email');
879
+								$secondary = ($primary == 'email' ? 'email_home' : 'email');
881 880
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
882
-								foreach($contacts as $contact) {
883
-									$innerCounter=0;
884
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
881
+								foreach ($contacts as $contact) {
882
+									$innerCounter = 0;
883
+									foreach (array($contact[$primary], $contact[$secondary]) as $email) {
885 884
 										// use pref distributionListPreferredMail for the primary address
886 885
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
887
-										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
888
-										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
889
-										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
890
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
886
+										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email);
887
+										$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
888
+										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>');
889
+										if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) {
891 890
 											$i++;
892 891
 											$innerCounter++;
893 892
 											$mailtoArray[$i] = $completeMailString;
@@ -896,8 +895,8 @@  discard block
 block discarded – undo
896 895
 								}
897 896
 							}
898 897
 							//error_log(__METHOD__.__LINE__.array2string($mailtoArray));
899
-							$alreadyProcessed['to']='to';
900
-							$content['to']=$mailtoArray;
898
+							$alreadyProcessed['to'] = 'to';
899
+							$content['to'] = $mailtoArray;
901 900
 						}
902 901
 					}
903 902
 				}
@@ -912,20 +911,20 @@  discard block
 block discarded – undo
912 911
 					$types = (array)$_REQUEST['preset']['type'];
913 912
 					//if (!empty($types) && in_array('text/calendar; method=request',$types))
914 913
 					$files = (array)$_REQUEST['preset']['file'];
915
-					foreach($files as $k => $path)
914
+					foreach ($files as $k => $path)
916 915
 					{
917
-						if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false)
916
+						if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false)
918 917
 						{
919 918
 							$insertSigOnTop = 'below';
920 919
 						}
921 920
 						//error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs')));
922
-						if (parse_url($path,PHP_URL_SCHEME == 'vfs'))
921
+						if (parse_url($path, PHP_URL_SCHEME == 'vfs'))
923 922
 						{
924 923
 							//Vfs::load_wrapper('vfs');
925 924
 							$type = Vfs::mime_content_type($path);
926 925
 							// special handling for attaching vCard of iCal --> use their link-title as name
927
-							if (substr($path,-7) != '/.entry' ||
928
-								!(list($app,$id) = array_slice(explode('/',$path),-3)) ||
926
+							if (substr($path, -7) != '/.entry' ||
927
+								!(list($app, $id) = array_slice(explode('/', $path), -3)) ||
929 928
 								!($name = Link::title($app, $id)))
930 929
 							{
931 930
 								$name = Vfs::decodePath(Vfs::basename($path));
@@ -939,7 +938,7 @@  discard block
 block discarded – undo
939 938
 							{
940 939
 								$type = $types[$k];
941 940
 							}
942
-							$path = str_replace('+','%2B',$path);
941
+							$path = str_replace('+', '%2B', $path);
943 942
 							$formData = array(
944 943
 								'name' => $name,
945 944
 								'type' => $type,
@@ -952,7 +951,7 @@  discard block
 block discarded – undo
952 951
 								Framework::message(lang('Directories have to be shared.'), 'info');
953 952
 							}
954 953
 						}
955
-						elseif(is_readable($path))
954
+						elseif (is_readable($path))
956 955
 						{
957 956
 							$formData = array(
958 957
 								'name' => isset($names[$k]) ? $names[$k] : basename($path),
@@ -965,28 +964,28 @@  discard block
 block discarded – undo
965 964
 						{
966 965
 							continue;
967 966
 						}
968
-						$this->addAttachment($formData,$content,($alwaysAttachVCardAtCompose?true:false));
967
+						$this->addAttachment($formData, $content, ($alwaysAttachVCardAtCompose ?true:false));
969 968
 					}
970 969
 					$remember = array();
971 970
 					if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])))
972 971
 					{
973
-						foreach(array_keys($content) as $k)
972
+						foreach (array_keys($content) as $k)
974 973
 						{
975
-							if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k]))
974
+							if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k]))
976 975
 							{
977
-								$alreadyProcessed[$k]=$k;
976
+								$alreadyProcessed[$k] = $k;
978 977
 								$remember[$k] = $this->sessionData[$k];
979 978
 							}
980 979
 						}
981 980
 					}
982
-					if(!empty($remember)) $content = array_merge($content,$remember);
981
+					if (!empty($remember)) $content = array_merge($content, $remember);
983 982
 				}
984
-				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
983
+				foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name)
985 984
 				{
986 985
 					//always handle mimeType
987
-					if ($name=='mimeType' && $_REQUEST['preset'][$name])
986
+					if ($name == 'mimeType' && $_REQUEST['preset'][$name])
988 987
 					{
989
-						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
988
+						$_content[$name] = $content[$name] = $_REQUEST['preset'][$name];
990 989
 					}
991 990
 					//skip if already processed by "preset Routines"
992 991
 					if ($alreadyProcessed[$name]) continue;
@@ -999,36 +998,36 @@  discard block
 block discarded – undo
999 998
 			{
1000 999
 				$content['to'] = base64_decode($_REQUEST['send_to']);
1001 1000
 				// first check if there is a questionmark or ampersand
1002
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1001
+				if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2);
1003 1002
 				$content['to'] = html_entity_decode($content['to']);
1004
-				if (($at_pos = strpos($content['to'],'@')) !== false)
1003
+				if (($at_pos = strpos($content['to'], '@')) !== false)
1005 1004
 				{
1006
-					if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false)
1005
+					if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false)
1007 1006
 					{
1008 1007
 						//list($email,$addoptions) = explode('&',$value,2);
1009
-						$email = substr($content['to'],0,$amp_pos+$at_pos);
1010
-						$rest = substr($content['to'], $amp_pos+$at_pos+1);
1008
+						$email = substr($content['to'], 0, $amp_pos + $at_pos);
1009
+						$rest = substr($content['to'], $amp_pos + $at_pos + 1);
1011 1010
 						//error_log(__METHOD__.__LINE__.$email.' '.$rest);
1012 1011
 						$content['to'] = $email;
1013 1012
 					}
1014 1013
 				}
1015
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1014
+				if (strpos($content['to'], '%40') !== false) $content['to'] = Api\Html::purify(str_replace('%40', '@', $content['to']));
1016 1015
 				$rarr = array(Api\Html::purify($rest));
1017
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1016
+				if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest);
1018 1017
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1019 1018
 				$karr = array();
1020 1019
 				foreach ($rarr as &$rval)
1021 1020
 				{
1022 1021
 					//must contain =
1023
-					if (strpos($rval,'=')!== false)
1022
+					if (strpos($rval, '=') !== false)
1024 1023
 					{
1025
-						list($k,$v) = explode('=',$rval,2);
1024
+						list($k, $v) = explode('=', $rval, 2);
1026 1025
 						$karr[$k] = (string)$v;
1027
-						unset($k,$v);
1026
+						unset($k, $v);
1028 1027
 					}
1029 1028
 				}
1030 1029
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1031
-				foreach(array('cc','bcc','subject','body') as $name)
1030
+				foreach (array('cc', 'bcc', 'subject', 'body') as $name)
1032 1031
 				{
1033 1032
 					if ($karr[$name]) $content[$name] = $karr[$name];
1034 1033
 				}
@@ -1040,17 +1039,17 @@  discard block
 block discarded – undo
1040 1039
 		if ($isFirstLoad && !empty($_REQUEST['mimeType']))
1041 1040
 		{
1042 1041
 			$_content['mimeType'] = $content['mimeType'];
1043
-			if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html')
1042
+			if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html')
1044 1043
 			{
1045
-				$_content['mimeType'] = $content['mimeType']  = 'plain';
1046
-				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1044
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
1045
+				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1047 1046
 			}
1048
-			if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html')
1047
+			if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html')
1049 1048
 			{
1050
-				$_content['mimeType'] = $content['mimeType']  = 'html';
1049
+				$_content['mimeType'] = $content['mimeType'] = 'html';
1051 1050
 				$content['body'] = "<pre>".$content['body']."</pre>";
1052 1051
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1053
-				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);
1052
+				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);
1054 1053
 			}
1055 1054
 		}
1056 1055
 		else
@@ -1058,24 +1057,24 @@  discard block
 block discarded – undo
1058 1057
 			// try to enforce a mimeType on reply ( if type is not of the wanted type )
1059 1058
 			if ($isReply)
1060 1059
 			{
1061
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" &&
1060
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" &&
1062 1061
 					$content['mimeType'] == 'html')
1063 1062
 				{
1064
-					$_content['mimeType'] = $content['mimeType']  = 'plain';
1065
-					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1063
+					$_content['mimeType'] = $content['mimeType'] = 'plain';
1064
+					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1066 1065
 				}
1067
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" &&
1066
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" &&
1068 1067
 					$content['mimeType'] != 'html')
1069 1068
 				{
1070
-					$_content['mimeType'] = $content['mimeType']  = 'html';
1069
+					$_content['mimeType'] = $content['mimeType'] = 'html';
1071 1070
 					$content['body'] = "<pre>".$content['body']."</pre>";
1072 1071
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1073
-					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);
1072
+					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);
1074 1073
 				}
1075 1074
 			}
1076 1075
 		}
1077 1076
 
1078
-		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false)
1077
+		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible() === false)
1079 1078
 		{
1080 1079
 			$_content['mimeType'] = $content['mimeType'] = 'plain';
1081 1080
 			$content['body'] = $this->convertHTMLToText($content['body']);
@@ -1094,36 +1093,36 @@  discard block
 block discarded – undo
1094 1093
 		//_debug_array(($presetSig ? $presetSig : $content['mailidentity']));
1095 1094
 		try
1096 1095
 		{
1097
-			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true);
1096
+			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true);
1098 1097
 		}
1099 1098
 		catch (Exception $e)
1100 1099
 		{
1101 1100
 			//PROBABLY NOT FOUND
1102
-			$signature=array();
1101
+			$signature = array();
1103 1102
 		}
1104 1103
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
1105 1104
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
1106
-			empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='')
1105
+			empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '')
1107 1106
 		{
1108 1107
 			$disableRuler = true;
1109 1108
 		}
1110 1109
 		$font_span = $font_part = '';
1111
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1110
+		if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1112 1111
 			// User preferences for style
1113 1112
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1114 1113
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1115
-			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1114
+			$font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">';
1116 1115
 			$font_span = $font_part.'&#8203;</span>';
1117 1116
 			if (empty($font) && empty($font_size)) $font_span = '';
1118 1117
 		}
1119 1118
 		// 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
1120
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1119
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = '';
1121 1120
 		//remove possible html header stuff
1122
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1121
+		if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']);
1123 1122
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1124
-		$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');
1125
-		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1126
-			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1123
+		$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');
1124
+		if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' &&
1125
+			!(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop
1127 1126
 		)
1128 1127
 		{
1129 1128
 			// ON tOP OR BELOW? pREF CAN TELL
@@ -1133,57 +1132,57 @@  discard block
 block discarded – undo
1133 1132
 						'1' => 'before reply, visible during compose',
1134 1133
 						'no_belowaftersend'  => 'appended after reply before sending',
1135 1134
 			*/
1136
-			$insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below'));
1137
-			$sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
1135
+			$insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below'));
1136
+			$sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
1138 1137
 			if ($content['mimeType'] == 'html')
1139 1138
 			{
1140
-				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1141
-				foreach($blockElements as $e)
1139
+				$sigTextStartsWithBlockElement = ($disableRuler ?false:true);
1140
+				foreach ($blockElements as $e)
1142 1141
 				{
1143 1142
 					if ($sigTextStartsWithBlockElement) break;
1144
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1143
+					if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true;
1145 1144
 				}
1146 1145
 			}
1147
-			if($content['mimeType'] == 'html') {
1146
+			if ($content['mimeType'] == 'html') {
1148 1147
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1149 1148
 				$inbetween = '';
1150 1149
 			} else {
1151
-				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1150
+				$before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
1152 1151
 				$inbetween = "\r\n";
1153 1152
 			}
1154 1153
 			if ($content['mimeType'] == 'html')
1155 1154
 			{
1156
-				$sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>");
1155
+				$sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>");
1157 1156
 			}
1158 1157
 
1159 1158
 			if ($insertSigOnTop === 'below')
1160 1159
 			{
1161
-				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true));
1160
+				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true));
1162 1161
 			}
1163 1162
 			else
1164 1163
 			{
1165
-				$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
1164
+				$content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body'];
1166 1165
 			}
1167 1166
 		}
1168 1167
 		else
1169 1168
 		{
1170
-			$content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":"");
1169
+			$content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : "");
1171 1170
 		}
1172 1171
 		//error_log(__METHOD__.__LINE__.$content['body']);
1173 1172
 
1174 1173
 		// prepare body
1175 1174
 		// 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
1176
-		$content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8');
1175
+		$content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8');
1177 1176
 		//error_log(__METHOD__.__LINE__.array2string($content));
1178 1177
 
1179 1178
 		// get identities of all accounts as "$acc_id:$ident_id" => $identity
1180 1179
 		$sel_options['mailaccount'] = $identities = array();
1181
-		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1180
+		foreach (Mail\Account::search(true, false) as $acc_id => $account)
1182 1181
 		{
1183 1182
 			// do NOT add SMTP only accounts as identities
1184 1183
 			if (!$account->is_imap(false)) continue;
1185 1184
 
1186
-			foreach($account->identities($acc_id) as $ident_id => $identity)
1185
+			foreach ($account->identities($acc_id) as $ident_id => $identity)
1187 1186
 			{
1188 1187
 				$sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity;
1189 1188
 				$identities[$ident_id] = $identity;
@@ -1194,7 +1193,7 @@  discard block
 block discarded – undo
1194 1193
 		//$content['bcc'] = array('[email protected]','[email protected]');
1195 1194
 		// address stuff like from, to, cc, replyto
1196 1195
 		$destinationRows = 0;
1197
-		foreach(self::$destinations as $destination) {
1196
+		foreach (self::$destinations as $destination) {
1198 1197
 			if (!is_array($content[$destination]))
1199 1198
 			{
1200 1199
 				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
@@ -1202,22 +1201,22 @@  discard block
 block discarded – undo
1202 1201
 			$addr_content = $content[strtolower($destination)];
1203 1202
 			// we clear the given address array and rebuild it
1204 1203
 			unset($content[strtolower($destination)]);
1205
-			foreach((array)$addr_content as $key => $value) {
1206
-				if ($value=="NIL@NIL") continue;
1207
-				if ($destination=='replyto' && str_replace('"','',$value) ==
1208
-					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1204
+			foreach ((array)$addr_content as $key => $value) {
1205
+				if ($value == "NIL@NIL") continue;
1206
+				if ($destination == 'replyto' && str_replace('"', '', $value) ==
1207
+					str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()]))
1209 1208
 				{
1210 1209
 					// preserve/restore the value to content.
1211
-					$content[strtolower($destination)][]=$value;
1210
+					$content[strtolower($destination)][] = $value;
1212 1211
 					continue;
1213 1212
 				}
1214 1213
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1215
-				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1216
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1214
+				$value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT));
1215
+				foreach (Mail::parseAddressList($value) as $addressObject) {
1217 1216
 					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1218
-					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1217
+					$address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
1219 1218
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1220
-					$content[strtolower($destination)][]=$address;
1219
+					$content[strtolower($destination)][] = $address;
1221 1220
 					$destinationRows++;
1222 1221
 				}
1223 1222
 			}
@@ -1225,10 +1224,10 @@  discard block
 block discarded – undo
1225 1224
 		if ($_content)
1226 1225
 		{
1227 1226
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1228
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1229
-			$content = array_merge($content,$_content);
1227
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']);
1228
+			$content = array_merge($content, $_content);
1230 1229
 
1231
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1230
+			if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true);
1232 1231
 			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1233 1232
 		}
1234 1233
 		else
@@ -1237,12 +1236,12 @@  discard block
 block discarded – undo
1237 1236
 			$content['mailaccount'] = $this->mail_bo->profileID;
1238 1237
 			//error_log(__METHOD__.__LINE__.$content['body']);
1239 1238
 		}
1240
-		$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
1241
-		$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
1242
-		$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body'];
1243
-		$content['showtempname']=0;
1239
+		$content['is_html'] = ($content['mimeType'] == 'html' ?true:'');
1240
+		$content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true);
1241
+		$content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body'];
1242
+		$content['showtempname'] = 0;
1244 1243
 		//if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments']));
1245
-		$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)));
1244
+		$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)));
1246 1245
 		//if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0;
1247 1246
 		$content['no_griddata'] = empty($content['attachments']);
1248 1247
 		$preserv['attachments'] = $content['attachments'];
@@ -1276,12 +1275,12 @@  discard block
 block discarded – undo
1276 1275
 		$sel_options['mimeType'] = self::$mimeTypes;
1277 1276
 		$sel_options['priority'] = self::$priorities;
1278 1277
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1279
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1278
+		if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3;
1280 1279
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1281 1280
 		$etpl = new Etemplate('mail.compose');
1282 1281
 
1283 1282
 		$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content));
1284
-		if ($content['mimeType']=='html')
1283
+		if ($content['mimeType'] == 'html')
1285 1284
 		{
1286 1285
 			//mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]"
1287 1286
 			$_htmlConfig = Mail::$htmLawed_config;
@@ -1291,23 +1290,23 @@  discard block
 block discarded – undo
1291 1290
 			// and not the eGroupware wide pref to prevent users from trying things that will potentially not work
1292 1291
 			// or not work as expected, as a full featured editor that may be wanted in other apps
1293 1292
 			// is way overloading the "normal" needs for composing mails
1294
-			$content['rtfEditorFeatures']='simple-withimage';//Api\Html\CkEditorConfig::get_ckeditor_config();
1293
+			$content['rtfEditorFeatures'] = 'simple-withimage'; //Api\Html\CkEditorConfig::get_ckeditor_config();
1295 1294
 			//$content['rtfEditorFeatures']='advanced';//Api\Html\CkEditorConfig::get_ckeditor_config();
1296
-			$content['validation_rules']= json_encode(Mail::$htmLawed_config);
1297
-			$etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']);
1298
-			$etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']);
1295
+			$content['validation_rules'] = json_encode(Mail::$htmLawed_config);
1296
+			$etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']);
1297
+			$etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']);
1299 1298
 			Mail::$htmLawed_config = $_htmlConfig;
1300 1299
 		}
1301 1300
 
1302
-		if (isset($content['composeID'])&&!empty($content['composeID']))
1301
+		if (isset($content['composeID']) && !empty($content['composeID']))
1303 1302
 		{
1304 1303
 			$composeCache = $content;
1305 1304
 			unset($composeCache['body']);
1306 1305
 			unset($composeCache['mail_htmltext']);
1307 1306
 			unset($composeCache['mail_plaintext']);
1308
-			Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2);
1307
+			Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2);
1309 1308
 		}
1310
-		if (!isset($_content['serverID'])||empty($_content['serverID']))
1309
+		if (!isset($_content['serverID']) || empty($_content['serverID']))
1311 1310
 		{
1312 1311
 			$content['serverID'] = $this->mail_bo->profileID;
1313 1312
 		}
@@ -1323,13 +1322,13 @@  discard block
 block discarded – undo
1323 1322
 		$preserv['list-id'] = $content['list-id'];
1324 1323
 		$preserv['mode'] = $content['mode'];
1325 1324
 		// convert it back to checkbox expectations
1326
-		if($content['mimeType'] == 'html') {
1327
-			$content['mimeType']=1;
1325
+		if ($content['mimeType'] == 'html') {
1326
+			$content['mimeType'] = 1;
1328 1327
 		} else {
1329
-			$content['mimeType']=0;
1328
+			$content['mimeType'] = 0;
1330 1329
 		}
1331 1330
 		// set the current selected mailaccount as param for folderselection
1332
-		$etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount']));
1331
+		$etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount']));
1333 1332
 		// join again mailaccount and identity
1334 1333
 		$content['mailaccount'] .= ':'.$content['mailidentity'];
1335 1334
 		//Try to set the initial selected account to the first identity match found
@@ -1348,14 +1347,14 @@  discard block
 block discarded – undo
1348 1347
 			}
1349 1348
 		}
1350 1349
 		// Resolve distribution list before send content to client
1351
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1350
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $f)
1352 1351
 		{
1353
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1352
+			if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]);
1354 1353
 		}
1355 1354
 
1356 1355
 		$content['to'] = self::resolveEmailAddressList($content['to']);
1357 1356
 		//error_log(__METHOD__.__LINE__.array2string($content));
1358
-		$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
1357
+		$etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2);
1359 1358
 	}
1360 1359
 
1361 1360
 	/**
@@ -1376,9 +1375,9 @@  discard block
 block discarded – undo
1376 1375
 		$content = array();
1377 1376
 		//error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply");
1378 1377
 		// on forward we may have to support multiple ids
1379
-		if ($from=='forward')
1378
+		if ($from == 'forward')
1380 1379
 		{
1381
-			$replyIds = explode(',',$mail_id);
1380
+			$replyIds = explode(',', $mail_id);
1382 1381
 			$mail_id = $replyIds[0];
1383 1382
 		}
1384 1383
 		$hA = mail_ui::splitRowID($mail_id);
@@ -1390,15 +1389,15 @@  discard block
 block discarded – undo
1390 1389
 			$this->changeProfile($icServerID);
1391 1390
 		}
1392 1391
 		$icServer = $this->mail_bo->icServer;
1393
-		if (!empty($folder) && !empty($msgUID) )
1392
+		if (!empty($folder) && !empty($msgUID))
1394 1393
 		{
1395 1394
 			// this fill the session data with the values from the original email
1396
-			switch($from)
1395
+			switch ($from)
1397 1396
 			{
1398 1397
 				case 'composefromdraft':
1399 1398
 				case 'composeasnew':
1400 1399
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1401
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1400
+					if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft';
1402 1401
 					$content['processedmail_id'] = $mail_id;
1403 1402
 
1404 1403
 					$_focusElement = 'body';
@@ -1414,7 +1413,7 @@  discard block
 block discarded – undo
1414 1413
 					$isReply = true;
1415 1414
 					break;
1416 1415
 				case 'forward':
1417
-					$mode  = ($_GET['mode']=='forwardinline'?'inline':'asmail');
1416
+					$mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail');
1418 1417
 					// this fill the session data with the values from the original email
1419 1418
 					foreach ($replyIds as &$mail_id)
1420 1419
 					{
@@ -1424,14 +1423,14 @@  discard block
 block discarded – undo
1424 1423
 						$folder = $hA['folder'];
1425 1424
 						$content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode);
1426 1425
 					}
1427
-					$content['processedmail_id'] = implode(',',$replyIds);
1426
+					$content['processedmail_id'] = implode(',', $replyIds);
1428 1427
 					$content['mode'] = 'forward';
1429
-					$isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline');
1430
-					$suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution
1428
+					$isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline');
1429
+					$suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution
1431 1430
 					$_focusElement = 'to';
1432 1431
 					break;
1433 1432
 				default:
1434
-					error_log('Unhandled compose source: ' . $from);
1433
+					error_log('Unhandled compose source: '.$from);
1435 1434
 			}
1436 1435
 		}
1437 1436
 		else if ($from == 'merge' && $_REQUEST['document'])
@@ -1446,12 +1445,12 @@  discard block
 block discarded – undo
1446 1445
 			$document_merge = new $merge_class();
1447 1446
 			$this->mail_bo->openConnection();
1448 1447
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1449
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1448
+			if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids);
1450 1449
 			try
1451 1450
 			{
1452 1451
 				$merged_mail_id = '';
1453 1452
 				$folder = '';
1454
-				if(($error = $document_merge->check_document($_REQUEST['document'],'')))
1453
+				if (($error = $document_merge->check_document($_REQUEST['document'], '')))
1455 1454
 				{
1456 1455
 					$content['msg'] = $error;
1457 1456
 					return $content;
@@ -1461,10 +1460,10 @@  discard block
 block discarded – undo
1461 1460
 				//$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
1462 1461
 
1463 1462
 				// Actually do the merge
1464
-				if(count($merge_ids) <= 1)
1463
+				if (count($merge_ids) <= 1)
1465 1464
 				{
1466 1465
 					$results = $this->mail_bo->importMessageToMergeAndSend(
1467
-						$document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1466
+						$document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1468 1467
 					);
1469 1468
 
1470 1469
 					// Open compose
@@ -1475,9 +1474,9 @@  discard block
 block discarded – undo
1475 1474
 				}
1476 1475
 				else
1477 1476
 				{
1478
-					$success = implode(', ',$results['success']);
1477
+					$success = implode(', ', $results['success']);
1479 1478
 					$fail = implode(', ', $results['failed']);
1480
-					if($success) Framework::message($success, 'success');
1479
+					if ($success) Framework::message($success, 'success');
1481 1480
 					Framework::window_close($fail);
1482 1481
 				}
1483 1482
 			}
@@ -1505,22 +1504,22 @@  discard block
 block discarded – undo
1505 1504
 		return 1;
1506 1505
 	}
1507 1506
 
1508
-	function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false)
1507
+	function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false)
1509 1508
 	{
1510 1509
 		$stripalltags = true;
1511 1510
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1512
-		if (!$sourceishtml) $stripalltags=false;
1513
-		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1511
+		if (!$sourceishtml) $stripalltags = false;
1512
+		return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags);
1514 1513
 	}
1515 1514
 
1516 1515
 	function generateRFC822Address($_addressObject)
1517 1516
 	{
1518
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1519
-			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1520
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1521
-			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1517
+		if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1518
+			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1519
+		} elseif ($_addressObject->mailbox && $_addressObject->host) {
1520
+			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1522 1521
 		} else {
1523
-			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1522
+			return $this->mail_bo->decode_header($_addressObject->mailbox, true);
1524 1523
 		}
1525 1524
 	}
1526 1525
 
@@ -1535,9 +1534,9 @@  discard block
 block discarded – undo
1535 1534
 	// $_mode can be:
1536 1535
 	// single: for a reply to one address
1537 1536
 	// all: for a reply to all
1538
-	function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL)
1537
+	function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL)
1539 1538
 	{
1540
-		unset($_icServer);	// not used
1539
+		unset($_icServer); // not used
1541 1540
 		$this->sessionData['to'] = array();
1542 1541
 
1543 1542
 		$mail_bo = $this->mail_bo;
@@ -1546,7 +1545,7 @@  discard block
 block discarded – undo
1546 1545
 
1547 1546
 		// get message headers for specified message
1548 1547
 		#$headers	= $mail_bo->getMessageHeader($_folder, $_uid);
1549
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID);
1548
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
1550 1549
 		$addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID);
1551 1550
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1552 1551
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
@@ -1554,10 +1553,10 @@  discard block
 block discarded – undo
1554 1553
 
1555 1554
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1556 1555
 		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1557
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1558
-				$fval=$val;
1556
+			foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) {
1557
+				$fval = $val;
1559 1558
 				$icServerID = $mail_bo->icServer->ImapServerId;
1560
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1559
+				if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2);
1561 1560
 				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1562 1561
 				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1563 1562
 			}
@@ -1593,71 +1592,71 @@  discard block
 block discarded – undo
1593 1592
 			}
1594 1593
 		}
1595 1594
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1596
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1595
+		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder);
1597 1596
 		$this->sessionData['uid'] = $_uid;
1598 1597
 		$this->sessionData['messageFolder'] = $_folder;
1599 1598
 		$this->sessionData['isDraft'] = true;
1600 1599
 		$foundAddresses = array();
1601
-		foreach((array)$headers['CC'] as $val) {
1602
-			$rfcAddr=Mail::parseAddressList($val);
1600
+		foreach ((array)$headers['CC'] as $val) {
1601
+			$rfcAddr = Mail::parseAddressList($val);
1603 1602
 			$_rfcAddr = $rfcAddr[0];
1604 1603
 			if (!$_rfcAddr->valid) continue;
1605
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1604
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1606 1605
 				continue;
1607 1606
 			}
1608
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1609
-			if(!$foundAddresses[$keyemail]) {
1610
-				$address = $this->mail_bo->decode_header($val,true);
1607
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1608
+			if (!$foundAddresses[$keyemail]) {
1609
+				$address = $this->mail_bo->decode_header($val, true);
1611 1610
 				$this->sessionData['cc'][] = $val;
1612 1611
 				$foundAddresses[$keyemail] = true;
1613 1612
 			}
1614 1613
 		}
1615 1614
 
1616
-		foreach((array)$headers['TO'] as $val) {
1617
-			if(!is_array($val))
1615
+		foreach ((array)$headers['TO'] as $val) {
1616
+			if (!is_array($val))
1618 1617
 			{
1619 1618
 				$this->sessionData['to'][] = $val;
1620 1619
 				continue;
1621 1620
 			}
1622
-			$rfcAddr=Mail::parseAddressList($val);
1621
+			$rfcAddr = Mail::parseAddressList($val);
1623 1622
 			$_rfcAddr = $rfcAddr[0];
1624 1623
 			if (!$_rfcAddr->valid) continue;
1625
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1624
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1626 1625
 				continue;
1627 1626
 			}
1628
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1629
-			if(!$foundAddresses[$keyemail]) {
1630
-				$address = $this->mail_bo->decode_header($val,true);
1627
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1628
+			if (!$foundAddresses[$keyemail]) {
1629
+				$address = $this->mail_bo->decode_header($val, true);
1631 1630
 				$this->sessionData['to'][] = $val;
1632 1631
 				$foundAddresses[$keyemail] = true;
1633 1632
 			}
1634 1633
 		}
1635 1634
 
1636
-		foreach((array)$headers['REPLY-TO'] as $val) {
1637
-			$rfcAddr=Mail::parseAddressList($val);
1635
+		foreach ((array)$headers['REPLY-TO'] as $val) {
1636
+			$rfcAddr = Mail::parseAddressList($val);
1638 1637
 			$_rfcAddr = $rfcAddr[0];
1639 1638
 			if (!$_rfcAddr->valid) continue;
1640
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1639
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1641 1640
 				continue;
1642 1641
 			}
1643
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1644
-			if(!$foundAddresses[$keyemail]) {
1645
-				$address = $this->mail_bo->decode_header($val,true);
1642
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1643
+			if (!$foundAddresses[$keyemail]) {
1644
+				$address = $this->mail_bo->decode_header($val, true);
1646 1645
 				$this->sessionData['replyto'][] = $val;
1647 1646
 				$foundAddresses[$keyemail] = true;
1648 1647
 			}
1649 1648
 		}
1650 1649
 
1651
-		foreach((array)$headers['BCC'] as $val) {
1652
-			$rfcAddr=Mail::parseAddressList($val);
1650
+		foreach ((array)$headers['BCC'] as $val) {
1651
+			$rfcAddr = Mail::parseAddressList($val);
1653 1652
 			$_rfcAddr = $rfcAddr[0];
1654 1653
 			if (!$_rfcAddr->valid) continue;
1655
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1654
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1656 1655
 				continue;
1657 1656
 			}
1658
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1659
-			if(!$foundAddresses[$keyemail]) {
1660
-				$address = $this->mail_bo->decode_header($val,true);
1657
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1658
+			if (!$foundAddresses[$keyemail]) {
1659
+				$address = $this->mail_bo->decode_header($val, true);
1661 1660
 				$this->sessionData['bcc'][] = $val;
1662 1661
 				$foundAddresses[$keyemail] = true;
1663 1662
 			}
@@ -1666,48 +1665,48 @@  discard block
 block discarded – undo
1666 1665
 		$this->sessionData['subject']	= $mail_bo->decode_header($headers['SUBJECT']);
1667 1666
 		// remove a printview tag if composing
1668 1667
 		$searchfor = '/^\['.lang('printview').':\]/';
1669
-		$this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']);
1670
-		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1668
+		$this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']);
1669
+		$bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID);
1671 1670
 		//_debug_array($bodyParts);
1672 1671
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1673
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1674
-			$this->sessionData['mimeType'] 	= 'html';
1672
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
1673
+			$this->sessionData['mimeType'] = 'html';
1675 1674
 
1676
-			for($i=0; $i<count($bodyParts); $i++) {
1677
-				if($i>0) {
1675
+			for ($i = 0; $i < count($bodyParts); $i++) {
1676
+				if ($i > 0) {
1678 1677
 					$this->sessionData['body'] .= '<hr>';
1679 1678
 				}
1680
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1679
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
1681 1680
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1682 1681
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1683 1682
 				}
1684
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1683
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1685 1684
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1686 1685
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1687
-				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1686
+				$this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body'];
1688 1687
 			}
1689 1688
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1690 1689
 
1691 1690
 		} else {
1692
-			$this->sessionData['mimeType']	= 'plain';
1691
+			$this->sessionData['mimeType'] = 'plain';
1693 1692
 
1694
-			for($i=0; $i<count($bodyParts); $i++) {
1695
-				if($i>0) {
1693
+			for ($i = 0; $i < count($bodyParts); $i++) {
1694
+				if ($i > 0) {
1696 1695
 					$this->sessionData['body'] .= "<hr>";
1697 1696
 				}
1698
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1697
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1699 1698
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1700 1699
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1701
-				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
1700
+				$this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body'];
1702 1701
 			}
1703
-			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1702
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain');
1704 1703
 		}
1705 1704
 
1706
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1707
-			foreach($attachments as $attachment) {
1705
+		if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1706
+			foreach ($attachments as $attachment) {
1708 1707
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1709 1708
 				$cid = $attachment['cid'];
1710
-				$match=null;
1709
+				$match = null;
1711 1710
 				preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match);
1712 1711
 				//error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match));
1713 1712
 				if (!$match || !$attachment['cid'])
@@ -1727,7 +1726,7 @@  discard block
 block discarded – undo
1727 1726
 
1728 1727
 	function getErrorInfo()
1729 1728
 	{
1730
-		if(isset($this->errorInfo)) {
1729
+		if (isset($this->errorInfo)) {
1731 1730
 			$errorInfo = $this->errorInfo;
1732 1731
 			unset($this->errorInfo);
1733 1732
 			return $errorInfo;
@@ -1735,39 +1734,39 @@  discard block
 block discarded – undo
1735 1734
 		return false;
1736 1735
 	}
1737 1736
 
1738
-	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false)
1737
+	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false)
1739 1738
 	{
1740 1739
 		if ($_mode)
1741 1740
 		{
1742 1741
 			$modebuff = $this->mailPreferences['message_forwarding'];
1743 1742
 			$this->mailPreferences['message_forwarding'] = $_mode;
1744 1743
 		}
1745
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1744
+		if ($this->mailPreferences['message_forwarding'] == 'inline') {
1746 1745
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1747 1746
 		}
1748
-		$mail_bo    = $this->mail_bo;
1747
+		$mail_bo = $this->mail_bo;
1749 1748
 		$mail_bo->openConnection();
1750 1749
 		$mail_bo->reopen($_folder);
1751 1750
 
1752 1751
 		// get message headers for specified message
1753
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder);
1752
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder);
1754 1753
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1755 1754
 		//_debug_array($headers); exit;
1756 1755
 		// check for Re: in subject header
1757
-		$this->sessionData['subject'] 	= "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']);
1756
+		$this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']);
1758 1757
 		// the three attributes below are substituted by processedmail_id and mode
1759 1758
 		//$this->sessionData['sourceFolder']=$_folder;
1760 1759
 		//$this->sessionData['forwardFlag']='forwarded';
1761 1760
 		//$this->sessionData['forwardedUID']=$_uid;
1762
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1763
-			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1764
-			if($headers['SIZE'])
1761
+		if ($this->mailPreferences['message_forwarding'] == 'asmail') {
1762
+			$this->sessionData['mimeType'] = $this->mailPreferences['composeOptions'];
1763
+			if ($headers['SIZE'])
1765 1764
 				$size				= $headers['SIZE'];
1766 1765
 			else
1767 1766
 				$size				= lang('unknown');
1768 1767
 
1769 1768
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1770
-				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
1769
+				$mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml',
1771 1770
 				'MESSAGE/RFC822', $size);
1772 1771
 		}
1773 1772
 		else
@@ -1775,10 +1774,10 @@  discard block
 block discarded – undo
1775 1774
 			unset($this->sessionData['in-reply-to']);
1776 1775
 			unset($this->sessionData['to']);
1777 1776
 			unset($this->sessionData['cc']);
1778
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
1777
+			if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID, null, true, false, false))) {
1779 1778
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1780
-				foreach($attachments as $attachment) {
1781
-					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1779
+				foreach ($attachments as $attachment) {
1780
+					if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1782 1781
 					{
1783 1782
 						$this->addMessageAttachment($_uid, $attachment['partID'],
1784 1783
 							$_folder,
@@ -1807,7 +1806,7 @@  discard block
 block discarded – undo
1807 1806
 	 * @param array $_content the content passed to the function and to be modified
1808 1807
 	 * @return void
1809 1808
 	 */
1810
-	function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false)
1809
+	function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false)
1811 1810
 	{
1812 1811
 		//error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content));
1813 1812
 
@@ -1816,7 +1815,7 @@  discard block
 block discarded – undo
1816 1815
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
1817 1816
 		try
1818 1817
 		{
1819
-			$tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false);
1818
+			$tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false);
1820 1819
 		}
1821 1820
 		catch (Api\Exception\WrongUserinput $e)
1822 1821
 		{
@@ -1832,8 +1831,8 @@  discard block
 block discarded – undo
1832 1831
 			foreach ((array)$_content['attachments'] as $attach)
1833 1832
 			{
1834 1833
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1835
-					strtolower($_formData['type'])== strtolower($attach['type']) &&
1836
-					stripos($_formData['file'],'vfs://') !== false) return;
1834
+					strtolower($_formData['type']) == strtolower($attach['type']) &&
1835
+					stripos($_formData['file'], 'vfs://') !== false) return;
1837 1836
 			}
1838 1837
 		}
1839 1838
 		if ($attachfailed === false)
@@ -1845,7 +1844,7 @@  discard block
 block discarded – undo
1845 1844
 				'tmp_name'	=> $tmpFileName,
1846 1845
 				'size'	=> $_formData['size']
1847 1846
 			);
1848
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
1847
+			if (!is_array($_content['attachments'])) $_content['attachments'] = array();
1849 1848
 			$_content['attachments'][] = $buffer;
1850 1849
 			unset($buffer);
1851 1850
 		}
@@ -1855,9 +1854,9 @@  discard block
 block discarded – undo
1855 1854
 		}
1856 1855
 	}
1857 1856
 
1858
-	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail= null)
1857
+	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail = null)
1859 1858
 	{
1860
-		$this->sessionData['attachments'][]=array (
1859
+		$this->sessionData['attachments'][] = array(
1861 1860
 			'uid'		=> $_uid,
1862 1861
 			'partID'	=> $_partID,
1863 1862
 			'name'		=> $_name,
@@ -1865,7 +1864,7 @@  discard block
 block discarded – undo
1865 1864
 			'size'		=> $_size,
1866 1865
 			'folder'	=> $_folder,
1867 1866
 			'winmailFlag' => $_is_winmail,
1868
-			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1),
1867
+			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1),
1869 1868
 		);
1870 1869
 	}
1871 1870
 
@@ -1874,7 +1873,7 @@  discard block
 block discarded – undo
1874 1873
 		// read attachment data from etemplate request, use tmpname only to identify it
1875 1874
 		if (($request = Etemplate\Request::read($_GET['etemplate_exec_id'])))
1876 1875
 		{
1877
-			foreach($request->preserv['attachments'] as $attachment)
1876
+			foreach ($request->preserv['attachments'] as $attachment)
1878 1877
 			{
1879 1878
 				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
1880 1879
 			}
@@ -1886,7 +1885,7 @@  discard block
 block discarded – undo
1886 1885
 		}
1887 1886
 
1888 1887
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
1889
-		if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs')
1888
+		if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs')
1890 1889
 		{
1891 1890
 			Vfs::load_wrapper('vfs');
1892 1891
 		}
@@ -1895,7 +1894,7 @@  discard block
 block discarded – undo
1895 1894
 		{
1896 1895
 			$attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['tmp_name']);
1897 1896
 		}
1898
-		if(!file_exists($attachment['tmp_name']))
1897
+		if (!file_exists($attachment['tmp_name']))
1899 1898
 		{
1900 1899
 			header('HTTP/1.1 404 Not found');
1901 1900
 			die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!');
@@ -1908,7 +1907,7 @@  discard block
 block discarded – undo
1908 1907
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY')
1909 1908
 			{
1910 1909
 				$sfxMimeType = $attachment['type'];
1911
-				$buff = explode('.',$attachment['tmp_name']);
1910
+				$buff = explode('.', $attachment['tmp_name']);
1912 1911
 				$suffix = '';
1913 1912
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1914 1913
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -1920,10 +1919,10 @@  discard block
 block discarded – undo
1920 1919
 			{
1921 1920
 				//error_log(__METHOD__."about to call calendar_ical");
1922 1921
 				$calendar_ical = new calendar_ical();
1923
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1922
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
1924 1923
 				//error_log(__METHOD__.array2string($eventid));
1925 1924
 				if (!$eventid) $eventid = -1;
1926
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1925
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true);
1927 1926
 				//error_log(__METHOD__.$event);
1928 1927
 				if ((int)$event > 0)
1929 1928
 				{
@@ -1931,7 +1930,7 @@  discard block
 block discarded – undo
1931 1930
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
1932 1931
 						'cal_id'      => $event,
1933 1932
 					);
1934
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1933
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1935 1934
 				}
1936 1935
 				//Import failed, download content anyway
1937 1936
 			}
@@ -1946,13 +1945,13 @@  discard block
 block discarded – undo
1946 1945
 				{
1947 1946
 					$vcard['uid'] = trim($vcard['uid']);
1948 1947
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1949
-					$contact = $addressbook_vcal->find_contact($vcard,false);
1948
+					$contact = $addressbook_vcal->find_contact($vcard, false);
1950 1949
 				}
1951 1950
 				if (!$contact) $contact = null;
1952 1951
 				// 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))
1953
-				if ($contact || count($vcard)>2)
1952
+				if ($contact || count($vcard) > 2)
1954 1953
 				{
1955
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true);
1954
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ?array_shift($contact) : $contact), true);
1956 1955
 				}
1957 1956
 				if ((int)$contact > 0)
1958 1957
 				{
@@ -1960,13 +1959,13 @@  discard block
 block discarded – undo
1960 1959
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
1961 1960
 						'contact_id'	=> $contact,
1962 1961
 					);
1963
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1962
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1964 1963
 				}
1965 1964
 				//Import failed, download content anyway
1966 1965
 			}
1967 1966
 		}
1968 1967
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
1969
-		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
1968
+		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save");
1970 1969
 		echo $attachment['attachment'];
1971 1970
 
1972 1971
 		exit();
@@ -1979,11 +1978,11 @@  discard block
 block discarded – undo
1979 1978
 	 * @param string haystack
1980 1979
 	 * @return boolean
1981 1980
 	 */
1982
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
1981
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) {
1983 1982
 		foreach (array_keys($arrayToTestAgainst) as $k)
1984 1983
 		{
1985 1984
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
1986
-			if (stripos($haystack,$k)!==false)
1985
+			if (stripos($haystack, $k) !== false)
1987 1986
 			{
1988 1987
 				//error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace());
1989 1988
 				return true;
@@ -2006,10 +2005,10 @@  discard block
 block discarded – undo
2006 2005
 	 */
2007 2006
 	function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID)
2008 2007
 	{
2009
-		unset($_icServer);	// not used
2008
+		unset($_icServer); // not used
2010 2009
 		$foundAddresses = array();
2011 2010
 
2012
-		$mail_bo  = $this->mail_bo;
2011
+		$mail_bo = $this->mail_bo;
2013 2012
 		$mail_bo->openConnection();
2014 2013
 		$mail_bo->reopen($_folder);
2015 2014
 
@@ -2017,20 +2016,20 @@  discard block
 block discarded – undo
2017 2016
 
2018 2017
 		// get message headers for specified message
2019 2018
 		//print "AAAA: $_folder, $_uid, $_partID<br>";
2020
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true);
2019
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true);
2021 2020
 		//$headers	= $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder);
2022 2021
 		$this->sessionData['uid'] = $_uid;
2023 2022
 		$this->sessionData['messageFolder'] = $_folder;
2024
-		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']);
2025
-		$this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']);
2023
+		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']);
2024
+		$this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']);
2026 2025
 
2027 2026
 		// break reference into multiple lines if they're greater than 998 chars
2028 2027
 		// and remove comma seperation. Fix error serer does not support binary
2029 2028
 		// data due to long references.
2030
-		if (strlen($this->sessionData['references'])> 998)
2029
+		if (strlen($this->sessionData['references']) > 998)
2031 2030
 		{
2032
-			$temp_refs = explode(',',$this->sessionData['references']);
2033
-			$this->sessionData['references'] = implode(" ",$temp_refs);
2031
+			$temp_refs = explode(',', $this->sessionData['references']);
2032
+			$this->sessionData['references'] = implode(" ", $temp_refs);
2034 2033
 		}
2035 2034
 
2036 2035
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
@@ -2040,36 +2039,36 @@  discard block
 block discarded – undo
2040 2039
 		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2041 2040
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2042 2041
 		// check for Reply-To: header and use if available
2043
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2044
-			foreach($headers['REPLY-TO'] as $val) {
2045
-				if(!$foundAddresses[$val]) {
2042
+		if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2043
+			foreach ($headers['REPLY-TO'] as $val) {
2044
+				if (!$foundAddresses[$val]) {
2046 2045
 					$oldTo[] = $val;
2047 2046
 					$foundAddresses[$val] = true;
2048 2047
 				}
2049 2048
 			}
2050
-			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2049
+			$oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']);
2051 2050
 		} else {
2052
-			foreach($headers['FROM'] as $val) {
2053
-				if(!$foundAddresses[$val]) {
2051
+			foreach ($headers['FROM'] as $val) {
2052
+				if (!$foundAddresses[$val]) {
2054 2053
 					$oldTo[] = $val;
2055 2054
 					$foundAddresses[$val] = true;
2056 2055
 				}
2057 2056
 			}
2058
-			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2057
+			$oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']);
2059 2058
 		}
2060 2059
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2061
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2060
+		if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) {
2062 2061
 			$this->sessionData['to'] = $oldTo;
2063 2062
 		}
2064 2063
 
2065
-		if($_mode == 'all') {
2064
+		if ($_mode == 'all') {
2066 2065
 			// reply to any address which is cc, but not to my self
2067 2066
 			#if($headers->cc) {
2068
-				foreach($headers['CC'] as $val) {
2069
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2067
+				foreach ($headers['CC'] as $val) {
2068
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2070 2069
 						continue;
2071 2070
 					}
2072
-					if(!$foundAddresses[$val]) {
2071
+					if (!$foundAddresses[$val]) {
2073 2072
 						$this->sessionData['cc'][] = $val;
2074 2073
 						$foundAddresses[$val] = true;
2075 2074
 					}
@@ -2078,11 +2077,11 @@  discard block
 block discarded – undo
2078 2077
 
2079 2078
 			// reply to any address which is to, but not to my self
2080 2079
 			#if($headers->to) {
2081
-				foreach($headers['TO'] as $val) {
2082
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2080
+				foreach ($headers['TO'] as $val) {
2081
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2083 2082
 						continue;
2084 2083
 					}
2085
-					if(!$foundAddresses[$val]) {
2084
+					if (!$foundAddresses[$val]) {
2086 2085
 						$this->sessionData['to'][] = $val;
2087 2086
 						$foundAddresses[$val] = true;
2088 2087
 					}
@@ -2090,12 +2089,12 @@  discard block
 block discarded – undo
2090 2089
 			#}
2091 2090
 
2092 2091
 			#if($headers->from) {
2093
-				foreach($headers['FROM'] as $val) {
2094
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2092
+				foreach ($headers['FROM'] as $val) {
2093
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2095 2094
 						continue;
2096 2095
 					}
2097 2096
 					//error_log(__METHOD__.__LINE__.' '.$val);
2098
-					if(!$foundAddresses[$val]) {
2097
+					if (!$foundAddresses[$val]) {
2099 2098
 						$this->sessionData['to'][] = $val;
2100 2099
 						$foundAddresses[$val] = true;
2101 2100
 					}
@@ -2104,59 +2103,59 @@  discard block
 block discarded – undo
2104 2103
 		}
2105 2104
 
2106 2105
 		// check for Re: in subject header
2107
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2106
+		if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2108 2107
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2109 2108
 		} else {
2110
-			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2109
+			$this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']);
2111 2110
 		}
2112 2111
 
2113 2112
 		//_debug_array($headers);
2114 2113
 		//error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions']));
2115
-		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID);
2114
+		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID);
2116 2115
 		//_debug_array($bodyParts);
2117 2116
 		$styles = Mail::getStyles($bodyParts);
2118 2117
 
2119
-		$fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM']));
2118
+		$fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM']));
2120 2119
 
2121 2120
 		$toAddressA = array();
2122 2121
 		$toAddress = '';
2123 2122
 		foreach ($headers['TO'] as $mailheader) {
2124
-			$toAddressA[] =  $mailheader;
2123
+			$toAddressA[] = $mailheader;
2125 2124
 		}
2126
-		if (count($toAddressA)>0)
2125
+		if (count($toAddressA) > 0)
2127 2126
 		{
2128
-			$toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA));
2129
-			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2127
+			$toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA));
2128
+			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2130 2129
 		}
2131 2130
 		$ccAddressA = array();
2132 2131
 		$ccAddress = '';
2133 2132
 		foreach ($headers['CC'] as $mailheader) {
2134
-			$ccAddressA[] =  $mailheader;
2133
+			$ccAddressA[] = $mailheader;
2135 2134
 		}
2136
-		if (count($ccAddressA)>0)
2135
+		if (count($ccAddressA) > 0)
2137 2136
 		{
2138
-			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2139
-			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2137
+			$ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA));
2138
+			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2140 2139
 		}
2141
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2142
-			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2140
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
2141
+			$this->sessionData['body'] = /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2143 2142
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2144 2143
 				$toAddress.$ccAddress.
2145
-				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2144
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>".
2146 2145
 				'----------------------------------------------------------'."</div>";
2147
-			$this->sessionData['mimeType'] 	= 'html';
2146
+			$this->sessionData['mimeType'] = 'html';
2148 2147
 			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2149
-			$this->sessionData['body']	.= '<blockquote type="cite">';
2148
+			$this->sessionData['body'] .= '<blockquote type="cite">';
2150 2149
 
2151
-			for($i=0; $i<count($bodyParts); $i++) {
2152
-				if($i>0) {
2150
+			for ($i = 0; $i < count($bodyParts); $i++) {
2151
+				if ($i > 0) {
2153 2152
 					$this->sessionData['body'] .= '<hr>';
2154 2153
 				}
2155
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2154
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
2156 2155
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2157 2156
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2158 2157
 				}
2159
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2158
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2160 2159
 
2161 2160
 				$_htmlConfig = Mail::$htmLawed_config;
2162 2161
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2166,30 +2165,30 @@  discard block
 block discarded – undo
2166 2165
 				#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2167 2166
 			}
2168 2167
 
2169
-			$this->sessionData['body']	.= '</blockquote><br>';
2170
-			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2168
+			$this->sessionData['body'] .= '</blockquote><br>';
2169
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2171 2170
 		} else {
2172 2171
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2173 2172
 			// 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)
2174
-            $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2173
+            $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2175 2174
                 @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2176 2175
 				$toAddress.$ccAddress.
2177
-				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
2176
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n".
2178 2177
                 '-------------------------------------------------'."\r\n \r\n ";
2179
-			$this->sessionData['mimeType']	= 'plain';
2178
+			$this->sessionData['mimeType'] = 'plain';
2180 2179
 
2181
-			for($i=0; $i<count($bodyParts); $i++) {
2182
-				if($i>0) {
2180
+			for ($i = 0; $i < count($bodyParts); $i++) {
2181
+				if ($i > 0) {
2183 2182
 					$this->sessionData['body'] .= "<hr>";
2184 2183
 				}
2185 2184
 
2186 2185
 				// add line breaks to $bodyParts
2187
-				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
2186
+				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
2188 2187
 				#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2189 2188
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2190 2189
 				$this->sessionData['body'] .= "\r\n";
2191 2190
 				// create body new, with good line breaks and indention
2192
-				foreach(explode("\n",$newBody) as $value) {
2191
+				foreach (explode("\n", $newBody) as $value) {
2193 2192
 					// the explode is removing the character
2194 2193
 					if (trim($value) != '') {
2195 2194
 						#if ($value != "\r") $value .= "\n";
@@ -2197,12 +2196,12 @@  discard block
 block discarded – undo
2197 2196
 					$numberOfChars = strspn(trim($value), ">");
2198 2197
 					$appendString = str_repeat('>', $numberOfChars + 1);
2199 2198
 
2200
-					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2199
+					$bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>');
2201 2200
 
2202
-					if($bodyAppend[0] == '>') {
2203
-						$bodyAppend = '>'. $bodyAppend;
2201
+					if ($bodyAppend[0] == '>') {
2202
+						$bodyAppend = '>'.$bodyAppend;
2204 2203
 					} else {
2205
-						$bodyAppend = '> '. $bodyAppend;
2204
+						$bodyAppend = '> '.$bodyAppend;
2206 2205
 					}
2207 2206
 
2208 2207
 					$this->sessionData['body'] .= $bodyAppend;
@@ -2225,16 +2224,16 @@  discard block
 block discarded – undo
2225 2224
 	 */
2226 2225
 	static function _getCleanHTML($_body, $_useTidy = false)
2227 2226
 	{
2228
-		static $nonDisplayAbleCharacters = array('[\016]','[\017]',
2229
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2230
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2227
+		static $nonDisplayAbleCharacters = array('[\016]', '[\017]',
2228
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2229
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2231 2230
 
2232
-		if ($_useTidy && extension_loaded('tidy') )
2231
+		if ($_useTidy && extension_loaded('tidy'))
2233 2232
 		{
2234 2233
 			$tidy = new tidy();
2235
-			$cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8');
2234
+			$cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8');
2236 2235
 			// Found errors. Strip it all so there's some output
2237
-			if($tidy->getStatus() == 2)
2236
+			if ($tidy->getStatus() == 2)
2238 2237
 			{
2239 2238
 				error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
2240 2239
 			}
@@ -2268,13 +2267,13 @@  discard block
 block discarded – undo
2268 2267
 	 *
2269 2268
 	 * @return array returns found inline images as attachment structure
2270 2269
 	 */
2271
-	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
2270
+	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false)
2272 2271
 	{
2273 2272
 		if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----')
2274 2273
 		{
2275 2274
 			$_formData['mimeType'] = 'openpgp';
2276 2275
 		}
2277
-		$mail_bo	= $this->mail_bo;
2276
+		$mail_bo = $this->mail_bo;
2278 2277
 		$activeMailProfile = Mail\Account::read($this->mail_bo->profileID);
2279 2278
 
2280 2279
 		// you need to set the sender, if you work with different identities, since most smtp servers, dont allow
@@ -2283,37 +2282,37 @@  discard block
 block discarded – undo
2283 2282
 		{
2284 2283
 			error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity));
2285 2284
 		}
2286
-		$email_From =  $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
2285
+		$email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
2287 2286
 		// Try to fix identity email with no domain part set
2288 2287
 		$_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From),
2289
-			Mail::generateIdentityString($_identity,false));
2288
+			Mail::generateIdentityString($_identity, false));
2290 2289
 
2291 2290
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2292 2291
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2293
-		if(!empty($_formData['in-reply-to'])) {
2294
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2292
+		if (!empty($_formData['in-reply-to'])) {
2293
+			if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>';
2295 2294
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2296 2295
 		}
2297
-		if(!empty($_formData['references'])) {
2298
-			if (stripos($_formData['references'],'<')===false)
2296
+		if (!empty($_formData['references'])) {
2297
+			if (stripos($_formData['references'], '<') === false)
2299 2298
 			{
2300
-				$_formData['references']='<'.trim($_formData['references']).'>';
2299
+				$_formData['references'] = '<'.trim($_formData['references']).'>';
2301 2300
 			}
2302 2301
 			$_mailObject->addHeader('References', $_formData['references']);
2303 2302
 		}
2304 2303
 
2305
-		if(!empty($_formData['thread-index'])) {
2304
+		if (!empty($_formData['thread-index'])) {
2306 2305
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2307 2306
 		}
2308
-		if(!empty($_formData['list-id'])) {
2307
+		if (!empty($_formData['list-id'])) {
2309 2308
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2310 2309
 		}
2311
-		if($_formData['disposition']=='on') {
2310
+		if ($_formData['disposition'] == 'on') {
2312 2311
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2313 2312
 		}
2314 2313
 
2315 2314
 		// Expand any mailing lists
2316
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2315
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $field)
2317 2316
 		{
2318 2317
 			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2319 2318
 
@@ -2329,7 +2328,7 @@  discard block
 block discarded – undo
2329 2328
 		}
2330 2329
 		$disableRuler = false;
2331 2330
 		$signature = $_identity['ident_signature'];
2332
-		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0;
2331
+		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0;
2333 2332
 		if ($sigAlreadyThere)
2334 2333
 		{
2335 2334
 			// note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature
@@ -2338,7 +2337,7 @@  discard block
 block discarded – undo
2338 2337
 		}
2339 2338
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
2340 2339
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
2341
-			empty($signature) || trim($this->convertHTMLToText($signature)) =='')
2340
+			empty($signature) || trim($this->convertHTMLToText($signature)) == '')
2342 2341
 		{
2343 2342
 			$disableRuler = true;
2344 2343
 		}
@@ -2349,7 +2348,7 @@  discard block
 block discarded – undo
2349 2348
 				array_unique(array_merge((array)$_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc'])),
2350 2349
 				$_formData['expiration'], $_formData['password']);
2351 2350
 		}
2352
-		if($_formData['mimeType'] == 'html')
2351
+		if ($_formData['mimeType'] == 'html')
2353 2352
 		{
2354 2353
 			$body = $_formData['body'];
2355 2354
 			if ($attachment_links)
@@ -2363,13 +2362,13 @@  discard block
 block discarded – undo
2363 2362
 					$body .= $attachment_links;
2364 2363
 				}
2365 2364
 			}
2366
-			if(!empty($signature))
2365
+			if (!empty($signature))
2367 2366
 			{
2368 2367
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true).
2369 2368
 					($disableRuler ? "\r\n" : "\r\n-- \r\n").
2370 2369
 					$this->convertHTMLToText($signature, true, true));
2371 2370
 
2372
-				$body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature;
2371
+				$body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature;
2373 2372
 			}
2374 2373
 			else
2375 2374
 			{
@@ -2377,11 +2376,11 @@  discard block
 block discarded – undo
2377 2376
 			}
2378 2377
 			// convert URL Images to inline images - if possible
2379 2378
 			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2380
-			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2379
+			if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false)
2381 2380
 			{
2382
-				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
2381
+				$body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body);
2383 2382
 			}
2384
-			$_mailObject->setHtmlBody($body, null, false);	// false = no automatic alternative, we called setBody()
2383
+			$_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody()
2385 2384
 		}
2386 2385
 		elseif ($_formData['mimeType'] == 'openpgp')
2387 2386
 		{
@@ -2389,14 +2388,14 @@  discard block
 block discarded – undo
2389 2388
 		}
2390 2389
 		else
2391 2390
 		{
2392
-			$body = $this->convertHTMLToText($_formData['body'],false);
2391
+			$body = $this->convertHTMLToText($_formData['body'], false);
2393 2392
 
2394 2393
 			if ($attachment_links) $body .= $attachment_links;
2395 2394
 
2396 2395
 			#$_mailObject->Body = $_formData['body'];
2397
-			if(!empty($signature)) {
2398
-				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2399
-					$this->convertHTMLToText($signature,true,true);
2396
+			if (!empty($signature)) {
2397
+				$body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n").
2398
+					$this->convertHTMLToText($signature, true, true);
2400 2399
 			}
2401 2400
 			$_mailObject->setBody($body);
2402 2401
 		}
@@ -2405,8 +2404,8 @@  discard block
 block discarded – undo
2405 2404
 		{
2406 2405
 			$connection_opened = false;
2407 2406
 			$tnfattachments = null;
2408
-			foreach((array)$_formData['attachments'] as $attachment) {
2409
-				if(is_array($attachment))
2407
+			foreach ((array)$_formData['attachments'] as $attachment) {
2408
+				if (is_array($attachment))
2410 2409
 				{
2411 2410
 					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2412 2411
 						/* Example:
@@ -2424,20 +2423,20 @@  discard block
 block discarded – undo
2424 2423
 							$connection_opened = true;
2425 2424
 						}
2426 2425
 						$mail_bo->reopen($attachment['folder']);
2427
-						switch(strtoupper($attachment['type'])) {
2426
+						switch (strtoupper($attachment['type'])) {
2428 2427
 							case 'MESSAGE/RFC':
2429 2428
 							case 'MESSAGE/RFC822':
2430
-								$rawBody='';
2429
+								$rawBody = '';
2431 2430
 								if (isset($attachment['partID'])) {
2432
-									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2433
-									$rawBody=$eml['attachment'];
2431
+									$eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']);
2432
+									$rawBody = $eml['attachment'];
2434 2433
 								} else {
2435
-									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2434
+									$rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']);
2436 2435
 								}
2437 2436
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
2438 2437
 								break;
2439 2438
 							default:
2440
-								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2439
+								$attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false);
2441 2440
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2442 2441
 								{
2443 2442
 									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
@@ -2445,7 +2444,7 @@  discard block
 block discarded – undo
2445 2444
 									{
2446 2445
 										if ($k['name'] == $attachment['name'])
2447 2446
 										{
2448
-											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']);
2447
+											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']);
2449 2448
 											$attachmentData['attachment'] = $tnfpart['attachment'];
2450 2449
 											break;
2451 2450
 										}
@@ -2458,7 +2457,7 @@  discard block
 block discarded – undo
2458 2457
 					// attach files not for autosaving
2459 2458
 					elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving)
2460 2459
 					{
2461
-						if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
2460
+						if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs')
2462 2461
 						{
2463 2462
 							Vfs::load_wrapper('vfs');
2464 2463
 							$tmp_path = $attachment['file'];
@@ -2467,7 +2466,7 @@  discard block
 block discarded – undo
2467 2466
 						{
2468 2467
 							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['file']);
2469 2468
 						}
2470
-						$_mailObject->addAttachment (
2469
+						$_mailObject->addAttachment(
2471 2470
 							$tmp_path,
2472 2471
 							$attachment['name'],
2473 2472
 							$attachment['type']
@@ -2477,7 +2476,7 @@  discard block
 block discarded – undo
2477 2476
 			}
2478 2477
 			if ($connection_opened) $mail_bo->closeConnection();
2479 2478
 		}
2480
-		return is_array($inline_images)?$inline_images:array();
2479
+		return is_array($inline_images) ? $inline_images : array();
2481 2480
 	}
2482 2481
 
2483 2482
 	/**
@@ -2493,16 +2492,16 @@  discard block
 block discarded – undo
2493 2492
 	 * @param string $password =null
2494 2493
 	 * @return string might be empty if no file attachments found
2495 2494
 	 */
2496
-	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2495
+	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null)
2497 2496
 	{
2498 2497
 		if ($filemode == Vfs\Sharing::ATTACH) return '';
2499 2498
 
2500 2499
 		$links = array();
2501
-		foreach($attachments as $attachment)
2500
+		foreach ($attachments as $attachment)
2502 2501
 		{
2503 2502
 			$path = $attachment['file'];
2504
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2505
-			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2503
+			if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts
2504
+			if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs')
2506 2505
 			{
2507 2506
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
2508 2507
 			}
@@ -2532,7 +2531,7 @@  discard block
 block discarded – undo
2532 2531
 		}
2533 2532
 		if (!$links)
2534 2533
 		{
2535
-			return null;	// no file attachments found
2534
+			return null; // no file attachments found
2536 2535
 		}
2537 2536
 		elseif ($html)
2538 2537
 		{
@@ -2547,7 +2546,7 @@  discard block
 block discarded – undo
2547 2546
 	 * @param array $content content sent from client-side
2548 2547
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2549 2548
 	 */
2550
-	public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
2549
+	public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]')
2551 2550
 	{
2552 2551
 		//error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)");
2553 2552
 		$response = Api\Json\Response::get();
@@ -2561,8 +2560,8 @@  discard block
 block discarded – undo
2561 2560
 
2562 2561
 		$formData = array_merge($content, array(
2563 2562
 			'isDrafted' => 1,
2564
-			'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')],
2565
-			'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value
2563
+			'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')],
2564
+			'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value
2566 2565
 		));
2567 2566
 
2568 2567
 		//Saving draft procedure
@@ -2574,8 +2573,8 @@  discard block
 block discarded – undo
2574 2573
 			if (($messageUid = $this->saveAsDraft($formData, $folder, $action)))
2575 2574
 			{
2576 2575
 				// saving as draft, does not mean closing the message
2577
-				$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
2578
-				if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder)))
2576
+				$messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid);
2577
+				if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder)))
2579 2578
 				{
2580 2579
 					$draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid);
2581 2580
 					if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted']))
@@ -2584,7 +2583,7 @@  discard block
 block discarded – undo
2584 2583
 						$duid = $dhA['msgUID'];
2585 2584
 						$dmailbox = $dhA['folder'];
2586 2585
 						// beware: do not delete the original mail as found in processedmail_id
2587
-						$pMuid='';
2586
+						$pMuid = '';
2588 2587
 						if ($content['processedmail_id'])
2589 2588
 						{
2590 2589
 							$pMhA = mail_ui::splitRowID($content['processedmail_id']);
@@ -2592,15 +2591,15 @@  discard block
 block discarded – undo
2592 2591
 						}
2593 2592
 						//error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments']));
2594 2593
 						// do not delete the original message if attachments are present
2595
-						if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments']))
2594
+						if (empty($pMuid) || $pMuid != $duid || empty($content['attachments']))
2596 2595
 						{
2597 2596
 							try
2598 2597
 							{
2599
-								$this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately');
2598
+								$this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately');
2600 2599
 							}
2601 2600
 							catch (Api\Exception $e)
2602 2601
 							{
2603
-								$msg = str_replace('"',"'",$e->getMessage());
2602
+								$msg = str_replace('"', "'", $e->getMessage());
2604 2603
 								$success = false;
2605 2604
 								error_log(__METHOD__.__LINE__.$msg);
2606 2605
 							}
@@ -2621,7 +2620,7 @@  discard block
 block discarded – undo
2621 2620
 		}
2622 2621
 		catch (Api\Exception\WrongUserinput $e)
2623 2622
 		{
2624
-			$msg = str_replace('"',"'",$e->getMessage());
2623
+			$msg = str_replace('"', "'", $e->getMessage());
2625 2624
 			error_log(__METHOD__.__LINE__.$msg);
2626 2625
 			$success = false;
2627 2626
 		}
@@ -2645,17 +2644,17 @@  discard block
 block discarded – undo
2645 2644
 	static function resolveEmailAddressList($_emailAddressList)
2646 2645
 	{
2647 2646
 		$contacts_obs = null;
2648
-		$addrFromList=array();
2649
-		foreach((array)$_emailAddressList as $ak => $address)
2647
+		$addrFromList = array();
2648
+		foreach ((array)$_emailAddressList as $ak => $address)
2650 2649
 		{
2651
-			if(is_int($address))
2650
+			if (is_int($address))
2652 2651
 			{
2653 2652
 				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
2654 2653
 				// List was selected, expand to addresses
2655 2654
 				unset($_emailAddressList[$ak]);
2656
-				$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));
2655
+				$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));
2657 2656
 				// Just add email addresses, they'll be checked below
2658
-				foreach($list as $email)
2657
+				foreach ($list as $email)
2659 2658
 				{
2660 2659
 					$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
2661 2660
 				}
@@ -2665,7 +2664,7 @@  discard block
 block discarded – undo
2665 2664
 		{
2666 2665
 			foreach ($addrFromList as $addr)
2667 2666
 			{
2668
-				if (!empty($addr)) $_emailAddressList[]=$addr;
2667
+				if (!empty($addr)) $_emailAddressList[] = $addr;
2669 2668
 			}
2670 2669
 		}
2671 2670
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2679,15 +2678,15 @@  discard block
 block discarded – undo
2679 2678
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2680 2679
 	 * @return boolean return messageUID| false due to an error
2681 2680
 	 */
2682
-	function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]')
2681
+	function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]')
2683 2682
 	{
2684 2683
 		//error_log(__METHOD__."(..., $savingDestination, action=$action)");
2685
-		$mail_bo	= $this->mail_bo;
2686
-		$mail		= new Api\Mailer($this->mail_bo->profileID);
2684
+		$mail_bo = $this->mail_bo;
2685
+		$mail = new Api\Mailer($this->mail_bo->profileID);
2687 2686
 
2688 2687
 		// preserve the bcc and if possible the save to folder information
2689
-		$this->sessionData['folder']    = $_formData['folder'];
2690
-		$this->sessionData['bcc']   = $_formData['bcc'];
2688
+		$this->sessionData['folder'] = $_formData['folder'];
2689
+		$this->sessionData['bcc'] = $_formData['bcc'];
2691 2690
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2692 2691
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2693 2692
 		$this->sessionData['mailaccount']  = $_formData['mailaccount'];
@@ -2696,11 +2695,11 @@  discard block
 block discarded – undo
2696 2695
 		{
2697 2696
 			$acc = Mail\Account::read($this->sessionData['mailaccount']);
2698 2697
 			//error_log(__METHOD__.__LINE__.array2string($acc));
2699
-			$identity = Mail\Account::read_identity($acc['ident_id'],true);
2698
+			$identity = Mail\Account::read_identity($acc['ident_id'], true);
2700 2699
 		}
2701 2700
 		catch (Exception $e)
2702 2701
 		{
2703
-			$identity=array();
2702
+			$identity = array();
2704 2703
 		}
2705 2704
 
2706 2705
 		$flags = '\\Seen \\Draft';
@@ -2710,7 +2709,7 @@  discard block
 block discarded – undo
2710 2709
 		// folder list as Customheader
2711 2710
 		if (!empty($this->sessionData['folder']))
2712 2711
 		{
2713
-			$folders = implode('|',array_unique($this->sessionData['folder']));
2712
+			$folders = implode('|', array_unique($this->sessionData['folder']));
2714 2713
 			$mail->addHeader('X-Mailfolder', $folders);
2715 2714
 		}
2716 2715
 		$mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']);
@@ -2730,25 +2729,25 @@  discard block
 block discarded – undo
2730 2729
 			$savingDestination = $this->sessionData['messageFolder'];
2731 2730
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2732 2731
 		}
2733
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
2732
+		if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder();
2734 2733
 
2735 2734
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2736 2735
 		$mail->forceBccHeader();
2737 2736
 
2738 2737
 		$mail_bo->openConnection();
2739
-		if ($mail_bo->folderExists($savingDestination,true)) {
2738
+		if ($mail_bo->folderExists($savingDestination, true)) {
2740 2739
 			try
2741 2740
 			{
2742 2741
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
2743 2742
 			}
2744 2743
 			catch (Api\Exception\WrongUserinput $e)
2745 2744
 			{
2746
-				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage()));
2745
+				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage()));
2747 2746
 				return false;
2748 2747
 			}
2749 2748
 
2750 2749
 		} else {
2751
-			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2750
+			error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server."));
2752 2751
 			return false;
2753 2752
 		}
2754 2753
 		$mail_bo->closeConnection();
@@ -2757,26 +2756,26 @@  discard block
 block discarded – undo
2757 2756
 
2758 2757
 	function send($_formData)
2759 2758
 	{
2760
-		$mail_bo	= $this->mail_bo;
2761
-		$mail 		= new Api\Mailer($mail_bo->profileID);
2762
-		$messageIsDraft	=  false;
2759
+		$mail_bo = $this->mail_bo;
2760
+		$mail = new Api\Mailer($mail_bo->profileID);
2761
+		$messageIsDraft = false;
2763 2762
 
2764
-		$this->sessionData['mailaccount']	= $_formData['mailaccount'];
2763
+		$this->sessionData['mailaccount'] = $_formData['mailaccount'];
2765 2764
 		$this->sessionData['to']	= self::resolveEmailAddressList($_formData['to']);
2766 2765
 		$this->sessionData['cc']	= self::resolveEmailAddressList($_formData['cc']);
2767
-		$this->sessionData['bcc']	= self::resolveEmailAddressList($_formData['bcc']);
2768
-		$this->sessionData['folder']	= $_formData['folder'];
2766
+		$this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']);
2767
+		$this->sessionData['folder'] = $_formData['folder'];
2769 2768
 		$this->sessionData['replyto']	= $_formData['replyto'];
2770 2769
 		$this->sessionData['subject']	= trim($_formData['subject']);
2771
-		$this->sessionData['body']	= $_formData['body'];
2772
-		$this->sessionData['priority']	= $_formData['priority'];
2770
+		$this->sessionData['body'] = $_formData['body'];
2771
+		$this->sessionData['priority'] = $_formData['priority'];
2773 2772
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2774 2773
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2775 2774
 		$this->sessionData['disposition'] = $_formData['disposition'];
2776
-		$this->sessionData['mimeType']	= $_formData['mimeType'];
2775
+		$this->sessionData['mimeType'] = $_formData['mimeType'];
2777 2776
 		$this->sessionData['to_infolog'] = $_formData['to_infolog'];
2778 2777
 		$this->sessionData['to_tracker'] = $_formData['to_tracker'];
2779
-		$this->sessionData['attachments']  = $_formData['attachments'];
2778
+		$this->sessionData['attachments'] = $_formData['attachments'];
2780 2779
 
2781 2780
 		if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted']))
2782 2781
 		{
@@ -2785,11 +2784,11 @@  discard block
 block discarded – undo
2785 2784
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']);
2786 2785
 		if (isset($_formData['mode']) && !empty($_formData['mode']))
2787 2786
 		{
2788
-			if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id']))
2787
+			if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id']))
2789 2788
 			{
2790
-				$this->sessionData['forwardFlag']='forwarded';
2791
-				$_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']);
2792
-				$this->sessionData['uid']=array();
2789
+				$this->sessionData['forwardFlag'] = 'forwarded';
2790
+				$_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']);
2791
+				$this->sessionData['uid'] = array();
2793 2792
 				foreach ($_formData['processedmail_id'] as $k =>$rowid)
2794 2793
 				{
2795 2794
 					$fhA = mail_ui::splitRowID($rowid);
@@ -2798,13 +2797,13 @@  discard block
 block discarded – undo
2798 2797
 					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
2799 2798
 				}
2800 2799
 			}
2801
-			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
2800
+			if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id']))
2802 2801
 			{
2803 2802
 				$rhA = mail_ui::splitRowID($_formData['processedmail_id']);
2804 2803
 				$this->sessionData['uid'] = $rhA['msgUID'];
2805 2804
 				$this->sessionData['messageFolder'] = $rhA['folder'];
2806 2805
 			}
2807
-			if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id']))
2806
+			if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id']))
2808 2807
 			{
2809 2808
 				$dhA = mail_ui::splitRowID($_formData['processedmail_id']);
2810 2809
 				$this->sessionData['uid'] = $dhA['msgUID'];
@@ -2813,26 +2812,26 @@  discard block
 block discarded – undo
2813 2812
 		}
2814 2813
 		// if the body is empty, maybe someone pasted something with scripts, into the message body
2815 2814
 		// this should not happen anymore, unless you call send directly, since the check was introduced with the action command
2816
-		if(empty($this->sessionData['body']))
2815
+		if (empty($this->sessionData['body']))
2817 2816
 		{
2818 2817
 			// this is to be found with the egw_unset_vars array for the _POST['body'] array
2819
-			$name='_POST';
2820
-			$key='body';
2818
+			$name = '_POST';
2819
+			$key = 'body';
2821 2820
 			#error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2822 2821
 			if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']']))
2823 2822
 			{
2824
-				$this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2825
-				$_formData['body']=$this->sessionData['body'];
2823
+				$this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2824
+				$_formData['body'] = $this->sessionData['body'];
2826 2825
 			}
2827 2826
 			#error_log($this->sessionData['body']);
2828 2827
 		}
2829
-		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2828
+		if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2830 2829
 		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
2831 2830
 		   	$messageIsDraft = true;
2832 2831
 		}
2833 2832
 		try
2834 2833
 		{
2835
-			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true);
2834
+			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true);
2836 2835
 		}
2837 2836
 		catch (Exception $e)
2838 2837
 		{
@@ -2843,7 +2842,7 @@  discard block
 block discarded – undo
2843 2842
 		// create the messages and store inline images
2844 2843
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2845 2844
 		// remember the identity
2846
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2845
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2847 2846
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2848 2847
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2849 2848
 		#exit;
@@ -2854,12 +2853,12 @@  discard block
 block discarded – undo
2854 2853
 		$folderOnMailAccount = array();
2855 2854
 		foreach ($folderToCheck as $k => $f)
2856 2855
 		{
2857
-			$fval=$f;
2858
-			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2859
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
2860
-			if ($_formData['serverID']!=$_formData['mailaccount'])
2856
+			$fval = $f;
2857
+			$icServerID = $_formData['serverID']; //folders always assumed with serverID
2858
+			if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2);
2859
+			if ($_formData['serverID'] != $_formData['mailaccount'])
2861 2860
 			{
2862
-				if ($icServerID == $_formData['serverID'] )
2861
+				if ($icServerID == $_formData['serverID'])
2863 2862
 				{
2864 2863
 					$folder[$fval] = $fval;
2865 2864
 					$folderOnServerID[] = $fval;
@@ -2872,7 +2871,7 @@  discard block
 block discarded – undo
2872 2871
 			}
2873 2872
 			else
2874 2873
 			{
2875
-				if ($icServerID == $_formData['serverID'] )
2874
+				if ($icServerID == $_formData['serverID'])
2876 2875
 				{
2877 2876
 					$folder[$fval] = $fval;
2878 2877
 					$folderOnServerID[] = $fval;
@@ -2889,7 +2888,7 @@  discard block
 block discarded – undo
2889 2888
 		// we use the sentFolder settings of the choosen mailaccount
2890 2889
 		// sentFolder is account specific
2891 2890
 		$changeProfileOnSentFolderNeeded = false;
2892
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2891
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2893 2892
 		{
2894 2893
 			$this->changeProfile($_formData['mailaccount']);
2895 2894
 			//error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#');
@@ -2897,30 +2896,30 @@  discard block
 block discarded – undo
2897 2896
 			// sentFolder is account specific
2898 2897
 			$sentFolder = $this->mail_bo->getSentFolder();
2899 2898
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2900
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2899
+			if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2901 2900
 		}
2902 2901
 		else
2903 2902
 		{
2904 2903
 			$sentFolder = $mail_bo->getSentFolder();
2905 2904
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2906
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2905
+			if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2907 2906
 		}
2908 2907
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2909 2908
 
2910 2909
 		// we switch $this->mail_bo back to the account we used to work on
2911
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2910
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2912 2911
 		{
2913 2912
 			$this->changeProfile($_formData['serverID']);
2914 2913
 		}
2915 2914
 
2916 2915
 
2917
-		if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2916
+		if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2918 2917
 			$this->mailPreferences['sendOptions'] != 'send_only' &&
2919 2918
 			$messageIsDraft == false)
2920 2919
 		{
2921 2920
 			if ($sentFolder)
2922 2921
 			{
2923
-				if ($_formData['serverID']!=$_formData['mailaccount'])
2922
+				if ($_formData['serverID'] != $_formData['mailaccount'])
2924 2923
 				{
2925 2924
 					$folderOnMailAccount[] = $sentFolder;
2926 2925
 				}
@@ -2937,14 +2936,14 @@  discard block
 block discarded – undo
2937 2936
 		}
2938 2937
 		else
2939 2938
 		{
2940
-			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2939
+			if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2941 2940
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2942 2941
 				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
2943 2942
 		}
2944 2943
 		// draftFolder is on Server we start from
2945
-		if($messageIsDraft == true) {
2944
+		if ($messageIsDraft == true) {
2946 2945
 			$draftFolder = $mail_bo->getDraftFolder();
2947
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
2946
+			if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) {
2948 2947
 				$this->sessionData['folder'] = array($draftFolder);
2949 2948
 				$folderOnServerID[] = $draftFolder;
2950 2949
 				$folder[$draftFolder] = $draftFolder;
@@ -2953,10 +2952,10 @@  discard block
 block discarded – undo
2953 2952
 		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2954 2953
 		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
2955 2954
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2956
-			!( count($folder) > 0) &&
2957
-			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
2955
+			!(count($folder) > 0) &&
2956
+			!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on'))
2958 2957
 		{
2959
-			$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:'');
2958
+			$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 : '');
2960 2959
 			#error_log($this->errorInfo);
2961 2960
 			return false;
2962 2961
 		}
@@ -2965,18 +2964,18 @@  discard block
 block discarded – undo
2965 2964
 		@set_time_limit(120);
2966 2965
 		//$mail->SMTPDebug = 10;
2967 2966
 		//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']));
2968
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2967
+		if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2969 2968
 			try {
2970 2969
 				$mail->send();
2971 2970
 			}
2972
-			catch(Exception $e) {
2971
+			catch (Exception $e) {
2973 2972
 				_egw_log_exception($e);
2974 2973
 				//if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details));
2975
-				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2974
+				$this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : '');
2976 2975
 				return false;
2977 2976
 			}
2978 2977
 		} else {
2979
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
2978
+			if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) {
2980 2979
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2981 2980
 			} else {
2982 2981
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
@@ -3004,15 +3003,15 @@  discard block
 block discarded – undo
3004 3003
 		// copying mail to folder
3005 3004
 		if (count($folder) > 0)
3006 3005
 		{
3007
-			foreach($folderOnServerID as $folderName) {
3006
+			foreach ($folderOnServerID as $folderName) {
3008 3007
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3009 3008
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3010 3009
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3011 3010
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3012
-				if ($mail_bo->folderExists($folderName,true)) {
3013
-					if($mail_bo->isSentFolder($folderName)) {
3011
+				if ($mail_bo->folderExists($folderName, true)) {
3012
+					if ($mail_bo->isSentFolder($folderName)) {
3014 3013
 						$flags = '\\Seen';
3015
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3014
+					} elseif ($mail_bo->isDraftFolder($folderName)) {
3016 3015
 						$flags = '\\Draft';
3017 3016
 					} else {
3018 3017
 						$flags = '\\Seen';
@@ -3028,25 +3027,25 @@  discard block
 block discarded – undo
3028 3027
 					}
3029 3028
 					catch (Api\Exception\WrongUserinput $e)
3030 3029
 					{
3031
-						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()));
3030
+						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()));
3032 3031
 					}
3033 3032
 				}
3034 3033
 				else
3035 3034
 				{
3036
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3035
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3037 3036
 				}
3038 3037
 			}
3039 3038
 			// if we choose to send from a differing profile
3040 3039
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3041
-			foreach($folderOnMailAccount as $folderName) {
3040
+			foreach ($folderOnMailAccount as $folderName) {
3042 3041
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3043 3042
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3044 3043
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3045 3044
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3046
-				if ($this->mail_bo->folderExists($folderName,true)) {
3047
-					if($this->mail_bo->isSentFolder($folderName)) {
3045
+				if ($this->mail_bo->folderExists($folderName, true)) {
3046
+					if ($this->mail_bo->isSentFolder($folderName)) {
3048 3047
 						$flags = '\\Seen';
3049
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3048
+					} elseif ($this->mail_bo->isDraftFolder($folderName)) {
3050 3049
 						$flags = '\\Draft';
3051 3050
 					} else {
3052 3051
 						$flags = '\\Seen';
@@ -3062,12 +3061,12 @@  discard block
 block discarded – undo
3062 3061
 					}
3063 3062
 					catch (Api\Exception\WrongUserinput $e)
3064 3063
 					{
3065
-						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()));
3064
+						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()));
3066 3065
 					}
3067 3066
 				}
3068 3067
 				else
3069 3068
 				{
3070
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3069
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3071 3070
 				}
3072 3071
 			}
3073 3072
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
@@ -3078,27 +3077,27 @@  discard block
 block discarded – undo
3078 3077
 		$lastDrafted = false;
3079 3078
 		if (isset($this->sessionData['lastDrafted']))
3080 3079
 		{
3081
-			$lastDrafted=array();
3080
+			$lastDrafted = array();
3082 3081
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3083 3082
 			$lastDrafted['uid'] = $dhA['msgUID'];
3084 3083
 			$lastDrafted['folder'] = $dhA['folder'];
3085
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3084
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']);
3086 3085
 			// manually drafted, do not delete
3087 3086
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3088
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3087
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false;
3089 3088
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3090 3089
 		}
3091 3090
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
3092 3091
 		{
3093 3092
 			try
3094 3093
 			{
3095
-				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' &&
3096
-					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments']))
3094
+				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' &&
3095
+					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3097 3096
 				{
3098 3097
 					//error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData));
3099 3098
 					//error_log(__METHOD__.__LINE__."#".array2string($_formData));
3100 3099
 					//error_log(__METHOD__.__LINE__."#".array2string($this->sessionData));
3101
-					$mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately');
3100
+					$mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately');
3102 3101
 				}
3103 3102
 			}
3104 3103
 			catch (Api\Exception $e)
@@ -3110,22 +3109,22 @@  discard block
 block discarded – undo
3110 3109
 		unset($this->sessionData['lastDrafted']);
3111 3110
 
3112 3111
 		//error_log("handling draft messages, flagging and such");
3113
-		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3112
+		if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3114 3113
 			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3115 3114
 			// mark message as answered
3116 3115
 			$mail_bo->openConnection();
3117
-			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3116
+			$mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3118 3117
 			// if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send
3119 3118
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
3120 3119
 			if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder']))
3121 3120
 			{
3122 3121
 				try // message may be deleted already, as it maybe done by autosave
3123 3122
 				{
3124
-					if ($_formData['mode']=='composefromdraft' &&
3123
+					if ($_formData['mode'] == 'composefromdraft' &&
3125 3124
 						!(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3126 3125
 					{
3127 3126
 						//error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']);
3128
-						$mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']);
3127
+						$mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder']);
3129 3128
 					}
3130 3129
 				}
3131 3130
 				catch (Api\Exception $e)
@@ -3134,14 +3133,14 @@  discard block
 block discarded – undo
3134 3133
 					unset($e);
3135 3134
 				}
3136 3135
 			} else {
3137
-				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3136
+				$mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3138 3137
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3139
-				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
3138
+				if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded')
3140 3139
 				{
3141 3140
 					try
3142 3141
 					{
3143 3142
 						//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3144
-						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']);
3143
+						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']);
3145 3144
 					}
3146 3145
 					catch (Api\Exception $e)
3147 3146
 					{
@@ -3169,49 +3168,49 @@  discard block
 block discarded – undo
3169 3168
 		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3170 3169
 		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3171 3170
 
3172
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3171
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on')
3173 3172
 		{
3174 3173
 			$this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images);
3175 3174
 
3176
-			foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
3175
+			foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key)
3177 3176
 			{
3178 3177
 				$entryid = $_formData['to_integrate_ids'][0][$app_key];
3179 3178
 				if ($_formData[$app_key] == 'on')
3180 3179
 				{
3181
-					$app_name = substr($app_key,3);
3180
+					$app_name = substr($app_key, 3);
3182 3181
 					// Get registered hook data of the app called for integration
3183
-					$hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name);
3182
+					$hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name);
3184 3183
 
3185 3184
 					// store mail / eml in temp. file to not have to download it from mail-server again
3186
-					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
3185
+					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate');
3187 3186
 					$eml_fp = fopen($eml, 'w');
3188 3187
 					stream_copy_to_stream($mail->getRaw(), $eml_fp);
3189 3188
 					fclose($eml_fp);
3190 3189
 					$target = array(
3191 3190
 						'menuaction' => $hook['menuaction'],
3192
-						'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
3191
+						'egw_data' => Link::set_data(null, 'mail_integration::integrate', array(
3193 3192
 							$mailaddresses,
3194 3193
 							$this->sessionData['subject'],
3195 3194
 							$this->convertHTMLToText($this->sessionData['body']),
3196 3195
 							$this->sessionData['attachments'],
3197 3196
 							false, // date
3198 3197
 							$eml,
3199
-							$_formData['serverID']),true),
3198
+							$_formData['serverID']), true),
3200 3199
 						'app' => $app_name
3201 3200
 					);
3202 3201
 					if ($entryid) $target['entry_id'] = $entryid;
3203 3202
 					// Open the app called for integration in a popup
3204 3203
 					// and store the mail raw data as egw_data, in order to
3205 3204
 					// be stored from registered app method later
3206
-					Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']);
3205
+					Framework::popup(Egw::link('/index.php', $target), '_blank', $hook['popup']);
3207 3206
 				}
3208 3207
 			}
3209 3208
 		}
3210 3209
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3211
-		elseif(is_array($this->sessionData['attachments']))
3210
+		elseif (is_array($this->sessionData['attachments']))
3212 3211
 		{
3213
-			foreach($this->sessionData['attachments'] as $value) {
3214
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3212
+			foreach ($this->sessionData['attachments'] as $value) {
3213
+				if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3215 3214
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3216 3215
 				}
3217 3216
 			}
@@ -3228,7 +3227,7 @@  discard block
 block discarded – undo
3228 3227
 	 * @param array $content
3229 3228
 	 * @return array - the input, enriched with some not set attributes
3230 3229
 	 */
3231
-	function setDefaults($content=array())
3230
+	function setDefaults($content = array())
3232 3231
 	{
3233 3232
 		// if there's not already an identity selected for current account
3234 3233
 		if (empty($content['mailidentity']))
@@ -3237,7 +3236,7 @@  discard block
 block discarded – undo
3237 3236
 			if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
3238 3237
 			{
3239 3238
 				$sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'];
3240
-				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0)
3239
+				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0)
3241 3240
 				{
3242 3241
 					$content['mailidentity'] = $sigPref[$this->mail_bo->profileID];
3243 3242
 				}
@@ -3246,7 +3245,7 @@  discard block
 block discarded – undo
3246 3245
 			if (empty($content['mailidentity']))
3247 3246
 			{
3248 3247
 				$default_identity = null;
3249
-				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3248
+				foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3250 3249
 				{
3251 3250
 					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3252 3251
 					if (!empty($identity['ident_signature']))
@@ -3261,7 +3260,7 @@  discard block
 block discarded – undo
3261 3260
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3262 3261
 		{
3263 3262
 			$content['mimeType'] = 'html';
3264
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3263
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain';
3265 3264
 		}
3266 3265
 		return $content;
3267 3266
 
@@ -3284,7 +3283,7 @@  discard block
 block discarded – undo
3284 3283
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3285 3284
 	 * @return type
3286 3285
 	 */
3287
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3286
+	function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) {
3288 3287
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3289 3288
 		static $useCacheIfPossible = null;
3290 3289
 		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
@@ -3297,36 +3296,36 @@  discard block
 block discarded – undo
3297 3296
 		{
3298 3297
 			$this->changeProfile($_mailaccountToSearch);
3299 3298
 		}
3300
-		if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer))
3299
+		if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer))
3301 3300
 		{
3302 3301
 			//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
3303 3302
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3304 3303
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3305
-			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3306
-			if (count($folderObjects)<=1) {
3304
+			$folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible);
3305
+			if (count($folderObjects) <= 1) {
3307 3306
 				$useCacheIfPossible = false;
3308 3307
 			}
3309 3308
 			else
3310 3309
 			{
3311 3310
 				$useCacheIfPossible = true;
3312 3311
 			}
3313
-			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
3312
+			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP');
3314 3313
 			foreach ($folderObjects as $k =>$fA)
3315 3314
 			{
3316 3315
 				//error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
3317
-				$f=false;
3318
-				$key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k;
3319
-				if ($_searchStringLength<=0)
3316
+				$f = false;
3317
+				$key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k;
3318
+				if ($_searchStringLength <= 0)
3320 3319
 				{
3321
-					$f=true;
3320
+					$f = true;
3322 3321
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3323 3322
 				}
3324
-				if ($f==false && stripos($fA->displayName,$_searchString)!==false)
3323
+				if ($f == false && stripos($fA->displayName, $_searchString) !== false)
3325 3324
 				{
3326
-					$f=true;
3325
+					$f = true;
3327 3326
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3328 3327
 				}
3329
-				if ($f==false && stripos($k,$searchString)!==false)
3328
+				if ($f == false && stripos($k, $searchString) !== false)
3330 3329
 				{
3331 3330
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3332 3331
 				}
@@ -3354,7 +3353,7 @@  discard block
 block discarded – undo
3354 3353
 		exit();
3355 3354
 	}
3356 3355
 
3357
-	public static function ajax_searchAddress($_searchStringLength=2) {
3356
+	public static function ajax_searchAddress($_searchStringLength = 2) {
3358 3357
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3359 3358
 		$_searchString = trim($_REQUEST['query']);
3360 3359
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3363,7 +3362,7 @@  discard block
 block discarded – undo
3363 3362
 		$results = array();
3364 3363
 
3365 3364
 		// Add up to 5 matching mailing lists
3366
-		if($include_lists)
3365
+		if ($include_lists)
3367 3366
 		{
3368 3367
 			$lists = array_filter(
3369 3368
 				$contacts_obj->get_lists(Acl::READ),
@@ -3372,7 +3371,7 @@  discard block
 block discarded – undo
3372 3371
 				}
3373 3372
 			);
3374 3373
 			$list_count = 0;
3375
-			foreach($lists as $key => $list_name)
3374
+			foreach ($lists as $key => $list_name)
3376 3375
 			{
3377 3376
 				$results[] = array(
3378 3377
 					'id'	=> $key,
@@ -3382,11 +3381,11 @@  discard block
 block discarded – undo
3382 3381
 					'title' => lang('Mailinglist'),
3383 3382
 					'data'	=> $key
3384 3383
 				);
3385
-				if($list_count++ > 5) break;
3384
+				if ($list_count++ > 5) break;
3386 3385
 			}
3387 3386
 		}
3388 3387
 
3389
-		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength)
3388
+		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength)
3390 3389
 		{
3391 3390
 			//error_log(__METHOD__.__LINE__.array2string($_searchString));
3392 3391
 			$showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']);
@@ -3395,64 +3394,64 @@  discard block
 block discarded – undo
3395 3394
 			{
3396 3395
 				if (mb_strlen($v) < 3) unset($search[$k]);
3397 3396
 			}
3398
-			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3397
+			$search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns
3399 3398
 			//error_log(__METHOD__.__LINE__.$_searchString);
3400 3399
 			$filter = $showAccounts ? array() : array('account_id' => null);
3401
-			$filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home');
3402
-			$cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home');
3403
-			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter);
3400
+			$filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3401
+			$cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3402
+			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3404 3403
 			// additionally search the accounts, if the contact storage is not the account storage
3405 3404
 			if ($showAccounts && $contacts_obj->so_accounts)
3406 3405
 			{
3407 3406
 				$filter['owner'] = 0;
3408
-				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter);
3407
+				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3409 3408
 
3410 3409
 				if ($contacts && $accounts)
3411 3410
 				{
3412
-					$contacts = array_merge($contacts,$accounts);
3413
-					usort($contacts,function($a, $b)
3411
+					$contacts = array_merge($contacts, $accounts);
3412
+					usort($contacts, function($a, $b)
3414 3413
 					{
3415 3414
 						return strcasecmp($a['n_fn'], $b['n_fn']);
3416 3415
 					});
3417 3416
 				}
3418
-				elseif($accounts)
3417
+				elseif ($accounts)
3419 3418
 				{
3420
-					$contacts =& $accounts;
3419
+					$contacts = & $accounts;
3421 3420
 				}
3422 3421
 				unset($accounts);
3423 3422
 			}
3424 3423
 		}
3425 3424
 		
3426
-		if(is_array($contacts)) {
3427
-			foreach($contacts as $contact) {
3428
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3425
+		if (is_array($contacts)) {
3426
+			foreach ($contacts as $contact) {
3427
+				foreach (array($contact['email'], $contact['email_home']) as $email) {
3429 3428
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3430 3429
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3431 3430
 					$rfcAddr = Mail::parseAddressList($email);
3432
-					$_rfcAddr=$rfcAddr->first();
3431
+					$_rfcAddr = $rfcAddr->first();
3433 3432
 					if (!$_rfcAddr->valid)
3434 3433
 					{
3435 3434
 						continue; // skip address if we encounter an error here
3436 3435
 					}
3437 3436
 					$email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
3438 3437
 
3439
-					if (method_exists($contacts_obj,'search'))
3438
+					if (method_exists($contacts_obj, 'search'))
3440 3439
 					{
3441
-						$contact['n_fn']='';
3440
+						$contact['n_fn'] = '';
3442 3441
 						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3443
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3444
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3445
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3446
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3442
+						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given'];
3443
+						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family'];
3444
+						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')';
3445
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3447 3446
 					}
3448 3447
 					else
3449 3448
 					{
3450
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3449
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3451 3450
 					}
3452 3451
 					$args = explode('@', trim($email));
3453 3452
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3454 3453
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3455
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3454
+					if (!empty($email) && in_array($completeMailString, $results) === false) {
3456 3455
 						$results[] = array(
3457 3456
 							'id'=>$completeMailString,
3458 3457
 							'label' => $completeMailString,
@@ -3468,10 +3467,10 @@  discard block
 block discarded – undo
3468 3467
 		// Add groups
3469 3468
 		$group_options = array('account_type' => 'groups');
3470 3469
 		$groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options);
3471
-		foreach($groups as $g_id => $name)
3470
+		foreach ($groups as $g_id => $name)
3472 3471
 		{
3473 3472
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3474
-			if(!$group['account_email']) continue;
3473
+			if (!$group['account_email']) continue;
3475 3474
 			$args = explode('@', trim($group['account_email']));
3476 3475
 			$args[] = $name;
3477 3476
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3501,7 +3500,7 @@  discard block
 block discarded – undo
3501 3500
 	public function ajax_merge($contact_id)
3502 3501
 	{
3503 3502
 		$response = Api\Json\Response::get();
3504
-		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3503
+		if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3505 3504
 		{
3506 3505
 			$document_merge = new $_REQUEST['merge']();
3507 3506
 		}
@@ -3511,7 +3510,7 @@  discard block
 block discarded – undo
3511 3510
 		}
3512 3511
 		$this->mail_bo->openConnection();
3513 3512
 
3514
-		if(($error = $document_merge->check_document($_REQUEST['document'],'')))
3513
+		if (($error = $document_merge->check_document($_REQUEST['document'], '')))
3515 3514
 		{
3516 3515
 			$response->error($error);
3517 3516
 			return;
@@ -3522,11 +3521,11 @@  discard block
 block discarded – undo
3522 3521
 		try
3523 3522
 		{
3524 3523
 			$results = $this->mail_bo->importMessageToMergeAndSend(
3525
-				$document_merge, Vfs::PREFIX . $_REQUEST['document'],
3524
+				$document_merge, Vfs::PREFIX.$_REQUEST['document'],
3526 3525
 				// Send an extra non-numeric ID to force actual send of document
3527 3526
 				// instead of save as draft
3528 3527
 				array((int)$contact_id, ''),
3529
-				$folder,$merged_mail_id
3528
+				$folder, $merged_mail_id
3530 3529
 			);
3531 3530
 		}
3532 3531
 		catch (Exception $e)
@@ -3540,13 +3539,13 @@  discard block
 block discarded – undo
3540 3539
 			);
3541 3540
 		}
3542 3541
 
3543
-		if($results['success'])
3542
+		if ($results['success'])
3544 3543
 		{
3545
-			$response->data(implode(',',$results['success']));
3544
+			$response->data(implode(',', $results['success']));
3546 3545
 		}
3547
-		if($results['failed'])
3546
+		if ($results['failed'])
3548 3547
 		{
3549
-			$response->error(implode(',',$results['failed']));
3548
+			$response->error(implode(',', $results['failed']));
3550 3549
 		}
3551 3550
 	}
3552 3551
 }
Please login to merge, or discard this patch.
mail/inc/class.mail_sieve.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1278,7 +1278,7 @@
 block discarded – undo
1278 1278
 	 * int $_searchStringLength
1279 1279
 	 * @param boolean $_returnList
1280 1280
 	 * @param int $_mailaccountToSearch
1281
-	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1281
+	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283 1283
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1284
 	{
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277 277
 			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
278
-            $error = 0;
278
+			$error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 	/**
1203 1203
 	 *
1204 1204
 	 * Get the data for iterating the rows on rules list grid
1205
- 	 *
1205
+	 *
1206 1206
 	 * @return {boolean|array} Array of rows | false if failed
1207 1207
 	 */
1208 1208
 	function get_rows()
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
1224 1224
 				}
1225
-            }
1225
+			}
1226 1226
 		}
1227 1227
 		else
1228 1228
 		{
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 				'caption' => 'Edit',
1248 1248
 				'default' => true,
1249 1249
 				'onExecute' => 'javaScript:app.mail.action',
1250
-                'disableClass' => 'th'
1250
+				'disableClass' => 'th'
1251 1251
 			),
1252 1252
 			'add' => array(
1253 1253
 				'caption' => 'Add',
@@ -1257,13 +1257,13 @@  discard block
 block discarded – undo
1257 1257
 				'caption' => 'Enable',
1258 1258
 				'onExecute' => 'javaScript:app.mail.action',
1259 1259
 				'enableClass' => 'mail_sieve_DISABLED',
1260
-                'hideOnDisabled' => true
1260
+				'hideOnDisabled' => true
1261 1261
 			),
1262 1262
 			'disable' => array(
1263 1263
 				'caption' => 'Disable',
1264 1264
 				'onExecute' => 'javaScript:app.mail.action',
1265 1265
 				'disableClass' => 'mail_sieve_DISABLED',
1266
-                'hideOnDisabled' => true
1266
+				'hideOnDisabled' => true
1267 1267
 			),
1268 1268
 			'delete' => array(
1269 1269
 				'caption' => 'Delete',
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		if ($acc_id > 0)
75 75
 		{
76 76
 			$this->account = Mail\Account::read($acc_id);
77
-			$identity = Mail\Account::read_identity($this->account->ident_id,true);
78
-			$this->currentIdentity = Mail::generateIdentityString($identity,false);
77
+			$identity = Mail\Account::read_identity($this->account->ident_id, true);
78
+			$this->currentIdentity = Mail::generateIdentityString($identity, false);
79 79
 		}
80 80
 
81 81
 		$this->restoreSessionData();
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param {array} $content
88 88
 	 * @param {string} $msg
89 89
 	 */
90
-	function index(array $content=null,$msg=null)
90
+	function index(array $content = null, $msg = null)
91 91
 	{
92 92
 		if (!is_array($content))
93 93
 		{
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 		if ($this->account->acc_sieve_enabled)
105 105
 		{
106 106
 			//Initializes the Grid contents
107
-			$content['rg']= $this->get_rows();
107
+			$content['rg'] = $this->get_rows();
108 108
 
109 109
 			// Set content-menu actions
110
-			$tmpl->setElementAttribute('rg', 'actions',$this->get_actions());
110
+			$tmpl->setElementAttribute('rg', 'actions', $this->get_actions());
111 111
 
112 112
 			$sel_options = array(
113 113
 				'status' => array(
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 		}
119 119
 		else
120 120
 		{
121
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
122
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
121
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
122
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
123 123
 		}
124
-		$tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array());
124
+		$tmpl->exec('mail.mail_sieve.index', $content, $sel_options, array());
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param {array} $content
132 132
 	 * @param {string} $msg
133 133
 	 */
134
-	function editEmailNotification($content=null, $msg='')
134
+	function editEmailNotification($content = null, $msg = '')
135 135
 	{
136 136
 		//Instantiate an eTemplate object, representing sieve.emailNotification
137 137
 		$eNotitmpl = new Etemplate('mail.sieve.emailNotification');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 				if (!empty($eNotification['externalEmail']))
148 148
 				{
149
-					$content['externalEmail'] = explode(",",$eNotification['externalEmail']);
149
+					$content['externalEmail'] = explode(",", $eNotification['externalEmail']);
150 150
 				}
151 151
 			}
152 152
 			else
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 				list($button) = @each($content['button']);
156 156
 				unset ($content['button']);
157 157
 
158
-				switch($button)
158
+				switch ($button)
159 159
 				{
160 160
 					case 'save':
161 161
 					case 'apply':
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 						{
164 164
 							$newEmailNotification = $content;
165 165
 							if (empty($this->mailConfig['prefpreventforwarding']) ||
166
-								$this->mailConfig['prefpreventforwarding'] == 0 )
166
+								$this->mailConfig['prefpreventforwarding'] == 0)
167 167
 							{
168 168
 								if (is_array($content['externalEmail']) && !empty($content['externalEmail']))
169 169
 								{
170
-									$newEmailNotification['externalEmail'] = implode(",",$content['externalEmail']);
170
+									$newEmailNotification['externalEmail'] = implode(",", $content['externalEmail']);
171 171
 								}
172 172
 							}
173 173
 						}
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 		else
217 217
 		{
218
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
219
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
218
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id);
219
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
220 220
 		}
221
-		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options);
221
+		$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content, $sel_options);
222 222
 	}
223 223
 
224 224
 	/**
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param {array} $content
228 228
 	 */
229
-	function edit ($content=null)
229
+	function edit($content = null)
230 230
 	{
231 231
 		//Instantiate an eTemplate object, representing sieve.edit template
232 232
 		$etmpl = new Etemplate('mail.sieve.edit');
233
-		$etmpl->setElementAttribute('action_folder_text','autocomplete_params', array('noPrefixId'=> true));
233
+		$etmpl->setElementAttribute('action_folder_text', 'autocomplete_params', array('noPrefixId'=> true));
234 234
 		if (!is_array($content))
235 235
 		{
236
-			if ( $this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
236
+			if ($this->getRules($_GET['ruleID']) && isset($_GET['ruleID']))
237 237
 			{
238 238
 
239 239
 				$rules = $this->rulesByID;
240
-				$content= $rules;
240
+				$content = $rules;
241 241
 				$content ['ruleID'] = $_GET['ruleID'];
242 242
 				switch ($rules['action'])
243 243
 				{
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			{
258 258
 
259 259
 				$this->getRules(null);
260
-				$newRulePriority = count($this->rules)*2+1;
260
+				$newRulePriority = count($this->rules) * 2 + 1;
261 261
 				$newRules ['priority'] = $newRulePriority;
262 262
 				$newRules ['status'] = 'ENABLED';
263 263
 				$readonlys = array(
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
 			list($button) = @each($content['button']);
275 275
 
276 276
 			//$ruleID is calculated by priority from the selected rule and is an unique ID
277
-			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2;
277
+			$content['ruleID'] = $ruleID = ($this->rulesByID['priority'] - 1) / 2;
278 278
             $error = 0;
279 279
 			switch ($button)
280 280
 			{
281 281
 				case 'save':
282 282
 				case 'apply':
283
-					if($content)
283
+					if ($content)
284 284
 					{
285 285
 						unset($content['button']);
286 286
 
287 287
 						$newRule = $content;
288
-						$newRule['priority']	= $this->rulesByID['priority'];
289
-						$newRule['status']	= $this->rulesByID['status'];
288
+						$newRule['priority'] = $this->rulesByID['priority'];
289
+						$newRule['status'] = $this->rulesByID['status'];
290 290
 
291 291
 						switch ($content['action'])
292 292
 						{
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 						unset($newRule['action_address_text']);
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307
-						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
307
+						$newRule['flg'] = 0;
308
+						if ($newRule['continue']) { $newRule['flg'] += 1; }
309
+						if ($newRule['gthan']) { $newRule['flg'] += 2; }
310
+						if ($newRule['anyof']) { $newRule['flg'] += 4; }
311
+						if ($newRule['keep']) { $newRule['flg'] += 8; }
312
+						if ($newRule['regexp']) { $newRule['flg'] += 128; }
313 313
 
314
-						if($newRule['action'] && $this->rulesByID['priority'])
314
+						if ($newRule['action'] && $this->rulesByID['priority'])
315 315
 						{
316 316
 							$this->rules[$ruleID] = $newRule;
317 317
 							$ret = $this->account->imapServer()->setRules($this->rules);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 							}
322 322
 							else
323 323
 							{
324
-								$msg .= lang("The rule with priority %1 successfully saved!",$ruleID);
324
+								$msg .= lang("The rule with priority %1 successfully saved!", $ruleID);
325 325
 							}
326 326
 							$this->saveSessionData();
327 327
 						}
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 				case 'delete':
347 347
 					if ($button == "delete")
348 348
 					{
349
-						if ($ruleID === count($this->rules)-1)
349
+						if ($ruleID === count($this->rules) - 1)
350 350
 						{
351
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!');
351
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!');
352 352
 						}
353 353
 						else
354 354
 						{
355 355
 
356
-							$msg = lang('rule with priority ') . $ruleID . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$ruleID+1,$ruleID);
356
+							$msg = lang('rule with priority ').$ruleID.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $ruleID + 1, $ruleID);
357 357
 						}
358 358
 						unset($this->rules[$ruleID]);
359 359
 						$this->rules = array_values($this->rules);
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 		);
385 385
 
386 386
 		//Set the preselect_options for mail/folders as we are not allow free entry for folder taglist
387
-		$sel_options['action_folder_text'] = $this->ajax_getFolders(0,true,null,true);
387
+		$sel_options['action_folder_text'] = $this->ajax_getFolders(0, true, null, true);
388 388
 
389
-		return $etmpl->exec('mail.mail_sieve.edit',$content,$sel_options,$readonlys,array(),2);
389
+		return $etmpl->exec('mail.mail_sieve.edit', $content, $sel_options, $readonlys, array(), 2);
390 390
 	}
391 391
 
392 392
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	function getEmailNotification()
400 400
 	{
401
-		if(!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
401
+		if (!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
402 402
 		{
403 403
 			throw new Api\Exception\NoPermission();
404 404
 		}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$emailNotification = $this->account->imapServer()->getEmailNotification();
408 408
 		}
409
-		catch(Exception $e) {
409
+		catch (Exception $e) {
410 410
 			unset($e);
411 411
 			$emailNotification = array();
412 412
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	function getVacation($accountID = null)
424 424
 	{
425
-		if(!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
425
+		if (!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
426 426
 		{
427 427
 			throw new Api\Exception\NoPermission();
428 428
 		}
@@ -439,25 +439,25 @@  discard block
 block discarded – undo
439 439
 				$vacation = $icServer->getVacation();
440 440
 			}
441 441
 		}
442
-		catch(Exception $e)
442
+		catch (Exception $e)
443 443
 		{
444 444
 			Framework::window_close(lang($e->getMessage()));
445 445
 		}
446 446
 		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
447 447
 
448
-		$account_email =  Api\Accounts::id2name($accountID, 'account_email');
448
+		$account_email = Api\Accounts::id2name($accountID, 'account_email');
449 449
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
450
-		$allAliases = $this->account->ident_email !=''?
450
+		$allAliases = $this->account->ident_email != '' ?
451 451
 				// Fix ident_email with no domain part set
452 452
 				array(Mail::fixInvalidAliasAddress($account_email, $this->account->ident_email))
453 453
 				: array();
454 454
 		foreach ($accAllIdentities as &$val)
455 455
 		{
456
-			if ($val['type'] !='default')
456
+			if ($val['type'] != 'default')
457 457
 			{
458 458
 				// if the alias has no domain part set try to add
459 459
 				// default domain extracted from ident_email address
460
-				$allAliases[] =  Mail::fixInvalidAliasAddress($account_email, $val['address']);
460
+				$allAliases[] = Mail::fixInvalidAliasAddress($account_email, $val['address']);
461 461
 			}
462 462
 		}
463 463
 		// try to fix already stored aliases
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param {array} $content
479 479
 	 * @param {string} $msg
480 480
 	 */
481
-	function editVacation($content=null, $msg='')
481
+	function editVacation($content = null, $msg = '')
482 482
 	{
483 483
 		//Instantiate an eTemplate object, representing the sieve.vacation template
484 484
 		$vtmpl = new Etemplate('mail.sieve.vacation');
@@ -491,27 +491,27 @@  discard block
 block discarded – undo
491 491
 			$account_id = $content['account_id'];
492 492
 			$preserv['acc_id'] = $content['acc_id'];
493 493
 		}
494
-		if(isset($account_id) && $this->mail_admin)
494
+		if (isset($account_id) && $this->mail_admin)
495 495
 		{
496
-			foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account)
496
+			foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account)
497 497
 			{
498 498
 				try {
499 499
 					// check if account is valid for multiple users, has admin credentials and sieve enabled
500 500
 					if (Mail\Account::is_multiple($account) &&
501
-						($icServer = $account->imapServer(true)) &&	// check on icServer object, so plugins can overwrite
501
+						($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite
502 502
 						$icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled)
503 503
 					{
504 504
 						$allAccounts[$account->acc_id] = $account->acc_name;
505 505
 						$accounts[$account->acc_id] = $account;
506 506
 					}
507 507
 				}
508
-				catch(Exception $e) {
508
+				catch (Exception $e) {
509 509
 					unset($e);
510 510
 					// ignore broken accounts
511 511
 				}
512 512
 			}
513 513
 
514
-			$profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id'];
514
+			$profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id'];
515 515
 			if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']]))
516 516
 			{
517 517
 				$profileID = $content['acc_id'] = (int)$_GET['acc_id'];
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			$this->is_admin_vac = true;
524 524
 			$preserv['account_id'] = $account_id;
525 525
 		}
526
-		elseif(!is_array($content) && isset($_GET['acc_id']))
526
+		elseif (!is_array($content) && isset($_GET['acc_id']))
527 527
 		{
528 528
 			$this->account = Mail\Account::read($_GET['acc_id']);
529 529
 			$preserv['acc_id'] = $this->account->acc_id;
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
 		if ($icServer->acc_sieve_enabled)
540 540
 		{
541 541
 			$vacRules = $this->getVacation($account_id);
542
-			if ($vacRules['vacation']===false)
542
+			if ($vacRules['vacation'] === false)
543 543
 			{
544 544
 				$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
545
-					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
546
-				$content['hideIfSieveDisabled']='mail_DisplayNone';
545
+					lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
546
+				$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
547 547
 			}
548 548
 			else
549 549
 			{
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
 				{
552 552
 					$ByDate = array('by_date' => lang('By date'));
553 553
 				}
554
-				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
554
+				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date'))))
555 555
 				{
556 556
 					$content = $vacation = $vacRules['vacation'];
557 557
 					if (!empty($profileID)) $content['acc_id'] = $profileID;
558
-					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
558
+					if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '')
559 559
 					{
560 560
 						$content['addresses'] = $vacRules['aliases'];
561 561
 					}
562 562
 					if (!empty($vacation['forwards']))
563 563
 					{
564
-						$content['forwards'] = explode(",",$vacation['forwards']);
564
+						$content['forwards'] = explode(",", $vacation['forwards']);
565 565
 					}
566 566
 					else
567 567
 					{
568 568
 						$content['forwards'] = '';
569 569
 					}
570
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
571
-					if (strlen(trim($content['text']))==0)
570
+					if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
571
+					if (strlen(trim($content['text'])) == 0)
572 572
 					{
573 573
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
574 574
 						Framework::refresh_opener($msg, 'mail');
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 					list($button) = @each($content['button']);
587 587
 					unset ($content['button']);
588 588
 
589
-					switch($button)
589
+					switch ($button)
590 590
 					{
591 591
 						case 'save':
592 592
 						case 'apply':
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 								$newVacation = $content;
605 605
 
606 606
 								if (empty($this->mailConfig['prefpreventforwarding']) ||
607
-									$this->mailConfig['prefpreventforwarding'] == 0 )
607
+									$this->mailConfig['prefpreventforwarding'] == 0)
608 608
 								{
609 609
 									$content['forwards'] = self::strip_rfc882_addresses($content['forwards']);
610 610
 									$newVacation['forwards'] = implode(',', $content['forwards']);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 									unset($newVacation ['forwards']);
615 615
 								}
616 616
 
617
-								if (!in_array($newVacation['status'],array('on','off','by_date')))
617
+								if (!in_array($newVacation['status'], array('on', 'off', 'by_date')))
618 618
 								{
619 619
 									$newVacation['status'] = 'off';
620 620
 								}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 										self::strip_rfc882_addresses($content['addresses']);
627 627
 								}
628 628
 
629
-								if($this->checkRule($newVacation,$checkAddresses))
629
+								if ($this->checkRule($newVacation, $checkAddresses))
630 630
 								{
631 631
 									if (isset($account_id) && $this->mail_admin)
632 632
 									{
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
 
640 640
 									if (!$resSetvac)
641 641
 									{
642
-										$msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error;
642
+										$msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error;
643 643
 										break;
644 644
 									}
645 645
 									// schedule job to switch message on/off, if request and not already in past
646 646
 									else
647 647
 									{
648
-										if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
648
+										if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() ||
649 649
 											$vacRules && $vacRules['vacation']['status'] == 'by_date')
650 650
 										{
651 651
 											self::setAsyncJob($newVacation);
@@ -653,29 +653,29 @@  discard block
 block discarded – undo
653 653
 										//Reset vacationNotice cache which is used in mail_ui get_rows
654 654
 										if (isset($account_id) && $this->mail_admin)
655 655
 										{
656
-											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
656
+											$account_lid = Api\Accounts::id2name($account_id, 'account_lid');
657 657
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
658 658
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
659
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
659
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations);
660 660
 										}
661 661
 										else
662 662
 										{
663 663
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
664 664
 											//error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations));
665
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
665
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
666 666
 										}
667 667
 										$msg = lang('Vacation notice sucessfully updated.');
668 668
 									}
669 669
 								}
670 670
 								else
671 671
 								{
672
-									$msg .= implode("\n",$this->errorStack);
672
+									$msg .= implode("\n", $this->errorStack);
673 673
 								}
674 674
 								// refresh vacationNotice on index
675 675
 								$response = Api\Json\Response::get();
676
-								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
676
+								$response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId);
677 677
 								Framework::refresh_opener($msg, 'mail');
678
-								if ($button === 'apply' || $icServer->error !=="")
678
+								if ($button === 'apply' || $icServer->error !== "")
679 679
 								{
680 680
 									break;
681 681
 								}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 						'on' => lang('Active'),
692 692
 						'off' => lang('Deactive'),
693 693
 					),
694
-					'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']),
694
+					'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']),
695 695
 				);
696 696
 				if (!isset($account_id))
697 697
 				{
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
 		}
716 716
 		else
717 717
 		{
718
-			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
719
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
718
+			$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId);
719
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
720 720
 		}
721
-		$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);
721
+		$vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2);
722 722
 	}
723 723
 
724 724
 	/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	static function strip_rfc882_addresses($_addresses)
733 733
 	{
734 734
 		$addresses = array();
735
-		foreach(Mail::parseAddressList($_addresses) as $addr)
735
+		foreach (Mail::parseAddressList($_addresses) as $addr)
736 736
 		{
737 737
 			if ($addr->valid)
738 738
 			{
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes
750 750
 	 * @return  void
751 751
 	 */
752
-	static function setAsyncJob (array $_vacation, $_reschedule=false)
752
+	static function setAsyncJob(array $_vacation, $_reschedule = false)
753 753
 	{
754 754
 		if (!($_vacation['acc_id'] > 0))
755 755
 		{
@@ -761,19 +761,19 @@  discard block
 block discarded – undo
761 761
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
762 762
 		$async->delete($async_id);
763 763
 
764
-		$end_date = $_vacation['end_date'] + 24*3600;   // end-date is inclusive, so we have to add 24h
764
+		$end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h
765 765
 		if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
766 766
 		{
767 767
 			$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
768
-			$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
768
+			$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
769 769
 		}
770 770
 		if ($_reschedule)
771 771
 		{
772
-			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
772
+			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5;
773 773
 			// only try to reschedule for 2 days max
774 774
 			if ($_vacation['rescheduled'] <= 2 * 24 * 60)
775 775
 			{
776
-				$time = time() + 60*($_vacation['rescheduled']);
776
+				$time = time() + 60 * ($_vacation['rescheduled']);
777 777
 				unset($_vacation['next']);
778 778
 				unset($_vacation['times']);
779 779
 				$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		}
810 810
 		catch (Exception $e) {
811 811
 			error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
812
-			self::setAsyncJob($_vacation, true);	// reschedule
812
+			self::setAsyncJob($_vacation, true); // reschedule
813 813
 			$ret = false;
814 814
 		}
815 815
 
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 *
825 825
 	 * @return boolean
826 826
 	 */
827
-	function checkRule($_vacation,$_checkAddresses=true)
827
+	function checkRule($_vacation, $_checkAddresses = true)
828 828
 	{
829 829
 		$this->errorStack = array();
830 830
 
@@ -838,12 +838,12 @@  discard block
 block discarded – undo
838 838
 			$this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!';
839 839
 		}
840 840
 
841
-		if(is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
841
+		if (is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
842 842
 		{
843
-			$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
843
+			$regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
844 844
 			foreach ($_vacation['addresses'] as $addr)
845 845
 			{
846
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
846
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
847 847
 				{
848 848
 					$this->errorStack['addresses'] = lang('One address is not valid').'!';
849 849
 				}
@@ -859,23 +859,23 @@  discard block
 block discarded – undo
859 859
 			{
860 860
 				$this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!');
861 861
 			}
862
-			elseif($_vacation['start_date'] > $_vacation['end_date'])
862
+			elseif ($_vacation['start_date'] > $_vacation['end_date'])
863 863
 			{
864 864
 				$this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!');
865 865
 			}
866 866
 		}
867 867
 		if ($_vacation['forwards'])
868 868
 		{
869
-			foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr)
869
+			foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr)
870 870
 			{
871
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
871
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
872 872
 				{
873 873
 					$this->errorStack['forwards'] = lang('One address is not valid'.'!');
874 874
 				}
875 875
 			}
876 876
 		}
877 877
 		//error_log(__METHOD__. array2string($this->errorStack));
878
-		if(count($this->errorStack) == 0)
878
+		if (count($this->errorStack) == 0)
879 879
 		{
880 880
 			return true;
881 881
 		}
@@ -896,14 +896,14 @@  discard block
 block discarded – undo
896 896
 
897 897
 		foreach ($orders as $keys => $val)
898 898
 		{
899
-			$orders[$keys] = $val -1;
899
+			$orders[$keys] = $val - 1;
900 900
 		}
901 901
 
902 902
 		$this->getRules(null);
903 903
 
904 904
 		$newrules = $this->rules;
905 905
 
906
-		foreach($orders as $keys => $ruleID)
906
+		foreach ($orders as $keys => $ruleID)
907 907
 		{
908 908
 			$newrules[$keys] = $this->rules[$ruleID];
909 909
 		}
@@ -932,24 +932,24 @@  discard block
 block discarded – undo
932 932
 		switch ($action)
933 933
 		{
934 934
 			case 'delete':
935
-				if ($checked === count($this->rules)-1)
935
+				if ($checked === count($this->rules) - 1)
936 936
 				{
937
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!');
937
+					$msg = lang('rule with priority ').$checked.lang(' deleted!');
938 938
 				}
939 939
 				else
940 940
 				{
941 941
 
942
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked);
942
+					$msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked);
943 943
 				}
944 944
 				unset($this->rules[$checked]);
945 945
 				$this->rules = array_values($this->rules);
946 946
 				break;
947 947
 			case 'enable':
948
-				$msg = lang('rule with priority ') . $checked . lang(' enabled!');
948
+				$msg = lang('rule with priority ').$checked.lang(' enabled!');
949 949
 				$this->rules[$checked][status] = 'ENABLED';
950 950
 				break;
951 951
 			case 'disable':
952
-				$msg = lang('rule with priority ') . $checked . lang(' disabled!');
952
+				$msg = lang('rule with priority ').$checked.lang(' disabled!');
953 953
 				$this->rules[$checked][status] = 'DISABLED';
954 954
 				break;
955 955
 			case 'move':
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 
962 962
 		$response = Api\Json\Response::get();
963 963
 
964
-		if($result)
964
+		if ($result)
965 965
 		{
966 966
 			$response->error($result);
967 967
 			return;
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
 	 */
980 980
 	function buildRule($rule)
981 981
 	{
982
-		$andor = ' '. lang('and') .' ';
982
+		$andor = ' '.lang('and').' ';
983 983
 		$started = 0;
984 984
 		if ($rule['anyof'])
985 985
 		{
986
-			$andor = ' '. lang('or') .' ';
986
+			$andor = ' '.lang('or').' ';
987 987
 		}
988 988
 		$complete = lang('IF').' ';
989 989
 		if ($rule['unconditional'])
@@ -992,8 +992,8 @@  discard block
 block discarded – undo
992 992
 		}
993 993
 		if ($rule['from'])
994 994
 		{
995
-			$match = $this->setMatchType($rule['from'],$rule['regexp']);
996
-			$complete .= "'From:' " . $match . " '" . $rule['from'] . "'";
995
+			$match = $this->setMatchType($rule['from'], $rule['regexp']);
996
+			$complete .= "'From:' ".$match." '".$rule['from']."'";
997 997
 			$started = 1;
998 998
 		}
999 999
 		if ($rule['to'])
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 			{
1003 1003
 				$complete .= $andor;
1004 1004
 			}
1005
-			$match = $this->setMatchType($rule['to'],$rule['regexp']);
1006
-			$complete .= "'To:' " . $match . " '" . $rule['to'] . "'";
1005
+			$match = $this->setMatchType($rule['to'], $rule['regexp']);
1006
+			$complete .= "'To:' ".$match." '".$rule['to']."'";
1007 1007
 			$started = 1;
1008 1008
 		}
1009 1009
 		if ($rule['subject'])
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 			{
1013 1013
 				$complete .= $andor;
1014 1014
 			}
1015
-			$match = $this->setMatchType($rule['subject'],$rule['regexp']);
1016
-			$complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'";
1015
+			$match = $this->setMatchType($rule['subject'], $rule['regexp']);
1016
+			$complete .= "'Subject:' ".$match." '".$rule['subject']."'";
1017 1017
 			$started = 1;
1018 1018
 		}
1019 1019
 		if ($rule['field'] && $rule['field_val'])
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 			{
1023 1023
 				$complete .= $andor;
1024 1024
 			}
1025
-			$match = $this->setMatchType($rule['field_val'],$rule['regexp']);
1026
-			$complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'";
1025
+			$match = $this->setMatchType($rule['field_val'], $rule['regexp']);
1026
+			$complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'";
1027 1027
 			$started = 1;
1028 1028
 		}
1029 1029
 		if ($rule['size'])
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			{
1038 1038
 				$complete .= $andor;
1039 1039
 			}
1040
-			$complete .= "message " . $xthan . $rule['size'] . "KB'";
1040
+			$complete .= "message ".$xthan.$rule['size']."KB'";
1041 1041
 			$started = 1;
1042 1042
 		}
1043 1043
 		if (!empty($rule['field_bodytransform']))
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 			{
1047 1047
 				$newruletext .= ", ";
1048 1048
 			}
1049
-			$btransform	= " :raw ";
1049
+			$btransform = " :raw ";
1050 1050
 			$match = ' :contains';
1051 1051
 			if ($rule['bodytransform'])
1052 1052
 			{
@@ -1060,11 +1060,11 @@  discard block
 block discarded – undo
1060 1060
 			{
1061 1061
 				$match = ':regex';
1062 1062
 			}
1063
-			$complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\"";
1063
+			$complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\"";
1064 1064
 			$started = 1;
1065 1065
 
1066 1066
 		}
1067
-		if ($rule['ctype']!= '0' && !empty($rule['ctype']))
1067
+		if ($rule['ctype'] != '0' && !empty($rule['ctype']))
1068 1068
 		{
1069 1069
 			if ($started)
1070 1070
 			{
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 			{
1077 1077
 				$ctype_subtype = "/";
1078 1078
 			}
1079
-			$complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\"";
1079
+			$complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\"";
1080 1080
 			$started = 1;
1081 1081
 			//error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array));
1082 1082
 		}
@@ -1084,19 +1084,19 @@  discard block
 block discarded – undo
1084 1084
 		{
1085 1085
 			$complete .= ' '.lang('THEN').' ';
1086 1086
 		}
1087
-		if (preg_match("/folder/i",$rule['action']))
1087
+		if (preg_match("/folder/i", $rule['action']))
1088 1088
 		{
1089
-			$complete .= lang('file into')." '" . $rule['action_arg'] . "';";
1089
+			$complete .= lang('file into')." '".$rule['action_arg']."';";
1090 1090
 		}
1091
-		if (preg_match("/reject/i",$rule['action']))
1091
+		if (preg_match("/reject/i", $rule['action']))
1092 1092
 		{
1093
-			$complete .= lang('reject with')." '" . $rule['action_arg'] . "'.";
1093
+			$complete .= lang('reject with')." '".$rule['action_arg']."'.";
1094 1094
 		}
1095
-		if (preg_match("/address/i",$rule['action']))
1095
+		if (preg_match("/address/i", $rule['action']))
1096 1096
 		{
1097
-			$complete .= lang('forward to').' ' . $rule['action_arg'] .'.';
1097
+			$complete .= lang('forward to').' '.$rule['action_arg'].'.';
1098 1098
 		}
1099
-		if (preg_match("/discard/i",$rule['action']))
1099
+		if (preg_match("/discard/i", $rule['action']))
1100 1100
 		{
1101 1101
 			$complete .= lang('discard').'.';
1102 1102
 		}
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 	 * @param {string} $regex regular expresion as pattern to be matched
1119 1119
 	 * @return {string} return the type
1120 1120
 	 */
1121
-	function setMatchType (&$matchstr, $regex = false)
1121
+	function setMatchType(&$matchstr, $regex = false)
1122 1122
 	{
1123 1123
 		$match = lang('contains');
1124 1124
 		if (preg_match("/^\s*!/", $matchstr))
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 		}
1144 1144
 		if ($regex && preg_match("/^\s*\\\\!/", $matchstr))
1145 1145
 		{
1146
-			$matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr);
1146
+			$matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr);
1147 1147
 		}
1148 1148
 		else
1149 1149
 		{
1150
-			$matchstr = preg_replace("/^\s*!/","",$matchstr);
1150
+			$matchstr = preg_replace("/^\s*!/", "", $matchstr);
1151 1151
 		}
1152 1152
 		return $match;
1153 1153
 	}
@@ -1157,9 +1157,9 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	function saveSessionData()
1159 1159
 	{
1160
-		$sessionData['sieve_rules']		= $this->rules;
1160
+		$sessionData['sieve_rules'] = $this->rules;
1161 1161
 		$sessionData['sieve_rulesByID'] = $this->rulesByID;
1162
-		$sessionData['sieve_scriptToEdit']	= $this->scriptToEdit;
1162
+		$sessionData['sieve_scriptToEdit'] = $this->scriptToEdit;
1163 1163
 		Api\Cache::setSession(__CLASS__, 'sieve_session_data', $sessionData);
1164 1164
 	}
1165 1165
 
@@ -1185,15 +1185,15 @@  discard block
 block discarded – undo
1185 1185
 	{
1186 1186
 		try {
1187 1187
 			$this->account->imapServer()->retrieveRules();
1188
-			$this->rules	= $this->account->imapServer()->getRules();
1188
+			$this->rules = $this->account->imapServer()->getRules();
1189 1189
 			$this->rulesByID = $this->rules[$ruleID];
1190
-			$this->vacation	= $this->account->imapServer()->getVacation();
1190
+			$this->vacation = $this->account->imapServer()->getVacation();
1191 1191
 		}
1192
-		catch(Exception $e) {
1192
+		catch (Exception $e) {
1193 1193
 			error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details);
1194
-			$this->rules	= array();
1194
+			$this->rules = array();
1195 1195
 			$this->rulesByID = array();
1196
-			$this->vacation	= array();
1196
+			$this->vacation = array();
1197 1197
 			return false;
1198 1198
 		}
1199 1199
 		return true;
@@ -1205,9 +1205,9 @@  discard block
 block discarded – undo
1205 1205
 	function restoreSessionData()
1206 1206
 	{
1207 1207
 		$sessionData = Api\Cache::getSession(__CLASS__, 'sieve_session_data');
1208
-		$this->rules		= $sessionData['sieve_rules'];
1208
+		$this->rules = $sessionData['sieve_rules'];
1209 1209
 		$this->rulesByID = $sessionData['sieve_rulesByID'];
1210
-		$this->scriptToEdit	= $sessionData['sieve_scriptToEdit'];
1210
+		$this->scriptToEdit = $sessionData['sieve_scriptToEdit'];
1211 1211
 	}
1212 1212
 
1213 1213
 	/**
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
 		$rows = array();
1222 1222
 		$this->getRules(null);
1223 1223
 
1224
-		if (is_array($this->rules) && !empty($this->rules) )
1224
+		if (is_array($this->rules) && !empty($this->rules))
1225 1225
 		{
1226 1226
 			$rows = $this->rules;
1227 1227
 
1228
-			foreach ($rows as &$row )
1228
+			foreach ($rows as &$row)
1229 1229
 			{
1230 1230
 				$row['rules'] = $this->buildRule($row);
1231
-				$row['ruleID'] =(string)(($row['priority'] -1) / 2 );
1231
+				$row['ruleID'] = (string)(($row['priority'] - 1) / 2);
1232 1232
 				if ($row ['status'] === 'DISABLED')
1233 1233
 				{
1234 1234
 					$row['class'] = 'mail_sieve_DISABLED';
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 			return false;
1242 1242
 		}
1243 1243
 		// Shift one down, because in grid the first row is reserved for header
1244
-		array_unshift($rows,array(''=> ''));
1244
+		array_unshift($rows, array(''=> ''));
1245 1245
 		return $rows;
1246 1246
 	}
1247 1247
 
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 	 */
1253 1253
 	private function get_actions()
1254 1254
 	{
1255
-		$actions =array(
1255
+		$actions = array(
1256 1256
 
1257 1257
 			'edit' => array(
1258 1258
 				'caption' => 'Edit',
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 	 * @param int $_mailaccountToSearch
1292 1292
 	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1293 1293
 	 */
1294
-	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1294
+	function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false)
1295 1295
 	{
1296 1296
 		$mailCompose = new mail_compose();
1297 1297
 		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
Please login to merge, or discard this patch.
Braces   +39 added lines, -11 removed lines patch added patch discarded remove patch
@@ -305,11 +305,21 @@  discard block
 block discarded – undo
305 305
 						unset($newRule['action_reject_text']);
306 306
 
307 307
 						$newRule['flg'] = 0 ;
308
-						if( $newRule['continue'] ) { $newRule['flg'] += 1; }
309
-						if( $newRule['gthan'] )    { $newRule['flg'] += 2; }
310
-						if( $newRule['anyof'] )    { $newRule['flg'] += 4; }
311
-						if( $newRule['keep'] )     { $newRule['flg'] += 8; }
312
-						if( $newRule['regexp'] )   { $newRule['flg'] += 128; }
308
+						if( $newRule['continue'] )
309
+						{
310
+$newRule['flg'] += 1; }
311
+						if( $newRule['gthan'] )
312
+						{
313
+$newRule['flg'] += 2; }
314
+						if( $newRule['anyof'] )
315
+						{
316
+$newRule['flg'] += 4; }
317
+						if( $newRule['keep'] )
318
+						{
319
+$newRule['flg'] += 8; }
320
+						if( $newRule['regexp'] )
321
+						{
322
+$newRule['flg'] += 128; }
313 323
 
314 324
 						if($newRule['action'] && $this->rulesByID['priority'])
315 325
 						{
@@ -443,7 +453,10 @@  discard block
 block discarded – undo
443 453
 		{
444 454
 			Framework::window_close(lang($e->getMessage()));
445 455
 		}
446
-		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
456
+		if (is_null($accountID))
457
+		{
458
+			$accountID = $GLOBALS['egw_info']['user']['account_id'];
459
+		}
447 460
 
448 461
 		$account_email =  Api\Accounts::id2name($accountID, 'account_email');
449 462
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
@@ -484,7 +497,10 @@  discard block
 block discarded – undo
484 497
 		$vtmpl = new Etemplate('mail.sieve.vacation');
485 498
 		$vacation = array();
486 499
 
487
-		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
500
+		if (isset($_GET['account_id']))
501
+		{
502
+			$account_id = $preserv['account_id'] = $_GET['account_id'];
503
+		}
488 504
 
489 505
 		if (isset($content['account_id']))
490 506
 		{
@@ -554,7 +570,10 @@  discard block
 block discarded – undo
554 570
 				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
555 571
 				{
556 572
 					$content = $vacation = $vacRules['vacation'];
557
-					if (!empty($profileID)) $content['acc_id'] = $profileID;
573
+					if (!empty($profileID))
574
+					{
575
+						$content['acc_id'] = $profileID;
576
+					}
558 577
 					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
559 578
 					{
560 579
 						$content['addresses'] = $vacRules['aliases'];
@@ -567,7 +586,10 @@  discard block
 block discarded – undo
567 586
 					{
568 587
 						$content['forwards'] = '';
569 588
 					}
570
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
589
+					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text'])
590
+					{
591
+						$content['text'] = $this->mailConfig['default_vacation_text'];
592
+					}
571 593
 					if (strlen(trim($content['text']))==0)
572 594
 					{
573 595
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
@@ -757,7 +779,10 @@  discard block
 block discarded – undo
757 779
 		}
758 780
 		// setting up an async job to enable/disable the vacation message
759 781
 		$async = new Api\Asyncservice();
760
-		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
782
+		if (empty($_vacation['account_id']))
783
+		{
784
+			$_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
785
+		}
761 786
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
762 787
 		$async->delete($async_id);
763 788
 
@@ -1294,7 +1319,10 @@  discard block
 block discarded – undo
1294 1319
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1295 1320
 	{
1296 1321
 		$mailCompose = new mail_compose();
1297
-		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
1322
+		if ($_REQUEST['noPrefixId'])
1323
+		{
1324
+			$_noPrefixId = $_REQUEST['noPrefixId'];
1325
+		}
1298 1326
 		$mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId);
1299 1327
 	}
1300 1328
 }
Please login to merge, or discard this patch.
mail/inc/class.mail_tree.inc.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $_profileID icServer profile id
77 77
 	 * @param string $_err error message to be shown on tree node
78 78
 	 * @param mixed $_path
79
-	 * @param mixed $_parent
79
+	 * @param string $_parent
80 80
 	 * @return array returns an array of tree node
81 81
 	 */
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * Check if the given tree id is account node (means root)
125 125
 	 *
126
-	 * @param type $_node a tree id node
126
+	 * @param string|null $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129 129
 	private static function isAccountNode ($_node)
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @param string $_parent = null no parent node means root with the first level of folders
157 157
 	 * @param string $_profileID = '' icServer id
158
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
158
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
159 159
 	 *  false|0 leaves them in closed state
160 160
 	 * @param $_noCheckboxNS = false no checkbox for namesapaces makes sure to not put checkbox for namespaces node
161 161
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @param type $_profileID = null Null means all accounts and giving profileid means fetches node for the account
445 445
 	 * @param type $_noCheckbox = false option to switch checkbox of
446
-	 * @param type $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
446
+	 * @param integer $_openTopLevel = 0 option to either start the node opened (1) or closed (0)
447 447
 	 *
448 448
 	 * @return array an array of baseNodes of accounts
449 449
 	 */
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 *
492 492
 	 * @param string $_parent = null no parent node means root with the first level of folders
493 493
 	 * @param string $_profileID = '' active profile / acc_id
494
-	 * @param int|boolean $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
494
+	 * @param integer $_openTopLevel = 1 Open top level folders on load if it's set to 1|true,
495 495
 	 *  false|0 leaves them in closed state
496 496
 	 * @param boolean $_subscribedOnly = false get only subscribed folders
497 497
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
Please login to merge, or discard this patch.
Braces   +54 added lines, -14 removed lines patch added patch discarded remove patch
@@ -116,7 +116,10 @@  discard block
 block discarded – undo
116 116
 		$hasChildren = 0;
117 117
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
118 118
 				in_array('\Haschildren', $_node['ATTRIBUTES']) ||
119
-				in_array('\HasChildren', $_node['ATTRIBUTES'])) $hasChildren = 1;
119
+				in_array('\HasChildren', $_node['ATTRIBUTES']))
120
+		{
121
+			$hasChildren = 1;
122
+		}
120 123
 		return $hasChildren;
121 124
 	}
122 125
 
@@ -129,7 +132,10 @@  discard block
 block discarded – undo
129 132
 	private static function isAccountNode ($_node)
130 133
 	{
131 134
 		list(,$leaf) = explode(self::DELIMITER, $_node);
132
-		if ($leaf || $_node == null) return false;
135
+		if ($leaf || $_node == null)
136
+		{
137
+			return false;
138
+		}
133 139
 		return true;
134 140
 	}
135 141
 
@@ -168,17 +174,24 @@  discard block
 block discarded – undo
168 174
 	{
169 175
 		//Init mail folders
170 176
 		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
171
-		if (!isset($this->ui->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
177
+		if (!isset($this->ui->mail_bo))
178
+		{
179
+			throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
180
+		}
172 181
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
173 182
 
174
-		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
183
+		if ($_parent)
184
+		{
185
+			list($_profileID) = explode(self::DELIMITER, $_parent);
186
+		}
175 187
 
176 188
 		if (is_numeric($_profileID) && $_profileID != $this->ui->mail_bo->profileID)
177 189
 		{
178 190
 			try
179 191
 			{
180 192
 				$this->ui->changeProfile($_profileID);
181
-			} catch (Exception $ex) {
193
+			}
194
+			catch (Exception $ex) {
182 195
 				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
183 196
 			}
184 197
 		}
@@ -188,9 +201,12 @@  discard block
 block discarded – undo
188 201
 			// *** Note: Should not apply any imap transaction, because in case of exception it will stop the
189 202
 			// process of rendering root node
190 203
 
191
-			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
204
+			if ($_parent && !self::isAccountNode($_parent))
205
+			{
206
+				// Single node loader
192 207
 			{
193 208
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
209
+			}
194 210
 				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
195 211
 
196 212
 				$childrenNode = array();
@@ -215,15 +231,21 @@  discard block
 block discarded – undo
215 231
 			}
216 232
 			else //Top Level Nodes loader
217 233
 			{
218
-				if (self::isAccountNode($_parent)) // An account called for open
234
+				if (self::isAccountNode($_parent))
235
+				{
236
+					// An account called for open
219 237
 				{
220 238
 					$_openTopLevel = 1;
239
+				}
221 240
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
222 241
 				}
223 242
 				else // Initial accounts|root nodes
224 243
 				{
225 244
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
226
-					if (!$_profileID && !$_openTopLevel) return $tree;
245
+					if (!$_profileID && !$_openTopLevel)
246
+					{
247
+						return $tree;
248
+					}
227 249
 				}
228 250
 
229 251
 				//List of folders
@@ -323,19 +345,28 @@  discard block
 block discarded – undo
323 345
 			{
324 346
 				$helper = array_slice($parents,1,null,true);
325 347
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
326
-				if ($parent) $parent .= $del;
348
+				if ($parent)
349
+				{
350
+					$parent .= $del;
351
+				}
327 352
 			}
328 353
 			else
329 354
 			{
330 355
 				$parent = implode(self::DELIMITER, $parents);
331
-				if ($parent) $parent .= self::DELIMITER;
356
+				if ($parent)
357
+				{
358
+					$parent .= self::DELIMITER;
359
+				}
332 360
 			}
333 361
 
334 362
 			if (!is_array($insert) || !isset($insert['item']))
335 363
 			{
336 364
 				// throwing an exeption here seems to be unrecoverable,
337 365
 				// even if the cause is a something that can be handeled by the mailserver
338
-				if (mail_bo::$debug) error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
366
+				if (mail_bo::$debug)
367
+				{
368
+					error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
369
+				}
339 370
 				// should we hit the break? if in personal: sure, something is wrong with the folderstructure
340 371
 				// if in shared or others we may proceed as access to folders may very well be limited to
341 372
 				// a single folder within the tree
@@ -346,11 +377,17 @@  discard block
 block discarded – undo
346 377
 					// we want to create the node in question as we meet the above considerations
347 378
 					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
348 379
 					{
349
-						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
380
+						if (mail_bo::$debug)
381
+						{
382
+							error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
383
+						}
350 384
 						$break=false;
351 385
 					}
352 386
 				}
353
-				if ($break) break;
387
+				if ($break)
388
+				{
389
+					break;
390
+				}
354 391
 			}
355 392
 			if ($insert['item'])
356 393
 			{
@@ -458,7 +495,10 @@  discard block
 block discarded – undo
458 495
 
459 496
 		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
460 497
 		{
461
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
498
+			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID)
499
+			{
500
+				continue;
501
+			}
462 502
 			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
463 503
 			// Open top level folders for active account
464 504
 			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		$this->ui = $mail_ui;
62 62
 
63 63
 		// check images available in png or svg
64
-		foreach(self::$leafImages as &$image)
64
+		foreach (self::$leafImages as &$image)
65 65
 		{
66 66
 			if (strpos($image, '.') === false)
67 67
 			{
68
-				$image = basename($img=Api\Image::find('mail', 'dhtmlxtree/'.$image));
68
+				$image = basename($img = Api\Image::find('mail', 'dhtmlxtree/'.$image));
69 69
 			}
70 70
 		}
71 71
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent)
83 83
 	{
84 84
 		$baseNode = array('id' => $_profileID);
85
-		$leaf =  array(
85
+		$leaf = array(
86 86
 			'id' => $_profileID.self::DELIMITER.'INBOX',
87 87
 			'text' => $_err,
88 88
 			'tooltip' => $_err,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		);
95 95
 		self::setOutStructure($leaf, $baseNode, self::DELIMITER);
96 96
 
97
-		return ($baseNode?$baseNode:array( // fallback not connected array
97
+		return ($baseNode ? $baseNode : array( // fallback not connected array
98 98
 						'id'=>0,
99 99
 						'item'=> array(
100 100
 							'text'=>'INBOX',
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param array $_node array of a node
112 112
 	 * @return int returns 1 if it has children flag set otherwise 0
113 113
 	 */
114
-	private static function nodeHasChildren ($_node)
114
+	private static function nodeHasChildren($_node)
115 115
 	{
116 116
 		$hasChildren = 0;
117 117
 		if (in_array('\haschildren', $_node['ATTRIBUTES']) ||
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param type $_node a tree id node
127 127
 	 * @return boolean returns true if the node is account node otherwise false
128 128
 	 */
129
-	private static function isAccountNode ($_node)
129
+	private static function isAccountNode($_node)
130 130
 	{
131 131
 		list(,$leaf) = explode(self::DELIMITER, $_node);
132 132
 		if ($leaf || $_node == null) return false;
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @return array returns an array of mail tree structure according to provided node
166 166
 	 */
167
-	function getTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly= false, $_allInOneGo = false, $_checkSubscribed = true)
167
+	function getTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly = false, $_allInOneGo = false, $_checkSubscribed = true)
168 168
 	{
169 169
 		//Init mail folders
170
-		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
170
+		$tree = array(Tree::ID=> $_parent ? $_parent : 0, Tree::CHILDREN => array());
171 171
 		if (!isset($this->ui->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem'));
172 172
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
173 173
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			{
180 180
 				$this->ui->changeProfile($_profileID);
181 181
 			} catch (Exception $ex) {
182
-				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
182
+				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
183 183
 			}
184 184
 		}
185 185
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
192 192
 			{
193 193
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
194
-				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
194
+				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly);
195 195
 
196 196
 				$childrenNode = array();
197 197
 				foreach ($folders as &$node)
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 					$nodeData = Mail::pathToFolderData($nodeId, $node['delimiter']);
201 201
 					$childrenNode[] = array(
202 202
 						Tree::ID=> $nodeId,
203
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node),
203
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ?false:self::nodeHasChildren($node),
204 204
 						Tree::CHILDREN =>array(),
205 205
 						Tree::LABEL => $nodeData['text'],
206 206
 						Tree::TOOLTIP => $nodeData['tooltip'],
207 207
 						Tree::IMAGE_LEAF => self::$leafImages['folderLeaf'],
208 208
 						Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'],
209 209
 						Tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClosed'],
210
-						Tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false,
210
+						Tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false,
211 211
 						'parent' => $_parent
212 212
 					);
213 213
 				}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 				}
228 228
 
229 229
 				//List of folders
230
-				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, false);
230
+				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, false);
231 231
 
232 232
 				// User defined folders based on account
233 233
 				$definedFolders = array(
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 
249 249
 					$data = array(
250 250
 						Tree::ID=>$_profileID.self::DELIMITER.$folder['MAILBOX'],
251
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder),
251
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ?false:self::nodeHasChildren($folder),
252 252
 						Tree::CHILDREN =>array(),
253 253
 						Tree::LABEL =>lang($folder['MAILBOX']),
254
-						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0,
254
+						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0,
255 255
 						Tree::TOOLTIP => lang($folder['MAILBOX']),
256
-						Tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false,
256
+						Tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false,
257 257
 						Tree::NOCHECKBOX => 0,
258
-						'parent' => $parent?$_profileID.self::DELIMITER.implode($folder['delimiter'], $parent):$_profileID,
258
+						'parent' => $parent ? $_profileID.self::DELIMITER.implode($folder['delimiter'], $parent) : $_profileID,
259 259
 						'path' => $path,
260 260
 						'folderarray' => $folder
261 261
 					);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		catch (Exception $ex) // Catch exceptions
294 294
 		{
295 295
 			//mail_ui::callWizard($ex->getMessage(), false, 'error');
296
-			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
296
+			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
297 297
 		}
298 298
 
299 299
 		return $tree;
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
 	 *					as clearance for access may be limited to a single branch-node of a tree
311 311
 	 * @return void
312 312
 	 */
313
-	static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array())
313
+	static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array())
314 314
 	{
315 315
 		//error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
316 316
 		$components = $data['path'];
317
-		array_pop($components);	// remove own name
317
+		array_pop($components); // remove own name
318 318
 
319 319
 		$insert = &$out;
320 320
 		$parents = array();
321
-		foreach($components as $component)
321
+		foreach ($components as $component)
322 322
 		{
323
-			if (count($parents)>1)
323
+			if (count($parents) > 1)
324 324
 			{
325
-				$helper = array_slice($parents,1,null,true);
325
+				$helper = array_slice($parents, 1, null, true);
326 326
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
327 327
 				if ($parent) $parent .= $del;
328 328
 			}
@@ -345,21 +345,21 @@  discard block
 block discarded – undo
345 345
 				{
346 346
 					// if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent
347 347
 					// we want to create the node in question as we meet the above considerations
348
-					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
348
+					if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::DELIMITER.$nsp['prefix']) === 0)
349 349
 					{
350 350
 						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
351
-						$break=false;
351
+						$break = false;
352 352
 					}
353 353
 				}
354 354
 				if ($break) break;
355 355
 			}
356 356
 			if ($insert['item'])
357 357
 			{
358
-				foreach($insert['item'] as &$item)
358
+				foreach ($insert['item'] as &$item)
359 359
 				{
360 360
 					if ($item['id'] == $parent.$component)
361 361
 					{
362
-						$insert =& $item;
362
+						$insert = & $item;
363 363
 						break;
364 364
 					}
365 365
 				}
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 						'im2' => self::$leafImages["folderNoSelectClosed"],
378 378
 						'tooltip' => lang('no access')
379 379
 					);
380
-					$insert['item'][] =& $item;
381
-					$insert =& $item;
380
+					$insert['item'][] = & $item;
381
+					$insert = & $item;
382 382
 				}
383 383
 				else
384 384
 				{
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 					$data[Tree::IMAGE_FOLDER_OPEN] =
412 412
 					$data [Tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png";
413 413
 			}
414
-			elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false)
414
+			elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false)
415 415
 			{
416 416
 				$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
417 417
 				$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@@ -453,20 +453,20 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return array an array of baseNodes of accounts
455 455
 	 */
456
-	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 )
456
+	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0)
457 457
 	{
458 458
 		$roots = array(Tree::ID => 0, Tree::CHILDREN => array());
459 459
 
460
-		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
460
+		foreach (Mail\Account::search(true, false) as $acc_id => $accObj)
461 461
 		{
462
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
463
-			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
462
+			if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue;
463
+			$identity = Mail\Account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']);
464 464
 			// Open top level folders for active account
465
-			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
465
+			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0;
466 466
 
467 467
 			$baseNode = array(
468 468
 							Tree::ID=> (string)$acc_id,
469
-							Tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity),
469
+							Tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity),
470 470
 							Tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity),
471 471
 							Tree::IMAGE_LEAF => self::$leafImages['folderAccount'],
472 472
 							Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'],
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
 							Tree::CHILDREN => array(), // dynamic loading on unfold
476 476
 							Tree::AUTOLOAD_CHILDREN => true,
477 477
 							'parent' => '',
478
-							Tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount,
478
+							Tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount,
479 479
 							// mark on account if Sieve is enabled
480 480
 							'data' => array(
481 481
 										'sieve' => $accObj->imapServer()->acc_sieve_enabled,
482
-										'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
483
-										'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
482
+										'spamfolder'=> $accObj->imapServer()->acc_folder_junk && (strtolower($accObj->imapServer()->acc_folder_junk) != 'none') ?true:false,
483
+										'archivefolder'=> $accObj->imapServer()->acc_folder_archive && (strtolower($accObj->imapServer()->acc_folder_archive) != 'none') ?true:false
484 484
 									),
485 485
 							Tree::NOCHECKBOX  => $_noCheckbox
486 486
 			);
487
-			self::setOutStructure($baseNode, $roots,self::DELIMITER);
487
+			self::setOutStructure($baseNode, $roots, self::DELIMITER);
488 488
 		}
489 489
 		return $roots;
490 490
 	}
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
504 504
 	 * @return type an array of tree
505 505
 	 */
506
-	function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false)
506
+	function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false)
507 507
 	{
508 508
 		$tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo);
509
-		$branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo);
509
+		$branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo);
510 510
 		foreach ($tree[Tree::CHILDREN] as &$account)
511 511
 		{
512 512
 			if ($account[Tree::ID] == $_profileID)
513 513
 			{
514
-				$account = array_merge($account , $branches);
514
+				$account = array_merge($account, $branches);
515 515
 			}
516 516
 		}
517 517
 		return $tree;
Please login to merge, or discard this patch.
notifications/inc/class.notifications.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -434,7 +434,7 @@
 block discarded – undo
434 434
 	 * Sets backends that should be skipped even if the user
435 435
 	 * defined them in its chain
436 436
 	 *
437
-	 * @param array $_skip_backends array with names of the backends to be skipped
437
+	 * @param string[] $_skip_backends array with names of the backends to be skipped
438 438
 	 * e.g. array('popup', 'winpopup')
439 439
 	 */
440 440
 	public function set_skip_backends(array $_skip_backends) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -660,14 +660,14 @@
 block discarded – undo
660 660
 	 }
661 661
 
662 662
 	 /**
663
-	 * returns notification chains based on admin prefs
664
-	 * @abstract the available chains can be retrieved in two different output formats:
665
-	 * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
-	 * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
-	 *
668
-	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
-	 * @return array containing notification chains, output like given in $_output
670
-	 */
663
+	  * returns notification chains based on admin prefs
664
+	  * @abstract the available chains can be retrieved in two different output formats:
665
+	  * routing: array with common and enabled chains, chain-name as key and the chain-array as value (used for message-routing)
666
+	  * human: array with common, enabled and disabled chains, chain-name as key and a human-readable description as value (used for config)
667
+	  *
668
+	  * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669
+	  * @return array containing notification chains, output like given in $_output
670
+	  */
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 */
181 181
 	public function __construct() {
182
-		$this->config = (object) Api\Config::read(self::_appname);
182
+		$this->config = (object)Api\Config::read(self::_appname);
183 183
 	}
184 184
 
185 185
 	/**
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @param boolean $reset =false true: reset all errors
189 189
 	 * @return array
190 190
 	 */
191
-	public static function errors($reset=false)
191
+	public static function errors($reset = false)
192 192
 	{
193 193
 		$ret = self::$errors;
194 194
 		if ($reset) self::$errors = array();
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 	 * it's an int with the account id or the e-mail address of a non-eGW user
204 204
 	 */
205 205
 	public function set_sender($_sender) {
206
-		if(is_object($_sender)) {
206
+		if (is_object($_sender)) {
207 207
 			$this->sender = $_sender;
208 208
 			return true;
209 209
 		} else {
210 210
 			// no object atm, we have to handle this and make a pseudo-object
211
-			if(is_numeric($_sender)) {
212
-				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
211
+			if (is_numeric($_sender)) {
212
+				$this->sender = (object)$GLOBALS['egw']->accounts->read($_sender);
213 213
 				return true;
214 214
 			}
215
-			if(is_string($_sender) && strpos($_sender,'@')) {
216
-				$this->sender = (object) array (
217
-									'account_email' => $this->get_addresspart($_sender,'email'),
218
-									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
215
+			if (is_string($_sender) && strpos($_sender, '@')) {
216
+				$this->sender = (object)array(
217
+									'account_email' => $this->get_addresspart($_sender, 'email'),
218
+									'account_fullname' => $this->get_addresspart($_sender, 'fullname'),
219 219
 									);
220 220
 				return true;
221 221
 			}
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
 	 * it's an int with the account id or the e-mail address of a non-eGW user
246 246
 	 */
247 247
 	public function add_receiver($_receiver) {
248
-		if(is_object($_receiver)) {
248
+		if (is_object($_receiver)) {
249 249
 			$this->receivers[] = $_receiver;
250 250
 			return true;
251 251
 		} else {
252 252
 			// no object atm, we have to handle this and make a pseudo-object
253
-			if(is_numeric($_receiver)) {
254
-				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
253
+			if (is_numeric($_receiver)) {
254
+				$this->receivers[] = (object)$GLOBALS['egw']->accounts->read($_receiver);
255 255
 				return true;
256 256
 			}
257
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
258
-				$this->receivers[] = (object) array (
259
-									'account_email' => $this->get_addresspart($_receiver,'email'),
260
-									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
257
+			if (is_string($_receiver) && strpos($_receiver, '@')) {
258
+				$this->receivers[] = (object)array(
259
+									'account_email' => $this->get_addresspart($_receiver, 'email'),
260
+									'account_fullname' => $this->get_addresspart($_receiver, 'fullname'),
261 261
 									);
262 262
 				return true;
263 263
 			}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 * @param string $_message
297 297
 	 */
298 298
 	public function set_message($_message) {
299
-		if(strlen($_message) == strlen(strip_tags($_message))) {
299
+		if (strlen($_message) == strlen(strip_tags($_message))) {
300 300
 			$this->message_plain = $_message;
301 301
 		} else {
302 302
 			$this->message_html = $_message;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function set_popupmessage($_message) {
316 316
 		//popup requires html
317
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
317
+		if (strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
318 318
 		$this->message_popup = $_message;
319 319
 		return true;
320 320
 	}
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function set_links(array $_links) {
328 328
 		$this->links = array(); // clear array if set
329
-		foreach($_links as $link) {
330
-			if(is_array($link)) {
331
-				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
329
+		foreach ($_links as $link) {
330
+			if (is_array($link)) {
331
+				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'], $link['id']);
332 332
 			}
333 333
 		}
334 334
 		return true;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function set_popuplinks(array $_links) {
343 343
 		$this->popup_links = array(); // clear array if set
344
-		foreach($_links as $link) {
345
-			if(is_array($link)) {
344
+		foreach ($_links as $link) {
345
+			if (is_array($link)) {
346 346
 				$this->add_popuplink($link['text'], $link['view'], $link['popup']);
347 347
 			}
348 348
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
360 360
 	 */
361 361
 	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
362
-		if(!$_view || !$_text) { return false; }
362
+		if (!$_view || !$_text) { return false; }
363 363
 		$this->links[] = (object)array(
364 364
 			'text'	=> $_text,
365 365
 			'view'	=> $_view,
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
379 379
 	 */
380 380
 	public function add_popuplink($_text, $_view, $_popup = false) {
381
-		if(!$_view || !$_text) { return false; }
382
-		$this->popup_links[] = (object)array(	'text'	=> $_text,
381
+		if (!$_view || !$_text) { return false; }
382
+		$this->popup_links[] = (object)array('text'	=> $_text,
383 383
 										'view'	=> $_view,
384 384
 										'popup'	=> $_popup,
385 385
 										);
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	public function set_attachments(array $_attachments) {
395 395
 		$this->attachments = array(); // clear array if set
396
-		foreach($_attachments as $attachment) {
397
-			if(is_array($attachment)) {
396
+		foreach ($_attachments as $attachment) {
397
+			if (is_array($attachment)) {
398 398
 				$this->add_attachment(
399 399
 					$attachment['string'],
400 400
 					$attachment['filename'],
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param string $_type File extension (MIME) type.
419 419
 	 * @param string $_path optional path to attachment, if !$_string
420 420
 	 */
421
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
422
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
421
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path = null) {
422
+		if (!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
423 423
 		$this->attachments[] = (object)array(
424 424
 			'string' => $_string,
425 425
 			'filename' => $_filename,
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		if (!is_array($this->receivers) || count($this->receivers) == 0) {
452 452
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
453 453
 		}
454
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
454
+		if (!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
455 455
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
456 456
 		}
457 457
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			$backend_errors = array();
464 464
 			try {
465 465
 				// system or non-system user
466
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
466
+				if ($receiver->account_id && is_numeric($receiver->account_id)) {
467 467
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
468 468
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
469 469
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -476,17 +476,17 @@  discard block
 block discarded – undo
476 476
 					}
477 477
 					$receiver->handle = $receiver->account_lid;
478 478
 					// check if the receiver has rights to run the notifcation app
479
-					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
479
+					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id, true);
480 480
 					$ids[] = $receiver->account_id;
481
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
481
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids, 'run', 'notifications')) {
482 482
 						// read the users notification chain
483 483
 						$prefs = new Api\Preferences($receiver->account_id);
484 484
 						$preferences_all = $prefs->read();
485 485
 						$preferences = (object)$preferences_all[self::_appname];
486
-						if($preferences->notification_chain) {
486
+						if ($preferences->notification_chain) {
487 487
 							// fallback: admin disabled user-chosen chain
488
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
489
-								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
488
+							if (!$notification_chain = $available_chains[$preferences->notification_chain]) {
489
+								$prepend_message .= lang('This eGroupWare notification has been sent to you by mail because your'
490 490
 															.' chosen notification-chain has been disabled by the administrator.'
491 491
 															.' Please choose another notification-chain in your preferences!');
492 492
 								$notification_chain = $available_chains[self::_fallback];
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
504 504
 				}
505 505
 
506
-				if($notification_chain == 'disable') {
506
+				if ($notification_chain == 'disable') {
507 507
 					continue; //user disabled notifications
508 508
 				}
509 509
 
510
-				foreach($notification_chain as $backend => $action) {
510
+				foreach ($notification_chain as $backend => $action) {
511 511
 					$notification_backend = null;
512 512
 					try {
513 513
 						// check if backend should be skipped
514
-						if( in_array($backend, $this->skip_backends) ) {
514
+						if (in_array($backend, $this->skip_backends)) {
515 515
 							// log as error just for the case too much skipping prevents user from being notified
516 516
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
517 517
 							continue;
518 518
 						}
519 519
 
520 520
 						$notification_backend = self::_appname.'_'.$backend;
521
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
522
-							throw new Exception('file for '.$notification_backend. ' does not exist');
521
+						if (!file_exists(EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.'.$notification_backend.'.inc.php')) {
522
+							throw new Exception('file for '.$notification_backend.' does not exist');
523 523
 						}
524
-						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
525
-						if ( !($obj instanceof notifications_iface) ) {
526
-							unset ( $obj );
527
-					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
524
+						$obj = new $notification_backend($this->sender, $receiver, $this->config, $preferences);
525
+						if (!($obj instanceof notifications_iface)) {
526
+							unset ($obj);
527
+					 		throw new Exception($notification_backend.' is no implementation of notifications_iface');
528 528
 						}
529 529
 						$lsubject = $this->subject;
530 530
 						$llinks = $this->links;
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
 					catch (Exception $exception) {
539 539
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
540 540
 						// try next backend
541
-						if($action == 'fail' || $action == 'continue') {
541
+						if ($action == 'fail' || $action == 'continue') {
542 542
 							continue;
543 543
 						}
544 544
 						break; // stop running through chain
545 545
 					}
546 546
 					// backend sucseeded
547 547
 					$user_notified = true;
548
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
548
+					if ($action == 'stop' || $action == 'fail') { break; } // stop running through chain
549 549
 				}
550 550
 				// check if the user has been notified at all
551
-				if(!$user_notified) {
551
+				if (!$user_notified) {
552 552
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
553 553
 					foreach($backend_errors as $id=>$backend_error) {
554 554
 						error_log($backend_error);
@@ -575,22 +575,22 @@  discard block
 block discarded – undo
575 575
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
576 576
 	 */
577 577
 	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
578
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
578
+		if (empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
579 579
 		$messages = array();
580 580
 
581 581
 		// create the messages
582
-		if(!empty($_message_plain)) {
582
+		if (!empty($_message_plain)) {
583 583
 			$messages['plain'] = $_message_plain;
584 584
 		} else {
585 585
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
586 586
 		}
587 587
 
588
-		if(!empty($_message_html)) {
588
+		if (!empty($_message_html)) {
589 589
 			$messages['html'] = $_message_html;
590 590
 		} else {
591 591
 			$messages['html'] = self::plain2html($_message_plain);
592 592
 		}
593
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
593
+		if (!empty($_message_popup)) $messages['popup'] = $_message_popup;
594 594
 		return $messages;
595 595
 	}
596 596
 
@@ -613,9 +613,9 @@  discard block
 block discarded – undo
613 613
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
614 614
 	 */
615 615
 	 private function prepend_message(array $_messages, $_prepend = null) {
616
-		if(strlen($_prepend) > 0) {
617
-			foreach($_messages as $key => $value) {
618
-				switch($key) {
616
+		if (strlen($_prepend) > 0) {
617
+			foreach ($_messages as $key => $value) {
618
+				switch ($key) {
619 619
 					case 'plain':
620 620
 						$_messages[$key] = $_prepend."\n\n".$value;
621 621
 						break;
@@ -639,17 +639,17 @@  discard block
 block discarded – undo
639 639
 	 * @param string $_part
640 640
 	 * @return string chosen part of the address
641 641
 	 */
642
-	private function get_addresspart($_address, $_part='email')
642
+	private function get_addresspart($_address, $_part = 'email')
643 643
 	{
644 644
 		$parts = null;
645
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
646
-	 		$fullname = trim(trim($parts[1]),'\"');
645
+	 	if (strpos($_address, '<') && preg_match('/^(.*)\S?\<(.*)\>/', $_address, $parts)) { // _address contains a fullname part
646
+	 		$fullname = trim(trim($parts[1]), '\"');
647 647
 	 		$email = $parts[2];
648 648
 	 	} else {
649 649
 	 		$fullname = false;
650 650
 	 		$email = $_address;
651 651
 	 	}
652
-	 	switch($_part) {
652
+	 	switch ($_part) {
653 653
 	 		case 'fullname':
654 654
 	 			return $fullname;
655 655
 	 		case 'email':
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
 	public function get_available_chains($_output = 'routing') {
672 672
 		// determine enabled backends from Api\Config
673 673
 		$enabled_backends = array();
674
-		foreach($this->backends as $backend) {
675
-			switch($backend) {
674
+		foreach ($this->backends as $backend) {
675
+			switch ($backend) {
676 676
 				case 'email':
677 677
 				case 'popup':
678 678
 				case 'jpopup':
@@ -687,15 +687,15 @@  discard block
 block discarded – undo
687 687
 
688 688
 		$enabled_chains = array();
689 689
 		$disabled_chains = array();
690
-		foreach($this->notification_chains as $key => $chain) {
690
+		foreach ($this->notification_chains as $key => $chain) {
691 691
 			$allow_chain = true;
692
-			if(is_array($chain)) {
693
-				foreach(array_keys($chain) as $name) {
694
-					if(!$enabled_backends[$name]) {
692
+			if (is_array($chain)) {
693
+				foreach (array_keys($chain) as $name) {
694
+					if (!$enabled_backends[$name]) {
695 695
 						$allow_chain = false; // disable whole chain if one backend is disabled
696 696
 					}
697 697
 				}
698
-				if($allow_chain) {
698
+				if ($allow_chain) {
699 699
 					$enabled_chains[$key] = $chain;
700 700
 				} else {
701 701
 					$disabled_chains[$key] = $chain;
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
 		// create the 'all' chain from the enabled backends
711 711
 		$chain_all = array();
712 712
 		$backend_count = 1;
713
-		foreach($enabled_backends as $backend => $enabled) {
714
-			if($enabled) {
713
+		foreach ($enabled_backends as $backend => $enabled) {
714
+			if ($enabled) {
715 715
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
716 716
 			}
717 717
 			$backend_count++;
718 718
 		}
719 719
 		$common_chains['all'] = $chain_all;
720 720
 
721
-		switch($_output) {
721
+		switch ($_output) {
722 722
 			case 'human':
723 723
 				$chain_groups = array(
724 724
 					lang('Common chains')	=> 'common_chains',
@@ -727,10 +727,10 @@  discard block
 block discarded – undo
727 727
 					);
728 728
 				$suffix = '_human';
729 729
 				// create descriptions for each chain key in each group
730
-				foreach($chain_groups as $name => $arr_name) {
730
+				foreach ($chain_groups as $name => $arr_name) {
731 731
 					${$arr_name.$suffix} = array();
732
-					foreach(array_keys(${$arr_name}) as $key) {
733
-						if($arr_name == 'disabled_chains') {
732
+					foreach (array_keys(${$arr_name}) as $key) {
733
+						if ($arr_name == 'disabled_chains') {
734 734
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
735 735
 						} else {
736 736
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 				}
740 740
 				// summarize all groups with minimum one chain to the final array
741 741
 				$chains_final = array();
742
-				foreach($chain_groups as $name => $arr_name) {
743
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
742
+				foreach ($chain_groups as $name => $arr_name) {
743
+					if (is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
744 744
 						$chains_final[$name] = ${$arr_name.$suffix};
745 745
 					}
746 746
 				}
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
761 761
 	 */
762 762
 	public function deleteaccount($settings) {
763
-		foreach($this->backends as $backend) {
764
-			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
763
+		foreach ($this->backends as $backend) {
764
+			$backend_hook = array(self::_appname.'_'.$backend, 'deleteaccount');
765 765
 			if (is_callable($backend_hook)) {
766
-				call_user_func($backend_hook,$settings);
766
+				call_user_func($backend_hook, $settings);
767 767
 			}
768 768
 		}
769 769
 	}
Please login to merge, or discard this patch.
Braces   +222 added lines, -96 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
  * called from this class. The backend's job is to deliver ONE message to ONE recipient.
25 25
  *
26 26
  */
27
-final class notifications {
27
+final class notifications
28
+{
28 29
 
29 30
 	/**
30 31
 	 * Appname
@@ -178,7 +179,8 @@  discard block
 block discarded – undo
178 179
 	 * constructor of notifications
179 180
 	 *
180 181
 	 */
181
-	public function __construct() {
182
+	public function __construct()
183
+	{
182 184
 		$this->config = (object) Api\Config::read(self::_appname);
183 185
 	}
184 186
 
@@ -191,7 +193,10 @@  discard block
 block discarded – undo
191 193
 	public static function errors($reset=false)
192 194
 	{
193 195
 		$ret = self::$errors;
194
-		if ($reset) self::$errors = array();
196
+		if ($reset)
197
+		{
198
+			self::$errors = array();
199
+		}
195 200
 		return $ret;
196 201
 	}
197 202
 
@@ -202,17 +207,23 @@  discard block
 block discarded – undo
202 207
 	 * as long as the accounts class isn't a nice object,
203 208
 	 * it's an int with the account id or the e-mail address of a non-eGW user
204 209
 	 */
205
-	public function set_sender($_sender) {
206
-		if(is_object($_sender)) {
210
+	public function set_sender($_sender)
211
+	{
212
+		if(is_object($_sender))
213
+		{
207 214
 			$this->sender = $_sender;
208 215
 			return true;
209
-		} else {
216
+		}
217
+		else
218
+		{
210 219
 			// no object atm, we have to handle this and make a pseudo-object
211
-			if(is_numeric($_sender)) {
220
+			if(is_numeric($_sender))
221
+			{
212 222
 				$this->sender = (object) $GLOBALS['egw']->accounts->read($_sender);
213 223
 				return true;
214 224
 			}
215
-			if(is_string($_sender) && strpos($_sender,'@')) {
225
+			if(is_string($_sender) && strpos($_sender,'@'))
226
+			{
216 227
 				$this->sender = (object) array (
217 228
 									'account_email' => $this->get_addresspart($_sender,'email'),
218 229
 									'account_fullname' => $this->get_addresspart($_sender,'fullname'),
@@ -230,9 +241,11 @@  discard block
 block discarded – undo
230 241
 	 * as long as the accounts class isn't a nice object,
231 242
 	 * it's an array with the int of the account id or the e-mail address of a non-eGW user
232 243
 	 */
233
-	public function set_receivers(array $_receivers) {
244
+	public function set_receivers(array $_receivers)
245
+	{
234 246
 		$this->receivers = array();
235
-		foreach ($_receivers as $receiver) {
247
+		foreach ($_receivers as $receiver)
248
+		{
236 249
 			$this->add_receiver($receiver);
237 250
 		}
238 251
 	}
@@ -244,17 +257,23 @@  discard block
 block discarded – undo
244 257
 	 * as long as the accounts class isn't a nice object,
245 258
 	 * it's an int with the account id or the e-mail address of a non-eGW user
246 259
 	 */
247
-	public function add_receiver($_receiver) {
248
-		if(is_object($_receiver)) {
260
+	public function add_receiver($_receiver)
261
+	{
262
+		if(is_object($_receiver))
263
+		{
249 264
 			$this->receivers[] = $_receiver;
250 265
 			return true;
251
-		} else {
266
+		}
267
+		else
268
+		{
252 269
 			// no object atm, we have to handle this and make a pseudo-object
253
-			if(is_numeric($_receiver)) {
270
+			if(is_numeric($_receiver))
271
+			{
254 272
 				$this->receivers[] = (object) $GLOBALS['egw']->accounts->read($_receiver);
255 273
 				return true;
256 274
 			}
257
-			if(is_string($_receiver) && strpos($_receiver,'@')) {
275
+			if(is_string($_receiver) && strpos($_receiver,'@'))
276
+			{
258 277
 				$this->receivers[] = (object) array (
259 278
 									'account_email' => $this->get_addresspart($_receiver,'email'),
260 279
 									'account_fullname' => $this->get_addresspart($_receiver,'fullname'),
@@ -270,7 +289,8 @@  discard block
 block discarded – undo
270 289
 	 *
271 290
 	 * @param string $_subject
272 291
 	 */
273
-	public function set_subject($_subject) {
292
+	public function set_subject($_subject)
293
+	{
274 294
 		$this->subject = $_subject;
275 295
 		return true;
276 296
 	}
@@ -280,7 +300,8 @@  discard block
 block discarded – undo
280 300
 	 *
281 301
 	 * @param string $_subject
282 302
 	 */
283
-	public function set_popupsubject($_subject) {
303
+	public function set_popupsubject($_subject)
304
+	{
284 305
 		$this->popupsubject = $_subject;
285 306
 		return true;
286 307
 	}
@@ -295,10 +316,14 @@  discard block
 block discarded – undo
295 316
 	 *
296 317
 	 * @param string $_message
297 318
 	 */
298
-	public function set_message($_message) {
299
-		if(strlen($_message) == strlen(strip_tags($_message))) {
319
+	public function set_message($_message)
320
+	{
321
+		if(strlen($_message) == strlen(strip_tags($_message)))
322
+		{
300 323
 			$this->message_plain = $_message;
301
-		} else {
324
+		}
325
+		else
326
+		{
302 327
 			$this->message_html = $_message;
303 328
 		}
304 329
 		return true;
@@ -312,9 +337,13 @@  discard block
 block discarded – undo
312 337
 	 *
313 338
 	 * @param string $_message
314 339
 	 */
315
-	public function set_popupmessage($_message) {
340
+	public function set_popupmessage($_message)
341
+	{
316 342
 		//popup requires html
317
-		if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
343
+		if(strlen($_message) == strlen(strip_tags($_message)))
344
+		{
345
+			$_message = self::plain2html($_message);
346
+		}
318 347
 		$this->message_popup = $_message;
319 348
 		return true;
320 349
 	}
@@ -324,10 +353,13 @@  discard block
 block discarded – undo
324 353
 	 *
325 354
 	 * @param array $_links link array (like defined in $this->add_link)
326 355
 	 */
327
-	public function set_links(array $_links) {
356
+	public function set_links(array $_links)
357
+	{
328 358
 		$this->links = array(); // clear array if set
329
-		foreach($_links as $link) {
330
-			if(is_array($link)) {
359
+		foreach($_links as $link)
360
+		{
361
+			if(is_array($link))
362
+			{
331 363
 				$this->add_link($link['text'], $link['view'], $link['popup'], $link['app'],$link['id']);
332 364
 			}
333 365
 		}
@@ -339,10 +371,13 @@  discard block
 block discarded – undo
339 371
 	 *
340 372
 	 * @param array $_links link array (like defined in $this->add_link)
341 373
 	 */
342
-	public function set_popuplinks(array $_links) {
374
+	public function set_popuplinks(array $_links)
375
+	{
343 376
 		$this->popup_links = array(); // clear array if set
344
-		foreach($_links as $link) {
345
-			if(is_array($link)) {
377
+		foreach($_links as $link)
378
+		{
379
+			if(is_array($link))
380
+			{
346 381
 				$this->add_popuplink($link['text'], $link['view'], $link['popup']);
347 382
 			}
348 383
 		}
@@ -358,8 +393,11 @@  discard block
 block discarded – undo
358 393
 	 * @param string $_app Application name, to use link registry (popup & view ignored)
359 394
 	 * @param string $_id Application ID, to use link registry (popup & view ignored)
360 395
 	 */
361
-	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false) {
362
-		if(!$_view || !$_text) { return false; }
396
+	public function add_link($_text, $_view, $_popup = false, $_app = false, $_id = false)
397
+	{
398
+		if(!$_view || !$_text)
399
+		{
400
+return false; }
363 401
 		$this->links[] = (object)array(
364 402
 			'text'	=> $_text,
365 403
 			'view'	=> $_view,
@@ -377,8 +415,11 @@  discard block
 block discarded – undo
377 415
 	 * @param array $_view all params needed to view the link (name => value pairs)
378 416
 	 * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false
379 417
 	 */
380
-	public function add_popuplink($_text, $_view, $_popup = false) {
381
-		if(!$_view || !$_text) { return false; }
418
+	public function add_popuplink($_text, $_view, $_popup = false)
419
+	{
420
+		if(!$_view || !$_text)
421
+		{
422
+return false; }
382 423
 		$this->popup_links[] = (object)array(	'text'	=> $_text,
383 424
 										'view'	=> $_view,
384 425
 										'popup'	=> $_popup,
@@ -391,10 +432,13 @@  discard block
 block discarded – undo
391 432
 	 *
392 433
 	 * @param array $_attachments attachment array (like defined in $this->add_attachment)
393 434
 	 */
394
-	public function set_attachments(array $_attachments) {
435
+	public function set_attachments(array $_attachments)
436
+	{
395 437
 		$this->attachments = array(); // clear array if set
396
-		foreach($_attachments as $attachment) {
397
-			if(is_array($attachment)) {
438
+		foreach($_attachments as $attachment)
439
+		{
440
+			if(is_array($attachment))
441
+			{
398 442
 				$this->add_attachment(
399 443
 					$attachment['string'],
400 444
 					$attachment['filename'],
@@ -418,8 +462,12 @@  discard block
 block discarded – undo
418 462
 	 * @param string $_type File extension (MIME) type.
419 463
 	 * @param string $_path optional path to attachment, if !$_string
420 464
 	 */
421
-	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
422
-		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
465
+	public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null)
466
+	{
467
+		if(!$_string && (!$_path || !file_exists($_path)) || !$_filename)
468
+		{
469
+			return false;
470
+		}
423 471
 		$this->attachments[] = (object)array(
424 472
 			'string' => $_string,
425 473
 			'filename' => $_filename,
@@ -437,33 +485,40 @@  discard block
 block discarded – undo
437 485
 	 * @param array $_skip_backends array with names of the backends to be skipped
438 486
 	 * e.g. array('popup', 'winpopup')
439 487
 	 */
440
-	public function set_skip_backends(array $_skip_backends) {
488
+	public function set_skip_backends(array $_skip_backends)
489
+	{
441 490
 		$this->skip_backends = $_skip_backends;
442 491
 	}
443 492
 
444 493
 	/**
445 494
 	 * sends notifications
446 495
 	 */
447
-	public function send() {
448
-		if (!is_object($this->sender)) {
496
+	public function send()
497
+	{
498
+		if (!is_object($this->sender))
499
+		{
449 500
 			throw new Exception('Error: cannot send notifications. No sender supplied');
450 501
 		}
451
-		if (!is_array($this->receivers) || count($this->receivers) == 0) {
502
+		if (!is_array($this->receivers) || count($this->receivers) == 0)
503
+		{
452 504
 			throw new Exception('Error: cannot send notifications. No receivers supplied');
453 505
 		}
454
-		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup)) {
506
+		if(!$messages = $this->create_messages($this->message_plain, $this->message_html, $this->message_popup))
507
+		{
455 508
 			throw new Exception('Error: cannot send notifications. No valid messages supplied');
456 509
 		}
457 510
 
458 511
 		$available_chains = $this->get_available_chains('routing');
459 512
 
460
-		foreach ($this->receivers as $receiver) {
513
+		foreach ($this->receivers as $receiver)
514
+		{
461 515
 			$user_notified = false;
462 516
 			$prepend_message = '';
463 517
 			$backend_errors = array();
464 518
 			try {
465 519
 				// system or non-system user
466
-				if($receiver->account_id && is_numeric($receiver->account_id)) {
520
+				if($receiver->account_id && is_numeric($receiver->account_id))
521
+				{
467 522
 					// system user, collect data and check for Status and expire state, skip notification if expired or not active
468 523
 					$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
469 524
 					//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@@ -478,51 +533,65 @@  discard block
 block discarded – undo
478 533
 					// check if the receiver has rights to run the notifcation app
479 534
 					$ids = $GLOBALS['egw']->accounts->memberships($receiver->account_id,true);
480 535
 					$ids[] = $receiver->account_id;
481
-					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications')) {
536
+					if ($GLOBALS['egw']->acl->get_specific_rights_for_account($ids,'run','notifications'))
537
+					{
482 538
 						// read the users notification chain
483 539
 						$prefs = new Api\Preferences($receiver->account_id);
484 540
 						$preferences_all = $prefs->read();
485 541
 						$preferences = (object)$preferences_all[self::_appname];
486
-						if($preferences->notification_chain) {
542
+						if($preferences->notification_chain)
543
+						{
487 544
 							// fallback: admin disabled user-chosen chain
488
-							if(!$notification_chain = $available_chains[$preferences->notification_chain]) {
545
+							if(!$notification_chain = $available_chains[$preferences->notification_chain])
546
+							{
489 547
 								$prepend_message .= lang(	'This eGroupWare notification has been sent to you by mail because your'
490 548
 															.' chosen notification-chain has been disabled by the administrator.'
491 549
 															.' Please choose another notification-chain in your preferences!');
492 550
 								$notification_chain = $available_chains[self::_fallback];
493 551
 							}
494
-						} else {
552
+						}
553
+						else
554
+						{
495 555
 							$notification_chain = $available_chains[self::user_fallback]; // fallback: no prefs
496 556
 						}
497
-					} else {
557
+					}
558
+					else
559
+					{
498 560
 						$notification_chain = $available_chains[self::_fallback]; // fallback: no rights to app
499 561
 					}
500
-				} else {
562
+				}
563
+				else
564
+				{
501 565
 					// non-system user
502 566
 					$receiver->handle = $receiver->account_email;
503 567
 					$notification_chain = $available_chains[self::_fallback]; // fallback: non-system user
504 568
 				}
505 569
 
506
-				if($notification_chain == 'disable') {
570
+				if($notification_chain == 'disable')
571
+				{
507 572
 					continue; //user disabled notifications
508 573
 				}
509 574
 
510
-				foreach($notification_chain as $backend => $action) {
575
+				foreach($notification_chain as $backend => $action)
576
+				{
511 577
 					$notification_backend = null;
512 578
 					try {
513 579
 						// check if backend should be skipped
514
-						if( in_array($backend, $this->skip_backends) ) {
580
+						if( in_array($backend, $this->skip_backends) )
581
+						{
515 582
 							// log as error just for the case too much skipping prevents user from being notified
516 583
 							$backend_errors[] = $backend.' will be skipped (as defined by calling application)';
517 584
 							continue;
518 585
 						}
519 586
 
520 587
 						$notification_backend = self::_appname.'_'.$backend;
521
-						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
588
+						if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php'))
589
+						{
522 590
 							throw new Exception('file for '.$notification_backend. ' does not exist');
523 591
 						}
524 592
 						$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
525
-						if ( !($obj instanceof notifications_iface) ) {
593
+						if ( !($obj instanceof notifications_iface) )
594
+						{
526 595
 							unset ( $obj );
527 596
 					 		throw new Exception($notification_backend. ' is no implementation of notifications_iface');
528 597
 						}
@@ -530,31 +599,44 @@  discard block
 block discarded – undo
530 599
 						$llinks = $this->links;
531 600
 						if ($backend == 'popup')
532 601
 						{
533
-							if (!empty($this->popupsubject)) $lsubject = $this->popupsubject;
534
-							if ($this->popup_links) $llinks = $this->popup_links;
602
+							if (!empty($this->popupsubject))
603
+							{
604
+								$lsubject = $this->popupsubject;
605
+							}
606
+							if ($this->popup_links)
607
+							{
608
+								$llinks = $this->popup_links;
609
+							}
535 610
 						}
536 611
 						$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments);
537 612
 					}
538 613
 					catch (Exception $exception) {
539 614
 						$backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();
540 615
 						// try next backend
541
-						if($action == 'fail' || $action == 'continue') {
616
+						if($action == 'fail' || $action == 'continue')
617
+						{
542 618
 							continue;
543 619
 						}
544 620
 						break; // stop running through chain
545 621
 					}
546 622
 					// backend sucseeded
547 623
 					$user_notified = true;
548
-					if($action == 'stop' || $action == 'fail') { break; } // stop running through chain
624
+					if($action == 'stop' || $action == 'fail')
625
+					{
626
+break; } // stop running through chain
549 627
 				}
550 628
 				// check if the user has been notified at all
551
-				if(!$user_notified) {
629
+				if(!$user_notified)
630
+				{
552 631
 					/*error_log('Error: notification of receiver '.$receiver->handle.' failed for the following reasons:');
553 632
 					foreach($backend_errors as $id=>$backend_error) {
554 633
 						error_log($backend_error);
555 634
 					}*/
556 635
 					$error = implode(', ', $backend_errors);
557
-					if (stripos($error, (string)$receiver->handle) !== false) $error = $receiver->handle.': '.$error;
636
+					if (stripos($error, (string)$receiver->handle) !== false)
637
+					{
638
+						$error = $receiver->handle.': '.$error;
639
+					}
558 640
 					self::$errors[] = $error;
559 641
 				}
560 642
 			}
@@ -574,23 +656,35 @@  discard block
 block discarded – undo
574 656
 	 * @param string $_message_popup
575 657
 	 * @return plain and html message in one array, $messages['plain'] and $messages['html'] and, if exists $messages['popup']
576 658
 	 */
577
-	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '') {
578
-		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup)) { return false; } // no message set
659
+	private function create_messages($_message_plain = '', $_message_html = '', $_message_popup = '')
660
+	{
661
+		if(empty($_message_plain) && empty($_message_html) && empty($_message_popup))
662
+		{
663
+return false; } // no message set
579 664
 		$messages = array();
580 665
 
581 666
 		// create the messages
582
-		if(!empty($_message_plain)) {
667
+		if(!empty($_message_plain))
668
+		{
583 669
 			$messages['plain'] = $_message_plain;
584
-		} else {
670
+		}
671
+		else
672
+		{
585 673
 			$messages['plain'] = Api\Mail\Html::convertHTMLToText($_message_html, false, true);
586 674
 		}
587 675
 
588
-		if(!empty($_message_html)) {
676
+		if(!empty($_message_html))
677
+		{
589 678
 			$messages['html'] = $_message_html;
590
-		} else {
679
+		}
680
+		else
681
+		{
591 682
 			$messages['html'] = self::plain2html($_message_plain);
592 683
 		}
593
-		if (!empty($_message_popup)) $messages['popup']=$_message_popup;
684
+		if (!empty($_message_popup))
685
+		{
686
+			$messages['popup']=$_message_popup;
687
+		}
594 688
 		return $messages;
595 689
 	}
596 690
 
@@ -612,10 +706,14 @@  discard block
 block discarded – undo
612 706
 	 * @param string $_prepend just a plain message to prepend, no html!
613 707
 	 * @return plain and html message in one array including the prepended message, $messages['plain'] and $messages['html']
614 708
 	 */
615
-	 private function prepend_message(array $_messages, $_prepend = null) {
616
-		if(strlen($_prepend) > 0) {
617
-			foreach($_messages as $key => $value) {
618
-				switch($key) {
709
+	 private function prepend_message(array $_messages, $_prepend = null)
710
+	 {
711
+		if(strlen($_prepend) > 0)
712
+		{
713
+			foreach($_messages as $key => $value)
714
+			{
715
+				switch($key)
716
+				{
619 717
 					case 'plain':
620 718
 						$_messages[$key] = $_prepend."\n\n".$value;
621 719
 						break;
@@ -642,14 +740,19 @@  discard block
 block discarded – undo
642 740
 	private function get_addresspart($_address, $_part='email')
643 741
 	{
644 742
 		$parts = null;
645
-	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts)) { // _address contains a fullname part
743
+	 	if(strpos($_address,'<') && preg_match('/^(.*)\S?\<(.*)\>/',$_address, $parts))
744
+	 	{
745
+// _address contains a fullname part
646 746
 	 		$fullname = trim(trim($parts[1]),'\"');
647 747
 	 		$email = $parts[2];
648
-	 	} else {
748
+	 	}
749
+	 	else
750
+	 	{
649 751
 	 		$fullname = false;
650 752
 	 		$email = $_address;
651 753
 	 	}
652
-	 	switch($_part) {
754
+	 	switch($_part)
755
+	 	{
653 756
 	 		case 'fullname':
654 757
 	 			return $fullname;
655 758
 	 		case 'email':
@@ -668,11 +771,14 @@  discard block
 block discarded – undo
668 771
 	 * @param string $_output one of: 'routing' or 'human', defaults to 'routing'
669 772
 	 * @return array containing notification chains, output like given in $_output
670 773
 	 */
671
-	public function get_available_chains($_output = 'routing') {
774
+	public function get_available_chains($_output = 'routing')
775
+	{
672 776
 		// determine enabled backends from Api\Config
673 777
 		$enabled_backends = array();
674
-		foreach($this->backends as $backend) {
675
-			switch($backend) {
778
+		foreach($this->backends as $backend)
779
+		{
780
+			switch($backend)
781
+			{
676 782
 				case 'email':
677 783
 				case 'popup':
678 784
 				case 'jpopup':
@@ -687,17 +793,24 @@  discard block
 block discarded – undo
687 793
 
688 794
 		$enabled_chains = array();
689 795
 		$disabled_chains = array();
690
-		foreach($this->notification_chains as $key => $chain) {
796
+		foreach($this->notification_chains as $key => $chain)
797
+		{
691 798
 			$allow_chain = true;
692
-			if(is_array($chain)) {
693
-				foreach(array_keys($chain) as $name) {
694
-					if(!$enabled_backends[$name]) {
799
+			if(is_array($chain))
800
+			{
801
+				foreach(array_keys($chain) as $name)
802
+				{
803
+					if(!$enabled_backends[$name])
804
+					{
695 805
 						$allow_chain = false; // disable whole chain if one backend is disabled
696 806
 					}
697 807
 				}
698
-				if($allow_chain) {
808
+				if($allow_chain)
809
+				{
699 810
 					$enabled_chains[$key] = $chain;
700
-				} else {
811
+				}
812
+				else
813
+				{
701 814
 					$disabled_chains[$key] = $chain;
702 815
 				}
703 816
 			}
@@ -710,15 +823,18 @@  discard block
 block discarded – undo
710 823
 		// create the 'all' chain from the enabled backends
711 824
 		$chain_all = array();
712 825
 		$backend_count = 1;
713
-		foreach($enabled_backends as $backend => $enabled) {
714
-			if($enabled) {
826
+		foreach($enabled_backends as $backend => $enabled)
827
+		{
828
+			if($enabled)
829
+			{
715 830
 				$chain_all[$backend] = count($enabled_backends) == $backend_count ? 'stop' : 'continue';
716 831
 			}
717 832
 			$backend_count++;
718 833
 		}
719 834
 		$common_chains['all'] = $chain_all;
720 835
 
721
-		switch($_output) {
836
+		switch($_output)
837
+		{
722 838
 			case 'human':
723 839
 				$chain_groups = array(
724 840
 					lang('Common chains')	=> 'common_chains',
@@ -727,20 +843,27 @@  discard block
 block discarded – undo
727 843
 					);
728 844
 				$suffix = '_human';
729 845
 				// create descriptions for each chain key in each group
730
-				foreach($chain_groups as $name => $arr_name) {
846
+				foreach($chain_groups as $name => $arr_name)
847
+				{
731 848
 					${$arr_name.$suffix} = array();
732
-					foreach(array_keys(${$arr_name}) as $key) {
733
-						if($arr_name == 'disabled_chains') {
849
+					foreach(array_keys(${$arr_name}) as $key)
850
+					{
851
+						if($arr_name == 'disabled_chains')
852
+						{
734 853
 							${$arr_name.$suffix}[$key] = '('.lang('Disabled').') '.lang($this->chains_descriptions[$key]);
735
-						} else {
854
+						}
855
+						else
856
+						{
736 857
 							${$arr_name.$suffix}[$key] = lang($this->chains_descriptions[$key]);
737 858
 						}
738 859
 					}
739 860
 				}
740 861
 				// summarize all groups with minimum one chain to the final array
741 862
 				$chains_final = array();
742
-				foreach($chain_groups as $name => $arr_name) {
743
-					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0) {
863
+				foreach($chain_groups as $name => $arr_name)
864
+				{
865
+					if(is_array(${$arr_name.$suffix}) && count(${$arr_name.$suffix}) > 0)
866
+					{
744 867
 						$chains_final[$name] = ${$arr_name.$suffix};
745 868
 					}
746 869
 				}
@@ -759,10 +882,13 @@  discard block
 block discarded – undo
759 882
 	 *
760 883
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
761 884
 	 */
762
-	public function deleteaccount($settings) {
763
-		foreach($this->backends as $backend) {
885
+	public function deleteaccount($settings)
886
+	{
887
+		foreach($this->backends as $backend)
888
+		{
764 889
 			$backend_hook = array(self::_appname.'_'.$backend,'deleteaccount');
765
-			if (is_callable($backend_hook)) {
890
+			if (is_callable($backend_hook))
891
+			{
766 892
 				call_user_func($backend_hook,$settings);
767 893
 			}
768 894
 		}
Please login to merge, or discard this patch.
notifications/inc/class.notifications_email.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 	 * @param array $_links
132 132
 	 * @param boolean $_render_html
133 133
 	 * @param boolean $_render_external
134
-	 * @return plain or html rendered link(s) as complete string
134
+	 * @return false|string or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137 137
 		if(!is_array($_links) || count($_links) == 0) { return false; }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 	 * @param object $_preferences
67 67
 	 */
68 68
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
70
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
71 71
 		$this->sender = $_sender;
72 72
 		$this->recipient = $_recipient;
73 73
 		$this->config = $_config;
74 74
 		$this->preferences = $_preferences;
75
-		if(is_object($this->mail))
75
+		if (is_object($this->mail))
76 76
 		{
77 77
 			unset($this->mail);
78 78
 		}
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 		$this->mail->setFrom($this->sender->account_email, $this->sender->account_fullname);
105 105
 
106 106
 		$this->mail->addHeader('Subject', trim($_subject)); // trim the subject to avoid strange wrong encoding problem
107
-		$this->mail->setHtmlBody($body_html, null, false);	// no automatic alternativ
107
+		$this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ
108 108
 		$this->mail->setBody($body_plain);
109 109
 
110
-		if(is_array($_attachments) && count($_attachments) > 0)
110
+		if (is_array($_attachments) && count($_attachments) > 0)
111 111
 		{
112
-			foreach($_attachments as $attachment)
112
+			foreach ($_attachments as $attachment)
113 113
 			{
114 114
 				if ($attachment->string)
115 115
 				{
116 116
 					$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
117 117
 				}
118
-				elseif($attachment->path)
118
+				elseif ($attachment->path)
119 119
 				{
120 120
 					$this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type);
121 121
 				}
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
 	 * @return plain or html rendered link(s) as complete string
135 135
 	 */
136 136
 	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137
-		if(!is_array($_links) || count($_links) == 0) { return false; }
137
+		if (!is_array($_links) || count($_links) == 0) { return false; }
138 138
 
139 139
 		// provide defaults if given arguments are null
140 140
 		// php distinguishes between missing and present(null) arguments
141
-		if(is_null($_render_html)) { $_render_html = false; }
142
-		if(is_null($_render_external)) { $_render_external = true; }
141
+		if (is_null($_render_html)) { $_render_html = false; }
142
+		if (is_null($_render_external)) { $_render_external = true; }
143 143
 		$newline = $_render_html ? "<br />" : "\n";
144 144
 		$hruler = $_render_html ? Api\Html::hr() : '';
145 145
 
146 146
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
147
+		foreach ($_links as $link) {
148
+			if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; }
149 149
 			// do not expose sensitive data
150
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
150
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', Api\Html::link('/index.php', $link->view));
151 151
 			// complete missing protocol and domain part if needed
152 152
 			if ($url{0} == '/' && $_render_external) {
153 153
 				$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			$rendered_links[] = $_render_html ? $a_href : $url;
158 158
 		}
159 159
 
160
-		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links);
160
+		return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links);
161 161
 	}
162 162
 
163 163
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via email.
17 17
  */
18
-class notifications_email implements notifications_iface {
18
+class notifications_email implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -65,9 +66,14 @@  discard block
 block discarded – undo
65 66
 	 * @param object $_config
66 67
 	 * @param object $_preferences
67 68
 	 */
68
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
69
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
70
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
69
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
70
+	{
71
+		if(!is_object($_sender))
72
+		{
73
+throw new Exception("no sender given."); }
74
+		if(!is_object($_recipient))
75
+		{
76
+throw new Exception("no recipient given."); }
71 77
 		$this->sender = $_sender;
72 78
 		$this->recipient = $_recipient;
73 79
 		$this->config = $_config;
@@ -133,23 +139,34 @@  discard block
 block discarded – undo
133 139
 	 * @param boolean $_render_external
134 140
 	 * @return plain or html rendered link(s) as complete string
135 141
 	 */
136
-	private function render_links($_links = false, $_render_html = false, $_render_external = true) {
137
-		if(!is_array($_links) || count($_links) == 0) { return false; }
142
+	private function render_links($_links = false, $_render_html = false, $_render_external = true)
143
+	{
144
+		if(!is_array($_links) || count($_links) == 0)
145
+		{
146
+return false; }
138 147
 
139 148
 		// provide defaults if given arguments are null
140 149
 		// php distinguishes between missing and present(null) arguments
141
-		if(is_null($_render_html)) { $_render_html = false; }
142
-		if(is_null($_render_external)) { $_render_external = true; }
150
+		if(is_null($_render_html))
151
+		{
152
+$_render_html = false; }
153
+		if(is_null($_render_external))
154
+		{
155
+$_render_external = true; }
143 156
 		$newline = $_render_html ? "<br />" : "\n";
144 157
 		$hruler = $_render_html ? Api\Html::hr() : '';
145 158
 
146 159
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; }
160
+		foreach($_links as $link)
161
+		{
162
+			if($_render_external || ! $link->popup)
163
+			{
164
+$link->view['no_popup'] = 1; }
149 165
 			// do not expose sensitive data
150 166
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view));
151 167
 			// complete missing protocol and domain part if needed
152
-			if ($url{0} == '/' && $_render_external) {
168
+			if ($url{0} == '/' && $_render_external)
169
+			{
153 170
 				$url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
154 171
 					($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$url;
155 172
 			}
Please login to merge, or discard this patch.