Passed
Push — 16.1 ( 3ae7fc...22ba35 )
by Ralf
12:47
created
api/src/Vfs/StreamWrapper.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
  	 * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite!
406 406
  	 *
407 407
  	 * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<'))
408
-  	 * {
408
+ 	 * {
409 409
  	 * 		$eof = !$eof;
410 410
  	 * }
411
-  	 *
411
+ 	 *
412 412
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
413 413
  	 */
414 414
 	function stream_eof ( )
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1));
917 917
 
918 918
 		while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) &&
919
-		       ($url = Vfs::dirname($url)))
919
+			   ($url = Vfs::dirname($url)))
920 920
 		{
921 921
 			if (($stat = $this->url_stat($url, 0, false, false)))
922 922
 			{
Please login to merge, or discard this patch.
Spacing   +132 added lines, -133 removed lines patch added patch discarded remove patch
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 	 * @param array|boolean &$stat=null on return: stat of existing file or false for non-existing files
158 158
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
159 159
 	 */
160
-	function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null)
160
+	function resolve_url_symlinks($_path, $file_exists = true, $resolve_last_symlink = true, &$stat = null)
161 161
 	{
162 162
 		$path = self::get_path($_path);
163 163
 
164
-		if (!($stat = $this->url_stat($path,$resolve_last_symlink?0:STREAM_URL_STAT_LINK)) && !$file_exists)
164
+		if (!($stat = $this->url_stat($path, $resolve_last_symlink ? 0 : STREAM_URL_STAT_LINK)) && !$file_exists)
165 165
 		{
166 166
 			$url = null;
167
-			$stat = self::check_symlink_components($path,0,$url);
167
+			$stat = self::check_symlink_components($path, 0, $url);
168 168
 			if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)";
169 169
 		}
170 170
 		else
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 			$url = $stat['url'];
173 173
 		}
174 174
 		// if the url resolves to a symlink to the vfs, resolve this vfs:// url direct
175
-		if ($url && Vfs::parse_url($url,PHP_URL_SCHEME) == self::SCHEME)
175
+		if ($url && Vfs::parse_url($url, PHP_URL_SCHEME) == self::SCHEME)
176 176
 		{
177
-			$url = self::resolve_url(Vfs::parse_url($url,PHP_URL_PATH));
177
+			$url = self::resolve_url(Vfs::parse_url($url, PHP_URL_PATH));
178 178
 		}
179 179
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log");
180 180
 		return $url;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param boolean $fix_url_query =false true append relativ path to url query parameter, default not
198 198
 	 * @return string|boolean false if the url cant be resolved, should not happen if fstab has a root entry
199 199
 	 */
200
-	static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true,$fix_url_query=false)
200
+	static function resolve_url($_path, $do_symlink = true, $use_symlinkcache = true, $replace_user_pass_host = true, $fix_url_query = false)
201 201
 	{
202 202
 		$path = self::get_path($_path);
203 203
 
@@ -210,52 +210,52 @@  discard block
 block discarded – undo
210 210
 		// check if we can already resolve path (or a part of it) with a known symlinks
211 211
 		if ($use_symlinkcache)
212 212
 		{
213
-			$path = self::symlinkCache_resolve($path,$do_symlink);
213
+			$path = self::symlinkCache_resolve($path, $do_symlink);
214 214
 		}
215 215
 		// setting default user, passwd and domain, if it's not contained int the url
216
-		static $defaults=null;
216
+		static $defaults = null;
217 217
 		if (is_null($defaults))
218 218
 		{
219 219
 			$defaults = array(
220 220
 				'user' => $GLOBALS['egw_info']['user']['account_lid'],
221 221
 				'pass' => urlencode($GLOBALS['egw_info']['user']['passwd']),
222 222
 				'host' => $GLOBALS['egw_info']['user']['domain'],
223
-				'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']),
223
+				'home' => str_replace(array('\\\\', '\\'), array('', '/'), $GLOBALS['egw_info']['user']['homedirectory']),
224 224
 			);
225 225
 		}
226
-		$parts = array_merge(Vfs::parse_url($path),$defaults);
227
-		if (!$parts['host']) $parts['host'] = 'default';	// otherwise we get an invalid url (scheme:///path/to/something)!
226
+		$parts = array_merge(Vfs::parse_url($path), $defaults);
227
+		if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)!
228 228
 
229 229
 		if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME)
230 230
 		{
231 231
 			if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)");
232
-			return $path;	// path is already a non-vfs url --> nothing to do
232
+			return $path; // path is already a non-vfs url --> nothing to do
233 233
 		}
234 234
 		if (empty($parts['path'])) $parts['path'] = '/';
235 235
 
236
-		foreach(array_reverse(self::$fstab) as $mounted => $url)
236
+		foreach (array_reverse(self::$fstab) as $mounted => $url)
237 237
 		{
238
-			if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'],0,strlen($mounted)+1))
238
+			if ($mounted == '/' || $mounted == $parts['path'] || $mounted.'/' == substr($parts['path'], 0, strlen($mounted) + 1))
239 239
 			{
240
-				$scheme = Vfs::parse_url($url,PHP_URL_SCHEME);
241
-				if (is_null(self::$wrappers) || !in_array($scheme,self::$wrappers))
240
+				$scheme = Vfs::parse_url($url, PHP_URL_SCHEME);
241
+				if (is_null(self::$wrappers) || !in_array($scheme, self::$wrappers))
242 242
 				{
243 243
 					self::load_wrapper($scheme);
244 244
 				}
245
-				if (($relative = substr($parts['path'],strlen($mounted))))
245
+				if (($relative = substr($parts['path'], strlen($mounted))))
246 246
 				{
247
-					$url = Vfs::concat($url,$relative);
247
+					$url = Vfs::concat($url, $relative);
248 248
 				}
249 249
 				// if url contains url parameter, eg. from filesystem streamwrapper, we need to append relative path here too
250 250
 				$matches = null;
251 251
 				if ($fix_url_query && preg_match('|([?&]url=)([^&]+)|', $url, $matches))
252 252
 				{
253
-					$url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'],strlen($mounted))), $url);
253
+					$url = str_replace($matches[0], $matches[1].Vfs::concat($matches[2], substr($parts['path'], strlen($mounted))), $url);
254 254
 				}
255 255
 
256 256
 				if ($replace_user_pass_host)
257 257
 				{
258
-					$url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url);
258
+					$url = str_replace(array('$user', '$pass', '$host', '$home'), array($parts['user'], $parts['pass'], $parts['host'], $parts['home']), $url);
259 259
 				}
260 260
 				if ($parts['query']) $url .= '?'.$parts['query'];
261 261
 				if ($parts['fragment']) $url .= '#'.$parts['fragment'];
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			}
269 269
 		}
270 270
 		if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n");
271
-		trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING);
271
+		trigger_error(__METHOD__."($path) can't resolve path!\n", E_USER_WARNING);
272 272
 		return false;
273 273
 	}
274 274
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 	 */
281 281
 	static function mount_url($fullurl)
