Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
api/src/Vfs.php 5 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 			return;	// not found, should not happen
673 673
 		}
674 674
 		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
675
-		    $type == 'F' && is_dir($path)))	// symlink to a directory
675
+			$type == 'F' && is_dir($path)))	// symlink to a directory
676 676
 		{
677 677
 			return;	// wrong type
678 678
 		}
@@ -1621,13 +1621,13 @@  discard block
 block discarded – undo
1621 1621
 		{
1622 1622
 			return false;
1623 1623
 		}
1624
-    	// remove the lock info evtl. set in the cache
1625
-    	unset(self::$lock_cache[$path]);
1624
+		// remove the lock info evtl. set in the cache
1625
+		unset(self::$lock_cache[$path]);
1626 1626
 
1627
-    	if ($timeout < 1000000)	// < 1000000 is a relative timestamp, so we add the current time
1628
-    	{
1629
-    		$timeout += time();
1630
-    	}
1627
+		if ($timeout < 1000000)	// < 1000000 is a relative timestamp, so we add the current time
1628
+		{
1629
+			$timeout += time();
1630
+		}
1631 1631
 
1632 1632
 		if ($update)	// Lock Update
1633 1633
 		{
@@ -1688,32 +1688,32 @@  discard block
 block discarded – undo
1688 1688
 		return $ret;
1689 1689
 	}
1690 1690
 
1691
-    /**
1692
-     * unlock a ressource/path
1693
-     *
1694
-     * @param string $path path to unlock
1695
-     * @param string $token locktoken
1691
+	/**
1692
+	 * unlock a ressource/path
1693
+	 *
1694
+	 * @param string $path path to unlock
1695
+	 * @param string $token locktoken
1696 1696
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1697
-     * @return boolean true on success
1698
-     */
1699
-    static function unlock($path,$token,$check_writable=true)
1700
-    {
1697
+	 * @return boolean true on success
1698
+	 */
1699
+	static function unlock($path,$token,$check_writable=true)
1700
+	{
1701 1701
 		// we require write rights to lock/unlock a resource
1702 1702
 		if ($check_writable && !self::is_writable($path))
1703 1703
 		{
1704 1704
 			return false;
1705 1705
 		}
1706
-        if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1707
-        	'lock_path' => $path,
1708
-        	'lock_token' => $token,
1709
-        ),__LINE__,__FILE__) && self::$db->affected_rows()))
1710
-        {
1711
-        	// remove the lock from the cache too
1712
-        	unset(self::$lock_cache[$path]);
1713
-        }
1706
+		if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1707
+			'lock_path' => $path,
1708
+			'lock_token' => $token,
1709
+		),__LINE__,__FILE__) && self::$db->affected_rows()))
1710
+		{
1711
+			// remove the lock from the cache too
1712
+			unset(self::$lock_cache[$path]);
1713
+		}
1714 1714
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$check_writable) returns ".($ret ? 'true' : 'false'));
1715 1715
 		return $ret;
1716
-    }
1716
+	}
1717 1717
 
1718 1718
 	/**
1719 1719
 	 * checkLock() helper
@@ -1741,13 +1741,13 @@  discard block
 block discarded – undo
1741 1741
 		}
1742 1742
 		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1743 1743
 		{
1744
-	        self::$db->delete(self::LOCK_TABLE,array(
1745
-	        	'lock_path' => $result['path'],
1746
-	        	'lock_token' => $result['token'],
1747
-	        ),__LINE__,__FILE__);
1744
+			self::$db->delete(self::LOCK_TABLE,array(
1745
+				'lock_path' => $result['path'],
1746
+				'lock_token' => $result['token'],
1747
+			),__LINE__,__FILE__);
1748 1748
 
1749 1749
 			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1750
-	        $result = false;
1750
+			$result = false;
1751 1751
 		}
1752 1752
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1753 1753
 		return self::$lock_cache[$path] = $result;
@@ -1887,9 +1887,9 @@  discard block
 block discarded – undo
1887 1887
 			$image = Image::find($mime_sub, 'navbar');
1888 1888
 		}
1889 1889
 		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
1890
-		         (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1891
-		         (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1892
-		         ($stat = self::stat($file)) && $stat['size'] < 1500000)
1890
+				 (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1891
+				 (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1892
+				 ($stat = self::stat($file)) && $stat['size'] < 1500000)
1893 1893
 		{
1894 1894
 			if (substr($file, 0, 6) == '/apps/')
1895 1895
 			{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1415,7 +1415,7 @@
 block discarded – undo
1415 1415
 	 *
1416 1416
 	 * @todo use https://github.com/maennchen/ZipStream-PHP to not assamble all files in memmory
1417 1417
 	 */
1418
-	public static function download_zip(Array $_files, $name = false)
1418
+	public static function download_zip(array $_files, $name = false)
1419 1419
 	{
1420 1420
 		//error_log(__METHOD__ . ': '.implode(',',$_files));
1421 1421
 
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * dir working on just the eGW VFS: returns directory object
175 175
 	 *
176 176
 	 * @param string $path filename with absolute path in the eGW VFS
177
-	 * @return Directory
177
+	 * @return \Directory
178 178
 	 */
179 179
 	static function dir($path)
180 180
 	{
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 	 * Also works around PHP under Windows returning dirname('/something') === '\\', which is NOT understood by EGroupware's VFS!
1327 1327
 	 *
1328 1328
 	 * @param string $_url path or url
1329
-	 * @return string|boolean parent or false if there's none ($path == '/')
1329
+	 * @return false|string parent or false if there's none ($path == '/')
1330 1330
 	 */
1331 1331
 	static function dirname($_url)
1332 1332
 	{
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 	 * checkLock() helper
1754 1754
 	 *
1755 1755
 	 * @param  string resource path to check for locks
1756
-	 * @return array|boolean false if there's no lock, else array with lock info
1756
+	 * @return string|null false if there's no lock, else array with lock info
1757 1757
 	 */
1758 1758
 	static function checkLock($path)
1759 1759
 	{
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 	/**
1970 1970
 	 * Copies the files given in $src to $dst.
1971 1971
 	 *
1972
-	 * @param array $src contains the source file
1972
+	 * @param string[] $src contains the source file
1973 1973
 	 * @param string $dst is the destination directory
1974 1974
 	 * @param int& $errs =null on return number of errors happened
1975 1975
 	 * @param array& $copied =null on return files copied
@@ -2221,7 +2221,6 @@  discard block
 block discarded – undo
2221 2221
 	 * In order for the appropriate error message to be returned, do not define this method if your wrapper does not support removing directories.
2222 2222
 	 *
2223 2223
 	 * @param string $path
2224
-	 * @param int $options Possible values include STREAM_REPORT_ERRORS.
2225 2224
 	 * @return boolean TRUE on success or FALSE on failure.
2226 2225
 	 */
2227 2226
 	static function rmdir($path)
@@ -2347,7 +2346,7 @@  discard block
 block discarded – undo
2347 2346
 	 * Requires root rights!
2348 2347
 	 *
2349 2348
 	 * @param string $path
2350
-	 * @param int|string $owner numeric user id or account-name
2349
+	 * @param integer $owner numeric user id or account-name
2351 2350
 	 * @return boolean true on success, false otherwise
2352 2351
 	 */
2353 2352
 	static function chown($path,$owner)
Please login to merge, or discard this patch.
Braces   +213 added lines, -56 removed lines patch added patch discarded remove patch
@@ -246,7 +246,10 @@  discard block
 block discarded – undo
246 246
 		}
247 247
 		foreach($props as &$prop)
248 248
 		{
249
-			if ($prop['name'] == $name && $prop['ns'] == $ns) return $prop;
249
+			if ($prop['name'] == $name && $prop['ns'] == $ns)
250
+			{
251
+				return $prop;
252
+			}
250 253
 		}
251 254
 		return null;
252 255
 	}
@@ -416,17 +419,27 @@  discard block
 block discarded – undo
416 419
 		$dirs_last = $options['depth'];	// put content of dirs before the dir itself
417 420
 		// show dirs on top by default, if no recursive listing (allways disabled if $type specified, as unnecessary)
418 421
 		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth'])&&$options['maxdepth']>0);
419
-		if ($dirsontop) $options['need_mime'] = true;	// otherwise dirsontop can NOT work
422
+		if ($dirsontop)
423
+		{
424
+			$options['need_mime'] = true;
425
+		}
426
+		// otherwise dirsontop can NOT work
420 427
 
421 428
 		// process some of the options (need to be done only once)
422
-		if (isset($options['name']) && !isset($options['name_preg']))	// change from simple *,? wildcards to preg regular expression once
429
+		if (isset($options['name']) && !isset($options['name_preg']))
430
+		{
431
+			// change from simple *,? wildcards to preg regular expression once
423 432
 		{
424 433
 			$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'])).'$/i';
425 434
 		}
426
-		if (isset($options['path']) && !isset($options['preg_path']))	// change from simple *,? wildcards to preg regular expression once
435
+		}
436
+		if (isset($options['path']) && !isset($options['preg_path']))
437
+		{
438
+			// change from simple *,? wildcards to preg regular expression once
427 439
 		{
428 440
 			$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'])).'$/i';
429 441
 		}
442
+		}
430 443
 		if (!isset($options['uid']))
431 444
 		{
432 445
 			if (isset($options['user']))
@@ -473,7 +486,10 @@  discard block
 block discarded – undo
473 486
 		{
474 487
 			if (!$url)
475 488
 			{
476
-				if ($path[0] != '/' || !self::stat($path)) continue;
489
+				if ($path[0] != '/' || !self::stat($path))
490
+				{
491
+					continue;
492
+				}
477 493
 				$path = self::PREFIX . $path;
478 494
 			}
479 495
 			if (!isset($options['remove']))
@@ -491,9 +507,17 @@  discard block
 block discarded – undo
491 507
 			{
492 508
 				while(($fname = readdir($dir)) !== false)
493 509
 				{
494
-					if ($fname == '.' || $fname == '..') continue;	// ignore current and parent dir!
510
+					if ($fname == '.' || $fname == '..')
511
+					{
512
+						continue;
513
+					}
514
+					// ignore current and parent dir!
495 515
 
496
-					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue;	// ignore hidden files
516
+					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden'])
517
+					{
518
+						continue;
519
+					}
520
+					// ignore hidden files
497 521
 
498 522
 					$file = self::concat($path, $fname);
499 523
 
@@ -505,8 +529,14 @@  discard block
 block discarded – undo
505 529
 					if (is_dir($file) && ($options['follow'] || !is_link($file)) && (!isset($options['maxdepth']) || $options['maxdepth'] > 1))
506 530
 					{
507 531
 						$opts = $options;
508
-						if ($opts['mindepth']) $opts['mindepth']--;
509
-						if ($opts['maxdepth']) $opts['depth']++;
532
+						if ($opts['mindepth'])
533
+						{
534
+							$opts['mindepth']--;
535
+						}
536
+						if ($opts['maxdepth'])
537
+						{
538
+							$opts['depth']++;
539
+						}
510 540
 						unset($opts['order']);
511 541
 						unset($opts['limit']);
512 542
 						foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
@@ -571,7 +601,10 @@  discard block
 block discarded – undo
571 601
 		if (isset($options['limit']))
572 602
 		{
573 603
 			list($limit,$start) = explode(',',$options['limit']);
574
-			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches'])) $limit = 15;
604
+			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches']))
605
+			{
606
+				$limit = 15;
607
+			}
575 608
 			//echo "total=".self::$find_total.", limit=$options[limit] --> start=$start, limit=$limit<br>\n";
576 609
 
577 610
 			if ((int)$start || self::$find_total > $limit)
@@ -631,9 +664,13 @@  discard block
 block discarded – undo
631 664
 			return;	// not found, should not happen
632 665
 		}
633 666
 		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
634
-		    $type == 'F' && is_dir($path)))	// symlink to a directory
667
+		    $type == 'F' && is_dir($path)))
635 668
 		{
636
-			return;	// wrong type
669
+			// symlink to a directory
670
+		{
671
+			return;
672
+		}
673
+		// wrong type
637 674
 		}
638 675
 		$stat['path'] = self::parse_url($path,PHP_URL_PATH);
639 676
 		$stat['name'] = $options['remove'] > 0 ? implode('/',array_slice(explode('/',$stat['path']),$options['remove'])) : self::basename($path);
@@ -655,11 +692,15 @@  discard block
 block discarded – undo
655 692
 		}
656 693
 		if (isset($options['mime']) && $options['mime'] != $stat['mime'])
657 694
 		{
658
-			if ($options['mime'][0] == '/')	// perl regular expression given
695
+			if ($options['mime'][0] == '/')
696
+			{
697
+				// perl regular expression given
659 698
 			{
660 699
 				if (!preg_match($options['mime'], $stat['mime']))
661 700
 				{
662
-					return;	// wrong mime-type
701
+					return;
702
+			}
703
+			// wrong mime-type
663 704
 				}
664 705
 			}
665 706
 			else
@@ -722,7 +763,10 @@  discard block
 block discarded – undo
722 763
 	 */
723 764
 	static function isProtectedDir($dir)
724 765
 	{
725
-		if ($dir[0] != '/') $dir = self::parse_url($dir, PHP_URL_PATH);
766
+		if ($dir[0] != '/')
767
+		{
768
+			$dir = self::parse_url($dir, PHP_URL_PATH);
769
+		}
726 770
 
727 771
 		return preg_match('#^/(apps(/[^/]+)?|home|templates(/[^/]+)?)?/*$#', $dir) > 0;
728 772
 	}
@@ -809,7 +853,10 @@  discard block
 block discarded – undo
809 853
 			{
810 854
 				self::clearstatcache($path);
811 855
 
812
-				if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
856
+				if (!isset($vfs))
857
+				{
858
+					$vfs = new Vfs\StreamWrapper();
859
+				}
813 860
 				$path_user_stat[$path][$user] = $vfs->url_stat($path, 0);
814 861
 
815 862
 				self::clearstatcache($path);	// we need to clear the stat-cache after the call too, as the next call might be the regular user again!
@@ -852,7 +899,10 @@  discard block
 block discarded – undo
852 899
 		// query stat array, if not given
853 900
 		if (is_null($stat))
854 901
 		{
855
-			if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
902
+			if (!isset($vfs))
903
+			{
904
+				$vfs = new Vfs\StreamWrapper();
905
+			}
856 906
 			$stat = $vfs->url_stat($path,0);
857 907
 		}
858 908
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check)");
@@ -1000,7 +1050,8 @@  discard block
 block discarded – undo
1000 1050
 			}
1001 1051
 
1002 1052
 			// sort by length descending, to show precedence
1003
-			usort($eacls, function($a, $b) {
1053
+			usort($eacls, function($a, $b)
1054
+			{
1004 1055
 				return strlen($b['path']) - strlen($a['path']);
1005 1056
 			});
1006 1057
 		}
@@ -1055,14 +1106,21 @@  discard block
 block discarded – undo
1055 1106
 	 */
1056 1107
 	static function mode2int($set,$mode=0)
1057 1108
 	{
1058
-		if (is_int($set))		// already an integer
1109
+		if (is_int($set))
1110
+		{
1111
+			// already an integer
1059 1112
 		{
1060 1113
 			return $set;
1061 1114
 		}
1062
-		if (is_numeric($set))	// octal string
1115
+		}
1116
+		if (is_numeric($set))
1117
+		{
1118
+			// octal string
1063 1119
 		{
1064 1120
 			//error_log(__METHOD__."($set,$mode) returning ".(int)base_convert($set,8,10));
1065
-			return (int)base_convert($set,8,10);	// convert octal to decimal
1121
+			return (int)base_convert($set,8,10);
1122
+		}
1123
+		// convert octal to decimal
1066 1124
 		}
1067 1125
 		foreach(explode(',',$set) as $s)
1068 1126
 		{
@@ -1118,34 +1176,55 @@  discard block
 block discarded – undo
1118 1176
 	 */
1119 1177
 	static function int2mode( $mode )
1120 1178
 	{
1121
-		if(($mode & self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1179
+		if(($mode & self::MODE_LINK) == self::MODE_LINK)
1180
+		{
1181
+			// Symbolic Link
1122 1182
 		{
1123 1183
 			$sP = 'l';
1124 1184
 		}
1125
-		elseif(($mode & 0xC000) == 0xC000) // Socket
1185
+		}
1186
+		elseif(($mode & 0xC000) == 0xC000)
1187
+		{
1188
+			// Socket
1126 1189
 		{
1127 1190
 			$sP = 's';
1128 1191
 		}
1129
-		elseif($mode & 0x1000)     // FIFO pipe
1192
+		}
1193
+		elseif($mode & 0x1000)
1194
+		{
1195
+			// FIFO pipe
1130 1196
 		{
1131 1197
 			$sP = 'p';
1132 1198
 		}
1133
-		elseif($mode & 0x2000) // Character special
1199
+		}
1200
+		elseif($mode & 0x2000)
1201
+		{
1202
+			// Character special
1134 1203
 		{
1135 1204
 			$sP = 'c';
1136 1205
 		}
1137
-		elseif($mode & 0x4000) // Directory
1206
+		}
1207
+		elseif($mode & 0x4000)
1208
+		{
1209
+			// Directory
1138 1210
 		{
1139 1211
 			$sP = 'd';
1140 1212
 		}
1141
-		elseif($mode & 0x6000) // Block special
1213
+		}
1214
+		elseif($mode & 0x6000)
1215
+		{
1216
+			// Block special
1142 1217
 		{
1143 1218
 			$sP = 'b';
1144 1219
 		}
1145
-		elseif($mode & 0x8000) // Regular
1220
+		}
1221
+		elseif($mode & 0x8000)
1222
+		{
1223
+			// Regular
1146 1224
 		{
1147 1225
 			$sP = '-';
1148 1226
 		}
1227
+		}
1149 1228
 		else                         // UNKNOWN
1150 1229
 		{
1151 1230
 			$sP = 'u';
@@ -1212,9 +1291,18 @@  discard block
 block discarded – undo
1212 1291
 	 */
1213 1292
 	static function hsize($size)
1214 1293
 	{
1215
-		if ($size < 1024) return $size;
1216
-		if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
1217
-		if ($size < 1024*1024*1024) return sprintf('%3.1lfM',(float)$size/(1024*1024));
1294
+		if ($size < 1024)
1295
+		{
1296
+			return $size;
1297
+		}
1298
+		if ($size < 1024*1024)
1299
+		{
1300
+			return sprintf('%3.1lfk',(float)$size/1024);
1301
+		}
1302
+		if ($size < 1024*1024*1024)
1303
+		{
1304
+			return sprintf('%3.1lfM',(float)$size/(1024*1024));
1305
+		}
1218 1306
 		return sprintf('%3.1lfG',(float)$size/(1024*1024*1024));
1219 1307
 	}
1220 1308
 
@@ -1225,7 +1313,10 @@  discard block
 block discarded – undo
1225 1313
 	 */
1226 1314
 	static function int_size($_val)
1227 1315
 	{
1228
-		if(empty($_val))return 0;
1316
+		if(empty($_val))
1317
+		{
1318
+			return 0;
1319
+		}
1229 1320
 
1230 1321
 		$val = trim($_val);
1231 1322
 
@@ -1233,11 +1324,13 @@  discard block
 block discarded – undo
1233 1324
 		preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
1234 1325
 
1235 1326
 		$last = '';
1236
-		if(isset($matches[2])){
1327
+		if(isset($matches[2]))
1328
+		{
1237 1329
 			$last = $matches[2];
1238 1330
 		}
1239 1331
 
1240
-		if(isset($matches[1])){
1332
+		if(isset($matches[1]))
1333
+		{
1241 1334
 			$val = (int) $matches[1];
1242 1335
 		}
1243 1336
 
@@ -1302,7 +1395,10 @@  discard block
 block discarded – undo
1302 1395
 			static $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D');
1303 1396
 			static $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]");
1304 1397
 			static $str_replace = null;
1305
-			if (!isset($str_replace)) $str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace';
1398
+			if (!isset($str_replace))
1399
+			{
1400
+				$str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace';
1401
+			}
1306 1402
 
1307 1403
 			// Create encoded URL with special URL characters decoded so it can be parsed
1308 1404
 			// All other characters will be encoded
@@ -1342,7 +1438,10 @@  discard block
 block discarded – undo
1342 1438
 			return false;
1343 1439
 		}
1344 1440
 		$parts = explode('/',$url);
1345
-		if (substr($url,-1) == '/') array_pop($parts);
1441
+		if (substr($url,-1) == '/')
1442
+		{
1443
+			array_pop($parts);
1444
+		}
1346 1445
 		array_pop($parts);
1347 1446
 		if ($url[0] != '/' && count($parts) == 3 || count($parts) == 1 && $parts[0] === '')
1348 1447
 		{
@@ -1385,7 +1484,10 @@  discard block
 block discarded – undo
1385 1484
 	static function concat($_url,$relative)
1386 1485
 	{
1387 1486
 		list($url,$query) = explode('?',$_url,2);
1388
-		if (substr($url,-1) == '/') $url = substr($url,0,-1);
1487
+		if (substr($url,-1) == '/')
1488
+		{
1489
+			$url = substr($url,0,-1);
1490
+		}
1389 1491
 		$ret = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
1390 1492
 
1391 1493
 		// now normalize the path (remove "/something/..")
@@ -1478,7 +1580,8 @@  discard block
 block discarded – undo
1478 1580
 		if(count($paths) > 0)
1479 1581
 		{
1480 1582
 			// Shortest to longest
1481
-			usort($paths, function($a, $b) {
1583
+			usort($paths, function($a, $b)
1584
+			{
1482 1585
 				return strlen($a) - strlen($b);
1483 1586
 			});
1484 1587
 
@@ -1551,7 +1654,10 @@  discard block
 block discarded – undo
1551 1654
 			// Don't go infinite with app entries
1552 1655
 			if(self::is_link($addfile))
1553 1656
 			{
1554
-				if(in_array($addfile, $links)) continue;
1657
+				if(in_array($addfile, $links))
1658
+				{
1659
+					continue;
1660
+				}
1555 1661
 				$links[] = $addfile;
1556 1662
 			}
1557 1663
 			// Add directory - if empty, client app might not show it though
@@ -1662,12 +1768,17 @@  discard block
 block discarded – undo
1662 1768
     	// remove the lock info evtl. set in the cache
1663 1769
     	unset(self::$lock_cache[$path]);
1664 1770
 
1665
-    	if ($timeout < 1000000)	// < 1000000 is a relative timestamp, so we add the current time
1771
+    	if ($timeout < 1000000)
1772
+    	{
1773
+    		// < 1000000 is a relative timestamp, so we add the current time
1666 1774
     	{
1667 1775
     		$timeout += time();
1668 1776
     	}
1777
+    	}
1669 1778
 
1670
-		if ($update)	// Lock Update
1779
+		if ($update)
1780
+		{
1781
+			// Lock Update
1671 1782
 		{
1672 1783
 			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE,array('lock_owner','lock_exclusive','lock_write'),array(
1673 1784
 				'lock_path' => $path,
@@ -1675,6 +1786,7 @@  discard block
 block discarded – undo
1675 1786
 			),__LINE__,__FILE__)->fetch())))
1676 1787
 			{
1677 1788
 				$owner = $row['lock_owner'];
1789
+		}
1678 1790
 				$scope = Db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared';
1679 1791
 				$type  = Db::from_bool($row['lock_write']) ? 'write' : 'read';
1680 1792
 
@@ -1722,7 +1834,10 @@  discard block
 block discarded – undo
1722 1834
 				$ret = false;	// there's already a lock
1723 1835
 			}
1724 1836
 		}
1725
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
1837
+		if (self::LOCK_DEBUG)
1838
+		{
1839
+			error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
1840
+		}
1726 1841
 		return $ret;
1727 1842
 	}
1728 1843
 
@@ -1749,7 +1864,10 @@  discard block
 block discarded – undo
1749 1864
         	// remove the lock from the cache too
1750 1865
         	unset(self::$lock_cache[$path]);
1751 1866
         }
1752
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$check_writable) returns ".($ret ? 'true' : 'false'));
1867
+		if (self::LOCK_DEBUG)
1868
+		{
1869
+			error_log(__METHOD__."($path,$token,$check_writable) returns ".($ret ? 'true' : 'false'));
1870
+		}
1753 1871
 		return $ret;
1754 1872
     }
1755 1873
 
@@ -1763,7 +1881,10 @@  discard block
 block discarded – undo
1763 1881
 	{
1764 1882
 		if (isset(self::$lock_cache[$path]))
1765 1883
 		{
1766
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1884
+			if (self::LOCK_DEBUG)
1885
+			{
1886
+				error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1887
+			}
1767 1888
 			return self::$lock_cache[$path];
1768 1889
 		}
1769 1890
 		$where = 'lock_path='.self::$db->quote($path);
@@ -1777,17 +1898,26 @@  discard block
 block discarded – undo
1777 1898
 			$result['scope'] = Db::from_bool($result['exclusive']) ? 'exclusive' : 'shared';
1778 1899
 			$result['depth'] = Db::from_bool($result['recursive']) ? 'infinite' : 0;
1779 1900
 		}
1780
-		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1901
+		if ($result && $result['expires'] < time())
1902
+		{
1903
+			// lock is expired --> remove it
1781 1904
 		{
1782 1905
 	        self::$db->delete(self::LOCK_TABLE,array(
1783 1906
 	        	'lock_path' => $result['path'],
1784 1907
 	        	'lock_token' => $result['token'],
1785 1908
 	        ),__LINE__,__FILE__);
1909
+		}
1786 1910
 
1787
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1911
+			if (self::LOCK_DEBUG)
1912
+			{
1913
+				error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1914
+			}
1788 1915
 	        $result = false;
1789 1916
 		}
1790
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1917
+		if (self::LOCK_DEBUG)
1918
+		{
1919
+			error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1920
+		}
1791 1921
 		return self::$lock_cache[$path] = $result;
1792 1922
 	}
1793 1923
 
@@ -1801,10 +1931,13 @@  discard block
 block discarded – undo
1801 1931
 	static function getExtraInfo($path,array $content=null)
1802 1932
 	{
1803 1933
 		$extra = array();
1804
-		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))	// true = fail silent if backend does NOT support it
1934
+		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))
1935
+		{
1936
+			// true = fail silent if backend does NOT support it
1805 1937
 		{
1806 1938
 			$extra[] = $extra_info;
1807 1939
 		}
1940
+		}
1808 1941
 
1809 1942
 		if (($vfs_extra = Hooks::process(array(
1810 1943
 			'location' => 'vfs_extra',
@@ -2083,30 +2216,42 @@  discard block
 block discarded – undo
2083 2216
 		}
2084 2217
 		if ($check_is_uploaded_file && !is_resource($tmp_name) && !is_uploaded_file($tmp_name))
2085 2218
 		{
2086
-			if (self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !is_uploaded_file()");
2219
+			if (self::LOG_LEVEL)
2220
+			{
2221
+				error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !is_uploaded_file()");
2222
+			}
2087 2223
 			return false;
2088 2224
 		}
2089 2225
 		if (!(self::is_writable($target) || ($dir = self::dirname($target)) && self::is_writable($dir)))
2090 2226
 		{
2091
-			if (self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !writable");
2227
+			if (self::LOG_LEVEL)
2228
+			{
2229
+				error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !writable");
2230
+			}
2092 2231
 			return false;
2093 2232
 		}
2094 2233
 		if ($props)
2095 2234
 		{
2096
-			if (!is_array($props)) $props = array(array('name' => 'comment','val' => $props));
2235
+			if (!is_array($props))
2236
+			{
2237
+				$props = array(array('name' => 'comment','val' => $props));
2238
+			}
2097 2239
 
2098 2240
 			// if $props is name => value pairs, convert it to internal array or array with values for keys 'name', 'val' and optional 'ns'
2099 2241
 			if (!isset($props[0]))
2100 2242
 			{
2101 2243
 				foreach($props as $name => $val)
2102 2244
 				{
2103
-					if (($name == 'comment' || $name[0] == '#') && $val)	// only copy 'comment' and cfs
2245
+					if (($name == 'comment' || $name[0] == '#') && $val)
2246
+					{
2247
+						// only copy 'comment' and cfs
2104 2248
 					{
2105 2249
 						$vfs_props[] = array(
2106 2250
 							'name' => $name,
2107 2251
 							'val'  => $val,
2108 2252
 						);
2109 2253
 					}
2254
+					}
2110 2255
 				}
2111 2256
 				$props = $vfs_props;
2112 2257
 			}
@@ -2138,7 +2283,10 @@  discard block
 block discarded – undo
2138 2283
 				copy($tmp_name, self::PREFIX.$target)) ?
2139 2284
 				self::stat($target) : false;
2140 2285
 		}
2141
-		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
2286
+		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL)
2287
+		{
2288
+			error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
2289
+		}
2142 2290
 		return $ret;
2143 2291
 	}
2144 2292
 
@@ -2271,7 +2419,10 @@  discard block
 block discarded – undo
2271 2419
 				return false;
2272 2420
 			}
2273 2421
 			$k=(string)self::parse_url($url,PHP_URL_SCHEME);
2274
-			if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array();
2422
+			if (!(is_array($scheme2urls[$k])))
2423
+			{
2424
+				$scheme2urls[$k] = array();
2425
+			}
2275 2426
 			$scheme2urls[$k][$path] = $url;
2276 2427
 		}
2277 2428
 		$ret = array();
@@ -2281,7 +2432,10 @@  discard block
 block discarded – undo
2281 2432
 			{
2282 2433
 				if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name))
2283 2434
 				{
2284
-					if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
2435
+					if (!$fail_silent)
2436
+					{
2437
+						trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
2438
+					}
2285 2439
 					return false;
2286 2440
 				}
2287 2441
 				if (!is_array($pathes))
@@ -2399,10 +2553,13 @@  discard block
 block discarded – undo
2399 2553
 	 */
2400 2554
 	static function symlink($target,$link)
2401 2555
 	{
2402
-		if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1)))	// 1=path is in $link!
2556
+		if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1)))
2557
+		{
2558
+			// 1=path is in $link!
2403 2559
 		{
2404 2560
 			Vfs\StreamWrapper::symlinkCache_remove($link);
2405 2561
 		}
2562
+		}
2406 2563
 		return $ret;
2407 2564
 	}
2408 2565
 
Please login to merge, or discard this patch.
Spacing   +289 added lines, -294 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param resource $context =null context to pass to stream-wrapper
146 146
 	 * @return resource
147 147
 	 */
