Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
api/src/Link/Storage.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -302,7 +302,10 @@
 block discarded – undo
302 302
 			}
303 303
 			if ($owner)
304 304
 			{
305
-				if ($app) $where = array($where);
305
+				if ($app)
306
+				{
307
+					$where = array($where);
308
+				}
306 309
 				$where['link_owner'] = $owner;
307 310
 			}
308 311
 		}
Please login to merge, or discard this patch.
api/src/loader/common.php 1 patch
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 {
48 48
 	static $func_overload = null;
49 49
 
50
-	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
50
+	if (is_null($func_overload))
51
+	{
52
+		$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
53
+	}
51 54
 
52 55
 	return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
53 56
 }
@@ -64,7 +67,10 @@  discard block
 block discarded – undo
64 67
 {
65 68
 	static $func_overload = null;
66 69
 
67
-	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
70
+	if (is_null($func_overload))
71
+	{
72
+		$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
73
+	}
68 74
 
69 75
 	if (is_null($len))
70 76
 	{
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 			{
131 137
 				$personal = str_replace('\\', '', substr($personal, 1, -1));
132 138
 			}
133
-			if (empty($host)) $host = $default_host;
139
+			if (empty($host))
140
+			{
141
+				$host = $default_host;
142
+			}
134 143
 
135 144
 			$addresses[] = (object)array_diff(array(
136 145
 				'mailbox'  => $mailbox,
@@ -153,13 +162,19 @@  discard block
 block discarded – undo
153 162
 	 */
154 163
 	function imap_rfc822_write_address($mailbox, $host, $personal)
155 164
 	{
156
-		if (is_array($personal))  $personal = implode(' ', $personal);
165
+		if (is_array($personal))
166
+		{
167
+			$personal = implode(' ', $personal);
168
+		}
157 169
 
158 170
 		//if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal))	// that's how I read the rfc(2)822
159
-		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))	// but quoting is never wrong, so quote more then necessary
171
+		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))
172
+		{
173
+			// but quoting is never wrong, so quote more then necessary
160 174
 		{
161 175
 			$personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"';
162 176
 		}
177
+		}
163 178
 		return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : '');
164 179
 	}
165 180
 }
@@ -366,7 +381,9 @@  discard block
 block discarded – undo
366 381
 	return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']);
367 382
 }
368 383
 