282 282
 	{
283
-		foreach(array_reverse(self::$fstab) as $url)
283
+		foreach (array_reverse(self::$fstab) as $url)
284 284
 		{
285
-			list($url_no_query) = explode('?',$url);
286
-			if (substr($fullurl,0,1+strlen($url_no_query)) === $url_no_query.'/')
285
+			list($url_no_query) = explode('?', $url);
286
+			if (substr($fullurl, 0, 1 + strlen($url_no_query)) === $url_no_query.'/')
287 287
 			{
288 288
 				return $url;
289 289
 			}
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 	 * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set
304 304
 	 * @return boolean true if the ressource was opened successful, otherwise false
305 305
 	 */
306
-	function stream_open ( $path, $mode, $options, &$opened_path )
306
+	function stream_open($path, $mode, $options, &$opened_path)
307 307
 	{
308
-		unset($options,$opened_path);	// not used but required by function signature
308
+		unset($options, $opened_path); // not used but required by function signature
309 309
 		$this->opened_stream = null;
310 310
 
311 311
 		$stat = null;
312
-		if (!($url = $this->resolve_url_symlinks($path,$mode[0]=='r',true,$stat)))
312
+		if (!($url = $this->resolve_url_symlinks($path, $mode[0] == 'r', true, $stat)))
313 313
 		{
314 314
 			return false;
315 315
 		}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * VFS calls either "vfs_read", "vfs_added" or "vfs_modified" hook
347 347
 	 */
348
-	function stream_close ( )
348
+	function stream_close( )
349 349
 	{
350 350
 		$ret = fclose($this->opened_stream);
351 351
 		// clear PHP's stat cache, it contains wrong size of just closed file,
@@ -355,12 +355,11 @@  discard block
 block discarded – undo
355 355
 		if (!class_exists('setup_process', false))
356 356
 		{
357 357
 			Api\Hooks::process(array(
358
-				'location' => str_replace('b','',$this->opened_stream_mode) == 'r' ? 'vfs_read' :
359
-					($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'),
358
+				'location' => str_replace('b', '', $this->opened_stream_mode) == 'r' ? 'vfs_read' : ($this->opened_stream_is_new ? 'vfs_added' : 'vfs_modified'),
360 359
 				'path' => $this->opened_stream_path,
361 360
 				'mode' => $this->opened_stream_mode,
362 361
 				'url'  => $this->opened_stream_url,
363
-			),'',true);
362
+			), '', true);
364 363
 		}
365 364
 		$this->opened_stream = $this->opened_stream_mode = $this->opened_stream_path = $this->opened_stream_url = $this->opened_stream_is_new = null;
366 365
 
@@ -378,9 +377,9 @@  discard block
 block discarded – undo
378 377
 	 * @param int $count
379 378
 	 * @return string/false up to count bytes read or false on EOF
380 379
 	 */
381
-	function stream_read ( $count )
380
+	function stream_read($count)
382 381
 	{
383
-		return fread($this->opened_stream,$count);
382
+		return fread($this->opened_stream, $count);
384 383
 	}
385 384
 
386 385
 	/**
@@ -394,9 +393,9 @@  discard block
 block discarded – undo
394 393
 	 * @param string $data
395 394
 	 * @return integer
396 395
 	 */
397
-	function stream_write ( $data )
396
+	function stream_write($data)
398 397
 	{
399
-		return fwrite($this->opened_stream,$data);
398
+		return fwrite($this->opened_stream, $data);
400 399
 	}
401 400
 
402 401
  	/**
@@ -411,7 +410,7 @@  discard block
 block discarded – undo
411 410
   	 *
412 411
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
413 412
  	 */
414
-	function stream_eof ( )
413
+	function stream_eof( )
415 414
 	{
416 415
 		return feof($this->opened_stream);
417 416
 	}
@@ -421,7 +420,7 @@  discard block
 block discarded – undo
421 420
 	 *
422 421
 	 * @return integer current read/write position of the stream
423 422
 	 */
424
- 	function stream_tell ( )
423
+ 	function stream_tell( )
425 424
  	{
426 425
  		return ftell($this->opened_stream);
427 426
  	}
@@ -438,9 +437,9 @@  discard block
 block discarded – undo
438 437
  	 * 							SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
439 438
  	 * @return boolean TRUE if the position was updated, FALSE otherwise.
440 439
  	 */
441
-	function stream_seek ( $offset, $whence )
440
+	function stream_seek($offset, $whence)
442 441
 	{
443
-		return !fseek($this->opened_stream,$offset,$whence);	// fseek returns 0 on success and -1 on failure
442
+		return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure
444 443
 	}
445 444
 
446 445
 	/**
@@ -450,7 +449,7 @@  discard block
 block discarded – undo
450 449
 	 *
451 450
 	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
452 451
 	 */
453
-	function stream_flush ( )
452
+	function stream_flush( )
454 453
 	{
455 454
 		return fflush($this->opened_stream);
456 455
 	}
@@ -469,7 +468,7 @@  discard block
 block discarded – undo
469 468
 	 *
470 469
 	 * @return array containing the same values as appropriate for the stream.
471 470
 	 */
472
-	function stream_stat ( )
471
+	function stream_stat( )
473 472
 	{
474 473
 		return fstat($this->opened_stream);
475 474
 	}
@@ -498,10 +497,10 @@  discard block
 block discarded – undo
498 497
 		}
499 498
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url");
500 499
 
501
-		switch($option)
500
+		switch ($option)
502 501
 		{
503 502
 			case STREAM_META_TOUCH:
504
-				return touch($url, $value[0]);	// atime is not supported
503
+				return touch($url, $value[0]); // atime is not supported
505 504
 
506 505
 			case STREAM_META_ACCESS:
507 506
 				return chmod($url, $value);
@@ -532,9 +531,9 @@  discard block
 block discarded – undo
532 531
 	 * @param string $path
533 532
 	 * @return boolean TRUE on success or FALSE on failure
534 533
 	 */
535
-	function unlink ( $path )
534
+	function unlink($path)
536 535
 	{
537
-		if (!($url = $this->resolve_url_symlinks($path,true,false)))	// true,false file need to exist, but do not resolve last component
536
+		if (!($url = $this->resolve_url_symlinks($path, true, false)))	// true,false file need to exist, but do not resolve last component
538 537
 		{
539 538
 			return false;
540 539
 		}
@@ -555,7 +554,7 @@  discard block
 block discarded – undo
555 554
 				'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH),
556 555
 				'url'  => $url,
557 556
 				'stat' => $stat,
558
-			),'',true);
557
+			), '', true);
559 558
 		}
560 559
 		return $ok;
561 560
 	}
@@ -573,14 +572,14 @@  discard block
 block discarded – undo
573 572
 	 * @return boolean TRUE on success or FALSE on failure
574 573
 	 * @throws Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected()
575 574
 	 */
576
-	function rename ( $path_from, $path_to )
575
+	function rename($path_from, $path_to)
577 576
 	{
578 577
 		if (Vfs::isProtectedDir($path_from))
579 578
 		{
580 579
 			throw new Exception\ProtectedDirectory("Renaming protected directory '$path_from' rejected!");
581 580
 		}
582
-		if (!($url_from = $this->resolve_url_symlinks($path_from,true,false)) ||
583
-			!($url_to = $this->resolve_url_symlinks($path_to,false)))
581
+		if (!($url_from = $this->resolve_url_symlinks($path_from, true, false)) ||
582
+			!($url_to = $this->resolve_url_symlinks($path_to, false)))
584 583
 		{
585 584
 			return false;
586 585
 		}
@@ -590,14 +589,14 @@  discard block
 block discarded – undo
590 589
 			return false;
591 590
 		}
592 591
 		// if file is moved from one filesystem / wrapper to an other --> copy it (rename fails cross wrappers)
593
-		if (Vfs::parse_url($url_from,PHP_URL_SCHEME) == Vfs::parse_url($url_to,PHP_URL_SCHEME))
592
+		if (Vfs::parse_url($url_from, PHP_URL_SCHEME) == Vfs::parse_url($url_to, PHP_URL_SCHEME))
594 593
 		{
595 594
 			self::symlinkCache_remove($path_from);
596
-			$ret = rename($url_from,$url_to);
595
+			$ret = rename($url_from, $url_to);
597 596
 		}
598
-		elseif (($from = fopen($url_from,'r')) && ($to = fopen($url_to,'w')))
597
+		elseif (($from = fopen($url_from, 'r')) && ($to = fopen($url_to, 'w')))
599 598
 		{
600
-			$ret = stream_copy_to_stream($from,$to) !== false;
599
+			$ret = stream_copy_to_stream($from, $to) !== false;
601 600
 			fclose($from);
602 601
 			fclose($to);
603 602
 			if ($ret) $this->unlink($path_from);
@@ -619,7 +618,7 @@  discard block
 block discarded – undo
619 618
 				'to' => $path_to[0] == '/' ? $path_to : Vfs::parse_url($path_to, PHP_URL_PATH),
620 619
 				'url_from' => $url_from,
621 620
 				'url_to' => $url_to,
622
-			),'',true);
621
+			), '', true);
623 622
 		}
