Completed
Push — 14.2 ( 8c75f3...7aeda4 )
by Ralf
108:06 queued 84:21
created
phpgwapi/inc/class.egw_datetime.inc.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -691,6 +691,9 @@  discard block
 block discarded – undo
691 691
 			return (int)(($server_time - $this->gmtnow) / 3600);
692 692
 		}
693 693
 
694
+		/**
695
+		 * @param string $date_str
696
+		 */
694 697
 		function convert_rfc_to_epoch($date_str)
695 698
 		{
696 699
 			$comma_pos = strpos($date_str,',');
@@ -993,6 +996,9 @@  discard block
 block discarded – undo
993 996
 			return $date;
994 997
 		}
995 998
 
999
+		/**
1000
+		 * @param integer $localtime
1001
+		 */
996 1002
 		function gmtdate($localtime)
997 1003
 		{
998 1004
 			return $this->localdates($localtime - $this->tz_offset);
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@
 block discarded – undo
38 38
 	unset($d3);
39 39
 
40 40
 	/**
41
-	* eGroupWare datetime class that contains common date/time functions
42
-	* 
43
-	* renamed to egw_datetime to support php5.2
44
-	*/
41
+	 * eGroupWare datetime class that contains common date/time functions
42
+	 * 
43
+	 * renamed to egw_datetime to support php5.2
44
+	 */
45 45
 	class egw_datetime
46 46
 	{
47 47
 		var $zone_offset_list = array(
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 
26 26
 	/* $Id$ */
27 27
 
28
-	$d1 = strtolower(@substr(EGW_API_INC,0,3));
29
-	$d2 = strtolower(@substr(EGW_SERVER_ROOT,0,3));
30
-	$d3 = strtolower(@substr(EGW_APP_INC,0,3));
31
-	if($d1 == 'htt' || $d1 == 'ftp' || $d2 == 'htt' || $d2 == 'ftp' || $d3 == 'htt' || $d3 == 'ftp')
28
+	$d1 = strtolower(@substr(EGW_API_INC, 0, 3));
29
+	$d2 = strtolower(@substr(EGW_SERVER_ROOT, 0, 3));
30
+	$d3 = strtolower(@substr(EGW_APP_INC, 0, 3));
31
+	if ($d1 == 'htt' || $d1 == 'ftp' || $d2 == 'htt' || $d2 == 'ftp' || $d3 == 'htt' || $d3 == 'ftp')
32 32
 	{
33 33
 		echo 'Failed attempt to break in via an old Security Hole!<br>'."\n";
34 34
 		exit;
@@ -584,21 +584,21 @@  discard block
 block discarded – undo
584 584
 		function egw_datetime()
585 585
 		{
586 586
 			$this->tz_offset = 3600 * @$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
587
-			print_debug('datetime::datetime::gmtnow',$this->gmtnow,'api');
587
+			print_debug('datetime::datetime::gmtnow', $this->gmtnow, 'api');
588 588
 
589 589
 			$error_occured = True;
590 590
 			// If we already have a GMT time, no need to do this again.
591
-			if(!$this->gmtnow)
591
+			if (!$this->gmtnow)
592 592
 			{
593
-				if(isset($GLOBALS['egw_info']['server']['tz_offset']))
593
+				if (isset($GLOBALS['egw_info']['server']['tz_offset']))
594 594
 				{
595 595
 					$this->gmtnow = time() - ((int)$GLOBALS['egw_info']['server']['tz_offset'] * 3600);
596
-					print_debug('datetime::datetime::tz_offset',"set via tz_offset=".$GLOBALS['egw_info']['server']['tz_offset'].": gmtnow=".date('Y/m/d H:i',$this->gmtnow),'api');
596
+					print_debug('datetime::datetime::tz_offset', "set via tz_offset=".$GLOBALS['egw_info']['server']['tz_offset'].": gmtnow=".date('Y/m/d H:i', $this->gmtnow), 'api');
597 597
 				}
598 598
 				else
599 599
 				{
600 600
 					$this->gmtnow = time() - ($this->getbestguess() * 3600);
601
-					print_debug('datetime::datetime::bestguess',"set via bestguess=".$this->getbestguess().": gmtnow=".date('Y/m/d H:i',$this->gmtnow),'api');
601
+					print_debug('datetime::datetime::bestguess', "set via bestguess=".$this->getbestguess().": gmtnow=".date('Y/m/d H:i', $this->gmtnow), 'api');
602 602
 				}
603 603
 			}
604 604
 			$this->users_localtime = time() + $this->tz_offset;
@@ -607,33 +607,33 @@  discard block
 block discarded – undo
607 607
 		function getntpoffset()
608 608
 		{
609 609
 			$error_occured = False;
610
-			if(!@is_object($GLOBALS['egw']->network))
610
+			if (!@is_object($GLOBALS['egw']->network))
611 611
 			{
612 612
 				$GLOBALS['egw']->network = createobject('phpgwapi.network');
613 613
 			}
614 614
 			$server_time = time();
615 615
 
616
-			if($GLOBALS['egw']->network->open_port('129.6.15.28',13,5))
616
+			if ($GLOBALS['egw']->network->open_port('129.6.15.28', 13, 5))
617 617
 			{
618 618
 				$line = $GLOBALS['egw']->network->bs_read_port(64);
619 619
 				$GLOBALS['egw']->network->close_port();
620 620
 
621
-				$array = explode(' ',$line);
621
+				$array = explode(' ', $line);
622 622
 				// host: 129.6.15.28
623 623
 				// Value returned is 52384 02-04-20 13:55:29 50 0 0   9.2 UTC(NIST) *
624
-				print_debug('Server datetime',time(),'api');
625
-				print_debug('Temporary NTP datetime',$line,'api');
624
+				print_debug('Server datetime', time(), 'api');
625
+				print_debug('Temporary NTP datetime', $line, 'api');
626 626
 				if ($array[5] == 4)
627 627
 				{
628 628
 					$error_occured = True;
629 629
 				}
630 630
 				else
631 631
 				{
632
-					$date = explode('-',$array[1]);
633
-					$time = explode(':',$array[2]);
634
-					$this->gmtnow = mktime((int)$time[0],(int)$time[1],(int)$time[2],(int)$date[1],(int)$date[2],(int)$date[0] + 2000);
635
-					print_debug('Temporary RFC epoch',$this->gmtnow,'api');
636
-					print_debug('GMT',date('Ymd H:i:s',$this->gmtnow),'api');
632
+					$date = explode('-', $array[1]);
633
+					$time = explode(':', $array[2]);
634
+					$this->gmtnow = mktime((int)$time[0], (int)$time[1], (int)$time[2], (int)$date[1], (int)$date[2], (int)$date[0] + 2000);
635
+					print_debug('Temporary RFC epoch', $this->gmtnow, 'api');
636
+					print_debug('GMT', date('Ymd H:i:s', $this->gmtnow), 'api');
637 637
 				}
638 638
 			}
639 639
 			else
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 				$error_occured = True;
642 642
 			}
643 643
 
644
-			if($error_occured == True)
644
+			if ($error_occured == True)
645 645
 			{
646 646
 				return $this->getbestguess();
647 647
 			}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 		function gethttpoffset()
655 655
 		{
656 656
 			$error_occured = False;
657
-			if(!@is_object($GLOBALS['egw']->network))
657
+			if (!@is_object($GLOBALS['egw']->network))
658 658
 			{
659 659
 				$GLOBALS['egw']->network = createobject('phpgwapi.network');
660 660
 			}
@@ -662,41 +662,41 @@  discard block
 block discarded – undo
662 662
 
663 663
 			$filename = 'http://132.163.4.213/timezone.cgi?GMT';
664 664
 			$file = $GLOBALS['egw']->network->gethttpsocketfile($filename);
665
-			if(!$file)
665
+			if (!$file)
666 666
 			{
667 667
 				return $this->getbestguess();
668 668
 			}
669 669
 			$time = strip_tags($file[55]);
670 670
 			$date = strip_tags($file[56]);
671 671
 
672
-			print_debug('GMT DateTime',$date.' '.$time,'api');
673
-			$dt_array = explode(' ',$date);
674
-			$temp_datetime = $dt_array[0].' '.substr($dt_array[2],0,-1).' '.substr($dt_array[1],0,3).' '.$dt_array[3].' '.$time.' GMT';
675
-			print_debug('Reformulated GMT DateTime',$temp_datetime,'api');
672
+			print_debug('GMT DateTime', $date.' '.$time, 'api');
673
+			$dt_array = explode(' ', $date);
674
+			$temp_datetime = $dt_array[0].' '.substr($dt_array[2], 0, -1).' '.substr($dt_array[1], 0, 3).' '.$dt_array[3].' '.$time.' GMT';
675
+			print_debug('Reformulated GMT DateTime', $temp_datetime, 'api');
676 676
 			$this->gmtnow = $this->convert_rfc_to_epoch($temp_datetime);
677
-			print_debug('this->gmtnow',$this->gmtnow,'api');
678
-			print_debug('server time',$server_time,'api');
679
-			print_debug('server DateTime',date('D, d M Y H:i:s',$server_time),'api');
677
+			print_debug('this->gmtnow', $this->gmtnow, 'api');
678
+			print_debug('server time', $server_time, 'api');
679
+			print_debug('server DateTime', date('D, d M Y H:i:s', $server_time), 'api');
680 680
 			return (int)(($server_time - $this->gmtnow) / 3600);
681 681
 		}
682 682
 
683 683
 		function getbestguess()
684 684
 		{
685
-			print_debug('datetime::datetime::debug: Inside getting from local server','api');
685
+			print_debug('datetime::datetime::debug: Inside getting from local server', 'api');
686 686
 			$server_time = time();
687 687
 			// Calculate GMT time...
688 688
 			// If DST, add 1 hour...
689 689
 			//  - (date('I') == 1?3600:0)
690
-			$this->gmtnow = $this->convert_rfc_to_epoch(gmdate('D, d M Y H:i:s',$server_time).' GMT');
690
+			$this->gmtnow = $this->convert_rfc_to_epoch(gmdate('D, d M Y H:i:s', $server_time).' GMT');
691 691
 			return (int)(($server_time - $this->gmtnow) / 3600);
692 692
 		}
693 693
 
694 694
 		function convert_rfc_to_epoch($date_str)
695 695
 		{
696
-			$comma_pos = strpos($date_str,',');
697
-			if($comma_pos)
696
+			$comma_pos = strpos($date_str, ',');
697
+			if ($comma_pos)
698 698
 			{
699
-				$date_str = substr($date_str,$comma_pos+1);
699
+				$date_str = substr($date_str, $comma_pos + 1);
700 700
 			}
701 701
 
702 702
 			// This may need to be a reference to the different months in native tongue....
@@ -718,14 +718,14 @@  discard block
 block discarded – undo
718 718
 			$ta = array();
719 719
 
720 720
 			// Convert "15 Jul 2000 20:50:22 +0200" to unixtime
721
-			$dta = explode(' ',$date_str);
722
-			$ta = explode(':',$dta[4]);
721
+			$dta = explode(' ', $date_str);
722
+			$ta = explode(':', $dta[4]);
723 723
 
724
-			if(substr($dta[5],0,3) <> 'GMT')
724
+			if (substr($dta[5], 0, 3) <> 'GMT')
725 725
 			{
726
-				$tzoffset = substr($dta[5],0,1);
727
-				$tzhours = (int)substr($dta[5],1,2);
728
-				$tzmins = (int)substr($dta[5],3,2);
726
+				$tzoffset = substr($dta[5], 0, 1);
727
+				$tzhours = (int)substr($dta[5], 1, 2);
728
+				$tzmins = (int)substr($dta[5], 3, 2);
729 729
 				switch ($tzoffset)
730 730
 				{
731 731
 					case '-':
@@ -738,13 +738,13 @@  discard block
 block discarded – undo
738 738
 						break;
739 739
 				}
740 740
 			}
741
-			return mktime($ta[0],$ta[1],$ta[2],$month[$dta[2]],$dta[1],$dta[3]);
741
+			return mktime($ta[0], $ta[1], $ta[2], $month[$dta[2]], $dta[1], $dta[3]);
742 742
 		}
743 743
 
744
-		function get_weekday_start($year,$month,$day)
744
+		function get_weekday_start($year, $month, $day)
745 745
 		{
746
-			$weekday = $this->day_of_week($year,$month,$day);
747
-			switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
746
+			$weekday = $this->day_of_week($year, $month, $day);
747
+			switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
748 748
 			{
749 749
 				// Saturday is for arabic support
750 750
 				case 'Saturday':
@@ -766,16 +766,16 @@  discard block
 block discarded – undo
766 766
 						5 => 'Th',
767 767
 						6 => 'Fr'
768 768
 					);
769
-					switch($weekday)
769
+					switch ($weekday)
770 770
 					{
771 771
 						case 0:
772
-							$sday = mktime(2,0,0,$month,$day - 1,$year);
772
+							$sday = mktime(2, 0, 0, $month, $day - 1, $year);
773 773
 							break;
774 774
 						case 6:
775
-							$sday = mktime(2,0,0,$month,$day,$year);
775
+							$sday = mktime(2, 0, 0, $month, $day, $year);
776 776
 							break;
777 777
 						default:
778
-							$sday = mktime(2,0,0,$month,$day - ($weekday + 1),$year);
778
+							$sday = mktime(2, 0, 0, $month, $day - ($weekday + 1), $year);
779 779
 							break;
780 780
 					}
781 781
 					break;
@@ -798,16 +798,16 @@  discard block
 block discarded – undo
798 798
 						5 => 'Sa',
799 799
 						6 => 'Su'
800 800
 					);
801
-					switch($weekday)
801
+					switch ($weekday)
802 802
 					{
803 803
 						case 0:
804
-							$sday = mktime(2,0,0,$month,$day - 6,$year);
804
+							$sday = mktime(2, 0, 0, $month, $day - 6, $year);
805 805
 							break;
806 806
 						case 1:
807
-							$sday = mktime(2,0,0,$month,$day,$year);
807
+							$sday = mktime(2, 0, 0, $month, $day, $year);
808 808
 							break;
809 809
 						default:
810
-							$sday = mktime(2,0,0,$month,$day - ($weekday - 1),$year);
810
+							$sday = mktime(2, 0, 0, $month, $day - ($weekday - 1), $year);
811 811
 							break;
812 812
 					}
813 813
 					break;
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 						5 => 'Fr',
832 832
 						6 => 'Sa'
833 833
 					);
834
-					$sday = mktime(2,0,0,$month,$day - $weekday,$year);
834
+					$sday = mktime(2, 0, 0, $month, $day - $weekday, $year);
835 835
 					break;
836 836
 			}
837 837
 			return $sday - 7200;
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 			}
850 850
 		}
851 851
 
852
-		function days_in_month($month,$year)
852
+		function days_in_month($month, $year)
853 853
 		{
854 854
 			$days = Array(
855 855
 				1  => 31,
@@ -868,22 +868,22 @@  discard block
 block discarded – undo
868 868
 			return $days[(int)$month];
869 869
 		}
870 870
 
871
-		function date_valid($year,$month,$day)
871
+		function date_valid($year, $month, $day)
872 872
 		{
873
-			return checkdate((int)$month,(int)$day,(int)$year);
873
+			return checkdate((int)$month, (int)$day, (int)$year);
874 874
 		}
875 875
 
876
-		function time_valid($hour,$minutes,$seconds)
876
+		function time_valid($hour, $minutes, $seconds)
877 877
 		{
878
-			if((int)$hour < 0 || (int)$hour > 24)
878
+			if ((int)$hour < 0 || (int)$hour > 24)
879 879
 			{
880 880
 				return False;
881 881
 			}
882
-			if((int)$minutes < 0 || (int)$minutes > 59)
882
+			if ((int)$minutes < 0 || (int)$minutes > 59)
883 883
 			{
884 884
 				return False;
885 885
 			}
886
-			if((int)$seconds < 0 || (int)$seconds > 59)
886
+			if ((int)$seconds < 0 || (int)$seconds > 59)
887 887
 			{
888 888
 				return False;
889 889
 			}
@@ -891,9 +891,9 @@  discard block
 block discarded – undo
891 891
 			return True;
892 892
 		}
893 893
 
894
-		function day_of_week($year,$month,$day)
894
+		function day_of_week($year, $month, $day)
895 895
 		{
896
-			if($month > 2)
896
+			if ($month > 2)
897 897
 			{
898 898
 				$month -= 2;
899 899
 			}
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
 			return (($day - 7 * floor($day / 7)));
907 907
 		}
908 908
 
909
-		function day_of_year($year,$month,$day)
909
+		function day_of_year($year, $month, $day)
910 910
 		{
911
-			$days = array(0,31,59,90,120,151,181,212,243,273,304,334);
911
+			$days = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
912 912
 
913 913
 			$julian = ($days[$month - 1] + $day);
914 914
 
915
-			if($month > 2 && $this->is_leap_year($year))
915
+			if ($month > 2 && $this->is_leap_year($year))
916 916
 			{
917 917
 				$julian++;
918 918
 			}
@@ -926,50 +926,50 @@  discard block
 block discarded – undo
926 926
 		@param $m1 - Month_1, $d1 - Day_1, $y1 - Year_1, $m2 - Month_2, $d2 - Day_2, $y2 - Year_2
927 927
 		@note the last param == 0, ensures that the calculation is always done without daylight-saveing
928 928
 		*/
929
-		function days_between($m1,$d1,$y1,$m2,$d2,$y2)
929
+		function days_between($m1, $d1, $y1, $m2, $d2, $y2)
930 930
 		{
931
-			return (int)((mktime(0,0,0,$m2,$d2,$y2,0) - mktime(0,0,0,$m1,$d1,$y1,0)) / 86400);
931
+			return (int)((mktime(0, 0, 0, $m2, $d2, $y2, 0) - mktime(0, 0, 0, $m1, $d1, $y1, 0)) / 86400);
932 932
 		}
933 933
 
934
-		function date_compare($a_year,$a_month,$a_day,$b_year,$b_month,$b_day)
934
+		function date_compare($a_year, $a_month, $a_day, $b_year, $b_month, $b_day)
935 935
 		{
936
-			$a_date = mktime(0,0,0,(int)$a_month,(int)$a_day,(int)$a_year);
937
-			$b_date = mktime(0,0,0,(int)$b_month,(int)$b_day,(int)$b_year);
938
-			if($a_date == $b_date)
936
+			$a_date = mktime(0, 0, 0, (int)$a_month, (int)$a_day, (int)$a_year);
937
+			$b_date = mktime(0, 0, 0, (int)$b_month, (int)$b_day, (int)$b_year);
938
+			if ($a_date == $b_date)
939 939
 			{
940 940
 				return 0;
941 941
 			}
942
-			elseif($a_date > $b_date)
942
+			elseif ($a_date > $b_date)
943 943
 			{
944 944
 				return 1;
945 945
 			}
946
-			elseif($a_date < $b_date)
946
+			elseif ($a_date < $b_date)
947 947
 			{
948 948
 				return -1;
949 949
 			}
950 950
 		}
951 951
 
952
-		function time_compare($a_hour,$a_minute,$a_second,$b_hour,$b_minute,$b_second)
952
+		function time_compare($a_hour, $a_minute, $a_second, $b_hour, $b_minute, $b_second)
953 953
 		{
954 954
 			// I use the 1970/1/2 to compare the times, as the 1. can get via TZ-offest still
955 955
 			// before 1970/1/1, which is the earliest date allowed on windows
956
-			$a_time = mktime((int)$a_hour,(int)$a_minute,(int)$a_second,1,2,1970);
957
-			$b_time = mktime((int)$b_hour,(int)$b_minute,(int)$b_second,1,2,1970);
958
-			if($a_time == $b_time)
956
+			$a_time = mktime((int)$a_hour, (int)$a_minute, (int)$a_second, 1, 2, 1970);
957
+			$b_time = mktime((int)$b_hour, (int)$b_minute, (int)$b_second, 1, 2, 1970);
958
+			if ($a_time == $b_time)
959 959
 			{
960 960
 				return 0;
961 961
 			}
962
-			elseif($a_time > $b_time)
962
+			elseif ($a_time > $b_time)
963 963
 			{
964 964
 				return 1;
965 965
 			}
966
-			elseif($a_time < $b_time)
966
+			elseif ($a_time < $b_time)
967 967
 			{
968 968
 				return -1;
969 969
 			}
970 970
 		}
971 971
 
972
-		function makegmttime($hour,$minute,$second,$month,$day,$year)
972
+		function makegmttime($hour, $minute, $second, $month, $day, $year)
973 973
 		{
974 974
 			return $this->gmtdate(mktime($hour, $minute, $second, $month, $day, $year));
975 975
 		}
@@ -977,18 +977,18 @@  discard block
 block discarded – undo
977 977
 		// Note common:show_date converts server- to user-time, before it returns the requested format !!!
978 978
 		function localdates($localtime)
979 979
 		{
980
-			$date = Array('raw','day','month','year','full','dow','dm','bd');
980
+			$date = Array('raw', 'day', 'month', 'year', 'full', 'dow', 'dm', 'bd');
981 981
 			$date['raw'] = $localtime;
982
-			$date['year'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'Y');
983
-			$date['month'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'m');
984
-			$date['day'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'d');
985
-			$date['full'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'Ymd');
986
-			$date['bd'] = mktime(0,0,0,$date['month'],$date['day'],$date['year']);
987
-			$date['dm'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'dm');
988
-			$date['dow'] = $this->day_of_week($date['year'],$date['month'],$date['day']);
989
-			$date['hour'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'H');
990
-			$date['minute'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'i');
991
-			$date['second'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'s');
982
+			$date['year'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'Y');
983
+			$date['month'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'm');
984
+			$date['day'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'd');
985
+			$date['full'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'Ymd');
986
+			$date['bd'] = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
987
+			$date['dm'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'dm');
988
+			$date['dow'] = $this->day_of_week($date['year'], $date['month'], $date['day']);
989
+			$date['hour'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'H');
990
+			$date['minute'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 'i');
991
+			$date['second'] = (int)$GLOBALS['egw']->common->show_date($date['raw'], 's');
992 992
 
993 993
 			return $date;
994 994
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 			'GMT-8:00' => '-8:00'
561 561
 		);
562 562
 		var $tz_offset;
563
-		var $days = Array();
564
-		var $days_short = Array();
563
+		var $days = array();
564
+		var $days_short = array();
565 565
 		var $gmtnow = 0;
566 566
 		var $users_localtime;
567 567
 		var $cv_gmtdate;
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 			{
749 749
 				// Saturday is for arabic support
750 750
 				case 'Saturday':
751
-					$this->days = Array(
751
+					$this->days = array(
752 752
 						0 => 'Sat',
753 753
 						1 => 'Sun',
754 754
 						2 => 'Mon',
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 						5 => 'Thu',
758 758
 						6 => 'Fri'
759 759
 					);
760
-					$this->days_short = Array(
760
+					$this->days_short = array(
761 761
 						0 => 'Sa',
762 762
 						1 => 'Su',
763 763
 						2 => 'Mo',
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 					}
781 781
 					break;
782 782
 				case 'Monday':
783
-					$this->days = Array(
783
+					$this->days = array(
784 784
 						0 => 'Mon',
785 785
 						1 => 'Tue',
786 786
 						2 => 'Wed',
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 						5 => 'Sat',
790 790
 						6 => 'Sun'
791 791
 					);
792
-					$this->days_short = Array(
792
+					$this->days_short = array(
793 793
 						0 => 'Mo',
794 794
 						1 => 'Tu',
795 795
 						2 => 'We',
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 					break;
814 814
 				case 'Sunday':
815 815
 				default:
816
-					$this->days = Array(
816
+					$this->days = array(
817 817
 						0 => 'Sun',
818 818
 						1 => 'Mon',
819 819
 						2 => 'Tue',
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 						5 => 'Fri',
823 823
 						6 => 'Sat'
824 824
 					);
825
-					$this->days_short = Array(
825
+					$this->days_short = array(
826 826
 						0 => 'Su',
827 827
 						1 => 'Mo',
828 828
 						2 => 'Tu',
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 
852 852
 		function days_in_month($month,$year)
853 853
 		{
854
-			$days = Array(
854
+			$days = array(
855 855
 				1  => 31,
856 856
 				2  => 28 + $this->is_leap_year((int)$year),
857 857
 				3  => 31,
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 		// Note common:show_date converts server- to user-time, before it returns the requested format !!!
978 978
 		function localdates($localtime)
979 979
 		{
980
-			$date = Array('raw','day','month','year','full','dow','dm','bd');
980
+			$date = array('raw','day','month','year','full','dow','dm','bd');
981 981
 			$date['raw'] = $localtime;
982 982
 			$date['year'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'Y');
983 983
 			$date['month'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'m');
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_db.inc.php 5 patches
Doc Comments   +9 added lines, -16 removed lines patch added patch discarded remove patch
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	}
287 287
 
288 288
 	/**
289
-	* @return int current connection id
289
+	* @return ADOConnection current connection id
290 290
 	*/
291 291
 	function link_id()
292 292
 	{
@@ -692,6 +692,7 @@  discard block
 block discarded – undo
692 692
 	* Convert a unix timestamp to a rdms specific timestamp
693 693
 	*
694 694
 	* @param int unix timestamp
695
+	* @param string $epoch
695 696
 	* @return string rdms specific timestamp
696 697
 	*/
697 698
 	function to_timestamp($epoch)
@@ -945,7 +946,7 @@  discard block
 block discarded – undo
945 946
 	/**
946 947
 	* Rollback the current transaction
947 948
 	*
948
-	* @return bool True if sucessful, False if fails
949
+	* @return false|null True if sucessful, False if fails
949 950
 	*/
950 951
 	function transaction_abort()
951 952
 	{
@@ -991,7 +992,7 @@  discard block
 block discarded – undo
991 992
 	* @deprecated not used anymore as it costs to much performance, use transactions if needed
992 993
 	* @param string $table name of table to lock
993 994
 	* @param string $mode type of lock required (optional), default write
994
-	* @return bool True if sucessful, False if fails
995
+	* @return boolean|null True if sucessful, False if fails
995 996
 	*/
996 997
 	function lock($table, $mode='write')
997 998
 	{
@@ -1002,7 +1003,7 @@  discard block
 block discarded – undo
1002 1003
 	* Unlock a table
1003 1004
 	*
1004 1005
 	* @deprecated not used anymore as it costs to much performance, use transactions if needed
1005
-	* @return bool True if sucessful, False if fails
1006
+	* @return boolean|null True if sucessful, False if fails
1006 1007
 	*/
1007 1008
 	function unlock()
1008 1009
 	{}
@@ -1306,7 +1307,6 @@  discard block
 block discarded – undo
1306 1307
 	 *
1307 1308
 	 * Example: $db->concat($db->quote('Hallo '),'username') would return
1308 1309
 	 *	for mysql "concat('Hallo ',username)" or "'Hallo ' || username" for postgres
1309
-	 * @param string $str1 already quoted stringliteral or column-name, variable number of arguments
1310 1310
 	 * @return string to be used in a query
1311 1311
 	 */
1312 1312
 	function concat(/*$str1, ...*/)
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 	 * @param string $expr column-name or expression optional prefixed with "DISTINCT"
1327 1327
 	 * @param string $order_by ='' optional order
1328 1328
 	 * @param string $separator =',' optional separator, default is comma
1329
-	 * @return string|boolean false if not supported by dbms
1329
+	 * @return false|string false if not supported by dbms
1330 1330
 	 */
1331 1331
 	function group_concat($expr, $order_by='', $separator=',')
1332 1332
 	{
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 	*	array('visits=visits+1') gives just "visits=visits+1" (no quoting at all !!!)
1659 1659
 	* @param boolean|string $use_key If $use_key===True a "$key=" prefix each value (default), typically set to False
1660 1660
 	*	or 'VALUES' for insert querys, on 'VALUES' "(key1,key2,...) VALUES (val1,val2,...)" is returned
1661
-	* @param array|boolean $only if set to an array only colums which are set (as data !!!) are written
1661
+	* @param boolean $only if set to an array only colums which are set (as data !!!) are written
1662 1662
 	*	typicaly used to form a WHERE-clause from the primary keys.
1663 1663
 	*	If set to True, only columns from the colum_definitons are written.
1664 1664
 	* @param array|boolean $column_definitions this can be set to the column-definitions-array
@@ -2133,13 +2133,6 @@  discard block
 block discarded – undo
2133 2133
 	 * gives "(name='test\'ed' AND lang='en') OR 'owner' IN (0,4,5,6,10)" if name,lang are strings and owner is an integer
2134 2134
 	 *
2135 2135
 	 * @param string|array $table_def table-name or definition array
2136
-	 * @param mixed $args variable number of arguments of the following types:
2137
-	 *	string: get's as is into the result
2138
-	 *	array:	column-name / value pairs: the value gets quoted according to the type of the column and prefixed
2139
-	 *		with column-name=, multiple pairs are AND'ed together, see db::column_data_implode
2140
-	 *	bool: If False or is_null($arg): the next 2 (!) arguments gets ignored
2141
-	 *
2142
-	 * Please note: As the function has a variable number of arguments, you CAN NOT add further parameters !!!
2143 2136
 	 *
2144 2137
 	 * @return string the expression generated from the arguments
2145 2138
 	 */
@@ -2277,7 +2270,7 @@  discard block
 block discarded – undo
2277 2270
 	 * Strip eg. a prefix from the keys of an array
2278 2271
 	 *
2279 2272
 	 * @param array $arr
2280
-	 * @param string|array $strip
2273
+	 * @param string $strip
2281 2274
 	 * @return array
2282 2275
 	 */
2283 2276
 	static function strip_array_keys($arr,$strip)
@@ -2373,7 +2366,7 @@  discard block
 block discarded – undo
2373 2366
 	 * @param Traversable $rs
2374 2367
 	 * @param callback $callback
2375 2368
 	 * @param array $params =array() additional parameters, row is always first parameter
2376
-	 * @param $key_callback =null optional callback, if you want different keys
2369
+	 * @param Closure $key_callback =null optional callback, if you want different keys
2377 2370
 	 */
2378 2371
 	public function __construct(Traversable $rs, $callback, $params=array(), $key_callback=null)
2379 2372
 	{
Please login to merge, or discard this patch.
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -68,43 +68,43 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	const FETCH_BOTH = ADODB_FETCH_BOTH;
70 70
 	/**
71
-	* @var string $type translated database type: mysqlt+mysqli ==> mysql, same for odbc-types
72
-	*/
71
+	 * @var string $type translated database type: mysqlt+mysqli ==> mysql, same for odbc-types
72
+	 */
73 73
 	var $Type     = '';
74 74
 
75 75
 	/**
76
-	* @var string $type database type as defined in the header.inc.php, eg. mysqlt
77
-	*/
76
+	 * @var string $type database type as defined in the header.inc.php, eg. mysqlt
77
+	 */
78 78
 	var $setupType     = '';
79 79
 
80 80
 	/**
81
-	* @var string $Host database host to connect to
82
-	*/
81
+	 * @var string $Host database host to connect to
82
+	 */
83 83
 	var $Host     = '';
84 84
 
85 85
 	/**
86
-	* @var string $Port port number of database to connect to
87
-	*/
86
+	 * @var string $Port port number of database to connect to
87
+	 */
88 88
 	var $Port     = '';
89 89
 
90 90
 	/**
91
-	* @var string $Database name of database to use
92
-	*/
91
+	 * @var string $Database name of database to use
92
+	 */
93 93
 	var $Database = '';
94 94
 
95 95
 	/**
96
-	* @var string $User name of database user
97
-	*/
96
+	 * @var string $User name of database user
97
+	 */
98 98
 	var $User     = '';
99 99
 
100 100
 	/**
101
-	* @var string $Password password for database user
102
-	*/
101
+	 * @var string $Password password for database user
102
+	 */
103 103
 	var $Password = '';
104 104
 
105 105
 	/**
106
-	* @var int $Debug enable debuging - 0 no, 1 yes
107
-	*/
106
+	 * @var int $Debug enable debuging - 0 no, 1 yes
107
+	 */
108 108
 	var $Debug         = 0;
109 109
 
110 110
 	/**
@@ -115,23 +115,23 @@  discard block
 block discarded – undo
115 115
 	var $log_updates = false;
116 116
 
117 117
 	/**
118
-	* @var array $Record current record
119
-	*/
118
+	 * @var array $Record current record
119
+	 */
120 120
 	var $Record   = array();
121 121
 
122 122
 	/**
123
-	* @var int row number for current record
124
-	*/
123
+	 * @var int row number for current record
124
+	 */
125 125
 	var $Row;
126 126
 
127 127
 	/**
128
-	* @var int $Errno internal rdms error number for last error
129
-	*/
128
+	 * @var int $Errno internal rdms error number for last error
129
+	 */
130 130
 	var $Errno    = 0;
131 131
 
132 132
 	/**
133
-	* @var string descriptive text from last error
134
-	*/
133
+	 * @var string descriptive text from last error
134
+	 */
135 135
 	var $Error    = '';
136 136
 
137 137
 	/**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	}
278 278
 
279 279
 	/**
280
-	* @param string $query query to be executed (optional)
281
-	*/
280
+	 * @param string $query query to be executed (optional)
281
+	 */
282 282
 
283 283
 	function db($query = '')
284 284
 	{
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	}
287 287
 
288 288
 	/**
289
-	* @return int current connection id
290
-	*/
289
+	 * @return int current connection id
290
+	 */
291 291
 	function link_id()
292 292
 	{
293 293
 		return $this->Link_ID;
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
 	}
655 655
 
656 656
 	/**
657
-	* Close a connection to a database
658
-	*/
657
+	 * Close a connection to a database
658
+	 */
659 659
 	function disconnect()
660 660
 	{
661 661
 		if (!$this->privat_Link_ID)
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
 	}
670 670
 
671 671
 	/**
672
-	* Escape strings before sending them to the database
673
-	*
674
-	* @deprecated use quote($value,$type='') instead
675
-	* @param string $str the string to be escaped
676
-	* @return string escaped sting
677
-	*/
672
+	 * Escape strings before sending them to the database
673
+	 *
674
+	 * @deprecated use quote($value,$type='') instead
675
+	 * @param string $str the string to be escaped
676
+	 * @return string escaped sting
677
+	 */
678 678
 	function db_addslashes($str)
679 679
 	{
680 680
 		if (!isset($str) || $str == '')
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
 	}
690 690
 
691 691
 	/**
692
-	* Convert a unix timestamp to a rdms specific timestamp
693
-	*
694
-	* @param int unix timestamp
695
-	* @return string rdms specific timestamp
696
-	*/
692
+	 * Convert a unix timestamp to a rdms specific timestamp
693
+	 *
694
+	 * @param int unix timestamp
695
+	 * @return string rdms specific timestamp
696
+	 */
697 697
 	function to_timestamp($epoch)
698 698
 	{
699 699
 		if (!$this->Link_ID && !$this->connect())
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
 	}
706 706
 
707 707
 	/**
708
-	* Convert a rdms specific timestamp to a unix timestamp
709
-	*
710
-	* @param string rdms specific timestamp
711
-	* @return int unix timestamp
712
-	*/
708
+	 * Convert a rdms specific timestamp to a unix timestamp
709
+	 *
710
+	 * @param string rdms specific timestamp
711
+	 * @return int unix timestamp
712
+	 */
713 713
 	function from_timestamp($timestamp)
714 714
 	{
715 715
 		if (!$this->Link_ID && !$this->connect())
@@ -742,19 +742,19 @@  discard block
 block discarded – undo
742 742
 	}
743 743
 
744 744
 	/**
745
-	* Execute a query
746
-	*
747
-	* @param string $Query_String the query to be executed
748
-	* @param int $line the line method was called from - use __LINE__
749
-	* @param string $file the file method was called from - use __FILE__
750
-	* @param int $offset row to start from, default 0
751
-	* @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']
752
-	* @param array|boolean $inputarr array for binding variables to parameters or false (default)
753
-	* @param int $fetchmode =egw_db::FETCH_BOTH egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
754
-	* @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!)
755
-	* @return ADORecordSet or false, if the query fails
756
-	* @throws egw_exception_db_invalid_sql with $this->Link_ID->ErrorNo() as code
757
-	*/
745
+	 * Execute a query
746
+	 *
747
+	 * @param string $Query_String the query to be executed
748
+	 * @param int $line the line method was called from - use __LINE__
749
+	 * @param string $file the file method was called from - use __FILE__
750
+	 * @param int $offset row to start from, default 0
751
+	 * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']
752
+	 * @param array|boolean $inputarr array for binding variables to parameters or false (default)
753
+	 * @param int $fetchmode =egw_db::FETCH_BOTH egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
754
+	 * @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!)
755
+	 * @return ADORecordSet or false, if the query fails
756
+	 * @throws egw_exception_db_invalid_sql with $this->Link_ID->ErrorNo() as code
757
+	 */
758 758
 	function query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=egw_db::FETCH_BOTH, $reconnect=true)
759 759
 	{
760 760
 		unset($line, $file);	// not used anymore
@@ -824,30 +824,30 @@  discard block
 block discarded – undo
824 824
 	}
825 825
 
826 826
 	/**
827
-	* Execute a query with limited result set
828
-	*
829
-	* @param string $Query_String the query to be executed
830
-	* @param int $offset row to start from, default 0
831
-	* @param int $line the line method was called from - use __LINE__
832
-	* @param string $file the file method was called from - use __FILE__
833
-	* @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']
834
-	* @param array|boolean $inputarr array for binding variables to parameters or false (default)
835
-	* @return ADORecordSet or false, if the query fails
836
-	*/
827
+	 * Execute a query with limited result set
828
+	 *
829
+	 * @param string $Query_String the query to be executed
830
+	 * @param int $offset row to start from, default 0
831
+	 * @param int $line the line method was called from - use __LINE__
832
+	 * @param string $file the file method was called from - use __FILE__
833
+	 * @param int $num_rows number of rows to return (optional), default -1 = all, 0 will use $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']
834
+	 * @param array|boolean $inputarr array for binding variables to parameters or false (default)
835
+	 * @return ADORecordSet or false, if the query fails
836
+	 */
837 837
 	function limit_query($Query_String, $offset, $line = '', $file = '', $num_rows = '',$inputarr=false)
838 838
 	{
839 839
 		return $this->query($Query_String,$line,$file,$offset,$num_rows,$inputarr);
840 840
 	}
841 841
 
842 842
 	/**
843
-	* Move to the next row in the results set
844
-	*
845
-	* Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!!
846
-	*
847
-	* @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object
848
-	* @param int $fetch_mode egw_db::FETCH_BOTH = numerical+assoc keys (eGW default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
849
-	* @return bool was another row found?
850
-	*/
843
+	 * Move to the next row in the results set
844
+	 *
845
+	 * Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!!
846
+	 *
847
+	 * @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object
848
+	 * @param int $fetch_mode egw_db::FETCH_BOTH = numerical+assoc keys (eGW default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
849
+	 * @return bool was another row found?
850
+	 */
851 851
 	function next_record($fetch_mode=egw_db::FETCH_BOTH)
852 852
 	{
853 853
 		if (!$this->Query_ID)
@@ -897,12 +897,12 @@  discard block
 block discarded – undo
897 897
 	}
898 898
 
899 899
 	/**
900
-	* Move to position in result set
901
-	*
902
-	* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
903
-	* @param int $pos required row (optional), default first row
904
-	* @return boolean true if sucessful or false if not found
905
-	*/
900
+	 * Move to position in result set
901
+	 *
902
+	 * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
903
+	 * @param int $pos required row (optional), default first row
904
+	 * @return boolean true if sucessful or false if not found
905
+	 */
906 906
 	function seek($pos = 0)
907 907
 	{
908 908
 		if (!$this->Query_ID  || !$this->Query_ID->Move($this->Row = $pos))
@@ -913,10 +913,10 @@  discard block
 block discarded – undo
913 913
 	}
914 914
 
915 915
 	/**
916
-	* Begin Transaction
917
-	*
918
-	* @return int/boolean current transaction-id, of false if no connection
919
-	*/
916
+	 * Begin Transaction
917
+	 *
918
+	 * @return int/boolean current transaction-id, of false if no connection
919
+	 */
920 920
 	function transaction_begin()
921 921
 	{
922 922
 		if (!$this->Link_ID && !$this->connect())
@@ -928,10 +928,10 @@  discard block
 block discarded – undo
928 928
 	}
929 929
 
930 930
 	/**
931
-	* Complete the transaction
932
-	*
933
-	* @return bool True if sucessful, False if fails
934
-	*/
931
+	 * Complete the transaction
932
+	 *
933
+	 * @return bool True if sucessful, False if fails
934
+	 */
935 935
 	function transaction_commit()
936 936
 	{
937 937
 		if (!$this->Link_ID && !$this->connect())
@@ -943,10 +943,10 @@  discard block
 block discarded – undo
943 943
 	}
944 944
 
945 945
 	/**
946
-	* Rollback the current transaction
947
-	*
948
-	* @return bool True if sucessful, False if fails
949
-	*/
946
+	 * Rollback the current transaction
947
+	 *
948
+	 * @return bool True if sucessful, False if fails
949
+	 */
950 950
 	function transaction_abort()
951 951
 	{
952 952
 		if (!$this->Link_ID && !$this->connect())
@@ -958,12 +958,12 @@  discard block
 block discarded – undo
958 958
 	}
959 959
 
960 960
 	/**
961
-	* Find the primary key of the last insertion on the current db connection
962
-	*
963
-	* @param string $table name of table the insert was performed on
964
-	* @param string $field the autoincrement primary key of the table
965
-	* @return int the id, -1 if fails
966
-	*/
961
+	 * Find the primary key of the last insertion on the current db connection
962
+	 *
963
+	 * @param string $table name of table the insert was performed on
964
+	 * @param string $field the autoincrement primary key of the table
965
+	 * @return int the id, -1 if fails
966
+	 */
967 967
 	function get_last_insert_id($table, $field)
968 968
 	{
969 969
 		if (!$this->Link_ID && !$this->connect())
@@ -986,32 +986,32 @@  discard block
 block discarded – undo
986 986
 	}
987 987
 
988 988
 	/**
989
-	* Lock a table
990
-	*
991
-	* @deprecated not used anymore as it costs to much performance, use transactions if needed
992
-	* @param string $table name of table to lock
993
-	* @param string $mode type of lock required (optional), default write
994
-	* @return bool True if sucessful, False if fails
995
-	*/
989
+	 * Lock a table
990
+	 *
991
+	 * @deprecated not used anymore as it costs to much performance, use transactions if needed
992
+	 * @param string $table name of table to lock
993
+	 * @param string $mode type of lock required (optional), default write
994
+	 * @return bool True if sucessful, False if fails
995
+	 */
996 996
 	function lock($table, $mode='write')
997 997
 	{
998 998
 		unset($table, $mode);	// not used anymore
999 999
 	}
1000 1000
 
1001 1001
 	/**
1002
-	* Unlock a table
1003
-	*
1004
-	* @deprecated not used anymore as it costs to much performance, use transactions if needed
1005
-	* @return bool True if sucessful, False if fails
1006
-	*/
1002
+	 * Unlock a table
1003
+	 *
1004
+	 * @deprecated not used anymore as it costs to much performance, use transactions if needed
1005
+	 * @return bool True if sucessful, False if fails
1006
+	 */
1007 1007
 	function unlock()
1008 1008
 	{}
1009 1009
 
1010 1010
 	/**
1011
-	* Get the number of rows affected by last update or delete
1012
-	*
1013
-	* @return int number of rows
1014
-	*/
1011
+	 * Get the number of rows affected by last update or delete
1012
+	 *
1013
+	 * @return int number of rows
1014
+	 */
1015 1015
 	function affected_rows()
1016 1016
 	{
1017 1017
 		if ($this->log_updates) return 0;
@@ -1024,52 +1024,52 @@  discard block
 block discarded – undo
1024 1024
 	}
1025 1025
 
1026 1026
 	/**
1027
-	* Number of rows in current result set
1028
-	*
1029
-	* @deprecated use the result-object returned by query/select()->NumRows(), so you can use the global db-object and not a clone
1030
-	* @return int number of rows
1031
-	*/
1027
+	 * Number of rows in current result set
1028
+	 *
1029
+	 * @deprecated use the result-object returned by query/select()->NumRows(), so you can use the global db-object and not a clone
1030
+	 * @return int number of rows
1031
+	 */
1032 1032
 	function num_rows()
1033 1033
 	{
1034 1034
 		return $this->Query_ID ? $this->Query_ID->RecordCount() : False;
1035 1035
 	}
1036 1036
 
1037 1037
 	/**
1038
-	* Number of fields in current row
1039
-	*
1040
-	* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
1041
-	* @return int number of fields
1042
-	*/
1038
+	 * Number of fields in current row
1039
+	 *
1040
+	 * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
1041
+	 * @return int number of fields
1042
+	 */
1043 1043
 	function num_fields()
1044 1044
 	{
1045 1045
 		return $this->Query_ID ? $this->Query_ID->FieldCount() : False;
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
1049
-	* @deprecated use num_rows()
1050
-	*/
1049
+	 * @deprecated use num_rows()
1050
+	 */
1051 1051
 	function nf()
1052 1052
 	{
1053 1053
 		return $this->num_rows();
1054 1054
 	}
1055 1055
 
1056 1056
 	/**
1057
-	* @deprecated use print num_rows()
1058
-	*/
1057
+	 * @deprecated use print num_rows()
1058
+	 */
1059 1059
 	function np()
1060 1060
 	{
1061 1061
 		print $this->num_rows();
1062 1062
 	}
1063 1063
 
1064 1064
 	/**
1065
-	* Return the value of a column
1066
-	*
1067
-	* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
1068
-	* @param string|integer $Name name of field or positional index starting from 0
1069
-	* @param bool $strip_slashes string escape chars from field(optional), default false
1070
-	*	depricated param, as correctly quoted values dont need any stripslashes!
1071
-	* @return string the field value
1072
-	*/
1065
+	 * Return the value of a column
1066
+	 *
1067
+	 * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
1068
+	 * @param string|integer $Name name of field or positional index starting from 0
1069
+	 * @param bool $strip_slashes string escape chars from field(optional), default false
1070
+	 *	depricated param, as correctly quoted values dont need any stripslashes!
1071
+	 * @return string the field value
1072
+	 */
1073 1073
 	function f($Name, $strip_slashes = False)
1074 1074
 	{
1075 1075
 		if ($strip_slashes)
@@ -1080,25 +1080,25 @@  discard block
 block discarded – undo
1080 1080
 	}
1081 1081
 
1082 1082
 	/**
1083
-	* Print the value of a field
1084
-	*
1085
-	* @param string $Name name of field to print
1086
-	* @param bool $strip_slashes string escape chars from field(optional), default false
1087
-	*	depricated param, as correctly quoted values dont need any stripslashes!
1088
-	*/
1083
+	 * Print the value of a field
1084
+	 *
1085
+	 * @param string $Name name of field to print
1086
+	 * @param bool $strip_slashes string escape chars from field(optional), default false
1087
+	 *	depricated param, as correctly quoted values dont need any stripslashes!
1088
+	 */
1089 1089
 	function p($Name, $strip_slashes = True)
1090 1090
 	{
1091 1091
 		print $this->f($Name, $strip_slashes);
1092 1092
 	}
1093 1093
 
1094 1094
 	/**
1095
-	* Returns a query-result-row as an associative array (no numerical keys !!!)
1096
-	*
1097
-	* @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object
1098
-	* @param bool $do_next_record should next_record() be called or not (default not)
1099
-	* @param string $strip ='' string to strip of the column-name, default ''
1100
-	* @return array/bool the associative array or False if no (more) result-row is availible
1101
-	*/
1095
+	 * Returns a query-result-row as an associative array (no numerical keys !!!)
1096
+	 *
1097
+	 * @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object
1098
+	 * @param bool $do_next_record should next_record() be called or not (default not)
1099
+	 * @param string $strip ='' string to strip of the column-name, default ''
1100
+	 * @return array/bool the associative array or False if no (more) result-row is availible
1101
+	 */
1102 1102
 	function row($do_next_record=False,$strip='')
1103 1103
 	{
1104 1104
 		if ($do_next_record && !$this->next_record(egw_db::FETCH_ASSOC) || !is_array($this->Record))
@@ -1119,14 +1119,14 @@  discard block
 block discarded – undo
1119 1119
 	}
1120 1120
 
1121 1121
 	/**
1122
-	* Get description of a table
1123
-	*
1124
-	* Beside the column-name all other data depends on the db-type !!!
1125
-	*
1126
-	* @param string $table name of table to describe
1127
-	* @param bool $full optional, default False summary information, True full information
1128
-	* @return array table meta data
1129
-	*/
1122
+	 * Get description of a table
1123
+	 *
1124
+	 * Beside the column-name all other data depends on the db-type !!!
1125
+	 *
1126
+	 * @param string $table name of table to describe
1127
+	 * @param bool $full optional, default False summary information, True full information
1128
+	 * @return array table meta data
1129
+	 */
1130 1130
 	function metadata($table='',$full=false)
1131 1131
 	{
1132 1132
 		if (!$this->Link_ID && !$this->connect())
@@ -1208,10 +1208,10 @@  discard block
 block discarded – undo
1208 1208
 	}
1209 1209
 
1210 1210
 	/**
1211
-	* Return a list of indexes in current database
1212
-	*
1213
-	* @return array list of indexes
1214
-	*/
1211
+	 * Return a list of indexes in current database
1212
+	 *
1213
+	 * @return array list of indexes
1214
+	 */
1215 1215
 	function index_names()
1216 1216
 	{
1217 1217
 		$indices = array();
@@ -1233,10 +1233,10 @@  discard block
 block discarded – undo
1233 1233
 	}
1234 1234
 
1235 1235
 	/**
1236
-	* Returns an array containing column names that are the primary keys of $tablename.
1237
-	*
1238
-	* @return array of columns
1239
-	*/
1236
+	 * Returns an array containing column names that are the primary keys of $tablename.
1237
+	 *
1238
+	 * @return array of columns
1239
+	 */
1240 1240
 	function pkey_columns($tablename)
1241 1241
 	{
1242 1242
 		if (!$this->Link_ID && !$this->connect())
@@ -1247,13 +1247,13 @@  discard block
 block discarded – undo
1247 1247
 	}
1248 1248
 
1249 1249
 	/**
1250
-	* Create a new database
1251
-	*
1252
-	* @param string $adminname name of database administrator user (optional)
1253
-	* @param string $adminpasswd password for the database administrator user (optional)
1254
-	* @param string $charset default charset for the database
1255
-	* @param string $grant_host ='localhost' host/ip of the webserver
1256
-	*/
1250
+	 * Create a new database
1251
+	 *
1252
+	 * @param string $adminname name of database administrator user (optional)
1253
+	 * @param string $adminpasswd password for the database administrator user (optional)
1254
+	 * @param string $charset default charset for the database
1255
+	 * @param string $grant_host ='localhost' host/ip of the webserver
1256
+	 */
1257 1257
 	function create_database($adminname = '', $adminpasswd = '', $charset='', $grant_host='localhost')
1258 1258
 	{
1259 1259
 		$currentUser = $this->User;
@@ -1509,12 +1509,12 @@  discard block
 block discarded – undo
1509 1509
 	}
1510 1510
 
1511 1511
 	/**
1512
-	* Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements
1513
-	*
1514
-	* This is mostly copy & paste from adodb's datadict class
1515
-	* @param string $_name
1516
-	* @return string quoted string
1517
-	*/
1512
+	 * Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements
1513
+	 *
1514
+	 * This is mostly copy & paste from adodb's datadict class
1515
+	 * @param string $_name
1516
+	 * @return string quoted string
1517
+	 */
1518 1518
 	function name_quote($_name = NULL)
1519 1519
 	{
1520 1520
 		if (!is_string($_name))
@@ -1553,19 +1553,19 @@  discard block
 block discarded – undo
1553 1553
 	}
1554 1554
 
1555 1555
 	/**
1556
-	* Escape values before sending them to the database - prevents SQL injection and SQL errors ;-)
1557
-	*
1558
-	* Please note that the quote function already returns necessary quotes: quote('Hello') === "'Hello'".
1559
-	* Int and Auto types are casted to int: quote('1','int') === 1, quote('','int') === 0, quote('Hello','int') === 0
1560
-	* Arrays of id's stored in strings: quote(array(1,2,3),'string') === "'1,2,3'"
1561
-	*
1562
-	* @param mixed $value the value to be escaped
1563
-	* @param string|boolean $type =false string the type of the db-column, default False === varchar
1564
-	* @param boolean $not_null =true is column NOT NULL, default true, else php null values are written as SQL NULL
1565
-	* @param int $length =null length of the varchar column, to truncate it if the database requires it (eg. Postgres)
1566
-	* @param string $glue =',' used to glue array values together for the string type
1567
-	* @return string escaped sting
1568
-	*/
1556
+	 * Escape values before sending them to the database - prevents SQL injection and SQL errors ;-)
1557
+	 *
1558
+	 * Please note that the quote function already returns necessary quotes: quote('Hello') === "'Hello'".
1559
+	 * Int and Auto types are casted to int: quote('1','int') === 1, quote('','int') === 0, quote('Hello','int') === 0
1560
+	 * Arrays of id's stored in strings: quote(array(1,2,3),'string') === "'1,2,3'"
1561
+	 *
1562
+	 * @param mixed $value the value to be escaped
1563
+	 * @param string|boolean $type =false string the type of the db-column, default False === varchar
1564
+	 * @param boolean $not_null =true is column NOT NULL, default true, else php null values are written as SQL NULL
1565
+	 * @param int $length =null length of the varchar column, to truncate it if the database requires it (eg. Postgres)
1566
+	 * @param string $glue =',' used to glue array values together for the string type
1567
+	 * @return string escaped sting
1568
+	 */
1569 1569
 	function quote($value,$type=False,$not_null=true,$length=null,$glue=',')
1570 1570
 	{
1571 1571
 		if ($this->Debug) echo "<p>db::quote(".(is_null($value)?'NULL':"'$value'").",'$type','$not_null')</p>\n";
@@ -1645,27 +1645,27 @@  discard block
 block discarded – undo
1645 1645
 	}
1646 1646
 
1647 1647
 	/**
1648
-	* Implodes an array of column-value pairs for the use in sql-querys.
1649
-	* All data is run through quote (does either addslashes() or (int)) - prevents SQL injunction and SQL errors ;-).
1650
-	*
1651
-	* @author RalfBecker<at>outdoor-training.de
1652
-	*
1653
-	* @param string $glue in most cases this will be either ',' or ' AND ', depending you your query
1654
-	* @param array $array column-name / value pairs, if the value is an array all its array-values will be quoted
1655
-	*	according to the type of the column, and the whole array with be formatted like (val1,val2,...)
1656
-	*	If $use_key == True, an ' IN ' instead a '=' is used. Good for category- or user-lists.
1657
-	*	If the key is numerical (no key given in the array-definition) the value is used as is, eg.
1658
-	*	array('visits=visits+1') gives just "visits=visits+1" (no quoting at all !!!)
1659
-	* @param boolean|string $use_key If $use_key===True a "$key=" prefix each value (default), typically set to False
1660
-	*	or 'VALUES' for insert querys, on 'VALUES' "(key1,key2,...) VALUES (val1,val2,...)" is returned
1661
-	* @param array|boolean $only if set to an array only colums which are set (as data !!!) are written
1662
-	*	typicaly used to form a WHERE-clause from the primary keys.
1663
-	*	If set to True, only columns from the colum_definitons are written.
1664
-	* @param array|boolean $column_definitions this can be set to the column-definitions-array
1665
-	*	of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
1666
-	*	If its set, the column-type-data determinates if (int) or addslashes is used.
1667
-	* @return string SQL
1668
-	*/
1648
+	 * Implodes an array of column-value pairs for the use in sql-querys.
1649
+	 * All data is run through quote (does either addslashes() or (int)) - prevents SQL injunction and SQL errors ;-).
1650
+	 *
1651
+	 * @author RalfBecker<at>outdoor-training.de
1652
+	 *
1653
+	 * @param string $glue in most cases this will be either ',' or ' AND ', depending you your query
1654
+	 * @param array $array column-name / value pairs, if the value is an array all its array-values will be quoted
1655
+	 *	according to the type of the column, and the whole array with be formatted like (val1,val2,...)
1656
+	 *	If $use_key == True, an ' IN ' instead a '=' is used. Good for category- or user-lists.
1657
+	 *	If the key is numerical (no key given in the array-definition) the value is used as is, eg.
1658
+	 *	array('visits=visits+1') gives just "visits=visits+1" (no quoting at all !!!)
1659
+	 * @param boolean|string $use_key If $use_key===True a "$key=" prefix each value (default), typically set to False
1660
+	 *	or 'VALUES' for insert querys, on 'VALUES' "(key1,key2,...) VALUES (val1,val2,...)" is returned
1661
+	 * @param array|boolean $only if set to an array only colums which are set (as data !!!) are written
1662
+	 *	typicaly used to form a WHERE-clause from the primary keys.
1663
+	 *	If set to True, only columns from the colum_definitons are written.
1664
+	 * @param array|boolean $column_definitions this can be set to the column-definitions-array
1665
+	 *	of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
1666
+	 *	If its set, the column-type-data determinates if (int) or addslashes is used.
1667
+	 * @return string SQL
1668
+	 */
1669 1669
 	function column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False)
1670 1670
 	{
1671 1671
 		if (!is_array($array))	// this allows to give an SQL-string for delete or update
@@ -1751,14 +1751,14 @@  discard block
 block discarded – undo
1751 1751
 	}
1752 1752
 
1753 1753
 	/**
1754
-	* Sets the default column-definitions for use with column_data_implode()
1755
-	*
1756
-	* @author RalfBecker<at>outdoor-training.de
1757
-	*
1758
-	* @param array|boolean $column_definitions this can be set to the column-definitions-array
1759
-	*	of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
1760
-	*	If its set, the column-type-data determinates if (int) or addslashes is used.
1761
-	*/
1754
+	 * Sets the default column-definitions for use with column_data_implode()
1755
+	 *
1756
+	 * @author RalfBecker<at>outdoor-training.de
1757
+	 *
1758
+	 * @param array|boolean $column_definitions this can be set to the column-definitions-array
1759
+	 *	of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
1760
+	 *	If its set, the column-type-data determinates if (int) or addslashes is used.
1761
+	 */
1762 1762
 	function set_column_definitions($column_definitions=False)
1763 1763
 	{
1764 1764
 		$this->column_definitions=$column_definitions;
@@ -1795,17 +1795,17 @@  discard block
 block discarded – undo
1795 1795
 	}
1796 1796
 
1797 1797
 	/**
1798
-	* reads the table-definitions from the app's setup/tables_current.inc.php file
1799
-	*
1800
-	* The already read table-definitions are shared between all db-instances via a static var.
1801
-	*
1802
-	* @author RalfBecker<at>outdoor-training.de
1803
-	*
1804
-	* @param bool|string $app name of the app or default False to use the app set by db::set_app or the current app,
1805
-	*	true to search the already loaded table-definitions for $table and then search all existing apps for it
1806
-	* @param bool|string $table if set return only defintions of that table, else return all defintions
1807
-	* @return mixed array with table-defintions or False if file not found
1808
-	*/
1798
+	 * reads the table-definitions from the app's setup/tables_current.inc.php file
1799
+	 *
1800
+	 * The already read table-definitions are shared between all db-instances via a static var.
1801
+	 *
1802
+	 * @author RalfBecker<at>outdoor-training.de
1803
+	 *
1804
+	 * @param bool|string $app name of the app or default False to use the app set by db::set_app or the current app,
1805
+	 *	true to search the already loaded table-definitions for $table and then search all existing apps for it
1806
+	 * @param bool|string $table if set return only defintions of that table, else return all defintions
1807
+	 * @return mixed array with table-defintions or False if file not found
1808
+	 */
1809 1809
 	function get_table_definitions($app=False,$table=False)
1810 1810
 	{
1811 1811
 		static $all_app_data = array();
@@ -1898,21 +1898,21 @@  discard block
 block discarded – undo
1898 1898
 	}
1899 1899
 
1900 1900
 	/**
1901
-	* Insert a row of data into a table or updates it if $where is given, all data is quoted according to it's type
1902
-	*
1903
-	* @author RalfBecker<at>outdoor-training.de
1904
-	*
1905
-	* @param string $table name of the table
1906
-	* @param array $data with column-name / value pairs
1907
-	* @param mixed $where string with where clause or array with column-name / values pairs to check if a row with that keys already exists, or false for an unconditional insert
1908
-	*	if the row exists db::update is called else a new row with $date merged with $where gets inserted (data has precedence)
1909
-	* @param int $line line-number to pass to query
1910
-	* @param string $file file-name to pass to query
1911
-	* @param string|boolean $app string with name of app or False to use the current-app
1912
-	* @param bool $use_prepared_statement use a prepared statement
1913
-	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
1914
-	* @return ADORecordSet or false, if the query fails
1915
-	*/
1901
+	 * Insert a row of data into a table or updates it if $where is given, all data is quoted according to it's type
1902
+	 *
1903
+	 * @author RalfBecker<at>outdoor-training.de
1904
+	 *
1905
+	 * @param string $table name of the table
1906
+	 * @param array $data with column-name / value pairs
1907
+	 * @param mixed $where string with where clause or array with column-name / values pairs to check if a row with that keys already exists, or false for an unconditional insert
1908
+	 *	if the row exists db::update is called else a new row with $date merged with $where gets inserted (data has precedence)
1909
+	 * @param int $line line-number to pass to query
1910
+	 * @param string $file file-name to pass to query
1911
+	 * @param string|boolean $app string with name of app or False to use the current-app
1912
+	 * @param bool $use_prepared_statement use a prepared statement
1913
+	 * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
1914
+	 * @return ADORecordSet or false, if the query fails
1915
+	 */
1916 1916
 	function insert($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False)
1917 1917
 	{
1918 1918
 		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app')</p>\n";
@@ -2009,20 +2009,20 @@  discard block
 block discarded – undo
2009 2009
 	}
2010 2010
 
2011 2011
 	/**
2012
-	* Updates the data of one or more rows in a table, all data is quoted according to it's type
2013
-	*
2014
-	* @author RalfBecker<at>outdoor-training.de
2015
-	*
2016
-	* @param string $table name of the table
2017
-	* @param array $data with column-name / value pairs
2018
-	* @param array $where column-name / values pairs and'ed together for the where clause
2019
-	* @param int $line line-number to pass to query
2020
-	* @param string $file file-name to pass to query
2021
-	* @param string|boolean $app string with name of app or False to use the current-app
2022
-	* @param bool $use_prepared_statement use a prepared statement
2023
-	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2024
-	* @return ADORecordSet or false, if the query fails
2025
-	*/
2012
+	 * Updates the data of one or more rows in a table, all data is quoted according to it's type
2013
+	 *
2014
+	 * @author RalfBecker<at>outdoor-training.de
2015
+	 *
2016
+	 * @param string $table name of the table
2017
+	 * @param array $data with column-name / value pairs
2018
+	 * @param array $where column-name / values pairs and'ed together for the where clause
2019
+	 * @param int $line line-number to pass to query
2020
+	 * @param string $file file-name to pass to query
2021
+	 * @param string|boolean $app string with name of app or False to use the current-app
2022
+	 * @param bool $use_prepared_statement use a prepared statement
2023
+	 * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2024
+	 * @return ADORecordSet or false, if the query fails
2025
+	 */
2026 2026
 	function update($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False)
2027 2027
 	{
2028 2028
 		if ($this->Debug) echo "<p>db::update('$table',".print_r($data,true).','.print_r($where,true).",$line,$file,'$app')</p>\n";
@@ -2099,18 +2099,18 @@  discard block
 block discarded – undo
2099 2099
 	}
2100 2100
 
2101 2101
 	/**
2102
-	* Deletes one or more rows in table, all data is quoted according to it's type
2103
-	*
2104
-	* @author RalfBecker<at>outdoor-training.de
2105
-	*
2106
-	* @param string $table name of the table
2107
-	* @param array $where column-name / values pairs and'ed together for the where clause
2108
-	* @param int $line line-number to pass to query
2109
-	* @param string $file file-name to pass to query
2110
-	* @param string|boolean $app string with name of app or False to use the current-app
2111
-	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2112
-	* @return ADORecordSet or false, if the query fails
2113
-	*/
2102
+	 * Deletes one or more rows in table, all data is quoted according to it's type
2103
+	 *
2104
+	 * @author RalfBecker<at>outdoor-training.de
2105
+	 *
2106
+	 * @param string $table name of the table
2107
+	 * @param array $where column-name / values pairs and'ed together for the where clause
2108
+	 * @param int $line line-number to pass to query
2109
+	 * @param string $file file-name to pass to query
2110
+	 * @param string|boolean $app string with name of app or False to use the current-app
2111
+	 * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2112
+	 * @return ADORecordSet or false, if the query fails
2113
+	 */
2114 2114
 	function delete($table,$where,$line,$file,$app=False,$table_def=False)
2115 2115
 	{
2116 2116
 		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
@@ -2176,25 +2176,25 @@  discard block
 block discarded – undo
2176 2176
 	}
2177 2177
 
2178 2178
 	/**
2179
-	* Selects one or more rows in table depending on where, all data is quoted according to it's type
2180
-	*
2181
-	* @author RalfBecker<at>outdoor-training.de
2182
-	*
2183
-	* @param string $table name of the table
2184
-	* @param array|string $cols string or array of column-names / select-expressions
2185
-	* @param array|string $where string or array with column-name / values pairs AND'ed together for the where clause
2186
-	* @param int $line line-number to pass to query
2187
-	* @param string $file file-name to pass to query
2188
-	* @param int|bool $offset offset for a limited query or False (default)
2189
-	* @param string $append string to append to the end of the query, eg. ORDER BY ...
2190
-	* @param string|boolean $app string with name of app or False to use the current-app
2191
-	* @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs
2192
-	* @param string $join =null sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
2193
-	*	"LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
2194
-	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2195
-	* @param int $fetchmode =egw_db::FETCH_ASSOC egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
2196
-	* @return ADORecordSet or false, if the query fails
2197
-	*/
2179
+	 * Selects one or more rows in table depending on where, all data is quoted according to it's type
2180
+	 *
2181
+	 * @author RalfBecker<at>outdoor-training.de
2182
+	 *
2183
+	 * @param string $table name of the table
2184
+	 * @param array|string $cols string or array of column-names / select-expressions
2185
+	 * @param array|string $where string or array with column-name / values pairs AND'ed together for the where clause
2186
+	 * @param int $line line-number to pass to query
2187
+	 * @param string $file file-name to pass to query
2188
+	 * @param int|bool $offset offset for a limited query or False (default)
2189
+	 * @param string $append string to append to the end of the query, eg. ORDER BY ...
2190
+	 * @param string|boolean $app string with name of app or False to use the current-app
2191
+	 * @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs
2192
+	 * @param string $join =null sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
2193
+	 *	"LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
2194
+	 * @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2195
+	 * @param int $fetchmode =egw_db::FETCH_ASSOC egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
2196
+	 * @return ADORecordSet or false, if the query fails
2197
+	 */
2198 2198
 	function select($table,$cols,$where,$line,$file,$offset=False,$append='',$app=False,$num_rows=0,$join='',$table_def=False,$fetchmode=egw_db::FETCH_ASSOC)
2199 2199
 	{
2200 2200
 		if ($this->Debug) echo "<p>db::select('$table',".print_r($cols,True).",".print_r($where,True).",$line,$file,$offset,'$app',$num_rows,'$join')</p>\n";
@@ -2229,20 +2229,20 @@  discard block
 block discarded – undo
2229 2229
 	}
2230 2230
 
2231 2231
 	/**
2232
-	* Does a union over multiple selects
2233
-	*
2234
-	* @author RalfBecker<at>outdoor-training.de
2235
-	*
2236
-	* @param array $selects array of selects, each select is an array with the possible keys/parameters: table, cols, where, append, app, join, table_def
2237
-	*	For further info about parameters see the definition of the select function, beside table, cols and where all other params are optional
2238
-	* @param int $line line-number to pass to query
2239
-	* @param string $file file-name to pass to query
2240
-	* @param string $order_by ORDER BY statement for the union
2241
-	* @param int|bool $offset offset for a limited query or False (default)
2242
-	* @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs
2243
-	* @param int $fetchmode =egw_db::FETCH_ASSOC egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
2244
-	* @return ADORecordSet or false, if the query fails
2245
-	*/
2232
+	 * Does a union over multiple selects
2233
+	 *
2234
+	 * @author RalfBecker<at>outdoor-training.de
2235
+	 *
2236
+	 * @param array $selects array of selects, each select is an array with the possible keys/parameters: table, cols, where, append, app, join, table_def
2237
+	 *	For further info about parameters see the definition of the select function, beside table, cols and where all other params are optional
2238
+	 * @param int $line line-number to pass to query
2239
+	 * @param string $file file-name to pass to query
2240
+	 * @param string $order_by ORDER BY statement for the union
2241
+	 * @param int|bool $offset offset for a limited query or False (default)
2242
+	 * @param int $num_rows number of rows to return if offset set, default 0 = use default in user prefs
2243
+	 * @param int $fetchmode =egw_db::FETCH_ASSOC egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
2244
+	 * @return ADORecordSet or false, if the query fails
2245
+	 */
2246 2246
 	function union($selects,$line,$file,$order_by='',$offset=false,$num_rows=0,$fetchmode=egw_db::FETCH_ASSOC)
2247 2247
 	{
2248 2248
 		if ($this->Debug) echo "<p>db::union(".print_r($selects,True).",$line,$file,$order_by,$offset,$num_rows)</p>\n";
Please login to merge, or discard this patch.
Spacing   +220 added lines, -222 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @version $Id$
12 12
  */
13 13
 
14
-if(empty($GLOBALS['egw_info']['server']['db_type']))
14
+if (empty($GLOBALS['egw_info']['server']['db_type']))
15 15
 {
16 16
 	$GLOBALS['egw_info']['server']['db_type'] = 'mysql';
17 17
 }
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
 	/**
71 71
 	* @var string $type translated database type: mysqlt+mysqli ==> mysql, same for odbc-types
72 72
 	*/
73
-	var $Type     = '';
73
+	var $Type = '';
74 74
 
75 75
 	/**
76 76
 	* @var string $type database type as defined in the header.inc.php, eg. mysqlt
77 77
 	*/
78
-	var $setupType     = '';
78
+	var $setupType = '';
79 79
 
80 80
 	/**
81 81
 	* @var string $Host database host to connect to
82 82
 	*/
83
-	var $Host     = '';
83
+	var $Host = '';
84 84
 
85 85
 	/**
86 86
 	* @var string $Port port number of database to connect to
87 87
 	*/
88
-	var $Port     = '';
88
+	var $Port = '';
89 89
 
90 90
 	/**
91 91
 	* @var string $Database name of database to use
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	* @var string $User name of database user
97 97
 	*/
98
-	var $User     = '';
98
+	var $User = '';
99 99
 
100 100
 	/**
101 101
 	* @var string $Password password for database user
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	* @var int $Debug enable debuging - 0 no, 1 yes
107 107
 	*/
108
-	var $Debug         = 0;
108
+	var $Debug = 0;
109 109
 
110 110
 	/**
111 111
 	 * Log update querys to error_log, do not run them
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	/**
118 118
 	* @var array $Record current record
119 119
 	*/
120
-	var $Record   = array();
120
+	var $Record = array();
121 121
 
122 122
 	/**
123 123
 	* @var int row number for current record
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 	/**
128 128
 	* @var int $Errno internal rdms error number for last error
129 129
 	*/
130
-	var $Errno    = 0;
130
+	var $Errno = 0;
131 131
 
132 132
 	/**
133 133
 	* @var string descriptive text from last error
134 134
 	*/
135
-	var $Error    = '';
135
+	var $Error = '';
136 136
 
137 137
 	/**
138 138
 	 * eGW's own query log, independent of the db-type, eg. /tmp/query.log
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @var ADOConnection
154 154
 	 */
155
-	var $privat_Link_ID = False;	// do we use a privat Link_ID or a reference to the global ADOdb object
155
+	var $privat_Link_ID = False; // do we use a privat Link_ID or a reference to the global ADOdb object
156 156
 	/**
157 157
 	 * ADOdb record set of the current query
158 158
 	 *
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 	/**
195 195
 	 * db is able to use DISTINCT on text or blob columns
196 196
 	 */
197
-	const CAPABILITY_DISTINCT_ON_TEXT =	'distinct_on_text';
197
+	const CAPABILITY_DISTINCT_ON_TEXT = 'distinct_on_text';
198 198
 	/**
199 199
 	 * DB is able to use LIKE on text columns
200 200
 	 */
201
-	const CAPABILITY_LIKE_ON_TEXT =	'like_on_text';
201
+	const CAPABILITY_LIKE_ON_TEXT = 'like_on_text';
202 202
 	/**
203 203
 	 * DB allows ORDER on text columns
204 204
 	 *
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 		self::CAPABILITY_CAST_AS_VARCHAR   => 'CAST(%s AS varchar)',
251 251
 	);
252 252
 
253
-	var $prepared_sql = array();	// sql is the index
253
+	var $prepared_sql = array(); // sql is the index
254 254
 
255 255
 	/**
256 256
 	 * Constructor
257 257
 	 *
258 258
 	 * @param array $db_data =null values for keys 'db_name', 'db_host', 'db_port', 'db_user', 'db_pass', 'db_type'
259 259
 	 */
260
-	function __construct(array $db_data=null)
260
+	function __construct(array $db_data = null)
261 261
 	{
262 262
 		if (!is_null($db_data))
263 263
 		{
264
-			foreach(array(
264
+			foreach (array(
265 265
 				'Database' => 'db_name',
266 266
 				'Host'     => 'db_host',
267 267
 				'Port'     => 'db_port',
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @throws egw_exception_db_connection
317 317
 	 * @return ADOConnection
318 318
 	 */
319
-	function connect($Database = NULL, $Host = NULL, $Port = NULL, $User = NULL, $Password = NULL,$Type = NULL)
319
+	function connect($Database = NULL, $Host = NULL, $Port = NULL, $User = NULL, $Password = NULL, $Type = NULL)
320 320
 	{
321 321
 		/* Handle defaults */
322 322
 		if (!is_null($Database) && $Database)
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 		}
326 326
 		if (!is_null($Host) && $Host)
327 327
 		{
328
-			$this->Host     = $Host;
328
+			$this->Host = $Host;
329 329
 		}
330 330
 		if (!is_null($Port) && $Port)
331 331
 		{
332
-			$this->Port     = $Port;
332
+			$this->Port = $Port;
333 333
 		}
334 334
 		if (!is_null($User) && $User)
335 335
 		{
336
-			$this->User     = $User;
336
+			$this->User = $User;
337 337
 		}
338 338
 		if (!is_null($Password) && $Password)
339 339
 		{
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		// on connection failure re-try with an other host
351 351
 		// remembering in session which host we used last time
352 352
 		$use_host_from_session = true;
353
-		while(($host = $this->get_host(!$use_host_from_session)))
353
+		while (($host = $this->get_host(!$use_host_from_session)))
354 354
 		{
355 355
 			try {
356 356
 				//error_log(__METHOD__."() this->Host(s)=$this->Host, n=$n --> host=$host");
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 				//error_log(__METHOD__."() host=$host, new_connection=$new_connection, this->Type=$this->Type, this->Host=$this->Host, wsrep_local_state=".array2string($state));
365 365
 				return $this->Link_ID;
366 366
 			}
367
-			catch(egw_exception_db_connection $e) {
367
+			catch (egw_exception_db_connection $e) {
368 368
 				_egw_log_exception($e);
369
-				$this->disconnect();	// force a new connect
370
-				$this->Type = $this->setupType;	// get set to "mysql" for "mysqli"
371
-				$use_host_from_session = false;	// re-try with next host from list
369
+				$this->disconnect(); // force a new connect
370
+				$this->Type = $this->setupType; // get set to "mysql" for "mysqli"
371
+				$use_host_from_session = false; // re-try with next host from list
372 372
 			}
373 373
 		}
374 374
 		if (!isset($e))
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 	{
418 418
 		$hosts = explode(';', $this->Host[0] == '@' ? getenv(substr($this->Host, 1)) : $this->Host);
419 419
 		$num_hosts = count($hosts);
420
-		$n =& egw_cache::getSession(__CLASS__, $this->Host);
420
+		$n = & egw_cache::getSession(__CLASS__, $this->Host);
421 421
 		if (!isset($n)) $n = 0;
422 422
 
423
-		if ($next && ++$n >= $num_hosts+2)
423
+		if ($next && ++$n >= $num_hosts + 2)
424 424
 		{
425
-			$n = 0;	// start search again with default on next request
425
+			$n = 0; // start search again with default on next request
426 426
 			$ret = false;
427 427
 		}
428 428
 		else
@@ -445,21 +445,21 @@  discard block
 block discarded – undo
445 445
 		if (!$this->Link_ID)
446 446
 		{
447 447
 			$Database = $User = $Password = $Port = $Type = '';
448
-			foreach(array('Database','User','Password','Port','Type') as $name)
448
+			foreach (array('Database', 'User', 'Password', 'Port', 'Type') as $name)
449 449
 			{
450 450
 				$$name = $this->$name;
451 451
 				if (${$name}[0] == '@' && $name != 'Password') $$name = getenv(substr($$name, 1));
452 452
 			}
453 453
 			$this->setupType = $php_extension = $Type;
454 454
 
455
-			switch($Type)	// convert to ADO db-type-names
455
+			switch ($Type)	// convert to ADO db-type-names
456 456
 			{
457 457
 				case 'pgsql':
458 458
 					$Type = 'postgres'; // name in ADOdb
459 459
 					// create our own pgsql connection-string, to allow unix domain soccets if !$Host
460 460
 					$Host = "dbname=$Database".($Host ? " host=$Host".($Port ? " port=$Port" : '') : '').
461 461
 						" user=$User".($Password ? " password='".addslashes($Password)."'" : '');
462
-					$User = $Password = $Database = '';	// to indicate $Host is a connection-string
462
+					$User = $Password = $Database = ''; // to indicate $Host is a connection-string
463 463
 					break;
464 464
 
465 465
 				case 'odbc_mssql':
@@ -482,22 +482,22 @@  discard block
 block discarded – undo
482 482
 					$Type = 'maxdb';
483 483
 					// fall through
484 484
 				case 'maxdb':
485
-					$Type ='sapdb';	// name in ADOdb
485
+					$Type = 'sapdb'; // name in ADOdb
486 486
 					$php_extension = 'odbc';
487 487
 					break;
488 488
 
489 489
 				case 'mysqlt':
490
-					$php_extension = 'mysql';	// you can use $this->setupType to determine if it's mysqlt or mysql
490
+					$php_extension = 'mysql'; // you can use $this->setupType to determine if it's mysqlt or mysql
491 491
 					// fall through
492 492
 				case 'mysqli':
493
-					$this->Type = 'mysql';		// need to be "mysql", so apps can check just for "mysql"!
493
+					$this->Type = 'mysql'; // need to be "mysql", so apps can check just for "mysql"!
494 494
 					// fall through
495 495
 				default:
496 496
 					if ($Port) $Host .= ':'.$Port;
497 497
 					break;
498 498
 			}
499
-			if (!isset($GLOBALS['egw']->ADOdb) ||	// we have no connection so far
500
-				(is_object($GLOBALS['egw']->db) &&	// we connect to a different db, then the global one
499
+			if (!isset($GLOBALS['egw']->ADOdb) || // we have no connection so far
500
+				(is_object($GLOBALS['egw']->db) && // we connect to a different db, then the global one
501 501
 					($this->Type != $GLOBALS['egw']->db->Type ||
502 502
 					$this->Database != $GLOBALS['egw']->db->Database ||
503 503
 					$this->User != $GLOBALS['egw']->db->User ||
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 				}
511 511
 				if (!isset($GLOBALS['egw']->ADOdb))	// use the global object to store the connection
512 512
 				{
513
-					$this->Link_ID =& $GLOBALS['egw']->ADOdb;
513
+					$this->Link_ID = & $GLOBALS['egw']->ADOdb;
514 514
 				}
515 515
 				else
516 516
 				{
517
-					$this->privat_Link_ID = True;	// remember that we use a privat Link_ID for disconnect
517
+					$this->privat_Link_ID = True; // remember that we use a privat Link_ID for disconnect
518 518
 				}
519 519
 				$this->Link_ID = ADONewConnection($Type);
520 520
 				if (!$this->Link_ID)
@@ -525,11 +525,11 @@  discard block
 block discarded – undo
525 525
 				if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database)))
526 526
 				{
527 527
 					$this->ServerInfo = $this->Link_ID->ServerInfo();
528
-					$this->set_capabilities($Type,$this->ServerInfo['version']);
528
+					$this->set_capabilities($Type, $this->ServerInfo['version']);
529 529
 				}
530 530
 				if (!$Ok)
531 531
 				{
532
-					$Host = preg_replace('/password=[^ ]+/','password=$Password',$Host);	// eg. postgres dsn contains password
532
+					$Host = preg_replace('/password=[^ ]+/', 'password=$Password', $Host); // eg. postgres dsn contains password
533 533
 					throw new egw_exception_db_connection("ADOdb::$connect($Host, $User, \$Password, $Database) failed.");
534 534
 				}
535 535
 				if ($this->Debug)
@@ -545,8 +545,8 @@  discard block
 block discarded – undo
545 545
 					// this is the format ADOdb expects
546 546
 					$this->Link_ID->Execute('SET DATEFORMAT ymd');
547 547
 					// sets the limit to the maximum
548
-					ini_set('mssql.textlimit',2147483647);
549
-					ini_set('mssql.sizelimit',2147483647);
548
+					ini_set('mssql.textlimit', 2147483647);
549
+					ini_set('mssql.sizelimit', 2147483647);
550 550
 				}
551 551
 				// set our default charset
552 552
 				$this->Link_ID->SetCharSet('utf-8');
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
 			}
556 556
 			else
557 557
 			{
558
-				$this->Link_ID =& $GLOBALS['egw']->ADOdb;
558
+				$this->Link_ID = & $GLOBALS['egw']->ADOdb;
559 559
 			}
560 560
 		}
561 561
 		if (!$this->Link_ID->isConnected() && !$this->Link_ID->Connect())
562 562
 		{
563
-			$Host = preg_replace('/password=[^ ]+/','password=$Password',$Host);	// eg. postgres dsn contains password
563
+			$Host = preg_replace('/password=[^ ]+/', 'password=$Password', $Host); // eg. postgres dsn contains password
564 564
 			throw new egw_exception_db_connection("ADOdb::$connect($Host, $User, \$Password, $Database) reconnect failed.");
565 565
 		}
566 566
 		// fix due to caching and reusing of connection not correctly set $this->Type == 'mysql'
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 		}
572 572
 		if ($new_connection)
573 573
 		{
574
-			foreach(get_included_files() as $file)
574
+			foreach (get_included_files() as $file)
575 575
 			{
576
-				if (strpos($file,'adodb') !== false && !in_array($file,(array)$_SESSION['egw_required_files']))
576
+				if (strpos($file, 'adodb') !== false && !in_array($file, (array)$_SESSION['egw_required_files']))
577 577
 				{
578 578
 					$_SESSION['egw_required_files'][] = $file;
579 579
 					//error_log(__METHOD__."() egw_required_files[] = $file");
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	 */
590 590
 	function __wakeup()
591 591
 	{
592
-		$this->connect();	// we need to re-connect
592
+		$this->connect(); // we need to re-connect
593 593
 	}
594 594
 
595 595
 	/**
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 */
603 603
 	function __sleep()
604 604
 	{
605
-		if (!empty($this->setupType)) $this->Type = $this->setupType;	// restore Type eg. to mysqli
605
+		if (!empty($this->setupType)) $this->Type = $this->setupType; // restore Type eg. to mysqli
606 606
 
607 607
 		$vars = get_object_vars($this);
608 608
 		unset($vars['Link_ID']);
@@ -616,23 +616,23 @@  discard block
 block discarded – undo
616 616
 	 * @param string $adodb_driver mysql, postgres, mssql, sapdb, oci8
617 617
 	 * @param string $db_version version-number of connected db-server, as reported by ServerInfo
618 618
 	 */
619
-	function set_capabilities($adodb_driver,$db_version)
619
+	function set_capabilities($adodb_driver, $db_version)
620 620
 	{
621
-		switch($adodb_driver)
621
+		switch ($adodb_driver)
622 622
 		{
623 623
 			case 'mysql':
624 624
 			case 'mysqlt':
625 625
 			case 'mysqli':
626
-				$this->capabilities[self::CAPABILITY_SUB_QUERIES] = (float) $db_version >= 4.1;
627
-				$this->capabilities[self::CAPABILITY_UNION] = (float) $db_version >= 4.0;
626
+				$this->capabilities[self::CAPABILITY_SUB_QUERIES] = (float)$db_version >= 4.1;
627
+				$this->capabilities[self::CAPABILITY_UNION] = (float)$db_version >= 4.0;
628 628
 				$this->capabilities[self::CAPABILITY_NAME_CASE] = 'preserv';
629
-				$this->capabilities[self::CAPABILITY_CLIENT_ENCODING] = (float) $db_version >= 4.1;
629
+				$this->capabilities[self::CAPABILITY_CLIENT_ENCODING] = (float)$db_version >= 4.1;
630 630
 				$this->capabilities[self::CAPABILITY_CAST_AS_VARCHAR] = 'CAST(%s AS char)';
631 631
 				break;
632 632
 
633 633
 			case 'postgres':
634 634
 				$this->capabilities[self::CAPABILITY_NAME_CASE] = 'lower';
635
-				$this->capabilities[self::CAPABILITY_CLIENT_ENCODING] = (float) $db_version >= 7.4;
635
+				$this->capabilities[self::CAPABILITY_CLIENT_ENCODING] = (float)$db_version >= 7.4;
636 636
 				$this->capabilities[self::CAPABILITY_OUTER_JOIN] = true;
637 637
 				$this->capabilities[self::CAPABILITY_CASE_INSENSITIV_LIKE] = '::text ILIKE';
638 638
 				$this->capabilities[self::CAPABILITY_REQUIRE_TRUNCATE_VARCHAR] = true;
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 			return False;
702 702
 		}
703 703
 		// the substring is needed as the string is already in quotes
704
-		return substr($this->Link_ID->DBTimeStamp($epoch),1,-1);
704
+		return substr($this->Link_ID->DBTimeStamp($epoch), 1, -1);
705 705
 	}
706 706
 
707 707
 	/**
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 */
728 728
 	public static function from_bool($val)
729 729
 	{
730
-		return $val && $val[0] !== 'f';	// everthing other then 0 or f[alse] is returned as true
730
+		return $val && $val[0] !== 'f'; // everthing other then 0 or f[alse] is returned as true
731 731
 	}
732 732
 
733 733
 	/**
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	 */
738 738
 	function free()
739 739
 	{
740
-		unset($this->Query_ID);	// else copying of the db-object does not work
740
+		unset($this->Query_ID); // else copying of the db-object does not work
741 741
 		$this->Query_ID = 0;
742 742
 	}
743 743
 
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
 	* @return ADORecordSet or false, if the query fails
756 756
 	* @throws egw_exception_db_invalid_sql with $this->Link_ID->ErrorNo() as code
757 757
 	*/
758
-	function query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=egw_db::FETCH_BOTH, $reconnect=true)
758
+	function query($Query_String, $line = '', $file = '', $offset = 0, $num_rows = -1, $inputarr = false, $fetchmode = egw_db::FETCH_BOTH, $reconnect = true)
759 759
 	{
760
-		unset($line, $file);	// not used anymore
760
+		unset($line, $file); // not used anymore
761 761
 
762 762
 		if ($Query_String == '')
763 763
 		{
@@ -788,23 +788,23 @@  discard block
 block discarded – undo
788 788
 		}
789 789
 		if ($num_rows > 0)
790 790
 		{
791
-			$this->Query_ID = $this->Link_ID->SelectLimit($Query_String,$num_rows,(int)$offset,$inputarr);
791
+			$this->Query_ID = $this->Link_ID->SelectLimit($Query_String, $num_rows, (int)$offset, $inputarr);
792 792
 		}
793 793
 		else
794 794
 		{
795
-			$this->Query_ID = $this->Link_ID->Execute($Query_String,$inputarr);
795
+			$this->Query_ID = $this->Link_ID->Execute($Query_String, $inputarr);
796 796
 		}
797 797
 		$this->Row = 0;
798 798
 		$this->Errno  = $this->Link_ID->ErrorNo();
799 799
 		$this->Error  = $this->Link_ID->ErrorMsg();
800 800
 
801
-		if ($this->query_log && ($f = @fopen($this->query_log,'a+')))
801
+		if ($this->query_log && ($f = @fopen($this->query_log, 'a+')))
802 802
 		{
803
-			fwrite($f,'['.(isset($GLOBALS['egw_setup']) ? $GLOBALS['egw_setup']->ConfigDomain : $GLOBALS['egw_info']['user']['domain']).'] ');
804
-			fwrite($f,date('Y-m-d H:i:s ').$Query_String.($inputarr ? "\n".print_r($inputarr,true) : '')."\n");
803
+			fwrite($f, '['.(isset($GLOBALS['egw_setup']) ? $GLOBALS['egw_setup']->ConfigDomain : $GLOBALS['egw_info']['user']['domain']).'] ');
804
+			fwrite($f, date('Y-m-d H:i:s ').$Query_String.($inputarr ? "\n".print_r($inputarr, true) : '')."\n");
805 805
 			if (!$this->Query_ID)
806 806
 			{
807
-				fwrite($f,"*** Error $this->Errno: $this->Error\n".function_backtrace()."\n");
807
+				fwrite($f, "*** Error $this->Errno: $this->Error\n".function_backtrace()."\n");
808 808
 			}
809 809
 			fclose($f);
810 810
 		}
@@ -815,11 +815,11 @@  discard block
 block discarded – undo
815 815
 				$this->disconnect();
816 816
 				return $this->query($Query_String, $line, $file, $offset, $num_rows, $inputarr, $fetchmode, false);
817 817
 			}
818
-			throw new egw_exception_db_invalid_sql("Invalid SQL: ".(is_array($Query_String)?$Query_String[0]:$Query_String).
818
+			throw new egw_exception_db_invalid_sql("Invalid SQL: ".(is_array($Query_String) ? $Query_String[0] : $Query_String).
819 819
 				"\n$this->Error ($this->Errno)".
820
-				($inputarr ? "\nParameters: '".implode("','",$inputarr)."'":''), $this->Errno);
820
+				($inputarr ? "\nParameters: '".implode("','", $inputarr)."'" : ''), $this->Errno);
821 821
 		}
822
-		elseif(empty($this->Query_ID->sql)) $this->Query_ID->sql = $Query_String;
822
+		elseif (empty($this->Query_ID->sql)) $this->Query_ID->sql = $Query_String;
823 823
 		return $this->Query_ID;
824 824
 	}
825 825
 
@@ -834,9 +834,9 @@  discard block
 block discarded – undo
834 834
 	* @param array|boolean $inputarr array for binding variables to parameters or false (default)
835 835
 	* @return ADORecordSet or false, if the query fails
836 836
 	*/
837
-	function limit_query($Query_String, $offset, $line = '', $file = '', $num_rows = '',$inputarr=false)
837
+	function limit_query($Query_String, $offset, $line = '', $file = '', $num_rows = '', $inputarr = false)
838 838
 	{
839
-		return $this->query($Query_String,$line,$file,$offset,$num_rows,$inputarr);
839
+		return $this->query($Query_String, $line, $file, $offset, $num_rows, $inputarr);
840 840
 	}
841 841
 
842 842
 	/**
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 	* @param int $fetch_mode egw_db::FETCH_BOTH = numerical+assoc keys (eGW default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
849 849
 	* @return bool was another row found?
850 850
 	*/
851
-	function next_record($fetch_mode=egw_db::FETCH_BOTH)
851
+	function next_record($fetch_mode = egw_db::FETCH_BOTH)
852 852
 	{
853 853
 		if (!$this->Query_ID)
854 854
 		{
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 		}
869 869
 		if ($this->capabilities[self::CAPABILITY_NAME_CASE] == 'upper')	// maxdb, oracle, ...
870 870
 		{
871
-			switch($fetch_mode)
871
+			switch ($fetch_mode)
872 872
 			{
873 873
 				case egw_db::FETCH_ASSOC:
874 874
 					$this->Record = array_change_key_case($this->Record);
@@ -905,9 +905,9 @@  discard block
 block discarded – undo
905 905
 	*/
906 906
 	function seek($pos = 0)
907 907
 	{
908
-		if (!$this->Query_ID  || !$this->Query_ID->Move($this->Row = $pos))
908
+		if (!$this->Query_ID || !$this->Query_ID->Move($this->Row = $pos))
909 909
 		{
910
-			throw new egw_exception_db("seek($pos) failed: resultset has " . $this->num_rows() . " rows");
910
+			throw new egw_exception_db("seek($pos) failed: resultset has ".$this->num_rows()." rows");
911 911
 		}
912 912
 		return True;
913 913
 	}
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 		{
975 975
 			$table = self::$tablealiases[$table];
976 976
 		}
977
-		$id = $this->Link_ID->PO_Insert_ID($table,$field);	// simulates Insert_ID with "SELECT MAX($field) FROM $table" if not native availible
977
+		$id = $this->Link_ID->PO_Insert_ID($table, $field); // simulates Insert_ID with "SELECT MAX($field) FROM $table" if not native availible
978 978
 
979 979
 		if ($id === False)	// function not supported
980 980
 		{
@@ -993,9 +993,9 @@  discard block
 block discarded – undo
993 993
 	* @param string $mode type of lock required (optional), default write
994 994
 	* @return bool True if sucessful, False if fails
995 995
 	*/
996
-	function lock($table, $mode='write')
996
+	function lock($table, $mode = 'write')
997 997
 	{
998
-		unset($table, $mode);	// not used anymore
998
+		unset($table, $mode); // not used anymore
999 999
 	}
1000 1000
 
1001 1001
 	/**
@@ -1099,18 +1099,18 @@  discard block
 block discarded – undo
1099 1099
 	* @param string $strip ='' string to strip of the column-name, default ''
1100 1100
 	* @return array/bool the associative array or False if no (more) result-row is availible
1101 1101
 	*/
1102
-	function row($do_next_record=False,$strip='')
1102
+	function row($do_next_record = False, $strip = '')
1103 1103
 	{
1104 1104
 		if ($do_next_record && !$this->next_record(egw_db::FETCH_ASSOC) || !is_array($this->Record))
1105 1105
 		{
1106 1106
 			return False;
1107 1107
 		}
1108 1108
 		$result = array();
1109
-		foreach($this->Record as $column => $value)
1109
+		foreach ($this->Record as $column => $value)
1110 1110
 		{
1111 1111
 			if (!is_numeric($column))
1112 1112
 			{
1113
-				if ($strip) $column = str_replace($strip,'',$column);
1113
+				if ($strip) $column = str_replace($strip, '', $column);
1114 1114
 
1115 1115
 				$result[$column] = $value;
1116 1116
 			}
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 	* @param bool $full optional, default False summary information, True full information
1128 1128
 	* @return array table meta data
1129 1129
 	*/
1130
-	function metadata($table='',$full=false)
1130
+	function metadata($table = '', $full = false)
1131 1131
 	{
1132 1132
 		if (!$this->Link_ID && !$this->connect())
1133 1133
 		{
@@ -1139,13 +1139,13 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		$metadata = array();
1141 1141
 		$i = 0;
1142
-		foreach($columns as $column)
1142
+		foreach ($columns as $column)
1143 1143
 		{
1144 1144
 			// for backwards compatibilty (depreciated)
1145 1145
 			$flags = null;
1146
-			if($column->auto_increment) $flags .= "auto_increment ";
1147
-			if($column->primary_key) $flags .= "primary_key ";
1148
-			if($column->binary) $flags .= "binary ";
1146
+			if ($column->auto_increment) $flags .= "auto_increment ";
1147
+			if ($column->primary_key) $flags .= "primary_key ";
1148
+			if ($column->binary) $flags .= "binary ";
1149 1149
 
1150 1150
 			$metadata[$i] = array(
1151 1151
 				'table' => $table,
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 	 * @param boolean $just_name =false true return array of table-names, false return old format
1181 1181
 	 * @return array list of the tables
1182 1182
 	 */
1183
-	function table_names($just_name=false)
1183
+	function table_names($just_name = false)
1184 1184
 	{
1185 1185
 		if (!$this->Link_ID) $this->connect();
1186 1186
 		if (!$this->Link_ID)
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 		$tables = $this->Link_ID->MetaTables('TABLES');
1192 1192
 		if (is_array($tables))
1193 1193
 		{
1194
-			foreach($tables as $table)
1194
+			foreach ($tables as $table)
1195 1195
 			{
1196 1196
 				if ($this->capabilities[self::CAPABILITY_NAME_CASE] == 'upper')
1197 1197
 				{
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 	* @param string $charset default charset for the database
1255 1255
 	* @param string $grant_host ='localhost' host/ip of the webserver
1256 1256
 	*/
1257
-	function create_database($adminname = '', $adminpasswd = '', $charset='', $grant_host='localhost')
1257
+	function create_database($adminname = '', $adminpasswd = '', $charset = '', $grant_host = 'localhost')
1258 1258
 	{
1259 1259
 		$currentUser = $this->User;
1260 1260
 		$currentPassword = $this->Password;
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 			case 'mysqli':
1279 1279
 			case 'mysqlt':
1280 1280
 				$create = "CREATE DATABASE `$currentDatabase`";
1281
-				if ($charset && isset($this->Link_ID->charset2mysql[$charset]) && (float) $this->ServerInfo['version'] >= 4.1)
1281
+				if ($charset && isset($this->Link_ID->charset2mysql[$charset]) && (float)$this->ServerInfo['version'] >= 4.1)
1282 1282
 				{
1283 1283
 					$create .= ' DEFAULT CHARACTER SET '.$this->Link_ID->charset2mysql[$charset].';';
1284 1284
 				}
@@ -1289,9 +1289,9 @@  discard block
 block discarded – undo
1289 1289
 				echo "<p>db::create_database(user='$adminname',\$pw) not yet implemented for DB-type '$this->Type'</p>\n";
1290 1290
 				break;
1291 1291
 		}
1292
-		foreach($sqls as $sql)
1292
+		foreach ($sqls as $sql)
1293 1293
 		{
1294
-			$this->query($sql,__LINE__,__FILE__);
1294
+			$this->query($sql, __LINE__, __FILE__);
1295 1295
 		}
1296 1296
 		$this->disconnect();
1297 1297
 
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 		{
1318 1318
 			return False;
1319 1319
 		}
1320
-		return call_user_func_array(array(&$this->Link_ID,'concat'),$args);
1320
+		return call_user_func_array(array(&$this->Link_ID, 'concat'), $args);
1321 1321
 	}
1322 1322
 
1323 1323
 	/**
@@ -1328,9 +1328,9 @@  discard block
 block discarded – undo
1328 1328
 	 * @param string $separator =',' optional separator, default is comma
1329 1329
 	 * @return string|boolean false if not supported by dbms
1330 1330
 	 */
1331
-	function group_concat($expr, $order_by='', $separator=',')
1331
+	function group_concat($expr, $order_by = '', $separator = ',')
1332 1332
 	{
1333
-		switch($this->Type)
1333
+		switch ($this->Type)
1334 1334
 		{
1335 1335
 			case 'mysql':
1336 1336
 				$sql = 'GROUP_CONCAT('.$expr;
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 	 */
1365 1365
 	function strpos($str, $substr)
1366 1366
 	{
1367
-		switch($this->Type)
1367
+		switch ($this->Type)
1368 1368
 		{
1369 1369
 			case 'mysql':
1370 1370
 				return "LOCATE($substr,$str)";
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 	 */
1385 1385
 	function unix_timestamp($expr)
1386 1386
 	{
1387
-		switch($this->Type)
1387
+		switch ($this->Type)
1388 1388
 		{
1389 1389
 			case 'mysql':
1390 1390
 				return "UNIX_TIMESTAMP($expr)";
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 	 */
1406 1406
 	function from_unixtime($expr)
1407 1407
 	{
1408
-		switch($this->Type)
1408
+		switch ($this->Type)
1409 1409
 		{
1410 1410
 			case 'mysql':
1411 1411
 				return "FROM_UNIXTIME($expr)";
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 				return "(TIMESTAMP WITH TIME ZONE 'epoch' + ($expr) * INTERVAL '1 sec')";
1415 1415
 
1416 1416
 			case 'mssql':	// we use date(,0) as we store server-time
1417
-				return "DATEADD(second,($expr),'".date('Y-m-d H:i:s',0)."')";
1417
+				return "DATEADD(second,($expr),'".date('Y-m-d H:i:s', 0)."')";
1418 1418
 		}
1419 1419
 		return false;
1420 1420
 	}
@@ -1428,30 +1428,30 @@  discard block
 block discarded – undo
1428 1428
 	 * @param string $format format specifier like '%Y-%m-%d %H:%i:%s' or '%V%X' ('%v%x') weeknumber & year with Sunday (Monday) as first day
1429 1429
 	 * @return string SQL expression of type timestamp
1430 1430
 	 */
1431
-	function date_format($expr,$format)
1431
+	function date_format($expr, $format)
1432 1432
 	{
1433
-		switch($this->Type)
1433
+		switch ($this->Type)
1434 1434
 		{
1435 1435
 			case 'mysql':
1436 1436
 				return "DATE_FORMAT($expr,'$format')";
1437 1437
 
1438 1438
 			case 'pgsql':
1439 1439
 				$format = str_replace(
1440
-					array('%Y',  '%y','%m','%d','%H',  '%h','%i','%s','%V','%v','%X',  '%x'),
1441
-					array('YYYY','YY','MM','DD','HH24','HH','MI','SS','IW','IW','YYYY','YYYY'),
1440
+					array('%Y', '%y', '%m', '%d', '%H', '%h', '%i', '%s', '%V', '%v', '%X', '%x'),
1441
+					array('YYYY', 'YY', 'MM', 'DD', 'HH24', 'HH', 'MI', 'SS', 'IW', 'IW', 'YYYY', 'YYYY'),
1442 1442
 					$format);
1443 1443
 				return "TO_CHAR($expr,'$format')";
1444 1444
 
1445 1445
 			case 'mssql':
1446 1446
 				$from = $to = array();
1447
-				foreach(array('%Y'=>'yyyy','%y'=>'yy','%m'=>'mm','%d'=>'dd','%H'=>'hh','%i'=>'mi','%s'=>'ss','%V'=>'wk','%v'=>'wk','%X'=>'yyyy','%x'=>'yyyy') as $f => $t)
1447
+				foreach (array('%Y'=>'yyyy', '%y'=>'yy', '%m'=>'mm', '%d'=>'dd', '%H'=>'hh', '%i'=>'mi', '%s'=>'ss', '%V'=>'wk', '%v'=>'wk', '%X'=>'yyyy', '%x'=>'yyyy') as $f => $t)
1448 1448
 				{
1449 1449
 					$from[] = $f;
1450 1450
 					$to[] = "'+DATEPART($t,($expr))+'";
1451 1451
 				}
1452 1452
 				$from[] = "''+"; $to[] = '';
1453 1453
 				$from[] = "+''"; $to[] = '';
1454
-				return str_replace($from,$to,$format);
1454
+				return str_replace($from, $to, $format);
1455 1455
 		}
1456 1456
 		return false;
1457 1457
 	}
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
 	 */
1465 1465
 	function to_double($expr)
1466 1466
 	{
1467
-		switch($this->Type)
1467
+		switch ($this->Type)
1468 1468
 		{
1469 1469
 			case 'pgsql':
1470 1470
 				return $expr.'::double';
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 	 */
1483 1483
 	function to_int($expr)
1484 1484
 	{
1485
-		switch($this->Type)
1485
+		switch ($this->Type)
1486 1486
 		{
1487 1487
 			case 'pgsql':
1488 1488
 				return $expr.'::integer';
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
 	 */
1501 1501
 	function to_varchar($expr)
1502 1502
 	{
1503
-		switch($this->Type)
1503
+		switch ($this->Type)
1504 1504
 		{
1505 1505
 			case 'pgsql':
1506 1506
 				return 'CAST('.$expr.' AS varchar)';
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 			// always quote for postgreSQL, as this is the only way to support mixed case names
1545 1545
 			if (preg_match('/\W/', $name) || $type == 'pgsql' && preg_match('/[A-Z]+/', $name) || $name == 'index')
1546 1546
 			{
1547
-				return $quote . $name . $quote;
1547
+				return $quote.$name.$quote;
1548 1548
 			}
1549 1549
 			return $name;
1550 1550
 		}, explode('.', $name));
@@ -1566,27 +1566,27 @@  discard block
 block discarded – undo
1566 1566
 	* @param string $glue =',' used to glue array values together for the string type
1567 1567
 	* @return string escaped sting
1568 1568
 	*/
1569
-	function quote($value,$type=False,$not_null=true,$length=null,$glue=',')
1569
+	function quote($value, $type = False, $not_null = true, $length = null, $glue = ',')
1570 1570
 	{
1571
-		if ($this->Debug) echo "<p>db::quote(".(is_null($value)?'NULL':"'$value'").",'$type','$not_null')</p>\n";
1571
+		if ($this->Debug) echo "<p>db::quote(".(is_null($value) ? 'NULL' : "'$value'").",'$type','$not_null')</p>\n";
1572 1572
 
1573 1573
 		if (!$not_null && is_null($value))	// writing unset php-variables and those set to NULL now as SQL NULL
1574 1574
 		{
1575 1575
 			return 'NULL';
1576 1576
 		}
1577
-		switch($type)
1577
+		switch ($type)
1578 1578
 		{
1579 1579
 			case 'int':
1580 1580
 				// if DateTime object given, convert it to a unix timestamp (NOT converting the timezone!)
1581 1581
 				if (is_object($value) && ($value instanceof DateTime))
1582 1582
 				{
1583
-					return ($value instanceof egw_time) ? $value->format('ts') : egw_time::to($value,'ts');
1583
+					return ($value instanceof egw_time) ? $value->format('ts') : egw_time::to($value, 'ts');
1584 1584
 				}
1585 1585
 			case 'auto':
1586 1586
 				// atm. (php5.2) php has only 32bit integers, it converts everything else to float.
1587 1587
 				// Casting it to int gives a negative number instead of the big 64bit integer!
1588 1588
 				// There for we have to keep it as float by using round instead the int cast.
1589
-				return is_float($value) ? round($value) : (int) $value;
1589
+				return is_float($value) ? round($value) : (int)$value;
1590 1590
 			case 'bool':
1591 1591
 				if ($this->Type == 'mysql')		// maybe it's not longer necessary with mysql5
1592 1592
 				{
@@ -1595,23 +1595,23 @@  discard block
 block discarded – undo
1595 1595
 				return $value ? 'true' : 'false';
1596 1596
 			case 'float':
1597 1597
 			case 'decimal':
1598
-				return (double) $value;
1598
+				return (double)$value;
1599 1599
 		}
1600 1600
 		if (!$this->Link_ID && !$this->connect())
1601 1601
 		{
1602 1602
 			return False;
1603 1603
 		}
1604
-		switch($type)
1604
+		switch ($type)
1605 1605
 		{
1606 1606
 			case 'blob':
1607 1607
 				switch ($this->Link_ID->blobEncodeType)
1608 1608
 				{
1609 1609
 					case 'C':	// eg. postgres
1610
-						return "'" . $this->Link_ID->BlobEncode($value) . "'";
1610
+						return "'".$this->Link_ID->BlobEncode($value)."'";
1611 1611
 					case 'I':
1612 1612
 						return $this->Link_ID->BlobEncode($value);
1613 1613
 				}
1614
-				break;	// handled like strings
1614
+				break; // handled like strings
1615 1615
 			case 'date':
1616 1616
 				// if DateTime object given, convert it (NOT converting the timezone!)
1617 1617
 				if (is_object($value) && ($value instanceof DateTime))
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 		}
1630 1630
 		if (is_array($value))
1631 1631
 		{
1632
-			$value = implode($glue,$value);
1632
+			$value = implode($glue, $value);
1633 1633
 		}
1634 1634
 		// only truncate string if length given and <= 255
1635 1635
 		// to not unnecessary truncate varchar(>255) as PostgreSQL uses text anyway and MySQL truncates itself silently (unless strict mode!)
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 	*	If its set, the column-type-data determinates if (int) or addslashes is used.
1667 1667
 	* @return string SQL
1668 1668
 	*/
1669
-	function column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False)
1669
+	function column_data_implode($glue, $array, $use_key = True, $only = False, $column_definitions = False)
1670 1670
 	{
1671 1671
 		if (!is_array($array))	// this allows to give an SQL-string for delete or update
1672 1672
 		{
@@ -1676,16 +1676,16 @@  discard block
 block discarded – undo
1676 1676
 		{
1677 1677
 			$column_definitions = $this->column_definitions;
1678 1678
 		}
1679
-		if ($this->Debug) echo "<p>db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre>\n";
1679
+		if ($this->Debug) echo "<p>db::column_data_implode('$glue',".print_r($array, True).",'$use_key',".print_r($only, True).",<pre>".print_r($column_definitions, True)."</pre>\n";
1680 1680
 
1681 1681
 		// do we need to truncate varchars to their max length (INSERT and UPDATE on Postgres)
1682 1682
 		$truncate_varchar = $glue == ',' && $this->capabilities[self::CAPABILITY_REQUIRE_TRUNCATE_VARCHAR];
1683 1683
 
1684 1684
 		$keys = $values = array();
1685
-		foreach($array as $key => $data)
1685
+		foreach ($array as $key => $data)
1686 1686
 		{
1687 1687
 			if (is_int($key) && $use_key !== 'VALUES' || !$only || $only === True && isset($column_definitions[$key]) ||
1688
-				is_array($only) && in_array($key,$only))
1688
+				is_array($only) && in_array($key, $only))
1689 1689
 			{
1690 1690
 				$keys[] = $this->name_quote($key);
1691 1691
 
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 					if (strpos($key, '.') !== false) list(, $col) = explode('.', $key);
1697 1697
 					if (!isset($column_definitions[$col]))
1698 1698
 					{
1699
-						throw new egw_exception_db_invalid_sql("db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre><b>nothing known about column '$key'!</b>");
1699
+						throw new egw_exception_db_invalid_sql("db::column_data_implode('$glue',".print_r($array, True).",'$use_key',".print_r($only, True).",<pre>".print_r($column_definitions, True)."</pre><b>nothing known about column '$key'!</b>");
1700 1700
 					}
1701 1701
 				}
1702 1702
 				$column_type = is_array($column_definitions) ? @$column_definitions[$col]['type'] : False;
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 				$maxlength = null;
1706 1706
 				if ($truncate_varchar)
1707 1707
 				{
1708
-					$maxlength = in_array($column_definitions[$col]['type'], array('varchar','ascii')) ? $column_definitions[$col]['precision'] : null;
1708
+					$maxlength = in_array($column_definitions[$col]['type'], array('varchar', 'ascii')) ? $column_definitions[$col]['precision'] : null;
1709 1709
 				}
1710 1710
 				// dont use IN ( ), if there's only one value, it's slower for MySQL
1711 1711
 				if (is_array($data) && count($data) == 1)
@@ -1715,39 +1715,38 @@  discard block
 block discarded – undo
1715 1715
 				if (is_array($data))
1716 1716
 				{
1717 1717
 					$or_null = '';
1718
-					foreach($data as $k => $v)
1718
+					foreach ($data as $k => $v)
1719 1719
 					{
1720
-						if (!$not_null && $use_key===True && is_null($v))
1720
+						if (!$not_null && $use_key === True && is_null($v))
1721 1721
 						{
1722 1722
 							$or_null = $this->name_quote($key).' IS NULL)';
1723 1723
 							unset($data[$k]);
1724 1724
 							continue;
1725 1725
 						}
1726
-						$data[$k] = $this->quote($v,$column_type,$not_null,$maxlength);
1726
+						$data[$k] = $this->quote($v, $column_type, $not_null, $maxlength);
1727 1727
 					}
1728
-					$values[] = ($or_null?'(':'').(!count($data) ?
1728
+					$values[] = ($or_null ? '(' : '').(!count($data) ?
1729 1729
 						// empty array on insert/update, store as NULL, or if not allowed whatever value NULL is casted to
1730
-						$this->quote(null, $column_type, $not_null) :
1731
-						($use_key===True ? $this->name_quote($key).' IN ' : '') .
1732
-						'('.implode(',',$data).')'.($or_null ? ' OR ' : '')).$or_null;
1730
+						$this->quote(null, $column_type, $not_null) : ($use_key === True ? $this->name_quote($key).' IN ' : '').
1731
+						'('.implode(',', $data).')'.($or_null ? ' OR ' : '')).$or_null;
1733 1732
 				}
1734
-				elseif (is_int($key) && $use_key===True)
1733
+				elseif (is_int($key) && $use_key === True)
1735 1734
 				{
1736
-					if (empty($data)) continue;	// would give SQL error
1735
+					if (empty($data)) continue; // would give SQL error
1737 1736
 					$values[] = $data;
1738 1737
 				}
1739 1738
 				elseif ($glue != ',' && $use_key === True && !$not_null && is_null($data))
1740 1739
 				{
1741
-					$values[] = $this->name_quote($key) .' IS NULL';
1740
+					$values[] = $this->name_quote($key).' IS NULL';
1742 1741
 				}
1743 1742
 				else
1744 1743
 				{
1745
-					$values[] = ($use_key===True ? $this->name_quote($key) . '=' : '') . $this->quote($data,$column_type,$not_null,$maxlength);
1744
+					$values[] = ($use_key === True ? $this->name_quote($key).'=' : '').$this->quote($data, $column_type, $not_null, $maxlength);
1746 1745
 				}
1747 1746
 			}
1748 1747
 		}
1749
-		return ($use_key==='VALUES' ? '('.implode(',',$keys).') VALUES (' : '').
1750
-			implode($glue,$values) . ($use_key==='VALUES' ? ')' : '');
1748
+		return ($use_key === 'VALUES' ? '('.implode(',', $keys).') VALUES (' : '').
1749
+			implode($glue, $values).($use_key === 'VALUES' ? ')' : '');
1751 1750
 	}
1752 1751
 
1753 1752
 	/**
@@ -1759,9 +1758,9 @@  discard block
 block discarded – undo
1759 1758
 	*	of your table ($tables_baseline[$table]['fd'] of the setup/tables_current.inc.php file).
1760 1759
 	*	If its set, the column-type-data determinates if (int) or addslashes is used.
1761 1760
 	*/
1762
-	function set_column_definitions($column_definitions=False)
1761
+	function set_column_definitions($column_definitions = False)
1763 1762
 	{
1764
-		$this->column_definitions=$column_definitions;
1763
+		$this->column_definitions = $column_definitions;
1765 1764
 	}
1766 1765
 
1767 1766
 	/**
@@ -1774,7 +1773,7 @@  discard block
 block discarded – undo
1774 1773
 	 *
1775 1774
 	 * @var string
1776 1775
 	 */
1777
-	private $app=self::API_APPNAME;
1776
+	private $app = self::API_APPNAME;
1778 1777
 
1779 1778
 	/**
1780 1779
 	 * Sets the application in which the db-class looks for table-defintions
@@ -1806,12 +1805,12 @@  discard block
 block discarded – undo
1806 1805
 	* @param bool|string $table if set return only defintions of that table, else return all defintions
1807 1806
 	* @return mixed array with table-defintions or False if file not found
1808 1807
 	*/
1809
-	function get_table_definitions($app=False,$table=False)
1808
+	function get_table_definitions($app = False, $table = False)
1810 1809
 	{
1811 1810
 		static $all_app_data = array();
1812 1811
 		if ($app === true && $table)
1813 1812
 		{
1814
-			foreach($all_app_data as $app => &$app_data)
1813
+			foreach ($all_app_data as $app => &$app_data)
1815 1814
 			{
1816 1815
 				if (isset($app_data[$table]))
1817 1816
 				{
@@ -1819,13 +1818,13 @@  discard block
 block discarded – undo
1819 1818
 				}
1820 1819
 			}
1821 1820
 			// $table not found in loaded apps, check not yet loaded ones
1822
-			foreach(scandir(EGW_INCLUDE_ROOT) as $app)
1821
+			foreach (scandir(EGW_INCLUDE_ROOT) as $app)
1823 1822
 			{
1824 1823
 				if ($app[0] == '.' || !is_dir(EGW_INCLUDE_ROOT.'/'.$app) || isset($all_app_data[$app]))
1825 1824
 				{
1826 1825
 					continue;
1827 1826
 				}
1828
-				$tables_current = EGW_INCLUDE_ROOT . "/$app/setup/tables_current.inc.php";
1827
+				$tables_current = EGW_INCLUDE_ROOT."/$app/setup/tables_current.inc.php";
1829 1828
 				if (!@file_exists($tables_current))
1830 1829
 				{
1831 1830
 					$all_app_data[$app] = False;
@@ -1834,7 +1833,7 @@  discard block
 block discarded – undo
1834 1833
 				{
1835 1834
 					$phpgw_baseline = null;
1836 1835
 					include($tables_current);
1837
-					$all_app_data[$app] =& $phpgw_baseline;
1836
+					$all_app_data[$app] = & $phpgw_baseline;
1838 1837
 					unset($phpgw_baseline);
1839 1838
 
1840 1839
 					if (isset($all_app_data[$app][$table]))
@@ -1849,17 +1848,17 @@  discard block
 block discarded – undo
1849 1848
 		{
1850 1849
 			$app = $this->app ? $this->app : $GLOBALS['egw_info']['flags']['currentapp'];
1851 1850
 		}
1852
-		$app_data =& $all_app_data[$app];
1851
+		$app_data = & $all_app_data[$app];
1853 1852
 
1854 1853
 		if (!isset($app_data))
1855 1854
 		{
1856
-			$tables_current = EGW_INCLUDE_ROOT . "/$app/setup/tables_current.inc.php";
1855
+			$tables_current = EGW_INCLUDE_ROOT."/$app/setup/tables_current.inc.php";
1857 1856
 			if (!@file_exists($tables_current))
1858 1857
 			{
1859 1858
 				return $app_data = False;
1860 1859
 			}
1861 1860
 			include($tables_current);
1862
-			$app_data =& $phpgw_baseline;
1861
+			$app_data = & $phpgw_baseline;
1863 1862
 			unset($phpgw_baseline);
1864 1863
 		}
1865 1864
 		if ($table && (!$app_data || !isset($app_data[$table])))
@@ -1882,14 +1881,14 @@  discard block
 block discarded – undo
1882 1881
 	 * @param string $attribute='comment' what field to return, NULL for array with all fields, default 'comment' to return the comment
1883 1882
 	 * @return string|array NULL if table or column or attribute not found
1884 1883
 	 */
1885
-	/* static */ function get_column_attribute($column,$table,$app=null,$attribute='comment')
1884
+	/* static */ function get_column_attribute($column, $table, $app = null, $attribute = 'comment')
1886 1885
 	{
1887
-		static $cached_columns=null,$cached_table=null;	// some caching
1886
+		static $cached_columns = null, $cached_table = null; // some caching
1888 1887
 
1889 1888
 		if ($cached_table !== $table || is_null($cached_columns))
1890 1889
 		{
1891 1890
 			$db = isset($this) ? $this : $GLOBALS['egw']->db;
1892
-			$table_def = $db->get_table_definitions($app,$table);
1891
+			$table_def = $db->get_table_definitions($app, $table);
1893 1892
 			$cached_columns = is_array($table_def) ? $table_def['fd'] : false;
1894 1893
 		}
1895 1894
 		if ($cached_columns === false) return null;
@@ -1913,39 +1912,39 @@  discard block
 block discarded – undo
1913 1912
 	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
1914 1913
 	* @return ADORecordSet or false, if the query fails
1915 1914
 	*/
1916
-	function insert($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False)
1915
+	function insert($table, $data, $where, $line, $file, $app = False, $use_prepared_statement = false, $table_def = False)
1917 1916
 	{
1918
-		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app')</p>\n";
1917
+		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data, True).",".print_r($where, True).",$line,$file,'$app')</p>\n";
1919 1918
 
1920
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
1919
+		if (!$table_def) $table_def = $this->get_table_definitions($app, $table);
1921 1920
 
1922 1921
 		$sql_append = '';
1923 1922
 		$cmd = 'INSERT';
1924 1923
 		if (is_array($where) && count($where))
1925 1924
 		{
1926
-			switch($this->Type)
1925
+			switch ($this->Type)
1927 1926
 			{
1928 1927
 				case 'sapdb': case 'maxdb':
1929 1928
 					$sql_append = ' UPDATE DUPLICATES';
1930 1929
 					break;
1931 1930
 				case 'mysql':
1932 1931
 					// use replace if primary keys are included
1933
-					if (count(array_intersect(array_keys($where),(array)$table_def['pk'])) == count($table_def['pk']))
1932
+					if (count(array_intersect(array_keys($where), (array)$table_def['pk'])) == count($table_def['pk']))
1934 1933
 					{
1935 1934
 						$cmd = 'REPLACE';
1936 1935
 						break;
1937 1936
 					}
1938 1937
 					// fall through !!!
1939 1938
 				default:
1940
-					$this->select($table,'count(*)',$where,$line,$file);
1939
+					$this->select($table, 'count(*)', $where, $line, $file);
1941 1940
 					if ($this->next_record() && $this->f(0))
1942 1941
 					{
1943
-						return !!$this->update($table,$data,$where,$line,$file,$app,$use_prepared_statement,$table_def);
1942
+						return !!$this->update($table, $data, $where, $line, $file, $app, $use_prepared_statement, $table_def);
1944 1943
 					}
1945 1944
 					break;
1946 1945
 			}
1947 1946
 			// the checked values need to be inserted too, value in data has precedence, also cant insert sql strings (numerical id)
1948
-			foreach($where as $column => $value)
1947
+			foreach ($where as $column => $value)
1949 1948
 			{
1950 1949
 				if (!is_numeric($column) && !isset($data[$column]) &&
1951 1950
 					// skip auto-id of 0 or NULL, as PostgreSQL does NOT create an auto-id, if they are given
@@ -1965,24 +1964,24 @@  discard block
 block discarded – undo
1965 1964
 			if ($where) throw new egw_exception_wrong_parameter('Can NOT use $where together with multiple data rows in $data!');
1966 1965
 
1967 1966
 			$sql = "$cmd INTO $table ";
1968
-			foreach($data as $k => $d)
1967
+			foreach ($data as $k => $d)
1969 1968
 			{
1970 1969
 				if (!$k)
1971 1970
 				{
1972
-					$sql .= $this->column_data_implode(',',$d,'VALUES',true,$table_def['fd']);
1971
+					$sql .= $this->column_data_implode(',', $d, 'VALUES', true, $table_def['fd']);
1973 1972
 				}
1974 1973
 				else
1975 1974
 				{
1976
-					$sql .= ",\n(".$this->column_data_implode(',',$d,false,true,$table_def['fd']).')';
1975
+					$sql .= ",\n(".$this->column_data_implode(',', $d, false, true, $table_def['fd']).')';
1977 1976
 				}
1978 1977
 			}
1979 1978
 			$sql .= $sql_append;
1980 1979
 		}
1981 1980
 		elseif ($use_prepared_statement && $this->Link_ID->_bindInputArray)	// eg. MaxDB
1982 1981
 		{
1983
-			$this->Link_ID->Param(false);	// reset param-counter
1982
+			$this->Link_ID->Param(false); // reset param-counter
1984 1983
 			$cols = array_keys($data);
1985
-			foreach($cols as $k => $col)
1984
+			foreach ($cols as $k => $col)
1986 1985
 			{
1987 1986
 				if (!isset($table_def['fd'][$col]))	// ignore columns not in this table
1988 1987
 				{
@@ -1991,7 +1990,7 @@  discard block
 block discarded – undo
1991 1990
 				}
1992 1991
 				$params[] = $this->Link_ID->Param($col);
1993 1992
 			}
1994
-			$sql = "$cmd INTO $table (".implode(',',$cols).') VALUES ('.implode(',',$params).')'.$sql_append;
1993
+			$sql = "$cmd INTO $table (".implode(',', $cols).') VALUES ('.implode(',', $params).')'.$sql_append;
1995 1994
 			// check if we already prepared that statement
1996 1995
 			if (!isset($this->prepared_sql[$sql]))
1997 1996
 			{
@@ -2002,10 +2001,10 @@  discard block
 block discarded – undo
2002 2001
 		}
2003 2002
 		else
2004 2003
 		{
2005
-			$sql = "$cmd INTO $table ".$this->column_data_implode(',',$data,'VALUES',true,$table_def['fd']).$sql_append;
2004
+			$sql = "$cmd INTO $table ".$this->column_data_implode(',', $data, 'VALUES', true, $table_def['fd']).$sql_append;
2006 2005
 		}
2007
-		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app') sql='$sql'</p>\n";
2008
-		return $this->query($sql,$line,$file,0,-1,$inputarr);
2006
+		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data, True).",".print_r($where, True).",$line,$file,'$app') sql='$sql'</p>\n";
2007
+		return $this->query($sql, $line, $file, 0, -1, $inputarr);
2009 2008
 	}
2010 2009
 
2011 2010
 	/**
@@ -2023,10 +2022,10 @@  discard block
 block discarded – undo
2023 2022
 	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2024 2023
 	* @return ADORecordSet or false, if the query fails
2025 2024
 	*/
2026
-	function update($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False)
2025
+	function update($table, $data, $where, $line, $file, $app = False, $use_prepared_statement = false, $table_def = False)
2027 2026
 	{
2028
-		if ($this->Debug) echo "<p>db::update('$table',".print_r($data,true).','.print_r($where,true).",$line,$file,'$app')</p>\n";
2029
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2027
+		if ($this->Debug) echo "<p>db::update('$table',".print_r($data, true).','.print_r($where, true).",$line,$file,'$app')</p>\n";
2028
+		if (!$table_def) $table_def = $this->get_table_definitions($app, $table);
2030 2029
 
2031 2030
 		$blobs2update = array();
2032 2031
 		// SapDB/MaxDB cant update LONG columns / blob's: if a blob-column is included in the update we remember it in $blobs2update
@@ -2037,7 +2036,7 @@  discard block
 block discarded – undo
2037 2036
 			case 'maxdb':
2038 2037
 				if ($use_prepared_statement) break;
2039 2038
 				// check if data contains any LONG columns
2040
-				foreach($data as $col => $val)
2039
+				foreach ($data as $col => $val)
2041 2040
 				{
2042 2041
 					switch ($table_def['fd'][$col]['type'])
2043 2042
 					{
@@ -2051,7 +2050,7 @@  discard block
 block discarded – undo
2051 2050
 				}
2052 2051
 				break;
2053 2052
 		}
2054
-		$where_str = $this->column_data_implode(' AND ',$where,True,true,$table_def['fd']);
2053
+		$where_str = $this->column_data_implode(' AND ', $where, True, true, $table_def['fd']);
2055 2054
 
2056 2055
 		if (self::$tablealiases && isset(self::$tablealiases[$table]))
2057 2056
 		{
@@ -2062,13 +2061,13 @@  discard block
 block discarded – undo
2062 2061
 			$inputarr = false;
2063 2062
 			if ($use_prepared_statement && $this->Link_ID->_bindInputArray)	// eg. MaxDB
2064 2063
 			{
2065
-				$this->Link_ID->Param(false);	// reset param-counter
2066
-				foreach($data as $col => $val)
2064
+				$this->Link_ID->Param(false); // reset param-counter
2065
+				foreach ($data as $col => $val)
2067 2066
 				{
2068
-					if (!isset($table_def['fd'][$col])) continue;	// ignore columns not in this table
2067
+					if (!isset($table_def['fd'][$col])) continue; // ignore columns not in this table
2069 2068
 					$params[] = $this->name_quote($col).'='.$this->Link_ID->Param($col);
2070 2069
 				}
2071
-				$sql = "UPDATE $table SET ".implode(',',$params).' WHERE '.$where_str;
2070
+				$sql = "UPDATE $table SET ".implode(',', $params).' WHERE '.$where_str;
2072 2071
 				// check if we already prepared that statement
2073 2072
 				if (!isset($this->prepared_sql[$sql]))
2074 2073
 				{
@@ -2080,19 +2079,19 @@  discard block
 block discarded – undo
2080 2079
 			else
2081 2080
 			{
2082 2081
 				$sql = "UPDATE $table SET ".
2083
-					$this->column_data_implode(',',$data,True,true,$table_def['fd']).' WHERE '.$where_str;
2082
+					$this->column_data_implode(',', $data, True, true, $table_def['fd']).' WHERE '.$where_str;
2084 2083
 			}
2085
-			$ret = $this->query($sql,$line,$file,0,-1,$inputarr);
2084
+			$ret = $this->query($sql, $line, $file, 0, -1, $inputarr);
2086 2085
 			if ($this->Debug) echo "<p>db::query('$sql',$line,$file)</p>\n";
2087 2086
 		}
2088 2087
 		// if we have any blobs to update, we do so now
2089 2088
 		if (($ret || !count($data)) && count($blobs2update))
2090 2089
 		{
2091
-			foreach($blobs2update as $col => $val)
2090
+			foreach ($blobs2update as $col => $val)
2092 2091
 			{
2093
-				$ret = $this->Link_ID->UpdateBlob($table,$col,$val,$where_str,$table_def['fd'][$col]['type'] == 'blob' ? 'BLOB' : 'CLOB');
2092
+				$ret = $this->Link_ID->UpdateBlob($table, $col, $val, $where_str, $table_def['fd'][$col]['type'] == 'blob' ? 'BLOB' : 'CLOB');
2094 2093
 				if ($this->Debug) echo "<p>adodb::UpdateBlob('$table','$col','$val','$where_str') = '$ret'</p>\n";
2095
-				if (!$ret) throw new egw_exception_db_invalid_sql("Error in UpdateBlob($table,$col,\$val,$where_str)",$line,$file);
2094
+				if (!$ret) throw new egw_exception_db_invalid_sql("Error in UpdateBlob($table,$col,\$val,$where_str)", $line, $file);
2096 2095
 			}
2097 2096
 		}
2098 2097
 		return $ret;
@@ -2111,18 +2110,18 @@  discard block
 block discarded – undo
2111 2110
 	* @param array|bool $table_def use this table definition. If False, the table definition will be read from tables_baseline
2112 2111
 	* @return ADORecordSet or false, if the query fails
2113 2112
 	*/
2114
-	function delete($table,$where,$line,$file,$app=False,$table_def=False)
2113
+	function delete($table, $where, $line, $file, $app = False, $table_def = False)
2115 2114
 	{
2116
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2115
+		if (!$table_def) $table_def = $this->get_table_definitions($app, $table);
2117 2116
 
2118 2117
 		if (self::$tablealiases && isset(self::$tablealiases[$table]))
2119 2118
 		{
2120 2119
 			$table = self::$tablealiases[$table];
2121 2120
 		}
2122 2121
 		$sql = "DELETE FROM $table WHERE ".
2123
-			$this->column_data_implode(' AND ',$where,True,False,$table_def['fd']);
2122
+			$this->column_data_implode(' AND ', $where, True, False, $table_def['fd']);
2124 2123
 
2125
-		return $this->query($sql,$line,$file);
2124
+		return $this->query($sql, $line, $file);
2126 2125
 	}
2127 2126
 
2128 2127
 	/**
@@ -2145,12 +2144,12 @@  discard block
 block discarded – undo
2145 2144
 	 */
2146 2145
 	function expression($table_def/*,$args, ...*/)
2147 2146
 	{
2148
-		if (!is_array($table_def)) $table_def = $this->get_table_definitions(true,$table_def);
2147
+		if (!is_array($table_def)) $table_def = $this->get_table_definitions(true, $table_def);
2149 2148
 		$sql = '';
2150 2149
 		$ignore_next = 0;
2151
-		foreach(func_get_args() as $n => $arg)
2150
+		foreach (func_get_args() as $n => $arg)
2152 2151
 		{
2153
-			if ($n < 1) continue;	// table-name
2152
+			if ($n < 1) continue; // table-name
2154 2153
 
2155 2154
 			if ($ignore_next)
2156 2155
 			{
@@ -2159,7 +2158,7 @@  discard block
 block discarded – undo
2159 2158
 			}
2160 2159
 			if (is_null($arg)) $arg = False;
2161 2160
 
2162
-			switch(gettype($arg))
2161
+			switch (gettype($arg))
2163 2162
 			{
2164 2163
 				case 'string':
2165 2164
 					$sql .= $arg;
@@ -2168,7 +2167,7 @@  discard block
 block discarded – undo
2168 2167
 					$ignore_next += !$arg ? 2 : 0;
2169 2168
 					break;
2170 2169
 				case 'array':
2171
-					$sql .= $this->column_data_implode(' AND ',$arg,True,False,$table_def['fd']);
2170
+					$sql .= $this->column_data_implode(' AND ', $arg, True, False, $table_def['fd']);
2172 2171
 					break;
2173 2172
 			}
2174 2173
 		}
@@ -2195,18 +2194,18 @@  discard block
 block discarded – undo
2195 2194
 	* @param int $fetchmode =egw_db::FETCH_ASSOC egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
2196 2195
 	* @return ADORecordSet or false, if the query fails
2197 2196
 	*/
2198
-	function select($table,$cols,$where,$line,$file,$offset=False,$append='',$app=False,$num_rows=0,$join='',$table_def=False,$fetchmode=egw_db::FETCH_ASSOC)
2197
+	function select($table, $cols, $where, $line, $file, $offset = False, $append = '', $app = False, $num_rows = 0, $join = '', $table_def = False, $fetchmode = egw_db::FETCH_ASSOC)
2199 2198
 	{
2200
-		if ($this->Debug) echo "<p>db::select('$table',".print_r($cols,True).",".print_r($where,True).",$line,$file,$offset,'$app',$num_rows,'$join')</p>\n";
2199
+		if ($this->Debug) echo "<p>db::select('$table',".print_r($cols, True).",".print_r($where, True).",$line,$file,$offset,'$app',$num_rows,'$join')</p>\n";
2201 2200
 
2202
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2201
+		if (!$table_def) $table_def = $this->get_table_definitions($app, $table);
2203 2202
 		if (is_array($cols))
2204 2203
 		{
2205
-			$cols = implode(',',$cols);
2204
+			$cols = implode(',', $cols);
2206 2205
 		}
2207 2206
 		if (is_array($where))
2208 2207
 		{
2209
-			$where = $this->column_data_implode(' AND ',$where,True,False,$table_def['fd']);
2208
+			$where = $this->column_data_implode(' AND ', $where, True, False, $table_def['fd']);
2210 2209
 		}
2211 2210
 		if (self::$tablealiases && isset(self::$tablealiases[$table]))
2212 2211
 		{
@@ -2215,7 +2214,7 @@  discard block
 block discarded – undo
2215 2214
 		$sql = "SELECT $cols FROM $table $join";
2216 2215
 
2217 2216
 		// if we have a where clause, we need to add it together with the WHERE statement, if thats not in the join
2218
-		if ($where) $sql .= (strpos($join,"WHERE")!==false) ? ' AND ('.$where.')' : ' WHERE '.$where;
2217
+		if ($where) $sql .= (strpos($join, "WHERE") !== false) ? ' AND ('.$where.')' : ' WHERE '.$where;
2219 2218
 
2220 2219
 		if ($append) $sql .= ' '.$append;
2221 2220
 
@@ -2225,7 +2224,7 @@  discard block
 block discarded – undo
2225 2224
 		{
2226 2225
 			return $sql;
2227 2226
 		}
2228
-		return $this->query($sql,$line,$file,$offset,$offset===False ? -1 : (int)$num_rows,false,$fetchmode);
2227
+		return $this->query($sql, $line, $file, $offset, $offset === False ? -1 : (int)$num_rows, false, $fetchmode);
2229 2228
 	}
2230 2229
 
2231 2230
 	/**
@@ -2243,34 +2242,34 @@  discard block
 block discarded – undo
2243 2242
 	* @param int $fetchmode =egw_db::FETCH_ASSOC egw_db::FETCH_BOTH (default), egw_db::FETCH_ASSOC or egw_db::FETCH_NUM
2244 2243
 	* @return ADORecordSet or false, if the query fails
2245 2244
 	*/
2246
-	function union($selects,$line,$file,$order_by='',$offset=false,$num_rows=0,$fetchmode=egw_db::FETCH_ASSOC)
2245
+	function union($selects, $line, $file, $order_by = '', $offset = false, $num_rows = 0, $fetchmode = egw_db::FETCH_ASSOC)
2247 2246
 	{
2248
-		if ($this->Debug) echo "<p>db::union(".print_r($selects,True).",$line,$file,$order_by,$offset,$num_rows)</p>\n";
2247
+		if ($this->Debug) echo "<p>db::union(".print_r($selects, True).",$line,$file,$order_by,$offset,$num_rows)</p>\n";
2249 2248
 
2250 2249
 		$union = array();
2251
-		foreach($selects as $select)
2250
+		foreach ($selects as $select)
2252 2251
 		{
2253
-			$union[] = call_user_func_array(array($this,'select'),array(
2252
+			$union[] = call_user_func_array(array($this, 'select'), array(
2254 2253
 				$select['table'],
2255 2254
 				$select['cols'],
2256 2255
 				$select['where'],
2257
-				false,	// line
2258
-				false,	// file
2259
-				false,	// offset
2256
+				false, // line
2257
+				false, // file
2258
+				false, // offset
2260 2259
 				$select['append'],
2261 2260
 				$select['app'],
2262
-				0,		// num_rows,
2261
+				0, // num_rows,
2263 2262
 				$select['join'],
2264 2263
 				$select['table_def'],
2265 2264
 			));
2266 2265
 		}
2267
-		$sql = count($union) > 1 ? '(' . implode(")\nUNION\n(",$union).')' : 'SELECT DISTINCT'.substr($union[0],6);
2266
+		$sql = count($union) > 1 ? '('.implode(")\nUNION\n(", $union).')' : 'SELECT DISTINCT'.substr($union[0], 6);
2268 2267
 
2269
-		if ($order_by) $sql .=  (!stristr($order_by,'ORDER BY') ? "\nORDER BY " : '').$order_by;
2268
+		if ($order_by) $sql .= (!stristr($order_by, 'ORDER BY') ? "\nORDER BY " : '').$order_by;
2270 2269
 
2271 2270
 		if ($this->Debug) echo "<p>sql='$sql'</p>";
2272 2271
 
2273
-		return $this->query($sql,$line,$file,$offset,$offset===False ? -1 : (int)$num_rows,false,$fetchmode);
2272
+		return $this->query($sql, $line, $file, $offset, $offset === False ? -1 : (int)$num_rows, false, $fetchmode);
2274 2273
 	}
2275 2274
 
2276 2275
 	/**
@@ -2280,12 +2279,12 @@  discard block
 block discarded – undo
2280 2279
 	 * @param string|array $strip
2281 2280
 	 * @return array
2282 2281
 	 */
2283
-	static function strip_array_keys($arr,$strip)
2282
+	static function strip_array_keys($arr, $strip)
2284 2283
 	{
2285 2284
 		$keys = array_keys($arr);
2286 2285
 
2287
-		return array_walk($keys,create_function('&$v,$k,$strip','$v = str_replace($strip,\'\',$v);'),$strip) ?
2288
-			array_combine($keys,$arr) : $arr;
2286
+		return array_walk($keys, create_function('&$v,$k,$strip', '$v = str_replace($strip,\'\',$v);'), $strip) ?
2287
+			array_combine($keys, $arr) : $arr;
2289 2288
 	}
2290 2289
 }
2291 2290
 
@@ -2375,13 +2374,13 @@  discard block
 block discarded – undo
2375 2374
 	 * @param array $params =array() additional parameters, row is always first parameter
2376 2375
 	 * @param $key_callback =null optional callback, if you want different keys
2377 2376
 	 */
2378
-	public function __construct(Traversable $rs, $callback, $params=array(), $key_callback=null)
2377
+	public function __construct(Traversable $rs, $callback, $params = array(), $key_callback = null)
2379 2378
 	{
2380 2379
 		$this->callback = $callback;
2381 2380
 		$this->params = $params;
2382 2381
 		$this->key_callback = $key_callback;
2383 2382
 
2384
-		if (is_a($rs,'IteratorAggregate'))
2383
+		if (is_a($rs, 'IteratorAggregate'))
2385 2384
 		{
2386 2385
 			$this->rs = $rs->getIterator();
2387 2386
 		}
@@ -2398,7 +2397,7 @@  discard block
 block discarded – undo
2398 2397
 	 */
2399 2398
 	public function current()
2400 2399
 	{
2401
-		if (is_a($this->rs,'iterator'))
2400
+		if (is_a($this->rs, 'iterator'))
2402 2401
 		{
2403 2402
 			$params = $this->params;
2404 2403
 			array_unshift($params, $this->rs->current());
@@ -2414,11 +2413,10 @@  discard block
 block discarded – undo
2414 2413
 	 */
2415 2414
 	public function key()
2416 2415
 	{
2417
-		if (is_a($this->rs,'iterator'))
2416
+		if (is_a($this->rs, 'iterator'))
2418 2417
 		{
2419 2418
 			return $this->key_callback ?
2420
-				call_user_func($this->key_callback, $this->rs->current()) :
2421
-				$this->rs->key();
2419
+				call_user_func($this->key_callback, $this->rs->current()) : $this->rs->key();
2422 2420
 		}
2423 2421
 		return 0;
2424 2422
 	}
@@ -2428,7 +2426,7 @@  discard block
 block discarded – undo
2428 2426
 	 */
2429 2427
 	public function next()
2430 2428
 	{
2431
-		if (is_a($this->rs,'iterator'))
2429
+		if (is_a($this->rs, 'iterator'))
2432 2430
 		{
2433 2431
 			return $this->rs->next();
2434 2432
 		}
@@ -2439,7 +2437,7 @@  discard block
 block discarded – undo
2439 2437
 	 */
2440 2438
 	public function rewind()
2441 2439
 	{
2442
-		if (is_a($this->rs,'iterator'))
2440
+		if (is_a($this->rs, 'iterator'))
2443 2441
 		{
2444 2442
 			return $this->rs->rewind();
2445 2443
 		}
@@ -2450,9 +2448,9 @@  discard block
 block discarded – undo
2450 2448
 	 *
2451 2449
 	 * @return boolean
2452 2450
 	 */
2453
-	public function valid ()
2451
+	public function valid()
2454 2452
 	{
2455
-		if (is_a($this->rs,'iterator'))
2453
+		if (is_a($this->rs, 'iterator'))
2456 2454
 		{
2457 2455
 			return $this->rs->valid();
2458 2456
 		}
Please login to merge, or discard this patch.
Braces   +250 added lines, -63 removed lines patch added patch discarded remove patch
@@ -399,7 +399,10 @@  discard block
 block discarded – undo
399 399
 			if ($state['wsrep_local_state_comment'] == 'Synced' ||
400 400
 				// if we have only 2 nodes (2. one starting), we can only use the donor
401 401
 				$state['wsrep_local_state_comment'] == 'Donor/Desynced' &&
402
-					$state['wsrep_cluster_size'] == 2) return;
402
+					$state['wsrep_cluster_size'] == 2)
403
+			{
404
+				return;
405
+			}
403 406
 
404 407
 			throw new egw_exception_db_connection('Node is NOT Synced! '.array2string($state));
405 408
 		}
@@ -418,7 +421,10 @@  discard block
 block discarded – undo
418 421
 		$hosts = explode(';', $this->Host[0] == '@' ? getenv(substr($this->Host, 1)) : $this->Host);
419 422
 		$num_hosts = count($hosts);
420 423
 		$n =& egw_cache::getSession(__CLASS__, $this->Host);
421
-		if (!isset($n)) $n = 0;
424
+		if (!isset($n))
425
+		{
426
+			$n = 0;
427
+		}
422 428
 
423 429
 		if ($next && ++$n >= $num_hosts+2)
424 430
 		{
@@ -448,7 +454,10 @@  discard block
 block discarded – undo
448 454
 			foreach(array('Database','User','Password','Port','Type') as $name)
449 455
 			{
450 456
 				$$name = $this->$name;
451
-				if (${$name}[0] == '@' && $name != 'Password') $$name = getenv(substr($$name, 1));
457
+				if (${$name}[0] == '@' && $name != 'Password')
458
+				{
459
+					$$name = getenv(substr($$name, 1));
460
+				}
452 461
 			}
453 462
 			$this->setupType = $php_extension = $Type;
454 463
 
@@ -467,7 +476,10 @@  discard block
 block discarded – undo
467 476
 					$Type = 'mssql';
468 477
 					// fall through
469 478
 				case 'mssql':
470
-					if ($Port) $Host .= ','.$Port;
479
+					if ($Port)
480
+					{
481
+						$Host .= ','.$Port;
482
+					}
471 483
 					break;
472 484
 
473 485
 				case 'odbc_oracle':
@@ -493,7 +505,10 @@  discard block
 block discarded – undo
493 505
 					$this->Type = 'mysql';		// need to be "mysql", so apps can check just for "mysql"!
494 506
 					// fall through
495 507
 				default:
496
-					if ($Port) $Host .= ':'.$Port;
508
+					if ($Port)
509
+					{
510
+						$Host .= ':'.$Port;
511
+					}
497 512
 					break;
498 513
 			}
499 514
 			if (!isset($GLOBALS['egw']->ADOdb) ||	// we have no connection so far
@@ -508,10 +523,13 @@  discard block
 block discarded – undo
508 523
 				{
509 524
 					throw new egw_exception_db_connection("Necessary php database support for $this->Type (".PHP_SHLIB_PREFIX.$php_extension.'.'.PHP_SHLIB_SUFFIX.") not loaded and can't be loaded, exiting !!!");
510 525
 				}
511
-				if (!isset($GLOBALS['egw']->ADOdb))	// use the global object to store the connection
526
+				if (!isset($GLOBALS['egw']->ADOdb))
527
+				{
528
+					// use the global object to store the connection
512 529
 				{
513 530
 					$this->Link_ID =& $GLOBALS['egw']->ADOdb;
514 531
 				}
532
+				}
515 533
 				else
516 534
 				{
517 535
 					$this->privat_Link_ID = True;	// remember that we use a privat Link_ID for disconnect
@@ -602,7 +620,11 @@  discard block
 block discarded – undo
602 620
 	 */
603 621
 	function __sleep()
604 622
 	{
605
-		if (!empty($this->setupType)) $this->Type = $this->setupType;	// restore Type eg. to mysqli
623
+		if (!empty($this->setupType))
624
+		{
625
+			$this->Type = $this->setupType;
626
+		}
627
+		// restore Type eg. to mysqli
606 628
 
607 629
 		$vars = get_object_vars($this);
608 630
 		unset($vars['Link_ID']);
@@ -665,7 +687,10 @@  discard block
 block discarded – undo
665 687
 		unset($this->Link_ID);
666 688
 		$this->Link_ID = 0;
667 689
 
668
-		if (!empty($this->setupType)) $this->Type = $this->setupType;
690
+		if (!empty($this->setupType))
691
+		{
692
+			$this->Type = $this->setupType;
693
+		}
669 694
 	}
670 695
 
671 696
 	/**
@@ -810,16 +835,22 @@  discard block
 block discarded – undo
810 835
 		}
811 836
 		if (!$this->Query_ID)
812 837
 		{
813
-			if ($reconnect && $this->Type == 'mysql' && $this->Errno == 2006)	// Server has gone away
838
+			if ($reconnect && $this->Type == 'mysql' && $this->Errno == 2006)
839
+			{
840
+				// Server has gone away
814 841
 			{
815 842
 				$this->disconnect();
843
+			}
816 844
 				return $this->query($Query_String, $line, $file, $offset, $num_rows, $inputarr, $fetchmode, false);
817 845
 			}
818 846
 			throw new egw_exception_db_invalid_sql("Invalid SQL: ".(is_array($Query_String)?$Query_String[0]:$Query_String).
819 847
 				"\n$this->Error ($this->Errno)".
820 848
 				($inputarr ? "\nParameters: '".implode("','",$inputarr)."'":''), $this->Errno);
821 849
 		}
822
-		elseif(empty($this->Query_ID->sql)) $this->Query_ID->sql = $Query_String;
850
+		elseif(empty($this->Query_ID->sql))
851
+		{
852
+			$this->Query_ID->sql = $Query_String;
853
+		}
823 854
 		return $this->Query_ID;
824 855
 	}
825 856
 
@@ -854,10 +885,13 @@  discard block
 block discarded – undo
854 885
 		{
855 886
 			throw new egw_exception_db('next_record called with no query pending.');
856 887
 		}
857
-		if ($this->Row)	// first row is already fetched
888
+		if ($this->Row)
889
+		{
890
+			// first row is already fetched
858 891
 		{
859 892
 			$this->Query_ID->MoveNext();
860 893
 		}
894
+		}
861 895
 		++$this->Row;
862 896
 
863 897
 		$this->Record = $this->Query_ID->fields;
@@ -866,12 +900,15 @@  discard block
 block discarded – undo
866 900
 		{
867 901
 			return False;
868 902
 		}
869
-		if ($this->capabilities[self::CAPABILITY_NAME_CASE] == 'upper')	// maxdb, oracle, ...
903
+		if ($this->capabilities[self::CAPABILITY_NAME_CASE] == 'upper')
904
+		{
905
+			// maxdb, oracle, ...
870 906
 		{
871 907
 			switch($fetch_mode)
872 908
 			{
873 909
 				case egw_db::FETCH_ASSOC:
874 910
 					$this->Record = array_change_key_case($this->Record);
911
+		}
875 912
 					break;
876 913
 				case egw_db::FETCH_NUM:
877 914
 					$this->Record = array_values($this->Record);
@@ -976,9 +1013,12 @@  discard block
 block discarded – undo
976 1013
 		}
977 1014
 		$id = $this->Link_ID->PO_Insert_ID($table,$field);	// simulates Insert_ID with "SELECT MAX($field) FROM $table" if not native availible
978 1015
 
979
-		if ($id === False)	// function not supported
1016
+		if ($id === False)
1017
+		{
1018
+			// function not supported
980 1019
 		{
981 1020
 			echo "<p>db::get_last_insert_id(table='$table',field='$field') not yet implemented for db-type '$this->Type' OR no insert operation before</p>\n";
1021
+		}
982 1022
 			echo '<p>'.function_backtrace()."</p>\n";
983 1023
 			return -1;
984 1024
 		}
@@ -1005,7 +1045,8 @@  discard block
 block discarded – undo
1005 1045
 	* @return bool True if sucessful, False if fails
1006 1046
 	*/
1007 1047
 	function unlock()
1008
-	{}
1048
+	{
1049
+}
1009 1050
 
1010 1051
 	/**
1011 1052
 	* Get the number of rows affected by last update or delete
@@ -1014,7 +1055,10 @@  discard block
 block discarded – undo
1014 1055
 	*/
1015 1056
 	function affected_rows()
1016 1057
 	{
1017
-		if ($this->log_updates) return 0;
1058
+		if ($this->log_updates)
1059
+		{
1060
+			return 0;
1061
+		}
1018 1062
 
1019 1063
 		if (!$this->Link_ID && !$this->connect())
1020 1064
 		{
@@ -1110,7 +1154,10 @@  discard block
 block discarded – undo
1110 1154
 		{
1111 1155
 			if (!is_numeric($column))
1112 1156
 			{
1113
-				if ($strip) $column = str_replace($strip,'',$column);
1157
+				if ($strip)
1158
+				{
1159
+					$column = str_replace($strip,'',$column);
1160
+				}
1114 1161
 
1115 1162
 				$result[$column] = $value;
1116 1163
 			}
@@ -1143,9 +1190,18 @@  discard block
 block discarded – undo
1143 1190
 		{
1144 1191
 			// for backwards compatibilty (depreciated)
1145 1192
 			$flags = null;
1146
-			if($column->auto_increment) $flags .= "auto_increment ";
1147
-			if($column->primary_key) $flags .= "primary_key ";
1148
-			if($column->binary) $flags .= "binary ";
1193
+			if($column->auto_increment)
1194
+			{
1195
+				$flags .= "auto_increment ";
1196
+			}
1197
+			if($column->primary_key)
1198
+			{
1199
+				$flags .= "primary_key ";
1200
+			}
1201
+			if($column->binary)
1202
+			{
1203
+				$flags .= "binary ";
1204
+			}
1149 1205
 
1150 1206
 			$metadata[$i] = array(
1151 1207
 				'table' => $table,
@@ -1182,7 +1238,10 @@  discard block
 block discarded – undo
1182 1238
 	 */
1183 1239
 	function table_names($just_name=false)
1184 1240
 	{
1185
-		if (!$this->Link_ID) $this->connect();
1241
+		if (!$this->Link_ID)
1242
+		{
1243
+			$this->connect();
1244
+		}
1186 1245
 		if (!$this->Link_ID)
1187 1246
 		{
1188 1247
 			return False;
@@ -1334,8 +1393,14 @@  discard block
 block discarded – undo
1334 1393
 		{
1335 1394
 			case 'mysql':
1336 1395
 				$sql = 'GROUP_CONCAT('.$expr;
1337
-				if ($order_by) $sql .= ' ORDER BY '.$order_by;
1338
-				if ($separator != ',') $sql .= ' SEPARATOR '.$this->quote($separator);
1396
+				if ($order_by)
1397
+				{
1398
+					$sql .= ' ORDER BY '.$order_by;
1399
+				}
1400
+				if ($separator != ',')
1401
+				{
1402
+					$sql .= ' SEPARATOR '.$this->quote($separator);
1403
+				}
1339 1404
 				$sql .= ')';
1340 1405
 				break;
1341 1406
 
@@ -1345,7 +1410,10 @@  discard block
 block discarded – undo
1345 1410
 					return false;
1346 1411
 				}
1347 1412
 				$sql = 'ARRAY_TO_STRING(ARRAY_AGG('.$expr;
1348
-				if ($order_by) $sql .= ' ORDER BY '.$order_by;
1413
+				if ($order_by)
1414
+				{
1415
+					$sql .= ' ORDER BY '.$order_by;
1416
+				}
1349 1417
 				$sql .= '), '.$this->quote($separator).')';
1350 1418
 				break;
1351 1419
 
@@ -1568,12 +1636,18 @@  discard block
 block discarded – undo
1568 1636
 	*/
1569 1637
 	function quote($value,$type=False,$not_null=true,$length=null,$glue=',')
1570 1638
 	{
1571
-		if ($this->Debug) echo "<p>db::quote(".(is_null($value)?'NULL':"'$value'").",'$type','$not_null')</p>\n";
1639
+		if ($this->Debug)
1640
+		{
1641
+			echo "<p>db::quote(".(is_null($value)?'NULL':"'$value'").",'$type','$not_null')</p>\n";
1642
+		}
1572 1643
 
1573
-		if (!$not_null && is_null($value))	// writing unset php-variables and those set to NULL now as SQL NULL
1644
+		if (!$not_null && is_null($value))
1645
+		{
1646
+			// writing unset php-variables and those set to NULL now as SQL NULL
1574 1647
 		{
1575 1648
 			return 'NULL';
1576 1649
 		}
1650
+		}
1577 1651
 		switch($type)
1578 1652
 		{
1579 1653
 			case 'int':
@@ -1588,10 +1662,13 @@  discard block
 block discarded – undo
1588 1662
 				// There for we have to keep it as float by using round instead the int cast.
1589 1663
 				return is_float($value) ? round($value) : (int) $value;
1590 1664
 			case 'bool':
1591
-				if ($this->Type == 'mysql')		// maybe it's not longer necessary with mysql5
1665
+				if ($this->Type == 'mysql')
1666
+				{
1667
+					// maybe it's not longer necessary with mysql5
1592 1668
 				{
1593 1669
 					return $value ? 1 : 0;
1594 1670
 				}
1671
+				}
1595 1672
 				return $value ? 'true' : 'false';
1596 1673
 			case 'float':
1597 1674
 			case 'decimal':
@@ -1639,7 +1716,10 @@  discard block
 block discarded – undo
1639 1716
 		}
1640 1717
 		// casting boolean explicitly to string, as ADODB_postgres64::qstr() has an unwanted special handling
1641 1718
 		// for boolean types, causing it to return "true" or "false" and not a quoted string like "'1'"!
1642
-		if (is_bool($value)) $value = (string)$value;
1719
+		if (is_bool($value))
1720
+		{
1721
+			$value = (string)$value;
1722
+		}
1643 1723
 
1644 1724
 		return $this->Link_ID->qstr($value);
1645 1725
 	}
@@ -1668,15 +1748,21 @@  discard block
 block discarded – undo
1668 1748
 	*/
1669 1749
 	function column_data_implode($glue,$array,$use_key=True,$only=False,$column_definitions=False)
1670 1750
 	{
1671
-		if (!is_array($array))	// this allows to give an SQL-string for delete or update
1751
+		if (!is_array($array))
1752
+		{
1753
+			// this allows to give an SQL-string for delete or update
1672 1754
 		{
1673 1755
 			return $array;
1674 1756
 		}
1757
+		}
1675 1758
 		if (!$column_definitions)
1676 1759
 		{
1677 1760
 			$column_definitions = $this->column_definitions;
1678 1761
 		}
1679
-		if ($this->Debug) echo "<p>db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre>\n";
1762
+		if ($this->Debug)
1763
+		{
1764
+			echo "<p>db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre>\n";
1765
+		}
1680 1766
 
1681 1767
 		// do we need to truncate varchars to their max length (INSERT and UPDATE on Postgres)
1682 1768
 		$truncate_varchar = $glue == ',' && $this->capabilities[self::CAPABILITY_REQUIRE_TRUNCATE_VARCHAR];
@@ -1693,7 +1779,10 @@  discard block
 block discarded – undo
1693 1779
 				// fix "table.column" expressions, to not trigger exception, if column alone would work
1694 1780
 				if (!is_int($key) && is_array($column_definitions) && !isset($column_definitions[$key]))
1695 1781
 				{
1696
-					if (strpos($key, '.') !== false) list(, $col) = explode('.', $key);
1782
+					if (strpos($key, '.') !== false)
1783
+					{
1784
+						list(, $col) = explode('.', $key);
1785
+					}
1697 1786
 					if (!isset($column_definitions[$col]))
1698 1787
 					{
1699 1788
 						throw new egw_exception_db_invalid_sql("db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre><b>nothing known about column '$key'!</b>");
@@ -1733,7 +1822,11 @@  discard block
 block discarded – undo
1733 1822
 				}
1734 1823
 				elseif (is_int($key) && $use_key===True)
1735 1824
 				{
1736
-					if (empty($data)) continue;	// would give SQL error
1825
+					if (empty($data))
1826
+					{
1827
+						continue;
1828
+					}
1829
+					// would give SQL error
1737 1830
 					$values[] = $data;
1738 1831
 				}
1739 1832
 				elseif ($glue != ',' && $use_key === True && !$not_null && is_null($data))
@@ -1864,10 +1957,16 @@  discard block
 block discarded – undo
1864 1957
 		}
1865 1958
 		if ($table && (!$app_data || !isset($app_data[$table])))
1866 1959
 		{
1867
-			if ($this->Debug) echo "<p>!!!get_table_definitions($app,$table) failed!!!</p>\n";
1960
+			if ($this->Debug)
1961
+			{
1962
+				echo "<p>!!!get_table_definitions($app,$table) failed!!!</p>\n";
1963
+			}
1868 1964
 			return False;
1869 1965
 		}
1870
-		if ($this->Debug) echo "<p>get_table_definitions($app,$table) succeeded</p>\n";
1966
+		if ($this->Debug)
1967
+		{
1968
+			echo "<p>get_table_definitions($app,$table) succeeded</p>\n";
1969
+		}
1871 1970
 		return $table ? $app_data[$table] : $app_data;
1872 1971
 	}
1873 1972
 
@@ -1892,7 +1991,10 @@  discard block
 block discarded – undo
1892 1991
 			$table_def = $db->get_table_definitions($app,$table);
1893 1992
 			$cached_columns = is_array($table_def) ? $table_def['fd'] : false;
1894 1993
 		}
1895
-		if ($cached_columns === false) return null;
1994
+		if ($cached_columns === false)
1995
+		{
1996
+			return null;
1997
+		}
1896 1998
 
1897 1999
 		return is_null($attribute) ? $cached_columns[$column] : $cached_columns[$column][$attribute];
1898 2000
 	}
@@ -1915,9 +2017,15 @@  discard block
 block discarded – undo
1915 2017
 	*/
1916 2018
 	function insert($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False)
1917 2019
 	{
1918
-		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app')</p>\n";
2020
+		if ($this->Debug)
2021
+		{
2022
+			echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app')</p>\n";
2023
+		}
1919 2024
 
1920
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2025
+		if (!$table_def)
2026
+		{
2027
+			$table_def = $this->get_table_definitions($app,$table);
2028
+		}
1921 2029
 
1922 2030
 		$sql_append = '';
1923 2031
 		$cmd = 'INSERT';
@@ -1960,9 +2068,12 @@  discard block
 block discarded – undo
1960 2068
 			$table = self::$tablealiases[$table];
1961 2069
 		}
1962 2070
 		$inputarr = false;
1963
-		if (isset($data[0]) && is_array($data[0]))	// multiple data rows
2071
+		if (isset($data[0]) && is_array($data[0]))
2072
+		{
2073
+			// multiple data rows
1964 2074
 		{
1965 2075
 			if ($where) throw new egw_exception_wrong_parameter('Can NOT use $where together with multiple data rows in $data!');
2076
+		}
1966 2077
 
1967 2078
 			$sql = "$cmd INTO $table ";
1968 2079
 			foreach($data as $k => $d)
@@ -1978,15 +2089,22 @@  discard block
 block discarded – undo
1978 2089
 			}
1979 2090
 			$sql .= $sql_append;
1980 2091
 		}
1981
-		elseif ($use_prepared_statement && $this->Link_ID->_bindInputArray)	// eg. MaxDB
2092
+		elseif ($use_prepared_statement && $this->Link_ID->_bindInputArray)
1982 2093
 		{
1983
-			$this->Link_ID->Param(false);	// reset param-counter
2094
+			// eg. MaxDB
2095
+		{
2096
+			$this->Link_ID->Param(false);
2097
+		}
2098
+		// reset param-counter
1984 2099
 			$cols = array_keys($data);
1985 2100
 			foreach($cols as $k => $col)
1986 2101
 			{
1987
-				if (!isset($table_def['fd'][$col]))	// ignore columns not in this table
2102
+				if (!isset($table_def['fd'][$col]))
2103
+				{
2104
+					// ignore columns not in this table
1988 2105
 				{
1989 2106
 					unset($cols[$k]);
2107
+				}
1990 2108
 					continue;
1991 2109
 				}
1992 2110
 				$params[] = $this->Link_ID->Param($col);
@@ -2004,7 +2122,10 @@  discard block
 block discarded – undo
2004 2122
 		{
2005 2123
 			$sql = "$cmd INTO $table ".$this->column_data_implode(',',$data,'VALUES',true,$table_def['fd']).$sql_append;
2006 2124
 		}
2007
-		if ($this->Debug) echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app') sql='$sql'</p>\n";
2125
+		if ($this->Debug)
2126
+		{
2127
+			echo "<p>db::insert('$table',".print_r($data,True).",".print_r($where,True).",$line,$file,'$app') sql='$sql'</p>\n";
2128
+		}
2008 2129
 		return $this->query($sql,$line,$file,0,-1,$inputarr);
2009 2130
 	}
2010 2131
 
@@ -2025,8 +2146,14 @@  discard block
 block discarded – undo
2025 2146
 	*/
2026 2147
 	function update($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false,$table_def=False)
2027 2148
 	{
2028
-		if ($this->Debug) echo "<p>db::update('$table',".print_r($data,true).','.print_r($where,true).",$line,$file,'$app')</p>\n";
2029
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2149
+		if ($this->Debug)
2150
+		{
2151
+			echo "<p>db::update('$table',".print_r($data,true).','.print_r($where,true).",$line,$file,'$app')</p>\n";
2152
+		}
2153
+		if (!$table_def)
2154
+		{
2155
+			$table_def = $this->get_table_definitions($app,$table);
2156
+		}
2030 2157
 
2031 2158
 		$blobs2update = array();
2032 2159
 		// SapDB/MaxDB cant update LONG columns / blob's: if a blob-column is included in the update we remember it in $blobs2update
@@ -2035,7 +2162,10 @@  discard block
 block discarded – undo
2035 2162
 		{
2036 2163
 			case 'sapdb':
2037 2164
 			case 'maxdb':
2038
-				if ($use_prepared_statement) break;
2165
+				if ($use_prepared_statement)
2166
+				{
2167
+					break;
2168
+				}
2039 2169
 				// check if data contains any LONG columns
2040 2170
 				foreach($data as $col => $val)
2041 2171
 				{
@@ -2060,12 +2190,20 @@  discard block
 block discarded – undo
2060 2190
 		if (count($data))
2061 2191
 		{
2062 2192
 			$inputarr = false;
2063
-			if ($use_prepared_statement && $this->Link_ID->_bindInputArray)	// eg. MaxDB
2193
+			if ($use_prepared_statement && $this->Link_ID->_bindInputArray)
2194
+			{
2195
+				// eg. MaxDB
2064 2196
 			{
2065
-				$this->Link_ID->Param(false);	// reset param-counter
2197
+				$this->Link_ID->Param(false);
2198
+			}
2199
+			// reset param-counter
2066 2200
 				foreach($data as $col => $val)
2067 2201
 				{
2068
-					if (!isset($table_def['fd'][$col])) continue;	// ignore columns not in this table
2202
+					if (!isset($table_def['fd'][$col]))
2203
+					{
2204
+						continue;
2205
+					}
2206
+					// ignore columns not in this table
2069 2207
 					$params[] = $this->name_quote($col).'='.$this->Link_ID->Param($col);
2070 2208
 				}
2071 2209
 				$sql = "UPDATE $table SET ".implode(',',$params).' WHERE '.$where_str;
@@ -2083,7 +2221,10 @@  discard block
 block discarded – undo
2083 2221
 					$this->column_data_implode(',',$data,True,true,$table_def['fd']).' WHERE '.$where_str;
2084 2222
 			}
2085 2223
 			$ret = $this->query($sql,$line,$file,0,-1,$inputarr);
2086
-			if ($this->Debug) echo "<p>db::query('$sql',$line,$file)</p>\n";
2224
+			if ($this->Debug)
2225
+			{
2226
+				echo "<p>db::query('$sql',$line,$file)</p>\n";
2227
+			}
2087 2228
 		}
2088 2229
 		// if we have any blobs to update, we do so now
2089 2230
 		if (($ret || !count($data)) && count($blobs2update))
@@ -2091,8 +2232,14 @@  discard block
 block discarded – undo
2091 2232
 			foreach($blobs2update as $col => $val)
2092 2233
 			{
2093 2234
 				$ret = $this->Link_ID->UpdateBlob($table,$col,$val,$where_str,$table_def['fd'][$col]['type'] == 'blob' ? 'BLOB' : 'CLOB');
2094
-				if ($this->Debug) echo "<p>adodb::UpdateBlob('$table','$col','$val','$where_str') = '$ret'</p>\n";
2095
-				if (!$ret) throw new egw_exception_db_invalid_sql("Error in UpdateBlob($table,$col,\$val,$where_str)",$line,$file);
2235
+				if ($this->Debug)
2236
+				{
2237
+					echo "<p>adodb::UpdateBlob('$table','$col','$val','$where_str') = '$ret'</p>\n";
2238
+				}
2239
+				if (!$ret)
2240
+				{
2241
+					throw new egw_exception_db_invalid_sql("Error in UpdateBlob($table,$col,\$val,$where_str)",$line,$file);
2242
+				}
2096 2243
 			}
2097 2244
 		}
2098 2245
 		return $ret;
@@ -2113,7 +2260,10 @@  discard block
 block discarded – undo
2113 2260
 	*/
2114 2261
 	function delete($table,$where,$line,$file,$app=False,$table_def=False)
2115 2262
 	{
2116
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2263
+		if (!$table_def)
2264
+		{
2265
+			$table_def = $this->get_table_definitions($app,$table);
2266
+		}
2117 2267
 
2118 2268
 		if (self::$tablealiases && isset(self::$tablealiases[$table]))
2119 2269
 		{
@@ -2145,19 +2295,29 @@  discard block
 block discarded – undo
2145 2295
 	 */
2146 2296
 	function expression($table_def/*,$args, ...*/)
2147 2297
 	{
2148
-		if (!is_array($table_def)) $table_def = $this->get_table_definitions(true,$table_def);
2298
+		if (!is_array($table_def))
2299
+		{
2300
+			$table_def = $this->get_table_definitions(true,$table_def);
2301
+		}
2149 2302
 		$sql = '';
2150 2303
 		$ignore_next = 0;
2151 2304
 		foreach(func_get_args() as $n => $arg)
2152 2305
 		{
2153
-			if ($n < 1) continue;	// table-name
2306
+			if ($n < 1)
2307
+			{
2308
+				continue;
2309
+			}
2310
+			// table-name
2154 2311
 
2155 2312
 			if ($ignore_next)
2156 2313
 			{
2157 2314
 				--$ignore_next;
2158 2315
 				continue;
2159 2316
 			}
2160
-			if (is_null($arg)) $arg = False;
2317
+			if (is_null($arg))
2318
+			{
2319
+				$arg = False;
2320
+			}
2161 2321
 
2162 2322
 			switch(gettype($arg))
2163 2323
 			{
@@ -2197,9 +2357,15 @@  discard block
 block discarded – undo
2197 2357
 	*/
2198 2358
 	function select($table,$cols,$where,$line,$file,$offset=False,$append='',$app=False,$num_rows=0,$join='',$table_def=False,$fetchmode=egw_db::FETCH_ASSOC)
2199 2359
 	{
2200
-		if ($this->Debug) echo "<p>db::select('$table',".print_r($cols,True).",".print_r($where,True).",$line,$file,$offset,'$app',$num_rows,'$join')</p>\n";
2360
+		if ($this->Debug)
2361
+		{
2362
+			echo "<p>db::select('$table',".print_r($cols,True).",".print_r($where,True).",$line,$file,$offset,'$app',$num_rows,'$join')</p>\n";
2363
+		}
2201 2364
 
2202
-		if (!$table_def) $table_def = $this->get_table_definitions($app,$table);
2365
+		if (!$table_def)
2366
+		{
2367
+			$table_def = $this->get_table_definitions($app,$table);
2368
+		}
2203 2369
 		if (is_array($cols))
2204 2370
 		{
2205 2371
 			$cols = implode(',',$cols);
@@ -2215,16 +2381,28 @@  discard block
 block discarded – undo
2215 2381
 		$sql = "SELECT $cols FROM $table $join";
2216 2382
 
2217 2383
 		// if we have a where clause, we need to add it together with the WHERE statement, if thats not in the join
2218
-		if ($where) $sql .= (strpos($join,"WHERE")!==false) ? ' AND ('.$where.')' : ' WHERE '.$where;
2384
+		if ($where)
2385
+		{
2386
+			$sql .= (strpos($join,"WHERE")!==false) ? ' AND ('.$where.')' : ' WHERE '.$where;
2387
+		}
2219 2388
 
2220
-		if ($append) $sql .= ' '.$append;
2389
+		if ($append)
2390
+		{
2391
+			$sql .= ' '.$append;
2392
+		}
2221 2393
 
2222
-		if ($this->Debug) echo "<p>sql='$sql'</p>";
2394
+		if ($this->Debug)
2395
+		{
2396
+			echo "<p>sql='$sql'</p>";
2397
+		}
2223 2398
 
2224
-		if ($line === false && $file === false)	// call by union, to return the sql rather then run the query
2399
+		if ($line === false && $file === false)
2400
+		{
2401
+			// call by union, to return the sql rather then run the query
2225 2402
 		{
2226 2403
 			return $sql;
2227 2404
 		}
2405
+		}
2228 2406
 		return $this->query($sql,$line,$file,$offset,$offset===False ? -1 : (int)$num_rows,false,$fetchmode);
2229 2407
 	}
2230 2408
 
@@ -2245,7 +2423,10 @@  discard block
 block discarded – undo
2245 2423
 	*/
2246 2424
 	function union($selects,$line,$file,$order_by='',$offset=false,$num_rows=0,$fetchmode=egw_db::FETCH_ASSOC)
2247 2425
 	{
2248
-		if ($this->Debug) echo "<p>db::union(".print_r($selects,True).",$line,$file,$order_by,$offset,$num_rows)</p>\n";
2426
+		if ($this->Debug)
2427
+		{
2428
+			echo "<p>db::union(".print_r($selects,True).",$line,$file,$order_by,$offset,$num_rows)</p>\n";
2429
+		}
2249 2430
 
2250 2431
 		$union = array();
2251 2432
 		foreach($selects as $select)
@@ -2266,9 +2447,15 @@  discard block
 block discarded – undo
2266 2447
 		}
2267 2448
 		$sql = count($union) > 1 ? '(' . implode(")\nUNION\n(",$union).')' : 'SELECT DISTINCT'.substr($union[0],6);
2268 2449
 
2269
-		if ($order_by) $sql .=  (!stristr($order_by,'ORDER BY') ? "\nORDER BY " : '').$order_by;
2450
+		if ($order_by)
2451
+		{
2452
+			$sql .=  (!stristr($order_by,'ORDER BY') ? "\nORDER BY " : '').$order_by;
2453
+		}
2270 2454
 
2271
-		if ($this->Debug) echo "<p>sql='$sql'</p>";
2455
+		if ($this->Debug)
2456
+		{
2457
+			echo "<p>sql='$sql'</p>";
2458
+		}
2272 2459
 
2273 2460
 		return $this->query($sql,$line,$file,$offset,$offset===False ? -1 : (int)$num_rows,false,$fetchmode);
2274 2461
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
 					if (!isset($table_def['fd'][$col])) continue;	// ignore columns not in this table
1846 1846
 					$params[] = $this->name_quote($col).'='.$this->Link_ID->Param($col);
1847 1847
 				}
1848
-				$sql = "UPDATE $table SET ".implode(',',$params).' WHERE '.$where_str;
1848
+				$sql = "update $table SET ".implode(',',$params).' WHERE '.$where_str;
1849 1849
 				// check if we already prepared that statement
1850 1850
 				if (!isset($this->prepared_sql[$sql]))
1851 1851
 				{
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
 			}
1857 1857
 			else
1858 1858
 			{
1859
-				$sql = "UPDATE $table SET ".
1859
+				$sql = "update $table SET ".
1860 1860
 					$this->column_data_implode(',',$data,True,true,$table_def['fd']).' WHERE '.$where_str;
1861 1861
 			}
1862 1862
 			$ret = $this->query($sql,$line,$file,0,-1,$inputarr);
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
 		{
1990 1990
 			$table = self::$tablealiases[$table];
1991 1991
 		}
1992
-		$sql = "SELECT $cols FROM $table $join";
1992
+		$sql = "select $cols FROM $table $join";
1993 1993
 
1994 1994
 		// if we have a where clause, we need to add it together with the WHERE statement, if thats not in the join
1995 1995
 		if ($where) $sql .= (strpos($join,"WHERE")!==false) ? ' AND ('.$where.')' : ' WHERE '.$where;
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_digest_auth.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@
 block discarded – undo
234 234
 	 * @param string $realm
235 235
 	 * @param string $username
236 236
 	 * @param string &$password=null password to use or if null, on return stored password
237
-	 * @return string|boolean false if $password not given and can NOT be read
237
+	 * @return false|string false if $password not given and can NOT be read
238 238
 	 */
239 239
 	static private function get_digest_A1($realm,$username,&$password=null)
240 240
 	{
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -255,20 +255,20 @@
 block discarded – undo
255 255
 	 */
256 256
 	static public function parse_digest($txt)
257 257
 	{
258
-	    // protect against missing data
259
-	    $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
260
-	    $data = array();
261
-	    $keys = implode('|', array_keys($needed_parts));
258
+		// protect against missing data
259
+		$needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
260
+		$data = array();
261
+		$keys = implode('|', array_keys($needed_parts));
262 262
 
263 263
 		$matches = null;
264
-	    preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
264
+		preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
265 265
 
266
-	    foreach ($matches as $m)
267
-	    {
268
-	        $data[$m[1]] = $m[3] ? $m[3] : $m[4];
269
-	        unset($needed_parts[$m[1]]);
270
-	    }
271
-	    //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data));
272
-	    return $needed_parts ? false : $data;
266
+		foreach ($matches as $m)
267
+		{
268
+			$data[$m[1]] = $m[3] ? $m[3] : $m[4];
269
+			unset($needed_parts[$m[1]]);
270
+		}
271
+		//error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data));
272
+		return $needed_parts ? false : $data;
273 273
 	}
274 274
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	static public function autocreate_session_callback(&$account)
77 77
 	{
78
-		unset($account);	// not used, but required by function signature
78
+		unset($account); // not used, but required by function signature
79 79
 		if (self::ERROR_LOG)
80 80
 		{
81 81
 			$pw = self::ERROR_LOG > 1 ? $_SERVER['PHP_AUTH_PW'] : '**********';
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 
87 87
 		$username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW'];
88 88
 		// Support for basic auth when using PHP CGI (what about digest auth?)
89
-		if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],'Basic ') === 0)
89
+		if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 'Basic ') === 0)
90 90
 		{
91
-			$hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],6));
91
+			$hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6));
92 92
 			if (strpos($hash, ':') !== false)
93 93
 			{
94 94
 				list($username, $password) = explode(':', $hash, 2);
95 95
 			}
96 96
 		}
97
-		elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm,$_SERVER['PHP_AUTH_DIGEST'],$username,$password))
97
+		elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm, $_SERVER['PHP_AUTH_DIGEST'], $username, $password))
98 98
 		{
99 99
 			unset($password);
100 100
 		}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			// if the session class gives a reason why the login failed --> append it to the REALM
112 112
 			if ($GLOBALS['egw']->session->reason) $realm .= ': '.$GLOBALS['egw']->session->reason;
113 113
 
114
-			header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
114
+			header('WWW-Authenticate: Basic realm="'.$realm.'"'); // draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
115 115
 			self::digest_header($realm);
116 116
 			header('HTTP/1.1 401 Unauthorized');
117 117
 			header('X-WebDAV-Status: 401 Unauthorized', true);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 			// replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts
136 136
 			if (strpos($password, '\\x') !== false)
137 137
 			{
138
-				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){
138
+				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) {
139 139
 					return chr(hexdec($matches[1]));
140 140
 				}, $password);
141 141
 			}
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 	 * @param string &$user_pw =null stored cleartext password, if $username given AND function returns true
158 158
 	 * @return boolean true if digest auth is available, false otherwise
159 159
 	 */
160
-	static public function digest_auth_available($realm,$username=null,&$user_pw=null)
160
+	static public function digest_auth_available($realm, $username = null, &$user_pw = null)
161 161
 	{
162 162
 		// we currently require plaintext passwords!
163 163
 		if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') ||
164 164
 			  $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain')
165 165
 		{
166 166
 			if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
167
-			return false;	// no plain-text passwords used
167
+			return false; // no plain-text passwords used
168 168
 		}
169 169
 		// check for specific user, if given
170
-		if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username,'account_pwd','u')) ||
171
-			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}'))
170
+		if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username, 'account_pwd', 'u')) ||
171
+			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw, 0, 7) != '{PLAIN}'))
172 172
 		{
173 173
 			unset($user_pw);
174 174
 			if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
175
-			return false;	// user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
175
+			return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
176 176
 		}
177
-		if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7);
177
+		if (substr($user_pw, 0, 7) == '{PLAIN}') $user_pw = substr($user_pw, 7);
178 178
 
179 179
 		if (self::ERROR_LOG)
180 180
 		{
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param string $realm
191 191
 	 * @param string &$nonce=null on return
192 192
 	 */
193
-	static public function digest_header($realm,&$nonce=null)
193
+	static public function digest_header($realm, &$nonce = null)
194 194
 	{
195 195
 		if (self::digest_auth_available($realm))
196 196
 		{
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 	 * @param string &$password on return cleartext password
210 210
 	 * @return boolean true if digest is correct, false otherwise
211 211
 	 */
212
-	static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null)
212
+	static public function is_valid($realm, $auth_digest = null, &$username = null, &$password = null)
213 213
 	{
214 214
 		if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
215 215
 
216 216
 		$data = self::parse_digest($auth_digest);
217 217
 
218
-		if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password=null)))
218
+		if (!$data || !($A1 = self::get_digest_A1($realm, $username = $data['username'], $password = null)))
219 219
 		{
220 220
 			error_log(__METHOD__."('$realm','$auth_digest','$username') returning FALSE");
221 221
 			return false;
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
 	 * @param string &$password=null password to use or if null, on return stored password
237 237
 	 * @return string|boolean false if $password not given and can NOT be read
238 238
 	 */
239
-	static private function get_digest_A1($realm,$username,&$password=null)
239
+	static private function get_digest_A1($realm, $username, &$password = null)
240 240
 	{
241 241
 		$user_pw = null;
242
-		if (empty($username) || empty($realm) || !self::digest_auth_available($realm,$username,$user_pw))
242
+		if (empty($username) || empty($realm) || !self::digest_auth_available($realm, $username, $user_pw))
243 243
 		{
244 244
 			return false;
245 245
 		}
246 246
 		if (is_null($password)) $password = $user_pw;
247 247
 
248
-		$A1 = md5($username . ':' . $realm . ':' . $password);
248
+		$A1 = md5($username.':'.$realm.':'.$password);
249 249
 		if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
250 250
 		return $A1;
251 251
 	}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	    $keys = implode('|', array_keys($needed_parts));
262 262
 
263 263
 		$matches = null;
264
-	    preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
264
+	    preg_match_all('@('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
265 265
 
266 266
 	    foreach ($matches as $m)
267 267
 	    {
Please login to merge, or discard this patch.
Braces   +42 added lines, -11 removed lines patch added patch discarded remove patch
@@ -82,7 +82,10 @@  discard block
 block discarded – undo
82 82
 			error_log(__METHOD__.'() PHP_AUTH_USER='.array2string($_SERVER['PHP_AUTH_USER']).', PHP_AUTH_PW='.array2string($pw).', PHP_AUTH_DIGEST='.array2string($_SERVER['PHP_AUTH_DIGEST']));
83 83
 		}
84 84
 		$realm = $GLOBALS['egw_info']['flags']['auth_realm'];
85
-		if (empty($realm)) $realm = 'EGroupware';
85
+		if (empty($realm))
86
+		{
87
+			$realm = 'EGroupware';
88
+		}
86 89
 
87 90
 		$username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW'];
88 91
 		// Support for basic auth when using PHP CGI (what about digest auth?)
@@ -109,7 +112,10 @@  discard block
 block discarded – undo
109 112
 		if (!isset($username) || !($sessionid = $GLOBALS['egw']->session->create($username, $password, 'text', true)))
110 113
 		{
111 114
 			// if the session class gives a reason why the login failed --> append it to the REALM
112
-			if ($GLOBALS['egw']->session->reason) $realm .= ': '.$GLOBALS['egw']->session->reason;
115
+			if ($GLOBALS['egw']->session->reason)
116
+			{
117
+				$realm .= ': '.$GLOBALS['egw']->session->reason;
118
+			}
113 119
 
114 120
 			header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
115 121
 			self::digest_header($realm);
@@ -135,7 +141,8 @@  discard block
 block discarded – undo
135 141
 			// replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts
136 142
 			if (strpos($password, '\\x') !== false)
137 143
 			{
138
-				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){
144
+				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches)
145
+				{
139 146
 					return chr(hexdec($matches[1]));
140 147
 				}, $password);
141 148
 			}
@@ -163,7 +170,10 @@  discard block
 block discarded – undo
163 170
 		if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') ||
164 171
 			  $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain')
165 172
 		{
166
-			if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
173
+			if (self::ERROR_LOG)
174
+			{
175
+				error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
176
+			}
167 177
 			return false;	// no plain-text passwords used
168 178
 		}
169 179
 		// check for specific user, if given
@@ -171,10 +181,16 @@  discard block
 block discarded – undo
171 181
 			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}'))
172 182
 		{
173 183
 			unset($user_pw);
174
-			if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
184
+			if (self::ERROR_LOG)
185
+			{
186
+				error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
187
+			}
175 188
 			return false;	// user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
176 189
 		}
177
-		if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7);
190
+		if (substr($user_pw,0,7) == '{PLAIN}')
191
+		{
192
+			$user_pw = substr($user_pw,7);
193
+		}
178 194
 
179 195
 		if (self::ERROR_LOG)
180 196
 		{
@@ -196,7 +212,10 @@  discard block
 block discarded – undo
196 212
 		{
197 213
 			$nonce = uniqid();
198 214
    			header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"');
199
-			if (self::ERROR_LOG) error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'");
215
+			if (self::ERROR_LOG)
216
+			{
217
+				error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'");
218
+			}
200 219
 		}
201 220
 	}
202 221
 
@@ -211,7 +230,10 @@  discard block
 block discarded – undo
211 230
 	 */
212 231
 	static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null)
213 232
 	{
214
-		if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
233
+		if (is_null($auth_digest))
234
+		{
235
+			$auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
236
+		}
215 237
 
216 238
 		$data = self::parse_digest($auth_digest);
217 239
 
@@ -224,7 +246,10 @@  discard block
 block discarded – undo
224 246
 
225 247
 		$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
226 248
 
227
-		if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response));
249
+		if (self::ERROR_LOG)
250
+		{
251
+			error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response));
252
+		}
228 253
 		return $data['response'] === $valid_response;
229 254
 	}
230 255
 
@@ -243,10 +268,16 @@  discard block
 block discarded – undo
243 268
 		{
244 269
 			return false;
245 270
 		}
246
-		if (is_null($password)) $password = $user_pw;
271
+		if (is_null($password))
272
+		{
273
+			$password = $user_pw;
274
+		}
247 275
 
248 276
 		$A1 = md5($username . ':' . $realm . ':' . $password);
249
-		if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
277
+		if (self::ERROR_LOG > 1)
278
+		{
279
+			error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
280
+		}
250 281
 		return $A1;
251 282
 	}
252 283
 
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_exception.inc.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -19,6 +19,9 @@
 block discarded – undo
19 19
  */
20 20
 class Admin extends App
21 21
 {
22
+	/**
23
+	 * @param string $msg
24
+	 */
22 25
 	function __construct($msg=null,$code=102)
23 26
 	{
24 27
 		if (is_null($msg)) $msg = 'admin';
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 class egw_exception extends Exception
28 28
 {
29 29
 	// nothing fancy yet
30
-	function __construct($msg=null,$code=100,Exception $previous=null)
30
+	function __construct($msg = null, $code = 100, Exception $previous = null)
31 31
 	{
32 32
 		return parent::__construct($msg, $code, $previous);
33 33
 	}
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 	 * @param string $msg =null message, default "Permission denied!"
46 46
 	 * @param int $code =100 numerical code, default 100
47 47
 	 */
48
-	function __construct($msg=null,$code=100)
48
+	function __construct($msg = null, $code = 100)
49 49
 	{
50 50
 		if (is_null($msg)) $msg = lang('Permisson denied!');
51 51
 
52
-		parent::__construct($msg,$code);
52
+		parent::__construct($msg, $code);
53 53
 	}
54 54
 }
55 55
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  */
60 60
 class egw_exception_no_permission_app extends egw_exception_no_permission
61 61
 {
62
-	function __construct($msg=null,$code=101)
62
+	function __construct($msg = null, $code = 101)
63 63
 	{
64 64
 		if (isset($GLOBALS['egw_info']['apps'][$msg]))
65 65
 		{
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 						'"'.$app.'"');
78 78
 			}
79 79
 		}
80
-		parent::__construct($msg,$code);
80
+		parent::__construct($msg, $code);
81 81
 	}
82 82
 }
83 83
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
  */
88 88
 class egw_exception_no_permission_admin extends egw_exception_no_permission_app
89 89
 {
90
-	function __construct($msg=null,$code=102)
90
+	function __construct($msg = null, $code = 102)
91 91
 	{
92 92
 		if (is_null($msg)) $msg = 'admin';
93 93
 
94
-		parent::__construct($msg,$code);
94
+		parent::__construct($msg, $code);
95 95
 	}
96 96
 }
97 97
 
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	 * @param string $msg =null message, default "Entry not found!"
114 114
 	 * @param int $code =99 numerical code, default 2
115 115
 	 */
116
-	function __construct($msg=null,$code=2)
116
+	function __construct($msg = null, $code = 2)
117 117
 	{
118 118
 		if (is_null($msg)) $msg = lang('Entry not found!');
119 119
 
120
-		parent::__construct($msg,$code);
120
+		parent::__construct($msg, $code);
121 121
 	}
122 122
 }
123 123
 
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @param string $msg =null message, default "Database error!"
153 153
 	 * @param int $code =100
154 154
 	 */
155
-	function __construct($msg=null,$code=100)
155
+	function __construct($msg = null, $code = 100)
156 156
 	{
157 157
 		if (is_null($msg)) $msg = lang('Database error!');
158 158
 
159
-		parent::__construct($msg,$code);
159
+		parent::__construct($msg, $code);
160 160
 	}
161 161
 }
162 162
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param string $msg
204 204
 	 * @param int $code
205 205
 	 */
206
-	function __construct($url,$app=null,$msg=null,$code=301)
206
+	function __construct($url, $app = null, $msg = null, $code = 301)
207 207
 	{
208 208
 		$this->url = $url;
209 209
 		$this->app = $app;
Please login to merge, or discard this patch.
Braces   +43 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	function __construct($msg=null,$code=100)
49 49
 	{
50
-		if (is_null($msg)) $msg = lang('Permisson denied!');
50
+		if (is_null($msg))
51
+		{
52
+			$msg = lang('Permisson denied!');
53
+		}
51 54
 
52 55
 		parent::__construct($msg,$code);
53 56
 	}
@@ -89,7 +92,10 @@  discard block
 block discarded – undo
89 92
 {
90 93
 	function __construct($msg=null,$code=102)
91 94
 	{
92
-		if (is_null($msg)) $msg = 'admin';
95
+		if (is_null($msg))
96
+		{
97
+			$msg = 'admin';
98
+		}
93 99
 
94 100
 		parent::__construct($msg,$code);
95 101
 	}
@@ -99,7 +105,9 @@  discard block
 block discarded – undo
99 105
  * User lacks a record level permission, eg. he's not the owner and has no grant from the owner
100 106
  *
101 107
  */
102
-class egw_exception_no_permission_record extends egw_exception_no_permission { }
108
+class egw_exception_no_permission_record extends egw_exception_no_permission
109
+{
110
+}
103 111
 
104 112
 /**
105 113
  * A record or application entry was not found for the given id
@@ -115,7 +123,10 @@  discard block
 block discarded – undo
115 123
 	 */
116 124
 	function __construct($msg=null,$code=2)
117 125
 	{
118
-		if (is_null($msg)) $msg = lang('Entry not found!');
126
+		if (is_null($msg))
127
+		{
128
+			$msg = lang('Entry not found!');
129
+		}
119 130
 
120 131
 		parent::__construct($msg,$code);
121 132
 	}
@@ -126,20 +137,26 @@  discard block
 block discarded – undo
126 137
  *
127 138
  * As you get this only by an error in the code or during development, the message does not need to be translated
128 139
  */
129
-class egw_exception_assertion_failed extends egw_exception { }
140
+class egw_exception_assertion_failed extends egw_exception
141
+{
142
+}
130 143
 
131 144
 /**
132 145
  * A method or function was called with a wrong or missing parameter
133 146
  *
134 147
  * As you get this only by an error in the code or during development, the message does not need to be translated
135 148
  */
136
-class egw_exception_wrong_parameter extends egw_exception_assertion_failed { }
149
+class egw_exception_wrong_parameter extends egw_exception_assertion_failed
150
+{
151
+}
137 152
 
138 153
 /**
139 154
  * Wrong or missing required user input: message should be translated so it can be shown directly to the user
140 155
  *
141 156
  */
142
-class egw_exception_wrong_userinput extends egw_exception_assertion_failed { }
157
+class egw_exception_wrong_userinput extends egw_exception_assertion_failed
158
+{
159
+}
143 160
 
144 161
 /**
145 162
  * Exception thrown by the egw_db class for everything not covered by extended classed below
@@ -154,7 +171,10 @@  discard block
 block discarded – undo
154 171
 	 */
155 172
 	function __construct($msg=null,$code=100)
156 173
 	{
157
-		if (is_null($msg)) $msg = lang('Database error!');
174
+		if (is_null($msg))
175
+		{
176
+			$msg = lang('Database error!');
177
+		}
158 178
 
159 179
 		parent::__construct($msg,$code);
160 180
 	}
@@ -163,27 +183,37 @@  discard block
 block discarded – undo
163 183
 /**
164 184
  * Storing the row violates a unique key constrain
165 185
  */
166
-class egw_exception_db_not_unique extends egw_exception_db { }
186
+class egw_exception_db_not_unique extends egw_exception_db
187
+{
188
+}
167 189
 
168 190
 /**
169 191
  *  Can not connect to database: eg. database down, wrong host, name or credentials
170 192
  */
171
-class egw_exception_db_connection extends egw_exception_db { }
193
+class egw_exception_db_connection extends egw_exception_db
194
+{
195
+}
172 196
 
173 197
 /**
174 198
  * PHP lackst support for configured database type
175 199
  */
176
-class egw_exception_db_support extends egw_exception_db { }
200
+class egw_exception_db_support extends egw_exception_db
201
+{
202
+}
177 203
 
178 204
 /**
179 205
  * Classic invalid SQL error
180 206
  */
181
-class egw_exception_db_invalid_sql extends egw_exception_db { }
207
+class egw_exception_db_invalid_sql extends egw_exception_db
208
+{
209
+}
182 210
 
183 211
 /**
184 212
  * EGroupware not (fully) installed, visit setup
185 213
  */
186
-class egw_exception_db_setup extends egw_exception_db { }
214
+class egw_exception_db_setup extends egw_exception_db
215
+{
216
+}
187 217
 
188 218
 /**
189 219
  * Allow callbacks to request a redirect
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_favorites.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@
 block discarded – undo
187 187
 	 * @param string $action "add" or "delete"
188 188
 	 * @param boolean|int|String $group ID of the group to create the favorite for, or 'all' for all users
189 189
 	 * @param array $filters key => value pairs for the filter
190
-	 * @return boolean Success
190
+	 * @return boolean|null Success
191 191
 	 */
192 192
 	public static function set_favorite($app, $_name, $action, $group, $filters = array())
193 193
 	{
Please login to merge, or discard this patch.
Spacing   +22 added lines, -23 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return array with a single sidebox menu item (array) containing html for favorites
40 40
 	 */
41
-	public static function list_favorites($app, $default=null)
41
+	public static function list_favorites($app, $default = null)
42 42
 	{
43 43
 		if (!$app)
44 44
 		{
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$target = 'favorite_sidebox_'.$app;
55 55
 
56 56
 		/* @var $filters array an array of favorites*/
57
-		$filters =  self::get_favorites($app);
57
+		$filters = self::get_favorites($app);
58 58
 		$is_admin = $GLOBALS['egw_info']['user']['apps']['admin'];
59 59
 		$html = "<span id='$target' class='ui-helper-clearfix sidebox-favorites'><ul class='ui-menu ui-widget-content ui-corner-all favorites' role='listbox'>\n";
60 60
 
@@ -65,25 +65,24 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 
67 67
 		// Get link for if there is no nextmatch - this is the fallback
68
-		$registry = egw_link::get_registry($app,'list');
68
+		$registry = egw_link::get_registry($app, 'list');
69 69
 		if (!$registry)
70 70
 		{
71 71
 			$registry = egw_link::get_registry($app, 'index');
72 72
 		}
73
-		foreach($filters as $name => $filter)
73
+		foreach ($filters as $name => $filter)
74 74
 		{
75 75
 			//filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database
76 76
 			if (!$filter)
77 77
 			{
78
-				error_log(__METHOD__.'Favorite filter is not suppose to be empty, it should be an array. filter = '. array2string($filters[$name]));
78
+				error_log(__METHOD__.'Favorite filter is not suppose to be empty, it should be an array. filter = '.array2string($filters[$name]));
79 79
 				continue;
80 80
 			}
81 81
 			$li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n";
82 82
 			$li .= '<a href="#" class="ui-corner-all" tabindex="-1">';
83
-			$li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".
83
+			$li .= "<div class='".((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar')."'></div>".
84 84
 				$filter['name'];
85
-			$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" :
86
-				"<div class='ui-icon ui-icon-trash' title='" . lang('Delete') . "'></div>");
85
+			$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : "<div class='ui-icon ui-icon-trash' title='".lang('Delete')."'></div>");
87 86
 			$li .= "</a></li>\n";
88 87
 			//error_log(__METHOD__."() $name, filter=".array2string($filter)." --> ".$li);
89 88
 			$html .= $li;
@@ -91,7 +90,7 @@  discard block
 block discarded – undo
91 90
 
92 91
 		// If were're here, the app supports favorites, so add a 'Add' link too
93 92
 		$html .= "<li data-id='add' class='ui-menu-item' role='menuitem'><a href='javascript:app.$app.add_favorite()' class='ui-corner-all'>";
94
-		$html .= html::image($app, 'new') . lang('Add current'). '</a></li>';
93
+		$html .= html::image($app, 'new').lang('Add current').'</a></li>';
95 94
 
96 95
 		$html .= '</ul></span>';
97 96
 
@@ -113,7 +112,7 @@  discard block
 block discarded – undo
113 112
 	 * @return (array|boolean) An array of sorted favorites or False if there's no preferenced sorted list
114 113
 	 *
115 114
 	 */
116
-	public static function get_fav_sort_pref ($app)
115
+	public static function get_fav_sort_pref($app)
117 116
 	{
118 117
 		$fav_sorted_list = array();
119 118
 
@@ -153,13 +152,13 @@  discard block
 block discarded – undo
153 152
 		$fav_sort_pref = self::get_fav_sort_pref($app);
154 153
 
155 154
 		// Look through all preferences & pull out favorites
156
-		foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref)
155
+		foreach ((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref)
157 156
 		{
158
-			if(strpos($pref_name, $pref_prefix) === 0)
157
+			if (strpos($pref_name, $pref_prefix) === 0)
159 158
 			{
160
-				if(!is_array($pref)) continue;	// old favorite
159
+				if (!is_array($pref)) continue; // old favorite
161 160
 
162
-				$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref;
161
+				$favorites[(string)substr($pref_name, strlen($pref_prefix))] = $pref;
163 162
 			}
164 163
 		}
165 164
 		if (is_array($fav_sort_pref))
@@ -168,7 +167,7 @@  discard block
 block discarded – undo
168 167
 			{
169 168
 				$sorted_list[$key] = $favorites[$key];
170 169
 			}
171
-			$favorites = array_merge($sorted_list,$favorites);
170
+			$favorites = array_merge($sorted_list, $favorites);
172 171
 		}
173 172
 		return $favorites;
174 173
 	}
@@ -200,7 +199,7 @@  discard block
 block discarded – undo
200 199
 			}
201 200
 			else
202 201
 			{
203
-				foreach($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid)
202
+				foreach ($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid)
204 203
 				{
205 204
 					$prefs = new preferences($gid);
206 205
 					$prefs->read_repository();
@@ -212,7 +211,7 @@  discard block
 block discarded – undo
212 211
 				}
213 212
 			}
214 213
 		}
215
-		if($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all')
214
+		if ($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all')
216 215
 		{
217 216
 			$prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
218 217
 		}
@@ -223,7 +222,7 @@  discard block
 block discarded – undo
223 222
 		$prefs->read_repository();
224 223
 		$type = $group === "all" ? "default" : "user";
225 224
 		//error_log(__METHOD__."('$app', '$name', '$action', ".array2string($group).", ...) pref_name=$pref_name, type=$type");
226
-		if($action == "add")
225
+		if ($action == "add")
227 226
 		{
228 227
 			$filters = array(
229 228
 				// This is the name as user entered it, minus tags
@@ -231,9 +230,9 @@  discard block
 block discarded – undo
231 230
 				'group' => $group ? $group : false,
232 231
 				'state' => $filters
233 232
 			);
234
-			$pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/','_',$name);
235
-			$result = $prefs->add($app,$pref_name,$filters,$type);
236
-			$pref = $prefs->save_repository(false,$type);
233
+			$pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/', '_', $name);
234
+			$result = $prefs->add($app, $pref_name, $filters, $type);
235
+			$pref = $prefs->save_repository(false, $type);
237 236
 
238 237
 			// Update preferences client side, or it could disappear
239 238
 			egw_json_response::get()->call('egw.set_preferences', (array)$pref[$app], $app);
@@ -243,8 +242,8 @@  discard block
 block discarded – undo
243 242
 		}
244 243
 		else if ($action == "delete")
245 244
 		{
246
-			$result = $prefs->delete($app,$pref_name, $type);
247
-			$pref = $prefs->save_repository(false,$type);
245
+			$result = $prefs->delete($app, $pref_name, $type);
246
+			$pref = $prefs->save_repository(false, $type);
248 247
 
249 248
 			// Update preferences client side, or it could come back
250 249
 			egw_json_response::get()->call('egw.set_preferences', (array)$pref[$app], $app);
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,11 @@
 block discarded – undo
161 161
 		{
162 162
 			if(strpos($pref_name, $pref_prefix) === 0)
163 163
 			{
164
-				if(!is_array($pref)) continue;	// old favorite
164
+				if(!is_array($pref))
165
+				{
166
+					continue;
167
+				}
168
+				// old favorite
165 169
 
166 170
 				$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref;
167 171
 			}
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_find_iterator.inc.php 3 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -18,6 +18,9 @@  discard block
 block discarded – undo
18 18
 define("FILTER_DISPLAY", -1); //The element filtered should not be returned to the caller of find, it should not be displayed
19 19
 define("FILTER_ALL", -2); //The element didn't pass the filter
20 20
 
21
+/**
22
+ * @param boolean $isurl
23
+ */
21 24
 function translate_path($path, $isurl) {
22 25
 	return $isurl ? $path : egw_vfs::PREFIX.parse_url($path, PHP_URL_PATH);
23 26
 }
@@ -39,6 +42,11 @@  discard block
 block discarded – undo
39 42
 	public $isdot = false;
40 43
 	public $filterstate = FILTER_ALL;
41 44
 
45
+	/**
46
+	 * @param string $path
47
+	 * @param boolean $isurl
48
+	 * @param boolean $need_mime
49
+	 */
42 50
 	public function __construct($path, $isurl, $need_mime)
43 51
 	{
44 52
 		//Copy the given parameters
@@ -372,6 +380,13 @@  discard block
 block discarded – undo
372 380
 		}
373 381
 	}
374 382
 
383
+	/**
384
+	 * @param RecursiveDirectoryIterator $iterator
385
+	 * @param boolean $follow
386
+	 * @param boolean $url
387
+	 * @param boolean $needmime
388
+	 * @param boolean $sort
389
+	 */
375 390
 	public function __construct($iterator, &$filter, $follow, $url, $needmime, 
376 391
 		$sort, $sortfunc)
377 392
 	{
Please login to merge, or discard this patch.
Spacing   +20 added lines, -22 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 		//Set filename, path and path + name as this information will most likely
51 51
 		//be needed
52 52
 		$paths = $this->isurl ? explode('/', $path) : explode('/', parse_url($path, PHP_URL_PATH));
53
-		$this->name = implode('/',$paths);
53
+		$this->name = implode('/', $paths);
54 54
 		$this->filename = array_pop($paths);
55
-		$this->path = implode('/',$paths).'/';
55
+		$this->path = implode('/', $paths).'/';
56 56
 		$this->is_dot = ($this->filename == '.') || ($this->filename == '..');
57 57
 	}
58 58
 	
@@ -61,8 +61,7 @@  discard block
 block discarded – undo
61 61
 		//Check whether the stat data has already been created, if not, create it
62 62
 		if ($this->stat === null)
63 63
 		{
64
-			$this->stat = $this->isurl ? lstat($this->base_path) :
65
-				egw_vfs::url_stat($this->base_path, STREAM_URL_STAT_LINK);
64
+			$this->stat = $this->isurl ? lstat($this->base_path) : egw_vfs::url_stat($this->base_path, STREAM_URL_STAT_LINK);
66 65
 			
67 66
 			//Remove numerical indices 0-12
68 67
 			$this->stat = array_slice($this->stat, 13);
@@ -172,7 +171,7 @@  discard block
 block discarded – undo
172 171
 		if ($argument < 0)
173 172
 			return $value < abs($argument);
174 173
 		
175
-		return $value > (int) substr($argument,1);
174
+		return $value > (int)substr($argument, 1);
176 175
 	}
177 176
 	
178 177
 	public function __construct($options)
@@ -196,19 +195,19 @@  discard block
 block discarded – undo
196 195
 		
197 196
 		//Convert the (probably) given path/name filters to regular expressions
198 197
 		if (isset($options['name']) && !isset($options['name_preg'])) // change from simple *,? wildcards to preg regular expression once
199
-			$this->name_preg = '/^'.str_replace(array('\\?','\\*'),
200
-				array('.{1}','.*'), preg_quote($options['name'])).'$/i';
198
+			$this->name_preg = '/^'.str_replace(array('\\?', '\\*'),
199
+				array('.{1}', '.*'), preg_quote($options['name'])).'$/i';
201 200
 		
202 201
 		if (isset($options['path']) && !isset($options['preg_path'])) // change from simple *,? wildcards to preg regular expression once
203
-			$this->path_preg = '/^'.str_replace(array('\\?','\\*'),
204
-				array('.{1}','.*'), preg_quote($options['path'])).'$/i';
202
+			$this->path_preg = '/^'.str_replace(array('\\?', '\\*'),
203
+				array('.{1}', '.*'), preg_quote($options['path'])).'$/i';
205 204
 		
206 205
 		//Translate username to uid
207 206
 		if (!isset($options['uid']))
208 207
 		{
209 208
 			if (isset($options['user']))
210 209
 			{
211
-				$this->uid = $GLOBALS['egw']->accounts->name2id($options['user'],'account_lid','u');
210
+				$this->uid = $GLOBALS['egw']->accounts->name2id($options['user'], 'account_lid', 'u');
212 211
 			}
213 212
 			elseif (isset($options['nouser']))
214 213
 			{
@@ -225,7 +224,7 @@  discard block
 block discarded – undo
225 224
 		{
226 225
 			if (isset($options['group']))
227 226
 			{
228
-				$this->gid = abs($GLOBALS['egw']->accounts->name2id($options['group'],'account_lid','g'));
227
+				$this->gid = abs($GLOBALS['egw']->accounts->name2id($options['group'], 'account_lid', 'g'));
229 228
 			}
230 229
 			elseif (isset($options['nogroup']))
231 230
 			{
@@ -287,10 +286,10 @@  discard block
 block discarded – undo
287 286
 				
288 287
 				//Excludes files where the creation/last modification timestamps is greater than
289 288
 				//the given time
290
-				if ($this->cmin && !self::check_num(round((time()-$stat['ctime'])/60), $this->cmin) ||
291
-					$this->mmin && !self::check_num(round((time()-$stat['mtime'])/60), $this->mmin) ||
292
-					$this->ctime && !self::check_num(round((time()-$stat['ctime'])/86400), $this->ctime) ||
293
-					$this->mtime && !self::check_num(round((time()-$stat['mtime'])/86400), $this->mtime))
289
+				if ($this->cmin && !self::check_num(round((time() - $stat['ctime']) / 60), $this->cmin) ||
290
+					$this->mmin && !self::check_num(round((time() - $stat['mtime']) / 60), $this->mmin) ||
291
+					$this->ctime && !self::check_num(round((time() - $stat['ctime']) / 86400), $this->ctime) ||
292
+					$this->mtime && !self::check_num(round((time() - $stat['mtime']) / 86400), $this->mtime))
294 293
 				{
295 294
 					return $dir_filter;
296 295
 				}
@@ -312,7 +311,7 @@  discard block
 block discarded – undo
312 311
 					list($type, $subtype) = explode('/', $this->mime);
313 312
 					
314 313
 					// no subtype (eg. 'image') --> check only the main type
315
-					if ($sub_type || substr($this->mime, 0, strlen($type)+1) != $type.'/')
314
+					if ($sub_type || substr($this->mime, 0, strlen($type) + 1) != $type.'/')
316 315
 						return $dir_filter; // wrong mime-type
317 316
 				}
318 317
 			}
@@ -349,7 +348,7 @@  discard block
 block discarded – undo
349 348
 		$this->elements = array();
350 349
 		
351 350
 		//Loop through each element of the recursive directory iterator
352
-		foreach($this->iterator as $key => $value)
351
+		foreach ($this->iterator as $key => $value)
353 352
 		{
354 353
 			//Create a new egw_find_file class for each entry and filter it
355 354
 			$findfile = new egw_find_file( 
@@ -532,7 +531,7 @@  discard block
 block discarded – undo
532 531
 		if ($findfile->filterstate >= FILTER_OK)
533 532
 		{
534 533
 			$this->index++;
535
-			if (($this->index-1 >= $this->lower_limit) && 
534
+			if (($this->index - 1 >= $this->lower_limit) && 
536 535
 				(($this->mindepth === null) || count($this->iterator_stack) >= $this->mindepth))
537 536
 			{
538 537
 				$this->current_cache = $findfile->get_result($this->pairs);
@@ -629,8 +628,7 @@  discard block
 block discarded – undo
629 628
 		$this->mindepth = isset($options['mindepth']) ? $options['mindepth'] : null;
630 629
 		$this->maxdepth = isset($options['maxdepth']) ? $options['maxdepth'] : null;
631 630
 		$this->depth = isset($options['depth']) ? $options['depth'] : false;
632
-		$this->dirsontop = isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : 
633
-			(isset($options['maxdepth']) && $options['maxdepth']>0);
631
+		$this->dirsontop = isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : (isset($options['maxdepth']) && $options['maxdepth'] > 0);
634 632
 		$this->sort = isset($options['sort']) ? (($options['sort'] == 'ASC') ? 1 : -1) : 1;
635 633
 		$this->order = isset($options['order']) ? $options['order'] : null;
636 634
 		
@@ -656,7 +654,7 @@  discard block
 block discarded – undo
656 654
 		}
657 655
 	}
658 656
 	
659
-	public function __construct($base, $options=null, $pairs = false)
657
+	public function __construct($base, $options = null, $pairs = false)
660 658
 	{
661 659
 		//_debug_array($options);
662 660
 		$this->pairs = $pairs;
@@ -674,7 +672,7 @@  discard block
 block discarded – undo
674 672
 		}
675 673
 		
676 674
 		//Add the default url prefix to every path if url is not set.
677
-		foreach($this->base as $key => $path)
675
+		foreach ($this->base as $key => $path)
678 676
 			$this->base[$key] = translate_path($path, $this->url);
679 677
 
680 678
 		$this->rewind();
Please login to merge, or discard this patch.
Braces   +70 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
18 18
 define("FILTER_DISPLAY", -1); //The element filtered should not be returned to the caller of find, it should not be displayed
19 19
 define("FILTER_ALL", -2); //The element didn't pass the filter
20 20
 
21
-function translate_path($path, $isurl) {
21
+function translate_path($path, $isurl)
22
+{
22 23
 	return $isurl ? $path : egw_vfs::PREFIX.parse_url($path, PHP_URL_PATH);
23 24
 }
24 25
 
@@ -75,7 +76,9 @@  discard block
 block discarded – undo
75 76
 	{
76 77
 		//Check if the mime data has already been read, if not, read it
77 78
 		if ($this->mime === null)
78
-			$res['mime'] = egw_vfs::mime_content_type($this->base_path);
79
+		{
80
+					$res['mime'] = egw_vfs::mime_content_type($this->base_path);
81
+		}
79 82
 			
80 83
 		return $this->mime;
81 84
 	}
@@ -92,7 +95,9 @@  discard block
 block discarded – undo
92 95
 			);
93 96
 			
94 97
 			if ($this->props['islink'])
95
-				$this->props['linktarget'] = readlink($this->base_path);
98
+			{
99
+							$this->props['linktarget'] = readlink($this->base_path);
100
+			}
96 101
 		}
97 102
 		
98 103
 		return $this->props;
@@ -112,7 +117,9 @@  discard block
 block discarded – undo
112 117
 				$this->result['path'] = $this->name;
113 118
 				$this->result['name'] = $this->filename;
114 119
 				if ($this->need_mime)
115
-					$this->result['mime'] = $this->get_mime();
120
+				{
121
+									$this->result['mime'] = $this->get_mime();
122
+				}
116 123
 			}
117 124
 			else
118 125
 			{
@@ -167,10 +174,14 @@  discard block
 block discarded – undo
167 174
 	private static function check_num($value, $argument)
168 175
 	{
169 176
 		if (is_int($argument) && $argument >= 0 || $argument[0] != '-' && $argument[0] != '+')
170
-			return $value == $argument;
177
+		{
178
+					return $value == $argument;
179
+		}
171 180
 		
172 181
 		if ($argument < 0)
173
-			return $value < abs($argument);
182
+		{
183
+					return $value < abs($argument);
184
+		}
174 185
 		
175 186
 		return $value > (int) substr($argument,1);
176 187
 	}
@@ -195,13 +206,19 @@  discard block
 block discarded – undo
195 206
 		$this->mime = isset($options['mime']) ? $options['mime'] : null;
196 207
 		
197 208
 		//Convert the (probably) given path/name filters to regular expressions
198
-		if (isset($options['name']) && !isset($options['name_preg'])) // change from simple *,? wildcards to preg regular expression once
209
+		if (isset($options['name']) && !isset($options['name_preg']))
210
+		{
211
+			// change from simple *,? wildcards to preg regular expression once
199 212
 			$this->name_preg = '/^'.str_replace(array('\\?','\\*'),
200 213
 				array('.{1}','.*'), preg_quote($options['name'])).'$/i';
214
+		}
201 215
 		
202
-		if (isset($options['path']) && !isset($options['preg_path'])) // change from simple *,? wildcards to preg regular expression once
216
+		if (isset($options['path']) && !isset($options['preg_path']))
217
+		{
218
+			// change from simple *,? wildcards to preg regular expression once
203 219
 			$this->path_preg = '/^'.str_replace(array('\\?','\\*'),
204 220
 				array('.{1}','.*'), preg_quote($options['path'])).'$/i';
221
+		}
205 222
 		
206 223
 		//Translate username to uid
207 224
 		if (!isset($options['uid']))
@@ -244,11 +261,15 @@  discard block
 block discarded – undo
244 261
 		{
245 262
 			//Exclude directory and parent directory
246 263
 			if ($findfile->isdot)
247
-				return FILTER_ALL;
264
+			{
265
+							return FILTER_ALL;
266
+			}
248 267
 			
249 268
 			//Exclude hidden files			 
250 269
 			if (!$this->hidden && (($findfile->filename[0] == '.') || ($findfile->filename == 'Thumbs.db')))
251
-				return FILTER_ALL;
270
+			{
271
+							return FILTER_ALL;
272
+			}
252 273
 			
253 274
 			//Read the file properties (like (is link etc.))
254 275
 			$props = $findfile->get_props();
@@ -256,19 +277,26 @@  discard block
 block discarded – undo
256 277
 			//If this is a directory, we probably need to keep this entry to crawl
257 278
 			//for files inside this directory. That's what FILTER_DISPLAY is for
258 279
 			if ($props['isdir'] && (!($props['islink']) || $this->follow))
259
-				$dir_filter = FILTER_DISPLAY; 
260
-			else
261
-				$dir_filter = FILTER_ALL;
280
+			{
281
+							$dir_filter = FILTER_DISPLAY;
282
+			}
283
+			else {
284
+							$dir_filter = FILTER_ALL;
285
+			}
262 286
 			
263 287
 			//Exclude files/directories based on the given regular expression
264 288
 			if ($this->name_preg && !preg_match($this->name_preg, $findfile->filename) || 
265 289
 				$this->path_preg && !preg_match($this->path_preg, $findfile->path))
266
-				return $dir_filter;
290
+			{
291
+							return $dir_filter;
292
+			}
267 293
 			
268 294
 			//Exclude directories/symlinks/files			
269 295
 			if ($this->type && ($this->type == 'd') == !($props['isdir'] && !$props['islink']) ||
270 296
 				(($this->type == 'F') && ($props['isdir'] || $props['islink'])))
271
-				return $dir_filter;
297
+			{
298
+							return $dir_filter;
299
+			}
272 300
 			
273 301
 			if (($this->cmin !== null) || ($this->mmin !== null) || 
274 302
 				($this->ctime !== null) || ($this->mtime !== null) ||
@@ -297,15 +325,19 @@  discard block
 block discarded – undo
297 325
 				
298 326
 				//Check filesize
299 327
 				if (($this->size !== null) && !self::check_num($stat['size'], $this->size) ||
300
-					(!$this->empty && $stat['size'] <= 0)) //TODO Check this
328
+					(!$this->empty && $stat['size'] <= 0))
329
+				{
330
+					//TODO Check this
301 331
 				{
302 332
 					return $dir_filter;
303 333
 				}
334
+				}
304 335
 			}
305 336
 			
306 337
 			//Check the mime type and subtype. As loading the mime type takes the
307 338
 			//longest time, it is postponed as long as possible
308
-			if ($this->mime !== null) {
339
+			if ($this->mime !== null)
340
+			{
309 341
 				$mime = $findfile->get_mime();
310 342
 				if ($options['mime'] != $mime)
311 343
 				{
@@ -313,7 +345,10 @@  discard block
 block discarded – undo
313 345
 					
314 346
 					// no subtype (eg. 'image') --> check only the main type
315 347
 					if ($sub_type || substr($this->mime, 0, strlen($type)+1) != $type.'/')
316
-						return $dir_filter; // wrong mime-type
348
+					{
349
+											return $dir_filter;
350
+					}
351
+					// wrong mime-type
317 352
 				}
318 353
 			}
319 354
 			
@@ -557,7 +592,7 @@  discard block
 block discarded – undo
557 592
 			while (($cur != null) && (!$this->upper_limit || ($this->index <= $this->upper_limit)))
558 593
 			{
559 594
 				$skip = false;
560
-				if ($cur->valid()) 
595
+				if ($cur->valid())
561 596
 				{
562 597
 					//Get a copy of the current file state
563 598
 					$findfile = $cur->current();
@@ -573,12 +608,16 @@  discard block
 block discarded – undo
573 608
 					}
574 609
 					
575 610
 					//Step the current element one further and get the (probably) new iterator
576
-					if (!$skip)	
577
-						$cur->next();
611
+					if (!$skip)
612
+					{
613
+											$cur->next();
614
+					}
578 615
 					$cur = $this->cur_iterator();
579 616
 					
580 617
 					if (!$skip && $this->output_directory($findfile))
581
-						break;
618
+					{
619
+											break;
620
+					}
582 621
 				}
583 622
 				
584 623
 				//If the current iterator doesn't contain any valid element, we're at the
@@ -608,7 +647,9 @@  discard block
 block discarded – undo
608 647
 							$findfile = $cur->current();
609 648
 							$cur->next();
610 649
 							if ($this->output_directory($findfile))
611
-								break;
650
+							{
651
+															break;
652
+							}
612 653
 						}
613 654
 					}
614 655
 				}
@@ -620,7 +661,9 @@  discard block
 block discarded – undo
620 661
 	{
621 662
 		//If options is not set, make it an empty array
622 663
 		if (!$options)
623
-			$options = array();
664
+		{
665
+					$options = array();
666
+		}
624 667
 		
625 668
 		//Create the filter object (passed to other objects by reference) and
626 669
 		//parse some other options relevant for this base class		
@@ -675,7 +718,9 @@  discard block
 block discarded – undo
675 718
 		
676 719
 		//Add the default url prefix to every path if url is not set.
677 720
 		foreach($this->base as $key => $path)
678
-			$this->base[$key] = translate_path($path, $this->url);
721
+		{
722
+					$this->base[$key] = translate_path($path, $this->url);
723
+		}
679 724
 
680 725
 		$this->rewind();
681 726
 	}
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_framework.inc.php 5 patches
Doc Comments   +5 added lines, -17 removed lines patch added patch discarded remove patch
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 	/**
988 988
 	 * Returns html with user and time
989 989
 	 *
990
-	 * @return void
990
+	 * @return string
991 991
 	 */
992 992
 	protected static function _user_time_info()
993 993
 	{
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 *
1116 1116
 	 * @param string $username =null username for regular basic auth
1117 1117
 	 * @param string $password =null password --------- " ----------
1118
-	 * @return resource|null context to use with file_get_context/fopen or null if no proxy configured
1118
+	 * @return resource context to use with file_get_context/fopen or null if no proxy configured
1119 1119
 	 */
1120 1120
 	public static function proxy_context($username=null, $password=null)
1121 1121
 	{
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
 	 * Parse beginning of given CSS file for /*@import url("...") statements
1461 1461
 	 *
1462 1462
 	 * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css
1463
-	 * @return array parsed pathes (EGroupware relative) including $path itself
1463
+	 * @return string[] parsed pathes (EGroupware relative) including $path itself
1464 1464
 	 */
1465 1465
 	protected static function resolve_css_includes($path, &$pathes=array())
1466 1466
 	{
@@ -1577,7 +1577,6 @@  discard block
 block discarded – undo
1577 1577
 	 *
1578 1578
 	 * Themes are css file in the template directory
1579 1579
 	 *
1580
-	 * @param string $themes_dir ='css'
1581 1580
 	 */
1582 1581
 	function list_themes()
1583 1582
 	{
@@ -1761,11 +1760,6 @@  discard block
 block discarded – undo
1761 1760
 	/**
1762 1761
 	* Add menu items to the topmenu template class to be displayed
1763 1762
 	*
1764
-	* @param array $app application data
1765
-	* @param mixed $alt_label string with alternative menu item label default value = null
1766
-	* @param string $urlextra string with alternate additional code inside <a>-tag
1767
-	* @access protected
1768
-	* @return void
1769 1763
 	*/
1770 1764
 	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1771 1765
 
@@ -1974,12 +1968,6 @@  discard block
 block discarded – undo
1974 1968
 	* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1975 1969
 	* @param string|array $file =null file to be included - no ".js" on the end or array with get params
1976 1970
 	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1977
-	* @param boolean $append =true should the file be added
1978
-	*
1979
-	* @discuss The browser specific option loads the file which is in the correct
1980
-	*          browser folder. Supported folder are those supported by class.browser.inc.php
1981
-	*
1982
-	* @returns bool was the file found?
1983 1971
 	*/
1984 1972
 	static function validate_file($package, $file=null, $app='phpgwapi')
1985 1973
 	{
@@ -2090,7 +2078,7 @@  discard block
 block discarded – undo
2090 2078
 	 * Generate bundle url(s) for given js files
2091 2079
 	 *
2092 2080
 	 * @param array $js_includes
2093
-	 * @param int& $max_modified =null on return maximum modification time of bundle
2081
+	 * @param integer $max_modified =null on return maximum modification time of bundle
2094 2082
 	 * @return array js-files (can be more then one, if one of given files can not be bundeled)
2095 2083
 	 */
2096 2084
 	protected static function bundle_urls(array $js_includes, &$max_modified=null)
@@ -2382,7 +2370,7 @@  discard block
 block discarded – undo
2382 2370
 	 * @param string $action "add" or "delete"
2383 2371
 	 * @param boolean|int|string $group ID of the group to create the favorite for, or 'all' for all users
2384 2372
 	 * @param array $filters =array() key => value pairs for the filter
2385
-	 * @return boolean Success
2373
+	 * @return boolean|null Success
2386 2374
 	 */
2387 2375
 	public static function ajax_set_favorite($app, $name, $action, $group, $filters = array())
2388 2376
 	{
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
 	var $template_dir;
54 54
 
55 55
 	/**
56
-	* true if $this->header() was called
57
-	*
58
-	* @var boolean
59
-	*/
56
+	 * true if $this->header() was called
57
+	 *
58
+	 * @var boolean
59
+	 */
60 60
 	static $header_done = false;
61 61
 	/**
62
-	* true if $this->navbar() was called
63
-	*
64
-	* @var boolean
65
-	*/
62
+	 * true if $this->navbar() was called
63
+	 *
64
+	 * @var boolean
65
+	 */
66 66
 	static $navbar_done = false;
67 67
 
68 68
 	/**
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	 *
583 583
 	 * @param string $extra_vars for login url
584 584
 	 * @param string $change_passwd =null string with message to render input fields for password change
585
-	*/
585
+	 */
586 586
 	function login_screen($extra_vars, $change_passwd=null)
587 587
 	{
588 588
 		self::csp_frame_src_attrs(array());	// array() no external frame-sources
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 	}
760 760
 
761 761
 	/**
762
-	* displays a login denied message
763
-	*/
762
+	 * displays a login denied message
763
+	 */
764 764
 	function denylogin_screen()
765 765
 	{
766 766
 		$tmpl = new Template(EGW_SERVER_ROOT.$this->template_dir);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 		ob_start();
823 823
 		// Include the apps footer files if it exists
824 824
 		if (EGW_APP_INC != EGW_API_INC &&	// this prevents an endless inclusion on the homepage
825
-			                                // (some apps set currentapp in hook_home => it's not releyable)
825
+											// (some apps set currentapp in hook_home => it's not releyable)
826 826
 			(file_exists (EGW_APP_INC . '/footer.inc.php') || isset($_GET['menuaction'])) &&
827 827
 			$GLOBALS['egw_info']['flags']['currentapp'] != 'home' &&
828 828
 			$GLOBALS['egw_info']['flags']['currentapp'] != 'login' &&
@@ -1649,13 +1649,13 @@  discard block
 block discarded – undo
1649 1649
 	}
1650 1650
 
1651 1651
 	/**
1652
-	* Compile entries for topmenu:
1653
-	* - regular items: links
1654
-	* - info items
1655
-	*
1656
-	* @param array $vars
1657
-	* @param array $apps
1658
-	*/
1652
+	 * Compile entries for topmenu:
1653
+	 * - regular items: links
1654
+	 * - info items
1655
+	 *
1656
+	 * @param array $vars
1657
+	 * @param array $apps
1658
+	 */
1659 1659
 	function topmenu(array $vars,array $apps)
1660 1660
 	{
1661 1661
 		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
@@ -1759,39 +1759,39 @@  discard block
 block discarded – undo
1759 1759
 	}
1760 1760
 
1761 1761
 	/**
1762
-	* Add menu items to the topmenu template class to be displayed
1763
-	*
1764
-	* @param array $app application data
1765
-	* @param mixed $alt_label string with alternative menu item label default value = null
1766
-	* @param string $urlextra string with alternate additional code inside <a>-tag
1767
-	* @access protected
1768
-	* @return void
1769
-	*/
1762
+	 * Add menu items to the topmenu template class to be displayed
1763
+	 *
1764
+	 * @param array $app application data
1765
+	 * @param mixed $alt_label string with alternative menu item label default value = null
1766
+	 * @param string $urlextra string with alternate additional code inside <a>-tag
1767
+	 * @access protected
1768
+	 * @return void
1769
+	 */
1770 1770
 	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1771 1771
 
1772 1772
 	/**
1773
-	* Add info items to the topmenu template class to be displayed
1774
-	*
1775
-	* @param string $content html of item
1776
-	* @param string $id =null
1777
-	* @access protected
1778
-	* @return void
1779
-	*/
1773
+	 * Add info items to the topmenu template class to be displayed
1774
+	 *
1775
+	 * @param string $content html of item
1776
+	 * @param string $id =null
1777
+	 * @access protected
1778
+	 * @return void
1779
+	 */
1780 1780
 	abstract function _add_topmenu_info_item($content, $id=null);
1781 1781
 
1782 1782
 	static $top_menu_extra = array();
1783 1783
 
1784 1784
 	/**
1785
-	* Called by hooks to add an entry in the topmenu location.
1786
-	* Extra entries will be added just before Logout.
1787
-	*
1788
-	* @param string $id unique element id
1789
-	* @param string $url Address for the entry to link to
1790
-	* @param string $title Text displayed for the entry
1791
-	* @param string $target Optional, so the entry can open in a new page or popup
1792
-	* @access public
1793
-	* @return void
1794
-	*/
1785
+	 * Called by hooks to add an entry in the topmenu location.
1786
+	 * Extra entries will be added just before Logout.
1787
+	 *
1788
+	 * @param string $id unique element id
1789
+	 * @param string $url Address for the entry to link to
1790
+	 * @param string $title Text displayed for the entry
1791
+	 * @param string $target Optional, so the entry can open in a new page or popup
1792
+	 * @access public
1793
+	 * @return void
1794
+	 */
1795 1795
 	public static function add_topmenu_item($id,$url,$title,$target = '')
1796 1796
 	{
1797 1797
 		$entry['name'] = $id;
@@ -1803,16 +1803,16 @@  discard block
 block discarded – undo
1803 1803
 	}
1804 1804
 
1805 1805
 	/**
1806
-	* called by hooks to add an icon in the topmenu info location
1807
-	*
1808
-	* @param string $id unique element id
1809
-	* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
1810
-	* @param string $iconlink where the icon links to
1811
-	* @param booleon $blink set true to make the icon blink
1812
-	* @param mixed $tooltip string containing the tooltip html, or null of no tooltip
1813
-	* @access public
1814
-	* @return void
1815
-	*/
1806
+	 * called by hooks to add an icon in the topmenu info location
1807
+	 *
1808
+	 * @param string $id unique element id
1809
+	 * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
1810
+	 * @param string $iconlink where the icon links to
1811
+	 * @param booleon $blink set true to make the icon blink
1812
+	 * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
1813
+	 * @access public
1814
+	 * @return void
1815
+	 */
1816 1816
 	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1817 1817
 
1818 1818
 	/**
@@ -1963,24 +1963,24 @@  discard block
 block discarded – undo
1963 1963
 	protected static $js_include_mgr;
1964 1964
 
1965 1965
 	/**
1966
-	* Checks to make sure a valid package and file name is provided
1967
-	*
1968
-	* Example call syntax:
1969
-	* a) egw_framework::validate_file('jscalendar','calendar')
1970
-	*    --> /phpgwapi/js/jscalendar/calendar.js
1971
-	* b) egw_framework::validate_file('/phpgwapi/inc/calendar-setup.js',array('lang'=>'de'))
1972
-	*    --> /phpgwapi/inc/calendar-setup.js?lang=de
1973
-	*
1974
-	* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1975
-	* @param string|array $file =null file to be included - no ".js" on the end or array with get params
1976
-	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1977
-	* @param boolean $append =true should the file be added
1978
-	*
1979
-	* @discuss The browser specific option loads the file which is in the correct
1980
-	*          browser folder. Supported folder are those supported by class.browser.inc.php
1981
-	*
1982
-	* @returns bool was the file found?
1983
-	*/
1966
+	 * Checks to make sure a valid package and file name is provided
1967
+	 *
1968
+	 * Example call syntax:
1969
+	 * a) egw_framework::validate_file('jscalendar','calendar')
1970
+	 *    --> /phpgwapi/js/jscalendar/calendar.js
1971
+	 * b) egw_framework::validate_file('/phpgwapi/inc/calendar-setup.js',array('lang'=>'de'))
1972
+	 *    --> /phpgwapi/inc/calendar-setup.js?lang=de
1973
+	 *
1974
+	 * @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1975
+	 * @param string|array $file =null file to be included - no ".js" on the end or array with get params
1976
+	 * @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1977
+	 * @param boolean $append =true should the file be added
1978
+	 *
1979
+	 * @discuss The browser specific option loads the file which is in the correct
1980
+	 *          browser folder. Supported folder are those supported by class.browser.inc.php
1981
+	 *
1982
+	 * @returns bool was the file found?
1983
+	 */
1984 1984
 	static function validate_file($package, $file=null, $app='phpgwapi')
1985 1985
 	{
1986 1986
 		self::$js_include_mgr->include_js_file($package, $file, $app);
Please login to merge, or discard this patch.
Spacing   +236 added lines, -238 removed lines patch added patch discarded remove patch
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 		$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
102 102
 		if (!class_exists($class))	// first try to autoload the class
103 103
 		{
104
-			require_once($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
105
-			if (!in_array($file,(array)$_SESSION['egw_required_files']))
104
+			require_once($file = EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
105
+			if (!in_array($file, (array)$_SESSION['egw_required_files']))
106 106
 			{
107
-				$_SESSION['egw_required_files'][] = $file;	// automatic load the used framework class, when the object get's restored
107
+				$_SESSION['egw_required_files'][] = $file; // automatic load the used framework class, when the object get's restored
108 108
 			}
109 109
 		}
110 110
 		// fall back to idots if a template does NOT support current user-agent
111
-		if ($class != 'idots_framework' && method_exists($class,'is_supported_user_agent') &&
112
-			!call_user_func(array($class,'is_supported_user_agent')))
111
+		if ($class != 'idots_framework' && method_exists($class, 'is_supported_user_agent') &&
112
+			!call_user_func(array($class, 'is_supported_user_agent')))
113 113
 		{
114 114
 			$GLOBALS['egw_info']['server']['template_set'] = 'idots';
115 115
 			return self::factory();
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 * @param string|array $set =array() 'unsafe-eval' and/or 'unsafe-inline' (without quotes!) or URL (incl. protocol!)
139 139
 	 * @return string with attributes eg. "'unsafe-eval' 'unsafe-inline'"
140 140
 	 */
141
-	public static function csp_script_src_attrs($set=null)
141
+	public static function csp_script_src_attrs($set = null)
142 142
 	{
143
-		foreach((array)$set as $attr)
143
+		foreach ((array)$set as $attr)
144 144
 		{
145 145
 			if (in_array($attr, array('none', 'self', 'unsafe-eval', 'unsafe-inline')))
146 146
 			{
147
-				$attr = "'$attr'";	// automatic add quotes
147
+				$attr = "'$attr'"; // automatic add quotes
148 148
 			}
149 149
 			if (!in_array($attr, self::$csp_script_src_attrs))
150 150
 			{
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
 	 * @param string|array $set =array() 'unsafe-inline' (without quotes!) and/or URL (incl. protocol!)
174 174
 	 * @return string with attributes eg. "'unsafe-inline'"
175 175
 	 */
176
-	public static function csp_style_src_attrs($set=null)
176
+	public static function csp_style_src_attrs($set = null)
177 177
 	{
178
-		foreach((array)$set as $attr)
178
+		foreach ((array)$set as $attr)
179 179
 		{
180 180
 			if (in_array($attr, array('none', 'self', 'unsafe-inline')))
181 181
 			{
182
-				$attr = "'$attr'";	// automatic add quotes
182
+				$attr = "'$attr'"; // automatic add quotes
183 183
 			}
184 184
 			if (!in_array($attr, self::$csp_style_src_attrs))
185 185
 			{
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	 * @param string|array $set =array() URL (incl. protocol!)
205 205
 	 * @return string with attributes eg. "'unsafe-inline'"
206 206
 	 */
207
-	public static function csp_connect_src_attrs($set=null)
207
+	public static function csp_connect_src_attrs($set = null)
208 208
 	{
209
-		foreach((array)$set as $attr)
209
+		foreach ((array)$set as $attr)
210 210
 		{
211 211
 			if (!in_array($attr, self::$csp_connect_src_attrs))
212 212
 			{
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @param string|array $set =array() URL (incl. protocol!)
234 234
 	 * @return string with attributes eg. "'unsafe-inline'"
235 235
 	 */
236
-	public static function csp_frame_src_attrs($set=null)
236
+	public static function csp_frame_src_attrs($set = null)
237 237
 	{
238 238
 		// set frame-src attrs of API and apps via hook
239 239
 		if (!isset(self::$csp_frame_src_attrs) && !isset($set))
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 			$frame_src = array('manual.egroupware.org', 'www.egroupware.org');
242 242
 			if (($app_additional = $GLOBALS['egw']->hooks->process('csp-frame-src')))
243 243
 			{
244
-				foreach($app_additional as $addtional)
244
+				foreach ($app_additional as $addtional)
245 245
 				{
246 246
 					if ($addtional) $frame_src = array_unique(array_merge($frame_src, $addtional));
247 247
 				}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
 		if (!isset(self::$csp_frame_src_attrs)) self::$csp_frame_src_attrs = array();
253 253
 
254
-		foreach((array)$set as $attr)
254
+		foreach ((array)$set as $attr)
255 255
 		{
256 256
 			if (!in_array($attr, self::$csp_frame_src_attrs))
257 257
 			{
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 
284 284
 		//$csp = "default-src * 'unsafe-eval' 'unsafe-inline'";	// allow everything
285 285
 		header("Content-Security-Policy: $csp");
286
-		header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
287
-		header("X-Content-Security-Policy: $csp");	// FF <= 22
286
+		header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS
287
+		header("X-Content-Security-Policy: $csp"); // FF <= 22
288 288
 
289 289
 		// allow client-side to detect first load aka just logged in
290
-		$reload_count =& egw_cache::getSession(__CLASS__, 'framework-reload');
290
+		$reload_count = & egw_cache::getSession(__CLASS__, 'framework-reload');
291 291
 		self::$extra['framework-reload'] = (int)(bool)$reload_count++;
292 292
 	}
293 293
 
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
329 329
 	 * @return string	The full url after processing
330 330
 	 */
331
-	static function link($url, $extravars = '', $link_app=null)
331
+	static function link($url, $extravars = '', $link_app = null)
332 332
 	{
333
-		unset($link_app);	// not used by required by function signature
333
+		unset($link_app); // not used by required by function signature
334 334
 		return $GLOBALS['egw']->session->link($url, $extravars);
335 335
 	}
336 336
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
343 343
 	 * @return string	The full url after processing
344 344
 	 */
345
-	static function redirect_link($url, $extravars='', $link_app=null)
345
+	static function redirect_link($url, $extravars = '', $link_app = null)
346 346
 	{
347 347
 		egw::redirect(self::link($url, $extravars), $link_app);
348 348
 	}
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 * @param string $navbar =null show the navigation, default !$GLOBALS['egw_info']['flags']['nonavbar'], false gives a typical popu
358 358
 	 *
359 359
 	 */
360
-	function render($content,$app_header=null,$navbar=null)
360
+	function render($content, $app_header = null, $navbar = null)
361 361
 	{
362 362
 		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
363 363
 		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 	 * @param string $with =null
407 407
 	 * @param string $msg_type =null 'error', 'warning' or 'success' (default)
408 408
 	 */
409
-	public static function refresh_opener($msg, $app, $id=null, $type=null, $targetapp=null, $replace=null, $with=null, $msg_type=null)
409
+	public static function refresh_opener($msg, $app, $id = null, $type = null, $targetapp = null, $replace = null, $with = null, $msg_type = null)
410 410
 	{
411 411
 		//error_log(__METHOD__.'('.array2string(func_get_args()).')');
412 412
 		self::$extra['refresh-opener'] = func_get_args();
413 413
 
414
-		unset($msg, $app, $id, $type, $targetapp, $replace, $with, $msg_type);	// used only via func_get_args();
414
+		unset($msg, $app, $id, $type, $targetapp, $replace, $with, $msg_type); // used only via func_get_args();
415 415
 	}
416 416
 
417 417
 	/**
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	 * @param string $msg message to show
423 423
 	 * @param string $type ='success' 'error', 'warning' or 'success' (default)
424 424
 	 */
425
-	public static function message($msg, $type='success')
425
+	public static function message($msg, $type = 'success')
426 426
 	{
427 427
 		self::$extra['message'] = func_get_args();
428 428
 
429
-		unset($msg, $type);	// used only via func_get_args();
429
+		unset($msg, $type); // used only via func_get_args();
430 430
 	}
431 431
 
432 432
 	/**
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
 	 * @param string $target
437 437
 	 * @param string $popup
438 438
 	 */
439
-	public static function popup($link, $target='_blank', $popup='640x480')
439
+	public static function popup($link, $target = '_blank', $popup = '640x480')
440 440
 	{
441 441
 		// default params are not returned by func_get_args!
442
-		$args = func_get_args()+array(null, '_blank', '640x480');
442
+		$args = func_get_args() + array(null, '_blank', '640x480');
443 443
 
444
-		unset($link, $target, $popup);	// used only via func_get_args()
444
+		unset($link, $target, $popup); // used only via func_get_args()
445 445
 
446 446
 		if (egw_json_request::isJSONRequest())
447 447
 		{
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	 *
459 459
 	 * @param string $alert_msg ='' optional message to display as alert, before closing the window
460 460
 	 */
461
-	public static function window_close($alert_msg='')
461
+	public static function window_close($alert_msg = '')
462 462
 	{
463 463
 		//error_log(__METHOD__."()");
464 464
 		self::$extra['window-close'] = $alert_msg ? $alert_msg : true;
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	public static function get_extra()
516 516
 	{
517 517
 		// adding links of refreshed entry, to give others apps more information about necessity to refresh
518
-		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 &&	// do not run twice
518
+		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 && // do not run twice
519 519
 			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))	// app/id given
520 520
 		{
521 521
 			$links = egw_link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]);
522 522
 			$apps = array();
523
-			foreach($links as $link)
523
+			foreach ($links as $link)
524 524
 			{
525 525
 				$apps[$link['app']][] = $link['id'];
526 526
 			}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	 *
539 539
 	 * @return string with html
540 540
 	 */
541
-	abstract function header(array $extra=array());
541
+	abstract function header(array $extra = array());
542 542
 
543 543
 	/**
544 544
 	 * Returns the html from the body-tag til the main application area (incl. opening div tag)
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true
559 559
 	 * @return boolean
560 560
 	 */
561
-	abstract function isTop($consider_navbar_not_yet_called_as_true=true);
561
+	abstract function isTop($consider_navbar_not_yet_called_as_true = true);
562 562
 
563 563
 	/**
564 564
 	 * Returns the content of one sidebox
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * @param array $file
569 569
 	 * @param string $type =null 'admin', 'preferences', 'favorites', ...
570 570
 	 */
571
-	abstract function sidebox($appname,$menu_title,$file,$type=null);
571
+	abstract function sidebox($appname, $menu_title, $file, $type = null);
572 572
 
573 573
 	/**
574 574
 	 * Returns the html from the closing div of the main application area to the closing html-tag
@@ -583,24 +583,24 @@  discard block
 block discarded – undo
583 583
 	 * @param string $extra_vars for login url
584 584
 	 * @param string $change_passwd =null string with message to render input fields for password change
585 585
 	*/
586
-	function login_screen($extra_vars, $change_passwd=null)
586
+	function login_screen($extra_vars, $change_passwd = null)
587 587
 	{
588
-		self::csp_frame_src_attrs(array());	// array() no external frame-sources
588
+		self::csp_frame_src_attrs(array()); // array() no external frame-sources
589 589
 
590 590
 		//error_log(__METHOD__."() this->template=$this->template, this->template_dir=$this->template_dir, get_class(this)=".get_class($this));
591 591
 		$tmpl = new Template(EGW_SERVER_ROOT.$this->template_dir);
592 592
 
593 593
 		$tmpl->set_file(array('login_form' => 'login.tpl'));
594 594
 
595
-		$tmpl->set_var('lang_message',$GLOBALS['loginscreenmessage']);
595
+		$tmpl->set_var('lang_message', $GLOBALS['loginscreenmessage']);
596 596
 
597 597
 		// hide change-password fields, if not requested
598 598
 		if (!$change_passwd)
599 599
 		{
600
-			$tmpl->set_block('login_form','change_password');
600
+			$tmpl->set_block('login_form', 'change_password');
601 601
 			$tmpl->set_var('change_password', '');
602
-			$tmpl->set_var('lang_password',lang('password'));
603
-			$tmpl->set_var('cd',check_logoutcode($_GET['cd']));
602
+			$tmpl->set_var('lang_password', lang('password'));
603
+			$tmpl->set_var('cd', check_logoutcode($_GET['cd']));
604 604
 			$tmpl->set_var('cd_class', isset($_GET['cd']) && $_GET['cd'] != 1 ? 'error' : '');
605 605
 			$last_loginid = $_COOKIE['last_loginid'];
606 606
 			$last_domain  = $_COOKIE['last_domain'];
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
 		}
610 610
 		else
611 611
 		{
612
-			$tmpl->set_var('lang_password',lang('Old password'));
613
-			$tmpl->set_var('lang_new_password',lang('New password'));
614
-			$tmpl->set_var('lang_repeat_password',lang('Repeat password'));
612
+			$tmpl->set_var('lang_password', lang('Old password'));
613
+			$tmpl->set_var('lang_new_password', lang('New password'));
614
+			$tmpl->set_var('lang_repeat_password', lang('Repeat password'));
615 615
 			$tmpl->set_var('cd', $change_passwd);
616 616
 			$tmpl->set_var('cd_class', 'error');
617 617
 			$last_loginid = $_POST['login'];
@@ -620,55 +620,55 @@  discard block
 block discarded – undo
620 620
 			$tmpl->set_var('autofocus_login', '');
621 621
 			$tmpl->set_var('autofocus_new_passwd', 'autofocus');
622 622
 		}
623
-		if($GLOBALS['egw_info']['server']['show_domain_selectbox'])
623
+		if ($GLOBALS['egw_info']['server']['show_domain_selectbox'])
624 624
 		{
625
-			foreach(array_keys($GLOBALS['egw_domain']) as $domain)
625
+			foreach (array_keys($GLOBALS['egw_domain']) as $domain)
626 626
 			{
627 627
 				$domains[$domain] = $domain;
628 628
 			}
629 629
 			$tmpl->set_var(array(
630 630
 				'lang_domain'   => lang('domain'),
631
-				'select_domain' => html::select('logindomain',$last_domain,$domains,true,'tabindex="2"',0,false),
631
+				'select_domain' => html::select('logindomain', $last_domain, $domains, true, 'tabindex="2"', 0, false),
632 632
 			));
633 633
 		}
634 634
 		else
635 635
 		{
636 636
 			/* trick to make domain section disapear */
637
-			$tmpl->set_block('login_form','domain_selection');
638
-			$tmpl->set_var('domain_selection',$GLOBALS['egw_info']['user']['domain'] ?
639
-			html::input_hidden('logindomain',$GLOBALS['egw_info']['user']['domain']) : '');
637
+			$tmpl->set_block('login_form', 'domain_selection');
638
+			$tmpl->set_var('domain_selection', $GLOBALS['egw_info']['user']['domain'] ?
639
+			html::input_hidden('logindomain', $GLOBALS['egw_info']['user']['domain']) : '');
640 640
 
641
-			if($last_loginid !== '')
641
+			if ($last_loginid !== '')
642 642
 			{
643 643
 				reset($GLOBALS['egw_domain']);
644 644
 				list($default_domain) = each($GLOBALS['egw_domain']);
645 645
 
646
-				if(!empty ($last_domain) && $last_domain != $default_domain)
646
+				if (!empty ($last_domain) && $last_domain != $default_domain)
647 647
 				{
648
-					$last_loginid .= '@' . $last_domain;
648
+					$last_loginid .= '@'.$last_domain;
649 649
 				}
650 650
 			}
651 651
 		}
652 652
 
653 653
 		$config_reg = config::read('registration');
654 654
 
655
-		if($config_reg['enable_registration'])
655
+		if ($config_reg['enable_registration'])
656 656
 		{
657 657
 			if ($config_reg['register_link'])
658 658
 			{
659
-				$reg_link='&nbsp;<a href="'. egw::link('/registration/index.php','lang_code='.$_GET['lang']). '">'.lang('Not a user yet? Register now').'</a><br/>';
659
+				$reg_link = '&nbsp;<a href="'.egw::link('/registration/index.php', 'lang_code='.$_GET['lang']).'">'.lang('Not a user yet? Register now').'</a><br/>';
660 660
 			}
661 661
 			if ($config_reg['lostpassword_link'])
662 662
 			{
663
-				$lostpw_link='&nbsp;<a href="'. egw::link('/registration/index.php','menuaction=registration.registration_ui.lost_password&lang_code='.$_GET['lang']). '">'.lang('Lost password').'</a><br/>';
663
+				$lostpw_link = '&nbsp;<a href="'.egw::link('/registration/index.php', 'menuaction=registration.registration_ui.lost_password&lang_code='.$_GET['lang']).'">'.lang('Lost password').'</a><br/>';
664 664
 			}
665 665
 			if ($config_reg['lostid_link'])
666 666
 			{
667
-				$lostid_link='&nbsp;<a href="'. egw::link('/registration/index.php','menuaction=registration.registration_ui.lost_username&lang_code='.$_GET['lang']). '">'.lang('Lost Login Id').'</a><br/>';
667
+				$lostid_link = '&nbsp;<a href="'.egw::link('/registration/index.php', 'menuaction=registration.registration_ui.lost_username&lang_code='.$_GET['lang']).'">'.lang('Lost Login Id').'</a><br/>';
668 668
 			}
669 669
 
670 670
 			/* if at least one option of "registration" is activated display the registration section */
671
-			if($config_reg['register_link'] || $config_reg['lostpassword_link'] || $config_reg['lostid_link'] )
671
+			if ($config_reg['register_link'] || $config_reg['lostpassword_link'] || $config_reg['lostid_link'])
672 672
 			{
673 673
 				$tmpl->set_var(array(
674 674
 				'register_link'     => $reg_link,
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
 			else
680 680
 			{
681 681
 				/* trick to make registration section disapear */
682
-				$tmpl->set_block('login_form','registration');
683
-				$tmpl->set_var('registration','');
682
+				$tmpl->set_block('login_form', 'registration');
683
+				$tmpl->set_var('registration', '');
684 684
 			}
685 685
 		}
686 686
 
687
-		$tmpl->set_var('login_url', $GLOBALS['egw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
687
+		$tmpl->set_var('login_url', $GLOBALS['egw_info']['server']['webserver_url'].'/login.php'.$extra_vars);
688 688
 		$tmpl->set_var('version', $GLOBALS['egw_info']['server']['versions']['phpgwapi']);
689 689
 		$tmpl->set_var('login', $last_loginid);
690 690
 
691
-		$tmpl->set_var('lang_username',lang('username'));
692
-		$tmpl->set_var('lang_login',lang('login'));
691
+		$tmpl->set_var('lang_username', lang('username'));
692
+		$tmpl->set_var('lang_login', lang('login'));
693 693
 
694 694
 		$tmpl->set_var('website_title', $GLOBALS['egw_info']['server']['site_title']);
695
-		$tmpl->set_var('template_set',$this->template);
695
+		$tmpl->set_var('template_set', $this->template);
696 696
 
697 697
 		if (substr($GLOBALS['egw_info']['server']['login_logo_file'], 0, 4) == 'http' ||
698 698
 			$GLOBALS['egw_info']['server']['login_logo_file'][0] == '/')
@@ -701,14 +701,14 @@  discard block
 block discarded – undo
701 701
 		}
702 702
 		else
703 703
 		{
704
-			$var['logo_file'] = common::image('phpgwapi',$GLOBALS['egw_info']['server']['login_logo_file']?$GLOBALS['egw_info']['server']['login_logo_file']:'logo', '', null);	// null=explicit allow svg
704
+			$var['logo_file'] = common::image('phpgwapi', $GLOBALS['egw_info']['server']['login_logo_file'] ? $GLOBALS['egw_info']['server']['login_logo_file'] : 'logo', '', null); // null=explicit allow svg
705 705
 		}
706
-		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
707
-		if (substr($var['logo_url'],0,4) != 'http')
706
+		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url'] ? $GLOBALS['egw_info']['server']['login_logo_url'] : 'http://www.eGroupWare.org';
707
+		if (substr($var['logo_url'], 0, 4) != 'http')
708 708
 		{
709 709
 			$var['logo_url'] = 'http://'.$var['logo_url'];
710 710
 		}
711
-		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
711
+		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title'] ? $GLOBALS['egw_info']['server']['login_logo_title'] : 'www.eGroupWare.org';
712 712
 		$tmpl->set_var($var);
713 713
 
714 714
 		/* language section if activated in site config */
@@ -716,14 +716,14 @@  discard block
 block discarded – undo
716 716
 		{
717 717
 			$tmpl->set_var(array(
718 718
 				'lang_language' => lang('Language'),
719
-				'select_language' => html::select('lang',$GLOBALS['egw_info']['user']['preferences']['common']['lang'],
720
-				translation::get_installed_langs(),true,'tabindex="1"',0,false),
719
+				'select_language' => html::select('lang', $GLOBALS['egw_info']['user']['preferences']['common']['lang'],
720
+				translation::get_installed_langs(), true, 'tabindex="1"', 0, false),
721 721
 			));
722 722
 		}
723 723
 		else
724 724
 		{
725
-			$tmpl->set_block('login_form','language_select');
726
-			$tmpl->set_var('language_select','');
725
+			$tmpl->set_block('login_form', 'language_select');
726
+			$tmpl->set_var('language_select', '');
727 727
 		}
728 728
 
729 729
 		/********************************************************\
@@ -731,31 +731,31 @@  discard block
 block discarded – undo
731 731
 		* and place a time selectbox, how long cookie is valid   *
732 732
 		\********************************************************/
733 733
 
734
-		if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
734
+		if ($GLOBALS['egw_info']['server']['allow_cookie_auth'])
735 735
 		{
736
-			$tmpl->set_block('login_form','remember_me_selection');
737
-			$tmpl->set_var('lang_remember_me',lang('Remember me'));
738
-			$tmpl->set_var('select_remember_me',html::select('remember_me', '', array(
736
+			$tmpl->set_block('login_form', 'remember_me_selection');
737
+			$tmpl->set_var('lang_remember_me', lang('Remember me'));
738
+			$tmpl->set_var('select_remember_me', html::select('remember_me', '', array(
739 739
 				'' => lang('not'),
740 740
 				'1hour' => lang('1 Hour'),
741 741
 				'1day' => lang('1 Day'),
742 742
 				'1week'=> lang('1 Week'),
743 743
 				'1month' => lang('1 Month'),
744 744
 				'forever' => lang('Forever'),
745
-			),true,'tabindex="3"',0,false));
745
+			), true, 'tabindex="3"', 0, false));
746 746
 		}
747 747
 		else
748 748
 		{
749 749
 			/* trick to make remember_me section disapear */
750
-			$tmpl->set_block('login_form','remember_me_selection');
751
-			$tmpl->set_var('remember_me_selection','');
750
+			$tmpl->set_block('login_form', 'remember_me_selection');
751
+			$tmpl->set_var('remember_me_selection', '');
752 752
 		}
753 753
 		$tmpl->set_var('autocomplete', ($GLOBALS['egw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
754 754
 
755 755
 		// load jquery for login screen too
756 756
 		self::validate_file('jquery', 'jquery');
757 757
 
758
-		$this->render($tmpl->fp('loginout','login_form'),false,false);
758
+		$this->render($tmpl->fp('loginout', 'login_form'), false, false);
759 759
 	}
760 760
 
761 761
 	/**
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		// load jquery for deny-login screen too
779 779
 		self::validate_file('jquery', 'jquery');
780 780
 
781
-		$this->render($tmpl->fp('loginout','login_form'),false,false);
781
+		$this->render($tmpl->fp('loginout', 'login_form'), false, false);
782 782
 	}
783 783
 
784 784
 	/**
@@ -789,19 +789,19 @@  discard block
 block discarded – undo
789 789
 	public function _get_footer()
790 790
 	{
791 791
 		$var = Array(
792
-			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
792
+			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images',
793 793
 			'version'        => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
794 794
 		);
795 795
 		$var['page_generation_time'] = '';
796
-		if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
796
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
797 797
 		{
798
-			$totaltime = sprintf('%4.2lf',microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']);
798
+			$totaltime = sprintf('%4.2lf', microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']);
799 799
 
800
-			$var['page_generation_time'] = '<div class="pageGenTime" id="divGenTime_'.$GLOBALS['egw_info']['flags']['currentapp'].'"><span>'.lang('Page was generated in %1 seconds',$totaltime);
800
+			$var['page_generation_time'] = '<div class="pageGenTime" id="divGenTime_'.$GLOBALS['egw_info']['flags']['currentapp'].'"><span>'.lang('Page was generated in %1 seconds', $totaltime);
801 801
 			if ($GLOBALS['egw_info']['flags']['session_restore_time'])
802 802
 			{
803 803
 				$var['page_generation_time'] .= ' '.lang('(session restored in %1 seconds)',
804
-					sprintf('%4.2lf',$GLOBALS['egw_info']['flags']['session_restore_time']));
804
+					sprintf('%4.2lf', $GLOBALS['egw_info']['flags']['session_restore_time']));
805 805
 			}
806 806
 			$var['page_generation_time'] .= '</span></div>';
807 807
 		}
@@ -821,23 +821,23 @@  discard block
 block discarded – undo
821 821
 	{
822 822
 		ob_start();
823 823
 		// Include the apps footer files if it exists
824
-		if (EGW_APP_INC != EGW_API_INC &&	// this prevents an endless inclusion on the homepage
824
+		if (EGW_APP_INC != EGW_API_INC && // this prevents an endless inclusion on the homepage
825 825
 			                                // (some apps set currentapp in hook_home => it's not releyable)
826
-			(file_exists (EGW_APP_INC . '/footer.inc.php') || isset($_GET['menuaction'])) &&
826
+			(file_exists(EGW_APP_INC.'/footer.inc.php') || isset($_GET['menuaction'])) &&
827 827
 			$GLOBALS['egw_info']['flags']['currentapp'] != 'home' &&
828 828
 			$GLOBALS['egw_info']['flags']['currentapp'] != 'login' &&
829 829
 			$GLOBALS['egw_info']['flags']['currentapp'] != 'logout' &&
830 830
 			!@$GLOBALS['egw_info']['flags']['noappfooter'])
831 831
 		{
832
-			list(, $class) = explode('.',(string)$_GET['menuaction']);
832
+			list(, $class) = explode('.', (string)$_GET['menuaction']);
833 833
 			if ($class && is_object($GLOBALS[$class]) && is_array($GLOBALS[$class]->public_functions) &&
834 834
 				isset($GLOBALS[$class]->public_functions['footer']))
835 835
 			{
836 836
 				$GLOBALS[$class]->footer();
837 837
 			}
838
-			elseif(file_exists(EGW_APP_INC.'/footer.inc.php'))
838
+			elseif (file_exists(EGW_APP_INC.'/footer.inc.php'))
839 839
 			{
840
-				include(EGW_APP_INC . '/footer.inc.php');
840
+				include(EGW_APP_INC.'/footer.inc.php');
841 841
 			}
842 842
 		}
843 843
 		$content = ob_get_contents();
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
853 853
 	 * @return array
854 854
 	 */
855
-	protected function _get_header(array $extra=array())
855
+	protected function _get_header(array $extra = array())
856 856
 	{
857 857
 		// display password expires in N days message once per session
858 858
 		$message = null;
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 		}
864 864
 
865 865
 		// get used language code (with a little xss check, if someone tries to sneak something in)
866
-		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$GLOBALS['egw_info']['user']['preferences']['common']['lang']))
866
+		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $GLOBALS['egw_info']['user']['preferences']['common']['lang']))
867 867
 		{
868 868
 			$lang_code = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
869 869
 		}
@@ -875,9 +875,9 @@  discard block
 block discarded – undo
875 875
 			$pngfix = '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'."\n";
876 876
 
877 877
 			// pngfix for IE6 defaults to yes
878
-			if(!$GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'] && html::$ua_version < 7)
878
+			if (!$GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'] && html::$ua_version < 7)
879 879
 			{
880
-				$pngfix_src = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/idots/js/pngfix.js';
880
+				$pngfix_src = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/idots/js/pngfix.js';
881 881
 				$pngfix .= '<!-- This solves the Internet Explorer PNG-transparency bug, but only for IE 5.5 - 6.0 and higher -->
882 882
 				<!--[if lt IE 7.0]>
883 883
 				<script src="'.$pngfix_src.'" type="text/javascript">
@@ -894,14 +894,14 @@  discard block
 block discarded – undo
894 894
 		// send appheader to clientside
895 895
 		$extra['app-header'] = $app_header;
896 896
 
897
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
898
-		if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
897
+		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots = '<meta name="robots" content="none" />';
898
+		if (substr($GLOBALS['egw_info']['server']['favicon_file'], 0, 4) == 'http')
899 899
 		{
900 900
 			$var['favicon_file'] = $GLOBALS['egw_info']['server']['favicon_file'];
901 901
 		}
902 902
 		else
903 903
 		{
904
-			$var['favicon_file'] = common::image('phpgwapi',$GLOBALS['egw_info']['server']['favicon_file']?$GLOBALS['egw_info']['server']['favicon_file']:'favicon.ico');
904
+			$var['favicon_file'] = common::image('phpgwapi', $GLOBALS['egw_info']['server']['favicon_file'] ? $GLOBALS['egw_info']['server']['favicon_file'] : 'favicon.ico');
905 905
 		}
906 906
 
907 907
 		if ($GLOBALS['egw_info']['flags']['include_wz_tooltip'] &&
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			$include_wz_tooltip = '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].
911 911
 				$wz_tooltip.'?'.filemtime(EGW_SERVER_ROOT.$wz_tooltip).'" type="text/javascript"></script>';
912 912
 		}
913
-		return $this->_get_css()+array(
913
+		return $this->_get_css() + array(
914 914
 			'img_icon'			=> $var['favicon_file'],
915 915
 			'img_shortcut'		=> $var['favicon_file'],
916 916
 			'pngfix'        	=> $pngfix,
@@ -934,15 +934,15 @@  discard block
 block discarded – undo
934 934
 	 */
935 935
 	protected function _get_navbar($apps)
936 936
 	{
937
-		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images';
937
+		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/'.$this->template.'/images';
938 938
 
939
-		if(isset($GLOBALS['egw_info']['flags']['app_header']))
939
+		if (isset($GLOBALS['egw_info']['flags']['app_header']))
940 940
 		{
941 941
 			$var['current_app_title'] = $GLOBALS['egw_info']['flags']['app_header'];
942 942
 		}
943 943
 		else
944 944
 		{
945
-			$var['current_app_title']=$apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
945
+			$var['current_app_title'] = $apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
946 946
 		}
947 947
 		$var['currentapp'] = $GLOBALS['egw_info']['flags']['currentapp'];
948 948
 
@@ -954,32 +954,32 @@  discard block
 block discarded – undo
954 954
 
955 955
 		$var['user_info'] = $this->_user_time_info();
956 956
 
957
-		if($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
957
+		if ($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
958 958
 		{
959 959
 			$api_messages = lang('You are required to change your password during your first login').'<br />'.
960
-				lang('Click this image on the navbar: %1','<img src="'.common::image('preferences','navbar.gif').'">');
960
+				lang('Click this image on the navbar: %1', '<img src="'.common::image('preferences', 'navbar.gif').'">');
961 961
 		}
962
-		elseif($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && $GLOBALS['egw_info']['user']['account_lastpwd_change'] < time() - (86400*$GLOBALS['egw_info']['server']['change_pwd_every_x_days']))
962
+		elseif ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && $GLOBALS['egw_info']['user']['account_lastpwd_change'] < time() - (86400 * $GLOBALS['egw_info']['server']['change_pwd_every_x_days']))
963 963
 		{
964
-			$api_messages = lang('it has been more then %1 days since you changed your password',$GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
964
+			$api_messages = lang('it has been more then %1 days since you changed your password', $GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
965 965
 		}
966 966
 
967
-		if (substr($GLOBALS['egw_info']['server']['login_logo_file'],0,4) == 'http' ||
967
+		if (substr($GLOBALS['egw_info']['server']['login_logo_file'], 0, 4) == 'http' ||
968 968
 			$GLOBALS['egw_info']['server']['login_logo_file'][0] == '/')
969 969
 		{
970 970
 			$var['logo_file'] = $GLOBALS['egw_info']['server']['login_logo_file'];
971 971
 		}
972 972
 		else
973 973
 		{
974
-			$var['logo_file'] = common::image('phpgwapi',$GLOBALS['egw_info']['server']['login_logo_file']?$GLOBALS['egw_info']['server']['login_logo_file']:'logo', '', null);	// null=explicit allow svg
974
+			$var['logo_file'] = common::image('phpgwapi', $GLOBALS['egw_info']['server']['login_logo_file'] ? $GLOBALS['egw_info']['server']['login_logo_file'] : 'logo', '', null); // null=explicit allow svg
975 975
 		}
976
-		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
976
+		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url'] ? $GLOBALS['egw_info']['server']['login_logo_url'] : 'http://www.eGroupWare.org';
977 977
 
978
-		if (substr($var['logo_url'],0,4) != 'http')
978
+		if (substr($var['logo_url'], 0, 4) != 'http')
979 979
 		{
980 980
 			$var['logo_url'] = 'http://'.$var['logo_url'];
981 981
 		}
982
-		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
982
+		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title'] ? $GLOBALS['egw_info']['server']['login_logo_title'] : 'www.eGroupWare.org';
983 983
 
984 984
 		return $var;
985 985
 	}
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 	protected static function _user_time_info()
993 993
 	{
994 994
 		$now = new egw_time();
995
-		$user_info = '<b>'.common::display_fullname() .'</b>'. ' - ' . lang($now->format('l')) . ' ' . $now->format(true);
995
+		$user_info = '<b>'.common::display_fullname().'</b>'.' - '.lang($now->format('l')).' '.$now->format(true);
996 996
 
997 997
 		$user_tzs = egw_time::getUserTimezones();
998 998
 		if (count($user_tzs) > 1)
999 999
 		{
1000 1000
 			$tz = $GLOBALS['egw_info']['user']['preferences']['common']['tz'];
1001
-			$user_info .= html::form(html::select('tz',$tz,$user_tzs,true),array(),
1002
-				'/index.php','','tz_selection',' style="display: inline;"','GET');
1001
+			$user_info .= html::form(html::select('tz', $tz, $user_tzs, true), array(),
1002
+				'/index.php', '', 'tz_selection', ' style="display: inline;"', 'GET');
1003 1003
 		}
1004 1004
 		return $user_info;
1005 1005
 	}
@@ -1011,10 +1011,10 @@  discard block
 block discarded – undo
1011 1011
 	 */
1012 1012
 	protected static function _current_users()
1013 1013
 	{
1014
-	   if( $GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
1014
+	   if ($GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
1015 1015
 	   {
1016
-		  $current_users = '<a href="' . egw::link('/index.php','menuaction=admin.admin_accesslog.sessions') . '">' .
1017
-		  	lang('Current users') . ': <span id="currentusers">' . $GLOBALS['egw']->session->session_count() . '</span></a>';
1016
+		  $current_users = '<a href="'.egw::link('/index.php', 'menuaction=admin.admin_accesslog.sessions').'">'.
1017
+		  	lang('Current users').': <span id="currentusers">'.$GLOBALS['egw']->session->session_count().'</span></a>';
1018 1018
 		  return $current_users;
1019 1019
 	   }
1020 1020
 	}
@@ -1070,8 +1070,8 @@  discard block
 block discarded – undo
1070 1070
 				list($current, $security) = explode("\n", $remote);
1071 1071
 				if (empty($security)) $security = $current;
1072 1072
 				$versions = array(
1073
-					'current'  => $current,		// last maintenance update
1074
-					'security' => $security,	// last security update
1073
+					'current'  => $current, // last maintenance update
1074
+					'security' => $security, // last security update
1075 1075
 				);
1076 1076
 			}
1077 1077
 			return $versions;
@@ -1117,14 +1117,14 @@  discard block
 block discarded – undo
1117 1117
 	 * @param string $password =null password --------- " ----------
1118 1118
 	 * @return resource|null context to use with file_get_context/fopen or null if no proxy configured
1119 1119
 	 */
1120
-	public static function proxy_context($username=null, $password=null)
1120
+	public static function proxy_context($username = null, $password = null)
1121 1121
 	{
1122 1122
 		$opts = array(
1123 1123
 			'method' => 'GET',
1124 1124
 		);
1125 1125
 		if (!empty($GLOBALS['egw_info']['server']['httpproxy_server']))
1126 1126
 		{
1127
-			$opts += array (
1127
+			$opts += array(
1128 1128
 				'proxy'  => 'tcp://'.$GLOBALS['egw_info']['server']['httpproxy_server'].':'.
1129 1129
 					($GLOBALS['egw_info']['server']['httpproxy_port'] ? $GLOBALS['egw_info']['server']['httpproxy_port'] : 8080),
1130 1130
 				'request_fulluri' => true,
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 	 */
1157 1157
 	protected static function update_older($version, $days)
1158 1158
 	{
1159
-		list(,,$date) = explode('.', $version);
1159
+		list(,, $date) = explode('.', $version);
1160 1160
 		if ($date < 20140000) return false;
1161 1161
 		$version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4));
1162 1162
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	 * @param string &$changelog on return path to changelog
1170 1170
 	 * @return string
1171 1171
 	 */
1172
-	public static function api_version(&$changelog=null)
1172
+	public static function api_version(&$changelog = null)
1173 1173
 	{
1174 1174
 		$version = preg_replace('/[^0-9.]/', '', $GLOBALS['egw_info']['server']['versions']['phpgwapi']);
1175 1175
 		// parse version from changelog
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 	 */
1193 1193
 	public static function index($app)
1194 1194
 	{
1195
-		$data =& $GLOBALS['egw_info']['user']['apps'][$app];
1195
+		$data = & $GLOBALS['egw_info']['user']['apps'][$app];
1196 1196
 		if (!isset($data))
1197 1197
 		{
1198 1198
 			throw new egw_exception_wrong_parameter("'$app' not a valid app for this user!");
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 				$index = '/index.php?menuaction='.$data['index'];
1210 1210
 			}
1211 1211
 		}
1212
-		return egw::link($index,$GLOBALS['egw_info']['flags']['params'][$app]);
1212
+		return egw::link($index, $GLOBALS['egw_info']['flags']['params'][$app]);
1213 1213
 	}
1214 1214
 
1215 1215
 	/**
@@ -1250,15 +1250,15 @@  discard block
 block discarded – undo
1250 1250
 	 *	true: always return svg, false: never return svg (current default), null: browser dependent, see svg_usable()
1251 1251
 	 * @return array
1252 1252
 	 */
1253
-	protected static function _get_navbar_apps($svg=false)
1253
+	protected static function _get_navbar_apps($svg = false)
1254 1254
 	{
1255 1255
 		list($first) = each($GLOBALS['egw_info']['user']['apps']);
1256
-		if(is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
1256
+		if (is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
1257 1257
 		{
1258 1258
 			$newarray['admin'] = $GLOBALS['egw_info']['user']['apps']['admin'];
1259
-			foreach($GLOBALS['egw_info']['user']['apps'] as $index => $value)
1259
+			foreach ($GLOBALS['egw_info']['user']['apps'] as $index => $value)
1260 1260
 			{
1261
-				if($index != 'admin')
1261
+				if ($index != 'admin')
1262 1262
 				{
1263 1263
 					$newarray[$index] = $value;
1264 1264
 				}
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 		unset($newarray);
1272 1272
 
1273 1273
 		$apps = array();
1274
-		foreach($GLOBALS['egw_info']['user']['apps'] as $app => $data)
1274
+		foreach ($GLOBALS['egw_info']['user']['apps'] as $app => $data)
1275 1275
 		{
1276 1276
 			if (is_long($app))
1277 1277
 			{
@@ -1288,29 +1288,29 @@  discard block
 block discarded – undo
1288 1288
 				if ($data['status'] == 4)
1289 1289
 				{
1290 1290
 					$apps[$app]['target'] = ' target="'.$app.'" onClick="'."if (this != '') { window.open(this+'".
1291
-						(strpos($apps[$app]['url'],'?') !== false ? '&' : '?').
1291
+						(strpos($apps[$app]['url'], '?') !== false ? '&' : '?').
1292 1292
 						"referer='+encodeURIComponent(location),this.target,'width=800,height=600,scrollbars=yes,resizable=yes'); return false; } else { return true; }".'"';
1293 1293
 				}
1294
-				elseif(isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
1294
+				elseif (isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
1295 1295
 				{
1296
-					$apps[$app]['target'] = 'target="' . $GLOBALS['egw_info']['flags']['navbar_target'] . '"';
1296
+					$apps[$app]['target'] = 'target="'.$GLOBALS['egw_info']['flags']['navbar_target'].'"';
1297 1297
 				}
1298 1298
 				else
1299 1299
 				{
1300 1300
 					$apps[$app]['target'] = '';
1301 1301
 				}
1302 1302
 
1303
-				$icon = isset($data['icon']) ?  $data['icon'] : 'navbar';
1303
+				$icon = isset($data['icon']) ? $data['icon'] : 'navbar';
1304 1304
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
1305 1305
 				if ($app != $GLOBALS['egw_info']['flags']['currentapp'])
1306 1306
 				{
1307
-					$apps[$app]['icon']  = common::image($icon_app,Array($icon,'nonav'),'',$svg);
1308
-					$apps[$app]['icon_hover']  = common::image_on($icon_app,Array($icon,'nonav'),'-over',$svg);
1307
+					$apps[$app]['icon'] = common::image($icon_app, Array($icon, 'nonav'), '', $svg);
1308
+					$apps[$app]['icon_hover'] = common::image_on($icon_app, Array($icon, 'nonav'), '-over', $svg);
1309 1309
 				}
1310 1310
 				else
1311 1311
 				{
1312
-					$apps[$app]['icon']  = common::image_on($icon_app,Array($icon,'nonav'),'-over',$svg);
1313
-					$apps[$app]['icon_hover']  = common::image($icon_app,Array($icon,'nonav'),'',$svg);
1312
+					$apps[$app]['icon'] = common::image_on($icon_app, Array($icon, 'nonav'), '-over', $svg);
1313
+					$apps[$app]['icon_hover'] = common::image($icon_app, Array($icon, 'nonav'), '', $svg);
1314 1314
 				}
1315 1315
 			}
1316 1316
 		}
@@ -1345,15 +1345,15 @@  discard block
 block discarded – undo
1345 1345
 		$apps['about']['title'] = 'EGroupware';
1346 1346
 
1347 1347
 		$apps['about']['url']   = egw::link('/about.php');
1348
-		$apps['about']['icon']  = common::image('phpgwapi',Array('about','nonav'));
1349
-		$apps['about']['icon_hover']  = common::image_on('phpgwapi',Array('about','nonav'),'-over');
1348
+		$apps['about']['icon']  = common::image('phpgwapi', Array('about', 'nonav'));
1349
+		$apps['about']['icon_hover'] = common::image_on('phpgwapi', Array('about', 'nonav'), '-over');
1350 1350
 		$apps['about']['name'] = 'about';
1351 1351
 
1352 1352
 		$apps['logout']['title'] = lang('Logout');
1353 1353
 		$apps['logout']['name'] = 'logout';
1354 1354
 		$apps['logout']['url']   = egw::link('/logout.php');
1355
-		$apps['logout']['icon']  = common::image('phpgwapi',Array('logout','nonav'));
1356
-		$apps['logout']['icon_hover']  = common::image_on('phpgwapi',Array('logout','nonav'),'-over');
1355
+		$apps['logout']['icon']  = common::image('phpgwapi', Array('logout', 'nonav'));
1356
+		$apps['logout']['icon_hover'] = common::image_on('phpgwapi', Array('logout', 'nonav'), '-over');
1357 1357
 
1358 1358
 		return $apps;
1359 1359
 	}
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 			if (html::$ua_mobile) $themes_to_check[] = $this->template_dir.'/css/mobile.css';
1400 1400
 			$themes_to_check[] = $this->template_dir.'/css/'.$GLOBALS['egw_info']['user']['preferences']['common']['theme'].'.css';
1401 1401
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
1402
-			foreach($themes_to_check as $theme_css)
1402
+			foreach ($themes_to_check as $theme_css)
1403 1403
 			{
1404 1404
 				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
1405 1405
 			}
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 
1412 1412
 			// sending print css last, so it can overwrite anything
1413 1413
 			$print_css = $this->template_dir.'/print.css';
1414
-			if(!file_exists(EGW_SERVER_ROOT.$print_css))
1414
+			if (!file_exists(EGW_SERVER_ROOT.$print_css))
1415 1415
 			{
1416 1416
 				$print_css = '/phpgwapi/templates/idots/print.css';
1417 1417
 			}
@@ -1423,15 +1423,15 @@  discard block
 block discarded – undo
1423 1423
 		$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
1424 1424
 		if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
1425 1425
 		$css_files = '';
1426
-		foreach(self::$css_include_files as $path)
1426
+		foreach (self::$css_include_files as $path)
1427 1427
 		{
1428
-			foreach(self::resolve_css_includes($path) as $path)
1428
+			foreach (self::resolve_css_includes($path) as $path)
1429 1429
 			{
1430
-				list($file,$query) = explode('?',$path,2);
1430
+				list($file, $query) = explode('?', $path, 2);
1431 1431
 				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod;
1432 1432
 
1433 1433
 				// do NOT include app.css or categories.php, as it changes from app to app
1434
-				if ($debug_minify || substr($path, -8) == '/app.css' || substr($file,-14) == 'categories.php')
1434
+				if ($debug_minify || substr($path, -8) == '/app.css' || substr($file, -14) == 'categories.php')
1435 1435
 				{
1436 1436
 					$css_files .= '<link href="'.$GLOBALS['egw_info']['server']['webserver_url'].$path.($query ? '&' : '?').$mod.'" type="text/css" rel="StyleSheet" />'."\n";
1437 1437
 				}
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 		{
1446 1446
 			$css = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/inc/min/?';
1447 1447
 			if ($base_path && $base_path != '/') $css .= 'b='.substr($base_path, 1).'&';
1448
-			$css .= 'f='.$css_file .
1448
+			$css .= 'f='.$css_file.
1449 1449
 				($GLOBALS['egw_info']['server']['debug_minify'] === 'debug' ? '&debug' : '').
1450 1450
 				'&'.$max_modified;
1451 1451
 			$css_files = '<link href="'.$css.'" type="text/css" rel="StyleSheet" />'."\n".$css_files;
@@ -1462,20 +1462,20 @@  discard block
 block discarded – undo
1462 1462
 	 * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css
1463 1463
 	 * @return array parsed pathes (EGroupware relative) including $path itself
1464 1464
 	 */
1465
-	protected static function resolve_css_includes($path, &$pathes=array())
1465
+	protected static function resolve_css_includes($path, &$pathes = array())
1466 1466
 	{
1467 1467
 		$matches = null;
1468 1468
 
1469
-		list($file,$query) = explode('?',$path,2);
1470
-		if (($to_check = file_get_contents (EGW_SERVER_ROOT.$file, false, null, -1, 1024)) &&
1469
+		list($file, $query) = explode('?', $path, 2);
1470
+		if (($to_check = file_get_contents(EGW_SERVER_ROOT.$file, false, null, -1, 1024)) &&
1471 1471
 			stripos($to_check, '/*@import') !== false && preg_match_all('|/\*@import url\("([^"]+)"|i', $to_check, $matches))
1472 1472
 		{
1473
-			foreach($matches[1] as $import_path)
1473
+			foreach ($matches[1] as $import_path)
1474 1474
 			{
1475 1475
 				if ($import_path[0] != '/')
1476 1476
 				{
1477 1477
 					$dir = dirname($path);
1478
-					while(substr($import_path,0,3) == '../')
1478
+					while (substr($import_path, 0, 3) == '../')
1479 1479
 					{
1480 1480
 						$dir = dirname($dir);
1481 1481
 						$import_path = substr($import_path, 3);
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
 	 * @param array $extra =array() extra data to pass to egw.js as data-parameter
1501 1501
 	 * @return string the javascript to be included
1502 1502
 	 */
1503
-	public static function _get_js(array $extra=array())
1503
+	public static function _get_js(array $extra = array())
1504 1504
 	{
1505 1505
 		$java_script = '';
1506 1506
 
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 		Think of conf vars etc...  ([email protected]) */
1509 1509
 		if (isset($GLOBALS['egw_info']['flags']['java_script_thirst']))
1510 1510
 		{
1511
-			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst'] . "\n";
1511
+			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst']."\n";
1512 1512
 		}
1513 1513
 		// add configuration, link-registry, images, user-data and -perferences for non-popup windows
1514 1514
 		// specifying etag in url to force reload, as we send expires header
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 			self::validate_file('/phpgwapi/images.php', array(
1521 1521
 				'template' => $GLOBALS['egw_info']['server']['template_set'],
1522 1522
 				'etag' => md5(json_encode(common::image_map($GLOBALS['egw_info']['server']['template_set']))),
1523
-				'svg' => 0,	// always load non-svg image map
1523
+				'svg' => 0, // always load non-svg image map
1524 1524
 			));
1525 1525
 			self::validate_file('/phpgwapi/user.php', array(
1526 1526
 				'user' => $GLOBALS['egw_info']['user']['account_lid'],
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
 		}
1533 1533
 
1534 1534
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
1535
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
1535
+		$extra['include'] = array_map(function($str) {return substr($str, 1); }, self::get_script_links(true), array(1));
1536 1536
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
1537 1537
 
1538 1538
 		// Load LABjs ONCE here
@@ -1542,18 +1542,18 @@  discard block
 block discarded – undo
1542 1542
 				'/phpgwapi/js/jsapi/egw.js?'.filemtime(EGW_SERVER_ROOT.'/phpgwapi/js/jsapi/egw.js').'" id="egw_script_id"';
1543 1543
 
1544 1544
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
1545
-		foreach($extra+self::$extra as $name => $value)
1545
+		foreach ($extra + self::$extra as $name => $value)
1546 1546
 		{
1547 1547
 			if (is_array($value)) $value = json_encode($value);
1548 1548
 			// we need to double encode (html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
1549
-			$java_script .= ' data-'.$name."=\"". html::htmlspecialchars($value, true)."\"";
1549
+			$java_script .= ' data-'.$name."=\"".html::htmlspecialchars($value, true)."\"";
1550 1550
 		}
1551 1551
 		$java_script .= "></script>\n";
1552 1552
 
1553
-		if(@isset($_GET['menuaction']))
1553
+		if (@isset($_GET['menuaction']))
1554 1554
 		{
1555
-			list(, $class) = explode('.',$_GET['menuaction']);
1556
-			if(is_array($GLOBALS[$class]->public_functions) &&
1555
+			list(, $class) = explode('.', $_GET['menuaction']);
1556
+			if (is_array($GLOBALS[$class]->public_functions) &&
1557 1557
 				$GLOBALS[$class]->public_functions['java_script'])
1558 1558
 			{
1559 1559
 				$java_script .= $GLOBALS[$class]->java_script();
@@ -1562,10 +1562,10 @@  discard block
 block discarded – undo
1562 1562
 		if (isset($GLOBALS['egw_info']['flags']['java_script']))
1563 1563
 		{
1564 1564
 			// Strip out any script tags, this needs to be executed as anonymous function
1565
-			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']);
1566
-			if(trim($GLOBALS['egw_info']['flags']['java_script']) != '')
1565
+			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']);
1566
+			if (trim($GLOBALS['egw_info']['flags']['java_script']) != '')
1567 1567
 			{
1568
-				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script'] . "});</script>\n";
1568
+				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script']."});</script>\n";
1569 1569
 			}
1570 1570
 		}
1571 1571
 
@@ -1582,13 +1582,13 @@  discard block
 block discarded – undo
1582 1582
 	function list_themes()
1583 1583
 	{
1584 1584
 		$list = array();
1585
-		if (($dh = @opendir(EGW_SERVER_ROOT.$this->template_dir . SEP . 'css')))
1585
+		if (($dh = @opendir(EGW_SERVER_ROOT.$this->template_dir.SEP.'css')))
1586 1586
 		{
1587 1587
 			while (($file = readdir($dh)))
1588 1588
 			{
1589 1589
 				if (preg_match('/'."\.css$".'/i', $file))
1590 1590
 				{
1591
-					list($name) = explode('.',$file);
1591
+					list($name) = explode('.', $file);
1592 1592
 					$list[$name] = $name;
1593 1593
 				}
1594 1594
 			}
@@ -1603,20 +1603,19 @@  discard block
 block discarded – undo
1603 1603
 	 * @param boolean $full_data =false true: value is array with values for keys 'name', 'title', ...
1604 1604
 	 * @returns array alphabetically sorted list of templates
1605 1605
 	 */
1606
-	static function list_templates($full_data=false)
1606
+	static function list_templates($full_data = false)
1607 1607
 	{
1608
-		$list = array('pixelegg'=>null,'jdots'=>null,'idots'=>null);
1608
+		$list = array('pixelegg'=>null, 'jdots'=>null, 'idots'=>null);
1609 1609
 		// templates packaged in the api
1610
-		$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
1611
-		while (($entry=$d->read()))
1610
+		$d = dir(EGW_SERVER_ROOT.'/phpgwapi/templates');
1611
+		while (($entry = $d->read()))
1612 1612
 		{
1613
-			if ($entry != '..' && file_exists(EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry .'/class.'.$entry.'_framework.inc.php'))
1613
+			if ($entry != '..' && file_exists(EGW_SERVER_ROOT.'/phpgwapi/templates/'.$entry.'/class.'.$entry.'_framework.inc.php'))
1614 1614
 			{
1615
-				if (file_exists ($f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php'))
1615
+				if (file_exists($f = EGW_SERVER_ROOT.'/phpgwapi/templates/'.$entry.'/setup/setup.inc.php'))
1616 1616
 				{
1617 1617
 					include($f);
1618
-					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
1619
-						$GLOBALS['egw_info']['template'][$entry]['title'];
1618
+					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] : $GLOBALS['egw_info']['template'][$entry]['title'];
1620 1619
 				}
1621 1620
 				else
1622 1621
 				{
@@ -1630,16 +1629,15 @@  discard block
 block discarded – undo
1630 1629
 		$d->close();
1631 1630
 		// templates packaged like apps in own directories (containing as setup/setup.inc.php file!)
1632 1631
 		$dr = dir(EGW_SERVER_ROOT);
1633
-		while (($entry=$dr->read()))
1632
+		while (($entry = $dr->read()))
1634 1633
 		{
1635 1634
 			if ($entry != '..' && !isset($GLOBALS['egw_info']['apps'][$entry]) && is_dir(EGW_SERVER_ROOT.'/'.$entry) &&
1636
-				file_exists($f = EGW_SERVER_ROOT . '/' . $entry .'/setup/setup.inc.php'))
1635
+				file_exists($f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'))
1637 1636
 			{
1638 1637
 				include($f);
1639 1638
 				if (isset($GLOBALS['egw_info']['template'][$entry]))
1640 1639
 				{
1641
-					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
1642
-						$GLOBALS['egw_info']['template'][$entry]['title'];
1640
+					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] : $GLOBALS['egw_info']['template'][$entry]['title'];
1643 1641
 				}
1644 1642
 			}
1645 1643
 		}
@@ -1656,14 +1654,14 @@  discard block
 block discarded – undo
1656 1654
 	* @param array $vars
1657 1655
 	* @param array $apps
1658 1656
 	*/
1659
-	function topmenu(array $vars,array $apps)
1657
+	function topmenu(array $vars, array $apps)
1660 1658
 	{
1661
-		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1659
+		if ($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1662 1660
 		{
1663 1661
 			$this->_add_topmenu_item($apps['home']);
1664 1662
 		}
1665 1663
 
1666
-		if($GLOBALS['egw_info']['user']['apps']['preferences'])
1664
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
1667 1665
 		{
1668 1666
 			$this->add_preferences_topmenu('prefs');
1669 1667
 			$this->add_preferences_topmenu('acl');
@@ -1688,9 +1686,9 @@  discard block
 block discarded – undo
1688 1686
 			$this->_add_topmenu_item(array_merge($apps['manual'],array('title' => lang('Help'))));
1689 1687
 		}*/
1690 1688
 
1691
-		$GLOBALS['egw']->hooks->process('topmenu_info',array(),true);
1689
+		$GLOBALS['egw']->hooks->process('topmenu_info', array(), true);
1692 1690
 		// Add extra items added by hooks
1693
-		foreach(self::$top_menu_extra as $extra_item) {
1691
+		foreach (self::$top_menu_extra as $extra_item) {
1694 1692
 			$this->_add_topmenu_item($extra_item);
1695 1693
 		}
1696 1694
 
@@ -1700,7 +1698,7 @@  discard block
 block discarded – undo
1700 1698
 		{
1701 1699
 			$this->_add_topmenu_info_item($update, 'update');
1702 1700
 		}
1703
-		if($GLOBALS['egw_info']['user']['apps']['notifications'])
1701
+		if ($GLOBALS['egw_info']['user']['apps']['notifications'])
1704 1702
 		{
1705 1703
 			$this->_add_topmenu_info_item(self::_get_notification_bell(), 'notifications');
1706 1704
 		}
@@ -1712,9 +1710,9 @@  discard block
 block discarded – undo
1712 1710
 	/**
1713 1711
 	 * Add preferences link to topmenu using settings-hook to know if an app supports preferences
1714 1712
 	 */
1715
-	protected function add_preferences_topmenu($type='prefs')
1713
+	protected function add_preferences_topmenu($type = 'prefs')
1716 1714
 	{
1717
-		static $memberships=null;
1715
+		static $memberships = null;
1718 1716
 		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1719 1717
 		static $types = array(
1720 1718
 			'prefs' => array(
@@ -1728,20 +1726,20 @@  discard block
 block discarded – undo
1728 1726
 			'cats' => array(
1729 1727
 				'title' => 'Categories',
1730 1728
 				'hook' => 'categories',
1731
-				'run_hook' => true,	// acturally run hook, not just look it's implemented
1729
+				'run_hook' => true, // acturally run hook, not just look it's implemented
1732 1730
 			),
1733 1731
 		);
1734 1732
 		if (!$GLOBALS['egw_info']['user']['apps']['preferences'] || $GLOBALS['egw_info']['server']['deny_'.$type] &&
1735 1733
 			array_intersect($memberships, (array)$GLOBALS['egw_info']['server']['deny_'.$type]) &&
1736 1734
 			!$GLOBALS['egw_info']['user']['apps']['admin'])
1737 1735
 		{
1738
-			return;	// user has no access to preferences app
1736
+			return; // user has no access to preferences app
1739 1737
 		}
1740 1738
 		if (isset($types[$type]['run_hook']))
1741 1739
 		{
1742 1740
 			$apps = $GLOBALS['egw']->hooks->process($types[$type]['hook']);
1743 1741
 			// as all apps answer, we need to remove none-true responses
1744
-			foreach($apps as $app => $val)
1742
+			foreach ($apps as $app => $val)
1745 1743
 			{
1746 1744
 				if (!$val) unset($apps[$app]);
1747 1745
 			}
@@ -1767,7 +1765,7 @@  discard block
 block discarded – undo
1767 1765
 	* @access protected
1768 1766
 	* @return void
1769 1767
 	*/
1770
-	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1768
+	abstract function _add_topmenu_item(array $app_data, $alt_label = null);
1771 1769
 
1772 1770
 	/**
1773 1771
 	* Add info items to the topmenu template class to be displayed
@@ -1777,7 +1775,7 @@  discard block
 block discarded – undo
1777 1775
 	* @access protected
1778 1776
 	* @return void
1779 1777
 	*/
1780
-	abstract function _add_topmenu_info_item($content, $id=null);
1778
+	abstract function _add_topmenu_info_item($content, $id = null);
1781 1779
 
1782 1780
 	static $top_menu_extra = array();
1783 1781
 
@@ -1792,7 +1790,7 @@  discard block
 block discarded – undo
1792 1790
 	* @access public
1793 1791
 	* @return void
1794 1792
 	*/
1795
-	public static function add_topmenu_item($id,$url,$title,$target = '')
1793
+	public static function add_topmenu_item($id, $url, $title, $target = '')
1796 1794
 	{
1797 1795
 		$entry['name'] = $id;
1798 1796
 		$entry['url'] = $url;
@@ -1813,7 +1811,7 @@  discard block
 block discarded – undo
1813 1811
 	* @access public
1814 1812
 	* @return void
1815 1813
 	*/
1816
-	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1814
+	abstract function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null);
1817 1815
 
1818 1816
 	/**
1819 1817
 	 * Call and return content of 'after_navbar' hook
@@ -1823,7 +1821,7 @@  discard block
 block discarded – undo
1823 1821
 	protected function _get_after_navbar()
1824 1822
 	{
1825 1823
 		ob_start();
1826
-		$GLOBALS['egw']->hooks->process('after_navbar',null,true);
1824
+		$GLOBALS['egw']->hooks->process('after_navbar', null, true);
1827 1825
 		$content = ob_get_contents();
1828 1826
 		ob_end_clean();
1829 1827
 
@@ -1857,7 +1855,7 @@  discard block
 block discarded – undo
1857 1855
 	 * @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
1858 1856
 	 * @return string content of onXXX tag after adding code
1859 1857
 	 */
1860
-	static function set_onload($code='',$replace=false)
1858
+	static function set_onload($code = '', $replace = false)
1861 1859
 	{
1862 1860
 		if ($replace || empty(self::$body_tags['onLoad']))
1863 1861
 		{
@@ -1878,7 +1876,7 @@  discard block
 block discarded – undo
1878 1876
 	 * @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
1879 1877
 	 * @return string content of onXXX tag after adding code
1880 1878
 	 */
1881
-	static function set_onunload($code='',$replace=false)
1879
+	static function set_onunload($code = '', $replace = false)
1882 1880
 	{
1883 1881
 		if ($replace || empty(self::$body_tags['onUnload']))
1884 1882
 		{
@@ -1899,7 +1897,7 @@  discard block
 block discarded – undo
1899 1897
 	 * @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
1900 1898
 	 * @return string content of onXXX tag after adding code
1901 1899
 	 */
1902
-	static function set_onbeforeunload($code='',$replace=false)
1900
+	static function set_onbeforeunload($code = '', $replace = false)
1903 1901
 	{
1904 1902
 		if ($replace || empty(self::$body_tags['onBeforeUnload']))
1905 1903
 		{
@@ -1920,7 +1918,7 @@  discard block
 block discarded – undo
1920 1918
 	 * @deprecated since 14.1 use app.js et2_ready method instead to execute code or bind a handler (CSP will stop onXXX attributes!)
1921 1919
 	 * @return string content of onXXX tag after adding code
1922 1920
 	 */
1923
-	static function set_onresize($code='',$replace=false)
1921
+	static function set_onresize($code = '', $replace = false)
1924 1922
 	{
1925 1923
 		if ($replace || empty(self::$body_tags['onResize']))
1926 1924
 		{
@@ -1942,16 +1940,16 @@  discard block
 block discarded – undo
1942 1940
 	static public function _get_body_attribs()
1943 1941
 	{
1944 1942
 		$js = '';
1945
-		foreach(self::$body_tags as $what => $data)
1943
+		foreach (self::$body_tags as $what => $data)
1946 1944
 		{
1947 1945
 			if (!empty($data))
1948 1946
 			{
1949
-				if($what == 'onLoad')
1947
+				if ($what == 'onLoad')
1950 1948
 				{
1951
-					$js .= 'onLoad="egw_LAB.wait(function() {'. htmlspecialchars($data).'})"';
1949
+					$js .= 'onLoad="egw_LAB.wait(function() {'.htmlspecialchars($data).'})"';
1952 1950
 					continue;
1953 1951
 				}
1954
-				$js .= ' '.$what.'="' . htmlspecialchars($data) . '"';
1952
+				$js .= ' '.$what.'="'.htmlspecialchars($data).'"';
1955 1953
 			}
1956 1954
 		}
1957 1955
 		return $js;
@@ -1981,7 +1979,7 @@  discard block
 block discarded – undo
1981 1979
 	*
1982 1980
 	* @returns bool was the file found?
1983 1981
 	*/
1984
-	static function validate_file($package, $file=null, $app='phpgwapi')
1982
+	static function validate_file($package, $file = null, $app = 'phpgwapi')
1985 1983
 	{
1986 1984
 		self::$js_include_mgr->include_js_file($package, $file, $app);
1987 1985
 	}
@@ -1993,7 +1991,7 @@  discard block
 block discarded – undo
1993 1991
 	 * @param boolean $clear_files =false true clear files after returning them
1994 1992
 	 * @return array with pathes relative to EGW_SERVER_ROOT
1995 1993
 	 */
1996
-	static function js_files(array $files=null, $clear_files=false)
1994
+	static function js_files(array $files = null, $clear_files = false)
1997 1995
 	{
1998 1996
 		if (isset($files) && is_array($files))
1999 1997
 		{
@@ -2012,7 +2010,7 @@  discard block
 block discarded – undo
2012 2010
 	 * @param boolean $clear_files =false true clear files after returning them
2013 2011
 	 * @return string|array see $return_pathes parameter
2014 2012
 	 */
2015
-	static public function get_script_links($return_pathes=false, $clear_files=false)
2013
+	static public function get_script_links($return_pathes = false, $clear_files = false)
2016 2014
 	{
2017 2015
 		$to_include = self::bundle_js_includes(self::$js_include_mgr->get_included_files($clear_files));
2018 2016
 
@@ -2020,7 +2018,7 @@  discard block
 block discarded – undo
2020 2018
 		{
2021 2019
 			return $to_include;
2022 2020
 		}
2023
-		$start = '<script type="text/javascript" src="'. $GLOBALS['egw_info']['server']['webserver_url'];
2021
+		$start = '<script type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'];
2024 2022
 		$end = '">'."</script>\n";
2025 2023
 		return "\n".$start.implode($end.$start, $to_include).$end;
2026 2024
 	}
@@ -2041,14 +2039,14 @@  discard block
 block discarded – undo
2041 2039
 			$bundles = egw_cache::getTree(__CLASS__, 'bundles', array(__CLASS__, 'get_bundles'), array(), 7200);
2042 2040
 			$bundles_ts = $bundles['.ts'];
2043 2041
 			unset($bundles['.ts']);
2044
-			foreach($bundles as $name => $files)
2042
+			foreach ($bundles as $name => $files)
2045 2043
 			{
2046 2044
 				$file2bundle += array_combine($files, array_fill(0, count($files), $name));
2047 2045
 			}
2048 2046
 		}
2049 2047
 		$to_include = $included_bundles = array();
2050 2048
 		$query = null;
2051
-		foreach($js_includes as $file)
2049
+		foreach ($js_includes as $file)
2052 2050
 		{
2053 2051
 			if (!isset($to_include[$file]))
2054 2052
 			{
@@ -2093,31 +2091,31 @@  discard block
 block discarded – undo
2093 2091
 	 * @param int& $max_modified =null on return maximum modification time of bundle
2094 2092
 	 * @return array js-files (can be more then one, if one of given files can not be bundeled)
2095 2093
 	 */
2096
-	protected static function bundle_urls(array $js_includes, &$max_modified=null)
2094
+	protected static function bundle_urls(array $js_includes, &$max_modified = null)
2097 2095
 	{
2098 2096
 		$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
2099 2097
 		$to_include = $to_minify = array();
2100 2098
 		$max_modified = 0;
2101 2099
 		$query = null;
2102
-		foreach($js_includes as $path)
2100
+		foreach ($js_includes as $path)
2103 2101
 		{
2104
-			if ($path == '/phpgwapi/js/jsapi/egw.js') continue;	// loaded via own tag, and we must not load it twice!
2102
+			if ($path == '/phpgwapi/js/jsapi/egw.js') continue; // loaded via own tag, and we must not load it twice!
2105 2103
 
2106 2104
 			unset($query);
2107
-			list($path,$query) = explode('?',$path,2);
2105
+			list($path, $query) = explode('?', $path, 2);
2108 2106
 			$mod = filemtime(EGW_SERVER_ROOT.$path);
2109 2107
 
2110 2108
 			// for now minify does NOT support query parameters, nor php files generating javascript
2111
-			if ($debug_minify || $query || substr($path, -3) != '.js' || strpos($path,'ckeditor') !== false ||
2109
+			if ($debug_minify || $query || substr($path, -3) != '.js' || strpos($path, 'ckeditor') !== false ||
2112 2110
 				substr($path, -7) == '/app.js')	// do NOT include app.js, as it changes from app to app
2113 2111
 			{
2114
-				$path .= '?'. $mod.($query ? '&'.$query : '');
2112
+				$path .= '?'.$mod.($query ? '&'.$query : '');
2115 2113
 				$to_include[] = $path;
2116 2114
 			}
2117 2115
 			else
2118 2116
 			{
2119 2117
 				if ($mod > $max_modified) $max_modified = $mod;
2120
-				$to_minify[] = substr($path,1);
2118
+				$to_minify[] = substr($path, 1);
2121 2119
 			}
2122 2120
 		}
2123 2121
 		if (!$debug_minify && $to_minify)
@@ -2125,7 +2123,7 @@  discard block
 block discarded – undo
2125 2123
 			$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
2126 2124
 			if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
2127 2125
 			$path = '/phpgwapi/inc/min/?'.($base_path && $base_path != '/' ? 'b='.substr($base_path, 1).'&' : '').
2128
-				'f='.implode(',', $to_minify) .
2126
+				'f='.implode(',', $to_minify).
2129 2127
 				($GLOBALS['egw_info']['server']['debug_minify'] === 'debug' ? '&debug' : '').
2130 2128
 				'&'.$max_modified;
2131 2129
 			// need to include minified javascript before not minified stuff like jscalendar-setup, as it might depend on it
@@ -2202,12 +2200,12 @@  discard block
 block discarded – undo
2202 2200
 		}*/
2203 2201
 
2204 2202
 		// automatic split bundles with more then MAX_BUNDLE_FILES (=50) files
2205
-		foreach($bundles as $name => $files)
2203
+		foreach ($bundles as $name => $files)
2206 2204
 		{
2207 2205
 			$n = '';
2208
-			while (count($files) > self::MAX_BUNDLE_FILES*(int)$n)
2206
+			while (count($files) > self::MAX_BUNDLE_FILES * (int)$n)
2209 2207
 			{
2210
-				$files80 = array_slice($files, self::MAX_BUNDLE_FILES*(int)$n, self::MAX_BUNDLE_FILES, true);
2208
+				$files80 = array_slice($files, self::MAX_BUNDLE_FILES * (int)$n, self::MAX_BUNDLE_FILES, true);
2211 2209
 				$bundles[$name.$n++] = $files80;
2212 2210
 			}
2213 2211
 		}
@@ -2241,7 +2239,7 @@  discard block
 block discarded – undo
2241 2239
 	 * @param boolean $no_default_css =false true do NOT load any default css, only what app explicitly includes
2242 2240
 	 * @return boolean false: css file not found, true: file found
2243 2241
 	 */
2244
-	public static function includeCSS($app, $name=null, $append=true, $no_default_css=false)
2242
+	public static function includeCSS($app, $name = null, $append = true, $no_default_css = false)
2245 2243
 	{
2246 2244
 		if ($no_default_css)
2247 2245
 		{
@@ -2261,12 +2259,12 @@  discard block
 block discarded – undo
2261 2259
 		{
2262 2260
 			$path = $app;
2263 2261
 		}
2264
-		if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT . parse_url($path,PHP_URL_PATH)))
2262
+		if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT.parse_url($path, PHP_URL_PATH)))
2265 2263
 		{
2266 2264
 			//error_log(__METHOD__."($app,$name) $path NOT found!");
2267 2265
 			return false;
2268 2266
 		}
2269
-		if (!in_array($path,self::$css_include_files))
2267
+		if (!in_array($path, self::$css_include_files))
2270 2268
 		{
2271 2269
 			if ($append)
2272 2270
 			{
@@ -2290,15 +2288,15 @@  discard block
 block discarded – undo
2290 2288
 
2291 2289
 		// try to add app specific css file
2292 2290
 		self::includeCSS($app, 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
2293
-			self::includeCSS($app,'app');
2291
+			self::includeCSS($app, 'app');
2294 2292
 
2295 2293
 		// add all css files from egw_framework::includeCSS()
2296 2294
 		$query = null;
2297
-		foreach(self::$css_include_files as $path)
2295
+		foreach (self::$css_include_files as $path)
2298 2296
 		{
2299 2297
 			unset($query);
2300
-			list($path,$query) = explode('?',$path,2);
2301
-			$path .= '?'. ($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
2298
+			list($path, $query) = explode('?', $path, 2);
2299
+			$path .= '?'.($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
2302 2300
 			$response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path);
2303 2301
 		}
2304 2302
 
@@ -2307,7 +2305,7 @@  discard block
 block discarded – undo
2307 2305
 
2308 2306
 		// add all js files from egw_framework::validate_file()
2309 2307
 		$files = self::bundle_js_includes(self::$js_include_mgr->get_included_files());
2310
-		foreach($files as $path)
2308
+		foreach ($files as $path)
2311 2309
 		{
2312 2310
 			$response->includeScript($GLOBALS['egw_info']['server']['webserver_url'].$path);
2313 2311
 		}
@@ -2367,7 +2365,7 @@  discard block
 block discarded – undo
2367 2365
 	 * @deprecated use egw_favorites::favorite_list
2368 2366
 	 * @return array with a single sidebox menu item (array) containing html for favorites
2369 2367
 	 */
2370
-	public static function favorite_list($app, $default=null)
2368
+	public static function favorite_list($app, $default = null)
2371 2369
 	{
2372 2370
 		return egw_favorites::list_favorites($app, $default);
2373 2371
 	}
@@ -2396,17 +2394,17 @@  discard block
 block discarded – undo
2396 2394
 	 */
2397 2395
 	public static function ajax_user_list()
2398 2396
 	{
2399
-		$list = array('accounts' => array(),'groups' => array(), 'owngroups' => array());
2400
-		if($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
2397
+		$list = array('accounts' => array(), 'groups' => array(), 'owngroups' => array());
2398
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
2401 2399
 		{
2402 2400
 			$list['accounts']['filter']['group'] = $GLOBALS['egw_info']['user']['account_primary_group'];
2403 2401
 		}
2404
-		foreach($list as $type => &$accounts)
2402
+		foreach ($list as $type => &$accounts)
2405 2403
 		{
2406 2404
 			$options = array('account_type' => $type) + $accounts;
2407
-			$key_pair = accounts::link_query('',$options);
2405
+			$key_pair = accounts::link_query('', $options);
2408 2406
 			$accounts = array();
2409
-			foreach($key_pair as $account_id => $name)
2407
+			foreach ($key_pair as $account_id => $name)
2410 2408
 			{
2411 2409
 				$accounts[] = array('value' => $account_id, 'label' => $name);
2412 2410
 			}
@@ -2443,9 +2441,9 @@  discard block
 block discarded – undo
2443 2441
 	 *
2444 2442
 	 * @deprecated use $GLOBALS['egw']->framework->sidebox()
2445 2443
 	 */
2446
-	function display_sidebox($appname,$menu_title,$_file)
2444
+	function display_sidebox($appname, $menu_title, $_file)
2447 2445
 	{
2448 2446
 		$file = str_replace('preferences.uisettings.index', 'preferences.preferences_settings.index', $_file);
2449
-		$GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file);
2447
+		$GLOBALS['egw']->framework->sidebox($appname, $menu_title, $file);
2450 2448
 	}
2451 2449
  }
Please login to merge, or discard this patch.
Braces   +107 added lines, -28 removed lines patch added patch discarded remove patch
@@ -96,12 +96,18 @@  discard block
 block discarded – undo
96 96
 			$GLOBALS['egw_info']['server']['template_set'] = 'pixelegg';
97 97
 		}
98 98
 		// default to idots, if no template_set set, to eg. not stall installations if settings use egw::link
99
-		if (empty($GLOBALS['egw_info']['server']['template_set'])) $GLOBALS['egw_info']['server']['template_set'] = 'idots';
99
+		if (empty($GLOBALS['egw_info']['server']['template_set']))
100
+		{
101
+			$GLOBALS['egw_info']['server']['template_set'] = 'idots';
102
+		}
100 103
 		// setup the new eGW framework (template sets)
101 104
 		$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
102
-		if (!class_exists($class))	// first try to autoload the class
105
+		if (!class_exists($class))
106
+		{
107
+			// first try to autoload the class
103 108
 		{
104 109
 			require_once($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
110
+		}
105 111
 			if (!in_array($file,(array)$_SESSION['egw_required_files']))
106 112
 			{
107 113
 				$_SESSION['egw_required_files'][] = $file;	// automatic load the used framework class, when the object get's restored
@@ -243,13 +249,19 @@  discard block
 block discarded – undo
243 249
 			{
244 250
 				foreach($app_additional as $addtional)
245 251
 				{
246
-					if ($addtional) $frame_src = array_unique(array_merge($frame_src, $addtional));
252
+					if ($addtional)
253
+					{
254
+						$frame_src = array_unique(array_merge($frame_src, $addtional));
255
+					}
247 256
 				}
248 257
 			}
249 258
 			return self::csp_frame_src_attrs($frame_src);
250 259
 		}
251 260
 
252
-		if (!isset(self::$csp_frame_src_attrs)) self::$csp_frame_src_attrs = array();
261
+		if (!isset(self::$csp_frame_src_attrs))
262
+		{
263
+			self::$csp_frame_src_attrs = array();
264
+		}
253 265
 
254 266
 		foreach((array)$set as $attr)
255 267
 		{
@@ -359,8 +371,14 @@  discard block
 block discarded – undo
359 371
 	 */
360 372
 	function render($content,$app_header=null,$navbar=null)
361 373
 	{
362
-		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
363
-		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
374
+		if (!is_null($app_header))
375
+		{
376
+			$GLOBALS['egw_info']['flags']['app_header'] = $app_header;
377
+		}
378
+		if (!is_null($navbar))
379
+		{
380
+			$GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
381
+		}
364 382
 
365 383
 		echo $this->header();
366 384
 
@@ -516,9 +534,12 @@  discard block
 block discarded – undo
516 534
 	{
517 535
 		// adding links of refreshed entry, to give others apps more information about necessity to refresh
518 536
 		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 &&	// do not run twice
519
-			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))	// app/id given
537
+			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))
538
+		{
539
+			// app/id given
520 540
 		{
521 541
 			$links = egw_link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]);
542
+		}
522 543
 			$apps = array();
523 544
 			foreach($links as $link)
524 545
 			{
@@ -894,7 +915,10 @@  discard block
 block discarded – undo
894 915
 		// send appheader to clientside
895 916
 		$extra['app-header'] = $app_header;
896 917
 
897
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
918
+		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki')
919
+		{
920
+			$robots ='<meta name="robots" content="none" />';
921
+		}
898 922
 		if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
899 923
 		{
900 924
 			$var['favicon_file'] = $GLOBALS['egw_info']['server']['favicon_file'];
@@ -1068,7 +1092,10 @@  discard block
 block discarded – undo
1068 1092
 			if (($remote = file_get_contents(egw_framework::CURRENT_VERSION_URL, false, egw_framework::proxy_context())))
1069 1093
 			{
1070 1094
 				list($current, $security) = explode("\n", $remote);
1071
-				if (empty($security)) $security = $current;
1095
+				if (empty($security))
1096
+				{
1097
+					$security = $current;
1098
+				}
1072 1099
 				$versions = array(
1073 1100
 					'current'  => $current,		// last maintenance update
1074 1101
 					'security' => $security,	// last security update
@@ -1157,7 +1184,10 @@  discard block
 block discarded – undo
1157 1184
 	protected static function update_older($version, $days)
1158 1185
 	{
1159 1186
 		list(,,$date) = explode('.', $version);
1160
-		if ($date < 20140000) return false;
1187
+		if ($date < 20140000)
1188
+		{
1189
+			return false;
1190
+		}
1161 1191
 		$version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4));
1162 1192
 
1163 1193
 		return (time() - $version_timestamp) / 86400 > $days;
@@ -1230,13 +1260,19 @@  discard block
 block discarded – undo
1230 1260
 		$ind_b = isset($arr[$b['name']]) ? $arr[$b['name']] : null;
1231 1261
 
1232 1262
 		if ($ind_a == $ind_b)
1233
-			return 0;
1263
+		{
1264
+					return 0;
1265
+		}
1234 1266
 
1235 1267
 		if ($ind_a == null)
1236
-			return -1;
1268
+		{
1269
+					return -1;
1270
+		}
1237 1271
 
1238 1272
 		if ($ind_b == null)
1239
-			return 1;
1273
+		{
1274
+					return 1;
1275
+		}
1240 1276
 
1241 1277
 		return $ind_a > $ind_b ? 1 : -1;
1242 1278
 	}
@@ -1334,9 +1370,12 @@  discard block
 block discarded – undo
1334 1370
 			$app_title = $GLOBALS['egw_info']['apps'][$app]['title'];
1335 1371
 		}
1336 1372
 
1337
-		if ($GLOBALS['egw_info']['user']['apps']['preferences'])	// preferences last
1373
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
1374
+		{
1375
+			// preferences last
1338 1376
 		{
1339 1377
 			$prefs = $apps['preferences'];
1378
+		}
1340 1379
 			unset($apps['preferences']);
1341 1380
 			$apps['preferences'] = $prefs;
1342 1381
 		}
@@ -1396,12 +1435,18 @@  discard block
 block discarded – undo
1396 1435
 
1397 1436
 			// For mobile user-agent we prefer mobile theme over selected one with a final fallback to theme named as template
1398 1437
 			$themes_to_check = array();
1399
-			if (html::$ua_mobile) $themes_to_check[] = $this->template_dir.'/css/mobile.css';
1438
+			if (html::$ua_mobile)
1439
+			{
1440
+				$themes_to_check[] = $this->template_dir.'/css/mobile.css';
1441
+			}
1400 1442
 			$themes_to_check[] = $this->template_dir.'/css/'.$GLOBALS['egw_info']['user']['preferences']['common']['theme'].'.css';
1401 1443
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
1402 1444
 			foreach($themes_to_check as $theme_css)
1403 1445
 			{
1404
-				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
1446
+				if (file_exists(EGW_SERVER_ROOT.$theme_css))
1447
+				{
1448
+					break;
1449
+				}
1405 1450
 			}
1406 1451
 			self::includeCSS($theme_css);
1407 1452
 
@@ -1421,14 +1466,20 @@  discard block
 block discarded – undo
1421 1466
 		$max_modified = 0;
1422 1467
 		$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
1423 1468
 		$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
1424
-		if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
1469
+		if ($base_path[0] != '/')
1470
+		{
1471
+			$base_path = parse_url($base_path, PHP_URL_PATH);
1472
+		}
1425 1473
 		$css_files = '';
1426 1474
 		foreach(self::$css_include_files as $path)
1427 1475
 		{
1428 1476
 			foreach(self::resolve_css_includes($path) as $path)
1429 1477
 			{
1430 1478
 				list($file,$query) = explode('?',$path,2);
1431
-				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod;
1479
+				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified)
1480
+				{
1481
+					$max_modified = $mod;
1482
+				}
1432 1483
 
1433 1484
 				// do NOT include app.css or categories.php, as it changes from app to app
1434 1485
 				if ($debug_minify || substr($path, -8) == '/app.css' || substr($file,-14) == 'categories.php')
@@ -1444,7 +1495,10 @@  discard block
 block discarded – undo
1444 1495
 		if (!$debug_minify)
1445 1496
 		{
1446 1497
 			$css = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/inc/min/?';
1447
-			if ($base_path && $base_path != '/') $css .= 'b='.substr($base_path, 1).'&';
1498
+			if ($base_path && $base_path != '/')
1499
+			{
1500
+				$css .= 'b='.substr($base_path, 1).'&';
1501
+			}
1448 1502
 			$css .= 'f='.$css_file .
1449 1503
 				($GLOBALS['egw_info']['server']['debug_minify'] === 'debug' ? '&debug' : '').
1450 1504
 				'&'.$max_modified;
@@ -1532,7 +1586,9 @@  discard block
 block discarded – undo
1532 1586
 		}
1533 1587
 
1534 1588
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
1535
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
1589
+		$extra['include'] = array_map(function($str)
1590
+		{
1591
+return substr($str,1);}, self::get_script_links(true), array(1));
1536 1592
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
1537 1593
 
1538 1594
 		// Load LABjs ONCE here
@@ -1544,7 +1600,10 @@  discard block
 block discarded – undo
1544 1600
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
1545 1601
 		foreach($extra+self::$extra as $name => $value)
1546 1602
 		{
1547
-			if (is_array($value)) $value = json_encode($value);
1603
+			if (is_array($value))
1604
+			{
1605
+				$value = json_encode($value);
1606
+			}
1548 1607
 			// we need to double encode (html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
1549 1608
 			$java_script .= ' data-'.$name."=\"". html::htmlspecialchars($value, true)."\"";
1550 1609
 		}
@@ -1690,7 +1749,8 @@  discard block
 block discarded – undo
1690 1749
 
1691 1750
 		$GLOBALS['egw']->hooks->process('topmenu_info',array(),true);
1692 1751
 		// Add extra items added by hooks
1693
-		foreach(self::$top_menu_extra as $extra_item) {
1752
+		foreach(self::$top_menu_extra as $extra_item)
1753
+		{
1694 1754
 			$this->_add_topmenu_item($extra_item);
1695 1755
 		}
1696 1756
 
@@ -1715,7 +1775,10 @@  discard block
 block discarded – undo
1715 1775
 	protected function add_preferences_topmenu($type='prefs')
1716 1776
 	{
1717 1777
 		static $memberships=null;
1718
-		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1778
+		if (!isset($memberships))
1779
+		{
1780
+			$memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1781
+		}
1719 1782
 		static $types = array(
1720 1783
 			'prefs' => array(
1721 1784
 				'title' => 'Preferences',
@@ -1743,7 +1806,10 @@  discard block
 block discarded – undo
1743 1806
 			// as all apps answer, we need to remove none-true responses
1744 1807
 			foreach($apps as $app => $val)
1745 1808
 			{
1746
-				if (!$val) unset($apps[$app]);
1809
+				if (!$val)
1810
+				{
1811
+					unset($apps[$app]);
1812
+				}
1747 1813
 			}
1748 1814
 		}
1749 1815
 		else
@@ -2101,7 +2167,11 @@  discard block
 block discarded – undo
2101 2167
 		$query = null;
2102 2168
 		foreach($js_includes as $path)
2103 2169
 		{
2104
-			if ($path == '/phpgwapi/js/jsapi/egw.js') continue;	// loaded via own tag, and we must not load it twice!
2170
+			if ($path == '/phpgwapi/js/jsapi/egw.js')
2171
+			{
2172
+				continue;
2173
+			}
2174
+			// loaded via own tag, and we must not load it twice!
2105 2175
 
2106 2176
 			unset($query);
2107 2177
 			list($path,$query) = explode('?',$path,2);
@@ -2109,21 +2179,30 @@  discard block
 block discarded – undo
2109 2179
 
2110 2180
 			// for now minify does NOT support query parameters, nor php files generating javascript
2111 2181
 			if ($debug_minify || $query || substr($path, -3) != '.js' || strpos($path,'ckeditor') !== false ||
2112
-				substr($path, -7) == '/app.js')	// do NOT include app.js, as it changes from app to app
2182
+				substr($path, -7) == '/app.js')
2183
+			{
2184
+				// do NOT include app.js, as it changes from app to app
2113 2185
 			{
2114 2186
 				$path .= '?'. $mod.($query ? '&'.$query : '');
2187
+			}
2115 2188
 				$to_include[] = $path;
2116 2189
 			}
2117 2190
 			else
2118 2191
 			{
2119
-				if ($mod > $max_modified) $max_modified = $mod;
2192
+				if ($mod > $max_modified)
2193
+				{
2194
+					$max_modified = $mod;
2195
+				}
2120 2196
 				$to_minify[] = substr($path,1);
2121 2197
 			}
2122 2198
 		}
2123 2199
 		if (!$debug_minify && $to_minify)
2124 2200
 		{
2125 2201
 			$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
2126
-			if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
2202
+			if ($base_path[0] != '/')
2203
+			{
2204
+				$base_path = parse_url($base_path, PHP_URL_PATH);
2205
+			}
2127 2206
 			$path = '/phpgwapi/inc/min/?'.($base_path && $base_path != '/' ? 'b='.substr($base_path, 1).'&' : '').
2128 2207
 				'f='.implode(',', $to_minify) .
2129 2208
 				($GLOBALS['egw_info']['server']['debug_minify'] === 'debug' ? '&debug' : '').
Please login to merge, or discard this patch.
Upper-Lower-Casing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	 */
789 789
 	public function _get_footer()
790 790
 	{
791
-		$var = Array(
791
+		$var = array(
792 792
 			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
793 793
 			'version'        => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
794 794
 		);
@@ -1304,13 +1304,13 @@  discard block
 block discarded – undo
1304 1304
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
1305 1305
 				if ($app != $GLOBALS['egw_info']['flags']['currentapp'])
1306 1306
 				{
1307
-					$apps[$app]['icon']  = common::image($icon_app,Array($icon,'nonav'),'',$svg);
1308
-					$apps[$app]['icon_hover']  = common::image_on($icon_app,Array($icon,'nonav'),'-over',$svg);
1307
+					$apps[$app]['icon']  = common::image($icon_app,array($icon,'nonav'),'',$svg);
1308
+					$apps[$app]['icon_hover']  = common::image_on($icon_app,array($icon,'nonav'),'-over',$svg);
1309 1309
 				}
1310 1310
 				else
1311 1311
 				{
1312
-					$apps[$app]['icon']  = common::image_on($icon_app,Array($icon,'nonav'),'-over',$svg);
1313
-					$apps[$app]['icon_hover']  = common::image($icon_app,Array($icon,'nonav'),'',$svg);
1312
+					$apps[$app]['icon']  = common::image_on($icon_app,array($icon,'nonav'),'-over',$svg);
1313
+					$apps[$app]['icon_hover']  = common::image($icon_app,array($icon,'nonav'),'',$svg);
1314 1314
 				}
1315 1315
 			}
1316 1316
 		}
@@ -1345,15 +1345,15 @@  discard block
 block discarded – undo
1345 1345
 		$apps['about']['title'] = 'EGroupware';
1346 1346
 
1347 1347
 		$apps['about']['url']   = egw::link('/about.php');
1348
-		$apps['about']['icon']  = common::image('phpgwapi',Array('about','nonav'));
1349
-		$apps['about']['icon_hover']  = common::image_on('phpgwapi',Array('about','nonav'),'-over');
1348
+		$apps['about']['icon']  = common::image('phpgwapi',array('about','nonav'));
1349
+		$apps['about']['icon_hover']  = common::image_on('phpgwapi',array('about','nonav'),'-over');
1350 1350
 		$apps['about']['name'] = 'about';
1351 1351
 
1352 1352
 		$apps['logout']['title'] = lang('Logout');
1353 1353
 		$apps['logout']['name'] = 'logout';
1354 1354
 		$apps['logout']['url']   = egw::link('/logout.php');
1355
-		$apps['logout']['icon']  = common::image('phpgwapi',Array('logout','nonav'));
1356
-		$apps['logout']['icon_hover']  = common::image_on('phpgwapi',Array('logout','nonav'),'-over');
1355
+		$apps['logout']['icon']  = common::image('phpgwapi',array('logout','nonav'));
1356
+		$apps['logout']['icon_hover']  = common::image_on('phpgwapi',array('logout','nonav'),'-over');
1357 1357
 
1358 1358
 		return $apps;
1359 1359
 	}
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_htmLawed.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
 	 * @param varchar $html2check =text input Text to check
105 105
 	 * @param mixed $Config = text or array
106 106
 	 * @param mixed $Spec =text or array; The '$spec' argument can be used to disallow an otherwise legal attribute for an element
107
-	 * @return varchar cleaned/fixed html
107
+	 * @return string cleaned/fixed html
108 108
 	 */
109 109
 	function run($html2check, $Config=null, $Spec=array())
110 110
 	{
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 		*/
82 82
 
83 83
 		$this->Configuration = array('comment'=>1, //remove comments
84
-			'make_tag_strict'=>3,//3 is a new own config value, to indicate that transformation is to be performed, but don't transform font, as size transformation of numeric sizes to keywords alters the intended result too much
85
-			'balance'=>0,//turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering)
84
+			'make_tag_strict'=>3, //3 is a new own config value, to indicate that transformation is to be performed, but don't transform font, as size transformation of numeric sizes to keywords alters the intended result too much
85
+			'balance'=>0, //turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering)
86 86
 			// tidy eats away even some wanted whitespace, so we switch it off;
87 87
 			// we used it for its compacting and beautifying capabilities, which resulted in better html for further processing
88 88
 			'tidy'=>0,
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param mixed $Spec =text or array; The '$spec' argument can be used to disallow an otherwise legal attribute for an element
103 103
 	 * @return varchar cleaned/fixed html
104 104
 	 */
105
-	function egw_htmLawed($html2check, $Config=null, $Spec=array())
105
+	function egw_htmLawed($html2check, $Config = null, $Spec = array())
106 106
 	{
107 107
 		//error_log(__METHOD__.__LINE__.' Input:'.$html2check);
108 108
 		if (is_array($Config) && is_array($this->Configuration)) $Config = array_merge($this->Configuration, $Config);
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 		// If we are processing mails, we take out stuff in <style> stuff </style> tags and
112 112
 		// put it back in after purifying; styles are processed for known security risks
113 113
 		// in html::getStyles
114
-		$styles='';
114
+		$styles = '';
115 115
 		// we allow filtered style sections now throughout egroupware
116 116
 		/*if ($Config['hook_tag'] =="hl_email_tag_transform")*/ $styles = html::getStyles($html2check);
117 117
 		//error_log(__METHOD__.__LINE__.array2string($styles));
118 118
 
119
-		return ($styles?$styles:'').htmLawed($html2check, $Config, $Spec);
119
+		return ($styles ? $styles : '').htmLawed($html2check, $Config, $Spec);
120 120
 	}
121 121
 }
122 122
 
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
  * 						a checking for title, replacing @
129 129
  * 						blockquote checking for cite, replacing @
130 130
  */
131
-function hl_my_tag_transform($element, $attribute_array=0)
131
+function hl_my_tag_transform($element, $attribute_array = 0)
132 132
 {
133 133
 	// If second argument is not received, it means a closing tag is being handled
134
-	if(is_numeric($attribute_array)){
134
+	if (is_numeric($attribute_array)) {
135 135
 		return "</$element>";
136 136
 	}
137 137
 
138 138
 	//if ($element=='img') error_log(__METHOD__.__LINE__." ".$element.'->'.array2string($attribute_array));
139
-	if ($element=='td' && isset($attribute_array['background']))
139
+	if ($element == 'td' && isset($attribute_array['background']))
140 140
 	{
141
-		if (is_object($GLOBALS['egw']) && stripos($attribute_array['background'],$GLOBALS['egw']->link('/index.php'))!==false)
141
+		if (is_object($GLOBALS['egw']) && stripos($attribute_array['background'], $GLOBALS['egw']->link('/index.php')) !== false)
142 142
 		{
143 143
 			//error_log(__METHOD__.__LINE__.array2string($attribute_array));
144 144
 			//$attribute_array['background'] = 'url('.$attribute_array['background'].');';
@@ -146,25 +146,25 @@  discard block
 block discarded – undo
146 146
 		else
147 147
 		{
148 148
 			// $attribute_array['background']='denied:'.$attribute_array['background'];
149
-			unset($attribute_array['background']);// only internal background images are allowed
149
+			unset($attribute_array['background']); // only internal background images are allowed
150 150
 		}
151 151
 	}
152 152
 	// Elements other than 'img' or 'img' without a 'img' attribute are returned unchanged
153
-	if($element == 'img')
153
+	if ($element == 'img')
154 154
 	{
155 155
 		// Re-build 'alt'
156
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
157
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
156
+		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt'] == 'image' ? '' : $attribute_array['alt']);
157
+		if (isset($attribute_array['alt']) && strpos($attribute_array['alt'], '@') !== false) $attribute_array['alt'] = str_replace('@', '(at)', $attribute_array['alt']);
158 158
 	}
159 159
 	if (isset($attribute_array['title']))
160 160
 	{
161
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
161
+		if (strpos($attribute_array['title'], '@') !== false) $attribute_array['title'] = str_replace('@', '(at)', $attribute_array['title']);
162 162
 	}
163 163
 	if ($element == 'blockquote')
164 164
 	{
165 165
 		if (isset($attribute_array['cite']))
166 166
 		{
167
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
167
+			if (strpos($attribute_array['cite'], '@') !== false) $attribute_array['cite'] = str_replace('@', '(at)', $attribute_array['cite']);
168 168
 		}
169 169
 	}
170 170
 	/*
@@ -196,31 +196,31 @@  discard block
 block discarded – undo
196 196
 		$attribute_array['style'] = implode('; ', $style);
197 197
 	}
198 198
 	*/
199
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
200
-	if($element == 'a')
199
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'], 'script') !== false) $attribute_array['style'] = str_ireplace('script', '', $attribute_array['style']);
200
+	if ($element == 'a')
201 201
 	{
202 202
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
203 203
 		// rebuild Anchors, if processed by hl_email_tag_transform
204
-		if (strpos($attribute_array['href'],"denied:javascript:GoToAnchor('")===0)
204
+		if (strpos($attribute_array['href'], "denied:javascript:GoToAnchor('") === 0)
205 205
 		{
206
-			$attribute_array['href']=str_ireplace("');",'',str_ireplace("denied:javascript:GoToAnchor('","#",$attribute_array['href']));
206
+			$attribute_array['href'] = str_ireplace("');", '', str_ireplace("denied:javascript:GoToAnchor('", "#", $attribute_array['href']));
207 207
 		}
208
-		if (strpos($attribute_array['href'],"javascript:GoToAnchor('")===0)
208
+		if (strpos($attribute_array['href'], "javascript:GoToAnchor('") === 0)
209 209
 		{
210
-			$attribute_array['href']=str_ireplace("');",'',str_ireplace("javascript:GoToAnchor('","#",$attribute_array['href']));
210
+			$attribute_array['href'] = str_ireplace("');", '', str_ireplace("javascript:GoToAnchor('", "#", $attribute_array['href']));
211 211
 		}
212
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
212
+		if (strpos($attribute_array['href'], 'denied:javascript') === 0) $attribute_array['href'] = '';
213 213
 	}
214 214
 
215 215
 	// Build the attributes string
216 216
 	$attributes = '';
217
-	foreach($attribute_array as $k=>$v){
217
+	foreach ($attribute_array as $k=>$v) {
218 218
 		$attributes .= " {$k}=\"{$v}\"";
219 219
 	}
220 220
 
221 221
 	// Return the opening tag with attributes
222 222
 	static $empty_elements = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1);
223
-	return "<{$element}{$attributes}". (isset($empty_elements[$element]) ? ' /' : ''). '>';
223
+	return "<{$element}{$attributes}".(isset($empty_elements[$element]) ? ' /' : '').'>';
224 224
 }
225 225
 
226 226
 /**
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
  * 						blockquote -checking for cite, replacing @
235 235
  * 						throwing away excess div elements, that carry no style or class or id info
236 236
  */
237
-function hl_email_tag_transform($element, $attribute_array=0)
237
+function hl_email_tag_transform($element, $attribute_array = 0)
238 238
 {
239 239
 	//error_log(__METHOD__.__LINE__.$element.array2string($attribute_array));
240 240
 	static $lastelement;
241 241
 	static $throwawaycounter;
242
-	if (is_null($lastelement)) $lastelement='';
242
+	if (is_null($lastelement)) $lastelement = '';
243 243
 	if (is_null($throwawaycounter)) $throwawaycounter = 0;
244 244
 	//if ($throwawaycounter>1) error_log(__METHOD__.__LINE__.' '.$throwawaycounter.$element.array2string($attribute_array));
245
-	if ($element=='div' && $element==$lastelement && ($attribute_array==0 || empty($attribute_array)))
245
+	if ($element == 'div' && $element == $lastelement && ($attribute_array == 0 || empty($attribute_array)))
246 246
 	{
247 247
 		if (is_array($attribute_array)) $throwawaycounter++;
248
-		if ($attribute_array==0 && $throwawaycounter>0) $throwawaycounter--;
249
-		if ($throwawaycounter>1) return '';
248
+		if ($attribute_array == 0 && $throwawaycounter > 0) $throwawaycounter--;
249
+		if ($throwawaycounter > 1) return '';
250 250
 	}
251
-	if ($lastelement=='div' && $element!=$lastelement && is_array($attribute_array)) $throwawaycounter = 0;
252
-	if (is_array($attribute_array) && !empty($attribute_array) && $element=='div')
251
+	if ($lastelement == 'div' && $element != $lastelement && is_array($attribute_array)) $throwawaycounter = 0;
252
+	if (is_array($attribute_array) && !empty($attribute_array) && $element == 'div')
253 253
 	{
254 254
 		$lastelement = 'div_with_attr';
255 255
 	}
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 		if (is_array($attribute_array)) $lastelement = $element;
259 259
 	}
260 260
 	// If second argument is not received, it means a closing tag is being handled
261
-	if(is_numeric($attribute_array)){
262
-		if($element==$lastelement) $lastelement='';
261
+	if (is_numeric($attribute_array)) {
262
+		if ($element == $lastelement) $lastelement = '';
263 263
 		return "</$element>";
264 264
 	}
265 265
 
266 266
 	//if ($element=='a') error_log(__METHOD__.__LINE__." ".$element.'->'.array2string($attribute_array));
267
-	if ($element=='td' && isset($attribute_array['background']))
267
+	if ($element == 'td' && isset($attribute_array['background']))
268 268
 	{
269
-		if (stripos($attribute_array['background'],'cid:')!==false)
269
+		if (stripos($attribute_array['background'], 'cid:') !== false)
270 270
 		{
271 271
 			//error_log(__METHOD__.__LINE__.array2string($attribute_array));
272 272
 			//$attribute_array['background'] = 'url('.$attribute_array['background'].');';
@@ -274,73 +274,73 @@  discard block
 block discarded – undo
274 274
 		else
275 275
 		{
276 276
 			// $attribute_array['background']='denied:'.$attribute_array['background'];
277
-			unset($attribute_array['background']);// only cid style background images are allowed
277
+			unset($attribute_array['background']); // only cid style background images are allowed
278 278
 		}
279 279
 	}
280 280
 	// Elements other than 'img' or 'img' without a 'img' attribute are returned unchanged
281
-	if($element == 'img')
281
+	if ($element == 'img')
282 282
 	{
283 283
 		// Re-build 'alt'
284
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
285
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
284
+		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt'] == 'image' ? '' : $attribute_array['alt']);
285
+		if (isset($attribute_array['alt']) && strpos($attribute_array['alt'], '@') !== false) $attribute_array['alt'] = str_replace('@', '(at)', $attribute_array['alt']);
286 286
 		// $GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'] ? '' : 'match' => '/^cid:.*/'),
287 287
 		if (isset($attribute_array['src']))
288 288
 		{
289
-			if (!(strlen($attribute_array['src'])>4 && strlen($attribute_array['src']<400)))
289
+			if (!(strlen($attribute_array['src']) > 4 && strlen($attribute_array['src'] < 400)))
290 290
 			{
291
-					$attribute_array['alt']= $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']';
292
-					if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
293
-					$attribute_array['src']=common::image('phpgwapi','dialog_error');
291
+					$attribute_array['alt'] = $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']';
292
+					if (!isset($attribute_array['title'])) $attribute_array['title'] = $attribute_array['alt'];
293
+					$attribute_array['src'] = common::image('phpgwapi', 'dialog_error');
294 294
 			}
295 295
 			if (!$GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'])
296 296
 			{
297
-				if (!preg_match('/^cid:.*/',$attribute_array['src']))
297
+				if (!preg_match('/^cid:.*/', $attribute_array['src']))
298 298
 				{
299
-					$attribute_array['alt']= $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']';
300
-					if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
301
-					$attribute_array['src']=common::image('mail','no-image-shown');
299
+					$attribute_array['alt'] = $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']';
300
+					if (!isset($attribute_array['title'])) $attribute_array['title'] = $attribute_array['alt'];
301
+					$attribute_array['src'] = common::image('mail', 'no-image-shown');
302 302
 					$attribute_array['border'] = 1;
303 303
 					if ($attribute_array['style'])
304 304
 					{
305
-						if (stripos($attribute_array['style'],'border')!==false) $attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si','',$attribute_array['style']);
305
+						if (stripos($attribute_array['style'], 'border') !== false) $attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si', '', $attribute_array['style']);
306 306
 					}
307 307
 				}
308 308
 			}
309 309
 		}
310 310
 	}
311
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
311
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'], 'script') !== false) $attribute_array['style'] = str_ireplace('script', '', $attribute_array['style']);
312 312
 	if (isset($attribute_array['title']))
313 313
 	{
314
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
314
+		if (strpos($attribute_array['title'], '@') !== false) $attribute_array['title'] = str_replace('@', '(at)', $attribute_array['title']);
315 315
 	}
316 316
 	if ($element == 'blockquote')
317 317
 	{
318 318
 		if (isset($attribute_array['cite']))
319 319
 		{
320
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
320
+			if (strpos($attribute_array['cite'], '@') !== false) $attribute_array['cite'] = str_replace('@', '(at)', $attribute_array['cite']);
321 321
 		}
322 322
 	}
323
-	if($element == 'a')
323
+	if ($element == 'a')
324 324
 	{
325 325
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
326
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
326
+		if (strpos($attribute_array['href'], 'denied:javascript') === 0) $attribute_array['href'] = '';
327 327
 		if (isset($attribute_array['name']) && isset($attribute_array['id'])) $attribute_array['id'] = $attribute_array['name'];
328
-		if (strpos($attribute_array['href'],'@')!==false) $attribute_array['href'] = str_replace('@','%40',$attribute_array['href']);
329
-		if (strpos($attribute_array['href'],'#')===0 && (isset(emailadmin_imapbase::$htmLawed_config['transform_anchor']) && emailadmin_imapbase::$htmLawed_config['transform_anchor']===true))
328
+		if (strpos($attribute_array['href'], '@') !== false) $attribute_array['href'] = str_replace('@', '%40', $attribute_array['href']);
329
+		if (strpos($attribute_array['href'], '#') === 0 && (isset(emailadmin_imapbase::$htmLawed_config['transform_anchor']) && emailadmin_imapbase::$htmLawed_config['transform_anchor'] === true))
330 330
 		{
331
-			$attribute_array['href'] = "javascript:GoToAnchor('".trim(substr($attribute_array['href'],1))."');";
331
+			$attribute_array['href'] = "javascript:GoToAnchor('".trim(substr($attribute_array['href'], 1))."');";
332 332
 		}
333 333
 
334 334
 	}
335 335
 
336 336
 	// Build the attributes string
337 337
 	$attributes = '';
338
-	foreach($attribute_array as $k=>$v){
338
+	foreach ($attribute_array as $k=>$v) {
339 339
 		$attributes .= " {$k}=\"{$v}\"";
340 340
 	}
341 341
 
342 342
 	// Return the opening tag with attributes
343 343
 	static $empty_elements = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1);
344
-	return "<{$element}{$attributes}". (isset($empty_elements[$element]) ? ' /' : ''). '>';
344
+	return "<{$element}{$attributes}".(isset($empty_elements[$element]) ? ' /' : '').'>';
345 345
 }
346 346
 
Please login to merge, or discard this patch.
Braces   +120 added lines, -32 removed lines patch added patch discarded remove patch
@@ -105,9 +105,18 @@  discard block
 block discarded – undo
105 105
 	function egw_htmLawed($html2check, $Config=null, $Spec=array())
106 106
 	{
107 107
 		//error_log(__METHOD__.__LINE__.' Input:'.$html2check);
108
-		if (is_array($Config) && is_array($this->Configuration)) $Config = array_merge($this->Configuration, $Config);
109
-		if (empty($Config)) $Config = $this->Configuration;
110
-		if (empty($Spec)) $Spec = $this->Spec;
108
+		if (is_array($Config) && is_array($this->Configuration))
109
+		{
110
+			$Config = array_merge($this->Configuration, $Config);
111
+		}
112
+		if (empty($Config))
113
+		{
114
+			$Config = $this->Configuration;
115
+		}
116
+		if (empty($Spec))
117
+		{
118
+			$Spec = $this->Spec;
119
+		}
111 120
 		// If we are processing mails, we take out stuff in <style> stuff </style> tags and
112 121
 		// put it back in after purifying; styles are processed for known security risks
113 122
 		// in html::getStyles
@@ -131,7 +140,8 @@  discard block
 block discarded – undo
131 140
 function hl_my_tag_transform($element, $attribute_array=0)
132 141
 {
133 142
 	// If second argument is not received, it means a closing tag is being handled
134
-	if(is_numeric($attribute_array)){
143
+	if(is_numeric($attribute_array))
144
+	{
135 145
 		return "</$element>";
136 146
 	}
137 147
 
@@ -153,18 +163,30 @@  discard block
 block discarded – undo
153 163
 	if($element == 'img')
154 164
 	{
155 165
 		// Re-build 'alt'
156
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
157
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
166
+		if (isset($attribute_array['alt']))
167
+		{
168
+			$attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
169
+		}
170
+		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false)
171
+		{
172
+			$attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
173
+		}
158 174
 	}
159 175
 	if (isset($attribute_array['title']))
160 176
 	{
161
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
177
+		if (strpos($attribute_array['title'],'@')!==false)
178
+		{
179
+			$attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
180
+		}
162 181
 	}
163 182
 	if ($element == 'blockquote')
164 183
 	{
165 184
 		if (isset($attribute_array['cite']))
166 185
 		{
167
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
186
+			if (strpos($attribute_array['cite'],'@')!==false)
187
+			{
188
+				$attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
189
+			}
168 190
 		}
169 191
 	}
170 192
 	/*
@@ -196,7 +218,10 @@  discard block
 block discarded – undo
196 218
 		$attribute_array['style'] = implode('; ', $style);
197 219
 	}
198 220
 	*/
199
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
221
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false)
222
+	{
223
+		$attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
224
+	}
200 225
 	if($element == 'a')
201 226
 	{
202 227
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
@@ -209,12 +234,16 @@  discard block
 block discarded – undo
209 234
 		{
210 235
 			$attribute_array['href']=str_ireplace("');",'',str_ireplace("javascript:GoToAnchor('","#",$attribute_array['href']));
211 236
 		}
212
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
237
+		if (strpos($attribute_array['href'],'denied:javascript')===0)
238
+		{
239
+			$attribute_array['href']='';
240
+		}
213 241
 	}
214 242
 
215 243
 	// Build the attributes string
216 244
 	$attributes = '';
217
-	foreach($attribute_array as $k=>$v){
245
+	foreach($attribute_array as $k=>$v)
246
+	{
218 247
 		$attributes .= " {$k}=\"{$v}\"";
219 248
 	}
220 249
 
@@ -239,27 +268,52 @@  discard block
 block discarded – undo
239 268
 	//error_log(__METHOD__.__LINE__.$element.array2string($attribute_array));
240 269
 	static $lastelement;
241 270
 	static $throwawaycounter;
242
-	if (is_null($lastelement)) $lastelement='';
243
-	if (is_null($throwawaycounter)) $throwawaycounter = 0;
271
+	if (is_null($lastelement))
272
+	{
273
+		$lastelement='';
274
+	}
275
+	if (is_null($throwawaycounter))
276
+	{
277
+		$throwawaycounter = 0;
278
+	}
244 279
 	//if ($throwawaycounter>1) error_log(__METHOD__.__LINE__.' '.$throwawaycounter.$element.array2string($attribute_array));
245 280
 	if ($element=='div' && $element==$lastelement && ($attribute_array==0 || empty($attribute_array)))
246 281
 	{
247
-		if (is_array($attribute_array)) $throwawaycounter++;
248
-		if ($attribute_array==0 && $throwawaycounter>0) $throwawaycounter--;
249
-		if ($throwawaycounter>1) return '';
282
+		if (is_array($attribute_array))
283
+		{
284
+			$throwawaycounter++;
285
+		}
286
+		if ($attribute_array==0 && $throwawaycounter>0)
287
+		{
288
+			$throwawaycounter--;
289
+		}
290
+		if ($throwawaycounter>1)
291
+		{
292
+			return '';
293
+		}
294
+	}
295
+	if ($lastelement=='div' && $element!=$lastelement && is_array($attribute_array))
296
+	{
297
+		$throwawaycounter = 0;
250 298
 	}
251
-	if ($lastelement=='div' && $element!=$lastelement && is_array($attribute_array)) $throwawaycounter = 0;
252 299
 	if (is_array($attribute_array) && !empty($attribute_array) && $element=='div')
253 300
 	{
254 301
 		$lastelement = 'div_with_attr';
255 302
 	}
256 303
 	else
257 304
 	{
258
-		if (is_array($attribute_array)) $lastelement = $element;
305
+		if (is_array($attribute_array))
306
+		{
307
+			$lastelement = $element;
308
+		}
259 309
 	}
260 310
 	// If second argument is not received, it means a closing tag is being handled
261
-	if(is_numeric($attribute_array)){
262
-		if($element==$lastelement) $lastelement='';
311
+	if(is_numeric($attribute_array))
312
+	{
313
+		if($element==$lastelement)
314
+		{
315
+			$lastelement='';
316
+		}
263 317
 		return "</$element>";
264 318
 	}
265 319
 
@@ -281,15 +335,24 @@  discard block
 block discarded – undo
281 335
 	if($element == 'img')
282 336
 	{
283 337
 		// Re-build 'alt'
284
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
285
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
338
+		if (isset($attribute_array['alt']))
339
+		{
340
+			$attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
341
+		}
342
+		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false)
343
+		{
344
+			$attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
345
+		}
286 346
 		// $GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'] ? '' : 'match' => '/^cid:.*/'),
287 347
 		if (isset($attribute_array['src']))
288 348
 		{
289 349
 			if (!(strlen($attribute_array['src'])>4 && strlen($attribute_array['src']<400)))
290 350
 			{
291 351
 					$attribute_array['alt']= $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']';
292
-					if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
352
+					if (!isset($attribute_array['title']))
353
+					{
354
+						$attribute_array['title']=$attribute_array['alt'];
355
+					}
293 356
 					$attribute_array['src']=common::image('phpgwapi','dialog_error');
294 357
 			}
295 358
 			if (!$GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'])
@@ -297,35 +360,59 @@  discard block
 block discarded – undo
297 360
 				if (!preg_match('/^cid:.*/',$attribute_array['src']))
298 361
 				{
299 362
 					$attribute_array['alt']= $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']';
300
-					if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
363
+					if (!isset($attribute_array['title']))
364
+					{
365
+						$attribute_array['title']=$attribute_array['alt'];
366
+					}
301 367
 					$attribute_array['src']=common::image('mail','no-image-shown');
302 368
 					$attribute_array['border'] = 1;
303 369
 					if ($attribute_array['style'])
304 370
 					{
305
-						if (stripos($attribute_array['style'],'border')!==false) $attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si','',$attribute_array['style']);
371
+						if (stripos($attribute_array['style'],'border')!==false)
372
+						{
373
+							$attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si','',$attribute_array['style']);
374
+						}
306 375
 					}
307 376
 				}
308 377
 			}
309 378
 		}
310 379
 	}
311
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
380
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false)
381
+	{
382
+		$attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
383
+	}
312 384
 	if (isset($attribute_array['title']))
313 385
 	{
314
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
386
+		if (strpos($attribute_array['title'],'@')!==false)
387
+		{
388
+			$attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
389
+		}
315 390
 	}
316 391
 	if ($element == 'blockquote')
317 392
 	{
318 393
 		if (isset($attribute_array['cite']))
319 394
 		{
320
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
395
+			if (strpos($attribute_array['cite'],'@')!==false)
396
+			{
397
+				$attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
398
+			}
321 399
 		}
322 400
 	}
323 401
 	if($element == 'a')
324 402
 	{
325 403
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
326
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
327
-		if (isset($attribute_array['name']) && isset($attribute_array['id'])) $attribute_array['id'] = $attribute_array['name'];
328
-		if (strpos($attribute_array['href'],'@')!==false) $attribute_array['href'] = str_replace('@','%40',$attribute_array['href']);
404
+		if (strpos($attribute_array['href'],'denied:javascript')===0)
405
+		{
406
+			$attribute_array['href']='';
407
+		}
408
+		if (isset($attribute_array['name']) && isset($attribute_array['id']))
409
+		{
410
+			$attribute_array['id'] = $attribute_array['name'];
411
+		}
412
+		if (strpos($attribute_array['href'],'@')!==false)
413
+		{
414
+			$attribute_array['href'] = str_replace('@','%40',$attribute_array['href']);
415
+		}
329 416
 		if (strpos($attribute_array['href'],'#')===0 && (isset(emailadmin_imapbase::$htmLawed_config['transform_anchor']) && emailadmin_imapbase::$htmLawed_config['transform_anchor']===true))
330 417
 		{
331 418
 			$attribute_array['href'] = "javascript:GoToAnchor('".trim(substr($attribute_array['href'],1))."');";
@@ -335,7 +422,8 @@  discard block
 block discarded – undo
335 422
 
336 423
 	// Build the attributes string
337 424
 	$attributes = '';
338
-	foreach($attribute_array as $k=>$v){
425
+	foreach($attribute_array as $k=>$v)
426
+	{
339 427
 		$attributes .= " {$k}=\"{$v}\"";
340 428
 	}
341 429
 
Please login to merge, or discard this patch.
phpgwapi/inc/class.egw_include_mgr.inc.php 4 patches
Doc Comments   +2 added lines, -7 removed lines patch added patch discarded remove patch
@@ -270,8 +270,6 @@  discard block
 block discarded – undo
270 270
 	 *    --> /phpgwapi/inc/calendar-setup.js?lang=de
271 271
 	 *
272 272
 	 * @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
273
-	 * @param string|array $file=null file to be included - no ".js" on the end or array with get params
274
-	 * @param string $app='phpgwapi' application directory to search - default = phpgwapi
275 273
 	 *
276 274
 	 * @returns the correct path on the server if the file is found or false, if the
277 275
 	 *  file is not found or no further processing is needed.
@@ -332,8 +330,6 @@  discard block
 block discarded – undo
332 330
 	 *    --> /phpgwapi/inc/calendar-setup.js?lang=de
333 331
 	 *
334 332
 	 * @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
335
-	 * @param string|array $file=null file to be included - no ".js" on the end or array with get params
336
-	 * @param string $app='phpgwapi' application directory to search - default = phpgwapi
337 333
 	 */
338 334
 	public function include_js_file($package, $file = null, $app = 'phpgwapi')
339 335
 	{
@@ -361,7 +357,7 @@  discard block
 block discarded – undo
361 357
 	 * Include given files, optionally clear list of files to include
362 358
 	 *
363 359
 	 * @param array $files
364
-	 * @param boolean $clear_files=false if true clear list of files, before including given ones
360
+	 * @param boolean $clear_files if true clear list of files, before including given ones
365 361
 	 */
366 362
 	public function include_files(array $files, $clear_files=false)
367 363
 	{
@@ -376,7 +372,7 @@  discard block
 block discarded – undo
376 372
 	/**
377 373
 	 * Return all files
378 374
 	 *
379
-	 * @param boolean $clear_files=false if true clear list of files after returning them
375
+	 * @param boolean $clear_files if true clear list of files after returning them
380 376
 	 * @return array
381 377
 	 */
382 378
 	public function get_included_files($clear_files=false)
@@ -389,7 +385,6 @@  discard block
 block discarded – undo
389 385
 	/**
390 386
 	 * Constructor
391 387
 	 *
392
-	 * @param array $files=null optional files to include as for include_files method
393 388
 	 */
394 389
 	public function __construct(array $files = null)
395 390
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@
 block discarded – undo
172 172
 	private function file_processed($file)
173 173
 	{
174 174
 		return (array_key_exists($file, $this->included_files) ||
175
-			    array_key_exists($file, $this->parsed_files));
175
+				array_key_exists($file, $this->parsed_files));
176 176
 	}
177 177
 
178 178
 	/**
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	private function parse_file($file)
73 73
 	{
74 74
 		// file is from url and can contain query-params, eg. /phpgwapi/inc/jscalendar-setup.php?dateformat=d.m.Y&amp;lang=de
75
-		if (strpos($file,'?') !== false) list($file) = explode('?',$file);
75
+		if (strpos($file, '?') !== false) list($file) = explode('?', $file);
76 76
 
77 77
 		// Mark the file as parsed
78 78
 		$this->parsed_files[$file] = true;
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	{
281 281
 		if ($package[0] == '/' && (is_readable(EGW_SERVER_ROOT.(parse_url($path = $package, PHP_URL_PATH))) ||
282 282
 			is_readable(EGW_SERVER_ROOT.($path = $package))) ||
283
-			$package == '.' && is_readable(EGW_SERVER_ROOT.($path="/$app/js/$file.js")) ||
284
-			is_readable(EGW_SERVER_ROOT.($path="/$app/js/$package/$file.js")) ||
285
-			$app != 'phpgwapi' && is_readable(EGW_SERVER_ROOT.($path="/phpgwapi/js/$package/$file.js")))
283
+			$package == '.' && is_readable(EGW_SERVER_ROOT.($path = "/$app/js/$file.js")) ||
284
+			is_readable(EGW_SERVER_ROOT.($path = "/$app/js/$package/$file.js")) ||
285
+			$app != 'phpgwapi' && is_readable(EGW_SERVER_ROOT.($path = "/phpgwapi/js/$package/$file.js")))
286 286
 		{
287 287
 			// normalise /./ to /
288 288
 			$path = str_replace('/./', '/', $path);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 			// 	adding the ctime to all js files...
294 294
 			if (is_array($file))
295 295
 			{
296
-				foreach($file as $name => $val)
296
+				foreach ($file as $name => $val)
297 297
 				{
298 298
 					$args .= (empty($args) ? '?' : '&').$name.'='.urlencode($val);
299 299
 				}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * @param array $files
364 364
 	 * @param boolean $clear_files=false if true clear list of files, before including given ones
365 365
 	 */
366
-	public function include_files(array $files, $clear_files=false)
366
+	public function include_files(array $files, $clear_files = false)
367 367
 	{
368 368
 		if ($clear_files) self::$included_files = array();
369 369
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 * @param boolean $clear_files=false if true clear list of files after returning them
380 380
 	 * @return array
381 381
 	 */
382
-	public function get_included_files($clear_files=false)
382
+	public function get_included_files($clear_files = false)
383 383
 	{
384 384
 		$ret = array_keys($this->included_files);
385 385
 		if ($clear_files) $this->included_files = array();
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 
412 412
 	$paths = !empty($_GET['path']) ? (array)$_GET['path'] : (array)'/stylite/js/filemanager/filemanager.js';
413 413
 
414
-	foreach($paths as $path)
414
+	foreach ($paths as $path)
415 415
 	{
416 416
 		echo "\t<h1>".htmlspecialchars($path)."</h1>\n";
417 417
 		$mgr->include_js_file($path);
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,10 @@  discard block
 block discarded – undo
72 72
 	private function parse_file($file)
73 73
 	{
74 74
 		// file is from url and can contain query-params, eg. /phpgwapi/inc/jscalendar-setup.php?dateformat=d.m.Y&amp;lang=de
75
-		if (strpos($file,'?') !== false) list($file) = explode('?',$file);
75
+		if (strpos($file,'?') !== false)
76
+		{
77
+			list($file) = explode('?',$file);
78
+		}
76 79
 
77 80
 		// Mark the file as parsed
78 81
 		$this->parsed_files[$file] = true;
@@ -314,12 +317,15 @@  discard block
 block discarded – undo
314 317
 			}
315 318
 		}
316 319
 
317
-		if (self::$DEBUG_MODE) // DEBUG_MODE is currently ALWAYS true. Comment this code out if you don't want error messages.
320
+		if (self::$DEBUG_MODE)
321
+		{
322
+			// DEBUG_MODE is currently ALWAYS true. Comment this code out if you don't want error messages.
318 323
 		{
319 324
 			//error_log(__METHOD__."($package,$file,$app) $path NOT found".($this->debug_processing_file ? " while processing file '{$this->debug_processing_file}'." : "!").' '.function_backtrace());
320 325
 		}
321 326
 
322 327
 		return false;
328
+		}
323 329
 	}
324 330
 
325 331
 	/**
@@ -365,7 +371,10 @@  discard block
 block discarded – undo
365 371
 	 */
366 372
 	public function include_files(array $files, $clear_files=false)
367 373
 	{
368
-		if ($clear_files) self::$included_files = array();
374
+		if ($clear_files)
375
+		{
376
+			self::$included_files = array();
377
+		}
369 378
 
370 379
 		foreach ($files as $file)
371 380
 		{
@@ -382,7 +391,10 @@  discard block
 block discarded – undo
382 391
 	public function get_included_files($clear_files=false)
383 392
 	{
384 393
 		$ret = array_keys($this->included_files);
385
-		if ($clear_files) $this->included_files = array();
394
+		if ($clear_files)
395
+		{
396
+			$this->included_files = array();
397
+		}
386 398
 		return $ret;
387 399
 	}
388 400
 
Please login to merge, or discard this patch.