369
-if (!function_exists('lang') || defined('NO_LANG'))	// setup declares an own version
384
+if (!function_exists('lang') || defined('NO_LANG'))
385
+{
386
+	// setup declares an own version
370 387
 {
371 388
 	/**
372 389
 	 * function to handle multilanguage support
@@ -380,6 +397,7 @@  discard block
 block discarded – undo
380 397
 		if(!is_array($vars))
381 398
 		{
382 399
 			$vars = func_get_args();
400
+}
383 401
 			array_shift($vars);	// remove $key
384 402
 		}
385 403
 		return Api\Translation::translate($key,$vars);
Please login to merge, or discard this patch.
api/src/loader/exception.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -188,7 +188,9 @@
 block discarded – undo
188 188
 /**
189 189
  * Used internally to trace warnings
190 190
  */
191
-class egw_exception_warning extends Exception {}
191
+class egw_exception_warning extends Exception
192
+{
193
+}
192 194
 
193 195
 // install our error-handler only for catchable fatal errors and warnings
194 196
 // following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING
Please login to merge, or discard this patch.
api/src/loader/security.php 1 patch
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 {
25 25
 	static $preg=null;
26 26
 	//old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i';
27
-	if (!isset($preg)) $preg =
27
+	if (!isset($preg))
28
+	{
29
+		$preg =
28 30
 		// forbidden tags like iframe or script
29 31
 		'/(<(\s*\/)?\s*(iframe|script|object|embed|math|meta)[^a-z0-9]|'.
30 32
 		// on* attributes
@@ -33,6 +35,7 @@  discard block
 block discarded – undo
33 35
 		'<[^>]+(href|src|dynsrc|lowsrc|background|style|poster|action)\s*=\s*("|\')?[^"\']*javascript|'.
34 36
 		// benavior:url and expression in style attribute
35 37
 		'<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i';
38
+	}
36 39
 	if (is_array($var))
37 40
 	{
38 41
 		foreach($var as $key => $val)
@@ -41,7 +44,9 @@  discard block
 block discarded – undo
41 44
 			{
42 45
 				_check_script_tag($var[$key],$name.'['.$key.']');
43 46
 			}
44
-			elseif(strpos($val, '<') !== false)	// speedup: ignore everything without <
47
+			elseif(strpos($val, '<') !== false)
48
+			{
49
+				// speedup: ignore everything without <
45 50
 			{
46 51
 				if (preg_match($preg,$val))
47 52
 				{
@@ -49,6 +54,7 @@  discard block
 block discarded – undo
49 54
 					if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true)))
50 55
 					{
51 56
 						_check_script_tag($json_data, $name.'[json_data]');
57
+			}
52 58
 						$_REQUEST[$key] = $var[$key] = json_encode($json_data);
53 59
 						continue;
54 60
 					}
Please login to merge, or discard this patch.
api/src/Storage/Tracking.php 1 patch
Braces   +157 added lines, -39 removed lines patch added patch discarded remove patch
@@ -239,7 +239,10 @@  discard block
 block discarded – undo
239 239
 			$header_done = false;
240 240
 			foreach($cfs as $name => $field)
241 241
 			{
242
-				if (in_array($field['type'], Customfields::$non_printable_fields)) continue;
242
+				if (in_array($field['type'], Customfields::$non_printable_fields))
243
+				{
244
+					continue;
245
+				}
243 246
 
244 247
 				if (!$header_done)
245 248
 				{
@@ -337,8 +340,14 @@  discard block
 block discarded – undo
337 340
 		{
338 341
 			//error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (new):'.array2string($data[$name]));
339 342
 			//error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (old):'.array2string($old[$name]));
340
-			if (is_array($data[$name]) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id'];
341
-			if (is_array($old[$name]) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id'];
343
+			if (is_array($data[$name]) && array_key_exists('id',$data[$name]))
344
+			{
345
+				$data[$name] = $data[$name]['id'];
346
+			}
347
+			if (is_array($old[$name]) && array_key_exists('id',$old[$name]))
348
+			{
349
+				$old[$name] = $old[$name]['id'];
350
+			}
342 351
 			//error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (new):'.array2string($data[$name]));
343 352
 			//error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (old):'.array2string($old[$name]));
344 353
 		}
@@ -352,11 +361,18 @@  discard block
 block discarded – undo
352 361
 			if (!($app = $this->cf_link_fields[$name]))
353 362
 			{
354 363
 				list($app,$id) = explode(':',$id);
355
-				if (!$id) continue;	// can be eg. 'addressbook:', if no contact selected
364
+				if (!$id)
365
+				{
366
+					continue;
367
+				}
368
+				// can be eg. 'addressbook:', if no contact selected
356 369
 			}
357 370
 			$source_id = $data[$this->id_field];
358 371
 			//error_log(__METHOD__.__LINE__.array2string($source_id));
359
-			if ($source_id) Api\Link::link($this->app,$source_id,$app,$id);
372
+			if ($source_id)
373
+			{
374
+				Api\Link::link($this->app,$source_id,$app,$id);
375
+			}
360 376
 			//error_log(__METHOD__.__LINE__."Api\Link::link('$this->app',".array2string($source_id).",'$app',$id);");
361 377
 			//echo "<p>Api\Link::link('$this->app',{$data[$this->id_field]},'$app',$id);</p>\n";
362 378
 		}
@@ -364,14 +380,24 @@  discard block
 block discarded – undo
364 380
 		// unlink removed application entries
365 381
 		foreach(array_diff($old_ids,$current_ids) as $name => $id)
366 382
 		{
367
-			if (!isset($data[$name])) continue;	// ignore not set link cf's, eg. from sync clients
383
+			if (!isset($data[$name]))
384
+			{
385
+				continue;
386
+			}
387
+			// ignore not set link cf's, eg. from sync clients
368 388
 			if (!($app = $this->cf_link_fields[$name]))
369 389
 			{
370 390
 				list($app,$id) = explode(':',$id);
371
-				if (!$id) continue;
391
+				if (!$id)
392
+				{
393
+					continue;
394
+				}
372 395
 			}
373 396
 			$source_id = $data[$this->id_field];
374
-			if ($source_id) Api\Link::unlink(null,$this->app,$source_id,0,$app,$id);
397
+			if ($source_id)
398
+			{
399
+				Api\Link::unlink(null,$this->app,$source_id,0,$app,$id);
400
+			}
375 401
 			//echo "<p>Api\Link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);</p>\n";
376 402
 		}
377 403
 	}
@@ -396,7 +422,10 @@  discard block
 block discarded – undo
396 422
 			$changed_fields = self::changed_fields($data,$old);
397 423
 			//error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields));
398 424
 		}
399
-		if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action'])) return 0;
425
+		if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action']))
426
+		{
427
+			return 0;
428
+		}
400 429
 
401 430
 		if (!is_object($this->historylog) || $this->historylog->user != $this->user)
402 431
 		{
@@ -412,10 +441,13 @@  discard block
 block discarded – undo
412 441
 		{
413 442
 			$status = isset($this->field2history[$name]) ? $this->field2history[$name] : $name;
414 443
 			//error_log(__METHOD__.__LINE__." Name $name,".' Status:'.array2string($status));
415
-			if (is_array($status))	// 1:N relation --> remove common rows
444
+			if (is_array($status))
445
+			{
446
+				// 1:N relation --> remove common rows
416 447
 			{
417 448
 				//error_log(__METHOD__.__LINE__.' is Array');
418 449
 				self::compact_1_N_relation($data[$name],$status);
450
+			}
419 451
 				self::compact_1_N_relation($old[$name],$status);
420 452
 				$added = array_values(array_diff($data[$name],$old[$name]));
421 453
 				$removed = array_values(array_diff($old[$name],$data[$name]));
@@ -449,17 +481,31 @@  discard block
 block discarded – undo
449 481
 	 */
450 482
 	public function changed_fields(array $data,array $old=null)
451 483
 	{
452
-		if (is_null($old)) return array_keys($data);
484
+		if (is_null($old))
485
+		{
486
+			return array_keys($data);
487
+		}
453 488
 		$changed_fields = array();
454 489
 		foreach($this->field2history as $name => $status)
455 490
 		{
456
-			if (!$old[$name] && !$data[$name]) continue;	// treat all sorts of empty equally
491
+			if (!$old[$name] && !$data[$name])
492
+			{
493
+				continue;
494
+			}
495
+			// treat all sorts of empty equally
457 496
 
458
-			if ($name[0] == '#' && !isset($data[$name])) continue;	// no set customfields are not stored, therefore not changed
497
+			if ($name[0] == '#' && !isset($data[$name]))
498
+			{
499
+				continue;
500
+			}
501
+			// no set customfields are not stored, therefore not changed
459 502
 
460
-			if (is_array($status))	// 1:N relation
503
+			if (is_array($status))
504
+			{
505
+				// 1:N relation
461 506
 			{
462 507
 				self::compact_1_N_relation($data[$name],$status);
508
+			}
463 509
 				self::compact_1_N_relation($old[$name],$status);
464 510
 			}
465 511
 			if ($old[$name] != $data[$name])
@@ -467,13 +513,22 @@  discard block
 block discarded – undo
467 513
 				// normalize arrays, we do NOT care for the order of multiselections
468 514
 				if (is_array($data[$name]) || is_array($old[$name]))
469 515
 				{
470
-					if (!is_array($data[$name])) $data[$name] = explode(',',$data[$name]);
471
-					if (!is_array($old[$name])) $old[$name] = explode(',',$old[$name]);
516
+					if (!is_array($data[$name]))
517
+					{
518
+						$data[$name] = explode(',',$data[$name]);
519
+					}
520
+					if (!is_array($old[$name]))
521
+					{
522
+						$old[$name] = explode(',',$old[$name]);
523
+					}
472 524
 					if (count($data[$name]) == count($old[$name]))
473 525
 					{
474 526
 						sort($data[$name]);
475 527
 						sort($old[$name]);
476
-						if ($data[$name] == $old[$name]) continue;
528
+						if ($data[$name] == $old[$name])
529
+						{
530
+							continue;
531
+						}
477 532
 					}
478 533
 				}
479 534
 				elseif (str_replace("\r", '', $old[$name]) == str_replace("\r", '', $data[$name]))
@@ -534,13 +589,19 @@  discard block
 block discarded – undo
534 589
 	public function do_notifications($data,$old,$deleted=null,&$email_notified=null)
535 590
 	{
536 591
 		$this->errors = $email_sent = array();
537
-		if (!empty($email_notified) && is_array($email_notified)) $email_sent = $email_notified;
592
+		if (!empty($email_notified) && is_array($email_notified))
593
+		{
594
+			$email_sent = $email_notified;
595
+		}
538 596
 
539
-		if (!$this->notify_current_user && $this->user)		// do we have a current user and should we notify the current user about his own changes
597
+		if (!$this->notify_current_user && $this->user)
598
+		{
599
+			// do we have a current user and should we notify the current user about his own changes
540 600
 		{
541 601
 			//error_log("do_notificaton() adding user=$this->user to email_sent, to not notify him");
542 602
 			$email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user,'account_email');
543 603
 		}
604
+		}
544 605
 		$skip_notify = $this->get_config('skip_notify',$data,$old);
545 606
 		if($skip_notify && is_array($skip_notify))
546 607
 		{
@@ -579,11 +640,14 @@  discard block
 block discarded – undo
579 640
 			//error_log(__METHOD__."() data[$this->assigned_field]=".print_r($data[$this->assigned_field],true).", old[$this->assigned_field]=".print_r($old[$this->assigned_field],true));
580 641
 			$old_assignees = array();
581 642
 			$assignees = $assigned ? $assigned : array();
582
-			if ($data[$this->assigned_field])	// current assignments
643
+			if ($data[$this->assigned_field])
644
+			{
645
+				// current assignments
583 646
 			{
584 647
 				$assignees = is_array($data[$this->assigned_field]) ?
585 648
 					$data[$this->assigned_field] : explode(',',$data[$this->assigned_field]);
586 649
 			}
650
+			}
587 651
 			if ($old && $old[$this->assigned_field])
588 652
 			{
589 653
 				$old_assignees = is_array($old[$this->assigned_field]) ?
@@ -592,7 +656,10 @@  discard block
 block discarded – undo
592 656
 			foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee)
593 657
 			{
594 658
 				//error_log(__METHOD__."() assignee=$assignee, type=".$GLOBALS['egw']->accounts->get_type($assignee).", email=".$GLOBALS['egw']->accounts->id2name($assignee,'account_email'));
595
-				if (!$assignee) continue;
659
+				if (!$assignee)
660
+				{
661
+					continue;
662
+				}
596 663
 
597 664
 				// item assignee is a user
598 665
 				if ($GLOBALS['egw']->accounts->get_type($assignee) == 'u')
@@ -600,10 +667,13 @@  discard block
 block discarded – undo
600 667
 					if (($email = $GLOBALS['egw']->accounts->id2name($assignee,'account_email')) && !in_array($email, $email_sent))
601 668
 					{
602 669
 						if ($this->send_notification($data,$old,$email,$assignee,'notify_assigned',
603
-							in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted))	// assignment changed
670
+							in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted))
671
+						{
672
+							// assignment changed
604 673
 						{
605 674
 							$email_sent[] = $email;
606 675
 						}
676
+						}
607 677
 					}
608 678
 				}
609 679
 				else	// item assignee is a group
@@ -613,10 +683,13 @@  discard block
 block discarded – undo
613 683
 						if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && !in_array($email, $email_sent))
614 684
 						{
615 685
 							if ($this->send_notification($data,$old,$email,$u,'notify_assigned',
616
-								in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted))	// assignment changed
686
+								in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted))
687
+							{
688
+								// assignment changed
617 689
 							{
618 690
 								$email_sent[] = $email;
619 691
 							}
692
+							}
620 693
 						}
621 694
 					}
622 695
 				}
@@ -679,25 +752,38 @@  discard block
 block discarded – undo
679 752
 	public function send_notification($data,$old,$email,$user_or_lang,$check=null,$assignment_changed=true,$deleted=null)
680 753
 	{
681 754
 		//error_log(__METHOD__."(,,'$email',$user_or_lang,$check,$assignment_changed,$deleted)");
682
-		if (!$email) return false;
755
+		if (!$email)
756
+		{
757
+			return false;
758
+		}
683 759
 
684 760
 		$save_user = $GLOBALS['egw_info']['user'];
685 761
 		$do_notify = true;
686 762
 
687
-		if (is_numeric($user_or_lang))	// user --> read everything from his prefs
763
+		if (is_numeric($user_or_lang))
764
+		{
765
+			// user --> read everything from his prefs
688 766
 		{
689 767
 			$GLOBALS['egw_info']['user']['account_id'] = $user_or_lang;
768
+		}
690 769
 			$GLOBALS['egw']->preferences->__construct($user_or_lang);
691 770
 			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false);	// no session prefs!
692 771
 
693
-			if ($check && $this->check2pref) $check = $this->check2pref[$check];
772
+			if ($check && $this->check2pref)
773
+			{
774
+				$check = $this->check2pref[$check];
775
+			}
694 776
 
695 777
 			if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] ||	// no notification requested
696 778
 				// only notification about changed assignment requested
697 779
 				$check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed ||
698
-				$this->user == $user_or_lang && !$this->notify_current_user)  // no popup for own actions
780
+				$this->user == $user_or_lang && !$this->notify_current_user)
699 781
 			{
700
-				$do_notify = false;	// no notification requested / necessary
782
+				// no popup for own actions
783
+			{
784
+				$do_notify = false;
785
+			}
786
+			// no notification requested / necessary
701 787
 			}
702 788
 		}
