Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
api/src/Vfs/WebDAV.php 1 patch
Braces   +133 added lines, -50 removed lines patch added patch discarded remove patch
@@ -64,7 +64,8 @@  discard block
 block discarded – undo
64 64
 		// special treatment for litmus compliance test
65 65
 		// reply on its identifier header
66 66
 		// not needed for the test itself but eases debugging
67
-		if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
67
+		if (isset($this->_SERVER['HTTP_X_LITMUS']))
68
+		{
68 69
 			error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
69 70
 			header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
70 71
 		}
@@ -123,24 +124,30 @@  discard block
 block discarded – undo
123 124
         $path   = $this->_unslashify($this->base .$options["path"]);
124 125
         $parent = Vfs::dirname($path);
125 126
 
126
-        if (!file_exists($parent)) {
127
+        if (!file_exists($parent))
128
+        {
127 129
             return "409 Conflict";
128 130
         }
129 131
 
130
-        if (!is_dir($parent)) {
132
+        if (!is_dir($parent))
133
+        {
131 134
             return "403 Forbidden";
132 135
         }
133 136
 
134
-        if ( file_exists($path) ) {
137
+        if ( file_exists($path) )
138
+        {
135 139
             return "405 Method not allowed";
136 140
         }
137 141
 
138
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
142
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
143
+        {
144
+// no body parsing yet
139 145
             return "415 Unsupported media type";
140 146
         }
141 147
 
142 148
         $stat = mkdir($path, 0777);
143
-        if (!$stat) {
149
+        if (!$stat)
150
+        {
144 151
             return "403 Forbidden";
145 152
         }
146 153
 
@@ -157,24 +164,35 @@  discard block
 block discarded – undo
157 164
     {
158 165
         // TODO Property updates still broken (Litmus should detect this?)
159 166
 
160
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
167
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
168
+        {
169
+// no body parsing yet
161 170
             return "415 Unsupported media type";
162 171
         }
163 172
 
164 173
         // no copying to different WebDAV Servers yet
165
-        if (isset($options["dest_url"])) {
174
+        if (isset($options["dest_url"]))
175
+        {
166 176
             return "502 bad gateway";
167 177
         }
168 178
 
169 179
         $source = $this->base .$options["path"];
170
-        if (!file_exists($source)) return "404 Not found";
180
+        if (!file_exists($source))
181
+        {
182
+        	return "404 Not found";
183
+        }
171 184
 
172
-        if (is_dir($source)) { // resource is a collection
173
-            switch ($options["depth"]) {
185
+        if (is_dir($source))
186
+        {
187
+// resource is a collection
188
+            switch ($options["depth"])
189
+            {
174 190
             case "infinity": // valid
175 191
                 break;
176 192
             case "0": // valid for COPY only
177
-                if ($del) { // MOVE?
193
+                if ($del)
194
+                {
195
+// MOVE?
178 196
                     return "400 Bad request";
179 197
                 }
180 198
                 break;
@@ -187,71 +205,99 @@  discard block
 block discarded – undo
187 205
         $dest         = $this->base . $options["dest"];
188 206
         $destdir      = dirname($dest);
189 207
 
190
-        if (!file_exists($destdir) || !is_dir($destdir)) {
208
+        if (!file_exists($destdir) || !is_dir($destdir))
209
+        {
191 210
             return "409 Conflict";
192 211
         }
193 212
 
194 213
         $new          = !file_exists($dest);
195 214
         $existing_col = false;
196 215
 
197
-        if (!$new) {
198
-            if ($del && is_dir($dest)) {
199
-                if (!$options["overwrite"]) {
216
+        if (!$new)
217
+        {
218
+            if ($del && is_dir($dest))
219
+            {
220
+                if (!$options["overwrite"])
221
+                {
200 222
                     return "412 precondition failed";
201 223
                 }
202 224
                 $dest .= basename($source);
203
-                if (file_exists($dest)) {
225
+                if (file_exists($dest))
226
+                {
204 227
                     $options["dest"] .= basename($source);
205
-                } else {
228
+                }
229
+                else
230
+                {
206 231
                     $new          = true;
207 232
                     $existing_col = true;
208 233
                 }
209 234
             }
210 235
         }
211 236
 
212
-        if (!$new) {
213
-            if ($options["overwrite"]) {
237
+        if (!$new)
238
+        {
239
+            if ($options["overwrite"])
240
+            {
214 241
                 $stat = $this->DELETE(array("path" => $options["dest"]));
215
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
242
+                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404"))
243
+                {
216 244
                     return $stat;
217 245
                 }
218
-            } else {
246
+            }
247
+            else
248
+            {
219 249
                 return "412 precondition failed";
220 250
             }
221 251
         }
222 252
 
223
-        if ($del) {
224
-            if (!rename($source, $dest)) {
253
+        if ($del)
254
+        {
255
+            if (!rename($source, $dest))
256
+            {
225 257
                 return "500 Internal server error";
226 258
             }
227
-        } else {
228
-            if (is_dir($source) && $options['depth'] == 'infinity') {
259
+        }
260
+        else
261
+        {
262
+            if (is_dir($source) && $options['depth'] == 'infinity')
263
+            {
229 264
             	$files = Vfs::find($source,array('depth' => true,'url' => true));	// depth=true: return dirs first, url=true: allow urls!
230
-            } else {
265
+            }
266
+            else
267
+            {
231 268
                 $files = array($source);
232 269
             }
233 270
 
234
-            if (!is_array($files) || empty($files)) {
271
+            if (!is_array($files) || empty($files))
272
+            {
235 273
                 return "500 Internal server error";
236 274
             }
237 275
 
238 276
 
239
-            foreach ($files as $file) {
240
-                if (is_dir($file)) {
277
+            foreach ($files as $file)
278
+            {
279
+                if (is_dir($file))
280
+                {
241 281
                     $file = $this->_slashify($file);
242 282
                 }
243 283
 
244 284
                 $destfile = str_replace($source, $dest, $file);
245 285
 
246
-                if (is_dir($file)) {
247
-                    if (!is_dir($destfile)) {
286
+                if (is_dir($file))
287
+                {
288
+                    if (!is_dir($destfile))
289
+                    {
248 290
                         // TODO "mkdir -p" here? (only natively supported by PHP 5)
249
-                        if (!@mkdir($destfile)) {
291
+                        if (!@mkdir($destfile))
292
+                        {
250 293
                             return "409 Conflict";
251 294
                         }
252 295
                     }
253
-                } else {
254
-                    if (!@copy($file, $destfile)) {
296
+                }
297
+                else
298
+                {
299
+                    if (!@copy($file, $destfile))
300
+                    {
255 301
                         return "409 Conflict";
256 302
                     }
257 303
                 }
@@ -301,17 +347,23 @@  discard block
 block discarded – undo
301 347
         $info["props"][] = self::mkprop("ishidden",        Vfs::is_hidden($fspath));
302 348
 
303 349
 		// type and size (caller already made sure that path exists)
304
-		if (is_dir($fspath)) {
350
+		if (is_dir($fspath))
351
+		{
305 352
 			// directory (WebDAV collection)
306 353
 			$info['props'][] = self::mkprop	('resourcetype', array(
307 354
 			 	self::mkprop('collection', '')));
308 355
 			$info['props'][] = self::mkprop	('getcontenttype', 'httpd/unix-directory');
309
-		} else {
356
+		}
357
+		else
358
+		{
310 359
 			// plain file (WebDAV resource)
311 360
 			$info['props'][] = self::mkprop	('resourcetype', '');
312
-			if (Vfs::is_readable($path)) {
361
+			if (Vfs::is_readable($path))
362
+			{
313 363
 				$info['props'][] = self::mkprop	('getcontenttype', Vfs::mime_content_type($path));
314
-			} else {
364
+			}
365
+			else
366
+			{
315 367
 				error_log(__METHOD__."($path) $fspath is not readable!");
316 368
 				$info['props'][] = self::mkprop	('getcontenttype', 'application/x-non-readable');
317 369
 			}
@@ -383,7 +435,10 @@  discard block
 block discarded – undo
383 435
 				continue;
384 436
 			}
385 437
 			$_path = $info['path'];
386
-			if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1);
438
+			if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/')
439
+			{
440
+				$_path = substr($info['path'],0,-1);
441
+			}
387 442
 
388 443
 			// need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it
389 444
 			// otherwise pathes containing url special chars like ? or # will not stat
@@ -422,16 +477,22 @@  discard block
 block discarded – undo
422 477
 				$fileprops =& $files['files'][$path2n[$path]]['props'];
423 478
 				foreach($props as $prop)
424 479
 				{
425
-					if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#')	// eGW's customfields
480
+					if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#')
481
+					{
482
+						// eGW's customfields
426 483
 					{
427 484
 						$prop['ns'] .= 'customfields/';
485
+					}
428 486
 						$prop['name'] = substr($prop['name'],1);
429 487
 					}
430 488
 					$fileprops[] = $prop;
431 489
 				}
432 490
 			}
433 491
 		}
434
-		if ($this->debug) error_log(__METHOD__."() props=".array2string($files['files']));
492
+		if ($this->debug)
493
+		{
494
+			error_log(__METHOD__."() props=".array2string($files['files']));
495
+		}
435 496
 		return true;
436 497
 	}
437 498
 
@@ -483,7 +544,8 @@  discard block
 block discarded – undo
483 544
 	{
484 545
 		$path = Api\Translation::convert($options['path'],'utf-8');
485 546
 
486
-		foreach ($options['props'] as $key => $prop) {
547
+		foreach ($options['props'] as $key => $prop)
548
+		{
487 549
 			$attributes = array();
488 550
 			switch($prop['ns'])
489 551
 			{
@@ -500,7 +562,10 @@  discard block
 block discarded – undo
500 562
 							//$attributes['created'] = strtotime($prop['val']);
501 563
 							//break;
502 564
 						default:
503
-							if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
565
+							if (!Vfs::proppatch($path,array($prop)))
566
+							{
567
+								$options['props'][$key]['status'] = '403 Forbidden';
568
+							}
504 569
 							break;
505 570
 					}
506 571
 					break;
@@ -529,7 +594,10 @@  discard block
 block discarded – undo
529 594
 						case 'Win32LastAccessTime':
530 595
 						case 'Win32FileAttributes':	// not sure what that is, it was always "00000000"
531 596
 						default:
532
-							if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
597
+							if (!Vfs::proppatch($path,array($prop)))
598
+							{
599
+								$options['props'][$key]['status'] = '403 Forbidden';
600
+							}
533 601
 							break;
534 602
 					}
535 603
 					break;
@@ -539,15 +607,24 @@  discard block
 block discarded – undo
539 607
 					$prop['name'] = '#'.$prop['name'];
540 608
 					// fall through
541 609
 				default:
542
-					if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
610
+					if (!Vfs::proppatch($path,array($prop)))
611
+					{
612
+						$options['props'][$key]['status'] = '403 Forbidden';
613
+					}
543 614
 					break;
544 615
 			}
545
-			if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
616
+			if ($this->debug)
617
+			{
618
+				$props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
619
+			}
546 620
 		}
547 621
 		if ($this->debug)
548 622
 		{
549 623
 			error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props));
550
-			if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
624
+			if ($attributes)
625
+			{
626
+				error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
627
+			}
551 628
 		}
552 629
 
553 630
 		return '';	// this is as the filesystem example handler does it, no true or false ...
@@ -561,7 +638,10 @@  discard block
 block discarded – undo
561 638
 	 */
562 639
 	function LOCK(&$options)
563 640
 	{
564
-		if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
641
+		if ($this->debug)
642
+		{
643
+			error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
644
+		}
565 645
 		// TODO recursive locks on directories not supported yet
566 646
 		if (is_dir($this->base . $options['path']) && !empty($options['depth']))
567 647
 		{
@@ -587,7 +667,10 @@  discard block
 block discarded – undo
587 667
 	 */
588 668
 	function UNLOCK(&$options)
589 669
 	{
590
-		if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
670
+		if ($this->debug)
671
+		{
672
+			error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
673
+		}
591 674
 		return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict';
592 675
 	}
593 676
 
Please login to merge, or discard this patch.
api/src/Vfs/StreamWrapper.php 1 patch
Braces   +184 added lines, -45 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(self::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(self::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
 	}
@@ -491,10 +525,13 @@  discard block
 block discarded – undo
491 525
 	 */
492 526
 	static function unlink ( $path )
493 527
 	{
494
-		if (!($url = self::resolve_url_symlinks($path,true,false)))	// true,false file need to exist, but do not resolve last component
528
+		if (!($url = self::resolve_url_symlinks($path,true,false)))
529
+		{
530
+			// true,false file need to exist, but do not resolve last component
495 531
 		{
496 532
 			return false;
497 533
 		}
534
+		}
498 535
 		if (self::url_is_readonly($url))
499 536
 		{
500 537
 			return false;
@@ -547,7 +584,10 @@  discard block
 block discarded – undo
547 584
 			$ret = stream_copy_to_stream($from,$to) !== false;
548 585
 			fclose($from);
549 586
 			fclose($to);
550
-			if ($ret) self::unlink($path_from);
587
+			if ($ret)
588
+			{
589
+				self::unlink($path_from);
590
+			}
551 591
 		}
552 592
 		else
553 593
 		{
@@ -584,10 +624,13 @@  discard block
 block discarded – undo
584 624
 	 */
585 625
 	static function mkdir ( $path, $mode, $options )
586 626
 	{
587
-		if (!($url = self::resolve_url_symlinks($path,false)))	// false = directory does not need to exists
627
+		if (!($url = self::resolve_url_symlinks($path,false)))
628
+		{
629
+			// false = directory does not need to exists
588 630
 		{
589 631
 			return false;
590 632
 		}
633
+		}
591 634
 		$ret = mkdir($url,$mode,$options);
592 635
 
593 636
 		// call "vfs_mkdir" hook
@@ -665,7 +708,10 @@  discard block
 block discarded – undo
665 708
 				return false;
666 709
 			}
667 710
 			$k=(string)self::parse_url($url,PHP_URL_SCHEME);
668
-			if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array();
711
+			if (!(is_array($scheme2urls[$k])))
712
+			{
713
+				$scheme2urls[$k] = array();
714
+			}
669 715
 			$scheme2urls[$k][$path] = $url;
670 716
 		}
671 717
 		$ret = array();
@@ -675,7 +721,10 @@  discard block
 block discarded – undo
675 721
 			{
676 722
 				if (!class_exists($class = self::scheme2class($scheme)) || !method_exists($class,$name))
677 723
 				{
678
-					if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
724
+					if (!$fail_silent)
725
+					{
726
+						trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
727
+					}
679 728
 					return false;
680 729
 				}
681 730
 				if (!is_array($pathes))
@@ -793,10 +842,13 @@  discard block
 block discarded – undo
793 842
 	 */
794 843
 	static function symlink($target,$link)
795 844
 	{
796
-		if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1)))	// 1=path is in $link!
845
+		if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1)))
846
+		{
847
+			// 1=path is in $link!
797 848
 		{
798 849
 			self::symlinkCache_remove($link);
799 850
 		}
851
+		}
800 852
 		return $ret;
801 853
 	}
802 854
 
@@ -866,13 +918,19 @@  discard block
 block discarded – undo
866 918
 
867 919
 		if (!($this->opened_dir_url = self::resolve_url_symlinks($path)))
868 920
 		{
869
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!");
921
+			if (self::LOG_LEVEL > 0)
922
+			{
923
+				error_log(__METHOD__."( $path,$options) resolve_url_symlinks() failed!");
924
+			}
870 925
 			return false;
871 926
 		}
872 927
 		if (!($this->opened_dir = $this->context ?
873 928
 			opendir($this->opened_dir_url, $this->context) : opendir($this->opened_dir_url)))
874 929
 		{
875
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!");
930
+			if (self::LOG_LEVEL > 0)
931
+			{
932
+				error_log(__METHOD__."( $path,$options) opendir($this->opened_dir_url) failed!");
933
+			}
876 934
 			return false;
877 935
 		}
878 936
 		$this->opened_dir_writable = Vfs::check_access($this->opened_dir_url,Vfs::WRITABLE);
@@ -890,7 +948,10 @@  discard block
 block discarded – undo
890 948
 		}
891 949
 
892 950
 
893
-		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());
951
+		if (self::LOG_LEVEL > 1)
952
+		{
953
+			error_log(__METHOD__."( $path,$options): opendir($this->opened_dir_url)=$this->opened_dir, extra_dirs=".array2string($this->extra_dirs).', '.function_backtrace());
954
+		}
894 955
 		return true;
895 956
 	}
896 957
 
@@ -926,7 +987,10 @@  discard block
 block discarded – undo
926 987
 	{
927 988
 		if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components)))
928 989
 		{
929
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
990
+			if (self::LOG_LEVEL > 0)
991
+			{
992
+				error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
993
+			}
930 994
 			return false;
931 995
 		}
932 996
 
@@ -943,18 +1007,27 @@  discard block
 block discarded – undo
943 1007
 				{
944 1008
 					if (!$check_symlink_depth)
945 1009
 					{
946
-						if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!");
1010
+						if (self::LOG_LEVEL > 0)
1011
+						{
1012
+							error_log(__METHOD__."('$path',$flags) maximum symlink depth exceeded, might be a circular symlink!");
1013
+						}
947 1014
 						$stat = false;
948 1015
 					}
949 1016
 					elseif (($lpath = self::readlink($url)))
950 1017
 					{
951
-						if ($lpath[0] != '/')	// concat relative path
1018
+						if ($lpath[0] != '/')
1019
+						{
1020
+							// concat relative path
952 1021
 						{
953 1022
 							$lpath = Vfs::concat(self::parse_url($path,PHP_URL_PATH),'../'.$lpath);
954 1023
 						}
1024
+						}
955 1025
 						$u_query = parse_url($url,PHP_URL_QUERY);
956 1026
 						$url = Vfs::PREFIX.$lpath;
957
-						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");
1027
+						if (self::LOG_LEVEL > 1)
1028
+						{
1029
+							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");
1030
+						}
958 1031
 						// try reading the stat of the link
959 1032
 						if (($stat = self::url_stat($lpath, STREAM_URL_STAT_QUIET, false, true, $check_symlink_depth-1)))
960 1033
 						{
@@ -967,7 +1040,11 @@  discard block
 block discarded – undo
967 1040
 								$stat_query = http_build_query(array_merge($stat_query, $u_query));
968 1041
 								$stat['url'] = $stat_url['scheme'].'://'.$stat_url['host'].$stat_url['path'].'?'.$stat_query;
969 1042
 							}
970
-							if(isset($stat['url'])) $url = $stat['url'];	// if stat returns an url use that, as there might be more links ...
1043
+							if(isset($stat['url']))
1044
+							{
1045
+								$url = $stat['url'];
1046
+							}
1047
+							// if stat returns an url use that, as there might be more links ...
971 1048
 							self::symlinkCache_add($path,$url);
972 1049
 						}
973 1050
 					}
@@ -990,7 +1067,9 @@  discard block
 block discarded – undo
990 1067
 		// check if a failed url_stat was for a home dir, in that case silently create it
991 1068
 		if (!$stat && $try_create_home && Vfs::dirname(self::parse_url($path,PHP_URL_PATH)) == '/home' &&
992 1069
 			($id = $GLOBALS['egw']->accounts->name2id(basename($path))) &&
993
-			$GLOBALS['egw']->accounts->id2name($id) == basename($path))	// make sure path has the right case!
1070
+			$GLOBALS['egw']->accounts->id2name($id) == basename($path))
1071
+		{
1072
+			// make sure path has the right case!
994 1073
 		{
995 1074
 			$hook_data = array(
996 1075
 				'location' => $GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'addgroup' : 'addaccount',
@@ -998,15 +1077,22 @@  discard block
 block discarded – undo
998 1077
 				'account_lid' => basename($path),
999 1078
 				'account_name' => basename($path),
1000 1079
 			);
1080
+		}
1001 1081
 			call_user_func(array(__NAMESPACE__.'\\Hooks',$hook_data['location']),$hook_data);
1002 1082
 			unset($hook_data);
1003 1083
 			$stat = self::url_stat($path,$flags,false);
1004 1084
 		}
1005 1085
 		$query = parse_url($url, PHP_URL_QUERY);
1006
-		if (!$stat && $check_symlink_components)	// check if there's a symlink somewhere inbetween the path
1086
+		if (!$stat && $check_symlink_components)
1087
+		{
1088
+			// check if there's a symlink somewhere inbetween the path
1007 1089
 		{
1008 1090
 			$stat = self::check_symlink_components($path,$flags,$url);
1009
-			if ($stat && isset($stat['url']) && !$query) self::symlinkCache_add($path,$stat['url']);
1091
+		}
1092
+			if ($stat && isset($stat['url']) && !$query)
1093
+			{
1094
+				self::symlinkCache_add($path,$stat['url']);
1095
+			}
1010 1096
 		}
1011 1097
 		elseif(is_array($stat) && !isset($stat['url']))
1012 1098
 		{
@@ -1021,7 +1107,10 @@  discard block
 block discarded – undo
1021 1107
 			$stat['url'] .= '?'.$query;
1022 1108
 		}
1023 1109
 
1024
-		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));
1110
+		if (self::LOG_LEVEL > 1)
1111
+		{
1112
+			error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components) returning ".array2string($stat));
1113
+		}
1025 1114
 
1026 1115
 		return $stat;
1027 1116
 
@@ -1047,10 +1136,16 @@  discard block
 block discarded – undo
1047 1136
 	{
1048 1137
 		if (is_null($url) && !($url = self::resolve_url($path)))
1049 1138
 		{
1050
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1));
1139
+			if (self::LOG_LEVEL > 0)
1140
+			{
1141
+				error_log(__METHOD__."('$path',$flags,'$url') can NOT resolve path: ".function_backtrace(1));
1142
+			}
1051 1143
 			return false;
1052 1144
 		}
1053
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1));
1145
+		if (self::LOG_LEVEL > 1)
1146
+		{
1147
+			error_log(__METHOD__."('$path',$flags,'$url'): ".function_backtrace(1));
1148
+		}
1054 1149
 
1055 1150
 		while (($rel_path = Vfs::basename($url).($rel_path ? '/'.$rel_path : '')) &&
1056 1151
 		       ($url = Vfs::dirname($url)))
@@ -1059,7 +1154,10 @@  discard block
 block discarded – undo
1059 1154
 			{
1060 1155
 				if (is_link($url) && ($lpath = self::readlink($url)))
1061 1156
 				{
1062
-					if (self::LOG_LEVEL > 1) $log = "rel_path='$rel_path', url='$url': lpath='$lpath'";
1157
+					if (self::LOG_LEVEL > 1)
1158
+					{
1159
+						$log = "rel_path='$rel_path', url='$url': lpath='$lpath'";
1160
+					}
1063 1161
 
1064 1162
 					if ($lpath[0] != '/')
1065 1163
 					{
@@ -1067,15 +1165,24 @@  discard block
 block discarded – undo
1067 1165
 					}
1068 1166
 					//self::symlinkCache_add($path,Vfs::PREFIX.$lpath);
1069 1167
 					$url = Vfs::PREFIX.Vfs::concat($lpath,$rel_path);
1070
-					if (self::LOG_LEVEL > 1) error_log("$log --> lpath='$lpath', url='$url'");
1168
+					if (self::LOG_LEVEL > 1)
1169
+					{
1170
+						error_log("$log --> lpath='$lpath', url='$url'");
1171
+					}
1071 1172
 					return self::url_stat($url,$flags);
1072 1173
 				}
1073 1174
 				$url = Vfs::concat($url,$rel_path);
1074
-				if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning null");
1175
+				if (self::LOG_LEVEL > 1)
1176
+				{
1177
+					error_log(__METHOD__."('$path',$flags,'$url') returning null");
1178
+				}
1075 1179
 				return null;
1076 1180
 			}
1077 1181
 		}
1078
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,'$url') returning false");
1182
+		if (self::LOG_LEVEL > 1)
1183
+		{
1184
+			error_log(__METHOD__."('$path',$flags,'$url') returning false");
1185
+		}
1079 1186
 		return false;	// $path does not exist
1080 1187
 	}
1081 1188
 
@@ -1096,9 +1203,16 @@  discard block
 block discarded – undo
1096 1203
 	{
1097 1204
 		$path = self::get_path($_path);
1098 1205
 
1099
-		if (isset(self::$symlink_cache[$path])) return;	// nothing to do
1206
+		if (isset(self::$symlink_cache[$path]))
1207
+		{
1208
+			return;
1209
+		}
1210
+		// nothing to do
1100 1211
 
1101
-		if ($target[0] != '/') $target = self::parse_url($target,PHP_URL_PATH);
1212
+		if ($target[0] != '/')
1213
+		{
1214
+			$target = self::parse_url($target,PHP_URL_PATH);
1215
+		}
1102 1216
 
1103 1217
 		self::$symlink_cache[$path] = $target;
1104 1218
 
@@ -1107,7 +1221,10 @@  discard block
 block discarded – undo
1107 1221
 		{
1108 1222
 			return strlen($a) - strlen($b);
1109 1223
 		});
1110
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache));
1224
+		if (self::LOG_LEVEL > 1)
1225
+		{
1226
+			error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache));
1227
+		}
1111 1228
 	}
1112 1229
 
1113 1230
 	/**
@@ -1120,7 +1237,10 @@  discard block
 block discarded – undo
1120 1237
 		$path = self::get_path($_path);
1121 1238
 
1122 1239
 		unset(self::$symlink_cache[$path]);
1123
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache));
1240
+		if (self::LOG_LEVEL > 1)
1241
+		{
1242
+			error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache));
1243
+		}
1124 1244
 	}
1125 1245
 
1126 1246
 	/**
@@ -1141,11 +1261,18 @@  discard block
 block discarded – undo
1141 1261
 
1142 1262
 		foreach(self::$symlink_cache as $p => $t)
1143 1263
 		{
1144
-			if (($strlen_p = strlen($p)) > $strlen_path) continue;	// $path can NOT start with $p
1264
+			if (($strlen_p = strlen($p)) > $strlen_path)
1265
+			{
1266
+				continue;
1267
+			}
1268
+			// $path can NOT start with $p
1145 1269
 
1146 1270
 			if ($path == $p)
1147 1271
 			{
1148
-				if ($do_symlink) $target = $t;
1272
+				if ($do_symlink)
1273
+				{
1274
+					$target = $t;
1275
+				}
1149 1276
 				break;
1150 1277
 			}
1151 1278
 			elseif (substr($path,0,$strlen_p+1) == $p.'/')
@@ -1154,7 +1281,10 @@  discard block
 block discarded – undo
1154 1281
 				break;
1155 1282
 			}
1156 1283
 		}
1157
-		if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target");
1284
+		if (self::LOG_LEVEL > 1 && isset($target))
1285
+		{
1286
+			error_log(__METHOD__."($path) = $target");
1287
+		}
1158 1288
 		return isset($target) ? $target : $path;
1159 1289
 	}
1160 1290
 
@@ -1203,7 +1333,10 @@  discard block
 block discarded – undo
1203 1333
 				self::HIDE_UNREADABLES && !$this->opened_dir_writable &&
1204 1334
 				!Vfs::check_access(Vfs::concat($this->opened_dir_url,$file),Vfs::READABLE)));
1205 1335
 		}
1206
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( $this->opened_dir ) = '$file'");
1336
+		if (self::LOG_LEVEL > 1)
1337
+		{
1338
+			error_log(__METHOD__."( $this->opened_dir ) = '$file'");
1339
+		}
1207 1340
 		return $file;
1208 1341
 	}
1209 1342
 
@@ -1306,7 +1439,10 @@  discard block
 block discarded – undo
1306 1439
 		) as $class)
1307 1440
 		{
1308 1441
 			//error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class)));
1309
-			if (class_exists($class))  return $class;
1442
+			if (class_exists($class))
1443
+			{
1444
+				return $class;
1445
+			}
1310 1446
 		}
1311 1447
 	}
1312 1448
 
@@ -1341,7 +1477,10 @@  discard block
 block discarded – undo
1341 1477
 			static $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%23', '%5B', '%5D');
1342 1478
 			static $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "#", "[", "]");
1343 1479
 			static $str_replace = null;
1344
-			if (!isset($str_replace)) $str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace';
1480
+			if (!isset($str_replace))
1481
+			{
1482
+				$str_replace = function_exists('mb_str_replace') ? 'mb_str_replace' : 'str_replace';
1483
+			}
1345 1484
 
1346 1485
 			// Create encoded URL with special URL characters decoded so it can be parsed
1347 1486
 			// All other characters will be encoded
Please login to merge, or discard this patch.
api/src/Vfs/Sharing.php 1 patch
Braces   +48 added lines, -12 removed lines patch added patch discarded remove patch
@@ -166,7 +166,10 @@  discard block
 block discarded – undo
166 166
 		if ($token && !$keep_session)
167 167
 		{
168 168
 			$_SERVER['PHP_AUTH_USER'] = $token;
169
-			if (!isset($_SERVER['PHP_AUTH_PW'])) $_SERVER['PHP_AUTH_PW'] = '';
169
+			if (!isset($_SERVER['PHP_AUTH_PW']))
170
+			{
171
+				$_SERVER['PHP_AUTH_PW'] = '';
172
+			}
170 173
 
171 174
 			unset($GLOBALS['egw_info']['flags']['autocreate_session_callback']);
172 175
 			if ($GLOBALS['egw']->session->verify() && isset($GLOBALS['egw']->sharing) &&
@@ -220,9 +223,12 @@  discard block
 block discarded – undo
220 223
 		}
221 224
 		//_debug_array($share);
222 225
 
223
-		if ($keep_session)	// add share to existing session
226
+		if ($keep_session)
227
+		{
228
+			// add share to existing session
224 229
 		{
225 230
 			$share['share_root'] = '/'.$share['share_token'];
231
+		}
226 232
 
227 233
 			// if current user is not the share owner, we cant just mount share
228 234
 			if (Vfs::$user != $share['share_owner'])
@@ -230,12 +236,15 @@  discard block
 block discarded – undo
230 236
 				$keep_session = false;
231 237
 			}
232 238
 		}
233
-		if (!$keep_session)	// do NOT change to else, as we might have set $keep_session=false!
239
+		if (!$keep_session)
240
+		{
241
+			// do NOT change to else, as we might have set $keep_session=false!
234 242
 		{
235 243
 			// only allow filemanager app
236 244
 			$GLOBALS['egw_info']['user']['apps'] = array(
237 245
 				'filemanager' => $GLOBALS['egw_info']['apps']['filemanager']
238 246
 			);
247
+		}
239 248
 
240 249
 			$share['share_root'] = '/';
241 250
 			Vfs::$user = $share['share_owner'];
@@ -391,9 +400,15 @@  discard block
 block discarded – undo
391 400
 	 */
392 401
 	public static function create($path, $mode, $name, $recipients, $extra=array())
393 402
 	{
394
-		if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db;
403
+		if (!isset(self::$db))
404
+		{
405
+			self::$db = $GLOBALS['egw']->db;
406
+		}
395 407
 
396
-		if (empty($name)) $name = $path;
408
+		if (empty($name))
409
+		{
410
+			$name = $path;
411
+		}
397 412
 
398 413
 		$path2tmp =& Api\Cache::getSession(__CLASS__, 'path2tmp');
399 414
 
@@ -472,7 +487,10 @@  discard block
 block discarded – undo
472 487
 				{
473 488
 					throw new Api\Exception\AssertionFailed("Could NOT create temp. file '$tmp_file'!");
474 489
 				}
475
-				if ($fp) fclose($fp);
490
+				if ($fp)
491
+				{
492
+					fclose($fp);
493
+				}
476 494
 
477 495
 				if (is_dir($path) && !Vfs::copy_files(array($path), $tmp_file) ||
478 496
 					!is_dir($path) && !copy($path, Vfs::PREFIX.$tmp_file))
@@ -493,7 +511,9 @@  discard block
 block discarded – undo
493 511
 			}
494 512
 
495 513
 			$i = 0;
496
-			while(true)	// self::token() can return an existing value
514
+			while(true)
515
+			{
516
+				// self::token() can return an existing value
497 517
 			{
498 518
 				try {
499 519
 					self::$db->insert(self::TABLE, $share = array(
@@ -503,12 +523,16 @@  discard block
 block discarded – undo
503 523
 						'share_with' => implode(',', (array)$recipients),
504 524
 						'share_created' => time(),
505 525
 					)+$extra, false, __LINE__, __FILE__);
526
+			}
506 527
 
507 528
 					$share['share_id'] = self::$db->get_last_insert_id(self::TABLE, 'share_id');
508 529
 					break;
509 530
 				}
510 531
 				catch(Api\Db\Exception $e) {
511
-					if ($i++ > 3) throw $e;
532
+					if ($i++ > 3)
533
+					{
534
+						throw $e;
535
+					}
512 536
 					unset($e);
513 537
 				}
514 538
 			}
@@ -546,7 +570,10 @@  discard block
 block discarded – undo
546 570
 	{
547 571
 		self::$db = $GLOBALS['egw']->db;
548 572
 
549
-		if (is_scalar($keys)) $keys = array('share_id' => $keys);
573
+		if (is_scalar($keys))
574
+		{
575
+			$keys = array('share_id' => $keys);
576
+		}
550 577
 
551 578
 		// get all temp. files, to be able to delete them
552 579
 		$tmp_paths = array();
@@ -593,7 +620,10 @@  discard block
 block discarded – undo
593 620
 	 */
594 621
 	public static function tmp_cleanup()
595 622
 	{
596
-		if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db;
623
+		if (!isset(self::$db))
624
+		{
625
+			self::$db = $GLOBALS['egw']->db;
626
+		}
597 627
 		Vfs::$is_root = true;
598 628
 
599 629
 		try {
@@ -603,7 +633,10 @@  discard block
 block discarded – undo
603 633
 				'MAX(share_created) AS share_created',
604 634
 				'MAX(share_last_accessed) AS share_last_accessed',
605 635
 			);
606
-			if (($group_concat = self::$db->group_concat('share_id'))) $cols[] = $group_concat.' AS share_id';
636
+			if (($group_concat = self::$db->group_concat('share_id')))
637
+			{
638
+				$cols[] = $group_concat.' AS share_id';
639
+			}
607 640
 			// remove expired tmp-files unconditionally
608 641
 			$having = 'HAVING share_expires < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '.
609 642
 				// remove without expiration date, when created over 100 days ago AND
@@ -651,7 +684,10 @@  discard block
 block discarded – undo
651 684
 	 */
652 685
 	public static function share2link($share)
653 686
 	{
654
-		if (is_array($share)) $share = $share['share_token'];
687
+		if (is_array($share))
688
+		{
689
+			$share = $share['share_token'];
690
+		}
655 691
 
656 692
 		$link = Api\Framework::link('/share.php').'/'.$share;
657 693
 		if ($link[0] == '/')
Please login to merge, or discard this patch.
api/src/Vfs/Links/StreamWrapper.php 1 patch
Braces   +26 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
  */
27 27
 if (!class_exists('EGroupware\\Api\\Vfs\\Links\\LinksParent', false))
28 28
 {
29
-	class LinksParent extends Vfs\Sqlfs\StreamWrapper {}
29
+	class LinksParent extends Vfs\Sqlfs\StreamWrapper
30
+	{
31
+}
30 32
 }
31 33
 
32 34
 /**
@@ -116,7 +118,10 @@  discard block
 block discarded – undo
116 118
 			$access = Api\Link::file_access($app,$id,$required,$rel_path,Vfs::$user);
117 119
 			$what = "from Api\Link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")";
118 120
 		}
119
-		if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!'));
121
+		if (self::DEBUG)
122
+		{
123
+			error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!'));
124
+		}
120 125
 		return $access;
121 126
 	}
122 127
 
@@ -180,7 +185,10 @@  discard block
 block discarded – undo
180 185
 				);
181 186
 			}
182 187
 		}
183
-		if (self::DEBUG) error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret));
188
+		if (self::DEBUG)
189
+		{
190
+			error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret));
191
+		}
184 192
 		return $ret;
185 193
 	}
186 194
 
@@ -238,19 +246,30 @@  discard block
 block discarded – undo
238 246
 
239 247
 		if($path[0] != '/')
240 248
 		{
241
-			if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY);
249
+			if (strpos($path,'?') !== false)
250
+			{
251
+				$query = Vfs::parse_url($path,PHP_URL_QUERY);
252
+			}
242 253
 			$path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : '');
243 254
 		}
244 255
 		list(,$apps,$app,$id) = explode('/',$path);
245 256
 
246 257
 		$ret = false;
247
-		if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE))	// app directory itself is allways ok
258
+		if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE))
259
+		{
260
+			// app directory itself is allways ok
248 261
 		{
249
-			$current_is_root = Vfs::$is_root; Vfs::$is_root = true;
262
+			$current_is_root = Vfs::$is_root;
263
+		}
264
+		Vfs::$is_root = true;
250 265
 			$current_user = Vfs::$user; Vfs::$user = 0;
251 266
 
252 267
 			$ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE);
253
-			if ($id) parent::chmod($path,0);	// no other rights
268
+			if ($id)
269
+			{
270
+				parent::chmod($path,0);
271
+			}
272
+			// no other rights
254 273
 
255 274
 			Vfs::$user = $current_user;
256 275
 			Vfs::$is_root = $current_is_root;
Please login to merge, or discard this patch.
api/src/Vfs/Dav/Directory.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,10 @@
 block discarded – undo
69 69
 		$path = $this->vfs_path . '/' . $name;
70 70
 		$vfs_path = $this->vfs_path . '/' . Vfs::encodePathComponent($name);
71 71
 
72
-		if (!Vfs::file_exists($vfs_path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
72
+		if (!Vfs::file_exists($vfs_path))
73
+		{
74
+			throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
75
+		}
73 76
 
74 77
 		if (Vfs::is_dir($vfs_path))
75 78
 		{
Please login to merge, or discard this patch.
api/src/Vfs/Hooks.php 1 patch
Braces   +32 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,7 +42,10 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	static function addAccount($data)
44 44
 	{
45
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
45
+		if (self::LOG_LEVEL > 0)
46
+		{
47
+			error_log(__METHOD__.'('.array2string($data).')');
48
+		}
46 49
 		// create a user-dir
47 50
 		Api\Vfs::$is_root = true;
48 51
 		if (Api\Vfs::mkdir($dir='/home/'.$data['account_lid'],0700,0))
@@ -64,7 +67,10 @@  discard block
 block discarded – undo
64 67
 	 */
65 68
 	static function editAccount($data)
66 69
 	{
67
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
70
+		if (self::LOG_LEVEL > 0)
71
+		{
72
+			error_log(__METHOD__.'('.array2string($data).')');
73
+		}
68 74
 		if (empty($data['account_lid']) || empty($data['old_loginid']) || $data['account_lid'] == $data['old_loginid'])
69 75
 		{
70 76
 			return;	// nothing to do here
@@ -85,7 +91,10 @@  discard block
 block discarded – undo
85 91
 	 */
86 92
 	static function deleteAccount($data)
87 93
 	{
88
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
94
+		if (self::LOG_LEVEL > 0)
95
+		{
96
+			error_log(__METHOD__.'('.array2string($data).')');
97
+		}
89 98
 		Api\Vfs::$is_root = true;
90 99
 		if ($data['new_owner'] && ($new_lid = $GLOBALS['egw']->accounts->id2name($data['new_owner'])))
91 100
 		{
@@ -119,8 +128,14 @@  discard block
 block discarded – undo
119 128
 	 */
120 129
 	static function addGroup($data)
121 130
 	{
122
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
123
-		if (empty($data['account_lid'])) throw new Api\Exception\WrongParameter('account_lid must not be empty!');
131
+		if (self::LOG_LEVEL > 0)
132
+		{
133
+			error_log(__METHOD__.'('.array2string($data).')');
134
+		}
135
+		if (empty($data['account_lid']))
136
+		{
137
+			throw new Api\Exception\WrongParameter('account_lid must not be empty!');
138
+		}
124 139
 
125 140
 		// create a group-dir
126 141
 		Api\Vfs::$is_root = true;
@@ -146,8 +161,14 @@  discard block
 block discarded – undo
146 161
 	 */
147 162
 	static function editGroup($data)
148 163
 	{
149
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
150
-		if (empty($data['account_lid']) || empty($data['old_name'])) throw new Api\Exception\WrongParameter('account_lid and old_name must not be empty!');
164
+		if (self::LOG_LEVEL > 0)
165
+		{
166
+			error_log(__METHOD__.'('.array2string($data).')');
167
+		}
168
+		if (empty($data['account_lid']) || empty($data['old_name']))
169
+		{
170
+			throw new Api\Exception\WrongParameter('account_lid and old_name must not be empty!');
171
+		}
151 172
 
152 173
 		if ($data['account_lid'] == $data['old_name'])
153 174
 		{
@@ -175,7 +196,10 @@  discard block
 block discarded – undo
175 196
 	 */
176 197
 	static function deleteGroup($data)
177 198
 	{
178
-		if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
199
+		if (self::LOG_LEVEL > 0)
200
+		{
201
+			error_log(__METHOD__.'('.array2string($data).')');
202
+		}
179 203
 
180 204
 		if(empty($data['account_lid']) || $data['account_lid'] == '/')
181 205
 		{
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_lockinfo.php 1 patch
Braces   +45 added lines, -20 removed lines patch added patch discarded remove patch
@@ -99,7 +99,8 @@  discard block
 block discarded – undo
99 99
 
100 100
         // open stream
101 101
         $f_in = fopen($path, "r");
102
-        if (!$f_in) {
102
+        if (!$f_in)
103
+        {
103 104
             $this->success = false;
104 105
             return;
105 106
         }
@@ -119,16 +120,19 @@  discard block
 block discarded – undo
119 120
                               XML_OPTION_CASE_FOLDING, false);
120 121
 
121 122
         // parse input
122
-        while ($this->success && !feof($f_in)) {
123
+        while ($this->success && !feof($f_in))
124
+        {
123 125
             $line = fgets($f_in);
124
-            if (is_string($line)) {
126
+            if (is_string($line))
127
+            {
125 128
                 $had_input = true;
126 129
                 $this->success &= xml_parse($xml_parser, $line, false);
127 130
             }
128 131
         }
129 132
 
130 133
         // finish parsing
131
-        if ($had_input) {
134
+        if ($had_input)
135
+        {
132 136
             $this->success &= xml_parse($xml_parser, "", true);
133 137
         }
134 138
 
@@ -156,29 +160,40 @@  discard block
 block discarded – undo
156 160
     function _startElement($parser, $name, $attrs)
157 161
     {
158 162
         // namespace handling
159
-        if (strstr($name, " ")) {
163
+        if (strstr($name, " "))
164
+        {
160 165
             list($ns, $tag) = explode(" ", $name);
161
-        } else {
166
+        }
167
+        else
168
+        {
162 169
             $ns  = "";
163 170
             $tag = $name;
164 171
         }
165 172
 
166 173
 
167
-        if ($this->collect_owner) {
174
+        if ($this->collect_owner)
175
+        {
168 176
             // everything within the <owner> tag needs to be collected
169 177
             $ns_short = "";
170 178
             $ns_attr  = "";
171
-            if ($ns) {
172
-                if ($ns == "DAV:") {
179
+            if ($ns)
180
+            {
181
+                if ($ns == "DAV:")
182
+                {
173 183
                     $ns_short = "D:";
174
-                } else {
184
+                }
185
+                else
186
+                {
175 187
                     $ns_attr = " xmlns='$ns'";
176 188
                 }
177 189
             }
178 190
             $this->owner .= "<$ns_short$tag$ns_attr>";
179
-        } else if ($ns == "DAV:") {
191
+        }
192
+        else if ($ns == "DAV:")
193
+        {
180 194
             // parse only the essential tags
181
-            switch ($tag) {
195
+            switch ($tag)
196
+            {
182 197
             case "write":
183 198
                 $this->locktype = $tag;
184 199
                 break;
@@ -204,7 +219,8 @@  discard block
 block discarded – undo
204 219
     function _data($parser, $data)
205 220
     {
206 221
         // only the <owner> tag has data content
207
-        if ($this->collect_owner) {
222
+        if ($this->collect_owner)
223
+        {
208 224
             $this->owner .= $data;
209 225
         }
210 226
     }
@@ -220,26 +236,35 @@  discard block
 block discarded – undo
220 236
     function _endElement($parser, $name)
221 237
     {
222 238
         // namespace handling
223
-        if (strstr($name, " ")) {
239
+        if (strstr($name, " "))
240
+        {
224 241
             list($ns, $tag) = explode(" ", $name);
225
-        } else {
242
+        }
243
+        else
244
+        {
226 245
             $ns  = "";
227 246
             $tag = $name;
228 247
         }
229 248
 
230 249
         // <owner> finished?
231
-        if (($ns == "DAV:") && ($tag == "owner")) {
250
+        if (($ns == "DAV:") && ($tag == "owner"))
251
+        {
232 252
             $this->collect_owner = false;
233 253
         }
234 254
 
235 255
         // within <owner> we have to collect everything
236
-        if ($this->collect_owner) {
256
+        if ($this->collect_owner)
257
+        {
237 258
             $ns_short = "";
238 259
             $ns_attr  = "";
239
-            if ($ns) {
240
-                if ($ns == "DAV:") {
260
+            if ($ns)
261
+            {
262
+                if ($ns == "DAV:")
263
+                {
241 264
                     $ns_short = "D:";
242
-                } else {
265
+                }
266
+                else
267
+                {
243 268
                     $ns_attr = " xmlns='$ns'";
244 269
                 }
245 270
             }
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_proppatch.php 1 patch
Braces   +48 added lines, -21 removed lines patch added patch discarded remove patch
@@ -106,7 +106,8 @@  discard block
 block discarded – undo
106 106
         $had_input = false;
107 107
 
108 108
         $f_in = fopen($path, "r");
109
-        if (!$f_in) {
109
+        if (!$f_in)
110
+        {
110 111
             $this->success = false;
111 112
             return;
112 113
         }
@@ -123,16 +124,22 @@  discard block
 block discarded – undo
123 124
         xml_parser_set_option($xml_parser,
124 125
                               XML_OPTION_CASE_FOLDING, false);
125 126
 
126
-        while($this->success && !feof($f_in)) {
127
+        while($this->success && !feof($f_in))
128
+        {
127 129
             $line = fgets($f_in);
128
-            if ($store_request) $this->request .= $line;
129
-            if (is_string($line)) {
130
+            if ($store_request)
131
+            {
132
+            	$this->request .= $line;
133
+            }
134
+            if (is_string($line))
135
+            {
130 136
                 $had_input = true;
131 137
                 $this->success &= xml_parse($xml_parser, $line, false);
132 138
             }
133 139
         }
134 140
 
135
-        if($had_input) {
141
+        if($had_input)
142
+        {
136 143
             $this->success &= xml_parse($xml_parser, "", true);
137 144
         }
138 145
 
@@ -152,31 +159,42 @@  discard block
 block discarded – undo
152 159
      */
153 160
     function _startElement($parser, $name, $attrs)
154 161
     {
155
-        if (strstr($name, " ")) {
162
+        if (strstr($name, " "))
163
+        {
156 164
             list($ns, $tag) = explode(" ", $name);
157 165
             if ($ns == "")
158
-                $this->success = false;
159
-        } else {
166
+            {
167
+                            $this->success = false;
168
+            }
169
+        }
170
+        else
171
+        {
160 172
             $ns = "";
161 173
             $tag = $name;
162 174
         }
163 175
 
164
-        if ($this->depth == 1) {
176
+        if ($this->depth == 1)
177
+        {
165 178
             $this->mode = $tag;
166 179
         }
167 180
 
168
-        if ($this->depth == 3) {
181
+        if ($this->depth == 3)
182
+        {
169 183
             $prop = array("name" => $tag);
170 184
             $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
171
-            if ($this->mode == "set") {
185
+            if ($this->mode == "set")
186
+            {
172 187
                 $this->current["val"] = "";     // default set val
173 188
             }
174 189
         }
175 190
 
176
-        if ($this->depth >= 4) {
191
+        if ($this->depth >= 4)
192
+        {
177 193
             $this->current["val"] .= "<$tag";
178
-            if (isset($attr)) {
179
-                foreach ($attr as $key => $val) {
194
+            if (isset($attr))
195
+            {
196
+                foreach ($attr as $key => $val)
197
+                {
180 198
                     $this->current["val"] .= ' '.$key.'="'.str_replace('"','&quot;', $val).'"';
181 199
                 }
182 200
             }
@@ -198,23 +216,31 @@  discard block
 block discarded – undo
198 216
      */
199 217
     function _endElement($parser, $name)
200 218
     {
201
-        if (strstr($name, " ")) {
219
+        if (strstr($name, " "))
220
+        {
202 221
             list($ns, $tag) = explode(" ", $name);
203 222
             if ($ns == "")
204
-                $this->success = false;
205
-        } else {
223
+            {
224
+                            $this->success = false;
225
+            }
226
+        }
227
+        else
228
+        {
206 229
             $ns = "";
207 230
             $tag = $name;
208 231
         }
209 232
 
210 233
         $this->depth--;
211 234
 
212
-        if ($this->depth >= 4) {
235
+        if ($this->depth >= 4)
236
+        {
213 237
             $this->current["val"] .= "</$tag>";
214 238
         }
215 239
 
216
-        if ($this->depth == 3) {
217
-            if (isset($this->current)) {
240
+        if ($this->depth == 3)
241
+        {
242
+            if (isset($this->current))
243
+            {
218 244
                 $this->props[] = $this->current;
219 245
                 unset($this->current);
220 246
             }
@@ -231,7 +257,8 @@  discard block
 block discarded – undo
231 257
      */
232 258
     function _data($parser, $data)
233 259
     {
234
-        if (isset($this->current)) {
260
+        if (isset($this->current))
261
+        {
235 262
             $this->current["val"] .= $data;
236 263
         }
237 264
     }
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_propfind.php 1 patch
Braces   +42 added lines, -16 removed lines patch added patch discarded remove patch
@@ -127,7 +127,8 @@  discard block
 block discarded – undo
127 127
 
128 128
         // open input stream
129 129
         $f_in = fopen($path, "r");
130
-        if (!$f_in) {
130
+        if (!$f_in)
131
+        {
131 132
             $this->success = false;
132 133
             return;
133 134
         }
@@ -149,17 +150,23 @@  discard block
 block discarded – undo
149 150
                               XML_OPTION_CASE_FOLDING, false);
150 151
 
151 152
         // parse input
152
-        while ($this->success && !feof($f_in)) {
153
+        while ($this->success && !feof($f_in))
154
+        {
153 155
             $line = fgets($f_in);
154
-            if ($store_request) $this->request .= $line;
155
-            if (is_string($line)) {
156
+            if ($store_request)
157
+            {
158
+            	$this->request .= $line;
159
+            }
160
+            if (is_string($line))
161
+            {
156 162
                 $had_input = true;
157 163
                 $this->success &= xml_parse($xml_parser, $line, false);
158 164
             }
159 165
         }
160 166
 
161 167
         // finish parsing
162
-        if ($had_input) {
168
+        if ($had_input)
169
+        {
163 170
             $this->success &= xml_parse($xml_parser, "", true);
164 171
         }
165 172
 
@@ -170,7 +177,11 @@  discard block
 block discarded – undo
170 177
         fclose($f_in);
171 178
 
172 179
         // if no input was parsed it was a request
173
-        if(!count($this->props)) $this->props = "all"; // default
180
+        if(!count($this->props))
181
+        {
182
+        	$this->props = "all";
183
+        }
184
+        // default
174 185
     }
175 186
 
176 187
 
@@ -185,21 +196,28 @@  discard block
 block discarded – undo
185 196
     function _startElement($parser, $name, $attrs)
186 197
     {
187 198
         // name space handling
188
-        if (strstr($name, " ")) {
199
+        if (strstr($name, " "))
200
+        {
189 201
             list($ns, $tag) = explode(" ", $name);
190 202
             if ($ns == "")
191
-                $this->success = false;
192
-        } else {
203
+            {
204
+                            $this->success = false;
205
+            }
206
+        }
207
+        else
208
+        {
193 209
             $ns  = "";
194 210
             $tag = $name;
195 211
         }
196 212
 
197 213
         // record root tag
198
-        if ($this->depth == 0) {
214
+        if ($this->depth == 0)
215
+        {
199 216
         	$this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs);
200 217
         }
201 218
         // special tags at level 1: <allprop> and <propname>
202
-        if ($this->depth == 1) {
219
+        if ($this->depth == 1)
220
+        {
203 221
          	$this->use = 'props';
204 222
             switch ($tag)
205 223
             {
@@ -225,11 +243,15 @@  discard block
 block discarded – undo
225 243
         // requested properties are found at level 2
226 244
         // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's)
227 245
         if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' ||
228
-        	$this->use == 'props' && $this->depth >= 2) {
246
+        	$this->use == 'props' && $this->depth >= 2)
247
+        {
229 248
             $prop = array("name" => $tag);
230 249
             if ($ns)
231
-                $prop["xmlns"] = $ns;
232
-            if ($this->use != 'props' || $this->depth > 2) {
250
+            {
251
+                            $prop["xmlns"] = $ns;
252
+            }
253
+            if ($this->use != 'props' || $this->depth > 2)
254
+            {
233 255
             	$prop['attrs'] = $attrs;
234 256
             	$prop['depth'] = $this->depth;
235 257
             }
@@ -243,7 +265,10 @@  discard block
 block discarded – undo
243 265
             {
244 266
 	         	// this can happen if we have allprop and prop in one propfind:
245 267
 	        	// <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop
246
-	            if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use});
268
+	            if (!is_array($this->{$this->use}) && $this->{$this->use})
269
+	            {
270
+	            	$this->{$this->use} = array($this->{$this->use});
271
+	            }
247 272
 	            $this->{$this->use}[] =& $prop;
248 273
 	            $this->last_prop =& $prop;
249 274
 	            unset($prop);
@@ -278,7 +303,8 @@  discard block
 block discarded – undo
278 303
      */
279 304
     function _charData($parser, $data)
280 305
     {
281
-        if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) {
306
+        if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data)))
307
+        {
282 308
         	$this->{$this->use}[$n-1]['data'] = $data;
283 309
         }
284 310
     }
Please login to merge, or discard this patch.