624 623
 		return $ret;
625 624
 	}
@@ -635,9 +634,9 @@  discard block
 block discarded – undo
635 634
 	 * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE
636 635
 	 * @return boolean TRUE on success or FALSE on failure
637 636
 	 */
638
-	function mkdir ( $path, $mode, $options )
637
+	function mkdir($path, $mode, $options)
639 638
 	{
640
-		if (!($url = $this->resolve_url_symlinks($path,false)))	// false = directory does not need to exists
639
+		if (!($url = $this->resolve_url_symlinks($path, false)))	// false = directory does not need to exists
641 640
 		{
642 641
 			return false;
643 642
 		}
@@ -647,7 +646,7 @@  discard block
 block discarded – undo
647 646
 			return false;
648 647
 		}
649 648
 		// check if recursive option is set and needed
650
-		if (($options & STREAM_MKDIR_RECURSIVE) &&
649
+		if (($options&STREAM_MKDIR_RECURSIVE) &&
651 650
 			($parent_url = Vfs::dirname($url)) &&
652 651
 			!($this->url_stat($parent_url, STREAM_URL_STAT_QUIET)) &&
653 652
 			Vfs::parse_url($parent_url, PHP_URL_PATH) !== '/')
@@ -657,7 +656,7 @@  discard block
 block discarded – undo
657 656
 		// unset it now, as it was handled above
658 657
 		$options &= ~STREAM_MKDIR_RECURSIVE;
659 658
 
660
-		$ret = mkdir($url,$mode,$options);
659
+		$ret = mkdir($url, $mode, $options);
661 660
 
662 661
 		// call "vfs_mkdir" hook
663 662
 		if ($ret && !class_exists('setup_process', false))
@@ -666,7 +665,7 @@  discard block
 block discarded – undo
666 665
 				'location' => 'vfs_mkdir',
667 666
 				'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH),
668 667
 				'url' => $url,
669
-			),'',true);
668
+			), '', true);
670 669
 		}
671 670
 		return $ret;
672 671
 	}
@@ -682,13 +681,13 @@  discard block
 block discarded – undo
682 681
 	 * @return boolean TRUE on success or FALSE on failure.
683 682
 	 * @throws Exception\ProtectedDirectory if trying to delete a protected directory, see Vfs::isProtected()
684 683
 	 */
685
-	function rmdir ( $path, $options )
684
+	function rmdir($path, $options)
686 685
 	{
687 686
 		if (Vfs::isProtectedDir($path))
688 687
 		{
689 688
 			throw new Exception\ProtectedDirectory("Deleting protected directory '$path' rejected!");
690 689
 		}
691
-		unset($options);	// not uses but required by function signature
690
+		unset($options); // not uses but required by function signature
692 691
 		if (!($url = $this->resolve_url_symlinks($path)))
693 692
 		{
694 693
 			return false;
@@ -710,7 +709,7 @@  discard block
 block discarded – undo
710 709
 				'path' => $path[0] == '/' ? $path : Vfs::parse_url($path, PHP_URL_PATH),
711 710
 				'url' => $url,
712 711
 				'stat' => $stat,
713
-			),'',true);
712
+			), '', true);
714 713
 		}
715 714
 		return $ok;
716 715
 	}
@@ -721,7 +720,7 @@  discard block
 block discarded – undo
721 720
 	 * @param string $path URL that was passed to opendir() and that this object is expected to explore.
722 721
 	 * @return booelan
723 722
 	 */
724
-	function dir_opendir ( $path, $options )
723
+	function dir_opendir($path, $options)
725 724
 	{
726 725
 		$this->opened_dir = $this->extra_dirs = null;
727 726
 		$this->dir_url_params = array();
@@ -738,15 +737,15 @@  discard block
 block discarded – undo
738 737
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!");
739 738
 			return false;
740 739
 		}
741
-		$this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE);
740
+		$this->opened_dir_writable = Vfs::check_access($this->opened_dir_url, Vfs::WRITABLE);
742 741
 		// check our fstab if we need to add some of the mountpoints
743
-		$basepath = Vfs::parse_url($path,PHP_URL_PATH);
744
-		foreach(array_keys(self::$fstab) as $mounted)
742
+		$basepath = Vfs::parse_url($path, PHP_URL_PATH);
743
+		foreach (array_keys(self::$fstab) as $mounted)
745 744
 		{
746 745
 			if (((Vfs::dirname($mounted) == $basepath || Vfs::dirname($mounted).'/' == $basepath) && $mounted != '/') &&
747 746
 				// only return children readable by the user, if dir is not writable
748 747
 				(!self::HIDE_UNREADABLES || $this->opened_dir_writable ||
749
-					Vfs::check_access($mounted,Vfs::READABLE)))
748
+					Vfs::check_access($mounted, Vfs::READABLE)))
750 749
 			{
751 750
 				$this->extra_dirs[] = basename($mounted);
752 751
 			}
@@ -785,24 +784,24 @@  discard block
 block discarded – undo
785 784
 	 * @param boolean $check_symlink_components =true check if path contains symlinks in path components other then the last one
786 785
 	 * @return array
787 786
 	 */
788
-	function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH, $try_reconnect=true )
787
+	function url_stat($path, $flags, $try_create_home = false, $check_symlink_components = true, $check_symlink_depth = self::MAX_SYMLINK_DEPTH, $try_reconnect = true)
789 788
 	{
790
-		if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components)))
789
+		if (!($url = self::resolve_url($path, !($flags&STREAM_URL_STAT_LINK), $check_symlink_components)))
791 790
 		{
792 791
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
793 792
 			return false;
794 793
 		}
795 794
 
796 795
 		try {
797
-			if ($flags & STREAM_URL_STAT_LINK)
796
+			if ($flags&STREAM_URL_STAT_LINK)
798 797
 			{
799
-				$stat = @lstat($url);	// suppressed the stat failed warnings
798
+				$stat = @lstat($url); // suppressed the stat failed warnings
800 799
 			}
801 800
 			else
802 801
 			{
803
-				$stat = @stat($url);	// suppressed the stat failed warnings
802
+				$stat = @stat($url); // suppressed the stat failed warnings
804 803
 
805
-				if ($stat && ($stat['mode'] & self::MODE_LINK))
804
+				if ($stat && ($stat['mode']&self::MODE_LINK))
806 805
 				{
807 806
 					if (!$check_symlink_depth)
808 807
 					{
@@ -813,25 +812,25 @@  discard block
 block discarded – undo
813 812
 					{
814 813
 						if ($lpath[0] != '/')	// concat relative path
815 814
 						{
816
-							$lpath = Vfs::concat(Vfs::parse_url($path,PHP_URL_PATH),'../'.$lpath);
815
+							$lpath = Vfs::concat(Vfs::parse_url($path, PHP_URL_PATH), '../'.$lpath);
817 816
 						}
818
-						$u_query = parse_url($url,PHP_URL_QUERY);
817
+						$u_query = parse_url($url, PHP_URL_QUERY);
819 818
 						$url = Vfs::PREFIX.$lpath;
820 819
 						if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1);	// remove trailing slash eg. added by WebDAVink found and resolved to $url");
821 820
 						// try reading the stat of the link
822
-						if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1)))
821
+						if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth - 1)))
823 822
 						{
824 823
 							$stat_query = parse_url($stat['url'], PHP_URL_QUERY);
825
-							if($u_query || $stat_query)
824
+							if ($u_query || $stat_query)
826 825
 							{
827 826
 								$stat_url = parse_url($stat['url']);
828
-								parse_str($stat_query,$stat_query);
827
+								parse_str($stat_query, $stat_query);
829 828
 								parse_str($u_query, $u_query);
830 829
 								$stat_query = http_build_query(array_merge($stat_query, $u_query));
831 830
 								$stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query;
832 831
 							}
833
-							if(isset($stat['url'])) $url = $stat['url'];	// if stat returns an url use that, as there might be more links ...
834
-							self::symlinkCache_add($path,$url);
832
+							if (isset($stat['url'])) $url = $stat['url']; // if stat returns an url use that, as there might be more links ...
833
+							self::symlinkCache_add($path, $url);
835 834
 						}