703 789
 		else
@@ -706,10 +792,13 @@  discard block
 block discarded – undo
706 792
 			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->default_prefs();
707 793
 			$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $user_or_lang;
708 794
 		}
709
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != Api\Translation::$userlang)	// load the right language if needed
795
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != Api\Translation::$userlang)
796
+		{
797
+			// load the right language if needed
710 798
 		{
711 799
 			Api\Translation::init();
712 800
 		}
801
+		}
713 802
 
714 803
 		$receiver = is_numeric($user_or_lang) ? $user_or_lang : $email;
715 804
 
@@ -813,7 +902,10 @@  discard block
 block discarded – undo
813 902
 			$do_time = ($timestamp->format('Hi') != '0000');
814 903
 		}
815 904
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
816
-		if ($do_time) $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] != 12 ? 'H:i' : 'h:i a');
905
+		if ($do_time)
906
+		{
907
+			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] != 12 ? 'H:i' : 'h:i a');
908
+		}
817 909
 
818 910
 		return $timestamp->format($format);
819 911
 	}
@@ -843,9 +935,12 @@  discard block
 block discarded – undo
843 935
 		{
844 936
 			$name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname');
845 937
 
846
-			if($prefer_id) {
938
+			if($prefer_id)
939
+			{
847 940
 				$sender = $this->user;
848
-			} else {
941
+			}
942
+			else
943
+			{
849 944
 				$sender = $name ? $name.' <'.$email.'>' : $email;
850 945
 			}
851 946
 		}
@@ -947,7 +1042,10 @@  discard block
 block discarded – undo
947 1042
 			// remove the session-id in the notification mail!
948 1043
 			$link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link);
