Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
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.
Spacing   +605 added lines, -606 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,38 +1093,38 @@  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 1105
 			empty($signature['ident_signature']) ||
1107
-			trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='' ||
1106
+			trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '' ||
1108 1107
 			$this->mailPreferences['insertSignatureAtTopOfMessage'] == '1')
1109 1108
 		{
1110 1109
 			$disableRuler = true;
1111 1110
 		}
1112 1111
 		$font_span = $font_part = '';
1113
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1112
+		if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1114 1113
 			// User preferences for style
1115 1114
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1116 1115
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1117
-			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1116
+			$font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">';
1118 1117
 			$font_span = $font_part.'&#8203;</span>';
1119 1118
 			if (empty($font) && empty($font_size)) $font_span = '';
1120 1119
 		}
1121 1120
 		// 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
1122
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1121
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = '';
1123 1122
 		//remove possible html header stuff
1124
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1123
+		if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']);
1125 1124
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1126
-		$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');
1127
-		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1128
-			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1125
+		$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');
1126
+		if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' &&
1127
+			!(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop
1129 1128
 		)
1130 1129
 		{
1131 1130
 			// ON tOP OR BELOW? pREF CAN TELL
@@ -1135,57 +1134,57 @@  discard block
 block discarded – undo
1135 1134
 						'1' => 'before reply, visible during compose',
1136 1135
 						'no_belowaftersend'  => 'appended after reply before sending',
1137 1136
 			*/
1138
-			$insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below'));
1139
-			$sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
1137
+			$insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below'));
1138
+			$sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
1140 1139
 			if ($content['mimeType'] == 'html')
1141 1140
 			{
1142
-				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1143
-				foreach($blockElements as $e)
1141
+				$sigTextStartsWithBlockElement = ($disableRuler ?false:true);
1142
+				foreach ($blockElements as $e)
1144 1143
 				{
1145 1144
 					if ($sigTextStartsWithBlockElement) break;
1146
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1145
+					if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true;
1147 1146
 				}
1148 1147
 			}
1149
-			if($content['mimeType'] == 'html') {
1148
+			if ($content['mimeType'] == 'html') {
1150 1149
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1151 1150
 				$inbetween = '';
1152 1151
 			} else {
1153
-				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1152
+				$before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
1154 1153
 				$inbetween = "\r\n";
1155 1154
 			}
1156 1155
 			if ($content['mimeType'] == 'html')
1157 1156
 			{
1158
-				$sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>");
1157
+				$sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>");
1159 1158
 			}
1160 1159
 
1161 1160
 			if ($insertSigOnTop === 'below')
1162 1161
 			{
1163
-				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true));
1162
+				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true));
1164 1163
 			}
1165 1164
 			else
1166 1165
 			{
1167
-				$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
1166
+				$content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body'];
1168 1167
 			}
1169 1168
 		}
1170 1169
 		else
1171 1170
 		{
1172
-			$content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":"");
1171
+			$content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : "");
1173 1172
 		}
1174 1173
 		//error_log(__METHOD__.__LINE__.$content['body']);
1175 1174
 
1176 1175
 		// prepare body
1177 1176
 		// 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
1178
-		$content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8');
1177
+		$content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8');
1179 1178
 		//error_log(__METHOD__.__LINE__.array2string($content));
1180 1179
 
1181 1180
 		// get identities of all accounts as "$acc_id:$ident_id" => $identity
1182 1181
 		$sel_options['mailaccount'] = $identities = array();
1183
-		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1182
+		foreach (Mail\Account::search(true, false) as $acc_id => $account)
1184 1183
 		{
1185 1184
 			// do NOT add SMTP only accounts as identities
1186 1185
 			if (!$account->is_imap(false)) continue;
1187 1186
 
1188
-			foreach($account->identities($acc_id) as $ident_id => $identity)
1187
+			foreach ($account->identities($acc_id) as $ident_id => $identity)
1189 1188
 			{
1190 1189
 				$sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity;
1191 1190
 				$identities[$ident_id] = $identity;
@@ -1196,7 +1195,7 @@  discard block
 block discarded – undo
1196 1195
 		//$content['bcc'] = array('[email protected]','[email protected]');
1197 1196
 		// address stuff like from, to, cc, replyto
1198 1197
 		$destinationRows = 0;
1199
-		foreach(self::$destinations as $destination) {
1198
+		foreach (self::$destinations as $destination) {
1200 1199
 			if (!is_array($content[$destination]))
1201 1200
 			{
1202 1201
 				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
@@ -1204,22 +1203,22 @@  discard block
 block discarded – undo
1204 1203
 			$addr_content = $content[strtolower($destination)];
1205 1204
 			// we clear the given address array and rebuild it
1206 1205
 			unset($content[strtolower($destination)]);
1207
-			foreach((array)$addr_content as $key => $value) {
1208
-				if ($value=="NIL@NIL") continue;
1209
-				if ($destination=='replyto' && str_replace('"','',$value) ==
1210
-					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1206
+			foreach ((array)$addr_content as $key => $value) {
1207
+				if ($value == "NIL@NIL") continue;
1208
+				if ($destination == 'replyto' && str_replace('"', '', $value) ==
1209
+					str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()]))
1211 1210
 				{
1212 1211
 					// preserve/restore the value to content.
1213
-					$content[strtolower($destination)][]=$value;
1212
+					$content[strtolower($destination)][] = $value;
1214 1213
 					continue;
1215 1214
 				}
1216 1215
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1217
-				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1218
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1216
+				$value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT));
1217
+				foreach (Mail::parseAddressList($value) as $addressObject) {
1219 1218
 					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1220
-					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1219
+					$address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
1221 1220
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1222
-					$content[strtolower($destination)][]=$address;
1221
+					$content[strtolower($destination)][] = $address;
1223 1222
 					$destinationRows++;
1224 1223
 				}
1225 1224
 			}
@@ -1227,10 +1226,10 @@  discard block
 block discarded – undo
1227 1226
 		if ($_content)
1228 1227
 		{
1229 1228
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1230
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1231
-			$content = array_merge($content,$_content);
1229
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']);
1230
+			$content = array_merge($content, $_content);
1232 1231
 
1233
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1232
+			if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true);
1234 1233
 			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1235 1234
 		}
1236 1235
 		else
@@ -1239,12 +1238,12 @@  discard block
 block discarded – undo
1239 1238
 			$content['mailaccount'] = $this->mail_bo->profileID;
1240 1239
 			//error_log(__METHOD__.__LINE__.$content['body']);
1241 1240
 		}
1242
-		$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
1243
-		$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
1244
-		$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body'];
1245
-		$content['showtempname']=0;
1241
+		$content['is_html'] = ($content['mimeType'] == 'html' ?true:'');
1242
+		$content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true);
1243
+		$content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body'];
1244
+		$content['showtempname'] = 0;
1246 1245
 		//if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments']));
1247
-		$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
+		$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)));
1248 1247
 		//if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0;
1249 1248
 		$content['no_griddata'] = empty($content['attachments']);
1250 1249
 		$preserv['attachments'] = $content['attachments'];
@@ -1278,12 +1277,12 @@  discard block
 block discarded – undo
1278 1277
 		$sel_options['mimeType'] = self::$mimeTypes;
1279 1278
 		$sel_options['priority'] = self::$priorities;
1280 1279
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1281
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1280
+		if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3;
1282 1281
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1283 1282
 		$etpl = new Etemplate('mail.compose');
1284 1283
 
1285 1284
 		$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content));
1286
-		if ($content['mimeType']=='html')
1285
+		if ($content['mimeType'] == 'html')
1287 1286
 		{
1288 1287
 			//mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]"
1289 1288
 			$_htmlConfig = Mail::$htmLawed_config;
@@ -1293,23 +1292,23 @@  discard block
 block discarded – undo
1293 1292
 			// and not the eGroupware wide pref to prevent users from trying things that will potentially not work
1294 1293
 			// or not work as expected, as a full featured editor that may be wanted in other apps
1295 1294
 			// is way overloading the "normal" needs for composing mails
1296
-			$content['rtfEditorFeatures']='simple-withimage';//Api\Html\CkEditorConfig::get_ckeditor_config();
1295
+			$content['rtfEditorFeatures'] = 'simple-withimage'; //Api\Html\CkEditorConfig::get_ckeditor_config();
1297 1296
 			//$content['rtfEditorFeatures']='advanced';//Api\Html\CkEditorConfig::get_ckeditor_config();
1298
-			$content['validation_rules']= json_encode(Mail::$htmLawed_config);
1299
-			$etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']);
1300
-			$etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']);
1297
+			$content['validation_rules'] = json_encode(Mail::$htmLawed_config);
1298
+			$etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']);
1299
+			$etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']);
1301 1300
 			Mail::$htmLawed_config = $_htmlConfig;
1302 1301
 		}
1303 1302
 
1304
-		if (isset($content['composeID'])&&!empty($content['composeID']))
1303
+		if (isset($content['composeID']) && !empty($content['composeID']))
1305 1304
 		{
1306 1305
 			$composeCache = $content;
1307 1306
 			unset($composeCache['body']);
1308 1307
 			unset($composeCache['mail_htmltext']);
1309 1308
 			unset($composeCache['mail_plaintext']);
1310
-			Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2);
1309
+			Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2);
1311 1310
 		}
1312
-		if (!isset($_content['serverID'])||empty($_content['serverID']))
1311
+		if (!isset($_content['serverID']) || empty($_content['serverID']))
1313 1312
 		{
1314 1313
 			$content['serverID'] = $this->mail_bo->profileID;
1315 1314
 		}
@@ -1325,13 +1324,13 @@  discard block
 block discarded – undo
1325 1324
 		$preserv['list-id'] = $content['list-id'];
1326 1325
 		$preserv['mode'] = $content['mode'];
1327 1326
 		// convert it back to checkbox expectations
1328
-		if($content['mimeType'] == 'html') {
1329
-			$content['mimeType']=1;
1327
+		if ($content['mimeType'] == 'html') {
1328
+			$content['mimeType'] = 1;
1330 1329
 		} else {
1331
-			$content['mimeType']=0;
1330
+			$content['mimeType'] = 0;
1332 1331
 		}
1333 1332
 		// set the current selected mailaccount as param for folderselection
1334
-		$etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount']));
1333
+		$etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount']));
1335 1334
 		// join again mailaccount and identity
1336 1335
 		$content['mailaccount'] .= ':'.$content['mailidentity'];
1337 1336
 		//Try to set the initial selected account to the first identity match found
@@ -1350,14 +1349,14 @@  discard block
 block discarded – undo
1350 1349
 			}
1351 1350
 		}
1352 1351
 		// Resolve distribution list before send content to client
1353
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1352
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $f)
1354 1353
 		{
1355
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1354
+			if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]);
1356 1355
 		}
1357 1356
 
1358 1357
 		$content['to'] = self::resolveEmailAddressList($content['to']);
1359 1358
 		//error_log(__METHOD__.__LINE__.array2string($content));
1360
-		$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
1359
+		$etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2);
1361 1360
 	}
1362 1361
 
1363 1362
 	/**
@@ -1378,9 +1377,9 @@  discard block
 block discarded – undo
1378 1377
 		$content = array();
1379 1378
 		//error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply");
1380 1379
 		// on forward we may have to support multiple ids
1381
-		if ($from=='forward')
1380
+		if ($from == 'forward')
1382 1381
 		{
1383
-			$replyIds = explode(',',$mail_id);
1382
+			$replyIds = explode(',', $mail_id);
1384 1383
 			$mail_id = $replyIds[0];
1385 1384
 		}
1386 1385
 		$hA = mail_ui::splitRowID($mail_id);
@@ -1392,15 +1391,15 @@  discard block
 block discarded – undo
1392 1391
 			$this->changeProfile($icServerID);
1393 1392
 		}
1394 1393
 		$icServer = $this->mail_bo->icServer;
1395
-		if (!empty($folder) && !empty($msgUID) )
1394
+		if (!empty($folder) && !empty($msgUID))
1396 1395
 		{
1397 1396
 			// this fill the session data with the values from the original email
1398
-			switch($from)
1397
+			switch ($from)
1399 1398
 			{
1400 1399
 				case 'composefromdraft':
1401 1400
 				case 'composeasnew':
1402 1401
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1403
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1402
+					if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft';
1404 1403
 					$content['processedmail_id'] = $mail_id;
1405 1404
 
1406 1405
 					$_focusElement = 'body';
@@ -1416,7 +1415,7 @@  discard block
 block discarded – undo
1416 1415
 					$isReply = true;
1417 1416
 					break;
1418 1417
 				case 'forward':
1419
-					$mode  = ($_GET['mode']=='forwardinline'?'inline':'asmail');
1418
+					$mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail');
1420 1419
 					// this fill the session data with the values from the original email
1421 1420
 					foreach ($replyIds as &$mail_id)
1422 1421
 					{
@@ -1426,14 +1425,14 @@  discard block
 block discarded – undo
1426 1425
 						$folder = $hA['folder'];
1427 1426
 						$content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode);
1428 1427
 					}
1429
-					$content['processedmail_id'] = implode(',',$replyIds);
1428
+					$content['processedmail_id'] = implode(',', $replyIds);
1430 1429
 					$content['mode'] = 'forward';
1431
-					$isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline');
1432
-					$suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution
1430
+					$isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline');
1431
+					$suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution
1433 1432
 					$_focusElement = 'to';
1434 1433
 					break;
1435 1434
 				default:
1436
-					error_log('Unhandled compose source: ' . $from);
1435
+					error_log('Unhandled compose source: '.$from);
1437 1436
 			}
1438 1437
 		}
1439 1438
 		else if ($from == 'merge' && $_REQUEST['document'])
@@ -1448,12 +1447,12 @@  discard block
 block discarded – undo
1448 1447
 			$document_merge = new $merge_class();
1449 1448
 			$this->mail_bo->openConnection();
1450 1449
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1451
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1450
+			if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids);
1452 1451
 			try
1453 1452
 			{
1454 1453
 				$merged_mail_id = '';
1455 1454
 				$folder = '';
1456
-				if(($error = $document_merge->check_document($_REQUEST['document'],'')))
1455
+				if (($error = $document_merge->check_document($_REQUEST['document'], '')))
1457 1456
 				{
1458 1457
 					$content['msg'] = $error;
1459 1458
 					return $content;
@@ -1463,10 +1462,10 @@  discard block
 block discarded – undo
1463 1462
 				//$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
1464 1463
 
1465 1464
 				// Actually do the merge
1466
-				if(count($merge_ids) <= 1)
1465
+				if (count($merge_ids) <= 1)
1467 1466
 				{
1468 1467
 					$results = $this->mail_bo->importMessageToMergeAndSend(
1469
-						$document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1468
+						$document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1470 1469
 					);
1471 1470
 
1472 1471
 					// Open compose
@@ -1477,9 +1476,9 @@  discard block
 block discarded – undo
1477 1476
 				}
1478 1477
 				else
1479 1478
 				{
1480
-					$success = implode(', ',$results['success']);
1479
+					$success = implode(', ', $results['success']);
1481 1480
 					$fail = implode(', ', $results['failed']);
1482
-					if($success) Framework::message($success, 'success');
1481
+					if ($success) Framework::message($success, 'success');
1483 1482
 					Framework::window_close($fail);
1484 1483
 				}
1485 1484
 			}
@@ -1507,22 +1506,22 @@  discard block
 block discarded – undo
1507 1506
 		return 1;
1508 1507
 	}
1509 1508
 
1510
-	function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false)
1509
+	function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false)
1511 1510
 	{
1512 1511
 		$stripalltags = true;
1513 1512
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1514
-		if (!$sourceishtml) $stripalltags=false;
1515
-		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1513
+		if (!$sourceishtml) $stripalltags = false;
1514
+		return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags);
1516 1515
 	}
1517 1516
 
1518 1517
 	function generateRFC822Address($_addressObject)
1519 1518
 	{
1520
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1521
-			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1522
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1523
-			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1519
+		if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1520
+			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1521
+		} elseif ($_addressObject->mailbox && $_addressObject->host) {
1522
+			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1524 1523
 		} else {
1525
-			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1524
+			return $this->mail_bo->decode_header($_addressObject->mailbox, true);
1526 1525
 		}
1527 1526
 	}
1528 1527
 
@@ -1537,9 +1536,9 @@  discard block
 block discarded – undo
1537 1536
 	// $_mode can be:
1538 1537
 	// single: for a reply to one address
1539 1538
 	// all: for a reply to all
1540
-	function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL)
1539
+	function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL)
1541 1540
 	{
1542
-		unset($_icServer);	// not used
1541
+		unset($_icServer); // not used
1543 1542
 		$this->sessionData['to'] = array();
1544 1543
 
1545 1544
 		$mail_bo = $this->mail_bo;
@@ -1548,7 +1547,7 @@  discard block
 block discarded – undo
1548 1547
 
1549 1548
 		// get message headers for specified message
1550 1549
 		#$headers	= $mail_bo->getMessageHeader($_folder, $_uid);
1551
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID);
1550
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
1552 1551
 		$addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID);
1553 1552
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1554 1553
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
@@ -1556,10 +1555,10 @@  discard block
 block discarded – undo
1556 1555
 
1557 1556
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1558 1557
 		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1559
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1560
-				$fval=$val;
1558
+			foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) {
1559
+				$fval = $val;
1561 1560
 				$icServerID = $mail_bo->icServer->ImapServerId;
1562
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1561
+				if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2);
1563 1562
 				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1564 1563
 				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1565 1564
 			}
@@ -1595,71 +1594,71 @@  discard block
 block discarded – undo
1595 1594
 			}
1596 1595
 		}
1597 1596
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1598
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1597
+		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder);
1599 1598
 		$this->sessionData['uid'] = $_uid;
1600 1599
 		$this->sessionData['messageFolder'] = $_folder;
1601 1600
 		$this->sessionData['isDraft'] = true;
1602 1601
 		$foundAddresses = array();
1603
-		foreach((array)$headers['CC'] as $val) {
1604
-			$rfcAddr=Mail::parseAddressList($val);
1602
+		foreach ((array)$headers['CC'] as $val) {
1603
+			$rfcAddr = Mail::parseAddressList($val);
1605 1604
 			$_rfcAddr = $rfcAddr[0];
1606 1605
 			if (!$_rfcAddr->valid) continue;
1607
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1606
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1608 1607
 				continue;
1609 1608
 			}
1610
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1611
-			if(!$foundAddresses[$keyemail]) {
1612
-				$address = $this->mail_bo->decode_header($val,true);
1609
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1610
+			if (!$foundAddresses[$keyemail]) {
1611
+				$address = $this->mail_bo->decode_header($val, true);
1613 1612
 				$this->sessionData['cc'][] = $val;
1614 1613
 				$foundAddresses[$keyemail] = true;
1615 1614
 			}
1616 1615
 		}
1617 1616
 
1618
-		foreach((array)$headers['TO'] as $val) {
1619
-			if(!is_array($val))
1617
+		foreach ((array)$headers['TO'] as $val) {
1618
+			if (!is_array($val))
1620 1619
 			{
1621 1620
 				$this->sessionData['to'][] = $val;
1622 1621
 				continue;
1623 1622
 			}
1624
-			$rfcAddr=Mail::parseAddressList($val);
1623
+			$rfcAddr = Mail::parseAddressList($val);
1625 1624
 			$_rfcAddr = $rfcAddr[0];
1626 1625
 			if (!$_rfcAddr->valid) continue;
1627
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1626
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1628 1627
 				continue;
1629 1628
 			}
1630
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1631
-			if(!$foundAddresses[$keyemail]) {
1632
-				$address = $this->mail_bo->decode_header($val,true);
1629
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1630
+			if (!$foundAddresses[$keyemail]) {
1631
+				$address = $this->mail_bo->decode_header($val, true);
1633 1632
 				$this->sessionData['to'][] = $val;
1634 1633
 				$foundAddresses[$keyemail] = true;
1635 1634
 			}
1636 1635
 		}
1637 1636
 
1638
-		foreach((array)$headers['REPLY-TO'] as $val) {
1639
-			$rfcAddr=Mail::parseAddressList($val);
1637
+		foreach ((array)$headers['REPLY-TO'] as $val) {
1638
+			$rfcAddr = Mail::parseAddressList($val);
1640 1639
 			$_rfcAddr = $rfcAddr[0];
1641 1640
 			if (!$_rfcAddr->valid) continue;
1642
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1641
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1643 1642
 				continue;
1644 1643
 			}
1645
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1646
-			if(!$foundAddresses[$keyemail]) {
1647
-				$address = $this->mail_bo->decode_header($val,true);
1644
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1645
+			if (!$foundAddresses[$keyemail]) {
1646
+				$address = $this->mail_bo->decode_header($val, true);
1648 1647
 				$this->sessionData['replyto'][] = $val;
1649 1648
 				$foundAddresses[$keyemail] = true;
1650 1649
 			}
1651 1650
 		}
1652 1651
 
1653
-		foreach((array)$headers['BCC'] as $val) {
1654
-			$rfcAddr=Mail::parseAddressList($val);
1652
+		foreach ((array)$headers['BCC'] as $val) {
1653
+			$rfcAddr = Mail::parseAddressList($val);
1655 1654
 			$_rfcAddr = $rfcAddr[0];
1656 1655
 			if (!$_rfcAddr->valid) continue;
1657
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1656
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1658 1657
 				continue;
1659 1658
 			}
1660
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1661
-			if(!$foundAddresses[$keyemail]) {
1662
-				$address = $this->mail_bo->decode_header($val,true);
1659
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1660
+			if (!$foundAddresses[$keyemail]) {
1661
+				$address = $this->mail_bo->decode_header($val, true);
1663 1662
 				$this->sessionData['bcc'][] = $val;
1664 1663
 				$foundAddresses[$keyemail] = true;
1665 1664
 			}
@@ -1668,48 +1667,48 @@  discard block
 block discarded – undo
1668 1667
 		$this->sessionData['subject']	= $mail_bo->decode_header($headers['SUBJECT']);
1669 1668
 		// remove a printview tag if composing
1670 1669
 		$searchfor = '/^\['.lang('printview').':\]/';
1671
-		$this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']);
1672
-		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1670
+		$this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']);
1671
+		$bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID);
1673 1672
 		//_debug_array($bodyParts);
1674 1673
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1675
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1676
-			$this->sessionData['mimeType'] 	= 'html';
1674
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
1675
+			$this->sessionData['mimeType'] = 'html';
1677 1676
 
1678
-			for($i=0; $i<count($bodyParts); $i++) {
1679
-				if($i>0) {
1677
+			for ($i = 0; $i < count($bodyParts); $i++) {
1678
+				if ($i > 0) {
1680 1679
 					$this->sessionData['body'] .= '<hr>';
1681 1680
 				}
1682
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1681
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
1683 1682
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1684 1683
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1685 1684
 				}
1686
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1685
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1687 1686
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1688 1687
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1689
-				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1688
+				$this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body'];
1690 1689
 			}
1691 1690
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1692 1691
 
1693 1692
 		} else {
1694
-			$this->sessionData['mimeType']	= 'plain';
1693
+			$this->sessionData['mimeType'] = 'plain';
1695 1694
 
1696
-			for($i=0; $i<count($bodyParts); $i++) {
1697
-				if($i>0) {
1695
+			for ($i = 0; $i < count($bodyParts); $i++) {
1696
+				if ($i > 0) {
1698 1697
 					$this->sessionData['body'] .= "<hr>";
1699 1698
 				}
1700
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1699
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1701 1700
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1702 1701
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1703
-				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
1702
+				$this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body'];
1704 1703
 			}
1705
-			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1704
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain');
1706 1705
 		}
1707 1706
 
1708
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1709
-			foreach($attachments as $attachment) {
1707
+		if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1708
+			foreach ($attachments as $attachment) {
1710 1709
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1711 1710
 				$cid = $attachment['cid'];
1712
-				$match=null;
1711
+				$match = null;
1713 1712
 				preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match);
1714 1713
 				//error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match));
1715 1714
 				if (!$match || !$attachment['cid'])
@@ -1729,7 +1728,7 @@  discard block
 block discarded – undo
1729 1728
 
1730 1729
 	function getErrorInfo()
1731 1730
 	{
1732
-		if(isset($this->errorInfo)) {
1731
+		if (isset($this->errorInfo)) {
1733 1732
 			$errorInfo = $this->errorInfo;
1734 1733
 			unset($this->errorInfo);
1735 1734
 			return $errorInfo;
@@ -1737,39 +1736,39 @@  discard block
 block discarded – undo
1737 1736
 		return false;
1738 1737
 	}
1739 1738
 
1740
-	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false)
1739
+	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false)
1741 1740
 	{
1742 1741
 		if ($_mode)
1743 1742
 		{
1744 1743
 			$modebuff = $this->mailPreferences['message_forwarding'];
1745 1744
 			$this->mailPreferences['message_forwarding'] = $_mode;
1746 1745
 		}
1747
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1746
+		if ($this->mailPreferences['message_forwarding'] == 'inline') {
1748 1747
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1749 1748
 		}
1750
-		$mail_bo    = $this->mail_bo;
1749
+		$mail_bo = $this->mail_bo;
1751 1750
 		$mail_bo->openConnection();
1752 1751
 		$mail_bo->reopen($_folder);
1753 1752
 
1754 1753
 		// get message headers for specified message
1755
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder);
1754
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder);
1756 1755
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1757 1756
 		//_debug_array($headers); exit;
1758 1757
 		// check for Re: in subject header
1759
-		$this->sessionData['subject'] 	= "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']);
1758
+		$this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']);
1760 1759
 		// the three attributes below are substituted by processedmail_id and mode
1761 1760
 		//$this->sessionData['sourceFolder']=$_folder;
1762 1761
 		//$this->sessionData['forwardFlag']='forwarded';
1763 1762
 		//$this->sessionData['forwardedUID']=$_uid;
1764
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1765
-			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1766
-			if($headers['SIZE'])
1763
+		if ($this->mailPreferences['message_forwarding'] == 'asmail') {
1764
+			$this->sessionData['mimeType'] = $this->mailPreferences['composeOptions'];
1765
+			if ($headers['SIZE'])
1767 1766
 				$size				= $headers['SIZE'];
1768 1767
 			else
1769 1768
 				$size				= lang('unknown');
1770 1769
 
1771 1770
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1772
-				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
1771
+				$mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml',
1773 1772
 				'MESSAGE/RFC822', $size);
1774 1773
 		}
1775 1774
 		else
@@ -1777,10 +1776,10 @@  discard block
 block discarded – undo
1777 1776
 			unset($this->sessionData['in-reply-to']);
1778 1777
 			unset($this->sessionData['to']);
1779 1778
 			unset($this->sessionData['cc']);
1780
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
1779
+			if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID, null, true, false, false))) {
1781 1780
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1782
-				foreach($attachments as $attachment) {
1783
-					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1781
+				foreach ($attachments as $attachment) {
1782
+					if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1784 1783
 					{
1785 1784
 						$this->addMessageAttachment($_uid, $attachment['partID'],
1786 1785
 							$_folder,
@@ -1809,7 +1808,7 @@  discard block
 block discarded – undo
1809 1808
 	 * @param array $_content the content passed to the function and to be modified
1810 1809
 	 * @return void
1811 1810
 	 */