836 835
 					}
837 836
 				}
@@ -851,7 +850,7 @@  discard block
 block discarded – undo
851 850
 			throw $e;
852 851
 		}
853 852
 		// check if a failed url_stat was for a home dir, in that case silently create it
854
-		if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path,PHP_URL_PATH)) == '/home' &&
853
+		if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path, PHP_URL_PATH)) == '/home' &&
855 854
 			($id = $GLOBALS['egw']->accounts->name2id(basename($path))) &&
856 855
 			$GLOBALS['egw']->accounts->id2name($id) == basename($path))	// make sure path has the right case!
857 856
 		{
@@ -861,25 +860,25 @@  discard block
 block discarded – undo
861 860
 				'account_lid' => basename($path),
862 861
 				'account_name' => basename($path),
863 862
 			);
864
-			call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data);
863
+			call_user_func(array(__NAMESPACE__.'\\Hooks', $hook_data['location']), $hook_data);
865 864
 			unset($hook_data);
866
-			$stat = $this->url_stat($path,$flags,false);
865
+			$stat = $this->url_stat($path, $flags, false);
867 866
 		}
868 867
 		$query = parse_url($url, PHP_URL_QUERY);
869 868
 		if (!$stat && $check_symlink_components)	// check if there's a symlink somewhere inbetween the path
870 869
 		{
871
-			$stat = self::check_symlink_components($path,$flags,$url);
872
-			if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']);
870
+			$stat = self::check_symlink_components($path, $flags, $url);
871
+			if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path, $stat['url']);
873 872
 		}
874
-		elseif(is_array($stat) && !isset($stat['url']))
873
+		elseif (is_array($stat) && !isset($stat['url']))
875 874
 		{
876 875
 			$stat['url'] = $url;
877 876
 		}
878
-		if (($stat['mode'] & 0222) && self::url_is_readonly($stat['url']))
877
+		if (($stat['mode']&0222) && self::url_is_readonly($stat['url']))
879 878
 		{
880 879
 			$stat['mode'] &= ~0222;
881 880
 		}
882
-		if($stat['url'] && $query && strpos($stat['url'],'?'.$query)===false)
881
+		if ($stat['url'] && $query && strpos($stat['url'], '?'.$query) === false)
883 882
 		{
884 883
 			$stat['url'] .= '?'.$query;
885 884
 		}
@@ -906,7 +905,7 @@  discard block
 block discarded – undo
906 905
 	 * @param string &$url=null already resolved path
907 906
 	 * @return array|boolean stat array or false if not found
908 907
 	 */
909
-	private function check_symlink_components($path,$flags=0,&$url=null)
908
+	private function check_symlink_components($path, $flags = 0, &$url = null)
910 909
 	{
911 910
 		if (is_null($url) && !($url = self::resolve_url($path)))
912 911
 		{
@@ -926,20 +925,20 @@  discard block
 block discarded – undo
926 925
 
927 926
 					if ($lpath[0] != '/')
928 927
 					{
929
-						$lpath = Vfs::concat(Vfs::parse_url($url,PHP_URL_PATH),'../'.$lpath);
928
+						$lpath = Vfs::concat(Vfs::parse_url($url, PHP_URL_PATH), '../'.$lpath);
930 929
 					}
931 930
 					//self::symlinkCache_add($path,Vfs::PREFIX.$lpath);
932
-					$url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path);
931
+					$url = Vfs::PREFIX.Vfs::concat($lpath, $rel_path);
933 932
 					if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'");
934
-					return $this->url_stat($url,$flags);
933
+					return $this->url_stat($url, $flags);
935 934
 				}
936
-				$url = Vfs::concat($url,$rel_path);
935
+				$url = Vfs::concat($url, $rel_path);
937 936
 				if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null");
938 937
 				return null;
939 938
 			}
940 939
 		}
941 940
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false");
942
-		return false;	// $path does not exist
941
+		return false; // $path does not exist
943 942
 	}
944 943
 
945 944
 	/**
@@ -955,13 +954,13 @@  discard block
 block discarded – undo
955 954
 	 * @param string $_path vfs path
956 955
 	 * @param string $target target path
957 956
 	 */
958
-	static protected function symlinkCache_add($_path,$target)
957
+	static protected function symlinkCache_add($_path, $target)
959 958
 	{
960 959
 		$path = self::get_path($_path);
961 960
 
962
-		if (isset(self::$symlink_cache[$path])) return;	// nothing to do
961
+		if (isset(self::$symlink_cache[$path])) return; // nothing to do
963 962
 
964
-		if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH);
963
+		if ($target[0] != '/') $target = Vfs::parse_url($target, PHP_URL_PATH);
965 964
 
966 965
 		self::$symlink_cache[$path] = $target;
967 966
 
@@ -995,25 +994,25 @@  discard block
 block discarded – undo
995 994
 	 * @param boolean $do_symlink =true is a direct match allowed, default yes (must be false for a lstat or readlink!)
996 995
 	 * @return string target or path, if path not found
997 996
 	 */