949 1044
 
950
-			if ($popup) $link .= '&nopopup=1';
1045
+			if ($popup)
1046
+			{
1047
+				$link .= '&nopopup=1';
1048
+			}
951 1049
 		}
952 1050
 		//error_log(__METHOD__."(..., $allow_popup, $receiver) returning ".array2string($allow_popup ? array($link,$popup) : $link));
953 1051
 		return $allow_popup ? array($link,$popup) : $link;
@@ -1022,7 +1120,11 @@  discard block
 block discarded – undo
1022 1120
 			// if both values are '', 0 or null, we count them as equal too
1023 1121
 			$modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]);
1024 1122
 			//if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified);
1025
-			if (empty($detail['value']) && !$modified) continue;	// skip unchanged, empty values
1123
+			if (empty($detail['value']) && !$modified)
1124
+			{
1125
+				continue;
1126
+			}
1127
+			// skip unchanged, empty values
1026 1128
 
1027 1129
 			$body .= $this->format_line($html_email,$detail['type'],$modified,
1028 1130
 				$detail['label'] ? $detail['label'] : '', $detail['value']);
@@ -1056,7 +1158,11 @@  discard block
 block discarded – undo
1056 1158
 
1057 1159
 		if ($html_mail)
1058 1160
 		{
1059
-			if (!$this->html_content_allow) $line = Api\Html::htmlspecialchars($line);	// XSS
1161
+			if (!$this->html_content_allow)
1162
+			{
1163
+				$line = Api\Html::htmlspecialchars($line);
1164
+			}
1165
+			// XSS
1060 1166
 
1061 1167
 			$color = $modified ? 'red' : false;
1062 1168
 			$size  = '110%';
@@ -1095,15 +1201,24 @@  discard block
 block discarded – undo
1095 1201
 		}
1096 1202
 		else	// text-mail
1097 1203
 		{
1098
-			if ($type == 'reply') $content = str_repeat('-',64)."\n";
1204
+			if ($type == 'reply')
1205
+			{
1206
+				$content = str_repeat('-',64)."\n";
1207
+			}
1099 1208
 
1100
-			if ($modified) $content .= '> ';
1209
+			if ($modified)
1210
+			{
1211
+				$content .= '> ';
1212
+			}
1101 1213
 		}
1102 1214
 		$content .= $line;
1103 1215
 
1104 1216
 		if ($html_mail)
