Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
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_so.inc.php 5 patches
Doc Comments   +1 added lines, -14 removed lines patch added patch discarded remove patch
@@ -85,6 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * Check if user is responsible for an entry: he or one of his memberships is in responsible
86 86
 	 *
87 87
 	 * @param array $info infolog entry as array
88
+	 * @param integer $user
88 89
 	 * @return boolean
89 90
 	 */
90 91
 	function is_responsible($info,$user=null)
@@ -476,8 +477,6 @@  discard block
 block discarded – undo
476 477
 	 * changes or deletes entries with a spezified owner (for hook_delete_account)
477 478
 	 *
478 479
 	 * @param array $args hook arguments
479
-	 * @param int $args['account_id'] account to delete
480
-	 * @param int $args['new_owner']=0 new owner
481 480
 	 */
482 481
 	function change_delete_owner(array $args)  // new_owner=0 means delete
483 482
 	{
@@ -659,19 +658,7 @@  discard block
 block discarded – undo
659 658
 	/**
660 659
 	 * searches InfoLog for a certain pattern in $query
661 660
 	 *
662
-	 * @param string $query[order] column-name to sort after
663
-	 * @param string $query[sort] sort-order DESC or ASC
664
-	 * @param string $query[filter] string with combination of acl-, date- and status-filters, eg. 'own-open-today' or ''
665
-	 * @param int $query[cat_id] category to use or 0 or unset
666
-	 * @param string $query[search] pattern to search, search is done in info_from, info_subject and info_des
667
-	 * @param string $query[action] / $query[action_id] if only entries linked to a specified app/entry show be used
668 661
 	 * @param int &$query[start], &$query[total] nextmatch-parameters will be used and set if query returns less entries
669
-	 * @param array $query[col_filter] array with column-name - data pairs, data == '' means no filter (!)
670
-	 * @param boolean $query[subs] return subs or not, if unset the user preference is used
671
-	 * @param int $query[num_rows] number of rows to return if $query[start] is set, default is to use the value from the general prefs
672
-	 * @param string|array $query[cols]=null what to query, if set the recordset / iterator get's returned
673
-	 * @param string $query[append]=null get's appended to sql query, eg. for GROUP BY
674
-	 * @param boolean $query['custom_fields']=false query custom-fields too, default not
675 662
 	 * @return array|iterator with id's as key of the matching log-entries or recordset/iterator if cols is set
676 663
 	 */
677 664
 	function search(&$query)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
 				$filtermethod .= " OR (".$this->responsible_filter($this->user).
249 249
 					($filter == 'own' && count($public_user_list) ?	// offer's should show up in own, eg. startpage, but need read-access
250 250
 						" OR info_status = 'offer' AND $public_access" : '').")".
251
-				                 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
251
+								 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
252 252
 			}
253 253
 			elseif ($filter != 'my' && $filter != 'responsible')	// none --> all entrys user has rights to see
254 254
 			{
Please login to merge, or discard this patch.
Spacing   +159 added lines, -160 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param array $grants =array()
72 72
 	 * @return soinfolog
73 73
 	 */
74
-	function __construct( $grants=array() )
74
+	function __construct($grants = array())
75 75
 	{
76 76
 		$this->db     = clone($GLOBALS['egw']->db);
77 77
 		$this->db->set_app('infolog');
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
 	 * @param array $info infolog entry as array
88 88
 	 * @return boolean
89 89
 	 */
90
-	function is_responsible($info,$user=null)
90
+	function is_responsible($info, $user = null)
91 91
 	{
92 92
 		if (!$user) $user = $this->user;
93 93
 
94 94
 		static $um_cache = array();
95
-		if ($user == $this->user) $user_and_memberships =& $um_cache[$user];
95
+		if ($user == $this->user) $user_and_memberships = & $um_cache[$user];
96 96
 		if (!isset($user_and_memberships))
97 97
 		{
98
-			$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user,true);
98
+			$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user, true);
99 99
 			$user_and_memberships[] = $user;
100 100
 		}
101
-		return $info['info_responsible'] && array_intersect((array)$info['info_responsible'],$user_and_memberships);
101
+		return $info['info_responsible'] && array_intersect((array)$info['info_responsible'], $user_and_memberships);
102 102
 	}
103 103
 
104 104
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param int $user =null user to check, default (null) $this->user
112 112
 	 * @return boolean True if access is granted else False
113 113
 	 */
114
-	function check_access( $info,$required_rights,$implicit_edit=false,array $grants=null,$user=null )
114
+	function check_access($info, $required_rights, $implicit_edit = false, array $grants = null, $user = null)
115 115
 	{
116 116
 		if (is_null($grants)) $grants = $this->grants;
117 117
 		if (!$user) $user = $this->user;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		{
124 124
 
125 125
 		}
126
-		elseif ((int) $info != $this->data['info_id'])      	// already loaded?
126
+		elseif ((int)$info != $this->data['info_id'])      	// already loaded?
127 127
 		{
128 128
 			// dont change our own internal data,
129 129
 			$backup_data = $this->data;
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 			return False;
140 140
 		}
141 141
 		$owner = $info['info_owner'];
142
-		$access_ok = $owner == $user ||	// user has all rights
142
+		$access_ok = $owner == $user || // user has all rights
143 143
 			// ACL only on public entrys || $owner granted _PRIVATE
144
-			(!!($grants[$owner] & $required_rights) ||
145
-				$this->is_responsible($info,$user) &&	// implicite rights for responsible user(s) and his memberships
144
+			(!!($grants[$owner]&$required_rights) ||
145
+				$this->is_responsible($info, $user) && // implicite rights for responsible user(s) and his memberships
146 146
 				($required_rights == Acl::READ || $required_rights == Acl::ADD || $implicit_edit && $required_rights == Acl::EDIT)) &&
147
-			($info['info_access'] == 'public' || !!($this->grants[$user] & Acl::PRIVAT));
147
+			($info['info_access'] == 'public' || !!($this->grants[$user]&Acl::PRIVAT));
148 148
 
149 149
 		// error_log(__METHOD__."($info[info_id],$required_rights,$implicit_edit,".array2string($grants).",$user) returning ".array2string($access_ok));
150 150
 		return $access_ok;
@@ -163,23 +163,22 @@  discard block
 block discarded – undo
163 163
 		if (!$users) return '0';
164 164
 
165 165
 		$responsible = array();
166
-		foreach((array)$users as $user)
166
+		foreach ((array)$users as $user)
167 167
 		{
168
-			$responsible = array_merge($responsible,(array)
169
-				($user > 0 ? $GLOBALS['egw']->accounts->memberships($user,true) :
170
-					$GLOBALS['egw']->accounts->members($user,true)));
168
+			$responsible = array_merge($responsible, (array)
169
+				($user > 0 ? $GLOBALS['egw']->accounts->memberships($user, true) : $GLOBALS['egw']->accounts->members($user, true)));
171 170
 			$responsible[] = $user;
172 171
 		}
173 172
 		if (is_array($users))
174 173
 		{
175 174
 			$responsible = array_unique($responsible);
176 175
 		}
177
-		foreach($responsible as $key => $uid)
176
+		foreach ($responsible as $key => $uid)
178 177
 		{
179
-			$responsible[$key] = $this->db->concat("','",'info_responsible',"','")." LIKE '%,$uid,%'";
178
+			$responsible[$key] = $this->db->concat("','", 'info_responsible', "','")." LIKE '%,$uid,%'";
180 179
 		}
181 180
 		//echo "<p align=right>responsible_filter($user) = ".'('.implode(' OR ',$responsible).')'."</p>\n";
182
-		return '('.implode(' OR ',$responsible).')';
181
+		return '('.implode(' OR ', $responsible).')';
183 182
 	}
184 183
 
185 184
 	/**
@@ -194,17 +193,17 @@  discard block
 block discarded – undo
194 193
 	function aclFilter($_filter = False)
195 194
 	{
196 195
 		$vars = null;
197
-		preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/',$_filter,$vars);
196
+		preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/', $_filter, $vars);
198 197
 		$filter = $vars[1];
199 198
 		$f_user = $vars[2];
200 199
 
201 200
 		if (isset($this->acl_filter[$filter.$f_user]))
202 201
 		{
203
-			return $this->acl_filter[$filter.$f_user];  // used cached filter if found
202
+			return $this->acl_filter[$filter.$f_user]; // used cached filter if found
204 203
 		}
205
-		if ($f_user && strpos($f_user,',') !== false)
204
+		if ($f_user && strpos($f_user, ',') !== false)
206 205
 		{
207
-			$f_user = explode(',',$f_user);
206
+			$f_user = explode(',', $f_user);
208 207
 		}
209 208
 
210 209
 		$filtermethod = " (info_owner=$this->user"; // user has all rights
@@ -221,24 +220,24 @@  discard block
 block discarded – undo
221 220
 		{
222 221
 			if (is_array($this->grants))
223 222
 			{
224
-				foreach($this->grants as $user => $grant)
223
+				foreach ($this->grants as $user => $grant)
225 224
 				{
226 225
 					// echo "<p>grants: user=$user, grant=$grant</p>";
227
-					if ($grant & (EGW_ACL_READ|EGW_ACL_EDIT))
226
+					if ($grant&(EGW_ACL_READ|EGW_ACL_EDIT))
228 227
 					{
229 228
 						$public_user_list[] = $user;
230 229
 					}
231
-					if ($grant & Acl::PRIVAT)
230
+					if ($grant&Acl::PRIVAT)
232 231
 					{
233 232
 						$private_user_list[] = $user;
234 233
 					}
235 234
 				}
236 235
 				if (count($private_user_list))
237 236
 				{
238
-					$has_private_access = $this->db->expression($this->info_table,array('info_owner' => $private_user_list));
237
+					$has_private_access = $this->db->expression($this->info_table, array('info_owner' => $private_user_list));
239 238
 				}
240 239
 			}
241
-			$public_access = $this->db->expression($this->info_table,array('info_owner' => $public_user_list));
240
+			$public_access = $this->db->expression($this->info_table, array('info_owner' => $public_user_list));
242 241
 			// implicit read-rights for responsible user
243 242
 			$filtermethod .= " OR (".$this->responsible_filter($this->user).')';
244 243
 
@@ -246,9 +245,9 @@  discard block
 block discarded – undo
246 245
 			if ($filter == 'private' || $filter == 'privat' || $filter == 'own')
247 246
 			{
248 247
 				$filtermethod .= " OR (".$this->responsible_filter($this->user).
249
-					($filter == 'own' && count($public_user_list) ?	// offer's should show up in own, eg. startpage, but need read-access
248
+					($filter == 'own' && count($public_user_list) ? // offer's should show up in own, eg. startpage, but need read-access
250 249
 						" OR info_status = 'offer' AND $public_access" : '').")".
251
-				                 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
250
+				                 " AND (info_access='public'".($has_private_access ? " OR $has_private_access" : '').')';
252 251
 			}
253 252
 			elseif ($filter != 'my' && $filter != 'responsible')	// none --> all entrys user has rights to see
254 253
 			{
@@ -265,13 +264,13 @@  discard block
 block discarded – undo
265 264
 
266 265
 			if ($filter == 'user' && $f_user)
267 266
 			{
268
-				$filtermethod .= $this->db->expression($this->info_table,' AND (',array(
267
+				$filtermethod .= $this->db->expression($this->info_table, ' AND (', array(
269 268
 					'info_owner' => $f_user,
270
-				)," AND info_responsible='0' OR ",$this->responsible_filter($f_user),')');
269
+				), " AND info_responsible='0' OR ", $this->responsible_filter($f_user), ')');
271 270
 			}
272 271
 		}
273 272
 		//echo "<p>aclFilter(filter='$_filter',user='$f_user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."</p>\n";
274
-		return $this->acl_filter[$filter.$f_user] = $filtermethod;  // cache the filter
273
+		return $this->acl_filter[$filter.$f_user] = $filtermethod; // cache the filter
275 274
 	}
276 275
 
277 276
 	/**
@@ -281,18 +280,18 @@  discard block
 block discarded – undo
281 280
 	 * @param boolean $prefix_and =true if true prefix the fileter with ' AND '
282 281
 	 * @return string the necesary sql
283 282
 	 */
284
-	function statusFilter($_filter = '',$prefix_and=true)
283
+	function statusFilter($_filter = '', $prefix_and = true)
285 284
 	{
286 285
 		$vars = null;
287
-		preg_match('/(done|open|offer|deleted|\+deleted)/',$_filter,$vars);
286
+		preg_match('/(done|open|offer|deleted|\+deleted)/', $_filter, $vars);
288 287
 		$filter = $vars[1];
289 288
 
290 289
 		switch ($filter)
291 290
 		{
292 291
 			case 'done':	$filter = "info_status IN ('done','billed','cancelled')"; break;
293 292
 			case 'open':	$filter = "NOT (info_status IN ('done','billed','cancelled','deleted','template','nonactive','archive'))"; break;
294
-			case 'offer':	$filter = "info_status = 'offer'";    break;
295
-			case 'deleted': $filter = "info_status = 'deleted'";  break;
293
+			case 'offer':	$filter = "info_status = 'offer'"; break;
294
+			case 'deleted': $filter = "info_status = 'deleted'"; break;
296 295
 			case '+deleted':$filter = "NOT (info_status IN ('template','nonactive','archive'))"; break;
297 296
 			default:        $filter = "NOT (info_status IN ('deleted','template','nonactive','archive'))"; break;
298 297
 		}
@@ -313,18 +312,18 @@  discard block
 block discarded – undo
313 312
 	function dateFilter($_filter = '')
314 313
 	{
315 314
 		$vars = null;
316
-		preg_match('/(open-upcoming|upcoming|today|overdue|date|enddate)([-\\/.0-9]*)/',$_filter,$vars);
315
+		preg_match('/(open-upcoming|upcoming|today|overdue|date|enddate)([-\\/.0-9]*)/', $_filter, $vars);
317 316
 		$filter = $vars[1];
318 317
 
319
-		if (isset($vars[2]) && !empty($vars[2]) && ($date = preg_split('/[-\\/.]/',$vars[2])))
318
+		if (isset($vars[2]) && !empty($vars[2]) && ($date = preg_split('/[-\\/.]/', $vars[2])))
320 319
 		{
321
-			$today = mktime(-$this->tz_offset,0,0,intval($date[1]),intval($date[2]),intval($date[0]));
322
-			$tomorrow = mktime(-$this->tz_offset,0,0,intval($date[1]),intval($date[2])+1,intval($date[0]));
320
+			$today = mktime(-$this->tz_offset, 0, 0, intval($date[1]), intval($date[2]), intval($date[0]));
321
+			$tomorrow = mktime(-$this->tz_offset, 0, 0, intval($date[1]), intval($date[2]) + 1, intval($date[0]));
323 322
 		}
324 323
 		else
325 324
 		{
326
-			$now = getdate(time()-60*60*$this->tz_offset);
327
-			$tomorrow = mktime(-$this->tz_offset,0,0,$now['mon'],$now['mday']+1,$now['year']);
325
+			$now = getdate(time() - 60 * 60 * $this->tz_offset);
326
+			$tomorrow = mktime(-$this->tz_offset, 0, 0, $now['mon'], $now['mday'] + 1, $now['year']);
328 327
 		}
329 328
 		switch ($filter)
330 329
 		{
@@ -388,7 +387,7 @@  discard block
 block discarded – undo
388 387
 			$minimum_uid_length = 8;
389 388
 		}
390 389
 
391
-		if (!$where || !($this->data = $this->db->select($this->info_table,'*',$where,__LINE__,__FILE__)->fetch()))
390
+		if (!$where || !($this->data = $this->db->select($this->info_table, '*', $where, __LINE__, __FILE__)->fetch()))
392 391
 		{
393 392
 			$this->init( );
394 393
 			//error_log(__METHOD__.'('.array2string($where).') returning FALSE');
@@ -400,15 +399,15 @@  discard block
 block discarded – undo
400 399
 			$this->data['info_uid'] = Api\CalDAV::generate_uid('infolog', $this->data['info_id']);
401 400
 			$this->db->update($this->info_table,
402 401
 				array('info_uid' => $this->data['info_uid']),
403
-				array('info_id' => $this->data['info_id']), __LINE__,__FILE__);
402
+				array('info_id' => $this->data['info_id']), __LINE__, __FILE__);
404 403
 		}
405 404
 		if (!is_array($this->data['info_responsible']))
406 405
 		{
407
-			$this->data['info_responsible'] = $this->data['info_responsible'] ? explode(',',$this->data['info_responsible']) : array();
406
+			$this->data['info_responsible'] = $this->data['info_responsible'] ? explode(',', $this->data['info_responsible']) : array();
408 407
 		}
409 408
 		// Cast back to integer
410 409
 		$this->data['info_id_parent'] = (int)$this->data['info_id_parent'];
411
-		foreach($this->db->select($this->extra_table,'info_extra_name,info_extra_value',array('info_id'=>$this->data['info_id']),__LINE__,__FILE__) as $row)
410
+		foreach ($this->db->select($this->extra_table, 'info_extra_name,info_extra_value', array('info_id'=>$this->data['info_id']), __LINE__, __FILE__) as $row)
412 411
 		{
413 412
 			$this->data['#'.$row['info_extra_name']] = $row['info_extra_value'];
414 413
 		}
@@ -423,16 +422,16 @@  discard block
 block discarded – undo
423 422
 	 * @param boolean $delete_children delete the children, if not set there parent-id to $new_parent
424 423
 	 * @param int $new_parent new parent-id to set for subs
425 424
 	 */
426
-	function delete($info_id,$delete_children=True,$new_parent=0)  // did _not_ ensure ACL
425
+	function delete($info_id, $delete_children = True, $new_parent = 0)  // did _not_ ensure ACL
427 426
 	{
428 427
 		//echo "<p>soinfolog::delete($info_id,'$delete_children',$new_parent)</p>\n";
429
-		if ((int) $info_id <= 0)
428
+		if ((int)$info_id <= 0)
430 429
 		{
431 430
 			return;
432 431
 		}
433
-		$this->db->delete($this->info_table,array('info_id'=>$info_id),__LINE__,__FILE__);
434
-		$this->db->delete($this->extra_table,array('info_id'=>$info_id),__LINE__,__FILE__);
435
-		Link::unlink(0,'infolog',$info_id);
432
+		$this->db->delete($this->info_table, array('info_id'=>$info_id), __LINE__, __FILE__);
433
+		$this->db->delete($this->extra_table, array('info_id'=>$info_id), __LINE__, __FILE__);
434
+		Link::unlink(0, 'infolog', $info_id);
436 435
 
437 436
 		if ($this->data['info_id'] == $info_id)
438 437
 		{
@@ -441,17 +440,17 @@  discard block
 block discarded – undo
441 440
 		// delete children, if they are owned by the user
442 441
 		if ($delete_children)
443 442
 		{
444
-			$db2 = clone($this->db);	// we need an extra result-set
445
-			foreach($db2->select($this->info_table,'info_id',array(
443
+			$db2 = clone($this->db); // we need an extra result-set
444
+			foreach ($db2->select($this->info_table, 'info_id', array(
446 445
 					'info_id_parent'	=> $info_id,
447 446
 					'info_owner'		=> $this->user,
448
-				),__LINE__,__FILE__) as $row)
447
+				), __LINE__, __FILE__) as $row)
449 448
 			{
450 449
 				$this->delete($row['info_id'], $delete_children);
451 450
 			}
452 451
 		}
453 452
 		// set parent_id to $new_parent or 0 for all not deleted children
454
-		$this->db->update($this->info_table,array('info_id_parent'=>$new_parent),array('info_id_parent'=>$info_id),__LINE__,__FILE__);
453
+		$this->db->update($this->info_table, array('info_id_parent'=>$new_parent), array('info_id_parent'=>$info_id), __LINE__, __FILE__);
455 454
 	}
456 455
 
457 456
 	/**
@@ -463,9 +462,9 @@  discard block
 block discarded – undo
463 462
 	function get_children($info_id)
464 463
 	{
465 464
 		$children = array();
466
-		foreach($this->db->select($this->info_table, 'info_id,info_owner', array(
465
+		foreach ($this->db->select($this->info_table, 'info_id,info_owner', array(
467 466
 			'info_id_parent'	=> $info_id,
468
-		),__LINE__,__FILE__) as $row)
467
+		), __LINE__, __FILE__) as $row)
469 468
 		{
470 469
 			$children[$row['info_id']] = $row['info_owner'];
471 470
 		}
@@ -481,27 +480,27 @@  discard block
 block discarded – undo
481 480
 	 */
482 481
 	function change_delete_owner(array $args)  // new_owner=0 means delete
483 482
 	{
484
-		if (!(int) $args['new_owner'])
483
+		if (!(int)$args['new_owner'])
485 484
 		{
486
-			foreach($this->db->select($this->info_table,'info_id',array('info_owner'=>$args['account_id']),__LINE__,__FILE__,false,'','infolog') as $row)
485
+			foreach ($this->db->select($this->info_table, 'info_id', array('info_owner'=>$args['account_id']), __LINE__, __FILE__, false, '', 'infolog') as $row)
487 486
 			{
488
-				$this->delete($row['info_id'],False);
487
+				$this->delete($row['info_id'], False);
489 488
 			}
490 489
 		}
491 490
 		else
492 491
 		{
493
-			$this->db->update($this->info_table,array('info_owner'=>$args['new_owner']),array('info_owner'=>$args['account_id']),__LINE__,__FILE__,'infolog');
492
+			$this->db->update($this->info_table, array('info_owner'=>$args['new_owner']), array('info_owner'=>$args['account_id']), __LINE__, __FILE__, 'infolog');
494 493
 		}
495
-		foreach($this->db->select($this->info_table,'info_id,info_responsible',
496
-			$this->db->concat("','",'info_responsible',"','").' LIKE '.$this->db->quote('%,'.(int)$args['account_id'].',%'),
497
-			__LINE__,__FILE__,false,'','infolog') as $row)
494
+		foreach ($this->db->select($this->info_table, 'info_id,info_responsible',
495
+			$this->db->concat("','", 'info_responsible', "','").' LIKE '.$this->db->quote('%,'.(int)$args['account_id'].',%'),
496
+			__LINE__, __FILE__, false, '', 'infolog') as $row)
498 497
 		{
499
-			$new_responsible = explode(',',$row['info_responsible']);
500
-			unset($new_responsible[array_search($args['account_id'],$new_responsible)]);
498
+			$new_responsible = explode(',', $row['info_responsible']);
499
+			unset($new_responsible[array_search($args['account_id'], $new_responsible)]);
501 500
 			if ((int)$args['new_owner']) $new_responsible[] = (int)$args['new_owner'];
502
-			$this->db->update($this->info_table,array(
503
-				'info_responsible' => implode(',',$new_responsible),
504
-			),array('info_id' => $row['info_id']),__LINE__,__FILE__,'infolog');
501
+			$this->db->update($this->info_table, array(
502
+				'info_responsible' => implode(',', $new_responsible),
503
+			), array('info_id' => $row['info_id']), __LINE__, __FILE__, 'infolog');
505 504
 		}
506 505
 	}
507 506
 
@@ -513,7 +512,7 @@  discard block
 block discarded – undo
513 512
 	 * @param string $purge_cfs =null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs
514 513
 	 * @return int|boolean info_id, false on error or 0 if the entry has been updated in the meantime
515 514
 	 */
516
-	function write($values, $check_modified=0, $purge_cfs=null)  // did _not_ ensure ACL
515
+	function write($values, $check_modified = 0, $purge_cfs = null)  // did _not_ ensure ACL
517 516
 	{
518 517
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
519 518
 		{
@@ -525,19 +524,19 @@  discard block
 block discarded – undo
525 524
 		}
526 525
 
527 526
 		//echo "soinfolog::write(,$check_modified) values="; _debug_array($values);
528
-		$info_id = (int) $values['info_id'];
527
+		$info_id = (int)$values['info_id'];
529 528
 
530
-		if (array_key_exists('info_responsible',$values))	// isset($values['info_responsible']) returns false for NULL!
529
+		if (array_key_exists('info_responsible', $values))	// isset($values['info_responsible']) returns false for NULL!
531 530
 		{
532
-			$values['info_responsible'] = $values['info_responsible'] ? implode(',',$values['info_responsible']) : '0';
531
+			$values['info_responsible'] = $values['info_responsible'] ? implode(',', $values['info_responsible']) : '0';
533 532
 		}
534
-		$table_def = $this->db->get_table_definitions('infolog',$this->info_table);
533
+		$table_def = $this->db->get_table_definitions('infolog', $this->info_table);
535 534
 		$to_write = array();
536
-		foreach($values as $key => $val)
535
+		foreach ($values as $key => $val)
537 536
 		{
538 537
 			if ($key != 'info_id' && isset($table_def['fd'][$key]))
539 538
 			{
540
-				$to_write[$key] = $this->data[$key] = $val;   // update internal data
539
+				$to_write[$key] = $this->data[$key] = $val; // update internal data
541 540
 			}
542 541
 		}
543 542
 		// writing no price as SQL NULL (required by postgres)
@@ -547,23 +546,23 @@  discard block
 block discarded – undo
547 546
 		{
548 547
 			$where = array('info_id' => $info_id);
549 548
 			if ($check_modified) $where['info_datemodified'] = $check_modified;
550
-			if (!$this->db->update($this->info_table,$to_write,$where,__LINE__,__FILE__))
549
+			if (!$this->db->update($this->info_table, $to_write, $where, __LINE__, __FILE__))
551 550
 			{
552 551
 				//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning false");
553
-				return false;	// Error
552
+				return false; // Error
554 553
 			}
555 554
 			if ($check_modified && $this->db->affected_rows() < 1)
556 555
 			{
557 556
 				//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning 0 (nothing updated, eg. condition not met)");
558
-				return 0;	// someone else updated the modtime or deleted the entry
557
+				return 0; // someone else updated the modtime or deleted the entry
559 558
 			}
560 559
 		}
561 560
 		else
562 561
 		{
563
-			if (!isset($to_write['info_id_parent'])) $to_write['info_id_parent'] = 0;	// must not be null
562
+			if (!isset($to_write['info_id_parent'])) $to_write['info_id_parent'] = 0; // must not be null
564 563
 
565
-			$this->db->insert($this->info_table,$to_write,false,__LINE__,__FILE__);
566
-			$info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table,'info_id');
564
+			$this->db->insert($this->info_table, $to_write, false, __LINE__, __FILE__);
565
+			$info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table, 'info_id');
567 566
 		}
568 567
 
569 568
 		$update = array();
@@ -579,8 +578,8 @@  discard block
 block discarded – undo
579 578
 		}
580 579
 		if ($update)
581 580
 		{
582
-			$this->db->update($this->info_table,$update,
583
-				array('info_id' => $info_id), __LINE__,__FILE__);
581
+			$this->db->update($this->info_table, $update,
582
+				array('info_id' => $info_id), __LINE__, __FILE__);
584 583
 		}
585 584
 
586 585
 		//echo "<p>soinfolog.write values= "; _debug_array($values);
@@ -590,38 +589,38 @@  discard block
 block discarded – undo
590 589
 		{
591 590
 			$where = array('info_id' => $info_id);
592 591
 			if ($purge_cfs == 'ical') $where[] = "info_extra_name LIKE '#%'";
593
-			$this->db->delete($this->extra_table,$where,__LINE__,__FILE__);
592
+			$this->db->delete($this->extra_table, $where, __LINE__, __FILE__);
594 593
 		}
595 594
 		$to_delete = array();
596
-		foreach($values as $key => $val)
595
+		foreach ($values as $key => $val)
597 596
 		{
598 597
 			if ($key[0] != '#')
599 598
 			{
600
-				continue;	// no customfield
599
+				continue; // no customfield
601 600
 			}
602
-			$this->data[$key] = $val;	// update internal data
601
+			$this->data[$key] = $val; // update internal data
603 602
 
604 603
 			if ($val)
605 604
 			{
606
-				$this->db->insert($this->extra_table,array(
605
+				$this->db->insert($this->extra_table, array(
607 606
 						// store multivalued CalDAV properties as serialized array, everything else get comma-separated
608
-						'info_extra_value'	=> is_array($val) ? ($key[1] == '#' ? serialize($val) : implode(',',$val)) : $val,
609
-					),array(
607
+						'info_extra_value'	=> is_array($val) ? ($key[1] == '#' ? serialize($val) : implode(',', $val)) : $val,
608
+					), array(
610 609
 						'info_id'			=> $info_id,
611
-						'info_extra_name'	=> substr($key,1),
612
-					),__LINE__,__FILE__);
610
+						'info_extra_name'	=> substr($key, 1),
611
+					), __LINE__, __FILE__);
613 612
 			}
614 613
 			else
615 614
 			{
616
-				$to_delete[] = substr($key,1);
615
+				$to_delete[] = substr($key, 1);
617 616
 			}
618 617
 		}
619 618
 		if ($to_delete && !$purge_cfs)
620 619
 		{
621
-			$this->db->delete($this->extra_table,array(
620
+			$this->db->delete($this->extra_table, array(
622 621
 					'info_id'			=> $info_id,
623 622
 					'info_extra_name'	=> $to_delete,
624
-				),__LINE__,__FILE__);
623
+				), __LINE__, __FILE__);
625 624
 		}
626 625
 		// echo "<p>soinfolog.write this->data= "; _debug_array($this->data);
627 626
 		//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning id=".$this->data['info_id']);
@@ -637,18 +636,18 @@  discard block
 block discarded – undo
637 636
 	 * @param int|array $info_id id(s) of log-entry
638 637
 	 * @return int|array the number of sub-entries or indexed by info_id, if array as param given
639 638
 	 */
640
-	function anzSubs( $info_id )
639
+	function anzSubs($info_id)
641 640
 	{
642 641
 		if (!is_array($info_id) || !$info_id)
643 642
 		{
644 643
 			if ((int)$info_id <= 0) return 0;
645 644
 		}
646 645
 		$counts = array();
647
-		foreach($this->db->select($this->info_table,'info_id_parent,COUNT(*) AS info_anz_subs',array(
646
+		foreach ($this->db->select($this->info_table, 'info_id_parent,COUNT(*) AS info_anz_subs', array(
648 647
 			'info_id_parent' => $info_id,
649
-			"info_status != 'deleted'",	// dont count deleted subs as subs, as they are not shown by default
650
-		),__LINE__,__FILE__,
651
-			false,'GROUP BY info_id_parent','infolog') as $row)
648
+			"info_status != 'deleted'", // dont count deleted subs as subs, as they are not shown by default
649
+		), __LINE__, __FILE__,
650
+			false, 'GROUP BY info_id_parent', 'infolog') as $row)
652 651
 		{
653 652
 			$counts[$row['info_id_parent']] = (int)$row['info_anz_subs'];
654 653
 		}
@@ -688,102 +687,102 @@  discard block
 block discarded – undo
688 687
 			$action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : $query['action'];
689 688
 			if ($action)
690 689
 			{
691
-				$links = Link\Storage::get_links($action=='sp'?'infolog':$action,
692
-					is_array($query['action_id']) ? $query['action_id'] : explode(',',$query['action_id']),'infolog','',$query['col_filter']['info_status'] =='deleted');
690
+				$links = Link\Storage::get_links($action == 'sp' ? 'infolog' : $action,
691
+					is_array($query['action_id']) ? $query['action_id'] : explode(',', $query['action_id']), 'infolog', '', $query['col_filter']['info_status'] == 'deleted');
693 692
 
694 693
 				if (count($links))
695 694
 				{
696
-					$links = call_user_func_array('array_merge',$links);	// flatten the array
697
-					$link_extra = ($action == 'sp' ? 'OR' : 'AND')." main.info_id IN (".implode(',',$links).')';
695
+					$links = call_user_func_array('array_merge', $links); // flatten the array
696
+					$link_extra = ($action == 'sp' ? 'OR' : 'AND')." main.info_id IN (".implode(',', $links).')';
698 697
 				}
699 698
 			}
700 699
 		}
701
-		$sortbycf='';
702
-		if (!empty($query['order']) && (preg_match('/^[a-z_0-9, ]+$/i',$query['order']) || stripos($query['order'],'#')!==FALSE ) &&
703
-			(empty($query['sort']) || preg_match('/^(DESC|ASC)$/i',$query['sort'])))
700
+		$sortbycf = '';
701
+		if (!empty($query['order']) && (preg_match('/^[a-z_0-9, ]+$/i', $query['order']) || stripos($query['order'], '#') !== FALSE) &&
702
+			(empty($query['sort']) || preg_match('/^(DESC|ASC)$/i', $query['sort'])))
704 703
 		{
705 704
 			$order = array();
706
-			foreach(explode(',',$query['order']) as $val)
705
+			foreach (explode(',', $query['order']) as $val)
707 706
 			{
708 707
 				$val = trim($val);
709 708
 				if ($val[0] == '#')
710 709
 				{
711
-					$sortbycf = substr($val,1);
710
+					$sortbycf = substr($val, 1);
712 711
 					$val = "cfsortcrit IS NULL,cfsortcrit";
713 712
 				}
714 713
 				else
715 714
 				{
716 715
 					static $table_def = null;
717
-					if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog',$this->info_table);
718
-					if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
716
+					if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog', $this->info_table);
717
+					if (substr($val, 0, 5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
719 718
 					if ($val == 'info_des' && $this->db->capabilities['order_on_text'] !== true)
720 719
 					{
721 720
 						if (!$this->db->capabilities['order_on_text']) continue;
722 721
 
723
-						$val = sprintf($this->db->capabilities['order_on_text'],$val);
722
+						$val = sprintf($this->db->capabilities['order_on_text'], $val);
724 723
 					}
725 724
 				}
726 725
 				$order[] = $val;
727 726
 			}
728
-			$ordermethod = 'ORDER BY ' . implode(',',$order) . ' ' . $query['sort'];
727
+			$ordermethod = 'ORDER BY '.implode(',', $order).' '.$query['sort'];
729 728
 		}
730 729
 		else
731 730
 		{
732
-			$ordermethod = 'ORDER BY info_datemodified DESC';   // newest first
731
+			$ordermethod = 'ORDER BY info_datemodified DESC'; // newest first
733 732
 		}
734 733
 		$filtermethod = $this->aclFilter($query['filter']);
735 734
 		if (!$query['col_filter']['info_status'])  $filtermethod .= $this->statusFilter($query['filter']);
736 735
 		$filtermethod .= $this->dateFilter($query['filter']);
737
-		$cfcolfilter=0;
736
+		$cfcolfilter = 0;
738 737
 		if (is_array($query['col_filter']))
739 738
 		{
740
-			foreach($query['col_filter'] as $col => $data)
739
+			foreach ($query['col_filter'] as $col => $data)
741 740
 			{
742 741
 				if (is_int($col))
743 742
 				{
744 743
 					$filtermethod .= ' AND '.$data;
745 744
 					continue;
746 745
 				}
747
-				if ($col[0] != '#' && substr($col,0,5) != 'info_' && isset($table_def['fd']['info_'.$col])) $col = 'info_'.$col;
748
-				if ((string)$data !== '' && preg_match('/^[a-z_0-9]+$/i',$col))
746
+				if ($col[0] != '#' && substr($col, 0, 5) != 'info_' && isset($table_def['fd']['info_'.$col])) $col = 'info_'.$col;
747
+				if ((string)$data !== '' && preg_match('/^[a-z_0-9]+$/i', $col))
749 748
 				{
750 749
 					switch ($col)
751 750
 					{
752 751
 						case 'info_responsible':
753
-							$data = (int) $data;
752
+							$data = (int)$data;
754 753
 							if (!$data) continue;
755 754
 							$filtermethod .= ' AND ('.$this->responsible_filter($data)." OR info_responsible='0' AND ".
756
-								$this->db->expression($this->info_table,array(
757
-									'info_owner' => $data > 0 ? $data : $GLOBALS['egw']->accounts->members($data,true)
755
+								$this->db->expression($this->info_table, array(
756
+									'info_owner' => $data > 0 ? $data : $GLOBALS['egw']->accounts->members($data, true)
758 757
 								)).')';
759 758
 							break;
760 759
 
761 760
 						case 'info_id':	// info_id itself is ambigous
762
-							$filtermethod .= ' AND '.$this->db->expression($this->info_table,'main.',array('info_id' => $data));
761
+							$filtermethod .= ' AND '.$this->db->expression($this->info_table, 'main.', array('info_id' => $data));
763 762
 							break;
764 763
 
765 764
 						default:
766
-							$filtermethod .= ' AND '.$this->db->expression($this->info_table,array($col => $data));
765
+							$filtermethod .= ' AND '.$this->db->expression($this->info_table, array($col => $data));
767 766
 							break;
768 767
 					}
769 768
 				}
770
-				if ($col[0] == '#' &&  $query['custom_fields'] && $data)
769
+				if ($col[0] == '#' && $query['custom_fields'] && $data)
771 770
 				{
772 771
 					$filtermethod .= " AND main.info_id IN (SELECT DISTINCT info_id FROM $this->extra_table WHERE ";
773 772
 					$custom_fields = Api\Storage\Customfields::get('infolog');
774 773
 
775
-					if($custom_fields[substr($col,1)]['type'] == 'select' && $custom_fields[substr($col,1)]['rows'] > 1)
774
+					if ($custom_fields[substr($col, 1)]['type'] == 'select' && $custom_fields[substr($col, 1)]['rows'] > 1)
776 775
 					{
777 776
 						// Multi-select - any entry with the filter value selected matches
778 777
 						$filtermethod .= $this->db->expression($this->extra_table, array(
779
-							'info_extra_name' => substr($col,1),
780
-							$this->db->concat("','",'info_extra_value',"','").' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$data.',%'),
778
+							'info_extra_name' => substr($col, 1),
779
+							$this->db->concat("','", 'info_extra_value', "','").' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$data.',%'),
781 780
 						)).')';
782 781
 					}
783 782
 					else
784 783
 					{
785
-						$filtermethod .= $this->db->expression($this->extra_table,array(
786
-							'info_extra_name'  => substr($col,1),
784
+						$filtermethod .= $this->db->expression($this->extra_table, array(
785
+							'info_extra_name'  => substr($col, 1),
787 786
 							'info_extra_value' => $data,
788 787
 						)).')';
789 788
 					}
@@ -795,15 +794,15 @@  discard block
 block discarded – undo
795 794
 
796 795
 		if ((int)$query['cat_id'])
797 796
 		{
798
-			$categories = new Api\Categories('','infolog');
797
+			$categories = new Api\Categories('', 'infolog');
799 798
 			$cats = $categories->return_all_children((int)$query['cat_id']);
800
-			$filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']);
799
+			$filtermethod .= ' AND info_cat'.(count($cats) > 1 ? ' IN ('.implode(',', $cats).') ' : '='.(int)$query['cat_id']);
801 800
 		}
802 801
 		$join = $distinct = '';
803
-		if ($query['query']) $query['search'] = $query['query'];	// allow both names
802
+		if ($query['query']) $query['search'] = $query['query']; // allow both names
804 803
 		if ($query['search'])			  // we search in _from, _subject, _des and _extra_value for $query
805 804
 		{
806
-			$columns = array('info_from','info_addr','info_location','info_subject','info_extra_value');
805
+			$columns = array('info_from', 'info_addr', 'info_location', 'info_subject', 'info_extra_value');
807 806
 			// at the moment MaxDB 7.5 cant cast nor search text columns, it's suppost to change in 7.6
808 807
 			if ($this->db->capabilities['like_on_text']) $columns[] = 'info_des';
809 808
 
@@ -811,13 +810,13 @@  discard block
 block discarded – undo
811 810
 			$so_sql = new Api\Storage\Base('infolog', $this->info_table, $this->db);
812 811
 			$search = $so_sql->search2criteria($query['search'], $wildcard, $op, null, $columns);
813 812
 			$sql_query = 'AND ('.(is_numeric($query['search']) ? 'main.info_id='.(int)$query['search'].' OR ' : '').
814
-				implode($op, $search) .')';
813
+				implode($op, $search).')';
815 814
 
816
-			$join = ($cfcolfilter>0 ? '':'LEFT')." JOIN $this->extra_table ON main.info_id=$this->extra_table.info_id ";
815
+			$join = ($cfcolfilter > 0 ? '' : 'LEFT')." JOIN $this->extra_table ON main.info_id=$this->extra_table.info_id ";
817 816
 			// mssql and others cant use DISTICT if text columns (info_des) are involved
818 817
 			$distinct = $this->db->capabilities['distinct_on_text'] ? 'DISTINCT' : '';
819 818
 		}
820
-		$pid = 'AND ' . $this->db->expression($this->info_table,array('info_id_parent' => ($action == 'sp' ?$query['action_id'] : 0)));
819
+		$pid = 'AND '.$this->db->expression($this->info_table, array('info_id_parent' => ($action == 'sp' ? $query['action_id'] : 0)));
821 820
 
822 821
 		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['listNoSubs'] != '1' && $action != 'sp' ||
823 822
 			(string)$query['col_filter']['info_id_parent'] !== '' ||
@@ -838,14 +837,14 @@  discard block
 block discarded – undo
838 837
 			}
839 838
 			else
840 839
 			{
841
-				$query['total'] = $this->db->query($sql="SELECT $distinct main.info_id ".$sql_query,__LINE__,__FILE__)->NumRows();
840
+				$query['total'] = $this->db->query($sql = "SELECT $distinct main.info_id ".$sql_query, __LINE__, __FILE__)->NumRows();
842 841
 			}
843 842
 			$info_customfield = '';
844 843
 			if ($sortbycf != '')
845 844
 			{
846 845
 				$sort_col = "(SELECT DISTINCT info_extra_value FROM $this->extra_table sub2 WHERE sub2.info_id=main.info_id AND info_extra_name=".$this->db->quote($sortbycf).")";
847 846
 				if (!isset($custom_fields)) $custom_fields = Api\Storage\Customfields::get('infolog');
848
-				switch($custom_fields[$sortbycf]['type'])
847
+				switch ($custom_fields[$sortbycf]['type'])
849 848
 				{
850 849
 					case 'int':
851 850
 						$sort_col = $this->db->to_int($sort_col);
@@ -864,9 +863,9 @@  discard block
 block discarded – undo
864 863
 					$query['start'] = 0;
865 864
 				}
866 865
 				$cols = isset($query['cols']) ? $query['cols'] : 'main.*';
867
-				if (is_array($cols)) $cols = implode(',',$cols);
868
-				$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__,
869
-					(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
866
+				if (is_array($cols)) $cols = implode(',', $cols);
867
+				$rs = $this->db->query($sql = 'SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod, __LINE__, __FILE__,
868
+					(int)$query['start'], isset($query['start']) ? (int)$query['num_rows'] : -1, false, Api\Db::FETCH_ASSOC);
870 869
 				//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
871 870
 
872 871
 				if ($mysql_calc_rows)
@@ -881,9 +880,9 @@  discard block
 block discarded – undo
881 880
 			{
882 881
 				return $rs;
883 882
 			}
884
-			foreach($rs as $info)
883
+			foreach ($rs as $info)
885 884
 			{
886
-				$info['info_responsible'] = $info['info_responsible'] ? explode(',',$info['info_responsible']) : array();
885
+				$info['info_responsible'] = $info['info_responsible'] ? explode(',', $info['info_responsible']) : array();
887 886
 
888 887
 				$ids[$info['info_id']] = $info;
889 888
 			}
@@ -896,19 +895,19 @@  discard block
 block discarded – undo
896 895
 			}
897 896
 			// if no specific custom field is selected, show/query all custom fields
898 897
 			if ($ids && ($query['custom_fields'] || $query['csv_export'] ||
899
-				$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'],$index_load_cfs)))
898
+				$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'], $index_load_cfs)))
900 899
 			{
901 900
 				$where = array('info_id' => array_keys($ids));
902
-				if (!($query['csv_export'] || strchr(is_array($query['selectcols']) ? implode(',',$query['selectcols']):$query['selectcols'],'#') === false ||
903
-					$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'],$index_load_cfs)))
901
+				if (!($query['csv_export'] || strchr(is_array($query['selectcols']) ? implode(',', $query['selectcols']) : $query['selectcols'], '#') === false ||
902
+					$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'], $index_load_cfs)))
904 903
 				{
905 904
 					$where['info_extra_name'] = array();
906
-					foreach(is_array($query['selectcols']) ? $query['selectcols'] : explode(',',$query['selectcols']) as $col)
905
+					foreach (is_array($query['selectcols']) ? $query['selectcols'] : explode(',', $query['selectcols']) as $col)
907 906
 					{
908
-						if ($col[0] == '#') $where['info_extra_name'][] = substr($col,1);
907
+						if ($col[0] == '#') $where['info_extra_name'][] = substr($col, 1);
909 908
 					}
910 909
 				}
911
-				foreach($this->db->select($this->extra_table,'*',$where,__LINE__,__FILE__) as $row)
910
+				foreach ($this->db->select($this->extra_table, '*', $where, __LINE__, __FILE__) as $row)
912 911
 				{
913 912
 					$ids[$row['info_id']]['#'.$row['info_extra_name']] = $row['info_extra_value'];
914 913
 				}
@@ -933,27 +932,27 @@  discard block
 block discarded – undo
933 932
 	{
934 933
 		$users = array();
935 934
 
936
-		foreach($this->db->select($this->info_table,'DISTINCT info_owner',array(
937
-			str_replace(' AND ','',$this->statusFilter('open')),
938
-			'(ABS(info_startdate-'.time().')<'.(4*24*60*60).' OR '.	// start_day within 4 days
939
-			'ABS(info_enddate-'.time().')<'.(4*24*60*60).')',		// end_day within 4 days
940
-		),__LINE__,__FILE__) as $row)
935
+		foreach ($this->db->select($this->info_table, 'DISTINCT info_owner', array(
936
+			str_replace(' AND ', '', $this->statusFilter('open')),
937
+			'(ABS(info_startdate-'.time().')<'.(4 * 24 * 60 * 60).' OR '.// start_day within 4 days
938
+			'ABS(info_enddate-'.time().')<'.(4 * 24 * 60 * 60).')', // end_day within 4 days
939
+		), __LINE__, __FILE__) as $row)
941 940
 		{
942 941
 			$users[] = $row['info_responsible'];
943 942
 		}
944
-		foreach($this->db->select($this->info_table,'DISTINCT info_responsible',$this->statusFilter('open',false),__LINE__,__FILE__) as $row)
943
+		foreach ($this->db->select($this->info_table, 'DISTINCT info_responsible', $this->statusFilter('open', false), __LINE__, __FILE__) as $row)
945 944
 		{
946
-			foreach(explode(',', $row['info_responsible']) as $responsible)
945
+			foreach (explode(',', $row['info_responsible']) as $responsible)
947 946
 			{
948 947
 				if ($GLOBALS['egw']->accounts->get_type($responsible) == 'g')
949 948
 				{
950
-					$responsible = $GLOBALS['egw']->accounts->members($responsible,true);
949
+					$responsible = $GLOBALS['egw']->accounts->members($responsible, true);
951 950
 				}
952 951
 				if ($responsible)
953 952
 				{
954
-					foreach(is_array($responsible) ? $responsible : array($responsible) as $user)
953
+					foreach (is_array($responsible) ? $responsible : array($responsible) as $user)
955 954
 					{
956
-						if ($user && !in_array($user,$users)) $users[] = $user;
955
+						if ($user && !in_array($user, $users)) $users[] = $user;
957 956
 					}
958 957
 				}
959 958
 			}
Please login to merge, or discard this patch.
Braces   +118 added lines, -29 removed lines patch added patch discarded remove patch
@@ -89,10 +89,16 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	function is_responsible($info,$user=null)
91 91
 	{
92
-		if (!$user) $user = $this->user;
92
+		if (!$user)
93
+		{
94
+			$user = $this->user;
95
+		}
93 96
 
94 97
 		static $um_cache = array();
95
-		if ($user == $this->user) $user_and_memberships =& $um_cache[$user];
98
+		if ($user == $this->user)
99
+		{
100
+			$user_and_memberships =& $um_cache[$user];
101
+		}
96 102
 		if (!isset($user_and_memberships))
97 103
 		{
98 104
 			$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user,true);
@@ -113,20 +119,32 @@  discard block
 block discarded – undo
113 119
 	 */
114 120
 	function check_access( $info,$required_rights,$implicit_edit=false,array $grants=null,$user=null )
115 121
 	{
116
-		if (is_null($grants)) $grants = $this->grants;
117
-		if (!$user) $user = $this->user;
122
+		if (is_null($grants))
123
+		{
124
+			$grants = $this->grants;
125
+		}
126
+		if (!$user)
127
+		{
128
+			$user = $this->user;
129
+		}
118 130
 
119 131
 		// if info-array, but no owner given, force reading of info from db
120
-		if (is_array($info) && !$info['info_owner']) $info = $info['info_id'];
132
+		if (is_array($info) && !$info['info_owner'])
133
+		{
134
+			$info = $info['info_id'];
135
+		}
121 136
 
122 137
 		if (is_array($info))
123 138
 		{
124 139
 
125 140
 		}
126
-		elseif ((int) $info != $this->data['info_id'])      	// already loaded?
141
+		elseif ((int) $info != $this->data['info_id'])
142
+		{
143
+			// already loaded?
127 144
 		{
128 145
 			// dont change our own internal data,
129 146
 			$backup_data = $this->data;
147
+		}
130 148
 			$info = $this->read(array('info_id'=>$info));
131 149
 			$this->data = $backup_data;
132 150
 		}
@@ -160,7 +178,10 @@  discard block
 block discarded – undo
160 178
 	 */
161 179
 	function responsible_filter($users)
162 180
 	{
163
-		if (!$users) return '0';
181
+		if (!$users)
182
+		{
183
+			return '0';
184
+		}
164 185
 
165 186
 		$responsible = array();
166 187
 		foreach((array)$users as $user)
@@ -250,11 +271,14 @@  discard block
 block discarded – undo
250 271
 						" OR info_status = 'offer' AND $public_access" : '').")".
251 272
 				                 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
252 273
 			}
253
-			elseif ($filter != 'my' && $filter != 'responsible')	// none --> all entrys user has rights to see
274
+			elseif ($filter != 'my' && $filter != 'responsible')
275
+			{
276
+				// none --> all entrys user has rights to see
254 277
 			{
255 278
 				if ($has_private_access)
256 279
 				{
257 280
 					$filtermethod .= " OR $has_private_access";
281
+			}
258 282
 				}
259 283
 				if (count($public_user_list))
260 284
 				{
@@ -498,7 +522,10 @@  discard block
 block discarded – undo
498 522
 		{
499 523
 			$new_responsible = explode(',',$row['info_responsible']);
500 524
 			unset($new_responsible[array_search($args['account_id'],$new_responsible)]);
501
-			if ((int)$args['new_owner']) $new_responsible[] = (int)$args['new_owner'];
525
+			if ((int)$args['new_owner'])
526
+			{
527
+				$new_responsible[] = (int)$args['new_owner'];
528
+			}
502 529
 			$this->db->update($this->info_table,array(
503 530
 				'info_responsible' => implode(',',$new_responsible),
504 531
 			),array('info_id' => $row['info_id']),__LINE__,__FILE__,'infolog');
@@ -527,10 +554,13 @@  discard block
 block discarded – undo
527 554
 		//echo "soinfolog::write(,$check_modified) values="; _debug_array($values);
528 555
 		$info_id = (int) $values['info_id'];
529 556
 
530
-		if (array_key_exists('info_responsible',$values))	// isset($values['info_responsible']) returns false for NULL!
557
+		if (array_key_exists('info_responsible',$values))
558
+		{
559
+			// isset($values['info_responsible']) returns false for NULL!
531 560
 		{
532 561
 			$values['info_responsible'] = $values['info_responsible'] ? implode(',',$values['info_responsible']) : '0';
533 562
 		}
563
+		}
534 564
 		$table_def = $this->db->get_table_definitions('infolog',$this->info_table);
535 565
 		$to_write = array();
536 566
 		foreach($values as $key => $val)
@@ -541,12 +571,18 @@  discard block
 block discarded – undo
541 571
 			}
542 572
 		}
543 573
 		// writing no price as SQL NULL (required by postgres)
544
-		if ($to_write['info_price'] === '') $to_write['info_price'] = NULL;
574
+		if ($to_write['info_price'] === '')
575
+		{
576
+			$to_write['info_price'] = NULL;
577
+		}
545 578
 
546 579
 		if (($this->data['info_id'] = $info_id))
547 580
 		{
548 581
 			$where = array('info_id' => $info_id);
549
-			if ($check_modified) $where['info_datemodified'] = $check_modified;
582
+			if ($check_modified)
583
+			{
584
+				$where['info_datemodified'] = $check_modified;
585
+			}
550 586
 			if (!$this->db->update($this->info_table,$to_write,$where,__LINE__,__FILE__))
551 587
 			{
552 588
 				//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning false");
@@ -560,7 +596,11 @@  discard block
 block discarded – undo
560 596
 		}
561 597
 		else
562 598
 		{
563
-			if (!isset($to_write['info_id_parent'])) $to_write['info_id_parent'] = 0;	// must not be null
599
+			if (!isset($to_write['info_id_parent']))
600
+			{
601
+				$to_write['info_id_parent'] = 0;
602
+			}
603
+			// must not be null
564 604
 
565 605
 			$this->db->insert($this->info_table,$to_write,false,__LINE__,__FILE__);
566 606
 			$info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table,'info_id');
@@ -589,7 +629,10 @@  discard block
 block discarded – undo
589 629
 		if ($purge_cfs)
590 630
 		{
591 631
 			$where = array('info_id' => $info_id);
592
-			if ($purge_cfs == 'ical') $where[] = "info_extra_name LIKE '#%'";
632
+			if ($purge_cfs == 'ical')
633
+			{
634
+				$where[] = "info_extra_name LIKE '#%'";
635
+			}
593 636
 			$this->db->delete($this->extra_table,$where,__LINE__,__FILE__);
594 637
 		}
595 638
 		$to_delete = array();
@@ -641,7 +684,10 @@  discard block
 block discarded – undo
641 684
 	{
642 685
 		if (!is_array($info_id) || !$info_id)
643 686
 		{
644
-			if ((int)$info_id <= 0) return 0;
687
+			if ((int)$info_id <= 0)
688
+			{
689
+				return 0;
690
+			}
645 691
 		}
646 692
 		$counts = array();
647 693
 		foreach($this->db->select($this->info_table,'info_id_parent,COUNT(*) AS info_anz_subs',array(
@@ -714,11 +760,20 @@  discard block
 block discarded – undo
714 760
 				else
715 761
 				{
716 762
 					static $table_def = null;
717
-					if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog',$this->info_table);
718
-					if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
763
+					if (is_null($table_def))
764
+					{
765
+						$table_def = $this->db->get_table_definitions('infolog',$this->info_table);
766
+					}
767
+					if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val]))
768
+					{
769
+						$val = 'info_'.$val;
770
+					}
719 771
 					if ($val == 'info_des' && $this->db->capabilities['order_on_text'] !== true)
720 772
 					{
721
-						if (!$this->db->capabilities['order_on_text']) continue;
773
+						if (!$this->db->capabilities['order_on_text'])
774
+						{
775
+							continue;
776
+						}
722 777
 
723 778
 						$val = sprintf($this->db->capabilities['order_on_text'],$val);
724 779
 					}
@@ -732,7 +787,10 @@  discard block
 block discarded – undo
732 787
 			$ordermethod = 'ORDER BY info_datemodified DESC';   // newest first
733 788
 		}
734 789
 		$filtermethod = $this->aclFilter($query['filter']);
735
-		if (!$query['col_filter']['info_status'])  $filtermethod .= $this->statusFilter($query['filter']);
790
+		if (!$query['col_filter']['info_status'])
791
+		{
792
+			$filtermethod .= $this->statusFilter($query['filter']);
793
+		}
736 794
 		$filtermethod .= $this->dateFilter($query['filter']);
737 795
 		$cfcolfilter=0;
738 796
 		if (is_array($query['col_filter']))
@@ -744,14 +802,20 @@  discard block
 block discarded – undo
744 802
 					$filtermethod .= ' AND '.$data;
745 803
 					continue;
746 804
 				}
747
-				if ($col[0] != '#' && substr($col,0,5) != 'info_' && isset($table_def['fd']['info_'.$col])) $col = 'info_'.$col;
805
+				if ($col[0] != '#' && substr($col,0,5) != 'info_' && isset($table_def['fd']['info_'.$col]))
806
+				{
807
+					$col = 'info_'.$col;
808
+				}
748 809
 				if ((string)$data !== '' && preg_match('/^[a-z_0-9]+$/i',$col))
749 810
 				{
750 811
 					switch ($col)
751 812
 					{
752 813
 						case 'info_responsible':
753 814
 							$data = (int) $data;
754
-							if (!$data) continue;
815
+							if (!$data)
816
+							{
817
+								continue;
818
+							}
755 819
 							$filtermethod .= ' AND ('.$this->responsible_filter($data)." OR info_responsible='0' AND ".
756 820
 								$this->db->expression($this->info_table,array(
757 821
 									'info_owner' => $data > 0 ? $data : $GLOBALS['egw']->accounts->members($data,true)
@@ -800,12 +864,22 @@  discard block
 block discarded – undo
800 864
 			$filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']);
801 865
 		}
802 866
 		$join = $distinct = '';
803
-		if ($query['query']) $query['search'] = $query['query'];	// allow both names
804
-		if ($query['search'])			  // we search in _from, _subject, _des and _extra_value for $query
867
+		if ($query['query'])
868
+		{
869
+			$query['search'] = $query['query'];
870
+		}
871
+		// allow both names
872
+		if ($query['search'])
873
+		{
874
+			// we search in _from, _subject, _des and _extra_value for $query
805 875
 		{
806 876
 			$columns = array('info_from','info_addr','info_location','info_subject','info_extra_value');
877
+		}
807 878
 			// at the moment MaxDB 7.5 cant cast nor search text columns, it's suppost to change in 7.6
808
-			if ($this->db->capabilities['like_on_text']) $columns[] = 'info_des';
879
+			if ($this->db->capabilities['like_on_text'])
880
+			{
881
+				$columns[] = 'info_des';
882
+			}
809 883
 
810 884
 			$wildcard = $op = null;
811 885
 			$so_sql = new Api\Storage\Base('infolog', $this->info_table, $this->db);
@@ -844,7 +918,10 @@  discard block
 block discarded – undo
844 918
 			if ($sortbycf != '')
845 919
 			{
846 920
 				$sort_col = "(SELECT DISTINCT info_extra_value FROM $this->extra_table sub2 WHERE sub2.info_id=main.info_id AND info_extra_name=".$this->db->quote($sortbycf).")";
847
-				if (!isset($custom_fields)) $custom_fields = Api\Storage\Customfields::get('infolog');
921
+				if (!isset($custom_fields))
922
+				{
923
+					$custom_fields = Api\Storage\Customfields::get('infolog');
924
+				}
848 925
 				switch($custom_fields[$sortbycf]['type'])
849 926
 				{
850 927
 					case 'int':
@@ -864,7 +941,10 @@  discard block
 block discarded – undo
864 941
 					$query['start'] = 0;
865 942
 				}
866 943
 				$cols = isset($query['cols']) ? $query['cols'] : 'main.*';
867
-				if (is_array($cols)) $cols = implode(',',$cols);
944
+				if (is_array($cols))
945
+				{
946
+					$cols = implode(',',$cols);
947
+				}
868 948
 				$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__,
869 949
 					(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
870 950
 				//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
@@ -892,7 +972,10 @@  discard block
 block discarded – undo
892 972
 			{
893 973
 				$config_data = Api\Config::read('infolog');
894 974
 				$index_load_cfs = $config_data['index_load_cfs'];
895
-				if (!is_array($index_load_cfs)) $index_load_cfs = explode(',', $index_load_cfs);
975
+				if (!is_array($index_load_cfs))
976
+				{
977
+					$index_load_cfs = explode(',', $index_load_cfs);
978
+				}
896 979
 			}
897 980
 			// if no specific custom field is selected, show/query all custom fields
898 981
 			if ($ids && ($query['custom_fields'] || $query['csv_export'] ||
@@ -905,7 +988,10 @@  discard block
 block discarded – undo
905 988
 					$where['info_extra_name'] = array();
906 989
 					foreach(is_array($query['selectcols']) ? $query['selectcols'] : explode(',',$query['selectcols']) as $col)
907 990
 					{
908
-						if ($col[0] == '#') $where['info_extra_name'][] = substr($col,1);
991
+						if ($col[0] == '#')
992
+						{
993
+							$where['info_extra_name'][] = substr($col,1);
994
+						}
909 995
 					}
910 996
 				}
911 997
 				foreach($this->db->select($this->extra_table,'*',$where,__LINE__,__FILE__) as $row)
@@ -953,7 +1039,10 @@  discard block
 block discarded – undo
953 1039
 				{
954 1040
 					foreach(is_array($responsible) ? $responsible : array($responsible) as $user)
955 1041
 					{
956
-						if ($user && !in_array($user,$users)) $users[] = $user;
1042
+						if ($user && !in_array($user,$users))
1043
+						{
1044
+							$users[] = $user;
1045
+						}
957 1046
 					}
958 1047
 				}
959 1048
 			}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 		$ids = array( );
829 829
 		if ($action == '' || $action == 'sp' || count($links))
830 830
 		{
831
-			$sql_query = "FROM $this->info_table main $join WHERE ($filtermethod $pid $sql_query) $link_extra";
831
+			$sql_query = "from $this->info_table main $join WHERE ($filtermethod $pid $sql_query) $link_extra";
832 832
 			#error_log("infolog.so.search:\n" . print_r($sql_query, true));
833 833
 
834 834
 			if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 			}
839 839
 			else
840 840
 			{
841
-				$query['total'] = $this->db->query($sql="SELECT $distinct main.info_id ".$sql_query,__LINE__,__FILE__)->NumRows();
841
+				$query['total'] = $this->db->query($sql="select $distinct main.info_id ".$sql_query,__LINE__,__FILE__)->NumRows();
842 842
 			}
843 843
 			$info_customfield = '';
844 844
 			if ($sortbycf != '')
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   +39 added lines, -39 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,31 +215,31 @@  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) && !empty($data['info_contact']) && is_array($data['link_to']['to_id']))
236
+			if ($name == 'info_from' && empty($value) && !empty($data['info_contact']) && is_array($data['link_to']['to_id']))
237 237
 			{
238 238
 				$lkeys = array_keys($data['link_to']['to_id']);
239
-				if (in_array($data['info_contact'],$lkeys))
239
+				if (in_array($data['info_contact'], $lkeys))
240 240
 				{
241
-					list($app,$id) = explode(':',$data['info_contact']);
242
-					if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
241
+					list($app, $id) = explode(':', $data['info_contact']);
242
+					if (!empty($app) && !empty($id)) $value = Link::title($app, $id);
243 243
 				}
244 244
 			}
245 245
 			$details[$name] = array(
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @param boolean $skip_notification = false do NOT send any notification
272 272
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
273 273
 	 */
274
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
274
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
275 275
 	{
276 276
 		//error_log(__METHOD__.__LINE__.' notify?'.($skip_notification?'no':'yes').function_backtrace());
277 277
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
 
281 281
 		if ($old && $this->field2history)
282 282
 		{
283
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
283
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
284 284
 		}
285 285
 
286 286
 		// Don't notify if the only change was to the modified date
287
-		if(is_null($changed_fields))
287
+		if (is_null($changed_fields))
288 288
 		{
289 289
 			$changed_fields = $this->changed_fields($data, $old);
290 290
 			$changes = count($changed_fields); // we need that since TRUE evaluates to 1
291 291
 		}
292 292
 		//error_log(__METHOD__.__LINE__.array2string($changed_fields));
293
-		if(is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
293
+		if (is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
294 294
 		{
295 295
 			return count($changes);
296 296
 		}
297 297
 
298 298
 		// do not run do_notifications if we have no changes
299
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
299
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
300 300
 		{
301 301
 			$changes = false;
302 302
 		}
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 	 * @param array $old = null old/last state of the entry or null for a new entry
315 315
 	 * @return mixed
316 316
 	 */
317
-	function get_config($name,$data,$old=null)
317
+	function get_config($name, $data, $old = null)
318 318
 	{
319
-		unset($old);	// not used, but required function signature
320
-		switch($name)
319
+		unset($old); // not used, but required function signature
320
+		switch ($name)
321 321
 		{
322 322
 			case 'copy':	// include the info_cc addresses
323
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
323
+				if ($data['info_access'] == 'private') return array(); // no copies for private entries
324 324
 				if ($data['info_cc'])
325 325
 				{
326
-					$config = preg_split('/, ?/',$data['info_cc']);
326
+					$config = preg_split('/, ?/', $data['info_cc']);
327 327
 				}
328 328
 				else
329 329
 				{
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				break;
333 333
 			case self::CUSTOM_NOTIFICATION:
334 334
 				$info_config = Api\Config::read('infolog');
335
-				if(!$info_config[self::CUSTOM_NOTIFICATION])
335
+				if (!$info_config[self::CUSTOM_NOTIFICATION])
336 336
 				{
337 337
 					return '';
338 338
 				}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
342 342
 
343 343
 				// Disabled
344
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
344
+				if (!$type_config['use_custom'] && !$global['use_custom']) return '';
345 345
 
346 346
 				// Type or globabl
347 347
 				$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   +22 added lines, -5 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
 		{
@@ -239,14 +243,20 @@  discard block
 block discarded – undo
239 243
 				if (in_array($data['info_contact'],$lkeys))
240 244
 				{
241 245
 					list($app,$id) = explode(':',$data['info_contact']);
242
-					if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
246
+					if (!empty($app)&&!empty($id))
247
+					{
248
+						$value = Link::title($app,$id);
249
+					}
243 250
 				}
244 251
 			}
245 252
 			$details[$name] = array(
246 253
 				'label' => lang($this->field2label[$name]),
247 254
 				'value' => $value,
248 255
 			);
249
-			if ($name == 'info_subject') $details[$name]['type'] = 'summary';
256
+			if ($name == 'info_subject')
257
+			{
258
+				$details[$name]['type'] = 'summary';
259
+			}
250 260
 		}
251 261
 		$details['info_des'] = array(
252 262
 			'value' => $data['info_des'],
@@ -320,7 +330,11 @@  discard block
 block discarded – undo
320 330
 		switch($name)
321 331
 		{
322 332
 			case 'copy':	// include the info_cc addresses
323
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
333
+				if ($data['info_access'] == 'private')
334
+				{
335
+					return array();
336
+				}
337
+				// no copies for private entries
324 338
 				if ($data['info_cc'])
325 339
 				{
326 340
 					$config = preg_split('/, ?/',$data['info_cc']);
@@ -341,7 +355,10 @@  discard block
 block discarded – undo
341 355
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
342 356
 
343 357
 				// Disabled
344
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
358
+				if(!$type_config['use_custom'] && !$global['use_custom'])
359
+				{
360
+					return '';
361
+				}
345 362
 
346 363
 				// Type or globabl
347 364
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
infolog/inc/class.infolog_ui.inc.php 4 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -295,6 +295,8 @@  discard block
 block discarded – undo
295 295
 	 * @param array &$query
296 296
 	 * @param array &$rows
297 297
 	 * @param array &$readonlys
298
+	 * @param type|null $rows
299
+	 * @param type|null $readonlys
298 300
 	 * @return int
299 301
 	 */
300 302
 	function get_rows(&$query,&$rows,&$readonlys)
@@ -574,7 +576,6 @@  discard block
 block discarded – undo
574 576
 	 * Hook for timesheet to set some extra data and links
575 577
 	 *
576 578
 	 * @param array $data
577
-	 * @param int $data[id] info_id
578 579
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
579 580
 	 */
580 581
 	function timesheet_set($data)
@@ -600,7 +601,6 @@  discard block
 block discarded – undo
600 601
 	 * Hook for calendar to set some extra data and links
601 602
 	 *
602 603
 	 * @param array $data event-array preset by calendar plus
603
-	 * @param int $data[entry_id] info_id
604 604
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
605 605
 	 */
606 606
 	function calendar_set($data)
@@ -688,11 +688,11 @@  discard block
 block discarded – undo
688 688
 	/**
689 689
 	 * Shows the infolog list
690 690
 	 *
691
-	 * @param array/string $values etemplate content or 'reset_action_view' if called by index.php to reset an action-view
691
+	 * @param integer $values etemplate content or 'reset_action_view' if called by index.php to reset an action-view
692 692
 	 * @param string $action if set only entries liked to that $action:$action_id are shown
693 693
 	 * @param string $action_id if set only entries liked to that $action:$action_id are shown
694
-	 * @param mixed $called_as is how we got called, for a hook eg. the call-params of that page containing the hook
695
-	 * @param boolean $e$extra_app_header * @param boolean $return_html=false
694
+	 * @param integer $called_as is how we got called, for a hook eg. the call-params of that page containing the hook
695
+	 * @param boolean $extra_app_header * @param boolean $return_html
696 696
 	 * @param string $own_referer='' this is our own referer
697 697
 	 * @param string $action_title='' app_header for the action, if '' we try the link-title
698 698
 	 */
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 	 * @param array $query get_rows parameter
1289 1289
 	 * @param string &$msg on return user feedback
1290 1290
 	 * @param boolean $skip_notifications true to NOT notify users about changes
1291
-	 * @return boolean true if all actions succeded, false otherwise
1291
+	 * @return boolean|null true if all actions succeded, false otherwise
1292 1292
 	 */
1293 1293
 	function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg,
1294 1294
 		array $query, &$msg, $skip_notifications = false)
@@ -1526,9 +1526,9 @@  discard block
 block discarded – undo
1526 1526
 	/**
1527 1527
 	 * Closes an infolog
1528 1528
 	 *
1529
-	 * @param int|array $values=0 info_id (default _GET[info_id])
1529
+	 * @param int|array $values info_id (default _GET[info_id])
1530 1530
 	 * @param string $_referer=''
1531
-	 * @param boolean $closesingle=false
1531
+	 * @param boolean $closesingle
1532 1532
 	 */
1533 1533
 	function close($values=0,$_referer='',$closesingle=false,$skip_notification = false)
1534 1534
 	{
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 	/**
1577 1577
 	 * Deletes an InfoLog entry
1578 1578
 	 *
1579
-	 * @param array|int $values info_id (default _GET[info_id])
1579
+	 * @param integer $values info_id (default _GET[info_id])
1580 1580
 	 * @param string $_referer
1581 1581
 	 * @param string $called_by
1582 1582
 	 * @param boolean $skip_notification Do not send notification of deletion
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@
 block discarded – undo
225 225
 
226 226
 				if ($show_links != 'none' && $show_links != 'no_describtion' &&
227 227
 					$link['link_id'] != $info['info_link_id'] &&
228
-				    ($link['app'] != $action || $link['id'] != $action_id) &&
228
+					($link['app'] != $action || $link['id'] != $action_id) &&
229 229
 					($show_links == 'all' || ($show_links == 'links') === ($link['app'] != Link::VFS_APPNAME)))
230 230
 				{
231 231
 					$info['filelinks'][] = $link;
Please login to merge, or discard this patch.
Spacing   +351 added lines, -355 removed lines patch added patch discarded remove patch
@@ -55,32 +55,32 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @var string
57 57
 	 */
58
-	var $duration_format = ',';	// comma is necessary!
58
+	var $duration_format = ','; // comma is necessary!
59 59
 
60 60
 	var $icons = array(
61 61
 		'type' => array(
62
-			'task'      => 'task.gif',      'task_alt'      => 'Task',
63
-			'phone'     => 'phone.gif',     'phone_alt'     => 'Phonecall',
64
-			'note'      => 'note.gif',      'note_alt'      => 'Note',
65
-			'confirm'   => 'confirm.gif',   'confirm_alt'   => 'Confirmation',
66
-			'reject'    => 'reject.gif',    'reject_alt'    => 'Reject',
67
-			'email'     => 'email.gif',     'email_alt'     => 'Email' ),
62
+			'task'      => 'task.gif', 'task_alt'      => 'Task',
63
+			'phone'     => 'phone.gif', 'phone_alt'     => 'Phonecall',
64
+			'note'      => 'note.gif', 'note_alt'      => 'Note',
65
+			'confirm'   => 'confirm.gif', 'confirm_alt'   => 'Confirmation',
66
+			'reject'    => 'reject.gif', 'reject_alt'    => 'Reject',
67
+			'email'     => 'email.gif', 'email_alt'     => 'Email' ),
68 68
 		'action' => array(
69
-			'new'       => 'new.gif',       'new_alt'       => 'Add Sub',
70
-			'view'      => 'view.gif',      'view_alt'      => 'View Subs',
71
-			'parent'    => 'parent.gif',    'parent_alt'    => 'View other Subs',
72
-			'edit'      => 'edit.gif',      'edit_alt'      => 'Edit',
73
-			'addfile'   => 'addfile.gif',   'addfile_alt'   => 'Add a file',
74
-			'delete'    => 'delete.gif',    'delete_alt'    => 'Delete',
75
-			'close'     => 'done.gif',      'close_alt'     => 'Close' ,
76
-			'close_all' => 'done_all.gif',  'close_all_alt' => 'Close' ),
69
+			'new'       => 'new.gif', 'new_alt'       => 'Add Sub',
70
+			'view'      => 'view.gif', 'view_alt'      => 'View Subs',
71
+			'parent'    => 'parent.gif', 'parent_alt'    => 'View other Subs',
72
+			'edit'      => 'edit.gif', 'edit_alt'      => 'Edit',
73
+			'addfile'   => 'addfile.gif', 'addfile_alt'   => 'Add a file',
74
+			'delete'    => 'delete.gif', 'delete_alt'    => 'Delete',
75
+			'close'     => 'done.gif', 'close_alt'     => 'Close',
76
+			'close_all' => 'done_all.gif', 'close_all_alt' => 'Close' ),
77 77
 		'status' => array(
78
-			'billed'    => 'billed.gif',    'billed_alt'    => 'billed',
79
-			'done'      => 'done.gif',      'done_alt'      => 'done',
78
+			'billed'    => 'billed.gif', 'billed_alt'    => 'billed',
79
+			'done'      => 'done.gif', 'done_alt'      => 'done',
80 80
 			'will-call' => 'will-call.gif', 'will-call_alt' => 'will-call',
81
-			'call'      => 'call.gif',      'call_alt'      => 'call',
82
-			'ongoing'   => 'ongoing.gif',   'ongoing_alt'   => 'ongoing',
83
-			'offer'     => 'offer.gif',     'offer_alt'     => 'offer' )
81
+			'call'      => 'call.gif', 'call_alt'      => 'call',
82
+			'ongoing'   => 'ongoing.gif', 'ongoing_alt'   => 'ongoing',
83
+			'offer'     => 'offer.gif', 'offer_alt'     => 'offer' )
84 84
 	);
85 85
 	var $filters;
86 86
 	var $messages = array(
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog');
101 101
 
102 102
 		// Make sure Global category is infolog - on first load, it may not be
103
-		if($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
103
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
104 104
 		{
105 105
 			$GLOBALS['egw']->categories = new Api\Categories();
106 106
 		}
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
113 113
 
114
-		$this->prefs =& $GLOBALS['egw_info']['user']['preferences']['infolog'];
114
+		$this->prefs = & $GLOBALS['egw_info']['user']['preferences']['infolog'];
115 115
 
116 116
 		// read the duration format from project-manager
117 117
 		if ($GLOBALS['egw_info']['apps']['projectmanager'])
118 118
 		{
119 119
 			$pm_config = Api\Config::read('projectmanager');
120
-			$this->duration_format = str_replace(',','',implode('', (array)$pm_config['duration_units']));
120
+			$this->duration_format = str_replace(',', '', implode('', (array)$pm_config['duration_units']));
121 121
 			//error_log(__METHOD__."() ".__LINE__." duration_format=$this->duration_format, duration_unit=".array2string($pm_config['duration_units']));
122 122
 			$this->hours_per_workday = $pm_config['hours_per_workday'];
123 123
 			unset($pm_config);
124 124
 		}
125
-		$this->filters =& $this->bo->filters;
125
+		$this->filters = & $this->bo->filters;
126 126
 		/* these are just for testing of the notifications
127 127
 		for($i = -1; $i <= 3; ++$i)
128 128
 		{
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 			$this->filters['responsible-open-date'.date('Y-m-d',time()+$i*24*60*60)] = "responsible starting in $i day(s)";
142 142
 		}
143 143
 		*/
144
-		$GLOBALS['infolog_ui'] =& $this;	// make ourself availible for ExecMethod of get_rows function
144
+		$GLOBALS['infolog_ui'] = & $this; // make ourself availible for ExecMethod of get_rows function
145 145
 	}
146 146
 
147 147
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param int $details
156 156
 	 * @return array
157 157
 	 */
158
-	function get_info($info,&$readonlys,$action='',$action_id='',$show_links=false,$details = 1)
158
+	function get_info($info, &$readonlys, $action = '', $action_id = '', $show_links = false, $details = 1)
159 159
 	{
160 160
 		if (!is_array($info))
161 161
 		{
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
 		$done = $info['info_status'] == 'done' || $info['info_status'] == 'billed' || $info['info_status'] == 'cancelled'; //cancelled is regarded as a completed status as well in bo
166 166
 		// regard an infolog as done/billed/cancelled if its percentage is 100% when there is to status like the above for that type
167 167
 		if (!$done && !isset($this->bo->status[$info['info_type']]['done']) && !isset($this->bo->status[$info['info_type']]['billed']) &&
168
-			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent']==100) $done = true ;
169
-		$info['sub_class'] = $this->bo->enums['priority'][$info['info_priority']] . ($done ? '_done' : '');
168
+			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent'] == 100) $done = true;
169
+		$info['sub_class'] = $this->bo->enums['priority'][$info['info_priority']].($done ? '_done' : '');
170 170
 		if (!$done && $info['info_enddate'] < $this->bo->user_time_now)
171 171
 		{
172 172
 			$info['end_class'] = 'infolog_overdue';
173 173
 		}
174 174
 		if (!isset($info['info_anz_subs'])) $info['info_anz_subs'] = $this->bo->anzSubs($id);
175
-		$this->bo->link_id2from($info,$action,$action_id);	// unset from for $action:$action_id
176
-		$info['info_percent'] = (int) $info['info_percent'].'%';
177
-		$editrights = $this->bo->check_access($info,Acl::EDIT);
175
+		$this->bo->link_id2from($info, $action, $action_id); // unset from for $action:$action_id
176
+		$info['info_percent'] = (int)$info['info_percent'].'%';
177
+		$editrights = $this->bo->check_access($info, Acl::EDIT);
178 178
 		$isresposible = $this->bo->is_responsible($info);
179 179
 		if ((!($editrights || // edit rights or more then standard responsible rights
180
-			$isresposible && array_diff($this->bo->responsible_edit,array('info_status','info_percent','info_datecompleted')))))
180
+			$isresposible && array_diff($this->bo->responsible_edit, array('info_status', 'info_percent', 'info_datecompleted')))))
181 181
 		{
182 182
 			$info['class'] .= 'rowNoEdit ';
183 183
 		}
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 		{
197 197
 			$info['class'] .= 'rowNoCloseAll ';
198 198
 		}
199
-		if (!$this->bo->check_access($info,Acl::DELETE))
199
+		if (!$this->bo->check_access($info, Acl::DELETE))
200 200
 		{
201 201
 			$info['class'] .= 'rowNoDelete ';
202 202
 		}
203
-		if (!$this->bo->check_access($info,Acl::ADD))
203
+		if (!$this->bo->check_access($info, Acl::ADD))
204 204
 		{
205 205
 			$info['class'] .= 'rowNoSubs ';
206 206
 		}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		if (!$show_links) $show_links = $this->prefs['show_links'];
213 213
 		if (($show_links != 'none' && $show_links != 'no_describtion' ||
214 214
 			 $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
215
-			(isset($info['links']) || ($info['links'] = Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true))))
215
+			(isset($info['links']) || ($info['links'] = Link::get_links('infolog', $info['info_id'], '', 'link_lastmod DESC', true, true))))
216 216
 		{
217 217
 			$timesheets = array();
218 218
 			foreach ($info['links'] as $link)
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 				$link_mod = Api\DateTime::server2user($link['lastmod']);
222 222
 				if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod;
223 223
 
224
-				if ($link['deleted']) continue;	// skip deleted links, but incl. them in row_mod!
224
+				if ($link['deleted']) continue; // skip deleted links, but incl. them in row_mod!
225 225
 
226 226
 				if ($show_links != 'none' && $show_links != 'no_describtion' &&
227 227
 					$link['link_id'] != $info['info_link_id'] &&
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 			}
239 239
 			if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets)
240 240
 			{
241
-				$sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets);
241
+				$sum = ExecMethod('timesheet.timesheet_bo.sum', $timesheets);
242 242
 				$info['info_sum_timesheets'] = $sum['duration'];
243 243
 				// incl. max timesheet modification in row_mod
244 244
 				if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified'];
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			}
257 257
 			$readonlys["edit_percent[$id]"] = true;
258 258
 		}
259
-		elseif($readonlys["edit_percent[$id]"])	// show percent, but button is switched off
259
+		elseif ($readonlys["edit_percent[$id]"])	// show percent, but button is switched off
260 260
 		{
261 261
 			$info['info_percent2'] = $info['info_percent'];
262 262
 		}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	protected static function filter(array $query)
278 278
 	{
279 279
 		$filter = $query['filter'] ? 'filter' : ($query['cat_id'] ? 'cat_id' : null);
280
-		foreach((array)$query['col_filter'] as $name => $value)
280
+		foreach ((array)$query['col_filter'] as $name => $value)
281 281
 		{
282 282
 			if ((string)$value !== '')
283 283
 			{
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @param array &$readonlys
298 298
 	 * @return int
299 299
 	 */
300
-	function get_rows(&$query,&$rows,&$readonlys)
300
+	function get_rows(&$query, &$rows, &$readonlys)
301 301
 	{
302 302
 		//error_log(__METHOD__."() query[csv_export]=".array2string($query['csv_export']).", query[filter]=".array2string($query['filter']).", query[col_filter]=".array2string(array_diff($query['col_filter'],array('',0))).' '.function_backtrace());
303 303
 		if (!$query['csv_export'])
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			}
315 315
 			//error_log(__METHOD__."() prefs[listNoSubs]=".array2string($this->prefs['listNoSubs'])." --> parent_id=$parent_id");
316 316
 			unset($query['col_filter']['parent_id']);
317
-			if(!$query['action'])
317
+			if (!$query['action'])
318 318
 			{
319 319
 				Api\Cache::setSession('infolog', $query['session_for'].'session_data', $query);
320 320
 			}
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 			$query['row_modified'] = 'row_mod';
324 324
 			$query['parent_id'] = 'info_id_parent';
325 325
 			$query['is_parent'] = 'info_anz_subs';
326
-			$query['action_var'] = 'multi_action';	// as 'action' is already used in infolog
326
+			$query['action_var'] = 'multi_action'; // as 'action' is already used in infolog
327 327
 		}
328 328
 		// nextmatch opened an infolog containing children --> do not filter them, always show all children
329
-		elseif($query['csv_export'] === 'children')
329
+		elseif ($query['csv_export'] === 'children')
330 330
 		{
331 331
 			$query['filter'] = $query['search'] = $query['cat_id'] = '';
332 332
 			$query['col_filter'] = array('info_id_parent' => $query['col_filter']['info_id_parent']);
@@ -346,17 +346,17 @@  discard block
 block discarded – undo
346 346
 			$links['linked'] = array();
347 347
 			unset($query['col_filter']['linked']);
348 348
 		}
349
-		if($query['action'] && in_array($query['action'], array_keys($GLOBALS['egw_info']['apps'])) && $query['action_id'])
349
+		if ($query['action'] && in_array($query['action'], array_keys($GLOBALS['egw_info']['apps'])) && $query['action_id'])
350 350
 		{
351 351
 			$link_filters['action'] = array('app'=>$query['action'], 'id' => $query['action_id']);
352 352
 			$links['action'] = array();
353 353
 		}
354
-		foreach($link_filters as $key => $link)
354
+		foreach ($link_filters as $key => $link)
355 355
 		{
356
-			if(!is_array($link))
356
+			if (!is_array($link))
357 357
 			{
358 358
 				// Legacy string style
359
-				list($app,$id) = explode(':',$link);
359
+				list($app, $id) = explode(':', $link);
360 360
 			}
361 361
 			else
362 362
 			{
@@ -364,25 +364,25 @@  discard block
 block discarded – undo
364 364
 				$app = $link['app'];
365 365
 				$id = $link['id'];
366 366
 			}
367
-			if(!is_array($id)) $id = explode(',',$id);
368
-			if (!($linked = Link::get_links_multiple($app,$id,true,'infolog','',$query['col_filter']['info_status'] == 'deleted')))
367
+			if (!is_array($id)) $id = explode(',', $id);
368
+			if (!($linked = Link::get_links_multiple($app, $id, true, 'infolog', '', $query['col_filter']['info_status'] == 'deleted')))
369 369
 			{
370
-				$rows = array();	// no infologs linked to selected link --> no rows to return
370
+				$rows = array(); // no infologs linked to selected link --> no rows to return
371 371
 				return 0;
372 372
 			}
373 373
 
374 374
 
375
-			foreach($linked as $infos)
375
+			foreach ($linked as $infos)
376 376
 			{
377
-				$links[$key] = array_merge($links[$key],$infos);
377
+				$links[$key] = array_merge($links[$key], $infos);
378 378
 			}
379 379
 			$links[$key] = array_unique($links[$key]);
380
-			if($key == 'linked')
380
+			if ($key == 'linked')
381 381
 			{
382 382
 				$linked = array('app' => $app, 'id' => $id, 'title' => (count($id) == 1 ? Link::title($app, $id) : lang('multiple')));
383 383
 			}
384 384
 		}
385
-		if(count($links))
385
+		if (count($links))
386 386
 		{
387 387
 			$query['col_filter']['info_id'] = count($links) > 1 ? call_user_func_array('array_intersect', $links) : $links[$key];
388 388
 		}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		$old_template = $query['template'];
392 392
 
393 393
 		// Reset custom, type-specific template if type was cleared (without changing it for home)
394
-		if(!$query['template'] || stripos($query['template'], 'infolog.index.rows') === 0)
394
+		if (!$query['template'] || stripos($query['template'], 'infolog.index.rows') === 0)
395 395
 		{
396 396
 			$query['template'] = 'infolog.index.rows';
397 397
 		}
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 			if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type']))
403 403
 			{
404 404
 				$query['template'] = $tpl->name;
405
-				$query['custom_fields'] = true;	// read the custom fields too
405
+				$query['custom_fields'] = true; // read the custom fields too
406 406
 			}
407 407
 			// If status is not valid for selected type, clear status filter
408
-			if($query['col_filter']['info_status'] && $query['col_filter']['info_status'] != 'deleted' &&
408
+			if ($query['col_filter']['info_status'] && $query['col_filter']['info_status'] != 'deleted' &&
409 409
 				!in_array($query['col_filter']['info_status'], array_keys($this->bo->status[$query['col_filter']['info_type']])))
410 410
 			{
411 411
 				$query['col_filter']['info_status'] = '';
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 			}
414 414
 		}
415 415
 		// Framework\Template change forces the UI to do a full update first, no point in getting rows right now
416
-		if($old_template && $old_template != $query['template']) return 0;
416
+		if ($old_template && $old_template != $query['template']) return 0;
417 417
 
418 418
 		// do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific
419 419
 		// so we have to check that as well
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
 
427 427
 		if (!$query['selectcols'] && $columselection)
428 428
 		{
429
-			$columselection = is_array($columselection) ? $columselection : explode(',',$columselection);
429
+			$columselection = is_array($columselection) ? $columselection : explode(',', $columselection);
430 430
 		}
431 431
 		else
432 432
 		{
433
-			$columselection = $query['selectcols'] ? (is_array($query['selectcols']) ? $query['selectcols'] : explode(',',$query['selectcols'])) : array();
433
+			$columselection = $query['selectcols'] ? (is_array($query['selectcols']) ? $query['selectcols'] : explode(',', $query['selectcols'])) : array();
434 434
 		}
435 435
 		// do we need to query the cf's
436
-		$query['custom_fields'] = $this->bo->customfields && (!$columselection || in_array('customfields',$columselection));
436
+		$query['custom_fields'] = $this->bo->customfields && (!$columselection || in_array('customfields', $columselection));
437 437
 
438 438
 		$infos = $this->bo->search($query);
439 439
 		$query['col_filter'] = $orginal_colfilter;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 			$query['default_cols'] = '!cat_id,info_datemodified,info_used_time_info_planned_time,info_used_time_info_planned_time_info_replanned_time,info_id';
452 452
 		}
453 453
 		// set old show_times pref, that get_info calculates the cumulated time of the timesheets (we only check used&planned to work for both time cols)
454
-		$this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']],'info_used_time_info_planned_time') !== false;
454
+		$this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']], 'info_used_time_info_planned_time') !== false;
455 455
 
456 456
 		// query all links and sub counts in one go
457 457
 		if ($infos && (!$query['csv_export'] || !is_array($query['csv_export'])))
458 458
 		{
459
-			$links = Link::get_links_multiple('infolog',array_keys($infos),true,'','link_lastmod DESC',true);	// true=incl. deleted
459
+			$links = Link::get_links_multiple('infolog', array_keys($infos), true, '', 'link_lastmod DESC', true); // true=incl. deleted
460 460
 			$anzSubs = $this->bo->anzSubs(array_keys($infos));
461 461
 		}
462 462
 		$rows = array();
@@ -467,27 +467,27 @@  discard block
 block discarded – undo
467 467
 			$parents = $query['action'] == 'sp' && $query['action_id'] ? (array)$query['action_id'] : array();
468 468
 			if (count($parents) == 1 && is_array($query['action_id']))
469 469
 			{
470
-				$query['action_id'] = array_shift($query['action_id']);	// display single parent as app_header
470
+				$query['action_id'] = array_shift($query['action_id']); // display single parent as app_header
471 471
 			}
472 472
 		}
473 473
 
474 474
 		$parent_first = count($parents) == 1;
475 475
 		$parent_index = 0;
476 476
 		// et2 nextmatch listens to total, and only displays that many rows, so add parent in or we'll lose the last row
477
-		if($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++;
477
+		if ($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++;
478 478
 
479 479
 		// Check to see if we need to remove description
480
-		foreach($infos as $id => $info)
480
+		foreach ($infos as $id => $info)
481 481
 		{
482
-			if (!(strpos($info['info_addr'],',')===false) && strpos($info['info_addr'],', ')===false) $info['info_addr'] = str_replace(',',', ',$info['info_addr']);
482
+			if (!(strpos($info['info_addr'], ',') === false) && strpos($info['info_addr'], ', ') === false) $info['info_addr'] = str_replace(',', ', ', $info['info_addr']);
483 483
 			if (!$query['csv_export'] || !is_array($query['csv_export']))
484 484
 			{
485
-				$info['links'] =& $links[$id];
485
+				$info['links'] = & $links[$id];
486 486
 				$info['info_anz_subs'] = (int)$anzSubs[$id];
487
-				$info = $this->get_info($info,$readonlys,null,null,false,$details);
487
+				$info = $this->get_info($info, $readonlys, null, null, false, $details);
488 488
 			}
489 489
 			// for subs view ('sp') add parent(s) in front of subs once(!)
490
-			if ( $parent_first && ($main = $this->bo->read($query['action_id'])) ||
490
+			if ($parent_first && ($main = $this->bo->read($query['action_id'])) ||
491 491
 				$parents && ($parent_index = array_search($info['info_id_parent'], $parents)) !== false &&
492 492
 				($main = $this->bo->read($info['info_id_parent'])))
493 493
 			{
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 				// as read() always read them all, while search() only reads the selected ones
498 498
 				if ($query['custom_fields'])
499 499
 				{
500
-					foreach($columselection as $col)
500
+					foreach ($columselection as $col)
501 501
 					{
502 502
 						if ($col[0] == '#')
503 503
 						{
504
-							foreach(array_keys($main) as $n)
504
+							foreach (array_keys($main) as $n)
505 505
 							{
506 506
 								if ($n[0] == '#' && !in_array($n, $columselection)) unset($main[$n]);
507 507
 							}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 					}
511 511
 				}
512 512
 				$parent_first = false;
513
-				if($query['start'] == 0)
513
+				if ($query['start'] == 0)
514 514
 				{
515 515
 					array_splice($rows, $id, 0, array($main));
516 516
 					unset($parents[$parent_index]);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		if ($query['cat_id']) $rows['no_cat_id'] = true;
524 524
 		if ($query['no_actions']) $rows['no_actions'] = true;
525 525
 		$rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']);
526
-		if($clear_status_filter)
526
+		if ($clear_status_filter)
527 527
 		{
528 528
 			$rows['info_status'] = '';
529 529
 		}
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 				$headers[] = lang($this->filters[$query['filter']]);
555 555
 			}
556 556
 			if ($query['action'] && ($title = $query['action_title'] || is_array($query['action_id']) ?
557
-				$query['action_title'] : Link::title($query['action']=='sp'?'infolog':$query['action'],$query['action_id'])))
557
+				$query['action_title'] : Link::title($query['action'] == 'sp' ? 'infolog' : $query['action'], $query['action_id'])))
558 558
 			{
559 559
 				$headers[] = $title;
560 560
 			}
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 			$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $headers);
566 566
 		}
567 567
 
568
-		if (isset($linked)) $query['col_filter']['linked'] = $linked;  // add linked back to the colfilter
568
+		if (isset($linked)) $query['col_filter']['linked'] = $linked; // add linked back to the colfilter
569 569
 
570 570
 		return $query['total'];
571 571
 	}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		{
585 585
 			if ($info['info_cat']) $set['cat_id'] = $info['info_cat'];
586 586
 
587
-			foreach(Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link)
587
+			foreach (Link::get_links('infolog', $info['info_id'], '', 'link_lastmod DESC', true) as $link)
588 588
 			{
589 589
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
590 590
 				{
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		{
610 610
 			return $data;
611 611
 		}
612
-		$event = array_merge($data,array(
612
+		$event = array_merge($data, array(
613 613
 			'category'	=> $GLOBALS['egw']->categories->check_list(Acl::READ, $infolog['info_cat']),
614 614
 			'priority'	=> $infolog['info_priority'] + 1,
615 615
 			'public'	=> $infolog['info_access'] != 'private',
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 			'end'		=> $infolog['info_enddate'] ? $infolog['info_enddate'] : $infolog['info_datecompleted']
621 621
 		));
622 622
 		unset($event['entry_id']);
623
-		if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
623
+		if (!$event['end']) $event['end'] = $event['start'] + (int)$GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60;
624 624
 
625 625
 		// Match Api\Categories by name
626 626
 		$event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat']));
@@ -629,38 +629,38 @@  discard block
 block discarded – undo
629 629
 		$event['owner'] = $user = $GLOBALS['egw_info']['user']['account_id'];
630 630
 
631 631
 		// add/modify participants according to prefs
632
-		$prefs = explode(',',$this->prefs['calendar_set'] ? $this->prefs['calendar_set'] : 'responsible,contact,user');
632
+		$prefs = explode(',', $this->prefs['calendar_set'] ? $this->prefs['calendar_set'] : 'responsible,contact,user');
633 633
 
634 634
 		// if no default participants (selected calendars) --> remove all
635
-		if (!in_array('selected',$prefs))
635
+		if (!in_array('selected', $prefs))
636 636
 		{
637 637
 			$event['participants'] = $event['participant_types'] = array();
638 638
 		}
639 639
 		// Add responsible as participant
640
-		if (in_array('responsible',$prefs))
640
+		if (in_array('responsible', $prefs))
641 641
 		{
642
-			foreach($infolog['info_responsible'] as $responsible)
642
+			foreach ($infolog['info_responsible'] as $responsible)
643 643
 			{
644 644
 				$event['participants'][$responsible] = $event['participant_types']['u'][$responsible] =
645
-					calendar_so::combine_status($user==$responsible?'A':'U');
645
+					calendar_so::combine_status($user == $responsible ? 'A' : 'U');
646 646
 			}
647 647
 		}
648 648
 		// Add linked contact as participant
649
-		if (in_array('contact',$prefs) && $infolog['info_link']['app'] == 'addressbook')
649
+		if (in_array('contact', $prefs) && $infolog['info_link']['app'] == 'addressbook')
650 650
 		{
651
-			$event['participants'][calendar_so::combine_user('c',$infolog['info_link']['id'])] =
651
+			$event['participants'][calendar_so::combine_user('c', $infolog['info_link']['id'])] =
652 652
 				$event['participant_types']['c'][$infolog['info_link']['id']] = calendar_so::combine_status('U');
653 653
 		}
654
-		if (in_array('owner',$prefs))
654
+		if (in_array('owner', $prefs))
655 655
 		{
656 656
 			$event['participants'][$infolog['info_owner']] = $event['participant_types']['u'][$infolog['info_owner']] =
657
-				calendar_so::combine_status('A',1,'CHAIR');
657
+				calendar_so::combine_status('A', 1, 'CHAIR');
658 658
 		}
659 659
 		// Add current user, if set or no other participants, which is not allowed
660
-		if (in_array('user',$prefs))
660
+		if (in_array('user', $prefs))
661 661
 		{
662 662
 			$event['participants'][$user] = $event['participant_types']['u'][$user] =
663
-				calendar_so::combine_status('A',1,'CHAIR');
663
+				calendar_so::combine_status('A', 1, 'CHAIR');
664 664
 		}
665 665
 
666 666
 		// Add infolog link to calendar entry
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		$event['link_id'][]  = $infolog['info_link']['id'];
669 669
 
670 670
 		// Copy infolog's links
671
-		foreach(Link::get_links('infolog',$infolog['info_id'],'','link_lastmod DESC',true) as $link)
671
+		foreach (Link::get_links('infolog', $infolog['info_id'], '', 'link_lastmod DESC', true) as $link)
672 672
 		{
673 673
 			if ($link['app'] != Link::VFS_APPNAME)
674 674
 			{
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			}
678 678
 		}
679 679
 		// Copy same custom fields
680
-		foreach(array_keys(Api\Storage\Customfields::get('calendar')) as $name)
680
+		foreach (array_keys(Api\Storage\Customfields::get('calendar')) as $name)
681 681
 		{
682 682
 			if ($this->bo->customfields[$name]) $event['#'.$name] = $infolog['#'.$name];
683 683
 		}
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
 	 * @param string $own_referer='' this is our own referer
697 697
 	 * @param string $action_title='' app_header for the action, if '' we try the link-title
698 698
 	 */
699
-	function index($values = null,$action='',$action_id='',$called_as=0,$extra_app_header=False,$return_html=False,$own_referer='',$action_title='')
699
+	function index($values = null, $action = '', $action_id = '', $called_as = 0, $extra_app_header = False, $return_html = False, $own_referer = '', $action_title = '')
700 700
 	{
701
-		unset($extra_app_header);	// not used, but dont want to change signature
701
+		unset($extra_app_header); // not used, but dont want to change signature
702 702
 		if (is_array($values))
703 703
 		{
704 704
 			$called_as = $values['called_as'];
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		elseif ($own_referer === '')
708 708
 		{
709 709
 			$own_referer = Api\Header\Referer::get();
710
-			if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false)
710
+			if (strpos($own_referer, 'menuaction=infolog.infolog_ui.edit') !== false)
711 711
 			{
712 712
 				$own_referer = Api\Cache::getSession('infolog', 'own_session');
713 713
 			}
@@ -718,11 +718,11 @@  discard block
 block discarded – undo
718 718
 		}
719 719
 
720 720
 		// Handle legacy buttons like actions
721
-		if(is_array($values))
721
+		if (is_array($values))
722 722
 		{
723
-			foreach(array('document', 'view', 'delete') as $button)
723
+			foreach (array('document', 'view', 'delete') as $button)
724 724
 			{
725
-				if(isset($values['nm']['rows'][$button]))
725
+				if (isset($values['nm']['rows'][$button]))
726 726
 				{
727 727
 					list($id) = @each($values['nm']['rows'][$button]);
728 728
 					$values['nm']['multi_action'] = $button;
@@ -742,27 +742,27 @@  discard block
 block discarded – undo
742 742
 				// Some processing to add values in for links and cats
743 743
 				$multi_action = $values['nm']['multi_action'];
744 744
 				// Action has an additional action - add / delete, etc.  Buttons named <multi-action>_action[action_name]
745
-				if(in_array($multi_action, array('link', 'responsible')))
745
+				if (in_array($multi_action, array('link', 'responsible')))
746 746
 				{
747 747
 					// eTemplate ignores the _popup namespace, but et2 doesn't
748
-					if($values[$multi_action.'_popup'])
748
+					if ($values[$multi_action.'_popup'])
749 749
 					{
750
-						$popup =& $values[$multi_action.'_popup'];
750
+						$popup = & $values[$multi_action.'_popup'];
751 751
 					}
752 752
 					else
753 753
 					{
754
-						$popup =& $values;
754
+						$popup = & $values;
755 755
 					}
756
-					$values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action']);
757
-					if($multi_action == 'link')
756
+					$values['nm']['multi_action'] .= '_'.key($popup[$multi_action.'_action']);
757
+					if ($multi_action == 'link')
758 758
 					{
759
-						$popup[$multi_action] = $popup['link']['app'] . ':'.$popup['link']['id'];
759
+						$popup[$multi_action] = $popup['link']['app'].':'.$popup['link']['id'];
760 760
 					}
761
-					else if(is_array($popup[$multi_action]))
761
+					else if (is_array($popup[$multi_action]))
762 762
 					{
763
-						$popup[$multi_action] = implode(',',$popup[$multi_action]);
763
+						$popup[$multi_action] = implode(',', $popup[$multi_action]);
764 764
 					}
765
-					$values['nm']['multi_action'] .= '_' . $popup[$multi_action];
765
+					$values['nm']['multi_action'] .= '_'.$popup[$multi_action];
766 766
 					unset($values[$multi_action.'_popup']);
767 767
 					unset($values[$multi_action]);
768 768
 				}
@@ -770,18 +770,18 @@  discard block
 block discarded – undo
770 770
 				if ($this->action($values['nm']['multi_action'], $values['nm']['selected'], $values['nm']['select_all'],
771 771
 					$success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications']))
772 772
 				{
773
-					$msg .= lang('%1 entries %2',$success,$action_msg);
773
+					$msg .= lang('%1 entries %2', $success, $action_msg);
774 774
 					Framework::message($msg);
775 775
 				}
776
-				elseif(is_null($msg))
776
+				elseif (is_null($msg))
777 777
 				{
778
-					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
779
-					Framework::message($msg,'error');
778
+					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
779
+					Framework::message($msg, 'error');
780 780
 				}
781
-				elseif($msg)
781
+				elseif ($msg)
782 782
 				{
783
-					$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
784
-					Framework::message($msg,'error');
783
+					$msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed);
784
+					Framework::message($msg, 'error');
785 785
 				}
786 786
 				unset($values['nm']['multi_action']);
787 787
 				unset($values['nm']['select_all']);
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 				$action_id = 0;
805 805
 				$action_title = '';
806 806
 			}
807
-			if($_GET['ajax'] === 'true')
807
+			if ($_GET['ajax'] === 'true')
808 808
 			{
809 809
 				$nm['action'] = '';
810 810
 				$nm['action_id'] = 0;
@@ -820,8 +820,7 @@  discard block
 block discarded – undo
820 820
 
821 821
 			if (isset($_GET['filter']) && $_GET['filter'] != 'default' || !isset($values['nm']['filter']) && !$this->called_by)
822 822
 			{
823
-				$values['nm']['filter'] = $_GET['filter'] && $_GET['filter'] != 'default' ? $_GET['filter'] :
824
-					$this->prefs['defaultFilter'];
823
+				$values['nm']['filter'] = $_GET['filter'] && $_GET['filter'] != 'default' ? $_GET['filter'] : $this->prefs['defaultFilter'];
825 824
 			}
826 825
 			if (!isset($values['nm']['order']) || !$values['nm']['order'])
827 826
 			{
@@ -835,21 +834,21 @@  discard block
 block discarded – undo
835 834
 			$action_title = $values['action_title'] = $action ? $action_title : $nm['action_title'];
836 835
 			$action = $values['action'] = $action ? $action : $nm['action'];
837 836
 		}
838
-		if($_GET['search']) $values['nm']['search'] = $_GET['search'];
837
+		if ($_GET['search']) $values['nm']['search'] = $_GET['search'];
839 838
 
840 839
 		if ($values['nm']['add'])
841 840
 		{
842 841
 			$values['add'] = $values['nm']['add'];
843 842
 			unset($values['nm']['add']);
844 843
 		}
845
-		unset($values['nm']['rows']['checked']);	// not longer used, but hides button actions
844
+		unset($values['nm']['rows']['checked']); // not longer used, but hides button actions
846 845
 
847 846
 		if ($values['add'] || $values['cancel'] || isset($values['main']))
848 847
 		{
849 848
 			if ($values['add'])
850 849
 			{
851 850
 				list($type) = each($values['add']);
852
-				return $this->edit(0,$action,$action_id,$type,$called_as);
851
+				return $this->edit(0, $action, $action_id, $type, $called_as);
853 852
 			}
854 853
 			elseif ($values['cancel'] && $own_referer)
855 854
 			{
@@ -860,14 +859,14 @@  discard block
 block discarded – undo
860 859
 			}
861 860
 			else
862 861
 			{
863
-				list($do,$do2) = each($values['main']);
862
+				list($do, $do2) = each($values['main']);
864 863
 				list($do_id) = @each($do2);
865
-				switch((string)$do)
864
+				switch ((string)$do)
866 865
 				{
867 866
 					case 'close':
868
-						$closesingle=true;
867
+						$closesingle = true;
869 868
 					case 'close_all':
870
-						$this->close($do_id,$called_as,$closesingle);
869
+						$this->close($do_id, $called_as, $closesingle);
871 870
 						break;
872 871
 					case 'view':
873 872
 						$value = array();
@@ -905,7 +904,7 @@  discard block
 block discarded – undo
905 904
 		$this->tmpl->read('infolog.index');
906 905
 		$values['nm']['options-filter'] = $this->filters;
907 906
 		$values['nm']['get_rows'] = 'infolog.infolog_ui.get_rows';
908
-		$values['nm']['options-filter2'] = (in_array($this->prefs['show_links'],array('all','no_describtion')) ? array() : array(
907
+		$values['nm']['options-filter2'] = (in_array($this->prefs['show_links'], array('all', 'no_describtion')) ? array() : array(
909 908
 			''               => 'default',
910 909
 		)) + array(
911 910
 			'no_describtion' => 'no details',
@@ -926,34 +925,34 @@  discard block
 block discarded – undo
926 925
 		else
927 926
 		{
928 927
 			// Allow saving parent ID into favorites
929
-			$values['nm']['favorites'] = array('action','action_id');
928
+			$values['nm']['favorites'] = array('action', 'action_id');
930 929
 		}
931 930
 
932 931
 		// Allow add actions even when there's no rows
933 932
 		$values['nm']['placeholder_actions'] = array('new');
934 933
 
935
-		if(!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
934
+		if (!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
936 935
 
937 936
 		// disable columns for main entry as set in the pref for details or no details
938 937
 		$values['nm']['columnselection_pref'] = 'nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows')
939
-			.($values['nm']['filter2']=='all' ? '-details' : '');
938
+			.($values['nm']['filter2'] == 'all' ? '-details' : '');
940 939
 		if ($action == 'sp')
941 940
 		{
942 941
 			$pref = $values['nm']['columnselection_pref'];
943
-			foreach(array('info_used_time_info_planned_time_info_replanned_time','info_datemodified','info_owner_info_responsible','customfields') as $name)
942
+			foreach (array('info_used_time_info_planned_time_info_replanned_time', 'info_datemodified', 'info_owner_info_responsible', 'customfields') as $name)
944 943
 			{
945
-				$values['main']['no_'.$name] = strpos($this->prefs[$pref],$name) === false;
944
+				$values['main']['no_'.$name] = strpos($this->prefs[$pref], $name) === false;
946 945
 			}
947 946
 			if (!$values['main']['no_customfields'])
948 947
 			{
949 948
 				// set the column-header of the main table for the customfields.
950
-				foreach(array_keys($this->bo->customfields) as $lname)
949
+				foreach (array_keys($this->bo->customfields) as $lname)
951 950
 				{
952
-					$values['main']['customfields'].=$lname."\n";
951
+					$values['main']['customfields'] .= $lname."\n";
953 952
 				}
954 953
 			}
955 954
 		}
956
-		if ($values['nm']['filter']=='bydate')
955
+		if ($values['nm']['filter'] == 'bydate')
957 956
 		{
958 957
 			foreach (array_keys($values['nm']['col_filter']) as $colfk)
959 958
 			{
@@ -986,7 +985,7 @@  discard block
 block discarded – undo
986 985
 		{
987 986
 			$values['css'] .= '<style type="text/css">@media screen { .infoDes {  '.
988 987
 				' max-height: '.
989
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	// dono why em is not real lines
988
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
990 989
 				'em; overflow: auto; }}</style>';
991 990
 		}
992 991
 
@@ -998,13 +997,13 @@  discard block
 block discarded – undo
998 997
 
999 998
 		// remove group-types user has not any rights to as filter
1000 999
 		// does not take implicit rights as delegated into account, so they will not be available as filters
1001
-		foreach($this->bo->group_owners as $type => $group)
1000
+		foreach ($this->bo->group_owners as $type => $group)
1002 1001
 		{
1003 1002
 			if (!isset($this->bo->grants[$group])) unset($sel_options['info_type'][$type]);
1004 1003
 		}
1005 1004
 
1006 1005
 
1007
-		return $this->tmpl->exec('infolog.infolog_ui.index',$values,$sel_options,$readonlys,$persist,$return_html ? -1 : 0);
1006
+		return $this->tmpl->exec('infolog.infolog_ui.index', $values, $sel_options, $readonlys, $persist, $return_html ? -1 : 0);
1008 1007
 	}
1009 1008
 
1010 1009
 	/**
@@ -1019,9 +1018,9 @@  discard block
 block discarded – undo
1019 1018
 		if ($this->bo->group_owners)
1020 1019
 		{
1021 1020
 			// remove types owned by groups the user has no edit grant
1022
-			foreach($this->bo->group_owners as $type => $group)
1021
+			foreach ($this->bo->group_owners as $type => $group)
1023 1022
 			{
1024
-				if (!($this->bo->grants[$group] & Acl::EDIT))
1023
+				if (!($this->bo->grants[$group]&Acl::EDIT))
1025 1024
 				{
1026 1025
 					unset($types[$type]);
1027 1026
 				}
@@ -1038,7 +1037,7 @@  discard block
 block discarded – undo
1038 1037
 	 */
1039 1038
 	private function get_actions(array $query)
1040 1039
 	{
1041
-		for($i = 0; $i <= 100; $i += 10)
1040
+		for ($i = 0; $i <= 100; $i += 10)
1042 1041
 		{
1043 1042
 			$percent[$i] = $i.'%';
1044 1043
 		}
@@ -1047,9 +1046,9 @@  discard block
 block discarded – undo
1047 1046
 		$types_add = array();
1048 1047
 		// Do not add deleted type to add or change menus
1049 1048
 		unset($types['delete']);
1050
-		foreach($types as $type => &$data)
1049
+		foreach ($types as $type => &$data)
1051 1050
 		{
1052
-			$image_exists = Api\Image::find('infolog',$type);
1051
+			$image_exists = Api\Image::find('infolog', $type);
1053 1052
 			$data = array(
1054 1053
 				'caption' => $data,
1055 1054
 				'icon' => $image_exists ? $type : 'infolog/navbar',
@@ -1061,9 +1060,9 @@  discard block
 block discarded – undo
1061 1060
 
1062 1061
 		$icons = null;
1063 1062
 		$statis = $this->bo->get_status($query['col_filter']['info_type'], $icons);
1064
-		foreach($statis as $type => &$data)
1063
+		foreach ($statis as $type => &$data)
1065 1064
 		{
1066
-			$image_exists = Api\Image::find('infolog',$icons[$type]);
1065
+			$image_exists = Api\Image::find('infolog', $icons[$type]);
1067 1066
 			$data = array(
1068 1067
 				'caption' => $data,
1069 1068
 				'icon' => $image_exists ? $icons[$type] : 'infolog/status',
@@ -1075,10 +1074,10 @@  discard block
 block discarded – undo
1075 1074
 				'caption' => 'Open',
1076 1075
 				'default' => true,
1077 1076
 				'allowOnMultiple' => false,
1078
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.infolog.viewEntry':'',
1077
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.infolog.viewEntry' : '',
1079 1078
 				'url' => 'menuaction=infolog.infolog_ui.edit&info_id=$id',
1080 1079
 				'popup' => Link::get_registry('infolog', 'add_popup'),
1081
-				'group' => $group=1,
1080
+				'group' => $group = 1,
1082 1081
 				'mobileViewTemplate' => 'edit?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/infolog/templates/mobile/edit.xet'))
1083 1082
 			),
1084 1083
 			'parent' => array(
@@ -1152,7 +1151,7 @@  discard block
 block discarded – undo
1152 1151
 						'icon' => 'completed',
1153 1152
 					),
1154 1153
 					'cat' =>  Etemplate\Widget\Nextmatch::category_action(
1155
-						'infolog',$group,'Change category','cat_'
1154
+						'infolog', $group, 'Change category', 'cat_'
1156 1155
 					),
1157 1156
 					'responsible' => array(
1158 1157
 						'caption' => 'Delegation',
@@ -1189,7 +1188,7 @@  discard block
 block discarded – undo
1189 1188
 				'onExecute' => 'javaScript:app.infolog.infolog_menu_print'
1190 1189
 			)
1191 1190
 		);
1192
-		++$group;	// integration with other apps
1191
+		++$group; // integration with other apps
1193 1192
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
1194 1193
 		{
1195 1194
 			$actions['filemanager'] = array(
@@ -1207,7 +1206,7 @@  discard block
 block discarded – undo
1207 1206
 				'caption' => 'Schedule appointment',
1208 1207
 				'group' => $group,
1209 1208
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&'.
1210
-					Link::get_registry('calendar', 'add_app') . '[]=infolog&'.Link::get_registry('calendar','add_id').'[]=$id',
1209
+					Link::get_registry('calendar', 'add_app').'[]=infolog&'.Link::get_registry('calendar', 'add_id').'[]=$id',
1211 1210
 				'allowOnMultiple' => false,
1212 1211
 				'popup' => Link::get_registry('calendar', 'add_popup'),
1213 1212
 			);
@@ -1231,7 +1230,7 @@  discard block
 block discarded – undo
1231 1230
 				'hint' => 'Convert to a ticket',
1232 1231
 				'group' => $group,
1233 1232
 				'url' => 'menuaction=tracker.tracker_ui.edit&'.
1234
-					Link::get_registry('tracker', 'add_app') . '[]=infolog&'.Link::get_registry('tracker','add_id').'[]=$id',
1233
+					Link::get_registry('tracker', 'add_app').'[]=infolog&'.Link::get_registry('tracker', 'add_id').'[]=$id',
1235 1234
 				'allowOnMultiple' => false,
1236 1235
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1237 1236
 			);
@@ -1244,7 +1243,7 @@  discard block
 block discarded – undo
1244 1243
 		$actions['ical'] = array(
1245 1244
 			'icon' => 'ical',
1246 1245
 			'caption' => 'Export iCal',
1247
-			'postSubmit' => true,	// download needs post submit to work
1246
+			'postSubmit' => true, // download needs post submit to work
1248 1247
 			'group' => $group,
1249 1248
 			'allowOnMultiple' => true,
1250 1249
 			'hideOnMobile' => true
@@ -1297,14 +1296,14 @@  discard block
 block discarded – undo
1297 1296
 		$success = $failed = 0;
1298 1297
 		if ($use_all)
1299 1298
 		{
1300
-			@set_time_limit(0);                     // switch off the execution time limit, as it's for big selections to small
1301
-			$query['num_rows'] = -1;        // all
1299
+			@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1300
+			$query['num_rows'] = -1; // all
1302 1301
 			$result = $readonlys = null;
1303
-			$this->get_rows($query,$result,$readonlys);
1302
+			$this->get_rows($query, $result, $readonlys);
1304 1303
 			$checked = array();
1305
-			foreach($result as $key => $info)
1304
+			foreach ($result as $key => $info)
1306 1305
 			{
1307
-				if(is_numeric($key))
1306
+				if (is_numeric($key))
1308 1307
 				{
1309 1308
 					$checked[] = $info['info_id'];
1310 1309
 				}
@@ -1315,29 +1314,29 @@  discard block
 block discarded – undo
1315 1314
 		list($action, $settings) = explode('_', $_action, 2);
1316 1315
 
1317 1316
 		// Actions that can handle a list of IDs
1318
-		switch($action)
1317
+		switch ($action)
1319 1318
 		{
1320 1319
 			case 'link':
1321 1320
 				list($add_remove, $link) = explode('_', $settings, 2);
1322
-				list($app, $link_id) = explode(strpos($link,':') !== false ? ':' : ',', $link);
1323
-				if(!$link_id)
1321
+				list($app, $link_id) = explode(strpos($link, ':') !== false ? ':' : ',', $link);
1322
+				if (!$link_id)
1324 1323
 				{
1325 1324
 					$action_msg = 'linked';
1326 1325
 					$msg = lang('You need to select an entry for linking.');
1327 1326
 					break;
1328 1327
 				}
1329 1328
 				$title = Link::title($app, $link_id);
1330
-				foreach($checked as $id)
1329
+				foreach ($checked as $id)
1331 1330
 				{
1332
-					if(!$this->bo->check_access($id, Acl::EDIT))
1331
+					if (!$this->bo->check_access($id, Acl::EDIT))
1333 1332
 					{
1334 1333
 						$failed++;
1335 1334
 						continue;
1336 1335
 					}
1337
-					if($add_remove == 'add')
1336
+					if ($add_remove == 'add')
1338 1337
 					{
1339 1338
 						$action_msg = lang('linked to %1', $title);
1340
-						if(Link::link('infolog', $id, $app, $link_id))
1339
+						if (Link::link('infolog', $id, $app, $link_id))
1341 1340
 						{
1342 1341
 							$success++;
1343 1342
 						}
@@ -1364,20 +1363,20 @@  discard block
 block discarded – undo
1364 1363
 			case 'ical':
1365 1364
 				// infolog_ical lets horde be auto-loaded, so it must go first
1366 1365
 				$boical = new infolog_ical();
1367
-				Api\Header\Content::type('todo.ics','text/calendar');
1366
+				Api\Header\Content::type('todo.ics', 'text/calendar');
1368 1367
 				echo $boical->exportvCalendar($checked);
1369 1368
 				exit();
1370 1369
 
1371 1370
 		}
1372 1371
 
1373 1372
 		// Actions that need to loop
1374
-		foreach($checked as $id)
1373
+		foreach ($checked as $id)
1375 1374
 		{
1376
-			if(!$entry = $this->bo->read($id))
1375
+			if (!$entry = $this->bo->read($id))
1377 1376
 			{
1378 1377
 				continue;
1379 1378
 			}
1380
-			switch($action)
1379
+			switch ($action)
1381 1380
 			{
1382 1381
 				case 'close':
1383 1382
 					$action_msg = lang('closed');
@@ -1387,8 +1386,8 @@  discard block
 block discarded – undo
1387 1386
 
1388 1387
 				case 'delete':
1389 1388
 					$action_msg = $settings == 'sub' ? lang(' (and children) deleted') : lang('deleted');
1390
-					$result = $this->bo->delete($id, $settings=='sub', false, $skip_notifications);
1391
-					if($result == true)
1389
+					$result = $this->bo->delete($id, $settings == 'sub', false, $skip_notifications);
1390
+					if ($result == true)
1392 1391
 					{
1393 1392
 						$success++;
1394 1393
 					}
@@ -1401,14 +1400,14 @@  discard block
 block discarded – undo
1401 1400
 				case 'type':
1402 1401
 					$action_msg = lang('changed type');
1403 1402
 					// Dont allow to change the type, if user has no delete rights from the group-owner
1404
-					if ($id && !($this->bo->grants[$entry['info_owner']] & Acl::DELETE))
1403
+					if ($id && !($this->bo->grants[$entry['info_owner']]&Acl::DELETE))
1405 1404
 					{
1406 1405
 						$failed++;
1407 1406
 						break;
1408 1407
 					}
1409 1408
 					$entry['info_type'] = $settings;
1410 1409
 					try {
1411
-						$this->bo->write($entry, true,true,true,$skip_notifications,true); // Throw exceptions
1410
+						$this->bo->write($entry, true, true, true, $skip_notifications, true); // Throw exceptions
1412 1411
 					}
1413 1412
 					catch (Api\Exception\WrongUserinput $e)
1414 1413
 					{
@@ -1423,11 +1422,11 @@  discard block
 block discarded – undo
1423 1422
 					$action_msg = lang('changed completion to %1%', $settings);
1424 1423
 					$entry['info_percent'] = $settings;
1425 1424
 					// Done and not-started entries will get changed right back if we don't change the status too
1426
-					if(in_array($entry['info_status'],array('not-started','done','billed','cancelled','archive')))
1425
+					if (in_array($entry['info_status'], array('not-started', 'done', 'billed', 'cancelled', 'archive')))
1427 1426
 					{
1428 1427
 						$entry['info_status'] = 'ongoing';
1429 1428
 					}
1430
-					if($entry['info_percent'] == 0)
1429
+					if ($entry['info_percent'] == 0)
1431 1430
 					{
1432 1431
 						$entry['info_status'] = 'not-started';
1433 1432
 					}
@@ -1435,7 +1434,7 @@  discard block
 block discarded – undo
1435 1434
 					{
1436 1435
 						$entry['info_status'] = 'done';
1437 1436
 					}
1438
-					if($this->bo->write($entry, true,true,true,$skip_notifications))
1437
+					if ($this->bo->write($entry, true, true, true, $skip_notifications))
1439 1438
 					{
1440 1439
 						$success++;
1441 1440
 					}
@@ -1447,24 +1446,23 @@  discard block
 block discarded – undo
1447 1446
 
1448 1447
 				case 'undelete':	// set it to valid status != 'deleted' for that type
1449 1448
 					$settings = isset($this->bo->status[$entry['info_type']]['done']) ?
1450
-						$this->bo->status[$entry['info_type']]['done'] :
1451
-						$this->bo->status['defaults'][$entry['info_type']];
1449
+						$this->bo->status[$entry['info_type']]['done'] : $this->bo->status['defaults'][$entry['info_type']];
1452 1450
 					// fall-through
1453 1451
 				case 'status':
1454
-					if(isset($this->bo->status[$entry['info_type']][$settings]))
1452
+					if (isset($this->bo->status[$entry['info_type']][$settings]))
1455 1453
 					{
1456 1454
 						$action_msg = lang('changed status to %1', lang($this->bo->status[$entry['info_type']][$settings]));
1457
-						if(!in_array($settings,array('done','billed','cancelled','archive')) && $entry['info_percent'] == 100)
1455
+						if (!in_array($settings, array('done', 'billed', 'cancelled', 'archive')) && $entry['info_percent'] == 100)
1458 1456
 						{
1459 1457
 							// Done entries will get changed right back if we don't change the completion too
1460 1458
 							$entry['info_percent'] = 10;
1461 1459
 						}
1462
-						if(in_array($settings, array('not-started')) && $entry['info_percent'] > 0)
1460
+						if (in_array($settings, array('not-started')) && $entry['info_percent'] > 0)
1463 1461
 						{
1464 1462
 							$entry['info_percent'] = 0;
1465 1463
 						}
1466 1464
 						$entry['info_status'] = $settings;
1467
-						if($this->bo->write($entry, true,true,true,$skip_notifications))
1465
+						if ($this->bo->write($entry, true, true, true, $skip_notifications))
1468 1466
 						{
1469 1467
 							$success++;
1470 1468
 						}
@@ -1477,7 +1475,7 @@  discard block
 block discarded – undo
1477 1475
 					break;
1478 1476
 
1479 1477
 				case 'cat':
1480
-					if($settings)
1478
+					if ($settings)
1481 1479
 					{
1482 1480
 						$cat_name = Api\Categories::id2name($settings);
1483 1481
 						$action_msg = lang('changed category to %1', $cat_name);
@@ -1487,7 +1485,7 @@  discard block
 block discarded – undo
1487 1485
 						$action_msg = lang('removed category');
1488 1486
 					}
1489 1487
 					$entry['info_cat'] = $settings;
1490
-					if($this->bo->write($entry, true,true,true,$skip_notifications))
1488
+					if ($this->bo->write($entry, true, true, true, $skip_notifications))
1491 1489
 					{
1492 1490
 						$success++;
1493 1491
 					}
@@ -1499,17 +1497,17 @@  discard block
 block discarded – undo
1499 1497
 
1500 1498
 				case 'responsible':
1501 1499
 					list($add_remove, $user_str) = explode('_', $settings, 2);
1502
-					$action_msg = ($add_remove == 'add' ? lang('added') : lang('removed')) . ' ';
1500
+					$action_msg = ($add_remove == 'add' ? lang('added') : lang('removed')).' ';
1503 1501
 					$names = array();
1504 1502
 					$users = explode(',', $user_str);
1505
-					foreach($users as $account_id)
1503
+					foreach ($users as $account_id)
1506 1504
 					{
1507 1505
 						$names[] = Api\Accounts::username($account_id);
1508 1506
 					}
1509 1507
 					$action_msg .= implode(', ', $names);
1510 1508
 					$function = $add_remove == 'add' ? 'array_merge' : 'array_diff';
1511 1509
 					$entry['info_responsible'] = array_unique($function($entry['info_responsible'], (array)$users));
1512
-					if($this->bo->write($entry, true,true,true,$skip_notifications))
1510
+					if ($this->bo->write($entry, true, true, true, $skip_notifications))
1513 1511
 					{
1514 1512
 						$success++;
1515 1513
 					}
@@ -1530,10 +1528,10 @@  discard block
 block discarded – undo
1530 1528
 	 * @param string $_referer=''
1531 1529
 	 * @param boolean $closesingle=false
1532 1530
 	 */
1533
-	function close($values=0,$_referer='',$closesingle=false,$skip_notification = false)
1531
+	function close($values = 0, $_referer = '', $closesingle = false, $skip_notification = false)
1534 1532
 	{
1535 1533
 		//echo "<p>".__METHOD__."($values,$referer,$closeall)</p>\n";
1536
-		$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1534
+		$info_id = (int)(is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1537 1535
 		$referer = is_array($values) ? $values['referer'] : $_referer;
1538 1536
 
1539 1537
 		if ($info_id)
@@ -1543,11 +1541,11 @@  discard block
 block discarded – undo
1543 1541
 			$status = $info['info_status'];
1544 1542
 			// closed stati assumed array('done','billed','cancelled')
1545 1543
 			if (isset($this->bo->status[$info['info_type']]['done'])) {
1546
-				$status ='done';
1544
+				$status = 'done';
1547 1545
 			} elseif (isset($this->bo->status[$info['info_type']]['billed'])) {
1548
-				$status ='billed';
1546
+				$status = 'billed';
1549 1547
 			} elseif (isset($this->bo->status[$info['info_type']]['cancelled'])) {
1550
-				$status ='cancelled';
1548
+				$status = 'cancelled';
1551 1549
 			}
1552 1550
 			#_debug_array($status);
1553 1551
 			$values = array(
@@ -1557,15 +1555,15 @@  discard block
 block discarded – undo
1557 1555
 				'info_percent'=> 100,
1558 1556
 				'info_datecompleted' => $this->bo->now_su,
1559 1557
 			);
1560
-			$this->bo->write($values, true,true,true,$skip_notification);
1558
+			$this->bo->write($values, true, true, true, $skip_notification);
1561 1559
 
1562
-			$query = array('action'=>'sp','action_id'=>$info_id);
1560
+			$query = array('action'=>'sp', 'action_id'=>$info_id);
1563 1561
 			if (!$closesingle) {
1564
-				foreach((array)$this->bo->search($query) as $info)
1562
+				foreach ((array)$this->bo->search($query) as $info)
1565 1563
 				{
1566 1564
 					if ($info['info_id_parent'] == $info_id)	// search also returns linked entries!
1567 1565
 					{
1568
-						$this->close($info['info_id'],$referer,$closesingle,$skip_notification);	// we call ourselfs recursive to process subs from subs too
1566
+						$this->close($info['info_id'], $referer, $closesingle, $skip_notification); // we call ourselfs recursive to process subs from subs too
1569 1567
 					}
1570 1568
 				}
1571 1569
 			}
@@ -1581,9 +1579,9 @@  discard block
 block discarded – undo
1581 1579
 	 * @param string $called_by
1582 1580
 	 * @param boolean $skip_notification Do not send notification of deletion
1583 1581
 	 */
1584
-	function delete($values=0,$_referer='',$called_by='',$skip_notification=False)
1582
+	function delete($values = 0, $_referer = '', $called_by = '', $skip_notification = False)
1585 1583
 	{
1586
-		$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1584
+		$info_id = (int)(is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1587 1585
 		$referer = is_array($values) ? $values['referer'] : $_referer;
1588 1586
 
1589 1587
 		if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id))	// entries without subs get confirmed by javascript
@@ -1594,9 +1592,9 @@  discard block
 block discarded – undo
1594 1592
 
1595 1593
 		if (is_array($values) || $info_id <= 0)
1596 1594
 		{
1597
-			if (($values['delete'] || $values['delete_subs']) && $info_id > 0 && $this->bo->check_access($info_id,Acl::DELETE))
1595
+			if (($values['delete'] || $values['delete_subs']) && $info_id > 0 && $this->bo->check_access($info_id, Acl::DELETE))
1598 1596
 			{
1599
-				$deleted = $this->bo->delete($info_id,$values['delete_subs'],$values['info_id_parent'], $skip_notification);
1597
+				$deleted = $this->bo->delete($info_id, $values['delete_subs'], $values['info_id_parent'], $skip_notification);
1600 1598
 			}
1601 1599
 			if ($called_by)		// direct call from the same request
1602 1600
 			{
@@ -1606,7 +1604,7 @@  discard block
 block discarded – undo
1606 1604
 			{
1607 1605
 				$this->edit(array(
1608 1606
 					'info_id' => $info_id,
1609
-					'button'  => array('deleted' => true),	// not delete!
1607
+					'button'  => array('deleted' => true), // not delete!
1610 1608
 					'referer' => $referer,
1611 1609
 					'msg'     => $deleted ? lang('Infolog entry deleted') : '',
1612 1610
 				));
@@ -1614,7 +1612,7 @@  discard block
 block discarded – undo
1614 1612
 			return $referer ? $this->tmpl->location($referer) : $this->index();
1615 1613
 		}
1616 1614
 		$readonlys = $values = array();
1617
-		$values['main'][1] = $this->get_info($info_id,$readonlys['main']);
1615
+		$values['main'][1] = $this->get_info($info_id, $readonlys['main']);
1618 1616
 
1619 1617
 		$this->tmpl->read('infolog.delete');
1620 1618
 
@@ -1635,7 +1633,7 @@  discard block
 block discarded – undo
1635 1633
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('InfoLog').' - '.lang('Delete');
1636 1634
 		$GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualInfologDelete');
1637 1635
 
1638
-		$this->tmpl->exec('infolog.infolog_ui.delete',$values,array(),$readonlys,$persist,$called_by == 'edit' ? 2 : 0);
1636
+		$this->tmpl->exec('infolog.infolog_ui.delete', $values, array(), $readonlys, $persist, $called_by == 'edit' ? 2 : 0);
1639 1637
 	}
1640 1638
 
1641 1639
 	/**
@@ -1647,77 +1645,77 @@  discard block
 block discarded – undo
1647 1645
 	 * @param string $type Type of log-entry: note,todo,task
1648 1646
 	 * @param string $referer array with param/get-vars of the refering page
1649 1647
 	 */
1650
-	function edit($content = null,$action = '',$action_id=0,$type='',$referer='')
1648
+	function edit($content = null, $action = '', $action_id = 0, $type = '', $referer = '')
1651 1649
 	{
1652 1650
 		if (($submit = is_array($content)))
1653 1651
 		{
1654 1652
 			//echo "infolog_ui::edit: content="; _debug_array($content);
1655 1653
 			$info_id   = $content['info_id'];
1656
-			$action    = $content['action'];    unset($content['action']);
1654
+			$action    = $content['action']; unset($content['action']);
1657 1655
 			$action_id = $content['action_id']; unset($content['action_id']);
1658
-			$referer   = $content['referer'];   unset($content['referer']);
1659
-			$no_popup  = $content['no_popup'];  unset($content['no_popup']);
1656
+			$referer   = $content['referer']; unset($content['referer']);
1657
+			$no_popup  = $content['no_popup']; unset($content['no_popup']);
1660 1658
 
1661 1659
 			list($button) = @each($content['button']);
1662
-			if (!$button && $action) $button = $action;	// action selectbox
1660
+			if (!$button && $action) $button = $action; // action selectbox
1663 1661
 			//info_cc expects an comma separated string
1664 1662
 			//error_log(__METHOD__.__LINE__.array2string($content));
1665 1663
 			if (empty($content['info_cc'])) $content['info_cc'] = "";
1666 1664
 			if (is_array($content['info_cc']))
1667 1665
 			{
1668
-				foreach($content['info_cc'] as $i => $value)
1666
+				foreach ($content['info_cc'] as $i => $value)
1669 1667
 				{
1670 1668
 					//imap_rfc822 should not be used, but it works reliable here, until we have some regex solution or use horde stuff
1671 1669
 					$addresses = imap_rfc822_parse_adrlist($value, '');
1672 1670
 					//error_log(__METHOD__.__LINE__.$value.'->'.array2string($addresses[0]));
1673
-					$content['info_cc'][$i]=$addresses[0]->host ? $addresses[0]->mailbox.'@'.$addresses[0]->host : $addresses[0]->mailbox;
1671
+					$content['info_cc'][$i] = $addresses[0]->host ? $addresses[0]->mailbox.'@'.$addresses[0]->host : $addresses[0]->mailbox;
1674 1672
 				}
1675
-				if (!empty($content['info_cc'])) $content['info_cc'] = implode(',',$content['info_cc']);
1673
+				if (!empty($content['info_cc'])) $content['info_cc'] = implode(',', $content['info_cc']);
1676 1674
 			}
1677 1675
 			unset($content['button']);
1678 1676
 			if ($button)
1679 1677
 			{
1680 1678
 				// Copy or schedule Infolog
1681
-				if (in_array($button,array('copy','schedule','ical','tracker')))
1679
+				if (in_array($button, array('copy', 'schedule', 'ical', 'tracker')))
1682 1680
 				{
1683 1681
 					$action = $button;
1684
-					if (!$info_id || $this->bo->check_access($info_id,Acl::EDIT))
1682
+					if (!$info_id || $this->bo->check_access($info_id, Acl::EDIT))
1685 1683
 					{
1686
-						$button = 'apply';	// need to store infolog first
1684
+						$button = 'apply'; // need to store infolog first
1687 1685
 					}
1688 1686
 				}
1689 1687
 				//Validate the enddate must be grather than startdate
1690 1688
 				if (!empty($content['info_enddate']) && !empty($content['info_startdate']))
1691 1689
 				{
1692
-					$duration_date = $content['info_enddate']-$content['info_startdate'];
1690
+					$duration_date = $content['info_enddate'] - $content['info_startdate'];
1693 1691
 					if ($duration_date < 0)
1694 1692
 					{
1695 1693
 						$this->tmpl->set_validation_error('info_startdate', lang('Startdate must be before Enddate!!!'));
1696
-						$button = $action = '';	// stop save or apply
1694
+						$button = $action = ''; // stop save or apply
1697 1695
 					}
1698 1696
 				}
1699 1697
 				//echo "<p>infolog_ui::edit(info_id=$info_id) '$button' button pressed, content="; _debug_array($content);
1700 1698
 				if (($button == 'save' || $button == 'apply') && isset($content['info_subject']) && empty($content['info_subject']))
1701 1699
 				{
1702
-					$this->tmpl->set_validation_error('info_subject',lang('Field must not be empty !!!'));
1703
-					$button = $action = '';	// stop save or apply
1700
+					$this->tmpl->set_validation_error('info_subject', lang('Field must not be empty !!!'));
1701
+					$button = $action = ''; // stop save or apply
1704 1702
 				}
1705 1703
 				if (($button == 'save' || $button == 'apply') && $info_id)
1706 1704
 				{
1707 1705
 					$old = $this->bo->read($info_id);
1708
-					if (!($edit_acl = $this->bo->check_access($info_id,Acl::EDIT)))
1706
+					if (!($edit_acl = $this->bo->check_access($info_id, Acl::EDIT)))
1709 1707
 					{
1710 1708
 						$status_only = $this->bo->is_responsible($old);
1711
-						$undelete = $this->bo->check_access($old,infolog_bo::ACL_UNDELETE);
1709
+						$undelete = $this->bo->check_access($old, infolog_bo::ACL_UNDELETE);
1712 1710
 					}
1713 1711
 				}
1714 1712
 				if (($button == 'save' || $button == 'apply') && (!$info_id || $edit_acl || $status_only || $undelete))
1715 1713
 				{
1716
-					$operation = $info_id ?  'edit' : 'add';
1714
+					$operation = $info_id ? 'edit' : 'add';
1717 1715
 					if ($content['info_contact'])
1718 1716
 					{
1719 1717
 						$old_link_id = (int)$content['info_link_id'];
1720
-						if(is_array($content['info_contact']))
1718
+						if (is_array($content['info_contact']))
1721 1719
 						{
1722 1720
 							// eTemplate2 returns the array all ready
1723 1721
 							$app = $content['info_contact']['app'];
@@ -1730,11 +1728,11 @@  discard block
 block discarded – undo
1730 1728
 						}
1731 1729
 						elseif ($app && $id)
1732 1730
 						{
1733
-							if(!is_array($content['link_to']))
1731
+							if (!is_array($content['link_to']))
1734 1732
 							{
1735 1733
 								$content['link_to'] = array();
1736 1734
 							}
1737
-							$content['info_link_id'] = (int)($info_link_id = Link::link('infolog',$content['link_to']['to_id'],$app,$id));
1735
+							$content['info_link_id'] = (int)($info_link_id = Link::link('infolog', $content['link_to']['to_id'], $app, $id));
1738 1736
 						}
1739 1737
 						else
1740 1738
 						{
@@ -1744,7 +1742,7 @@  discard block
 block discarded – undo
1744 1742
 						{
1745 1743
 							$link = Link::get_link($old_link_id);
1746 1744
 							// remove selected project, if removed link is that project
1747
-							if($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $content['old_pm_id'])
1745
+							if ($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $content['old_pm_id'])
1748 1746
 							{
1749 1747
 								unset($content['pm_id'], $content['old_pm_id']);
1750 1748
 							}
@@ -1758,39 +1756,38 @@  discard block
 block discarded – undo
1758 1756
 					}
1759 1757
 					if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
1760 1758
 					{
1761
-						$content['info_link_id'] = 0;	// as field has to be int
1759
+						$content['info_link_id'] = 0; // as field has to be int
1762 1760
 					}
1763 1761
 					$active_tab = $content['tabs'];
1764 1762
 					if (!($info_id = $this->bo->write($content, true, true, true, $content['no_notifications'])))
1765 1763
 					{
1766
-						$content['msg'] = $info_id !== 0 || !$content['info_id'] ? lang('Error: saving the entry') :
1767
-							lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1768
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1769
-								htmlspecialchars(Egw::link('/index.php',array(
1764
+						$content['msg'] = $info_id !== 0 || !$content['info_id'] ? lang('Error: saving the entry') : lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1765
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1766
+								htmlspecialchars(Egw::link('/index.php', array(
1770 1767
 									'menuaction' => 'infolog.infolog_ui.edit',
1771 1768
 									'info_id'    => $content['info_id'],
1772 1769
 									'no_popup'   => $no_popup,
1773 1770
 									'referer'    => $referer,
1774
-								))).'">','</a>');
1775
-						$button = $action = '';	// not exiting edit
1771
+								))).'">', '</a>');
1772
+						$button = $action = ''; // not exiting edit
1776 1773
 						$info_id = $content['info_id'];
1777 1774
 					}
1778 1775
 					else
1779 1776
 					{
1780
-						$GLOBALS['egw']->preferences->add('infolog','preferred_type',$content['info_type']);
1781
-						$GLOBALS['egw']->preferences->save_repository(false,'user',false);
1777
+						$GLOBALS['egw']->preferences->add('infolog', 'preferred_type', $content['info_type']);
1778
+						$GLOBALS['egw']->preferences->save_repository(false, 'user', false);
1782 1779
 						$content['msg'] = lang('InfoLog entry saved');
1783
-						Framework::refresh_opener($content['msg'],'infolog',$info_id,$operation);
1780
+						Framework::refresh_opener($content['msg'], 'infolog', $info_id, $operation);
1784 1781
 					}
1785 1782
 					$content['tabs'] = $active_tab;
1786
-					if ((int) $content['pm_id'] != (int) $content['old_pm_id'])
1783
+					if ((int)$content['pm_id'] != (int)$content['old_pm_id'])
1787 1784
 					{
1788 1785
 						//echo "<p>pm_id changed: $content[old_pm_id] -> $content[pm_id]</p>\n";
1789 1786
 						// update links accordingly, if selected project changed
1790 1787
 						if ($content['pm_id'])
1791 1788
 						{
1792 1789
 							//echo "<p>this->link->link('infolog',{$content['link_to']['to_id']},'projectmanager',{$content['pm_id']});</p>";
1793
-							Link::link('infolog',$content['link_to']['to_id'],'projectmanager',$content['pm_id']);
1790
+							Link::link('infolog', $content['link_to']['to_id'], 'projectmanager', $content['pm_id']);
1794 1791
 							// making the project the selected link, if no other link selected
1795 1792
 							if (!$info_link_id || $info_link_id == 'projectmanager:'.$content['old_pm_id'])
1796 1793
 							{
@@ -1800,7 +1797,7 @@  discard block
 block discarded – undo
1800 1797
 						if ($content['old_pm_id'])
1801 1798
 						{
1802 1799
 							//echo "<p>this->link->unlink2(0,infolog,{$content['link_to']['to_id']},0,'projectmanager',{$content['old_pm_id']});</p>\n";
1803
-							Link::unlink2(0,infolog,$content['link_to']['to_id'],0,'projectmanager',$content['old_pm_id']);
1800
+							Link::unlink2(0, infolog, $content['link_to']['to_id'], 0, 'projectmanager', $content['old_pm_id']);
1804 1801
 						}
1805 1802
 						$content['old_pm_id'] = $content['pm_id'];
1806 1803
 					}
@@ -1808,14 +1805,14 @@  discard block
 block discarded – undo
1808 1805
 					if ($info_id && is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
1809 1806
 					{
1810 1807
 						//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
1811
-						Link::link('infolog',$info_id,$content['link_to']['to_id']);
1808
+						Link::link('infolog', $info_id, $content['link_to']['to_id']);
1812 1809
 						$content['link_to']['to_id'] = $info_id;
1813 1810
 					}
1814
-					if ($info_link_id && strpos($info_link_id,':') !== false)	// updating info_link_id if necessary
1811
+					if ($info_link_id && strpos($info_link_id, ':') !== false)	// updating info_link_id if necessary
1815 1812
 					{
1816
-						list($app,$id) = explode(':',$info_link_id);
1817
-						$link = Link::get_link('infolog',$info_id,$app,$id);
1818
-						if ((int) $content['info_link_id'] != (int) $link['link_id'])
1813
+						list($app, $id) = explode(':', $info_link_id);
1814
+						$link = Link::get_link('infolog', $info_id, $app, $id);
1815
+						if ((int)$content['info_link_id'] != (int)$link['link_id'])
1819 1816
 						{
1820 1817
 							$content['info_link_id'] = $link['link_id'];
1821 1818
 
@@ -1827,9 +1824,9 @@  discard block
 block discarded – undo
1827 1824
 								'info_owner'   => $content['info_owner'],
1828 1825
 							);
1829 1826
 							//echo "<p>updating info_link_id: ".print_r($to_write,true)."</p>\n";
1830
-							$this->bo->write($to_write,False,true,true,true);	// last true = no notifications, as no real change
1827
+							$this->bo->write($to_write, False, true, true, true); // last true = no notifications, as no real change
1831 1828
 							// we need eg. the new modification date, for further updates
1832
-							$content = array_merge($content,$to_write);
1829
+							$content = array_merge($content, $to_write);
1833 1830
 						}
1834 1831
 					}
1835 1832
 				}
@@ -1840,33 +1837,33 @@  discard block
 block discarded – undo
1840 1837
 						'action' => $action,
1841 1838
 						'action_id' => $action_id
1842 1839
 					);
1843
-					if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return;	// checks ACL first
1840
+					if (!($content['msg'] = $this->delete($info_id, $referer, 'edit'))) return; // checks ACL first
1844 1841
 
1845
-					Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
1842
+					Framework::refresh_opener($content['msg'], 'infolog', $info_id, 'delete');
1846 1843
 				}
1847 1844
 				// called again after delete confirmation dialog
1848
-				elseif ($button == 'deleted'  && $content['msg'])
1845
+				elseif ($button == 'deleted' && $content['msg'])
1849 1846
 				{
1850
-					Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
1847
+					Framework::refresh_opener($content['msg'], 'infolog', $info_id, 'delete');
1851 1848
 				}
1852 1849
 				if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted')
1853 1850
 				{
1854 1851
 					if ($no_popup)
1855 1852
 					{
1856
-						Egw::redirect_link($referer,array('msg' => $content['msg']));
1853
+						Egw::redirect_link($referer, array('msg' => $content['msg']));
1857 1854
 					}
1858 1855
 					Framework::window_close();
1859 1856
 				}
1860 1857
 			}
1861 1858
 			// on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type
1862
-			if (!array_key_exists($content['info_status'],$this->bo->status[$content['info_type']]))
1859
+			if (!array_key_exists($content['info_status'], $this->bo->status[$content['info_type']]))
1863 1860
 			{
1864 1861
 				$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
1865 1862
 				// Make sure we don't end up with invalid status / percent combinations
1866 1863
 				if ($content['info_status'] != 'done')
1867 1864
 				{
1868 1865
 					$content['info_datecompleted'] = '';
1869
-					if((int)$content['info_percent'] === 100)
1866
+					if ((int)$content['info_percent'] === 100)
1870 1867
 					{
1871 1868
 						$content['info_percent'] = 10;
1872 1869
 					}
@@ -1875,7 +1872,7 @@  discard block
 block discarded – undo
1875 1872
 				{
1876 1873
 					$content['info_percent'] = 100;
1877 1874
 				}
1878
-				if($content['info_status'] != 'not-started' && (int)$content['info_percent'] == 0)
1875
+				if ($content['info_status'] != 'not-started' && (int)$content['info_percent'] == 0)
1879 1876
 				{
1880 1877
 					$content['info_percent'] = 10;
1881 1878
 				}
@@ -1884,22 +1881,21 @@  discard block
 block discarded – undo
1884 1881
 		else	// new call via GET
1885 1882
 		{
1886 1883
 			//echo "<p>infolog_ui::edit: info_id=$info_id,  action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
1887
-			$action    = $action    ? $action    : $_REQUEST['action'];
1884
+			$action    = $action ? $action : $_REQUEST['action'];
1888 1885
 			$action_id = $action_id ? $action_id : $_REQUEST['action_id'];
1889
-			$info_id   = $content   ? $content   : $_REQUEST['info_id'];
1890
-			$type      = $type      ? $type      : $_REQUEST['type'];
1891
-			$referer   = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] :
1892
-				Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
1893
-			if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer);	// remove previou/old msg from referer
1886
+			$info_id   = $content ? $content : $_REQUEST['info_id'];
1887
+			$type      = $type ? $type : $_REQUEST['type'];
1888
+			$referer   = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] : Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
1889
+			if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/', '\\1', $referer); // remove previou/old msg from referer
1894 1890
 			$no_popup  = $_GET['no_popup'];
1895
-			$print = (int) $_REQUEST['print'];
1891
+			$print = (int)$_REQUEST['print'];
1896 1892
 			//echo "<p>infolog_ui::edit: info_id=$info_id,  action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
1897 1893
 
1898
-			$content = $this->bo->read( $info_id || $action != 'sp' ? $info_id : $action_id );
1899
-			if (!(strpos($content['info_addr'],',')===false) && strpos($content['info_addr'],', ')===false) $content['info_addr'] = str_replace(',',', ',$content['info_addr']);
1900
-			foreach(array('info_subject', 'info_des') as $key)
1894
+			$content = $this->bo->read($info_id || $action != 'sp' ? $info_id : $action_id);
1895
+			if (!(strpos($content['info_addr'], ',') === false) && strpos($content['info_addr'], ', ') === false) $content['info_addr'] = str_replace(',', ', ', $content['info_addr']);
1896
+			foreach (array('info_subject', 'info_des') as $key)
1901 1897
 			{
1902
-				if(!isset($content[$key]) || strlen($content[$key]) < 75)
1898
+				if (!isset($content[$key]) || strlen($content[$key]) < 75)
1903 1899
 				{
1904 1900
 					continue;
1905 1901
 				}
@@ -1907,66 +1903,66 @@  discard block
 block discarded – undo
1907 1903
 				$clarray = array();
1908 1904
 				foreach ($contlines as &$line)
1909 1905
 				{
1910
-					if(strlen($line) < 75)
1906
+					if (strlen($line) < 75)
1911 1907
 					{
1912 1908
 						$clarray[] = $line;
1913 1909
 						continue;
1914 1910
 					}
1915 1911
 					$cont = explode(' ', $line);
1916 1912
 					$ckarray = array();
1917
-					foreach($cont as &$word)
1913
+					foreach ($cont as &$word)
1918 1914
 					{
1919 1915
 						// set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get
1920
-						if (strlen($word)>75)
1916
+						if (strlen($word) > 75)
1921 1917
 						{
1922 1918
 							$buff = Api\Html::activate_links($word);
1923 1919
 							if (strlen($buff) == strlen($word)) // no links -> try to break overlong words
1924 1920
 							{
1925
-								if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word);
1926
-								if (!(strpos($word,'.')===false) && strpos($word,'. ')===false) $word = str_replace('.','. ',$word);
1921
+								if (!(strpos($word, ',') === false) && strpos($word, ', ') === false) $word = str_replace(',', ', ', $word);
1922
+								if (!(strpos($word, '.') === false) && strpos($word, '. ') === false) $word = str_replace('.', '. ', $word);
1927 1923
 								$word = wordwrap($word, 75, ' ', true);
1928 1924
 							}
1929 1925
 						}
1930
-						$ckarray[] =$word;
1926
+						$ckarray[] = $word;
1931 1927
 					}
1932
-					$line = join(' ',$ckarray);
1928
+					$line = join(' ', $ckarray);
1933 1929
 					unset($ckarray);
1934 1930
 					$clarray[] = $line;
1935 1931
 				}
1936
-				$content[$key] = join("\n",$clarray);
1932
+				$content[$key] = join("\n", $clarray);
1937 1933
 				unset($clarray);
1938 1934
 			}
1939 1935
 			if (is_numeric($_REQUEST['cat_id']))
1940 1936
 			{
1941
-				$content['info_cat'] = (int) $_REQUEST['cat_id'];
1937
+				$content['info_cat'] = (int)$_REQUEST['cat_id'];
1942 1938
 			}
1943 1939
 			if (!$content)
1944 1940
 			{
1945 1941
 				$content['info_cat'] = $this->prefs['cat_add_default'];
1946 1942
 			}
1947
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
1943
+			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML!
1948 1944
 
1949
-			switch($this->prefs['set_start'])
1945
+			switch ($this->prefs['set_start'])
1950 1946
 			{
1951
-				case 'date': default: $set_startdate = mktime(0,0,0,date('m',$this->bo->user_time_now),date('d',$this->bo->user_time_now),date('Y',$this->bo->user_time_now)); break;
1947
+				case 'date': default: $set_startdate = mktime(0, 0, 0, date('m', $this->bo->user_time_now), date('d', $this->bo->user_time_now), date('Y', $this->bo->user_time_now)); break;
1952 1948
 				case 'datetime':      $set_startdate = $this->bo->user_time_now; break;
1953 1949
 				case 'empty':         $set_startdate = 0; break;
1954 1950
 			}
1955 1951
 			if ((int)$content['info_link_id'] > 0 && !Link::get_link($content['info_link_id']))
1956 1952
 			{
1957
-				$content['info_link_id'] = 0;	// link has been deleted
1953
+				$content['info_link_id'] = 0; // link has been deleted
1958 1954
 				if (!$content['info_custom_link']) $content['info_from'] = '';
1959 1955
 			}
1960 1956
 			if (!$info_id && $action_id && $action == 'sp')    // new SubProject
1961 1957
 			{
1962
-				if (!$this->bo->check_access($action_id,Acl::ADD))
1958
+				if (!$this->bo->check_access($action_id, Acl::ADD))
1963 1959
 				{
1964
-					return $referer ? $this->tmpl->location($referer) : $this->index(0,$action,$action_id);
1960
+					return $referer ? $this->tmpl->location($referer) : $this->index(0, $action, $action_id);
1965 1961
 				}
1966 1962
 			}
1967 1963
 			else
1968 1964
 			{
1969
-				$undelete = $this->bo->check_access($info_id,infolog_bo::ACL_UNDELETE);
1965
+				$undelete = $this->bo->check_access($info_id, infolog_bo::ACL_UNDELETE);
1970 1966
 			}
1971 1967
 			$content['links'] = $content['link_to'] = array(
1972 1968
 				'to_id' => $info_id,
@@ -1974,12 +1970,12 @@  discard block
 block discarded – undo
1974 1970
 			);
1975 1971
 		}
1976 1972
 		// new call via GET or some actions handled here, as they can happen both ways ($_GET[action] or button/action in GUI)
1977
-		if (!$submit || in_array($action,array('sp','copy','schedule','ical','to_tracker')))
1973
+		if (!$submit || in_array($action, array('sp', 'copy', 'schedule', 'ical', 'to_tracker')))
1978 1974
 		{
1979 1975
 			switch ($action)
1980 1976
 			{
1981 1977
 				case 'schedule':
1982
-					Egw::redirect_link('/index.php',array(
1978
+					Egw::redirect_link('/index.php', array(
1983 1979
 						'menuaction' => 'calendar.calendar_uiforms.edit',
1984 1980
 						'link_app' => 'infolog',
1985 1981
 						'link_id' => $info_id,
@@ -1987,7 +1983,7 @@  discard block
 block discarded – undo
1987 1983
 					break;
1988 1984
 				case 'ical':
1989 1985
 					$boical = new infolog_ical();
1990
-					$result = $boical->exportVTODO($content,'2.0','PUBLISH',false);
1986
+					$result = $boical->exportVTODO($content, '2.0', 'PUBLISH', false);
1991 1987
 					Api\Header\Content::type('todo.ics', 'text/calendar');
1992 1988
 					echo $result;
1993 1989
 					exit();
@@ -1998,23 +1994,23 @@  discard block
 block discarded – undo
1998 1994
 					if ($action == 'sp')	// for sub-entries use type or category, like for new entries
1999 1995
 					{
2000 1996
 						if ($type) $content['info_type'] = $type;
2001
-						if (is_numeric($_REQUEST['cat_id'])) $content['info_cat'] = (int) $_REQUEST['cat_id'];
1997
+						if (is_numeric($_REQUEST['cat_id'])) $content['info_cat'] = (int)$_REQUEST['cat_id'];
2002 1998
 					}
2003
-					unset($action);	// it get stored in $content and will cause an other copy after [apply]
1999
+					unset($action); // it get stored in $content and will cause an other copy after [apply]
2004 2000
 					break;
2005 2001
 				case 'to_tracker':
2006
-					Egw::redirect_link('/index.php',array(
2002
+					Egw::redirect_link('/index.php', array(
2007 2003
 						'menuaction' => 'tracker.tracker_ui.edit',
2008 2004
 						Link::get_registry('tracker', 'add_app').'[]' => 'infolog',
2009
-						Link::get_registry('tracker','add_id').'[]' => $info_id,
2005
+						Link::get_registry('tracker', 'add_id').'[]' => $info_id,
2010 2006
 					));
2011 2007
 					break;
2012 2008
 				case 'projectmanager':
2013 2009
 					$pm_links = array($action_id);
2014 2010
 				default:	// to allow other apps to participate
2015 2011
 					$content['info_subject'] = Link::title($action, $id);
2016
-					$action_ids = explode(',',$action_id);
2017
-					if(count($action_ids) == 1)
2012
+					$action_ids = explode(',', $action_id);
2013
+					if (count($action_ids) == 1)
2018 2014
 					{
2019 2015
 						$content['info_contact'] = $action.':'.$action_id;
2020 2016
 					}
@@ -2023,11 +2019,11 @@  discard block
 block discarded – undo
2023 2019
 						Link::link('infolog', $content['link_to']['to_id'], $action, $id);
2024 2020
 
2025 2021
 						// calling "infolog_set" hook for first, in case app wants to set some more values
2026
-						if (!$n && ($set = Api\Hooks::single(array('location'=>'infolog_set','id'=>$action_id),$action)))
2022
+						if (!$n && ($set = Api\Hooks::single(array('location'=>'infolog_set', 'id'=>$action_id), $action)))
2027 2023
 						{
2028
-							foreach((array)$set['link_app'] as $i => $l_app)
2024
+							foreach ((array)$set['link_app'] as $i => $l_app)
2029 2025
 							{
2030
-								if (($l_id=$set['link_id'][$i])) Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
2026
+								if (($l_id = $set['link_id'][$i])) Link::link('infolog', $content['link_to']['to_id'], $l_app, $l_id);
2031 2027
 							}
2032 2028
 							unset($set['link_app']);
2033 2029
 							unset($set['link_id']);
@@ -2041,12 +2037,12 @@  discard block
 block discarded – undo
2041 2037
 					{
2042 2038
 						if (!isset($pm_links))
2043 2039
 						{
2044
-							$pm_links = Link::get_links('infolog',$info_id,'projectmanager');
2040
+							$pm_links = Link::get_links('infolog', $info_id, 'projectmanager');
2045 2041
 						}
2046
-						break;	// normal edit
2042
+						break; // normal edit
2047 2043
 					}
2048 2044
 				case 'new':		// new entry, set some defaults, if not set by infolog_set hook
2049
-					if (empty($content['info_startdate'])) $content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
2045
+					if (empty($content['info_startdate'])) $content['info_startdate'] = (int)$_GET['startdate'] ? (int)$_GET['startdate'] : $set_startdate;
2050 2046
 					if (empty($content['info_priority'])) $content['info_priority'] = 1; // normal
2051 2047
 					$content['info_owner'] = $this->user;
2052 2048
 					if ($type != '' && empty($content['info_type']))
@@ -2071,9 +2067,9 @@  discard block
 block discarded – undo
2071 2067
 		if ($this->bo->group_owners)
2072 2068
 		{
2073 2069
 			// remove types owned by groups the user has no edit grant (current type is made readonly)
2074
-			foreach($this->bo->group_owners as $type => $group)
2070
+			foreach ($this->bo->group_owners as $type => $group)
2075 2071
 			{
2076
-				if (!($this->bo->grants[$group] & Acl::EDIT))
2072
+				if (!($this->bo->grants[$group]&Acl::EDIT))
2077 2073
 				{
2078 2074
 					if ($type == $content['info_type'])
2079 2075
 					{
@@ -2091,7 +2087,7 @@  discard block
 block discarded – undo
2091 2087
 			{
2092 2088
 				$content['info_owner'] = $this->bo->group_owners[$content['info_type']];
2093 2089
 				// Dont allow to change the type, if user has no delete rights from the group-owner
2094
-				if ($info_id && !($this->bo->grants[$content['info_owner']] & Acl::DELETE))
2090
+				if ($info_id && !($this->bo->grants[$content['info_owner']]&Acl::DELETE))
2095 2091
 				{
2096 2092
 					//echo "<p>setting type to r/o as user has no delete rights from group #$group</p>\n";
2097 2093
 					$readonlys['info_type'] = true;
@@ -2099,7 +2095,7 @@  discard block
 block discarded – undo
2099 2095
 				// disable info_access for group-owners
2100 2096
 				$readonlys['info_access'] = true;
2101 2097
 			}
2102
-			elseif($GLOBALS['egw']->accounts->get_type($content['info_owner']) == 'g')
2098
+			elseif ($GLOBALS['egw']->accounts->get_type($content['info_owner']) == 'g')
2103 2099
 			{
2104 2100
 				$content['info_owner'] = $this->user;
2105 2101
 			}
@@ -2111,18 +2107,18 @@  discard block
 block discarded – undo
2111 2107
 		unset($preserv['links']); unset($preserv['link_to']);
2112 2108
 
2113 2109
 		// for no edit rights or implizit edit of responsible user make all fields readonly, but status and percent
2114
-		if ($info_id && !$this->bo->check_access($info_id,Acl::EDIT) && !$undelete)
2110
+		if ($info_id && !$this->bo->check_access($info_id, Acl::EDIT) && !$undelete)
2115 2111
 		{
2116
-			$readonlys['__ALL__'] = true;	// make all fields not explicitly set readonly
2112
+			$readonlys['__ALL__'] = true; // make all fields not explicitly set readonly
2117 2113
 			if ($this->bo->is_responsible($content))
2118 2114
 			{
2119
-				foreach($this->bo->responsible_edit as $name)
2115
+				foreach ($this->bo->responsible_edit as $name)
2120 2116
 				{
2121 2117
 					$readonlys[$name] = false;
2122 2118
 				}
2123 2119
 				$readonlys['button[edit]'] = $readonlys['button[save]'] = $readonlys['button[apply]'] = $readonlys['no_notifications'] = false;
2124 2120
 			}
2125
-			$readonlys['action'] = $readonlys['button[cancel]'] = false;	// always allowed
2121
+			$readonlys['action'] = $readonlys['button[cancel]'] = false; // always allowed
2126 2122
 		}
2127 2123
 		elseif (!$info_id)
2128 2124
 		{
@@ -2135,16 +2131,16 @@  discard block
 block discarded – undo
2135 2131
 			$this->tmpl->setElementAttribute('button[save]', 'label', 'Un-Delete');
2136 2132
 		}
2137 2133
 
2138
-		if (!($readonlys['button[delete]'] = !$info_id || !$this->bo->check_access($info_id,Acl::DELETE)))
2134
+		if (!($readonlys['button[delete]'] = !$info_id || !$this->bo->check_access($info_id, Acl::DELETE)))
2139 2135
 		{
2140
-			$content['info_anz_subs'] = $this->bo->anzSubs($info_id);	// to determine js confirmation of delete or not
2136
+			$content['info_anz_subs'] = $this->bo->anzSubs($info_id); // to determine js confirmation of delete or not
2141 2137
 		}
2142 2138
 		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->messages[$info_id ? 'edit' : ($action == 'sp' ? 'add_sub' : 'add')]);
2143 2139
 
2144 2140
 		// use a typ-specific template (infolog.edit.xyz), if one exists, otherwise fall back to the generic one
2145 2141
 		if (!$this->tmpl->read('infolog.edit.'.$content['info_type']))
2146 2142
 		{
2147
-			$this->tmpl->read($print ? 'infolog.edit.print':'infolog.edit');
2143
+			$this->tmpl->read($print ? 'infolog.edit.print' : 'infolog.edit');
2148 2144
 		}
2149 2145
 		if ($this->bo->has_customfields($content['info_type']))
2150 2146
 		{
@@ -2156,14 +2152,14 @@  discard block
 block discarded – undo
2156 2152
 		}
2157 2153
 		if (!isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
2158 2154
 		{
2159
-			$readonlys['tabs']['project'] = true;	// disable the project tab
2155
+			$readonlys['tabs']['project'] = true; // disable the project tab
2160 2156
 		}
2161 2157
 
2162 2158
 		$content['duration_format'] = $this->duration_format;
2163 2159
 		$content['hours_per_workday'] = $this->hours_per_workday;
2164 2160
 		if ($this->prefs['show_id']) $content['info_number'] = $info_id;
2165 2161
 
2166
-		$content['info_anz_subs'] = (int)$content['info_anz_subs'];	// gives javascript error if empty!
2162
+		$content['info_anz_subs'] = (int)$content['info_anz_subs']; // gives javascript error if empty!
2167 2163
 
2168 2164
 		$old_pm_id = is_array($pm_links) ? array_shift($pm_links) : $content['old_pm_id'];
2169 2165
 		if (!isset($content['pm_id']) && $old_pm_id) $content['pm_id'] = $old_pm_id;
@@ -2181,7 +2177,7 @@  discard block
 block discarded – undo
2181 2177
 					'Pr' => $this->bo->enums['priority'],
2182 2178
 					'Ow' => 'select-account',
2183 2179
 					//'Ac',	//	info_access: private||public
2184
-					'St' => $this->bo->status[$content['info_type']]+array('deleted' => 'deleted'),
2180
+					'St' => $this->bo->status[$content['info_type']] + array('deleted' => 'deleted'),
2185 2181
 					'Pe' => 'select-percent',
2186 2182
 					'Co' => 'date-time',
2187 2183
 					'st' => 'date-time',
@@ -2198,7 +2194,7 @@  discard block
 block discarded – undo
2198 2194
 			);
2199 2195
 			$history_stati = array();
2200 2196
 			$tracking = new infolog_tracking($this);
2201
-			foreach($tracking->field2history as $field => $history)
2197
+			foreach ($tracking->field2history as $field => $history)
2202 2198
 			{
2203 2199
 				$history_stati[$history] = $tracking->field2label[$field];
2204 2200
 			}
@@ -2239,15 +2235,15 @@  discard block
 block discarded – undo
2239 2235
 		//$content['info_des'] = substr($content['info_des'],0,1793);
2240 2236
 		//echo "<p>infolog_ui.edit(info_id='$info_id',action='$action',action_id='$action_id') readonlys="; print_r($readonlys); echo ", content = "; _debug_array($content);
2241 2237
 		//$content['info_cc'] is expected (by the widget) to be an array of emailaddresses, but is stored as comma separated string
2242
-		if (!empty($content['info_cc'])&&!is_array($content['info_cc']))$content['info_cc'] = explode(',',$content['info_cc']);
2243
-		$this->tmpl->exec('infolog.infolog_ui.edit',$content,$sel_options,$readonlys,$preserv+array(	// preserved values
2238
+		if (!empty($content['info_cc']) && !is_array($content['info_cc']))$content['info_cc'] = explode(',', $content['info_cc']);
2239
+		$this->tmpl->exec('infolog.infolog_ui.edit', $content, $sel_options, $readonlys, $preserv + array(	// preserved values
2244 2240
 			'info_id'       => $info_id,
2245 2241
 			'action'        => $action,
2246 2242
 			'action_id'     => $action_id,
2247 2243
 			'referer'       => $referer,
2248 2244
 			'no_popup'      => $no_popup,
2249 2245
 			'old_pm_id'     => $old_pm_id,
2250
-		),$no_popup ? 0 : 2);
2246
+		), $no_popup ? 0 : 2);
2251 2247
 	}
2252 2248
 
2253 2249
 	/**
@@ -2258,16 +2254,16 @@  discard block
 block discarded – undo
2258 2254
 	 * @param array &$content
2259 2255
 	 * @param boolean $create_sub true: create a sub-entry instead of a copy, default false to create a copy
2260 2256
 	 */
2261
-	private function create_copy(array &$content, $create_sub=false)
2257
+	private function create_copy(array &$content, $create_sub = false)
2262 2258
 	{
2263
-		$info_id = $content['info_id'];	// it will be unset by exclude-fields
2259
+		$info_id = $content['info_id']; // it will be unset by exclude-fields
2264 2260
 
2265 2261
 		// empty fields configured to be excluded (also contains id, uid, ...)
2266 2262
 		$exclude_fields = $create_sub ? $this->bo->sub_excludefields : $this->bo->copy_excludefields;
2267 2263
 		foreach ($exclude_fields as $field)
2268 2264
 		{
2269 2265
 			unset($content[$field]);
2270
-			if ($field == 'info_from') unset($content['info_link_id']);	// both together is called contact in UI
2266
+			if ($field == 'info_from') unset($content['info_link_id']); // both together is called contact in UI
2271 2267
 		}
2272 2268
 		if ($create_sub)
2273 2269
 		{
@@ -2276,9 +2272,9 @@  discard block
 block discarded – undo
2276 2272
 		// no startdate or startdate in the past --> set startdate from pref
2277 2273
 		if (!isset($content['info_startdate']) || $content['info_startdate'] < $this->bo->user_time_now)
2278 2274
 		{
2279
-			switch($this->prefs['set_start'])
2275
+			switch ($this->prefs['set_start'])
2280 2276
 			{
2281
-				case 'date': default: $set_startdate = mktime(0,0,0,date('m',$this->bo->user_time_now),date('d',$this->bo->user_time_now),date('Y',$this->bo->user_time_now)); break;
2277
+				case 'date': default: $set_startdate = mktime(0, 0, 0, date('m', $this->bo->user_time_now), date('d', $this->bo->user_time_now), date('Y', $this->bo->user_time_now)); break;
2282 2278
 				case 'datetime':      $set_startdate = $this->bo->user_time_now; break;
2283 2279
 				case 'empty':         $set_startdate = 0; break;
2284 2280
 			}
@@ -2297,17 +2293,17 @@  discard block
 block discarded – undo
2297 2293
 		// get a consistent status, percent and date-completed
2298 2294
 		if (!isset($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2299 2295
 		if (!isset($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2300
-		$content['info_datecompleted'] =$content['info_status'] == 'done' ? $this->bo->user_time_now : 0;
2296
+		$content['info_datecompleted'] = $content['info_status'] == 'done' ? $this->bo->user_time_now : 0;
2301 2297
 
2302 2298
 		if (!isset($content['info_cat'])) $content['info_cat'] = $this->prefs['cat_add_default'];
2303 2299
 
2304
-		if(!is_array($content['link_to'])) $content['link_to'] = array();
2300
+		if (!is_array($content['link_to'])) $content['link_to'] = array();
2305 2301
 		$content['link_to']['to_app'] = 'infolog';
2306 2302
 		$content['link_to']['to_id'] = 0;
2307 2303
 		// Get links to be copied, if not excluded
2308
-		if (!in_array('link_to',$exclude_fields) || !in_array('attachments',$exclude_fields))
2304
+		if (!in_array('link_to', $exclude_fields) || !in_array('attachments', $exclude_fields))
2309 2305
 		{
2310
-			foreach(Link::get_links($content['link_to']['to_app'], $info_id) as $link)
2306
+			foreach (Link::get_links($content['link_to']['to_app'], $info_id) as $link)
2311 2307
 			{
2312 2308
 				if ($link['app'] != Link::VFS_APPNAME && !in_array('link_to', $exclude_fields))
2313 2309
 				{
@@ -2331,19 +2327,19 @@  discard block
 block discarded – undo
2331 2327
 			if (!isset($content['info_contact']) || empty($content['info_contact']) || $content['info_contact'] === 'copy:')
2332 2328
 			{
2333 2329
 				$linkinfos = Link::get_link($info_link_id);
2334
-				$content['info_contact'] = $linkinfos['link_app1']=='infolog'? $linkinfos['link_app2'].':'.$linkinfos['link_id2']:$linkinfos['link_app1'].':'.$linkinfos['link_id1'];
2335
-				if (stripos($content['info_contact'],'projectmanager')!==false) $content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
2330
+				$content['info_contact'] = $linkinfos['link_app1'] == 'infolog' ? $linkinfos['link_app2'].':'.$linkinfos['link_id2'] : $linkinfos['link_app1'].':'.$linkinfos['link_id1'];
2331
+				if (stripos($content['info_contact'], 'projectmanager') !== false) $content['pm_id'] = $linkinfos['link_app1'] == 'projectmanager' ? $linkinfos['link_id1'] : $linkinfos['link_id2'];
2336 2332
 			}
2337 2333
 			unset($content['info_link_id']);
2338 2334
 		}
2339
-		$content['info_owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
2335
+		$content['info_owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD, 0, $this->owner) ? $this->user : $this->owner;
2340 2336
 
2341 2337
 		if (!empty($content['info_subject']))
2342 2338
 		{
2343 2339
 			if ($create_sub)
2344 2340
 			{
2345 2341
 				$config = Api\Config::read('infolog');
2346
-				$prefix = lang(empty($config['sub_prefix']) ? 'Re:': $config['sub_prefix']);
2342
+				$prefix = lang(empty($config['sub_prefix']) ? 'Re:' : $config['sub_prefix']);
2347 2343
 			}
2348 2344
 			else
2349 2345
 			{
@@ -2353,11 +2349,11 @@  discard block
 block discarded – undo
2353 2349
 		}
2354 2350
 		if (!$create_sub)
2355 2351
 		{
2356
-			$content['msg'] .= ($content['msg']?"\n":'').lang('Infolog copied - the copy can now be edited');
2352
+			$content['msg'] .= ($content['msg'] ? "\n" : '').lang('Infolog copied - the copy can now be edited');
2357 2353
 		}
2358 2354
 	}
2359 2355
 
2360
-	function icon($cat,$id,$status='')
2356
+	function icon($cat, $id, $status = '')
2361 2357
 	{
2362 2358
 		if (!$status || !($icon = $this->icons[$cat][$id.'_'.$status]))
2363 2359
 		{
@@ -2374,7 +2370,7 @@  discard block
 block discarded – undo
2374 2370
 				$alt = $id;
2375 2371
 			}
2376 2372
 		}
2377
-		return $icon ? Api\Html::image('infolog',$icon,lang($alt),'border=0') : lang($alt);
2373
+		return $icon ? Api\Html::image('infolog', $icon, lang($alt), 'border=0') : lang($alt);
2378 2374
 	}
2379 2375
 
2380 2376
 	/**
@@ -2424,27 +2420,27 @@  discard block
 block discarded – undo
2424 2420
 			'info_cc' => 'CC',
2425 2421
 		);
2426 2422
 		// add customfields to field list
2427
-		foreach(Api\Storage\Customfields::get('infolog') as $name => $data)
2423
+		foreach (Api\Storage\Customfields::get('infolog') as $name => $data)
2428 2424
 		{
2429 2425
 			$excludefields['#'.$name] = $data['label'];
2430 2426
 		}
2431 2427
 		$sub_excludefields = $excludefields;
2432
-		unset($sub_excludefields['info_id_parent']);	// always set to parent!
2428
+		unset($sub_excludefields['info_id_parent']); // always set to parent!
2433 2429
 
2434 2430
 		$config = Api\Config::read('infolog');
2435 2431
 
2436
-		if($content)
2432
+		if ($content)
2437 2433
 		{
2438 2434
 			// Save
2439 2435
 			$button = key($content['button']);
2440
-			if($button == 'save' || $button == 'apply')
2436
+			if ($button == 'save' || $button == 'apply')
2441 2437
 			{
2442
-				$this->bo->responsible_edit = array('info_status','info_percent','info_datecompleted');
2438
+				$this->bo->responsible_edit = array('info_status', 'info_percent', 'info_datecompleted');
2443 2439
 
2444 2440
 				if ($content['responsible_edit'])
2445 2441
 				{
2446
-					$extra = array_intersect($content['responsible_edit'],array_keys($fields));
2447
-					$this->bo->responsible_edit = array_unique(array_merge($this->bo->responsible_edit,$extra));
2442
+					$extra = array_intersect($content['responsible_edit'], array_keys($fields));
2443
+					$this->bo->responsible_edit = array_unique(array_merge($this->bo->responsible_edit, $extra));
2448 2444
 				}
2449 2445
 				Api\Config::save_value('copy_excludefields', $content['copy_excludefields'] ? $content['copy_excludefields'] : null, 'infolog');
2450 2446
 				Api\Config::save_value('sub_excludefields', $content['sub_excludefields'] ? $content['sub_excludefields'] : array('*NONE*'), 'infolog');
@@ -2455,12 +2451,12 @@  discard block
 block discarded – undo
2455 2451
 				Api\Config::save_value('sub_prefix', $content['sub_prefix'], 'infolog');
2456 2452
 
2457 2453
 				// Notifications
2458
-				$notifications =& $config[infolog_tracking::CUSTOM_NOTIFICATION];
2454
+				$notifications = & $config[infolog_tracking::CUSTOM_NOTIFICATION];
2459 2455
 				$notifications[$content['notification_type']] = $content['notification'];
2460
-				Api\Config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications,'infolog');
2456
+				Api\Config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications, 'infolog');
2461 2457
 			}
2462 2458
 
2463
-			if($button == 'save' || $button == 'cancel')
2459
+			if ($button == 'save' || $button == 'cancel')
2464 2460
 			{
2465 2461
 				Egw::redirect_link('/index.php', array(
2466 2462
 					'menuaction' => 'admin.admin_ui.index',
@@ -2483,7 +2479,7 @@  discard block
 block discarded – undo
2483 2479
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('InfoLog').' - '.lang('Site configuration');
2484 2480
 
2485 2481
 		// Load selected custom notification
2486
-		if(!$content['notification_type'])
2482
+		if (!$content['notification_type'])
2487 2483
 		{
2488 2484
 			$content['notification_type'] = '~global~';
2489 2485
 		}
@@ -2507,7 +2503,7 @@  discard block
 block discarded – undo
2507 2503
 		);
2508 2504
 		$preserve['notification_old_type'] = $content['notification_type'];
2509 2505
 		$this->tmpl->read('infolog.config');
2510
-		$this->tmpl->exec('infolog.infolog_ui.admin',$content,$sel_options,array(),$preserve);
2506
+		$this->tmpl->exec('infolog.infolog_ui.admin', $content, $sel_options, array(), $preserve);
2511 2507
 	}
2512 2508
 
2513 2509
 	/**
@@ -2516,13 +2512,13 @@  discard block
 block discarded – undo
2516 2512
 	 * @param array $mailContent = null content of mail
2517 2513
 	 * @return  array
2518 2514
 	 */
2519
-	function mail_import(array $mailContent=null)
2515
+	function mail_import(array $mailContent = null)
2520 2516
 	{
2521 2517
 		// It would get called from compose as a popup with egw_data
2522 2518
 		if (!is_array($mailContent) && ($_GET['egw_data']))
2523 2519
 		{
2524 2520
 			// get the mail raw data
2525
-			Link::get_data ($_GET['egw_data']);
2521
+			Link::get_data($_GET['egw_data']);
2526 2522
 			return false;
2527 2523
 		}
2528 2524
 
@@ -2553,7 +2549,7 @@  discard block
 block discarded – undo
2553 2549
 	function hook_view($args)
2554 2550
 	{
2555 2551
 		// Load JS for infolog actions
2556
-		Framework::includeJS('.','app','infolog');
2552
+		Framework::includeJS('.', 'app', 'infolog');
2557 2553
 
2558 2554
 		switch ($args['location'])
2559 2555
 		{
@@ -2581,7 +2577,7 @@  discard block
 block discarded – undo
2581 2577
 		{
2582 2578
 			return False;
2583 2579
 		}
2584
-		$this->called_by = $app;	// for read/save_sessiondata, to have different sessions for the hooks
2580
+		$this->called_by = $app; // for read/save_sessiondata, to have different sessions for the hooks
2585 2581
 
2586 2582
 		// Set to calling app, so actions wind up in the correct place client side
2587 2583
 		$GLOBALS['egw_info']['flags']['currentapp'] = $app;
@@ -2589,11 +2585,11 @@  discard block
 block discarded – undo
2589 2585
 		Api\Translation::add_app('infolog');
2590 2586
 
2591 2587
 		// Still want infolog Api\Categories though
2592
-		$GLOBALS['egw']->categories = new Api\Categories('','infolog');
2593
-		$this->index(null,$app,$args[$view_id],array(
2588
+		$GLOBALS['egw']->categories = new Api\Categories('', 'infolog');
2589
+		$this->index(null, $app, $args[$view_id], array(
2594 2590
 			'menuaction' => $view,
2595 2591
 			isset($view_id2) ? $view_id2 : $view_id => $args[$view_id]
2596
-		),True);
2592
+		), True);
2597 2593
 	}
2598 2594
 
2599 2595
 	/**
@@ -2602,26 +2598,26 @@  discard block
 block discarded – undo
2602 2598
 	 * @param string $type infolog type to include only the matching custom fields if set
2603 2599
 	 * @return array
2604 2600
 	 */
2605
-	function csv_export_fields($type=null)
2601
+	function csv_export_fields($type = null)
2606 2602
 	{
2607 2603
 		$fields = array(
2608 2604
 			'info_type'          => lang('Type'),
2609 2605
 			'info_from'          => lang('Contact'),
2610 2606
 			'info_addr'          => lang('Phone/Email'),
2611 2607
 //			'info_link_id'       => lang('primary link'),
2612
-			'info_cat'           => array('label' => lang('Category'),'type' => 'select-cat'),
2608
+			'info_cat'           => array('label' => lang('Category'), 'type' => 'select-cat'),
2613 2609
 			'info_priority'      => lang('Priority'),
2614
-			'info_owner'         => array('label' => lang('Owner'),'type' => 'select-account'),
2610
+			'info_owner'         => array('label' => lang('Owner'), 'type' => 'select-account'),
2615 2611
 			'info_access'        => lang('Access'),
2616 2612
 			'info_status'        => lang('Status'),
2617 2613
 			'info_percent'       => lang('Completed'),
2618 2614
 			'info_datecompleted' => lang('Date completed'),
2619 2615
 			'info_datemodified'  => lang('Last modified'),
2620
-			'info_modifier'      => array('label' => lang('Modifier'),'type' => 'select-account'),
2616
+			'info_modifier'      => array('label' => lang('Modifier'), 'type' => 'select-account'),
2621 2617
 			'info_location'      => lang('Location'),
2622 2618
 			'info_startdate'     => lang('Startdate'),
2623 2619
 			'info_enddate'       => lang('Enddate'),
2624
-			'info_responsible'   => array('label' => lang('Responsible'),'type' => 'select-account'),
2620
+			'info_responsible'   => array('label' => lang('Responsible'), 'type' => 'select-account'),
2625 2621
 			'info_subject'       => lang('Subject'),
2626 2622
 			'info_des'           => lang('Description'),
2627 2623
 			'info_id'            => lang('Id'),
@@ -2631,13 +2627,13 @@  discard block
 block discarded – undo
2631 2627
 			'pl_id'              => lang('pricelist'),
2632 2628
 			'info_price'         => lang('price'),
2633 2629
 		);
2634
-		foreach($this->bo->timestamps as $name)
2630
+		foreach ($this->bo->timestamps as $name)
2635 2631
 		{
2636
-			$fields[$name] = array('label' => $fields[$name],'type' => 'date-time');
2632
+			$fields[$name] = array('label' => $fields[$name], 'type' => 'date-time');
2637 2633
 		}
2638
-		foreach($this->bo->customfields as $name => $data)
2634
+		foreach ($this->bo->customfields as $name => $data)
2639 2635
 		{
2640
-			if ($data['type2'] && $type && !in_array($type,explode(',',$data['type2']))) continue;
2636
+			if ($data['type2'] && $type && !in_array($type, explode(',', $data['type2']))) continue;
2641 2637
 
2642 2638
 			$fields['#'.$name] = array(
2643 2639
 				'label' => $data['label'],
Please login to merge, or discard this patch.
Braces   +284 added lines, -71 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	function __construct()
99 99
 	{
100
-		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog');
100
+		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog')
101
+		{
102
+			Api\Translation::add_app('infolog');
103
+		}
101 104
 
102 105
 		// Make sure Global category is infolog - on first load, it may not be
103 106
 		if($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
@@ -165,13 +168,19 @@  discard block
 block discarded – undo
165 168
 		$done = $info['info_status'] == 'done' || $info['info_status'] == 'billed' || $info['info_status'] == 'cancelled'; //cancelled is regarded as a completed status as well in bo
166 169
 		// regard an infolog as done/billed/cancelled if its percentage is 100% when there is to status like the above for that type
167 170
 		if (!$done && !isset($this->bo->status[$info['info_type']]['done']) && !isset($this->bo->status[$info['info_type']]['billed']) &&
168
-			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent']==100) $done = true ;
171
+			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent']==100)
172
+		{
173
+			$done = true ;
174
+		}
169 175
 		$info['sub_class'] = $this->bo->enums['priority'][$info['info_priority']] . ($done ? '_done' : '');
170 176
 		if (!$done && $info['info_enddate'] < $this->bo->user_time_now)
171 177
 		{
172 178
 			$info['end_class'] = 'infolog_overdue';
173 179
 		}
174
-		if (!isset($info['info_anz_subs'])) $info['info_anz_subs'] = $this->bo->anzSubs($id);
180
+		if (!isset($info['info_anz_subs']))
181
+		{
182
+			$info['info_anz_subs'] = $this->bo->anzSubs($id);
183
+		}
175 184
 		$this->bo->link_id2from($info,$action,$action_id);	// unset from for $action:$action_id
176 185
 		$info['info_percent'] = (int) $info['info_percent'].'%';
177 186
 		$editrights = $this->bo->check_access($info,Acl::EDIT);
@@ -204,12 +213,21 @@  discard block
 block discarded – undo
204 213
 		{
205 214
 			$info['class'] .= 'rowNoSubs ';
206 215
 		}
207
-		if ($info['info_id_parent']) $info['class'] .= 'infolog_rowHasParent ';
208
-		if ($info['info_anz_subs'] > 0) $info['class'] .= 'infolog_rowHasSubs ';
216
+		if ($info['info_id_parent'])
217
+		{
218
+			$info['class'] .= 'infolog_rowHasParent ';
219
+		}
220
+		if ($info['info_anz_subs'] > 0)
221
+		{
222
+			$info['class'] .= 'infolog_rowHasSubs ';
223
+		}
209 224
 
210 225
 		$info['row_mod'] = $info['info_datemodified'];
211 226
 
212
-		if (!$show_links) $show_links = $this->prefs['show_links'];
227
+		if (!$show_links)
228
+		{
229
+			$show_links = $this->prefs['show_links'];
230
+		}
213 231
 		if (($show_links != 'none' && $show_links != 'no_describtion' ||
214 232
 			 $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
215 233
 			(isset($info['links']) || ($info['links'] = Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true))))
@@ -219,9 +237,16 @@  discard block
 block discarded – undo
219 237
 			{
220 238
 				// incl. link modification time into row_mod (link's lastmod is always in server-time!)
221 239
 				$link_mod = Api\DateTime::server2user($link['lastmod']);
222
-				if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod;
240
+				if ($info['row_mod'] < $link_mod)
241
+				{
242
+					$info['row_mod'] = $link_mod;
243
+				}
223 244
 
224
-				if ($link['deleted']) continue;	// skip deleted links, but incl. them in row_mod!
245
+				if ($link['deleted'])
246
+				{
247
+					continue;
248
+				}
249
+				// skip deleted links, but incl. them in row_mod!
225 250
 
226 251
 				if ($show_links != 'none' && $show_links != 'no_describtion' &&
227 252
 					$link['link_id'] != $info['info_link_id'] &&
@@ -234,14 +259,20 @@  discard block
 block discarded – undo
234 259
 				{
235 260
 					$info['pm_id'] = $link['id'];
236 261
 				}
237
-				if ($link['app'] == 'timesheet') $timesheets[] = $link['id'];
262
+				if ($link['app'] == 'timesheet')
263
+				{
264
+					$timesheets[] = $link['id'];
265
+				}
238 266
 			}
239 267
 			if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets)
240 268
 			{
241 269
 				$sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets);
242 270
 				$info['info_sum_timesheets'] = $sum['duration'];
243 271
 				// incl. max timesheet modification in row_mod
244
-				if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified'];
272
+				if ($info['row_mod'] < $sum['max_modified'])
273
+				{
274
+					$info['row_mod'] = $sum['max_modified'];
275
+				}
245 276
 			}
246 277
 		}
247 278
 		$info['info_type_label'] = $this->bo->enums['type'][$info['info_type']];
@@ -256,10 +287,13 @@  discard block
 block discarded – undo
256 287
 			}
257 288
 			$readonlys["edit_percent[$id]"] = true;
258 289
 		}
259
-		elseif($readonlys["edit_percent[$id]"])	// show percent, but button is switched off
290
+		elseif($readonlys["edit_percent[$id]"])
291
+		{
292
+			// show percent, but button is switched off
260 293
 		{
261 294
 			$info['info_percent2'] = $info['info_percent'];
262 295
 		}
296
+		}
263 297
 		if ($this->prefs['show_id'] == 1 || $this->prefs['show_id'] == 2 && $details)
264 298
 		{
265 299
 			$info['info_number'] = $info['info_id'];
@@ -332,10 +366,16 @@  discard block
 block discarded – undo
332 366
 			$query['col_filter'] = array('info_id_parent' => $query['col_filter']['info_id_parent']);
333 367
 		}
334 368
 		$orginal_colfilter = $query['col_filter'];
335
-		if (isset($parent_id)) $query['col_filter']['info_id_parent'] = (string)$parent_id;
369
+		if (isset($parent_id))
370
+		{
371
+			$query['col_filter']['info_id_parent'] = (string)$parent_id;
372
+		}
336 373
 
337 374
 		//echo "<p>infolog_ui.get_rows(start=$query[start],search='$query[search]',filter='$query[filter]',cat_id=$query[cat_id],action='$query[action]/$query[action_id]',col_filter=".print_r($query['col_filter'],True).",sort=$query[sort],order=$query[order])</p>\n";
338
-		if (!isset($query['start'])) $query['start'] = 0;
375
+		if (!isset($query['start']))
376
+		{
377
+			$query['start'] = 0;
378
+		}
339 379
 
340 380
 		// handle action and linked filter (show only entries linked to a certain other entry)
341 381
 		$link_filters = array();
@@ -364,7 +404,10 @@  discard block
 block discarded – undo
364 404
 				$app = $link['app'];
365 405
 				$id = $link['id'];
366 406
 			}
367
-			if(!is_array($id)) $id = explode(',',$id);
407
+			if(!is_array($id))
408
+			{
409
+				$id = explode(',',$id);
410
+			}
368 411
 			if (!($linked = Link::get_links_multiple($app,$id,true,'infolog','',$query['col_filter']['info_status'] == 'deleted')))
369 412
 			{
370 413
 				$rows = array();	// no infologs linked to selected link --> no rows to return
@@ -413,7 +456,10 @@  discard block
 block discarded – undo
413 456
 			}
414 457
 		}
415 458
 		// Framework\Template change forces the UI to do a full update first, no point in getting rows right now
416
-		if($old_template && $old_template != $query['template']) return 0;
459
+		if($old_template && $old_template != $query['template'])
460
+		{
461
+			return 0;
462
+		}
417 463
 
418 464
 		// do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific
419 465
 		// so we have to check that as well
@@ -474,12 +520,18 @@  discard block
 block discarded – undo
474 520
 		$parent_first = count($parents) == 1;
475 521
 		$parent_index = 0;
476 522
 		// et2 nextmatch listens to total, and only displays that many rows, so add parent in or we'll lose the last row
477
-		if($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++;
523
+		if($parent_first || $query['action'] == 'sp' && is_array($query['action_id']))
524
+		{
525
+			$query['total']++;
526
+		}
478 527
 
479 528
 		// Check to see if we need to remove description
480 529
 		foreach($infos as $id => $info)
481 530
 		{
482
-			if (!(strpos($info['info_addr'],',')===false) && strpos($info['info_addr'],', ')===false) $info['info_addr'] = str_replace(',',', ',$info['info_addr']);
531
+			if (!(strpos($info['info_addr'],',')===false) && strpos($info['info_addr'],', ')===false)
532
+			{
533
+				$info['info_addr'] = str_replace(',',', ',$info['info_addr']);
534
+			}
483 535
 			if (!$query['csv_export'] || !is_array($query['csv_export']))
484 536
 			{
485 537
 				$info['links'] =& $links[$id];
@@ -503,7 +555,10 @@  discard block
 block discarded – undo
503 555
 						{
504 556
 							foreach(array_keys($main) as $n)
505 557
 							{
506
-								if ($n[0] == '#' && !in_array($n, $columselection)) unset($main[$n]);
558
+								if ($n[0] == '#' && !in_array($n, $columselection))
559
+								{
560
+									unset($main[$n]);
561
+								}
507 562
 							}
508 563
 							break;
509 564
 						}
@@ -520,8 +575,14 @@  discard block
 block discarded – undo
520 575
 		}
521 576
 		unset($links);
522 577
 
523
-		if ($query['cat_id']) $rows['no_cat_id'] = true;
524
-		if ($query['no_actions']) $rows['no_actions'] = true;
578
+		if ($query['cat_id'])
579
+		{
580
+			$rows['no_cat_id'] = true;
581
+		}
582
+		if ($query['no_actions'])
583
+		{
584
+			$rows['no_actions'] = true;
585
+		}
525 586
 		$rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']);
526 587
 		if($clear_status_filter)
527 588
 		{
@@ -565,7 +626,11 @@  discard block
 block discarded – undo
565 626
 			$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $headers);
566 627
 		}
567 628
 
568
-		if (isset($linked)) $query['col_filter']['linked'] = $linked;  // add linked back to the colfilter
629
+		if (isset($linked))
630
+		{
631
+			$query['col_filter']['linked'] = $linked;
632
+		}
633
+		// add linked back to the colfilter
569 634
 
570 635
 		return $query['total'];
571 636
 	}
@@ -582,7 +647,10 @@  discard block
 block discarded – undo
582 647
 		$set = array();
583 648
 		if ((int)$data['id'] && ($info = $this->bo->read($data['id'])))
584 649
 		{
585
-			if ($info['info_cat']) $set['cat_id'] = $info['info_cat'];
650
+			if ($info['info_cat'])
651
+			{
652
+				$set['cat_id'] = $info['info_cat'];
653
+			}
586 654
 
587 655
 			foreach(Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link)
588 656
 			{
@@ -620,7 +688,10 @@  discard block
 block discarded – undo
620 688
 			'end'		=> $infolog['info_enddate'] ? $infolog['info_enddate'] : $infolog['info_datecompleted']
621 689
 		));
622 690
 		unset($event['entry_id']);
623
-		if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
691
+		if (!$event['end'])
692
+		{
693
+			$event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
694
+		}
624 695
 
625 696
 		// Match Api\Categories by name
626 697
 		$event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat']));
@@ -679,7 +750,10 @@  discard block
 block discarded – undo
679 750
 		// Copy same custom fields
680 751
 		foreach(array_keys(Api\Storage\Customfields::get('calendar')) as $name)
681 752
 		{
682
-			if ($this->bo->customfields[$name]) $event['#'.$name] = $infolog['#'.$name];
753
+			if ($this->bo->customfields[$name])
754
+			{
755
+				$event['#'.$name] = $infolog['#'.$name];
756
+			}
683 757
 		}
684 758
 		//error_log(__METHOD__.'('.array2string($data).') infolog='.array2string($infolog).' returning '.array2string($event));
685 759
 		return $event;
@@ -829,13 +903,19 @@  discard block
 block discarded – undo
829 903
 				$values['nm']['sort'] = 'DESC';
830 904
 			}
831 905
 
832
-			if (!$values['nm']['session_for'] && $this->called_by) $values['nm']['session_for'] = $this->called_by;
906
+			if (!$values['nm']['session_for'] && $this->called_by)
907
+			{
908
+				$values['nm']['session_for'] = $this->called_by;
909
+			}
833 910
 
834 911
 			$action_id = $values['action_id'] = $action ? $action_id : $nm['action_id'];
835 912
 			$action_title = $values['action_title'] = $action ? $action_title : $nm['action_title'];
836 913
 			$action = $values['action'] = $action ? $action : $nm['action'];
837 914
 		}
838
-		if($_GET['search']) $values['nm']['search'] = $_GET['search'];
915
+		if($_GET['search'])
916
+		{
917
+			$values['nm']['search'] = $_GET['search'];
918
+		}
839 919
 
840 920
 		if ($values['nm']['add'])
841 921
 		{
@@ -885,7 +965,10 @@  discard block
 block discarded – undo
885 965
 		switch ($action)
886 966
 		{
887 967
 			case 'sp':
888
-				if (!is_array($action_id) && strpos($action_id, 'infolog:') === 0) $action_id = (int)substr($action_id, 8);
968
+				if (!is_array($action_id) && strpos($action_id, 'infolog:') === 0)
969
+				{
970
+					$action_id = (int)substr($action_id, 8);
971
+				}
889 972
 				if ((is_array($action_id) && !$this->bo->read(current($action_id))) || !$this->bo->read($action_id))
890 973
 				{
891 974
 					$action = '';
@@ -932,7 +1015,10 @@  discard block
 block discarded – undo
932 1015
 		// Allow add actions even when there's no rows
933 1016
 		$values['nm']['placeholder_actions'] = array('new');
934 1017
 
935
-		if(!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
1018
+		if(!isset($values['nm']['filter2']))
1019
+		{
1020
+			$values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
1021
+		}
936 1022
 
937 1023
 		// disable columns for main entry as set in the pref for details or no details
938 1024
 		$values['nm']['columnselection_pref'] = 'nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows')
@@ -957,7 +1043,10 @@  discard block
 block discarded – undo
957 1043
 		{
958 1044
 			foreach (array_keys($values['nm']['col_filter']) as $colfk)
959 1045
 			{
960
-				if (is_int($colfk)) unset($values['nm']['col_filter']);
1046
+				if (is_int($colfk))
1047
+				{
1048
+					unset($values['nm']['col_filter']);
1049
+				}
961 1050
 			}
962 1051
 		}
963 1052
 		$values['action'] = $persist['action'] = $values['nm']['action'] = $action;
@@ -1000,7 +1089,10 @@  discard block
 block discarded – undo
1000 1089
 		// does not take implicit rights as delegated into account, so they will not be available as filters
1001 1090
 		foreach($this->bo->group_owners as $type => $group)
1002 1091
 		{
1003
-			if (!isset($this->bo->grants[$group])) unset($sel_options['info_type'][$type]);
1092
+			if (!isset($this->bo->grants[$group]))
1093
+			{
1094
+				unset($sel_options['info_type'][$type]);
1095
+			}
1004 1096
 		}
1005 1097
 
1006 1098
 
@@ -1356,7 +1448,10 @@  discard block
 block discarded – undo
1356 1448
 				return $failed == 0;
1357 1449
 
1358 1450
 			case 'document':
1359
-				if (!$settings) $settings = $this->prefs['default_document'];
1451
+				if (!$settings)
1452
+				{
1453
+					$settings = $this->prefs['default_document'];
1454
+				}
1360 1455
 				$document_merge = new infolog_merge();
1361 1456
 				$msg = $document_merge->download($settings, $checked, '', $this->prefs['document_dir']);
1362 1457
 				$failed = count($checked);
@@ -1542,11 +1637,16 @@  discard block
 block discarded – undo
1542 1637
 			#_debug_array($info);
1543 1638
 			$status = $info['info_status'];
1544 1639
 			// closed stati assumed array('done','billed','cancelled')
1545
-			if (isset($this->bo->status[$info['info_type']]['done'])) {
1640
+			if (isset($this->bo->status[$info['info_type']]['done']))
1641
+			{
1546 1642
 				$status ='done';
1547
-			} elseif (isset($this->bo->status[$info['info_type']]['billed'])) {
1643
+			}
1644
+			elseif (isset($this->bo->status[$info['info_type']]['billed']))
1645
+			{
1548 1646
 				$status ='billed';
1549
-			} elseif (isset($this->bo->status[$info['info_type']]['cancelled'])) {
1647
+			}
1648
+			elseif (isset($this->bo->status[$info['info_type']]['cancelled']))
1649
+			{
1550 1650
 				$status ='cancelled';
1551 1651
 			}
1552 1652
 			#_debug_array($status);
@@ -1560,17 +1660,25 @@  discard block
 block discarded – undo
1560 1660
 			$this->bo->write($values, true,true,true,$skip_notification);
1561 1661
 
1562 1662
 			$query = array('action'=>'sp','action_id'=>$info_id);
1563
-			if (!$closesingle) {
1663
+			if (!$closesingle)
1664
+			{
1564 1665
 				foreach((array)$this->bo->search($query) as $info)
1565 1666
 				{
1566
-					if ($info['info_id_parent'] == $info_id)	// search also returns linked entries!
1667
+					if ($info['info_id_parent'] == $info_id)
1668
+					{
1669
+						// search also returns linked entries!
1567 1670
 					{
1568
-						$this->close($info['info_id'],$referer,$closesingle,$skip_notification);	// we call ourselfs recursive to process subs from subs too
1671
+						$this->close($info['info_id'],$referer,$closesingle,$skip_notification);
1672
+					}
1673
+					// we call ourselfs recursive to process subs from subs too
1569 1674
 					}
1570 1675
 				}
1571 1676
 			}
1572 1677
 		}
1573
-		if ($referer) $this->tmpl->location($referer);
1678
+		if ($referer)
1679
+		{
1680
+			$this->tmpl->location($referer);
1681
+		}
1574 1682
 	}
1575 1683
 
1576 1684
 	/**
@@ -1586,10 +1694,13 @@  discard block
 block discarded – undo
1586 1694
 		$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1587 1695
 		$referer = is_array($values) ? $values['referer'] : $_referer;
1588 1696
 
1589
-		if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id))	// entries without subs get confirmed by javascript
1697
+		if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id))
1698
+		{
1699
+			// entries without subs get confirmed by javascript
1590 1700
 		{
1591 1701
 			$values = array('delete' => true);
1592 1702
 		}
1703
+		}
1593 1704
 		//echo "<p>infolog_ui::delete(".print_r($values,true).",'$referer','$called_by') info_id=$info_id</p>\n";
1594 1705
 
1595 1706
 		if (is_array($values) || $info_id <= 0)
@@ -1598,11 +1709,16 @@  discard block
 block discarded – undo
1598 1709
 			{
1599 1710
 				$deleted = $this->bo->delete($info_id,$values['delete_subs'],$values['info_id_parent'], $skip_notification);
1600 1711
 			}
1601
-			if ($called_by)		// direct call from the same request
1712
+			if ($called_by)
1713
+			{
1714
+				// direct call from the same request
1602 1715
 			{
1603 1716
 				return $deleted ? lang('InfoLog entry deleted') : '';
1604 1717
 			}
1605
-			if ($values['called_by'] == 'edit')	// we run in the edit popup => give control back to edit
1718
+			}
1719
+			if ($values['called_by'] == 'edit')
1720
+			{
1721
+				// we run in the edit popup => give control back to edit
1606 1722
 			{
1607 1723
 				$this->edit(array(
1608 1724
 					'info_id' => $info_id,
@@ -1611,6 +1727,7 @@  discard block
 block discarded – undo
1611 1727
 					'msg'     => $deleted ? lang('Infolog entry deleted') : '',
1612 1728
 				));
1613 1729
 			}
1730
+			}
1614 1731
 			return $referer ? $this->tmpl->location($referer) : $this->index();
1615 1732
 		}
1616 1733
 		$readonlys = $values = array();
@@ -1659,10 +1776,17 @@  discard block
 block discarded – undo
1659 1776
 			$no_popup  = $content['no_popup'];  unset($content['no_popup']);
1660 1777
 
1661 1778
 			list($button) = @each($content['button']);
1662
-			if (!$button && $action) $button = $action;	// action selectbox
1779
+			if (!$button && $action)
1780
+			{
1781
+				$button = $action;
1782
+			}
1783
+			// action selectbox
1663 1784
 			//info_cc expects an comma separated string
1664 1785
 			//error_log(__METHOD__.__LINE__.array2string($content));
1665
-			if (empty($content['info_cc'])) $content['info_cc'] = "";
1786
+			if (empty($content['info_cc']))
1787
+			{
1788
+				$content['info_cc'] = "";
1789
+			}
1666 1790
 			if (is_array($content['info_cc']))
1667 1791
 			{
1668 1792
 				foreach($content['info_cc'] as $i => $value)
@@ -1672,7 +1796,10 @@  discard block
 block discarded – undo
1672 1796
 					//error_log(__METHOD__.__LINE__.$value.'->'.array2string($addresses[0]));
1673 1797
 					$content['info_cc'][$i]=$addresses[0]->host ? $addresses[0]->mailbox.'@'.$addresses[0]->host : $addresses[0]->mailbox;
1674 1798
 				}
1675
-				if (!empty($content['info_cc'])) $content['info_cc'] = implode(',',$content['info_cc']);
1799
+				if (!empty($content['info_cc']))
1800
+				{
1801
+					$content['info_cc'] = implode(',',$content['info_cc']);
1802
+				}
1676 1803
 			}
1677 1804
 			unset($content['button']);
1678 1805
 			if ($button)
@@ -1811,9 +1938,12 @@  discard block
 block discarded – undo
1811 1938
 						Link::link('infolog',$info_id,$content['link_to']['to_id']);
1812 1939
 						$content['link_to']['to_id'] = $info_id;
1813 1940
 					}
1814
-					if ($info_link_id && strpos($info_link_id,':') !== false)	// updating info_link_id if necessary
1941
+					if ($info_link_id && strpos($info_link_id,':') !== false)
1942
+					{
1943
+						// updating info_link_id if necessary
1815 1944
 					{
1816 1945
 						list($app,$id) = explode(':',$info_link_id);
1946
+					}
1817 1947
 						$link = Link::get_link('infolog',$info_id,$app,$id);
1818 1948
 						if ((int) $content['info_link_id'] != (int) $link['link_id'])
1819 1949
 						{
@@ -1835,12 +1965,19 @@  discard block
 block discarded – undo
1835 1965
 				}
1836 1966
 				elseif ($button == 'delete' && $info_id > 0)
1837 1967
 				{
1838
-					if (!$referer && $action) $referer = array(
1968
+					if (!$referer && $action)
1969
+					{
1970
+						$referer = array(
1839 1971
 						'menuaction' => 'infolog.infolog_ui.index',
1840 1972
 						'action' => $action,
1841 1973
 						'action_id' => $action_id
1842 1974
 					);
1843
-					if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return;	// checks ACL first
1975
+					}
1976
+					if (!($content['msg'] = $this->delete($info_id,$referer,'edit')))
1977
+					{
1978
+						return;
1979
+					}
1980
+					// checks ACL first
1844 1981
 
1845 1982
 					Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
1846 1983
 				}
@@ -1890,13 +2027,20 @@  discard block
 block discarded – undo
1890 2027
 			$type      = $type      ? $type      : $_REQUEST['type'];
1891 2028
 			$referer   = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] :
1892 2029
 				Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
1893
-			if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer);	// remove previou/old msg from referer
2030
+			if (strpos($referer, 'msg=') !== false)
2031
+			{
2032
+				$referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer);
2033
+			}
2034
+			// remove previou/old msg from referer
1894 2035
 			$no_popup  = $_GET['no_popup'];
1895 2036
 			$print = (int) $_REQUEST['print'];
1896 2037
 			//echo "<p>infolog_ui::edit: info_id=$info_id,  action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
1897 2038
 
1898 2039
 			$content = $this->bo->read( $info_id || $action != 'sp' ? $info_id : $action_id );
1899
-			if (!(strpos($content['info_addr'],',')===false) && strpos($content['info_addr'],', ')===false) $content['info_addr'] = str_replace(',',', ',$content['info_addr']);
2040
+			if (!(strpos($content['info_addr'],',')===false) && strpos($content['info_addr'],', ')===false)
2041
+			{
2042
+				$content['info_addr'] = str_replace(',',', ',$content['info_addr']);
2043
+			}
1900 2044
 			foreach(array('info_subject', 'info_des') as $key)
1901 2045
 			{
1902 2046
 				if(!isset($content[$key]) || strlen($content[$key]) < 75)
@@ -1920,10 +2064,16 @@  discard block
 block discarded – undo
1920 2064
 						if (strlen($word)>75)
1921 2065
 						{
1922 2066
 							$buff = Api\Html::activate_links($word);
1923
-							if (strlen($buff) == strlen($word)) // no links -> try to break overlong words
2067
+							if (strlen($buff) == strlen($word))
2068
+							{
2069
+								// no links -> try to break overlong words
1924 2070
 							{
1925 2071
 								if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word);
1926
-								if (!(strpos($word,'.')===false) && strpos($word,'. ')===false) $word = str_replace('.','. ',$word);
2072
+							}
2073
+								if (!(strpos($word,'.')===false) && strpos($word,'. ')===false)
2074
+								{
2075
+									$word = str_replace('.','. ',$word);
2076
+								}
1927 2077
 								$word = wordwrap($word, 75, ' ', true);
1928 2078
 							}
1929 2079
 						}
@@ -1944,7 +2094,11 @@  discard block
 block discarded – undo
1944 2094
 			{
1945 2095
 				$content['info_cat'] = $this->prefs['cat_add_default'];
1946 2096
 			}
1947
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2097
+			if ($_GET['msg'])
2098
+			{
2099
+				$content['msg'] = strip_tags($_GET['msg']);
2100
+			}
2101
+			// dont allow HTML!
1948 2102
 
1949 2103
 			switch($this->prefs['set_start'])
1950 2104
 			{
@@ -1955,13 +2109,19 @@  discard block
 block discarded – undo
1955 2109
 			if ((int)$content['info_link_id'] > 0 && !Link::get_link($content['info_link_id']))
1956 2110
 			{
1957 2111
 				$content['info_link_id'] = 0;	// link has been deleted
1958
-				if (!$content['info_custom_link']) $content['info_from'] = '';
2112
+				if (!$content['info_custom_link'])
2113
+				{
2114
+					$content['info_from'] = '';
2115
+				}
1959 2116
 			}
1960
-			if (!$info_id && $action_id && $action == 'sp')    // new SubProject
2117
+			if (!$info_id && $action_id && $action == 'sp')
2118
+			{
2119
+				// new SubProject
1961 2120
 			{
1962 2121
 				if (!$this->bo->check_access($action_id,Acl::ADD))
1963 2122
 				{
1964 2123
 					return $referer ? $this->tmpl->location($referer) : $this->index(0,$action,$action_id);
2124
+			}
1965 2125
 				}
1966 2126
 			}
1967 2127
 			else
@@ -1995,10 +2155,16 @@  discard block
 block discarded – undo
1995 2155
 				case 'copy':
1996 2156
 					$info_id = 0;
1997 2157
 					$this->create_copy($content, $action == 'sp');
1998
-					if ($action == 'sp')	// for sub-entries use type or category, like for new entries
2158
+					if ($action == 'sp')
2159
+					{
2160
+						// for sub-entries use type or category, like for new entries
1999 2161
 					{
2000 2162
 						if ($type) $content['info_type'] = $type;
2001
-						if (is_numeric($_REQUEST['cat_id'])) $content['info_cat'] = (int) $_REQUEST['cat_id'];
2163
+					}
2164
+						if (is_numeric($_REQUEST['cat_id']))
2165
+						{
2166
+							$content['info_cat'] = (int) $_REQUEST['cat_id'];
2167
+						}
2002 2168
 					}
2003 2169
 					unset($action);	// it get stored in $content and will cause an other copy after [apply]
2004 2170
 					break;
@@ -2027,7 +2193,10 @@  discard block
 block discarded – undo
2027 2193
 						{
2028 2194
 							foreach((array)$set['link_app'] as $i => $l_app)
2029 2195
 							{
2030
-								if (($l_id=$set['link_id'][$i])) Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
2196
+								if (($l_id=$set['link_id'][$i]))
2197
+								{
2198
+									Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
2199
+								}
2031 2200
 							}
2032 2201
 							unset($set['link_app']);
2033 2202
 							unset($set['link_id']);
@@ -2046,8 +2215,15 @@  discard block
 block discarded – undo
2046 2215
 						break;	// normal edit
2047 2216
 					}
2048 2217
 				case 'new':		// new entry, set some defaults, if not set by infolog_set hook
2049
-					if (empty($content['info_startdate'])) $content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
2050
-					if (empty($content['info_priority'])) $content['info_priority'] = 1; // normal
2218
+					if (empty($content['info_startdate']))
2219
+					{
2220
+						$content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
2221
+					}
2222
+					if (empty($content['info_priority']))
2223
+					{
2224
+						$content['info_priority'] = 1;
2225
+					}
2226
+					// normal
2051 2227
 					$content['info_owner'] = $this->user;
2052 2228
 					if ($type != '' && empty($content['info_type']))
2053 2229
 					{
@@ -2057,8 +2233,14 @@  discard block
 block discarded – undo
2057 2233
 					{
2058 2234
 						$content['info_type'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['preferred_type'];
2059 2235
 					}
2060
-					if (empty($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2061
-					if (empty($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2236
+					if (empty($content['info_status']))
2237
+					{
2238
+						$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2239
+					}
2240
+					if (empty($content['info_percent']))
2241
+					{
2242
+						$content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2243
+					}
2062 2244
 					break;
2063 2245
 			}
2064 2246
 			if (!isset($this->bo->enums['type'][$content['info_type']]))
@@ -2161,12 +2343,18 @@  discard block
 block discarded – undo
2161 2343
 
2162 2344
 		$content['duration_format'] = $this->duration_format;
2163 2345
 		$content['hours_per_workday'] = $this->hours_per_workday;
2164
-		if ($this->prefs['show_id']) $content['info_number'] = $info_id;
2346
+		if ($this->prefs['show_id'])
2347
+		{
2348
+			$content['info_number'] = $info_id;
2349
+		}
2165 2350
 
2166 2351
 		$content['info_anz_subs'] = (int)$content['info_anz_subs'];	// gives javascript error if empty!
2167 2352
 
2168 2353
 		$old_pm_id = is_array($pm_links) ? array_shift($pm_links) : $content['old_pm_id'];
2169
-		if (!isset($content['pm_id']) && $old_pm_id) $content['pm_id'] = $old_pm_id;
2354
+		if (!isset($content['pm_id']) && $old_pm_id)
2355
+		{
2356
+			$content['pm_id'] = $old_pm_id;
2357
+		}
2170 2358
 
2171 2359
 		if ($info_id && $this->bo->history)
2172 2360
 		{
@@ -2239,7 +2427,10 @@  discard block
 block discarded – undo
2239 2427
 		//$content['info_des'] = substr($content['info_des'],0,1793);
2240 2428
 		//echo "<p>infolog_ui.edit(info_id='$info_id',action='$action',action_id='$action_id') readonlys="; print_r($readonlys); echo ", content = "; _debug_array($content);
2241 2429
 		//$content['info_cc'] is expected (by the widget) to be an array of emailaddresses, but is stored as comma separated string
2242
-		if (!empty($content['info_cc'])&&!is_array($content['info_cc']))$content['info_cc'] = explode(',',$content['info_cc']);
2430
+		if (!empty($content['info_cc'])&&!is_array($content['info_cc']))
2431
+		{
2432
+			$content['info_cc'] = explode(',',$content['info_cc']);
2433
+		}
2243 2434
 		$this->tmpl->exec('infolog.infolog_ui.edit',$content,$sel_options,$readonlys,$preserv+array(	// preserved values
2244 2435
 			'info_id'       => $info_id,
2245 2436
 			'action'        => $action,
@@ -2267,7 +2458,11 @@  discard block
 block discarded – undo
2267 2458
 		foreach ($exclude_fields as $field)
2268 2459
 		{
2269 2460
 			unset($content[$field]);
2270
-			if ($field == 'info_from') unset($content['info_link_id']);	// both together is called contact in UI
2461
+			if ($field == 'info_from')
2462
+			{
2463
+				unset($content['info_link_id']);
2464
+			}
2465
+			// both together is called contact in UI
2271 2466
 		}
2272 2467
 		if ($create_sub)
2273 2468
 		{
@@ -2295,13 +2490,25 @@  discard block
 block discarded – undo
2295 2490
 			$content['info_type'] = $types[0];
2296 2491
 		}
2297 2492
 		// get a consistent status, percent and date-completed
2298
-		if (!isset($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2299
-		if (!isset($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2493
+		if (!isset($content['info_status']))
2494
+		{
2495
+			$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2496
+		}
2497
+		if (!isset($content['info_percent']))
2498
+		{
2499
+			$content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2500
+		}
2300 2501
 		$content['info_datecompleted'] =$content['info_status'] == 'done' ? $this->bo->user_time_now : 0;
2301 2502
 
2302
-		if (!isset($content['info_cat'])) $content['info_cat'] = $this->prefs['cat_add_default'];
2503
+		if (!isset($content['info_cat']))
2504
+		{
2505
+			$content['info_cat'] = $this->prefs['cat_add_default'];
2506
+		}
2303 2507
 
2304
-		if(!is_array($content['link_to'])) $content['link_to'] = array();
2508
+		if(!is_array($content['link_to']))
2509
+		{
2510
+			$content['link_to'] = array();
2511
+		}
2305 2512
 		$content['link_to']['to_app'] = 'infolog';
2306 2513
 		$content['link_to']['to_id'] = 0;
2307 2514
 		// Get links to be copied, if not excluded
@@ -2332,7 +2539,10 @@  discard block
 block discarded – undo
2332 2539
 			{
2333 2540
 				$linkinfos = Link::get_link($info_link_id);
2334 2541
 				$content['info_contact'] = $linkinfos['link_app1']=='infolog'? $linkinfos['link_app2'].':'.$linkinfos['link_id2']:$linkinfos['link_app1'].':'.$linkinfos['link_id1'];
2335
-				if (stripos($content['info_contact'],'projectmanager')!==false) $content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
2542
+				if (stripos($content['info_contact'],'projectmanager')!==false)
2543
+				{
2544
+					$content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
2545
+				}
2336 2546
 			}
2337 2547
 			unset($content['info_link_id']);
2338 2548
 		}
@@ -2637,7 +2847,10 @@  discard block
 block discarded – undo
2637 2847
 		}
2638 2848
 		foreach($this->bo->customfields as $name => $data)
2639 2849
 		{
2640
-			if ($data['type2'] && $type && !in_array($type,explode(',',$data['type2']))) continue;
2850
+			if ($data['type2'] && $type && !in_array($type,explode(',',$data['type2'])))
2851
+			{
2852
+				continue;
2853
+			}
2641 2854
 
2642 2855
 			$fields['#'.$name] = array(
2643 2856
 				'label' => $data['label'],
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.
Spacing   +40 added lines, -40 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 array $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,7 +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']): $content['mailbox'][0];
84
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : $content['mailbox'][0];
85 85
 		if (empty($mailbox))
86 86
 		{
87 87
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($this->imap->isAdminConnection) : 'INBOX';
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 
112 112
 					foreach ($rights as $right)
113 113
 					{
114
-						$content['grid'][$n]['acl_'. $right] = true;
114
+						$content['grid'][$n]['acl_'.$right] = true;
115 115
 					}
116
-					$virtualD = array('e','t');
117
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
118
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
116
+					$virtualD = array('e', 't');
117
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false : true; //c=kx more information rfc4314, Obsolote Rights
118
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false : true; //d=et more information rfc4314, Obsolote Rights
119 119
 
120 120
 					sort($rights);
121
-					$acl_abbrvs = implode('',$rights);
121
+					$acl_abbrvs = implode('', $rights);
122 122
 
123 123
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
124 124
 					{
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				case 'apply':
160 160
 					if ($content)
161 161
 					{
162
-						$validation_err = $this->update_acl($content,$msg);
162
+						$validation_err = $this->update_acl($content, $msg);
163 163
 						if ($validation_err)
164 164
 						{
165 165
 							foreach ($validation_err as &$row)
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 					}
194 194
 					else
195 195
 					{
196
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
196
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
197 197
 					}
198 198
 					Framework::message($msg);
199 199
 			}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
203 203
 
204 204
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
205
-		foreach($content['grid'] as $key => $fields)
205
+		foreach ($content['grid'] as $key => $fields)
206 206
 		{
207 207
 			if ($fields['acc_id'] == $this->imap->acc_imap_username ||
208 208
 					$fields['acc_id'][0] == $this->imap->acc_imap_username)
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			));
236 236
 		}
237 237
 
238
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
238
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
239 239
 	}
240 240
 
241 241
 	/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
255 255
 
256 256
 		$folders = array();
257
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
257
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
258 258
 		{
259 259
 			if (stripos($folder, $_GET['query']) !== false)
260 260
 			{
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param string $msg Message
283 283
 	 *
284 284
 	 */
285
-	function update_acl ($content, &$msg)
285
+	function update_acl($content, &$msg)
286 286
 	{
287 287
 		$validator = array();
288 288
 
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 			{
299 299
 				if ($value[$key] == true)
300 300
 				{
301
-					$right = explode("acl_" ,$key);
301
+					$right = explode("acl_", $key);
302 302
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
303 303
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
304
-					$options['rights'] .=  $right[1];
304
+					$options['rights'] .= $right[1];
305 305
 				}
306 306
 			}
307 307
 			$username = $content['grid'][$keys]['acc_id'] == $this->imap->acc_imap_username
308
-				?$content['grid'][$keys]['acc_id']:$content['grid'][$keys]['acc_id'][0];
308
+				? $content['grid'][$keys]['acc_id'] : $content['grid'][$keys]['acc_id'][0];
309 309
 			//error_log(__METHOD__."(".__LINE__.") setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
310 310
 			if (is_numeric($username) && ($u = $this->imap->getMailBoxUserName($username)))
311 311
 			{
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			if (!empty($username))
315 315
 			{
316 316
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
317
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
317
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
318 318
 				{
319 319
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
320 320
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 			}
327 327
 			else
328 328
 			{
329
-				if($keys !== count($content['grid']))
329
+				if ($keys !== count($content['grid']))
330 330
 				{
331 331
 					array_push($validator, $keys);
332 332
 					$msg = lang("Error:Could not save the ACL! Because some names are empty!");
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 * Retrive Folder ACL rights
344 344
 	 * @todo rights 'c' and 'd' should be fixed
345 345
 	 */
346
-	function retrive_acl ($mailbox, &$msg)
346
+	function retrive_acl($mailbox, &$msg)
347 347
 	{
348 348
 		if (($acl = $this->getACL($mailbox)))
349 349
 		 {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	function remove_acl($content, &$msg)
370 370
 	{
371
-		$row_num = array_keys($content['grid']['delete'],"pressed");
371
+		$row_num = array_keys($content['grid']['delete'], "pressed");
372 372
 		if ($row_num) $row_num = $row_num[0];
373 373
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
374 374
 		$identifier = $content['grid'][$row_num]['acc_id'][0];
@@ -378,24 +378,24 @@  discard block
 block discarded – undo
378 378
 			$identifier = $u;
379 379
 		}
380 380
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
381
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
381
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
382 382
 		{
383 383
 			unset($content['grid'][$row_num]);
384 384
 			unset($content['grid']['delete']);
385 385
 			if ($recursive)
386 386
 			{
387
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
387
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
388 388
 			}
389 389
 			else
390 390
 			{
391
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
391
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
392 392
 			}
393 393
 
394 394
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
395 395
 		}
396 396
 		else
397 397
 		{
398
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
398
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
399 399
 			return false;
400 400
 		}
401 401
 	}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
412 412
 	 */
413
-	function deleteACL ($mailbox, $identifier, $recursive)
413
+	function deleteACL($mailbox, $identifier, $recursive)
414 414
 	{
415 415
 		if ($recursive)
416 416
 		{
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 		{
421 421
 			$folders = (array)$mailbox;
422 422
 		}
423
-		foreach($folders as $sbFolders)
423
+		foreach ($folders as $sbFolders)
424 424
 		{
425 425
 			try
426 426
 			{
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 			}
429 429
 			catch (Exception $e)
430 430
 			{
431
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ." because of " .$e->getMessage());
431
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier." because of ".$e->getMessage());
432 432
 				return false;
433 433
 			}
434 434
 		}
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
472 472
 	 *
473 473
 	 */
474
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
474
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
475 475
 	{
476 476
 		if ($recursive)
477 477
 		{
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
 		{
482 482
 			$folders = (array)$mailbox;
483 483
 		}
484
-		foreach($folders as $sbFolders)
484
+		foreach ($folders as $sbFolders)
485 485
 		{
486 486
 			try
487 487
 			{
488
-				$this->imap->setACL($sbFolders,$identifier,$options);
488
+				$this->imap->setACL($sbFolders, $identifier, $options);
489 489
 			}
490 490
 			catch (Exception $e)
491 491
 			{
492 492
 				$msg = $e->getMessage();
493
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . " because of " .$e->getMessage());
493
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier." because of ".$e->getMessage());
494 494
 				return false;
495 495
 			}
496 496
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 	 * @param String $mailbox folder name that needs to be read
504 504
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
505 505
 	 */
506
-	function getACL ($mailbox)
506
+	function getACL($mailbox)
507 507
 	{
508 508
 		try
509 509
 		{
510 510
 			$acl = $this->imap->getACL($mailbox);
511 511
 			return $acl;
512 512
 		} catch (Exception $e) {
513
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . " because of " .$e->getMessage());
513
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox." because of ".$e->getMessage());
514 514
 			return false;
515 515
 		}
516 516
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -9 removed lines patch added patch discarded remove patch
@@ -95,7 +95,10 @@  discard block
 block discarded – undo
95 95
 			//Todo: Implement autocomplete_url function with admin stuffs consideration
96 96
 		}
97 97
 		// Unset the content if folder is changed, in order to read acl rights for new selected folder
98
-		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete'])) unset($content);
98
+		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete']))
99
+		{
100
+			unset($content);
101
+		}
99 102
 
100 103
 		if (!is_array($content))
101 104
 		{
@@ -170,7 +173,9 @@  discard block
 block discarded – undo
170 173
 
171 174
 						//Add new row at the end
172 175
 						if ($content['grid'][count($content['grid'])]['acc_id'])
173
-							array_push($content['grid'], array('acc_id'=>''));
176
+						{
177
+													array_push($content['grid'], array('acc_id'=>''));
178
+						}
174 179
 					}
175 180
 					else
176 181
 					{
@@ -178,7 +183,10 @@  discard block
 block discarded – undo
178 183
 					}
179 184
 					//Send message
180 185
 					Framework::message($msg);
181
-					if ($button == "apply") break;
186
+					if ($button == "apply")
187
+					{
188
+						break;
189
+					}
182 190
 
183 191
 				//Fall through
184 192
 				case 'cancel':
@@ -299,8 +307,16 @@  discard block
 block discarded – undo
299 307
 				if ($value[$key] == true)
300 308
 				{
301 309
 					$right = explode("acl_" ,$key);
302
-					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
303
-					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
310
+					if ($right[1] === 'c')
311
+					{
312
+						$right[1] = 'kx';
313
+					}
314
+					// c = kx , rfc 4314
315
+					if ($right[1] === 'd')
316
+					{
317
+						$right[1] = 'et';
318
+					}
319
+					// d = et , rfc 4314
304 320
 					$options['rights'] .=  $right[1];
305 321
 				}
306 322
 			}
@@ -346,7 +362,7 @@  discard block
 block discarded – undo
346 362
 	function retrive_acl ($mailbox, &$msg)
347 363
 	{
348 364
 		if (($acl = $this->getACL($mailbox)))
349
-		 {
365
+		{
350 366
 			$msg = lang('ACL rights retrived successfully');
351 367
 			return $acl;
352 368
 		 }
@@ -369,10 +385,16 @@  discard block
 block discarded – undo
369 385
 	function remove_acl($content, &$msg)
370 386
 	{
371 387
 		$row_num = array_keys($content['grid']['delete'],"pressed");
372
-		if ($row_num) $row_num = $row_num[0];
388
+		if ($row_num)
389
+		{
390
+			$row_num = $row_num[0];
391
+		}
373 392
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
374 393
 		$identifier = $content['grid'][$row_num]['acc_id'][0];
375
-		if (is_array($content['mailbox'])) $content['mailbox'] = $content['mailbox'][0];
394
+		if (is_array($content['mailbox']))
395
+		{
396
+			$content['mailbox'] = $content['mailbox'][0];
397
+		}
376 398
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
377 399
 		{
378 400
 			$identifier = $u;
@@ -509,7 +531,8 @@  discard block
 block discarded – undo
509 531
 		{
510 532
 			$acl = $this->imap->getACL($mailbox);
511 533
 			return $acl;
512
-		} catch (Exception $e) {
534
+		}
535
+		catch (Exception $e) {
513 536
 			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . " because of " .$e->getMessage());
514 537
 			return false;
515 538
 		}
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   +598 added lines, -599 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
 
@@ -204,7 +203,7 @@  discard block
 block discarded – undo
204 203
 				'children' => array(),
205 204
 				'hint' => 'Select the message priority tag',
206 205
 			),
207
-			'save2vfs' => array (
206
+			'save2vfs' => array(
208 207
 				'caption' => 'Save to VFS',
209 208
 				'icon' => 'filesave',
210 209
 				'group' => ++$group,
@@ -241,7 +240,7 @@  discard block
 block discarded – undo
241 240
 		{
242 241
 			foreach (array_keys($actions) as $key)
243 242
 			{
244
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
243
+				if (!in_array($key, array('send', 'button[saveAsDraft]', 'uploadForCompose'))) {
245 244
 					$actions[$key]['toolbarDefault'] = false;
246 245
 				}
247 246
 			}
@@ -259,7 +258,7 @@  discard block
 block discarded – undo
259 258
 	 * @var boolean $suppressSigOnTop =false
260 259
 	 * @var boolean $isReply =false
261 260
 	 */
262
-	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
261
+	function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false)
263 262
 	{
264 263
 		if ($msg) Framework::message($msg);
265 264
 
@@ -280,14 +279,14 @@  discard block
 block discarded – undo
280 279
 		//lang('compose'),lang('from') // needed to be found by translationtools
281 280
 		//error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace());
282 281
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
283
-		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
284
-		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
282
+		$_contentHasSigID = $_content ? array_key_exists('mailidentity', (array)$_content) : false;
283
+		$_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false;
285 284
 		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
286 285
 		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
287 286
 
288 287
 		// Process different places we can use as a start for composing an email
289 288
 		$actionToProcess = 'compose';
290
-		if($_GET['from'] && $replyID)
289
+		if ($_GET['from'] && $replyID)
291 290
 		{
292 291
 			$_content = array_merge((array)$_content, $this->getComposeFrom(
293 292
 				// Parameters needed for fetching appropriate data
@@ -305,10 +304,10 @@  discard block
 block discarded – undo
305 304
 		}
306 305
 
307 306
 		$composeCache = array();
308
-		if (isset($_content['composeID'])&&!empty($_content['composeID']))
307
+		if (isset($_content['composeID']) && !empty($_content['composeID']))
309 308
 		{
310 309
 			$isFirstLoad = false;
311
-			$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);
310
+			$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);
312 311
 			$this->composeID = $_content['composeID'];
313 312
 			//error_log(__METHOD__.__LINE__.array2string($composeCache));
314 313
 		}
@@ -318,7 +317,7 @@  discard block
 block discarded – undo
318 317
 			// respect that composeasnew may not want that, as we assume there
319 318
 			// is some style already set and our initalStyle always adds a span with &nbsp;
320 319
 			// and we want to avoid that
321
-			$isFirstLoad = !($actionToProcess=='composeasnew');//true;
320
+			$isFirstLoad = !($actionToProcess == 'composeasnew'); //true;
322 321
 			$this->composeID = $_content['composeID'] = $this->generateComposeID();
323 322
 			if (!is_array($_content))
324 323
 			{
@@ -353,7 +352,7 @@  discard block
 block discarded – undo
353 352
 				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
354 353
 				try
355 354
 				{
356
-					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
355
+					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload, $this->composeID, false);
357 356
 				}
358 357
 				catch (Api\Exception\WrongUserinput $e)
359 358
 				{
@@ -379,12 +378,12 @@  discard block
 block discarded – undo
379 378
 			unset($_content['attachments']['delete']);
380 379
 			$attachments = $_content['attachments'];
381 380
 			unset($_content['attachments']);
382
-			foreach($attachments as $i => $att)
381
+			foreach ($attachments as $i => $att)
383 382
 			{
384
-				$remove=false;
385
-				foreach(array_keys($toDelete) as $k)
383
+				$remove = false;
384
+				foreach (array_keys($toDelete) as $k)
386 385
 				{
387
-					if ($att['tmp_name']==$k) $remove=true;
386
+					if ($att['tmp_name'] == $k) $remove = true;
388 387
 				}
389 388
 				if (!$remove) $_content['attachments'][] = $att;
390 389
 			}
@@ -392,7 +391,7 @@  discard block
 block discarded – undo
392 391
 		// someone clicked something like send, or saveAsDraft
393 392
 		// make sure, we are connected to the correct server for sending and storing the send message
394 393
 		$activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose
395
-		$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);
394
+		$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);
396 395
 		if (!empty($activeFolderCache[$this->mail_bo->profileID]))
397 396
 		{
398 397
 			//error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]);
@@ -400,7 +399,7 @@  discard block
 block discarded – undo
400 399
 		}
401 400
 		//error_log(__METHOD__.__LINE__.array2string($_content));
402 401
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
403
-			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
402
+			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint'])
404 403
 		)
405 404
 		{
406 405
 			$this->changeProfile($_content['serverID']);
@@ -414,19 +413,19 @@  discard block
 block discarded – undo
414 413
 		{
415 414
 			$buttonClicked = $suppressSigOnTop = true;
416 415
 			$sendOK = true;
417
-			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']);
416
+			$_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
418 417
 			/*
419 418
 			perform some simple checks, before trying to send on:
420 419
 			$_content['to'];$_content['cc'];$_content['bcc'];
421 420
 			trim($_content['subject']);
422 421
 			trim(strip_tags(str_replace('&nbsp;','',$_content['body'])));
423 422
 			*/
424
-			if (strlen(trim(strip_tags(str_replace('&nbsp;','',$_content['body']))))==0 && count($_content['attachments'])==0)
423
+			if (strlen(trim(strip_tags(str_replace('&nbsp;', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0)
425 424
 			{
426 425
 				$sendOK = false;
427 426
 				$_content['msg'] = $message = lang("no message body supplied");
428 427
 			}
429
-			if ($sendOK && strlen(trim($_content['subject']))==0)
428
+			if ($sendOK && strlen(trim($_content['subject'])) == 0)
430 429
 			{
431 430
 				$sendOK = false;
432 431
 				$_content['msg'] = $message = lang("no subject supplied");
@@ -441,15 +440,15 @@  discard block
 block discarded – undo
441 440
 				try
442 441
 				{
443 442
 					$success = $this->send($_content);
444
-					if ($success==false)
443
+					if ($success == false)
445 444
 					{
446
-						$sendOK=false;
445
+						$sendOK = false;
447 446
 						$message = $this->errorInfo;
448 447
 					}
449 448
 					if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID])
450 449
 					{
451
-						$sigPref[$this->mail_bo->profileID]=$_content['mailidentity'];
452
-						$GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user');
450
+						$sigPref[$this->mail_bo->profileID] = $_content['mailidentity'];
451
+						$GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user');
453 452
 						// save prefs
454 453
 						$GLOBALS['egw']->preferences->save_repository(true);
455 454
 					}
@@ -473,23 +472,23 @@  discard block
 block discarded – undo
473 472
 				if (isset($_content['mode']) && !empty($_content['mode']))
474 473
 				{
475 474
 					$mode = $_content['mode'];
476
-					if ($_content['mode']=='forward' && !empty($_content['processedmail_id']))
475
+					if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id']))
477 476
 					{
478
-						$_content['processedmail_id'] = explode(',',$_content['processedmail_id']);
477
+						$_content['processedmail_id'] = explode(',', $_content['processedmail_id']);
479 478
 						foreach ($_content['processedmail_id'] as $k =>$rowid)
480 479
 						{
481 480
 							$fhA = mail_ui::splitRowID($rowid);
482 481
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
483 482
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
484
-							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
483
+							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false);
485 484
 							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
486 485
 						}
487 486
 					}
488
-					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
487
+					if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id']))
489 488
 					{
490 489
 						$rhA = mail_ui::splitRowID($_content['processedmail_id']);
491 490
 						//$this->sessionData['uid'] = $rhA['msgUID'];
492
-						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
491
+						$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
493 492
 						$workingFolder = $rhA['folder'];
494 493
 					}
495 494
 				}
@@ -497,30 +496,30 @@  discard block
 block discarded – undo
497 496
 				if (empty($idsForRefresh) && !empty($_content['processedmail_id']))
498 497
 				{
499 498
 					$rhA = mail_ui::splitRowID($_content['processedmail_id']);
500
-					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
499
+					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false);
501 500
 				}
502 501
 				$response = Api\Json\Response::get();
503 502
 				if ($activeProfile != $composeProfile)
504 503
 				{
505 504
 					// we need a message only, when account ids (composeProfile vs. activeProfile) differ
506
-					$response->call('opener.egw_message',lang('Message send successfully.'));
505
+					$response->call('opener.egw_message', lang('Message send successfully.'));
507 506
 				}
508
-				elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)))
507
+				elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)))
509 508
 				{
510
-					if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))
509
+					if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))
511 510
 					{
512 511
 						// we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action
513
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail');
512
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail');
514 513
 					}
515 514
 					else
516 515
 					{
517 516
 						//error_log(__METHOD__.__LINE__.array2string($idsForRefresh));
518
-						$response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update');
517
+						$response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update');
519 518
 					}
520 519
 				}
521 520
 				else
522 521
 				{
523
-					$response->call('opener.egw_message',lang('Message send successfully.'));
522
+					$response->call('opener.egw_message', lang('Message send successfully.'));
524 523
 				}
525 524
 				//egw_framework::refresh_opener(lang('Message send successfully.'),'mail');
526 525
 				Framework::window_close();
@@ -528,60 +527,60 @@  discard block
 block discarded – undo
528 527
 			if ($sendOK == false)
529 528
 			{
530 529
 				$response = Api\Json\Response::get();
531
-				Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate
530
+				Framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate
532 531
 				$response->call('app.mail.clearIntevals');
533 532
 			}
534 533
 		}
535 534
 
536 535
 		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
537 536
 		$insertSigOnTop = false;
538
-		$content = (is_array($_content)?$_content:array());
537
+		$content = (is_array($_content) ? $_content : array());
539 538
 		if ($_contentHasMimeType)
540 539
 		{
541 540
 			// mimeType is now a checkbox; convert it here to match expectations
542 541
 			// ToDo: match Code to meet checkbox value
543
-			if ($content['mimeType']==1)
542
+			if ($content['mimeType'] == 1)
544 543
 			{
545
-				$_content['mimeType'] = $content['mimeType']='html';
544
+				$_content['mimeType'] = $content['mimeType'] = 'html';
546 545
 			}
547 546
 			else
548 547
 			{
549
-				$_content['mimeType'] = $content['mimeType']='plain';
548
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
550 549
 			}
551 550
 
552 551
 		}
553 552
 		// user might have switched desired mimetype, so we should convert
554
-		if ($content['is_html'] && $content['mimeType']=='plain')
553
+		if ($content['is_html'] && $content['mimeType'] == 'plain')
555 554
 		{
556 555
 			//error_log(__METHOD__.__LINE__.$content['mail_htmltext']);
557 556
 			$suppressSigOnTop = true;
558
-			if (stripos($content['mail_htmltext'],'<pre>')!==false)
557
+			if (stripos($content['mail_htmltext'], '<pre>') !== false)
559 558
 			{
560 559
 				$contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']);
561 560
 				if (is_array($contentArr))
562 561
 				{
563 562
 					foreach ($contentArr as $k =>&$elem)
564 563
 					{
565
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
564
+						if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem);
566 565
 					}
567
-					$content['mail_htmltext'] = implode('',$contentArr);
566
+					$content['mail_htmltext'] = implode('', $contentArr);
568 567
 				}
569 568
 			}
570 569
 			$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']);
571
-			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
570
+			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true);
572 571
 
573 572
 			$content['body'] = $content['mail_htmltext'];
574 573
 			unset($content['mail_htmltext']);
575 574
 			$content['is_html'] = false;
576 575
 			$content['is_plain'] = true;
577 576
 		}
578
-		if ($content['is_plain'] && $content['mimeType']=='html')
577
+		if ($content['is_plain'] && $content['mimeType'] == 'html')
579 578
 		{
580 579
 			// the possible font span should only be applied on first load or on switch plain->html
581 580
 			$isFirstLoad = "switchedplaintohtml";
582 581
 			//error_log(__METHOD__.__LINE__.$content['mail_plaintext']);
583 582
 			$suppressSigOnTop = true;
584
-			$content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']);
583
+			$content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']);
585 584
 			//$this->replaceEmailAdresses($content['mail_plaintext']);
586 585
 			$content['body'] = $content['mail_plaintext'];
587 586
 			unset($content['mail_plaintext']);
@@ -589,14 +588,14 @@  discard block
 block discarded – undo
589 588
 			$content['is_plain'] = false;
590 589
 		}
591 590
 
592
-		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']);
591
+		$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']);
593 592
 		unset($_content['body']);
594 593
 		unset($_content['mail_htmltext']);
595 594
 		unset($_content['mail_plaintext']);
596 595
 
597 596
 		// form was submitted either by clicking a button or by changing one of the triggering selectboxes
598 597
 		// identity and signatureid; this might trigger that the signature in mail body may have to be altered
599
-		if ( !empty($content['body']) &&
598
+		if (!empty($content['body']) &&
600 599
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
601 600
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
602 601
 		)
@@ -607,7 +606,7 @@  discard block
 block discarded – undo
607 606
 			{
608 607
 				$acc = Mail\Account::read($_content['mailaccount']);
609 608
 				//error_log(__METHOD__.__LINE__.array2string($acc));
610
-				$Identities = Mail\Account::read_identity($acc['ident_id'],true);
609
+				$Identities = Mail\Account::read_identity($acc['ident_id'], true);
611 610
 				//error_log(__METHOD__.__LINE__.array2string($Identities));
612 611
 				if ($Identities['ident_id'])
613 612
 				{
@@ -620,41 +619,41 @@  discard block
 block discarded – undo
620 619
 				}
621 620
 			}
622 621
 			$_oldSig = $composeCache['mailidentity'];
623
-			$_signatureid = ($newSig?$newSig:$_content['mailidentity']);
622
+			$_signatureid = ($newSig ? $newSig : $_content['mailidentity']);
624 623
 			$_currentMode = $_content['mimeType'];
625 624
 			if ($_oldSig != $_signatureid)
626 625
 			{
627
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
626
+				if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
628 627
 				// prepare signatures, the selected sig may be used on top of the body
629 628
 				try
630 629
 				{
631
-					$oldSignature = Mail\Account::read_identity($_oldSig,true);
630
+					$oldSignature = Mail\Account::read_identity($_oldSig, true);
632 631
 					//error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#');
633 632
 					$oldSigText = $oldSignature['ident_signature'];
634 633
 				}
635 634
 				catch (Exception $e)
636 635
 				{
637
-					$oldSignature=array();
636
+					$oldSignature = array();
638 637
 					$oldSigText = null;
639 638
 				}
640 639
 				try
641 640
 				{
642
-					$signature = Mail\Account::read_identity($_signatureid,true);
641
+					$signature = Mail\Account::read_identity($_signatureid, true);
643 642
 					//error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#');
644 643
 					$sigText = $signature['ident_signature'];
645 644
 				}
646 645
 				catch (Exception $e)
647 646
 				{
648
-					$signature=array();
647
+					$signature = array();
649 648
 					$sigText = null;
650 649
 				}
651 650
 				//error_log(__METHOD__.'Old:'.$oldSigText.'#');
652 651
 				//error_log(__METHOD__.'New:'.$sigText.'#');
653 652
 				if ($_currentMode == 'plain')
654 653
 				{
655
-					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
656
-					$sigText = $this->convertHTMLToText($sigText,true,true);
657
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
654
+					$oldSigText = $this->convertHTMLToText($oldSigText, true, true);
655
+					$sigText = $this->convertHTMLToText($sigText, true, true);
656
+					if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
658 657
 				}
659 658
 
660 659
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -664,22 +663,22 @@  discard block
 block discarded – undo
664 663
 				$_htmlConfig = Mail::$htmLawed_config;
665 664
 				Mail::$htmLawed_config['comment'] = 2;
666 665
 				Mail::$htmLawed_config['transform_anchor'] = false;
667
-				$oldSigTextCleaned = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($oldSigText,null,array(),true):$oldSigText));
666
+				$oldSigTextCleaned = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), ($_currentMode == 'html' ? html::purify($oldSigText, null, array(), true) : $oldSigText));
668 667
 				//error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#');
669 668
 				if ($_currentMode == 'html')
670 669
 				{
671
-					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
670
+					$content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace
672 671
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
673
-					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
672
+					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
674 673
 				}
675
-				$content['body'] = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($content['body'],Mail::$htmLawed_config,array(),true):$content['body']));
674
+				$content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), ($_currentMode == 'html' ? html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']));
676 675
 				Mail::$htmLawed_config = $_htmlConfig;
677 676
 				if ($_currentMode == 'html')
678 677
 				{
679 678
 					$replaced = null;
680
-					$content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u',
681
-						$rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced);
682
-					$content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'&ndash;','&mdash;','&euro;'),$content['body']);
679
+					$content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u',
680
+						$rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced);
681
+					$content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '&ndash;', '&mdash;', '&euro;'), $content['body']);
683 682
 					//error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced");
684 683
 					unset($rep, $in);
685 684
 					if ($replaced)
@@ -690,32 +689,32 @@  discard block
 block discarded – undo
690 689
 					else
691 690
 					{
692 691
 						// try the old way
693
-						$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
692
+						$found = (strlen(trim($oldSigTextCleaned)) > 0 ? strpos($content['body'], trim($oldSigTextCleaned)) : false);
694 693
 					}
695 694
 				}
696 695
 				else
697 696
 				{
698
-					$found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false);
697
+					$found = (strlen(trim($oldSigTextCleaned)) > 0 ? strpos($content['body'], trim($oldSigTextCleaned)) : false);
699 698
 				}
700 699
 
701
-				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
700
+				if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
702 701
 				{
703 702
 					//error_log(__METHOD__.'Old Content:'.$content['body'].'#');
704
-					$_oldSigText = preg_quote($oldSigTextCleaned,'~');
703
+					$_oldSigText = preg_quote($oldSigTextCleaned, '~');
705 704
 					//error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#');
706
-					$content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1);
705
+					$content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1);
707 706
 					//error_log(__METHOD__.'new Content:'.$content['body'].'#');
708 707
 				}
709 708
 
710
-				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) ==''))
709
+				if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == ''))
711 710
 				{
712 711
 					// if there is no sig selected, there is no way to replace a signature
713 712
 				}
714 713
 
715 714
 				if ($found === false)
716 715
 				{
717
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
718
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
716
+					if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
717
+					if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
719 718
 				}
720 719
 				else
721 720
 				{
@@ -734,7 +733,7 @@  discard block
 block discarded – undo
734 733
 		if ($isFirstLoad)
735 734
 		{
736 735
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
737
-			if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
736
+			if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) &&
738 737
 				$this->mailPreferences['attachVCardAtCompose']))
739 738
 			{
740 739
 				$alwaysAttachVCardAtCompose = true;
@@ -743,7 +742,7 @@  discard block
 block discarded – undo
743 742
 					$f = $_REQUEST['preset']['file'];
744 743
 					$_REQUEST['preset']['file'] = array($f);
745 744
 				}
746
-				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry";
745
+				$_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry";
747 746
 			}
748 747
 			// an app passed the request for fetching and mailing an entry
749 748
 			if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))
@@ -752,33 +751,33 @@  discard block
 block discarded – undo
752 751
 				$mt = $_REQUEST['method'];
753 752
 				$id = $_REQUEST['id'];
754 753
 				// passed method MUST be registered
755
-				$method = Link::get_registry($app,$mt);
754
+				$method = Link::get_registry($app, $mt);
756 755
 				//error_log(__METHOD__.__LINE__.array2string($method));
757 756
 				if ($method)
758 757
 				{
759
-					$res = ExecMethod($method,array($id,'html'));
758
+					$res = ExecMethod($method, array($id, 'html'));
760 759
 					//error_log(__METHOD__.__LINE__.array2string($res));
761 760
 					if (!empty($res))
762 761
 					{
763 762
 						$insertSigOnTop = 'below';
764 763
 						if (isset($res['attachments']) && is_array($res['attachments']))
765 764
 						{
766
-							foreach($res['attachments'] as $f)
765
+							foreach ($res['attachments'] as $f)
767 766
 							{
768 767
 								$_REQUEST['preset']['file'][] = $f;
769 768
 							}
770 769
 						}
771 770
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
772
-						foreach(array('subject','body','mimetype') as $name) {
771
+						foreach (array('subject', 'body', 'mimetype') as $name) {
773 772
 							$sName = $name;
774
-							if ($name=='mimetype'&&$res[$name])
773
+							if ($name == 'mimetype' && $res[$name])
775 774
 							{
776 775
 								$sName = 'mimeType';
777 776
 								$content[$sName] = $res[$name];
778 777
 							}
779 778
 							else
780 779
 							{
781
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
780
+								if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name];
782 781
 							}
783 782
 						}
784 783
 					}
@@ -787,45 +786,45 @@  discard block
 block discarded – undo
787 786
 			// handle preset info/values
788 787
 			if (is_array($_REQUEST['preset']))
789 788
 			{
790
-				$alreadyProcessed=array();
789
+				$alreadyProcessed = array();
791 790
 				//_debug_array($_REQUEST);
792 791
 				if ($_REQUEST['preset']['mailto']) {
793 792
 					// handle mailto strings such as
794 793
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
795 794
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
796 795
 					// first, strip the mailto: string out of the mailto URL
797
-					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
796
+					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7)));
798 797
 					// check if there is more than the to address
799
-					$mailtoArray = explode('?',$tmp_send_to,2);
798
+					$mailtoArray = explode('?', $tmp_send_to, 2);
800 799
 					if ($mailtoArray[1]) {
801 800
 						// check if there are more than one requests
802
-						$addRequests = explode('&',$mailtoArray[1]);
801
+						$addRequests = explode('&', $mailtoArray[1]);
803 802
 						foreach ($addRequests as $key => $reqval) {
804 803
 							// the additional requests should have a =, to separate key from value.
805
-							$keyValuePair = explode('=',$reqval,2);
806
-							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
804
+							$keyValuePair = explode('=', $reqval, 2);
805
+							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1];
807 806
 						}
808 807
 					}
809
-					$content['to']=$mailtoArray[0];
810
-					$alreadyProcessed['to']='to';
808
+					$content['to'] = $mailtoArray[0];
809
+					$alreadyProcessed['to'] = 'to';
811 810
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
812
-					foreach(array('cc','bcc','subject','body') as $name) {
813
-						$alreadyProcessed[$name]=$name;
814
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
811
+					foreach (array('cc', 'bcc', 'subject', 'body') as $name) {
812
+						$alreadyProcessed[$name] = $name;
813
+						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name];
815 814
 					}
816 815
 				}
817 816
 
818 817
 				if ($_REQUEST['preset']['mailtocontactbyid']) {
819 818
 					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
820 819
 						$contacts_obj = new Api\Contacts();
821
-						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
822
-						if (method_exists($contacts_obj,'search')) {
820
+						$addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook'];
821
+						if (method_exists($contacts_obj, 'search')) {
823 822
 
824
-							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
823
+							$addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']);
825 824
 							foreach ((array)$addressArray as $id => $addressID)
826 825
 							{
827
-								$addressID = (int) $addressID;
828
-								if (!($addressID>0))
826
+								$addressID = (int)$addressID;
827
+								if (!($addressID > 0))
829 828
 								{
830 829
 									unset($addressArray[$id]);
831 830
 								}
@@ -834,44 +833,44 @@  discard block
 block discarded – undo
834 833
 							{
835 834
 								$_searchCond = array('contact_id'=>$addressArray);
836 835
 								//error_log(__METHOD__.__LINE__.$_searchString);
837
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
838
-								$filter = ($showAccounts?array():array('account_id' => null));
839
-								$filter['cols_to_search']=array('n_fn','email','email_home');
840
-								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
836
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts = false;
837
+								$filter = ($showAccounts ? array() : array('account_id' => null));
838
+								$filter['cols_to_search'] = array('n_fn', 'email', 'email_home');
839
+								$contacts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
841 840
 								// additionally search the accounts, if the contact storage is not the account storage
842 841
 								if ($showAccounts &&
843 842
 									$GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
844 843
 									$GLOBALS['egw_info']['server']['contact_repository'] == 'sql')
845 844
 								{
846
-									$accounts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0));
845
+									$accounts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0));
847 846
 
848 847
 									if ($contacts && $accounts)
849 848
 									{
850
-										$contacts = array_merge($contacts,$accounts);
851
-										usort($contacts,create_function('$a,$b','return strcasecmp($a["n_fn"],$b["n_fn"]);'));
849
+										$contacts = array_merge($contacts, $accounts);
850
+										usort($contacts, create_function('$a,$b', 'return strcasecmp($a["n_fn"],$b["n_fn"]);'));
852 851
 									}
853
-									elseif($accounts)
852
+									elseif ($accounts)
854 853
 									{
855
-										$contacts =& $accounts;
854
+										$contacts = & $accounts;
856 855
 									}
857 856
 									unset($accounts);
858 857
 								}
859 858
 							}
860
-							if(is_array($contacts)) {
859
+							if (is_array($contacts)) {
861 860
 								$mailtoArray = array();
862 861
 								$primary = $addressbookprefs['distributionListPreferredMail'];
863 862
 								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
864
-								$secondary = ($primary == 'email'?'email_home':'email');
863
+								$secondary = ($primary == 'email' ? 'email_home' : 'email');
865 864
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
866
-								foreach($contacts as $contact) {
867
-									$innerCounter=0;
868
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
865
+								foreach ($contacts as $contact) {
866
+									$innerCounter = 0;
867
+									foreach (array($contact[$primary], $contact[$secondary]) as $email) {
869 868
 										// use pref distributionListPreferredMail for the primary address
870 869
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
871
-										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
872
-										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
873
-										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
874
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
870
+										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email);
871
+										$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
872
+										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>');
873
+										if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) {
875 874
 											$i++;
876 875
 											$innerCounter++;
877 876
 											$mailtoArray[$i] = $completeMailString;
@@ -880,8 +879,8 @@  discard block
 block discarded – undo
880 879
 								}
881 880
 							}
882 881
 							//error_log(__METHOD__.__LINE__.array2string($mailtoArray));
883
-							$alreadyProcessed['to']='to';
884
-							$content['to']=$mailtoArray;
882
+							$alreadyProcessed['to'] = 'to';
883
+							$content['to'] = $mailtoArray;
885 884
 						}
886 885
 					}
887 886
 				}
@@ -896,20 +895,20 @@  discard block
 block discarded – undo
896 895
 					$types = (array)$_REQUEST['preset']['type'];
897 896
 					//if (!empty($types) && in_array('text/calendar; method=request',$types))
898 897
 					$files = (array)$_REQUEST['preset']['file'];
899
-					foreach($files as $k => $path)
898
+					foreach ($files as $k => $path)
900 899
 					{
901
-						if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false)
900
+						if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false)
902 901
 						{
903 902
 							$insertSigOnTop = 'below';
904 903
 						}
905 904
 						//error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs')));
906
-						if (parse_url($path,PHP_URL_SCHEME == 'vfs'))
905
+						if (parse_url($path, PHP_URL_SCHEME == 'vfs'))
907 906
 						{
908 907
 							//Vfs::load_wrapper('vfs');
909 908
 							$type = Vfs::mime_content_type($path);
910 909
 							// special handling for attaching vCard of iCal --> use their link-title as name
911
-							if (substr($path,-7) != '/.entry' ||
912
-								!(list($app,$id) = array_slice(explode('/',$path),-3)) ||
910
+							if (substr($path, -7) != '/.entry' ||
911
+								!(list($app, $id) = array_slice(explode('/', $path), -3)) ||
913 912
 								!($name = Link::title($app, $id)))
914 913
 							{
915 914
 								$name = Vfs::decodePath(Vfs::basename($path));
@@ -923,7 +922,7 @@  discard block
 block discarded – undo
923 922
 							{
924 923
 								$type = $types[$k];
925 924
 							}
926
-							$path = str_replace('+','%2B',$path);
925
+							$path = str_replace('+', '%2B', $path);
927 926
 							$formData = array(
928 927
 								'name' => $name,
929 928
 								'type' => $type,
@@ -936,7 +935,7 @@  discard block
 block discarded – undo
936 935
 								Framework::message(lang('Directories have to be shared.'), 'info');
937 936
 							}
938 937
 						}
939
-						elseif(is_readable($path))
938
+						elseif (is_readable($path))
940 939
 						{
941 940
 							$formData = array(
942 941
 								'name' => isset($names[$k]) ? $names[$k] : basename($path),
@@ -949,28 +948,28 @@  discard block
 block discarded – undo
949 948
 						{
950 949
 							continue;
951 950
 						}
952
-						$this->addAttachment($formData,$content,($alwaysAttachVCardAtCompose?true:false));
951
+						$this->addAttachment($formData, $content, ($alwaysAttachVCardAtCompose ? true : false));
953 952
 					}
954 953
 					$remember = array();
955 954
 					if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])))
956 955
 					{
957
-						foreach(array_keys($content) as $k)
956
+						foreach (array_keys($content) as $k)
958 957
 						{
959
-							if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k]))
958
+							if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k]))
960 959
 							{
961
-								$alreadyProcessed[$k]=$k;
960
+								$alreadyProcessed[$k] = $k;
962 961
 								$remember[$k] = $this->sessionData[$k];
963 962
 							}
964 963
 						}
965 964
 					}
966
-					if(!empty($remember)) $content = array_merge($content,$remember);
965
+					if (!empty($remember)) $content = array_merge($content, $remember);
967 966
 				}
968
-				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
967
+				foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name)
969 968
 				{
970 969
 					//always handle mimeType
971
-					if ($name=='mimeType' && $_REQUEST['preset'][$name])
970
+					if ($name == 'mimeType' && $_REQUEST['preset'][$name])
972 971
 					{
973
-						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
972
+						$_content[$name] = $content[$name] = $_REQUEST['preset'][$name];
974 973
 					}
975 974
 					//skip if already processed by "preset Routines"
976 975
 					if ($alreadyProcessed[$name]) continue;
@@ -983,36 +982,36 @@  discard block
 block discarded – undo
983 982
 			{
984 983
 				$content['to'] = base64_decode($_REQUEST['send_to']);
985 984
 				// first check if there is a questionmark or ampersand
986
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
985
+				if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2);
987 986
 				$content['to'] = html_entity_decode($content['to']);
988
-				if (($at_pos = strpos($content['to'],'@')) !== false)
987
+				if (($at_pos = strpos($content['to'], '@')) !== false)
989 988
 				{
990
-					if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false)
989
+					if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false)
991 990
 					{
992 991
 						//list($email,$addoptions) = explode('&',$value,2);
993
-						$email = substr($content['to'],0,$amp_pos+$at_pos);
994
-						$rest = substr($content['to'], $amp_pos+$at_pos+1);
992
+						$email = substr($content['to'], 0, $amp_pos + $at_pos);
993
+						$rest = substr($content['to'], $amp_pos + $at_pos + 1);
995 994
 						//error_log(__METHOD__.__LINE__.$email.' '.$rest);
996 995
 						$content['to'] = $email;
997 996
 					}
998 997
 				}
999
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
998
+				if (strpos($content['to'], '%40') !== false) $content['to'] = Api\Html::purify(str_replace('%40', '@', $content['to']));
1000 999
 				$rarr = array(Api\Html::purify($rest));
1001
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1000
+				if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest);
1002 1001
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1003 1002
 				$karr = array();
1004 1003
 				foreach ($rarr as &$rval)
1005 1004
 				{
1006 1005
 					//must contain =
1007
-					if (strpos($rval,'=')!== false)
1006
+					if (strpos($rval, '=') !== false)
1008 1007
 					{
1009
-						list($k,$v) = explode('=',$rval,2);
1008
+						list($k, $v) = explode('=', $rval, 2);
1010 1009
 						$karr[$k] = (string)$v;
1011
-						unset($k,$v);
1010
+						unset($k, $v);
1012 1011
 					}
1013 1012
 				}
1014 1013
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1015
-				foreach(array('cc','bcc','subject','body') as $name)
1014
+				foreach (array('cc', 'bcc', 'subject', 'body') as $name)
1016 1015
 				{
1017 1016
 					if ($karr[$name]) $content[$name] = $karr[$name];
1018 1017
 				}
@@ -1024,17 +1023,17 @@  discard block
 block discarded – undo
1024 1023
 		if ($isFirstLoad && !empty($_REQUEST['mimeType']))
1025 1024
 		{
1026 1025
 			$_content['mimeType'] = $content['mimeType'];
1027
-			if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html')
1026
+			if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html')
1028 1027
 			{
1029
-				$_content['mimeType'] = $content['mimeType']  = 'plain';
1030
-				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1028
+				$_content['mimeType'] = $content['mimeType'] = 'plain';
1029
+				$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1031 1030
 			}
1032
-			if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html')
1031
+			if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html')
1033 1032
 			{
1034
-				$_content['mimeType'] = $content['mimeType']  = 'html';
1033
+				$_content['mimeType'] = $content['mimeType'] = 'html';
1035 1034
 				$content['body'] = "<pre>".$content['body']."</pre>";
1036 1035
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1037
-				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);
1036
+				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);
1038 1037
 			}
1039 1038
 		}
1040 1039
 		else
@@ -1042,24 +1041,24 @@  discard block
 block discarded – undo
1042 1041
 			// try to enforce a mimeType on reply ( if type is not of the wanted type )
1043 1042
 			if ($isReply)
1044 1043
 			{
1045
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" &&
1044
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" &&
1046 1045
 					$content['mimeType'] == 'html')
1047 1046
 				{
1048
-					$_content['mimeType'] = $content['mimeType']  = 'plain';
1049
-					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body']));
1047
+					$_content['mimeType'] = $content['mimeType'] = 'plain';
1048
+					$content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body']));
1050 1049
 				}
1051
-				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" &&
1050
+				if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" &&
1052 1051
 					$content['mimeType'] != 'html')
1053 1052
 				{
1054
-					$_content['mimeType'] = $content['mimeType']  = 'html';
1053
+					$_content['mimeType'] = $content['mimeType'] = 'html';
1055 1054
 					$content['body'] = "<pre>".$content['body']."</pre>";
1056 1055
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1057
-					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);
1056
+					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);
1058 1057
 				}
1059 1058
 			}
1060 1059
 		}
1061 1060
 
1062
-		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false)
1061
+		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible() === false)
1063 1062
 		{
1064 1063
 			$_content['mimeType'] = $content['mimeType'] = 'plain';
1065 1064
 			$content['body'] = $this->convertHTMLToText($content['body']);
@@ -1078,36 +1077,36 @@  discard block
 block discarded – undo
1078 1077
 		//_debug_array(($presetSig ? $presetSig : $content['mailidentity']));
1079 1078
 		try
1080 1079
 		{
1081
-			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true);
1080
+			$signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true);
1082 1081
 		}
1083 1082
 		catch (Exception $e)
1084 1083
 		{
1085 1084
 			//PROBABLY NOT FOUND
1086
-			$signature=array();
1085
+			$signature = array();
1087 1086
 		}
1088 1087
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
1089 1088
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
1090
-			empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='')
1089
+			empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '')
1091 1090
 		{
1092 1091
 			$disableRuler = true;
1093 1092
 		}
1094 1093
 		$font_span = $font_part = '';
1095
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1094
+		if ($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1096 1095
 			// User preferences for style
1097 1096
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1098 1097
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1099
-			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1098
+			$font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">';
1100 1099
 			$font_span = $font_part.'&#8203;</span>';
1101 1100
 			if (empty($font) && empty($font_size)) $font_span = '';
1102 1101
 		}
1103 1102
 		// 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
1104
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1103
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = '';
1105 1104
 		//remove possible html header stuff
1106
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1105
+		if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']);
1107 1106
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1108
-		$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');
1109
-		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1110
-			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1107
+		$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');
1108
+		if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' &&
1109
+			!(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop
1111 1110
 		)
1112 1111
 		{
1113 1112
 			// ON tOP OR BELOW? pREF CAN TELL
@@ -1117,54 +1116,54 @@  discard block
 block discarded – undo
1117 1116
 						'1' => 'before reply, visible during compose',
1118 1117
 						'no_belowaftersend'  => 'appended after reply before sending',
1119 1118
 			*/
1120
-			$insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below'));
1121
-			$sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
1119
+			$insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below'));
1120
+			$sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')));
1122 1121
 			if ($content['mimeType'] == 'html')
1123 1122
 			{
1124
-				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1125
-				foreach($blockElements as $e)
1123
+				$sigTextStartsWithBlockElement = ($disableRuler ? false : true);
1124
+				foreach ($blockElements as $e)
1126 1125
 				{
1127 1126
 					if ($sigTextStartsWithBlockElement) break;
1128
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1127
+					if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true;
1129 1128
 				}
1130 1129
 			}
1131
-			if($content['mimeType'] == 'html') {
1130
+			if ($content['mimeType'] == 'html') {
1132 1131
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1133 1132
 				$inbetween = '';
1134 1133
 			} else {
1135
-				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1134
+				$before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n");
1136 1135
 				$inbetween = "\r\n";
1137 1136
 			}
1138 1137
 			if ($content['mimeType'] == 'html')
1139 1138
 			{
1140
-				$sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>");
1139
+				$sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>");
1141 1140
 			}
1142 1141
 
1143 1142
 			if ($insertSigOnTop === 'below')
1144 1143
 			{
1145
-				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true));
1144
+				$content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true));
1146 1145
 			}
1147 1146
 			else
1148 1147
 			{
1149
-				$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
1148
+				$content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body'];
1150 1149
 			}
1151 1150
 		}
1152 1151
 		else
1153 1152
 		{
1154
-			$content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):/*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml"?"</span>":"");
1153
+			$content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : /*($content['mimeType'] == 'html'?'&nbsp;':'')*/'').$content['body'].($isFirstLoad === "switchedplaintohtml" ? "</span>" : "");
1155 1154
 		}
1156 1155
 		//error_log(__METHOD__.__LINE__.$content['body']);
1157 1156
 
1158 1157
 		// prepare body
1159 1158
 		// 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
1160
-		$content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8');
1159
+		$content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8');
1161 1160
 		//error_log(__METHOD__.__LINE__.array2string($content));
1162 1161
 
1163 1162
 		// get identities of all accounts as "$acc_id:$ident_id" => $identity
1164 1163
 		$sel_options['mailaccount'] = $identities = array();
1165
-		foreach(Mail\Account::search(true,false) as $acc_id => $account)
1164
+		foreach (Mail\Account::search(true, false) as $acc_id => $account)
1166 1165
 		{
1167
-			foreach($account->identities($acc_id) as $ident_id => $identity)
1166
+			foreach ($account->identities($acc_id) as $ident_id => $identity)
1168 1167
 			{
1169 1168
 				$sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity;
1170 1169
 				$identities[$ident_id] = $identity;
@@ -1175,7 +1174,7 @@  discard block
 block discarded – undo
1175 1174
 		//$content['bcc'] = array('[email protected]','[email protected]');
1176 1175
 		// address stuff like from, to, cc, replyto
1177 1176
 		$destinationRows = 0;
1178
-		foreach(self::$destinations as $destination) {
1177
+		foreach (self::$destinations as $destination) {
1179 1178
 			if (!is_array($content[$destination]))
1180 1179
 			{
1181 1180
 				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
@@ -1183,22 +1182,22 @@  discard block
 block discarded – undo
1183 1182
 			$addr_content = $content[strtolower($destination)];
1184 1183
 			// we clear the given address array and rebuild it
1185 1184
 			unset($content[strtolower($destination)]);
1186
-			foreach((array)$addr_content as $key => $value) {
1187
-				if ($value=="NIL@NIL") continue;
1188
-				if ($destination=='replyto' && str_replace('"','',$value) ==
1189
-					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1185
+			foreach ((array)$addr_content as $key => $value) {
1186
+				if ($value == "NIL@NIL") continue;
1187
+				if ($destination == 'replyto' && str_replace('"', '', $value) ==
1188
+					str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()]))
1190 1189
 				{
1191 1190
 					// preserve/restore the value to content.
1192
-					$content[strtolower($destination)][]=$value;
1191
+					$content[strtolower($destination)][] = $value;
1193 1192
 					continue;
1194 1193
 				}
1195 1194
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1196
-				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1197
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1195
+				$value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT));
1196
+				foreach (Mail::parseAddressList($value) as $addressObject) {
1198 1197
 					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1199
-					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1198
+					$address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
1200 1199
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1201
-					$content[strtolower($destination)][]=$address;
1200
+					$content[strtolower($destination)][] = $address;
1202 1201
 					$destinationRows++;
1203 1202
 				}
1204 1203
 			}
@@ -1206,10 +1205,10 @@  discard block
 block discarded – undo
1206 1205
 		if ($_content)
1207 1206
 		{
1208 1207
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1209
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1210
-			$content = array_merge($content,$_content);
1208
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']);
1209
+			$content = array_merge($content, $_content);
1211 1210
 
1212
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1211
+			if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true);
1213 1212
 			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1214 1213
 		}
1215 1214
 		else
@@ -1218,12 +1217,12 @@  discard block
 block discarded – undo
1218 1217
 			$content['mailaccount'] = $this->mail_bo->profileID;
1219 1218
 			//error_log(__METHOD__.__LINE__.$content['body']);
1220 1219
 		}
1221
-		$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
1222
-		$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
1223
-		$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body'];
1224
-		$content['showtempname']=0;
1220
+		$content['is_html'] = ($content['mimeType'] == 'html' ? true : '');
1221
+		$content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true);
1222
+		$content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body'];
1223
+		$content['showtempname'] = 0;
1225 1224
 		//if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments']));
1226
-		$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)));
1225
+		$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)));
1227 1226
 		//if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0;
1228 1227
 		$content['no_griddata'] = empty($content['attachments']);
1229 1228
 		$preserv['attachments'] = $content['attachments'];
@@ -1257,12 +1256,12 @@  discard block
 block discarded – undo
1257 1256
 		$sel_options['mimeType'] = self::$mimeTypes;
1258 1257
 		$sel_options['priority'] = self::$priorities;
1259 1258
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1260
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1259
+		if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3;
1261 1260
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1262 1261
 		$etpl = new Etemplate('mail.compose');
1263 1262
 
1264 1263
 		$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content));
1265
-		if ($content['mimeType']=='html')
1264
+		if ($content['mimeType'] == 'html')
1266 1265
 		{
1267 1266
 			//mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]"
1268 1267
 			$_htmlConfig = Mail::$htmLawed_config;
@@ -1272,23 +1271,23 @@  discard block
 block discarded – undo
1272 1271
 			// and not the eGroupware wide pref to prevent users from trying things that will potentially not work
1273 1272
 			// or not work as expected, as a full featured editor that may be wanted in other apps
1274 1273
 			// is way overloading the "normal" needs for composing mails
1275
-			$content['rtfEditorFeatures']='simple-withimage';//Api\Html\CkEditorConfig::get_ckeditor_config();
1274
+			$content['rtfEditorFeatures'] = 'simple-withimage'; //Api\Html\CkEditorConfig::get_ckeditor_config();
1276 1275
 			//$content['rtfEditorFeatures']='advanced';//Api\Html\CkEditorConfig::get_ckeditor_config();
1277
-			$content['validation_rules']= json_encode(Mail::$htmLawed_config);
1278
-			$etpl->setElementAttribute('mail_htmltext','mode',$content['rtfEditorFeatures']);
1279
-			$etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']);
1276
+			$content['validation_rules'] = json_encode(Mail::$htmLawed_config);
1277
+			$etpl->setElementAttribute('mail_htmltext', 'mode', $content['rtfEditorFeatures']);
1278
+			$etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']);
1280 1279
 			Mail::$htmLawed_config = $_htmlConfig;
1281 1280
 		}
1282 1281
 
1283
-		if (isset($content['composeID'])&&!empty($content['composeID']))
1282
+		if (isset($content['composeID']) && !empty($content['composeID']))
1284 1283
 		{
1285 1284
 			$composeCache = $content;
1286 1285
 			unset($composeCache['body']);
1287 1286
 			unset($composeCache['mail_htmltext']);
1288 1287
 			unset($composeCache['mail_plaintext']);
1289
-			Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2);
1288
+			Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2);
1290 1289
 		}
1291
-		if (!isset($_content['serverID'])||empty($_content['serverID']))
1290
+		if (!isset($_content['serverID']) || empty($_content['serverID']))
1292 1291
 		{
1293 1292
 			$content['serverID'] = $this->mail_bo->profileID;
1294 1293
 		}
@@ -1304,25 +1303,25 @@  discard block
 block discarded – undo
1304 1303
 		$preserv['list-id'] = $content['list-id'];
1305 1304
 		$preserv['mode'] = $content['mode'];
1306 1305
 		// convert it back to checkbox expectations
1307
-		if($content['mimeType'] == 'html') {
1308
-			$content['mimeType']=1;
1306
+		if ($content['mimeType'] == 'html') {
1307
+			$content['mimeType'] = 1;
1309 1308
 		} else {
1310
-			$content['mimeType']=0;
1309
+			$content['mimeType'] = 0;
1311 1310
 		}
1312 1311
 		// set the current selected mailaccount as param for folderselection
1313
-		$etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount']));
1312
+		$etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount']));
1314 1313
 		// join again mailaccount and identity
1315 1314
 		$content['mailaccount'] .= ':'.$content['mailidentity'];
1316 1315
 
1317 1316
 		// Resolve distribution list before send content to client
1318
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1317
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $f)
1319 1318
 		{
1320
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1319
+			if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]);
1321 1320
 		}
1322 1321
 
1323 1322
 		$content['to'] = self::resolveEmailAddressList($content['to']);
1324 1323
 		//error_log(__METHOD__.__LINE__.array2string($content));
1325
-		$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
1324
+		$etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2);
1326 1325
 	}
1327 1326
 
1328 1327
 	/**
@@ -1343,9 +1342,9 @@  discard block
 block discarded – undo
1343 1342
 		$content = array();
1344 1343
 		//error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply");
1345 1344
 		// on forward we may have to support multiple ids
1346
-		if ($from=='forward')
1345
+		if ($from == 'forward')
1347 1346
 		{
1348
-			$replyIds = explode(',',$mail_id);
1347
+			$replyIds = explode(',', $mail_id);
1349 1348
 			$mail_id = $replyIds[0];
1350 1349
 		}
1351 1350
 		$hA = mail_ui::splitRowID($mail_id);
@@ -1357,15 +1356,15 @@  discard block
 block discarded – undo
1357 1356
 			$this->changeProfile($icServerID);
1358 1357
 		}
1359 1358
 		$icServer = $this->mail_bo->icServer;
1360
-		if (!empty($folder) && !empty($msgUID) )
1359
+		if (!empty($folder) && !empty($msgUID))
1361 1360
 		{
1362 1361
 			// this fill the session data with the values from the original email
1363
-			switch($from)
1362
+			switch ($from)
1364 1363
 			{
1365 1364
 				case 'composefromdraft':
1366 1365
 				case 'composeasnew':
1367 1366
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1368
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1367
+					if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft';
1369 1368
 					$content['processedmail_id'] = $mail_id;
1370 1369
 
1371 1370
 					$_focusElement = 'body';
@@ -1381,7 +1380,7 @@  discard block
 block discarded – undo
1381 1380
 					$isReply = true;
1382 1381
 					break;
1383 1382
 				case 'forward':
1384
-					$mode  = ($_GET['mode']=='forwardinline'?'inline':'asmail');
1383
+					$mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail');
1385 1384
 					// this fill the session data with the values from the original email
1386 1385
 					foreach ($replyIds as &$mail_id)
1387 1386
 					{
@@ -1391,14 +1390,14 @@  discard block
 block discarded – undo
1391 1390
 						$folder = $hA['folder'];
1392 1391
 						$content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode);
1393 1392
 					}
1394
-					$content['processedmail_id'] = implode(',',$replyIds);
1393
+					$content['processedmail_id'] = implode(',', $replyIds);
1395 1394
 					$content['mode'] = 'forward';
1396
-					$isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline');
1397
-					$suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution
1395
+					$isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline');
1396
+					$suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution
1398 1397
 					$_focusElement = 'to';
1399 1398
 					break;
1400 1399
 				default:
1401
-					error_log('Unhandled compose source: ' . $from);
1400
+					error_log('Unhandled compose source: '.$from);
1402 1401
 			}
1403 1402
 		}
1404 1403
 		else if ($from == 'merge' && $_REQUEST['document'])
@@ -1413,12 +1412,12 @@  discard block
 block discarded – undo
1413 1412
 			$document_merge = new $merge_class();
1414 1413
 			$this->mail_bo->openConnection();
1415 1414
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1416
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1415
+			if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids);
1417 1416
 			try
1418 1417
 			{
1419 1418
 				$merged_mail_id = '';
1420 1419
 				$folder = '';
1421
-				if(($error = $document_merge->check_document($_REQUEST['document'],'')))
1420
+				if (($error = $document_merge->check_document($_REQUEST['document'], '')))
1422 1421
 				{
1423 1422
 					$content['msg'] = $error;
1424 1423
 					return $content;
@@ -1428,10 +1427,10 @@  discard block
 block discarded – undo
1428 1427
 				//$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
1429 1428
 
1430 1429
 				// Actually do the merge
1431
-				if(count($merge_ids) <= 1)
1430
+				if (count($merge_ids) <= 1)
1432 1431
 				{
1433 1432
 					$results = $this->mail_bo->importMessageToMergeAndSend(
1434
-						$document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1433
+						$document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id
1435 1434
 					);
1436 1435
 
1437 1436
 					// Open compose
@@ -1442,9 +1441,9 @@  discard block
 block discarded – undo
1442 1441
 				}
1443 1442
 				else
1444 1443
 				{
1445
-					$success = implode(', ',$results['success']);
1444
+					$success = implode(', ', $results['success']);
1446 1445
 					$fail = implode(', ', $results['failed']);
1447
-					if($success) Framework::message($success, 'success');
1446
+					if ($success) Framework::message($success, 'success');
1448 1447
 					Framework::window_close($fail);
1449 1448
 				}
1450 1449
 			}
@@ -1472,22 +1471,22 @@  discard block
 block discarded – undo
1472 1471
 		return 1;
1473 1472
 	}
1474 1473
 
1475
-	function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false)
1474
+	function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false)
1476 1475
 	{
1477 1476
 		$stripalltags = true;
1478 1477
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1479
-		if (!$sourceishtml) $stripalltags=false;
1480
-		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1478
+		if (!$sourceishtml) $stripalltags = false;
1479
+		return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags);
1481 1480
 	}
1482 1481
 
1483 1482
 	function generateRFC822Address($_addressObject)
1484 1483
 	{
1485
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1486
-			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1487
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1488
-			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1484
+		if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1485
+			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1486
+		} elseif ($_addressObject->mailbox && $_addressObject->host) {
1487
+			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE'));
1489 1488
 		} else {
1490
-			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1489
+			return $this->mail_bo->decode_header($_addressObject->mailbox, true);
1491 1490
 		}
1492 1491
 	}
1493 1492
 
@@ -1502,9 +1501,9 @@  discard block
 block discarded – undo
1502 1501
 	// $_mode can be:
1503 1502
 	// single: for a reply to one address
1504 1503
 	// all: for a reply to all
1505
-	function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL)
1504
+	function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL)
1506 1505
 	{
1507
-		unset($_icServer);	// not used
1506
+		unset($_icServer); // not used
1508 1507
 		$this->sessionData['to'] = array();
1509 1508
 
1510 1509
 		$mail_bo = $this->mail_bo;
@@ -1513,7 +1512,7 @@  discard block
 block discarded – undo
1513 1512
 
1514 1513
 		// get message headers for specified message
1515 1514
 		#$headers	= $mail_bo->getMessageHeader($_folder, $_uid);
1516
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID);
1515
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
1517 1516
 		$addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID);
1518 1517
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1519 1518
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
@@ -1521,10 +1520,10 @@  discard block
 block discarded – undo
1521 1520
 
1522 1521
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1523 1522
 		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1524
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1525
-				$fval=$val;
1523
+			foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) {
1524
+				$fval = $val;
1526 1525
 				$icServerID = $mail_bo->icServer->ImapServerId;
1527
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1526
+				if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2);
1528 1527
 				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1529 1528
 				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1530 1529
 			}
@@ -1560,71 +1559,71 @@  discard block
 block discarded – undo
1560 1559
 			}
1561 1560
 		}
1562 1561
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1563
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1562
+		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder);
1564 1563
 		$this->sessionData['uid'] = $_uid;
1565 1564
 		$this->sessionData['messageFolder'] = $_folder;
1566 1565
 		$this->sessionData['isDraft'] = true;
1567 1566
 		$foundAddresses = array();
1568
-		foreach((array)$headers['CC'] as $val) {
1569
-			$rfcAddr=Mail::parseAddressList($val);
1567
+		foreach ((array)$headers['CC'] as $val) {
1568
+			$rfcAddr = Mail::parseAddressList($val);
1570 1569
 			$_rfcAddr = $rfcAddr[0];
1571 1570
 			if (!$_rfcAddr->valid) continue;
1572
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1571
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1573 1572
 				continue;
1574 1573
 			}
1575
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1576
-			if(!$foundAddresses[$keyemail]) {
1577
-				$address = $this->mail_bo->decode_header($val,true);
1574
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1575
+			if (!$foundAddresses[$keyemail]) {
1576
+				$address = $this->mail_bo->decode_header($val, true);
1578 1577
 				$this->sessionData['cc'][] = $val;
1579 1578
 				$foundAddresses[$keyemail] = true;
1580 1579
 			}
1581 1580
 		}
1582 1581
 
1583
-		foreach((array)$headers['TO'] as $val) {
1584
-			if(!is_array($val))
1582
+		foreach ((array)$headers['TO'] as $val) {
1583
+			if (!is_array($val))
1585 1584
 			{
1586 1585
 				$this->sessionData['to'][] = $val;
1587 1586
 				continue;
1588 1587
 			}
1589
-			$rfcAddr=Mail::parseAddressList($val);
1588
+			$rfcAddr = Mail::parseAddressList($val);
1590 1589
 			$_rfcAddr = $rfcAddr[0];
1591 1590
 			if (!$_rfcAddr->valid) continue;
1592
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1591
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) {
1593 1592
 				continue;
1594 1593
 			}
1595
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1596
-			if(!$foundAddresses[$keyemail]) {
1597
-				$address = $this->mail_bo->decode_header($val,true);
1594
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1595
+			if (!$foundAddresses[$keyemail]) {
1596
+				$address = $this->mail_bo->decode_header($val, true);
1598 1597
 				$this->sessionData['to'][] = $val;
1599 1598
 				$foundAddresses[$keyemail] = true;
1600 1599
 			}
1601 1600
 		}
1602 1601
 
1603
-		foreach((array)$headers['REPLY-TO'] as $val) {
1604
-			$rfcAddr=Mail::parseAddressList($val);
1602
+		foreach ((array)$headers['REPLY-TO'] as $val) {
1603
+			$rfcAddr = Mail::parseAddressList($val);
1605 1604
 			$_rfcAddr = $rfcAddr[0];
1606 1605
 			if (!$_rfcAddr->valid) continue;
1607
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1606
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_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['replyto'][] = $val;
1614 1613
 				$foundAddresses[$keyemail] = true;
1615 1614
 			}
1616 1615
 		}
1617 1616
 
1618
-		foreach((array)$headers['BCC'] as $val) {
1619
-			$rfcAddr=Mail::parseAddressList($val);
1617
+		foreach ((array)$headers['BCC'] as $val) {
1618
+			$rfcAddr = Mail::parseAddressList($val);
1620 1619
 			$_rfcAddr = $rfcAddr[0];
1621 1620
 			if (!$_rfcAddr->valid) continue;
1622
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1621
+			if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) {
1623 1622
 				continue;
1624 1623
 			}
1625
-			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1626
-			if(!$foundAddresses[$keyemail]) {
1627
-				$address = $this->mail_bo->decode_header($val,true);
1624
+			$keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1625
+			if (!$foundAddresses[$keyemail]) {
1626
+				$address = $this->mail_bo->decode_header($val, true);
1628 1627
 				$this->sessionData['bcc'][] = $val;
1629 1628
 				$foundAddresses[$keyemail] = true;
1630 1629
 			}
@@ -1633,48 +1632,48 @@  discard block
 block discarded – undo
1633 1632
 		$this->sessionData['subject']	= $mail_bo->decode_header($headers['SUBJECT']);
1634 1633
 		// remove a printview tag if composing
1635 1634
 		$searchfor = '/^\['.lang('printview').':\]/';
1636
-		$this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']);
1637
-		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1635
+		$this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']);
1636
+		$bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID);
1638 1637
 		//_debug_array($bodyParts);
1639 1638
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1640
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1641
-			$this->sessionData['mimeType'] 	= 'html';
1639
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
1640
+			$this->sessionData['mimeType'] = 'html';
1642 1641
 
1643
-			for($i=0; $i<count($bodyParts); $i++) {
1644
-				if($i>0) {
1642
+			for ($i = 0; $i < count($bodyParts); $i++) {
1643
+				if ($i > 0) {
1645 1644
 					$this->sessionData['body'] .= '<hr>';
1646 1645
 				}
1647
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1646
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
1648 1647
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1649 1648
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1650 1649
 				}
1651
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1650
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1652 1651
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1653 1652
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1654
-				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1653
+				$this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body'];
1655 1654
 			}
1656 1655
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1657 1656
 
1658 1657
 		} else {
1659
-			$this->sessionData['mimeType']	= 'plain';
1658
+			$this->sessionData['mimeType'] = 'plain';
1660 1659
 
1661
-			for($i=0; $i<count($bodyParts); $i++) {
1662
-				if($i>0) {
1660
+			for ($i = 0; $i < count($bodyParts); $i++) {
1661
+				if ($i > 0) {
1663 1662
 					$this->sessionData['body'] .= "<hr>";
1664 1663
 				}
1665
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1664
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1666 1665
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1667 1666
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1668
-				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
1667
+				$this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body'];
1669 1668
 			}
1670
-			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1669
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain');
1671 1670
 		}
1672 1671
 
1673
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1674
-			foreach($attachments as $attachment) {
1672
+		if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1673
+			foreach ($attachments as $attachment) {
1675 1674
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1676 1675
 				$cid = $attachment['cid'];
1677
-				$match=null;
1676
+				$match = null;
1678 1677
 				preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match);
1679 1678
 				//error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match));
1680 1679
 				if (!$match || !$attachment['cid'])
@@ -1693,7 +1692,7 @@  discard block
 block discarded – undo
1693 1692
 
1694 1693
 	function getErrorInfo()
1695 1694
 	{
1696
-		if(isset($this->errorInfo)) {
1695
+		if (isset($this->errorInfo)) {
1697 1696
 			$errorInfo = $this->errorInfo;
1698 1697
 			unset($this->errorInfo);
1699 1698
 			return $errorInfo;
@@ -1701,39 +1700,39 @@  discard block
 block discarded – undo
1701 1700
 		return false;
1702 1701
 	}
1703 1702
 
1704
-	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false)
1703
+	function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false)
1705 1704
 	{
1706 1705
 		if ($_mode)
1707 1706
 		{
1708 1707
 			$modebuff = $this->mailPreferences['message_forwarding'];
1709 1708
 			$this->mailPreferences['message_forwarding'] = $_mode;
1710 1709
 		}
1711
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1710
+		if ($this->mailPreferences['message_forwarding'] == 'inline') {
1712 1711
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1713 1712
 		}
1714
-		$mail_bo    = $this->mail_bo;
1713
+		$mail_bo = $this->mail_bo;
1715 1714
 		$mail_bo->openConnection();
1716 1715
 		$mail_bo->reopen($_folder);
1717 1716
 
1718 1717
 		// get message headers for specified message
1719
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder);
1718
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder);
1720 1719
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1721 1720
 		//_debug_array($headers); exit;
1722 1721
 		// check for Re: in subject header
1723
-		$this->sessionData['subject'] 	= "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']);
1722
+		$this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']);
1724 1723
 		// the three attributes below are substituted by processedmail_id and mode
1725 1724
 		//$this->sessionData['sourceFolder']=$_folder;
1726 1725
 		//$this->sessionData['forwardFlag']='forwarded';
1727 1726
 		//$this->sessionData['forwardedUID']=$_uid;
1728
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1729
-			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1730
-			if($headers['SIZE'])
1727
+		if ($this->mailPreferences['message_forwarding'] == 'asmail') {
1728
+			$this->sessionData['mimeType'] = $this->mailPreferences['composeOptions'];
1729
+			if ($headers['SIZE'])
1731 1730
 				$size				= $headers['SIZE'];
1732 1731
 			else
1733 1732
 				$size				= lang('unknown');
1734 1733
 
1735 1734
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1736
-				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
1735
+				$mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml',
1737 1736
 				'MESSAGE/RFC822', $size);
1738 1737
 		}
1739 1738
 		else
@@ -1741,10 +1740,10 @@  discard block
 block discarded – undo
1741 1740
 			unset($this->sessionData['in-reply-to']);
1742 1741
 			unset($this->sessionData['to']);
1743 1742
 			unset($this->sessionData['cc']);
1744
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1743
+			if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) {
1745 1744
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1746
-				foreach($attachments as $attachment) {
1747
-					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])))
1745
+				foreach ($attachments as $attachment) {
1746
+					if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])))
1748 1747
 					{
1749 1748
 						$this->addMessageAttachment($_uid, $attachment['partID'],
1750 1749
 							$_folder,
@@ -1773,7 +1772,7 @@  discard block
 block discarded – undo
1773 1772
 	 * @param array $_content the content passed to the function and to be modified
1774 1773
 	 * @return void
1775 1774
 	 */
1776
-	function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false)
1775
+	function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false)
1777 1776
 	{
1778 1777
 		//error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content));
1779 1778
 
@@ -1782,7 +1781,7 @@  discard block
 block discarded – undo
1782 1781
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
1783 1782
 		try
1784 1783
 		{
1785
-			$tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false);
1784
+			$tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false);
1786 1785
 		}
1787 1786
 		catch (Api\Exception\WrongUserinput $e)
1788 1787
 		{
@@ -1798,8 +1797,8 @@  discard block
 block discarded – undo
1798 1797
 			foreach ((array)$_content['attachments'] as $attach)
1799 1798
 			{
1800 1799
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1801
-					strtolower($_formData['type'])== strtolower($attach['type']) &&
1802
-					stripos($_formData['file'],'vfs://') !== false) return;
1800
+					strtolower($_formData['type']) == strtolower($attach['type']) &&
1801
+					stripos($_formData['file'], 'vfs://') !== false) return;
1803 1802
 			}
1804 1803
 		}
1805 1804
 		if ($attachfailed === false)
@@ -1811,7 +1810,7 @@  discard block
 block discarded – undo
1811 1810
 				'tmp_name'	=> $tmpFileName,
1812 1811
 				'size'	=> $_formData['size']
1813 1812
 			);
1814
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
1813
+			if (!is_array($_content['attachments'])) $_content['attachments'] = array();
1815 1814
 			$_content['attachments'][] = $buffer;
1816 1815
 			unset($buffer);
1817 1816
 		}
@@ -1823,14 +1822,14 @@  discard block
 block discarded – undo
1823 1822
 
1824 1823
 	function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size)
1825 1824
 	{
1826
-		$this->sessionData['attachments'][]=array (
1825
+		$this->sessionData['attachments'][] = array(
1827 1826
 			'uid'		=> $_uid,
1828 1827
 			'partID'	=> $_partID,
1829 1828
 			'name'		=> $_name,
1830 1829
 			'type'		=> $_type,
1831 1830
 			'size'		=> $_size,
1832 1831
 			'folder'	=> $_folder,
1833
-			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1),
1832
+			'tmp_name'	=> mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1),
1834 1833
 		);
1835 1834
 	}
1836 1835
 
@@ -1839,7 +1838,7 @@  discard block
 block discarded – undo
1839 1838
 		// read attachment data from etemplate request, use tmpname only to identify it
1840 1839
 		if (($request = Etemplate\Request::read($_GET['etemplate_exec_id'])))
1841 1840
 		{
1842
-			foreach($request->preserv['attachments'] as $attachment)
1841
+			foreach ($request->preserv['attachments'] as $attachment)
1843 1842
 			{
1844 1843
 				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
1845 1844
 			}
@@ -1851,7 +1850,7 @@  discard block
 block discarded – undo
1851 1850
 		}
1852 1851
 
1853 1852
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
1854
-		if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs')
1853
+		if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs')
1855 1854
 		{
1856 1855
 			Vfs::load_wrapper('vfs');
1857 1856
 		}
@@ -1860,7 +1859,7 @@  discard block
 block discarded – undo
1860 1859
 		{
1861 1860
 			$attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($attachment['tmp_name']);
1862 1861
 		}
1863
-		if(!file_exists($attachment['tmp_name']))
1862
+		if (!file_exists($attachment['tmp_name']))
1864 1863
 		{
1865 1864
 			header('HTTP/1.1 404 Not found');
1866 1865
 			die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!');
@@ -1873,7 +1872,7 @@  discard block
 block discarded – undo
1873 1872
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY')
1874 1873
 			{
1875 1874
 				$sfxMimeType = $attachment['type'];
1876
-				$buff = explode('.',$attachment['tmp_name']);
1875
+				$buff = explode('.', $attachment['tmp_name']);
1877 1876
 				$suffix = '';
1878 1877
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1879 1878
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -1885,10 +1884,10 @@  discard block
 block discarded – undo
1885 1884
 			{
1886 1885
 				//error_log(__METHOD__."about to call calendar_ical");
1887 1886
 				$calendar_ical = new calendar_ical();
1888
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1887
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
1889 1888
 				//error_log(__METHOD__.array2string($eventid));
1890 1889
 				if (!$eventid) $eventid = -1;
1891
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1890
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true);
1892 1891
 				//error_log(__METHOD__.$event);
1893 1892
 				if ((int)$event > 0)
1894 1893
 				{
@@ -1896,7 +1895,7 @@  discard block
 block discarded – undo
1896 1895
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
1897 1896
 						'cal_id'      => $event,
1898 1897
 					);
1899
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1898
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1900 1899
 				}
1901 1900
 				//Import failed, download content anyway
1902 1901
 			}
@@ -1911,13 +1910,13 @@  discard block
 block discarded – undo
1911 1910
 				{
1912 1911
 					$vcard['uid'] = trim($vcard['uid']);
1913 1912
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1914
-					$contact = $addressbook_vcal->find_contact($vcard,false);
1913
+					$contact = $addressbook_vcal->find_contact($vcard, false);
1915 1914
 				}
1916 1915
 				if (!$contact) $contact = null;
1917 1916
 				// 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))
1918
-				if ($contact || count($vcard)>2)
1917
+				if ($contact || count($vcard) > 2)
1919 1918
 				{
1920
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true);
1919
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true);
1921 1920
 				}
1922 1921
 				if ((int)$contact > 0)
1923 1922
 				{
@@ -1925,13 +1924,13 @@  discard block
 block discarded – undo
1925 1924
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
1926 1925
 						'contact_id'	=> $contact,
1927 1926
 					);
1928
-					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1927
+					$GLOBALS['egw']->redirect_link('../index.php', $vars);
1929 1928
 				}
1930 1929
 				//Import failed, download content anyway
1931 1930
 			}
1932 1931
 		}
1933 1932
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
1934
-		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
1933
+		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save");
1935 1934
 		echo $attachment['attachment'];
1936 1935
 
1937 1936
 		exit();
@@ -1944,11 +1943,11 @@  discard block
 block discarded – undo
1944 1943
 	 * @param string haystack
1945 1944
 	 * @return boolean
1946 1945
 	 */
1947
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
1946
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) {
1948 1947
 		foreach (array_keys($arrayToTestAgainst) as $k)
1949 1948
 		{
1950 1949
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
1951
-			if (stripos($haystack,$k)!==false)
1950
+			if (stripos($haystack, $k) !== false)
1952 1951
 			{
1953 1952
 				//error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace());
1954 1953
 				return true;
@@ -1971,10 +1970,10 @@  discard block
 block discarded – undo
1971 1970
 	 */
1972 1971
 	function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID)
1973 1972
 	{
1974
-		unset($_icServer);	// not used
1973
+		unset($_icServer); // not used
1975 1974
 		$foundAddresses = array();
1976 1975
 
1977
-		$mail_bo  = $this->mail_bo;
1976
+		$mail_bo = $this->mail_bo;
1978 1977
 		$mail_bo->openConnection();
1979 1978
 		$mail_bo->reopen($_folder);
1980 1979
 
@@ -1982,12 +1981,12 @@  discard block
 block discarded – undo
1982 1981
 
1983 1982
 		// get message headers for specified message
1984 1983
 		//print "AAAA: $_folder, $_uid, $_partID<br>";
1985
-		$headers	= $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true);
1984
+		$headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true);
1986 1985
 		//$headers	= $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder);
1987 1986
 		$this->sessionData['uid'] = $_uid;
1988 1987
 		$this->sessionData['messageFolder'] = $_folder;
1989
-		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']);
1990
-		$this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']);
1988
+		$this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']);
1989
+		$this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']);
1991 1990
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1992 1991
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
1993 1992
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
@@ -1995,36 +1994,36 @@  discard block
 block discarded – undo
1995 1994
 		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
1996 1995
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
1997 1996
 		// check for Reply-To: header and use if available
1998
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
1999
-			foreach($headers['REPLY-TO'] as $val) {
2000
-				if(!$foundAddresses[$val]) {
1997
+		if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
1998
+			foreach ($headers['REPLY-TO'] as $val) {
1999
+				if (!$foundAddresses[$val]) {
2001 2000
 					$oldTo[] = $val;
2002 2001
 					$foundAddresses[$val] = true;
2003 2002
 				}
2004 2003
 			}
2005
-			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2004
+			$oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']);
2006 2005
 		} else {
2007
-			foreach($headers['FROM'] as $val) {
2008
-				if(!$foundAddresses[$val]) {
2006
+			foreach ($headers['FROM'] as $val) {
2007
+				if (!$foundAddresses[$val]) {
2009 2008
 					$oldTo[] = $val;
2010 2009
 					$foundAddresses[$val] = true;
2011 2010
 				}
2012 2011
 			}
2013
-			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2012
+			$oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']);
2014 2013
 		}
2015 2014
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2016
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2015
+		if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) {
2017 2016
 			$this->sessionData['to'] = $oldTo;
2018 2017
 		}
2019 2018
 
2020
-		if($_mode == 'all') {
2019
+		if ($_mode == 'all') {
2021 2020
 			// reply to any address which is cc, but not to my self
2022 2021
 			#if($headers->cc) {
2023
-				foreach($headers['CC'] as $val) {
2024
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2022
+				foreach ($headers['CC'] as $val) {
2023
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2025 2024
 						continue;
2026 2025
 					}
2027
-					if(!$foundAddresses[$val]) {
2026
+					if (!$foundAddresses[$val]) {
2028 2027
 						$this->sessionData['cc'][] = $val;
2029 2028
 						$foundAddresses[$val] = true;
2030 2029
 					}
@@ -2033,11 +2032,11 @@  discard block
 block discarded – undo
2033 2032
 
2034 2033
 			// reply to any address which is to, but not to my self
2035 2034
 			#if($headers->to) {
2036
-				foreach($headers['TO'] as $val) {
2037
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2035
+				foreach ($headers['TO'] as $val) {
2036
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2038 2037
 						continue;
2039 2038
 					}
2040
-					if(!$foundAddresses[$val]) {
2039
+					if (!$foundAddresses[$val]) {
2041 2040
 						$this->sessionData['to'][] = $val;
2042 2041
 						$foundAddresses[$val] = true;
2043 2042
 					}
@@ -2045,12 +2044,12 @@  discard block
 block discarded – undo
2045 2044
 			#}
2046 2045
 
2047 2046
 			#if($headers->from) {
2048
-				foreach($headers['FROM'] as $val) {
2049
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2047
+				foreach ($headers['FROM'] as $val) {
2048
+					if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) {
2050 2049
 						continue;
2051 2050
 					}
2052 2051
 					//error_log(__METHOD__.__LINE__.' '.$val);
2053
-					if(!$foundAddresses[$val]) {
2052
+					if (!$foundAddresses[$val]) {
2054 2053
 						$this->sessionData['to'][] = $val;
2055 2054
 						$foundAddresses[$val] = true;
2056 2055
 					}
@@ -2059,59 +2058,59 @@  discard block
 block discarded – undo
2059 2058
 		}
2060 2059
 
2061 2060
 		// check for Re: in subject header
2062
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2061
+		if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2063 2062
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2064 2063
 		} else {
2065
-			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2064
+			$this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']);
2066 2065
 		}
2067 2066
 
2068 2067
 		//_debug_array($headers);
2069 2068
 		//error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions']));
2070
-		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID);
2069
+		$bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID);
2071 2070
 		//_debug_array($bodyParts);
2072 2071
 		$styles = Mail::getStyles($bodyParts);
2073 2072
 
2074
-		$fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM']));
2073
+		$fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM']));
2075 2074
 
2076 2075
 		$toAddressA = array();
2077 2076
 		$toAddress = '';
2078 2077
 		foreach ($headers['TO'] as $mailheader) {
2079
-			$toAddressA[] =  $mailheader;
2078
+			$toAddressA[] = $mailheader;
2080 2079
 		}
2081
-		if (count($toAddressA)>0)
2080
+		if (count($toAddressA) > 0)
2082 2081
 		{
2083
-			$toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA));
2084
-			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2082
+			$toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA));
2083
+			$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2085 2084
 		}
2086 2085
 		$ccAddressA = array();
2087 2086
 		$ccAddress = '';
2088 2087
 		foreach ($headers['CC'] as $mailheader) {
2089
-			$ccAddressA[] =  $mailheader;
2088
+			$ccAddressA[] = $mailheader;
2090 2089
 		}
2091
-		if (count($ccAddressA)>0)
2090
+		if (count($ccAddressA) > 0)
2092 2091
 		{
2093
-			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2094
-			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2092
+			$ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA));
2093
+			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n");
2095 2094
 		}
2096
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2097
-			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2095
+		if ($bodyParts['0']['mimeType'] == 'text/html') {
2096
+			$this->sessionData['body'] = /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2098 2097
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2099 2098
 				$toAddress.$ccAddress.
2100
-				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2099
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>".
2101 2100
 				'----------------------------------------------------------'."</div>";
2102
-			$this->sessionData['mimeType'] 	= 'html';
2101
+			$this->sessionData['mimeType'] = 'html';
2103 2102
 			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2104
-			$this->sessionData['body']	.= '<blockquote type="cite">';
2103
+			$this->sessionData['body'] .= '<blockquote type="cite">';
2105 2104
 
2106
-			for($i=0; $i<count($bodyParts); $i++) {
2107
-				if($i>0) {
2105
+			for ($i = 0; $i < count($bodyParts); $i++) {
2106
+				if ($i > 0) {
2108 2107
 					$this->sessionData['body'] .= '<hr>';
2109 2108
 				}
2110
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2109
+				if ($bodyParts[$i]['mimeType'] == 'text/plain') {
2111 2110
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2112 2111
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2113 2112
 				}
2114
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2113
+				if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2115 2114
 
2116 2115
 				$_htmlConfig = Mail::$htmLawed_config;
2117 2116
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2121,30 +2120,30 @@  discard block
 block discarded – undo
2121 2120
 				#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2122 2121
 			}
2123 2122
 
2124
-			$this->sessionData['body']	.= '</blockquote><br>';
2125
-			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2123
+			$this->sessionData['body'] .= '</blockquote><br>';
2124
+			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2126 2125
 		} else {
2127 2126
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2128 2127
 			// 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".
2128
+            $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
2130 2129
                 @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
2131 2130
 				$toAddress.$ccAddress.
2132
-				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
2131
+				@htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n".
2133 2132
                 '-------------------------------------------------'."\r\n \r\n ";
2134
-			$this->sessionData['mimeType']	= 'plain';
2133
+			$this->sessionData['mimeType'] = 'plain';
2135 2134
 
2136
-			for($i=0; $i<count($bodyParts); $i++) {
2137
-				if($i>0) {
2135
+			for ($i = 0; $i < count($bodyParts); $i++) {
2136
+				if ($i > 0) {
2138 2137
 					$this->sessionData['body'] .= "<hr>";
2139 2138
 				}
2140 2139
 
2141 2140
 				// add line breaks to $bodyParts
2142
-				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
2141
+				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
2143 2142
 				#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
2144 2143
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2145 2144
 				$this->sessionData['body'] .= "\r\n";
2146 2145
 				// create body new, with good line breaks and indention
2147
-				foreach(explode("\n",$newBody) as $value) {
2146
+				foreach (explode("\n", $newBody) as $value) {
2148 2147
 					// the explode is removing the character
2149 2148
 					if (trim($value) != '') {
2150 2149
 						#if ($value != "\r") $value .= "\n";
@@ -2152,12 +2151,12 @@  discard block
 block discarded – undo
2152 2151
 					$numberOfChars = strspn(trim($value), ">");
2153 2152
 					$appendString = str_repeat('>', $numberOfChars + 1);
2154 2153
 
2155
-					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2154
+					$bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>');
2156 2155
 
2157
-					if($bodyAppend[0] == '>') {
2158
-						$bodyAppend = '>'. $bodyAppend;
2156
+					if ($bodyAppend[0] == '>') {
2157
+						$bodyAppend = '>'.$bodyAppend;
2159 2158
 					} else {
2160
-						$bodyAppend = '> '. $bodyAppend;
2159
+						$bodyAppend = '> '.$bodyAppend;
2161 2160
 					}
2162 2161
 
2163 2162
 					$this->sessionData['body'] .= $bodyAppend;
@@ -2180,16 +2179,16 @@  discard block
 block discarded – undo
2180 2179
 	 */
2181 2180
 	static function _getCleanHTML($_body, $_useTidy = false)
2182 2181
 	{
2183
-		static $nonDisplayAbleCharacters = array('[\016]','[\017]',
2184
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2185
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2182
+		static $nonDisplayAbleCharacters = array('[\016]', '[\017]',
2183
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2184
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2186 2185
 
2187
-		if ($_useTidy && extension_loaded('tidy') )
2186
+		if ($_useTidy && extension_loaded('tidy'))
2188 2187
 		{
2189 2188
 			$tidy = new tidy();
2190
-			$cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8');
2189
+			$cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8');
2191 2190
 			// Found errors. Strip it all so there's some output
2192
-			if($tidy->getStatus() == 2)
2191
+			if ($tidy->getStatus() == 2)
2193 2192
 			{
2194 2193
 				error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
2195 2194
 			}
@@ -2221,14 +2220,14 @@  discard block
 block discarded – undo
2221 2220
 	 * @param array $_identity
2222 2221
 	 * @param boolean $_autosaving =false true: autosaving, false: save-as-draft or send
2223 2222
 	 */
2224
-	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
2223
+	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false)
2225 2224
 	{
2226 2225
 		if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----')
2227 2226
 		{
2228 2227
 			$_formData['mimeType'] = 'openpgp';
2229 2228
 		}
2230 2229
 		//error_log(__METHOD__."(, formDate[filemode]=$_formData[filemode], _autosaving=".array2string($_autosaving).') '.function_backtrace());
2231
-		$mail_bo	= $this->mail_bo;
2230
+		$mail_bo = $this->mail_bo;
2232 2231
 		$activeMailProfile = Mail\Account::read($this->mail_bo->profileID);
2233 2232
 
2234 2233
 		// you need to set the sender, if you work with different identities, since most smtp servers, dont allow
@@ -2238,17 +2237,17 @@  discard block
 block discarded – undo
2238 2237
 			error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity));
2239 2238
 		}
2240 2239
 		$_mailObject->setFrom($_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'],
2241
-			Mail::generateIdentityString($_identity,false));
2240
+			Mail::generateIdentityString($_identity, false));
2242 2241
 
2243 2242
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2244 2243
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2245
-		if(!empty($_formData['in-reply-to'])) {
2246
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2244
+		if (!empty($_formData['in-reply-to'])) {
2245
+			if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>';
2247 2246
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(In-Reply-To', $_formData['in-reply-to'].")");
2248 2247
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2249 2248
 		}
2250
-		if(!empty($_formData['references'])) {
2251
-			if (stripos($_formData['references'],'<')===false) $_formData['references']='<'.trim($_formData['references']).'>';
2249
+		if (!empty($_formData['references'])) {
2250
+			if (stripos($_formData['references'], '<') === false) $_formData['references'] = '<'.trim($_formData['references']).'>';
2252 2251
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(References', $_formData['references'].")");
2253 2252
 			$_mailObject->addHeader('References', $_formData['references']);
2254 2253
 		}
@@ -2259,16 +2258,16 @@  discard block
 block discarded – undo
2259 2258
 		//	$_mailObject->addHeader('Thread-Topic', $_formData['thread-topic']);
2260 2259
 		//}
2261 2260
 
2262
-		if(!empty($_formData['thread-index'])) {
2261
+		if (!empty($_formData['thread-index'])) {
2263 2262
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(Tread-Index', $_formData['thread-index'].")");
2264 2263
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2265 2264
 		}
2266
-		if(!empty($_formData['list-id'])) {
2265
+		if (!empty($_formData['list-id'])) {
2267 2266
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(List-Id', $_formData['list-id'].")");
2268 2267
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2269 2268
 		}
2270 2269
 		//error_log(__METHOD__.__LINE__.' notify to:'.$_identity['ident_email'].'->'.array2string($_formData));
2271
-		if($_formData['disposition']=='on') {
2270
+		if ($_formData['disposition'] == 'on') {
2272 2271
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2273 2272
 		}
2274 2273
 		//error_log(__METHOD__.__LINE__.' Organization:'.array2string($_identity));
@@ -2277,7 +2276,7 @@  discard block
 block discarded – undo
2277 2276
 		//}
2278 2277
 
2279 2278
 		// Expand any mailing lists
2280
-		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2279
+		foreach (array('to', 'cc', 'bcc', 'replyto')  as $field)
2281 2280
 		{
2282 2281
 			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2283 2282
 
@@ -2300,7 +2299,7 @@  discard block
 block discarded – undo
2300 2299
 					'1' => 'before reply, visible during compose',
2301 2300
 					'no_belowaftersend'  => 'appended after reply before sending',
2302 2301
 		*/
2303
-		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0;
2302
+		$sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0;
2304 2303
 		if ($sigAlreadyThere)
2305 2304
 		{
2306 2305
 			// note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature
@@ -2309,7 +2308,7 @@  discard block
 block discarded – undo
2309 2308
 		}
2310 2309
 		if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) &&
2311 2310
 			$this->mailPreferences['disableRulerForSignatureSeparation']) ||
2312
-			empty($signature) || trim($this->convertHTMLToText($signature)) =='')
2311
+			empty($signature) || trim($this->convertHTMLToText($signature)) == '')
2313 2312
 		{
2314 2313
 			$disableRuler = true;
2315 2314
 		}
@@ -2326,7 +2325,7 @@  discard block
 block discarded – undo
2326 2325
 				array_unique(array_merge((array)$_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc'])),
2327 2326
 				$_formData['expiration'], $_formData['password']);
2328 2327
 		}
2329
-		if($_formData['mimeType'] == 'html')
2328
+		if ($_formData['mimeType'] == 'html')
2330 2329
 		{
2331 2330
 			$body = $_formData['body'];
2332 2331
 			if ($attachment_links)
@@ -2340,13 +2339,13 @@  discard block
 block discarded – undo
2340 2339
 					$body .= $attachment_links;
2341 2340
 				}
2342 2341
 			}
2343
-			if(!empty($signature))
2342
+			if (!empty($signature))
2344 2343
 			{
2345 2344
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true).
2346 2345
 					($disableRuler ? "\r\n" : "\r\n-- \r\n").
2347 2346
 					$this->convertHTMLToText($signature, true, true));
2348 2347
 
2349
-				$body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature;
2348
+				$body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature;
2350 2349
 			}
2351 2350
 			else
2352 2351
 			{
@@ -2354,11 +2353,11 @@  discard block
 block discarded – undo
2354 2353
 			}
2355 2354
 			// convert URL Images to inline images - if possible
2356 2355
 			if (!$_autosaving) Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2357
-			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2356
+			if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false)
2358 2357
 			{
2359
-				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
2358
+				$body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body);
2360 2359
 			}
2361
-			$_mailObject->setHtmlBody($body, null, false);	// false = no automatic alternative, we called setBody()
2360
+			$_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody()
2362 2361
 		}
2363 2362
 		elseif ($_formData['mimeType'] == 'openpgp')
2364 2363
 		{
@@ -2366,14 +2365,14 @@  discard block
 block discarded – undo
2366 2365
 		}
2367 2366
 		else
2368 2367
 		{
2369
-			$body = $this->convertHTMLToText($_formData['body'],false);
2368
+			$body = $this->convertHTMLToText($_formData['body'], false);
2370 2369
 
2371 2370
 			if ($attachment_links) $body .= $attachment_links;
2372 2371
 
2373 2372
 			#$_mailObject->Body = $_formData['body'];
2374
-			if(!empty($signature)) {
2375
-				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2376
-					$this->convertHTMLToText($signature,true,true);
2373
+			if (!empty($signature)) {
2374
+				$body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n").
2375
+					$this->convertHTMLToText($signature, true, true);
2377 2376
 			}
2378 2377
 			$_mailObject->setBody($body);
2379 2378
 		}
@@ -2384,9 +2383,9 @@  discard block
 block discarded – undo
2384 2383
 			$connection_opened = false;
2385 2384
 			//error_log(__METHOD__.__LINE__.array2string($_formData['attachments']));
2386 2385
 			$tnfattachments = null;
2387
-			foreach((array)$_formData['attachments'] as $attachment) {
2386
+			foreach ((array)$_formData['attachments'] as $attachment) {
2388 2387
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2389
-				if(is_array($attachment))
2388
+				if (is_array($attachment))
2390 2389
 				{
2391 2390
 					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2392 2391
 						/* Example:
@@ -2404,20 +2403,20 @@  discard block
 block discarded – undo
2404 2403
 							$connection_opened = true;
2405 2404
 						}
2406 2405
 						$mail_bo->reopen($attachment['folder']);
2407
-						switch(strtoupper($attachment['type'])) {
2406
+						switch (strtoupper($attachment['type'])) {
2408 2407
 							case 'MESSAGE/RFC':
2409 2408
 							case 'MESSAGE/RFC822':
2410
-								$rawBody='';
2409
+								$rawBody = '';
2411 2410
 								if (isset($attachment['partID'])) {
2412
-									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2413
-									$rawBody=$eml['attachment'];
2411
+									$eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']);
2412
+									$rawBody = $eml['attachment'];
2414 2413
 								} else {
2415
-									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2414
+									$rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']);
2416 2415
 								}
2417 2416
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
2418 2417
 								break;
2419 2418
 							default:
2420
-								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2419
+								$attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false);
2421 2420
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2422 2421
 								{
2423 2422
 									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
@@ -2425,7 +2424,7 @@  discard block
 block discarded – undo
2425 2424
 									{
2426 2425
 										if ($k['name'] == $attachment['name'])
2427 2426
 										{
2428
-											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']);
2427
+											$tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']);
2429 2428
 											$attachmentData['attachment'] = $tnfpart['attachment'];
2430 2429
 											//error_log(__METHOD__.__LINE__.$k['name'].'<->'.$attachment['name'].':'.array2string($attachmentData['attachment']));
2431 2430
 											break;
@@ -2439,7 +2438,7 @@  discard block
 block discarded – undo
2439 2438
 					// attach files not for autosaving
2440 2439
 					elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving)
2441 2440
 					{
2442
-						if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs')
2441
+						if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs')
2443 2442
 						{
2444 2443
 							Vfs::load_wrapper('vfs');
2445 2444
 							$tmp_path = $attachment['file'];
@@ -2448,7 +2447,7 @@  discard block
 block discarded – undo
2448 2447
 						{
2449 2448
 							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($attachment['file']);
2450 2449
 						}
2451
-						$_mailObject->addAttachment (
2450
+						$_mailObject->addAttachment(
2452 2451
 							$tmp_path,
2453 2452
 							$attachment['name'],
2454 2453
 							$attachment['type']
@@ -2473,16 +2472,16 @@  discard block
 block discarded – undo
2473 2472
 	 * @param string $password =null
2474 2473
 	 * @return string might be empty if no file attachments found
2475 2474
 	 */
2476
-	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2475
+	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null)
2477 2476
 	{
2478 2477
 		if ($filemode == Vfs\Sharing::ATTACH) return '';
2479 2478
 
2480 2479
 		$links = array();
2481
-		foreach($attachments as $attachment)
2480
+		foreach ($attachments as $attachment)
2482 2481
 		{
2483 2482
 			$path = $attachment['file'];
2484
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2485
-			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2483
+			if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts
2484
+			if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs')
2486 2485
 			{
2487 2486
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($path);
2488 2487
 			}
@@ -2512,7 +2511,7 @@  discard block
 block discarded – undo
2512 2511
 		}
2513 2512
 		if (!$links)
2514 2513
 		{
2515
-			return null;	// no file attachments found
2514
+			return null; // no file attachments found
2516 2515
 		}
2517 2516
 		elseif ($html)
2518 2517
 		{
@@ -2527,7 +2526,7 @@  discard block
 block discarded – undo
2527 2526
 	 * @param array $content content sent from client-side
2528 2527
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2529 2528
 	 */
2530
-	public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
2529
+	public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]')
2531 2530
 	{
2532 2531
 		//error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)");
2533 2532
 		$response = Api\Json\Response::get();
@@ -2541,8 +2540,8 @@  discard block
 block discarded – undo
2541 2540
 
2542 2541
 		$formData = array_merge($content, array(
2543 2542
 			'isDrafted' => 1,
2544
-			'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')],
2545
-			'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value
2543
+			'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')],
2544
+			'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value
2546 2545
 		));
2547 2546
 
2548 2547
 		//Saving draft procedure
@@ -2554,8 +2553,8 @@  discard block
 block discarded – undo
2554 2553
 			if (($messageUid = $this->saveAsDraft($formData, $folder, $action)))
2555 2554
 			{
2556 2555
 				// saving as draft, does not mean closing the message
2557
-				$messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid);
2558
-				if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder)))
2556
+				$messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid);
2557
+				if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder)))
2559 2558
 				{
2560 2559
 					$draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid);
2561 2560
 					if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted']))
@@ -2564,7 +2563,7 @@  discard block
 block discarded – undo
2564 2563
 						$duid = $dhA['msgUID'];
2565 2564
 						$dmailbox = $dhA['folder'];
2566 2565
 						// beware: do not delete the original mail as found in processedmail_id
2567
-						$pMuid='';
2566
+						$pMuid = '';
2568 2567
 						if ($content['processedmail_id'])
2569 2568
 						{
2570 2569
 							$pMhA = mail_ui::splitRowID($content['processedmail_id']);
@@ -2572,15 +2571,15 @@  discard block
 block discarded – undo
2572 2571
 						}
2573 2572
 						//error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments']));
2574 2573
 						// do not delete the original message if attachments are present
2575
-						if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments']))
2574
+						if (empty($pMuid) || $pMuid != $duid || empty($content['attachments']))
2576 2575
 						{
2577 2576
 							try
2578 2577
 							{
2579
-								$this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately');
2578
+								$this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately');
2580 2579
 							}
2581 2580
 							catch (Api\Exception $e)
2582 2581
 							{
2583
-								$msg = str_replace('"',"'",$e->getMessage());
2582
+								$msg = str_replace('"', "'", $e->getMessage());
2584 2583
 								$success = false;
2585 2584
 								error_log(__METHOD__.__LINE__.$msg);
2586 2585
 							}
@@ -2601,7 +2600,7 @@  discard block
 block discarded – undo
2601 2600
 		}
2602 2601
 		catch (Api\Exception\WrongUserinput $e)
2603 2602
 		{
2604
-			$msg = str_replace('"',"'",$e->getMessage());
2603
+			$msg = str_replace('"', "'", $e->getMessage());
2605 2604
 			error_log(__METHOD__.__LINE__.$msg);
2606 2605
 			$success = false;
2607 2606
 		}
@@ -2625,17 +2624,17 @@  discard block
 block discarded – undo
2625 2624
 	static function resolveEmailAddressList($_emailAddressList)
2626 2625
 	{
2627 2626
 		$contacts_obs = null;
2628
-		$addrFromList=array();
2629
-		foreach((array)$_emailAddressList as $ak => $address)
2627
+		$addrFromList = array();
2628
+		foreach ((array)$_emailAddressList as $ak => $address)
2630 2629
 		{
2631
-			if(is_int($address))
2630
+			if (is_int($address))
2632 2631
 			{
2633 2632
 				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
2634 2633
 				// List was selected, expand to addresses
2635 2634
 				unset($_emailAddressList[$ak]);
2636
-				$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));
2635
+				$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));
2637 2636
 				// Just add email addresses, they'll be checked below
2638
-				foreach($list as $email)
2637
+				foreach ($list as $email)
2639 2638
 				{
2640 2639
 					$addrFromList[] = $email['email'] ? $email['email'] : $email['email_home'];
2641 2640
 				}
@@ -2645,7 +2644,7 @@  discard block
 block discarded – undo
2645 2644
 		{
2646 2645
 			foreach ($addrFromList as $addr)
2647 2646
 			{
2648
-				if (!empty($addr)) $_emailAddressList[]=$addr;
2647
+				if (!empty($addr)) $_emailAddressList[] = $addr;
2649 2648
 			}
2650 2649
 		}
2651 2650
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2659,15 +2658,15 @@  discard block
 block discarded – undo
2659 2658
 	 * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]'
2660 2659
 	 * @return boolean return messageUID| false due to an error
2661 2660
 	 */
2662
-	function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]')
2661
+	function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]')
2663 2662
 	{
2664 2663
 		//error_log(__METHOD__."(..., $savingDestination, action=$action)");
2665
-		$mail_bo	= $this->mail_bo;
2666
-		$mail		= new Api\Mailer($this->mail_bo->profileID);
2664
+		$mail_bo = $this->mail_bo;
2665
+		$mail = new Api\Mailer($this->mail_bo->profileID);
2667 2666
 
2668 2667
 		// preserve the bcc and if possible the save to folder information
2669
-		$this->sessionData['folder']    = $_formData['folder'];
2670
-		$this->sessionData['bcc']   = $_formData['bcc'];
2668
+		$this->sessionData['folder'] = $_formData['folder'];
2669
+		$this->sessionData['bcc'] = $_formData['bcc'];
2671 2670
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2672 2671
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2673 2672
 		$this->sessionData['mailaccount']  = $_formData['mailaccount'];
@@ -2676,11 +2675,11 @@  discard block
 block discarded – undo
2676 2675
 		{
2677 2676
 			$acc = Mail\Account::read($this->sessionData['mailaccount']);
2678 2677
 			//error_log(__METHOD__.__LINE__.array2string($acc));
2679
-			$identity = Mail\Account::read_identity($acc['ident_id'],true);
2678
+			$identity = Mail\Account::read_identity($acc['ident_id'], true);
2680 2679
 		}
2681 2680
 		catch (Exception $e)
2682 2681
 		{
2683
-			$identity=array();
2682
+			$identity = array();
2684 2683
 		}
2685 2684
 
2686 2685
 		$flags = '\\Seen \\Draft';
@@ -2690,7 +2689,7 @@  discard block
 block discarded – undo
2690 2689
 		// folder list as Customheader
2691 2690
 		if (!empty($this->sessionData['folder']))
2692 2691
 		{
2693
-			$folders = implode('|',array_unique($this->sessionData['folder']));
2692
+			$folders = implode('|', array_unique($this->sessionData['folder']));
2694 2693
 			$mail->addHeader('X-Mailfolder', $folders);
2695 2694
 		}
2696 2695
 		$mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']);
@@ -2710,25 +2709,25 @@  discard block
 block discarded – undo
2710 2709
 			$savingDestination = $this->sessionData['messageFolder'];
2711 2710
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2712 2711
 		}
2713
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
2712
+		if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder();
2714 2713
 
2715 2714
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2716 2715
 		$mail->forceBccHeader();
2717 2716
 
2718 2717
 		$mail_bo->openConnection();
2719
-		if ($mail_bo->folderExists($savingDestination,true)) {
2718
+		if ($mail_bo->folderExists($savingDestination, true)) {
2720 2719
 			try
2721 2720
 			{
2722 2721
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
2723 2722
 			}
2724 2723
 			catch (Api\Exception\WrongUserinput $e)
2725 2724
 			{
2726
-				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage()));
2725
+				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage()));
2727 2726
 				return false;
2728 2727
 			}
2729 2728
 
2730 2729
 		} else {
2731
-			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2730
+			error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server."));
2732 2731
 			return false;
2733 2732
 		}
2734 2733
 		$mail_bo->closeConnection();
@@ -2737,26 +2736,26 @@  discard block
 block discarded – undo
2737 2736
 
2738 2737
 	function send($_formData)
2739 2738
 	{
2740
-		$mail_bo	= $this->mail_bo;
2741
-		$mail 		= new Api\Mailer($mail_bo->profileID);
2742
-		$messageIsDraft	=  false;
2739
+		$mail_bo = $this->mail_bo;
2740
+		$mail = new Api\Mailer($mail_bo->profileID);
2741
+		$messageIsDraft = false;
2743 2742
 
2744
-		$this->sessionData['mailaccount']	= $_formData['mailaccount'];
2743
+		$this->sessionData['mailaccount'] = $_formData['mailaccount'];
2745 2744
 		$this->sessionData['to']	= self::resolveEmailAddressList($_formData['to']);
2746 2745
 		$this->sessionData['cc']	= self::resolveEmailAddressList($_formData['cc']);
2747
-		$this->sessionData['bcc']	= self::resolveEmailAddressList($_formData['bcc']);
2748
-		$this->sessionData['folder']	= $_formData['folder'];
2746
+		$this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']);
2747
+		$this->sessionData['folder'] = $_formData['folder'];
2749 2748
 		$this->sessionData['replyto']	= $_formData['replyto'];
2750 2749
 		$this->sessionData['subject']	= trim($_formData['subject']);
2751
-		$this->sessionData['body']	= $_formData['body'];
2752
-		$this->sessionData['priority']	= $_formData['priority'];
2750
+		$this->sessionData['body'] = $_formData['body'];
2751
+		$this->sessionData['priority'] = $_formData['priority'];
2753 2752
 		$this->sessionData['mailidentity'] = $_formData['mailidentity'];
2754 2753
 		//$this->sessionData['stationeryID'] = $_formData['stationeryID'];
2755 2754
 		$this->sessionData['disposition'] = $_formData['disposition'];
2756
-		$this->sessionData['mimeType']	= $_formData['mimeType'];
2755
+		$this->sessionData['mimeType'] = $_formData['mimeType'];
2757 2756
 		$this->sessionData['to_infolog'] = $_formData['to_infolog'];
2758 2757
 		$this->sessionData['to_tracker'] = $_formData['to_tracker'];
2759
-		$this->sessionData['attachments']  = $_formData['attachments'];
2758
+		$this->sessionData['attachments'] = $_formData['attachments'];
2760 2759
 
2761 2760
 		if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted']))
2762 2761
 		{
@@ -2765,11 +2764,11 @@  discard block
 block discarded – undo
2765 2764
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']);
2766 2765
 		if (isset($_formData['mode']) && !empty($_formData['mode']))
2767 2766
 		{
2768
-			if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id']))
2767
+			if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id']))
2769 2768
 			{
2770
-				$this->sessionData['forwardFlag']='forwarded';
2771
-				$_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']);
2772
-				$this->sessionData['uid']=array();
2769
+				$this->sessionData['forwardFlag'] = 'forwarded';
2770
+				$_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']);
2771
+				$this->sessionData['uid'] = array();
2773 2772
 				foreach ($_formData['processedmail_id'] as $k =>$rowid)
2774 2773
 				{
2775 2774
 					$fhA = mail_ui::splitRowID($rowid);
@@ -2778,13 +2777,13 @@  discard block
 block discarded – undo
2778 2777
 					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
2779 2778
 				}
2780 2779
 			}
2781
-			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
2780
+			if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id']))
2782 2781
 			{
2783 2782
 				$rhA = mail_ui::splitRowID($_formData['processedmail_id']);
2784 2783
 				$this->sessionData['uid'] = $rhA['msgUID'];
2785 2784
 				$this->sessionData['messageFolder'] = $rhA['folder'];
2786 2785
 			}
2787
-			if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id']))
2786
+			if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id']))
2788 2787
 			{
2789 2788
 				$dhA = mail_ui::splitRowID($_formData['processedmail_id']);
2790 2789
 				$this->sessionData['uid'] = $dhA['msgUID'];
@@ -2793,26 +2792,26 @@  discard block
 block discarded – undo
2793 2792
 		}
2794 2793
 		// if the body is empty, maybe someone pasted something with scripts, into the message body
2795 2794
 		// this should not happen anymore, unless you call send directly, since the check was introduced with the action command
2796
-		if(empty($this->sessionData['body']))
2795
+		if (empty($this->sessionData['body']))
2797 2796
 		{
2798 2797
 			// this is to be found with the egw_unset_vars array for the _POST['body'] array
2799
-			$name='_POST';
2800
-			$key='body';
2798
+			$name = '_POST';
2799
+			$key = 'body';
2801 2800
 			#error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2802 2801
 			if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']']))
2803 2802
 			{
2804
-				$this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2805
-				$_formData['body']=$this->sessionData['body'];
2803
+				$this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']);
2804
+				$_formData['body'] = $this->sessionData['body'];
2806 2805
 			}
2807 2806
 			#error_log($this->sessionData['body']);
2808 2807
 		}
2809
-		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2808
+		if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2810 2809
 		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
2811 2810
 		   	$messageIsDraft = true;
2812 2811
 		}
2813 2812
 		try
2814 2813
 		{
2815
-			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true);
2814
+			$identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true);
2816 2815
 		}
2817 2816
 		catch (Exception $e)
2818 2817
 		{
@@ -2823,7 +2822,7 @@  discard block
 block discarded – undo
2823 2822
 		// create the messages
2824 2823
 		$this->createMessage($mail, $_formData, $identity);
2825 2824
 		// remember the identity
2826
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2825
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2827 2826
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2828 2827
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2829 2828
 		#exit;
@@ -2834,12 +2833,12 @@  discard block
 block discarded – undo
2834 2833
 		$folderOnMailAccount = array();
2835 2834
 		foreach ($folderToCheck as $k => $f)
2836 2835
 		{
2837
-			$fval=$f;
2838
-			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2839
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
2840
-			if ($_formData['serverID']!=$_formData['mailaccount'])
2836
+			$fval = $f;
2837
+			$icServerID = $_formData['serverID']; //folders always assumed with serverID
2838
+			if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2);
2839
+			if ($_formData['serverID'] != $_formData['mailaccount'])
2841 2840
 			{
2842
-				if ($icServerID == $_formData['serverID'] )
2841
+				if ($icServerID == $_formData['serverID'])
2843 2842
 				{
2844 2843
 					$folder[$fval] = $fval;
2845 2844
 					$folderOnServerID[] = $fval;
@@ -2852,7 +2851,7 @@  discard block
 block discarded – undo
2852 2851
 			}
2853 2852
 			else
2854 2853
 			{
2855
-				if ($icServerID == $_formData['serverID'] )
2854
+				if ($icServerID == $_formData['serverID'])
2856 2855
 				{
2857 2856
 					$folder[$fval] = $fval;
2858 2857
 					$folderOnServerID[] = $fval;
@@ -2869,7 +2868,7 @@  discard block
 block discarded – undo
2869 2868
 		// we use the sentFolder settings of the choosen mailaccount
2870 2869
 		// sentFolder is account specific
2871 2870
 		$changeProfileOnSentFolderNeeded = false;
2872
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2871
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2873 2872
 		{
2874 2873
 			$this->changeProfile($_formData['mailaccount']);
2875 2874
 			//error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#');
@@ -2877,30 +2876,30 @@  discard block
 block discarded – undo
2877 2876
 			// sentFolder is account specific
2878 2877
 			$sentFolder = $this->mail_bo->getSentFolder();
2879 2878
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2880
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2879
+			if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2881 2880
 		}
2882 2881
 		else
2883 2882
 		{
2884 2883
 			$sentFolder = $mail_bo->getSentFolder();
2885 2884
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2886
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
2885
+			if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false;
2887 2886
 		}
2888 2887
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2889 2888
 
2890 2889
 		// we switch $this->mail_bo back to the account we used to work on
2891
-		if ($_formData['serverID']!=$_formData['mailaccount'])
2890
+		if ($_formData['serverID'] != $_formData['mailaccount'])
2892 2891
 		{
2893 2892
 			$this->changeProfile($_formData['serverID']);
2894 2893
 		}
2895 2894
 
2896 2895
 
2897
-		if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2896
+		if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
2898 2897
 			$this->mailPreferences['sendOptions'] != 'send_only' &&
2899 2898
 			$messageIsDraft == false)
2900 2899
 		{
2901 2900
 			if ($sentFolder)
2902 2901
 			{
2903
-				if ($_formData['serverID']!=$_formData['mailaccount'])
2902
+				if ($_formData['serverID'] != $_formData['mailaccount'])
2904 2903
 				{
2905 2904
 					$folderOnMailAccount[] = $sentFolder;
2906 2905
 				}
@@ -2917,14 +2916,14 @@  discard block
 block discarded – undo
2917 2916
 		}
2918 2917
 		else
2919 2918
 		{
2920
-			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2919
+			if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2921 2920
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2922 2921
 				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
2923 2922
 		}
2924 2923
 		// draftFolder is on Server we start from
2925
-		if($messageIsDraft == true) {
2924
+		if ($messageIsDraft == true) {
2926 2925
 			$draftFolder = $mail_bo->getDraftFolder();
2927
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
2926
+			if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) {
2928 2927
 				$this->sessionData['folder'] = array($draftFolder);
2929 2928
 				$folderOnServerID[] = $draftFolder;
2930 2929
 				$folder[$draftFolder] = $draftFolder;
@@ -2933,10 +2932,10 @@  discard block
 block discarded – undo
2933 2932
 		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2934 2933
 		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
2935 2934
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2936
-			!( count($folder) > 0) &&
2937
-			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
2935
+			!(count($folder) > 0) &&
2936
+			!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on'))
2938 2937
 		{
2939
-			$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:'');
2938
+			$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 : '');
2940 2939
 			#error_log($this->errorInfo);
2941 2940
 			return false;
2942 2941
 		}
@@ -2945,18 +2944,18 @@  discard block
 block discarded – undo
2945 2944
 		@set_time_limit(120);
2946 2945
 		//$mail->SMTPDebug = 10;
2947 2946
 		//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']));
2948
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2947
+		if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
2949 2948
 			try {
2950 2949
 				$mail->send();
2951 2950
 			}
2952
-			catch(Exception $e) {
2951
+			catch (Exception $e) {
2953 2952
 				_egw_log_exception($e);
2954 2953
 				//if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details));
2955
-				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2954
+				$this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : '');
2956 2955
 				return false;
2957 2956
 			}
2958 2957
 		} else {
2959
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
2958
+			if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) {
2960 2959
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2961 2960
 			} else {
2962 2961
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
@@ -2984,15 +2983,15 @@  discard block
 block discarded – undo
2984 2983
 		// copying mail to folder
2985 2984
 		if (count($folder) > 0)
2986 2985
 		{
2987
-			foreach($folderOnServerID as $folderName) {
2986
+			foreach ($folderOnServerID as $folderName) {
2988 2987
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
2989 2988
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
2990 2989
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
2991 2990
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
2992
-				if ($mail_bo->folderExists($folderName,true)) {
2993
-					if($mail_bo->isSentFolder($folderName)) {
2991
+				if ($mail_bo->folderExists($folderName, true)) {
2992
+					if ($mail_bo->isSentFolder($folderName)) {
2994 2993
 						$flags = '\\Seen';
2995
-					} elseif($mail_bo->isDraftFolder($folderName)) {
2994
+					} elseif ($mail_bo->isDraftFolder($folderName)) {
2996 2995
 						$flags = '\\Draft';
2997 2996
 					} else {
2998 2997
 						$flags = '\\Seen';
@@ -3008,25 +3007,25 @@  discard block
 block discarded – undo
3008 3007
 					}
3009 3008
 					catch (Api\Exception\WrongUserinput $e)
3010 3009
 					{
3011
-						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()));
3010
+						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()));
3012 3011
 					}
3013 3012
 				}
3014 3013
 				else
3015 3014
 				{
3016
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3015
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3017 3016
 				}
3018 3017
 			}
3019 3018
 			// if we choose to send from a differing profile
3020 3019
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3021
-			foreach($folderOnMailAccount as $folderName) {
3020
+			foreach ($folderOnMailAccount as $folderName) {
3022 3021
 				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3023 3022
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3024 3023
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3025 3024
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3026
-				if ($this->mail_bo->folderExists($folderName,true)) {
3027
-					if($this->mail_bo->isSentFolder($folderName)) {
3025
+				if ($this->mail_bo->folderExists($folderName, true)) {
3026
+					if ($this->mail_bo->isSentFolder($folderName)) {
3028 3027
 						$flags = '\\Seen';
3029
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3028
+					} elseif ($this->mail_bo->isDraftFolder($folderName)) {
3030 3029
 						$flags = '\\Draft';
3031 3030
 					} else {
3032 3031
 						$flags = '\\Seen';
@@ -3042,12 +3041,12 @@  discard block
 block discarded – undo
3042 3041
 					}
3043 3042
 					catch (Api\Exception\WrongUserinput $e)
3044 3043
 					{
3045
-						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()));
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()));
3046 3045
 					}
3047 3046
 				}
3048 3047
 				else
3049 3048
 				{
3050
-					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3049
+					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName));
3051 3050
 				}
3052 3051
 			}
3053 3052
 			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
@@ -3058,27 +3057,27 @@  discard block
 block discarded – undo
3058 3057
 		$lastDrafted = false;
3059 3058
 		if (isset($this->sessionData['lastDrafted']))
3060 3059
 		{
3061
-			$lastDrafted=array();
3060
+			$lastDrafted = array();
3062 3061
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3063 3062
 			$lastDrafted['uid'] = $dhA['msgUID'];
3064 3063
 			$lastDrafted['folder'] = $dhA['folder'];
3065
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3064
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']);
3066 3065
 			// manually drafted, do not delete
3067 3066
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3068
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3067
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false;
3069 3068
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3070 3069
 		}
3071 3070
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
3072 3071
 		{
3073 3072
 			try
3074 3073
 			{
3075
-				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' &&
3076
-					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments']))
3074
+				if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' &&
3075
+					($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3077 3076
 				{
3078 3077
 					//error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData));
3079 3078
 					//error_log(__METHOD__.__LINE__."#".array2string($_formData));
3080 3079
 					//error_log(__METHOD__.__LINE__."#".array2string($this->sessionData));
3081
-					$mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately');
3080
+					$mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately');
3082 3081
 				}
3083 3082
 			}
3084 3083
 			catch (Api\Exception $e)
@@ -3090,22 +3089,22 @@  discard block
 block discarded – undo
3090 3089
 		unset($this->sessionData['lastDrafted']);
3091 3090
 
3092 3091
 		//error_log("handling draft messages, flagging and such");
3093
-		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3092
+		if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3094 3093
 			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3095 3094
 			// mark message as answered
3096 3095
 			$mail_bo->openConnection();
3097
-			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3096
+			$mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3098 3097
 			// if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send
3099 3098
 			// unless your templatefolder is a subfolder of your draftfolder, and the message is in there
3100 3099
 			if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder']))
3101 3100
 			{
3102 3101
 				try // message may be deleted already, as it maybe done by autosave
3103 3102
 				{
3104
-					if ($_formData['mode']=='composefromdraft' &&
3103
+					if ($_formData['mode'] == 'composefromdraft' &&
3105 3104
 						!(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments']))
3106 3105
 					{
3107 3106
 						//error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']);
3108
-						$mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']);
3107
+						$mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder']);
3109 3108
 					}
3110 3109
 				}
3111 3110
 				catch (Api\Exception $e)
@@ -3114,14 +3113,14 @@  discard block
 block discarded – undo
3114 3113
 					unset($e);
3115 3114
 				}
3116 3115
 			} else {
3117
-				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3116
+				$mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder']));
3118 3117
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3119
-				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
3118
+				if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded')
3120 3119
 				{
3121 3120
 					try
3122 3121
 					{
3123 3122
 						//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3124
-						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']);
3123
+						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']);
3125 3124
 					}
3126 3125
 					catch (Api\Exception $e)
3127 3126
 					{
@@ -3149,18 +3148,18 @@  discard block
 block discarded – undo
3149 3148
 		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3150 3149
 		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3151 3150
 
3152
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3151
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on')
3153 3152
 		{
3154
-			foreach(array('to_infolog','to_tracker','to_calendar') as $app_key)
3153
+			foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key)
3155 3154
 			{
3156 3155
 				if ($_formData[$app_key] == 'on')
3157 3156
 				{
3158
-					$app_name = substr($app_key,3);
3157
+					$app_name = substr($app_key, 3);
3159 3158
 					// Get registered hook data of the app called for integration
3160
-					$hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name);
3159
+					$hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name);
3161 3160
 
3162 3161
 					// store mail / eml in temp. file to not have to download it from mail-server again
3163
-					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
3162
+					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate');
3164 3163
 					$eml_fp = fopen($eml, 'w');
3165 3164
 					stream_copy_to_stream($mail->getRaw(), $eml_fp);
3166 3165
 					fclose($eml_fp);
@@ -3170,24 +3169,24 @@  discard block
 block discarded – undo
3170 3169
 					// be stored from registered app method later
3171 3170
 					Framework::popup(Egw::link('/index.php', array(
3172 3171
 						'menuaction' => $hook['menuaction'],
3173
-						'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
3172
+						'egw_data' => Link::set_data(null, 'mail_integration::integrate', array(
3174 3173
 							$mailaddresses,
3175 3174
 							$this->sessionData['subject'],
3176 3175
 							$this->convertHTMLToText($this->sessionData['body']),
3177 3176
 							$this->sessionData['attachments'],
3178 3177
 							false, // date
3179 3178
 							$eml,
3180
-							$_formData['serverID']),true),
3179
+							$_formData['serverID']), true),
3181 3180
 						'app' => $app_name
3182
-					)),'_blank',$hook['popup']);
3181
+					)), '_blank', $hook['popup']);
3183 3182
 				}
3184 3183
 			}
3185 3184
 		}
3186 3185
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3187
-		elseif(is_array($this->sessionData['attachments']))
3186
+		elseif (is_array($this->sessionData['attachments']))
3188 3187
 		{
3189
-			foreach($this->sessionData['attachments'] as $value) {
3190
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3188
+			foreach ($this->sessionData['attachments'] as $value) {
3189
+				if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3191 3190
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3192 3191
 				}
3193 3192
 			}
@@ -3204,7 +3203,7 @@  discard block
 block discarded – undo
3204 3203
 	 * @param array $content
3205 3204
 	 * @return array - the input, enriched with some not set attributes
3206 3205
 	 */
3207
-	function setDefaults($content=array())
3206
+	function setDefaults($content = array())
3208 3207
 	{
3209 3208
 		// if there's not already an identity selected for current account
3210 3209
 		if (empty($content['mailidentity']))
@@ -3213,7 +3212,7 @@  discard block
 block discarded – undo
3213 3212
 			if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
3214 3213
 			{
3215 3214
 				$sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'];
3216
-				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0)
3215
+				if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0)
3217 3216
 				{
3218 3217
 					$content['mailidentity'] = $sigPref[$this->mail_bo->profileID];
3219 3218
 				}
@@ -3222,7 +3221,7 @@  discard block
 block discarded – undo
3222 3221
 			if (empty($content['mailidentity']))
3223 3222
 			{
3224 3223
 				$default_identity = null;
3225
-				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3224
+				foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3226 3225
 				{
3227 3226
 					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3228 3227
 					if (!empty($identity['ident_signature']))
@@ -3237,7 +3236,7 @@  discard block
 block discarded – undo
3237 3236
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3238 3237
 		{
3239 3238
 			$content['mimeType'] = 'html';
3240
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3239
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain';
3241 3240
 		}
3242 3241
 		return $content;
3243 3242
 
@@ -3260,7 +3259,7 @@  discard block
 block discarded – undo
3260 3259
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3261 3260
 	 * @return type
3262 3261
 	 */
3263
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3262
+	function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) {
3264 3263
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3265 3264
 		static $useCacheIfPossible = null;
3266 3265
 		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
@@ -3273,36 +3272,36 @@  discard block
 block discarded – undo
3273 3272
 		{
3274 3273
 			$this->changeProfile($_mailaccountToSearch);
3275 3274
 		}
3276
-		if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer))
3275
+		if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer))
3277 3276
 		{
3278 3277
 			//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
3279 3278
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3280 3279
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3281
-			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3282
-			if (count($folderObjects)<=1) {
3280
+			$folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible);
3281
+			if (count($folderObjects) <= 1) {
3283 3282
 				$useCacheIfPossible = false;
3284 3283
 			}
3285 3284
 			else
3286 3285
 			{
3287 3286
 				$useCacheIfPossible = true;
3288 3287
 			}
3289
-			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
3288
+			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP');
3290 3289
 			foreach ($folderObjects as $k =>$fA)
3291 3290
 			{
3292 3291
 				//error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
3293
-				$f=false;
3294
-				$key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k;
3295
-				if ($_searchStringLength<=0)
3292
+				$f = false;
3293
+				$key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k;
3294
+				if ($_searchStringLength <= 0)
3296 3295
 				{
3297
-					$f=true;
3296
+					$f = true;
3298 3297
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3299 3298
 				}
3300
-				if ($f==false && stripos($fA->displayName,$_searchString)!==false)
3299
+				if ($f == false && stripos($fA->displayName, $_searchString) !== false)
3301 3300
 				{
3302
-					$f=true;
3301
+					$f = true;
3303 3302
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3304 3303
 				}
3305
-				if ($f==false && stripos($k,$searchString)!==false)
3304
+				if ($f == false && stripos($k, $searchString) !== false)
3306 3305
 				{
3307 3306
 					$results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName));
3308 3307
 				}
@@ -3330,13 +3329,13 @@  discard block
 block discarded – undo
3330 3329
 		exit();
3331 3330
 	}
3332 3331
 
3333
-	public static function ajax_searchAddress($_searchStringLength=2) {
3332
+	public static function ajax_searchAddress($_searchStringLength = 2) {
3334 3333
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3335 3334
 		$_searchString = trim($_REQUEST['query']);
3336 3335
 		$include_lists = (boolean)$_REQUEST['include_lists'];
3337 3336
 
3338 3337
 		$contacts_obj = new Api\Contacts();
3339
-		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength)
3338
+		if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength)
3340 3339
 		{
3341 3340
 			//error_log(__METHOD__.__LINE__.array2string($_searchString));
3342 3341
 			$showAccounts = empty($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']);
@@ -3345,64 +3344,64 @@  discard block
 block discarded – undo
3345 3344
 			{
3346 3345
 				if (mb_strlen($v) < 3) unset($search[$k]);
3347 3346
 			}
3348
-			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3347
+			$search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns
3349 3348
 			//error_log(__METHOD__.__LINE__.$_searchString);
3350 3349
 			$filter = $showAccounts ? array() : array('account_id' => null);
3351
-			$filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home');
3352
-			$cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home');
3353
-			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter);
3350
+			$filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3351
+			$cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home');
3352
+			$contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3354 3353
 			// additionally search the accounts, if the contact storage is not the account storage
3355 3354
 			if ($showAccounts && $contacts_obj->so_accounts)
3356 3355
 			{
3357 3356
 				$filter['owner'] = 0;
3358
-				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter);
3357
+				$accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter);
3359 3358
 
3360 3359
 				if ($contacts && $accounts)
3361 3360
 				{
3362
-					$contacts = array_merge($contacts,$accounts);
3363
-					usort($contacts,function($a, $b)
3361
+					$contacts = array_merge($contacts, $accounts);
3362
+					usort($contacts, function($a, $b)
3364 3363
 					{
3365 3364
 						return strcasecmp($a['n_fn'], $b['n_fn']);
3366 3365
 					});
3367 3366
 				}
3368
-				elseif($accounts)
3367
+				elseif ($accounts)
3369 3368
 				{
3370
-					$contacts =& $accounts;
3369
+					$contacts = & $accounts;
3371 3370
 				}
3372 3371
 				unset($accounts);
3373 3372
 			}
3374 3373
 		}
3375 3374
 		$results = array();
3376
-		if(is_array($contacts)) {
3377
-			foreach($contacts as $contact) {
3378
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3375
+		if (is_array($contacts)) {
3376
+			foreach ($contacts as $contact) {
3377
+				foreach (array($contact['email'], $contact['email_home']) as $email) {
3379 3378
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3380 3379
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3381 3380
 					$rfcAddr = Mail::parseAddressList($email);
3382
-					$_rfcAddr=$rfcAddr->first();
3381
+					$_rfcAddr = $rfcAddr->first();
3383 3382
 					if (!$_rfcAddr->valid)
3384 3383
 					{
3385 3384
 						continue; // skip address if we encounter an error here
3386 3385
 					}
3387 3386
 					$email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host;
3388 3387
 
3389
-					if (method_exists($contacts_obj,'search'))
3388
+					if (method_exists($contacts_obj, 'search'))
3390 3389
 					{
3391
-						$contact['n_fn']='';
3390
+						$contact['n_fn'] = '';
3392 3391
 						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3393
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3394
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3395
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3396
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3392
+						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given'];
3393
+						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family'];
3394
+						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')';
3395
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3397 3396
 					}
3398 3397
 					else
3399 3398
 					{
3400
-						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3399
+						$contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']);
3401 3400
 					}
3402 3401
 					$args = explode('@', trim($email));
3403 3402
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3404 3403
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3405
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3404
+					if (!empty($email) && in_array($completeMailString, $results) === false) {
3406 3405
 						$results[] = array(
3407 3406
 							'id'=>$completeMailString,
3408 3407
 							'label' => $completeMailString,
@@ -3418,10 +3417,10 @@  discard block
 block discarded – undo
3418 3417
 		// Add groups
3419 3418
 		$group_options = array('account_type' => 'groups');
3420 3419
 		$groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options);
3421
-		foreach($groups as $g_id => $name)
3420
+		foreach ($groups as $g_id => $name)
3422 3421
 		{
3423 3422
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3424
-			if(!$group['account_email']) continue;
3423
+			if (!$group['account_email']) continue;
3425 3424
 			$args = explode('@', trim($group['account_email']));
3426 3425
 			$args[] = $name;
3427 3426
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3434,7 +3433,7 @@  discard block
 block discarded – undo
3434 3433
 		}
3435 3434
 
3436 3435
 		// Add up to 5 matching mailing lists
3437
-		if($include_lists)
3436
+		if ($include_lists)
3438 3437
 		{
3439 3438
 			$lists = array_filter(
3440 3439
 				$contacts_obj->get_lists(Acl::READ),
@@ -3443,7 +3442,7 @@  discard block
 block discarded – undo
3443 3442
 				}
3444 3443
 			);
3445 3444
 			$list_count = 0;
3446
-			foreach($lists as $key => $list_name)
3445
+			foreach ($lists as $key => $list_name)
3447 3446
 			{
3448 3447
 				$results[] = array(
3449 3448
 					'id'	=> $key,
@@ -3453,7 +3452,7 @@  discard block
 block discarded – undo
3453 3452
 					'title' => lang('Mailinglist'),
3454 3453
 					'data'	=> $key
3455 3454
 				);
3456
-				if($list_count++ > 5) break;
3455
+				if ($list_count++ > 5) break;
3457 3456
 			}
3458 3457
 		}
3459 3458
 		 // switch regular JSON response handling off
@@ -3474,7 +3473,7 @@  discard block
 block discarded – undo
3474 3473
 	public function ajax_merge($contact_id)
3475 3474
 	{
3476 3475
 		$response = Api\Json\Response::get();
3477
-		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3476
+		if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
3478 3477
 		{
3479 3478
 			$document_merge = new $_REQUEST['merge']();
3480 3479
 		}
@@ -3484,7 +3483,7 @@  discard block
 block discarded – undo
3484 3483
 		}
3485 3484
 		$this->mail_bo->openConnection();
3486 3485
 
3487
-		if(($error = $document_merge->check_document($_REQUEST['document'],'')))
3486
+		if (($error = $document_merge->check_document($_REQUEST['document'], '')))
3488 3487
 		{
3489 3488
 			$response->error($error);
3490 3489
 			return;
@@ -3493,20 +3492,20 @@  discard block
 block discarded – undo
3493 3492
 		// Actually do the merge
3494 3493
 		$folder = $merged_mail_id = null;
3495 3494
 		$results = $this->mail_bo->importMessageToMergeAndSend(
3496
-			$document_merge, Vfs::PREFIX . $_REQUEST['document'],
3495
+			$document_merge, Vfs::PREFIX.$_REQUEST['document'],
3497 3496
 			// Send an extra non-numeric ID to force actual send of document
3498 3497
 			// instead of save as draft
3499 3498
 			array((int)$contact_id, ''),
3500
-			$folder,$merged_mail_id
3499
+			$folder, $merged_mail_id
3501 3500
 		);
3502 3501
 
3503
-		if($results['success'])
3502
+		if ($results['success'])
3504 3503
 		{
3505
-			$response->data(implode(',',$results['success']));
3504
+			$response->data(implode(',', $results['success']));
3506 3505
 		}
3507
-		if($results['failed'])
3506
+		if ($results['failed'])
3508 3507
 		{
3509
-			$response->error(implode(',',$results['failed']));
3508
+			$response->error(implode(',', $results['failed']));
3510 3509
 		}
3511 3510
 	}
3512 3511
 }
Please login to merge, or discard this patch.
Braces   +799 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
 		}
@@ -241,7 +254,8 @@  discard block
 block discarded – undo
241 254
 		{
242 255
 			foreach (array_keys($actions) as $key)
243 256
 			{
244
-				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) {
257
+				if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' )))
258
+				{
245 259
 					$actions[$key]['toolbarDefault'] = false;
246 260
 				}
247 261
 			}
@@ -261,7 +275,10 @@  discard block
 block discarded – undo
261 275
 	 */
262 276
 	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
263 277
 	{
264
-		if ($msg) Framework::message($msg);
278
+		if ($msg)
279
+		{
280
+			Framework::message($msg);
281
+		}
265 282
 
266 283
 		if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
267 284
 		{
@@ -282,8 +299,14 @@  discard block
 block discarded – undo
282 299
 		//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
283 300
 		$_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false;
284 301
 		$_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false;
285
-		if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
286
-		if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
302
+		if (isset($_GET['reply_id']))
303
+		{
304
+			$replyID = $_GET['reply_id'];
305
+		}
306
+		if (!$replyID && isset($_GET['id']))
307
+		{
308
+			$replyID = $_GET['id'];
309
+		}
287 310
 
288 311
 		// Process different places we can use as a start for composing an email
289 312
 		$actionToProcess = 'compose';
@@ -350,7 +373,10 @@  discard block
 block discarded – undo
350 373
 			$suppressSigOnTop = true;
351 374
 			foreach ($_content['uploadForCompose'] as $i => &$upload)
352 375
 			{
353
-				if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
376
+				if (!isset($upload['file']))
377
+				{
378
+					$upload['file'] = $upload['tmp_name'];
379
+				}
354 380
 				try
355 381
 				{
356 382
 					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
@@ -384,9 +410,15 @@  discard block
 block discarded – undo
384 410
 				$remove=false;
385 411
 				foreach(array_keys($toDelete) as $k)
386 412
 				{
387
-					if ($att['tmp_name']==$k) $remove=true;
413
+					if ($att['tmp_name']==$k)
414
+					{
415
+						$remove=true;
416
+					}
417
+				}
418
+				if (!$remove)
419
+				{
420
+					$_content['attachments'][] = $att;
388 421
 				}
389
-				if (!$remove) $_content['attachments'][] = $att;
390 422
 			}
391 423
 		}
392 424
 		// someone clicked something like send, or saveAsDraft
@@ -401,8 +433,7 @@  discard block
 block discarded – undo
401 433
 		//error_log(__METHOD__.__LINE__.array2string($_content));
402 434
 		if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
403 435
 			($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
404
-		)
405
-		{
436
+		) {
406 437
 			$this->changeProfile($_content['serverID']);
407 438
 			$composeProfile = $this->mail_bo->profileID;
408 439
 		}
@@ -482,7 +513,10 @@  discard block
 block discarded – undo
482 513
 							//$this->sessionData['uid'][] = $fhA['msgUID'];
483 514
 							//$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
484 515
 							$idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false);
485
-							if (!empty($fhA['folder'])) $workingFolder = $fhA['folder'];
516
+							if (!empty($fhA['folder']))
517
+							{
518
+								$workingFolder = $fhA['folder'];
519
+							}
486 520
 						}
487 521
 					}
488 522
 					if ($_content['mode']=='reply' && !empty($_content['processedmail_id']))
@@ -533,7 +567,10 @@  discard block
 block discarded – undo
533 567
 			}
534 568
 		}
535 569
 
536
-		if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile);
570
+		if ($activeProfile != $composeProfile)
571
+		{
572
+			$this->changeProfile($activeProfile);
573
+		}
537 574
 		$insertSigOnTop = false;
538 575
 		$content = (is_array($_content)?$_content:array());
539 576
 		if ($_contentHasMimeType)
@@ -562,7 +599,10 @@  discard block
 block discarded – undo
562 599
 				{
563 600
 					foreach ($contentArr as $k =>&$elem)
564 601
 					{
565
-						if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
602
+						if (stripos($elem,'<pre>')!==false)
603
+						{
604
+							$elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
605
+						}
566 606
 					}
567 607
 					$content['mail_htmltext'] = implode('',$contentArr);
568 608
 				}
@@ -599,8 +639,7 @@  discard block
 block discarded – undo
599 639
 		if ( !empty($content['body']) &&
600 640
 			(!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) ||
601 641
 			(!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity'])
602
-		)
603
-		{
642
+		) {
604 643
 			$buttonClicked = true;
605 644
 			$suppressSigOnTop = true;
606 645
 			if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount'])
@@ -616,7 +655,10 @@  discard block
 block discarded – undo
616 655
 				else
617 656
 				{
618 657
 					$newSig = $this->mail_bo->getDefaultIdentity();
619
-					if ($newSig === false) $newSig = -2;
658
+					if ($newSig === false)
659
+					{
660
+						$newSig = -2;
661
+					}
620 662
 				}
621 663
 			}
622 664
 			$_oldSig = $composeCache['mailidentity'];
@@ -624,7 +666,10 @@  discard block
 block discarded – undo
624 666
 			$_currentMode = $_content['mimeType'];
625 667
 			if ($_oldSig != $_signatureid)
626 668
 			{
627
-				if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
669
+				if($this->_debug)
670
+				{
671
+					error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
672
+				}
628 673
 				// prepare signatures, the selected sig may be used on top of the body
629 674
 				try
630 675
 				{
@@ -654,7 +699,10 @@  discard block
 block discarded – undo
654 699
 				{
655 700
 					$oldSigText = $this->convertHTMLToText($oldSigText,true,true);
656 701
 					$sigText = $this->convertHTMLToText($sigText,true,true);
657
-					if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
702
+					if($this->_debug)
703
+					{
704
+						error_log(__METHOD__." Old signature:".$oldSigText);
705
+					}
658 706
 				}
659 707
 
660 708
 				//$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
@@ -670,7 +718,11 @@  discard block
 block discarded – undo
670 718
 				{
671 719
 					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
672 720
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
673
-					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
721
+					if (stripos($content['body'],'style')!==false)
722
+					{
723
+						Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true);
724
+					}
725
+					// clean out empty or pagewide style definitions / left over tags
674 726
 				}
675 727
 				$content['body'] = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($content['body'],Mail::$htmLawed_config,array(),true):$content['body']));
676 728
 				Mail::$htmLawed_config = $_htmlConfig;
@@ -714,8 +766,14 @@  discard block
 block discarded – undo
714 766
 
715 767
 				if ($found === false)
716 768
 				{
717
-					if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
718
-					if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']);
769
+					if($this->_debug)
770
+					{
771
+						error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned);
772
+					}
773
+					if($this->_debug)
774
+					{
775
+						error_log(__METHOD__." Compare content:".$content['body']);
776
+					}
719 777
 				}
720 778
 				else
721 779
 				{
@@ -730,7 +788,10 @@  discard block
 block discarded – undo
730 788
 		}
731 789
 
732 790
 		// do not double insert a signature on a server roundtrip
733
-		if ($buttonClicked) $suppressSigOnTop = true;
791
+		if ($buttonClicked)
792
+		{
793
+			$suppressSigOnTop = true;
794
+		}
734 795
 		if ($isFirstLoad)
735 796
 		{
736 797
 			$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
@@ -769,7 +830,8 @@  discard block
 block discarded – undo
769 830
 							}
770 831
 						}
771 832
 						$content['subject'] = lang($app).' #'.$res['id'].': ';
772
-						foreach(array('subject','body','mimetype') as $name) {
833
+						foreach(array('subject','body','mimetype') as $name)
834
+						{
773 835
 							$sName = $name;
774 836
 							if ($name=='mimetype'&&$res[$name])
775 837
 							{
@@ -778,7 +840,10 @@  discard block
 block discarded – undo
778 840
 							}
779 841
 							else
780 842
 							{
781
-								if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
843
+								if ($res[$name])
844
+								{
845
+									$content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name];
846
+								}
782 847
 							}
783 848
 						}
784 849
 					}
@@ -789,7 +854,8 @@  discard block
 block discarded – undo
789 854
 			{
790 855
 				$alreadyProcessed=array();
791 856
 				//_debug_array($_REQUEST);
792
-				if ($_REQUEST['preset']['mailto']) {
857
+				if ($_REQUEST['preset']['mailto'])
858
+				{
793 859
 					// handle mailto strings such as
794 860
 					// mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
795 861
 					// the above string may be htmlentyty encoded, then multiple body tags are supported
@@ -797,10 +863,12 @@  discard block
 block discarded – undo
797 863
 					$tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7)));
798 864
 					// check if there is more than the to address
799 865
 					$mailtoArray = explode('?',$tmp_send_to,2);
800
-					if ($mailtoArray[1]) {
866
+					if ($mailtoArray[1])
867
+					{
801 868
 						// check if there are more than one requests
802 869
 						$addRequests = explode('&',$mailtoArray[1]);
803
-						foreach ($addRequests as $key => $reqval) {
870
+						foreach ($addRequests as $key => $reqval)
871
+						{
804 872
 							// the additional requests should have a =, to separate key from value.
805 873
 							$keyValuePair = explode('=',$reqval,2);
806 874
 							$content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1];
@@ -809,17 +877,24 @@  discard block
 block discarded – undo
809 877
 					$content['to']=$mailtoArray[0];
810 878
 					$alreadyProcessed['to']='to';
811 879
 					// if the mailto string is not htmlentity decoded the arguments are passed as simple requests
812
-					foreach(array('cc','bcc','subject','body') as $name) {
880
+					foreach(array('cc','bcc','subject','body') as $name)
881
+					{
813 882
 						$alreadyProcessed[$name]=$name;
814
-						if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
883
+						if ($_REQUEST[$name])
884
+						{
885
+							$content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name];
886
+						}
815 887
 					}
816 888
 				}
817 889
 
818
-				if ($_REQUEST['preset']['mailtocontactbyid']) {
819
-					if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
890
+				if ($_REQUEST['preset']['mailtocontactbyid'])
891
+				{
892
+					if ($GLOBALS['egw_info']['user']['apps']['addressbook'])
893
+					{
820 894
 						$contacts_obj = new Api\Contacts();
821 895
 						$addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook'];
822
-						if (method_exists($contacts_obj,'search')) {
896
+						if (method_exists($contacts_obj,'search'))
897
+						{
823 898
 
824 899
 							$addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']);
825 900
 							foreach ((array)$addressArray as $id => $addressID)
@@ -834,7 +909,10 @@  discard block
 block discarded – undo
834 909
 							{
835 910
 								$_searchCond = array('contact_id'=>$addressArray);
836 911
 								//error_log(__METHOD__.__LINE__.$_searchString);
837
-								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $showAccounts=false;
912
+								if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
913
+								{
914
+									$showAccounts=false;
915
+								}
838 916
 								$filter = ($showAccounts?array():array('account_id' => null));
839 917
 								$filter['cols_to_search']=array('n_fn','email','email_home');
840 918
 								$contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter);
@@ -857,21 +935,28 @@  discard block
 block discarded – undo
857 935
 									unset($accounts);
858 936
 								}
859 937
 							}
860
-							if(is_array($contacts)) {
938
+							if(is_array($contacts))
939
+							{
861 940
 								$mailtoArray = array();
862 941
 								$primary = $addressbookprefs['distributionListPreferredMail'];
863
-								if ($primary != 'email' && $primary != 'email_home') $primary = 'email';
942
+								if ($primary != 'email' && $primary != 'email_home')
943
+								{
944
+									$primary = 'email';
945
+								}
864 946
 								$secondary = ($primary == 'email'?'email_home':'email');
865 947
 								//error_log(__METHOD__.__LINE__.array2string($contacts));
866
-								foreach($contacts as $contact) {
948
+								foreach($contacts as $contact)
949
+								{
867 950
 									$innerCounter=0;
868
-									foreach(array($contact[$primary],$contact[$secondary]) as $email) {
951
+									foreach(array($contact[$primary],$contact[$secondary]) as $email)
952
+									{
869 953
 										// use pref distributionListPreferredMail for the primary address
870 954
 										// avoid wrong addresses, if an rfc822 encoded address is in addressbook
871 955
 										$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
872 956
 										$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
873 957
 										$completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>');
874
-										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) {
958
+										if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false)
959
+										{
875 960
 											$i++;
876 961
 											$innerCounter++;
877 962
 											$mailtoArray[$i] = $completeMailString;
@@ -963,7 +1048,10 @@  discard block
 block discarded – undo
963 1048
 							}
964 1049
 						}
965 1050
 					}
966
-					if(!empty($remember)) $content = array_merge($content,$remember);
1051
+					if(!empty($remember))
1052
+					{
1053
+						$content = array_merge($content,$remember);
1054
+					}
967 1055
 				}
968 1056
 				foreach(array('to','cc','bcc','subject','body','mimeType') as $name)
969 1057
 				{
@@ -973,9 +1061,15 @@  discard block
 block discarded – undo
973 1061
 						$_content[$name]=$content[$name]=$_REQUEST['preset'][$name];
974 1062
 					}
975 1063
 					//skip if already processed by "preset Routines"
976
-					if ($alreadyProcessed[$name]) continue;
1064
+					if ($alreadyProcessed[$name])
1065
+					{
1066
+						continue;
1067
+					}
977 1068
 					//error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]);
978
-					if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name];
1069
+					if ($_REQUEST['preset'][$name])
1070
+					{
1071
+						$content[$name] = $_REQUEST['preset'][$name];
1072
+					}
979 1073
 				}
980 1074
 			}
981 1075
 			// is the to address set already?
@@ -983,7 +1077,10 @@  discard block
 block discarded – undo
983 1077
 			{
984 1078
 				$content['to'] = base64_decode($_REQUEST['send_to']);
985 1079
 				// first check if there is a questionmark or ampersand
986
-				if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2);
1080
+				if (strpos($content['to'],'?')!== false)
1081
+				{
1082
+					list($content['to'],$rest) = explode('?',$content['to'],2);
1083
+				}
987 1084
 				$content['to'] = html_entity_decode($content['to']);
988 1085
 				if (($at_pos = strpos($content['to'],'@')) !== false)
989 1086
 				{
@@ -996,9 +1093,15 @@  discard block
 block discarded – undo
996 1093
 						$content['to'] = $email;
997 1094
 					}
998 1095
 				}
999
-				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1096
+				if (strpos($content['to'],'%40')!== false)
1097
+				{
1098
+					$content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
1099
+				}
1000 1100
 				$rarr = array(Api\Html::purify($rest));
1001
-				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
1101
+				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false)
1102
+				{
1103
+					$rarr = explode('&',$rest);
1104
+				}
1002 1105
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
1003 1106
 				$karr = array();
1004 1107
 				foreach ($rarr as &$rval)
@@ -1014,9 +1117,15 @@  discard block
 block discarded – undo
1014 1117
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr));
1015 1118
 				foreach(array('cc','bcc','subject','body') as $name)
1016 1119
 				{
1017
-					if ($karr[$name]) $content[$name] = $karr[$name];
1120
+					if ($karr[$name])
1121
+					{
1122
+						$content[$name] = $karr[$name];
1123
+					}
1124
+				}
1125
+				if (!empty($_REQUEST['subject']))
1126
+				{
1127
+					$content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1018 1128
 				}
1019
-				if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
1020 1129
 			}
1021 1130
 		}
1022 1131
 		//error_log(__METHOD__.__LINE__.array2string($content));
@@ -1034,7 +1143,10 @@  discard block
 block discarded – undo
1034 1143
 				$_content['mimeType'] = $content['mimeType']  = 'html';
1035 1144
 				$content['body'] = "<pre>".$content['body']."</pre>";
1036 1145
 				// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1037
-				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);
1146
+				if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1147
+				{
1148
+					$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1149
+				}
1038 1150
 			}
1039 1151
 		}
1040 1152
 		else
@@ -1054,7 +1166,10 @@  discard block
 block discarded – undo
1054 1166
 					$_content['mimeType'] = $content['mimeType']  = 'html';
1055 1167
 					$content['body'] = "<pre>".$content['body']."</pre>";
1056 1168
 					// take care this assumption is made on the creation of the reply header in bocompose::getReplyData
1057
-					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);
1169
+					if (strpos($content['body'],"<pre> \r\n \r\n---")===0)
1170
+					{
1171
+						$content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1);
1172
+					}
1058 1173
 				}
1059 1174
 			}
1060 1175
 		}
@@ -1092,24 +1207,33 @@  discard block
 block discarded – undo
1092 1207
 			$disableRuler = true;
1093 1208
 		}
1094 1209
 		$font_span = $font_part = '';
1095
-		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/) {
1210
+		if($content['mimeType'] == 'html' /*&& trim($content['body'])==''*/)
1211
+		{
1096 1212
 			// User preferences for style
1097 1213
 			$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
1098 1214
 			$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
1099 1215
 			$font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
1100 1216
 			$font_span = $font_part.'&#8203;</span>';
1101
-			if (empty($font) && empty($font_size)) $font_span = '';
1217
+			if (empty($font) && empty($font_size))
1218
+			{
1219
+				$font_span = '';
1220
+			}
1102 1221
 		}
1103 1222
 		// 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
1104
-		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = '';
1223
+		if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false)
1224
+		{
1225
+			$font_span = '';
1226
+		}
1105 1227
 		//remove possible html header stuff
1106
-		if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1228
+		if (stripos($content['body'],'<html><head></head><body>')!==false)
1229
+		{
1230
+			$content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']);
1231
+		}
1107 1232
 		//error_log(__METHOD__.__LINE__.array2string($this->mailPreferences));
1108 1233
 		$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');
1109 1234
 		if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' &&
1110 1235
 			!(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop
1111
-		)
1112
-		{
1236
+		) {
1113 1237
 			// ON tOP OR BELOW? pREF CAN TELL
1114 1238
 			/*
1115 1239
 				Signature behavior preference changed. New default, if not set -> 0
@@ -1124,14 +1248,23 @@  discard block
 block discarded – undo
1124 1248
 				$sigTextStartsWithBlockElement = ($disableRuler?false:true);
1125 1249
 				foreach($blockElements as $e)
1126 1250
 				{
1127
-					if ($sigTextStartsWithBlockElement) break;
1128
-					if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true;
1251
+					if ($sigTextStartsWithBlockElement)
1252
+					{
1253
+						break;
1254
+					}
1255
+					if (stripos(trim($sigText),'<'.$e)===0)
1256
+					{
1257
+						$sigTextStartsWithBlockElement = true;
1258
+					}
1129 1259
 				}
1130 1260
 			}
1131
-			if($content['mimeType'] == 'html') {
1261
+			if($content['mimeType'] == 'html')
1262
+			{
1132 1263
 				$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
1133 1264
 				$inbetween = '';
1134
-			} else {
1265
+			}
1266
+			else
1267
+			{
1135 1268
 				$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
1136 1269
 				$inbetween = "\r\n";
1137 1270
 			}
@@ -1175,16 +1308,24 @@  discard block
 block discarded – undo
1175 1308
 		//$content['bcc'] = array('[email protected]','[email protected]');
1176 1309
 		// address stuff like from, to, cc, replyto
1177 1310
 		$destinationRows = 0;
1178
-		foreach(self::$destinations as $destination) {
1311
+		foreach(self::$destinations as $destination)
1312
+		{
1179 1313
 			if (!is_array($content[$destination]))
1180 1314
 			{
1181
-				if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination];
1315
+				if (!empty($content[$destination]))
1316
+				{
1317
+					$content[$destination] = (array)$content[$destination];
1318
+				}
1182 1319
 			}
1183 1320
 			$addr_content = $content[strtolower($destination)];
1184 1321
 			// we clear the given address array and rebuild it
1185 1322
 			unset($content[strtolower($destination)]);
1186
-			foreach((array)$addr_content as $key => $value) {
1187
-				if ($value=="NIL@NIL") continue;
1323
+			foreach((array)$addr_content as $key => $value)
1324
+			{
1325
+				if ($value=="NIL@NIL")
1326
+				{
1327
+					continue;
1328
+				}
1188 1329
 				if ($destination=='replyto' && str_replace('"','',$value) ==
1189 1330
 					str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()]))
1190 1331
 				{
@@ -1194,8 +1335,12 @@  discard block
 block discarded – undo
1194 1335
 				}
1195 1336
 				//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
1196 1337
 				$value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT));
1197
-				foreach(Mail::parseAddressList($value) as $addressObject) {
1198
-					if ($addressObject->host == '.SYNTAX-ERROR.') continue;
1338
+				foreach(Mail::parseAddressList($value) as $addressObject)
1339
+				{
1340
+					if ($addressObject->host == '.SYNTAX-ERROR.')
1341
+					{
1342
+						continue;
1343
+					}
1199 1344
 					$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
1200 1345
 					//$address = Mail::htmlentities($address, $this->displayCharset);
1201 1346
 					$content[strtolower($destination)][]=$address;
@@ -1206,11 +1351,20 @@  discard block
 block discarded – undo
1206 1351
 		if ($_content)
1207 1352
 		{
1208 1353
 			//input array of _content had no signature information but was seeded later, and content has a valid setting
1209
-			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']);
1354
+			if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content))
1355
+			{
1356
+				unset($_content['mailidentity']);
1357
+			}
1210 1358
 			$content = array_merge($content,$_content);
1211 1359
 
1212
-			if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
1213
-			if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID;
1360
+			if (!empty($content['folder']))
1361
+			{
1362
+				$sel_options['folder']=$this->ajax_searchFolder(0,true);
1363
+			}
1364
+			if (empty($content['mailaccount']))
1365
+			{
1366
+				$content['mailaccount'] = $this->mail_bo->profileID;
1367
+			}
1214 1368
 		}
1215 1369
 		else
1216 1370
 		{
@@ -1253,11 +1407,17 @@  discard block
 block discarded – undo
1253 1407
 		//error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']);
1254 1408
 		$preserv['is_html'] = $content['is_html'];
1255 1409
 		$preserv['is_plain'] = $content['is_plain'];
1256
-		if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
1410
+		if (isset($content['mimeType']))
1411
+		{
1412
+			$preserv['mimeType'] = $content['mimeType'];
1413
+		}
1257 1414
 		$sel_options['mimeType'] = self::$mimeTypes;
1258 1415
 		$sel_options['priority'] = self::$priorities;
1259 1416
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
1260
-		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
1417
+		if (!isset($content['priority']) || empty($content['priority']))
1418
+		{
1419
+			$content['priority']=3;
1420
+		}
1261 1421
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
1262 1422
 		$etpl = new Etemplate('mail.compose');
1263 1423
 
@@ -1304,9 +1464,12 @@  discard block
 block discarded – undo
1304 1464
 		$preserv['list-id'] = $content['list-id'];
1305 1465
 		$preserv['mode'] = $content['mode'];
1306 1466
 		// convert it back to checkbox expectations
1307
-		if($content['mimeType'] == 'html') {
1467
+		if($content['mimeType'] == 'html')
1468
+		{
1308 1469
 			$content['mimeType']=1;
1309
-		} else {
1470
+		}
1471
+		else
1472
+		{
1310 1473
 			$content['mimeType']=0;
1311 1474
 		}
1312 1475
 		// set the current selected mailaccount as param for folderselection
@@ -1317,7 +1480,10 @@  discard block
 block discarded – undo
1317 1480
 		// Resolve distribution list before send content to client
1318 1481
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $f)
1319 1482
 		{
1320
-			if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
1483
+			if (is_array($content[$f]))
1484
+			{
1485
+				$content[$f]= self::resolveEmailAddressList ($content[$f]);
1486
+			}
1321 1487
 		}
1322 1488
 
1323 1489
 		$content['to'] = self::resolveEmailAddressList($content['to']);
@@ -1365,7 +1531,10 @@  discard block
 block discarded – undo
1365 1531
 				case 'composefromdraft':
1366 1532
 				case 'composeasnew':
1367 1533
 					$content = $this->getDraftData($icServer, $folder, $msgUID, $part_id);
1368
-					if ($from =='composefromdraft') $content['mode'] = 'composefromdraft';
1534
+					if ($from =='composefromdraft')
1535
+					{
1536
+						$content['mode'] = 'composefromdraft';
1537
+					}
1369 1538
 					$content['processedmail_id'] = $mail_id;
1370 1539
 
1371 1540
 					$_focusElement = 'body';
@@ -1413,7 +1582,10 @@  discard block
 block discarded – undo
1413 1582
 			$document_merge = new $merge_class();
1414 1583
 			$this->mail_bo->openConnection();
1415 1584
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
1416
-			if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids);
1585
+			if (!is_array($merge_ids))
1586
+			{
1587
+				$merge_ids = explode(',',$merge_ids);
1588
+			}
1417 1589
 			try
1418 1590
 			{
1419 1591
 				$merged_mail_id = '';
@@ -1444,7 +1616,10 @@  discard block
 block discarded – undo
1444 1616
 				{
1445 1617
 					$success = implode(', ',$results['success']);
1446 1618
 					$fail = implode(', ', $results['failed']);
1447
-					if($success) Framework::message($success, 'success');
1619
+					if($success)
1620
+					{
1621
+						Framework::message($success, 'success');
1622
+					}
1448 1623
 					Framework::window_close($fail);
1449 1624
 				}
1450 1625
 			}
@@ -1476,17 +1651,25 @@  discard block
 block discarded – undo
1476 1651
 	{
1477 1652
 		$stripalltags = true;
1478 1653
 		// third param is stripalltags, we may not need that, if the source is already in ascii
1479
-		if (!$sourceishtml) $stripalltags=false;
1654
+		if (!$sourceishtml)
1655
+		{
1656
+			$stripalltags=false;
1657
+		}
1480 1658
 		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
1481 1659
 	}
1482 1660
 
1483 1661
 	function generateRFC822Address($_addressObject)
1484 1662
 	{
1485
-		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
1663
+		if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host)
1664
+		{
1486 1665
 			return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1487
-		} elseif($_addressObject->mailbox && $_addressObject->host) {
1666
+		}
1667
+		elseif($_addressObject->mailbox && $_addressObject->host)
1668
+		{
1488 1669
 			return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
1489
-		} else {
1670
+		}
1671
+		else
1672
+		{
1490 1673
 			return $this->mail_bo->decode_header($_addressObject->mailbox,true);
1491 1674
 		}
1492 1675
 	}
@@ -1520,16 +1703,28 @@  discard block
 block discarded – undo
1520 1703
 		//if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC'];
1521 1704
 
1522 1705
 		//error_log(__METHOD__.__LINE__.array2string($headers));
1523
-		if (!empty($addHeadInfo['X-MAILFOLDER'])) {
1524
-			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) {
1706
+		if (!empty($addHeadInfo['X-MAILFOLDER']))
1707
+		{
1708
+			foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val )
1709
+			{
1525 1710
 				$fval=$val;
1526 1711
 				$icServerID = $mail_bo->icServer->ImapServerId;
1527
-				if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2);
1528
-				if ($icServerID != $mail_bo->icServer->ImapServerId) continue;
1529
-				if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val;
1712
+				if (stripos($val,'::')!==false)
1713
+				{
1714
+					list($icServerID,$fval) = explode('::',$val,2);
1715
+				}
1716
+				if ($icServerID != $mail_bo->icServer->ImapServerId)
1717
+				{
1718
+					continue;
1719
+				}
1720
+				if ($mail_bo->folderExists($fval))
1721
+				{
1722
+					$this->sessionData['folder'][] = $val;
1723
+				}
1530 1724
 			}
1531 1725
 		}
1532
-		if (!empty($addHeadInfo['X-MAILIDENTITY'])) {
1726
+		if (!empty($addHeadInfo['X-MAILIDENTITY']))
1727
+		{
1533 1728
 			// with the new system it would be the identity
1534 1729
 			try
1535 1730
 			{
@@ -1545,7 +1740,8 @@  discard block
 block discarded – undo
1545 1740
 			$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
1546 1741
 		}
1547 1742
 		*/
1548
-		if (!empty($addHeadInfo['X-MAILACCOUNT'])) {
1743
+		if (!empty($addHeadInfo['X-MAILACCOUNT']))
1744
+		{
1549 1745
 			// with the new system it would the identity is the account id
1550 1746
 			try
1551 1747
 			{
@@ -1560,27 +1756,38 @@  discard block
 block discarded – undo
1560 1756
 			}
1561 1757
 		}
1562 1758
 		// if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort))
1563
-		if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder);
1759
+		if ($mail_bo->isDraftFolder($_folder))
1760
+		{
1761
+			$this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);
1762
+		}
1763
+		//array('uid'=>$_uid,'folder'=>$_folder);
1564 1764
 		$this->sessionData['uid'] = $_uid;
1565 1765
 		$this->sessionData['messageFolder'] = $_folder;
1566 1766
 		$this->sessionData['isDraft'] = true;
1567 1767
 		$foundAddresses = array();
1568
-		foreach((array)$headers['CC'] as $val) {
1768
+		foreach((array)$headers['CC'] as $val)
1769
+		{
1569 1770
 			$rfcAddr=Mail::parseAddressList($val);
1570 1771
 			$_rfcAddr = $rfcAddr[0];
1571
-			if (!$_rfcAddr->valid) continue;
1572
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1772
+			if (!$_rfcAddr->valid)
1773
+			{
1774
+				continue;
1775
+			}
1776
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1777
+			{
1573 1778
 				continue;
1574 1779
 			}
1575 1780
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1576
-			if(!$foundAddresses[$keyemail]) {
1781
+			if(!$foundAddresses[$keyemail])
1782
+			{
1577 1783
 				$address = $this->mail_bo->decode_header($val,true);
1578 1784
 				$this->sessionData['cc'][] = $val;
1579 1785
 				$foundAddresses[$keyemail] = true;
1580 1786
 			}
1581 1787
 		}
1582 1788
 
1583
-		foreach((array)$headers['TO'] as $val) {
1789
+		foreach((array)$headers['TO'] as $val)
1790
+		{
1584 1791
 			if(!is_array($val))
1585 1792
 			{
1586 1793
 				$this->sessionData['to'][] = $val;
@@ -1588,42 +1795,59 @@  discard block
 block discarded – undo
1588 1795
 			}
1589 1796
 			$rfcAddr=Mail::parseAddressList($val);
1590 1797
 			$_rfcAddr = $rfcAddr[0];
1591
-			if (!$_rfcAddr->valid) continue;
1592
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
1798
+			if (!$_rfcAddr->valid)
1799
+			{
1800
+				continue;
1801
+			}
1802
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) )
1803
+			{
1593 1804
 				continue;
1594 1805
 			}
1595 1806
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1596
-			if(!$foundAddresses[$keyemail]) {
1807
+			if(!$foundAddresses[$keyemail])
1808
+			{
1597 1809
 				$address = $this->mail_bo->decode_header($val,true);
1598 1810
 				$this->sessionData['to'][] = $val;
1599 1811
 				$foundAddresses[$keyemail] = true;
1600 1812
 			}
1601 1813
 		}
1602 1814
 
1603
-		foreach((array)$headers['REPLY-TO'] as $val) {
1815
+		foreach((array)$headers['REPLY-TO'] as $val)
1816
+		{
1604 1817
 			$rfcAddr=Mail::parseAddressList($val);
1605 1818
 			$_rfcAddr = $rfcAddr[0];
1606
-			if (!$_rfcAddr->valid) continue;
1607
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1819
+			if (!$_rfcAddr->valid)
1820
+			{
1821
+				continue;
1822
+			}
1823
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1824
+			{
1608 1825
 				continue;
1609 1826
 			}
1610 1827
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1611
-			if(!$foundAddresses[$keyemail]) {
1828
+			if(!$foundAddresses[$keyemail])
1829
+			{
1612 1830
 				$address = $this->mail_bo->decode_header($val,true);
1613 1831
 				$this->sessionData['replyto'][] = $val;
1614 1832
 				$foundAddresses[$keyemail] = true;
1615 1833
 			}
1616 1834
 		}
1617 1835
 
1618
-		foreach((array)$headers['BCC'] as $val) {
1836
+		foreach((array)$headers['BCC'] as $val)
1837
+		{
1619 1838
 			$rfcAddr=Mail::parseAddressList($val);
1620 1839
 			$_rfcAddr = $rfcAddr[0];
1621
-			if (!$_rfcAddr->valid) continue;
1622
-			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
1840
+			if (!$_rfcAddr->valid)
1841
+			{
1842
+				continue;
1843
+			}
1844
+			if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) )
1845
+			{
1623 1846
 				continue;
1624 1847
 			}
1625 1848
 			$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
1626
-			if(!$foundAddresses[$keyemail]) {
1849
+			if(!$foundAddresses[$keyemail])
1850
+			{
1627 1851
 				$address = $this->mail_bo->decode_header($val,true);
1628 1852
 				$this->sessionData['bcc'][] = $val;
1629 1853
 				$foundAddresses[$keyemail] = true;
@@ -1637,32 +1861,46 @@  discard block
 block discarded – undo
1637 1861
 		$bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID);
1638 1862
 		//_debug_array($bodyParts);
1639 1863
 		#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
1640
-		if($bodyParts['0']['mimeType'] == 'text/html') {
1864
+		if($bodyParts['0']['mimeType'] == 'text/html')
1865
+		{
1641 1866
 			$this->sessionData['mimeType'] 	= 'html';
1642 1867
 
1643
-			for($i=0; $i<count($bodyParts); $i++) {
1644
-				if($i>0) {
1868
+			for($i=0; $i<count($bodyParts); $i++)
1869
+			{
1870
+				if($i>0)
1871
+				{
1645 1872
 					$this->sessionData['body'] .= '<hr>';
1646 1873
 				}
1647
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
1874
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
1875
+				{
1648 1876
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']);
1649 1877
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
1650 1878
 				}
1651
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1879
+				if ($bodyParts[$i]['charSet']===false)
1880
+				{
1881
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1882
+				}
1652 1883
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1653 1884
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1654 1885
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
1655 1886
 			}
1656 1887
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID);
1657 1888
 
1658
-		} else {
1889
+		}
1890
+		else
1891
+		{
1659 1892
 			$this->sessionData['mimeType']	= 'plain';
1660 1893
 
1661
-			for($i=0; $i<count($bodyParts); $i++) {
1662
-				if($i>0) {
1894
+			for($i=0; $i<count($bodyParts); $i++)
1895
+			{
1896
+				if($i>0)
1897
+				{
1663 1898
 					$this->sessionData['body'] .= "<hr>";
1664 1899
 				}
1665
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1900
+				if ($bodyParts[$i]['charSet']===false)
1901
+				{
1902
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
1903
+				}
1666 1904
 				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
1667 1905
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
1668 1906
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
@@ -1670,8 +1908,10 @@  discard block
 block discarded – undo
1670 1908
 			$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain');
1671 1909
 		}
1672 1910
 
1673
-		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1674
-			foreach($attachments as $attachment) {
1911
+		if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1912
+		{
1913
+			foreach($attachments as $attachment)
1914
+			{
1675 1915
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
1676 1916
 				$cid = $attachment['cid'];
1677 1917
 				$match=null;
@@ -1693,7 +1933,8 @@  discard block
 block discarded – undo
1693 1933
 
1694 1934
 	function getErrorInfo()
1695 1935
 	{
1696
-		if(isset($this->errorInfo)) {
1936
+		if(isset($this->errorInfo))
1937
+		{
1697 1938
 			$errorInfo = $this->errorInfo;
1698 1939
 			unset($this->errorInfo);
1699 1940
 			return $errorInfo;
@@ -1708,7 +1949,8 @@  discard block
 block discarded – undo
1708 1949
 			$modebuff = $this->mailPreferences['message_forwarding'];
1709 1950
 			$this->mailPreferences['message_forwarding'] = $_mode;
1710 1951
 		}
1711
-		if  ($this->mailPreferences['message_forwarding'] == 'inline') {
1952
+		if  ($this->mailPreferences['message_forwarding'] == 'inline')
1953
+		{
1712 1954
 			$this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID);
1713 1955
 		}
1714 1956
 		$mail_bo    = $this->mail_bo;
@@ -1725,12 +1967,16 @@  discard block
 block discarded – undo
1725 1967
 		//$this->sessionData['sourceFolder']=$_folder;
1726 1968
 		//$this->sessionData['forwardFlag']='forwarded';
1727 1969
 		//$this->sessionData['forwardedUID']=$_uid;
1728
-		if  ($this->mailPreferences['message_forwarding'] == 'asmail') {
1970
+		if  ($this->mailPreferences['message_forwarding'] == 'asmail')
1971
+		{
1729 1972
 			$this->sessionData['mimeType']  = $this->mailPreferences['composeOptions'];
1730 1973
 			if($headers['SIZE'])
1731
-				$size				= $headers['SIZE'];
1732
-			else
1733
-				$size				= lang('unknown');
1974
+			{
1975
+							$size				= $headers['SIZE'];
1976
+			}
1977
+			else {
1978
+							$size				= lang('unknown');
1979
+			}
1734 1980
 
1735 1981
 			$this->addMessageAttachment($_uid, $_partID, $_folder,
1736 1982
 				$mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml',
@@ -1741,9 +1987,11 @@  discard block
 block discarded – undo
1741 1987
 			unset($this->sessionData['in-reply-to']);
1742 1988
 			unset($this->sessionData['to']);
1743 1989
 			unset($this->sessionData['cc']);
1744
-			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) {
1990
+			if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID)))
1991
+			{
1745 1992
 				//error_log(__METHOD__.__LINE__.':'.array2string($attachments));
1746
-				foreach($attachments as $attachment) {
1993
+				foreach($attachments as $attachment)
1994
+				{
1747 1995
 					if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])))
1748 1996
 					{
1749 1997
 						$this->addMessageAttachment($_uid, $attachment['partID'],
@@ -1799,7 +2047,10 @@  discard block
 block discarded – undo
1799 2047
 			{
1800 2048
 				if ($attach['name'] && $attach['name'] == $_formData['name'] &&
1801 2049
 					strtolower($_formData['type'])== strtolower($attach['type']) &&
1802
-					stripos($_formData['file'],'vfs://') !== false) return;
2050
+					stripos($_formData['file'],'vfs://') !== false)
2051
+				{
2052
+					return;
2053
+				}
1803 2054
 			}
1804 2055
 		}
1805 2056
 		if ($attachfailed === false)
@@ -1811,7 +2062,10 @@  discard block
 block discarded – undo
1811 2062
 				'tmp_name'	=> $tmpFileName,
1812 2063
 				'size'	=> $_formData['size']
1813 2064
 			);
1814
-			if (!is_array($_content['attachments'])) $_content['attachments']=array();
2065
+			if (!is_array($_content['attachments']))
2066
+			{
2067
+				$_content['attachments']=array();
2068
+			}
1815 2069
 			$_content['attachments'][] = $buffer;
1816 2070
 			unset($buffer);
1817 2071
 		}
@@ -1841,7 +2095,10 @@  discard block
 block discarded – undo
1841 2095
 		{
1842 2096
 			foreach($request->preserv['attachments'] as $attachment)
1843 2097
 			{
1844
-				if ($_GET['tmpname'] === $attachment['tmp_name']) break;
2098
+				if ($_GET['tmpname'] === $attachment['tmp_name'])
2099
+				{
2100
+					break;
2101
+				}
1845 2102
 			}
1846 2103
 		}
1847 2104
 		if (!$request || $_GET['tmpname'] !== $attachment['tmp_name'])
@@ -1875,10 +2132,20 @@  discard block
 block discarded – undo
1875 2132
 				$sfxMimeType = $attachment['type'];
1876 2133
 				$buff = explode('.',$attachment['tmp_name']);
1877 2134
 				$suffix = '';
1878
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
1879
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2135
+				if (is_array($buff))
2136
+				{
2137
+					$suffix = array_pop($buff);
2138
+				}
2139
+				// take the last extension to check with ext2mime
2140
+				if (!empty($suffix))
2141
+				{
2142
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2143
+				}
1880 2144
 				$attachment['type'] = $sfxMimeType;
1881
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2145
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2146
+				{
2147
+					$attachment['type'] = strtoupper($sfxMimeType);
2148
+				}
1882 2149
 			}
1883 2150
 			//error_log(__METHOD__.print_r($attachment,true));
1884 2151
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -1887,7 +2154,10 @@  discard block
 block discarded – undo
1887 2154
 				$calendar_ical = new calendar_ical();
1888 2155
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
1889 2156
 				//error_log(__METHOD__.array2string($eventid));
1890
-				if (!$eventid) $eventid = -1;
2157
+				if (!$eventid)
2158
+				{
2159
+					$eventid = -1;
2160
+				}
1891 2161
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true);
1892 2162
 				//error_log(__METHOD__.$event);
1893 2163
 				if ((int)$event > 0)
@@ -1913,7 +2183,10 @@  discard block
 block discarded – undo
1913 2183
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1914 2184
 					$contact = $addressbook_vcal->find_contact($vcard,false);
1915 2185
 				}
1916
-				if (!$contact) $contact = null;
2186
+				if (!$contact)
2187
+				{
2188
+					$contact = null;
2189
+				}
1917 2190
 				// 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))
1918 2191
 				if ($contact || count($vcard)>2)
1919 2192
 				{
@@ -1944,7 +2217,8 @@  discard block
 block discarded – undo
1944 2217
 	 * @param string haystack
1945 2218
 	 * @return boolean
1946 2219
 	 */
1947
-	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) {
2220
+	function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack)
2221
+	{
1948 2222
 		foreach (array_keys($arrayToTestAgainst) as $k)
1949 2223
 		{
1950 2224
 			//error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack);
@@ -1991,21 +2265,34 @@  discard block
 block discarded – undo
1991 2265
 		// thread-topic is a proprietary microsoft header and deprecated with the current version
1992 2266
 		// horde does not support the encoding of thread-topic, and probably will not no so in the future
1993 2267
 		//if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC'];
1994
-		if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
1995
-		if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID'];
2268
+		if ($headers['THREAD-INDEX'])
2269
+		{
2270
+			$this->sessionData['thread-index'] = $headers['THREAD-INDEX'];
2271
+		}
2272
+		if ($headers['LIST-ID'])
2273
+		{
2274
+			$this->sessionData['list-id'] = $headers['LIST-ID'];
2275
+		}
1996 2276
 		//error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers));
1997 2277
 		// check for Reply-To: header and use if available
1998
-		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) {
1999
-			foreach($headers['REPLY-TO'] as $val) {
2000
-				if(!$foundAddresses[$val]) {
2278
+		if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM']))
2279
+		{
2280
+			foreach($headers['REPLY-TO'] as $val)
2281
+			{
2282
+				if(!$foundAddresses[$val])
2283
+				{
2001 2284
 					$oldTo[] = $val;
2002 2285
 					$foundAddresses[$val] = true;
2003 2286
 				}
2004 2287
 			}
2005 2288
 			$oldToAddress	= (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']);
2006
-		} else {
2007
-			foreach($headers['FROM'] as $val) {
2008
-				if(!$foundAddresses[$val]) {
2289
+		}
2290
+		else
2291
+		{
2292
+			foreach($headers['FROM'] as $val)
2293
+			{
2294
+				if(!$foundAddresses[$val])
2295
+				{
2009 2296
 					$oldTo[] = $val;
2010 2297
 					$foundAddresses[$val] = true;
2011 2298
 				}
@@ -2013,18 +2300,23 @@  discard block
 block discarded – undo
2013 2300
 			$oldToAddress	= (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']);
2014 2301
 		}
2015 2302
 		//error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#');
2016
-		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) {
2303
+		if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) )
2304
+		{
2017 2305
 			$this->sessionData['to'] = $oldTo;
2018 2306
 		}
2019 2307
 
2020
-		if($_mode == 'all') {
2308
+		if($_mode == 'all')
2309
+		{
2021 2310
 			// reply to any address which is cc, but not to my self
2022 2311
 			#if($headers->cc) {
2023
-				foreach($headers['CC'] as $val) {
2024
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2312
+				foreach($headers['CC'] as $val)
2313
+				{
2314
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2315
+					{
2025 2316
 						continue;
2026 2317
 					}
2027
-					if(!$foundAddresses[$val]) {
2318
+					if(!$foundAddresses[$val])
2319
+					{
2028 2320
 						$this->sessionData['cc'][] = $val;
2029 2321
 						$foundAddresses[$val] = true;
2030 2322
 					}
@@ -2033,11 +2325,14 @@  discard block
 block discarded – undo
2033 2325
 
2034 2326
 			// reply to any address which is to, but not to my self
2035 2327
 			#if($headers->to) {
2036
-				foreach($headers['TO'] as $val) {
2037
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2328
+				foreach($headers['TO'] as $val)
2329
+				{
2330
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2331
+					{
2038 2332
 						continue;
2039 2333
 					}
2040
-					if(!$foundAddresses[$val]) {
2334
+					if(!$foundAddresses[$val])
2335
+					{
2041 2336
 						$this->sessionData['to'][] = $val;
2042 2337
 						$foundAddresses[$val] = true;
2043 2338
 					}
@@ -2045,12 +2340,15 @@  discard block
 block discarded – undo
2045 2340
 			#}
2046 2341
 
2047 2342
 			#if($headers->from) {
2048
-				foreach($headers['FROM'] as $val) {
2049
-					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) {
2343
+				foreach($headers['FROM'] as $val)
2344
+				{
2345
+					if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val))
2346
+					{
2050 2347
 						continue;
2051 2348
 					}
2052 2349
 					//error_log(__METHOD__.__LINE__.' '.$val);
2053
-					if(!$foundAddresses[$val]) {
2350
+					if(!$foundAddresses[$val])
2351
+					{
2054 2352
 						$this->sessionData['to'][] = $val;
2055 2353
 						$foundAddresses[$val] = true;
2056 2354
 					}
@@ -2059,9 +2357,12 @@  discard block
 block discarded – undo
2059 2357
 		}
2060 2358
 
2061 2359
 		// check for Re: in subject header
2062
-		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") {
2360
+		if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:")
2361
+		{
2063 2362
 			$this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']);
2064
-		} else {
2363
+		}
2364
+		else
2365
+		{
2065 2366
 			$this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']);
2066 2367
 		}
2067 2368
 
@@ -2075,7 +2376,8 @@  discard block
 block discarded – undo
2075 2376
 
2076 2377
 		$toAddressA = array();
2077 2378
 		$toAddress = '';
2078
-		foreach ($headers['TO'] as $mailheader) {
2379
+		foreach ($headers['TO'] as $mailheader)
2380
+		{
2079 2381
 			$toAddressA[] =  $mailheader;
2080 2382
 		}
2081 2383
 		if (count($toAddressA)>0)
@@ -2085,7 +2387,8 @@  discard block
 block discarded – undo
2085 2387
 		}
2086 2388
 		$ccAddressA = array();
2087 2389
 		$ccAddress = '';
2088
-		foreach ($headers['CC'] as $mailheader) {
2390
+		foreach ($headers['CC'] as $mailheader)
2391
+		{
2089 2392
 			$ccAddressA[] =  $mailheader;
2090 2393
 		}
2091 2394
 		if (count($ccAddressA)>0)
@@ -2093,25 +2396,35 @@  discard block
 block discarded – undo
2093 2396
 			$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
2094 2397
 			$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
2095 2398
 		}
2096
-		if($bodyParts['0']['mimeType'] == 'text/html') {
2399
+		if($bodyParts['0']['mimeType'] == 'text/html')
2400
+		{
2097 2401
 			$this->sessionData['body']	= /*"<br>".*//*"&nbsp;".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
2098 2402
 				@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
2099 2403
 				$toAddress.$ccAddress.
2100 2404
 				@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
2101 2405
 				'----------------------------------------------------------'."</div>";
2102 2406
 			$this->sessionData['mimeType'] 	= 'html';
2103
-			if (!empty($styles)) $this->sessionData['body'] .= $styles;
2407
+			if (!empty($styles))
2408
+			{
2409
+				$this->sessionData['body'] .= $styles;
2410
+			}
2104 2411
 			$this->sessionData['body']	.= '<blockquote type="cite">';
2105 2412
 
2106
-			for($i=0; $i<count($bodyParts); $i++) {
2107
-				if($i>0) {
2413
+			for($i=0; $i<count($bodyParts); $i++)
2414
+			{
2415
+				if($i>0)
2416
+				{
2108 2417
 					$this->sessionData['body'] .= '<hr>';
2109 2418
 				}
2110
-				if($bodyParts[$i]['mimeType'] == 'text/plain') {
2419
+				if($bodyParts[$i]['mimeType'] == 'text/plain')
2420
+				{
2111 2421
 					#$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>";
2112 2422
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
2113 2423
 				}
2114
-				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2424
+				if ($bodyParts[$i]['charSet']===false)
2425
+				{
2426
+					$bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
2427
+				}
2115 2428
 
2116 2429
 				$_htmlConfig = Mail::$htmLawed_config;
2117 2430
 				Mail::$htmLawed_config['comment'] = 2;
@@ -2123,7 +2436,9 @@  discard block
 block discarded – undo
2123 2436
 
2124 2437
 			$this->sessionData['body']	.= '</blockquote><br>';
2125 2438
 			$this->sessionData['body'] =  mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
2126
-		} else {
2439
+		}
2440
+		else
2441
+		{
2127 2442
 			//$this->sessionData['body']	= @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
2128 2443
 			// 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 2444
             $this->sessionData['body']  = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
@@ -2133,8 +2448,10 @@  discard block
 block discarded – undo
2133 2448
                 '-------------------------------------------------'."\r\n \r\n ";
2134 2449
 			$this->sessionData['mimeType']	= 'plain';
2135 2450
 
2136
-			for($i=0; $i<count($bodyParts); $i++) {
2137
-				if($i>0) {
2451
+			for($i=0; $i<count($bodyParts); $i++)
2452
+			{
2453
+				if($i>0)
2454
+				{
2138 2455
 					$this->sessionData['body'] .= "<hr>";
2139 2456
 				}
2140 2457
 
@@ -2144,9 +2461,11 @@  discard block
 block discarded – undo
2144 2461
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
2145 2462
 				$this->sessionData['body'] .= "\r\n";
2146 2463
 				// create body new, with good line breaks and indention
2147
-				foreach(explode("\n",$newBody) as $value) {
2464
+				foreach(explode("\n",$newBody) as $value)
2465
+				{
2148 2466
 					// the explode is removing the character
2149
-					if (trim($value) != '') {
2467
+					if (trim($value) != '')
2468
+					{
2150 2469
 						#if ($value != "\r") $value .= "\n";
2151 2470
 					}
2152 2471
 					$numberOfChars = strspn(trim($value), ">");
@@ -2154,9 +2473,12 @@  discard block
 block discarded – undo
2154 2473
 
2155 2474
 					$bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
2156 2475
 
2157
-					if($bodyAppend[0] == '>') {
2476
+					if($bodyAppend[0] == '>')
2477
+					{
2158 2478
 						$bodyAppend = '>'. $bodyAppend;
2159
-					} else {
2479
+					}
2480
+					else
2481
+					{
2160 2482
 						$bodyAppend = '> '. $bodyAppend;
2161 2483
 					}
2162 2484
 
@@ -2205,9 +2527,12 @@  discard block
 block discarded – undo
2205 2527
 
2206 2528
 	static function _getHostName()
2207 2529
 	{
2208
-		if (isset($_SERVER['SERVER_NAME'])) {
2530
+		if (isset($_SERVER['SERVER_NAME']))
2531
+		{
2209 2532
 			$result = $_SERVER['SERVER_NAME'];
2210
-		} else {
2533
+		}
2534
+		else
2535
+		{
2211 2536
 			$result = 'localhost.localdomain';
2212 2537
 		}
2213 2538
 		return $result;
@@ -2242,13 +2567,21 @@  discard block
 block discarded – undo
2242 2567
 
2243 2568
 		$_mailObject->addHeader('X-Priority', $_formData['priority']);
2244 2569
 		$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');
2245
-		if(!empty($_formData['in-reply-to'])) {
2246
-			if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2570
+		if(!empty($_formData['in-reply-to']))
2571
+		{
2572
+			if (stripos($_formData['in-reply-to'],'<')===false)
2573
+			{
2574
+				$_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>';
2575
+			}
2247 2576
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(In-Reply-To', $_formData['in-reply-to'].")");
2248 2577
 			$_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']);
2249 2578
 		}
2250
-		if(!empty($_formData['references'])) {
2251
-			if (stripos($_formData['references'],'<')===false) $_formData['references']='<'.trim($_formData['references']).'>';
2579
+		if(!empty($_formData['references']))
2580
+		{
2581
+			if (stripos($_formData['references'],'<')===false)
2582
+			{
2583
+				$_formData['references']='<'.trim($_formData['references']).'>';
2584
+			}
2252 2585
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(References', $_formData['references'].")");
2253 2586
 			$_mailObject->addHeader('References', $_formData['references']);
2254 2587
 		}
@@ -2259,16 +2592,19 @@  discard block
 block discarded – undo
2259 2592
 		//	$_mailObject->addHeader('Thread-Topic', $_formData['thread-topic']);
2260 2593
 		//}
2261 2594
 
2262
-		if(!empty($_formData['thread-index'])) {
2595
+		if(!empty($_formData['thread-index']))
2596
+		{
2263 2597
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(Tread-Index', $_formData['thread-index'].")");
2264 2598
 			$_mailObject->addHeader('Thread-Index', $_formData['thread-index']);
2265 2599
 		}
2266
-		if(!empty($_formData['list-id'])) {
2600
+		if(!empty($_formData['list-id']))
2601
+		{
2267 2602
 			//error_log(__METHOD__.__LINE__.'$_mailObject->addHeader(List-Id', $_formData['list-id'].")");
2268 2603
 			$_mailObject->addHeader('List-Id', $_formData['list-id']);
2269 2604
 		}
2270 2605
 		//error_log(__METHOD__.__LINE__.' notify to:'.$_identity['ident_email'].'->'.array2string($_formData));
2271
-		if($_formData['disposition']=='on') {
2606
+		if($_formData['disposition']=='on')
2607
+		{
2272 2608
 			$_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']);
2273 2609
 		}
2274 2610
 		//error_log(__METHOD__.__LINE__.' Organization:'.array2string($_identity));
@@ -2279,15 +2615,22 @@  discard block
 block discarded – undo
2279 2615
 		// Expand any mailing lists
2280 2616
 		foreach(array('to', 'cc', 'bcc', 'replyto')  as $field)
2281 2617
 		{
2282
-			if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2618
+			if ($field != 'replyto')
2619
+			{
2620
+				$_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
2621
+			}
2283 2622
 
2284
-			if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field);
2623
+			if ($_formData[$field])
2624
+			{
2625
+				$_mailObject->addAddress($_formData[$field], '', $field);
2626
+			}
2285 2627
 		}
2286 2628
 
2287 2629
 		$_mailObject->addHeader('Subject', $_formData['subject']);
2288 2630
 
2289 2631
 		// this should never happen since we come from the edit dialog
2290
-		if (Mail::detect_qp($_formData['body'])) {
2632
+		if (Mail::detect_qp($_formData['body']))
2633
+		{
2291 2634
 			//error_log("Error: bocompose::createMessage found QUOTED-PRINTABLE while Composing Message. Charset:$realCharset Message:".print_r($_formData['body'],true));
2292 2635
 			$_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']);
2293 2636
 			$_formData['body'] = quoted_printable_decode($_formData['body']);
@@ -2353,7 +2696,10 @@  discard block
 block discarded – undo
2353 2696
 				$_mailObject->setBody($this->convertHTMLToText($body, true, true));
2354 2697
 			}
2355 2698
 			// convert URL Images to inline images - if possible
2356
-			if (!$_autosaving) Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2699
+			if (!$_autosaving)
2700
+			{
2701
+				Mail::processURL2InlineImages($_mailObject, $body, $mail_bo);
2702
+			}
2357 2703
 			if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false)
2358 2704
 			{
2359 2705
 				$body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body);
@@ -2368,10 +2714,14 @@  discard block
 block discarded – undo
2368 2714
 		{
2369 2715
 			$body = $this->convertHTMLToText($_formData['body'],false);
2370 2716
 
2371
-			if ($attachment_links) $body .= $attachment_links;
2717
+			if ($attachment_links)
2718
+			{
2719
+				$body .= $attachment_links;
2720
+			}
2372 2721
 
2373 2722
 			#$_mailObject->Body = $_formData['body'];
2374
-			if(!empty($signature)) {
2723
+			if(!empty($signature))
2724
+			{
2375 2725
 				$body .= ($disableRuler ?"\r\n":"\r\n-- \r\n").
2376 2726
 					$this->convertHTMLToText($signature,true,true);
2377 2727
 			}
@@ -2384,11 +2734,13 @@  discard block
 block discarded – undo
2384 2734
 			$connection_opened = false;
2385 2735
 			//error_log(__METHOD__.__LINE__.array2string($_formData['attachments']));
2386 2736
 			$tnfattachments = null;
2387
-			foreach((array)$_formData['attachments'] as $attachment) {
2737
+			foreach((array)$_formData['attachments'] as $attachment)
2738
+			{
2388 2739
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
2389 2740
 				if(is_array($attachment))
2390 2741
 				{
2391
-					if (!empty($attachment['uid']) && !empty($attachment['folder'])) {
2742
+					if (!empty($attachment['uid']) && !empty($attachment['folder']))
2743
+					{
2392 2744
 						/* Example:
2393 2745
 						Array([0] => Array(
2394 2746
 						[uid] => 21178
@@ -2404,14 +2756,18 @@  discard block
 block discarded – undo
2404 2756
 							$connection_opened = true;
2405 2757
 						}
2406 2758
 						$mail_bo->reopen($attachment['folder']);
2407
-						switch(strtoupper($attachment['type'])) {
2759
+						switch(strtoupper($attachment['type']))
2760
+						{
2408 2761
 							case 'MESSAGE/RFC':
2409 2762
 							case 'MESSAGE/RFC822':
2410 2763
 								$rawBody='';
2411
-								if (isset($attachment['partID'])) {
2764
+								if (isset($attachment['partID']))
2765
+								{
2412 2766
 									$eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']);
2413 2767
 									$rawBody=$eml['attachment'];
2414
-								} else {
2768
+								}
2769
+								else
2770
+								{
2415 2771
 									$rawBody        = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']);
2416 2772
 								}
2417 2773
 								$_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822');
@@ -2420,7 +2776,10 @@  discard block
 block discarded – undo
2420 2776
 								$attachmentData	= $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false);
2421 2777
 								if ($attachmentData['type'] == 'APPLICATION/MS-TNEF')
2422 2778
 								{
2423
-									if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2779
+									if (!is_array($tnfattachments))
2780
+									{
2781
+										$tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']);
2782
+									}
2424 2783
 									foreach ($tnfattachments as $k)
2425 2784
 									{
2426 2785
 										if ($k['name'] == $attachment['name'])
@@ -2456,7 +2815,10 @@  discard block
 block discarded – undo
2456 2815
 					}
2457 2816
 				}
2458 2817
 			}
2459
-			if ($connection_opened) $mail_bo->closeConnection();
2818
+			if ($connection_opened)
2819
+			{
2820
+				$mail_bo->closeConnection();
2821
+			}
2460 2822
 		}
2461 2823
 	}
2462 2824
 
@@ -2475,13 +2837,20 @@  discard block
 block discarded – undo
2475 2837
 	 */
2476 2838
 	protected function getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null)
2477 2839
 	{
2478
-		if ($filemode == Vfs\Sharing::ATTACH) return '';
2840
+		if ($filemode == Vfs\Sharing::ATTACH)
2841
+		{
2842
+			return '';
2843
+		}
2479 2844
 
2480 2845
 		$links = array();
2481 2846
 		foreach($attachments as $attachment)
2482 2847
 		{
2483 2848
 			$path = $attachment['file'];
2484
-			if (empty($path)) continue;	// we only care about file attachments, not forwarded messages or parts
2849
+			if (empty($path))
2850
+			{
2851
+				continue;
2852
+			}
2853
+			// we only care about file attachments, not forwarded messages or parts
2485 2854
 			if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs')
2486 2855
 			{
2487 2856
 				$path = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($path);
@@ -2584,13 +2953,19 @@  discard block
 block discarded – undo
2584 2953
 								$success = false;
2585 2954
 								error_log(__METHOD__.__LINE__.$msg);
2586 2955
 							}
2587
-						} else {
2956
+						}
2957
+						else
2958
+						{
2588 2959
 							error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former');
2589 2960
 						}
2590
-					} else {
2961
+					}
2962
+					else
2963
+					{
2591 2964
 						error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)");
2592 2965
 					}
2593
-				} else {
2966
+				}
2967
+				else
2968
+				{
2594 2969
 					error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)");
2595 2970
 				}
2596 2971
 			}
@@ -2606,7 +2981,10 @@  discard block
 block discarded – undo
2606 2981
 			$success = false;
2607 2982
 		}
2608 2983
 
2609
-		if ($success) $msg = lang('Message saved successfully.');
2984
+		if ($success)
2985
+		{
2986
+			$msg = lang('Message saved successfully.');
2987
+		}
2610 2988
 
2611 2989
 		// Include new information to json respose, because we need them in client-side callback
2612 2990
 		$response->data(array(
@@ -2630,7 +3008,10 @@  discard block
 block discarded – undo
2630 3008
 		{
2631 3009
 			if(is_int($address))
2632 3010
 			{
2633
-				if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts();
3011
+				if (!isset($contacts_obs))
3012
+				{
3013
+					$contacts_obj = new Api\Contacts();
3014
+				}
2634 3015
 				// List was selected, expand to addresses
2635 3016
 				unset($_emailAddressList[$ak]);
2636 3017
 				$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));
@@ -2645,7 +3026,10 @@  discard block
 block discarded – undo
2645 3026
 		{
2646 3027
 			foreach ($addrFromList as $addr)
2647 3028
 			{
2648
-				if (!empty($addr)) $_emailAddressList[]=$addr;
3029
+				if (!empty($addr))
3030
+				{
3031
+					$_emailAddressList[]=$addr;
3032
+				}
2649 3033
 			}
2650 3034
 		}
2651 3035
 		return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList;
@@ -2699,7 +3083,10 @@  discard block
 block discarded – undo
2699 3083
 		// decide where to save the message (default to draft folder, if we find nothing else)
2700 3084
 		// if the current folder is in draft or template folder save it there
2701 3085
 		// if it is called from printview then save it with the draft folder
2702
-		if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder();
3086
+		if (empty($savingDestination))
3087
+		{
3088
+			$savingDestination = $mail_bo->getDraftFolder();
3089
+		}
2703 3090
 		if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox']))
2704 3091
 		{
2705 3092
 			$this->sessionData['messageFolder'] = $this->sessionData['mailbox'];
@@ -2710,13 +3097,17 @@  discard block
 block discarded – undo
2710 3097
 			$savingDestination = $this->sessionData['messageFolder'];
2711 3098
 			//error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination);
2712 3099
 		}
2713
-		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder();
3100
+		if (  !empty($_formData['printit']) && $_formData['printit'] == 0 )
3101
+		{
3102
+			$savingDestination = $mail_bo->getDraftFolder();
3103
+		}
2714 3104
 
2715 3105
 		// normaly Bcc is only added to recipients, but not as header visible to all recipients
2716 3106
 		$mail->forceBccHeader();
2717 3107
 
2718 3108
 		$mail_bo->openConnection();
2719
-		if ($mail_bo->folderExists($savingDestination,true)) {
3109
+		if ($mail_bo->folderExists($savingDestination,true))
3110
+		{
2720 3111
 			try
2721 3112
 			{
2722 3113
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
@@ -2727,7 +3118,9 @@  discard block
 block discarded – undo
2727 3118
 				return false;
2728 3119
 			}
2729 3120
 
2730
-		} else {
3121
+		}
3122
+		else
3123
+		{
2731 3124
 			error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server."));
2732 3125
 			return false;
2733 3126
 		}
@@ -2775,7 +3168,10 @@  discard block
 block discarded – undo
2775 3168
 					$fhA = mail_ui::splitRowID($rowid);
2776 3169
 					$this->sessionData['uid'][] = $fhA['msgUID'];
2777 3170
 					$this->sessionData['forwardedUID'][] = $fhA['msgUID'];
2778
-					if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder'];
3171
+					if (!empty($fhA['folder']))
3172
+					{
3173
+						$this->sessionData['sourceFolder'] = $fhA['folder'];
3174
+					}
2779 3175
 				}
2780 3176
 			}
2781 3177
 			if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id']))
@@ -2807,7 +3203,8 @@  discard block
 block discarded – undo
2807 3203
 			#error_log($this->sessionData['body']);
2808 3204
 		}
2809 3205
 		if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) &&
2810
-		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) {
3206
+		   empty($this->sessionData['bcc']) && empty($this->sessionData['folder']))
3207
+		{
2811 3208
 		   	$messageIsDraft = true;
2812 3209
 		}
2813 3210
 		try
@@ -2823,7 +3220,11 @@  discard block
 block discarded – undo
2823 3220
 		// create the messages
2824 3221
 		$this->createMessage($mail, $_formData, $identity);
2825 3222
 		// remember the identity
2826
-		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
3223
+		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3224
+		{
3225
+			$fromAddress = $mail->From;
3226
+		}
3227
+		//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':'');
2827 3228
 		#print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>";
2828 3229
 		#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
2829 3230
 		#exit;
@@ -2836,7 +3237,10 @@  discard block
 block discarded – undo
2836 3237
 		{
2837 3238
 			$fval=$f;
2838 3239
 			$icServerID = $_formData['serverID'];//folders always assumed with serverID
2839
-			if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2);
3240
+			if (stripos($f,'::')!==false)
3241
+			{
3242
+				list($icServerID,$fval) = explode('::',$f,2);
3243
+			}
2840 3244
 			if ($_formData['serverID']!=$_formData['mailaccount'])
2841 3245
 			{
2842 3246
 				if ($icServerID == $_formData['serverID'] )
@@ -2877,13 +3281,19 @@  discard block
 block discarded – undo
2877 3281
 			// sentFolder is account specific
2878 3282
 			$sentFolder = $this->mail_bo->getSentFolder();
2879 3283
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2880
-			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3284
+			if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true))
3285
+			{
3286
+				$sentFolder=false;
3287
+			}
2881 3288
 		}
2882 3289
 		else
2883 3290
 		{
2884 3291
 			$sentFolder = $mail_bo->getSentFolder();
2885 3292
 			//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2886
-			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
3293
+			if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true))
3294
+			{
3295
+				$sentFolder=false;
3296
+			}
2887 3297
 		}
2888 3298
 		//error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#');
2889 3299
 
@@ -2919,19 +3329,30 @@  discard block
 block discarded – undo
2919 3329
 		{
2920 3330
 			if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') ||
2921 3331
 				($this->mailPreferences['sendOptions'] != 'send_only' &&
2922
-				$sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences");
3332
+				$sentFolder != 'none'))
3333
+			{
3334
+				$this->errorInfo = lang("No Send Folder set in preferences");
3335
+			}
2923 3336
 		}
2924 3337
 		// draftFolder is on Server we start from
2925
-		if($messageIsDraft == true) {
3338
+		if($messageIsDraft == true)
3339
+		{
2926 3340
 			$draftFolder = $mail_bo->getDraftFolder();
2927
-			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) {
3341
+			if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true))
3342
+			{
2928 3343
 				$this->sessionData['folder'] = array($draftFolder);
2929 3344
 				$folderOnServerID[] = $draftFolder;
2930 3345
 				$folder[$draftFolder] = $draftFolder;
2931 3346
 			}
2932 3347
 		}
2933
-		if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID);
2934
-		if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount);
3348
+		if ($folderOnServerID)
3349
+		{
3350
+			$folderOnServerID = array_unique($folderOnServerID);
3351
+		}
3352
+		if ($folderOnMailAccount)
3353
+		{
3354
+			$folderOnMailAccount = array_unique($folderOnMailAccount);
3355
+		}
2935 3356
 		if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') &&
2936 3357
 			!( count($folder) > 0) &&
2937 3358
 			!($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on'))
@@ -2945,7 +3366,8 @@  discard block
 block discarded – undo
2945 3366
 		@set_time_limit(120);
2946 3367
 		//$mail->SMTPDebug = 10;
2947 3368
 		//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']));
2948
-		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) {
3369
+		if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0)
3370
+		{
2949 3371
 			try {
2950 3372
 				$mail->send();
2951 3373
 			}
@@ -2955,10 +3377,15 @@  discard block
 block discarded – undo
2955 3377
 				$this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:'');
2956 3378
 				return false;
2957 3379
 			}
2958
-		} else {
2959
-			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) {
3380
+		}
3381
+		else
3382
+		{
3383
+			if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder']))
3384
+			{
2960 3385
 				//error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true));
2961
-			} else {
3386
+			}
3387
+			else
3388
+			{
2962 3389
 				$this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided.");
2963 3390
 				//error_log(__METHOD__.__LINE__.$this->errorInfo);
2964 3391
 				return false;
@@ -2968,14 +3395,16 @@  discard block
 block discarded – undo
2968 3395
 		//error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder));
2969 3396
 		//error_log(__METHOD__.__LINE__.array2string($folder));
2970 3397
 		if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
2971
-            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3398
+            || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3399
+		{
2972 3400
 			$mail_bo = $this->mail_bo;
2973 3401
 			$mail_bo->openConnection();
2974 3402
 			//$mail_bo->reopen($this->sessionData['messageFolder']);
2975 3403
 			#error_log("(re)opened Connection");
2976 3404
 		}
2977 3405
 		// if copying mail to folder, or saving mail to infolog, we need to gather the needed information
2978
-		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
3406
+		if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')
3407
+		{
2979 3408
 			//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
2980 3409
 
2981 3410
 			// normaly Bcc is only added to recipients, but not as header visible to all recipients
@@ -2984,17 +3413,28 @@  discard block
 block discarded – undo
2984 3413
 		// copying mail to folder
2985 3414
 		if (count($folder) > 0)
2986 3415
 		{
2987
-			foreach($folderOnServerID as $folderName) {
2988
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3416
+			foreach($folderOnServerID as $folderName)
3417
+			{
3418
+				if (is_array($folderName))
3419
+				{
3420
+					$folderName = array_shift($folderName);
3421
+				}
3422
+				// should not happen at all
2989 3423
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
2990 3424
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
2991 3425
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
2992
-				if ($mail_bo->folderExists($folderName,true)) {
2993
-					if($mail_bo->isSentFolder($folderName)) {
3426
+				if ($mail_bo->folderExists($folderName,true))
3427
+				{
3428
+					if($mail_bo->isSentFolder($folderName))
3429
+					{
2994 3430
 						$flags = '\\Seen';
2995
-					} elseif($mail_bo->isDraftFolder($folderName)) {
3431
+					}
3432
+					elseif($mail_bo->isDraftFolder($folderName))
3433
+					{
2996 3434
 						$flags = '\\Draft';
2997
-					} else {
3435
+					}
3436
+					else
3437
+					{
2998 3438
 						$flags = '\\Seen';
2999 3439
 					}
3000 3440
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3017,18 +3457,32 @@  discard block
 block discarded – undo
3017 3457
 				}
3018 3458
 			}
3019 3459
 			// if we choose to send from a differing profile
3020
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['mailaccount']);
3021
-			foreach($folderOnMailAccount as $folderName) {
3022
-				if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
3460
+			if ($folderOnMailAccount)
3461
+			{
3462
+				$this->changeProfile($_formData['mailaccount']);
3463
+			}
3464
+			foreach($folderOnMailAccount as $folderName)
3465
+			{
3466
+				if (is_array($folderName))
3467
+				{
3468
+					$folderName = array_shift($folderName);
3469
+				}
3470
+				// should not happen at all
3023 3471
 				//error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName));
3024 3472
 				// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
3025 3473
 				// if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue;
3026
-				if ($this->mail_bo->folderExists($folderName,true)) {
3027
-					if($this->mail_bo->isSentFolder($folderName)) {
3474
+				if ($this->mail_bo->folderExists($folderName,true))
3475
+				{
3476
+					if($this->mail_bo->isSentFolder($folderName))
3477
+					{
3028 3478
 						$flags = '\\Seen';
3029
-					} elseif($this->mail_bo->isDraftFolder($folderName)) {
3479
+					}
3480
+					elseif($this->mail_bo->isDraftFolder($folderName))
3481
+					{
3030 3482
 						$flags = '\\Draft';
3031
-					} else {
3483
+					}
3484
+					else
3485
+					{
3032 3486
 						$flags = '\\Seen';
3033 3487
 					}
3034 3488
 					#$mailHeader=explode('From:',$mail->getMessageHeader());
@@ -3050,7 +3504,10 @@  discard block
 block discarded – undo
3050 3504
 					error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
3051 3505
 				}
3052 3506
 			}
3053
-			if ($folderOnMailAccount)  $this->changeProfile($_formData['serverID']);
3507
+			if ($folderOnMailAccount)
3508
+			{
3509
+				$this->changeProfile($_formData['serverID']);
3510
+			}
3054 3511
 
3055 3512
 			//$mail_bo->closeConnection();
3056 3513
 		}
@@ -3062,10 +3519,16 @@  discard block
 block discarded – undo
3062 3519
 			$dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']);
3063 3520
 			$lastDrafted['uid'] = $dhA['msgUID'];
3064 3521
 			$lastDrafted['folder'] = $dhA['folder'];
3065
-			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']);
3522
+			if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid']))
3523
+			{
3524
+				$lastDrafted['uid']=trim($lastDrafted['uid']);
3525
+			}
3066 3526
 			// manually drafted, do not delete
3067 3527
 			// will be handled later on IF mode was $_formData['mode']=='composefromdraft'
3068
-			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false;
3528
+			if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid']))
3529
+			{
3530
+				$lastDrafted=false;
3531
+			}
3069 3532
 			//error_log(__METHOD__.__LINE__.array2string($lastDrafted));
3070 3533
 		}
3071 3534
 		if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder']))
@@ -3091,7 +3554,8 @@  discard block
 block discarded – undo
3091 3554
 
3092 3555
 		//error_log("handling draft messages, flagging and such");
3093 3556
 		if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder']))
3094
-			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) {
3557
+			|| (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder'])))
3558
+		{
3095 3559
 			// mark message as answered
3096 3560
 			$mail_bo->openConnection();
3097 3561
 			$mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
@@ -3113,7 +3577,9 @@  discard block
 block discarded – undo
3113 3577
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
3114 3578
 					unset($e);
3115 3579
 				}
3116
-			} else {
3580
+			}
3581
+			else
3582
+			{
3117 3583
 				$mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder']));
3118 3584
 				//error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
3119 3585
 				if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded')
@@ -3132,7 +3598,10 @@  discard block
 block discarded – undo
3132 3598
 			}
3133 3599
 			//$mail_bo->closeConnection();
3134 3600
 		}
3135
-		if ($mail_bo) $mail_bo->closeConnection();
3601
+		if ($mail_bo)
3602
+		{
3603
+			$mail_bo->closeConnection();
3604
+		}
3136 3605
 		//error_log("performing Infolog Stuff");
3137 3606
 		//error_log(print_r($this->sessionData['to'],true));
3138 3607
 		//error_log(print_r($this->sessionData['cc'],true));
@@ -3145,9 +3614,18 @@  discard block
 block discarded – undo
3145 3614
 		{
3146 3615
 			$mailaddresses = array();
3147 3616
 		}
3148
-		if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc'];
3149
-		if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc'];
3150
-		if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3617
+		if (is_array($this->sessionData['cc']))
3618
+		{
3619
+			$mailaddresses['cc'] = $this->sessionData['cc'];
3620
+		}
3621
+		if (is_array($this->sessionData['bcc']))
3622
+		{
3623
+			$mailaddresses['bcc'] = $this->sessionData['bcc'];
3624
+		}
3625
+		if (!empty($mailaddresses))
3626
+		{
3627
+			$mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress);
3628
+		}
3151 3629
 
3152 3630
 		if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )
3153 3631
 		{
@@ -3186,8 +3664,11 @@  discard block
 block discarded – undo
3186 3664
 		// only clean up temp-files, if we dont need them for mail_integration::integrate
3187 3665
 		elseif(is_array($this->sessionData['attachments']))
3188 3666
 		{
3189
-			foreach($this->sessionData['attachments'] as $value) {
3190
-				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') {	// happens when forwarding mails
3667
+			foreach($this->sessionData['attachments'] as $value)
3668
+			{
3669
+				if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs')
3670
+				{
3671
+// happens when forwarding mails
3191 3672
 					unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']);
3192 3673
 				}
3193 3674
 			}
@@ -3224,7 +3705,10 @@  discard block
 block discarded – undo
3224 3705
 				$default_identity = null;
3225 3706
 				foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity)
3226 3707
 				{
3227
-					if (!isset($default_identity)) $default_identity = $identity['ident_id'];
3708
+					if (!isset($default_identity))
3709
+					{
3710
+						$default_identity = $identity['ident_id'];
3711
+					}
3228 3712
 					if (!empty($identity['ident_signature']))
3229 3713
 					{
3230 3714
 						$content['mailidentity'] = $identity['ident_id'];
@@ -3232,12 +3716,18 @@  discard block
 block discarded – undo
3232 3716
 					}
3233 3717
 				}
3234 3718
 			}
3235
-			if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity;
3719
+			if (empty($content['mailidentity']))
3720
+			{
3721
+				$content['mailidentity'] = $default_identity;
3722
+			}
3236 3723
 		}
3237 3724
 		if (!isset($content['mimeType']) || empty($content['mimeType']))
3238 3725
 		{
3239 3726
 			$content['mimeType'] = 'html';
3240
-			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType']  = 'plain';
3727
+			if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text")
3728
+			{
3729
+				$content['mimeType']  = 'plain';
3730
+			}
3241 3731
 		}
3242 3732
 		return $content;
3243 3733
 
@@ -3245,9 +3735,12 @@  discard block
 block discarded – undo
3245 3735
 
3246 3736
 	function stripSlashes($_string)
3247 3737
 	{
3248
-		if (get_magic_quotes_gpc()) {
3738
+		if (get_magic_quotes_gpc())
3739
+		{
3249 3740
 			return stripslashes($_string);
3250
-		} else {
3741
+		}
3742
+		else
3743
+		{
3251 3744
 			return $_string;
3252 3745
 		}
3253 3746
 	}
@@ -3260,15 +3753,25 @@  discard block
 block discarded – undo
3260 3753
 	 * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id
3261 3754
 	 * @return type
3262 3755
 	 */
3263
-	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) {
3756
+	function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
3757
+	{
3264 3758
 		//error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST));
3265 3759
 		static $useCacheIfPossible = null;
3266
-		if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
3760
+		if (is_null($useCacheIfPossible))
3761
+		{
3762
+			$useCacheIfPossible = true;
3763
+		}
3267 3764
 		$_searchString = trim($_REQUEST['query']);
3268 3765
 		$results = array();
3269 3766
 		$rememberServerID = $this->mail_bo->icServer->ImapServerId;
3270
-		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount'];
3271
-		if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3767
+		if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount']))
3768
+		{
3769
+			$_mailaccountToSearch = $_REQUEST['mailaccount'];
3770
+		}
3771
+		if (empty($_mailaccountToSearch))
3772
+		{
3773
+			$_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId;
3774
+		}
3272 3775
 		if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch)
3273 3776
 		{
3274 3777
 			$this->changeProfile($_mailaccountToSearch);
@@ -3279,7 +3782,8 @@  discard block
 block discarded – undo
3279 3782
 			$this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
3280 3783
 			//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
3281 3784
 			$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
3282
-			if (count($folderObjects)<=1) {
3785
+			if (count($folderObjects)<=1)
3786
+			{
3283 3787
 				$useCacheIfPossible = false;
3284 3788
 			}
3285 3789
 			else
@@ -3330,7 +3834,8 @@  discard block
 block discarded – undo
3330 3834
 		exit();
3331 3835
 	}
3332 3836
 
3333
-	public static function ajax_searchAddress($_searchStringLength=2) {
3837
+	public static function ajax_searchAddress($_searchStringLength=2)
3838
+	{
3334 3839
 		//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
3335 3840
 		$_searchString = trim($_REQUEST['query']);
3336 3841
 		$include_lists = (boolean)$_REQUEST['include_lists'];
@@ -3343,7 +3848,10 @@  discard block
 block discarded – undo
3343 3848
 			$search = explode(' ', $_searchString);
3344 3849
 			foreach ($search as $k => $v)
3345 3850
 			{
3346
-				if (mb_strlen($v) < 3) unset($search[$k]);
3851
+				if (mb_strlen($v) < 3)
3852
+				{
3853
+					unset($search[$k]);
3854
+				}
3347 3855
 			}
3348 3856
 			$search_str = implode(' +', $search);	// tell contacts/so_sql to AND search patterns
3349 3857
 			//error_log(__METHOD__.__LINE__.$_searchString);
@@ -3373,9 +3881,12 @@  discard block
 block discarded – undo
3373 3881
 			}
3374 3882
 		}
3375 3883
 		$results = array();
3376
-		if(is_array($contacts)) {
3377
-			foreach($contacts as $contact) {
3378
-				foreach(array($contact['email'],$contact['email_home']) as $email) {
3884
+		if(is_array($contacts))
3885
+		{
3886
+			foreach($contacts as $contact)
3887
+			{
3888
+				foreach(array($contact['email'],$contact['email_home']) as $email)
3889
+				{
3379 3890
 					// avoid wrong addresses, if an rfc822 encoded address is in addressbook
3380 3891
 					//$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email);
3381 3892
 					$rfcAddr = Mail::parseAddressList($email);
@@ -3389,10 +3900,22 @@  discard block
 block discarded – undo
3389 3900
 					if (method_exists($contacts_obj,'search'))
3390 3901
 					{
3391 3902
 						$contact['n_fn']='';
3392
-						if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix'];
3393
-						if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3394
-						if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3395
-						if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3903
+						if (!empty($contact['n_prefix']))
3904
+						{
3905
+							$contact['n_fn'] = $contact['n_prefix'];
3906
+						}
3907
+						if (!empty($contact['n_given']))
3908
+						{
3909
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given'];
3910
+						}
3911
+						if (!empty($contact['n_family']))
3912
+						{
3913
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family'];
3914
+						}
3915
+						if (!empty($contact['org_name']))
3916
+						{
3917
+							$contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')';
3918
+						}
3396 3919
 						$contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']);
3397 3920
 					}
3398 3921
 					else
@@ -3402,7 +3925,8 @@  discard block
 block discarded – undo
3402 3925
 					$args = explode('@', trim($email));
3403 3926
 					$args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']);
3404 3927
 					$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
3405
-					if(!empty($email) && in_array($completeMailString ,$results) === false) {
3928
+					if(!empty($email) && in_array($completeMailString ,$results) === false)
3929
+					{
3406 3930
 						$results[] = array(
3407 3931
 							'id'=>$completeMailString,
3408 3932
 							'label' => $completeMailString,
@@ -3421,7 +3945,10 @@  discard block
 block discarded – undo
3421 3945
 		foreach($groups as $g_id => $name)
3422 3946
 		{
3423 3947
 			$group = $GLOBALS['egw']->accounts->read($g_id);
3424
-			if(!$group['account_email']) continue;
3948
+			if(!$group['account_email'])
3949
+			{
3950
+				continue;
3951
+			}
3425 3952
 			$args = explode('@', trim($group['account_email']));
3426 3953
 			$args[] = $name;
3427 3954
 			$completeMailString = call_user_func_array('imap_rfc822_write_address', $args);
@@ -3438,7 +3965,8 @@  discard block
 block discarded – undo
3438 3965
 		{
3439 3966
 			$lists = array_filter(
3440 3967
 				$contacts_obj->get_lists(Acl::READ),
3441
-				function($element) use($_searchString) {
3968
+				function($element) use($_searchString)
3969
+				{
3442 3970
 					return (stripos($element, $_searchString) !== false);
3443 3971
 				}
3444 3972
 			);
@@ -3453,7 +3981,10 @@  discard block
 block discarded – undo
3453 3981
 					'title' => lang('Mailinglist'),
3454 3982
 					'data'	=> $key
3455 3983
 				);
3456
-				if($list_count++ > 5) break;
3984
+				if($list_count++ > 5)
3985
+				{
3986
+					break;
3987
+				}
3457 3988
 			}
3458 3989
 		}
3459 3990
 		 // switch regular JSON response handling off
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   +139 added lines, -139 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,7 +439,7 @@  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
 		}
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 		$allAliases = array($this->account->ident_email);
450 450
 		foreach ($accAllIdentities as &$arrVal)
451 451
 		{
452
-			if ($arrVal['type'] !='default')
452
+			if ($arrVal['type'] != 'default')
453 453
 			{
454
-				$allAliases[] =  $arrVal['address'];
454
+				$allAliases[] = $arrVal['address'];
455 455
 			}
456 456
 		}
457 457
 		asort($allAliases);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @param {array} $content
468 468
 	 * @param {string} $msg
469 469
 	 */
470
-	function editVacation($content=null, $msg='')
470
+	function editVacation($content = null, $msg = '')
471 471
 	{
472 472
 		//Instantiate an eTemplate object, representing the sieve.vacation template
473 473
 		$vtmpl = new Etemplate('mail.sieve.vacation');
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 			$account_id = $content['account_id'];
481 481
 			$preserv['acc_id'] = $content['acc_id'];
482 482
 		}
483
-		if(isset($account_id) && $this->mail_admin)
483
+		if (isset($account_id) && $this->mail_admin)
484 484
 		{
485
-			foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account)
485
+			foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account)
486 486
 			{
487 487
 				try {
488 488
 					// check if account is valid for multiple users, has admin credentials and sieve enabled
489 489
 					if (Mail\Account::is_multiple($account) &&
490
-						($icServer = $account->imapServer(true)) &&	// check on icServer object, so plugins can overwrite
490
+						($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite
491 491
 						$icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled)
492 492
 					{
493 493
 						$allAccounts[$account->acc_id] = $account->acc_name;
494 494
 						$accounts[$account->acc_id] = $account;
495 495
 					}
496 496
 				}
497
-				catch(Exception $e) {
497
+				catch (Exception $e) {
498 498
 					unset($e);
499 499
 					// ignore broken accounts
500 500
 				}
501 501
 			}
502 502
 
503
-			$profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id'];
503
+			$profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id'];
504 504
 			if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']]))
505 505
 			{
506 506
 				$profileID = $content['acc_id'] = (int)$_GET['acc_id'];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$this->is_admin_vac = true;
513 513
 			$preserv['account_id'] = $account_id;
514 514
 		}
515
-		elseif(!is_array($content) && isset($_GET['acc_id']))
515
+		elseif (!is_array($content) && isset($_GET['acc_id']))
516 516
 		{
517 517
 			$this->account = Mail\Account::read($_GET['acc_id']);
518 518
 			$preserv['acc_id'] = $this->account->acc_id;
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
 		if ($icServer->acc_sieve_enabled)
529 529
 		{
530 530
 			$vacRules = $this->getVacation($account_id);
531
-			if ($vacRules['vacation']===false)
531
+			if ($vacRules['vacation'] === false)
532 532
 			{
533 533
 				$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
534
-					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);
535
-				$content['hideIfSieveDisabled']='mail_DisplayNone';
534
+					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);
535
+				$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
536 536
 			}
537 537
 			else
538 538
 			{
@@ -540,24 +540,24 @@  discard block
 block discarded – undo
540 540
 				{
541 541
 					$ByDate = array('by_date' => lang('By date'));
542 542
 				}
543
-				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
543
+				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date'))))
544 544
 				{
545 545
 					$content = $vacation = $vacRules['vacation'];
546 546
 					if (!empty($profileID)) $content['acc_id'] = $profileID;
547
-					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
547
+					if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '')
548 548
 					{
549 549
 						$content['addresses'] = $vacRules['aliases'];
550 550
 					}
551 551
 					if (!empty($vacation['forwards']))
552 552
 					{
553
-						$content['forwards'] = explode(",",$vacation['forwards']);
553
+						$content['forwards'] = explode(",", $vacation['forwards']);
554 554
 					}
555 555
 					else
556 556
 					{
557 557
 						$content['forwards'] = '';
558 558
 					}
559
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
560
-					if (strlen(trim($content['text']))==0)
559
+					if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
560
+					if (strlen(trim($content['text'])) == 0)
561 561
 					{
562 562
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
563 563
 						Framework::refresh_opener($msg, 'mail');
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 					list($button) = @each($content['button']);
576 576
 					unset ($content['button']);
577 577
 
578
-					switch($button)
578
+					switch ($button)
579 579
 					{
580 580
 						case 'save':
581 581
 						case 'apply':
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 								$newVacation = $content;
594 594
 
595 595
 								if (empty($this->mailConfig['prefpreventforwarding']) ||
596
-									$this->mailConfig['prefpreventforwarding'] == 0 )
596
+									$this->mailConfig['prefpreventforwarding'] == 0)
597 597
 								{
598 598
 									$content['forwards'] = self::strip_rfc882_addresses($content['forwards']);
599 599
 									$newVacation['forwards'] = implode(',', $content['forwards']);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 									unset($newVacation ['forwards']);
604 604
 								}
605 605
 
606
-								if (!in_array($newVacation['status'],array('on','off','by_date')))
606
+								if (!in_array($newVacation['status'], array('on', 'off', 'by_date')))
607 607
 								{
608 608
 									$newVacation['status'] = 'off';
609 609
 								}
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 										self::strip_rfc882_addresses($content['addresses']);
616 616
 								}
617 617
 
618
-								if($this->checkRule($newVacation,$checkAddresses))
618
+								if ($this->checkRule($newVacation, $checkAddresses))
619 619
 								{
620 620
 									if (isset($account_id) && $this->mail_admin)
621 621
 									{
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 
629 629
 									if (!$resSetvac)
630 630
 									{
631
-										$msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error;
631
+										$msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error;
632 632
 										break;
633 633
 									}
634 634
 									// schedule job to switch message on/off, if request and not already in past
635 635
 									else
636 636
 									{
637
-										if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
637
+										if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() ||
638 638
 											$vacRules && $vacRules['vacation']['status'] == 'by_date')
639 639
 										{
640 640
 											self::setAsyncJob($newVacation);
@@ -642,29 +642,29 @@  discard block
 block discarded – undo
642 642
 										//Reset vacationNotice cache which is used in mail_ui get_rows
643 643
 										if (isset($account_id) && $this->mail_admin)
644 644
 										{
645
-											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
645
+											$account_lid = Api\Accounts::id2name($account_id, 'account_lid');
646 646
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
647 647
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
648
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
648
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations);
649 649
 										}
650 650
 										else
651 651
 										{
652 652
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
653 653
 											//error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations));
654
-											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
654
+											Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations);
655 655
 										}
656 656
 										$msg = lang('Vacation notice sucessfully updated.');
657 657
 									}
658 658
 								}
659 659
 								else
660 660
 								{
661
-									$msg .= implode("\n",$this->errorStack);
661
+									$msg .= implode("\n", $this->errorStack);
662 662
 								}
663 663
 								// refresh vacationNotice on index
664 664
 								$response = Api\Json\Response::get();
665
-								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
665
+								$response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId);
666 666
 								Framework::refresh_opener($msg, 'mail');
667
-								if ($button === 'apply' || $icServer->error !=="")
667
+								if ($button === 'apply' || $icServer->error !== "")
668 668
 								{
669 669
 									break;
670 670
 								}
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 						'on' => lang('Active'),
681 681
 						'off' => lang('Deactive'),
682 682
 					),
683
-					'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']),
683
+					'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']),
684 684
 				);
685 685
 				if (!isset($account_id))
686 686
 				{
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 		}
705 705
 		else
706 706
 		{
707
-			$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);
708
-			$content['hideIfSieveDisabled']='mail_DisplayNone';
707
+			$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);
708
+			$content['hideIfSieveDisabled'] = 'mail_DisplayNone';
709 709
 		}
710
-		$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);
710
+		$vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2);
711 711
 	}
712 712
 
713 713
 	/**
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	static function strip_rfc882_addresses($_addresses)
722 722
 	{
723 723
 		$addresses = array();
724
-		foreach(Mail::parseAddressList($_addresses) as $addr)
724
+		foreach (Mail::parseAddressList($_addresses) as $addr)
725 725
 		{
726 726
 			if ($addr->valid)
727 727
 			{
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes
739 739
 	 * @return  void
740 740
 	 */
741
-	static function setAsyncJob (array $_vacation, $_reschedule=false)
741
+	static function setAsyncJob(array $_vacation, $_reschedule = false)
742 742
 	{
743 743
 		if (!($_vacation['acc_id'] > 0))
744 744
 		{
@@ -750,19 +750,19 @@  discard block
 block discarded – undo
750 750
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
751 751
 		$async->delete($async_id);
752 752
 
753
-		$end_date = $_vacation['end_date'] + 24*3600;   // end-date is inclusive, so we have to add 24h
753
+		$end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h
754 754
 		if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
755 755
 		{
756 756
 			$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
757
-			$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
757
+			$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
758 758
 		}
759 759
 		if ($_reschedule)
760 760
 		{
761
-			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
761
+			$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5;
762 762
 			// only try to reschedule for 2 days max
763 763
 			if ($_vacation['rescheduled'] <= 2 * 24 * 60)
764 764
 			{
765
-				$time = time() + 60*($_vacation['rescheduled']);
765
+				$time = time() + 60 * ($_vacation['rescheduled']);
766 766
 				unset($_vacation['next']);
767 767
 				unset($_vacation['times']);
768 768
 				$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 		}
799 799
 		catch (Exception $e) {
800 800
 			error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
801
-			self::setAsyncJob($_vacation, true);	// reschedule
801
+			self::setAsyncJob($_vacation, true); // reschedule
802 802
 			$ret = false;
803 803
 		}
804 804
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	 *
814 814
 	 * @return boolean
815 815
 	 */
816
-	function checkRule($_vacation,$_checkAddresses=true)
816
+	function checkRule($_vacation, $_checkAddresses = true)
817 817
 	{
818 818
 		$this->errorStack = array();
819 819
 
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 			$this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!';
828 828
 		}
829 829
 
830
-		if(is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
830
+		if (is_array($_vacation['addresses']) && !empty($_vacation['addresses']))
831 831
 		{
832
-			$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
832
+			$regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
833 833
 			foreach ($_vacation['addresses'] as $addr)
834 834
 			{
835
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
835
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
836 836
 				{
837 837
 					$this->errorStack['addresses'] = lang('One address is not valid').'!';
838 838
 				}
@@ -848,23 +848,23 @@  discard block
 block discarded – undo
848 848
 			{
849 849
 				$this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!');
850 850
 			}
851
-			elseif($_vacation['start_date'] > $_vacation['end_date'])
851
+			elseif ($_vacation['start_date'] > $_vacation['end_date'])
852 852
 			{
853 853
 				$this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!');
854 854
 			}
855 855
 		}
856 856
 		if ($_vacation['forwards'])
857 857
 		{
858
-			foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr)
858
+			foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr)
859 859
 			{
860
-				if (!preg_match($regexp,$addr) && $_checkAddresses)
860
+				if (!preg_match($regexp, $addr) && $_checkAddresses)
861 861
 				{
862 862
 					$this->errorStack['forwards'] = lang('One address is not valid'.'!');
863 863
 				}
864 864
 			}
865 865
 		}
866 866
 		//error_log(__METHOD__. array2string($this->errorStack));
867
-		if(count($this->errorStack) == 0)
867
+		if (count($this->errorStack) == 0)
868 868
 		{
869 869
 			return true;
870 870
 		}
@@ -885,14 +885,14 @@  discard block
 block discarded – undo
885 885
 
886 886
 		foreach ($orders as $keys => $val)
887 887
 		{
888
-			$orders[$keys] = $val -1;
888
+			$orders[$keys] = $val - 1;
889 889
 		}
890 890
 
891 891
 		$this->getRules(null);
892 892
 
893 893
 		$newrules = $this->rules;
894 894
 
895
-		foreach($orders as $keys => $ruleID)
895
+		foreach ($orders as $keys => $ruleID)
896 896
 		{
897 897
 			$newrules[$keys] = $this->rules[$ruleID];
898 898
 		}
@@ -921,24 +921,24 @@  discard block
 block discarded – undo
921 921
 		switch ($action)
922 922
 		{
923 923
 			case 'delete':
924
-				if ($checked === count($this->rules)-1)
924
+				if ($checked === count($this->rules) - 1)
925 925
 				{
926
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!');
926
+					$msg = lang('rule with priority ').$checked.lang(' deleted!');
927 927
 				}
928 928
 				else
929 929
 				{
930 930
 
931
-					$msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked);
931
+					$msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked);
932 932
 				}
933 933
 				unset($this->rules[$checked]);
934 934
 				$this->rules = array_values($this->rules);
935 935
 				break;
936 936
 			case 'enable':
937
-				$msg = lang('rule with priority ') . $checked . lang(' enabled!');
937
+				$msg = lang('rule with priority ').$checked.lang(' enabled!');
938 938
 				$this->rules[$checked][status] = 'ENABLED';
939 939
 				break;
940 940
 			case 'disable':
941
-				$msg = lang('rule with priority ') . $checked . lang(' disabled!');
941
+				$msg = lang('rule with priority ').$checked.lang(' disabled!');
942 942
 				$this->rules[$checked][status] = 'DISABLED';
943 943
 				break;
944 944
 			case 'move':
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 
951 951
 		$response = Api\Json\Response::get();
952 952
 
953
-		if($result)
953
+		if ($result)
954 954
 		{
955 955
 			$response->error($result);
956 956
 			return;
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	function buildRule($rule)
970 970
 	{
971
-		$andor = ' '. lang('and') .' ';
971
+		$andor = ' '.lang('and').' ';
972 972
 		$started = 0;
973 973
 		if ($rule['anyof'])
974 974
 		{
975
-			$andor = ' '. lang('or') .' ';
975
+			$andor = ' '.lang('or').' ';
976 976
 		}
977 977
 		$complete = lang('IF').' ';
978 978
 		if ($rule['unconditional'])
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
 		}
982 982
 		if ($rule['from'])
983 983
 		{
984
-			$match = $this->setMatchType($rule['from'],$rule['regexp']);
985
-			$complete .= "'From:' " . $match . " '" . $rule['from'] . "'";
984
+			$match = $this->setMatchType($rule['from'], $rule['regexp']);
985
+			$complete .= "'From:' ".$match." '".$rule['from']."'";
986 986
 			$started = 1;
987 987
 		}
988 988
 		if ($rule['to'])
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				$complete .= $andor;
993 993
 			}
994
-			$match = $this->setMatchType($rule['to'],$rule['regexp']);
995
-			$complete .= "'To:' " . $match . " '" . $rule['to'] . "'";
994
+			$match = $this->setMatchType($rule['to'], $rule['regexp']);
995
+			$complete .= "'To:' ".$match." '".$rule['to']."'";
996 996
 			$started = 1;
997 997
 		}
998 998
 		if ($rule['subject'])
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 			{
1002 1002
 				$complete .= $andor;
1003 1003
 			}
1004
-			$match = $this->setMatchType($rule['subject'],$rule['regexp']);
1005
-			$complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'";
1004
+			$match = $this->setMatchType($rule['subject'], $rule['regexp']);
1005
+			$complete .= "'Subject:' ".$match." '".$rule['subject']."'";
1006 1006
 			$started = 1;
1007 1007
 		}
1008 1008
 		if ($rule['field'] && $rule['field_val'])
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 			{
1012 1012
 				$complete .= $andor;
1013 1013
 			}
1014
-			$match = $this->setMatchType($rule['field_val'],$rule['regexp']);
1015
-			$complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'";
1014
+			$match = $this->setMatchType($rule['field_val'], $rule['regexp']);
1015
+			$complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'";
1016 1016
 			$started = 1;
1017 1017
 		}
1018 1018
 		if ($rule['size'])
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 			{
1027 1027
 				$complete .= $andor;
1028 1028
 			}
1029
-			$complete .= "message " . $xthan . $rule['size'] . "KB'";
1029
+			$complete .= "message ".$xthan.$rule['size']."KB'";
1030 1030
 			$started = 1;
1031 1031
 		}
1032 1032
 		if (!empty($rule['field_bodytransform']))
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 			{
1036 1036
 				$newruletext .= ", ";
1037 1037
 			}
1038
-			$btransform	= " :raw ";
1038
+			$btransform = " :raw ";
1039 1039
 			$match = ' :contains';
1040 1040
 			if ($rule['bodytransform'])
1041 1041
 			{
@@ -1049,11 +1049,11 @@  discard block
 block discarded – undo
1049 1049
 			{
1050 1050
 				$match = ':regex';
1051 1051
 			}
1052
-			$complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\"";
1052
+			$complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\"";
1053 1053
 			$started = 1;
1054 1054
 
1055 1055
 		}
1056
-		if ($rule['ctype']!= '0' && !empty($rule['ctype']))
1056
+		if ($rule['ctype'] != '0' && !empty($rule['ctype']))
1057 1057
 		{
1058 1058
 			if ($started)
1059 1059
 			{
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 			{
1066 1066
 				$ctype_subtype = "/";
1067 1067
 			}
1068
-			$complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\"";
1068
+			$complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\"";
1069 1069
 			$started = 1;
1070 1070
 			//error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array));
1071 1071
 		}
@@ -1073,19 +1073,19 @@  discard block
 block discarded – undo
1073 1073
 		{
1074 1074
 			$complete .= ' '.lang('THEN').' ';
1075 1075
 		}
1076
-		if (preg_match("/folder/i",$rule['action']))
1076
+		if (preg_match("/folder/i", $rule['action']))
1077 1077
 		{
1078
-			$complete .= lang('file into')." '" . $rule['action_arg'] . "';";
1078
+			$complete .= lang('file into')." '".$rule['action_arg']."';";
1079 1079
 		}
1080
-		if (preg_match("/reject/i",$rule['action']))
1080
+		if (preg_match("/reject/i", $rule['action']))
1081 1081
 		{
1082
-			$complete .= lang('reject with')." '" . $rule['action_arg'] . "'.";
1082
+			$complete .= lang('reject with')." '".$rule['action_arg']."'.";
1083 1083
 		}
1084
-		if (preg_match("/address/i",$rule['action']))
1084
+		if (preg_match("/address/i", $rule['action']))
1085 1085
 		{
1086
-			$complete .= lang('forward to').' ' . $rule['action_arg'] .'.';
1086
+			$complete .= lang('forward to').' '.$rule['action_arg'].'.';
1087 1087
 		}
1088
-		if (preg_match("/discard/i",$rule['action']))
1088
+		if (preg_match("/discard/i", $rule['action']))
1089 1089
 		{
1090 1090
 			$complete .= lang('discard').'.';
1091 1091
 		}
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 * @param {string} $regex regular expresion as pattern to be matched
1108 1108
 	 * @return {string} return the type
1109 1109
 	 */
1110
-	function setMatchType (&$matchstr, $regex = false)
1110
+	function setMatchType(&$matchstr, $regex = false)
1111 1111
 	{
1112 1112
 		$match = lang('contains');
1113 1113
 		if (preg_match("/^\s*!/", $matchstr))
@@ -1132,11 +1132,11 @@  discard block
 block discarded – undo
1132 1132
 		}
1133 1133
 		if ($regex && preg_match("/^\s*\\\\!/", $matchstr))
1134 1134
 		{
1135
-			$matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr);
1135
+			$matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr);
1136 1136
 		}
1137 1137
 		else
1138 1138
 		{
1139
-			$matchstr = preg_replace("/^\s*!/","",$matchstr);
1139
+			$matchstr = preg_replace("/^\s*!/", "", $matchstr);
1140 1140
 		}
1141 1141
 		return $match;
1142 1142
 	}
@@ -1146,10 +1146,10 @@  discard block
 block discarded – undo
1146 1146
 	 */
1147 1147
 	function saveSessionData()
1148 1148
 	{
1149
-		$sessionData['sieve_rules']		= $this->rules;
1149
+		$sessionData['sieve_rules'] = $this->rules;
1150 1150
 		$sessionData['sieve_rulesByID'] = $this->rulesByID;
1151
-		$sessionData['sieve_scriptToEdit']	= $this->scriptToEdit;
1152
-		$GLOBALS['egw']->session->appsession('sieve_session_data','',$sessionData);
1151
+		$sessionData['sieve_scriptToEdit'] = $this->scriptToEdit;
1152
+		$GLOBALS['egw']->session->appsession('sieve_session_data', '', $sessionData);
1153 1153
 	}
1154 1154
 
1155 1155
 	/**
@@ -1174,15 +1174,15 @@  discard block
 block discarded – undo
1174 1174
 	{
1175 1175
 		try {
1176 1176
 			$this->account->imapServer()->retrieveRules();
1177
-			$this->rules	= $this->account->imapServer()->getRules();
1177
+			$this->rules = $this->account->imapServer()->getRules();
1178 1178
 			$this->rulesByID = $this->rules[$ruleID];
1179
-			$this->vacation	= $this->account->imapServer()->getVacation();
1179
+			$this->vacation = $this->account->imapServer()->getVacation();
1180 1180
 		}
1181
-		catch(Exception $e) {
1181
+		catch (Exception $e) {
1182 1182
 			error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details);
1183
-			$this->rules	= array();
1183
+			$this->rules = array();
1184 1184
 			$this->rulesByID = array();
1185
-			$this->vacation	= array();
1185
+			$this->vacation = array();
1186 1186
 			return false;
1187 1187
 		}
1188 1188
 		return true;
@@ -1194,9 +1194,9 @@  discard block
 block discarded – undo
1194 1194
 	function restoreSessionData()
1195 1195
 	{
1196 1196
 		$sessionData = $GLOBALS['egw']->session->appsession('sieve_session_data');
1197
-		$this->rules		= $sessionData['sieve_rules'];
1197
+		$this->rules = $sessionData['sieve_rules'];
1198 1198
 		$this->rulesByID = $sessionData['sieve_rulesByID'];
1199
-		$this->scriptToEdit	= $sessionData['sieve_scriptToEdit'];
1199
+		$this->scriptToEdit = $sessionData['sieve_scriptToEdit'];
1200 1200
 	}
1201 1201
 
1202 1202
 	/**
@@ -1210,14 +1210,14 @@  discard block
 block discarded – undo
1210 1210
 		$rows = array();
1211 1211
 		$this->getRules(null);
1212 1212
 
1213
-		if (is_array($this->rules) && !empty($this->rules) )
1213
+		if (is_array($this->rules) && !empty($this->rules))
1214 1214
 		{
1215 1215
 			$rows = $this->rules;
1216 1216
 
1217
-			foreach ($rows as &$row )
1217
+			foreach ($rows as &$row)
1218 1218
 			{
1219 1219
 				$row['rules'] = $this->buildRule($row);
1220
-				$row['ruleID'] =(string)(($row['priority'] -1) / 2 );
1220
+				$row['ruleID'] = (string)(($row['priority'] - 1) / 2);
1221 1221
 				if ($row ['status'] === 'DISABLED')
1222 1222
 				{
1223 1223
 					$row['class'] = 'mail_sieve_DISABLED';
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 			return false;
1231 1231
 		}
1232 1232
 		// Shift one down, because in grid the first row is reserved for header
1233
-		array_unshift($rows,array(''=> ''));
1233
+		array_unshift($rows, array(''=> ''));
1234 1234
 		return $rows;
1235 1235
 	}
1236 1236
 
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 	 */
1242 1242
 	private function get_actions()
1243 1243
 	{
1244
-		$actions =array(
1244
+		$actions = array(
1245 1245
 
1246 1246
 			'edit' => array(
1247 1247
 				'caption' => 'Edit',
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	 * @param int $_mailaccountToSearch
1281 1281
 	 * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id
1282 1282
 	 */
1283
-	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1283
+	function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false)
1284 1284
 	{
1285 1285
 		$mailCompose = new mail_compose();
1286 1286
 		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
 		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
449 462
 		$allAliases = array($this->account->ident_email);
@@ -473,7 +486,10 @@  discard block
 block discarded – undo
473 486
 		$vtmpl = new Etemplate('mail.sieve.vacation');
474 487
 		$vacation = array();
475 488
 
476
-		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
489
+		if (isset($_GET['account_id']))
490
+		{
491
+			$account_id = $preserv['account_id'] = $_GET['account_id'];
492
+		}
477 493
 
478 494
 		if (isset($content['account_id']))
479 495
 		{
@@ -543,7 +559,10 @@  discard block
 block discarded – undo
543 559
 				if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date'))))
544 560
 				{
545 561
 					$content = $vacation = $vacRules['vacation'];
546
-					if (!empty($profileID)) $content['acc_id'] = $profileID;
562
+					if (!empty($profileID))
563
+					{
564
+						$content['acc_id'] = $profileID;
565
+					}
547 566
 					if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '')
548 567
 					{
549 568
 						$content['addresses'] = $vacRules['aliases'];
@@ -556,7 +575,10 @@  discard block
 block discarded – undo
556 575
 					{
557 576
 						$content['forwards'] = '';
558 577
 					}
559
-					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text'];
578
+					if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text'])
579
+					{
580
+						$content['text'] = $this->mailConfig['default_vacation_text'];
581
+					}
560 582
 					if (strlen(trim($content['text']))==0)
561 583
 					{
562 584
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
@@ -746,7 +768,10 @@  discard block
 block discarded – undo
746 768
 		}
747 769
 		// setting up an async job to enable/disable the vacation message
748 770
 		$async = new Api\Asyncservice();
749
-		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
771
+		if (empty($_vacation['account_id']))
772
+		{
773
+			$_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
774
+		}
750 775
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
751 776
 		$async->delete($async_id);
752 777
 
@@ -1283,7 +1308,10 @@  discard block
 block discarded – undo
1283 1308
 	function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false)
1284 1309
 	{
1285 1310
 		$mailCompose = new mail_compose();
1286
-		if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId'];
1311
+		if ($_REQUEST['noPrefixId'])
1312
+		{
1313
+			$_noPrefixId = $_REQUEST['noPrefixId'];
1314
+		}
1287 1315
 		$mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId);
1288 1316
 	}
1289 1317
 }
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.
Spacing   +42 added lines, -42 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
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
172 172
 
173 173
 		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			{
179 179
 				$this->ui->changeProfile($_profileID);
180 180
 			} catch (Exception $ex) {
181
-				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
181
+				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
182 182
 			}
183 183
 		}
184 184
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
197 197
 			{
198 198
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
199
-				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
199
+				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly);
200 200
 
201 201
 				$childrenNode = array();
202 202
 				foreach ($folders as &$node)
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 					$nodeData = Mail::pathToFolderData($nodeId, $node['delimiter']);
206 206
 					$childrenNode[] = array(
207 207
 						Tree::ID=> $nodeId,
208
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node),
208
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($node),
209 209
 						Tree::CHILDREN =>array(),
210 210
 						Tree::LABEL => $nodeData['text'],
211 211
 						Tree::TOOLTIP => $nodeData['tooltip'],
212 212
 						Tree::IMAGE_LEAF => self::$leafImages['folderLeaf'],
213 213
 						Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'],
214 214
 						Tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClosed'],
215
-						Tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false,
215
+						Tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false,
216 216
 						'parent' => $_parent
217 217
 					);
218 218
 				}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 				}
233 233
 
234 234
 				//List of folders
235
-				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, false);
235
+				$foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, false);
236 236
 				foreach ($foldersList as &$folder)
237 237
 				{
238 238
 					$path = $parent = $parts = explode($folder['delimiter'], $folder['MAILBOX']);
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 
243 243
 					$data = array(
244 244
 						Tree::ID=>$_profileID.self::DELIMITER.$folder['MAILBOX'],
245
-						Tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder),
245
+						Tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($folder),
246 246
 						Tree::CHILDREN =>array(),
247 247
 						Tree::LABEL =>lang($folder['MAILBOX']),
248
-						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0,
248
+						Tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0,
249 249
 						Tree::TOOLTIP => lang($folder['MAILBOX']),
250
-						Tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false,
250
+						Tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false,
251 251
 						Tree::NOCHECKBOX => 0,
252
-						'parent' => $parent?$_profileID.self::DELIMITER.implode($folder['delimiter'], $parent):$_profileID,
252
+						'parent' => $parent ? $_profileID.self::DELIMITER.implode($folder['delimiter'], $parent) : $_profileID,
253 253
 						'path' => $path,
254 254
 						'folderarray' => $folder
255 255
 					);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		catch (Exception $ex) // Catch exceptions
288 288
 		{
289 289
 			//mail_ui::callWizard($ex->getMessage(), false, 'error');
290
-			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
290
+			return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), '');
291 291
 		}
292 292
 
293 293
 		return $tree;
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
 	 *					as clearance for access may be limited to a single branch-node of a tree
305 305
 	 * @return void
306 306
 	 */
307
-	static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array())
307
+	static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array())
308 308
 	{
309 309
 		//error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
310 310
 		$components = $data['path'];
311
-		array_pop($components);	// remove own name
311
+		array_pop($components); // remove own name
312 312
 
313 313
 		$insert = &$out;
314 314
 		$parents = array();
315
-		foreach($components as $component)
315
+		foreach ($components as $component)
316 316
 		{
317
-			if (count($parents)>1)
317
+			if (count($parents) > 1)
318 318
 			{
319
-				$helper = array_slice($parents,1,null,true);
319
+				$helper = array_slice($parents, 1, null, true);
320 320
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
321 321
 				if ($parent) $parent .= $del;
322 322
 			}
@@ -339,21 +339,21 @@  discard block
 block discarded – undo
339 339
 				{
340 340
 					// if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent
341 341
 					// we want to create the node in question as we meet the above considerations
342
-					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
342
+					if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::DELIMITER.$nsp['prefix']) === 0)
343 343
 					{
344 344
 						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
345
-						$break=false;
345
+						$break = false;
346 346
 					}
347 347
 				}
348 348
 				if ($break) break;
349 349
 			}
350 350
 			if ($insert['item'])
351 351
 			{
352
-				foreach($insert['item'] as &$item)
352
+				foreach ($insert['item'] as &$item)
353 353
 				{
354 354
 					if ($item['id'] == $parent.$component)
355 355
 					{
356
-						$insert =& $item;
356
+						$insert = & $item;
357 357
 						break;
358 358
 					}
359 359
 				}
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 						'im2' => self::$leafImages["folderNoSelectClosed"],
372 372
 						'tooltip' => lang('no access')
373 373
 					);
374
-					$insert['item'][] =& $item;
375
-					$insert =& $item;
374
+					$insert['item'][] = & $item;
375
+					$insert = & $item;
376 376
 				}
377 377
 				else
378 378
 				{
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 					$data[Tree::IMAGE_FOLDER_OPEN] =
406 406
 					$data [Tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png";
407 407
 			}
408
-			elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false)
408
+			elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false)
409 409
 			{
410 410
 				$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
411 411
 				$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@@ -447,20 +447,20 @@  discard block
 block discarded – undo
447 447
 	 *
448 448
 	 * @return array an array of baseNodes of accounts
449 449
 	 */
450
-	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 )
450
+	static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0)
451 451
 	{
452 452
 		$roots = array(Tree::ID => 0, Tree::CHILDREN => array());
453 453
 
454
-		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
454
+		foreach (Mail\Account::search(true, false) as $acc_id => $accObj)
455 455
 		{
456
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
457
-			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
456
+			if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue;
457
+			$identity = Mail\Account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']);
458 458
 			// Open top level folders for active account
459
-			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
459
+			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0;
460 460
 
461 461
 			$baseNode = array(
462 462
 							Tree::ID=> (string)$acc_id,
463
-							Tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity),
463
+							Tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity),
464 464
 							Tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity),
465 465
 							Tree::IMAGE_LEAF => self::$leafImages['folderAccount'],
466 466
 							Tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'],
@@ -469,16 +469,16 @@  discard block
 block discarded – undo
469 469
 							Tree::CHILDREN => array(), // dynamic loading on unfold
470 470
 							Tree::AUTOLOAD_CHILDREN => true,
471 471
 							'parent' => '',
472
-							Tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount,
472
+							Tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount,
473 473
 							// mark on account if Sieve is enabled
474 474
 							'data' => array(
475 475
 										'sieve' => $accObj->imapServer()->acc_sieve_enabled,
476
-										'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
477
-										'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
476
+										'spamfolder'=> $accObj->imapServer()->acc_folder_junk && (strtolower($accObj->imapServer()->acc_folder_junk) != 'none') ? true : false,
477
+										'archivefolder'=> $accObj->imapServer()->acc_folder_archive && (strtolower($accObj->imapServer()->acc_folder_archive) != 'none') ? true : false
478 478
 									),
479 479
 							Tree::NOCHECKBOX  => $_noCheckbox
480 480
 			);
481
-			self::setOutStructure($baseNode, $roots,self::DELIMITER);
481
+			self::setOutStructure($baseNode, $roots, self::DELIMITER);
482 482
 		}
483 483
 		return $roots;
484 484
 	}
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 	 * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go
498 498
 	 * @return type an array of tree
499 499
 	 */
500
-	function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false)
500
+	function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false)
501 501
 	{
502 502
 		$tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo);
503
-		$branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo);
503
+		$branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo);
504 504
 		foreach ($tree[Tree::CHILDREN] as &$account)
505 505
 		{
506 506
 			if ($account[Tree::ID] == $_profileID)
Please login to merge, or discard this patch.
Braces   +50 added lines, -13 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
 
@@ -170,14 +176,18 @@  discard block
 block discarded – undo
170 176
 		$tree = array(Tree::ID=> $_parent?$_parent:0,Tree::CHILDREN => array());
171 177
 		$hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter();
172 178
 
173
-		if ($_parent) list($_profileID) = explode(self::DELIMITER, $_parent);
179
+		if ($_parent)
180
+		{
181
+			list($_profileID) = explode(self::DELIMITER, $_parent);
182
+		}
174 183
 
175 184
 		if (is_numeric($_profileID) && $_profileID != $this->ui->mail_bo->profileID)
176 185
 		{
177 186
 			try
178 187
 			{
179 188
 				$this->ui->changeProfile($_profileID);
180
-			} catch (Exception $ex) {
189
+			}
190
+			catch (Exception $ex) {
181 191
 				return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), '');
182 192
 			}
183 193
 		}
@@ -193,9 +203,12 @@  discard block
 block discarded – undo
193 203
 				'Junk'      => $this->ui->mail_bo->getJunkFolder(false),
194 204
 				'Outbox'    => $this->ui->mail_bo->getOutboxFolder(false),
195 205
 			);
196
-			if ($_parent && !self::isAccountNode($_parent)) // Single node loader
206
+			if ($_parent && !self::isAccountNode($_parent))
207
+			{
208
+				// Single node loader
197 209
 			{
198 210
 				$nodeInfo = Mail::pathToFolderData($_parent, $hDelimiter);
211
+			}
199 212
 				$folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly);
200 213
 
201 214
 				$childrenNode = array();
@@ -220,15 +233,21 @@  discard block
 block discarded – undo
220 233
 			}
221 234
 			else //Top Level Nodes loader
222 235
 			{
223
-				if (self::isAccountNode($_parent)) // An account called for open
236
+				if (self::isAccountNode($_parent))
237
+				{
238
+					// An account called for open
224 239
 				{
225 240
 					$_openTopLevel = 1;
241
+				}
226 242
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
227 243
 				}
228 244
 				else // Initial accounts|root nodes
229 245
 				{
230 246
 					$tree = self::getAccountsRootNode($_profileID, $_noCheckboxNS, $_openTopLevel);
231
-					if (!$_profileID && !$_openTopLevel) return $tree;
247
+					if (!$_profileID && !$_openTopLevel)
248
+					{
249
+						return $tree;
250
+					}
232 251
 				}
233 252
 
234 253
 				//List of folders
@@ -318,19 +337,28 @@  discard block
 block discarded – undo
318 337
 			{
319 338
 				$helper = array_slice($parents,1,null,true);
320 339
 				$parent = $parents[0].self::DELIMITER.implode($del, $helper);
321
-				if ($parent) $parent .= $del;
340
+				if ($parent)
341
+				{
342
+					$parent .= $del;
343
+				}
322 344
 			}
323 345
 			else
324 346
 			{
325 347
 				$parent = implode(self::DELIMITER, $parents);
326
-				if ($parent) $parent .= self::DELIMITER;
348
+				if ($parent)
349
+				{
350
+					$parent .= self::DELIMITER;
351
+				}
327 352
 			}
328 353
 
329 354
 			if (!is_array($insert) || !isset($insert['item']))
330 355
 			{
331 356
 				// throwing an exeption here seems to be unrecoverable,
332 357
 				// even if the cause is a something that can be handeled by the mailserver
333
-				if (mail_bo::$debug) error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
358
+				if (mail_bo::$debug)
359
+				{
360
+					error_log(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' of '$component' not found!");
361
+				}
334 362
 				// should we hit the break? if in personal: sure, something is wrong with the folderstructure
335 363
 				// if in shared or others we may proceed as access to folders may very well be limited to
336 364
 				// a single folder within the tree
@@ -341,11 +369,17 @@  discard block
 block discarded – undo
341 369
 					// we want to create the node in question as we meet the above considerations
342 370
 					if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::DELIMITER.$nsp['prefix'])===0)
343 371
 					{
344
-						if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
372
+						if (mail_bo::$debug)
373
+						{
374
+							error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::DELIMITER.$nsp['prefix']);
375
+						}
345 376
 						$break=false;
346 377
 					}
347 378
 				}
348
-				if ($break) break;
379
+				if ($break)
380
+				{
381
+					break;
382
+				}
349 383
 			}
350 384
 			if ($insert['item'])
351 385
 			{
@@ -453,7 +487,10 @@  discard block
 block discarded – undo
453 487
 
454 488
 		foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
455 489
 		{
456
-			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
490
+			if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID)
491
+			{
492
+				continue;
493
+			}
457 494
 			$identity = Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']);
458 495
 			// Open top level folders for active account
459 496
 			$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;
Please login to merge, or discard this patch.