998
-	static public function symlinkCache_resolve($_path,$do_symlink=true)
997
+	static public function symlinkCache_resolve($_path, $do_symlink = true)
999 998
 	{
1000 999
 		// remove vfs scheme, but no other schemes (eg. filesystem!)
1001 1000
 		$path = self::get_path($_path);
1002 1001
 
1003 1002
 		$strlen_path = strlen($path);
1004 1003
 
1005
-		foreach(self::$symlink_cache as $p => $t)
1004
+		foreach (self::$symlink_cache as $p => $t)
1006 1005
 		{
1007
-			if (($strlen_p = strlen($p)) > $strlen_path) continue;	// $path can NOT start with $p
1006
+			if (($strlen_p = strlen($p)) > $strlen_path) continue; // $path can NOT start with $p
1008 1007
 
1009 1008
 			if ($path == $p)
1010 1009
 			{
1011 1010
 				if ($do_symlink) $target = $t;
1012 1011
 				break;
1013 1012
 			}
1014
-			elseif (substr($path,0,$strlen_p+1) == $p.'/')
1013
+			elseif (substr($path, 0, $strlen_p + 1) == $p.'/')
1015 1014
 			{
1016
-				$target = $t . substr($path,$strlen_p);
1015
+				$target = $t.substr($path, $strlen_p);
1017 1016
 				break;
1018 1017
 			}
1019 1018
 		}
@@ -1041,7 +1040,7 @@  discard block
 block discarded – undo
1041 1040
 	 *
1042 1041
 	 * @return string
1043 1042
 	 */
1044
-	function dir_readdir ( )
1043
+	function dir_readdir( )
1045 1044
 	{
1046 1045
 		if ($this->extra_dirs && count($this->extra_dirs) > $this->extra_dir_ptr)
1047 1046
 		{
@@ -1053,10 +1052,10 @@  discard block
 block discarded – undo
1053 1052
 			do {
1054 1053
 				$file = readdir($this->opened_dir);
1055 1054
 			}
1056
-			while($file !== false &&
1057
-				(is_array($this->extra_dirs) && in_array($file,$this->extra_dirs) || // do NOT return extra_dirs twice
1055
+			while ($file !== false &&
1056
+				(is_array($this->extra_dirs) && in_array($file, $this->extra_dirs) || // do NOT return extra_dirs twice
1058 1057
 				self::HIDE_UNREADABLES && !$this->opened_dir_writable &&
1059
-				!Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE)));
1058
+				!Vfs::check_access(Vfs::concat($this->opened_dir_url, $file), Vfs::READABLE)));
1060 1059
 		}
1061 1060
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'");
1062 1061
 		return $file;
@@ -1070,7 +1069,7 @@  discard block
 block discarded – undo
1070 1069
 	 *
1071 1070
 	 * @return boolean
1072 1071
 	 */
1073
-	function dir_rewinddir ( )
1072
+	function dir_rewinddir( )
1074 1073
 	{
1075 1074
 		$this->extra_dir_ptr = 0;
1076 1075
 
@@ -1084,7 +1083,7 @@  discard block
 block discarded – undo
1084 1083
 	 *
1085 1084
 	 * @return boolean
1086 1085
 	 */
1087
-	function dir_closedir ( )
1086
+	function dir_closedir( )
1088 1087
 	{
1089 1088
 		$ret = closedir($this->opened_dir);
1090 1089
 
@@ -1101,9 +1100,9 @@  discard block
 block discarded – undo
1101 1100
 	 */
1102 1101
 	static function load_wrapper($scheme)
1103 1102
 	{
1104
-		if (!in_array($scheme,self::get_wrappers()))
1103
+		if (!in_array($scheme, self::get_wrappers()))
1105 1104
 		{
1106
-			switch($scheme)
1105
+			switch ($scheme)
1107 1106
 			{
1108 1107
 				case 'webdav':
1109 1108
 				case 'webdavs':
@@ -1111,16 +1110,16 @@  discard block
 block discarded – undo
1111 1110
 					self::$wrappers[] = $scheme;
1112 1111
 					break;
1113 1112
 				case '':
1114
-					break;	// default file, always loaded
1113
+					break; // default file, always loaded
1115 1114
 				default:
1116 1115
 					// check if scheme is buildin in php or one of our own stream wrappers
1117
-					if (in_array($scheme,stream_get_wrappers()) || class_exists(self::scheme2class($scheme)))
1116
+					if (in_array($scheme, stream_get_wrappers()) || class_exists(self::scheme2class($scheme)))
1118 1117
 					{
1119 1118
 						self::$wrappers[] = $scheme;
1120 1119
 					}
1121 1120
 					else
1122 1121
 					{
1123
-						trigger_error("Can't load stream-wrapper for scheme '$scheme'!",E_USER_WARNING);
1122
+						trigger_error("Can't load stream-wrapper for scheme '$scheme'!", E_USER_WARNING);
1124 1123
 						return false;
1125 1124
 					}
1126 1125
 			}
@@ -1154,10 +1153,10 @@  discard block
 block discarded – undo
1154 1153
 	static function scheme2class($scheme)
1155 1154
 	{
1156 1155
 		list($app, $app_scheme) = explode('.', $scheme);
1157
-		foreach(array(
1158
-			empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' :	// streamwrapper in Api\Vfs
1156
+		foreach (array(
1157
+			empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\'.ucfirst($scheme).'\\StreamWrapper' : // streamwrapper in Api\Vfs
1159 1158
 				'EGroupware\\'.ucfirst($app).'\\Vfs\\'.ucfirst($app_scheme).'\\StreamWrapper', // streamwrapper in $app\Vfs
1160
-			str_replace('.','_',$scheme).'_stream_wrapper',	// old (flat) name
1159
+			str_replace('.', '_', $scheme).'_stream_wrapper', // old (flat) name
1161 1160
 		) as $class)
1162 1161
 		{
1163 1162
 			//error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class)));
@@ -1172,7 +1171,7 @@  discard block
 block discarded – undo
1172 1171
 	 * @param string $only_remove_scheme =self::SCHEME if given only that scheme get's removed
1173 1172
 	 * @return string path without training slash
1174 1173
 	 */
1175
-	static protected function get_path($path,$only_remove_scheme=self::SCHEME)
1174
+	static protected function get_path($path, $only_remove_scheme = self::SCHEME)
1176 1175
 	{
1177 1176
 		if ($path[0] != '/' && (!$only_remove_scheme || Vfs::parse_url($path, PHP_URL_SCHEME) == $only_remove_scheme))
1178 1177
 		{
@@ -1183,7 +1182,7 @@  discard block
 block discarded – undo
1183 1182
 		{
1184 1183
 			while (mb_substr($path, -1) == '/' && $path != '/' && ($path[0] == '/' || Vfs::parse_url($path, PHP_URL_PATH) != '/'))
1185 1184
 			{
1186
-				$path = mb_substr($path,0,-1);
1185
+				$path = mb_substr($path, 0, -1);
1187 1186
 			}
1188 1187
 		}
1189 1188
 		return $path;
@@ -1198,7 +1197,7 @@  discard block
 block discarded – undo
1198 1197
 	static function url_is_readonly($url)
1199 1198
 	{
1200 1199
 		static $cache = array();
1201
-		$ret =& $cache[$url];
1200
+		$ret = & $cache[$url];
1202 1201
 		if (!isset($ret))
1203 1202
 		{
1204 1203
 			$matches = null;
@@ -1220,9 +1219,9 @@  discard block
 block discarded – undo
1220 1219
 	 * @param boolean $clear_fstab =false true clear current fstab, false (default) only add given mount
1221 1220
 	 * @return array|boolean array with fstab, if called without parameter or true on successful mount
1222 1221
 	 */
1223
-	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
1222
+	static function mount($url = null, $path = null, $check_url = null, $persitent_mount = true, $clear_fstab = false)
1224 1223
 	{
1225
-		if (is_null($check_url)) $check_url = strpos($url,'$') === false;
1224
+		if (is_null($check_url)) $check_url = strpos($url, '$') === false;
1226 1225
 
1227 1226
 		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))	// happens eg. in setup
1228 1227
 		{
@@ -1248,7 +1247,7 @@  discard block
 block discarded – undo
1248 1247
 		if (!Vfs::$is_root)
1249 1248
 		{
1250 1249
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
1251
-			return false;	// only root can mount
1250
+			return false; // only root can mount
1252 1251
 		}
1253 1252
 		if ($clear_fstab)
1254 1253
 		{
@@ -1257,14 +1256,14 @@  discard block
 block discarded – undo
1257 1256
 		if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url)
1258 1257
 		{
1259 1258
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
1260
-			return true;	// already mounted
1259
+			return true; // already mounted
1261 1260
 		}
1262
-		self::load_wrapper(Vfs::parse_url($url,PHP_URL_SCHEME));
1261
+		self::load_wrapper(Vfs::parse_url($url, PHP_URL_SCHEME));
1263 1262
 
1264 1263
 		if ($check_url && (!file_exists($url) || opendir($url) === false))
1265 1264
 		{
1266 1265
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
1267
-			return false;	// url does not exist
1266
+			return false; // url does not exist
1268 1267
 		}
1269 1268
 		self::$fstab[$path] = $url;
1270 1269
 
@@ -1275,10 +1274,10 @@  discard block
 block discarded – undo
1275 1274
 
1276 1275
 		if ($persitent_mount)
1277 1276
 		{
1278
-			Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
1277
+			Api\Config::save_value('vfs_fstab', self::$fstab, 'phpgwapi');
1279 1278
 			$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
1280 1279
 			// invalidate session cache
1281
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1280
+			if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
1282 1281
 			{
1283 1282
 				$GLOBALS['egw']->invalidate_session_cache();
1284 1283
 			}
@@ -1297,19 +1296,19 @@  discard block
 block discarded – undo
1297 1296
 		if (!Vfs::$is_root)
1298 1297
 		{
1299 1298
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
1300
-			return false;	// only root can mount
1299
+			return false; // only root can mount
1301 1300
 		}
1302
-		if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
1301
+		if (!isset(self::$fstab[$path]) && ($path = array_search($path, self::$fstab)) === false)
1303 1302
 		{
1304 1303
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
1305
-			return false;	// $path not mounted
1304
+			return false; // $path not mounted
1306 1305
 		}
1307 1306
 		unset(self::$fstab[$path]);
1308 1307
 
1309
-		Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
1308
+		Api\Config::save_value('vfs_fstab', self::$fstab, 'phpgwapi');
1310 1309
 		$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
1311 1310
 		// invalidate session cache
1312
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1311
+		if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
1313 1312
 		{
1314 1313
 			$GLOBALS['egw']->invalidate_session_cache();
1315 1314
 		}
@@ -1323,7 +1322,7 @@  discard block
 block discarded – undo
1323 1322
 	 */
1324 1323
 	static function init_static()
1325 1324
 	{
1326
-		stream_register_wrapper(self::SCHEME,__CLASS__);
1325
+		stream_register_wrapper(self::SCHEME, __CLASS__);
1327 1326
 
1328 1327
 		if (($fstab = $GLOBALS['egw_info']['server']['vfs_fstab']) && is_array($fstab) && count($fstab))
1329 1328
 		{
Please login to merge, or discard this patch.
Braces   +234 added lines, -58 removed lines patch added patch discarded remove patch
@@ -165,7 +165,10 @@  discard block
 block discarded – undo
165 165
 		{
166 166
 			$url = null;
167 167
 			$stat = self::check_symlink_components($path,0,$url);
168
-			if (self::LOG_LEVEL > 1) $log = " (check_symlink_components('$path',0,'$url') = $stat)";
168
+			if (self::LOG_LEVEL > 1)
169
+			{
170
+				$log = " (check_symlink_components('$path',0,'$url') = $stat)";
171
+			}
169 172
 		}
170 173
 		else
171 174
 		{
@@ -176,7 +179,10 @@  discard block
 block discarded – undo
176 179
 		{
177 180
 			$url = self::resolve_url(Vfs::parse_url($url,PHP_URL_PATH));
178 181
 		}
179
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log");
182
+		if (self::LOG_LEVEL > 1)
183
+		{
184
+			error_log(__METHOD__."($path,file_exists=$file_exists,resolve_last_symlink=$resolve_last_symlink) = '$url'$log");
185
+		}
180 186
 		return $url;
181 187
 	}
182 188
 
@@ -204,7 +210,10 @@  discard block
 block discarded – undo
204 210
 		// we do some caching here
205 211
 		if (isset(self::$resolve_url_cache[$path]) && $replace_user_pass_host)
206 212
 		{
207
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)");
213
+			if (self::LOG_LEVEL > 1)
214
+			{
215
+				error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)");
216
+			}
208 217
 			return self::$resolve_url_cache[$path];
209 218
 		}
210 219
 		// check if we can already resolve path (or a part of it) with a known symlinks
@@ -224,14 +233,24 @@  discard block
 block discarded – undo
224 233
 			);
225 234
 		}
226 235
 		$parts = array_merge(Vfs::parse_url($path),$defaults);
227
-		if (!$parts['host']) $parts['host'] = 'default';	// otherwise we get an invalid url (scheme:///path/to/something)!
236
+		if (!$parts['host'])
237
+		{
238
+			$parts['host'] = 'default';
239
+		}
240
+		// otherwise we get an invalid url (scheme:///path/to/something)!
228 241
 
229 242
 		if (!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME)
230 243
 		{
231
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)");
244
+			if (self::LOG_LEVEL > 1)
245
+			{
246
+				error_log(__METHOD__."('$path') = '$path' (path is already an url)");
247
+			}
232 248
 			return $path;	// path is already a non-vfs url --> nothing to do
233 249
 		}
234
-		if (empty($parts['path'])) $parts['path'] = '/';
250
+		if (empty($parts['path']))
251
+		{
252
+			$parts['path'] = '/';
253
+		}
235 254
 
236 255
 		foreach(array_reverse(self::$fstab) as $mounted => $url)
237 256
 		{
@@ -257,17 +276,32 @@  discard block
 block discarded – undo
257 276
 				{
258 277
 					$url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url);
259 278
 				}
260
-				if ($parts['query']) $url .= '?'.$parts['query'];
261
-				if ($parts['fragment']) $url .= '#'.$parts['fragment'];
279
+				if ($parts['query'])
280
+				{
281
+					$url .= '?'.$parts['query'];
282
+				}
283
+				if ($parts['fragment'])
284
+				{
285
+					$url .= '#'.$parts['fragment'];
286
+				}
262 287
 
263
-				if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'");
288
+				if (self::LOG_LEVEL > 1)
289
+				{
290
+					error_log(__METHOD__."('$path') = '$url'");
291
+				}
264 292
 
265
-				if ($replace_user_pass_host) self::$resolve_url_cache[$path] = $url;
293
+				if ($replace_user_pass_host)
294
+				{
295
+					self::$resolve_url_cache[$path] = $url;
296
+				}
266 297
 
267 298
 				return $url;
268 299
 			}
269 300
 		}
270
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n");
301
+		if (self::LOG_LEVEL > 0)
302
+		{
303
+			error_log(__METHOD__."('$path') can't resolve path!\n");
304
+		}
271 305
 		trigger_error(__METHOD__."($path) can't resolve path!\n",E_USER_WARNING);
272 306
 		return false;
273 307
 	}
@@ -488,15 +522,21 @@  discard block
 block discarded – undo
488 522
 	 */
489 523
 	function stream_metadata($path, $option, $value)
490 524
 	{
491
-		if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false)))	// true,false file need to exist, but do not resolve last component
525
+		if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false)))
526
+		{
527
+			// true,false file need to exist, but do not resolve last component
492 528
 		{
493 529
 			return false;
494 530
 		}
531
+		}
495 532
 		if (self::url_is_readonly($url))
496 533
 		{
497 534
 			return false;
498 535
 		}
499
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url");
536
+		if (self::LOG_LEVEL > 1)
537
+		{
538
+			error_log(__METHOD__."('$path', $option, ".array2string($value).") url=$url");
539
+		}
500 540
 
501 541
 		switch($option)
502 542
 		{
@@ -508,14 +548,18 @@  discard block
 block discarded – undo
508 548
 
509 549
 			case STREAM_META_OWNER_NAME:
510 550
 				if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false)
511
-					return false;
551
+				{
552
+									return false;
553
+				}
512 554
 				// fall through
513 555
 			case STREAM_META_OWNER:
514 556
 				return chown($url, $value);
515 557
 
516 558
 			case STREAM_META_GROUP_NAME:
517 559
 				if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false)
518
-					return false;
560
+				{
561
+									return false;
562
+				}
519 563
 				// fall through
520 564
 			case STREAM_META_GROUP:
521 565
 				return chgrp($url, $value);
@@ -534,10 +578,13 @@  discard block
 block discarded – undo
534 578
 	 */
535 579
 	function unlink ( $path )
536 580
 	{
537
-		if (!($url = $this->resolve_url_symlinks($path,true,false)))	// true,false file need to exist, but do not resolve last component
581
+		if (!($url = $this->resolve_url_symlinks($path,true,false)))
582
+		{
583
+			// true,false file need to exist, but do not resolve last component
538 584
 		{
539 585
 			return false;
540 586
 		}
587
+		}
541 588
 		if (self::url_is_readonly($url))
542 589
 		{
543 590
 			return false;
@@ -600,7 +647,10 @@  discard block
 block discarded – undo
600 647
 			$ret = stream_copy_to_stream($from,$to) !== false;
601 648
 			fclose($from);
602 649
 			fclose($to);
603
-			if ($ret) $this->unlink($path_from);
650
+			if ($ret)
651
+			{
652
+				$this->unlink($path_from);
653
+			}
604 654
 		}
605 655
 		else
606 656
 		{
@@ -637,10 +687,13 @@  discard block
 block discarded – undo
637 687
 	 */
638 688
 	function mkdir ( $path, $mode, $options )
639 689
 	{
640
-		if (!($url = $this->resolve_url_symlinks($path,false)))	// false = directory does not need to exists
690
+		if (!($url = $this->resolve_url_symlinks($path,false)))
691
+		{
692
+			// false = directory does not need to exists
641 693
 		{
642 694
 			return false;
643 695
 		}
696
+		}
644 697
 		// refuse to modify readonly target (eg. readonly share)
645 698
 		if (self::url_is_readonly($url))
646 699
 		{
@@ -652,7 +705,10 @@  discard block
 block discarded – undo
652 705
 			!($this->url_stat($parent_url, STREAM_URL_STAT_QUIET)) &&
653 706
 			Vfs::parse_url($parent_url, PHP_URL_PATH) !== '/')
654 707
 		{
655
-			if (!mkdir($parent_url, $mode, $options)) return false;
708
+			if (!mkdir($parent_url, $mode, $options))
709
+			{
710
+				return false;
711
+			}
656 712
 		}
657 713
 		// unset it now, as it was handled above
658 714
 		$options &= ~STREAM_MKDIR_RECURSIVE;
@@ -729,13 +785,19 @@  discard block
 block discarded – undo
729 785
 
730 786
 		if (!($this->opened_dir_url = $this->resolve_url_symlinks($path)))
731 787
 		{
732
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!");
788
+			if (self::LOG_LEVEL > 0)
789
+			{
790
+				error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!");
791
+			}
733 792
 			return false;
734 793
 		}
735 794
 		if (!($this->opened_dir = $this->context ?
736 795
 			opendir($this->opened_dir_url, $this->context) : opendir($this->opened_dir_url)))
737 796
 		{
738
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!");
797
+			if (self::LOG_LEVEL > 0)
798
+			{
799
+				error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!");
800
+			}
739 801
 			return false;
740 802
 		}
741 803
 		$this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE);
@@ -753,7 +815,10 @@  discard block
 block discarded – undo
753 815
 		}
754 816
 
755 817
 
756
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace());
818
+		if (self::LOG_LEVEL > 1)
819
+		{
820
+			error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace());
821
+		}
757 822
 		return true;
758 823
 	}