148
-	static function fopen($path, $mode, $context=null)
148
+	static function fopen($path, $mode, $context = null)
149 149
 	{
150 150
 		if ($path[0] != '/')
151 151
 		{
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @param resource $context =null context to pass to stream-wrapper
162 162
 	 * @return resource
163 163
 	 */
164
-	static function opendir($path, $context=null)
164
+	static function opendir($path, $context = null)
165 165
 	{
166 166
 		if ($path[0] != '/')
167 167
 		{
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	 * @param int $sorting_order =0 !$sorting_order (default) alphabetical in ascending order, $sorting_order alphabetical in descending order.
193 193
 	 * @return array
194 194
 	 */
195
-	static function scandir($path,$sorting_order=0)
195
+	static function scandir($path, $sorting_order = 0)
196 196
 	{
197 197
 		if ($path[0] != '/')
198 198
 		{
199 199
 			throw new Exception\AssertionFailed("Directory '$path' is not an absolute path!");
200 200
 		}
201
-		return scandir(self::PREFIX.$path,$sorting_order);
201
+		return scandir(self::PREFIX.$path, $sorting_order);
202 202
 	}
203 203
 
204 204
 	/**
@@ -208,25 +208,25 @@  discard block
 block discarded – undo
208 208
 	 * @param string $to
209 209
 	 * @return boolean
210 210
 	 */
211
-	static function copy($from,$to)
211
+	static function copy($from, $to)
212 212
 	{
213
-		$old_props = self::file_exists($to) ? self::propfind($to,null) : array();
213
+		$old_props = self::file_exists($to) ? self::propfind($to, null) : array();
214 214
 		// copy properties (eg. file comment), if there are any and evtl. existing old properties
215
-		$props = self::propfind($from,null);
216
-		if(!$props)
215
+		$props = self::propfind($from, null);
216
+		if (!$props)
217 217
 		{
218 218
 			$props = array();
219 219
 		}
220
-		foreach($old_props as $prop)
220
+		foreach ($old_props as $prop)
221 221
 		{
222
-			if (!self::find_prop($props,$prop))
222
+			if (!self::find_prop($props, $prop))
223 223
 			{
224
-				$prop['val'] = null;	// null = delete prop
224
+				$prop['val'] = null; // null = delete prop
225 225
 				$props[] = $prop;
226 226
 			}
227 227
 		}
228 228
 		// using self::copy_uploaded() to treat copying incl. properties as atomar operation in respect of notifications
229
-		return self::copy_uploaded(self::PREFIX.$from,$to,$props,false);	// false = no is_uploaded_file check!
229
+		return self::copy_uploaded(self::PREFIX.$from, $to, $props, false); // false = no is_uploaded_file check!
230 230
 	}
231 231
 
232 232
 	/**
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 	 * @param string $ns =self::DEFAULT_PROP_NAMESPACE namespace, only if $prop is no array
238 238
 	 * @return &array reference to property in $props or null if not found
239 239
 	 */
240
-	static function &find_prop(array &$props,$name,$ns=self::DEFAULT_PROP_NAMESPACE)
240
+	static function &find_prop(array &$props, $name, $ns = self::DEFAULT_PROP_NAMESPACE)
241 241
 	{
242 242
 		if (is_array($name))
243 243
 		{
244 244
 			$ns = $name['ns'];
245 245
 			$name = $name['name'];
246 246
 		}
247
-		foreach($props as &$prop)
247
+		foreach ($props as &$prop)
248 248
 		{
249 249
 			if ($prop['name'] == $name && $prop['ns'] == $ns) return $prop;
250 250
 		}
@@ -258,16 +258,16 @@  discard block
 block discarded – undo
258 258
 	 * @param boolean $try_create_home =false should a non-existing home-directory be automatically created
259 259
 	 * @return array
260 260
 	 */
261
-	static function stat($path,$try_create_home=false)
261
+	static function stat($path, $try_create_home = false)
262 262
 	{
263 263
 		if ($path[0] != '/' && strpos($path, self::PREFIX.'/') !== 0)
264 264
 		{
265 265
 			throw new Exception\AssertionFailed("File '$path' is not an absolute path!");
266 266
 		}
267 267
 		$vfs = new Vfs\StreamWrapper();
268
-		if (($stat = $vfs->url_stat($path,0,$try_create_home)))
268
+		if (($stat = $vfs->url_stat($path, 0, $try_create_home)))
269 269
 		{
270
-			$stat = array_slice($stat,13);	// remove numerical indices 0-12
270
+			$stat = array_slice($stat, 13); // remove numerical indices 0-12
271 271
 		}
272 272
 		return $stat;
273 273
 	}
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	 * @param boolean $try_create_home =false should a non-existing home-directory be automatically created
280 280
 	 * @return array
281 281
 	 */
282
-	static function lstat($path,$try_create_home=false)
282
+	static function lstat($path, $try_create_home = false)
283 283
 	{
284 284
 		if ($path[0] != '/' && strpos($path, self::PREFIX.'/') !== 0)
285 285
 		{
286 286
 			throw new Exception\AssertionFailed("File '$path' is not an absolute path!");
287 287
 		}
288 288
 		$vfs = new Vfs\StreamWrapper();
289
-		if (($stat = $vfs->url_stat($path,STREAM_URL_STAT_LINK,$try_create_home)))
289
+		if (($stat = $vfs->url_stat($path, STREAM_URL_STAT_LINK, $try_create_home)))
290 290
 		{
291
-			$stat = array_slice($stat,13);	// remove numerical indices 0-12
291
+			$stat = array_slice($stat, 13); // remove numerical indices 0-12
292 292
 		}
293 293
 		return $stat;
294 294
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 * @param boolean $clear_fstab =false true clear current fstab, false (default) only add given mount
340 340
 	 * @return array|boolean array with fstab, if called without parameter or true on successful mount
341 341
 	 */
342
-	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
342
+	static function mount($url = null, $path = null, $check_url = null, $persitent_mount = true, $clear_fstab = false)
343 343
 	{
344 344
 		return Vfs\StreamWrapper::mount($url, $path, $check_url, $persitent_mount, $clear_fstab);
345 345
 	}
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 	 * @param boolean $allow_versions =false allow .versions or .attic
373 373
 	 * @return boolean
374 374
 	 */
375
-	public static function is_hidden($path, $allow_versions=false)
375
+	public static function is_hidden($path, $allow_versions = false)
376 376
 	{
377 377
 		$file = self::basename($path);
378 378
 
@@ -408,30 +408,30 @@  discard block
 block discarded – undo
408 408
 	 * @param array $exec_params =null further params for exec as array, path is always the first param and stat the last!
409 409
 	 * @return array of pathes if no $exec, otherwise path => stat pairs
410 410
 	 */
411
-	static function find($base,$options=null,$exec=null,$exec_params=null)
411
+	static function find($base, $options = null, $exec = null, $exec_params = null)
412 412
 	{
413 413
 		//error_log(__METHOD__."(".print_r($base,true).",".print_r($options,true).",".print_r($exec,true).",".print_r($exec_params,true).")\n");
414 414
 
415
-		$type = $options['type'];	// 'd', 'f' or 'F'
416
-		$dirs_last = $options['depth'];	// put content of dirs before the dir itself
415
+		$type = $options['type']; // 'd', 'f' or 'F'
416
+		$dirs_last = $options['depth']; // put content of dirs before the dir itself
417 417
 		// show dirs on top by default, if no recursive listing (allways disabled if $type specified, as unnecessary)
418
-		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth'])&&$options['maxdepth']>0);
419
-		if ($dirsontop) $options['need_mime'] = true;	// otherwise dirsontop can NOT work
418
+		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth']) && $options['maxdepth'] > 0);
419
+		if ($dirsontop) $options['need_mime'] = true; // otherwise dirsontop can NOT work
420 420
 
421 421
 		// process some of the options (need to be done only once)
422 422
 		if (isset($options['name']) && !isset($options['name_preg']))	// change from simple *,? wildcards to preg regular expression once
423 423
 		{
424
-			$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'])).'$/i';
424
+			$options['name_preg'] = '/^'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($options['name'])).'$/i';
425 425
 		}
426 426
 		if (isset($options['path']) && !isset($options['preg_path']))	// change from simple *,? wildcards to preg regular expression once
427 427
 		{
428
-			$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'])).'$/i';
428
+			$options['path_preg'] = '/^'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($options['path'])).'$/i';
429 429
 		}
430 430
 		if (!isset($options['uid']))
431 431
 		{
432 432
 			if (isset($options['user']))
433 433
 			{
434
-				$options['uid'] = $GLOBALS['egw']->accounts->name2id($options['user'],'account_lid','u');
434
+				$options['uid'] = $GLOBALS['egw']->accounts->name2id($options['user'], 'account_lid', 'u');
435 435
 			}
436 436
 			elseif (isset($options['nouser']))
437 437
 			{
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		{
443 443
 			if (isset($options['group']))
444 444
 			{
445
-				$options['gid'] = abs($GLOBALS['egw']->accounts->name2id($options['group'],'account_lid','g'));
445
+				$options['gid'] = abs($GLOBALS['egw']->accounts->name2id($options['group'], 'account_lid', 'g'));
446 446
 			}
447 447
 			elseif (isset($options['nogroup']))
448 448
 			{
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		}
452 452
 		if ($options['order'] == 'mime')
453 453
 		{
454
-			$options['need_mime'] = true;	// we need to return the mime colum
454
+			$options['need_mime'] = true; // we need to return the mime colum
455 455
 		}
456 456
 		// implicit show deleted files, if hidden is enabled (requires versioning!)
457 457
 		if (!empty($options['hidden']) && !isset($options['show-deleted']))
@@ -469,37 +469,37 @@  discard block
 block discarded – undo
469 469
 			$base = array($base);
470 470
 		}
471 471
 		$result = array();
472
-		foreach($base as $path)
472
+		foreach ($base as $path)
473 473
 		{
474 474
 			if (!$url)
475 475
 			{
476 476
 				if ($path[0] != '/' || !self::stat($path)) continue;
477
-				$path = self::PREFIX . $path;
477
+				$path = self::PREFIX.$path;
478 478
 			}
479 479
 			if (!isset($options['remove']))
480 480
 			{
481
-				$options['remove'] = count($base) == 1 ? count(explode('/',$path))-3+(int)(substr($path,-1)!='/') : 0;
481
+				$options['remove'] = count($base) == 1 ? count(explode('/', $path)) - 3 + (int)(substr($path, -1) != '/') : 0;
482 482
 			}
483 483
 			$is_dir = is_dir($path);
484 484
 			if ((int)$options['mindepth'] == 0 && (!$dirs_last || !$is_dir))
485 485
 			{
486
-				self::_check_add($options,$path,$result);
486
+				self::_check_add($options, $path, $result);
487 487
 			}
488 488
 			if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 &&
489 489
 				$options['depth'] < $options['maxdepth'])) &&
490 490
 				($dir = @opendir($path, $context)))
491 491
 			{
492
-				while(($fname = readdir($dir)) !== false)
492
+				while (($fname = readdir($dir)) !== false)
493 493
 				{
494
-					if ($fname == '.' || $fname == '..') continue;	// ignore current and parent dir!
494
+					if ($fname == '.' || $fname == '..') continue; // ignore current and parent dir!
495 495
 
496
-					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue;	// ignore hidden files
496
+					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue; // ignore hidden files
497 497
 
498 498
 					$file = self::concat($path, $fname);
499 499
 
500 500
 					if ((int)$options['mindepth'] <= 1)
501 501
 					{
502
-						self::_check_add($options,$file,$result);
502
+						self::_check_add($options, $file, $result);
503 503
 					}
504 504
 					// only descend into subdirs, if it's a real dir (no link to a dir) or we should follow symlinks
505 505
 					if (is_dir($file) && ($options['follow'] || !is_link($file)) && (!isset($options['maxdepth']) || $options['maxdepth'] > 1))
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 						if ($opts['maxdepth']) $opts['depth']++;
510 510
 						unset($opts['order']);
511 511
 						unset($opts['limit']);
512
-						foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
512
+						foreach (self::find($options['url'] ? $file : self::parse_url($file, PHP_URL_PATH), $opts, true) as $p => $s)
513 513
 						{
514 514
 							unset($result[$p]);
515 515
 							$result[$p] = $s;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 			if ($is_dir && (int)$options['mindepth'] == 0 && $dirs_last)
522 522
 			{
523
-				self::_check_add($options,$path,$result);
523
+				self::_check_add($options, $path, $result);
524 524
 			}
525 525
 		}
526 526
 		// sort code, to place directories before files, if $dirsontop enabled
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 		if (isset($options['order']))
531 531
 		{
532 532
 			$sort = strtolower($options['sort']) == 'desc' ? '-' : '';
533
-			switch($options['order'])
533
+			switch ($options['order'])
534 534
 			{
535 535
 				// sort numerical
536 536
 				case 'size':
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 					$code = $dirsfirst.$sort.'($a[\''.$options['order'].'\']-$b[\''.$options['order'].'\']);';
543 543
 					// always use name as second sort criteria
544 544
 					$code = '$cmp = '.$code.' return $cmp ? $cmp : strcasecmp($a[\'name\'],$b[\'name\']);';
545
-					$ok = uasort($result,create_function('$a,$b',$code));
545
+					$ok = uasort($result, create_function('$a,$b', $code));
546 546
 					break;
547 547
 
548 548
 				// sort alphanumerical
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 					{
562 562
 						$code = 'return '.$code;
563 563
 					}
564
-					$ok = uasort($result,create_function('$a,$b',$code));
564
+					$ok = uasort($result, create_function('$a,$b', $code));
565 565
 					break;
566 566
 			}
567 567
 			//echo "<p>order='$options[order]', sort='$options[sort]' --> uasort($result,create_function(,'$code'))=".array2string($ok)."</p>>\n";
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
 		self::$find_total = count($result);
571 571
 		if (isset($options['limit']))
572 572
 		{
573
-			list($limit,$start) = explode(',',$options['limit']);
573
+			list($limit, $start) = explode(',', $options['limit']);
574 574
 			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches'])) $limit = 15;
575 575
 			//echo "total=".self::$find_total.", limit=$options[limit] --> start=$start, limit=$limit<br>\n";
576 576
 
577 577
 			if ((int)$start || self::$find_total > $limit)
578 578
 			{
579
-				$result = array_slice($result,(int)$start,(int)$limit,true);
579
+				$result = array_slice($result, (int)$start, (int)$limit, true);
580 580
 			}
581 581
 		}
582 582
 		//echo $path; _debug_array($result);
@@ -586,13 +586,13 @@  discard block
 block discarded – undo
586 586
 			{
587 587
 				$exec_params = is_null($exec_params) ? array() : array($exec_params);
588 588
 			}
589
-			foreach($result as $path => &$stat)
589
+			foreach ($result as $path => &$stat)
590 590
 			{
591 591
 				$options = $exec_params;
592
-				array_unshift($options,$path);
593
-				array_push($options,$stat);
592
+				array_unshift($options, $path);
593
+				array_push($options, $stat);
594 594
 				//echo "calling ".print_r($exec,true).print_r($options,true)."\n";
595
-				$stat = call_user_func_array($exec,$options);
595
+				$stat = call_user_func_array($exec, $options);
596 596
 			}
597 597
 			return $result;
598 598
 		}
@@ -611,15 +611,15 @@  discard block
 block discarded – undo
611 611
 	 * @param string $path name of path to add
612 612
 	 * @param array &$result here we add the stat for the key $path, if the checks are successful
613 613
 	 */
614
-	private static function _check_add($options,$path,&$result)
614
+	private static function _check_add($options, $path, &$result)
615 615
 	{
616
-		$type = $options['type'];	// 'd' or 'f'
616
+		$type = $options['type']; // 'd' or 'f'
617 617
 
618 618
 		if ($options['url'])
619 619
 		{
620 620
 			if (($stat = @lstat($path)))
621 621
 			{
622
-				$stat = array_slice($stat,13);	// remove numerical indices 0-12
622
+				$stat = array_slice($stat, 13); // remove numerical indices 0-12
623 623
 			}
624 624
 		}
625 625
 		else
@@ -628,30 +628,30 @@  discard block
 block discarded – undo
628 628
 		}
629 629
 		if (!$stat)
630 630
 		{
631
-			return;	// not found, should not happen
631
+			return; // not found, should not happen
632 632
 		}
633
-		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
633
+		if ($type && (($type == 'd') == !($stat['mode']&Vfs\Sqlfs\StreamWrapper::MODE_DIR) || // != is_dir() which can be true for symlinks
634 634
 		    $type == 'F' && is_dir($path)))	// symlink to a directory
635 635
 		{
636
-			return;	// wrong type
636
+			return; // wrong type
637 637
 		}
638
-		$stat['path'] = self::parse_url($path,PHP_URL_PATH);
639
-		$stat['name'] = $options['remove'] > 0 ? implode('/',array_slice(explode('/',$stat['path']),$options['remove'])) : self::basename($path);
638
+		$stat['path'] = self::parse_url($path, PHP_URL_PATH);
639
+		$stat['name'] = $options['remove'] > 0 ? implode('/', array_slice(explode('/', $stat['path']), $options['remove'])) : self::basename($path);
640 640
 
641 641
 		if ($options['mime'] || $options['need_mime'])
642 642
 		{
643 643
 			$stat['mime'] = self::mime_content_type($path);
644 644
 		}
645
-		if (isset($options['name_preg']) && !preg_match($options['name_preg'],$stat['name']) ||
646
-			isset($options['path_preg']) && !preg_match($options['path_preg'],$path))
645
+		if (isset($options['name_preg']) && !preg_match($options['name_preg'], $stat['name']) ||
646
+			isset($options['path_preg']) && !preg_match($options['path_preg'], $path))
647 647
 		{
648 648
 			//echo "<p>!preg_match('{$options['name_preg']}','{$stat['name']}')</p>\n";
649
-			return;	// wrong name or path
649
+			return; // wrong name or path
650 650
 		}
651 651
 		if (isset($options['gid']) && $stat['gid'] != $options['gid'] ||
652 652
 			isset($options['uid']) && $stat['uid'] != $options['uid'])
653 653
 		{
654
-			return;	// wrong user or group
654
+			return; // wrong user or group
655 655
 		}
656 656
 		if (isset($options['mime']) && $options['mime'] != $stat['mime'])
657 657
 		{
@@ -659,40 +659,40 @@  discard block
 block discarded – undo
659 659
 			{
660 660
 				if (!preg_match($options['mime'], $stat['mime']))
661 661
 				{
662
-					return;	// wrong mime-type
662
+					return; // wrong mime-type
663 663
 				}
664 664
 			}
665 665
 			else
666 666
 			{
667
-				list($type,$subtype) = explode('/',$options['mime']);
667
+				list($type, $subtype) = explode('/', $options['mime']);
668 668
 				// no subtype (eg. 'image') --> check only the main type
669
-				if ($subtype || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
669
+				if ($subtype || substr($stat['mime'], 0, strlen($type) + 1) != $type.'/')
670 670
 				{
671
-					return;	// wrong mime-type
671
+					return; // wrong mime-type
672 672
 				}
673 673
 			}
674 674
 		}
675
-		if (isset($options['size']) && !self::_check_num($stat['size'],$options['size']) ||
675
+		if (isset($options['size']) && !self::_check_num($stat['size'], $options['size']) ||
676 676
 			(isset($options['empty']) && !!$options['empty'] !== !$stat['size']))
677 677
 		{
678
-			return;	// wrong size
678
+			return; // wrong size
679 679
 		}
680
-		if (isset($options['cmin']) && !self::_check_num(round((time()-$stat['ctime'])/60),$options['cmin']) ||
681
-			isset($options['mmin']) && !self::_check_num(round((time()-$stat['mtime'])/60),$options['mmin']) ||
682
-			isset($options['ctime']) && !self::_check_num(round((time()-$stat['ctime'])/86400),$options['ctime']) ||
683
-			isset($options['mtime']) && !self::_check_num(round((time()-$stat['mtime'])/86400),$options['mtime']))
680
+		if (isset($options['cmin']) && !self::_check_num(round((time() - $stat['ctime']) / 60), $options['cmin']) ||
681
+			isset($options['mmin']) && !self::_check_num(round((time() - $stat['mtime']) / 60), $options['mmin']) ||
682
+			isset($options['ctime']) && !self::_check_num(round((time() - $stat['ctime']) / 86400), $options['ctime']) ||
683
+			isset($options['mtime']) && !self::_check_num(round((time() - $stat['mtime']) / 86400), $options['mtime']))
684 684
 		{
685
-			return;	// not create/modified in the spezified time
685
+			return; // not create/modified in the spezified time
686 686
 		}
687 687
 		// do we return url or just vfs pathes
688 688
 		if (!$options['url'])
689 689
 		{
690
-			$path = self::parse_url($path,PHP_URL_PATH);
690
+			$path = self::parse_url($path, PHP_URL_PATH);
691 691
 		}
692 692
 		$result[$path] = $stat;
693 693
 	}
694 694
 
695
-	private static function _check_num($value,$argument)
695
+	private static function _check_num($value, $argument)
696 696
 	{
697 697
 		if (is_int($argument) && $argument >= 0 || $argument[0] != '-' && $argument[0] != '+')
698 698
 		{
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			return $value < abs($argument);
706 706
 		}
707 707
 		//echo "_check_num($value,$argument) check > == ".(int)($value > (int)substr($argument,1))."\n";
708
-		return $value > (int) substr($argument,1);
708
+		return $value > (int)substr($argument, 1);
709 709
 	}
710 710
 
711 711
 	/**
@@ -735,10 +735,10 @@  discard block
 block discarded – undo
735 735
 	 * @throws Vfs\Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected()
736 736
 	 * @return array
737 737
 	 */
738
-	static function remove($urls,$allow_urls=false)
738
+	static function remove($urls, $allow_urls = false)
739 739
 	{
740 740
 		//error_log(__METHOD__.'('.array2string($urls).')');
741
-		foreach((array)$urls as $url)
741
+		foreach ((array)$urls as $url)
742 742
 		{
743 743
 			// some precaution to never allow to (recursivly) remove /, /apps or /home, see Vfs::isProtected()
744 744
 			if (self::isProtectedDir($url))
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 				throw new Vfs\Exception\ProtectedDirectory("Deleting protected directory '$url' rejected!");
747 747
 			}
748 748
 		}
749
-		return self::find($urls, array('depth'=>true,'url'=>$allow_urls,'hidden'=>true), __CLASS__.'::_rm_rmdir');
749
+		return self::find($urls, array('depth'=>true, 'url'=>$allow_urls, 'hidden'=>true), __CLASS__.'::_rm_rmdir');
750 750
 	}
751 751
 
752 752
 	/**
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
 	{
760 760
 		if ($url[0] == '/')
761 761
 		{
762
-			$url = self::PREFIX . $url;
762
+			$url = self::PREFIX.$url;
763 763
 		}
764 764
 		$vfs = new Vfs\StreamWrapper();
765 765
 		if (is_dir($url) && !is_link($url))
766 766
 		{
767
-			return $vfs->rmdir($url,0);
767
+			return $vfs->rmdir($url, 0);
768 768
 		}
769 769
 		return $vfs->unlink($url);
770 770
 	}
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 	 * 	2 = self::WRITABLE, 1 = self::EXECUTABLE
779 779
 	 * @return boolean
780 780
 	 */
781
-	static function is_readable($path,$check = self::READABLE)
781
+	static function is_readable($path, $check = self::READABLE)
782 782
 	{
783
-		return self::check_access($path,$check);
783
+		return self::check_access($path, $check);
784 784
 	}
785 785
 
786 786
 	/**
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	 * @param int $user =null user used for check, if not current user (self::$user)
795 795
 	 * @return boolean
796 796
 	 */
797
-	static function check_access($path, $check, $stat=null, $user=null)
797
+	static function check_access($path, $check, $stat = null, $user = null)
798 798
 	{
799 799
 		static $vfs = null;
800 800
 
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 				if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
813 813
 				$path_user_stat[$path][$user] = $vfs->url_stat($path, 0);
814 814
 
815
-				self::clearstatcache($path);	// we need to clear the stat-cache after the call too, as the next call might be the regular user again!
815
+				self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again!
816 816
 			}
817 817
 			if (($stat = $path_user_stat[$path][$user]))
818 818
 			{
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 			}
829 829
 			else
830 830
 			{
831
-				$ret = false;	// no access, if we can not stat the file
831
+				$ret = false; // no access, if we can not stat the file
832 832
 			}
833 833
 			self::$user = $backup_user;
834 834
 
@@ -853,20 +853,20 @@  discard block
 block discarded – undo
853 853
 		if (is_null($stat))
854 854
 		{
855 855
 			if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
856
-			$stat = $vfs->url_stat($path,0);
856
+			$stat = $vfs->url_stat($path, 0);
857 857
 		}
858 858
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check)");
859 859
 
860 860
 		if (!$stat)
861 861
 		{
862 862
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) no stat array!");
863
-			return false;	// file not found
863
+			return false; // file not found
864 864
 		}
865 865
 		// check if we use an EGroupwre stream wrapper, or a stock php one
866 866
 		// if it's not an EGroupware one, we can NOT use uid, gid and mode!
867
-		if (($scheme = self::parse_url($stat['url'],PHP_URL_SCHEME)) && !(class_exists(self::scheme2class($scheme))))
867
+		if (($scheme = self::parse_url($stat['url'], PHP_URL_SCHEME)) && !(class_exists(self::scheme2class($scheme))))
868 868
 		{
869
-			switch($check)
869
+			switch ($check)
870 870
 			{
871 871
 				case self::READABLE:
872 872
 					return is_readable($stat['url']);
@@ -877,19 +877,19 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 		}
879 879
 		// check if other rights grant access
880
-		if (($stat['mode'] & $check) == $check)
880
+		if (($stat['mode']&$check) == $check)
881 881
 		{
882 882
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) access via other rights!");
883 883
 			return true;
884 884
 		}
885 885
 		// check if there's owner access and we are the owner
886
-		if (($stat['mode'] & ($check << 6)) == ($check << 6) && $stat['uid'] && $stat['uid'] == self::$user)
886
+		if (($stat['mode']&($check << 6)) == ($check << 6) && $stat['uid'] && $stat['uid'] == self::$user)
887 887
 		{
888 888
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) access via owner rights!");
889 889
 			return true;
890 890
 		}
891 891
 		// check if there's a group access and we have the right membership
892
-		if (($stat['mode'] & ($check << 3)) == ($check << 3) && $stat['gid'])
892
+		if (($stat['mode']&($check << 3)) == ($check << 3) && $stat['gid'])
893 893
 		{
894 894
 			if (($memberships = $GLOBALS['egw']->accounts->memberships(self::$user, true)) && in_array(-abs($stat['gid']), $memberships))
895 895
 			{
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 			}
899 899
 		}
900 900
 		// check backend for extended acls (only if path given)
901
-		$ret = $path && self::_call_on_backend('check_extended_acl',array(isset($stat['url'])?$stat['url']:$path,$check),true);	// true = fail silent if backend does not support
901
+		$ret = $path && self::_call_on_backend('check_extended_acl', array(isset($stat['url']) ? $stat['url'] : $path, $check), true); // true = fail silent if backend does not support
902 902
 
903 903
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) ".($ret ? 'backend extended acl granted access.' : 'no access!!!'));
904 904
 		return $ret;
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 	 */
914 914
 	static function is_writable($path)
915 915
 	{
916
-		return self::is_readable($path,self::WRITABLE);
916
+		return self::is_readable($path, self::WRITABLE);
917 917
 	}
918 918
 
919 919
 	/**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 	 */
926 926
 	static function is_executable($path)
927 927
 	{
928
-		return self::is_readable($path,self::EXECUTABLE);
928
+		return self::is_readable($path, self::EXECUTABLE);
929 929
 	}
930 930
 
931 931
 	/**
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	 */
937 937
 	static function deny_script($path)
938 938
 	{
939
-		return self::_call_on_backend('deny_script',array($path),true);
939
+		return self::_call_on_backend('deny_script', array($path), true);
940 940
 	}
941 941
 
942 942
 	/**
@@ -955,11 +955,11 @@  discard block
 block discarded – undo
955 955
 	 * @param boolean $session_only =false true: set eacl only for this session, does NO further checks currently!
956 956
 	 * @return boolean true if acl is set/deleted, false on error
957 957
 	 */
958
-	static function eacl($url,$rights=null,$owner=null,$session_only=false)
958
+	static function eacl($url, $rights = null, $owner = null, $session_only = false)
959 959
 	{
960 960
 		if ($session_only)
961 961
 		{
962
-			$session_eacls =& Cache::getSession(__CLASS__, self::SESSION_EACL);
962
+			$session_eacls = & Cache::getSession(__CLASS__, self::SESSION_EACL);
963 963
 			$session_eacls[] = array(
964 964
 				'path'   => $url[0] == '/' ? $url : self::parse_url($url, PHP_URL_PATH),
965 965
 				'owner'  => $owner ? $owner : self::$user,
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 			);
968 968
 			return true;
969 969
 		}
970
-		return self::_call_on_backend('eacl',array($url,$rights,$owner));
970
+		return self::_call_on_backend('eacl', array($url, $rights, $owner));
971 971
 	}
972 972
 
973 973
 	/**
@@ -980,9 +980,9 @@  discard block
 block discarded – undo
980 980
 	 */
981 981
 	static function get_eacl($path)
982 982
 	{
983
-		$eacls = self::_call_on_backend('get_eacl',array($path),true);	// true = fail silent (no PHP Warning)
983
+		$eacls = self::_call_on_backend('get_eacl', array($path), true); // true = fail silent (no PHP Warning)
984 984
 
985
-		$session_eacls =& Cache::getSession(__CLASS__, self::SESSION_EACL);
985
+		$session_eacls = & Cache::getSession(__CLASS__, self::SESSION_EACL);
986 986
 		if ($session_eacls)
987 987
 		{
988 988
 			// eacl is recursive, therefore we have to match all parent-dirs too
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				$paths[] = $path = self::dirname($path);
993 993
 			}
994
-			foreach((array)$session_eacls as $eacl)
994
+			foreach ((array)$session_eacls as $eacl)
995 995
 			{
996 996
 				if (in_array($eacl['path'], $paths))
997 997
 				{
@@ -1014,9 +1014,9 @@  discard block
 block discarded – undo
1014 1014
 	 * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop)
1015 1015
 	 * @return boolean true if props are updated, false otherwise (eg. ressource not found)
1016 1016
 	 */
1017
-	static function proppatch($path,array $props)
1017
+	static function proppatch($path, array $props)
1018 1018
 	{
1019
-		return self::_call_on_backend('proppatch',array($path,$props));
1019
+		return self::_call_on_backend('proppatch', array($path, $props));
1020 1020
 	}
1021 1021
 
1022 1022
 	/**
@@ -1033,9 +1033,9 @@  discard block
 block discarded – undo
1033 1033
 	 * @return array|boolean array with props (values for keys 'name', 'ns', 'val'), or path => array of props for is_array($path)
1034 1034
 	 * 	false if $path does not exist
1035 1035
 	 */
1036
-	static function propfind($path,$ns=self::DEFAULT_PROP_NAMESPACE)
1036
+	static function propfind($path, $ns = self::DEFAULT_PROP_NAMESPACE)
1037 1037
 	{
1038
-		return self::_call_on_backend('propfind',array($path,$ns),true);	// true = fail silent (no PHP Warning)
1038
+		return self::_call_on_backend('propfind', array($path, $ns), true); // true = fail silent (no PHP Warning)
1039 1039
 	}
1040 1040
 
1041 1041
 	/**
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	 * @param int $mode =0 current mode of the file, necessary for +/- operation
1054 1054
 	 * @return int
1055 1055
 	 */
1056
-	static function mode2int($set,$mode=0)
1056
+	static function mode2int($set, $mode = 0)
1057 1057
 	{
1058 1058
 		if (is_int($set))		// already an integer
1059 1059
 		{
@@ -1062,23 +1062,23 @@  discard block
 block discarded – undo
1062 1062
 		if (is_numeric($set))	// octal string
1063 1063
 		{
1064 1064
 			//error_log(__METHOD__."($set,$mode) returning ".(int)base_convert($set,8,10));
1065
-			return (int)base_convert($set,8,10);	// convert octal to decimal
1065
+			return (int)base_convert($set, 8, 10); // convert octal to decimal
1066 1066
 		}
1067
-		foreach(explode(',',$set) as $s)
1067
+		foreach (explode(',', $set) as $s)
1068 1068
 		{
1069 1069
 			$matches = null;
1070
-			if (!preg_match($use='/^([ugoa]*)([+=-]+)([rwx]+)$/',$s,$matches))
1070
+			if (!preg_match($use = '/^([ugoa]*)([+=-]+)([rwx]+)$/', $s, $matches))
1071 1071
 			{
1072
-				$use = str_replace(array('/','^','$','(',')'),'',$use);
1072
+				$use = str_replace(array('/', '^', '$', '(', ')'), '', $use);
1073 1073
 				throw new Exception\WrongUserinput("$s is not an allowed mode, use $use !");
1074 1074
 			}
1075
-			$base = (strpos($matches[3],'r') !== false ? self::READABLE : 0) |
1076
-				(strpos($matches[3],'w') !== false ? self::WRITABLE : 0) |
1077
-				(strpos($matches[3],'x') !== false ? self::EXECUTABLE : 0);
1075
+			$base = (strpos($matches[3], 'r') !== false ? self::READABLE : 0)|
1076
+				(strpos($matches[3], 'w') !== false ? self::WRITABLE : 0)|
1077
+				(strpos($matches[3], 'x') !== false ? self::EXECUTABLE : 0);
1078 1078
 
1079
-			for($n = $m = 0; $n < strlen($matches[1]); $n++)
1079
+			for ($n = $m = 0; $n < strlen($matches[1]); $n++)
1080 1080
 			{
1081
-				switch($matches[1][$n])
1081
+				switch ($matches[1][$n])
1082 1082
 				{
1083 1083
 					case 'o':
1084 1084
 						$m |= $base;
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 						break;
1092 1092
 					default:
1093 1093
 					case 'a':
1094
-						$m = $base | ($base << 3) | ($base << 6);
1094
+						$m = $base|($base << 3)|($base << 6);
1095 1095
 				}
1096 1096
 			}
1097
-			switch($matches[2])
1097
+			switch ($matches[2])
1098 1098
 			{
1099 1099
 				case '+':
1100 1100
 					$mode |= $m;
@@ -1116,33 +1116,33 @@  discard block
 block discarded – undo
1116 1116
 	 * @param int $mode
1117 1117
 	 * @return string
1118 1118
 	 */
1119
-	static function int2mode( $mode )
1119
+	static function int2mode($mode)
1120 1120
 	{
1121
-		if(($mode & self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1121
+		if (($mode&self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1122 1122
 		{
1123 1123
 			$sP = 'l';
1124 1124
 		}
1125
-		elseif(($mode & 0xC000) == 0xC000) // Socket
1125
+		elseif (($mode&0xC000) == 0xC000) // Socket
1126 1126
 		{
1127 1127
 			$sP = 's';
1128 1128
 		}
1129
-		elseif($mode & 0x1000)     // FIFO pipe
1129
+		elseif ($mode&0x1000)     // FIFO pipe
1130 1130
 		{
1131 1131
 			$sP = 'p';
1132 1132
 		}
1133
-		elseif($mode & 0x2000) // Character special
1133
+		elseif ($mode&0x2000) // Character special
1134 1134
 		{
1135 1135
 			$sP = 'c';
1136 1136
 		}
1137
-		elseif($mode & 0x4000) // Directory
1137
+		elseif ($mode&0x4000) // Directory
1138 1138
 		{
1139 1139
 			$sP = 'd';
1140 1140
 		}
1141
-		elseif($mode & 0x6000) // Block special
1141
+		elseif ($mode&0x6000) // Block special
1142 1142
 		{
1143 1143
 			$sP = 'b';
1144 1144
 		}
1145
-		elseif($mode & 0x8000) // Regular
1145
+		elseif ($mode&0x8000) // Regular
1146 1146
 		{
1147 1147
 			$sP = '-';
1148 1148
 		}
@@ -1152,22 +1152,19 @@  discard block
 block discarded – undo
1152 1152
 		}
1153 1153
 
1154 1154
 		// owner
1155
-		$sP .= (($mode & 0x0100) ? 'r' : '-') .
1156
-		(($mode & 0x0080) ? 'w' : '-') .
1157
-		(($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) :
1158
-		(($mode & 0x0800) ? 'S' : '-'));
1155
+		$sP .= (($mode&0x0100) ? 'r' : '-').
1156
+		(($mode&0x0080) ? 'w' : '-').
1157
+		(($mode&0x0040) ? (($mode&0x0800) ? 's' : 'x') : (($mode&0x0800) ? 'S' : '-'));
1159 1158
 
1160 1159
 		// group
1161
-		$sP .= (($mode & 0x0020) ? 'r' : '-') .
1162
-		(($mode & 0x0010) ? 'w' : '-') .
1163
-		(($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) :
1164
-		(($mode & 0x0400) ? 'S' : '-'));
1160
+		$sP .= (($mode&0x0020) ? 'r' : '-').
1161
+		(($mode&0x0010) ? 'w' : '-').
1162
+		(($mode&0x0008) ? (($mode&0x0400) ? 's' : 'x') : (($mode&0x0400) ? 'S' : '-'));
1165 1163
 
1166 1164
 		// world
1167
-		$sP .= (($mode & 0x0004) ? 'r' : '-') .
1168
-		(($mode & 0x0002) ? 'w' : '-') .
1169
-		(($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) :
1170
-		(($mode & 0x0200) ? 'T' : '-'));
1165
+		$sP .= (($mode&0x0004) ? 'r' : '-').
1166
+		(($mode&0x0002) ? 'w' : '-').
1167
+		(($mode&0x0001) ? (($mode&0x0200) ? 't' : 'x') : (($mode&0x0200) ? 'T' : '-'));
1171 1168
 
1172 1169
 		return $sP;
1173 1170
 	}
@@ -1180,26 +1177,26 @@  discard block
 block discarded – undo
1180 1177
 	 * @param int $size =128
1181 1178
 	 * @return string
1182 1179
 	 */
1183
-	static function mime_icon($mime_type, $et_image=true, $size=128)
1180
+	static function mime_icon($mime_type, $et_image = true, $size = 128)
1184 1181
 	{
1185 1182
 		if ($mime_type == self::DIR_MIME_TYPE)
1186 1183
 		{
1187 1184
 			$mime_type = 'Directory';
1188 1185
 		}
1189
-		if(!$mime_type)
1186
+		if (!$mime_type)
1190 1187
 		{
1191 1188
 			$mime_type = 'unknown';
1192 1189
 		}
1193
-		$mime_full = strtolower(str_replace	('/','_',$mime_type));
1194
-		list($mime_part) = explode('_',$mime_full);
1190
+		$mime_full = strtolower(str_replace('/', '_', $mime_type));
1191
+		list($mime_part) = explode('_', $mime_full);
1195 1192
 
1196
-		if (!($img=Image::find('etemplate',$icon='mime'.$size.'_'.$mime_full)) &&
1193
+		if (!($img = Image::find('etemplate', $icon = 'mime'.$size.'_'.$mime_full)) &&
1197 1194
 			// check mime-alias-map before falling back to more generic icons
1198 1195
 			!(isset(MimeMagic::$mime_alias_map[$mime_type]) &&
1199
-				($img=Image::find('etemplate',$icon='mime'.$size.'_'.str_replace('/','_',MimeMagic::$mime_alias_map[$mime_full])))) &&
1200
-			!($img=Image::find('etemplate',$icon='mime'.$size.'_'.$mime_part)))
1196
+				($img = Image::find('etemplate', $icon = 'mime'.$size.'_'.str_replace('/', '_', MimeMagic::$mime_alias_map[$mime_full])))) &&
1197
+			!($img = Image::find('etemplate', $icon = 'mime'.$size.'_'.$mime_part)))
1201 1198
 		{
1202
-			$img = Image::find('etemplate',$icon='mime'.$size.'_unknown');
1199
+			$img = Image::find('etemplate', $icon = 'mime'.$size.'_unknown');
1203 1200
 		}
1204 1201
 		return $et_image ? 'etemplate/'.$icon : $img;
1205 1202
 	}
@@ -1213,9 +1210,9 @@  discard block
 block discarded – undo
1213 1210
 	static function hsize($size)
1214 1211
 	{
1215 1212
 		if ($size < 1024) return $size;
1216
-		if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
1217
-		if ($size < 1024*1024*1024) return sprintf('%3.1lfM',(float)$size/(1024*1024));
1218
-		return sprintf('%3.1lfG',(float)$size/(1024*1024*1024));
1213
+		if ($size < 1024 * 1024) return sprintf('%3.1lfk', (float)$size / 1024);
1214
+		if ($size < 1024 * 1024 * 1024) return sprintf('%3.1lfM', (float)$size / (1024 * 1024));
1215
+		return sprintf('%3.1lfG', (float)$size / (1024 * 1024 * 1024));
1219 1216
 	}
1220 1217
 
1221 1218
 	/**
@@ -1225,7 +1222,7 @@  discard block
 block discarded – undo
1225 1222
 	 */
1226 1223
 	static function int_size($_val)
1227 1224
 	{
1228
-		if(empty($_val))return 0;
1225
+		if (empty($_val))return 0;
1229 1226
 
1230 1227
 		$val = trim($_val);
1231 1228
 
@@ -1233,12 +1230,12 @@  discard block
 block discarded – undo
1233 1230
 		preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
1234 1231
 
1235 1232
 		$last = '';
1236
-		if(isset($matches[2])){
1233
+		if (isset($matches[2])) {
1237 1234
 			$last = $matches[2];
1238 1235
 		}
1239 1236
 
1240
-		if(isset($matches[1])){
1241
-			$val = (int) $matches[1];
1237
+		if (isset($matches[1])) {
1238
+			$val = (int)$matches[1];
1242 1239
 		}
1243 1240
 
1244 1241
 		switch (strtolower($last))
@@ -1254,7 +1251,7 @@  discard block
 block discarded – undo
1254 1251
 			$val *= 1024;
1255 1252
 		}
1256 1253
 
1257
-		return (int) $val;
1254
+		return (int)$val;
1258 1255
 	}
1259 1256
 
1260 1257
 	/**
@@ -1265,8 +1262,8 @@  discard block
 block discarded – undo
1265 1262
 	 */
1266 1263
 	static function basename($_path)
1267 1264
 	{
1268
-		list($path) = explode('?',$_path);	// remove query
1269
-		$parts = explode('/',$path);
1265
+		list($path) = explode('?', $_path); // remove query
1266
+		$parts = explode('/', $path);
1270 1267
 
1271 1268
 		return array_pop($parts);
1272 1269
 	}
@@ -1280,7 +1277,7 @@  discard block
 block discarded – undo
1280 1277
 	 * @param int $component =-1 PHP_URL_* constants
1281 1278
 	 * @return array|string|boolean on success array or string, if $component given, or false on failure
1282 1279
 	 */
1283
-	static function parse_url($url, $component=-1)
1280
+	static function parse_url($url, $component = -1)
1284 1281
 	{
1285 1282
 		static $component2str = array(
1286 1283
 			PHP_URL_SCHEME => 'scheme',
@@ -1292,9 +1289,9 @@  discard block
 block discarded – undo
1292 1289
 			PHP_URL_QUERY => 'query',
1293 1290
 			PHP_URL_FRAGMENT => 'fragment',
1294 1291
 		);
1295
-		static $cache = array();	// some caching
1292
+		static $cache = array(); // some caching
1296 1293
 
1297
-		$result =& $cache[$url];
1294
+		$result = & $cache[$url];
1298 1295
 
1299 1296
 		if (!isset($result))
1300 1297
 		{
@@ -1334,22 +1331,22 @@  discard block
 block discarded – undo
1334 1331
 	 */
1335 1332
 	static function dirname($_url)
1336 1333
 	{
1337
-		list($url,$query) = explode('?',$_url,2);	// strip the query first, as it can contain slashes
1334
+		list($url, $query) = explode('?', $_url, 2); // strip the query first, as it can contain slashes
1338 1335
 
1339
-		if ($url == '/' || $url[0] != '/' && self::parse_url($url,PHP_URL_PATH) == '/')
1336
+		if ($url == '/' || $url[0] != '/' && self::parse_url($url, PHP_URL_PATH) == '/')
1340 1337
 		{
1341 1338
 			//error_log(__METHOD__."($url) returning FALSE: already in root!");
1342 1339
 			return false;
1343 1340
 		}
1344
-		$parts = explode('/',$url);
1345
-		if (substr($url,-1) == '/') array_pop($parts);
1341
+		$parts = explode('/', $url);
1342
+		if (substr($url, -1) == '/') array_pop($parts);
1346 1343
 		array_pop($parts);
1347 1344
 		if ($url[0] != '/' && count($parts) == 3 || count($parts) == 1 && $parts[0] === '')
1348 1345
 		{
1349
-			array_push($parts,'');	// scheme://host is wrong (no path), has to be scheme://host/
1346
+			array_push($parts, ''); // scheme://host is wrong (no path), has to be scheme://host/
1350 1347
 		}
1351 1348
 		//error_log(__METHOD__."($url)=".implode('/',$parts).($query ? '?'.$query : ''));
1352
-		return implode('/',$parts).($query ? '?'.$query : '');
1349
+		return implode('/', $parts).($query ? '?'.$query : '');
1353 1350
 	}
1354 1351
 
1355 1352
 	/**
@@ -1361,16 +1358,16 @@  discard block
 block discarded – undo
1361 1358
 	 * @param array $stat =null stat for path, default queried by this function
1362 1359
 	 * @return boolean
1363 1360
 	 */
1364
-	static function has_owner_rights($path,array $stat=null)
1361
+	static function has_owner_rights($path, array $stat = null)
1365 1362
 	{
1366 1363
 		if (!$stat)
1367 1364
 		{
1368 1365
 			$vfs = new Vfs\StreamWrapper();
1369
-			$stat = $vfs->url_stat($path,0);
1366
+			$stat = $vfs->url_stat($path, 0);
1370 1367
 		}
1371
-		return $stat['uid'] == self::$user ||	// user is the owner
1372
-			self::$is_root ||					// class runs with root rights
1373
-			!$stat['uid'] && $stat['gid'] && self::$is_admin;	// group directory and user is an eGW admin
1368
+		return $stat['uid'] == self::$user || // user is the owner
1369
+			self::$is_root || // class runs with root rights
1370
+			!$stat['uid'] && $stat['gid'] && self::$is_admin; // group directory and user is an eGW admin
1374 1371
 	}
1375 1372
 
1376 1373
 	/**
@@ -1382,22 +1379,22 @@  discard block
 block discarded – undo
1382 1379
 	 * @param string $relative relative path to add to $url
1383 1380
 	 * @return string
1384 1381
 	 */
1385
-	static function concat($_url,$relative)
1382
+	static function concat($_url, $relative)
1386 1383
 	{
1387
-		list($url,$query) = explode('?',$_url,2);
1388
-		if (substr($url,-1) == '/') $url = substr($url,0,-1);
1384
+		list($url, $query) = explode('?', $_url, 2);
1385
+		if (substr($url, -1) == '/') $url = substr($url, 0, -1);
1389 1386
 		$ret = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
1390 1387
 
1391 1388
 		// now normalize the path (remove "/something/..")
1392
-		while (strpos($ret,'/../') !== false)
1389
+		while (strpos($ret, '/../') !== false)
1393 1390
 		{
1394
-			list($a_str,$b_str) = explode('/../',$ret,2);
1395
-			$a = explode('/',$a_str);
1391
+			list($a_str, $b_str) = explode('/../', $ret, 2);
1392
+			$a = explode('/', $a_str);
1396 1393
 			array_pop($a);
1397
-			$b = explode('/',$b_str);
1398
-			$ret = implode('/',array_merge($a,$b));
1394
+			$b = explode('/', $b_str);
1395
+			$ret = implode('/', array_merge($a, $b));
1399 1396
 		}
1400
-		return $ret.($query ? (strpos($url,'?')===false ? '?' : '&').$query : '');
1397
+		return $ret.($query ? (strpos($url, '?') === false ? '?' : '&').$query : '');
1401 1398
 	}
1402 1399
 
1403 1400
 	/**
@@ -1408,11 +1405,11 @@  discard block
 block discarded – undo
1408 1405
 	 */
1409 1406
 	static function build_url(array $url_parts)
1410 1407
 	{
1411
-		$url = (!isset($url_parts['scheme'])?'':$url_parts['scheme'].'://'.
1412
-			(!isset($url_parts['user'])?'':$url_parts['user'].(!isset($url_parts['pass'])?'':':'.$url_parts['pass']).'@').
1408
+		$url = (!isset($url_parts['scheme']) ? '' : $url_parts['scheme'].'://'.
1409
+			(!isset($url_parts['user']) ? '' : $url_parts['user'].(!isset($url_parts['pass']) ? '' : ':'.$url_parts['pass']).'@').
1413 1410
 			$url_parts['host']).$url_parts['path'].
1414
-			(!isset($url_parts['query'])?'':'?'.$url_parts['query']).
1415
-			(!isset($url_parts['fragment'])?'':'?'.$url_parts['fragment']);
1411
+			(!isset($url_parts['query']) ? '' : '?'.$url_parts['query']).
1412
+			(!isset($url_parts['fragment']) ? '' : '?'.$url_parts['fragment']);
1416 1413
 		//error_log(__METHOD__.'('.array2string($url_parts).") = '".$url."'");
1417 1414
 		return $url;
1418 1415
 	}
@@ -1430,19 +1427,19 @@  discard block
 block discarded – undo
1430 1427
 	 * @todo get $force_download working through webdav
1431 1428
 	 * @return string
1432 1429
 	 */
1433
-	static function download_url($path,$force_download=false)
1430
+	static function download_url($path, $force_download = false)
1434 1431
 	{
1435
-		if (($url = self::_call_on_backend('download_url',array($path,$force_download),true)))
1432
+		if (($url = self::_call_on_backend('download_url', array($path, $force_download), true)))
1436 1433
 		{
1437 1434
 			return $url;
1438 1435
 		}
1439 1436
 		if ($path[0] != '/')
1440 1437
 		{
1441
-			$path = self::parse_url($path,PHP_URL_PATH);
1438
+			$path = self::parse_url($path, PHP_URL_PATH);
1442 1439
 		}
1443 1440
 		// we do NOT need to encode % itself, as our path are already url encoded, with the exception of ' ' and '+'
1444 1441
 		// we urlencode double quotes '"', as that fixes many problems in html markup
1445
-		return '/webdav.php'.strtr($path,array('+' => '%2B',' ' => '%20','"' => '%22')).($force_download ? '?download' : '');
1442
+		return '/webdav.php'.strtr($path, array('+' => '%2B', ' ' => '%20', '"' => '%22')).($force_download ? '?download' : '');
1446 1443
 	}
1447 1444
 
1448 1445
 	/**
@@ -1470,12 +1467,12 @@  discard block
 block discarded – undo
1470 1467
 		// eg: User selected /home/nathan/picture.jpg, /home/Pictures/logo.jpg
1471 1468
 		// We want /home
1472 1469
 		$dirs = array();
1473
-		foreach($_files as $file)
1470
+		foreach ($_files as $file)
1474 1471
 		{
1475 1472
 			$dirs[] = self::dirname($file);
1476 1473
 		}
1477 1474
 		$paths = array_unique($dirs);
1478
-		if(count($paths) > 0)
1475
+		if (count($paths) > 0)
1479 1476
 		{
1480 1477
 			// Shortest to longest
1481 1478
 			usort($paths, function($a, $b) {
@@ -1483,13 +1480,13 @@  discard block
 block discarded – undo
1483 1480
 			});
1484 1481
 
1485 1482
 			// Start with shortest, pop off sub-directories that don't match
1486
-			$parts = explode('/',$paths[0]);
1487
-			foreach($paths as $path)
1483
+			$parts = explode('/', $paths[0]);
1484
+			foreach ($paths as $path)
1488 1485
 			{
1489
-				$dirs = explode('/',$path);
1490
-				foreach($dirs as $dir_index => $dir)
1486
+				$dirs = explode('/', $path);
1487
+				foreach ($dirs as $dir_index => $dir)
1491 1488
 				{
1492
-					if($parts[$dir_index] && $parts[$dir_index] != $dir)
1489
+					if ($parts[$dir_index] && $parts[$dir_index] != $dir)
1493 1490
 					{
1494 1491
 						unset($parts[$dir_index]);
1495 1492
 					}
@@ -1508,24 +1505,23 @@  discard block
 block discarded – undo
1508 1505
 			// Linux
1509 1506
 			'/',
1510 1507
 			// Windows
1511
-			'\\','?','%','*',':','|',/*'.',*/ '"','<','>'
1508
+			'\\', '?', '%', '*', ':', '|', /*'.',*/ '"', '<', '>'
1512 1509
 		);
1513 1510
 
1514 1511
 		// A nice name for the user,
1515
-		$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' .
1516
-			str_replace($replace,'_',(
1512
+		$filename = $GLOBALS['egw_info']['server']['site_title'].'_'.
1513
+			str_replace($replace, '_', (
1517 1514
 			$name ? $name : (
1518 1515
 			count($_files) == 1 ?
1519 1516
 			// Just one file (hopefully a directory?) selected
1520
-			self::basename($_files[0]) :
1521
-			// Use the lowest common directory (eg: Infolog, Open, nathan)
1517
+			self::basename($_files[0]) : // Use the lowest common directory (eg: Infolog, Open, nathan)
1522 1518
 			self::basename($base_dir))
1523
-		)) . '.zip';
1519
+		)).'.zip';
1524 1520
 
1525 1521
 		// Make sure basename is a dir
1526
-		if(substr($base_dir, -1) != '/')
1522
+		if (substr($base_dir, -1) != '/')
1527 1523
 		{
1528
-			$base_dir .='/';
1524
+			$base_dir .= '/';
1529 1525
 		}
1530 1526
 
1531 1527
 		// Go into directories, find them all
@@ -1536,37 +1532,37 @@  discard block
 block discarded – undo
1536 1532
 		$tempfiles = array();
1537 1533
 
1538 1534
 		// Give 1 second per file, but try to allow more time for big files when amount of files is low
1539
-		set_time_limit((count($files)<=9?10:count($files)));
1535
+		set_time_limit((count($files) <= 9 ? 10 : count($files)));
1540 1536
 
1541 1537
 		// Add files to archive
1542
-		foreach($files as &$addfile)
1538
+		foreach ($files as &$addfile)
1543 1539
 		{
1544 1540
 			// Use relative paths inside zip
1545 1541
 			$relative = substr($addfile, strlen($base_dir));
1546 1542
 
1547 1543
 			// Use safe names - replace unsafe chars, convert to ASCII (ZIP spec says CP437, but we'll try)
1548
-			$path = explode('/',$relative);
1549
-			$_name = Translation::convert(Translation::to_ascii(implode('/', str_replace($replace,'_',$path))),false,'ASCII');
1544
+			$path = explode('/', $relative);
1545
+			$_name = Translation::convert(Translation::to_ascii(implode('/', str_replace($replace, '_', $path))), false, 'ASCII');
1550 1546
 
1551 1547
 			// Don't go infinite with app entries
1552
-			if(self::is_link($addfile))
1548
+			if (self::is_link($addfile))
1553 1549
 			{
1554
-				if(in_array($addfile, $links)) continue;
1550
+				if (in_array($addfile, $links)) continue;
1555 1551
 				$links[] = $addfile;
1556 1552
 			}
1557 1553
 			// Add directory - if empty, client app might not show it though
1558
-			if(self::is_dir($addfile))
1554
+			if (self::is_dir($addfile))
1559 1555
 			{
1560 1556
 				// Zip directories
1561 1557
 				$zip->addEmptyDir($addfile);
1562 1558
 			}
1563
-			else if(self::is_readable($addfile))
1559
+			else if (self::is_readable($addfile))
1564 1560
 			{
1565 1561
 				// Copy to temp file, as ZipArchive fails to read VFS
1566 1562
 				$temp = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'zip_');
1567
-				$from = self::fopen($addfile,'r');
1568
-		 		$to = fopen($temp,'w');
1569
-				if(!stream_copy_to_stream($from,$to) || !$zip->addFile($temp, $_name))
1563
+				$from = self::fopen($addfile, 'r');
1564
+		 		$to = fopen($temp, 'w');
1565
+				if (!stream_copy_to_stream($from, $to) || !$zip->addFile($temp, $_name))
1570 1566
 				{
1571 1567
 					unlink($temp);
1572 1568
 					trigger_error("Could not add $addfile to ZIP file", E_USER_ERROR);
@@ -1577,10 +1573,10 @@  discard block
 block discarded – undo
1577 1573
 
1578 1574
 				// Add comment in
1579 1575
 				$props = self::propfind($addfile);
1580
-				if($props)
1576
+				if ($props)
1581 1577
 				{
1582
-					$comment = self::find_prop($props,'comment');
1583
-					if($comment)
1578
+					$comment = self::find_prop($props, 'comment');
1579
+					if ($comment)
1584 1580
 					{
1585 1581
 						$zip->setCommentName($_name, $comment);
1586 1582
 					}
@@ -1590,34 +1586,34 @@  discard block
 block discarded – undo
1590 1586
 		}
1591 1587
 
1592 1588
 		// Set a comment to help tell them apart
1593
-		$zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']) . ' ' .DateTime::to());
1589
+		$zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']).' '.DateTime::to());
1594 1590
 
1595 1591
 		// Record total for debug, not available after close()
1596 1592
 		$total_files = $zip->numFiles;
1597 1593
 
1598 1594
 		$result = $zip->close();
1599
-		if(!$result || !filesize($zip_file))
1595
+		if (!$result || !filesize($zip_file))
1600 1596
 		{
1601 1597
 			error_log('close() result: '.array2string($result));
1602 1598
 			return 'Error creating zip file';
1603 1599
 		}
1604 1600
 
1605
-		error_log("Total files: " . $total_files . " Peak memory to zip: " . self::hsize(memory_get_peak_usage(true)));
1601
+		error_log("Total files: ".$total_files." Peak memory to zip: ".self::hsize(memory_get_peak_usage(true)));
1606 1602
 
1607 1603
 		// Stop any buffering
1608
-		while(ob_get_level() > 0)
1604
+		while (ob_get_level() > 0)
1609 1605
 		{
1610 1606
 			ob_end_clean();
1611 1607
 		}
1612 1608
 
1613 1609
 		// Stream the file to the client
1614 1610
 		header("Content-Type: application/zip");
1615
-		header("Content-Length: " . filesize($zip_file));
1611
+		header("Content-Length: ".filesize($zip_file));
1616 1612
 		header("Content-Disposition: attachment; filename=\"$filename\"");
1617 1613
 		readfile($zip_file);
1618 1614
 
1619 1615
 		unlink($zip_file);
1620
-		foreach($tempfiles as $temp_file)
1616
+		foreach ($tempfiles as $temp_file)
1621 1617
 		{
1622 1618
 			unlink($temp_file);
1623 1619
 		}
@@ -1651,11 +1647,11 @@  discard block
 block discarded – undo
1651 1647
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1652 1648
 	 * @return boolean true on success
1653 1649
 	 */
1654
-	static function lock($path,&$token,&$timeout,&$owner,&$scope,&$type,$update=false,$check_writable=true)
1650
+	static function lock($path, &$token, &$timeout, &$owner, &$scope, &$type, $update = false, $check_writable = true)
1655 1651
 	{
1656 1652
 		// we require write rights to lock/unlock a resource
1657 1653
 		if (!$path || $update && !$token || $check_writable &&
1658
-			!(self::is_writable($path) || !self::file_exists($path) && ($dir=self::dirname($path)) && self::is_writable($dir)))
1654
+			!(self::is_writable($path) || !self::file_exists($path) && ($dir = self::dirname($path)) && self::is_writable($dir)))
1659 1655
 		{
1660 1656
 			return false;
1661 1657
 		}
@@ -1669,28 +1665,28 @@  discard block
 block discarded – undo
1669 1665
 
1670 1666
 		if ($update)	// Lock Update
1671 1667
 		{
1672
-			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE,array('lock_owner','lock_exclusive','lock_write'),array(
1668
+			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE, array('lock_owner', 'lock_exclusive', 'lock_write'), array(
1673 1669
 				'lock_path' => $path,
1674 1670
 				'lock_token' => $token,
1675
-			),__LINE__,__FILE__)->fetch())))
1671
+			), __LINE__, __FILE__)->fetch())))
1676 1672
 			{
1677 1673
 				$owner = $row['lock_owner'];
1678 1674
 				$scope = Db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared';
1679 1675
 				$type  = Db::from_bool($row['lock_write']) ? 'write' : 'read';
1680 1676
 
1681
-				self::$db->update(self::LOCK_TABLE,array(
1677
+				self::$db->update(self::LOCK_TABLE, array(
1682 1678
 					'lock_expires' => $timeout,
1683 1679
 					'lock_modified' => time(),
1684
-				),array(
1680
+				), array(
1685 1681
 					'lock_path' => $path,
1686 1682
 					'lock_token' => $token,
1687
-				),__LINE__,__FILE__);
1683
+				), __LINE__, __FILE__);
1688 1684
 			}
1689 1685
 		}
1690 1686
 		// HTTP_WebDAV_Server does this check before calling LOCK, but we want to be complete and usable outside WebDAV
1691
-		elseif(($lock = self::checkLock($path)) && ($lock['scope'] == 'exclusive' || $scope == 'exclusive'))
1687
+		elseif (($lock = self::checkLock($path)) && ($lock['scope'] == 'exclusive' || $scope == 'exclusive'))
1692 1688
 		{
1693
-			$ret = false;	// there's alread a lock
1689
+			$ret = false; // there's alread a lock
1694 1690
 		}
1695 1691
 		else
1696 1692
 		{
@@ -1705,7 +1701,7 @@  discard block
 block discarded – undo
1705 1701
 				$token = HTTP_WebDAV_Server::_new_locktoken();
1706 1702
 			}
1707 1703
 			try {
1708
-				self::$db->insert(self::LOCK_TABLE,array(
1704
+				self::$db->insert(self::LOCK_TABLE, array(
1709 1705
 					'lock_token' => $token,
1710 1706
 					'lock_path'  => $path,
1711 1707
 					'lock_created' => time(),
@@ -1714,12 +1710,12 @@  discard block
 block discarded – undo
1714 1710
 					'lock_expires' => $timeout,
1715 1711
 					'lock_exclusive' => $scope == 'exclusive',
1716 1712
 					'lock_write' => $type == 'write',
1717
-				),false,__LINE__,__FILE__);
1713
+				), false, __LINE__, __FILE__);
1718 1714
 				$ret = true;
1719 1715
 			}
1720
-			catch(Db\Exception $e) {
1716
+			catch (Db\Exception $e) {
1721 1717
 				unset($e);
1722
-				$ret = false;	// there's already a lock
1718
+				$ret = false; // there's already a lock
1723 1719
 			}
1724 1720
 		}
1725 1721
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
@@ -1734,17 +1730,17 @@  discard block
 block discarded – undo
1734 1730
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1735 1731
      * @return boolean true on success
1736 1732
      */
1737
-    static function unlock($path,$token,$check_writable=true)
1733
+    static function unlock($path, $token, $check_writable = true)
1738 1734
     {
1739 1735
 		// we require write rights to lock/unlock a resource
1740 1736
 		if ($check_writable && !self::is_writable($path))
1741 1737
 		{
1742 1738
 			return false;
1743 1739
 		}
1744
-        if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1740
+        if (($ret = self::$db->delete(self::LOCK_TABLE, array(
1745 1741
         	'lock_path' => $path,
1746 1742
         	'lock_token' => $token,
1747
-        ),__LINE__,__FILE__) && self::$db->affected_rows()))
1743
+        ), __LINE__, __FILE__) && self::$db->affected_rows()))
1748 1744
         {
1749 1745
         	// remove the lock from the cache too
1750 1746
         	unset(self::$lock_cache[$path]);
@@ -1763,31 +1759,31 @@  discard block
 block discarded – undo
1763 1759
 	{
1764 1760
 		if (isset(self::$lock_cache[$path]))
1765 1761
 		{
1766
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1762
+			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n", '    '), '', print_r(self::$lock_cache[$path], true)));
1767 1763
 			return self::$lock_cache[$path];
1768 1764
 		}
1769 1765
 		$where = 'lock_path='.self::$db->quote($path);
1770 1766
 		// ToDo: additional check parent dirs for locks and children of the requested directory
1771 1767
 		//$where .= ' OR '.self::$db->quote($path).' LIKE '.self::$db->concat('lock_path',"'%'").' OR lock_path LIKE '.self::$db->quote($path.'%');
1772 1768
 		// ToDo: shared locks can return multiple rows
1773
-		if (($result = self::$db->select(self::LOCK_TABLE,'*',$where,__LINE__,__FILE__)->fetch()))
1769
+		if (($result = self::$db->select(self::LOCK_TABLE, '*', $where, __LINE__, __FILE__)->fetch()))
1774 1770
 		{
1775
-			$result = Db::strip_array_keys($result,'lock_');
1771
+			$result = Db::strip_array_keys($result, 'lock_');
1776 1772
 			$result['type']  = Db::from_bool($result['write']) ? 'write' : 'read';
1777 1773
 			$result['scope'] = Db::from_bool($result['exclusive']) ? 'exclusive' : 'shared';
1778 1774
 			$result['depth'] = Db::from_bool($result['recursive']) ? 'infinite' : 0;
1779 1775
 		}
1780 1776
 		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1781 1777
 		{
1782
-	        self::$db->delete(self::LOCK_TABLE,array(
1778
+	        self::$db->delete(self::LOCK_TABLE, array(
1783 1779
 	        	'lock_path' => $result['path'],
1784 1780
 	        	'lock_token' => $result['token'],
1785
-	        ),__LINE__,__FILE__);
1781
+	        ), __LINE__, __FILE__);
1786 1782
 
1787
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1783
+			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s', $result['expires'])." --> removed");
1788 1784
 	        $result = false;
1789 1785
 		}
1790
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1786
+		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result ?array2string($result) : 'false'));
1791 1787
 		return self::$lock_cache[$path] = $result;
1792 1788
 	}
1793 1789
 
@@ -1798,10 +1794,10 @@  discard block
 block discarded – undo
1798 1794
 	 * @param array $content =null
1799 1795
 	 * @return array|boolean array with values for keys 'data','etemplate','name','label','help' or false if not supported by backend
1800 1796
 	 */
1801
-	static function getExtraInfo($path,array $content=null)
1797
+	static function getExtraInfo($path, array $content = null)
1802 1798
 	{
1803 1799
 		$extra = array();
1804
-		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))	// true = fail silent if backend does NOT support it
1800
+		if (($extra_info = self::_call_on_backend('extra_info', array($path, $content), true)))	// true = fail silent if backend does NOT support it
1805 1801
 		{
1806 1802
 			$extra[] = $extra_info;
1807 1803
 		}
@@ -1812,7 +1808,7 @@  discard block
 block discarded – undo
1812 1808
 			'content' => $content,
1813 1809
 		))))
