Passed
Push — 17.1 ( 6ec951...0f0060 )
by Ralf
09:52
created
api/src/Vfs/WebDAV.php 2 patches
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -171,16 +171,16 @@
 block discarded – undo
171 171
 
172 172
         if (is_dir($source)) { // resource is a collection
173 173
             switch ($options["depth"]) {
174
-            case "infinity": // valid
175
-                break;
176
-            case "0": // valid for COPY only
177
-                if ($del) { // MOVE?
178
-                    return "400 Bad request";
179
-                }
180
-                break;
181
-            case "1": // invalid for both COPY and MOVE
182
-            default:
183
-                return "400 Bad request";
174
+            	case "infinity": // valid
175
+                	break;
176
+            	case "0": // valid for COPY only
177
+                	if ($del) { // MOVE?
178
+                    	return "400 Bad request";
179
+                	}
180
+                	break;
181
+            	case "1": // invalid for both COPY and MOVE
182
+            	default:
183
+                	return "400 Bad request";
184 184
             }
185 185
         }
186 186
 
Please login to merge, or discard this 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,76 +205,104 @@  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 .= Vfs::basename($source);
203
-                if (file_exists($dest)) {
225
+                if (file_exists($dest))
226
+                {
204 227
                     $options["dest"] .= Vfs::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) {
253
+        if ($del)
254
+        {
224 255
 			try {
225
-				if (!rename($source, $dest)) {
256
+				if (!rename($source, $dest))
257
+				{
226 258
 					return "500 Internal server error";
227 259
 				}
228 260
 			}
229 261
 			catch (Exception\ProtectedDirectory $e) {
230 262
 				return "403 Forbidden: ".$e->getMessage();
231 263
 			}
232
-        } else {
233
-            if (is_dir($source) && $options['depth'] == 'infinity') {
264
+        }
265
+        else
266
+        {
267
+            if (is_dir($source) && $options['depth'] == 'infinity')
268
+            {
234 269
             	$files = Vfs::find($source,array('depth' => true,'url' => true));	// depth=true: return dirs first, url=true: allow urls!
235
-            } else {
270
+            }
271
+            else
272
+            {
236 273
                 $files = array($source);
237 274
             }
238 275
 
239
-            if (!is_array($files) || empty($files)) {
276
+            if (!is_array($files) || empty($files))
277
+            {
240 278
                 return "500 Internal server error";
241 279
             }
242 280
 
243 281
 
244
-            foreach ($files as $file) {
245
-                if (is_dir($file)) {
282
+            foreach ($files as $file)
283
+            {
284
+                if (is_dir($file))
285
+                {
246 286
                     $file = $this->_slashify($file);
247 287
                 }
248 288
 
249 289
                 $destfile = str_replace($source, $dest, $file);
250 290
 
251
-                if (is_dir($file)) {
252
-                    if (!is_dir($destfile)) {
291
+                if (is_dir($file))
292
+                {
293
+                    if (!is_dir($destfile))
294
+                    {
253 295
                         // TODO "mkdir -p" here? (only natively supported by PHP 5)
254
-                        if (!@mkdir($destfile)) {
296
+                        if (!@mkdir($destfile))
297
+                        {
255 298
                             return "409 Conflict";
256 299
                         }
257 300
                     }
258
-                } else {
259
-                    if (!@copy($file, $destfile)) {
301
+                }
302
+                else
303
+                {
304
+                    if (!@copy($file, $destfile))
305
+                    {
260 306
                         return "409 Conflict";
261 307
                     }
262 308
                 }
@@ -306,17 +352,23 @@  discard block
 block discarded – undo
306 352
         $info["props"][] = self::mkprop("ishidden",        Vfs::is_hidden($fspath));
307 353
 
308 354
 		// type and size (caller already made sure that path exists)
309
-		if (is_dir($fspath)) {
355
+		if (is_dir($fspath))
356
+		{
310 357
 			// directory (WebDAV collection)
311 358
 			$info['props'][] = self::mkprop	('resourcetype', array(
312 359
 			 	self::mkprop('collection', '')));
313 360
 			$info['props'][] = self::mkprop	('getcontenttype', 'httpd/unix-directory');
314
-		} else {
361
+		}
362
+		else
363
+		{
315 364
 			// plain file (WebDAV resource)
316 365
 			$info['props'][] = self::mkprop	('resourcetype', '');
317
-			if (Vfs::is_readable($path)) {
366
+			if (Vfs::is_readable($path))
367
+			{
318 368
 				$info['props'][] = self::mkprop	('getcontenttype', Vfs::mime_content_type($path));
319
-			} else {
369
+			}
370
+			else
371
+			{
320 372
 				error_log(__METHOD__."($path) $fspath is not readable!");
321 373
 				$info['props'][] = self::mkprop	('getcontenttype', 'application/x-non-readable');
322 374
 			}
@@ -388,7 +440,10 @@  discard block
 block discarded – undo
388 440
 				continue;
389 441
 			}
390 442
 			$_path = $info['path'];
391
-			if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1);
443
+			if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/')
444
+			{
445
+				$_path = substr($info['path'],0,-1);
446
+			}
392 447
 
393 448
 			// need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it
394 449
 			// otherwise pathes containing url special chars like ? or # will not stat
@@ -427,16 +482,22 @@  discard block
 block discarded – undo
427 482
 				$fileprops =& $files['files'][$path2n[$path]]['props'];
428 483
 				foreach($props as $prop)
429 484
 				{
430
-					if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#')	// eGW's customfields
485
+					if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#')
486
+					{
487
+						// eGW's customfields
431 488
 					{
432 489
 						$prop['ns'] .= 'customfields/';
490
+					}
433 491
 						$prop['name'] = substr($prop['name'],1);
434 492
 					}
435 493
 					$fileprops[] = $prop;
436 494
 				}
437 495
 			}
438 496
 		}
439
-		if ($this->debug) error_log(__METHOD__."() props=".array2string($files['files']));
497
+		if ($this->debug)
498
+		{
499
+			error_log(__METHOD__."() props=".array2string($files['files']));
500
+		}
440 501
 		return true;
441 502
 	}
442 503
 
@@ -488,7 +549,8 @@  discard block
 block discarded – undo
488 549
 	{
489 550
 		$path = Api\Translation::convert($options['path'],'utf-8');
490 551
 
491
-		foreach ($options['props'] as $key => $prop) {
552
+		foreach ($options['props'] as $key => $prop)
553
+		{
492 554
 			$attributes = array();
493 555
 			switch($prop['ns'])
494 556
 			{
@@ -505,7 +567,10 @@  discard block
 block discarded – undo
505 567
 							//$attributes['created'] = strtotime($prop['val']);
506 568
 							//break;
507 569
 						default:
508
-							if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
570
+							if (!Vfs::proppatch($path,array($prop)))
571
+							{
572
+								$options['props'][$key]['status'] = '403 Forbidden';
573
+							}
509 574
 							break;
510 575
 					}
511 576
 					break;
@@ -534,7 +599,10 @@  discard block
 block discarded – undo
534 599
 						case 'Win32LastAccessTime':
535 600
 						case 'Win32FileAttributes':	// not sure what that is, it was always "00000000"
536 601
 						default:
537
-							if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
602
+							if (!Vfs::proppatch($path,array($prop)))
603
+							{
604
+								$options['props'][$key]['status'] = '403 Forbidden';
605
+							}
538 606
 							break;
539 607
 					}
540 608
 					break;
@@ -544,15 +612,24 @@  discard block
 block discarded – undo
544 612
 					$prop['name'] = '#'.$prop['name'];
545 613
 					// fall through
546 614
 				default:
547
-					if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
615
+					if (!Vfs::proppatch($path,array($prop)))
616
+					{
617
+						$options['props'][$key]['status'] = '403 Forbidden';
618
+					}
548 619
 					break;
549 620
 			}
550
-			if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
621
+			if ($this->debug)
622
+			{
623
+				$props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
624
+			}
551 625
 		}
552 626
 		if ($this->debug)
553 627
 		{
554 628
 			error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props));
555
-			if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
629
+			if ($attributes)
630
+			{
631
+				error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
632
+			}
556 633
 		}
557 634
 
558 635
 		return '';	// this is as the filesystem example handler does it, no true or false ...
@@ -566,7 +643,10 @@  discard block
 block discarded – undo
566 643
 	 */
567 644
 	function LOCK(&$options)
568 645
 	{
569
-		if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
646
+		if ($this->debug)
647
+		{
648
+			error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
649
+		}
570 650
 		// TODO recursive locks on directories not supported yet
571 651
 		if (is_dir($this->base . $options['path']) && !empty($options['depth']))
572 652
 		{
@@ -592,7 +672,10 @@  discard block
 block discarded – undo
592 672
 	 */
593 673
 	function UNLOCK(&$options)
594 674
 	{
595
-		if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
675
+		if ($this->debug)
676
+		{
677
+			error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
678
+		}
596 679
 		return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict';
597 680
 	}
598 681
 
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_lockinfo.php 2 patches
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -179,16 +179,16 @@
 block discarded – undo
179 179
         } else if ($ns == "DAV:") {
180 180
             // parse only the essential tags
181 181
             switch ($tag) {
182
-            case "write":
183
-                $this->locktype = $tag;
184
-                break;
185
-            case "exclusive":
186
-            case "shared":
187
-                $this->lockscope = $tag;
188
-                break;
189
-            case "owner":
190
-                $this->collect_owner = true;
191
-                break;
182
+            	case "write":
183
+                	$this->locktype = $tag;
184
+                	break;
185
+            	case "exclusive":
186
+            	case "shared":
187
+                	$this->lockscope = $tag;
188
+                	break;
189
+            	case "owner":
190
+                	$this->collect_owner = true;
191
+                	break;
192 192
             }
193 193
         }
194 194
     }
Please login to merge, or discard this 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/Server/Filesystem.php 2 patches
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -365,18 +365,18 @@  discard block
 block discarded – undo
365 365
             //       the registry)
366 366
             // TODO: have a seperate PEAR class for mimetype detection?
367 367
             switch (strtolower(strrchr(basename($fspath), "."))) {
368
-            case ".html":
369
-                $mime_type = "text/html";
370
-                break;
371
-            case ".gif":
372
-                $mime_type = "image/gif";
373
-                break;
374
-            case ".jpg":
375
-                $mime_type = "image/jpeg";
376
-                break;
377
-            default:
378
-                $mime_type = "application/octet-stream";
379
-                break;
368
+            	case ".html":
369
+                	$mime_type = "text/html";
370
+                	break;
371
+            	case ".gif":
372
+                	$mime_type = "image/gif";
373
+                	break;
374
+            	case ".jpg":
375
+                	$mime_type = "image/jpeg";
376
+                	break;
377
+            	default:
378
+                	$mime_type = "application/octet-stream";
379
+                	break;
380 380
             }
381 381
         }
382 382
 
@@ -633,16 +633,16 @@  discard block
 block discarded – undo
633 633
 
634 634
         if (is_dir($source)) { // resource is a collection
635 635
             switch ($options["depth"]) {
636
-            case "infinity": // valid
637
-                break;
638
-            case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
640
-                    return "400 Bad request";
641
-                }
642
-                break;
643
-            case "1": // invalid for both COPY and MOVE
644
-            default:
645
-                return "400 Bad request";
636
+            	case "infinity": // valid
637
+                	break;
638
+            	case "0": // valid for COPY only
639
+                	if ($del) { // MOVE?
640
+                    	return "400 Bad request";
641
+                	}
642
+                	break;
643
+            	case "1": // invalid for both COPY and MOVE
644
+            	default:
645
+                	return "400 Bad request";
646 646
             }
647 647
         }
648 648
 
Please login to merge, or discard this patch.
Braces   +212 added lines, -91 removed lines patch added patch discarded remove patch
@@ -105,15 +105,19 @@  discard block
 block discarded – undo
105 105
         // special treatment for litmus compliance test
106 106
         // reply on its identifier header
107 107
         // not needed for the test itself but eases debugging
108
-        if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
108
+        if (isset($this->_SERVER['HTTP_X_LITMUS']))
109
+        {
109 110
             error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
110 111
             header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
111 112
         }
112 113
 
113 114
         // set root directory, defaults to webserver document root if not set
114
-        if ($base) {
115
+        if ($base)
116
+        {
115 117
             $this->base = realpath($base); // TODO throw if not a directory
116
-        } else if (!$this->base) {
118
+        }
119
+        else if (!$this->base)
120
+        {
117 121
             $this->base = $this->_SERVER['DOCUMENT_ROOT'];
118 122
         }
119 123
 
@@ -154,7 +158,8 @@  discard block
 block discarded – undo
154 158
         $fspath = $this->base . $options["path"];
155 159
 
156 160
         // sanity check
157
-        if (!file_exists($fspath)) {
161
+        if (!file_exists($fspath))
162
+        {
158 163
             return false;
159 164
         }
160 165
 
@@ -165,7 +170,8 @@  discard block
 block discarded – undo
165 170
         $files["files"][] = $this->fileinfo($options["path"]);
166 171
 
167 172
         // information for contained resources requested?
168
-        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) {
173
+        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath))
174
+        {
169 175
 
170 176
             // make sure path ends with '/'
171 177
             $options["path"] = $this->_slashify($options["path"]);
@@ -173,10 +179,13 @@  discard block
 block discarded – undo
173 179
             // try to open directory
174 180
             $handle = opendir($fspath);
175 181
 
176
-            if ($handle) {
182
+            if ($handle)
183
+            {
177 184
                 // ok, now get all its contents
178
-                while ($filename = readdir($handle)) {
179
-                    if ($filename != "." && $filename != "..") {
185
+                while ($filename = readdir($handle))
186
+                {
187
+                    if ($filename != "." && $filename != "..")
188
+                    {
180 189
                         $files["files"][] = $this->fileinfo($options["path"].$filename);
181 190
                     }
182 191
                 }
@@ -218,16 +227,22 @@  discard block
 block discarded – undo
218 227
         $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219 228
 
220 229
         // type and size (caller already made sure that path exists)
221
-        if (is_dir($fspath)) {
230
+        if (is_dir($fspath))
231
+        {
222 232
             // directory (WebDAV collection)
223 233
             $info["props"][] = $this->mkprop("resourcetype", "collection");
224 234
             $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
225
-        } else {
235
+        }
236
+        else
237
+        {
226 238
             // plain file (WebDAV resource)
227 239
             $info["props"][] = $this->mkprop("resourcetype", "");
228
-            if ($this->_is_readable($fspath)) {
240
+            if ($this->_is_readable($fspath))
241
+            {
229 242
                 $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath));
230
-            } else {
243
+            }
244
+            else
245
+            {
231 246
                 $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
232 247
             }
233 248
             $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
@@ -238,7 +253,8 @@  discard block
 block discarded – undo
238 253
                         FROM {$this->db_prefix}properties
239 254
                        WHERE path = '$path'";
240 255
         $res = mysql_query($query);
241
-        while ($row = mysql_fetch_assoc($res)) {
256
+        while ($row = mysql_fetch_assoc($res))
257
+        {
242 258
             $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
243 259
         }
244 260
         mysql_free_result($res);
@@ -259,30 +275,45 @@  discard block
 block discarded – undo
259 275
     function _can_execute($name, $path = false)
260 276
     {
261 277
         // path defaults to PATH from environment if not set
262
-        if ($path === false) {
278
+        if ($path === false)
279
+        {
263 280
             $path = getenv("PATH");
264 281
         }
265 282
 
266 283
         // check method depends on operating system
267
-        if (!strncmp(PHP_OS, "WIN", 3)) {
284
+        if (!strncmp(PHP_OS, "WIN", 3))
285
+        {
268 286
             // on Windows an appropriate COM or EXE file needs to exist
269 287
             $exts     = array(".exe", ".com");
270 288
             $check_fn = "file_exists";
271
-        } else {
289
+        }
290
+        else
291
+        {
272 292
             // anywhere else we look for an executable file of that name
273 293
             $exts     = array("");
274 294
             $check_fn = "is_executable";
275 295
         }
276 296
 
277 297
         // now check the directories in the path for the program
278
-        foreach (explode(PATH_SEPARATOR, $path) as $dir) {
298
+        foreach (explode(PATH_SEPARATOR, $path) as $dir)
299
+        {
279 300
             // skip invalid path entries
280
-            if (!file_exists($dir)) continue;
281
-            if (!is_dir($dir)) continue;
301
+            if (!file_exists($dir))
302
+            {
303
+            	continue;
304
+            }
305
+            if (!is_dir($dir))
306
+            {
307
+            	continue;
308
+            }
282 309
 
283 310
             // and now look for the file
284
-            foreach ($exts as $ext) {
285
-                if ($check_fn("$dir/$name".$ext)) return true;
311
+            foreach ($exts as $ext)
312
+            {
313
+                if ($check_fn("$dir/$name".$ext))
314
+                {
315
+                	return true;
316
+                }
286 317
             }
287 318
         }
288 319
 
@@ -323,13 +354,18 @@  discard block
 block discarded – undo
323 354
      */
324 355
     function _mimetype($fspath)
325 356
     {
326
-        if (is_dir($fspath)) {
357
+        if (is_dir($fspath))
358
+        {
327 359
             // directories are easy
328 360
             return "httpd/unix-directory";
329
-        } else if (function_exists("mime_content_type")) {
361
+        }
362
+        else if (function_exists("mime_content_type"))
363
+        {
330 364
             // use mime magic extension if available
331 365
             $mime_type = mime_content_type($fspath);
332
-        } else if ($this->_can_execute("file")) {
366
+        }
367
+        else if ($this->_can_execute("file"))
368
+        {
333 369
             // it looks like we have a 'file' command,
334 370
             // lets see it it does have mime support
335 371
             $fp    = popen("file -i '$fspath' 2>/dev/null", "r");
@@ -341,16 +377,19 @@  discard block
 block discarded – undo
341 377
             // so we test the format of the returned string
342 378
 
343 379
             // the reply begins with the requested filename
344
-            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
380
+            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2))
381
+            {
345 382
                 $reply = substr($reply, strlen($fspath)+2);
346 383
                 // followed by the mime type (maybe including options)
347
-                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
384
+                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches))
385
+                {
348 386
                     $mime_type = $matches[0];
349 387
                 }
350 388
             }
351 389
         }
352 390
 
353
-        if (empty($mime_type)) {
391
+        if (empty($mime_type))
392
+        {
354 393
             // Fallback solution: try to guess the type by the file extension
355 394
             // TODO: add more ...
356 395
             // TODO: it has been suggested to delegate mimetype detection
@@ -364,7 +403,8 @@  discard block
 block discarded – undo
364 403
             //       anyway (overriding it with information taken from
365 404
             //       the registry)
366 405
             // TODO: have a seperate PEAR class for mimetype detection?
367
-            switch (strtolower(strrchr(basename($fspath), "."))) {
406
+            switch (strtolower(strrchr(basename($fspath), ".")))
407
+            {
368 408
             case ".html":
369 409
                 $mime_type = "text/html";
370 410
                 break;
@@ -395,7 +435,10 @@  discard block
 block discarded – undo
395 435
         $fspath = $this->base . $options["path"];
396 436
 
397 437
         // sanity check
398
-        if (!file_exists($fspath)) return false;
438
+        if (!file_exists($fspath))
439
+        {
440
+        	return false;
441
+        }
399 442
 
400 443
         // detect resource type
401 444
         $options['mimetype'] = $this->_mimetype($fspath);
@@ -424,12 +467,14 @@  discard block
 block discarded – undo
424 467
         $fspath = $this->base . $options["path"];
425 468
 
426 469
         // is this a collection?
427
-        if (is_dir($fspath)) {
470
+        if (is_dir($fspath))
471
+        {
428 472
             return $this->GetDir($fspath, $options);
429 473
         }
430 474
 
431 475
         // the header output is the same as for HEAD
432
-        if (!$this->HEAD($options)) {
476
+        if (!$this->HEAD($options))
477
+        {
433 478
             return false;
434 479
         }
435 480
 
@@ -451,7 +496,8 @@  discard block
 block discarded – undo
451 496
     function GetDir($fspath, &$options)
452 497
     {
453 498
         $path = $this->_slashify($options["path"]);
454
-        if ($path != $options["path"]) {
499
+        if ($path != $options["path"])
500
+        {
455 501
             header("Location: ".$this->base_uri.$path);
456 502
             exit;
457 503
         }
@@ -459,12 +505,14 @@  discard block
 block discarded – undo
459 505
         // fixed width directory column format
460 506
         $format = "%15s  %-19s  %-s\n";
461 507
 
462
-        if (!$this->_is_readable($fspath)) {
508
+        if (!$this->_is_readable($fspath))
509
+        {
463 510
             return false;
464 511
         }
465 512
 
466 513
         $handle = opendir($fspath);
467
-        if (!$handle) {
514
+        if (!$handle)
515
+        {
468 516
             return false;
469 517
         }
470 518
 
@@ -476,8 +524,10 @@  discard block
 block discarded – undo
476 524
         printf($format, "Size", "Last modified", "Filename");
477 525
         echo "<hr>";
478 526
 
479
-        while ($filename = readdir($handle)) {
480
-            if ($filename != "." && $filename != "..") {
527
+        while ($filename = readdir($handle))
528
+        {
529
+            if ($filename != "." && $filename != "..")
530
+            {
481 531
                 $fullpath = $fspath.$filename;
482 532
                 $name     = htmlspecialchars($filename);
483 533
                 printf($format,
@@ -507,19 +557,23 @@  discard block
 block discarded – undo
507 557
         $fspath = $this->base . $options["path"];
508 558
 
509 559
         $dir = dirname($fspath);
510
-        if (!file_exists($dir) || !is_dir($dir)) {
560
+        if (!file_exists($dir) || !is_dir($dir))
561
+        {
511 562
             return "409 Conflict"; // TODO right status code for both?
512 563
         }
513 564
 
514 565
         $options["new"] = ! file_exists($fspath);
515 566
 
516
-        if ($options["new"] && !$this->_is_writable($dir)) {
567
+        if ($options["new"] && !$this->_is_writable($dir))
568
+        {
517 569
             return "403 Forbidden";
518 570
         }
519
-        if (!$options["new"] && !$this->_is_writable($fspath)) {
571
+        if (!$options["new"] && !$this->_is_writable($fspath))
572
+        {
520 573
             return "403 Forbidden";
521 574
         }
522
-        if (!$options["new"] && is_dir($fspath)) {
575
+        if (!$options["new"] && is_dir($fspath))
576
+        {
523 577
             return "403 Forbidden";
524 578
         }
525 579
 
@@ -541,24 +595,30 @@  discard block
 block discarded – undo
541 595
         $parent = dirname($path);
542 596
         $name   = basename($path);
543 597
 
544
-        if (!file_exists($parent)) {
598
+        if (!file_exists($parent))
599
+        {
545 600
             return "409 Conflict";
546 601
         }
547 602
 
548
-        if (!is_dir($parent)) {
603
+        if (!is_dir($parent))
604
+        {
549 605
             return "403 Forbidden";
550 606
         }
551 607
 
552
-        if ( file_exists($parent."/".$name) ) {
608
+        if ( file_exists($parent."/".$name) )
609
+        {
553 610
             return "405 Method not allowed";
554 611
         }
555 612
 
556
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
613
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
614
+        {
615
+// no body parsing yet
557 616
             return "415 Unsupported media type";
558 617
         }
559 618
 
560 619
         $stat = mkdir($parent."/".$name, 0777);
561
-        if (!$stat) {
620
+        if (!$stat)
621
+        {
562 622
             return "403 Forbidden";
563 623
         }
564 624
 
@@ -576,16 +636,20 @@  discard block
 block discarded – undo
576 636
     {
577 637
         $path = $this->base . "/" .$options["path"];
578 638
 
579
-        if (!file_exists($path)) {
639
+        if (!file_exists($path))
640
+        {
580 641
             return "404 Not found";
581 642
         }
582 643
 
583
-        if (is_dir($path)) {
644
+        if (is_dir($path))
645
+        {
584 646
             $query = "DELETE FROM {$this->db_prefix}properties
585 647
                            WHERE path LIKE '".$this->_slashify($options["path"])."%'";
586 648
             mysql_query($query);
587 649
             System::rm(array("-rf", $path));
588
-        } else {
650
+        }
651
+        else
652
+        {
589 653
             unlink($path);
590 654
         }
591 655
         $query = "DELETE FROM {$this->db_prefix}properties
@@ -617,26 +681,35 @@  discard block
 block discarded – undo
617 681
     {
618 682
         // TODO Property updates still broken (Litmus should detect this?)
619 683
 
620
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
684
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
685
+        {
686
+// no body parsing yet
621 687
             return "415 Unsupported media type";
622 688
         }
623 689
 
624 690
         // no copying to different WebDAV Servers yet
625
-        if (isset($options["dest_url"])) {
691
+        if (isset($options["dest_url"]))
692
+        {
626 693
             return "502 bad gateway";
627 694
         }
628 695
 
629 696
         $source = $this->base . $options["path"];
630
-        if (!file_exists($source)) {
697
+        if (!file_exists($source))
698
+        {
631 699
             return "404 Not found";
632 700
         }
633 701
 
634
-        if (is_dir($source)) { // resource is a collection
635
-            switch ($options["depth"]) {
702
+        if (is_dir($source))
703
+        {
704
+// resource is a collection
705
+            switch ($options["depth"])
706
+            {
636 707
             case "infinity": // valid
637 708
                 break;
638 709
             case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
710
+                if ($del)
711
+                {
712
+// MOVE?
640 713
                     return "400 Bad request";
641 714
                 }
642 715
                 break;
@@ -649,7 +722,8 @@  discard block
 block discarded – undo
649 722
         $dest         = $this->base . $options["dest"];
650 723
         $destdir      = dirname($dest);
651 724
 
652
-        if (!file_exists($destdir) || !is_dir($destdir)) {
725
+        if (!file_exists($destdir) || !is_dir($destdir))
726
+        {
653 727
             return "409 Conflict";
654 728
         }
655 729
 
@@ -657,38 +731,52 @@  discard block
 block discarded – undo
657 731
         $new          = !file_exists($dest);
658 732
         $existing_col = false;
659 733
 
660
-        if (!$new) {
661
-            if ($del && is_dir($dest)) {
662
-                if (!$options["overwrite"]) {
734
+        if (!$new)
735
+        {
736
+            if ($del && is_dir($dest))
737
+            {
738
+                if (!$options["overwrite"])
739
+                {
663 740
                     return "412 precondition failed";
664 741
                 }
665 742
                 $dest .= basename($source);
666
-                if (file_exists($dest)) {
743
+                if (file_exists($dest))
744
+                {
667 745
                     $options["dest"] .= basename($source);
668
-                } else {
746
+                }
747
+                else
748
+                {
669 749
                     $new          = true;
670 750
                     $existing_col = true;
671 751
                 }
672 752
             }
673 753
         }
674 754
 
675
-        if (!$new) {
676
-            if ($options["overwrite"]) {
755
+        if (!$new)
756
+        {
757
+            if ($options["overwrite"])
758
+            {
677 759
                 $stat = $this->DELETE(array("path" => $options["dest"]));
678
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
760
+                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404"))
761
+                {
679 762
                     return $stat;
680 763
                 }
681
-            } else {
764
+            }
765
+            else
766
+            {
682 767
                 return "412 precondition failed";
683 768
             }
684 769
         }
685 770
 
686
-        if ($del) {
687
-            if (!rename($source, $dest)) {
771
+        if ($del)
772
+        {
773
+            if (!rename($source, $dest))
774
+            {
688 775
                 return "500 Internal server error";
689 776
             }
690 777
             $destpath = $this->_unslashify($options["dest"]);
691
-            if (is_dir($source)) {
778
+            if (is_dir($source))
779
+            {
692 780
                 $query = "UPDATE {$this->db_prefix}properties
693 781
                                  SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
694 782
                                WHERE path LIKE '".$this->_slashify($options["path"])."%'";
@@ -699,40 +787,58 @@  discard block
 block discarded – undo
699 787
                              SET path = '".$destpath."'
700 788
                            WHERE path = '".$options["path"]."'";
701 789
             mysql_query($query);
702
-        } else {
703
-            if (is_dir($source) && $options["depth"] == "infinity") {	// no find for depth="0"
790
+        }
791
+        else
792
+        {
793
+            if (is_dir($source) && $options["depth"] == "infinity")
794
+            {
795
+// no find for depth="0"
704 796
                 $files = System::find($source);
705 797
                 $files = array_reverse($files);
706
-            } else {
798
+            }
799
+            else
800
+            {
707 801
                 $files = array($source);
708 802
             }
709 803
 
710
-            if (!is_array($files) || empty($files)) {
804
+            if (!is_array($files) || empty($files))
805
+            {
711 806
                 return "500 Internal server error";
712 807
             }
713 808
 
714 809
 
715
-            foreach ($files as $file) {
716
-                if (is_dir($file)) {
810
+            foreach ($files as $file)
811
+            {
812
+                if (is_dir($file))
813
+                {
717 814
                     $file = $this->_slashify($file);
718 815
                 }
719 816
 
720 817
                 $destfile = str_replace($source, $dest, $file);
721 818
 
722
-                if (is_dir($file)) {
723
-                    if (!file_exists($destfile)) {
724
-                        if (!$this->_is_writable(dirname($destfile))) {
819
+                if (is_dir($file))
820
+                {
821
+                    if (!file_exists($destfile))
822
+                    {
823
+                        if (!$this->_is_writable(dirname($destfile)))
824
+                        {
725 825
                             return "403 Forbidden";
726 826
                         }
727
-                        if (!mkdir($destfile)) {
827
+                        if (!mkdir($destfile))
828
+                        {
728 829
                             return "409 Conflict";
729 830
                         }
730
-                    } else if (!is_dir($destfile)) {
831
+                    }
832
+                    else if (!is_dir($destfile))
833
+                    {
731 834
                         return "409 Conflict";
732 835
                     }
733
-                } else {
836
+                }
837
+                else
838
+                {
734 839
 
735
-                    if (!copy($file, $destfile)) {
840
+                    if (!copy($file, $destfile))
841
+                    {
736 842
                         return "409 Conflict";
737 843
                     }
738 844
                 }
@@ -762,17 +868,24 @@  discard block
 block discarded – undo
762 868
         $dir  = dirname($path)."/";
763 869
         $base = basename($path);
764 870
 
765
-        foreach ($options["props"] as $key => $prop) {
766
-            if ($prop["ns"] == "DAV:") {
871
+        foreach ($options["props"] as $key => $prop)
872
+        {
873
+            if ($prop["ns"] == "DAV:")
874
+            {
767 875
                 $options["props"][$key]['status'] = "403 Forbidden";
768
-            } else {
769
-                if (isset($prop["val"])) {
876
+            }
877
+            else
878
+            {
879
+                if (isset($prop["val"]))
880
+                {
770 881
                     $query = "REPLACE INTO {$this->db_prefix}properties
771 882
                                            SET path = '$options[path]'
772 883
                                              , name = '$prop[name]'
773 884
                                              , ns= '$prop[ns]'
774 885
                                              , value = '$prop[val]'";
775
-                } else {
886
+                }
887
+                else
888
+                {
776 889
                     $query = "DELETE FROM {$this->db_prefix}properties
777 890
                                         WHERE path = '$options[path]'
778 891
                                           AND name = '$prop[name]'
@@ -799,13 +912,16 @@  discard block
 block discarded – undo
799 912
 
800 913
         // TODO recursive locks on directories not supported yet
801 914
         // makes litmus test "32. lock_collection" fail
802
-        if (is_dir($fspath) && !empty($options["depth"])) {
915
+        if (is_dir($fspath) && !empty($options["depth"]))
916
+        {
803 917
             return "409 Conflict";
804 918
         }
805 919
 
806 920
         $options["timeout"] = time()+300; // 5min. hardcoded
807 921
 
808
-        if (isset($options["update"])) { // Lock Update
922
+        if (isset($options["update"]))
923
+        {
924
+// Lock Update
809 925
             $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
810 926
 
811 927
             $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where";
@@ -813,7 +929,8 @@  discard block
 block discarded – undo
813 929
             $row   = mysql_fetch_assoc($res);
814 930
             mysql_free_result($res);
815 931
 
816
-            if (is_array($row)) {
932
+            if (is_array($row))
933
+            {
817 934
                 $query = "UPDATE {$this->db_prefix}locks
818 935
                                  SET expires = '$options[timeout]'
819 936
                                    , modified = ".time()."
@@ -825,7 +942,9 @@  discard block
 block discarded – undo
825 942
                 $options['type']  = $row["exclusivelock"] ? "write"     : "read";
826 943
 
827 944
                 return true;
828
-            } else {
945
+            }
946
+            else
947
+            {
829 948
                 return false;
830 949
             }
831 950
         }
@@ -876,11 +995,13 @@  discard block
 block discarded – undo
876 995
                ";
877 996
         $res = mysql_query($query);
878 997
 
879
-        if ($res) {
998
+        if ($res)
999
+        {
880 1000
             $row = mysql_fetch_array($res);
881 1001
             mysql_free_result($res);
882 1002
 
883
-            if ($row) {
1003
+            if ($row)
1004
+            {
884 1005
                 $result = array( "type"    => "write",
885 1006
                                  "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886 1007
                                  "depth"   => 0,
Please login to merge, or discard this patch.
api/src/Mail/Imap.php 2 patches
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 		$mailbox = '';
581 581
 		if ( is_int( $restriction_search ) ){
582 582
 			switch ( $restriction_search ) {
583
-			case 0:
584
-				$searchstring = $reference."*";
585
-				break;
586
-			case 1:
587
-				$mailbox = $searchstring = $reference;
588
-				//$reference = '%';
589
-				break;
590
-			case 2:
591
-				$searchstring = $reference."%";
592
-				break;
583
+				case 0:
584
+					$searchstring = $reference."*";
585
+					break;
586
+				case 1:
587
+					$mailbox = $searchstring = $reference;
588
+					//$reference = '%';
589
+					break;
590
+				case 2:
591
+					$searchstring = $reference."%";
592
+					break;
593 593
 			}
594 594
 		}else{
595 595
 			if ( is_string( $restriction_search ) ){
@@ -664,16 +664,16 @@  discard block
 block discarded – undo
664 664
 		$mailbox = '';
665 665
 		if ( is_int( $restriction_search ) ){
666 666
 			switch ( $restriction_search ) {
667
-			case 0:
668
-				$searchstring = $reference."*";
669
-				break;
670
-			case 1:
671
-				$mailbox = $searchstring = $reference;
672
-				//$reference = '%';
673
-				break;
674
-			case 2:
675
-				$searchstring = $reference."%";
676
-				break;
667
+				case 0:
668
+					$searchstring = $reference."*";
669
+					break;
670
+				case 1:
671
+					$mailbox = $searchstring = $reference;
672
+					//$reference = '%';
673
+					break;
674
+				case 2:
675
+					$searchstring = $reference."%";
676
+					break;
677 677
 			}
678 678
 		}else{
679 679
 			if ( is_string( $restriction_search ) ){
@@ -730,16 +730,16 @@  discard block
 block discarded – undo
730 730
 
731 731
 		if ( is_int( $restriction_search ) ){
732 732
 			switch ( $restriction_search ) {
733
-			case 0:
734
-				$mailbox = $reference."*";
735
-				break;
736
-			case 1:
737
-				$mailbox = $reference;
738
-				$reference = '%';
739
-				break;
740
-			case 2:
741
-				$mailbox = "%";
742
-				break;
733
+				case 0:
734
+					$mailbox = $reference."*";
735
+					break;
736
+				case 1:
737
+					$mailbox = $reference;
738
+					$reference = '%';
739
+					break;
740
+				case 2:
741
+					$mailbox = "%";
742
+					break;
743 743
 			}
744 744
 		}else{
745 745
 			if ( is_string( $restriction_search ) ){
Please login to merge, or discard this patch.
Braces   +130 added lines, -42 removed lines patch added patch discarded remove patch
@@ -156,7 +156,10 @@  discard block
 block discarded – undo
156 156
 		$this->loginType = $this->params['acc_imap_logintype'];
157 157
 		$this->domainName = $this->params['acc_domain'];
158 158
 
159
-		if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
159
+		if (is_null($_timeout))
160
+		{
161
+			$_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
162
+		}
160 163
 
161 164
 		// Horde use locale for translation of error messages
162 165
 		// need to set LC_CTYPE for charachter classification (eg. Umlauts)
@@ -169,7 +172,10 @@  discard block
 block discarded – undo
169 172
 		{
170 173
 			$username = $this->getMailBoxUserName($username);
171 174
 		}
172
-		if ($_adminConnection) $this->adminConnection($username);
175
+		if ($_adminConnection)
176
+		{
177
+			$this->adminConnection($username);
178
+		}
173 179
 		$parent_params = array(
174 180
 			'username' => $this->params[$_adminConnection ? 'acc_imap_admin_username' : 'acc_imap_username'],
175 181
 			'password' => $this->params[$_adminConnection ? 'acc_imap_admin_password' : 'acc_imap_password'],
@@ -343,7 +349,11 @@  discard block
 block discarded – undo
343 349
 	static function getTimeOut($_use='IMAP')
344 350
 	{
345 351
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
346
-		if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value
352
+		if (empty($timeout) || !($timeout > 0))
353
+		{
354
+			$timeout = $_use == 'SIEVE' ? 10 : 20;
355
+		}
356
+		// this is the default value
347 357
 		return $timeout;
348 358
 	}
349 359
 
@@ -406,7 +416,8 @@  discard block
 block discarded – undo
406 416
 	 */
407 417
 	function encodeFolderName($_folderName)
408 418
 	{
409
-		if($this->mbAvailable) {
419
+		if($this->mbAvailable)
420
+		{
410 421
 			return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset());
411 422
 		}
412 423
 
@@ -424,14 +435,21 @@  discard block
 block discarded – undo
424 435
 	function getMailbox($mailbox)
425 436
 	{
426 437
 		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL);
427
-		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
438
+		if (empty($mailboxes))
439
+		{
440
+			$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
441
+		}
428 442
 		//error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes));
429 443
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
430 444
 		//_debug_array($mboxes->count());
431 445
 		foreach ($mboxes->getIterator() as $k =>$box)
432 446
 		{
433 447
 			//error_log(__METHOD__.__LINE__.'->'.$k);
434
-			if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
448
+			if ($k!='user' && $k != '' && $k==$mailbox)
449
+			{
450
+				return $box['mailbox'];
451
+			}
452
+			//_debug_array(array($k => $client->status($k)));
435 453
 		}
436 454
 		return ($this->mailboxExist($mailbox)?$mailbox:false);
437 455
 	}
@@ -500,8 +518,14 @@  discard block
 block discarded – undo
500 518
 			//throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage());
501 519
 			unset($e);
502 520
 		}
503
-		if (!empty($mailbox)) return $mailbox['mailbox'];
504
-		if (empty($mailbox) && $this->mailboxExist('INBOX')) return 'INBOX';
521
+		if (!empty($mailbox))
522
+		{
523
+			return $mailbox['mailbox'];
524
+		}
525
+		if (empty($mailbox) && $this->mailboxExist('INBOX'))
526
+		{
527
+			return 'INBOX';
528
+		}
505 529
 		return null;
506 530
 	}
507 531
 
@@ -571,7 +595,10 @@  discard block
 block discarded – undo
571 595
 			));
572 596
 
573 597
 		$flags = Horde_Imap_Client::STATUS_ALL;
574
-		if ($ignoreStatusCache) $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH;
598
+		if ($ignoreStatusCache)
599
+		{
600
+			$flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH;
601
+		}
575 602
 
576 603
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
577 604
 		//error_log(__METHOD__.__LINE__.array2string($mboxes->count()));
@@ -614,12 +641,15 @@  discard block
 block discarded – undo
614 641
 	 */
615 642
 	function getMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
616 643
 	{
617
-		if ( is_bool($restriction_search) ){
644
+		if ( is_bool($restriction_search) )
645
+		{
618 646
 			$restriction_search = (int) $restriction_search;
619 647
 		}
620 648
 		$mailbox = '';
621
-		if ( is_int( $restriction_search ) ){
622
-			switch ( $restriction_search ) {
649
+		if ( is_int( $restriction_search ) )
650
+		{
651
+			switch ( $restriction_search )
652
+			{
623 653
 			case 0:
624 654
 				$searchstring = $reference."*";
625 655
 				break;
@@ -631,8 +661,11 @@  discard block
 block discarded – undo
631 661
 				$searchstring = $reference."%";
632 662
 				break;
633 663
 			}
634
-		}else{
635
-			if ( is_string( $restriction_search ) ){
664
+		}
665
+		else
666
+		{
667
+			if ( is_string( $restriction_search ) )
668
+			{
636 669
 				$mailbox = $searchstring = $restriction_search;
637 670
 			}
638 671
 		}
@@ -698,12 +731,15 @@  discard block
 block discarded – undo
698 731
 	 */
699 732
 	function listSubscribedMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
700 733
 	{
701
-		if ( is_bool($restriction_search) ){
734
+		if ( is_bool($restriction_search) )
735
+		{
702 736
 			$restriction_search = (int) $restriction_search;
703 737
 		}
704 738
 		$mailbox = '';
705
-		if ( is_int( $restriction_search ) ){
706
-			switch ( $restriction_search ) {
739
+		if ( is_int( $restriction_search ) )
740
+		{
741
+			switch ( $restriction_search )
742
+			{
707 743
 			case 0:
708 744
 				$searchstring = $reference."*";
709 745
 				break;
@@ -715,8 +751,11 @@  discard block
 block discarded – undo
715 751
 				$searchstring = $reference."%";
716 752
 				break;
717 753
 			}
718
-		}else{
719
-			if ( is_string( $restriction_search ) ){
754
+		}
755
+		else
756
+		{
757
+			if ( is_string( $restriction_search ) )
758
+			{
720 759
 				$mailbox = $searchstring = $restriction_search;
721 760
 			}
722 761
 		}
@@ -764,12 +803,15 @@  discard block
 block discarded – undo
764 803
 	 */
765 804
 	function listUnSubscribedMailboxes($reference = ''  , $restriction_search = 0)
766 805
 	{
767
-		if ( is_bool($restriction_search) ){
806
+		if ( is_bool($restriction_search) )
807
+		{
768 808
 			$restriction_search = (int) $restriction_search;
769 809
 		}
770 810
 
771
-		if ( is_int( $restriction_search ) ){
772
-			switch ( $restriction_search ) {
811
+		if ( is_int( $restriction_search ) )
812
+		{
813
+			switch ( $restriction_search )
814
+			{
773 815
 			case 0:
774 816
 				$mailbox = $reference."*";
775 817
 				break;
@@ -781,8 +823,11 @@  discard block
 block discarded – undo
781 823
 				$mailbox = "%";
782 824
 				break;
783 825
 			}
784
-		}else{
785
-			if ( is_string( $restriction_search ) ){
826
+		}
827
+		else
828
+		{
829
+			if ( is_string( $restriction_search ) )
830
+			{
786 831
 				$mailbox = $restriction_search;
787 832
 			}
788 833
 		}
@@ -801,7 +846,10 @@  discard block
 block discarded – undo
801 846
 		foreach ($unsubscribed as $box)
802 847
 		{
803 848
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
804
-			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8;
849
+			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX')
850
+			{
851
+				$ret[]=$box['mailbox']->utf8;
852
+			}
805 853
 		}
806 854
 		return $ret;
807 855
 	}
@@ -815,10 +863,16 @@  discard block
 block discarded – undo
815 863
 	 */
816 864
 	function examineMailbox($mailbox, $flags=null)
817 865
 	{
818
-		if ($mailbox=='') return false;
866
+		if ($mailbox=='')
867
+		{
868
+			return false;
869
+		}
819 870
 		$mailboxes = $this->listMailboxes($mailbox);
820 871
 
821
-		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
872
+		if (is_null($flags))
873
+		{
874
+			$flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
875
+		}
822 876
 
823 877
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
824 878
 		//_debug_array($mboxes->count());
@@ -900,7 +954,10 @@  discard block
 block discarded – undo
900 954
 		}
901 955
 		catch (\Exception $e)
902 956
 		{
903
-			if ($this->debug) error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage());
957
+			if ($this->debug)
958
+			{
959
+				error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage());
960
+			}
904 961
 			return false;
905 962
 		}
906 963
 		if (!is_array($cap))
@@ -940,7 +997,10 @@  discard block
 block discarded – undo
940 997
 	{
941 998
 		foreach($_nameSpace as &$singleNameSpace)
942 999
 		{
943
-			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
1000
+			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix'])
1001
+			{
1002
+				return $singleNameSpace['prefix'];
1003
+			}
944 1004
 		}
945 1005
 		return "";
946 1006
 	}
@@ -957,7 +1017,8 @@  discard block
 block discarded – undo
957 1017
 	 */
958 1018
 	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
959 1019
 	{
960
-		if ($reclevel > 25) {
1020
+		if ($reclevel > 25)
1021
+		{
961 1022
 			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
962 1023
 			return array();
963 1024
 		}
@@ -973,7 +1034,8 @@  discard block
 block discarded – undo
973 1034
 		{
974 1035
 			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false);
975 1036
 			$allMailboxes = array();
976
-			foreach ($buff as $mbxname) {
1037
+			foreach ($buff as $mbxname)
1038
+			{
977 1039
 				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
978 1040
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
979 1041
 				if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix  && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
@@ -981,7 +1043,10 @@  discard block
 block discarded – undo
981 1043
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
982 1044
 				}
983 1045
 			}
984
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
1046
+			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
1047
+			{
1048
+				$allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
1049
+			}
985 1050
 			return $allMailboxes;
986 1051
 		}
987 1052
 		else
@@ -1003,9 +1068,16 @@  discard block
 block discarded – undo
1003 1068
 		static $nameSpace=null;
1004 1069
 		$foldersNameSpace = array();
1005 1070
 		$delimiter = $this->getDelimiter();
1006
-		if (empty($delimiter)) $delimiter='/';
1007
-		if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray();
1008
-		if (is_array($nameSpace)) {
1071
+		if (empty($delimiter))
1072
+		{
1073
+			$delimiter='/';
1074
+		}
1075
+		if (is_null($nameSpace))
1076
+		{
1077
+			$nameSpace = $this->getNameSpaceArray();
1078
+		}
1079
+		if (is_array($nameSpace))
1080
+		{
1009 1081
 			foreach($nameSpace as $type => $singleNameSpaceArray)
1010 1082
 			{
1011 1083
 				foreach ($singleNameSpaceArray as $singleNameSpace)
@@ -1022,7 +1094,9 @@  discard block
 block discarded – undo
1022 1094
 						$_foldersNameSpace['prefix_present'] = 'forced';
1023 1095
 						// uw-imap server with mailbox prefix or dovecot maybe
1024 1096
 						$_foldersNameSpace['prefix'] = 'mail';
1025
-					} else {
1097
+					}
1098
+					else
1099
+					{
1026 1100
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
1027 1101
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
1028 1102
 					}
@@ -1062,7 +1136,10 @@  discard block
 block discarded – undo
1062 1136
 		$namespaces = $this->getNamespaces();
1063 1137
 		foreach ($namespaces as $nsp)
1064 1138
 		{
1065
-			if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter'];
1139
+			if ($nsp['type']==$type && $nsp['delimiter'])
1140
+			{
1141
+				return $nsp['delimiter'];
1142
+			}
1066 1143
 		}
1067 1144
 		return "/";
1068 1145
 	}
@@ -1158,12 +1235,14 @@  discard block
 block discarded – undo
1158 1235
 	{
1159 1236
 		$nameSpaces = $this->getNameSpaceArray();
1160 1237
 
1161
-		if(!isset($nameSpaces['others'])) {
1238
+		if(!isset($nameSpaces['others']))
1239
+		{
1162 1240
 			return false;
1163 1241
 		}
1164 1242
 
1165 1243
 		$username = $this->getMailBoxUserName($_username);
1166
-		if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') {
1244
+		if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber')
1245
+		{
1167 1246
 			$username .= '@'. $this->domainName;
1168 1247
 		}
1169 1248
 
@@ -1315,7 +1394,10 @@  discard block
 block discarded – undo
1315 1394
 	 */
1316 1395
 	public function __call($name,array $params=null)
1317 1396
 	{
1318
-		if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1397
+		if ($this->debug)
1398
+		{
1399
+			error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1400
+		}
1319 1401
 		switch($name)
1320 1402
 		{
1321 1403
 			case 'installScript':
@@ -1350,7 +1432,10 @@  discard block
 block discarded – undo
1350 1432
 	 */
1351 1433
 	public function setVacationUser($_euser, array $_vacation, $_scriptName=null)
1352 1434
 	{
1353
-		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1435
+		if ($this->debug)
1436
+		{
1437
+			error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1438
+		}
1354 1439
 
1355 1440
 		if (is_numeric($_euser))
1356 1441
 		{
@@ -1378,7 +1463,10 @@  discard block
 block discarded – undo
1378 1463
 	 */
1379 1464
 	public function getVacationUser($_euser, $_scriptName=null)
1380 1465
 	{
1381
-		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser));
1466
+		if ($this->debug)
1467
+		{
1468
+			error_log(__METHOD__.' User:'.array2string($_euser));
1469
+		}
1382 1470
 
1383 1471
 		if (is_numeric($_euser))
1384 1472
 		{
Please login to merge, or discard this patch.
setup/setup-cli.php 2 patches
Switch Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -68,91 +68,91 @@
 block discarded – undo
68 68
 
69 69
 switch($action)
70 70
 {
71
-	case '--version':
72
-	case '--check':
73
-		setup_cmd::check_installed($arguments[0],0,true);
74
-		break;
75
-
76
-	case '--create-header':
77
-	case '--edit-header':
78
-	case '--upgrade-header':
79
-	case '--update-header':
80
-		do_header($action == '--create-header',$arguments);
81
-		break;
82
-
83
-	case '--install':
84
-		do_install($arguments);
85
-		break;
86
-
87
-	case '--config':
88
-		do_config($arguments);
89
-		break;
90
-
91
-	case '--admin':
92
-		do_admin($arguments[0]);
93
-		break;
94
-
95
-	case '--update':
96
-		do_update($arguments[0]);
97
-		break;
98
-
99
-	case '--register-hooks':
100
-	case '--register-all-hooks':
101
-		do_hooks($arguments[0]);
102
-		break;
103
-
104
-	case '--backup':
105
-		do_backup($arguments[0]);
106
-		break;
107
-
108
-	case '--languages':
109
-		echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
110
-		break;
111
-
112
-	case '--charsets':
113
-		echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
114
-		break;
115
-
116
-	case '--exit-codes':
117
-		list_exit_codes();
118
-		break;
119
-
120
-	case '--help':
121
-	case '--usage':
122
-		do_usage($arguments[0]);
123
-		break;
124
-
125
-	default:
126
-		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
127
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
128
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
129
-		{
130
-			$args = array();
131
-			list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
132
-			foreach($arguments as $arg)
71
+		case '--version':
72
+		case '--check':
73
+			setup_cmd::check_installed($arguments[0],0,true);
74
+			break;
75
+
76
+		case '--create-header':
77
+		case '--edit-header':
78
+		case '--upgrade-header':
79
+		case '--update-header':
80
+			do_header($action == '--create-header',$arguments);
81
+			break;
82
+
83
+		case '--install':
84
+			do_install($arguments);
85
+			break;
86
+
87
+		case '--config':
88
+			do_config($arguments);
89
+			break;
90
+
91
+		case '--admin':
92
+			do_admin($arguments[0]);
93
+			break;
94
+
95
+		case '--update':
96
+			do_update($arguments[0]);
97
+			break;
98
+
99
+		case '--register-hooks':
100
+		case '--register-all-hooks':
101
+			do_hooks($arguments[0]);
102
+			break;
103
+
104
+		case '--backup':
105
+			do_backup($arguments[0]);
106
+			break;
107
+
108
+		case '--languages':
109
+			echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
110
+			break;
111
+
112
+		case '--charsets':
113
+			echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
114
+			break;
115
+
116
+		case '--exit-codes':
117
+			list_exit_codes();
118
+			break;
119
+
120
+		case '--help':
121
+		case '--usage':
122
+			do_usage($arguments[0]);
123
+			break;
124
+
125
+		default:
126
+			// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
127
+			if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
128
+				is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
133 129
 			{
134
-				list($name,$value) = explode('=',$arg,2);
135
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
136
-				{
137
-					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138
-				}
139
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
130
+				$args = array();
131
+				list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
132
+				foreach($arguments as $arg)
140 133
 				{
141
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
142
-					$args[$name][$sub] = $value;
143
-				}
144
-				else
145
-				{
146
-					$args[$name] = $value;
134
+					list($name,$value) = explode('=',$arg,2);
135
+					if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
136
+					{
137
+						throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138
+					}
139
+					if (substr($name,-1) == ']')	// allow 1-dim. arrays
140
+					{
141
+						list($name,$sub) = explode('[',substr($name,0,-1),2);
142
+						$args[$name][$sub] = $value;
143
+					}
144
+					else
145
+					{
146
+						$args[$name] = $value;
147
+					}
147 148
 				}
149
+				$cmd = new $class($args);
150
+				$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
+				if (is_array($msg)) $msg = print_r($msg,true);
152
+				echo "$msg\n";
153
+				break;
148 154
 			}
149
-			$cmd = new $class($args);
150
-			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
-			if (is_array($msg)) $msg = print_r($msg,true);
152
-			echo "$msg\n";
153
-			break;
154
-		}
155
-		throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90);
155
+			throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90);
156 156
 }
157 157
 exit(0);
158 158
 
Please login to merge, or discard this patch.
Braces   +69 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 
16 16
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
17 17
 
18
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
18
+if (php_sapi_name() !== 'cli')
19
+{
20
+	// security precaution: forbit calling setup-cli as web-page
19 21
 {
20 22
 	die('<h1>setup-cli.php must NOT be called as web-page --> exiting !!!</h1>');
21 23
 }
24
+}
22 25
 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
23 26
 
24 27
 $dry_run = false;
@@ -33,7 +36,11 @@  discard block
 block discarded – undo
33 36
 	}
34 37
 	$arguments = $_SERVER['argv'];
35 38
 	$action = array_shift($arguments);
36
-	if (isset($arguments[0])) list($_POST['FormDomain']) = explode(',',$arguments[0]);	// header include needs that to detects the right domain
39
+	if (isset($arguments[0]))
40
+	{
41
+		list($_POST['FormDomain']) = explode(',',$arguments[0]);
42
+	}
43
+	// header include needs that to detects the right domain
37 44
 }
38 45
 else
39 46
 {
@@ -51,7 +58,10 @@  discard block
 block discarded – undo
51 58
 // check if date.timezone is set, report it and set something if not, as it gives tons of errors in install log
52 59
 if (!ini_get('date.timezone'))
53 60
 {
54
-	if (!($tz = date_default_timezone_get())) $tz = 'UTC';
61
+	if (!($tz = date_default_timezone_get()))
62
+	{
63
+		$tz = 'UTC';
64
+	}
55 65
 	echo "No default timezone (php.ini date.timezone) set, we temporary set '$tz'. You should fix that permanent!\n";
56 66
 	ini_set('date.timezone',$tz);
57 67
 }
@@ -132,13 +142,19 @@  discard block
 block discarded – undo
132 142
 			foreach($arguments as $arg)
133 143
 			{
134 144
 				list($name,$value) = explode('=',$arg,2);
135
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
145
+				if(property_exists('admin_cmd',$name))
146
+				{
147
+					// dont allow to overwrite admin_cmd properties
136 148
 				{
137 149
 					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138 150
 				}
139
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
151
+				}
152
+				if (substr($name,-1) == ']')
153
+				{
154
+					// allow 1-dim. arrays
140 155
 				{
141 156
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
157
+				}
142 158
 					$args[$name][$sub] = $value;
143 159
 				}
144 160
 				else
@@ -148,7 +164,10 @@  discard block
 block discarded – undo
148 164
 			}
149 165
 			$cmd = new $class($args);
150 166
 			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
-			if (is_array($msg)) $msg = print_r($msg,true);
167
+			if (is_array($msg))
168
+			{
169
+				$msg = print_r($msg,true);
170
+			}
152 171
 			echo "$msg\n";
153 172
 			break;
154 173
 		}
@@ -164,14 +183,20 @@  discard block
 block discarded – undo
164 183
 function do_config($args)
165 184
 {
166 185
 	$arg0 = explode(',',array_shift($args));
167
-	if (!($domain = @array_shift($arg0))) $domain = 'default';
186
+	if (!($domain = @array_shift($arg0)))
187
+	{
188
+		$domain = 'default';
189
+	}
168 190
 	$user = @array_shift($arg0);
169 191
 	$password = @array_shift($arg0);
170 192
 	_fetch_user_password($user,$password);
171 193
 
172
-	if ($arg0)	// direct assignments (name=value,...) left
194
+	if ($arg0)
195
+	{
196
+		// direct assignments (name=value,...) left
173 197
 	{
174 198
 		array_unshift($args,implode(',',$arg0));
199
+	}
175 200
 		array_unshift($args,'--config');
176 201
 	}
177 202
 
@@ -238,9 +263,15 @@  discard block
 block discarded – undo
238 263
 	{
239 264
 		$options[0] = $domain;
240 265
 
241
-		if ($quite_check) ob_start();
266
+		if ($quite_check)
267
+		{
268
+			ob_start();
269
+		}
242 270
 		_check_auth_config(implode(',',$options),14);
243
-		if ($quite_check) ob_end_clean();
271
+		if ($quite_check)
272
+		{
273
+			ob_end_clean();
274
+		}
244 275
 
245 276
 		if ($backup == 'no')
246 277
 		{
@@ -316,7 +347,10 @@  discard block
 block discarded – undo
316 347
 function _check_auth_config($arg,$stop,$set_lang=true)
317 348
 {
318 349
 	$options = explode(',',$arg);
319
-	if (!($domain = array_shift($options))) $domain = 'default';
350
+	if (!($domain = array_shift($options)))
351
+	{
352
+		$domain = 'default';
353
+	}
320 354
 	$user = array_shift($options);
321 355
 	$password = array_shift($options);
322 356
 	_fetch_user_password($user,$password);
@@ -324,7 +358,10 @@  discard block
 block discarded – undo
324 358
 	setup_cmd::check_installed($domain,$stop,true);
325 359
 
326 360
 	// reset charset for the output to the charset used by the OS
327
-	if ($set_lang) $GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
361
+	if ($set_lang)
362
+	{
363
+		$GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
364
+	}
328 365
 
329 366
 	setup_cmd::check_setup_auth($user,$password,$domain);
330 367
 
@@ -360,7 +397,10 @@  discard block
 block discarded – undo
360 397
 function _fetch_user_password(&$user,&$password)
361 398
 {
362 399
 	// read password from enviroment or query it from user, if not given
363
-	if (!$user) $user = 'admin';
400
+	if (!$user)
401
+	{
402
+		$user = 'admin';
403
+	}
364 404
 	if (!$password && !($password = $_SERVER['EGW_CLI_PASSWORD']))
365 405
 	{
366 406
 		echo lang('Admin password to header manager').' ';
@@ -406,9 +446,15 @@  discard block
 block discarded – undo
406 446
 		list($code,$language) = explode("\t",$line);
407 447
 		$languages[$code] = $language;
408 448
 	}
409
-	if (isset($languages[$lang.'-'.$nation])) return $lang.'-'.$nation;
449
+	if (isset($languages[$lang.'-'.$nation]))
450
+	{
451
+		return $lang.'-'.$nation;
452
+	}
410 453
 
411
-	if (isset($languages[$lang])) return $lang;
454
+	if (isset($languages[$lang]))
455
+	{
456
+		return $lang;
457
+	}
412 458
 
413 459
 	return 'en';
414 460
 }
@@ -448,7 +494,10 @@  discard block
 block discarded – undo
448 494
 	if (!$what || $what == 'config')
449 495
 	{
450 496
 		echo '--config '.lang('domain(default),[config user(admin)],password,[name=value,...] sets config values beside:')."\n";
451
-		if (!$what) echo '	--help config '.lang('gives further options')."\n";
497
+		if (!$what)
498
+		{
499
+			echo '	--help config '.lang('gives further options')."\n";
500
+		}
452 501
 	}
453 502
 	if ($what == 'config')
454 503
 	{
@@ -477,7 +526,10 @@  discard block
 block discarded – undo
477 526
 		echo lang('Create or edit the EGroupware configuration file: header.inc.php:')."\n";
478 527
 		echo '--create-header '.lang('header-password[,header-user(admin)]')."\n";
479 528
 		echo '--edit-header '.lang('[header-password],[header-user],[new-password],[new-user]')."\n";
480
-		if (!$what) echo '	--help header '.lang('gives further options')."\n";
529
+		if (!$what)
530
+		{
531
+			echo '	--help header '.lang('gives further options')."\n";
532
+		}
481 533
 	}
482 534
 	if ($what == 'header')
483 535
 	{
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_admin.inc.php 1 patch
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -131,7 +131,10 @@  discard block
 block discarded – undo
131 131
 					($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount']))
132 132
 				{
133 133
 					$url = str_replace('$path',$path,$content['mounts']['url']);
134
-					if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path;
134
+					if (empty($url) && $this->versioning)
135
+					{
136
+						$url = Versioning\StreamWrapper::PREFIX.$path;
137
+					}
135 138
 
136 139
 					if ($content['mounts']['enable'] && !$this->versioning)
137 140
 					{
@@ -227,16 +230,25 @@  discard block
 block discarded – undo
227 230
 			$content['versionedpath'] = '/';
228 231
 			$content['mtime'] = 100;
229 232
 		}
230
-		if (true) $content = array(
233
+		if (true)
234
+		{
235
+			$content = array(
231 236
 			'versionedpath' => $content['versionedpath'],
232 237
 			'mtime' => $content['mtime'],
233 238
 		);
239
+		}
234 240
 		if ($this->versioning)
235 241
 		{
236 242
 			// statistical information
237 243
 			$content += Versioning\StreamWrapper::summary();
238
-			if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
239
-			if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
244
+			if ($content['total_files'])
245
+			{
246
+				$content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
247
+			}
248
+			if ($content['total_size'])
249
+			{
250
+				$content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
251
+			}
240 252
 		}
241 253
 		if (!($content['is_root']=Vfs::$is_root))
242 254
 		{
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_shares.inc.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,10 @@
 block discarded – undo
101 101
 				$row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY;
102 102
 			}
103 103
 			$row['share_passwd'] = (boolean)$row['share_passwd'];
104
-			if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']);
104
+			if ($row['share_with'])
105
+			{
106
+				$row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']);
107
+			}
105 108
 		}
106 109
 		return $total;
107 110
 	}
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_favorite_portlet.inc.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,10 @@
 block discarded – undo
104 104
 		if ($content['nm']['action'])
105 105
 		{
106 106
 			$msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
107
-			if($msg) Api\Json\Response::get()->apply('egw.message',array($msg));
107
+			if($msg)
108
+			{
109
+				Api\Json\Response::get()->apply('egw.message',array($msg));
110
+			}
108 111
 			foreach($content['nm']['selected'] as &$id)
109 112
 			{
110 113
 				$id = 'filemanager::'.$id;
Please login to merge, or discard this patch.
filemanager/test.php 1 patch
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,10 @@  discard block
 block discarded – undo
22 22
 {
23 23
 	$path = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
24 24
 }
25
-if (isset($_REQUEST['path'])) $path = $_REQUEST['path'];
25
+if (isset($_REQUEST['path']))
26
+{
27
+	$path = $_REQUEST['path'];
28
+}
26 29
 echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"').
27 30
 	Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET');
28 31
 
@@ -53,9 +56,12 @@  discard block
 block discarded – undo
53 56
 	$stime = number_format(1000*(microtime(true)-$time),1);
54 57
 
55 58
 	$time2 = microtime(true);
56
-	if ($is_dir)// && ($d = Vfs::opendir($path)))
59
+	if ($is_dir)
60
+	{
61
+		// && ($d = Vfs::opendir($path)))
57 62
 	{
58 63
 		$files = array();
64
+	}
59 65
 		//while(($file = readdir($d)))
60 66
 		foreach(Vfs::scandir($path) as $file)
61 67
 		{
@@ -69,7 +75,10 @@  discard block
 block discarded – undo
69 75
 		//closedir($d);
70 76
 		$time2f = number_format(1000*(microtime(true)-$time2),1);
71 77
 		echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n";
72
-		if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n";
78
+		if($files)
79
+		{
80
+			echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n";
81
+		}
73 82
 	}
74 83
 
75 84
 	echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')';
Please login to merge, or discard this patch.