759 824
 
@@ -789,7 +854,10 @@  discard block
 block discarded – undo
789 854
 	{
790 855
 		if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components)))
791 856
 		{
792
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
857
+			if (self::LOG_LEVEL > 0)
858
+			{
859
+				error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
860
+			}
793 861
 			return false;
794 862
 		}
795 863
 
@@ -806,18 +874,27 @@  discard block
 block discarded – undo
806 874
 				{
807 875
 					if (!$check_symlink_depth)
808 876
 					{
809
-						if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!");
877
+						if (self::LOG_LEVEL > 0)
878
+						{
879
+							error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!");
880
+						}
810 881
 						$stat = false;
811 882
 					}
812 883
 					elseif (($lpath = Vfs::readlink($url)))
813 884
 					{
814
-						if ($lpath[0] != '/')	// concat relative path
885
+						if ($lpath[0] != '/')
886
+						{
887
+							// concat relative path
815 888
 						{
816 889
 							$lpath = Vfs::concat(Vfs::parse_url($path,PHP_URL_PATH),'../'.$lpath);
817 890
 						}
891
+						}
818 892
 						$u_query = parse_url($url,PHP_URL_QUERY);
819 893
 						$url = Vfs::PREFIX.$lpath;
820
-						if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1);	// remove trailing slash eg. added by WebDAVink found and resolved to $url");
894
+						if (self::LOG_LEVEL > 1)
895
+						{
896
+							error_log(__METHOD__."($path,$flags) symlif (substr($path,-1) == '/' && $path != '/') $path = substr($path,0,-1);	// remove trailing slash eg. added by WebDAVink found and resolved to $url");
897
+						}
821 898
 						// try reading the stat of the link
822 899
 						if (($stat = $this->url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1)))