1814 1810
 		{
1815
-			foreach($vfs_extra as $data)
1811
+			foreach ($vfs_extra as $data)
1816 1812
 			{
1817 1813
 				$extra = $extra ? array_merge($extra, $data) : $data;
1818 1814
 			}
@@ -1827,7 +1823,7 @@  discard block
 block discarded – undo
1827 1823
 	 * @param int|string $id
1828 1824
 	 * @return string
1829 1825
 	 */
1830
-	static function app_entry_lock_path($app,$id)
1826
+	static function app_entry_lock_path($app, $id)
1831 1827
 	{
1832 1828
 		return "/apps/$app/entry/$id";
1833 1829
 	}
@@ -1841,7 +1837,7 @@  discard block
 block discarded – undo
1841 1837
 		//'%' => '%25',	// % should be encoded, but easily leads to double encoding, therefore better NOT encodig it
1842 1838
 		'#' => '%23',
1843 1839
 		'?' => '%3F',
1844
-		'/' => '',	// better remove it completly
1840
+		'/' => '', // better remove it completly
1845 1841
 	);
1846 1842
 
1847 1843
 	/**
@@ -1856,7 +1852,7 @@  discard block
 block discarded – undo
1856 1852
 	 */
1857 1853
 	static public function encodePathComponent($component)
1858 1854
 	{
1859
-		return str_replace(array_keys(self::$encode),array_values(self::$encode),$component);
1855
+		return str_replace(array_keys(self::$encode), array_values(self::$encode), $component);
1860 1856
 	}
1861 1857
 
1862 1858
 	/**
@@ -1869,7 +1865,7 @@  discard block
 block discarded – undo
1869 1865
 	 */
1870 1866
 	static public function encodePath($path)
1871 1867
 	{
1872
-		return implode('/',self::encodePathComponent(explode('/',$path)));
1868
+		return implode('/', self::encodePathComponent(explode('/', $path)));
1873 1869
 	}
1874 1870
 
1875 1871
 	/**
@@ -1924,7 +1920,7 @@  discard block
 block discarded – undo
1924 1920
 		{
1925 1921
 			$image = Image::find($mime_sub, 'navbar');
1926 1922
 		}
1927
-		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
1923
+		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png', 'jpeg', 'jpg', 'gif', 'bmp')) &&
1928 1924
 		         (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1929 1925
 		         (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1930 1926
 		         ($stat = self::stat($file)) && $stat['size'] < 1500000)
@@ -1979,7 +1975,7 @@  discard block
 block discarded – undo
1979 1975
 	 * @param array& $copied =null on return files copied
1980 1976
 	 * @return boolean true for no errors, false otherwise
1981 1977
 	 */