1812
-	function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false)
1811
+	function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false)
1813 1812
 	{
1814 1813
 		//error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content));
1815 1814
 
@@ -1818,7 +1817,7 @@  discard block
 block discarded – undo
1818 1817
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
1819 1818
 		try
1820 1819
 		{
1821
-			$tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false);
1820
+			$tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false);
1822 1821
 		}
1823 1822
 		catch (Api\Exception\WrongUserinput $e)
1824 1823
 		{
@@ -1834,8 +1833,8 @@  discard block
 block discarded – undo
1834 1833
 			foreach ((array)$_content['attachments'] as $attach)
1835 1834
 			{
1836 1835
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1837
-					strtolower($_formData['type'])== strtolower($attach['type']) &&
1838
-					stripos($_formData['file'],'vfs://') !== false) return;
1836
+					strtolower($_formData['type']) == strtolower($attach['type']) &&
1837
+					stripos($_formData['file'], 'vfs://') !== false) return;
1839 1838
 			}
1840 1839
 		}
1841 1840
 		if ($attachfailed === false)
@@ -1847,7 +1846,7 @@  discard block
 block discarded – undo
1847 1846
 				'tmp_name'	=> $tmpFileName,
1848 1847
 				'size'	=> $_formData['size']
1849 1848
 			);
1850
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
1849
+			if (!is_array($_content['attachments'])) $_content['attachments'] = array();
1851 1850
 			$_content['attachments'][] = $buffer;
1852 1851
 			unset($buffer);
1853 1852
 		}
@@ -1857,9 +1856,9 @@  discard block
 block discarded – undo
1857 1856
 		}
1858 1857
 	}
1859 1858
 
1860
-	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail= null)
1859
+	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail = null)
1861 1860
 	{
1862
-		$this->sessionData['attachments'][]=array (
1861
+		$this->sessionData['attachments'][] = array(
1863 1862
 			'uid'		=> $_uid,
1864 1863
 			'partID'	=> $_partID,
1865 1864
 			'name'		=> $_name,
@@ -1867,7 +1866,7 @@  discard block
 block discarded – undo
1867 1866
 			'size'		=> $_size,
1868 1867
 			'folder'	=> $_folder,
1869 1868
 			'winmailFlag' => $_is_winmail,
1870
-			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1),
1869
+			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1),
1871 1870
 		);
1872 1871
 	}
1873 1872
 
@@ -1876,7 +1875,7 @@  discard block
 block discarded – undo
1876 1875
 		// read attachment data from etemplate request, use tmpname only to identify it
1877 1876
 		if (($request = Etemplate\Request::read($_GET['etemplate_exec_id'])))
1878 1877
 		{
1879
-			foreach($request->preserv['attachments'] as $attachment)
1878
+			foreach ($request->preserv['attachments'] as $attachment)
1880 1879
 			{
1881 1880
 				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
1882 1881
 			}
@@ -1888,7 +1887,7 @@  discard block
 block discarded – undo
1888 1887
 		}
1889 1888
 
1890 1889
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
1891
-		if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs')
1890
+		if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs')
1892 1891
 		{
1893 1892
 			Vfs::load_wrapper('vfs');
1894 1893
 		}
@@ -1897,7 +1896,7 @@  discard block
 block discarded – undo
1897 1896
 		{
1898 1897
 			$attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['tmp_name']);
1899 1898
 		}
1900
-		if(!file_exists($attachment['tmp_name']))
1899
+		if (!file_exists($attachment['tmp_name']))
1901 1900
 		{
1902 1901
 			header('HTTP/1.1 404 Not found');
1903 1902
 			die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!');
@@ -1910,7 +1909,7 @@  discard block
 block discarded – undo
1910 1909
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY')
1911 1910
 			{
1912 1911
 				$sfxMimeType = $attachment['type'];
1913
-				$buff = explode('.',$attachment['tmp_name']);
1912
+				$buff = explode('.', $attachment['tmp_name']);
1914 1913
 				$suffix = '';
1915 1914
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1916 1915
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -1922,10 +1921,10 @@  discard block
 block discarded – undo
1922 1921
 			{
1923 1922
 				//error_log(__METHOD__."about to call calendar_ical");
1924 1923
 				$calendar_ical = new calendar_ical();
1925
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1924
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
1926 1925
 				//error_log(__METHOD__.array2string($eventid));
1927 1926
 				if (!$eventid) $eventid = -1;
1928
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1927
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true);
1929 1928
 				//error_log(__METHOD__.$event);
1930 1929
 				if ((int)$event > 0)
1931 1930
 				{
@@ -1933,7 +1932,7 @@  discard block
 block discarded – undo
1933 1932
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
1934 1933
 						'cal_id'      => $event,
1935 1934
 					);
1936
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1935
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1937 1936
 				}
1938 1937
 				//Import failed, download content anyway
1939 1938
 			}
@@ -1948,13 +1947,13 @@  discard block
 block discarded – undo
1948 1947
 				{
1949 1948
 					$vcard['uid'] = trim($vcard['uid']);
1950 1949
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1951
-					$contact = $addressbook_vcal->find_contact($vcard,false);
1950
+					$contact = $addressbook_vcal->find_contact($vcard, false);
1952 1951
 				}
1953 1952
 				if (!$contact) $contact = null;
1954 1953
 				// 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))
1955
-				if ($contact || count($vcard)>2)
1954
+				if ($contact || count($vcard) > 2)
1956 1955
 				{
1957
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true);
1956
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ?array_shift($contact) : $contact), true);
1958 1957
 				}
1959 1958
 				if ((int)$contact > 0)
1960 1959
 				{
@@ -1962,13 +1961,13 @@  discard block
 block discarded – undo
1962 1961
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
1963 1962
 						'contact_id'	=> $contact,
1964 1963
 					);
1965
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1964
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1966 1965
 				}
1967 1966
 				//Import failed, download content anyway
1968 1967
 			}
1969 1968
 		}
1970 1969
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
1971
-		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
1970
+		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save");
1972 1971
 		echo $attachment['attachment'];
1973 1972
 
1974 1973
 		exit();
@@ -1981,11 +1980,11 @@  discard block
 block discarded – undo
1981 1980
 	 * @param string haystack
1982 1981
 	 * @return boolean
1983 1982
 	 */