823 900
 						{
@@ -830,7 +907,11 @@  discard block
 block discarded – undo
830 907
 								$stat_query = http_build_query(array_merge($stat_query, $u_query));
831 908
 								$stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query;
832 909
 							}
833
-							if(isset($stat['url'])) $url = $stat['url'];	// if stat returns an url use that, as there might be more links ...
910
+							if(isset($stat['url']))
911
+							{
912
+								$url = $stat['url'];
913
+							}
914
+							// if stat returns an url use that, as there might be more links ...
834 915
 							self::symlinkCache_add($path,$url);
835 916
 						}
836 917
 					}
@@ -853,7 +934,9 @@  discard block
 block discarded – undo
853 934
 		// check if a failed url_stat was for a home dir, in that case silently create it
854 935
 		if (!$stat && $try_create_home && Vfs::dirname(Vfs::parse_url($path,PHP_URL_PATH)) == '/home' &&
855 936
 			($id = $GLOBALS['egw']->accounts->name2id(basename($path))) &&
856
-			$GLOBALS['egw']->accounts->id2name($id) == basename($path))	// make sure path has the right case!
937
+			$GLOBALS['egw']->accounts->id2name($id) == basename($path))
938
+		{
939
+			// make sure path has the right case!
857 940
 		{
858 941
 			$hook_data = array(
859 942
 				'location' => $GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'addgroup' : 'addaccount',
@@ -861,15 +944,22 @@  discard block
 block discarded – undo
861 944
 				'account_lid' => basename($path),
862 945
 				'account_name' => basename($path),
863 946
 			);
947
+		}
864 948
 			call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data);
865 949
 			unset($hook_data);
866 950
 			$stat = $this->url_stat($path,$flags,false);
867 951
 		}
868 952
 		$query = parse_url($url, PHP_URL_QUERY);
869
-		if (!$stat && $check_symlink_components)	// check if there's a symlink somewhere inbetween the path
953
+		if (!$stat && $check_symlink_components)
954
+		{
955
+			// check if there's a symlink somewhere inbetween the path
870 956
 		{
871 957
 			$stat = self::check_symlink_components($path,$flags,$url);
872
-			if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']);
958
+		}
959
+			if ($stat && isset($stat['url']) && !$query)
960
+			{
961
+				self::symlinkCache_add($path,$stat['url']);
962
+			}
873 963
 		}
874 964
 		elseif(is_array($stat) && !isset($stat['url']))
875 965
 		{
@@ -884,7 +974,10 @@  discard block
 block discarded – undo
884 974
 			$stat['url'] .= '?'.$query;
885 975
 		}
886 976
 
887
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat));
977
+		if (self::LOG_LEVEL > 1)
978
+		{
979
+			error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat));
980
+		}
888 981
 
889 982
 		return $stat;
890 983
 
@@ -910,10 +1003,16 @@  discard block
 block discarded – undo
910 1003
 	{
911 1004
 		if (is_null($url) && !($url = self::resolve_url($path)))
912 1005
 		{
913
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1));
1006
+			if (self::LOG_LEVEL > 0)
1007
+			{
1008
+				error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1));
1009
+			}
914 1010
 			return false;
915 1011
 		}
916
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1));
1012
+		if (self::LOG_LEVEL > 1)
1013
+		{
1014
+			error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1));
1015
+		}
917 1016
 
918 1017
 		while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) &&
919 1018
 		       ($url = Vfs::dirname($url)))
@@ -922,7 +1021,10 @@  discard block
 block discarded – undo
922 1021
 			{
923 1022
 				if (is_link($url) && ($lpath = Vfs::readlink($url)))
924 1023
 				{
925
-					if (self::LOG_LEVEL > 1) $log = "rel_path='$rel_path', url='$url': lpath='$lpath'";
1024
+					if (self::LOG_LEVEL > 1)
1025
+					{
1026
+						$log = "rel_path='$rel_path', url='$url': lpath='$lpath'";
1027
+					}
926 1028
 
927 1029
 					if ($lpath[0] != '/')
928 1030
 					{
@@ -930,15 +1032,24 @@  discard block
 block discarded – undo
930 1032
 					}
931 1033
 					//self::symlinkCache_add($path,Vfs::PREFIX.$lpath);
932 1034
 					$url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path);
933
-					if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'");
1035
+					if (self::LOG_LEVEL > 1)
1036
+					{
1037
+						error_log("$log --> lpath='$lpath', url='$url'");
1038
+					}
934 1039
 					return $this->url_stat($url,$flags);
935 1040
 				}
936 1041
 				$url = Vfs::concat($url,$rel_path);
937
-				if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null");
1042
+				if (self::LOG_LEVEL > 1)
1043
+				{
1044
+					error_log(__METHOD__."('$path',$flags,'$url') returning null");
1045
+				}
938 1046
 				return null;
939 1047
 			}
940 1048
 		}
941
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false");
1049
+		if (self::LOG_LEVEL > 1)
1050
+		{
1051
+			error_log(__METHOD__."('$path',$flags,'$url') returning false");
1052
+		}
942 1053
 		return false;	// $path does not exist