1982
-	static public function copy_files(array $src, $dst, &$errs=null, array &$copied=null)
1978
+	static public function copy_files(array $src, $dst, &$errs = null, array &$copied = null)
1983 1979
 	{
1984 1980
 		if (self::is_dir($dst))
1985 1981
 		{
@@ -1997,7 +1993,7 @@  discard block
 block discarded – undo
1997 1993
 						if ($file !== $target)
1998 1994
 						{
1999 1995
 							// Create the target directory
2000
-							self::mkdir($target,null,STREAM_MKDIR_RECURSIVE);
1996
+							self::mkdir($target, null, STREAM_MKDIR_RECURSIVE);
2001 1997
 
2002 1998
 							$copied[] = $file;
2003 1999
 							$copied[] = $target; // < newly created folder must not be copied again!
@@ -2041,7 +2037,7 @@  discard block
 block discarded – undo
2041 2037
 		if (self::is_dir($dst))
2042 2038
 		{
2043 2039
 			$vfs = new Vfs\StreamWrapper();
2044
-			foreach($src as $file)
2040
+			foreach ($src as $file)
2045 2041
 			{
2046 2042
 				$target = self::concat($dst, self::basename($file));
2047 2043
 
@@ -2073,7 +2069,7 @@  discard block
 block discarded – undo
2073 2069
 	 * @param boolean $check_is_uploaded_file =true should method perform an is_uploaded_file check, default yes
2074 2070
 	 * @return boolean|array stat array on success, false on error
2075 2071
 	 */
2076
-	static public function copy_uploaded($src,$target,$props=null,$check_is_uploaded_file=true)
2072
+	static public function copy_uploaded($src, $target, $props = null, $check_is_uploaded_file = true)
2077 2073
 	{
2078 2074
 		$tmp_name = is_array($src) ? $src['tmp_name'] : $src;
2079 2075
 
@@ -2093,12 +2089,12 @@  discard block
 block discarded – undo
2093 2089
 		}
2094 2090
 		if ($props)
2095 2091
 		{
2096
-			if (!is_array($props)) $props = array(array('name' => 'comment','val' => $props));
2092
+			if (!is_array($props)) $props = array(array('name' => 'comment', 'val' => $props));
2097 2093
 
2098 2094
 			// if $props is name => value pairs, convert it to internal array or array with values for keys 'name', 'val' and optional 'ns'
2099 2095
 			if (!isset($props[0]))
2100 2096
 			{
2101
-				foreach($props as $name => $val)
2097
+				foreach ($props as $name => $val)
2102 2098
 				{
2103 2099
 					if (($name == 'comment' || $name[0] == '#') && $val)	// only copy 'comment' and cfs
2104 2100
 					{
@@ -2116,7 +2112,7 @@  discard block
 block discarded – undo
2116 2112
 			// set props before copying the file, so notifications already contain them
2117 2113
 			if (!self::stat($target))
2118 2114
 			{
2119
-				self::touch($target);	// create empty file, to be able to attach properties
2115
+				self::touch($target); // create empty file, to be able to attach properties
2120 2116
 				// tell vfs stream-wrapper to treat file in following copy as a new file notification-wises
2121 2117
 				$context = stream_context_create(array(
2122 2118
 					self::SCHEME => array('treat_as_new' => true)
@@ -2134,8 +2130,7 @@  discard block
 block discarded – undo
2134 2130
 		}
2135 2131
 		else
2136 2132
 		{
2137
-			$ret = ($context ? copy($tmp_name, self::PREFIX.$target, $context) :
2138
-				copy($tmp_name, self::PREFIX.$target)) ?
2133
+			$ret = ($context ? copy($tmp_name, self::PREFIX.$target, $context) : copy($tmp_name, self::PREFIX.$target)) ?
2139 2134
 				self::stat($target) : false;
2140 2135
 		}
2141 2136
 		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
@@ -2181,7 +2176,7 @@  discard block
 block discarded – undo
2181 2176
 	 * @param array|boolean &$stat=null on return: stat of existing file or false for non-existing files
2182 2177
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
2183 2178
 	 */
2184
-	static function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null)
2179
+	static function resolve_url_symlinks($_path, $file_exists = true, $resolve_last_symlink = true, &$stat = null)
2185 2180
 	{
2186 2181
 		$vfs = new Vfs\StreamWrapper();
2187 2182
 		return $vfs->resolve_url_symlinks($_path, $file_exists, $resolve_last_symlink, $stat);
@@ -2197,7 +2192,7 @@  discard block
 block discarded – undo
2197 2192
 	 * @param boolean $fix_url_query =false true append relativ path to url query parameter, default not
2198 2193
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
2199 2194
 	 */
2200
-	static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true,$fix_url_query=false)
2195
+	static function resolve_url($_path, $do_symlink = true, $use_symlinkcache = true, $replace_user_pass_host = true, $fix_url_query = false)
2201 2196
 	{
2202 2197
 		return Vfs\StreamWrapper::resolve_url($_path, $do_symlink, $use_symlinkcache, $replace_user_pass_host, $fix_url_query);
2203 2198
 	}
@@ -2213,7 +2208,7 @@  discard block
 block discarded – undo
2213 2208
 	 * @param boolean $recursive =false true: create missing parents too
2214 2209
 	 * @return boolean TRUE on success or FALSE on failure
2215 2210
 	 */
2216
-	static function mkdir ($path, $mode=0750, $recursive=false)
2211
+	static function mkdir($path, $mode = 0750, $recursive = false)
2217 2212
 	{
2218 2213
 		return $path[0] == '/' && mkdir(self::PREFIX.$path, $mode, $recursive);
2219 2214
 	}
@@ -2242,7 +2237,7 @@  discard block
 block discarded – undo
2242 2237
 	 * @param string $path
2243 2238
 	 * @return boolean TRUE on success or FALSE on failure
2244 2239
 	 */
2245
-	static function unlink ( $path )
2240
+	static function unlink($path)
2246 2241
 	{
2247 2242
 		return $path[0] == '/' && unlink(self::PREFIX.$path);
2248 2243
 	}
@@ -2259,60 +2254,60 @@  discard block
 block discarded – undo
2259 2254
 	 * @param int $path_param_key =0 key in params containing the path, default 0
2260 2255
 	 * @return mixed return value of backend or false if function does not exist on backend
2261 2256
 	 */
2262
-	static protected function _call_on_backend($name,$params,$fail_silent=false,$path_param_key=0)
2257
+	static protected function _call_on_backend($name, $params, $fail_silent = false, $path_param_key = 0)
2263 2258
 	{
2264 2259
 		$pathes = $params[$path_param_key];
2265 2260
 
2266 2261
 		$scheme2urls = array();
2267
-		foreach(is_array($pathes) ? $pathes : array($pathes) as $path)
2262
+		foreach (is_array($pathes) ? $pathes : array($pathes) as $path)
2268 2263
 		{
2269
-			if (!($url = self::resolve_url_symlinks($path,false,false)))
2264
+			if (!($url = self::resolve_url_symlinks($path, false, false)))
2270 2265
 			{
2271 2266
 				return false;
2272 2267
 			}
2273
-			$k=(string)self::parse_url($url,PHP_URL_SCHEME);
2268
+			$k = (string)self::parse_url($url, PHP_URL_SCHEME);
2274 2269
 			if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array();
2275 2270
 			$scheme2urls[$k][$path] = $url;
2276 2271
 		}
2277 2272
 		$ret = array();
2278
-		foreach($scheme2urls as $scheme => $urls)
2273
+		foreach ($scheme2urls as $scheme => $urls)
2279 2274
 		{
2280 2275
 			if ($scheme)
2281 2276
 			{
2282
-				if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name))
2277
+				if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class, $name))
2283 2278
 				{
2284
-					if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
2279
+					if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n", E_USER_WARNING);
2285 2280
 					return false;
2286 2281
 				}
2287 2282
 				if (!is_array($pathes))
2288 2283
 				{
2289 2284
 					$params[$path_param_key] = $url;
2290 2285
 
2291
-					return call_user_func_array(array($class,$name),$params);
2286
+					return call_user_func_array(array($class, $name), $params);
2292 2287
 				}
2293 2288
 				$params[$path_param_key] = $urls;
2294
-				if (!is_array($r = call_user_func_array(array($class,$name),$params)))
2289
+				if (!is_array($r = call_user_func_array(array($class, $name), $params)))
2295 2290
 				{
2296 2291
 					return $r;
2297 2292
 				}
2298 2293
 				// we need to re-translate the urls to pathes, as they can eg. contain symlinks
2299
-				foreach($urls as $path => $url)
2294
+				foreach ($urls as $path => $url)
2300 2295
 				{
2301
-					if (isset($r[$url]) || isset($r[$url=self::parse_url($url,PHP_URL_PATH)]))
2296
+					if (isset($r[$url]) || isset($r[$url = self::parse_url($url, PHP_URL_PATH)]))
2302 2297
 					{
2303 2298
 						$ret[$path] = $r[$url];
2304 2299
 					}
2305 2300
 				}
2306 2301
 			}
2307 2302
 			// call the filesystem specific function (dont allow to use arrays!)
2308
-			elseif(!function_exists($name) || is_array($pathes))
2303
+			elseif (!function_exists($name) || is_array($pathes))
2309 2304
 			{
2310 2305
 				return false;
2311 2306
 			}
2312 2307
 			else
2313 2308
 			{
2314 2309
 				$time = null;
2315
-				return $name($url,$time);
2310
+				return $name($url, $time);
2316 2311
 			}
2317 2312
 		}
2318 2313
 		return $ret;
@@ -2326,7 +2321,7 @@  discard block
 block discarded – undo
2326 2321
 	 * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs!
2327 2322
 	 * @return boolean true on success, false otherwise
2328 2323
 	 */
2329
-	static function touch($path,$time=null,$atime=null)
2324
+	static function touch($path, $time = null, $atime = null)
2330 2325
 	{
2331 2326
 		return $path[0] == '/' && touch(self::PREFIX.$path, $time, $atime);
2332 2327
 	}
@@ -2340,7 +2335,7 @@  discard block
 block discarded – undo
2340 2335
 	 * @param string $mode mode string see Vfs::mode2int
2341 2336
 	 * @return boolean true on success, false otherwise
2342 2337
 	 */
2343
-	static function chmod($path,$mode)
2338
+	static function chmod($path, $mode)
2344 2339
 	{
2345 2340
 		return $path[0] == '/' && chmod(self::PREFIX.$path, $mode);
2346 2341
 	}
@@ -2354,7 +2349,7 @@  discard block
 block discarded – undo
2354 2349
 	 * @param int|string $owner numeric user id or account-name
2355 2350
 	 * @return boolean true on success, false otherwise
2356 2351
 	 */
2357
-	static function chown($path,$owner)
2352
+	static function chown($path, $owner)
2358 2353
 	{
2359 2354
 		return $path[0] == '/' && chown(self::PREFIX.$path, is_numeric($owner) ? abs($owner) : $owner);
2360 2355
 	}
@@ -2368,7 +2363,7 @@  discard block
 block discarded – undo
2368 2363
 	 * @param int|string $group numeric group id or group-name
2369 2364
 	 * @return boolean true on success, false otherwise
2370 2365
 	 */
2371
-	static function chgrp($path,$group)
2366
+	static function chgrp($path, $group)
2372 2367
 	{
2373 2368
 		return $path[0] == '/' && chgrp(self::PREFIX.$path, is_numeric($group) ? abs($group) : $group);
2374 2369
 	}
@@ -2383,7 +2378,7 @@  discard block
 block discarded – undo
2383 2378
 	 */
2384 2379
 	static function readlink($path)
2385 2380
 	{
2386
-		$ret = self::_call_on_backend('readlink',array($path),true);	// true = fail silent, if backend does not support readlink
2381
+		$ret = self::_call_on_backend('readlink', array($path), true); // true = fail silent, if backend does not support readlink
2387 2382
 		//error_log(__METHOD__."('$path') returning ".array2string($ret).' '.function_backtrace());
2388 2383
 		return $ret;
2389 2384
 	}
@@ -2397,9 +2392,9 @@  discard block
 block discarded – undo
2397 2392
 	 * @param string $link path of the link to create
2398 2393
 	 * @return boolean true on success, false on error
2399 2394
 	 */
2400
-	static function symlink($target,$link)
2395
+	static function symlink($target, $link)
2401 2396
 	{
2402
-		if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1)))	// 1=path is in $link!
2397
+		if (($ret = self::_call_on_backend('symlink', array($target, $link), false, 1)))	// 1=path is in $link!
2403 2398
 		{
2404 2399
 			Vfs\StreamWrapper::symlinkCache_remove($link);
2405 2400
 		}
@@ -2419,13 +2414,13 @@  discard block
 block discarded – undo
2419 2414
 	 * @param boolean $recheck =false true = do a new check, false = rely on stored mime type (if existing)
2420 2415
 	 * @return string mime-type (self::DIR_MIME_TYPE for directories)
2421 2416
 	 */
2422
-	static function mime_content_type($path,$recheck=false)
2417
+	static function mime_content_type($path, $recheck = false)
2423 2418
 	{
2424 2419
 		if (!($url = self::resolve_url_symlinks($path)))
2425 2420
 		{
2426 2421
 			return false;
2427 2422
 		}
2428
-		if (($scheme = self::parse_url($url,PHP_URL_SCHEME)) && !$recheck)
2423
+		if (($scheme = self::parse_url($url, PHP_URL_SCHEME)) && !$recheck)
2429 2424
 		{
2430 2425
 			// check it it's an eGW stream wrapper returning mime-type via url_stat
2431 2426
 			// we need to first check if the constant is defined, as we get a fatal error in php5.3 otherwise
@@ -2434,7 +2429,7 @@  discard block
 block discarded – undo
2434 2429
 				($mime_attr = constant($class.'::STAT_RETURN_MIME_TYPE')))
2435 2430
 			{
2436 2431
 				$inst = new $class;
2437
-				$stat = $inst->url_stat(self::parse_url($url,PHP_URL_PATH),0);
2432
+				$stat = $inst->url_stat(self::parse_url($url, PHP_URL_PATH), 0);
2438 2433
 				if ($stat && $stat[$mime_attr])
2439 2434
 				{
2440 2435
 					$mime = $stat[$mime_attr];
@@ -2453,7 +2448,7 @@  discard block
 block discarded – undo
2453 2448
 		// using EGw's own mime magic (currently only checking the extension!)
2454 2449
 		if (!$mime)
2455 2450
 		{
2456
-			$mime = MimeMagic::filename2mime(self::parse_url($url,PHP_URL_PATH));
2451
+			$mime = MimeMagic::filename2mime(self::parse_url($url, PHP_URL_PATH));
2457 2452
 		}
2458 2453
 		//error_log(__METHOD__."($path,$recheck) mime=$mime");
2459 2454
 		return $mime;
@@ -2483,7 +2478,7 @@  discard block
 block discarded – undo
2483 2478
 	 *
2484 2479
 	 * @param string $path ='/' path of backend, whos cache to clear
2485 2480
 	 */
2486
-	static function clearstatcache($path='/')
2481
+	static function clearstatcache($path = '/')
2487 2482
 	{
2488 2483
 		//error_log(__METHOD__."('$path')");
2489 2484
 		Vfs\StreamWrapper::clearstatcache($path);
@@ -2503,7 +2498,7 @@  discard block
 block discarded – undo
2503 2498
 	 * @param string $path_to
2504 2499
 	 * @return boolean TRUE on success or FALSE on failure
2505 2500
 	 */
2506
-	static function rename ( $path_from, $path_to )
2501
+	static function rename($path_from, $path_to)
2507 2502
 	{
2508 2503
 		$vfs = new Vfs\StreamWrapper();
2509 2504
 		return $vfs->rename($path_from, $path_to);
Please login to merge, or discard this patch.
api/src/Framework.php 5 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 	var $template_dirs = array();
63 63
 
64 64
 	/**
65
-	* true if $this->header() was called
66
-	*
67
-	* @var boolean
68
-	*/
65
+	 * true if $this->header() was called
66
+	 *
67
+	 * @var boolean
68
+	 */
69 69
 	static $header_done = false;
70 70
 	/**
71
-	* true if $this->navbar() was called
72
-	*
73
-	* @var boolean
74
-	*/
71
+	 * true if $this->navbar() was called
72
+	 *
73
+	 * @var boolean
74
+	 */
75 75
 	static $navbar_done = false;
76 76
 
77 77
 	/**
@@ -1044,13 +1044,13 @@  discard block
 block discarded – undo
1044 1044
 	}
1045 1045
 
1046 1046
 	/**
1047
-	* Compile entries for topmenu:
1048
-	* - regular items: links
1049
-	* - info items
1050
-	*
1051
-	* @param array $vars
1052
-	* @param array $apps
1053
-	*/
1047
+	 * Compile entries for topmenu:
1048
+	 * - regular items: links
1049
+	 * - info items
1050
+	 *
1051
+	 * @param array $vars
1052
+	 * @param array $apps
1053
+	 */
1054 1054
 	function topmenu(array $vars,array $apps)
1055 1055
 	{
1056 1056
 		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
@@ -1154,39 +1154,39 @@  discard block
 block discarded – undo
1154 1154
 	}
1155 1155
 
1156 1156
 	/**
1157
-	* Add menu items to the topmenu template class to be displayed
1158
-	*
1159
-	* @param array $app application data
1160
-	* @param mixed $alt_label string with alternative menu item label default value = null
1161
-	* @param string $urlextra string with alternate additional code inside <a>-tag
1162
-	* @access protected
1163
-	* @return void
1164
-	*/
1157
+	 * Add menu items to the topmenu template class to be displayed
1158
+	 *
1159
+	 * @param array $app application data
1160
+	 * @param mixed $alt_label string with alternative menu item label default value = null
1161
+	 * @param string $urlextra string with alternate additional code inside <a>-tag
1162
+	 * @access protected
1163
+	 * @return void
1164
+	 */
1165 1165
 	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1166 1166
 
1167 1167
 	/**
1168
-	* Add info items to the topmenu template class to be displayed
1169
-	*
1170
-	* @param string $content Html of item
1171
-	* @param string $id =null
1172
-	* @access protected
1173
-	* @return void
1174
-	*/
1168
+	 * Add info items to the topmenu template class to be displayed
1169
+	 *
1170
+	 * @param string $content Html of item
1171
+	 * @param string $id =null
1172
+	 * @access protected
1173
+	 * @return void
1174
+	 */
1175 1175
 	abstract function _add_topmenu_info_item($content, $id=null);
1176 1176
 
1177 1177
 	static $top_menu_extra = array();
1178 1178
 
1179 1179
 	/**
1180
-	* Called by hooks to add an entry in the topmenu location.
1181
-	* Extra entries will be added just before Logout.
1182
-	*
1183
-	* @param string $id unique element id
1184
-	* @param string $url Address for the entry to link to
1185
-	* @param string $title Text displayed for the entry
1186
-	* @param string $target Optional, so the entry can open in a new page or popup
1187
-	* @access public
1188
-	* @return void
1189
-	*/
1180
+	 * Called by hooks to add an entry in the topmenu location.
1181
+	 * Extra entries will be added just before Logout.
1182
+	 *
1183
+	 * @param string $id unique element id
1184
+	 * @param string $url Address for the entry to link to
1185
+	 * @param string $title Text displayed for the entry
1186
+	 * @param string $target Optional, so the entry can open in a new page or popup
1187
+	 * @access public
1188
+	 * @return void
1189
+	 */
1190 1190
 	public static function add_topmenu_item($id,$url,$title,$target = '')
1191 1191
 	{
1192 1192
 		$entry['name'] = $id;
@@ -1198,16 +1198,16 @@  discard block
 block discarded – undo
1198 1198
 	}
1199 1199
 
1200 1200
 	/**
1201
-	* called by hooks to add an icon in the topmenu info location
1202
-	*
1203
-	* @param string $id unique element id
1204
-	* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
1205
-	* @param string $iconlink where the icon links to
1206
-	* @param booleon $blink set true to make the icon blink
1207
-	* @param mixed $tooltip string containing the tooltip html, or null of no tooltip
1208
-	* @access public
1209
-	* @return void
1210
-	*/
1201
+	 * called by hooks to add an icon in the topmenu info location
1202
+	 *
1203
+	 * @param string $id unique element id
1204
+	 * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
1205
+	 * @param string $iconlink where the icon links to
1206
+	 * @param booleon $blink set true to make the icon blink
1207
+	 * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
1208
+	 * @access public
1209
+	 * @return void
1210
+	 */
1211 1211
 	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1212 1212
 
1213 1213
 	/**
@@ -1242,19 +1242,19 @@  discard block
 block discarded – undo
1242 1242
 	protected static $js_include_mgr;
1243 1243
 
1244 1244
 	/**
1245
-	* Checks to make sure a valid package and file name is provided
1246
-	*
1247
-	* Example call syntax:
1248
-	* a) Api\Framework::includeJS('jscalendar','calendar')
1249
-	*    --> /phpgwapi/js/jscalendar/calendar.js
1250
-	* b) Api\Framework::includeJS('/phpgwapi/inc/calendar-setup.js',array('lang'=>'de'))
1251
-	*    --> /phpgwapi/inc/calendar-setup.js?lang=de
1252
-	*
1253
-	* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1254
-	* @param string|array $file =null file to be included - no ".js" on the end or array with get params
1255
-	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1256
-	* @param boolean $append =true should the file be added
1257
-	*/
1245
+	 * Checks to make sure a valid package and file name is provided
1246
+	 *
1247
+	 * Example call syntax:
1248
+	 * a) Api\Framework::includeJS('jscalendar','calendar')
1249
+	 *    --> /phpgwapi/js/jscalendar/calendar.js
1250
+	 * b) Api\Framework::includeJS('/phpgwapi/inc/calendar-setup.js',array('lang'=>'de'))
1251
+	 *    --> /phpgwapi/inc/calendar-setup.js?lang=de
1252
+	 *
1253
+	 * @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1254
+	 * @param string|array $file =null file to be included - no ".js" on the end or array with get params
1255
+	 * @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1256
+	 * @param boolean $append =true should the file be added
1257
+	 */
1258 1258
 	static function includeJS($package, $file=null, $app='phpgwapi')
1259 1259
 	{
1260 1260
 		self::$js_include_mgr->include_js_file($package, $file, $app);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 */
355 355
 	public function _get_footer()
356 356
 	{
357
-		$var = Array(
357
+		$var = array(
358 358
 			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
359 359
 			'version'        => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
360 360
 		);
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 
764 764
 				$icon = isset($data['icon']) ?  $data['icon'] : 'navbar';
765 765
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
766
-				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,Array($icon,'nonav'),'',$svg);
766
+				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,array($icon,'nonav'),'',$svg);
767 767
 			}
768 768
 		}
769 769
 
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 		// We handle this here because its special
797 797
 		$apps['about']['title'] = 'EGroupware';
798 798
 		$apps['about']['url']   = self::link('/about.php');
799
-		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',Array('about','nonav'));
799
+		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',array('about','nonav'));
800 800
 		$apps['about']['name']  = 'about';
801 801
 
802 802
 		$apps['logout']['title'] = lang('Logout');
803 803
 		$apps['logout']['name']  = 'logout';
804 804
 		$apps['logout']['url']   = self::link('/logout.php');
805
-		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',Array('logout','nonav'));
805
+		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',array('logout','nonav'));
806 806
 
807 807
 		return $apps;
808 808
 	}
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,6 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Constructor
79 79
 	 *
80 80
 	 * The constructor instanciates the class in $GLOBALS['egw']->framework, from where it should be used
81
+	 * @param string $template
81 82
 	 */
82 83
 	function __construct($template)
83 84
 	{
@@ -564,7 +565,7 @@  discard block
 block discarded – undo
564 565
 	/**
565 566
 	 * Returns Html with user and time
566 567
 	 *
567
-	 * @return void
568
+	 * @return string
568 569
 	 */
569 570
 	protected static function _user_time_info()
570 571
 	{
@@ -993,7 +994,6 @@  discard block
 block discarded – undo
993 994
 	 *
994 995
 	 * Themes are css file in the template directory
995 996
 	 *
996
-	 * @param string $themes_dir ='css'
997 997
 	 */
998 998
 	function list_themes()
999 999
 	{
@@ -1184,11 +1184,6 @@  discard block
 block discarded – undo
1184 1184
 	/**
1185 1185
 	* Add menu items to the topmenu template class to be displayed
1186 1186
 	*
1187
-	* @param array $app application data
1188
-	* @param mixed $alt_label string with alternative menu item label default value = null
1189
-	* @param string $urlextra string with alternate additional code inside <a>-tag
1190
-	* @access protected
1191
-	* @return void
1192 1187
 	*/
1193 1188
 	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1194 1189
 
@@ -1281,7 +1276,6 @@  discard block
 block discarded – undo
1281 1276
 	* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1282 1277
 	* @param string|array $file =null file to be included - no ".js" on the end or array with get params
1283 1278
 	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1284
-	* @param boolean $append =true should the file be added
1285 1279
 	*/
1286 1280
 	static function includeJS($package, $file=null, $app='phpgwapi')
1287 1281
 	{
@@ -1442,7 +1436,7 @@  discard block
 block discarded – undo
1442 1436
 	 * @param string $action "add" or "delete"
1443 1437
 	 * @param boolean|int|string $group ID of the group to create the favorite for, or 'all' for all users
1444 1438
 	 * @param array $filters =array() key => value pairs for the filter
1445
-	 * @return boolean Success
1439
+	 * @return boolean|null Success
1446 1440
 	 */
1447 1441
 	public static function ajax_set_favorite($app, $name, $action, $group, $filters = array())
1448 1442
 	{
Please login to merge, or discard this patch.
Braces   +54 added lines, -15 removed lines patch added patch discarded remove patch
@@ -222,7 +222,10 @@  discard block
 block discarded – undo
222 222
 		}
223 223
 
224 224
 		// commit session (if existing), to fix timing problems sometimes preventing session creation ("Your session can not be verified")
225
-		if (isset($GLOBALS['egw']->session)) $GLOBALS['egw']->session->commit_session();
225
+		if (isset($GLOBALS['egw']->session))
226
+		{
227
+			$GLOBALS['egw']->session->commit_session();
228
+		}
226 229
 
227 230
 		exit;
228 231
 	}
@@ -252,8 +255,14 @@  discard block
 block discarded – undo
252 255
 	 */
253 256
 	function render($content,$app_header=null,$navbar=null)
254 257
 	{
255
-		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
256
-		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
258
+		if (!is_null($app_header))
259
+		{
260
+			$GLOBALS['egw_info']['flags']['app_header'] = $app_header;
261
+		}
262
+		if (!is_null($navbar))
263
+		{
264
+			$GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
265
+		}
257 266
 
258 267
 		echo $this->header();
259 268
 
@@ -450,7 +459,10 @@  discard block
 block discarded – undo
450 459
 		// send appheader to clientside
451 460
 		$extra['app-header'] = $app_header;
452 461
 
453
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
462
+		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki')
463
+		{
464
+			$robots ='<meta name="robots" content="none" />';
465
+		}
454 466
 
455 467
 		if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
456 468
 		{
@@ -692,13 +704,19 @@  discard block
 block discarded – undo
692 704
 		$ind_b = isset($arr[$b['name']]) ? $arr[$b['name']] : null;
693 705
 
694 706
 		if ($ind_a == $ind_b)
695
-			return 0;
707
+		{
708
+					return 0;
709
+		}
696 710
 
697 711
 		if ($ind_a == null)
698
-			return -1;
712
+		{
713
+					return -1;
714
+		}
699 715
 
700 716
 		if ($ind_b == null)
701
-			return 1;
717
+		{
718
+					return 1;
719
+		}
702 720
 
703 721
 		return $ind_a > $ind_b ? 1 : -1;
704 722
 	}
@@ -787,9 +805,12 @@  discard block
 block discarded – undo
787 805
 			$app_title = $GLOBALS['egw_info']['apps'][$app]['title'];
788 806
 		}
789 807
 
790
-		if ($GLOBALS['egw_info']['user']['apps']['preferences'])	// Preferences last
808
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
809
+		{
810
+			// Preferences last
791 811
 		{
792 812
 			$prefs = $apps['preferences'];
813
+		}
793 814
 			unset($apps['preferences']);
794 815
 			$apps['preferences'] = $prefs;
795 816
 		}
@@ -839,7 +860,10 @@  discard block
 block discarded – undo
839 860
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
840 861
 			foreach($themes_to_check as $theme_css)
841 862
 			{
842
-				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
863
+				if (file_exists(EGW_SERVER_ROOT.$theme_css))
864
+				{
865
+					break;
866
+				}
843 867
 			}
844 868
 			$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
845 869
 			if (!$debug_minify && file_exists(EGW_SERVER_ROOT.($theme_min_css = str_replace('.css', '.min.css', $theme_css))))
@@ -929,7 +953,9 @@  discard block
 block discarded – undo
929 953
 		}
930 954
 
931 955
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
932
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
956
+		$extra['include'] = array_map(function($str)
957
+		{
958
+return substr($str,1);}, self::get_script_links(true), array(1));
933 959
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
934 960
 
935 961
 		// Load LABjs ONCE here
@@ -941,7 +967,10 @@  discard block
 block discarded – undo
941 967
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
942 968
 		foreach($extra+self::$extra as $name => $value)
943 969
 		{
944
-			if (is_array($value)) $value = json_encode($value);
970
+			if (is_array($value))
971
+			{
972
+				$value = json_encode($value);
973
+			}
945 974
 			// we need to double encode (Html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
946 975
 			$java_script .= ' data-'.$name."=\"". Html::htmlspecialchars($value, true)."\"";
947 976
 		}
@@ -991,7 +1020,10 @@  discard block
 block discarded – undo
991 1020
 				if (preg_match('/'."\.css$".'/i', $file))
992 1021
 				{
993 1022
 					list($name) = explode('.',$file);
994
-					if (!isset($list[$name])) $list[$name] = ucfirst ($name);
1023
+					if (!isset($list[$name]))
1024
+					{
1025
+						$list[$name] = ucfirst ($name);
1026
+					}
995 1027
 				}
996 1028
 			}
997 1029
 			closedir($dh);
@@ -1070,7 +1102,8 @@  discard block
 block discarded – undo
1070 1102
 
1071 1103
 		Hooks::process('topmenu_info',array(),true);
1072 1104
 		// Add extra items added by hooks
1073
-		foreach(self::$top_menu_extra as $extra_item) {
1105
+		foreach(self::$top_menu_extra as $extra_item)
1106
+		{
1074 1107
 			$this->_add_topmenu_item($extra_item);
1075 1108
 		}
1076 1109
 
@@ -1095,7 +1128,10 @@  discard block
 block discarded – undo
1095 1128
 	protected function add_preferences_topmenu($type='prefs')
1096 1129
 	{
1097 1130
 		static $memberships=null;
1098
-		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1131
+		if (!isset($memberships))
1132
+		{
1133
+			$memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1134
+		}
1099 1135
 		static $types = array(
1100 1136
 			'prefs' => array(
1101 1137
 				'title' => 'Preferences',
@@ -1123,7 +1159,10 @@  discard block
 block discarded – undo
1123 1159
 			// as all apps answer, we need to remove none-true responses
1124 1160
 			foreach($apps as $app => $val)
1125 1161
 			{
1126
-				if (!$val) unset($apps[$app]);
1162
+				if (!$val)
1163
+				{
1164
+					unset($apps[$app]);
1165
+				}
1127 1166
 			}
1128 1167
 		}
1129 1168
 		else
Please login to merge, or discard this patch.
Spacing   +114 added lines, -115 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			$GLOBALS['egw_info']['server']['template_set'] = 'jdots';
117 117
 		}
118 118
 		// eg. "default" is only used for login at the moment
119
-		if (!class_exists($class=$GLOBALS['egw_info']['server']['template_set'].'_framework'))
119
+		if (!class_exists($class = $GLOBALS['egw_info']['server']['template_set'].'_framework'))
120 120
 		{
121 121
 			$class = __CLASS__.'\\Minimal';
122 122
 		}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		Header\ContentSecurityPolicy::send();
135 135
 
136 136
 		// allow client-side to detect first load aka just logged in
137
-		$reload_count =& Cache::getSession(__CLASS__, 'framework-reload');
137
+		$reload_count = & Cache::getSession(__CLASS__, 'framework-reload');
138 138
 		self::$extra['framework-reload'] = (int)(bool)$reload_count++;
139 139
 	}
140 140
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
165 165
 	 * @return string	The full url after processing
166 166
 	 */
167
-	static function link($url, $extravars = '', $link_app=null)
167
+	static function link($url, $extravars = '', $link_app = null)
168 168
 	{
169
-		unset($link_app);	// not used by required by function signature
169
+		unset($link_app); // not used by required by function signature
170 170
 		return $GLOBALS['egw']->session->link($url, $extravars);
171 171
 	}
172 172
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param string $url url to redirect to
179 179
 	 * @param string $link_app =null appname to redirect for, default currentapp
180 180
 	 */
181
-	static function redirect($url, $link_app=null)
181
+	static function redirect($url, $link_app = null)
182 182
 	{
183 183
 		// Determines whether the current output buffer should be flushed
184 184
 		$do_flush = true;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		else
201 201
 		{
202 202
 			$file = $line = null;
203
-			if (headers_sent($file,$line))
203
+			if (headers_sent($file, $line))
204 204
 			{
205 205
 				throw new Exception\AssertionFailed(__METHOD__."('".htmlspecialchars($url)."') can NOT redirect, output already started at $file line $line!");
206 206
 			}
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
236 236
 	 * @return string	The full url after processing
237 237
 	 */
238
-	static function redirect_link($url, $extravars='', $link_app=null)
238
+	static function redirect_link($url, $extravars = '', $link_app = null)
239 239
 	{
240 240
 		self::redirect(self::link($url, $extravars), $link_app);
241 241
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * @param string $navbar =null show the navigation, default !$GLOBALS['egw_info']['flags']['nonavbar'], false gives a typical popu
251 251
 	 *
252 252
 	 */
253
-	function render($content,$app_header=null,$navbar=null)
253
+	function render($content, $app_header = null, $navbar = null)
254 254
 	{
255 255
 		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
256 256
 		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @return string with Html
273 273
 	 */
274
-	abstract function header(array $extra=array());
274
+	abstract function header(array $extra = array());
275 275
 
276 276
 	/**
277 277
 	 * Returns the Html from the body-tag til the main application area (incl. opening div tag)
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true
292 292
 	 * @return boolean
293 293
 	 */
294
-	abstract function isTop($consider_navbar_not_yet_called_as_true=true);
294
+	abstract function isTop($consider_navbar_not_yet_called_as_true = true);
295 295
 
296 296
 	/**
297 297
 	 * Returns the content of one sidebox
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 * @param array $file
302 302
 	 * @param string $type =null 'admin', 'preferences', 'favorites', ...
303 303
 	 */
304
-	abstract function sidebox($appname,$menu_title,$file,$type=null);
304
+	abstract function sidebox($appname, $menu_title, $file, $type = null);
305 305
 
306 306
 	/**
307 307
 	 * Returns the Html from the closing div of the main application area to the closing html-tag
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @param string $extra_vars for login url
317 317
 	 * @param string $change_passwd =null string with message to render input fields for password change
318 318
 	 */
319
-	function login_screen($extra_vars, $change_passwd=null)
319
+	function login_screen($extra_vars, $change_passwd = null)
320 320
 	{
321 321
 		(new Framework\Login($this))->screen($extra_vars, $change_passwd);
322 322
 	}
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	public function _get_footer()
355 355
 	{
356 356
 		$var = Array(
357
-			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
357
+			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images',
358 358
 			'version'        => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
359 359
 		);
360 360
 		$var['page_generation_time'] = '';
361
-		if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
361
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
362 362
 		{
363 363
 			$times = self::get_page_generation_time();
364 364
 
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
 	static public function _get_body_attribs()
399 399
 	{
400 400
 		$js = '';
401
-		foreach(self::$body_tags as $what => $data)
401
+		foreach (self::$body_tags as $what => $data)
402 402
 		{
403 403
 			if (!empty($data))
404 404
 			{
405
-				if($what == 'onLoad')
405
+				if ($what == 'onLoad')
406 406
 				{
407
-					$js .= 'onLoad="egw_LAB.wait(function() {'. htmlspecialchars($data).'})"';
407
+					$js .= 'onLoad="egw_LAB.wait(function() {'.htmlspecialchars($data).'})"';
408 408
 					continue;
409 409
 				}
410
-				$js .= ' '.$what.'="' . htmlspecialchars($data) . '"';
410
+				$js .= ' '.$what.'="'.htmlspecialchars($data).'"';
411 411
 			}
412 412
 		}
413 413
 		return $js;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
420 420
 	 * @return array
421 421
 	 */
422
-	protected function _get_header(array $extra=array())
422
+	protected function _get_header(array $extra = array())
423 423
 	{
424 424
 		// display password expires in N days message once per session
425 425
 		$message = null;
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		}
431 431
 
432 432
 		// get used language code (with a little xss check, if someone tries to sneak something in)
433
-		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$GLOBALS['egw_info']['user']['preferences']['common']['lang']))
433
+		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $GLOBALS['egw_info']['user']['preferences']['common']['lang']))
434 434
 		{
435 435
 			$lang_code = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
436 436
 		}
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 		// send appheader to clientside
451 451
 		$extra['app-header'] = $app_header;
452 452
 
453
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
453
+		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots = '<meta name="robots" content="none" />';
454 454
 
455
-		if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
455
+		if (substr($GLOBALS['egw_info']['server']['favicon_file'], 0, 4) == 'http')
456 456
 		{
457 457
 			$var['favicon_file'] = $GLOBALS['egw_info']['server']['favicon_file'];
458 458
 		}
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 			$include_wz_tooltip = '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].
469 469
 				$wz_tooltip.'?'.filemtime(EGW_SERVER_ROOT.$wz_tooltip).'" type="text/javascript"></script>';
470 470
 		}
471
-		return $this->_get_css()+array(
471
+		return $this->_get_css() + array(
472 472
 			'img_icon'			=> $var['favicon_file'],
473 473
 			'img_shortcut'		=> $var['favicon_file'],
474 474
 			'pngfix'        	=> $pngfix,
@@ -492,15 +492,15 @@  discard block
 block discarded – undo
492 492
 	 */
493 493
 	protected function _get_navbar($apps)
494 494
 	{
495
-		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images';
495
+		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/'.$this->template.'/images';
496 496
 
497
-		if(isset($GLOBALS['egw_info']['flags']['app_header']))
497
+		if (isset($GLOBALS['egw_info']['flags']['app_header']))
498 498
 		{
499 499
 			$var['current_app_title'] = $GLOBALS['egw_info']['flags']['app_header'];
500 500
 		}
501 501
 		else
502 502
 		{
503
-			$var['current_app_title']=$apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
503
+			$var['current_app_title'] = $apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
504 504
 		}
505 505
 		$var['currentapp'] = $GLOBALS['egw_info']['flags']['currentapp'];
506 506
 
@@ -512,32 +512,32 @@  discard block
 block discarded – undo
512 512
 
513 513
 		$var['user_info'] = $this->_user_time_info();
514 514
 
515
-		if($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
515
+		if ($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
516 516
 		{
517 517
 			$api_messages = lang('You are required to change your password during your first login').'<br />'.
518
-				lang('Click this image on the navbar: %1','<img src="'.Image::find('preferences','navbar.gif').'">');
518
+				lang('Click this image on the navbar: %1', '<img src="'.Image::find('preferences', 'navbar.gif').'">');
519 519
 		}
520
-		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']))
520
+		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']))
521 521
 		{
522
-			$api_messages = lang('it has been more then %1 days since you changed your password',$GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
522
+			$api_messages = lang('it has been more then %1 days since you changed your password', $GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
523 523
 		}
524 524
 
525
-		if (substr($GLOBALS['egw_info']['server']['login_logo_file'],0,4) == 'http' ||
525
+		if (substr($GLOBALS['egw_info']['server']['login_logo_file'], 0, 4) == 'http' ||
526 526
 			$GLOBALS['egw_info']['server']['login_logo_file'][0] == '/')
527 527
 		{
528 528
 			$var['logo_file'] = $GLOBALS['egw_info']['server']['login_logo_file'];
529 529
 		}
530 530
 		else
531 531
 		{
532
-			$var['logo_file'] = Image::find('phpgwapi',$GLOBALS['egw_info']['server']['login_logo_file']?$GLOBALS['egw_info']['server']['login_logo_file']:'logo', '', null);	// null=explicit allow svg
532
+			$var['logo_file'] = Image::find('phpgwapi', $GLOBALS['egw_info']['server']['login_logo_file'] ? $GLOBALS['egw_info']['server']['login_logo_file'] : 'logo', '', null); // null=explicit allow svg
533 533
 		}
534
-		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
534
+		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url'] ? $GLOBALS['egw_info']['server']['login_logo_url'] : 'http://www.eGroupWare.org';
535 535
 
536
-		if (substr($var['logo_url'],0,4) != 'http')
536
+		if (substr($var['logo_url'], 0, 4) != 'http')
537 537
 		{
538 538
 			$var['logo_url'] = 'http://'.$var['logo_url'];
539 539
 		}
540
-		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
540
+		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title'] ? $GLOBALS['egw_info']['server']['login_logo_title'] : 'www.eGroupWare.org';
541 541
 
542 542
 		return $var;
543 543
 	}
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
 	protected static function _user_time_info()
551 551
 	{
552 552
 		$now = new DateTime();
553
-		$user_info = '<b>'.Accounts::format_username() .'</b>'. ' - ' . lang($now->format('l')) . ' ' . $now->format(true);
553
+		$user_info = '<b>'.Accounts::format_username().'</b>'.' - '.lang($now->format('l')).' '.$now->format(true);
554 554
 
555 555
 		$user_tzs = DateTime::getUserTimezones();
556 556
 		if (count($user_tzs) > 1)
557 557
 		{
558 558
 			$tz = $GLOBALS['egw_info']['user']['preferences']['common']['tz'];
559
-			$user_info .= Html::form(Html::select('tz',$tz,$user_tzs,true),array(),
560
-				'/index.php','','tz_selection',' style="display: inline;"','GET');
559
+			$user_info .= Html::form(Html::select('tz', $tz, $user_tzs, true), array(),
560
+				'/index.php', '', 'tz_selection', ' style="display: inline;"', 'GET');
561 561
 		}
562 562
 		return $user_info;
563 563
 	}
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
 	 */
570 570
 	protected static function _current_users()
571 571
 	{
572
-	   if( $GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
572
+	   if ($GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
573 573
 	   {
574
-		  $current_users = '<a href="' . self::link('/index.php','menuaction=admin.admin_accesslog.sessions') . '">' .
575
-		  	lang('Current users') . ': <span id="currentusers">' . $GLOBALS['egw']->session->session_count() . '</span></a>';
574
+		  $current_users = '<a href="'.self::link('/index.php', 'menuaction=admin.admin_accesslog.sessions').'">'.
575
+		  	lang('Current users').': <span id="currentusers">'.$GLOBALS['egw']->session->session_count().'</span></a>';
576 576
 		  return $current_users;
577 577
 	   }
578 578
 	}
@@ -606,14 +606,14 @@  discard block
 block discarded – undo
606 606
 	 * @param array $opts =array() further params for http(s) context, eg. array('timeout' => 123)
607 607
 	 * @return resource|null context to use with file_get_context/fopen or null if no proxy configured
608 608
 	 */
609
-	public static function proxy_context($username=null, $password=null, array $opts = array())
609
+	public static function proxy_context($username = null, $password = null, array $opts = array())
610 610
 	{
611 611
 		$opts += array(
612 612
 			'method' => 'GET',
613 613
 		);
614 614
 		if (!empty($GLOBALS['egw_info']['server']['httpproxy_server']))
615 615
 		{
616
-			$opts += array (
616
+			$opts += array(
617 617
 				'proxy'  => 'tcp://'.$GLOBALS['egw_info']['server']['httpproxy_server'].':'.
618 618
 					($GLOBALS['egw_info']['server']['httpproxy_port'] ? $GLOBALS['egw_info']['server']['httpproxy_port'] : 8080),
619 619
 				'request_fulluri' => true,
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	 * @param string &$changelog on return path to changelog
643 643
 	 * @return string
644 644
 	 */
645
-	public static function api_version(&$changelog=null)
645
+	public static function api_version(&$changelog = null)
646 646
 	{
647 647
 		return Framework\Updates::api_version($changelog);
648 648
 	}
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	 */
656 656
 	public static function index($app)
657 657
 	{
658
-		$data =& $GLOBALS['egw_info']['user']['apps'][$app];
658
+		$data = & $GLOBALS['egw_info']['user']['apps'][$app];
659 659
 		if (!isset($data))
660 660
 		{
661 661
 			throw new Exception\WrongParameter("'$app' not a valid app for this user!");
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 				$index = '/index.php?menuaction='.$data['index'];
673 673
 			}
674 674
 		}
675
-		return self::link($index,$GLOBALS['egw_info']['flags']['params'][$app]);
675
+		return self::link($index, $GLOBALS['egw_info']['flags']['params'][$app]);
676 676
 	}
677 677
 
678 678
 	/**
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 	 *	true: always return svg, false: never return svg (current default), null: browser dependent, see svg_usable()
714 714
 	 * @return array
715 715
 	 */
716
-	protected static function _get_navbar_apps($svg=false)
716
+	protected static function _get_navbar_apps($svg = false)
717 717
 	{
718 718
 		list($first) = each($GLOBALS['egw_info']['user']['apps']);
719
-		if(is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
719
+		if (is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
720 720
 		{
721 721
 			$newarray['admin'] = $GLOBALS['egw_info']['user']['apps']['admin'];
722
-			foreach($GLOBALS['egw_info']['user']['apps'] as $index => $value)
722
+			foreach ($GLOBALS['egw_info']['user']['apps'] as $index => $value)
723 723
 			{
724
-				if($index != 'admin')
724
+				if ($index != 'admin')
725 725
 				{
726 726
 					$newarray[$index] = $value;
727 727
 				}
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 		unset($newarray);
735 735
 
736 736
 		$apps = array();
737
-		foreach($GLOBALS['egw_info']['user']['apps'] as $app => $data)
737
+		foreach ($GLOBALS['egw_info']['user']['apps'] as $app => $data)
738 738
 		{
739 739
 			if (is_long($app))
740 740
 			{
@@ -751,21 +751,21 @@  discard block
 block discarded – undo
751 751
 				if ($data['status'] == 4)
752 752
 				{
753 753
 					$apps[$app]['target'] = ' target="'.$app.'" onClick="'."if (this != '') { window.open(this+'".
754
-						(strpos($apps[$app]['url'],'?') !== false ? '&' : '?').
754
+						(strpos($apps[$app]['url'], '?') !== false ? '&' : '?').
755 755
 						"referer='+encodeURIComponent(location),this.target,'width=800,height=600,scrollbars=yes,resizable=yes'); return false; } else { return true; }".'"';
756 756
 				}
757
-				elseif(isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
757
+				elseif (isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
758 758
 				{
759
-					$apps[$app]['target'] = 'target="' . $GLOBALS['egw_info']['flags']['navbar_target'] . '"';
759
+					$apps[$app]['target'] = 'target="'.$GLOBALS['egw_info']['flags']['navbar_target'].'"';
760 760
 				}
761 761
 				else
762 762
 				{
763 763
 					$apps[$app]['target'] = '';
764 764
 				}
765 765
 
766
-				$icon = isset($data['icon']) ?  $data['icon'] : 'navbar';
766
+				$icon = isset($data['icon']) ? $data['icon'] : 'navbar';
767 767
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
768
-				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,Array($icon,'nonav'),'',$svg);
768
+				$apps[$app]['icon'] = $apps[$app]['icon_hover'] = Image::find($icon_app, Array($icon, 'nonav'), '', $svg);
769 769
 			}
770 770
 		}
771 771
 
@@ -798,13 +798,13 @@  discard block
 block discarded – undo
798 798
 		// We handle this here because its special
799 799
 		$apps['about']['title'] = 'EGroupware';
800 800
 		$apps['about']['url']   = self::link('/about.php');
801
-		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',Array('about','nonav'));
801
+		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api', Array('about', 'nonav'));
802 802
 		$apps['about']['name']  = 'about';
803 803
 
804 804
 		$apps['logout']['title'] = lang('Logout');
805 805
 		$apps['logout']['name']  = 'logout';
806 806
 		$apps['logout']['url']   = self::link('/logout.php');
807
-		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',Array('logout','nonav'));
807
+		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api', Array('logout', 'nonav'));
808 808
 
809 809
 		return $apps;
810 810
 	}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 			}
839 839
 			$themes_to_check[] = $this->template_dir.'/css/'.$GLOBALS['egw_info']['user']['preferences']['common']['theme'].'.css';
840 840
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
841
-			foreach($themes_to_check as $theme_css)
841
+			foreach ($themes_to_check as $theme_css)
842 842
 			{
843 843
 				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
844 844
 			}
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 
873 873
 				// sending print css last, so it can overwrite anything
874 874
 				$print_css = $this->template_dir.'/print.css';
875
-				if(!file_exists(EGW_SERVER_ROOT.$print_css))
875
+				if (!file_exists(EGW_SERVER_ROOT.$print_css))
876 876
 				{
877 877
 					$print_css = '/api/templates/default/print.css';
878 878
 				}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 	 * @param array $extra =array() extra data to pass to egw.js as data-parameter
899 899
 	 * @return string the javascript to be included
900 900
 	 */
901
-	public static function _get_js(array $extra=array())
901
+	public static function _get_js(array $extra = array())
902 902
 	{
903 903
 		$java_script = '';
904 904
 
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 		Think of conf vars etc...  ([email protected]) */
907 907
 		if (isset($GLOBALS['egw_info']['flags']['java_script_thirst']))
908 908
 		{
909
-			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst'] . "\n";
909
+			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst']."\n";
910 910
 		}
911 911
 		// add configuration, link-registry, images, user-data and -perferences for non-popup windows
912 912
 		// specifying etag in url to force reload, as we send expires header
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 			self::includeJS('/api/images.php', array(
919 919
 				'template' => $GLOBALS['egw_info']['server']['template_set'],
920 920
 				'etag' => md5(json_encode(Image::map($GLOBALS['egw_info']['server']['template_set']))),
921
-				'svg' => Header\UserAgent::mobile(),	// always load non-svg image map, ATM we use svg icons only for mobile theme
921
+				'svg' => Header\UserAgent::mobile(), // always load non-svg image map, ATM we use svg icons only for mobile theme
922 922
 			));
923 923
 			self::includeJS('/api/user.php', array(
924 924
 				'user' => $GLOBALS['egw_info']['user']['account_lid'],
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 		}
931 931
 
932 932
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
933
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
933
+		$extra['include'] = array_map(function($str) {return substr($str, 1); }, self::get_script_links(true), array(1));
934 934
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
935 935
 
936 936
 		// Load LABjs ONCE here
@@ -940,18 +940,18 @@  discard block
 block discarded – undo
940 940
 				'/api/js/jsapi/egw.js?'.filemtime(EGW_SERVER_ROOT.'/api/js/jsapi/egw.js').'" id="egw_script_id"';
941 941
 
942 942
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
943
-		foreach($extra+self::$extra as $name => $value)
943
+		foreach ($extra + self::$extra as $name => $value)
944 944
 		{
945 945
 			if (is_array($value)) $value = json_encode($value);
946 946
 			// we need to double encode (Html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
947
-			$java_script .= ' data-'.$name."=\"". Html::htmlspecialchars($value, true)."\"";
947
+			$java_script .= ' data-'.$name."=\"".Html::htmlspecialchars($value, true)."\"";
948 948
 		}
949 949
 		$java_script .= "></script>\n";
950 950
 
951
-		if(@isset($_GET['menuaction']))
951
+		if (@isset($_GET['menuaction']))
952 952
 		{
953
-			list(, $class) = explode('.',$_GET['menuaction']);
954
-			if(is_array($GLOBALS[$class]->public_functions) &&
953
+			list(, $class) = explode('.', $_GET['menuaction']);
954
+			if (is_array($GLOBALS[$class]->public_functions) &&
955 955
 				$GLOBALS[$class]->public_functions['java_script'])
956 956
 			{
957 957
 				$java_script .= $GLOBALS[$class]->java_script();
@@ -960,10 +960,10 @@  discard block
 block discarded – undo
960 960
 		if (isset($GLOBALS['egw_info']['flags']['java_script']))
961 961
 		{
962 962
 			// Strip out any script tags, this needs to be executed as anonymous function
963
-			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']);
964
-			if(trim($GLOBALS['egw_info']['flags']['java_script']) != '')
963
+			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']);
964
+			if (trim($GLOBALS['egw_info']['flags']['java_script']) != '')
965 965
 			{
966
-				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script'] . "});</script>\n";
966
+				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script']."});</script>\n";
967 967
 			}
968 968
 		}
969 969
 
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 	function list_themes()
981 981
 	{
982 982
 		$list = array();
983
-		if (file_exists($file=EGW_SERVER_ROOT.$this->template_dir.'/setup/setup.inc.php') &&
983
+		if (file_exists($file = EGW_SERVER_ROOT.$this->template_dir.'/setup/setup.inc.php') &&
984 984
 			(include $file) && isset($GLOBALS['egw_info']['template'][$this->template]['themes']))
985 985
 		{
986 986
 			$list = $GLOBALS['egw_info']['template'][$this->template]['themes'];
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 			{
992 992
 				if (preg_match('/'."\.css$".'/i', $file))
993 993
 				{
994
-					list($name) = explode('.',$file);
995
-					if (!isset($list[$name])) $list[$name] = ucfirst ($name);
994
+					list($name) = explode('.', $file);
995
+					if (!isset($list[$name])) $list[$name] = ucfirst($name);
996 996
 				}
997 997
 			}
998 998
 			closedir($dh);
@@ -1006,21 +1006,20 @@  discard block
 block discarded – undo
1006 1006
 	 * @param boolean $full_data =false true: value is array with values for keys 'name', 'title', ...
1007 1007
 	 * @returns array alphabetically sorted list of templates
1008 1008
 	 */
1009
-	static function list_templates($full_data=false)
1009
+	static function list_templates($full_data = false)
1010 1010
 	{
1011 1011
 		$list = array('pixelegg'=>null);
1012 1012
 		// templates packaged like apps in own directories (containing as setup/setup.inc.php file!)
1013 1013
 		$dr = dir(EGW_SERVER_ROOT);
1014
-		while (($entry=$dr->read()))
1014
+		while (($entry = $dr->read()))
1015 1015
 		{
1016 1016
 			if ($entry != '..' && !isset($GLOBALS['egw_info']['apps'][$entry]) && is_dir(EGW_SERVER_ROOT.'/'.$entry) &&
1017
-				file_exists($f = EGW_SERVER_ROOT . '/' . $entry .'/setup/setup.inc.php'))
1017
+				file_exists($f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'))
1018 1018
 			{
1019 1019
 				include($f);
1020 1020
 				if (isset($GLOBALS['egw_info']['template'][$entry]))
1021 1021
 				{
1022
-					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
1023
-						$GLOBALS['egw_info']['template'][$entry]['title'];
1022
+					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] : $GLOBALS['egw_info']['template'][$entry]['title'];
1024 1023
 				}
1025 1024
 			}
1026 1025
 		}
@@ -1037,14 +1036,14 @@  discard block
 block discarded – undo
1037 1036
 	* @param array $vars
1038 1037
 	* @param array $apps
1039 1038
 	*/
1040
-	function topmenu(array $vars,array $apps)
1039
+	function topmenu(array $vars, array $apps)
1041 1040
 	{
1042
-		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1041
+		if ($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1043 1042
 		{
1044 1043
 			$this->_add_topmenu_item($apps['home']);
1045 1044
 		}
1046 1045
 
1047
-		if($GLOBALS['egw_info']['user']['apps']['preferences'])
1046
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
1048 1047
 		{
1049 1048
 			$this->add_preferences_topmenu('prefs');
1050 1049
 			$this->add_preferences_topmenu('acl');
@@ -1069,9 +1068,9 @@  discard block
 block discarded – undo
1069 1068
 			$this->_add_topmenu_item(array_merge($apps['manual'],array('title' => lang('Help'))));
1070 1069
 		}*/
1071 1070
 
1072
-		Hooks::process('topmenu_info',array(),true);
1071
+		Hooks::process('topmenu_info', array(), true);
1073 1072
 		// Add extra items added by hooks
1074
-		foreach(self::$top_menu_extra as $extra_item) {
1073
+		foreach (self::$top_menu_extra as $extra_item) {
1075 1074
 			$this->_add_topmenu_item($extra_item);
1076 1075
 		}
1077 1076
 
@@ -1081,7 +1080,7 @@  discard block
 block discarded – undo
1081 1080
 		{
1082 1081
 			$this->_add_topmenu_info_item($update, 'update');
1083 1082
 		}
1084
-		if($GLOBALS['egw_info']['user']['apps']['notifications'])
1083
+		if ($GLOBALS['egw_info']['user']['apps']['notifications'])
1085 1084
 		{
1086 1085
 			$this->_add_topmenu_info_item(self::_get_notification_bell(), 'notifications');
1087 1086
 		}
@@ -1093,9 +1092,9 @@  discard block
 block discarded – undo
1093 1092
 	/**
1094 1093
 	 * Add Preferences link to topmenu using settings-hook to know if an app supports Preferences
1095 1094
 	 */
1096
-	protected function add_preferences_topmenu($type='prefs')
1095
+	protected function add_preferences_topmenu($type = 'prefs')
1097 1096
 	{
1098
-		static $memberships=null;
1097
+		static $memberships = null;
1099 1098
 		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1100 1099
 		static $types = array(
1101 1100
 			'prefs' => array(
@@ -1109,20 +1108,20 @@  discard block
 block discarded – undo
1109 1108
 			'cats' => array(
1110 1109
 				'title' => 'Categories',
1111 1110
 				'hook' => 'categories',
1112
-				'run_hook' => true,	// acturally run hook, not just look it's implemented
1111
+				'run_hook' => true, // acturally run hook, not just look it's implemented
1113 1112
 			),
1114 1113
 		);
1115 1114
 		if (!$GLOBALS['egw_info']['user']['apps']['preferences'] || $GLOBALS['egw_info']['server']['deny_'.$type] &&
1116 1115
 			array_intersect($memberships, (array)$GLOBALS['egw_info']['server']['deny_'.$type]) &&
1117 1116
 			!$GLOBALS['egw_info']['user']['apps']['admin'])
1118 1117
 		{
1119
-			return;	// user has no access to Preferences app
1118
+			return; // user has no access to Preferences app
1120 1119
 		}
1121 1120
 		if (isset($types[$type]['run_hook']))
1122 1121
 		{
1123 1122
 			$apps = Hooks::process($types[$type]['hook']);
1124 1123
 			// as all apps answer, we need to remove none-true responses
1125
-			foreach($apps as $app => $val)
1124
+			foreach ($apps as $app => $val)
1126 1125
 			{
1127 1126
 				if (!$val) unset($apps[$app]);
1128 1127
 			}
@@ -1148,7 +1147,7 @@  discard block
 block discarded – undo
1148 1147
 	* @access protected
1149 1148
 	* @return void
1150 1149
 	*/
1151
-	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1150
+	abstract function _add_topmenu_item(array $app_data, $alt_label = null);
1152 1151
 
1153 1152
 	/**
1154 1153
 	* Add info items to the topmenu template class to be displayed
@@ -1158,7 +1157,7 @@  discard block
 block discarded – undo
1158 1157
 	* @access protected
1159 1158
 	* @return void
1160 1159
 	*/
1161
-	abstract function _add_topmenu_info_item($content, $id=null);
1160
+	abstract function _add_topmenu_info_item($content, $id = null);
1162 1161
 
1163 1162
 	static $top_menu_extra = array();
1164 1163
 
@@ -1173,7 +1172,7 @@  discard block
 block discarded – undo
1173 1172
 	* @access public
1174 1173
 	* @return void
1175 1174
 	*/
1176
-	public static function add_topmenu_item($id,$url,$title,$target = '')
1175
+	public static function add_topmenu_item($id, $url, $title, $target = '')
1177 1176
 	{
1178 1177
 		$entry['name'] = $id;
1179 1178
 		$entry['url'] = $url;
@@ -1194,7 +1193,7 @@  discard block
 block discarded – undo
1194 1193
 	* @access public
1195 1194
 	* @return void
1196 1195
 	*/
1197
-	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1196
+	abstract function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null);
1198 1197
 
1199 1198
 	/**
1200 1199
 	 * Call and return content of 'after_navbar' hook
@@ -1204,7 +1203,7 @@  discard block
 block discarded – undo
1204 1203
 	protected function _get_after_navbar()
1205 1204
 	{
1206 1205
 		ob_start();
1207
-		Hooks::process('after_navbar',null,true);
1206
+		Hooks::process('after_navbar', null, true);
1208 1207
 		$content = ob_get_contents();
1209 1208
 		ob_end_clean();
1210 1209
 
@@ -1241,7 +1240,7 @@  discard block
 block discarded – undo
1241 1240
 	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1242 1241
 	* @param boolean $append =true should the file be added
1243 1242
 	*/
1244
-	static function includeJS($package, $file=null, $app='phpgwapi')
1243
+	static function includeJS($package, $file = null, $app = 'phpgwapi')
1245 1244
 	{
1246 1245
 		self::$js_include_mgr->include_js_file($package, $file, $app);
1247 1246
 	}
@@ -1253,7 +1252,7 @@  discard block
 block discarded – undo
1253 1252
 	 * @param boolean $clear_files =false true clear files after returning them
1254 1253
 	 * @return array with pathes relative to EGW_SERVER_ROOT
1255 1254
 	 */
1256
-	static function js_files(array $files=null, $clear_files=false)
1255
+	static function js_files(array $files = null, $clear_files = false)
1257 1256
 	{
1258 1257
 		if (isset($files) && is_array($files))
1259 1258
 		{
@@ -1272,7 +1271,7 @@  discard block
 block discarded – undo
1272 1271
 	 * @param boolean $clear_files =false true clear files after returning them
1273 1272
 	 * @return string|array see $return_pathes parameter
1274 1273
 	 */
1275
-	static public function get_script_links($return_pathes=false, $clear_files=false)
1274
+	static public function get_script_links($return_pathes = false, $clear_files = false)
1276 1275
 	{
1277 1276
 		$to_include = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files($clear_files));
1278 1277
 
@@ -1280,7 +1279,7 @@  discard block
 block discarded – undo
1280 1279
 		{
1281 1280
 			return $to_include;
1282 1281
 		}
1283
-		$start = '<script type="text/javascript" src="'. $GLOBALS['egw_info']['server']['webserver_url'];
1282
+		$start = '<script type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'];
1284 1283
 		$end = '">'."</script>\n";
1285 1284
 		return "\n".$start.implode($end.$start, $to_include).$end;
1286 1285
 	}
@@ -1300,7 +1299,7 @@  discard block
 block discarded – undo
1300 1299
 	 * @param boolean $no_default_css =false true do NOT load any default css, only what app explicitly includes
1301 1300
 	 * @return boolean false: css file not found, true: file found
1302 1301
 	 */
1303
-	public static function includeCSS($app, $name=null, $append=true, $no_default_css=false)
1302
+	public static function includeCSS($app, $name = null, $append = true, $no_default_css = false)
1304 1303
 	{
1305 1304
 		if ($no_default_css)
1306 1305
 		{
@@ -1320,16 +1319,16 @@  discard block
 block discarded – undo
1320 1319
 
1321 1320
 		// try to add app specific css file
1322 1321
 		self::includeCSS($app, 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
1323
-			self::includeCSS($app,'app');
1322
+			self::includeCSS($app, 'app');
1324 1323
 
1325 1324
 		// add all css files from Framework::includeCSS()
1326 1325
 		$query = null;
1327 1326
 		//error_log(__METHOD__."() Framework\CssIncludes::get()=".array2string(Framework\CssIncludes::get()));
1328
-		foreach(Framework\CssIncludes::get() as $path)
1327
+		foreach (Framework\CssIncludes::get() as $path)
1329 1328
 		{
1330 1329
 			unset($query);
1331
-			list($path,$query) = explode('?',$path,2);
1332
-			$path .= '?'. ($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
1330
+			list($path, $query) = explode('?', $path, 2);
1331
+			$path .= '?'.($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
1333 1332
 			$response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path);
1334 1333
 		}
1335 1334
 
@@ -1338,7 +1337,7 @@  discard block
 block discarded – undo
1338 1337
 
1339 1338
 		// add all js files from Framework::includeJS()
1340 1339
 		$files = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files());
1341
-		foreach($files as $path)
1340
+		foreach ($files as $path)
1342 1341
 		{
1343 1342
 			$response->includeScript($GLOBALS['egw_info']['server']['webserver_url'].$path);
1344 1343
 		}
@@ -1414,17 +1413,17 @@  discard block
 block discarded – undo
1414 1413
 	 */
1415 1414
 	public static function ajax_user_list()
1416 1415
 	{
1417
-		$list = array('accounts' => array(),'groups' => array(), 'owngroups' => array());
1418
-		if($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
1416
+		$list = array('accounts' => array(), 'groups' => array(), 'owngroups' => array());
1417
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
1419 1418
 		{
1420 1419
 			$list['accounts']['filter']['group'] = $GLOBALS['egw_info']['user']['account_primary_group'];
1421 1420
 		}
1422
-		foreach($list as $type => &$accounts)
1421
+		foreach ($list as $type => &$accounts)
1423 1422
 		{
1424 1423
 			$options = array('account_type' => $type) + $accounts;
1425
-			$key_pair = Accounts::link_query('',$options);
1424
+			$key_pair = Accounts::link_query('', $options);
1426 1425
 			$accounts = array();
1427
-			foreach($key_pair as $account_id => $name)
1426
+			foreach ($key_pair as $account_id => $name)
1428 1427
 			{
1429 1428
 				$accounts[] = array('value' => $account_id, 'label' => $name);
1430 1429
 			}
@@ -1442,16 +1441,16 @@  discard block
 block discarded – undo
1442 1441
 	 * @param boolean $_resolve_groups =false true: return attribute for all members, false return attribute for group itself
1443 1442
 	 * @return array account_id => data pairs
1444 1443
 	 */
1445
-	public static function ajax_account_data($_account_ids, $_field, $_resolve_groups=false)
1444
+	public static function ajax_account_data($_account_ids, $_field, $_resolve_groups = false)
1446 1445
 	{
1447 1446
 		$list = array();
1448
-		foreach((array)$_account_ids as $account_id)
1447
+		foreach ((array)$_account_ids as $account_id)
1449 1448
 		{
1450
-			foreach($account_id < 0 && $_resolve_groups ?
1449
+			foreach ($account_id < 0 && $_resolve_groups ?
1451 1450
 				$GLOBALS['egw']->accounts->members($account_id, true) : array($account_id) as $account_id)
1452 1451
 			{
1453 1452
 				// Make sure name is formatted according to preference
1454
-				if($_field == 'account_fullname')
1453
+				if ($_field == 'account_fullname')
1455 1454
 				{
1456 1455
 					$list[$account_id] = Accounts::format_username(
1457 1456
 						$GLOBALS['egw']->accounts->id2name($account_id, 'account_lid'),
Please login to merge, or discard this patch.
api/src/Storage/Db2DataIterator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 	 * @param Base $storage
47 47
 	 * @param \Traversable $rs
48 48
 	 */
49
-	public function __construct(Base $storage, \Traversable $rs=null)
49
+	public function __construct(Base $storage, \Traversable $rs = null)
50 50
 	{
51 51
 		$this->storage = $storage;
52 52
 
53 53
 		$this->total = $storage->total;
54 54
 
55
-		if (is_a($rs,'IteratorAggregate'))
55
+		if (is_a($rs, 'IteratorAggregate'))
56 56
 		{
57 57
 			$this->rs = $rs->getIterator();
58 58
 		}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function current()
71 71
 	{
72
-		if (is_a($this->rs,'iterator'))
72
+		if (is_a($this->rs, 'iterator'))
73 73
 		{
74 74
 			$data = $this->rs->current();
75 75
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function key()
87 87
 	{
88
-		if (is_a($this->rs,'iterator'))
88
+		if (is_a($this->rs, 'iterator'))
89 89
 		{
90 90
 			return $this->rs->key();
91 91
 		}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function next()
99 99
 	{
100
-		if (is_a($this->rs,'iterator'))
100
+		if (is_a($this->rs, 'iterator'))
101 101
 		{
102 102
 			return $this->rs->next();
103 103
 		}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function rewind()
110 110
 	{
111
-		if (is_a($this->rs,'iterator'))
111
+		if (is_a($this->rs, 'iterator'))
112 112
 		{
113 113
 			return $this->rs->rewind();
114 114
 		}
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return boolean
121 121
 	 */
122
-	public function valid ()
122
+	public function valid()
123 123
 	{
124
-		if (is_a($this->rs,'iterator'))
124
+		if (is_a($this->rs, 'iterator'))
125 125
 		{
126 126
 			return $this->rs->valid();
127 127
 		}
Please login to merge, or discard this patch.
api/src/Storage/Base.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1367,14 +1367,14 @@
 block discarded – undo
1367 1367
 	}
1368 1368
 
1369 1369
 	/**
1370
-	* Get a default list of columns to search
1371
-	* This is to be used as a fallback, for when the extending class does not define
1372
-	* $this->columns_to_search.  All the columns are considered, and any with $skip_columns_with in
1373
-	* their name are discarded because these columns are expected to be foreign keys or other numeric
1374
-	* values with no meaning to the user.
1375
-	*
1376
-	* @return array of column names
1377
-	*/
1370
+	 * Get a default list of columns to search
1371
+	 * This is to be used as a fallback, for when the extending class does not define
1372
+	 * $this->columns_to_search.  All the columns are considered, and any with $skip_columns_with in
1373
+	 * their name are discarded because these columns are expected to be foreign keys or other numeric
1374
+	 * values with no meaning to the user.
1375
+	 *
1376
+	 * @return array of column names
1377
+	 */
1378 1378
 	protected function get_default_search_columns()
1379 1379
 	{
1380 1380
 		$skip_columns_with = array('_id', 'modified', 'modifier', 'status', 'cat_id', 'owner');
Please login to merge, or discard this patch.
Braces   +193 added lines, -51 removed lines patch added patch discarded remove patch
@@ -182,7 +182,10 @@  discard block
 block discarded – undo
182 182
 	function __construct($app='',$table='',Api\Db $db=null,$column_prefix='',$no_clone=false,$timestamp_type=null)
183 183
 	{
184 184
 		// ease the transition to api
185
-		if ($app == 'phpgwapi') $app = 'api';
185
+		if ($app == 'phpgwapi')
186
+		{
187
+			$app = 'api';
188
+		}
186 189
 
187 190
 		if ($no_clone)
188 191
 		{
@@ -198,9 +201,15 @@  discard block
 block discarded – undo
198 201
 		{
199 202
 			$this->app = $app;
200 203
 
201
-			if (!$no_clone) $this->db->set_app($app);
204
+			if (!$no_clone)
205
+			{
206
+				$this->db->set_app($app);
207
+			}
202 208
 
203
-			if ($table) $this->setup_table($app,$table,$column_prefix);
209
+			if ($table)
210
+			{
211
+				$this->setup_table($app,$table,$column_prefix);
212
+			}
204 213
 		}
205 214
 		$this->init();
206 215
 
@@ -221,7 +230,10 @@  discard block
 block discarded – undo
221 230
 	 */
222 231
 	public function set_times($timestamp_type=false)
223 232
 	{
224
-		if ($timestamp_type !== false) $this->timestamp_type = $timestamp_type;
233
+		if ($timestamp_type !== false)
234
+		{
235
+			$this->timestamp_type = $timestamp_type;
236
+		}
225 237
 
226 238
 		// set current time
227 239
 		switch($this->timestamp_type)
@@ -279,7 +291,10 @@  discard block
 block discarded – undo
279 291
 			{
280 292
 				$this->autoinc_id = $col;
281 293
 			}
282
-			if ($def['type'] == 'bool') $this->has_bools = true;
294
+			if ($def['type'] == 'bool')
295
+			{
296
+				$this->has_bools = true;
297
+			}
283 298
 
284 299
 			foreach($this->table_def['uc'] as $k => $uni_index)
285 300
 			{
@@ -318,7 +333,10 @@  discard block
 block discarded – undo
318 333
 	 */
319 334
 	function data_merge($new)
320 335
 	{
321
-		if ((int) $this->debug >= 4) echo "<p>so_sql::data_merge(".print_r($new,true).")</p>\n";
336
+		if ((int) $this->debug >= 4)
337
+		{
338
+			echo "<p>so_sql::data_merge(".print_r($new,true).")</p>\n";
339
+		}
322 340
 
323 341
 		if (!is_array($new) || !count($new))
324 342
 		{
@@ -342,7 +360,10 @@  discard block
 block discarded – undo
342 360
 		{
343 361
 			$this->data[self::USER_TIMEZONE_READ] = $new[self::USER_TIMEZONE_READ];
344 362
 		}
345
-		if ((int) $this->debug >= 4) _debug_array($this->data);
363
+		if ((int) $this->debug >= 4)
364
+		{
365
+			_debug_array($this->data);
366
+		}
346 367
 	}
347 368
 
348 369
 	/**
@@ -486,7 +507,10 @@  discard block
 block discarded – undo
486 507
 		if (!is_array($keys))
487 508
 		{
488 509
 			$pk = array_values($this->db_key_cols);
489
-			if ($pk) $keys = array($pk[0] => $keys);
510
+			if ($pk)
511
+			{
512
+				$keys = array($pk[0] => $keys);
513
+			}
490 514
 		}
491 515
 
492 516
 		$this->init($keys);
@@ -500,13 +524,16 @@  discard block
 block discarded – undo
500 524
 				$query[$db_col] = $this->data[$col];
501 525
 			}
502 526
 		}
503
-		if (!$query)	// no primary key in keys, lets try the data_cols for a unique key
527
+		if (!$query)
528
+		{
529
+			// no primary key in keys, lets try the data_cols for a unique key
504 530
 		{
505 531
 			foreach($this->db_uni_cols as $db_col => $col)
506 532
 			{
507 533
 				if (!is_array($col) && $this->data[$col] != '')
508 534
 				{
509 535
 					$query[$db_col] = $this->data[$col];
536
+		}
510 537
 				}
511 538
 				elseif(is_array($col))
512 539
 				{
@@ -520,31 +547,43 @@  discard block
 block discarded – undo
520 547
 						}
521 548
 						$q[$db_c] = $this->data[$c];
522 549
 					}
523
-					if ($q) $query += $q;
550
+					if ($q)
551
+					{
552
+						$query += $q;
553
+					}
524 554
 				}
525 555
 			}
526 556
 		}
527
-		if (!$query)	// no unique key in keys, lets try everything else
557
+		if (!$query)
558
+		{
559
+			// no unique key in keys, lets try everything else
528 560
 		{
529 561
 			foreach($this->db_data_cols as $db_col => $col)
530 562
 			{
531 563
 				if ($this->data[$col] != '')
532 564
 				{
533 565
 					$query[$db_col] = $this->data[$col];
566
+		}
534 567
 				}
535 568
 			}
536 569
 		}
537
-		if (!$query)	// keys has no cols
570
+		if (!$query)
571
+		{
572
+			// keys has no cols
538 573
 		{
539 574
 			$this->db2data();
575
+		}
540 576
 
541 577
 			return False;
542 578
 		}
543
-		if ($join)	// Prefix the columns with the table-name, as they might exist in the join
579
+		if ($join)
580
+		{
581
+			// Prefix the columns with the table-name, as they might exist in the join
544 582
 		{
545 583
 			foreach($query as $col => $val)
546 584
 			{
547 585
 				if (is_int($col) || strpos($join,$col) === false) continue;
586
+		}
548 587
 				$query[] = $this->db->expression($this->table_name,$this->table_name.'.',array($col=>$val));
549 588
 				unset($query[$col]);
550 589
 			}
@@ -553,11 +592,14 @@  discard block
 block discarded – undo
553 592
 			$query,__LINE__,__FILE__,False,'',$this->app,0,$join) as $row)
554 593
 		{
555 594
 			$cols = $this->db_cols;
556
-			if ($extra_cols)	// extra columns to report
595
+			if ($extra_cols)
596
+			{
597
+				// extra columns to report
557 598
 			{
558 599
 				foreach(is_array($extra_cols) ? $extra_cols : array($extra_cols) as $col)
559 600
 				{
560 601
 					if (FALSE!==stripos($col,' as ')) $col = preg_replace('/^.* as *([a-z0-9_]+) *$/i','\\1',$col);
602
+			}
561 603
 					$cols[$col] = $col;
562 604
 				}
563 605
 			}
@@ -580,7 +622,10 @@  discard block
 block discarded – undo
580 622
 		{
581 623
 			unset($this->data[$this->db_key_cols[$this->autoinc_id]]);
582 624
 		}
583
-		if ((int) $this->debug >= 4) echo "nothing found !!!</p>\n";
625
+		if ((int) $this->debug >= 4)
626
+		{
627
+			echo "nothing found !!!</p>\n";
628
+		}
584 629
 
585 630
 		$this->db2data();
586 631
 
@@ -596,7 +641,10 @@  discard block
 block discarded – undo
596 641
 	 */
597 642
 	function save($keys=null,$extra_where=null)
598 643
 	{
599
-		if (is_array($keys) && count($keys)) $this->data_merge($keys);
644
+		if (is_array($keys) && count($keys))
645
+		{
646
+			$this->data_merge($keys);
647
+		}
600 648
 
601 649
 		// check if data contains user timezone during read AND user changed timezone since then
602 650
 		// --> load old timezone for the rest of this request
@@ -613,9 +661,13 @@  discard block
 block discarded – undo
613 661
 		}
614 662
 		$this->data2db();
615 663
 
616
-		if ((int) $this->debug >= 4) { echo "so_sql::save(".print_r($keys,true).") autoinc_id='$this->autoinc_id', data="; _debug_array($this->data); }
664
+		if ((int) $this->debug >= 4)
665
+		{
666
+echo "so_sql::save(".print_r($keys,true).") autoinc_id='$this->autoinc_id', data="; _debug_array($this->data); }
617 667
 
618
-		if ($this->autoinc_id && !$this->data[$this->db_key_cols[$this->autoinc_id]])	// insert with auto id
668
+		if ($this->autoinc_id && !$this->data[$this->db_key_cols[$this->autoinc_id]])
669
+		{
670
+			// insert with auto id
619 671
 		{
620 672
 			foreach($this->db_cols as $db_col => $col)
621 673
 			{
@@ -625,7 +677,9 @@  discard block
 block discarded – undo
625 677
 						(isset($this->table_def['fd'][$db_col]['default']) ||	// we have a default value
626 678
 						 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))	// column is nullable
627 679
 					{
628
-						continue;	// no need to write that (unset) column
680
+						continue;
681
+		}
682
+		// no need to write that (unset) column
629 683
 					}
630 684
 					if ($this->table_def['fd'][$db_col]['type'] == 'varchar' &&
631 685
 						strlen($this->data[$col]) > $this->table_def['fd'][$db_col]['precision'])
@@ -656,9 +710,13 @@  discard block
 block discarded – undo
656 710
 				if (!array_key_exists($col,$this->data) &&	// handling of unset columns in $this->data
657 711
 					($this->autoinc_id ||			// update of table with auto id or
658 712
 					 isset($this->table_def['fd'][$db_col]['default']) ||	// we have a default value or
659
-					 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))	// column is nullable
713
+					 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))
660 714
 				{
661
-					continue;	// no need to write that (unset) column
715
+					// column is nullable
716
+				{
717
+					continue;
718
+				}
719
+				// no need to write that (unset) column
662 720
 				}
663 721
 				$data[$db_col] = !is_object($this->data[$col]) && (string) $this->data[$col] === '' && $this->empty_on_write == 'NULL' ? null : $this->data[$col];
664 722
 			}
@@ -675,9 +733,12 @@  discard block
 block discarded – undo
675 733
 			{
676 734
 				$keys[$db_col] = $this->data[$col];
677 735
 			}
678
-			if (!$data && !$this->autoinc_id)	// happens if all columns are in the primary key
736
+			if (!$data && !$this->autoinc_id)
737
+			{
738
+				// happens if all columns are in the primary key
679 739
 			{
680 740
 				$data = $keys;
741
+			}
681 742
 				$keys = False;
682 743
 			}
683 744
 			if ($this->autoinc_id)
@@ -708,7 +769,10 @@  discard block
 block discarded – undo
708 769
 	 */
709 770
 	function update($_fields,$merge=true)
710 771
 	{
711
-		if ($merge) $this->data_merge($_fields);
772
+		if ($merge)
773
+		{
774
+			$this->data_merge($_fields);
775
+		}
712 776
 
713 777
 		$fields = $this->data2db($_fields);
714 778
 
@@ -761,9 +825,12 @@  discard block
 block discarded – undo
761 825
 		{
762 826
 			$keys = array($this->autoinc_id => $keys);
763 827
 		}
764
-		if (!is_array($keys) || !count($keys))	// use internal data
828
+		if (!is_array($keys) || !count($keys))
829
+		{
830
+			// use internal data
765 831
 		{
766 832
 			$data = $this->data;
833
+		}
767 834
 			$keys = $this->db_key_cols;
768 835
 		}
769 836
 		else	// data and keys are supplied in $keys
@@ -783,7 +850,10 @@  discard block
 block discarded – undo
783 850
 		{
784 851
 			$query[$db_col] = $data[$col];
785 852
 		}
786
-		if ($only_return_query) return $query;
853
+		if ($only_return_query)
854
+		{
855
+			return $query;
856
+		}
787 857
 
788 858
 		$this->db->delete($this->table_name,$query,__LINE__,__FILE__,$this->app);
789 859
 
@@ -816,7 +886,10 @@  discard block
 block discarded – undo
816 886
 	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
817 887
 	{
818 888
 		//error_log(__METHOD__.'('.array2string(array_combine(array_slice(array('criteria','only_keys','order_by','extra_cols','wildcard','empty','op','start','filter','join','need_full_no_count'), 0, count(func_get_args())), func_get_args())).')');
819
-		if ((int) $this->debug >= 4) echo "<p>so_sql::search(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
889
+		if ((int) $this->debug >= 4)
890
+		{
891
+			echo "<p>so_sql::search(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
892
+		}
820 893
 
821 894
 		// if extending class or instanciator set columns to search, convert string criteria to array
822 895
 		if ($criteria && !is_array($criteria))
@@ -880,9 +953,12 @@  discard block
 block discarded – undo
880 953
 								($negate ? ') ' : '');
881 954
 						}
882 955
 					}
883
-					elseif (strpos($db_col,'.') !== false)	// we have a table-name specified
956
+					elseif (strpos($db_col,'.') !== false)
957
+					{
958
+						// we have a table-name specified
884 959
 					{
885 960
 						list($table,$only_col) = explode('.',$db_col);
961
+					}
886 962
 						$type = $this->db->get_column_attribute($only_col, $table, true, 'type');
887 963
 						if (empty($type))
888 964
 						{
@@ -907,13 +983,17 @@  discard block
 block discarded – undo
907 983
 					}
908 984
 				}
909 985
 			}
910
-			if (is_array($query) && $op != 'AND') $query = $this->db->column_data_implode(' '.$op.' ',$query);
986
+			if (is_array($query) && $op != 'AND')
987
+			{
988
+				$query = $this->db->column_data_implode(' '.$op.' ',$query);
989
+			}
911 990
 		}
912 991
 		if (is_array($filter))
913 992
 		{
914 993
 			$db_filter = array();
915 994
 			$data2db_filter = $this->data2db($filter);
916
-			if (!is_array($data2db_filter)) {
995
+			if (!is_array($data2db_filter))
996
+			{
917 997
 				echo function_backtrace()."<br/>\n";
918 998
 				echo "filter=";_debug_array($filter);
919 999
 				echo "data2db(filter)=";_debug_array($data2db_filter);
@@ -1009,7 +1089,10 @@  discard block
 block discarded – undo
1009 1089
 			}
1010 1090
 		}
1011 1091
 		$num_rows = 0;	// as spec. in max_matches in the user-prefs
1012
-		if (is_array($start)) list($start,$num_rows) = $start;
1092
+		if (is_array($start))
1093
+		{
1094
+			list($start,$num_rows) = $start;
1095
+		}
1013 1096
 
1014 1097
 		// fix GROUP BY clause to contain all non-aggregate selected columns
1015 1098
 		if ($order_by && stripos($order_by,'GROUP BY') !== false)
@@ -1037,18 +1120,24 @@  discard block
 block discarded – undo
1037 1120
 					'append' => $order_by,
1038 1121
 					'join'   => $join,
1039 1122
 				);
1040
-				if (!$union_cols)	// union used the colum-names of the first query
1123
+				if (!$union_cols)
1124
+				{
1125
+					// union used the colum-names of the first query
1041 1126
 				{
1042 1127
 					$union_cols = $this->_get_columns($only_keys,$extra_cols);
1043 1128
 				}
1129
+				}
1044 1130
 				return true;	// waiting for further calls, before running the union-query
1045 1131
 			}
1046 1132
 			// running the union query now
1047
-			if ($start !== false)	// need to get the total too, saved in $this->total
1133
+			if ($start !== false)
1134
+			{
1135
+				// need to get the total too, saved in $this->total
1048 1136
 			{
1049 1137
 				if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
1050 1138
 				{
1051 1139
 					$union[0]['cols'] = ($mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ').$union[0]['cols'];
1140
+			}
1052 1141
 				}
1053 1142
 				else	// cant do a count, have to run the query without limit
1054 1143
 				{
@@ -1056,18 +1145,24 @@  discard block
 block discarded – undo
1056 1145
 				}
1057 1146
 			}
1058 1147
 			$rs = $this->db->union($union,__LINE__,__FILE__,$order_by,$start,$num_rows);
1059
-			if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1148
+			if ($this->debug)
1149
+			{
1150
+				error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1151
+			}
1060 1152
 
1061 1153
 			$cols = $union_cols;
1062 1154
 			$union = $union_cols = array();
1063 1155
 		}
1064 1156
 		else	// no UNION
1065 1157
 		{
1066
-			if ($start !== false)	// need to get the total too, saved in $this->total
1158
+			if ($start !== false)
1159
+			{
1160
+				// need to get the total too, saved in $this->total
1067 1161
 			{
1068 1162
 				if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
1069 1163
 				{
1070 1164
 					$mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ';
1165
+			}
1071 1166
 				}
1072 1167
 				elseif (!$need_full_no_count && (!$join || stripos($join,'LEFT JOIN')!==false))
1073 1168
 				{
@@ -1080,10 +1175,16 @@  discard block
 block discarded – undo
1080 1175
 			}
1081 1176
 			$rs = $this->db->select($this->table_name,$mysql_calc_rows.$colums,$query,__LINE__,__FILE__,
1082 1177
 				$start,$order_by,$this->app,$num_rows,$join);
1083
-			if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1178
+			if ($this->debug)
1179
+			{
1180
+				error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1181
+			}
1084 1182
 			$cols = $this->_get_columns($only_keys,$extra_cols);
1085 1183
 		}
1086
-		if ((int) $this->debug >= 4) echo "<p>sql='{$this->db->Query_ID->sql}'</p>\n";
1184
+		if ((int) $this->debug >= 4)
1185
+		{
1186
+			echo "<p>sql='{$this->db->Query_ID->sql}'</p>\n";
1187
+		}
1087 1188
 
1088 1189
 		if ($mysql_calc_rows)
1089 1190
 		{
@@ -1096,9 +1197,12 @@  discard block
 block discarded – undo
1096 1197
 		}
1097 1198
 		$arr = array();
1098 1199
 		$n = 0;
1099
-		if ($rs) foreach($rs as $row)
1200
+		if ($rs)
1201
+		{
1202
+			foreach($rs as $row)
1100 1203
 		{
1101 1204
 			$data = array();
1205
+		}
1102 1206
 			foreach($cols as $db_col => $col)
1103 1207
 			{
1104 1208
 				$data[$col] = (isset($row[$db_col]) ? $row[$db_col] : $row[$col]);
@@ -1166,9 +1270,15 @@  discard block
 block discarded – undo
1166 1270
 					$col = substr($col, $pos+9);
1167 1271
 				}
1168 1272
 				$alias = $col;
1169
-				if (stripos($col, ' AS ')) list($col, $alias) = preg_split('/ +AS +/i', $col);
1273
+				if (stripos($col, ' AS '))
1274
+				{
1275
+					list($col, $alias) = preg_split('/ +AS +/i', $col);
1276
+				}
1170 1277
 				// do NOT group by constant expressions
1171
-				if (preg_match('/^ *(-?[0-9]+|".*"|\'.*\'|NULL) *$/i', $col)) continue;
1278
+				if (preg_match('/^ *(-?[0-9]+|".*"|\'.*\'|NULL) *$/i', $col))
1279
+				{
1280
+					continue;
1281
+				}
1172 1282
 				if (!in_array($col, $group_by_cols) && !in_array($alias, $group_by_cols))
1173 1283
 				{
1174 1284
 					// instead of aliased primary key, we have to use original column incl. table-name as alias is ambigues
@@ -1201,7 +1311,10 @@  discard block
 block discarded – undo
1201 1311
 	{
1202 1312
 		$pattern = trim($_pattern);
1203 1313
 		// This function can get called multiple times.  Make sure it doesn't re-process.
1204
-		if (empty($pattern) || is_array($pattern)) return $pattern;
1314
+		if (empty($pattern) || is_array($pattern))
1315
+		{
1316
+			return $pattern;
1317
+		}
1205 1318
 		if(strpos($pattern, 'CAST(COALESCE(') !== false)
1206 1319
 		{
1207 1320
 			return $pattern;
@@ -1271,7 +1384,7 @@  discard block
 block discarded – undo
1271 1384
 			{
1272 1385
 				$token = substr($token, 1,strlen($token));
1273 1386
  				if(substr($token, -1) != '"')
1274
-				{
1387
+ 				{
1275 1388
 					$token .= ' '.strtok('"');
1276 1389
 				}
1277 1390
 				else
@@ -1387,7 +1500,8 @@  discard block
 block discarded – undo
1387 1500
 			foreach($search_cols as $key => &$col)
1388 1501
 			{
1389 1502
 				// If the name as given isn't a real column name, and adding the prefix doesn't help, skip it
1390
-				if(!$this->table_def['fd'][$col] && !($col = $this->prefix.array_search($col, $search_cols))) {
1503
+				if(!$this->table_def['fd'][$col] && !($col = $this->prefix.array_search($col, $search_cols)))
1504
+				{
1391 1505
 					// Can't search this column
1392 1506
 					unset($search_cols[$key]);
1393 1507
 					continue;
@@ -1421,10 +1535,13 @@  discard block
 block discarded – undo
1421 1535
 	function _get_columns($only_keys,$extra_cols)
1422 1536
 	{
1423 1537
 		//echo "_get_columns() only_keys="; _debug_array($only_keys); echo "extra_cols="; _debug_array($extra_cols);
1424
-		if ($only_keys === true)	// only primary key
1538
+		if ($only_keys === true)
1539
+		{
1540
+			// only primary key
1425 1541
 		{
1426 1542
 			$cols = $this->db_key_cols;
1427 1543
 		}
1544
+		}
1428 1545
 		else
1429 1546
 		{
1430 1547
 			$cols = array();
@@ -1433,18 +1550,27 @@  discard block
 block discarded – undo
1433 1550
 			{
1434 1551
 				if (!$distinct_checked)
1435 1552
 				{
1436
-					if (stripos($col, 'DISTINCT ') === 0) $col = substr($col, 9);
1553
+					if (stripos($col, 'DISTINCT ') === 0)
1554
+					{
1555
+						$col = substr($col, 9);
1556
+					}
1437 1557
 					$distinct_checked = true;
1438 1558
 				}
1439
-				if (!$col || $col == '*' || $col == $this->table_name.'.*')	// all columns
1559
+				if (!$col || $col == '*' || $col == $this->table_name.'.*')
1560
+				{
1561
+					// all columns
1440 1562
 				{
1441 1563
 					$cols = array_merge($cols,$this->db_cols);
1442 1564
 				}
1565
+				}
1443 1566
 				else	// only the specified columns
1444 1567
 				{
1445
-					if (stripos($col,'as'))	// if there's already an explicit naming of the column, just use it
1568
+					if (stripos($col,'as'))
1569
+					{
1570
+						// if there's already an explicit naming of the column, just use it
1446 1571
 					{
1447 1572
 						$col = preg_replace('/^.*as +([a-z0-9_]+) *$/i','\\1',$col);
1573
+					}
1448 1574
 						$cols[$col] = $col;
1449 1575
 						continue;
1450 1576
 					}
@@ -1459,11 +1585,14 @@  discard block
 block discarded – undo
1459 1585
 				}
1460 1586
 			}
1461 1587
 		}
1462
-		if ($extra_cols)	// extra columns to report
1588
+		if ($extra_cols)
1589
+		{
1590
+			// extra columns to report
1463 1591
 		{
1464 1592
 			foreach(is_array($extra_cols) ? $extra_cols : explode(',',$extra_cols) as $col)
1465 1593
 			{
1466 1594
 				if (stripos($col,'as ')!==false) $col = preg_replace('/^.*as +([a-z0-9_]+) *$/i','\\1',$col);
1595
+		}
1467 1596
 				if (($db_col = array_search($col,$this->db_cols)) !== false)
1468 1597
 				{
1469 1598
 					$cols[$db_col] = $col;
@@ -1508,7 +1637,11 @@  discard block
 block discarded – undo
1508 1637
 			'',false,$op,$query['num_rows']?array((int)$query['start'],$query['num_rows']):(int)$query['start'],
1509 1638
 			$query['col_filter'],$join,$need_full_no_count);
1510 1639
 
1511
-		if (!$rows) $rows = array();	// otherwise false returned from search would be returned as array(false)
1640
+		if (!$rows)
1641
+		{
1642
+			$rows = array();
1643
+		}
1644
+		// otherwise false returned from search would be returned as array(false)
1512 1645
 
1513 1646
 		return $this->total;
1514 1647
 	}
@@ -1587,7 +1720,10 @@  discard block
 block discarded – undo
1587 1720
 		{
1588 1721
 			return $cache[$cache_key];
1589 1722
 		}
1590
-		if (!is_array($value_col)) $value_col = array($value_col);
1723
+		if (!is_array($value_col))
1724
+		{
1725
+			$value_col = array($value_col);
1726
+		}
1591 1727
 
1592 1728
 		$cols = $ret = array();
1593 1729
 		foreach($value_col as $key => $col)
@@ -1595,7 +1731,10 @@  discard block
 block discarded – undo
1595 1731
 			$matches = null;
1596 1732
 			$cols[$key] = preg_match('/AS ([a-z_0-9]+)$/i',$col,$matches) ? $matches[1] : $col;
1597 1733
 		}
1598
-		if (!$order) $order = current($cols);
1734
+		if (!$order)
1735
+		{
1736
+			$order = current($cols);
1737
+		}
1599 1738
 
1600 1739
 		if (($search =& $this->search(array(),($key_col ? $key_col.',' : 'DISTINCT ').implode(',',$value_col),$order,'','',false,'AND',false,$filter)))
1601 1740
 		{
@@ -1621,7 +1760,10 @@  discard block
 block discarded – undo
1621 1760
 				{
1622 1761
 					$data = $row[current($cols)];
1623 1762
 				}
1624
-				if ($data) $ret[$row[$key_col]] = $data;
1763
+				if ($data)
1764
+				{
1765
+					$ret[$row[$key_col]] = $data;
1766
+				}
1625 1767
 			}
1626 1768
 		}
1627 1769
 		return $cache[$cache_key] =& $ret;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1194,7 +1194,7 @@
 block discarded – undo
1194 1194
 	 * @param string &$wildcard ='' on return wildcard char to use, if pattern does not already contain wildcards!
1195 1195
 	 * @param string &$op ='AND' on return boolean operation to use, if pattern does not start with ! we use OR else AND
1196 1196
 	 * @param string $extra_col =null extra column to search
1197
-	 * @param array $search_cols =array() List of columns to search.  If not provided, all columns in $this->db_cols will be considered
1197
+	 * @param string[] $search_cols =array() List of columns to search.  If not provided, all columns in $this->db_cols will be considered
1198 1198
 	 * @return array or column => value pairs
1199 1199
 	 */
1200 1200
 	public function search2criteria($_pattern,&$wildcard='',&$op='AND',$extra_col=null, $search_cols = array())
Please login to merge, or discard this patch.
Spacing   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param string $timestamp_type =null default null=leave them as is, 'ts'|'integer' use integer unix timestamps,
180 180
 	 * 	'object' use Api\DateTime objects or 'string' use DB timestamp (Y-m-d H:i:s) string
181 181
 	 */
182
-	function __construct($app='',$table='',Api\Db $db=null,$column_prefix='',$no_clone=false,$timestamp_type=null)
182
+	function __construct($app = '', $table = '', Api\Db $db = null, $column_prefix = '', $no_clone = false, $timestamp_type = null)
183 183
 	{
184 184
 		// ease the transition to api
185 185
 		if ($app == 'phpgwapi') $app = 'api';
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 
201 201
 			if (!$no_clone) $this->db->set_app($app);
202 202
 
203
-			if ($table) $this->setup_table($app,$table,$column_prefix);
203
+			if ($table) $this->setup_table($app, $table, $column_prefix);
204 204
 		}
205 205
 		$this->init();
206 206
 
207
-		if ((int) $this->debug >= 4)
207
+		if ((int)$this->debug >= 4)
208 208
 		{
209 209
 			echo "<p>".__METHOD__."('$app','$table')</p>\n";
210 210
 			_debug_array($this);
@@ -219,21 +219,21 @@  discard block
 block discarded – undo
219 219
 	 * 	null=leave them as is, 'ts'|'integer' use integer unix timestamps, 'object' use Api\DateTime objects,
220 220
 	 *  'string' use DB timestamp (Y-m-d H:i:s) string
221 221
 	 */
222
-	public function set_times($timestamp_type=false)
222
+	public function set_times($timestamp_type = false)
223 223
 	{
224 224
 		if ($timestamp_type !== false) $this->timestamp_type = $timestamp_type;
225 225
 
226 226
 		// set current time
227
-		switch($this->timestamp_type)
227
+		switch ($this->timestamp_type)
228 228
 		{
229 229
 			case 'object':
230 230
 				$this->now = new Api\DateTime('now');
231 231
 				break;
232 232
 			case 'string':
233
-				$this->now = Api\DateTime::to('now',Api\DateTime::DATABASE);
233
+				$this->now = Api\DateTime::to('now', Api\DateTime::DATABASE);
234 234
 				break;
235 235
 			default:
236
-				$this->now = Api\DateTime::to('now','ts');
236
+				$this->now = Api\DateTime::to('now', 'ts');
237 237
 		}
238 238
 		$this->tz_offset_s = Api\DateTime::tz_offset_s();
239 239
 	}
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 	 * @param string $table table-name
248 248
 	 * @param string $colum_prefix ='' column prefix to automatic remove from the column-name, if the column name starts with it
249 249
 	 */
250
-	function setup_table($app,$table,$colum_prefix='')
250
+	function setup_table($app, $table, $colum_prefix = '')
251 251
 	{
252 252
 		$this->table_name = $table;
253
-		$this->table_def = $this->db->get_table_definitions($app,$table);
253
+		$this->table_def = $this->db->get_table_definitions($app, $table);
254 254
 		if (!$this->table_def || !is_array($this->table_def['fd']))
255 255
 		{
256 256
 			throw new Api\Exception\WrongParameter(__METHOD__."('$app','$table'): No table definition for '$table' found !!!");
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 		$this->db_key_cols = $this->db_data_cols = $this->db_cols = array();
259 259
 		$this->autoinc_id = '';
260 260
 		$len_prefix = strlen($colum_prefix);
261
-		foreach($this->table_def['fd'] as $col => $def)
261
+		foreach ($this->table_def['fd'] as $col => $def)
262 262
 		{
263 263
 			$name = $col;
264
-			if ($len_prefix && substr($name,0,$len_prefix) == $colum_prefix)
264
+			if ($len_prefix && substr($name, 0, $len_prefix) == $colum_prefix)
265 265
 			{
266
-				$name = substr($col,$len_prefix);
266
+				$name = substr($col, $len_prefix);
267 267
 			}
268
-			if (in_array($col,$this->table_def['pk']))
268
+			if (in_array($col, $this->table_def['pk']))
269 269
 			{
270 270
 				$this->db_key_cols[$col] = $name;
271 271
 			}
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 			if ($def['type'] == 'bool') $this->has_bools = true;
283 283
 
284
-			foreach($this->table_def['uc'] as $k => $uni_index)
284
+			foreach ($this->table_def['uc'] as $k => $uni_index)
285 285
 			{
286
-				if (is_array($uni_index) && in_array($name,$uni_index))
286
+				if (is_array($uni_index) && in_array($name, $uni_index))
287 287
 				{
288 288
 					$this->db_uni_cols[$k][$col] = $name;
289 289
 				}
290
-				elseif($name === $uni_index)
290
+				elseif ($name === $uni_index)
291 291
 				{
292 292
 					$this->db_uni_cols[$col] = $name;
293 293
 				}
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	function convert_all_timestamps()
303 303
 	{
304 304
 		$check_already_included = !empty($this->timestamps);
305
-		foreach($this->table_def['fd'] as $name => $data)
305
+		foreach ($this->table_def['fd'] as $name => $data)
306 306
 		{
307
-			if ($data['type'] == 'timestamp' && (!$check_already_included || !in_array($name,$this->timestamps)))
307
+			if ($data['type'] == 'timestamp' && (!$check_already_included || !in_array($name, $this->timestamps)))
308 308
 			{
309 309
 				$this->timestamps[] = $name;
310 310
 			}
@@ -318,22 +318,22 @@  discard block
 block discarded – undo
318 318
 	 */
319 319
 	function data_merge($new)
320 320
 	{
321
-		if ((int) $this->debug >= 4) echo "<p>so_sql::data_merge(".print_r($new,true).")</p>\n";
321
+		if ((int)$this->debug >= 4) echo "<p>so_sql::data_merge(".print_r($new, true).")</p>\n";
322 322
 
323 323
 		if (!is_array($new) || !count($new))
324 324
 		{
325 325
 			return;
326 326
 		}
327
-		foreach($this->db_cols as $db_col => $col)
327
+		foreach ($this->db_cols as $db_col => $col)
328 328
 		{
329
-			if (array_key_exists($col,$new))
329
+			if (array_key_exists($col, $new))
330 330
 			{
331 331
 				$this->data[$col] = $new[$col];
332 332
 			}
333 333
 		}
334
-		foreach($this->non_db_cols as $db_col => $col)
334
+		foreach ($this->non_db_cols as $db_col => $col)
335 335
 		{
336
-			if (array_key_exists($col,$new))
336
+			if (array_key_exists($col, $new))
337 337
 			{
338 338
 				$this->data[$col] = $new[$col];
339 339
 			}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		{
343 343
 			$this->data[self::USER_TIMEZONE_READ] = $new[self::USER_TIMEZONE_READ];
344 344
 		}
345
-		if ((int) $this->debug >= 4) _debug_array($this->data);
345
+		if ((int)$this->debug >= 4) _debug_array($this->data);
346 346
 	}
347 347
 
348 348
 	/**
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
367 367
 	 * @return array
368 368
 	 */
369
-	function db2data($data=null)
369
+	function db2data($data = null)
370 370
 	{
371 371
 		if (!is_array($data))
372 372
 		{
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		}
375 375
 		if ($this->timestamps)
376 376
 		{
377
-			foreach($this->timestamps as $name)
377
+			foreach ($this->timestamps as $name)
378 378
 			{
379 379
 				if (isset($data[$name]) && $data[$name])
380 380
 				{
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 					}
385 385
 					else
386 386
 					{
387
-						$data[$name] = Api\DateTime::server2user($data[$name],$this->timestamp_type);
387
+						$data[$name] = Api\DateTime::server2user($data[$name], $this->timestamp_type);
388 388
 					}
389 389
 				}
390 390
 			}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 					throw new Api\Exception\WrongParameter(__METHOD__."(): No table definition for '$this->table' found !!!");
401 401
 				}
402 402
 			}
403
-			foreach($this->table_def['fd'] as $col => $def)
403
+			foreach ($this->table_def['fd'] as $col => $def)
404 404
 			{
405 405
 				if ($def['type'] == 'bool' && isset($data[$col]))
406 406
 				{
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
433 433
 	 * @return array
434 434
 	 */
435
-	function data2db($data=null)
435
+	function data2db($data = null)
436 436
 	{
437 437
 		if (!is_array($data))
438 438
 		{
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 		}
441 441
 		if ($this->timestamps)
442 442
 		{
443
-			foreach($this->timestamps as $name)
443
+			foreach ($this->timestamps as $name)
444 444
 			{
445 445
 				if (isset($data[$name]) && $data[$name])
446 446
 				{
447
-					$data[$name] = Api\DateTime::user2server($data[$name],$this->timestamp_type);
447
+					$data[$name] = Api\DateTime::user2server($data[$name], $this->timestamp_type);
448 448
 				}
449 449
 			}
450 450
 		}
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 * @param array $keys =array() array with keys in form internalName => value
458 458
 	 * @return array internal data after init
459 459
 	 */
460
-	function init($keys=array())
460
+	function init($keys = array())
461 461
 	{
462 462
 		$this->data = array();
463 463
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
482 482
 	 * @return array|boolean data if row could be retrived else False
483 483
 	 */
484
-	function read($keys,$extra_cols='',$join='')
484
+	function read($keys, $extra_cols = '', $join = '')
485 485
 	{
486 486
 		if (!is_array($keys))
487 487
 		{
@@ -502,16 +502,16 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 		if (!$query)	// no primary key in keys, lets try the data_cols for a unique key
504 504
 		{
505
-			foreach($this->db_uni_cols as $db_col => $col)
505
+			foreach ($this->db_uni_cols as $db_col => $col)
506 506
 			{
507 507
 				if (!is_array($col) && $this->data[$col] != '')
508 508
 				{
509 509
 					$query[$db_col] = $this->data[$col];
510 510
 				}
511
-				elseif(is_array($col))
511
+				elseif (is_array($col))
512 512
 				{
513 513
 					$q = array();
514
-					foreach($col as $db_c => $c)
514
+					foreach ($col as $db_c => $c)
515 515
 					{
516 516
 						if ($this->data[$col] == '')
517 517
 						{
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		}
527 527
 		if (!$query)	// no unique key in keys, lets try everything else
528 528
 		{
529
-			foreach($this->db_data_cols as $db_col => $col)
529
+			foreach ($this->db_data_cols as $db_col => $col)
530 530
 			{
531 531
 				if ($this->data[$col] != '')
532 532
 				{
@@ -542,27 +542,27 @@  discard block
 block discarded – undo
542 542
 		}
543 543
 		if ($join)	// Prefix the columns with the table-name, as they might exist in the join
544 544
 		{
545
-			foreach($query as $col => $val)
545
+			foreach ($query as $col => $val)
546 546
 			{
547
-				if (is_int($col) || strpos($join,$col) === false) continue;
548
-				$query[] = $this->db->expression($this->table_name,$this->table_name.'.',array($col=>$val));
547
+				if (is_int($col) || strpos($join, $col) === false) continue;
548
+				$query[] = $this->db->expression($this->table_name, $this->table_name.'.', array($col=>$val));
549 549
 				unset($query[$col]);
550 550
 			}
551 551
 		}
552 552
 		// copy direct SQL parts from $keys
553
-		for($i = 0; is_array($keys) && isset($keys[$i]); ++$i)
553
+		for ($i = 0; is_array($keys) && isset($keys[$i]); ++$i)
554 554
 		{
555 555
 			$query[] = $keys[$i];
556 556
 		}
557
-		foreach($this->db->select($this->table_name,'*'.($extra_cols?','.(is_array($extra_cols)?implode(',',$extra_cols):$extra_cols):''),
558
-			$query,__LINE__,__FILE__,False,'',$this->app,0,$join) as $row)
557
+		foreach ($this->db->select($this->table_name, '*'.($extra_cols ? ','.(is_array($extra_cols) ?implode(',', $extra_cols) : $extra_cols) : ''),
558
+			$query, __LINE__, __FILE__, False, '', $this->app, 0, $join) as $row)
559 559
 		{
560 560
 			$cols = $this->db_cols;
561 561
 			if ($extra_cols)	// extra columns to report
562 562
 			{
563
-				foreach(is_array($extra_cols) ? $extra_cols : array($extra_cols) as $col)
563
+				foreach (is_array($extra_cols) ? $extra_cols : array($extra_cols) as $col)
564 564
 				{
565
-					if (FALSE!==stripos($col,' as ')) $col = preg_replace('/^.* as *([a-z0-9_]+) *$/i','\\1',$col);
565
+					if (FALSE !== stripos($col, ' as ')) $col = preg_replace('/^.* as *([a-z0-9_]+) *$/i', '\\1', $col);
566 566
 					$cols[$col] = $col;
567 567
 				}
568 568
 			}
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 			// store user timezone used for reading
576 576
 			$this->data[self::USER_TIMEZONE_READ] = Api\DateTime::$user_timezone->getName();
577 577
 
578
-			if ((int) $this->debug >= 4)
578
+			if ((int)$this->debug >= 4)
579 579
 			{
580 580
 				echo "data =\n"; _debug_array($this->data);
581 581
 			}
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		{
586 586
 			unset($this->data[$this->db_key_cols[$this->autoinc_id]]);
587 587
 		}
588
-		if ((int) $this->debug >= 4) echo "nothing found !!!</p>\n";
588
+		if ((int)$this->debug >= 4) echo "nothing found !!!</p>\n";
589 589
 
590 590
 		$this->db2data();
591 591
 
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	 * @param string|array $extra_where =null extra where clause, eg. to check an etag, returns true if no affected rows!
600 600
 	 * @return int|boolean 0 on success, or errno != 0 on error, or true if $extra_where is given and no rows affected
601 601
 	 */
602
-	function save($keys=null,$extra_where=null)
602
+	function save($keys = null, $extra_where = null)
603 603
 	{
604 604
 		if (is_array($keys) && count($keys)) $this->data_merge($keys);
605 605
 
@@ -618,65 +618,65 @@  discard block
 block discarded – undo
618 618
 		}
619 619
 		$this->data2db();
620 620
 
621
-		if ((int) $this->debug >= 4) { echo "so_sql::save(".print_r($keys,true).") autoinc_id='$this->autoinc_id', data="; _debug_array($this->data); }
621
+		if ((int)$this->debug >= 4) { echo "so_sql::save(".print_r($keys, true).") autoinc_id='$this->autoinc_id', data="; _debug_array($this->data); }
622 622
 
623 623
 		if ($this->autoinc_id && !$this->data[$this->db_key_cols[$this->autoinc_id]])	// insert with auto id
624 624
 		{
625
-			foreach($this->db_cols as $db_col => $col)
625
+			foreach ($this->db_cols as $db_col => $col)
626 626
 			{
627 627
 				if (!$this->autoinc_id || $db_col != $this->autoinc_id)	// not write auto-inc-id
628 628
 				{
629
-					if (!array_key_exists($col,$this->data) && 	// handling of unset columns in $this->data
630
-						(isset($this->table_def['fd'][$db_col]['default']) ||	// we have a default value
629
+					if (!array_key_exists($col, $this->data) && // handling of unset columns in $this->data
630
+						(isset($this->table_def['fd'][$db_col]['default']) || // we have a default value
631 631
 						 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))	// column is nullable
632 632
 					{
633
-						continue;	// no need to write that (unset) column
633
+						continue; // no need to write that (unset) column
634 634
 					}
635 635
 					if ($this->table_def['fd'][$db_col]['type'] == 'varchar' &&
636 636
 						strlen($this->data[$col]) > $this->table_def['fd'][$db_col]['precision'])
637 637
 					{
638 638
 						// truncate the field to mamimum length, if upper layers didn't care
639
-						$data[$db_col] = substr($this->data[$col],0,$this->table_def['fd'][$db_col]['precision']);
639
+						$data[$db_col] = substr($this->data[$col], 0, $this->table_def['fd'][$db_col]['precision']);
640 640
 					}
641 641
 					else
642 642
 					{
643
-						$data[$db_col] = (string) $this->data[$col] === '' && $this->empty_on_write == 'NULL' ? null : $this->data[$col];
643
+						$data[$db_col] = (string)$this->data[$col] === '' && $this->empty_on_write == 'NULL' ? null : $this->data[$col];
644 644
 					}
645 645
 				}
646 646
 			}
647
-			$this->db->insert($this->table_name,$data,false,__LINE__,__FILE__,$this->app);
647
+			$this->db->insert($this->table_name, $data, false, __LINE__, __FILE__, $this->app);
648 648
 
649 649
 			if ($this->autoinc_id)
650 650
 			{
651
-				$this->data[$this->db_key_cols[$this->autoinc_id]] = $this->db->get_last_insert_id($this->table_name,$this->autoinc_id);
651
+				$this->data[$this->db_key_cols[$this->autoinc_id]] = $this->db->get_last_insert_id($this->table_name, $this->autoinc_id);
652 652
 			}
653 653
 		}
654 654
 		else // insert in table without auto id or update of existing row, dont write colums unset in $this->data
655 655
 		{
656
-			foreach($this->db_data_cols as $db_col => $col)
656
+			foreach ($this->db_data_cols as $db_col => $col)
657 657
 			{
658 658
 				// we need to update columns set to null: after a $this->data[$col]=null:
659 659
 				// - array_key_exits($col,$this->data) === true
660 660
 				// - isset($this->data[$col]) === false
661
-				if (!array_key_exists($col,$this->data) &&	// handling of unset columns in $this->data
662
-					($this->autoinc_id ||			// update of table with auto id or
663
-					 isset($this->table_def['fd'][$db_col]['default']) ||	// we have a default value or
661
+				if (!array_key_exists($col, $this->data) && // handling of unset columns in $this->data
662
+					($this->autoinc_id || // update of table with auto id or
663
+					 isset($this->table_def['fd'][$db_col]['default']) || // we have a default value or
664 664
 					 !isset($this->table_def['fd'][$db_col]['nullable']) || $this->table_def['fd'][$db_col]['nullable']))	// column is nullable
665 665
 				{
666
-					continue;	// no need to write that (unset) column
666
+					continue; // no need to write that (unset) column
667 667
 				}
668
-				$data[$db_col] = !is_object($this->data[$col]) && (string) $this->data[$col] === '' && $this->empty_on_write == 'NULL' ? null : $this->data[$col];
668
+				$data[$db_col] = !is_object($this->data[$col]) && (string)$this->data[$col] === '' && $this->empty_on_write == 'NULL' ? null : $this->data[$col];
669 669
 			}
670 670
 			// allow to add direct sql updates, eg. "etag=etag+1" with int keys
671 671
 			if (is_array($keys) && isset($keys[0]))
672 672
 			{
673
-				for($n=0; isset($keys[$n]); ++$n)
673
+				for ($n = 0; isset($keys[$n]); ++$n)
674 674
 				{
675 675
 					$data[] = $keys[$n];
676 676
 				}
677 677
 			}
678 678
 			$keys = $extra_where;
679
-			foreach($this->db_key_cols as $db_col => $col)
679
+			foreach ($this->db_key_cols as $db_col => $col)
680 680
 			{
681 681
 				$keys[$db_col] = $this->data[$col];
682 682
 			}
@@ -687,16 +687,16 @@  discard block
 block discarded – undo
687 687
 			}
688 688
 			if ($this->autoinc_id)
689 689
 			{
690
-				$this->db->update($this->table_name,$data,$keys,__LINE__,__FILE__,$this->app);
690
+				$this->db->update($this->table_name, $data, $keys, __LINE__, __FILE__, $this->app);
691 691
 				if (($nothing_affected = !$this->db->Errno && !$this->db->affected_rows()) && $extra_where)
692 692
 				{
693
-					return true;	// extra_where not met, eg. etag wrong
693
+					return true; // extra_where not met, eg. etag wrong
694 694
 				}
695 695
 			}
696 696
 			// always try an insert if we have no autoinc_id, as we dont know if the data exists
697 697
 			if (!$this->autoinc_id || $nothing_affected)
698 698
 			{
699
-				$this->db->insert($this->table_name,$data,$keys,__LINE__,__FILE__,$this->app);
699
+				$this->db->insert($this->table_name, $data, $keys, __LINE__, __FILE__, $this->app);
700 700
 			}
701 701
 		}
702 702
 		$this->db2data();
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 * @param boolean $merge =true if true $fields will be merged with $this->data (after update!), otherwise $this->data will be just $fields
712 712
 	 * @return int|boolean 0 on success, or errno != 0 on error, or true if $extra_where is given and no rows affected
713 713
 	 */
714
-	function update($_fields,$merge=true)
714
+	function update($_fields, $merge = true)
715 715
 	{
716 716
 		if ($merge) $this->data_merge($_fields);
717 717
 
@@ -719,23 +719,23 @@  discard block
 block discarded – undo
719 719
 
720 720
 		// extract the keys from $fields or - if not set there - from $this->data
721 721
 		$keys = array();
722
-		foreach($this->db_key_cols as $col => $name)
722
+		foreach ($this->db_key_cols as $col => $name)
723 723
 		{
724 724
 			$keys[$col] = isset($fields[$name]) ? $fields[$name] : $this->data[$name];
725 725
 			unset($fields[$name]);
726 726
 		}
727 727
 		// extract the data from $fields
728 728
 		$data = array();
729
-		foreach($this->db_data_cols as $col => $name)
729
+		foreach ($this->db_data_cols as $col => $name)
730 730
 		{
731
-			if (array_key_exists($name,$fields))
731
+			if (array_key_exists($name, $fields))
732 732
 			{
733 733
 				$data[$col] = $fields[$name];
734 734
 				unset($fields[$name]);
735 735
 			}
736 736
 		}
737 737
 		// add direct sql like 'etag=etag+1' (it has integer keys)
738
-		foreach($fields as $key => $value)
738
+		foreach ($fields as $key => $value)
739 739
 		{
740 740
 			if (is_int($key))
741 741
 			{
@@ -744,9 +744,9 @@  discard block
 block discarded – undo
744 744
 		}
745 745
 		if (!$data)
746 746
 		{
747
-			return 0;	// nothing to update
747
+			return 0; // nothing to update
748 748
 		}
749
-		if (!$this->db->update($this->table_name,$data,$keys,__LINE__,__FILE__,$this->app))
749
+		if (!$this->db->update($this->table_name, $data, $keys, __LINE__, __FILE__, $this->app))
750 750
 		{
751 751
 			return $this->db->Errno;
752 752
 		}
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	 * @param boolean $only_return_query =false return $query of delete call to db object, but not run it (used by so_sql_cf!)
761 761
 	 * @return int|array affected rows, should be 1 if ok, 0 if an error or array with id's if $only_return_ids
762 762
 	 */
763
-	function delete($keys=null,$only_return_query=false)
763
+	function delete($keys = null, $only_return_query = false)
764 764
 	{
765 765
 		if ($this->autoinc_id && $keys && !is_array($keys))
766 766
 		{
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		else	// data and keys are supplied in $keys
775 775
 		{
776 776
 			$data = $keys; $keys = array();
777
-			foreach($this->db_cols as $db_col => $col)
777
+			foreach ($this->db_cols as $db_col => $col)
778 778
 			{
779 779
 				if (isset($data[$col]))
780 780
 				{
@@ -784,13 +784,13 @@  discard block
 block discarded – undo
784 784
 		}
785 785
 		$data = $this->data2db($data);
786 786
 
787
-		foreach($keys as $db_col => $col)
787
+		foreach ($keys as $db_col => $col)
788 788
 		{
789 789
 			$query[$db_col] = $data[$col];
790 790
 		}
791 791
 		if ($only_return_query) return $query;
792 792
 
793
-		$this->db->delete($this->table_name,$query,__LINE__,__FILE__,$this->app);
793
+		$this->db->delete($this->table_name, $query, __LINE__, __FILE__, $this->app);
794 794
 
795 795
 		return $this->db->affected_rows();
796 796
 	}
@@ -818,15 +818,15 @@  discard block
 block discarded – undo
818 818
 	 * @todo return an interator instead of an array
819 819
 	 * @return array|NULL array of matching rows (the row is an array of the cols) or NULL
820 820
 	 */
821
-	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
821
+	function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false)
822 822
 	{
823 823
 		//error_log(__METHOD__.'('.array2string(array_combine(array_slice(array('criteria','only_keys','order_by','extra_cols','wildcard','empty','op','start','filter','join','need_full_no_count'), 0, count(func_get_args())), func_get_args())).')');
824
-		if ((int) $this->debug >= 4) echo "<p>so_sql::search(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
824
+		if ((int)$this->debug >= 4) echo "<p>so_sql::search(".print_r($criteria, true).",'$only_keys','$order_by',".print_r($extra_cols, true).",'$wildcard','$empty','$op','$start',".print_r($filter, true).",'$join')</p>\n";
825 825
 
826 826
 		// if extending class or instanciator set columns to search, convert string criteria to array
827 827
 		if ($criteria && !is_array($criteria))
828 828
 		{
829
-			$search = $this->search2criteria($criteria,$wildcard,$op);
829
+			$search = $this->search2criteria($criteria, $wildcard, $op);
830 830
 			$criteria = array($search);
831 831
 		}
832 832
 		if (!is_array($criteria))
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		else
837 837
 		{
838 838
 			$criteria = $this->data2db($criteria);
839
-			foreach($criteria as $col => $val)
839
+			foreach ($criteria as $col => $val)
840 840
 			{
841 841
 				if (is_int($col))
842 842
 				{
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 				}
845 845
 				elseif ($empty || $val != '')
846 846
 				{
847
-					if (!($db_col = array_search($col,$this->db_cols)))
847
+					if (!($db_col = array_search($col, $this->db_cols)))
848 848
 					{
849 849
 						$db_col = $col;
850 850
 					}
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 							$this->table_def['fd'][$db_col]['nullable'] !== false)
856 856
 						{
857 857
 							unset($criteria[$col]);
858
-							$query[] =  '(' . $db_col . ' IS NULL OR ' . $db_col . " = '')";
858
+							$query[] = '('.$db_col.' IS NULL OR '.$db_col." = '')";
859 859
 						}
860 860
 						else
861 861
 						{
@@ -863,10 +863,10 @@  discard block
 block discarded – undo
863 863
 						}
864 864
 					}
865 865
 					elseif ($wildcard || $criteria[$col][0] == '!' ||
866
-						is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false))
866
+						is_string($criteria[$col]) && (strpos($criteria[$col], '*') !== false || strpos($criteria[$col], '?') !== false))
867 867
 					{
868 868
 						// if search pattern alread contains a wildcard, do NOT add further ones automatic
869
-						if (is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false))
869
+						if (is_string($criteria[$col]) && (strpos($criteria[$col], '*') !== false || strpos($criteria[$col], '?') !== false))
870 870
 						{
871 871
 							$wildcard = '';
872 872
 						}
@@ -875,19 +875,19 @@  discard block
 block discarded – undo
875 875
 						if ($criteria[$col][0] == '!')
876 876
 						{
877 877
 							$cmp_op = ' NOT'.$cmp_op;
878
-							$criteria[$col] = substr($criteria[$col],1);
878
+							$criteria[$col] = substr($criteria[$col], 1);
879 879
 							$negate = true;
880 880
 						}
881
-						foreach(explode(' ',$criteria[$col]) as $crit)
881
+						foreach (explode(' ', $criteria[$col]) as $crit)
882 882
 						{
883 883
 							$query[] = ($negate ? ' ('.$db_col.' IS NULL OR ' : '').$db_col.$cmp_op.
884
-								$this->db->quote($wildcard.str_replace(array('%','_','*','?'),array('\\%','\\_','%','_'),$crit).$wildcard).
884
+								$this->db->quote($wildcard.str_replace(array('%', '_', '*', '?'), array('\\%', '\\_', '%', '_'), $crit).$wildcard).
885 885
 								($negate ? ') ' : '');
886 886
 						}
887 887
 					}
888
-					elseif (strpos($db_col,'.') !== false)	// we have a table-name specified
888
+					elseif (strpos($db_col, '.') !== false)	// we have a table-name specified
889 889
 					{
890
-						list($table,$only_col) = explode('.',$db_col);
890
+						list($table, $only_col) = explode('.', $db_col);
891 891
 						$type = $this->db->get_column_attribute($only_col, $table, true, 'type');
892 892
 						if (empty($type))
893 893
 						{
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
 						}
896 896
 						if (is_array($val) && count($val) > 1)
897 897
 						{
898
-							foreach($val as &$v)
898
+							foreach ($val as &$v)
899 899
 							{
900 900
 								$v = $this->db->quote($v, $type);
901 901
 							}
902
-							$query[] = $sql = $db_col.' IN (' .implode(',',$val).')';
902
+							$query[] = $sql = $db_col.' IN ('.implode(',', $val).')';
903 903
 						}
904 904
 						else
905 905
 						{
906
-							$query[] = $db_col.'='.$this->db->quote(is_array($val)?array_shift($val):$val,$type);
906
+							$query[] = $db_col.'='.$this->db->quote(is_array($val) ?array_shift($val) : $val, $type);
907 907
 						}
908 908
 					}
909 909
 					else
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 					}
913 913
 				}
914 914
 			}
915
-			if (is_array($query) && $op != 'AND') $query = $this->db->column_data_implode(' '.$op.' ',$query);
915
+			if (is_array($query) && $op != 'AND') $query = $this->db->column_data_implode(' '.$op.' ', $query);
916 916
 		}
917 917
 		if (is_array($filter))
918 918
 		{
@@ -920,19 +920,19 @@  discard block
 block discarded – undo
920 920
 			$data2db_filter = $this->data2db($filter);
921 921
 			if (!is_array($data2db_filter)) {
922 922
 				echo function_backtrace()."<br/>\n";
923
-				echo "filter=";_debug_array($filter);
924
-				echo "data2db(filter)=";_debug_array($data2db_filter);
923
+				echo "filter="; _debug_array($filter);
924
+				echo "data2db(filter)="; _debug_array($data2db_filter);
925 925
 			}
926
-			foreach($data2db_filter as $col => $val)
926
+			foreach ($data2db_filter as $col => $val)
927 927
 			{
928 928
 				if ($val !== '')
929 929
 				{
930 930
 					// check if a db-internal name conversation necessary
931
-					if (!is_int($col) && ($c = array_search($col,$this->db_cols)))
931
+					if (!is_int($col) && ($c = array_search($col, $this->db_cols)))
932 932
 					{
933
-						$col = $this->table_name . '.' . $c;
933
+						$col = $this->table_name.'.'.$c;
934 934
 					}
935
-					if(is_int($col))
935
+					if (is_int($col))
936 936
 					{
937 937
 						$db_filter[] = $val;
938 938
 					}
@@ -950,35 +950,35 @@  discard block
 block discarded – undo
950 950
 			{
951 951
 				if ($op != 'AND')
952 952
 				{
953
-					$db_filter[] = '('.$this->db->column_data_implode(' '.$op.' ',$query).')';
953
+					$db_filter[] = '('.$this->db->column_data_implode(' '.$op.' ', $query).')';
954 954
 				}
955 955
 				else
956 956
 				{
957
-					$db_filter = array_merge($db_filter,$query);
957
+					$db_filter = array_merge($db_filter, $query);
958 958
 				}
959 959
 			}
960 960
 			$query = $db_filter;
961 961
 		}
962
-		if ((int) $this->debug >= 4)
962
+		if ((int)$this->debug >= 4)
963 963
 		{
964
-			echo "<p>so_sql::search(,only_keys=$only_keys,order_by='$order_by',wildcard='$wildcard',empty=$empty,$op,start='$start',".print_r($filter,true).") query=".print_r($query,true).", total='$this->total'</p>\n";
964
+			echo "<p>so_sql::search(,only_keys=$only_keys,order_by='$order_by',wildcard='$wildcard',empty=$empty,$op,start='$start',".print_r($filter, true).") query=".print_r($query, true).", total='$this->total'</p>\n";
965 965
 			echo "<br>criteria = "; _debug_array($criteria);
966 966
 		}
967 967
 		if ($only_keys === true)
968 968
 		{
969 969
 			$colums = array_keys($this->db_key_cols);
970
-			foreach($colums as &$column)
970
+			foreach ($colums as &$column)
971 971
 			{
972
-				$column = $this->table_name . '.' . $column;
972
+				$column = $this->table_name.'.'.$column;
973 973
 			}
974 974
 		}
975 975
 		elseif (is_array($only_keys))
976 976
 		{
977 977
 			$colums = array();
978
-			foreach($only_keys as $key => $col)
978
+			foreach ($only_keys as $key => $col)
979 979
 			{
980 980
 				//Convert ambiguous columns to prefixed tablename.column name
981
-				$colums[] = ($db_col = array_search($col,$this->db_cols)) ?  $this->table_name .'.'.$db_col.' AS '.$col :$col;
981
+				$colums[] = ($db_col = array_search($col, $this->db_cols)) ? $this->table_name.'.'.$db_col.' AS '.$col : $col;
982 982
 			}
983 983
 		}
984 984
 		elseif (!$only_keys)
@@ -1008,20 +1008,20 @@  discard block
 block discarded – undo
1008 1008
 			{
1009 1009
 				$colums[$key] = $this->table_name.'.'.$this->autoinc_id.' AS '.$this->autoinc_id;
1010 1010
 			}
1011
-			elseif (!is_array($colums) && strpos($colums,$this->autoinc_id) !== false)
1011
+			elseif (!is_array($colums) && strpos($colums, $this->autoinc_id) !== false)
1012 1012
 			{
1013
-				$colums = preg_replace('/(?<! AS)([ ,]+)'.preg_quote($this->autoinc_id).'([ ,]+)/','\\1'.$this->table_name.'.'.$this->autoinc_id.' AS '.$this->autoinc_id.'\\2',$colums);
1013
+				$colums = preg_replace('/(?<! AS)([ ,]+)'.preg_quote($this->autoinc_id).'([ ,]+)/', '\\1'.$this->table_name.'.'.$this->autoinc_id.' AS '.$this->autoinc_id.'\\2', $colums);
1014 1014
 			}
1015 1015
 		}
1016
-		$num_rows = 0;	// as spec. in max_matches in the user-prefs
1017
-		if (is_array($start)) list($start,$num_rows) = $start;
1016
+		$num_rows = 0; // as spec. in max_matches in the user-prefs
1017
+		if (is_array($start)) list($start, $num_rows) = $start;
1018 1018
 
1019 1019
 		// fix GROUP BY clause to contain all non-aggregate selected columns
1020
-		if ($order_by && stripos($order_by,'GROUP BY') !== false)
1020
+		if ($order_by && stripos($order_by, 'GROUP BY') !== false)
1021 1021
 		{
1022 1022
 			$order_by = $this->fix_group_by_columns($order_by, $colums, $this->table_name, $this->autoinc_id);
1023 1023
 		}
1024
-		elseif ($order_by && stripos($order_by,'ORDER BY')===false && stripos($order_by,'GROUP BY')===false && stripos($order_by,'HAVING')===false)
1024
+		elseif ($order_by && stripos($order_by, 'ORDER BY') === false && stripos($order_by, 'GROUP BY') === false && stripos($order_by, 'HAVING') === false)
1025 1025
 		{
1026 1026
 			$order_by = 'ORDER BY '.$order_by;
1027 1027
 		}
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
 				);
1045 1045
 				if (!$union_cols)	// union used the colum-names of the first query
1046 1046
 				{
1047
-					$union_cols = $this->_get_columns($only_keys,$extra_cols);
1047
+					$union_cols = $this->_get_columns($only_keys, $extra_cols);
1048 1048
 				}
1049
-				return true;	// waiting for further calls, before running the union-query
1049
+				return true; // waiting for further calls, before running the union-query
1050 1050
 			}
1051 1051
 			// running the union query now
1052 1052
 			if ($start !== false)	// need to get the total too, saved in $this->total
@@ -1057,10 +1057,10 @@  discard block
 block discarded – undo
1057 1057
 				}
1058 1058
 				else	// cant do a count, have to run the query without limit
1059 1059
 				{
1060
-					$this->total = $this->db->union($union,__LINE__,__FILE__)->NumRows();
1060
+					$this->total = $this->db->union($union, __LINE__, __FILE__)->NumRows();
1061 1061
 				}
1062 1062
 			}
1063
-			$rs = $this->db->union($union,__LINE__,__FILE__,$order_by,$start,$num_rows);
1063
+			$rs = $this->db->union($union, __LINE__, __FILE__, $order_by, $start, $num_rows);
1064 1064
 			if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1065 1065
 
1066 1066
 			$cols = $union_cols;
@@ -1074,21 +1074,21 @@  discard block
 block discarded – undo
1074 1074
 				{
1075 1075
 					$mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ';
1076 1076
 				}
1077
-				elseif (!$need_full_no_count && (!$join || stripos($join,'LEFT JOIN')!==false))
1077
+				elseif (!$need_full_no_count && (!$join || stripos($join, 'LEFT JOIN') !== false))
1078 1078
 				{
1079
-					$this->total = $this->db->select($this->table_name,'COUNT(*)',$query,__LINE__,__FILE__,false,'',$this->app,0,$join)->fetchColumn();
1079
+					$this->total = $this->db->select($this->table_name, 'COUNT(*)', $query, __LINE__, __FILE__, false, '', $this->app, 0, $join)->fetchColumn();
1080 1080
 				}
1081 1081
 				else	// cant do a count, have to run the query without limit
1082 1082
 				{
1083
-					$this->total = $this->db->select($this->table_name,$colums,$query,__LINE__,__FILE__,false,$order_by,false,0,$join)->NumRows();
1083
+					$this->total = $this->db->select($this->table_name, $colums, $query, __LINE__, __FILE__, false, $order_by, false, 0, $join)->NumRows();
1084 1084
 				}
1085 1085
 			}
1086
-			$rs = $this->db->select($this->table_name,$mysql_calc_rows.$colums,$query,__LINE__,__FILE__,
1087
-				$start,$order_by,$this->app,$num_rows,$join);
1086
+			$rs = $this->db->select($this->table_name, $mysql_calc_rows.$colums, $query, __LINE__, __FILE__,
1087
+				$start, $order_by, $this->app, $num_rows, $join);
1088 1088
 			if ($this->debug) error_log(__METHOD__."() ".$this->db->Query_ID->sql);
1089
-			$cols = $this->_get_columns($only_keys,$extra_cols);
1089
+			$cols = $this->_get_columns($only_keys, $extra_cols);
1090 1090
 		}
1091
-		if ((int) $this->debug >= 4) echo "<p>sql='{$this->db->Query_ID->sql}'</p>\n";
1091
+		if ((int)$this->debug >= 4) echo "<p>sql='{$this->db->Query_ID->sql}'</p>\n";
1092 1092
 
1093 1093
 		if ($mysql_calc_rows)
1094 1094
 		{
@@ -1097,14 +1097,14 @@  discard block
 block discarded – undo
1097 1097
 		// ToDo: Implement that as an iterator, as $rs is also an interator and we could return one instead of an array
1098 1098
 		if ($this->search_return_iterator)
1099 1099
 		{
1100
-			return new Db2DataIterator($this,$rs);
1100
+			return new Db2DataIterator($this, $rs);
1101 1101
 		}
1102 1102
 		$arr = array();
1103 1103
 		$n = 0;
1104
-		if ($rs) foreach($rs as $row)
1104
+		if ($rs) foreach ($rs as $row)
1105 1105
 		{
1106 1106
 			$data = array();
1107
-			foreach($cols as $db_col => $col)
1107
+			foreach ($cols as $db_col => $col)
1108 1108
 			{
1109 1109
 				$data[$col] = (isset($row[$db_col]) ? $row[$db_col] : $row[$col]);
1110 1110
 			}
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 		$matches = null;
1135 1135
 		if (substr($GLOBALS['egw']->db->Type, 0, 5) == 'mysql' || !preg_match('/(GROUP BY .*)(HAVING.*|ORDER BY.*)?$/iU', $group_by, $matches))
1136 1136
 		{
1137
-			return $group_by;	// nothing to do
1137
+			return $group_by; // nothing to do
1138 1138
 		}
1139 1139
 		$changes = 0;
1140 1140
 		$group_by_cols = preg_split('/, */', trim(substr($matches[1], 9)));
@@ -1144,9 +1144,9 @@  discard block
 block discarded – undo
1144 1144
 			$columns = preg_split('/, */', $columns);
1145 1145
 
1146 1146
 			// fix columns containing commas as part of function calls
1147
-			for($n = 0; $n < count($columns); ++$n)
1147
+			for ($n = 0; $n < count($columns); ++$n)
1148 1148
 			{
1149
-				$col =& $columns[$n];
1149
+				$col = & $columns[$n];
1150 1150
 				while (substr_count($col, '(') > substr_count($col, ')') && ++$n < count($columns))
1151 1151
 				{
1152 1152
 					$col .= ','.$columns[$n];
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			}
1156 1156
 			unset($col);
1157 1157
 		}
1158
-		foreach($columns as $n => $col)
1158
+		foreach ($columns as $n => $col)
1159 1159
 		{
1160 1160
 			if ($col == '*')
1161 1161
 			{
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			{
1169 1169
 				if (($pos = stripos($col, 'DISTINCT ')) !== false)
1170 1170
 				{
1171
-					$col = substr($col, $pos+9);
1171
+					$col = substr($col, $pos + 9);
1172 1172
 				}
1173 1173
 				$alias = $col;
1174 1174
 				if (stripos($col, ' AS ')) list($col, $alias) = preg_split('/ +AS +/i', $col);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		$ret = $group_by;
1187 1187
 		if ($changes)
1188 1188
 		{
1189
-			$ret = str_replace($matches[1], 'GROUP BY '.implode(',', $group_by_cols).' ',  $group_by);
1189
+			$ret = str_replace($matches[1], 'GROUP BY '.implode(',', $group_by_cols).' ', $group_by);
1190 1190
 			//error_log(__METHOD__."('$group_by', ".array2string($columns).") group_by_cols=".array2string($group_by_cols)." changed to $ret");
1191 1191
 		}
1192 1192
 		return $ret;
@@ -1206,12 +1206,12 @@  discard block
 block discarded – undo
1206 1206
 	 * @param array $search_cols =array() List of columns to search.  If not provided, all columns in $this->db_cols will be considered
1207 1207
 	 * @return array or column => value pairs
1208 1208
 	 */
1209
-	public function search2criteria($_pattern,&$wildcard='',&$op='AND',$extra_col=null, $search_cols = array())
1209
+	public function search2criteria($_pattern, &$wildcard = '', &$op = 'AND', $extra_col = null, $search_cols = array())
1210 1210
 	{
1211 1211
 		$pattern = trim($_pattern);
1212 1212
 		// This function can get called multiple times.  Make sure it doesn't re-process.
1213 1213
 		if (empty($pattern) || is_array($pattern)) return $pattern;
1214
-		if(strpos($pattern, 'CAST(COALESCE(') !== false)
1214
+		if (strpos($pattern, 'CAST(COALESCE(') !== false)
1215 1215
 		{
1216 1216
 			return $pattern;
1217 1217
 		}
@@ -1228,24 +1228,24 @@  discard block
 block discarded – undo
1228 1228
 		$numeric_columns = array();
1229 1229
 
1230 1230
 		// Special handling for an ID search, #<int>
1231
-		if(strpos($_pattern, '#') === 0 && is_numeric(substr($_pattern, 1)))
1231
+		if (strpos($_pattern, '#') === 0 && is_numeric(substr($_pattern, 1)))
1232 1232
 		{
1233
-			return array('(' . $this->table_name.'.'. $this->autoinc_id . '=' . (int)substr($_pattern,1) . ')');
1233
+			return array('('.$this->table_name.'.'.$this->autoinc_id.'='.(int)substr($_pattern, 1).')');
1234 1234
 		}
1235
-		if(!$search_cols)
1235
+		if (!$search_cols)
1236 1236
 		{
1237 1237
 			$search_cols = $this->get_default_search_columns();
1238 1238
 		}
1239 1239
 		// Concat all fields to be searched together, so the conditions operate across the whole record
1240
-		foreach($search_cols as $col)
1240
+		foreach ($search_cols as $col)
1241 1241
 		{
1242 1242
 			$col_name = $col;
1243 1243
 			$table = $this->table_name;
1244
-			if (strpos($col,'.') !== false)
1244
+			if (strpos($col, '.') !== false)
1245 1245
 			{
1246
-				list($table,$col_name) = explode('.',$col);
1246
+				list($table, $col_name) = explode('.', $col);
1247 1247
 			}
1248
-			$table_def = $table == $this->table_name ? $this->table_def : $this->db->get_table_definitions(true,$table);
1248
+			$table_def = $table == $this->table_name ? $this->table_def : $this->db->get_table_definitions(true, $table);
1249 1249
 			if ($table_def['fd'][$col_name] && in_array($table_def['fd'][$col_name]['type'], $numeric_types))
1250 1250
 			{
1251 1251
 				$numeric_columns[] = $col;
@@ -1253,11 +1253,11 @@  discard block
 block discarded – undo
1253 1253
 			}
1254 1254
 			if ($this->db->Type == 'mysql' && $table_def['fd'][$col_name]['type'] === 'ascii' && preg_match('/[\x80-\xFF]/', $_pattern))
1255 1255
 			{
1256
-				continue;	// will only give sql error
1256
+				continue; // will only give sql error
1257 1257
 			}
1258
-			$columns[] = sprintf($this->db->capabilities[Api\Db::CAPABILITY_CAST_AS_VARCHAR],"COALESCE($col,'')");
1258
+			$columns[] = sprintf($this->db->capabilities[Api\Db::CAPABILITY_CAST_AS_VARCHAR], "COALESCE($col,'')");
1259 1259
 		}
1260
-		if(!$columns)
1260
+		if (!$columns)
1261 1261
 		{
1262 1262
 			return array();
1263 1263
 		}
@@ -1266,9 +1266,9 @@  discard block
 block discarded – undo
1266 1266
 		$break = ' ';
1267 1267
 		$token = strtok($pattern, $break);
1268 1268
 
1269
-		while($token)
1269
+		while ($token)
1270 1270
 		{
1271
-			if($token == strtoupper(lang('AND')) || $token == 'AND')
1271
+			if ($token == strtoupper(lang('AND')) || $token == 'AND')
1272 1272
 			{
1273 1273
 				$token = '+'.strtok($break);
1274 1274
 			}
@@ -1281,10 +1281,10 @@  discard block
 block discarded – undo
1281 1281
 			{
1282 1282
 				$token = '-'.strtok($break);
1283 1283
 			}
1284
-			if ($token[0]=='"')
1284
+			if ($token[0] == '"')
1285 1285
 			{
1286
-				$token = substr($token, 1,strlen($token));
1287
- 				if(substr($token, -1) != '"')
1286
+				$token = substr($token, 1, strlen($token));
1287
+ 				if (substr($token, -1) != '"')
1288 1288
 				{
1289 1289
 					$token .= ' '.strtok('"');
1290 1290
 				}
@@ -1295,16 +1295,16 @@  discard block
 block discarded – undo
1295 1295
 			}
1296 1296
 
1297 1297
 			// prepend and append extra wildcard %, if pattern does NOT already contain wildcards
1298
-			if (strpos($token,'*') === false && strpos($token,'?') === false)
1298
+			if (strpos($token, '*') === false && strpos($token, '?') === false)
1299 1299
 			{
1300
-				$wildcard = '%';	// if pattern contains no wildcards, add them before AND after the pattern
1300
+				$wildcard = '%'; // if pattern contains no wildcards, add them before AND after the pattern
1301 1301
 			}
1302 1302
 			else
1303 1303
 			{
1304
-				$wildcard = '';		// no extra wildcard, if pattern already contains some
1304
+				$wildcard = ''; // no extra wildcard, if pattern already contains some
1305 1305
 			}
1306 1306
 
1307
-			switch($token[0])
1307
+			switch ($token[0])
1308 1308
 			{
1309 1309
 				case '+':
1310 1310
 					$op = 'AND';
@@ -1319,32 +1319,32 @@  discard block
 block discarded – undo
1319 1319
 					$op = 'OR';
1320 1320
 					break;
1321 1321
 			}
1322
-			$token_filter = ' '.call_user_func_array(array($GLOBALS['egw']->db,'concat'),$columns).' '.
1323
-				$this->db->capabilities['case_insensitive_like'] . ' ' .
1324
-				$GLOBALS['egw']->db->quote($wildcard.str_replace(array('%','_','*','?'),array('\\%','\\_','%','_'),$token).$wildcard);
1322
+			$token_filter = ' '.call_user_func_array(array($GLOBALS['egw']->db, 'concat'), $columns).' '.
1323
+				$this->db->capabilities['case_insensitive_like'].' '.
1324
+				$GLOBALS['egw']->db->quote($wildcard.str_replace(array('%', '_', '*', '?'), array('\\%', '\\_', '%', '_'), $token).$wildcard);
1325 1325
 
1326 1326
 			// Compare numeric token as equality for numeric columns
1327 1327
 			// skip user-wildcards (*,?) in is_numeric test, but not SQL wildcards, which get escaped and give sql-error
1328
-			if (is_numeric(str_replace(array('*','?'), '', $token)))
1328
+			if (is_numeric(str_replace(array('*', '?'), '', $token)))
1329 1329
 			{
1330 1330
 				$numeric_filter = array();
1331
-				foreach($numeric_columns as $col)
1331
+				foreach ($numeric_columns as $col)
1332 1332
 				{
1333
-					if($wildcard == '')
1333
+					if ($wildcard == '')
1334 1334
 					{
1335 1335
 						// Token has a wildcard from user, use LIKE
1336
-						$numeric_filter[] = "($col IS NOT NULL AND CAST($col AS CHAR) " .
1337
-							$this->db->capabilities['case_insensitive_like'] . ' ' .
1338
-							$GLOBALS['egw']->db->quote(str_replace(array('*','?'), array('%','_'), $token)) . ')';
1336
+						$numeric_filter[] = "($col IS NOT NULL AND CAST($col AS CHAR) ".
1337
+							$this->db->capabilities['case_insensitive_like'].' '.
1338
+							$GLOBALS['egw']->db->quote(str_replace(array('*', '?'), array('%', '_'), $token)).')';
1339 1339
 					}
1340 1340
 					else
1341 1341
 					{
1342 1342
 						$numeric_filter[] = "($col IS NOT NULL AND $col = $token)";
1343 1343
 					}
1344 1344
 				}
1345
-				if(count($numeric_filter) > 0)
1345
+				if (count($numeric_filter) > 0)
1346 1346
 				{
1347
-					$token_filter = '(' . $token_filter . ' OR ' . implode(' OR ', $numeric_filter) . ')';
1347
+					$token_filter = '('.$token_filter.' OR '.implode(' OR ', $numeric_filter).')';
1348 1348
 				}
1349 1349
 			}
1350 1350
 			$criteria[$op][] = $token_filter;
@@ -1352,32 +1352,32 @@  discard block
 block discarded – undo
1352 1352
 			$token = strtok($break);
1353 1353
 		}
1354 1354
 
1355
-		if($criteria['NOT'])
1355
+		if ($criteria['NOT'])
1356 1356
 		{
1357
-			$filter[] = 'NOT (' . implode(' OR ', $criteria['NOT']) . ') ';
1357
+			$filter[] = 'NOT ('.implode(' OR ', $criteria['NOT']).') ';
1358 1358
 		}
1359
-		if($criteria['AND'])
1359
+		if ($criteria['AND'])
1360 1360
 		{
1361
-			$filter[] = implode(' AND ', $criteria['AND']) . ' ';
1361
+			$filter[] = implode(' AND ', $criteria['AND']).' ';
1362 1362
 		}
1363
-		if($criteria['OR'])
1363
+		if ($criteria['OR'])
1364 1364
 		{
1365
-			$filter[] = '(' . implode(' OR ', $criteria['OR']) . ') ';
1365
+			$filter[] = '('.implode(' OR ', $criteria['OR']).') ';
1366 1366
 		}
1367 1367
 
1368
-		if(count($filter))
1368
+		if (count($filter))
1369 1369
 		{
1370
-			$result = '(' . implode(' AND ', $filter) . ')';
1370
+			$result = '('.implode(' AND ', $filter).')';
1371 1371
 		}
1372 1372
 
1373 1373
 		// OR extra column on the end so a null or blank won't block a hit in the main columns
1374 1374
 		if ($extra_col)
1375 1375
 		{
1376
-			$result .= (strlen($result) ? ' OR ' : ' ') . "$extra_col = " . $GLOBALS['egw']->db->quote($pattern);
1376
+			$result .= (strlen($result) ? ' OR ' : ' ')."$extra_col = ".$GLOBALS['egw']->db->quote($pattern);
1377 1377
 		}
1378 1378
 
1379 1379
 		$op = 'OR';
1380
-		return array('(' . $result . ')');
1380
+		return array('('.$result.')');
1381 1381
 	}
1382 1382
 
1383 1383
 	/**
@@ -1396,21 +1396,21 @@  discard block
 block discarded – undo
1396 1396
 		$numeric_types = array('auto', 'int', 'float', 'double');
1397 1397
 
1398 1398
 		// Skip some numeric columns that don't make sense to search if we have to default to all columns
1399
-		if(is_null($this->columns_to_search))
1399
+		if (is_null($this->columns_to_search))
1400 1400
 		{
1401
-			foreach($search_cols as $key => &$col)
1401
+			foreach ($search_cols as $key => &$col)
1402 1402
 			{
1403 1403
 				// If the name as given isn't a real column name, and adding the prefix doesn't help, skip it
1404
-				if(!$this->table_def['fd'][$col] && !($col = $this->prefix.array_search($col, $search_cols))) {
1404
+				if (!$this->table_def['fd'][$col] && !($col = $this->prefix.array_search($col, $search_cols))) {
1405 1405
 					// Can't search this column
1406 1406
 					unset($search_cols[$key]);
1407 1407
 					continue;
1408 1408
 				}
1409
-				if(in_array($this->table_def['fd'][$col]['type'], $numeric_types))
1409
+				if (in_array($this->table_def['fd'][$col]['type'], $numeric_types))
1410 1410
 				{
1411
-					foreach($skip_columns_with as $bad)
1411
+					foreach ($skip_columns_with as $bad)
1412 1412
 					{
1413
-						if(strpos($col, $bad) !== false)
1413
+						if (strpos($col, $bad) !== false)
1414 1414
 						{
1415 1415
 							unset($search_cols[$key]);
1416 1416
 							continue 2;
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 	 * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
1433 1433
 	 * @return array with columns as db-name => internal-name pairs
1434 1434
 	 */
1435
-	function _get_columns($only_keys,$extra_cols)
1435
+	function _get_columns($only_keys, $extra_cols)
1436 1436
 	{
1437 1437
 		//echo "_get_columns() only_keys="; _debug_array($only_keys); echo "extra_cols="; _debug_array($extra_cols);
1438 1438
 		if ($only_keys === true)	// only primary key
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 		{
1444 1444
 			$cols = array();
1445 1445
 			$distinct_checked = false;
1446
-			foreach(is_array($only_keys) ? $only_keys : explode(',', $only_keys) as $col)
1446
+			foreach (is_array($only_keys) ? $only_keys : explode(',', $only_keys) as $col)
1447 1447
 			{
1448 1448
 				if (!$distinct_checked)
1449 1449
 				{
@@ -1452,17 +1452,17 @@  discard block
 block discarded – undo
1452 1452
 				}
1453 1453
 				if (!$col || $col == '*' || $col == $this->table_name.'.*')	// all columns
1454 1454
 				{
1455
-					$cols = array_merge($cols,$this->db_cols);
1455
+					$cols = array_merge($cols, $this->db_cols);
1456 1456
 				}
1457 1457
 				else	// only the specified columns
1458 1458
 				{
1459
-					if (stripos($col,'as'))	// if there's already an explicit naming of the column, just use it
1459
+					if (stripos($col, 'as'))	// if there's already an explicit naming of the column, just use it
1460 1460
 					{
1461
-						$col = preg_replace('/^.*as +([a-z0-9_]+) *$/i','\\1',$col);
1461
+						$col = preg_replace('/^.*as +([a-z0-9_]+) *$/i', '\\1', $col);
1462 1462
 						$cols[$col] = $col;
1463 1463
 						continue;
1464 1464
 					}
1465
-					if (($db_col = array_search($col,$this->db_cols)) !== false)
1465
+					if (($db_col = array_search($col, $this->db_cols)) !== false)
1466 1466
 					{
1467 1467
 						$cols[$db_col] = $col;
1468 1468
 					}
@@ -1475,10 +1475,10 @@  discard block
 block discarded – undo
1475 1475
 		}
1476 1476
 		if ($extra_cols)	// extra columns to report
1477 1477
 		{
1478
-			foreach(is_array($extra_cols) ? $extra_cols : explode(',',$extra_cols) as $col)
1478
+			foreach (is_array($extra_cols) ? $extra_cols : explode(',', $extra_cols) as $col)
1479 1479
 			{
1480
-				if (stripos($col,'as ')!==false) $col = preg_replace('/^.*as +([a-z0-9_]+) *$/i','\\1',$col);
1481
-				if (($db_col = array_search($col,$this->db_cols)) !== false)
1480
+				if (stripos($col, 'as ') !== false) $col = preg_replace('/^.*as +([a-z0-9_]+) *$/i', '\\1', $col);
1481
+				if (($db_col = array_search($col, $this->db_cols)) !== false)
1482 1482
 				{
1483 1483
 					$cols[$db_col] = $col;
1484 1484
 				}
@@ -1505,12 +1505,12 @@  discard block
 block discarded – undo
1505 1505
 	 * @param string|array $extra_cols =array()
1506 1506
 	 * @return int total number of rows
1507 1507
 	 */
1508
-	function get_rows($query,&$rows,&$readonlys,$join='',$need_full_no_count=false,$only_keys=false,$extra_cols=array())
1508
+	function get_rows($query, &$rows, &$readonlys, $join = '', $need_full_no_count = false, $only_keys = false, $extra_cols = array())
1509 1509
 	{
1510
-		unset($readonlys);	// required by function signature, but not used in this default implementation
1511
-		if ((int) $this->debug >= 4)
1510
+		unset($readonlys); // required by function signature, but not used in this default implementation
1511
+		if ((int)$this->debug >= 4)
1512 1512
 		{
1513
-			echo "<p>so_sql::get_rows(".print_r($query,true).",,)</p>\n";
1513
+			echo "<p>so_sql::get_rows(".print_r($query, true).",,)</p>\n";
1514 1514
 		}
1515 1515
 		$criteria = array();
1516 1516
 		$op = 'AND';
@@ -1518,11 +1518,11 @@  discard block
 block discarded – undo
1518 1518
 		{
1519 1519
 			$criteria = $query['search'];
1520 1520
 		}
1521
-		$rows = $this->search($criteria,$only_keys,$query['order']?$query['order'].' '.$query['sort']:'',$extra_cols,
1522
-			'',false,$op,$query['num_rows']?array((int)$query['start'],$query['num_rows']):(int)$query['start'],
1523
-			$query['col_filter'],$join,$need_full_no_count);
1521
+		$rows = $this->search($criteria, $only_keys, $query['order'] ? $query['order'].' '.$query['sort'] : '', $extra_cols,
1522
+			'', false, $op, $query['num_rows'] ? array((int)$query['start'], $query['num_rows']) : (int)$query['start'],
1523
+			$query['col_filter'], $join, $need_full_no_count);
1524 1524
 
1525
-		if (!$rows) $rows = array();	// otherwise false returned from search would be returned as array(false)
1525
+		if (!$rows) $rows = array(); // otherwise false returned from search would be returned as array(false)
1526 1526
 
1527 1527
 		return $this->total;
1528 1528
 	}
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 	 * @param array $data =null data-set to check, defaults to $this->data
1534 1534
 	 * @return int 0: all keys are unique, 1: first key not unique, 2: ...
1535 1535
 	 */
1536
-	function not_unique($data=null)
1536
+	function not_unique($data = null)
1537 1537
 	{
1538 1538
 		if (!is_array($data))
1539 1539
 		{
@@ -1546,12 +1546,12 @@  discard block
 block discarded – undo
1546 1546
 		{
1547 1547
 			$uni_keys[] = $this->db_key_cols;
1548 1548
 		}
1549
-		foreach($uni_keys as $db_col => $col)
1549
+		foreach ($uni_keys as $db_col => $col)
1550 1550
 		{
1551 1551
 			if (is_array($col))
1552 1552
 			{
1553 1553
 				$query = array();
1554
-				foreach($col as $db_c => $c)
1554
+				foreach ($col as $db_c => $c)
1555 1555
 				{
1556 1556
 					$query[$db_c] = $data[$c];
1557 1557
 				}
@@ -1560,17 +1560,17 @@  discard block
 block discarded – undo
1560 1560
 			{
1561 1561
 				$query = array($db_col => $data[$col]);
1562 1562
 			}
1563
-			foreach($this->db->select($this->table_name,$this->db_key_cols,$query,__LINE__,__FILE__,false,'',$this->app) as $other)
1563
+			foreach ($this->db->select($this->table_name, $this->db_key_cols, $query, __LINE__, __FILE__, false, '', $this->app) as $other)
1564 1564
 			{
1565
-				foreach($this->db_key_cols as $key_col)
1565
+				foreach ($this->db_key_cols as $key_col)
1566 1566
 				{
1567 1567
 					if ($data[$key_col] != $other[$key_col])
1568 1568
 					{
1569
-						if ((int) $this->debug >= 4)
1569
+						if ((int)$this->debug >= 4)
1570 1570
 						{
1571 1571
 							echo "<p>not_unique in ".array2string($col)." as for '$key_col': '${data[$key_col]}' != '${other[$key_col]}'</p>\n";
1572 1572
 						}
1573
-						return $n;	// different entry => $n not unique
1573
+						return $n; // different entry => $n not unique
1574 1574
 					}
1575 1575
 				}
1576 1576
 			}
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 	 * @param string $order ='' order, default '' = same as (first) $value_col
1592 1592
 	 * @return array with key_col => value_col pairs or array if more then one value_col given (keys as in value_col)
1593 1593
 	 */
1594
-	function query_list($value_col,$key_col='',$filter=array(),$order='')
1594
+	function query_list($value_col, $key_col = '', $filter = array(), $order = '')
1595 1595
 	{
1596 1596
 		static $cache = array();
1597 1597
 
@@ -1604,16 +1604,16 @@  discard block
 block discarded – undo
1604 1604
 		if (!is_array($value_col)) $value_col = array($value_col);
1605 1605
 
1606 1606
 		$cols = $ret = array();
1607
-		foreach($value_col as $key => $col)
1607
+		foreach ($value_col as $key => $col)
1608 1608
 		{
1609 1609
 			$matches = null;
1610
-			$cols[$key] = preg_match('/AS ([a-z_0-9]+)$/i',$col,$matches) ? $matches[1] : $col;
1610
+			$cols[$key] = preg_match('/AS ([a-z_0-9]+)$/i', $col, $matches) ? $matches[1] : $col;
1611 1611
 		}
1612 1612
 		if (!$order) $order = current($cols);
1613 1613
 
1614
-		if (($search =& $this->search(array(),($key_col ? $key_col.',' : 'DISTINCT ').implode(',',$value_col),$order,'','',false,'AND',false,$filter)))
1614
+		if (($search = & $this->search(array(), ($key_col ? $key_col.',' : 'DISTINCT ').implode(',', $value_col), $order, '', '', false, 'AND', false, $filter)))
1615 1615
 		{
1616
-			if (preg_match('/AS ([a-z_0-9]+)$/i',$key_col,$matches))
1616
+			if (preg_match('/AS ([a-z_0-9]+)$/i', $key_col, $matches))
1617 1617
 			{
1618 1618
 				$key_col = $matches[1];
1619 1619
 			}
@@ -1621,12 +1621,12 @@  discard block
 block discarded – undo
1621 1621
 			{
1622 1622
 				$key_col = current($cols);
1623 1623
 			}
1624
-			foreach($search as $row)
1624
+			foreach ($search as $row)
1625 1625
 			{
1626 1626
 				if (count($cols) > 1)
1627 1627
 				{
1628 1628
 					$data = array();
1629
-					foreach($cols as $key => $col)
1629
+					foreach ($cols as $key => $col)
1630 1630
 					{
1631 1631
 						$data[$key] = $row[$col];
1632 1632
 					}
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
 				if ($data) $ret[$row[$key_col]] = $data;
1639 1639
 			}
1640 1640
 		}
1641
-		return $cache[$cache_key] =& $ret;
1641
+		return $cache[$cache_key] = & $ret;
1642 1642
 	}
1643 1643
 
1644 1644
 	/**
@@ -1647,13 +1647,13 @@  discard block
 block discarded – undo
1647 1647
 	 * @param string $column =null name of column or null for all (default)
1648 1648
 	 * @return array|string array with internal-name => comment pairs, or string with comment, if $column given
1649 1649
 	 */
1650
-	public function get_comments($column=null)
1650
+	public function get_comments($column = null)
1651 1651
 	{
1652
-		static $comments=null;
1652
+		static $comments = null;
1653 1653
 
1654 1654
 		if (is_null($comments))
1655 1655
 		{
1656
-			foreach($this->db_cols as $db_col => $col)
1656
+			foreach ($this->db_cols as $db_col => $col)
1657 1657
 			{
1658 1658
 				$comments[$col] = $this->table_def['fd'][$db_col]['comment'];
1659 1659
 			}
Please login to merge, or discard this patch.
api/src/Storage/Base2.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return so_sql2
55 55
 	 */
56
-	function __construct($app='',$table='',Api\Db $db=null,$column_prefix='',$no_clone=false)
56
+	function __construct($app = '', $table = '', Api\Db $db = null, $column_prefix = '', $no_clone = false)
57 57
 	{
58
-		parent::__construct($app,$table,$db,$column_prefix,$no_clone);
58
+		parent::__construct($app, $table, $db, $column_prefix, $no_clone);
59 59
 	}
60 60
 
61 61
 	/**
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	function __get($property)
70 70
 	{
71
-		switch($property)
71
+		switch ($property)
72 72
 		{
73 73
 			case 'id':
74 74
 				$property = $this->autoinc_id;
75 75
 				break;
76 76
 		}
77
-		if (in_array($property,$this->db_cols) || in_array($property,$this->non_db_cols))
77
+		if (in_array($property, $this->db_cols) || in_array($property, $this->non_db_cols))
78 78
 		{
79 79
 			return $this->data[$property];
80 80
 		}
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 	 * @param string $property
89 89
 	 * @param mixed $value
90 90
 	 */
91
-	function __set($property,$value)
91
+	function __set($property, $value)
92 92
 	{
93
-		switch($property)
93
+		switch ($property)
94 94
 		{
95 95
 			case 'id':
96 96
 				$property = $this->autoinc_id;
97 97
 				break;
98 98
 		}
99
-		if (in_array($property,$this->db_cols) || in_array($property,$this->non_db_cols))
99
+		if (in_array($property, $this->db_cols) || in_array($property, $this->non_db_cols))
100 100
 		{
101 101
 			$this->data[$property] = $value;
102 102
 		}
Please login to merge, or discard this patch.
api/src/Exception/NoPermission/App.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class App extends Exception\NoPermission
23 23
 {
24
-	function __construct($msg=null,$code=101)
24
+	function __construct($msg = null, $code = 101)
25 25
 	{
26 26
 		if (isset($GLOBALS['egw_info']['apps'][$msg]))
27 27
 		{
@@ -39,6 +39,6 @@  discard block
 block discarded – undo
39 39
 						'"'.$app.'"');
40 40
 			}
41 41
 		}
42
-		parent::__construct($msg,$code);
42
+		parent::__construct($msg, $code);
43 43
 	}
44 44
 }
Please login to merge, or discard this patch.
api/src/Exception/NotFound.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@
 block discarded – undo
26 26
 	 * @param string $msg =null message, default "Entry not found!"
27 27
 	 * @param int $code =99 numerical code, default 2
28 28
 	 */
29
-	function __construct($msg=null,$code=2)
29
+	function __construct($msg = null, $code = 2)
30 30
 	{
31 31
 		if (is_null($msg)) $msg = lang('Entry not found!');
32 32
 
33
-		parent::__construct($msg,$code);
33
+		parent::__construct($msg, $code);
34 34
 	}
35 35
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,10 @@
 block discarded – undo
28 28
 	 */
29 29
 	function __construct($msg=null,$code=2)
30 30
 	{
31
-		if (is_null($msg)) $msg = lang('Entry not found!');
31
+		if (is_null($msg))
32
+		{
33
+			$msg = lang('Entry not found!');
34
+		}
32 35
 
33 36
 		parent::__construct($msg,$code);
34 37
 	}
Please login to merge, or discard this patch.
api/src/Exception/Redirect.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @param string $msg
34 34
 	 * @param int $code
35 35
 	 */
36
-	function __construct($url,$app=null,$msg=null,$code=301)
36
+	function __construct($url, $app = null, $msg = null, $code = 301)
37 37
 	{
38 38
 		$this->url = $url;
39 39
 		$this->app = $app;
Please login to merge, or discard this patch.
api/src/Exception/NoPermission.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
 	 * @param string $msg =null message, default "Permission denied!"
28 28
 	 * @param int $code =100 numerical code, default 100
29 29
 	 */
30
-	function __construct($msg=null,$code=100)
30
+	function __construct($msg = null, $code = 100)
31 31
 	{
32 32
 		if (is_null($msg)) $msg = lang('Permisson denied!');
33 33
 
34
-		parent::__construct($msg,$code);
34
+		parent::__construct($msg, $code);
35 35
 	}
36 36
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,10 @@
 block discarded – undo
29 29
 	 */
30 30
 	function __construct($msg=null,$code=100)
31 31
 	{
32
-		if (is_null($msg)) $msg = lang('Permisson denied!');
32
+		if (is_null($msg))
33
+		{
34
+			$msg = lang('Permisson denied!');
35
+		}
33 36
 
34 37
 		parent::__construct($msg,$code);
35 38
 	}
Please login to merge, or discard this patch.