1984
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
1983
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) {
1985 1984
 		foreach (array_keys($arrayToTestAgainst) as $k)
1986 1985
 		{
1987 1986
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
1988
-			if (stripos($haystack,$k)!==false)
1987
+			if (stripos($haystack, $k) !== false)
1989 1988
 			{
1990 1989
 				//error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace());
1991 1990
 				return true;
@@ -2008,10 +2007,10 @@  discard block
 block discarded – undo
2008 2007
 	 */
2009 2008
 	function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID)
2010 2009
 	{
2011
-		unset($_icServer);	// not used
2010
+		unset($_icServer); // not used
2012 2011
 		$foundAddresses = array();
2013 2012
 
2014
-		$mail_bo  = $this->mail_bo;
2013
+		$mail_bo = $this->mail_bo;
2015 2014
 		$mail_bo->openConnection();
2016 2015
 		$mail_bo->reopen($_folder);
2017 2016
 
@@ -2019,20 +2018,20 @@  discard block
 block discarded – undo
2019 2018
 
2020 2019
 		// get message headers for specified message
2021 2020
 		//print "AAAA: $_folder, $_uid, $_partID<br>";
2022
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true);
2021
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true);
2023 2022
 		//$headers	= $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder);
2024 2023
 		$this->sessionData['uid'] = $_uid;
2025 2024
 		$this->sessionData['messageFolder'] = $_folder;
2026
-		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']);
2027
-		$this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']);
2025
+		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']);
2026
+		$this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']);
2028 2027
 
2029 2028
 		// break reference into multiple lines if they're greater than 998 chars
2030 2029
 		// and remove comma seperation. Fix error serer does not support binary
2031 2030
 		// data due to long references.
2032
-		if (strlen($this->sessionData['references'])> 998)
2031
+		if (strlen($this->sessionData['references']) > 998)
2033 2032
 		{
2034
-			$temp_refs = explode(',',$this->sessionData['references']);
2035
-			$this->sessionData['references'] = implode(" ",$temp_refs);
2033
+			$temp_refs = explode(',', $this->sessionData['references']);
2034
+			$this->sessionData['references'] = implode(" ", $temp_refs);
2036 2035
 		}
2037 2036
 
2038 2037
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
@@ -2042,36 +2041,36 @@  discard block
 block discarded – undo
2042 2041
 		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2043 2042
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2044 2043
 		// check for Reply-To: header and use if available
2045
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2046
-			foreach($headers['REPLY-TO'] as $val) {
2047
-				if(!$foundAddresses[$val]) {
2044
+		if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2045
+			foreach ($headers['REPLY-TO'] as $val) {
2046
+				if (!$foundAddresses[$val]) {
2048 2047
 					$oldTo[] = $val;
2049 2048
 					$foundAddresses[$val] = true;
2050 2049
 				}
2051 2050
 			}
2052
-			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2051
+			$oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']);
2053 2052
 		} else {
2054
-			foreach($headers['FROM'] as $val) {
2055
-				if(!$foundAddresses[$val]) {
2053
+			foreach ($headers['FROM'] as $val) {
2054
+				if (!$foundAddresses[$val]) {
2056 2055
 					$oldTo[] = $val;
2057 2056
 					$foundAddresses[$val] = true;
2058 2057
 				}
2059 2058
 			}
2060
-			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2059
+			$oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']);
2061 2060
 		}
2062 2061
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2063
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2062
+		if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) {
2064 2063
 			$this->sessionData['to'] = $oldTo;
2065 2064
 		}
2066 2065
 
2067
-		if($_mode == 'all') {
2066
+		if ($_mode == 'all') {
2068 2067
 			// reply to any address which is cc, but not to my self
2069 2068
 			#if($headers->cc) {
2070
-				foreach($headers['CC'] as $val) {
2071
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2069
+				foreach ($headers['CC'] as $val) {
2070
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2072 2071
 						continue;
2073 2072
 					}
2074
-					if(!$foundAddresses[$val]) {
2073
+					if (!$foundAddresses[$val]) {
2075 2074
 						$this->sessionData['cc'][] = $val;
2076 2075
 						$foundAddresses[$val] = true;
2077 2076
 					}
@@ -2080,11 +2079,11 @@  discard block
 block discarded – undo
2080 2079
 
2081 2080
 			// reply to any address which is to, but not to my self
2082 2081
 			#if($headers->to) {
2083
-				foreach($headers['TO'] as $val) {
2084
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2082
+				foreach ($headers['TO'] as $val) {
2083
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2085 2084
 						continue;
2086 2085
 					}
2087
-					if(!$foundAddresses[$val]) {
2086
+					if (!$foundAddresses[$val]) {
2088 2087
 						$this->sessionData['to'][] = $val;
2089 2088
 						$foundAddresses[$val] = true;
2090 2089
 					}
@@ -2092,12 +2091,12 @@  discard block
 block discarded – undo
2092 2091
 			#}
2093 2092
 
2094 2093
 			#if($headers->from) {
2095
-				foreach($headers['FROM'] as $val) {
2096
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2094
+				foreach ($headers['FROM'] as $val) {
2095
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2097 2096
 						continue;
2098 2097
 					}
2099 2098
 					//error_log(__METHOD__.__LINE__.' '.$val);
2100
-					if(!$foundAddresses[$val]) {
2099
+					if (!$foundAddresses[$val]) {
2101 2100
 						$this->sessionData['to'][] = $val;
2102 2101
 						$foundAddresses[$val] = true;
2103 2102
 					}
@@ -2106,59 +2105,59 @@  discard block
 block discarded – undo
2106 2105
 		}
2107 2106
 
2108 2107
 		// check for Re: in subject header
2109
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2108
+		if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2110 2109
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2111 2110
 		} else {
2112
-			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2111
+			$this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']);
2113 2112
 		}
2114 2113
 
2115 2114
 		//_debug_array($headers);
2116 2115
 		//error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions']));
2117
-		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID);
2116
+		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID);
2118 2117
 		//_debug_array($bodyParts);
2119 2118
 		$styles = Mail::getStyles($bodyParts);
2120 2119
 
2121
-		$fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM']));
2120
+		$fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM']));
2122 2121
 
2123 2122
 		$toAddressA = array();
2124 2123
 		$toAddress = '';
2125 2124
 		foreach ($headers['TO'] as $mailheader) {
2126
-			$toAddressA[] =  $mailheader;
2125
+			$toAddressA[] = $mailheader;
2127 2126
 		}
2128
-		if (count($toAddressA)>0)
2127
+		if (count($toAddressA) > 0)
2129 2128
 		{
2130
-			$toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA));
2131
-			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2129
+			$toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA));
2130
+			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2132 2131
 		}
2133 2132
 		$ccAddressA = array();
2134 2133
 		$ccAddress = '';
2135 2134
 		foreach ($headers['CC'] as $mailheader) {
2136
-			$ccAddressA[] =  $mailheader;
2135
+			$ccAddressA[] = $mailheader;
2137 2136
 		}
2138
-		if (count($ccAddressA)>0)
2137
+		if (count($ccAddressA) > 0)
2139 2138
 		{
2140
-			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2141
-			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2139
+			$ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA));
2140
+			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2142 2141
 		}
2143
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2144
-			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2142
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
2143
+			$this->sessionData['body'] = /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2145 2144
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2146 2145
 				$toAddress.$ccAddress.
2147
-				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2146
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>".
2148 2147
 				'----------------------------------------------------------'."</div>";
2149
-			$this->sessionData['mimeType'] 	= 'html';
2148
+			$this->sessionData['mimeType'] = 'html';
2150 2149
 			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2151
-			$this->sessionData['body']	.= '<blockquote type="cite">';
2150
+			$this->sessionData['body'] .= '<blockquote type="cite">';
2152 2151
 
2153
-			for($i=0; $i<count($bodyParts); $i++) {
2154
-				if($i>0) {
2152
+			for ($i = 0; $i < count($bodyParts); $i++) {
2153
+				if ($i > 0) {
2155 2154
 					$this->sessionData['body'] .= '<hr>';
2156 2155
 				}
2157
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2156
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
2158 2157
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2159 2158
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2160 2159
 				}
2161
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2160
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2162 2161
 
2163 2162
 				$_htmlConfig = Mail::$htmLawed_config;
2164 2163
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2168,37 +2167,37 @@  discard block
 block discarded – undo
2168 2167
 				#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2169 2168
 			}
2170 2169
 
2171
-			$this->sessionData['body']	.= '</blockquote><br>';
2172
-			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2170
+			$this->sessionData['body'] .= '</blockquote><br>';
2171
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2173 2172
 		} else {
2174 2173
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2175 2174
 			// 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)
2176
-            $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2175
+            $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2177 2176
                 @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2178 2177
 				$toAddress.$ccAddress.
2179
-				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
2178
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n".
2180 2179
                 '-------------------------------------------------'."\r\n \r\n ";
2181
-			$this->sessionData['mimeType']	= 'plain';
2180
+			$this->sessionData['mimeType'] = 'plain';
2182 2181
 
2183
-			for($i=0; $i<count($bodyParts); $i++) {
2184
-				if($i>0) {
2182
+			for ($i = 0; $i < count($bodyParts); $i++) {
2183
+				if ($i > 0) {
2185 2184
 					$this->sessionData['body'] .= "<hr>";
2186 2185
 				}
2187 2186
 
2188 2187
 				// add line breaks to $bodyParts
2189
-				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
2188
+				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
2190 2189
 				#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2191 2190
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2192 2191
 				$this->sessionData['body'] .= "\r\n";
2193 2192
 				$hasSignature = false;
2194 2193
 				// create body new, with good line breaks and indention
2195
-				foreach(explode("\n",$newBody) as $value) {
2194
+				foreach (explode("\n", $newBody) as $value) {
2196 2195
 					// the explode is removing the character
2197 2196
 					//$value .= 'ee';
2198 2197
 
2199 2198
 					// Try to remove signatures from qouted parts to avoid multiple
2200 2199
 					// signatures problem in reply (rfc3676#section-4.3).
2201
-					if ($hasSignature || ($hasSignature = preg_match("/\G--(\s|\s[\r\n])$/",$value)))
2200
+					if ($hasSignature || ($hasSignature = preg_match("/\G--(\s|\s[\r\n])$/", $value)))
2202 2201
 					{
2203 2202
 						continue;
2204 2203
 					}
@@ -2210,12 +2209,12 @@  discard block
 block discarded – undo
2210 2209
 					$numberOfChars = strspn(trim($value), ">");
2211 2210
 					$appendString = str_repeat('>', $numberOfChars + 1);
2212 2211
 
2213
-					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2212
+					$bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>');
2214 2213
 
2215
-					if($bodyAppend[0] == '>') {
2216
-						$bodyAppend = '>'. $bodyAppend;
2214
+					if ($bodyAppend[0] == '>') {
2215
+						$bodyAppend = '>'.$bodyAppend;
2217 2216
 					} else {
2218
-						$bodyAppend = '> '. $bodyAppend;
2217
+						$bodyAppend = '> '.$bodyAppend;
2219 2218
 					}
2220 2219
 
2221 2220
 					$this->sessionData['body'] .= $bodyAppend;
@@ -2238,16 +2237,16 @@  discard block
 block discarded – undo
2238 2237
 	 */
2239 2238
 	static function _getCleanHTML($_body, $_useTidy = false)
2240 2239
 	{
2241
-		static $nonDisplayAbleCharacters = array('[\016]','[\017]',
2242
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2243
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2240
+		static $nonDisplayAbleCharacters = array('[\016]', '[\017]',
2241
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2242
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2244 2243
 
2245
-		if ($_useTidy && extension_loaded('tidy') )
2244
+		if ($_useTidy && extension_loaded('tidy'))
2246 2245
 		{
2247 2246
 			$tidy = new tidy();
2248
-			$cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8');
2247
+			$cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8');
2249 2248
 			// Found errors. Strip it all so there's some output
2250
-			if($tidy->getStatus() == 2)
2249
+			if ($tidy->getStatus() == 2)
2251 2250
 			{
2252 2251
 				error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
2253 2252
 			}
@@ -2281,13 +2280,13 @@  discard block
 block discarded – undo
2281 2280
 	 *
2282 2281
 	 * @return array returns found inline images as attachment structure
2283 2282
 	 */
2284
-	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
2283
+	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false)
2285 2284
 	{
2286 2285
 		if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----')
2287 2286
 		{
2288 2287
 			$_formData['mimeType'] = 'openpgp';
2289 2288
 		}
2290
-		$mail_bo	= $this->mail_bo;
2289
+		$mail_bo = $this->mail_bo;
2291 2290
 		$activeMailProfile = Mail\Account::read($this->mail_bo->profileID);
2292 2291
 
2293 2292
 		// you need to set the sender, if you work with different identities, since most smtp servers, dont allow
@@ -2296,37 +2295,37 @@  discard block
 block discarded – undo
2296 2295
 		{
2297 2296
 			error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity));
2298 2297
 		}
2299
-		$email_From =  $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
2298
+		$email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
2300 2299
 		// Try to fix identity email with no domain part set
2301 2300
 		$_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From),
2302
-			Mail::generateIdentityString($_identity,false));
2301
+			Mail::generateIdentityString($_identity, false));
2303 2302
 
2304 2303
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2305 2304
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2306
-		if(!empty($_formData['in-reply-to'])) {
2307
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2305
+		if (!empty($_formData['in-reply-to'])) {
2306
+			if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>';
2308 2307
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2309 2308
 		}
2310
-		if(!empty($_formData['references'])) {
2311
-			if (stripos($_formData['references'],'<')===false)
2309
+		if (!empty($_formData['references'])) {
2310
+			if (stripos($_formData['references'], '<') === false)
2312 2311
 			{
2313
-				$_formData['references']='<'.trim($_formData['references']).'>';
2312
+				$_formData['references'] = '<'.trim($_formData['references']).'>';
2314 2313
 			}
2315 2314
 			$_mailObject->addHeader('References', $_formData['references']);
2316 2315
 		}
2317 2316
 
2318
-		if(!empty($_formData['thread-index'])) {
2317
+		if (!empty($_formData['thread-index'])) {
2319 2318
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2320 2319
 		}
2321
-		if(!empty($_formData['list-id'])) {
2320
+		if (!empty($_formData['list-id'])) {
2322 2321
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2323 2322
 		}
2324
-		if($_formData['disposition']=='on') {
2323
+		if ($_formData['disposition'] == 'on') {
2325 2324
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2326 2325
 		}
2327 2326
 
2328 2327
 		// Expand any mailing lists
2329
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2328
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $field)
2330 2329
 		{
2331 2330
 			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2332 2331
 
@@ -2342,7 +2341,7 @@  discard block
 block discarded – undo
2342 2341
 		}
2343 2342
 		$disableRuler = false;
2344 2343
 		$signature = $_identity['ident_signature'];
2345
-		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0;
2344
+		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0;
2346 2345
 		if ($sigAlreadyThere)
2347 2346
 		{
2348 2347
 			// note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature
@@ -2351,7 +2350,7 @@  discard block
 block discarded – undo
2351 2350
 		}
2352 2351
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
2353 2352
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
2354
-			empty($signature) || trim($this->convertHTMLToText($signature)) =='')
2353
+			empty($signature) || trim($this->convertHTMLToText($signature)) == '')
2355 2354
 		{
2356 2355
 			$disableRuler = true;
2357 2356
 		}
@@ -2362,7 +2361,7 @@  discard block
 block discarded – undo
2362 2361
 				array_unique(array_merge((array)$_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc'])),
2363 2362
 				$_formData['expiration'], $_formData['password']);
2364 2363
 		}
2365
-		if($_formData['mimeType'] == 'html')
2364
+		if ($_formData['mimeType'] == 'html')
2366 2365
 		{
2367 2366
 			$body = $_formData['body'];
2368 2367
 			if ($attachment_links)
@@ -2376,13 +2375,13 @@  discard block
 block discarded – undo
2376 2375
 					$body .= $attachment_links;
2377 2376
 				}
2378 2377
 			}
2379
-			if(!empty($signature))
2378
+			if (!empty($signature))
2380 2379
 			{
2381 2380
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true).
2382 2381
 					($disableRuler ? "\r\n" : "\r\n-- \r\n").
2383 2382
 					$this->convertHTMLToText($signature, true, true));
2384 2383
 
2385
-				$body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature;
2384
+				$body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature;
2386 2385
 			}
2387 2386
 			else
2388 2387
 			{
@@ -2390,11 +2389,11 @@  discard block
 block discarded – undo
2390 2389
 			}
2391 2390
 			// convert URL Images to inline images - if possible
2392 2391
 			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2393
-			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2392
+			if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false)
2394 2393
 			{
2395
-				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
2394
+				$body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body);
2396 2395
 			}
2397
-			$_mailObject->setHtmlBody($body, null, false);	// false = no automatic alternative, we called setBody()
2396
+			$_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody()
2398 2397
 		}
2399 2398
 		elseif ($_formData['mimeType'] == 'openpgp')
2400 2399
 		{
@@ -2402,14 +2401,14 @@  discard block
 block discarded – undo
2402 2401
 		}
2403 2402
 		else
2404 2403
 		{
2405
-			$body = $this->convertHTMLToText($_formData['body'],false);
2404
+			$body = $this->convertHTMLToText($_formData['body'], false);
2406 2405
 
2407 2406
 			if ($attachment_links) $body .= $attachment_links;
2408 2407
 
2409 2408
 			#$_mailObject->Body = $_formData['body'];
2410
-			if(!empty($signature)) {
2411
-				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2412
-					$this->convertHTMLToText($signature,true,true);
2409
+			if (!empty($signature)) {
2410
+				$body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n").
2411
+					$this->convertHTMLToText($signature, true, true);
2413 2412
 			}
2414 2413
 			$_mailObject->setBody($body);
2415 2414
 		}
@@ -2418,8 +2417,8 @@  discard block
 block discarded – undo
2418 2417
 		{
2419 2418
 			$connection_opened = false;
2420 2419
 			$tnfattachments = null;
2421
-			foreach((array)$_formData['attachments'] as $attachment) {
2422
-				if(is_array($attachment))
2420
+			foreach ((array)$_formData['attachments'] as $attachment) {
2421
+				if (is_array($attachment))
2423 2422
 				{
2424 2423
 					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2425 2424
 						/* Example:
@@ -2437,20 +2436,20 @@  discard block
 block discarded – undo
2437 2436
 							$connection_opened = true;
2438 2437
 						}
2439 2438
 						$mail_bo->reopen($attachment['folder']);
2440
-						switch(strtoupper($attachment['type'])) {
2439
+						switch (strtoupper($attachment['type'])) {
2441 2440
 							case 'MESSAGE/RFC':
2442 2441
 							case 'MESSAGE/RFC822':
2443
-								$rawBody='';
2442
+								$rawBody = '';
2444 2443
 								if (isset($attachment['partID'])) {
2445
-									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2446
-									$rawBody=$eml['attachment'];
2444
+									$eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']);
2445
+									$rawBody = $eml['attachment'];
2447 2446
 								} else {
2448
-									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2447
+									$rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']);
2449 2448
 								}
2450 2449
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
2451 2450
 								break;
2452 2451
 							default:
2453
-								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2452
+								$attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false);
2454 2453
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2455 2454
 								{
2456 2455
 									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
@@ -2458,7 +2457,7 @@  discard block
 block discarded – undo
2458 2457
 									{
2459 2458
 										if ($k['name'] == $attachment['name'])
2460 2459
 										{
2461
-											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']);
2460
+											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']);
2462 2461
 											$attachmentData['attachment'] = $tnfpart['attachment'];
2463 2462
 											break;
2464 2463
 										}
@@ -2471,7 +2470,7 @@  discard block
 block discarded – undo
2471 2470
 					// attach files not for autosaving
2472 2471
 					elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving)
2473 2472
 					{
2474
-						if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
2473
+						if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs')
2475 2474
 						{
2476 2475
 							Vfs::load_wrapper('vfs');
2477 2476
 							$tmp_path = $attachment['file'];
@@ -2480,7 +2479,7 @@  discard block
 block discarded – undo
2480 2479
 						{
2481 2480
 							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['file']);
2482 2481
 						}
2483
-						$_mailObject->addAttachment (
2482
+						$_mailObject->addAttachment(
2484 2483
 							$tmp_path,
2485 2484
 							$attachment['name'],
2486 2485
 							$attachment['type']
@@ -2490,7 +2489,7 @@  discard block
 block discarded – undo
2490 2489
 			}
2491 2490
 			if ($connection_opened) $mail_bo->closeConnection();
2492 2491
 		}
2493
-		return is_array($inline_images)?$inline_images:array();
2492
+		return is_array($inline_images) ? $inline_images : array();
2494 2493
 	}
2495 2494
 
2496 2495
 	/**
@@ -2506,16 +2505,16 @@  discard block
 block discarded – undo
2506 2505
 	 * @param string $password =null
2507 2506
 	 * @return string might be empty if no file attachments found
2508 2507
 	 */
2509
-	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2508
+	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null)
2510 2509
 	{
2511 2510
 		if ($filemode == Vfs\Sharing::ATTACH) return '';
2512 2511
 
2513 2512
 		$links = array();
2514
-		foreach($attachments as $attachment)
2513
+		foreach ($attachments as $attachment)
2515 2514
 		{
2516 2515
 			$path = $attachment['file'];
2517
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2518
-			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2516
+			if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts
2517
+			if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs')
2519 2518
 			{
2520 2519
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
2521 2520
 			}
@@ -2545,7 +2544,7 @@  discard block
 block discarded – undo
2545 2544
 		}
2546 2545
 		if (!$links)
2547 2546
 		{
2548
-			return null;	// no file attachments found
2547
+			return null; // no file attachments found
2549 2548
 		}
2550 2549
 		elseif ($html)
2551 2550
 		{
@@ -2560,7 +2559,7 @@  discard block
 block discarded – undo
2560 2559
 	 * @param array $content content sent from client-side
2561 2560
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2562 2561
 	 */
2563
-	public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
2562
+	public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]')
2564 2563
 	{
2565 2564
 		//error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)");
2566 2565
 		$response = Api\Json\Response::get();
@@ -2574,8 +2573,8 @@  discard block
 block discarded – undo
2574 2573
 
2575 2574
 		$formData = array_merge($content, array(
2576 2575
 			'isDrafted' => 1,
2577
-			'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')],
2578
-			'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value
2576
+			'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')],
2577
+			'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value
2579 2578
 		));
2580 2579
 
2581 2580
 		//Saving draft procedure
@@ -2587,8 +2586,8 @@  discard block
 block discarded – undo
2587 2586
 			if (($messageUid = $this->saveAsDraft($formData, $folder, $action)))
2588 2587
 			{
2589 2588
 				// saving as draft, does not mean closing the message
2590
-				$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
2591
-				if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder)))
2589
+				$messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid);
2590
+				if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder)))
2592 2591
 				{
2593 2592
 					$draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid);
2594 2593
 					if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted']))
@@ -2597,7 +2596,7 @@  discard block
 block discarded – undo
2597 2596
 						$duid = $dhA['msgUID'];
2598 2597
 						$dmailbox = $dhA['folder'];
2599 2598
 						// beware: do not delete the original mail as found in processedmail_id
2600
-						$pMuid='';
2599
+						$pMuid = '';
2601 2600
 						if ($content['processedmail_id'])
2602 2601
 						{
2603 2602
 							$pMhA = mail_ui::splitRowID($content['processedmail_id']);
@@ -2605,15 +2604,15 @@  discard block
 block discarded – undo
2605 2604
 						}
2606 2605
 						//error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments']));
2607 2606
 						// do not delete the original message if attachments are present