943 1054
 	}
944 1055
 
@@ -959,9 +1070,16 @@  discard block
 block discarded – undo
959 1070
 	{
960 1071
 		$path = self::get_path($_path);
961 1072
 
962
-		if (isset(self::$symlink_cache[$path])) return;	// nothing to do
1073
+		if (isset(self::$symlink_cache[$path]))
1074
+		{
1075
+			return;
1076
+		}
1077
+		// nothing to do
963 1078
 
964
-		if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH);
1079
+		if ($target[0] != '/')
1080
+		{
1081
+			$target = Vfs::parse_url($target,PHP_URL_PATH);
1082
+		}
965 1083
 
966 1084
 		self::$symlink_cache[$path] = $target;
967 1085
 
@@ -970,7 +1088,10 @@  discard block
 block discarded – undo
970 1088
 		{
971 1089
 			return strlen($a) - strlen($b);
972 1090
 		});
973
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache));
1091
+		if (self::LOG_LEVEL > 1)
1092
+		{
1093
+			error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache));
1094
+		}
974 1095
 	}
975 1096
 
976 1097
 	/**
@@ -983,7 +1104,10 @@  discard block
 block discarded – undo
983 1104
 		$path = self::get_path($_path);
984 1105
 
985 1106
 		unset(self::$symlink_cache[$path]);
986
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache));
1107
+		if (self::LOG_LEVEL > 1)
1108
+		{
1109
+			error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache));
1110
+		}
987 1111
 	}
988 1112
 
989 1113
 	/**
@@ -1004,11 +1128,18 @@  discard block
 block discarded – undo
1004 1128
 
1005 1129
 		foreach(self::$symlink_cache as $p => $t)
1006 1130
 		{
1007
-			if (($strlen_p = strlen($p)) > $strlen_path) continue;	// $path can NOT start with $p
1131
+			if (($strlen_p = strlen($p)) > $strlen_path)
1132
+			{
1133
+				continue;
1134
+			}
1135
+			// $path can NOT start with $p
1008 1136
 
1009 1137
 			if ($path == $p)
1010 1138
 			{
1011
-				if ($do_symlink) $target = $t;
1139
+				if ($do_symlink)
1140
+				{
1141
+					$target = $t;
1142
+				}
1012 1143
 				break;
1013 1144
 			}
1014 1145
 			elseif (substr($path,0,$strlen_p+1) == $p.'/')
@@ -1017,7 +1148,10 @@  discard block
 block discarded – undo
1017 1148
 				break;
1018 1149
 			}
1019 1150
 		}
1020
-		if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target");
1151
+		if (self::LOG_LEVEL > 1 && isset($target))
1152
+		{
1153
+			error_log(__METHOD__."($path) = $target");
1154
+		}
1021 1155
 		return isset($target) ? $target : $path;
1022 1156
 	}
1023 1157
 
@@ -1058,7 +1192,10 @@  discard block
 block discarded – undo
1058 1192
 				self::HIDE_UNREADABLES && !$this->opened_dir_writable &&
1059 1193
 				!Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE)));
1060 1194
 		}
1061
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'");
1195
+		if (self::LOG_LEVEL > 1)
1196
+		{
1197
+			error_log(__METHOD__."( $this->opened_dir ) = '$file'");
1198
+		}
1062 1199
 		return $file;
1063 1200
 	}
1064 1201
 
@@ -1161,7 +1298,10 @@  discard block
 block discarded – undo
1161 1298
 		) as $class)
1162 1299
 		{
1163 1300
 			//error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class)));
1164
-			if (class_exists($class))  return $class;
1301
+			if (class_exists($class))
1302
+			{
1303
+				return $class;
1304
+			}
1165 1305
 		}
1166 1306
 	}
1167 1307
 
@@ -1222,11 +1362,17 @@  discard block
 block discarded – undo
1222 1362
 	 */
1223 1363
 	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
1224 1364
 	{
1225
-		if (is_null($check_url)) $check_url = strpos($url,'$') === false;
1365
+		if (is_null($check_url))
1366
+		{
1367
+			$check_url = strpos($url,'$') === false;
1368
+		}
1226 1369
 
1227
-		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))	// happens eg. in setup
1370
+		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))
1371
+		{
1372
+			// happens eg. in setup
1228 1373
 		{
1229 1374
 			$api_config = Api\Config::read('phpgwapi');
1375
+		}
1230 1376
 			if (isset($api_config['vfs_fstab']) && is_array($api_config['vfs_fstab']))
1231 1377
 			{
1232 1378
 				self::$fstab = $api_config['vfs_fstab'];
@@ -1242,12 +1388,18 @@  discard block
 block discarded – undo
1242 1388
 		}
1243 1389
 		if (is_null($url) || is_null($path))
1244 1390
 		{
1245
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab));
1391
+			if (self::LOG_LEVEL > 1)
1392
+			{
1393
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab));
1394
+			}
1246 1395
 			return self::$fstab;
1247 1396
 		}
1248 1397
 		if (!Vfs::$is_root)
1249 1398
 		{
1250
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
1399
+			if (self::LOG_LEVEL > 0)
1400
+			{
1401
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
1402
+			}
1251 1403
 			return false;	// only root can mount
1252 1404
 		}
1253 1405
 		if ($clear_fstab)
@@ -1256,14 +1408,20 @@  discard block
 block discarded – undo
1256 1408
 		}
1257 1409
 		if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url)
1258 1410
 		{
1259
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
1411
+			if (self::LOG_LEVEL > 0)
1412
+			{
1413
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
1414
+			}
1260 1415
 			return true;	// already mounted
1261 1416
 		}
1262 1417
 		self::load_wrapper(Vfs::parse_url($url,PHP_URL_SCHEME));
1263 1418
 
1264 1419
 		if ($check_url && (!file_exists($url) || opendir($url) === false))
1265 1420
 		{
1266
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
1421
+			if (self::LOG_LEVEL > 0)
1422
+			{
1423
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
1424
+			}
1267 1425
 			return false;	// url does not exist
1268 1426
 		}
1269 1427
 		self::$fstab[$path] = $url;
@@ -1278,12 +1436,18 @@  discard block
 block discarded – undo
1278 1436
 			Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
1279 1437
 			$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
1280 1438
 			// invalidate session cache
1281
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1439
+			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
1440
+			{
1441
+				// egw object in setup is limited
1282 1442
 			{
1283 1443
 				$GLOBALS['egw']->invalidate_session_cache();
1284 1444
 			}
1445
+			}
1446
+		}
1447
+		if (self::LOG_LEVEL > 1)
1448
+		{
1449
+			error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).');
1285 1450
 		}
1286
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).');
1287 1451
 		return true;
1288 1452
 	}
1289 1453
 
@@ -1296,12 +1460,18 @@  discard block
 block discarded – undo
1296 1460
 	{
1297 1461
 		if (!Vfs::$is_root)
1298 1462
 		{
1299
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
1463
+			if (self::LOG_LEVEL > 0)
1464
+			{
1465
+				error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
1466
+			}
1300 1467
 			return false;	// only root can mount
1301 1468
 		}
1302 1469
 		if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
1303 1470
 		{
1304
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
1471
+			if (self::LOG_LEVEL > 0)
1472
+			{
1473
+				error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
1474
+			}
1305 1475
 			return false;	// $path not mounted
1306 1476
 		}
1307 1477
 		unset(self::$fstab[$path]);
@@ -1309,11 +1479,17 @@  discard block
 block discarded – undo
1309 1479
 		Api\Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
1310 1480
 		$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
1311 1481
 		// invalidate session cache
1312
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
1482
+		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
1483
+		{
1484
+			// egw object in setup is limited
1313 1485
 		{
1314 1486
 			$GLOBALS['egw']->invalidate_session_cache();
1315 1487
 		}
1316
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).');
1488
+		}
1489
+		if (self::LOG_LEVEL > 1)
1490
+		{
1491
+			error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).');
1492
+		}
1317 1493
 		return true;
1318 1494
 	}
1319 1495
 
Please login to merge, or discard this patch.