1105 1217
 		{
1106
-			if ($line && $data) $content .= '</td><td style="'.$style.'">';
1218
+			if ($line && $data)
1219
+			{
1220
+				$content .= '</td><td style="'.$style.'">';
1221
+			}
1107 1222
 			if ($type == 'link')
1108 1223
 			{
1109 1224
 				// the link is often too long for html boxes chunk-split allows to break lines if needed
@@ -1122,7 +1237,10 @@  discard block
 block discarded – undo
1122 1237
 		{
1123 1238
 			$content .= ($content&&$data?': ':'').$data;
1124 1239
 		}
1125
-		if ($html_mail) $content .= '</td></tr>';
1240
+		if ($html_mail)
1241
+		{
1242
+			$content .= '</td></tr>';
1243
+		}
1126 1244
 
1127 1245
 		$content .= "\n";
1128 1246
 
Please login to merge, or discard this patch.
api/src/Storage/Base.php 1 patch
Braces   +193 added lines, -51 removed lines patch added patch discarded remove patch
@@ -182,7 +182,10 @@  discard block
 block discarded – undo
182 182
 	function __construct($app='',$table='',Api\Db $db=null,$column_prefix='',$no_clone=false,$timestamp_type=null)
183 183
 	{
184 184
 		// ease the transition to api
185
-		if ($app == 'phpgwapi') $app = 'api';
185
+		if ($app == 'phpgwapi')
186
+		{
187
+			$app = 'api';
188
+		}
186 189
 
187 190
 		if ($no_clone)
188 191
 		{
@@ -198,9 +201,15 @@  discard block
 block discarded – undo
198 201
 		{
199 202
 			$this->app = $app;
200 203
 
201
-			if (!$no_clone) $this->db->set_app($app);
204
+			if (!$no_clone)
205
+			{
206
+				$this->db->set_app($app);
207
+			}
202 208
 
203
-			if ($table) $this->setup_table($app,$table,$column_prefix);
209
+			if ($table)
210
+			{
211
+				$this->setup_table($app,$table,$column_prefix);
212
+			}
204 213
 		}
205 214
 		$this->init();
206 215
 
@@ -221,7 +230,10 @@  discard block
 block discarded – undo
221 230
 	 */
222 231
 	public function set_times($timestamp_type=false)
223 232
 	{
224
-		if ($timestamp_type !== false) $this->timestamp_type = $timestamp_type;
233
+		if ($timestamp_type !== false)
234
+		{
235
+			$this->timestamp_type = $timestamp_type;
236
+		}
225 237
 
226 238
 		// set current time
227 239
 		switch($this->timestamp_type)
@@ -279,7 +291,10 @@  discard block
 block discarded – undo
279 291
 			{
280 292
 				$this->autoinc_id = $col;
281 293
 			}
282
-			if ($def['type'] == 'bool') $this->has_bools = true;
294
+			if ($def['type'] == 'bool')
295
+			{
296
+				$this->has_bools = true;
297
+			}
283 298
 
284 299
 			foreach($this->table_def['uc'] as $k => $uni_index)
285 300
 			{
@@ -318,7 +333,10 @@  discard block
 block discarded – undo
318 333
 	 */
319 334
 	function data_merge($new)
320 335
 	{
321
-		if ((int) $this->debug >= 4) echo "<p>so_sql::data_merge(".print_r($new,true).")</p>\n";
336
+		if ((int) $this->debug >= 4)
337
+		{
338
+			echo "<p>so_sql::data_merge(".print_r($new,true).")</p>\n";
339
+		}
322 340
 
323 341
 		if (!is_array($new) || !count($new))
324 342
 		{
@@ -342,7 +360,10 @@  discard block
 block discarded – undo
342 360
 		{
343 361
 			$this->data[self::USER_TIMEZONE_READ] = $new[self::USER_TIMEZONE_READ];
344 362
 		}
345
-		if ((int) $this->debug >= 4) _debug_array($this->data);
363
+		if ((int) $this->debug >= 4)
364
+		{
365
+			_debug_array($this->data);
366
+		}
346 367
 	}
347 368
 
348 369
 	/**
@@ -486,7 +507,10 @@  discard block
 block discarded – undo
486 507
 		if (!is_array($keys))
487 508
 		{
488 509
 			$pk = array_values($this->db_key_cols);
489
-			if ($pk) $keys = array($pk[0] => $keys);
510
+			if ($pk)
511
+			{
512
+				$keys = array($pk[0] => $keys);
513
+			}
490 514
 		}
491 515
 
492 516
 		$this->init($keys);
@@ -500,13 +524,16 @@  discard block
 block discarded – undo
500 524
 				$query[$db_col] = $this->data[$col];
501 525
 			}
502 526
 		}
503
-		if (!$query)	// no primary key in keys, lets try the data_cols for a unique key
527
+		if (!$query)
528
+		{
529
+			// no primary key in keys, lets try the data_cols for a unique key
504 530
 		{
505 531
 			foreach($this->db_uni_cols as $db_col => $col)
506 532
 			{
507 533
 				if (!is_array($col) && $this->data[$col] != '')
508 534
 				{
509 535
 					$query[$db_col] = $this->data[$col];
536
+		}
510 537
 				}
511 538
 				elseif(is_array($col))
512 539
 				{
@@ -520,31 +547,43 @@  discard block
 block discarded – undo
520 547
 						}
521 548
 						$q[$db_c] = $this->data[$c];
522 549
 					}
523
-					if ($q) $query += $q;
550
+					if ($q)
551
+					{
552
+						$query += $q;
553
+					}
524 554
 				}
525 555
 			}
526 556
 		}
527
-		if (!$query)	// no unique key in keys, lets try everything else
557
+		if (!$query)
558
+		{
559
+			// no unique key in keys, lets try everything else
528 560
 		{
529 561
 			foreach($this->db_data_cols as $db_col => $col)
530 562
 			{
531 563
 				if ($this->data[$col] != '')
532 564
 				{
533 565
 					$query[$db_col] = $this->data[$col];
566
+		}
534 567
 				}
535 568
 			}
536 569
 		}
537
-		if (!$query)	// keys has no cols
570
+		if (!$query)
571
+		{
572
+			// keys has no cols
538 573
 		{
539 574
 			$this->db2data();
575
+		}
540 576
 
541 577
 			return False;
542 578
 		}
543
-		if ($join)	// Prefix the columns with the table-name, as they might exist in the join
579
+		if ($join)
580
+		{
581
+			// Prefix the columns with the table-name, as they might exist in the join
544 582
 		{
545 583
 			foreach($query as $col => $val)
546 584
 			{
547 585
 				if (is_int($col) || strpos($join,$col) === false) continue;
586
+		}
548 587
 				$query[] = $this->db->expression($this->table_name,$this->table_name.'.',array($col=>$val));
549 588
 				unset($query[$col]);
550 589
 			}
@@ -553,11 +592,14 @@  discard block
 block discarded – undo
553 592
 			$query,__LINE__,__FILE__,False,'',$this->app,0,$join) as $row)
554 593
 		{
555 594
 			$cols = $this->db_cols;
556
-			if ($extra_cols)	// extra columns to report
595
+			if ($extra_cols)
596
+			{
597
+				// extra columns to report
557 598
 			{
558 599
 				foreach(is_array($extra_cols) ? $extra_cols : array($extra_cols) as $col)
559 600
 				{
560 601
 					if (FALSE!==stripos($col,' as ')) $col = preg_replace('/^.* as *([a-z0-9_]+) *$/i','\\1',$col);
602
+			}
561 603
 					$cols[$col] = $col;
562 604
 				}
563 605
 			}
@@ -580,7 +622,10 @@  discard block
 block discarded – undo
580 622
 		{
581 623
 			unset($this->data[$this->db_key_cols[$this->autoinc_id]]);
582 624
 		}
583
-		if ((int) $this->debug >= 4) echo "nothing found !!!</p>\n";
625
+		if ((int) $this->debug >= 4)
626
+		{
627
+			echo "nothing found !!!</p>\n";
628
+		}
584 629
 
585 630
 		$this->db2data();
586 631
 
@@ -596,7 +641,10 @@  discard block
 block discarded – undo
596 641
 	 */
597 642
 	function save($keys=null,$extra_where=null)
598 643
 	{
599
-		if (is_array($keys) && count($keys)) $this->data_merge($keys);
644
+		if (is_array($keys) && count($keys))
645
+		{
646
+			$this->data_merge($keys);
647
+		}
600 648
 
601 649
 		// check if data contains user timezone during read AND user changed timezone since then
602 650
 		// --> load old timezone for the rest of this request
@@ -613,9 +661,13 @@  discard block
 block discarded – undo
613 661
 		}
614 662
 		$this->data2db();
615 663
 
616
-		if ((int) $this->debug >= 4) { echo "so_sql::save(".print_r($keys,true).") autoinc_id='$this->autoinc_id', data="; _debug_array($this->data); }
664
+		if ((int) $this->debug >= 4)
665
+		{
666
+echo "so_sql::save(".print_r($keys,true).") autoinc_id='$this->autoinc_id', data="; _debug_array($this->data); }
617 667
 
618
-		if ($this->autoinc_id && !$this->data[$this->db_key_cols[$this->autoinc_id]])	// insert with auto id
668
+		if ($this->autoinc_id && !$this->data[$this->db_key_cols[$this->autoinc_id]])
669
+		{
670
+			// insert with auto id
619 671
 		{
620 672
 			foreach($this->db_cols as $db_col => $col)
621 673
 			{
@@ -625,7 +677,9 @@  discard block
 block discarded – undo
625 677
 						(isset($this->table_def['fd'][$db_col]['default']) ||	// we have a default value
626 678
 						 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))	// column is nullable
627 679
 					{
628
-						continue;	// no need to write that (unset) column
680
+						continue;
681
+		}
682
+		// no need to write that (unset) column
629 683
 					}
630 684
 					if ($this->table_def['fd'][$db_col]['type'] == 'varchar' &&
631 685
 						strlen($this->data[$col]) > $this->table_def['fd'][$db_col]['precision'])
@@ -656,9 +710,13 @@  discard block
 block discarded – undo
656 710
 				if (!array_key_exists($col,$this->data) &&	// handling of unset columns in $this->data
657 711
 					($this->autoinc_id ||			// update of table with auto id or
658 712
 					 isset($this->table_def['fd'][$db_col]['default']) ||	// we have a default value or
659
-					 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))	// column is nullable
713
+					 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))
660 714
 				{
661
-					continue;	// no need to write that (unset) column
715
+					// column is nullable
716
+				{
717
+					continue;
718
+				}
719
+				// no need to write that (unset) column
662 720
 				}
663 721
 				$data[$db_col] = !is_object($this->data[$col]) && (string) $this->data[$col] === '' && $this->empty_on_write == 'NULL' ? null : $this->data[$col];
664 722
 			}
@@ -675,9 +733,12 @@  discard block
 block discarded – undo
675 733
 			{
676 734
 				$keys[$db_col] = $this->data[$col];
677 735
 			}
678
-			if (!$data && !$this->autoinc_id)	// happens if all columns are in the primary key
736
+			if (!$data && !$this->autoinc_id)
737
+			{
738
+				// happens if all columns are in the primary key
679 739
 			{
680 740
 				$data = $keys;
741
+			}
681 742
 				$keys = False;
682 743
 			}
683 744
 			if ($this->autoinc_id)
@@ -708,7 +769,10 @@  discard block
 block discarded – undo
708 769
 	 */
709 770
 	function update($_fields,$merge=true)
710 771
 	{
711
-		if ($merge) $this->data_merge($_fields);
772
+		if ($merge)
773
+		{
774
+			$this->data_merge($_fields);
775
+		}
712 776
 
713 777
 		$fields = $this->data2db($_fields);
714 778
 
@@ -761,9 +825,12 @@  discard block
 block discarded – undo
761 825
 		{
762 826
 			$keys = array($this->autoinc_id => $keys);
763 827
 		}
764
-		if (!is_array($keys) || !count($keys))	// use internal data
828
+		if (!is_array($keys) || !count($keys))
829
+		{
830
+			// use internal data
765 831
 		{
766 832
 			$data = $this->data;
833
+		}
767 834
 			$keys = $this->db_key_cols;
768 835
 		}
769 836
 		else	// data and keys are supplied in $keys
@@ -783,7 +850,10 @@  discard block
 block discarded – undo
783 850
 		{
784 851
 			$query[$db_col] = $data[$col];
785 852
 		}
786
-		if ($only_return_query) return $query;
853
+		if ($only_return_query)
854
+		{
855
+			return $query;
856
+		}
787 857
 
788 858
 		$this->db->delete($this->table_name,$query,__LINE__,__FILE__,$this->app);
789 859
 
@@ -816,7 +886,10 @@  discard block
 block discarded – undo
816 886
 	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
817 887
 	{
818 888
 		//error_log(__METHOD__.'('.array2string(array_combine(array_slice(array('criteria','only_keys','order_by','extra_cols','wildcard','empty','op','start','filter','join','need_full_no_count'), 0, count(func_get_args())), func_get_args())).')');
819
-		if ((int) $this->debug >= 4) echo "<p>so_sql::search(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
889
+		if ((int) $this->debug >= 4)
890
+		{
891
+			echo "<p>so_sql::search(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
892
+		}
820 893
 
821 894
 		// if extending class or instanciator set columns to search, convert string criteria to array
822 895
 		if ($criteria && !is_array($criteria))
@@ -880,9 +953,12 @@  discard block
 block discarded – undo
880 953
 								($negate ? ') ' : '');
881 954
 						}
882 955
 					}
883
-					elseif (strpos($db_col,'.') !== false)	// we have a table-name specified
956
+					elseif (strpos($db_col,'.') !== false)
957
+					{
958
+						// we have a table-name specified
884 959
 					{
885 960
 						list($table,$only_col) = explode('.',$db_col);
961
+					}
886 962
 						$type = $this->db->get_column_attribute($only_col, $table, true, 'type');
887 963
 						if (empty($type))
888 964
 						{
@@ -907,13 +983,17 @@  discard block
 block discarded – undo
907 983
 					}
908 984
 				}
909 985
 			}
910
-			if (is_array($query) && $op != 'AND') $query = $this->db->column_data_implode(' '.$op.' ',$query);
986
+			if (is_array($query) && $op != 'AND')
987
+			{
988
+				$query = $this->db->column_data_implode(' '.$op.' ',$query);
989
+			}
911 990
 		}
912 991
 		if (is_array($filter))
913 992
 		{
914 993
 			$db_filter = array();
915 994
 			$data2db_filter = $this->data2db($filter);
916
-			if (!is_array($data2db_filter)) {
995
+			if (!is_array($data2db_filter))
996
+			{
917 997
 				echo function_backtrace()."<br/>\n";
918 998
 				echo "filter=";_debug_array($filter);
919 999
 				echo "data2db(filter)=";_debug_array($data2db_filter);
@@ -1009,7 +1089,10 @@  discard block
 block discarded – undo
1009 1089
 			}
1010 1090
 		}
1011 1091
 		$num_rows = 0;	// as spec. in max_matches in the user-prefs
1012
-		if (is_array($start)) list($start,$num_rows) = $start;
1092
+		if (is_array($start))
1093
+		{
1094
+			list($start,$num_rows) = $start;
1095
+		}
1013 1096
 
1014 1097
 		// fix GROUP BY clause to contain all non-aggregate selected columns
1015 1098
 		if ($order_by && stripos($order_by,'GROUP BY') !== false)
@@ -1037,18 +1120,24 @@  discard block
 block discarded – undo
1037 1120
 					'append' => $order_by,
1038 1121
 					'join'   => $join,
1039 1122
 				);
1040
-				if (!$union_cols)	// union used the colum-names of the first query
1123
+				if (!$union_cols)
1124
+				{
1125
+					// union used the colum-names of the first query
1041 1126
 				{
1042 1127
 					$union_cols = $this->_get_columns($only_keys,$extra_cols);
1043 1128
 				}
1129
+				}
1044 1130
 				return true;	// waiting for further calls, before running the union-query
1045 1131
 			}
1046 1132
 			// running the union query now
1047
-			if ($start !== false)	// need to get the total too, saved in $this->total
1133
+			if ($start !== false)
1134
+			{
1135
+				// need to get the total too, saved in $this->total
1048 1136
 			{
1049 1137
 				if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
1050 1138
 				{
1051 1139
 					$union[0]['cols'] = ($mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ').$union[0]['cols'];
1140
+			}
1052 1141
 				}
1053 1142
 				else	// cant do a count, have to run the query without limit
1054 1143
 				{
@@ -1056,18 +1145,24 @@  discard block
 block discarded – undo
1056 1145
 				}
1057 1146
 			}
1058 1147
 			$rs = $this->db->union($union,__LINE__,__FILE__,$order_by,$start,$num_rows);
1059
-			if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1148
+			if ($this->debug)
1149
+			{
1150
+				error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1151
+			}
1060 1152
 
1061 1153
 			$cols = $union_cols;
1062 1154
 			$union = $union_cols = array();
1063 1155
 		}
1064 1156
 		else	// no UNION
1065 1157
 		{
1066
-			if ($start !== false)	// need to get the total too, saved in $this->total
1158
+			if ($start !== false)
1159
+			{
1160
+				// need to get the total too, saved in $this->total
1067 1161
 			{
1068 1162
 				if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
1069 1163
 				{
1070 1164
 					$mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ';
1165
+			}
1071 1166
 				}
1072 1167
 				elseif (!$need_full_no_count && (!$join || stripos($join,'LEFT JOIN')!==false))
1073 1168
 				{
@@ -1080,10 +1175,16 @@  discard block
 block discarded – undo
1080 1175
 			}
1081 1176
 			$rs = $this->db->select($this->table_name,$mysql_calc_rows.$colums,$query,__LINE__,__FILE__,
1082 1177
 				$start,$order_by,$this->app,$num_rows,$join);
1083
-			if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1178
+			if ($this->debug)
1179
+			{
1180
+				error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1181
+			}
1084 1182
 			$cols = $this->_get_columns($only_keys,$extra_cols);
1085 1183
 		}
1086
-		if ((int) $this->debug >= 4) echo "<p>sql='{$this->db->Query_ID->sql}'</p>\n";
1184
+		if ((int) $this->debug >= 4)
1185
+		{
1186
+			echo "<p>sql='{$this->db->Query_ID->sql}'</p>\n";
1187
+		}
1087 1188
 
1088 1189
 		if ($mysql_calc_rows)
1089 1190
 		{
@@ -1096,9 +1197,12 @@  discard block
 block discarded – undo
1096 1197
 		}
1097 1198
 		$arr = array();
1098 1199
 		$n = 0;
1099
-		if ($rs) foreach($rs as $row)
1200
+		if ($rs)
1201
+		{
1202
+			foreach($rs as $row)
1100 1203
 		{
1101 1204
 			$data = array();
1205
+		}
1102 1206
 			foreach($cols as $db_col => $col)
1103 1207
 			{
1104 1208
 				$data[$col] = (isset($row[$db_col]) ? $row[$db_col] : $row[$col]);
@@ -1166,9 +1270,15 @@  discard block
 block discarded – undo
1166 1270
 					$col = substr($col, $pos+9);
1167 1271
 				}
1168 1272
 				$alias = $col;
1169
-				if (stripos($col, ' AS ')) list($col, $alias) = preg_split('/ +AS +/i', $col);
1273
+				if (stripos($col, ' AS '))
1274
+				{
1275
+					list($col, $alias) = preg_split('/ +AS +/i', $col);
1276
+				}
1170 1277
 				// do NOT group by constant expressions
1171
-				if (preg_match('/^ *(-?[0-9]+|".*"|\'.*\'|NULL) *$/i', $col)) continue;
1278
+				if (preg_match('/^ *(-?[0-9]+|".*"|\'.*\'|NULL) *$/i', $col))
1279
+				{
1280
+					continue;
1281
+				}
1172 1282
 				if (!in_array($col, $group_by_cols) && !in_array($alias, $group_by_cols))
1173 1283
 				{
1174 1284
 					// instead of aliased primary key, we have to use original column incl. table-name as alias is ambigues
@@ -1201,7 +1311,10 @@  discard block
 block discarded – undo
1201 1311
 	{
1202 1312
 		$pattern = trim($_pattern);
1203 1313
 		// This function can get called multiple times.  Make sure it doesn't re-process.
1204
-		if (empty($pattern) || is_array($pattern)) return $pattern;
1314
+		if (empty($pattern) || is_array($pattern))
1315
+		{
1316
+			return $pattern;
1317
+		}
1205 1318
 		if(strpos($pattern, 'CAST(COALESCE(') !== false)
1206 1319
 		{
1207 1320
 			return $pattern;
@@ -1271,7 +1384,7 @@  discard block
 block discarded – undo
1271 1384
 			{
1272 1385
 				$token = substr($token, 1,strlen($token));
1273 1386
  				if(substr($token, -1) != '"')
1274
-				{
1387
+ 				{
1275 1388
 					$token .= ' '.strtok('"');
1276 1389
 				}
1277 1390
 				else
@@ -1387,7 +1500,8 @@  discard block
 block discarded – undo
1387 1500
 			foreach($search_cols as $key => &$col)
1388 1501
 			{
1389 1502
 				// If the name as given isn't a real column name, and adding the prefix doesn't help, skip it
1390
-				if(!$this->table_def['fd'][$col] && !($col = $this->prefix.array_search($col, $search_cols))) {
1503
+				if(!$this->table_def['fd'][$col] && !($col = $this->prefix.array_search($col, $search_cols)))
1504
+				{
1391 1505
 					// Can't search this column
1392 1506
 					unset($search_cols[$key]);
1393 1507
 					continue;
@@ -1421,10 +1535,13 @@  discard block
 block discarded – undo
1421 1535
 	function _get_columns($only_keys,$extra_cols)
1422 1536
 	{
1423 1537
 		//echo "_get_columns() only_keys="; _debug_array($only_keys); echo "extra_cols="; _debug_array($extra_cols);
1424
-		if ($only_keys === true)	// only primary key
1538
+		if ($only_keys === true)
1539
+		{
1540
+			// only primary key
1425 1541
 		{
1426 1542
 			$cols = $this->db_key_cols;
1427 1543
 		}
1544
+		}
1428 1545
 		else
1429 1546
 		{
1430 1547
 			$cols = array();
@@ -1433,18 +1550,27 @@  discard block
 block discarded – undo
1433 1550
 			{
1434 1551
 				if (!$distinct_checked)
1435 1552
 				{
1436
-					if (stripos($col, 'DISTINCT ') === 0) $col = substr($col, 9);
1553
+					if (stripos($col, 'DISTINCT ') === 0)
1554
+					{
1555
+						$col = substr($col, 9);
1556
+					}
1437 1557
 					$distinct_checked = true;
1438 1558
 				}
1439
-				if (!$col || $col == '*' || $col == $this->table_name.'.*')	// all columns
1559
+				if (!$col || $col == '*' || $col == $this->table_name.'.*')
1560
+				{
1561
+					// all columns
1440 1562
 				{
1441 1563
 					$cols = array_merge($cols,$this->db_cols);
1442 1564
 				}
1565
+				}
1443 1566
 				else	// only the specified columns
1444 1567
 				{
1445
-					if (stripos($col,'as'))	// if there's already an explicit naming of the column, just use it
1568
+					if (stripos($col,'as'))
1569
+					{
1570
+						// if there's already an explicit naming of the column, just use it
1446 1571
 					{
1447 1572
 						$col = preg_replace('/^.*as +([a-z0-9_]+) *$/i','\\1',$col);
1573
+					}
1448 1574
 						$cols[$col] = $col;
1449 1575
 						continue;
1450 1576
 					}
@@ -1459,11 +1585,14 @@  discard block
 block discarded – undo
1459 1585
 				}
1460 1586
 			}
1461 1587
 		}
1462
-		if ($extra_cols)	// extra columns to report
1588
+		if ($extra_cols)
1589
+		{
1590
+			// extra columns to report
1463 1591
 		{
1464 1592
 			foreach(is_array($extra_cols) ? $extra_cols : explode(',',$extra_cols) as $col)
1465 1593
 			{
1466 1594
 				if (stripos($col,'as ')!==false) $col = preg_replace('/^.*as +([a-z0-9_]+) *$/i','\\1',$col);
1595
+		}
1467 1596
 				if (($db_col = array_search($col,$this->db_cols)) !== false)
1468 1597
 				{
1469 1598
 					$cols[$db_col] = $col;
@@ -1508,7 +1637,11 @@  discard block
 block discarded – undo
1508 1637
 			'',false,$op,$query['num_rows']?array((int)$query['start'],$query['num_rows']):(int)$query['start'],
1509 1638
 			$query['col_filter'],$join,$need_full_no_count);
1510 1639
 
1511
-		if (!$rows) $rows = array();	// otherwise false returned from search would be returned as array(false)
1640
+		if (!$rows)
1641
+		{
1642
+			$rows = array();
1643
+		}
1644
+		// otherwise false returned from search would be returned as array(false)
1512 1645
 
1513 1646
 		return $this->total;
1514 1647
 	}
@@ -1587,7 +1720,10 @@  discard block
 block discarded – undo
1587 1720
 		{
1588 1721
 			return $cache[$cache_key];
1589 1722
 		}
1590
-		if (!is_array($value_col)) $value_col = array($value_col);
1723
+		if (!is_array($value_col))
1724
+		{
1725
+			$value_col = array($value_col);
1726
+		}
1591 1727
 
1592 1728
 		$cols = $ret = array();
1593 1729
 		foreach($value_col as $key => $col)
@@ -1595,7 +1731,10 @@  discard block
 block discarded – undo
1595 1731
 			$matches = null;
1596 1732
 			$cols[$key] = preg_match('/AS ([a-z_0-9]+)$/i',$col,$matches) ? $matches[1] : $col;
1597 1733
 		}
1598
-		if (!$order) $order = current($cols);
1734
+		if (!$order)
1735
+		{
1736
+			$order = current($cols);
1737
+		}
1599 1738
 
1600 1739
 		if (($search =& $this->search(array(),($key_col ? $key_col.',' : 'DISTINCT ').implode(',',$value_col),$order,'','',false,'AND',false,$filter)))
1601 1740
 		{
@@ -1621,7 +1760,10 @@  discard block
 block discarded – undo
1621 1760
 				{
1622 1761
 					$data = $row[current($cols)];
1623 1762
 				}
1624
-				if ($data) $ret[$row[$key_col]] = $data;
1763
+				if ($data)
1764
+				{
1765
+					$ret[$row[$key_col]] = $data;
1766
+				}
1625 1767
 			}
1626 1768
 		}
1627 1769
 		return $cache[$cache_key] =& $ret;
Please login to merge, or discard this patch.
api/src/Storage/History.php 1 patch
Braces   +16 added lines, -5 removed lines patch added patch discarded remove patch
@@ -142,7 +142,10 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	function search($filter,$order='history_id',$sort='DESC',$limit=null)
144 144
 	{
145
-		if (!is_array($filter)) $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array();
145
+		if (!is_array($filter))
146
+		{
147
+			$filter = is_numeric($filter) ? array('history_record_id' => $filter) : array();
148
+		}
146 149
 
147 150
 		if (!$order || !preg_match('/^[a-z0-9_]+$/i',$order) || !preg_match('/^(asc|desc)?$/i',$sort))
148 151
 		{
@@ -160,10 +163,16 @@  discard block
 block discarded – undo
160 163
 				unset($filter[$col]);
161 164
 			}
162 165
 		}
163
-		if (!isset($filter['history_appname'])) $filter['history_appname'] = $this->appname;
166
+		if (!isset($filter['history_appname']))
167
+		{
168
+			$filter['history_appname'] = $this->appname;
169
+		}
164 170
 
165 171
 		// do not try to read all history entries of an app
166
-		if (!$filter['history_record_id']) return array();
172
+		if (!$filter['history_record_id'])
173
+		{
174
+			return array();
175
+		}
167 176
 
168 177
 		$rows = array();
169 178
 		foreach($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__,
@@ -188,8 +197,10 @@  discard block
 block discarded – undo
188 197
 		$rows = array();
189 198
 		$filter['history_appname'] = $query['appname'];
190 199
 		$filter['history_record_id'] = $query['record_id'];
191
-		if(is_array($query['colfilter'])) {
192
-			foreach($query['colfilter'] as $column => $value) {
200
+		if(is_array($query['colfilter']))
201
+		{
202
+			foreach($query['colfilter'] as $column => $value)
203
+			{
193 204
 				$filter[$column] = $value;
194 205
 			}
195 206
 		}
Please login to merge, or discard this patch.
api/src/Exception/NoPermission/Admin.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,10 @@
 block discarded – undo
21 21
 {
22 22
 	function __construct($msg=null,$code=102)
23 23
 	{
24
-		if (is_null($msg)) $msg = 'admin';
24
+		if (is_null($msg))
25
+		{
26
+			$msg = 'admin';
27
+		}
25 28
 
26 29
 		parent::__construct($msg,$code);
27 30
 	}
Please login to merge, or discard this patch.
api/src/Exception/NoPermission/Record.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,4 +19,6 @@
 block discarded – undo
19 19
  * User lacks a record level permission, eg. he's not the owner and has no grant from the owner
20 20
  *
21 21
  */
22
-class Record extends Exception\NoPermission { }
22
+class Record extends Exception\NoPermission
23
+{
24
+}
Please login to merge, or discard this patch.