2608
-						if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments']))
2607
+						if (empty($pMuid) || $pMuid != $duid || empty($content['attachments']))
2609 2608
 						{
2610 2609
 							try
2611 2610
 							{
2612
-								$this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately');
2611
+								$this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately');
2613 2612
 							}
2614 2613
 							catch (Api\Exception $e)
2615 2614
 							{
2616
-								$msg = str_replace('"',"'",$e->getMessage());
2615
+								$msg = str_replace('"', "'", $e->getMessage());
2617 2616
 								$success = false;
2618 2617
 								error_log(__METHOD__.__LINE__.$msg);
2619 2618
 							}
@@ -2634,7 +2633,7 @@  discard block
 block discarded – undo
2634 2633
 		}
2635 2634
 		catch (Api\Exception\WrongUserinput $e)
2636 2635
 		{
2637
-			$msg = str_replace('"',"'",$e->getMessage());
2636
+			$msg = str_replace('"', "'", $e->getMessage());
2638 2637
 			error_log(__METHOD__.__LINE__.$msg);
2639 2638
 			$success = false;
2640 2639
 		}
@@ -2658,17 +2657,17 @@  discard block
 block discarded – undo
2658 2657
 	static function resolveEmailAddressList($_emailAddressList)
2659 2658
 	{
2660 2659
 		$contacts_obs = null;
2661
-		$addrFromList=array();
2662
-		foreach((array)$_emailAddressList as $ak => $address)
2660
+		$addrFromList = array();
2661
+		foreach ((array)$_emailAddressList as $ak => $address)
2663 2662
 		{
2664
-			if(is_int($address))
2663
+			if (is_int($address))
2665 2664
 			{
2666 2665
 				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
2667 2666
 				// List was selected, expand to addresses
2668 2667
 				unset($_emailAddressList[$ak]);
2669
-				$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));
2668
+				$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));
2670 2669
 				// Just add email addresses, they'll be checked below
2671
-				foreach($list as $email)
2670
+				foreach ($list as $email)
2672 2671
 				{
2673 2672
 					$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
2674 2673
 				}
@@ -2678,7 +2677,7 @@  discard block
 block discarded – undo
2678 2677
 		{
2679 2678
 			foreach ($addrFromList as $addr)
2680 2679
 			{
2681
-				if (!empty($addr)) $_emailAddressList[]=$addr;
2680
+				if (!empty($addr)) $_emailAddressList[] = $addr;
2682 2681
 			}
2683 2682
 		}
2684 2683
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2692,15 +2691,15 @@  discard block
 block discarded – undo
2692 2691
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2693 2692
 	 * @return boolean return messageUID| false due to an error
2694 2693
 	 */
2695
-	function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]')
2694
+	function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]')
2696 2695
 	{
2697 2696
 		//error_log(__METHOD__."(..., $savingDestination, action=$action)");
2698
-		$mail_bo	= $this->mail_bo;
2699
-		$mail		= new Api\Mailer($this->mail_bo->profileID);
2697
+		$mail_bo = $this->mail_bo;
2698
+		$mail = new Api\Mailer($this->mail_bo->profileID);
2700 2699
 
2701 2700
 		// preserve the bcc and if possible the save to folder information
2702
-		$this->sessionData['folder']    = $_formData['folder'];
2703
-		$this->sessionData['bcc']   = $_formData['bcc'];
2701
+		$this->sessionData['folder'] = $_formData['folder'];
2702
+		$this->sessionData['bcc'] = $_formData['bcc'];
2704 2703
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2705 2704
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2706 2705
 		$this->sessionData['mailaccount']  = $_formData['mailaccount'];
@@ -2709,11 +2708,11 @@  discard block
 block discarded – undo
2709 2708
 		{
2710 2709
 			$acc = Mail\Account::read($this->sessionData['mailaccount']);
2711 2710
 			//error_log(__METHOD__.__LINE__.array2string($acc));
2712
-			$identity = Mail\Account::read_identity($acc['ident_id'],true);
2711
+			$identity = Mail\Account::read_identity($acc['ident_id'], true);
2713 2712
 		}
2714 2713
 		catch (Exception $e)
2715 2714
 		{
2716
-			$identity=array();
2715
+			$identity = array();
2717 2716
 		}
2718 2717
 
2719 2718
 		$flags = '\\Seen \\Draft';
@@ -2723,7 +2722,7 @@  discard block
 block discarded – undo
2723 2722
 		// folder list as Customheader
2724 2723
 		if (!empty($this->sessionData['folder']))
2725 2724
 		{
2726
-			$folders = implode('|',array_unique($this->sessionData['folder']));
2725
+			$folders = implode('|', array_unique($this->sessionData['folder']));
2727 2726
 			$mail->addHeader('X-Mailfolder', $folders);
2728 2727
 		}
2729 2728
 		$mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']);
@@ -2743,25 +2742,25 @@  discard block
 block discarded – undo
2743 2742
 			$savingDestination = $this->sessionData['messageFolder'];
2744 2743
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2745 2744
 		}
2746
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
2745
+		if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder();
2747 2746
 
2748 2747
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2749 2748
 		$mail->forceBccHeader();
2750 2749
 
2751 2750
 		$mail_bo->openConnection();
2752
-		if ($mail_bo->folderExists($savingDestination,true)) {
2751
+		if ($mail_bo->folderExists($savingDestination, true)) {
2753 2752
 			try
2754 2753
 			{
2755 2754
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
2756 2755
 			}
2757 2756
 			catch (Api\Exception\WrongUserinput $e)
2758 2757
 			{
2759
-				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage()));
2758
+				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage()));
2760 2759
 				return false;
2761 2760
 			}
2762 2761
 
2763 2762
 		} else {
2764
-			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2763
+			error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server."));
2765 2764
 			return false;
2766 2765
 		}
2767 2766
 		$mail_bo->closeConnection();
@@ -2770,26 +2769,26 @@  discard block
 block discarded – undo
2770 2769
 
2771 2770
 	function send($_formData)
2772 2771
 	{
2773
-		$mail_bo	= $this->mail_bo;
2774
-		$mail 		= new Api\Mailer($mail_bo->profileID);
2775
-		$messageIsDraft	=  false;
2772
+		$mail_bo = $this->mail_bo;
2773
+		$mail = new Api\Mailer($mail_bo->profileID);
2774
+		$messageIsDraft = false;
2776 2775
 
2777
-		$this->sessionData['mailaccount']	= $_formData['mailaccount'];
2776
+		$this->sessionData['mailaccount'] = $_formData['mailaccount'];
2778 2777
 		$this->sessionData['to']	= self::resolveEmailAddressList($_formData['to']);
2779 2778
 		$this->sessionData['cc']	= self::resolveEmailAddressList($_formData['cc']);
2780
-		$this->sessionData['bcc']	= self::resolveEmailAddressList($_formData['bcc']);
2781
-		$this->sessionData['folder']	= $_formData['folder'];
2779
+		$this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']);
2780
+		$this->sessionData['folder'] = $_formData['folder'];
2782 2781
 		$this->sessionData['replyto']	= $_formData['replyto'];
2783 2782
 		$this->sessionData['subject']	= trim($_formData['subject']);
2784
-		$this->sessionData['body']	= $_formData['body'];
2785
-		$this->sessionData['priority']	= $_formData['priority'];
2783
+		$this->sessionData['body'] = $_formData['body'];
2784
+		$this->sessionData['priority'] = $_formData['priority'];
2786 2785
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2787 2786
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2788 2787
 		$this->sessionData['disposition'] = $_formData['disposition'];
2789
-		$this->sessionData['mimeType']	= $_formData['mimeType'];
2788
+		$this->sessionData['mimeType'] = $_formData['mimeType'];
2790 2789
 		$this->sessionData['to_infolog'] = $_formData['to_infolog'];
2791 2790
 		$this->sessionData['to_tracker'] = $_formData['to_tracker'];
2792
-		$this->sessionData['attachments']  = $_formData['attachments'];
2791
+		$this->sessionData['attachments'] = $_formData['attachments'];
2793 2792
 
2794 2793
 		if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted']))
2795 2794
 		{
@@ -2798,11 +2797,11 @@  discard block
 block discarded – undo
2798 2797
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']);
2799 2798
 		if (isset($_formData['mode']) && !empty($_formData['mode']))
2800 2799
 		{
2801
-			if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id']))
2800
+			if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id']))
2802 2801
 			{
2803
-				$this->sessionData['forwardFlag']='forwarded';
2804
-				$_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']);
2805
-				$this->sessionData['uid']=array();
2802
+				$this->sessionData['forwardFlag'] = 'forwarded';
2803
+				$_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']);
2804
+				$this->sessionData['uid'] = array();
2806 2805
 				foreach ($_formData['processedmail_id'] as $k =>$rowid)
2807 2806
 				{
2808 2807
 					$fhA = mail_ui::splitRowID($rowid);
@@ -2811,13 +2810,13 @@  discard block
 block discarded – undo
2811 2810
 					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
2812 2811
 				}
2813 2812
 			}
2814
-			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
2813
+			if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id']))
2815 2814
 			{
2816 2815
 				$rhA = mail_ui::splitRowID($_formData['processedmail_id']);
2817 2816
 				$this->sessionData['uid'] = $rhA['msgUID'];
2818 2817
 				$this->sessionData['messageFolder'] = $rhA['folder'];
2819 2818
 			}
2820
-			if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id']))
2819
+			if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id']))
2821 2820
 			{
2822 2821
 				$dhA = mail_ui::splitRowID($_formData['processedmail_id']);
2823 2822
 				$this->sessionData['uid'] = $dhA['msgUID'];
@@ -2826,26 +2825,26 @@  discard block
 block discarded – undo
2826 2825
 		}
2827 2826
 		// if the body is empty, maybe someone pasted something with scripts, into the message body
2828 2827
 		// this should not happen anymore, unless you call send directly, since the check was introduced with the action command
2829
-		if(empty($this->sessionData['body']))
2828
+		if (empty($this->sessionData['body']))
2830 2829
 		{
2831 2830
 			// this is to be found with the egw_unset_vars array for the _POST['body'] array
2832
-			$name='_POST';
2833
-			$key='body';
2831
+			$name = '_POST';
2832
+			$key = 'body';
2834 2833
 			#error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2835 2834
 			if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']']))
2836 2835
 			{
2837
-				$this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2838
-				$_formData['body']=$this->sessionData['body'];
2836
+				$this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2837
+				$_formData['body'] = $this->sessionData['body'];
2839 2838
 			}
2840 2839
 			#error_log($this->sessionData['body']);
2841 2840
 		}
2842
-		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2841
+		if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2843 2842
 		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
2844 2843
 		   	$messageIsDraft = true;
2845 2844
 		}
2846 2845
 		try
2847 2846
 		{
2848
-			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true);
2847
+			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true);
2849 2848
 		}
2850 2849
 		catch (Exception $e)
2851 2850
 		{
@@ -2856,7 +2855,7 @@  discard block
 block discarded – undo
2856 2855
 		// create the messages and store inline images
2857 2856
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2858 2857
 		// remember the identity
2859
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2858
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2860 2859
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2861 2860
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2862 2861
 		#exit;
@@ -2867,12 +2866,12 @@  discard block
 block discarded – undo
2867 2866
 		$folderOnMailAccount = array();
2868 2867
 		foreach ($folderToCheck as $k => $f)
2869 2868
 		{
2870
-			$fval=$f;
2871
-			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2872
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
2873
-			if ($_formData['serverID']!=$_formData['mailaccount'])
2869
+			$fval = $f;
2870
+			$icServerID = $_formData['serverID']; //folders always assumed with serverID
2871
+			if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2);
2872
+			if ($_formData['serverID'] != $_formData['mailaccount'])
2874 2873
 			{
2875
-				if ($icServerID == $_formData['serverID'] )
2874
+				if ($icServerID == $_formData['serverID'])
2876 2875
 				{
2877 2876
 					$folder[$fval] = $fval;
2878 2877
 					$folderOnServerID[] = $fval;
@@ -2885,7 +2884,7 @@  discard block
 block discarded – undo
2885 2884
 			}
2886 2885
 			else
2887 2886
 			{
2888
-				if ($icServerID == $_formData['serverID'] )
2887
+				if ($icServerID == $_formData['serverID'])
2889 2888
 				{
2890 2889
 					$folder[$fval] = $fval;
2891 2890
 					$folderOnServerID[] = $fval;
@@ -2902,7 +2901,7 @@  discard block
 block discarded – undo
2902 2901
 		// we use the sentFolder settings of the choosen mailaccount
2903 2902
 		// sentFolder is account specific
2904 2903
 		$changeProfileOnSentFolderNeeded = false;
2905
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2904
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2906 2905
 		{
2907 2906
 			$this->changeProfile($_formData['mailaccount']);
2908 2907
 			//error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#');
@@ -2910,30 +2909,30 @@  discard block
 block discarded – undo
2910 2909
 			// sentFolder is account specific
2911 2910
 			$sentFolder = $this->mail_bo->getSentFolder();
2912 2911
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2913
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2912
+			if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2914 2913
 		}
2915 2914
 		else
2916 2915
 		{
2917 2916
 			$sentFolder = $mail_bo->getSentFolder();
2918 2917
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2919
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2918
+			if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2920 2919
 		}
2921 2920
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2922 2921
 
2923 2922
 		// we switch $this->mail_bo back to the account we used to work on
2924
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2923
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2925 2924
 		{
2926 2925
 			$this->changeProfile($_formData['serverID']);
2927 2926
 		}
2928 2927
 
2929 2928
 
2930
-		if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2929
+		if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2931 2930
 			$this->mailPreferences['sendOptions'] != 'send_only' &&
2932 2931
 			$messageIsDraft == false)
2933 2932
 		{
2934 2933
 			if ($sentFolder)
2935 2934
 			{
2936
-				if ($_formData['serverID']!=$_formData['mailaccount'])
2935
+				if ($_formData['serverID'] != $_formData['mailaccount'])
2937 2936
 				{
2938 2937
 					$folderOnMailAccount[] = $sentFolder;
2939 2938
 				}
@@ -2950,14 +2949,14 @@  discard block
 block discarded – undo
2950 2949
 		}
2951 2950
 		else
2952 2951
 		{
2953
-			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2952
+			if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2954 2953
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2955 2954
 				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
2956 2955
 		}
2957 2956
 		// draftFolder is on Server we start from
2958
-		if($messageIsDraft == true) {
2957
+		if ($messageIsDraft == true) {
2959 2958
 			$draftFolder = $mail_bo->getDraftFolder();
2960
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
2959
+			if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) {
2961 2960
 				$this->sessionData['folder'] = array($draftFolder);
2962 2961
 				$folderOnServerID[] = $draftFolder;
2963 2962
 				$folder[$draftFolder] = $draftFolder;
@@ -2966,10 +2965,10 @@  discard block
 block discarded – undo
2966 2965
 		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2967 2966
 		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
2968 2967
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2969
-			!( count($folder) > 0) &&
2970
-			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
2968
+			!(count($folder) > 0) &&
2969
+			!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on'))
2971 2970
 		{
2972
-			$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:'');
2971
+			$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 : '');
2973 2972
 			#error_log($this->errorInfo);
2974 2973
 			return false;
2975 2974
 		}
@@ -2978,18 +2977,18 @@  discard block
 block discarded – undo
2978 2977
 		@set_time_limit(120);
2979 2978
 		//$mail->SMTPDebug = 10;
2980 2979
 		//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']));
2981
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2980
+		if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2982 2981
 			try {
2983 2982
 				$mail->send();
2984 2983
 			}
2985
-			catch(Exception $e) {
2984
+			catch (Exception $e) {
2986 2985
 				_egw_log_exception($e);
2987 2986
 				//if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details));
2988
-				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2987
+				$this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : '');
2989 2988
 				return false;
2990 2989
 			}
2991 2990
 		} else {
2992
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
2991
+			if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) {
2993 2992
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2994 2993
 			} else {
2995 2994
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
@@ -3017,15 +3016,15 @@  discard block
 block discarded – undo
3017 3016
 		// copying mail to folder
3018 3017
 		if (count($folder) > 0)
3019 3018
 		{
3020
-			foreach($folderOnServerID as $folderName) {
3019
+			foreach ($folderOnServerID as $folderName) {
3021 3020
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3022 3021
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3023 3022
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3024 3023
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3025
-				if ($mail_bo->folderExists($folderName,true)) {
3026
-					if($mail_bo->isSentFolder($folderName)) {
3024
+				if ($mail_bo->folderExists($folderName, true)) {
3025
+					if ($mail_bo->isSentFolder($folderName)) {
3027 3026
 						$flags = '\\Seen';
3028
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3027
+					} elseif ($mail_bo->isDraftFolder($folderName)) {
3029 3028
 						$flags = '\\Draft';
3030 3029
 					} else {
3031 3030
 						$flags = '\\Seen';
@@ -3041,25 +3040,25 @@  discard block
 block discarded – undo
3041 3040
 					}
3042 3041
 					catch (Api\Exception\WrongUserinput $e)
3043 3042
 					{
3044
-						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()));
3043
+						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()));
3045 3044
 					}
3046 3045
 				}
3047 3046
 				else
3048 3047
 				{
3049
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3048
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3050 3049
 				}
3051 3050
 			}
3052 3051
 			// if we choose to send from a differing profile
3053 3052
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3054
-			foreach($folderOnMailAccount as $folderName) {
3053
+			foreach ($folderOnMailAccount as $folderName) {
3055 3054
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3056 3055
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3057 3056
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3058 3057
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3059
-				if ($this->mail_bo->folderExists($folderName,true)) {
3060
-					if($this->mail_bo->isSentFolder($folderName)) {
3058
+				if ($this->mail_bo->folderExists($folderName, true)) {
3059
+					if ($this->mail_bo->isSentFolder($folderName)) {
3061 3060
 						$flags = '\\Seen';
3062
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3061
+					} elseif ($this->mail_bo->isDraftFolder($folderName)) {
3063 3062
 						$flags = '\\Draft';
3064 3063
 					} else {
3065 3064
 						$flags = '\\Seen';
@@ -3075,12 +3074,12 @@  discard block
 block discarded – undo
3075 3074
 					}
3076 3075
 					catch (Api\Exception\WrongUserinput $e)
3077 3076
 					{
3078
-						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()));
3077
+						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()));
3079 3078
 					}
3080 3079
 				}
3081 3080
 				else
3082 3081
 				{
3083
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3082
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3084 3083
 				}
3085 3084
 			}
3086 3085
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
@@ -3091,27 +3090,27 @@  discard block
 block discarded – undo
3091 3090
 		$lastDrafted = false;
3092 3091
 		if (isset($this->sessionData['lastDrafted']))
3093 3092
 		{
3094
-			$lastDrafted=array();
3093
+			$lastDrafted = array();
3095 3094
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3096 3095
 			$lastDrafted['uid'] = $dhA['msgUID'];
3097 3096
 			$lastDrafted['folder'] = $dhA['folder'];
3098
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3097
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']);
3099 3098
 			// manually drafted, do not delete
3100 3099
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3101
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3100
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false;
3102 3101
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3103 3102
 		}
3104 3103
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
3105 3104
 		{
3106 3105
 			try
3107 3106
 			{
3108
-				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' &&
3109
-					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments']))
3107
+				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' &&
3108
+					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3110 3109
 				{
3111 3110
 					//error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData));
3112 3111
 					//error_log(__METHOD__.__LINE__."#".array2string($_formData));
3113 3112
 					//error_log(__METHOD__.__LINE__."#".array2string($this->sessionData));
3114
-					$mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately');
3113
+					$mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately');
3115 3114
 				}
3116 3115
 			}
3117 3116
 			catch (Api\Exception $e)
@@ -3123,22 +3122,22 @@  discard block
 block discarded – undo
3123 3122
 		unset($this->sessionData['lastDrafted']);
3124 3123
 
3125 3124
 		//error_log("handling draft messages, flagging and such");
3126
-		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3125
+		if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3127 3126
 			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3128 3127
 			// mark message as answered
3129 3128
 			$mail_bo->openConnection();
3130
-			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3129
+			$mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3131 3130
 			// if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send
3132 3131
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
3133 3132
 			if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder']))
3134 3133
 			{
3135 3134
 				try // message may be deleted already, as it maybe done by autosave
3136 3135
 				{
3137
-					if ($_formData['mode']=='composefromdraft' &&
3136
+					if ($_formData['mode'] == 'composefromdraft' &&
3138 3137
 						!(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3139 3138
 					{
3140 3139
 						//error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']);
3141
-						$mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']);
3140
+						$mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder']);
3142 3141
 					}
3143 3142
 				}
3144 3143
 				catch (Api\Exception $e)
@@ -3147,14 +3146,14 @@  discard block
 block discarded – undo
3147 3146
 					unset($e);
3148 3147
 				}
3149 3148
 			} else {
3150
-				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3149
+				$mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3151 3150
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3152
-				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
3151
+				if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded')
3153 3152
 				{
3154 3153
 					try
3155 3154
 					{
3156 3155
 						//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3157
-						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']);
3156
+						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']);
3158 3157
 					}
3159 3158
 					catch (Api\Exception $e)
3160 3159
 					{
@@ -3182,49 +3181,49 @@  discard block
 block discarded – undo
3182 3181
 		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3183 3182
 		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3184 3183
 
3185
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3184
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on')
3186 3185
 		{
3187 3186
 			$this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images);
3188 3187
 
3189
-			foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
3188
+			foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key)
3190 3189
 			{
3191 3190
 				$entryid = $_formData['to_integrate_ids'][0][$app_key];
3192 3191
 				if ($_formData[$app_key] == 'on')
3193 3192
 				{
3194
-					$app_name = substr($app_key,3);
3193
+					$app_name = substr($app_key, 3);
3195 3194
 					// Get registered hook data of the app called for integration
3196
-					$hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name);
3195
+					$hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name);
3197 3196
 
3198 3197
 					// store mail / eml in temp. file to not have to download it from mail-server again
3199
-					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
3198
+					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate');
3200 3199
 					$eml_fp = fopen($eml, 'w');
3201 3200
 					stream_copy_to_stream($mail->getRaw(), $eml_fp);
3202 3201
 					fclose($eml_fp);
3203 3202
 					$target = array(
3204 3203
 						'menuaction' => $hook['menuaction'],
3205
-						'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
3204
+						'egw_data' => Link::set_data(null, 'mail_integration::integrate', array(
3206 3205
 							$mailaddresses,
3207 3206
 							$this->sessionData['subject'],
3208 3207
 							$this->convertHTMLToText($this->sessionData['body']),
3209 3208
 							$this->sessionData['attachments'],
3210 3209
 							false, // date
3211 3210
 							$eml,
3212
-							$_formData['serverID']),true),
3211
+							$_formData['serverID']), true),
3213 3212
 						'app' => $app_name
3214 3213
 					);
3215 3214
 					if ($entryid) $target['entry_id'] = $entryid;
3216 3215
 					// Open the app called for integration in a popup
3217 3216
 					// and store the mail raw data as egw_data, in order to
3218 3217
 					// be stored from registered app method later
3219
-					Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']);
3218
+					Framework::popup(Egw::link('/index.php', $target), '_blank', $hook['popup']);
3220 3219
 				}
3221 3220
 			}
3222 3221
 		}
3223 3222
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3224
-		elseif(is_array($this->sessionData['attachments']))
3223
+		elseif (is_array($this->sessionData['attachments']))
3225 3224
 		{
3226
-			foreach($this->sessionData['attachments'] as $value) {
3227
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3225
+			foreach ($this->sessionData['attachments'] as $value) {
3226
+				if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3228 3227
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3229 3228
 				}
3230 3229
 			}
@@ -3241,7 +3240,7 @@  discard block
 block discarded – undo
3241 3240
 	 * @param array $content
3242 3241
 	 * @return array - the input, enriched with some not set attributes
3243 3242
 	 */
3244
-	function setDefaults($content=array())
3243
+	function setDefaults($content = array())
3245 3244
 	{
3246 3245
 		// if there's not already an identity selected for current account
3247 3246
 		if (empty($content['mailidentity']))
@@ -3250,7 +3249,7 @@  discard block
 block discarded – undo
3250 3249
 			if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
3251 3250
 			{
3252 3251
 				$sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'];
3253
-				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0)
3252
+				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0)
3254 3253
 				{
3255 3254
 					$content['mailidentity'] = $sigPref[$this->mail_bo->profileID];
3256 3255
 				}
@@ -3259,7 +3258,7 @@  discard block
 block discarded – undo
3259 3258
 			if (empty($content['mailidentity']))
3260 3259
 			{
3261 3260
 				$default_identity = null;
3262
-				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3261
+				foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3263 3262
 				{
3264 3263
 					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3265 3264
 					if (!empty($identity['ident_signature']))
@@ -3274,7 +3273,7 @@  discard block
 block discarded – undo
3274 3273
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3275 3274
 		{
3276 3275
 			$content['mimeType'] = 'html';
3277
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3276
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain';
3278 3277
 		}
3279 3278
 		return $content;
3280 3279
 
@@ -3297,7 +3296,7 @@  discard block
 block discarded – undo
3297 3296
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3298 3297
 	 * @return type
3299 3298
 	 */
3300
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3299
+	function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) {
3301 3300
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3302 3301
 		static $useCacheIfPossible = null;
3303 3302
 		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
@@ -3310,36 +3309,36 @@  discard block
 block discarded – undo
3310 3309
 		{
3311 3310
 			$this->changeProfile($_mailaccountToSearch);
3312 3311
 		}
3313
-		if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer))
3312
+		if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer))
3314 3313
 		{
3315 3314
 			//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
3316 3315
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3317 3316
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3318
-			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3319
-			if (count($folderObjects)<=1) {
3317
+			$folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible);
3318
+			if (count($folderObjects) <= 1) {
3320 3319
 				$useCacheIfPossible = false;
3321 3320
 			}
3322 3321
 			else
3323 3322
 			{
3324 3323
 				$useCacheIfPossible = true;
3325 3324
 			}
3326
-			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
3325
+			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP');
3327 3326
 			foreach ($folderObjects as $k =>$fA)
3328 3327
 			{
3329 3328
 				//error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
3330
-				$f=false;
3331
-				$key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k;
3332
-				if ($_searchStringLength<=0)
3329
+				$f = false;
3330
+				$key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k;
3331
+				if ($_searchStringLength <= 0)
3333 3332
 				{
3334
-					$f=true;
3333
+					$f = true;
3335 3334
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3336 3335
 				}
3337
-				if ($f==false && stripos($fA->displayName,$_searchString)!==false)
3336
+				if ($f == false && stripos($fA->displayName, $_searchString) !== false)
3338 3337
 				{
3339
-					$f=true;
3338
+					$f = true;
3340 3339
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3341 3340
 				}
3342
-				if ($f==false && stripos($k,$searchString)!==false)
3341
+				if ($f == false && stripos($k, $searchString) !== false)
3343 3342
 				{
3344 3343
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3345 3344
 				}
@@ -3367,7 +3366,7 @@  discard block
 block discarded – undo
3367 3366
 		exit();
3368 3367
 	}
3369 3368
 
3370
-	public static function ajax_searchAddress($_searchStringLength=2) {
3369
+	public static function ajax_searchAddress($_searchStringLength = 2) {
3371 3370
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3372 3371
 		$_searchString = trim($_REQUEST['query']);
3373 3372
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3376,7 +3375,7 @@  discard block
 block discarded – undo
3376 3375
 		$results = array();
3377 3376
 
3378 3377
 		// Add up to 5 matching mailing lists
3379
-		if($include_lists)
3378
+		if ($include_lists)
3380 3379
 		{
3381 3380
 			$lists = array_filter(
3382 3381
 				$contacts_obj->get_lists(Acl::READ),
@@ -3385,7 +3384,7 @@  discard block
 block discarded – undo
3385 3384
 				}
3386 3385
 			);
3387 3386
 			$list_count = 0;
3388
-			foreach($lists as $key => $list_name)
3387
+			foreach ($lists as $key => $list_name)
3389 3388
 			{
3390 3389
 				$results[] = array(
3391 3390
 					'id'	=> $key,
@@ -3395,11 +3394,11 @@  discard block
 block discarded – undo
3395 3394
 					'title' => lang('Mailinglist'),
3396 3395
 					'data'	=> $key
3397 3396
 				);
3398
-				if($list_count++ > 5) break;
3397
+				if ($list_count++ > 5) break;
3399 3398
 			}
3400 3399
 		}
3401 3400
 
3402
-		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength)
3401
+		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength)
3403 3402
 		{
3404 3403
 			//error_log(__METHOD__.__LINE__.array2string($_searchString));
3405 3404
 			$showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']);
@@ -3408,64 +3407,64 @@  discard block
 block discarded – undo
3408 3407
 			{
3409 3408
 				if (mb_strlen($v) < 3) unset($search[$k]);
3410 3409
 			}
3411
-			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3410
+			$search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns
3412 3411
 			//error_log(__METHOD__.__LINE__.$_searchString);
3413 3412
 			$filter = $showAccounts ? array() : array('account_id' => null);
3414
-			$filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home');
3415
-			$cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home');
3416
-			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter);
3413
+			$filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3414
+			$cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3415
+			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3417 3416
 			// additionally search the accounts, if the contact storage is not the account storage
3418 3417
 			if ($showAccounts && $contacts_obj->so_accounts)
3419 3418
 			{
3420 3419
 				$filter['owner'] = 0;
3421
-				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter);
3420
+				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3422 3421
 
3423 3422
 				if ($contacts && $accounts)
3424 3423
 				{
3425
-					$contacts = array_merge($contacts,$accounts);
3426
-					usort($contacts,function($a, $b)
3424
+					$contacts = array_merge($contacts, $accounts);
3425
+					usort($contacts, function($a, $b)
3427 3426
 					{
3428 3427
 						return strcasecmp($a['n_fn'], $b['n_fn']);
3429 3428
 					});
3430 3429
 				}
3431
-				elseif($accounts)
3430
+				elseif ($accounts)
3432 3431
 				{
3433
-					$contacts =& $accounts;
3432
+					$contacts = & $accounts;
3434 3433
 				}
3435 3434
 				unset($accounts);
3436 3435
 			}
3437 3436
 		}
3438 3437
 		
3439
-		if(is_array($contacts)) {
3440
-			foreach($contacts as $contact) {
3441
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3438
+		if (is_array($contacts)) {
3439
+			foreach ($contacts as $contact) {
3440
+				foreach (array($contact['email'], $contact['email_home']) as $email) {
3442 3441
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3443 3442
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3444 3443
 					$rfcAddr = Mail::parseAddressList($email);
3445
-					$_rfcAddr=$rfcAddr->first();
3444
+					$_rfcAddr = $rfcAddr->first();
3446 3445
 					if (!$_rfcAddr->valid)
3447 3446
 					{
3448 3447
 						continue; // skip address if we encounter an error here
3449 3448
 					}
3450 3449
 					$email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
3451 3450
 
3452
-					if (method_exists($contacts_obj,'search'))
3451
+					if (method_exists($contacts_obj, 'search'))
3453 3452
 					{
3454
-						$contact['n_fn']='';
3453
+						$contact['n_fn'] = '';
3455 3454
 						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3456
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3457
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3458
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3459
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3455
+						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given'];
3456
+						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family'];
3457
+						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')';
3458
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3460 3459
 					}
3461 3460
 					else
3462 3461
 					{
3463
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3462
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3464 3463
 					}
3465 3464
 					$args = explode('@', trim($email));
3466 3465
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3467 3466
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3468
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3467
+					if (!empty($email) && in_array($completeMailString, $results) === false) {
3469 3468
 						$results[] = array(
3470 3469
 							'id'=>$completeMailString,
3471 3470
 							'label' => $completeMailString,
@@ -3481,10 +3480,10 @@  discard block
 block discarded – undo
3481 3480
 		// Add groups
3482 3481
 		$group_options = array('account_type' => 'groups');
3483 3482
 		$groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options);
3484
-		foreach($groups as $g_id => $name)
3483
+		foreach ($groups as $g_id => $name)
3485 3484
 		{
3486 3485
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3487
-			if(!$group['account_email']) continue;
3486
+			if (!$group['account_email']) continue;
3488 3487
 			$args = explode('@', trim($group['account_email']));
3489 3488
 			$args[] = $name;
3490 3489
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3514,7 +3513,7 @@  discard block
 block discarded – undo
3514 3513
 	public function ajax_merge($contact_id)
3515 3514
 	{
3516 3515
 		$response = Api\Json\Response::get();
3517
-		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3516
+		if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3518 3517
 		{
3519 3518
 			$document_merge = new $_REQUEST['merge']();
3520 3519
 		}
@@ -3524,7 +3523,7 @@  discard block
 block discarded – undo
3524 3523
 		}
3525 3524
 		$this->mail_bo->openConnection();
3526 3525
 
3527
-		if(($error = $document_merge->check_document($_REQUEST['document'],'')))
3526
+		if (($error = $document_merge->check_document($_REQUEST['document'], '')))
3528 3527
 		{
3529 3528
 			$response->error($error);
3530 3529
 			return;
@@ -3535,11 +3534,11 @@  discard block
 block discarded – undo
3535 3534
 		try
3536 3535
 		{
3537 3536
 			$results = $this->mail_bo->importMessageToMergeAndSend(
3538
-				$document_merge, Vfs::PREFIX . $_REQUEST['document'],
3537
+				$document_merge, Vfs::PREFIX.$_REQUEST['document'],
3539 3538
 				// Send an extra non-numeric ID to force actual send of document
3540 3539
 				// instead of save as draft
3541 3540
 				array((int)$contact_id, ''),
3542
-				$folder,$merged_mail_id
3541
+				$folder, $merged_mail_id
3543 3542
 			);
3544 3543
 		}
3545 3544
 		catch (Exception $e)
@@ -3553,13 +3552,13 @@  discard block
 block discarded – undo
3553 3552
 			);
3554 3553
 		}
3555 3554
 
3556
-		if($results['success'])
3555
+		if ($results['success'])
3557 3556
 		{
3558
-			$response->data(implode(',',$results['success']));
3557
+			$response->data(implode(',', $results['success']));
3559 3558
 		}
3560
-		if($results['failed'])
3559
+		if ($results['failed'])
3561 3560
 		{
3562
-			$response->error(implode(',',$results['failed']));
3561
+			$response->error(implode(',', $results['failed']));
3563 3562
 		}
3564 3563
 	}
3565 3564
 }
Please login to merge, or discard this patch.
Braces   +801 added lines, -268 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
 		}
@@ -1110,24 +1225,33 @@  discard block
 block discarded – undo
1110 1225
 			$disableRuler = true;
1111 1226
 		}
1112 1227
 		$font_span = $font_part = '';
1113
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1228
+		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/)
1229
+		{
1114 1230
 			// User preferences for style
1115 1231
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1116 1232
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1117 1233
 			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1118 1234
 			$font_span = $font_part.'&#8203;</span>';
1119
-			if (empty($font) && empty($font_size)) $font_span = '';
1235
+			if (empty($font) && empty($font_size))
1236
+			{
1237
+				$font_span = '';
1238
+			}
1120 1239
 		}
1121 1240
 		// 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
1122
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1241
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false)
1242
+		{
1243
+			$font_span = '';
1244
+		}
1123 1245
 		//remove possible html header stuff
1124
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1246
+		if (stripos($content['body'],'<html><head></head><body>')!==false)
1247
+		{
1248
+			$content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1249
+		}
1125 1250
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1126 1251
 		$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');
1127 1252
 		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1128 1253
 			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1129
-		)
1130
-		{
1254
+		) {
1131 1255
 			// ON tOP OR BELOW? pREF CAN TELL
1132 1256
 			/*
1133 1257
 				Signature behavior preference changed. New default, if not set -> 0
@@ -1142,14 +1266,23 @@  discard block
 block discarded – undo
1142 1266
 				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1143 1267
 				foreach($blockElements as $e)
1144 1268
 				{
1145
-					if ($sigTextStartsWithBlockElement) break;
1146
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1269
+					if ($sigTextStartsWithBlockElement)
1270
+					{
1271
+						break;
1272
+					}
1273
+					if (stripos(trim($sigText),'<'.$e)===0)
1274
+					{
1275
+						$sigTextStartsWithBlockElement = true;
1276
+					}
1147 1277
 				}
1148 1278
 			}
1149
-			if($content['mimeType'] == 'html') {
1279
+			if($content['mimeType'] == 'html')
1280
+			{
1150 1281
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1151 1282
 				$inbetween = '';
1152
-			} else {
1283
+			}
1284
+			else
1285
+			{
1153 1286
 				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1154 1287
 				$inbetween = "\r\n";
1155 1288
 			}
@@ -1183,7 +1316,10 @@  discard block
 block discarded – undo
1183 1316
 		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1184 1317
 		{
1185 1318
 			// do NOT add SMTP only accounts as identities
1186
-			if (!$account->is_imap(false)) continue;
1319
+			if (!$account->is_imap(false))
1320
+			{
1321
+				continue;
1322
+			}
1187 1323
 
1188 1324
 			foreach($account->identities($acc_id) as $ident_id => $identity)
1189 1325
 			{
@@ -1196,16 +1332,24 @@  discard block
 block discarded – undo
1196 1332
 		//$content['bcc'] = array('[email protected]','[email protected]');
1197 1333
 		// address stuff like from, to, cc, replyto
1198 1334
 		$destinationRows = 0;
1199
-		foreach(self::$destinations as $destination) {
1335
+		foreach(self::$destinations as $destination)
1336
+		{
1200 1337
 			if (!is_array($content[$destination]))
1201 1338
 			{
1202
-				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
1339
+				if (!empty($content[$destination]))
1340
+				{
1341
+					$content[$destination] = (array)$content[$destination];
1342
+				}
1203 1343
 			}
1204 1344
 			$addr_content = $content[strtolower($destination)];
1205 1345
 			// we clear the given address array and rebuild it
1206 1346
 			unset($content[strtolower($destination)]);
1207
-			foreach((array)$addr_content as $key => $value) {
1208
-				if ($value=="NIL@NIL") continue;
1347
+			foreach((array)$addr_content as $key => $value)
1348
+			{
1349
+				if ($value=="NIL@NIL")
1350
+				{
1351
+					continue;
1352
+				}
1209 1353
 				if ($destination=='replyto' && str_replace('"','',$value) ==
1210 1354
 					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1211 1355
 				{
@@ -1215,8 +1359,12 @@  discard block
 block discarded – undo
1215 1359
 				}
1216 1360
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1217 1361
 				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1218
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1219
-					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1362
+				foreach(Mail::parseAddressList($value) as $addressObject)
1363
+				{
1364
+					if ($addressObject->host == '.SYNTAX-ERROR.')
1365
+					{
1366
+						continue;
1367
+					}
1220 1368
 					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1221 1369
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1222 1370
 					$content[strtolower($destination)][]=$address;
@@ -1227,11 +1375,20 @@  discard block
 block discarded – undo
1227 1375
 		if ($_content)
1228 1376
 		{
1229 1377
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1230
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1378
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content))
1379
+			{
1380
+				unset($_content['mailidentity']);
1381
+			}
1231 1382
 			$content = array_merge($content,$_content);
1232 1383
 
1233
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1234
-			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1384
+			if (!empty($content['folder']))
1385
+			{
1386
+				$sel_options['folder']=$this->ajax_searchFolder(0,true);
1387
+			}
1388
+			if (empty($content['mailaccount']))
1389
+			{
1390
+				$content['mailaccount'] = $this->mail_bo->profileID;
1391
+			}
1235 1392
 		}
1236 1393
 		else
1237 1394
 		{
@@ -1274,11 +1431,17 @@  discard block
 block discarded – undo
1274 1431
 		//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
1275 1432
 		$preserv['is_html'] = $content['is_html'];
1276 1433
 		$preserv['is_plain'] = $content['is_plain'];
1277
-		if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
1434
+		if (isset($content['mimeType']))
1435
+		{
1436
+			$preserv['mimeType'] = $content['mimeType'];
1437
+		}
1278 1438
 		$sel_options['mimeType'] = self::$mimeTypes;
1279 1439
 		$sel_options['priority'] = self::$priorities;
1280 1440
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1281
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1441
+		if (!isset($content['priority']) || empty($content['priority']))
1442
+		{
1443
+			$content['priority']=3;
1444
+		}
1282 1445
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1283 1446
 		$etpl = new Etemplate('mail.compose');
1284 1447
 
@@ -1325,9 +1488,12 @@  discard block
 block discarded – undo
1325 1488
 		$preserv['list-id'] = $content['list-id'];
1326 1489
 		$preserv['mode'] = $content['mode'];
1327 1490
 		// convert it back to checkbox expectations
1328
-		if($content['mimeType'] == 'html') {
1491
+		if($content['mimeType'] == 'html')
1492
+		{
1329 1493
 			$content['mimeType']=1;
1330
-		} else {
1494
+		}
1495
+		else
1496
+		{
1331 1497
 			$content['mimeType']=0;
1332 1498
 		}
1333 1499
 		// set the current selected mailaccount as param for folderselection
@@ -1352,7 +1518,10 @@  discard block
 block discarded – undo
1352 1518
 		// Resolve distribution list before send content to client
1353 1519
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1354 1520
 		{
1355
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1521
+			if (is_array($content[$f]))
1522
+			{
1523
+				$content[$f]= self::resolveEmailAddressList ($content[$f]);
1524
+			}
1356 1525
 		}
1357 1526
 
1358 1527
 		$content['to'] = self::resolveEmailAddressList($content['to']);
@@ -1400,7 +1569,10 @@  discard block
 block discarded – undo
1400 1569
 				case 'composefromdraft':
1401 1570
 				case 'composeasnew':
1402 1571
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1403
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1572
+					if ($from =='composefromdraft')
1573
+					{
1574
+						$content['mode'] = 'composefromdraft';
1575
+					}
1404 1576
 					$content['processedmail_id'] = $mail_id;
1405 1577
 
1406 1578
 					$_focusElement = 'body';
@@ -1448,7 +1620,10 @@  discard block
 block discarded – undo
1448 1620
 			$document_merge = new $merge_class();
1449 1621
 			$this->mail_bo->openConnection();
1450 1622
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1451
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1623
+			if (!is_array($merge_ids))
1624
+			{
1625
+				$merge_ids = explode(',',$merge_ids);
1626
+			}
1452 1627
 			try
1453 1628
 			{
1454 1629
 				$merged_mail_id = '';
@@ -1479,7 +1654,10 @@  discard block
 block discarded – undo
1479 1654
 				{
1480 1655
 					$success = implode(', ',$results['success']);
1481 1656
 					$fail = implode(', ', $results['failed']);
1482
-					if($success) Framework::message($success, 'success');
1657
+					if($success)
1658
+					{
1659
+						Framework::message($success, 'success');
1660
+					}
1483 1661
 					Framework::window_close($fail);
1484 1662
 				}
1485 1663
 			}
@@ -1511,17 +1689,25 @@  discard block
 block discarded – undo
1511 1689
 	{
1512 1690
 		$stripalltags = true;
1513 1691
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1514
-		if (!$sourceishtml) $stripalltags=false;
1692
+		if (!$sourceishtml)
1693
+		{
1694
+			$stripalltags=false;
1695
+		}
1515 1696
 		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1516 1697
 	}
1517 1698
 
1518 1699
 	function generateRFC822Address($_addressObject)
1519 1700
 	{
1520
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1701
+		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host)
1702
+		{
1521 1703
 			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1522
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1704
+		}
1705
+		elseif($_addressObject->mailbox && $_addressObject->host)
1706
+		{
1523 1707
 			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1524
-		} else {
1708
+		}
1709
+		else
1710
+		{
1525 1711
 			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1526 1712
 		}
1527 1713
 	}
@@ -1555,16 +1741,28 @@  discard block
 block discarded – undo
1555 1741
 		//if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC'];
1556 1742
 
1557 1743
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1558
-		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1559
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1744
+		if (!empty($addHeadInfo['X-MAILFOLDER']))
1745
+		{
1746
+			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val )
1747
+			{
1560 1748
 				$fval=$val;
1561 1749
 				$icServerID = $mail_bo->icServer->ImapServerId;
1562
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1563
-				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1564
-				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1750
+				if (stripos($val,'::')!==false)
1751
+				{
1752
+					list($icServerID,$fval) = explode('::',$val,2);
1753
+				}
1754
+				if ($icServerID != $mail_bo->icServer->ImapServerId)
1755
+				{
1756
+					continue;
1757
+				}
1758
+				if ($mail_bo->folderExists($fval))
1759
+				{
1760
+					$this->sessionData['folder'][] = $val;
1761
+				}
1565 1762
 			}
1566 1763
 		}
1567
-		if (!empty($addHeadInfo['X-MAILIDENTITY'])) {
1764
+		if (!empty($addHeadInfo['X-MAILIDENTITY']))
1765
+		{
1568 1766
 			// with the new system it would be the identity
1569 1767
 			try
1570 1768
 			{
@@ -1580,7 +1778,8 @@  discard block
 block discarded – undo
1580 1778
 			$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
1581 1779
 		}
1582 1780
 		*/
1583
-		if (!empty($addHeadInfo['X-MAILACCOUNT'])) {
1781
+		if (!empty($addHeadInfo['X-MAILACCOUNT']))
1782
+		{
1584 1783
 			// with the new system it would the identity is the account id
1585 1784
 			try
1586 1785
 			{
@@ -1595,27 +1794,38 @@  discard block
 block discarded – undo
1595 1794
 			}
1596 1795
 		}
1597 1796
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1598
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1797
+		if ($mail_bo->isDraftFolder($_folder))
1798
+		{
1799
+			$this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);
1800
+		}
1801
+		//array('uid'=>$_uid,'folder'=>$_folder);
1599 1802
 		$this->sessionData['uid'] = $_uid;
1600 1803
 		$this->sessionData['messageFolder'] = $_folder;
1601 1804
 		$this->sessionData['isDraft'] = true;
1602 1805
 		$foundAddresses = array();
1603
-		foreach((array)$headers['CC'] as $val) {
1806
+		foreach((array)$headers['CC'] as $val)
1807
+		{
1604 1808
 			$rfcAddr=Mail::parseAddressList($val);
1605 1809
 			$_rfcAddr = $rfcAddr[0];
1606
-			if (!$_rfcAddr->valid) continue;
1607
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1810
+			if (!$_rfcAddr->valid)
1811
+			{
1812
+				continue;
1813
+			}
1814
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1815
+			{
1608 1816
 				continue;
1609 1817
 			}
1610 1818
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1611
-			if(!$foundAddresses[$keyemail]) {
1819
+			if(!$foundAddresses[$keyemail])
1820
+			{
1612 1821
 				$address = $this->mail_bo->decode_header($val,true);
1613 1822
 				$this->sessionData['cc'][] = $val;
1614 1823
 				$foundAddresses[$keyemail] = true;
1615 1824
 			}
1616 1825
 		}
1617 1826
 
1618
-		foreach((array)$headers['TO'] as $val) {
1827
+		foreach((array)$headers['TO'] as $val)
1828
+		{
1619 1829
 			if(!is_array($val))
1620 1830
 			{
1621 1831
 				$this->sessionData['to'][] = $val;
@@ -1623,42 +1833,59 @@  discard block
 block discarded – undo
1623 1833
 			}
1624 1834
 			$rfcAddr=Mail::parseAddressList($val);
1625 1835
 			$_rfcAddr = $rfcAddr[0];
1626
-			if (!$_rfcAddr->valid) continue;
1627
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1836
+			if (!$_rfcAddr->valid)
1837
+			{
1838
+				continue;
1839
+			}
1840
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1841
+			{
1628 1842
 				continue;
1629 1843
 			}
1630 1844
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1631
-			if(!$foundAddresses[$keyemail]) {
1845
+			if(!$foundAddresses[$keyemail])
1846
+			{
1632 1847
 				$address = $this->mail_bo->decode_header($val,true);
1633 1848
 				$this->sessionData['to'][] = $val;
1634 1849
 				$foundAddresses[$keyemail] = true;
1635 1850
 			}
1636 1851
 		}
1637 1852
 
1638
-		foreach((array)$headers['REPLY-TO'] as $val) {
1853
+		foreach((array)$headers['REPLY-TO'] as $val)
1854
+		{
1639 1855
 			$rfcAddr=Mail::parseAddressList($val);
1640 1856
 			$_rfcAddr = $rfcAddr[0];
1641
-			if (!$_rfcAddr->valid) continue;
1642
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1857
+			if (!$_rfcAddr->valid)
1858
+			{
1859
+				continue;
1860
+			}
1861
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1862
+			{
1643 1863
 				continue;
1644 1864
 			}
1645 1865
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1646
-			if(!$foundAddresses[$keyemail]) {
1866
+			if(!$foundAddresses[$keyemail])
1867
+			{
1647 1868
 				$address = $this->mail_bo->decode_header($val,true);
1648 1869
 				$this->sessionData['replyto'][] = $val;
1649 1870
 				$foundAddresses[$keyemail] = true;
1650 1871
 			}
1651 1872
 		}
1652 1873
 
1653
-		foreach((array)$headers['BCC'] as $val) {
1874
+		foreach((array)$headers['BCC'] as $val)
1875
+		{
1654 1876
 			$rfcAddr=Mail::parseAddressList($val);
1655 1877
 			$_rfcAddr = $rfcAddr[0];
1656
-			if (!$_rfcAddr->valid) continue;
1657
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1878
+			if (!$_rfcAddr->valid)
1879
+			{
1880
+				continue;
1881
+			}
1882
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1883
+			{
1658 1884
 				continue;
1659 1885
 			}
1660 1886
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1661
-			if(!$foundAddresses[$keyemail]) {
1887
+			if(!$foundAddresses[$keyemail])
1888
+			{
1662 1889
 				$address = $this->mail_bo->decode_header($val,true);
1663 1890
 				$this->sessionData['bcc'][] = $val;
1664 1891
 				$foundAddresses[$keyemail] = true;
@@ -1672,32 +1899,46 @@  discard block
 block discarded – undo
1672 1899
 		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1673 1900
 		//_debug_array($bodyParts);
1674 1901
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1675
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1902
+		if($bodyParts['0']['mimeType'] == 'text/html')
1903
+		{
1676 1904
 			$this->sessionData['mimeType'] 	= 'html';
1677 1905
 
1678
-			for($i=0; $i<count($bodyParts); $i++) {
1679
-				if($i>0) {
1906
+			for($i=0; $i<count($bodyParts); $i++)
1907
+			{
1908
+				if($i>0)
1909
+				{
1680 1910
 					$this->sessionData['body'] .= '<hr>';
1681 1911
 				}
1682
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1912
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
1913
+				{
1683 1914
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1684 1915
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1685 1916
 				}
1686
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1917
+				if ($bodyParts[$i]['charSet']===false)
1918
+				{
1919
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1920
+				}
1687 1921
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1688 1922
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1689 1923
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1690 1924
 			}
1691 1925
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1692 1926
 
1693
-		} else {
1927
+		}
1928
+		else
1929
+		{
1694 1930
 			$this->sessionData['mimeType']	= 'plain';
1695 1931
 
1696
-			for($i=0; $i<count($bodyParts); $i++) {
1697
-				if($i>0) {
1932
+			for($i=0; $i<count($bodyParts); $i++)
1933
+			{
1934
+				if($i>0)
1935
+				{
1698 1936
 					$this->sessionData['body'] .= "<hr>";
1699 1937
 				}
1700
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1938
+				if ($bodyParts[$i]['charSet']===false)
1939
+				{
1940
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1941
+				}
1701 1942
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1702 1943
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1703 1944
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
@@ -1705,8 +1946,10 @@  discard block
 block discarded – undo
1705 1946
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1706 1947
 		}
1707 1948
 
1708
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1709
-			foreach($attachments as $attachment) {
1949
+		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1950
+		{
1951
+			foreach($attachments as $attachment)
1952
+			{
1710 1953
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1711 1954
 				$cid = $attachment['cid'];
1712 1955
 				$match=null;
@@ -1729,7 +1972,8 @@  discard block
 block discarded – undo
1729 1972
 
1730 1973
 	function getErrorInfo()
1731 1974
 	{
1732
-		if(isset($this->errorInfo)) {
1975
+		if(isset($this->errorInfo))
1976
+		{
1733 1977
 			$errorInfo = $this->errorInfo;
1734 1978
 			unset($this->errorInfo);
1735 1979
 			return $errorInfo;
@@ -1744,7 +1988,8 @@  discard block
 block discarded – undo
1744 1988
 			$modebuff = $this->mailPreferences['message_forwarding'];
1745 1989
 			$this->mailPreferences['message_forwarding'] = $_mode;
1746 1990
 		}
1747
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1991
+		if  ($this->mailPreferences['message_forwarding'] == 'inline')
1992
+		{
1748 1993
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1749 1994
 		}
1750 1995
 		$mail_bo    = $this->mail_bo;
@@ -1761,12 +2006,16 @@  discard block
 block discarded – undo
1761 2006
 		//$this->sessionData['sourceFolder']=$_folder;
1762 2007
 		//$this->sessionData['forwardFlag']='forwarded';
1763 2008
 		//$this->sessionData['forwardedUID']=$_uid;
1764
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
2009
+		if  ($this->mailPreferences['message_forwarding'] == 'asmail')
2010
+		{
1765 2011
 			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1766 2012
 			if($headers['SIZE'])
1767
-				$size				= $headers['SIZE'];
1768
-			else
1769
-				$size				= lang('unknown');
2013
+			{
2014
+							$size				= $headers['SIZE'];
2015
+			}
2016
+			else {
2017
+							$size				= lang('unknown');
2018
+			}
1770 2019
 
1771 2020
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1772 2021
 				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
@@ -1777,9 +2026,11 @@  discard block
 block discarded – undo
1777 2026
 			unset($this->sessionData['in-reply-to']);
1778 2027
 			unset($this->sessionData['to']);
1779 2028
 			unset($this->sessionData['cc']);
1780
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) {
2029
+			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false)))
2030
+			{
1781 2031
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1782
-				foreach($attachments as $attachment) {
2032
+				foreach($attachments as $attachment)
2033
+				{
1783 2034
 					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment')
1784 2035
 					{
1785 2036
 						$this->addMessageAttachment($_uid, $attachment['partID'],
@@ -1835,7 +2086,10 @@  discard block
 block discarded – undo
1835 2086
 			{
1836 2087
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1837 2088
 					strtolower($_formData['type'])== strtolower($attach['type']) &&
1838
-					stripos($_formData['file'],'vfs://') !== false) return;
2089
+					stripos($_formData['file'],'vfs://') !== false)
2090
+				{
2091
+					return;
2092
+				}
1839 2093
 			}
1840 2094
 		}
1841 2095
 		if ($attachfailed === false)
@@ -1847,7 +2101,10 @@  discard block
 block discarded – undo
1847 2101
 				'tmp_name'	=> $tmpFileName,
1848 2102
 				'size'	=> $_formData['size']
1849 2103
 			);
1850
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
2104
+			if (!is_array($_content['attachments']))
2105
+			{
2106
+				$_content['attachments']=array();
2107
+			}
1851 2108
 			$_content['attachments'][] = $buffer;
1852 2109
 			unset($buffer);
1853 2110
 		}
@@ -1878,7 +2135,10 @@  discard block
 block discarded – undo
1878 2135
 		{
1879 2136
 			foreach($request->preserv['attachments'] as $attachment)
1880 2137
 			{
1881
-				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2138
+				if ($_GET['tmpname'] === $attachment['tmp_name'])
2139
+				{
2140
+					break;
2141
+				}
1882 2142
 			}
1883 2143
 		}
1884 2144
 		if (!$request || $_GET['tmpname'] !== $attachment['tmp_name'])
@@ -1912,10 +2172,20 @@  discard block
 block discarded – undo
1912 2172
 				$sfxMimeType = $attachment['type'];
1913 2173
 				$buff = explode('.',$attachment['tmp_name']);
1914 2174
 				$suffix = '';
1915
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1916
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2175
+				if (is_array($buff))
2176
+				{
2177
+					$suffix = array_pop($buff);
2178
+				}
2179
+				// take the last extension to check with ext2mime
2180
+				if (!empty($suffix))
2181
+				{
2182
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2183
+				}
1917 2184
 				$attachment['type'] = $sfxMimeType;
1918
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2185
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2186
+				{
2187
+					$attachment['type'] = strtoupper($sfxMimeType);
2188
+				}
1919 2189
 			}
1920 2190
 			//error_log(__METHOD__.print_r($attachment,true));
1921 2191
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -1924,7 +2194,10 @@  discard block
 block discarded – undo
1924 2194
 				$calendar_ical = new calendar_ical();
1925 2195
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1926 2196
 				//error_log(__METHOD__.array2string($eventid));
1927
-				if (!$eventid) $eventid = -1;
2197
+				if (!$eventid)
2198
+				{
2199
+					$eventid = -1;
2200
+				}
1928 2201
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1929 2202
 				//error_log(__METHOD__.$event);
1930 2203
 				if ((int)$event > 0)
@@ -1950,7 +2223,10 @@  discard block
 block discarded – undo
1950 2223
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1951 2224
 					$contact = $addressbook_vcal->find_contact($vcard,false);
1952 2225
 				}
1953
-				if (!$contact) $contact = null;
2226
+				if (!$contact)
2227
+				{
2228
+					$contact = null;
2229
+				}
1954 2230
 				// 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))
1955 2231
 				if ($contact || count($vcard)>2)
1956 2232
 				{
@@ -1981,7 +2257,8 @@  discard block
 block discarded – undo
1981 2257
 	 * @param string haystack
1982 2258
 	 * @return boolean
1983 2259
 	 */
1984
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2260
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack)
2261
+	{
1985 2262
 		foreach (array_keys($arrayToTestAgainst) as $k)
1986 2263
 		{
1987 2264
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
@@ -2038,21 +2315,34 @@  discard block
 block discarded – undo
2038 2315
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
2039 2316
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
2040 2317
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
2041
-		if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2042
-		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2318
+		if ($headers['THREAD-INDEX'])
2319
+		{
2320
+			$this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2321
+		}
2322
+		if ($headers['LIST-ID'])
2323
+		{
2324
+			$this->sessionData['list-id'] = $headers['LIST-ID'];
2325
+		}
2043 2326
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
2044 2327
 		// check for Reply-To: header and use if available
2045
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
2046
-			foreach($headers['REPLY-TO'] as $val) {
2047
-				if(!$foundAddresses[$val]) {
2328
+		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM']))
2329
+		{
2330
+			foreach($headers['REPLY-TO'] as $val)
2331
+			{
2332
+				if(!$foundAddresses[$val])
2333
+				{
2048 2334
 					$oldTo[] = $val;
2049 2335
 					$foundAddresses[$val] = true;
2050 2336
 				}
2051 2337
 			}
2052 2338
 			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2053
-		} else {
2054
-			foreach($headers['FROM'] as $val) {
2055
-				if(!$foundAddresses[$val]) {
2339
+		}
2340
+		else
2341
+		{
2342
+			foreach($headers['FROM'] as $val)
2343
+			{
2344
+				if(!$foundAddresses[$val])
2345
+				{
2056 2346
 					$oldTo[] = $val;
2057 2347
 					$foundAddresses[$val] = true;
2058 2348
 				}
@@ -2060,18 +2350,23 @@  discard block
 block discarded – undo
2060 2350
 			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2061 2351
 		}
2062 2352
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2063
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2353
+		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) )
2354
+		{
2064 2355
 			$this->sessionData['to'] = $oldTo;
2065 2356
 		}
2066 2357
 
2067
-		if($_mode == 'all') {
2358
+		if($_mode == 'all')
2359
+		{
2068 2360
 			// reply to any address which is cc, but not to my self
2069 2361
 			#if($headers->cc) {
2070
-				foreach($headers['CC'] as $val) {
2071
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2362
+				foreach($headers['CC'] as $val)
2363
+				{
2364
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2365
+					{
2072 2366
 						continue;
2073 2367
 					}
2074
-					if(!$foundAddresses[$val]) {
2368
+					if(!$foundAddresses[$val])
2369
+					{
2075 2370
 						$this->sessionData['cc'][] = $val;
2076 2371
 						$foundAddresses[$val] = true;
2077 2372
 					}
@@ -2080,11 +2375,14 @@  discard block
 block discarded – undo
2080 2375
 
2081 2376
 			// reply to any address which is to, but not to my self
2082 2377
 			#if($headers->to) {
2083
-				foreach($headers['TO'] as $val) {
2084
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2378
+				foreach($headers['TO'] as $val)
2379
+				{
2380
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2381
+					{
2085 2382
 						continue;
2086 2383
 					}
2087
-					if(!$foundAddresses[$val]) {
2384
+					if(!$foundAddresses[$val])
2385
+					{
2088 2386
 						$this->sessionData['to'][] = $val;
2089 2387
 						$foundAddresses[$val] = true;
2090 2388
 					}
@@ -2092,12 +2390,15 @@  discard block
 block discarded – undo
2092 2390
 			#}
2093 2391
 
2094 2392
 			#if($headers->from) {
2095
-				foreach($headers['FROM'] as $val) {
2096
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2393
+				foreach($headers['FROM'] as $val)
2394
+				{
2395
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2396
+					{
2097 2397
 						continue;
2098 2398
 					}
2099 2399
 					//error_log(__METHOD__.__LINE__.' '.$val);
2100
-					if(!$foundAddresses[$val]) {
2400
+					if(!$foundAddresses[$val])
2401
+					{
2101 2402
 						$this->sessionData['to'][] = $val;
2102 2403
 						$foundAddresses[$val] = true;
2103 2404
 					}
@@ -2106,9 +2407,12 @@  discard block
 block discarded – undo
2106 2407
 		}
2107 2408
 
2108 2409
 		// check for Re: in subject header
2109
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2410
+		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:")
2411
+		{
2110 2412
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2111
-		} else {
2413
+		}
2414
+		else
2415
+		{
2112 2416
 			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2113 2417
 		}
2114 2418
 
@@ -2122,7 +2426,8 @@  discard block
 block discarded – undo
2122 2426
 
2123 2427
 		$toAddressA = array();
2124 2428
 		$toAddress = '';
2125
-		foreach ($headers['TO'] as $mailheader) {
2429
+		foreach ($headers['TO'] as $mailheader)
2430
+		{
2126 2431
 			$toAddressA[] =  $mailheader;
2127 2432
 		}
2128 2433
 		if (count($toAddressA)>0)
@@ -2132,7 +2437,8 @@  discard block
 block discarded – undo
2132 2437
 		}
2133 2438
 		$ccAddressA = array();
2134 2439
 		$ccAddress = '';
2135
-		foreach ($headers['CC'] as $mailheader) {
2440
+		foreach ($headers['CC'] as $mailheader)
2441
+		{
2136 2442
 			$ccAddressA[] =  $mailheader;
2137 2443
 		}
2138 2444
 		if (count($ccAddressA)>0)
@@ -2140,25 +2446,35 @@  discard block
 block discarded – undo
2140 2446
 			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2141 2447
 			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2142 2448
 		}
2143
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2449
+		if($bodyParts['0']['mimeType'] == 'text/html')
2450
+		{
2144 2451
 			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2145 2452
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2146 2453
 				$toAddress.$ccAddress.
2147 2454
 				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2148 2455
 				'----------------------------------------------------------'."</div>";
2149 2456
 			$this->sessionData['mimeType'] 	= 'html';
2150
-			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2457
+			if (!empty($styles))
2458
+			{
2459
+				$this->sessionData['body'] .= $styles;
2460
+			}
2151 2461
 			$this->sessionData['body']	.= '<blockquote type="cite">';
2152 2462
 
2153
-			for($i=0; $i<count($bodyParts); $i++) {
2154
-				if($i>0) {
2463
+			for($i=0; $i<count($bodyParts); $i++)
2464
+			{
2465
+				if($i>0)
2466
+				{
2155 2467
 					$this->sessionData['body'] .= '<hr>';
2156 2468
 				}
2157
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2469
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2470
+				{
2158 2471
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2159 2472
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2160 2473
 				}
2161
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2474
+				if ($bodyParts[$i]['charSet']===false)
2475
+				{
2476
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2477
+				}
2162 2478
 
2163 2479
 				$_htmlConfig = Mail::$htmLawed_config;
2164 2480
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2170,7 +2486,9 @@  discard block
 block discarded – undo
2170 2486
 
2171 2487
 			$this->sessionData['body']	.= '</blockquote><br>';
2172 2488
 			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2173
-		} else {
2489
+		}
2490
+		else
2491
+		{
2174 2492
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2175 2493
 			// 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)
2176 2494
             $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
@@ -2180,8 +2498,10 @@  discard block
 block discarded – undo
2180 2498
                 '-------------------------------------------------'."\r\n \r\n ";
2181 2499
 			$this->sessionData['mimeType']	= 'plain';
2182 2500
 
2183
-			for($i=0; $i<count($bodyParts); $i++) {
2184
-				if($i>0) {
2501
+			for($i=0; $i<count($bodyParts); $i++)
2502
+			{
2503
+				if($i>0)
2504
+				{
2185 2505
 					$this->sessionData['body'] .= "<hr>";
2186 2506
 				}
2187 2507
 
@@ -2192,7 +2512,8 @@  discard block
 block discarded – undo
2192 2512
 				$this->sessionData['body'] .= "\r\n";
2193 2513
 				$hasSignature = false;
2194 2514
 				// create body new, with good line breaks and indention
2195
-				foreach(explode("\n",$newBody) as $value) {
2515
+				foreach(explode("\n",$newBody) as $value)
2516
+				{
2196 2517
 					// the explode is removing the character
2197 2518
 					//$value .= 'ee';
2198 2519
 
@@ -2208,9 +2529,12 @@  discard block
 block discarded – undo
2208 2529
 
2209 2530
 					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2210 2531
 
2211
-					if($bodyAppend[0] == '>') {
2532
+					if($bodyAppend[0] == '>')
2533
+					{
2212 2534
 						$bodyAppend = '>'. $bodyAppend;
2213
-					} else {
2535
+					}
2536
+					else
2537
+					{
2214 2538
 						$bodyAppend = '> '. $bodyAppend;
2215 2539
 					}
2216 2540
 
@@ -2259,9 +2583,12 @@  discard block
 block discarded – undo
2259 2583
 
2260 2584
 	static function _getHostName()
2261 2585
 	{
2262
-		if (isset($_SERVER['SERVER_NAME'])) {
2586
+		if (isset($_SERVER['SERVER_NAME']))
2587
+		{
2263 2588
 			$result = $_SERVER['SERVER_NAME'];
2264
-		} else {
2589
+		}
2590
+		else
2591
+		{
2265 2592
 			$result = 'localhost.localdomain';
2266 2593
 		}
2267 2594
 		return $result;
@@ -2299,11 +2626,16 @@  discard block
 block discarded – undo
2299 2626
 
2300 2627
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2301 2628
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2302
-		if(!empty($_formData['in-reply-to'])) {
2303
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2629
+		if(!empty($_formData['in-reply-to']))
2630
+		{
2631
+			if (stripos($_formData['in-reply-to'],'<')===false)
2632
+			{
2633
+				$_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2634
+			}
2304 2635
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2305 2636
 		}
2306
-		if(!empty($_formData['references'])) {
2637
+		if(!empty($_formData['references']))
2638
+		{
2307 2639
 			if (stripos($_formData['references'],'<')===false)
2308 2640
 			{
2309 2641
 				$_formData['references']='<'.trim($_formData['references']).'>';
@@ -2311,28 +2643,38 @@  discard block
 block discarded – undo
2311 2643
 			$_mailObject->addHeader('References', $_formData['references']);
2312 2644
 		}
2313 2645
 
2314
-		if(!empty($_formData['thread-index'])) {
2646
+		if(!empty($_formData['thread-index']))
2647
+		{
2315 2648
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2316 2649
 		}
2317
-		if(!empty($_formData['list-id'])) {
2650
+		if(!empty($_formData['list-id']))
2651
+		{
2318 2652
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2319 2653
 		}
2320
-		if($_formData['disposition']=='on') {
2654
+		if($_formData['disposition']=='on')
2655
+		{
2321 2656
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2322 2657
 		}
2323 2658
 
2324 2659
 		// Expand any mailing lists
2325 2660
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2326 2661
 		{
2327
-			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2662
+			if ($field != 'replyto')
2663
+			{
2664
+				$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2665
+			}
2328 2666
 
2329
-			if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field);
2667
+			if ($_formData[$field])
2668
+			{
2669
+				$_mailObject->addAddress($_formData[$field], '', $field);
2670
+			}
2330 2671
 		}
2331 2672
 
2332 2673
 		$_mailObject->addHeader('Subject', $_formData['subject']);
2333 2674
 
2334 2675
 		// this should never happen since we come from the edit dialog
2335
-		if (Mail::detect_qp($_formData['body'])) {
2676
+		if (Mail::detect_qp($_formData['body']))
2677
+		{
2336 2678
 			$_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']);
2337 2679
 			$_formData['body'] = quoted_printable_decode($_formData['body']);
2338 2680
 		}
@@ -2385,7 +2727,10 @@  discard block
 block discarded – undo
2385 2727
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true));
2386 2728
 			}
2387 2729
 			// convert URL Images to inline images - if possible
2388
-			if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2730
+			if (!$_autosaving)
2731
+			{
2732
+				$inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2733
+			}
2389 2734
 			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2390 2735
 			{
2391 2736
 				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@@ -2400,10 +2745,14 @@  discard block
 block discarded – undo
2400 2745
 		{
2401 2746
 			$body = $this->convertHTMLToText($_formData['body'],false);
2402 2747
 
2403
-			if ($attachment_links) $body .= $attachment_links;
2748
+			if ($attachment_links)
2749
+			{
2750
+				$body .= $attachment_links;
2751
+			}
2404 2752
 
2405 2753
 			#$_mailObject->Body = $_formData['body'];
2406
-			if(!empty($signature)) {
2754
+			if(!empty($signature))
2755
+			{
2407 2756
 				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2408 2757
 					$this->convertHTMLToText($signature,true,true);
2409 2758
 			}
@@ -2414,10 +2763,12 @@  discard block
 block discarded – undo
2414 2763
 		{
2415 2764
 			$connection_opened = false;
2416 2765
 			$tnfattachments = null;
2417
-			foreach((array)$_formData['attachments'] as $attachment) {
2766
+			foreach((array)$_formData['attachments'] as $attachment)
2767
+			{
2418 2768
 				if(is_array($attachment))
2419 2769
 				{
2420
-					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2770
+					if (!empty($attachment['uid']) && !empty($attachment['folder']))
2771
+					{
2421 2772
 						/* Example:
2422 2773
 						Array([0] => Array(
2423 2774
 						[uid] => 21178
@@ -2433,14 +2784,18 @@  discard block
 block discarded – undo
2433 2784
 							$connection_opened = true;
2434 2785
 						}
2435 2786
 						$mail_bo->reopen($attachment['folder']);
2436
-						switch(strtoupper($attachment['type'])) {
2787
+						switch(strtoupper($attachment['type']))
2788
+						{
2437 2789
 							case 'MESSAGE/RFC':
2438 2790
 							case 'MESSAGE/RFC822':
2439 2791
 								$rawBody='';
2440
-								if (isset($attachment['partID'])) {
2792
+								if (isset($attachment['partID']))
2793
+								{
2441 2794
 									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2442 2795
 									$rawBody=$eml['attachment'];
2443
-								} else {
2796
+								}
2797
+								else
2798
+								{
2444 2799
 									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2445 2800
 								}
2446 2801
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
@@ -2449,7 +2804,10 @@  discard block
 block discarded – undo
2449 2804
 								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2450 2805
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2451 2806
 								{
2452
-									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2807
+									if (!is_array($tnfattachments))
2808
+									{
2809
+										$tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2810
+									}
2453 2811
 									foreach ($tnfattachments as $k)
2454 2812
 									{
2455 2813
 										if ($k['name'] == $attachment['name'])
@@ -2484,7 +2842,10 @@  discard block
 block discarded – undo
2484 2842
 					}
2485 2843
 				}
2486 2844
 			}
2487
-			if ($connection_opened) $mail_bo->closeConnection();
2845
+			if ($connection_opened)
2846
+			{
2847
+				$mail_bo->closeConnection();
2848
+			}
2488 2849
 		}
2489 2850
 		return is_array($inline_images)?$inline_images:array();
2490 2851
 	}
@@ -2504,13 +2865,20 @@  discard block
 block discarded – undo
2504 2865
 	 */
2505 2866
 	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2506 2867
 	{
2507
-		if ($filemode == Vfs\Sharing::ATTACH) return '';
2868
+		if ($filemode == Vfs\Sharing::ATTACH)
2869
+		{
2870
+			return '';
2871
+		}
2508 2872
 
2509 2873
 		$links = array();
2510 2874
 		foreach($attachments as $attachment)
2511 2875
 		{
2512 2876
 			$path = $attachment['file'];
2513
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2877
+			if (empty($path))
2878
+			{
2879
+				continue;
2880
+			}
2881
+			// we only care about file attachments, not forwarded messages or parts
2514 2882
 			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2515 2883
 			{
2516 2884
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path);
@@ -2613,13 +2981,19 @@  discard block
 block discarded – undo
2613 2981
 								$success = false;
2614 2982
 								error_log(__METHOD__.__LINE__.$msg);
2615 2983
 							}
2616
-						} else {
2984
+						}
2985
+						else
2986
+						{
2617 2987
 							error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former');
2618 2988
 						}
2619
-					} else {
2989
+					}
2990
+					else
2991
+					{
2620 2992
 						error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)");
2621 2993
 					}
2622
-				} else {
2994
+				}
2995
+				else
2996
+				{
2623 2997
 					error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)");
2624 2998
 				}
2625 2999
 			}
@@ -2635,7 +3009,10 @@  discard block
 block discarded – undo
2635 3009
 			$success = false;
2636 3010
 		}
2637 3011
 
2638
-		if ($success) $msg = lang('Message saved successfully.');
3012
+		if ($success)
3013
+		{
3014
+			$msg = lang('Message saved successfully.');
3015
+		}
2639 3016
 
2640 3017
 		// Include new information to json respose, because we need them in client-side callback
2641 3018
 		$response->data(array(
@@ -2659,7 +3036,10 @@  discard block
 block discarded – undo
2659 3036
 		{
2660 3037
 			if(is_int($address))
2661 3038
 			{
2662
-				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
3039
+				if (!isset($contacts_obs))
3040
+				{
3041
+					$contacts_obj = new Api\Contacts();
3042
+				}
2663 3043
 				// List was selected, expand to addresses
2664 3044
 				unset($_emailAddressList[$ak]);
2665 3045
 				$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));
@@ -2674,7 +3054,10 @@  discard block
 block discarded – undo
2674 3054
 		{
2675 3055
 			foreach ($addrFromList as $addr)
2676 3056
 			{
2677
-				if (!empty($addr)) $_emailAddressList[]=$addr;
3057
+				if (!empty($addr))
3058
+				{
3059
+					$_emailAddressList[]=$addr;
3060
+				}
2678 3061
 			}
2679 3062
 		}
2680 3063
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2728,7 +3111,10 @@  discard block
 block discarded – undo
2728 3111
 		// decide where to save the message (default to draft folder, if we find nothing else)
2729 3112
 		// if the current folder is in draft or template folder save it there
2730 3113
 		// if it is called from printview then save it with the draft folder
2731
-		if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder();
3114
+		if (empty($savingDestination))
3115
+		{
3116
+			$savingDestination = $mail_bo->getDraftFolder();
3117
+		}
2732 3118
 		if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox']))
2733 3119
 		{
2734 3120
 			$this->sessionData['messageFolder'] = $this->sessionData['mailbox'];
@@ -2739,13 +3125,17 @@  discard block
 block discarded – undo
2739 3125
 			$savingDestination = $this->sessionData['messageFolder'];
2740 3126
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2741 3127
 		}
2742
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
3128
+		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 )
3129
+		{
3130
+			$savingDestination = $mail_bo->getDraftFolder();
3131
+		}
2743 3132
 
2744 3133
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2745 3134
 		$mail->forceBccHeader();
2746 3135
 
2747 3136
 		$mail_bo->openConnection();
2748
-		if ($mail_bo->folderExists($savingDestination,true)) {
3137
+		if ($mail_bo->folderExists($savingDestination,true))
3138
+		{
2749 3139
 			try
2750 3140
 			{
2751 3141
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
@@ -2756,7 +3146,9 @@  discard block
 block discarded – undo
2756 3146
 				return false;
2757 3147
 			}
2758 3148
 
2759
-		} else {
3149
+		}
3150
+		else
3151
+		{
2760 3152
 			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2761 3153
 			return false;
2762 3154
 		}
@@ -2804,7 +3196,10 @@  discard block
 block discarded – undo
2804 3196
 					$fhA = mail_ui::splitRowID($rowid);
2805 3197
 					$this->sessionData['uid'][] = $fhA['msgUID'];
2806 3198
 					$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
2807
-					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
3199
+					if (!empty($fhA['folder']))
3200
+					{
3201
+						$this->sessionData['sourceFolder'] = $fhA['folder'];
3202
+					}
2808 3203
 				}
2809 3204
 			}
2810 3205
 			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
@@ -2836,7 +3231,8 @@  discard block
 block discarded – undo
2836 3231
 			#error_log($this->sessionData['body']);
2837 3232
 		}
2838 3233
 		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2839
-		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
3234
+		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder']))
3235
+		{
2840 3236
 		   	$messageIsDraft = true;
2841 3237
 		}
2842 3238
 		try
@@ -2852,7 +3248,11 @@  discard block
 block discarded – undo
2852 3248
 		// create the messages and store inline images
2853 3249
 		$inline_images = $this->createMessage($mail, $_formData, $identity);
2854 3250
 		// remember the identity
2855
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
3251
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3252
+		{
3253
+			$fromAddress = $mail->From;
3254
+		}
3255
+		//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2856 3256
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2857 3257
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2858 3258
 		#exit;
@@ -2865,7 +3265,10 @@  discard block
 block discarded – undo
2865 3265
 		{
2866 3266
 			$fval=$f;
2867 3267
 			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2868
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3268
+			if (stripos($f,'::')!==false)
3269
+			{
3270
+				list($icServerID,$fval) = explode('::',$f,2);
3271
+			}
2869 3272
 			if ($_formData['serverID']!=$_formData['mailaccount'])
2870 3273
 			{
2871 3274
 				if ($icServerID == $_formData['serverID'] )
@@ -2906,13 +3309,19 @@  discard block
 block discarded – undo
2906 3309
 			// sentFolder is account specific
2907 3310
 			$sentFolder = $this->mail_bo->getSentFolder();
2908 3311
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2909
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3312
+			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true))
3313
+			{
3314
+				$sentFolder=false;
3315
+			}
2910 3316
 		}
2911 3317
 		else
2912 3318
 		{
2913 3319
 			$sentFolder = $mail_bo->getSentFolder();
2914 3320
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2915
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3321
+			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true))
3322
+			{
3323
+				$sentFolder=false;
3324
+			}
2916 3325
 		}
2917 3326
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2918 3327
 
@@ -2948,19 +3357,30 @@  discard block
 block discarded – undo
2948 3357
 		{
2949 3358
 			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2950 3359
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2951
-				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3360
+				$sentFolder != 'none'))
3361
+			{
3362
+				$this->errorInfo = lang("No Send Folder set in preferences");
3363
+			}
2952 3364
 		}
2953 3365
 		// draftFolder is on Server we start from
2954
-		if($messageIsDraft == true) {
3366
+		if($messageIsDraft == true)
3367
+		{
2955 3368
 			$draftFolder = $mail_bo->getDraftFolder();
2956
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3369
+			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true))
3370
+			{
2957 3371
 				$this->sessionData['folder'] = array($draftFolder);
2958 3372
 				$folderOnServerID[] = $draftFolder;
2959 3373
 				$folder[$draftFolder] = $draftFolder;
2960 3374
 			}
2961 3375
 		}
2962
-		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2963
-		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3376
+		if ($folderOnServerID)
3377
+		{
3378
+			$folderOnServerID = array_unique($folderOnServerID);
3379
+		}
3380
+		if ($folderOnMailAccount)
3381
+		{
3382
+			$folderOnMailAccount = array_unique($folderOnMailAccount);
3383
+		}
2964 3384
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2965 3385
 			!( count($folder) > 0) &&
2966 3386
 			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
@@ -2974,7 +3394,8 @@  discard block
 block discarded – undo
2974 3394
 		@set_time_limit(120);
2975 3395
 		//$mail->SMTPDebug = 10;
2976 3396
 		//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']));
2977
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3397
+		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0)
3398
+		{
2978 3399
 			try {
2979 3400
 				$mail->send();
2980 3401
 			}
@@ -2984,10 +3405,15 @@  discard block
 block discarded – undo
2984 3405
 				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2985 3406
 				return false;
2986 3407
 			}
2987
-		} else {
2988
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3408
+		}
3409
+		else
3410
+		{
3411
+			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder']))
3412
+			{
2989 3413
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2990
-			} else {
3414
+			}
3415
+			else
3416
+			{
2991 3417
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
2992 3418
 				//error_log(__METHOD__.__LINE__.$this->errorInfo);
2993 3419
 				return false;
@@ -2997,14 +3423,16 @@  discard block
 block discarded – undo
2997 3423
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
2998 3424
 		//error_log(__METHOD__.__LINE__.array2string($folder));
2999 3425
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3000
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3426
+            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3427
+		{
3001 3428
 			$mail_bo = $this->mail_bo;
3002 3429
 			$mail_bo->openConnection();
3003 3430
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
3004 3431
 			#error_log("(re)opened Connection");
3005 3432
 		}
3006 3433
 		// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
3007
-		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
3434
+		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3435
+		{
3008 3436
 			//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
3009 3437
 
3010 3438
 			// normaly Bcc is only added to recipients, but not as header visible to all recipients
@@ -3013,17 +3441,28 @@  discard block
 block discarded – undo
3013 3441
 		// copying mail to folder
3014 3442
 		if (count($folder) > 0)
3015 3443
 		{
3016
-			foreach($folderOnServerID as $folderName) {
3017
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3444
+			foreach($folderOnServerID as $folderName)
3445
+			{
3446
+				if (is_array($folderName))
3447
+				{
3448
+					$folderName = array_shift($folderName);
3449
+				}
3450
+				// should not happen at all
3018 3451
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3019 3452
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3020 3453
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3021
-				if ($mail_bo->folderExists($folderName,true)) {
3022
-					if($mail_bo->isSentFolder($folderName)) {
3454
+				if ($mail_bo->folderExists($folderName,true))
3455
+				{
3456
+					if($mail_bo->isSentFolder($folderName))
3457
+					{
3023 3458
 						$flags = '\\Seen';
3024
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3459
+					}
3460
+					elseif($mail_bo->isDraftFolder($folderName))
3461
+					{
3025 3462
 						$flags = '\\Draft';
3026
-					} else {
3463
+					}
3464
+					else
3465
+					{
3027 3466
 						$flags = '\\Seen';
3028 3467
 					}
3029 3468
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3046,18 +3485,32 @@  discard block
 block discarded – undo
3046 3485
 				}
3047 3486
 			}
3048 3487
 			// if we choose to send from a differing profile
3049
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3050
-			foreach($folderOnMailAccount as $folderName) {
3051
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3488
+			if ($folderOnMailAccount)
3489
+			{
3490
+				$this->changeProfile($_formData['mailaccount']);
3491
+			}
3492
+			foreach($folderOnMailAccount as $folderName)
3493
+			{
3494
+				if (is_array($folderName))
3495
+				{
3496
+					$folderName = array_shift($folderName);
3497
+				}
3498
+				// should not happen at all
3052 3499
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3053 3500
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3054 3501
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3055
-				if ($this->mail_bo->folderExists($folderName,true)) {
3056
-					if($this->mail_bo->isSentFolder($folderName)) {
3502
+				if ($this->mail_bo->folderExists($folderName,true))
3503
+				{
3504
+					if($this->mail_bo->isSentFolder($folderName))
3505
+					{
3057 3506
 						$flags = '\\Seen';
3058
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3507
+					}
3508
+					elseif($this->mail_bo->isDraftFolder($folderName))
3509
+					{
3059 3510
 						$flags = '\\Draft';
3060
-					} else {
3511
+					}
3512
+					else
3513
+					{
3061 3514
 						$flags = '\\Seen';
3062 3515
 					}
3063 3516
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3079,7 +3532,10 @@  discard block
 block discarded – undo
3079 3532
 					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3080 3533
 				}
3081 3534
 			}
3082
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
3535
+			if ($folderOnMailAccount)
3536
+			{
3537
+				$this->changeProfile($_formData['serverID']);
3538
+			}
3083 3539
 
3084 3540
 			//$mail_bo->closeConnection();
3085 3541
 		}
@@ -3091,10 +3547,16 @@  discard block
 block discarded – undo
3091 3547
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3092 3548
 			$lastDrafted['uid'] = $dhA['msgUID'];
3093 3549
 			$lastDrafted['folder'] = $dhA['folder'];
3094
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3550
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid']))
3551
+			{
3552
+				$lastDrafted['uid']=trim($lastDrafted['uid']);
3553
+			}
3095 3554
 			// manually drafted, do not delete
3096 3555
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3097
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3556
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid']))
3557
+			{
3558
+				$lastDrafted=false;
3559
+			}
3098 3560
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3099 3561
 		}
3100 3562
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
@@ -3120,7 +3582,8 @@  discard block
 block discarded – undo
3120 3582
 
3121 3583
 		//error_log("handling draft messages, flagging and such");
3122 3584
 		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3123
-			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3585
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3586
+		{
3124 3587
 			// mark message as answered
3125 3588
 			$mail_bo->openConnection();
3126 3589
 			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
@@ -3142,7 +3605,9 @@  discard block
 block discarded – undo
3142 3605
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
3143 3606
 					unset($e);
3144 3607
 				}
3145
-			} else {
3608
+			}
3609
+			else
3610
+			{
3146 3611
 				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3147 3612
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3148 3613
 				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
@@ -3161,7 +3626,10 @@  discard block
 block discarded – undo
3161 3626
 			}
3162 3627
 			//$mail_bo->closeConnection();
3163 3628
 		}
3164
-		if ($mail_bo) $mail_bo->closeConnection();
3629
+		if ($mail_bo)
3630
+		{
3631
+			$mail_bo->closeConnection();
3632
+		}
3165 3633
 		//error_log("performing Infolog Stuff");
3166 3634
 		//error_log(print_r($this->sessionData['to'],true));
3167 3635
 		//error_log(print_r($this->sessionData['cc'],true));
@@ -3174,9 +3642,18 @@  discard block
 block discarded – undo
3174 3642
 		{
3175 3643
 			$mailaddresses = array();
3176 3644
 		}
3177
-		if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
3178
-		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3179
-		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3645
+		if (is_array($this->sessionData['cc']))
3646
+		{
3647
+			$mailaddresses['cc'] = $this->sessionData['cc'];
3648
+		}
3649
+		if (is_array($this->sessionData['bcc']))
3650
+		{
3651
+			$mailaddresses['bcc'] = $this->sessionData['bcc'];
3652
+		}
3653
+		if (!empty($mailaddresses))
3654
+		{
3655
+			$mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3656
+		}
3180 3657
 
3181 3658
 		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3182 3659
 		{
@@ -3208,7 +3685,10 @@  discard block
 block discarded – undo
3208 3685
 							$_formData['serverID']),true),
3209 3686
 						'app' => $app_name
3210 3687
 					);
3211
-					if ($entryid) $target['entry_id'] = $entryid;
3688
+					if ($entryid)
3689
+					{
3690
+						$target['entry_id'] = $entryid;
3691
+					}
3212 3692
 					// Open the app called for integration in a popup
3213 3693
 					// and store the mail raw data as egw_data, in order to
3214 3694
 					// be stored from registered app method later
@@ -3219,8 +3699,11 @@  discard block
 block discarded – undo
3219 3699
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3220 3700
 		elseif(is_array($this->sessionData['attachments']))
3221 3701
 		{
3222
-			foreach($this->sessionData['attachments'] as $value) {
3223
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3702
+			foreach($this->sessionData['attachments'] as $value)
3703
+			{
3704
+				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs')
3705
+				{
3706
+// happens when forwarding mails
3224 3707
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3225 3708
 				}
3226 3709
 			}
@@ -3257,7 +3740,10 @@  discard block
 block discarded – undo
3257 3740
 				$default_identity = null;
3258 3741
 				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3259 3742
 				{
3260
-					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3743
+					if (!isset($default_identity))
3744
+					{
3745
+						$default_identity = $identity['ident_id'];
3746
+					}
3261 3747
 					if (!empty($identity['ident_signature']))
3262 3748
 					{
3263 3749
 						$content['mailidentity'] = $identity['ident_id'];
@@ -3265,12 +3751,18 @@  discard block
 block discarded – undo
3265 3751
 					}
3266 3752
 				}
3267 3753
 			}
3268
-			if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity;
3754
+			if (empty($content['mailidentity']))
3755
+			{
3756
+				$content['mailidentity'] = $default_identity;
3757
+			}
3269 3758
 		}
3270 3759
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3271 3760
 		{
3272 3761
 			$content['mimeType'] = 'html';
3273
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3762
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text")
3763
+			{
3764
+				$content['mimeType']  = 'plain';
3765
+			}
3274 3766
 		}
3275 3767
 		return $content;
3276 3768
 
@@ -3278,9 +3770,12 @@  discard block
 block discarded – undo
3278 3770
 
3279 3771
 	function stripSlashes($_string)
3280 3772
 	{
3281
-		if (get_magic_quotes_gpc()) {
3773
+		if (get_magic_quotes_gpc())
3774
+		{
3282 3775
 			return stripslashes($_string);
3283
-		} else {
3776
+		}
3777
+		else
3778
+		{
3284 3779
 			return $_string;
3285 3780
 		}
3286 3781
 	}
@@ -3293,15 +3788,25 @@  discard block
 block discarded – undo
3293 3788
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3294 3789
 	 * @return type
3295 3790
 	 */
3296
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3791
+	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
3792
+	{
3297 3793
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3298 3794
 		static $useCacheIfPossible = null;
3299
-		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
3795
+		if (is_null($useCacheIfPossible))
3796
+		{
3797
+			$useCacheIfPossible = true;
3798
+		}
3300 3799
 		$_searchString = trim($_REQUEST['query']);
3301 3800
 		$results = array();
3302 3801
 		$rememberServerID = $this->mail_bo->icServer->ImapServerId;
3303
-		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount'];
3304
-		if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3802
+		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount']))
3803
+		{
3804
+			$_mailaccountToSearch = $_REQUEST['mailaccount'];
3805
+		}
3806
+		if (empty($_mailaccountToSearch))
3807
+		{
3808
+			$_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3809
+		}
3305 3810
 		if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch)
3306 3811
 		{
3307 3812
 			$this->changeProfile($_mailaccountToSearch);
@@ -3312,7 +3817,8 @@  discard block
 block discarded – undo
3312 3817
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3313 3818
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3314 3819
 			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3315
-			if (count($folderObjects)<=1) {
3820
+			if (count($folderObjects)<=1)
3821
+			{
3316 3822
 				$useCacheIfPossible = false;
3317 3823
 			}
3318 3824
 			else
@@ -3363,7 +3869,8 @@  discard block
 block discarded – undo
3363 3869
 		exit();
3364 3870
 	}
3365 3871
 
3366
-	public static function ajax_searchAddress($_searchStringLength=2) {
3872
+	public static function ajax_searchAddress($_searchStringLength=2)
3873
+	{
3367 3874
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3368 3875
 		$_searchString = trim($_REQUEST['query']);
3369 3876
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3376,7 +3883,8 @@  discard block
 block discarded – undo
3376 3883
 		{
3377 3884
 			$lists = array_filter(
3378 3885
 				$contacts_obj->get_lists(Acl::READ),
3379
-				function($element) use($_searchString) {
3886
+				function($element) use($_searchString)
3887
+				{
3380 3888
 					return (stripos($element, $_searchString) !== false);
3381 3889
 				}
3382 3890
 			);
@@ -3391,7 +3899,10 @@  discard block
 block discarded – undo
3391 3899
 					'title' => lang('Mailinglist'),
3392 3900
 					'data'	=> $key
3393 3901
 				);
3394
-				if($list_count++ > 5) break;
3902
+				if($list_count++ > 5)
3903
+				{
3904
+					break;
3905
+				}
3395 3906
 			}
3396 3907
 		}
3397 3908
 
@@ -3402,7 +3913,10 @@  discard block
 block discarded – undo
3402 3913
 			$search = explode(' ', $_searchString);
3403 3914
 			foreach ($search as $k => $v)
3404 3915
 			{
3405
-				if (mb_strlen($v) < 3) unset($search[$k]);
3916
+				if (mb_strlen($v) < 3)
3917
+				{
3918
+					unset($search[$k]);
3919
+				}
3406 3920
 			}
3407 3921
 			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3408 3922
 			//error_log(__METHOD__.__LINE__.$_searchString);
@@ -3432,9 +3946,12 @@  discard block
 block discarded – undo
3432 3946
 			}
3433 3947
 		}
3434 3948
 		
3435
-		if(is_array($contacts)) {
3436
-			foreach($contacts as $contact) {
3437
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3949
+		if(is_array($contacts))
3950
+		{
3951
+			foreach($contacts as $contact)
3952
+			{
3953
+				foreach(array($contact['email'],$contact['email_home']) as $email)
3954
+				{
3438 3955
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3439 3956
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3440 3957
 					$rfcAddr = Mail::parseAddressList($email);
@@ -3448,10 +3965,22 @@  discard block
 block discarded – undo
3448 3965
 					if (method_exists($contacts_obj,'search'))
3449 3966
 					{
3450 3967
 						$contact['n_fn']='';
3451
-						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3452
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3453
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3454
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3968
+						if (!empty($contact['n_prefix']))
3969
+						{
3970
+							$contact['n_fn'] = $contact['n_prefix'];
3971
+						}
3972
+						if (!empty($contact['n_given']))
3973
+						{
3974
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3975
+						}
3976
+						if (!empty($contact['n_family']))
3977
+						{
3978
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3979
+						}
3980
+						if (!empty($contact['org_name']))
3981
+						{
3982
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3983
+						}
3455 3984
 						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3456 3985
 					}
3457 3986
 					else
@@ -3461,7 +3990,8 @@  discard block
 block discarded – undo
3461 3990
 					$args = explode('@', trim($email));
3462 3991
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3463 3992
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3464
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3993
+					if(!empty($email) && in_array($completeMailString ,$results) === false)
3994
+					{
3465 3995
 						$results[] = array(
3466 3996
 							'id'=>$completeMailString,
3467 3997
 							'label' => $completeMailString,
@@ -3480,7 +4010,10 @@  discard block
 block discarded – undo
3480 4010
 		foreach($groups as $g_id => $name)
3481 4011
 		{
3482 4012
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3483
-			if(!$group['account_email']) continue;
4013
+			if(!$group['account_email'])
4014
+			{
4015
+				continue;
4016
+			}
3484 4017
 			$args = explode('@', trim($group['account_email']));
3485 4018
 			$args[] = $name;
3486 4019
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
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.