Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
api/src/CalDAV/PropfindIterator.php 1 patch
Braces   +41 added lines, -10 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function __construct(Handler $handler, $path, array $filter,array &$files=array())
99 99
 	{
100
-		if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)");
100
+		if ($this->debug)
101
+		{
102
+			error_log(__METHOD__."('$path', ".array2string($filter).",)");
103
+		}
101 104
 		$this->path    = $path;
102 105
 		$this->handler = $handler;
103 106
 		$this->filter  = $filter;
@@ -112,7 +115,10 @@  discard block
 block discarded – undo
112 115
 	 */
113 116
 	public function current()
114 117
 	{
115
-		if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files)));
118
+		if ($this->debug)
119
+		{
120
+			error_log(__METHOD__."() returning ".array2string(current($this->files)));
121
+		}
116 122
 		return current($this->files);
117 123
 	}
118 124
 
@@ -125,7 +131,10 @@  discard block
 block discarded – undo
125 131
 	{
126 132
 		$current = current($this->files);
127 133
 
128
-		if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path']));
134
+		if ($this->debug)
135
+		{
136
+			error_log(__METHOD__."() returning ".array2string($current['path']));
137
+		}
129 138
 		return $current['path'];	// we return path as key
130 139
 	}
131 140
 
@@ -136,26 +145,38 @@  discard block
 block discarded – undo
136 145
 	{
137 146
 		if (next($this->files) !== false)
138 147
 		{
139
-			if ($this->debug) error_log(__METHOD__."() returning TRUE");
148
+			if ($this->debug)
149
+			{
150
+				error_log(__METHOD__."() returning TRUE");
151
+			}
140 152
 			return true;
141 153
 		}
142 154
 		// check if previous query gave less then CHUNK_SIZE entries --> we're done
143 155
 		if ($this->start && count($this->files) < self::CHUNK_SIZE)
144 156
 		{
145
-			if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)");
157
+			if ($this->debug)
158
+			{
159
+				error_log(__METHOD__."() returning FALSE (no more entries)");
160
+			}
146 161
 			return false;
147 162
 		}
148 163
 		// try query further files via propfind callback of handler and store result in $this->files
149 164
 		$this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE));
150 165
 		if (!is_array($this->files) || !($entries = count($this->files)))
151 166
 		{
152
-			if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)");
167
+			if ($this->debug)
168
+			{
169
+				error_log(__METHOD__."() returning FALSE (no more entries)");
170
+			}
153 171
 			return false;	// no further entries
154 172
 		}
155 173
 		$this->start += self::CHUNK_SIZE;
156 174
 		reset($this->files);
157 175
 
158
-		if ($this->debug) error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false));
176
+		if ($this->debug)
177
+		{
178
+			error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false));
179
+		}
159 180
 
160 181
 		return current($this->files) !== false;
161 182
 	}
@@ -165,11 +186,18 @@  discard block
 block discarded – undo
165 186
 	 */
166 187
 	public function rewind()
167 188
 	{
168
-		if ($this->debug) error_log(__METHOD__."()");
189
+		if ($this->debug)
190
+		{
191
+			error_log(__METHOD__."()");
192
+		}
169 193
 
170 194
 		$this->start = 0;
171 195
 		$this->files = $this->common_files;
172
-		if (!$this->files) $this->next();	// otherwise valid will return false and nothing get returned
196
+		if (!$this->files)
197
+		{
198
+			$this->next();
199
+		}
200
+		// otherwise valid will return false and nothing get returned
173 201
 		reset($this->files);
174 202
 	}
175 203
 
@@ -180,7 +208,10 @@  discard block
 block discarded – undo
180 208
 	 */
181 209
 	public function valid ()
182 210
 	{
183
-		if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
211
+		if ($this->debug)
212
+		{
213
+			error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
214
+		}
184 215
 		return current($this->files) !== false;
185 216
 	}
186 217
 }
Please login to merge, or discard this patch.
api/src/CalDAV/IcalIterator.php 1 patch
Braces   +29 added lines, -8 removed lines patch added patch discarded remove patch
@@ -116,7 +116,10 @@  discard block
 block discarded – undo
116 116
 		if (is_callable($callback))
117 117
 		{
118 118
 			$this->callback = $callback;
119
-			if ($add_container) $callback_params[] = $this;
119
+			if ($add_container)
120
+			{
121
+				$callback_params[] = $this;
122
+			}
120 123
 			$this->callback_params = $callback_params;
121 124
 		}
122 125
 		if (is_string($ical_file))
@@ -197,8 +200,14 @@  discard block
 block discarded – undo
197 200
 		{
198 201
 			$ret = is_a($this->component,'Horde_Icalendar');
199 202
 			do {
200
-				if ($ret === false) $this->next();
201
-				if (!is_a($this->component,'Horde_Icalendar')) return false;
203
+				if ($ret === false)
204
+				{
205
+					$this->next();
206
+				}
207
+				if (!is_a($this->component,'Horde_Icalendar'))
208
+				{
209
+					return false;
210
+				}
202 211
 				$params = $this->callback_params;
203 212
 				array_unshift($params,$this->component);
204 213
 			}
@@ -231,9 +240,12 @@  discard block
 block discarded – undo
231 240
 		{
232 241
 			// ignore it
233 242
 		}
234
-		if ($line === false)	// end-of-file or end-of-container
243
+		if ($line === false)
244
+		{
245
+			// end-of-file or end-of-container
235 246
 		{
236 247
 			$this->component = false;
248
+		}
237 249
 			return;
238 250
 		}
239 251
 		$type = substr(trim($line),6);
@@ -309,7 +321,10 @@  discard block
 block discarded – undo
309 321
 			//error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')");
310 322
 			$this->parsevCalendar($data,$this->base,$this->charset);
311 323
 		}
312
-		if ($line) $this->unread_line($line);
324
+		if ($line)
325
+		{
326
+			$this->unread_line($line);
327
+		}
313 328
 
314 329
 		// advance to first element
315 330
 		$this->next();
@@ -438,7 +453,10 @@  discard block
 block discarded – undo
438 453
 ';
439 454
 	echo $GLOBALS['egw']->framework->header();
440 455
 	//$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics');
441
-	if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n";
456
+	if (!is_resource($ical_file))
457
+	{
458
+		echo "<pre>$ical_file</pre>\n";
459
+	}
442 460
 	//$calendar_ical = new calendar_ical();
443 461
 	//$calendar_ical->setSupportedFields('file');
444 462
 	$ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin'));
@@ -446,5 +464,8 @@  discard block
 block discarded – undo
446 464
 	{
447 465
 		echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n";
448 466
 	}
449
-	if (is_resource($ical_file)) fclose($ical_file);
450
-}
451 467
\ No newline at end of file
468
+	if (is_resource($ical_file))
469
+	{
470
+		fclose($ical_file);
471
+	}
472
+	}
452 473
\ No newline at end of file
Please login to merge, or discard this patch.
api/src/CalDAV/Handler.php 1 patch
Braces   +60 added lines, -15 removed lines patch added patch discarded remove patch
@@ -123,7 +123,10 @@  discard block
 block discarded – undo
123 123
 	function __construct($app, Api\CalDAV $caldav)
124 124
 	{
125 125
 		$this->app = $app;
126
-		if (!is_null($caldav->debug)) $this->debug = $caldav->debug;
126
+		if (!is_null($caldav->debug))
127
+		{
128
+			$this->debug = $caldav->debug;
129
+		}
127 130
 		$this->base_uri = $caldav->base_uri;
128 131
 		$this->caldav = $caldav;
129 132
 
@@ -282,11 +285,17 @@  discard block
 block discarded – undo
282 285
 	 */
283 286
 	function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false)
284 287
 	{
285
-		if (self::$path_extension) $id = basename($id,self::$path_extension);
288
+		if (self::$path_extension)
289
+		{
290
+			$id = basename($id,self::$path_extension);
291
+		}
286 292
 
287 293
 		if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app])
288 294
 		{
289
-			if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'");
295
+			if ($this->debug)
296
+			{
297
+				error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'");
298
+			}
290 299
 			return '403 Forbidden';		// no app rights
291 300
 		}
292 301
 		$extra_acl = $this->method2acl[$method];
@@ -295,12 +304,18 @@  discard block
 block discarded – undo
295 304
 		{
296 305
 			if ($return_no_access && !is_null($entry))
297 306
 			{
298
-				if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false");
307
+				if ($this->debug)
308
+				{
309
+					error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false");
310
+				}
299 311
 				$return_no_access = false;
300 312
 			}
301 313
 			else
302 314
 			{
303
-				if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null'));
315
+				if ($this->debug)
316
+				{
317
+					error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null'));
318
+				}
304 319
 				return !is_null($entry) ? '403 Forbidden' : '404 Not Found';
305 320
 			}
306 321
 		}
@@ -313,11 +328,17 @@  discard block
 block discarded – undo
313 328
 			{
314 329
 				$this->http_if_match = $_SERVER['HTTP_IF_MATCH'];
315 330
 				// strip of quotes around etag, if they exist, that way we allow etag with and without quotes
316
-				if ($this->http_if_match[0] == '"') $this->http_if_match = substr($this->http_if_match, 1, -1);
331
+				if ($this->http_if_match[0] == '"')
332
+				{
333
+					$this->http_if_match = substr($this->http_if_match, 1, -1);
334
+				}
317 335
 
318 336
 				if ($this->http_if_match !== $etag)
319 337
 				{
320
-					if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
338
+					if ($this->debug)
339
+					{
340
+						error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
341
+					}
321 342
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
322 343
 					$this->check_return_representation($options, $id);
323 344
 					return '412 Precondition Failed';
@@ -327,17 +348,26 @@  discard block
 block discarded – undo
327 348
 			{
328 349
 				$if_none_match = $_SERVER['HTTP_IF_NONE_MATCH'];
329 350
 				// strip of quotes around etag, if they exist, that way we allow etag with and without quotes
330
-				if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1);
351
+				if ($if_none_match[0] == '"')
352
+				{
353
+					$if_none_match = substr($if_none_match, 1, -1);
354
+				}
331 355
 
332 356
 				// if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date
333 357
 				if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match)
334 358
 				{
335
-					if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified");
359
+					if ($this->debug)
360
+					{
361
+						error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified");
362
+					}
336 363
 					return '304 Not Modified';
337 364
 				}
338 365
 				if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag))
339 366
 				{
340
-					if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
367
+					if ($this->debug)
368
+					{
369
+						error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
370
+					}
341 371
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
342 372
 					$this->check_return_representation($options, $id);
343 373
 					return '412 Precondition Failed';
@@ -376,7 +406,10 @@  discard block
 block discarded – undo
376 406
 
377 407
 			if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data']))
378 408
 			{
379
-				if (!$this->caldav->use_compression()) header('Content-Length: '.$this->caldav->bytes($options['data']));
409
+				if (!$this->caldav->use_compression())
410
+				{
411
+					header('Content-Length: '.$this->caldav->bytes($options['data']));
412
+				}
380 413
 				header('Content-Type: '.$options['mimetype']);
381 414
 				echo $options['data'];
382 415
 			}
@@ -412,7 +445,10 @@  discard block
 block discarded – undo
412 445
 		if (!array_key_exists($app,$handler_cache))
413 446
 		{
414 447
 			$class = $app.'_groupdav';
415
-			if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) return null;
448
+			if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app)))
449
+			{
450
+				return null;
451
+			}
416 452
 
417 453
 			$handler_cache[$app] = new $class($app, $groupdav);
418 454
 		}
@@ -474,7 +510,10 @@  discard block
 block discarded – undo
474 510
 						$matches = null;
475 511
 						if (preg_match('/address%20book\/([0-9.]+)/', $user_agent, $matches))
476 512
 						{
477
-							if ((int)$matches[1] < 868) $agent .= '_old';
513
+							if ((int)$matches[1] < 868)
514
+							{
515
+								$agent .= '_old';
516
+							}
478 517
 						}
479 518
 						break;
480 519
 					case 'kde':
@@ -575,7 +614,10 @@  discard block
 block discarded – undo
575 614
 		// --> as all clients dislike not getting an ETag for a PUT, we sending it again even not storing byte-by-byte
576 615
 		//if (get_class($this) == 'addressbook_groupdav' && in_array(self::get_agent(),array('thunderbird','lightning')))
577 616
 		{
578
-			if (is_null($etag)) $etag = $this->get_etag($entry);
617
+			if (is_null($etag))
618
+			{
619
+				$etag = $this->get_etag($entry);
620
+			}
579 621
 			header('ETag: "'.$etag.'"');
580 622
 		}
581 623
 
@@ -741,7 +783,10 @@  discard block
 block discarded – undo
741 783
 	 */
742 784
 	public function get_sync_token($path, $user, $token=null)
743 785
 	{
744
-		if (!isset($token)) $token = $this->getctag($path, $user);
786
+		if (!isset($token))
787
+		{
788
+			$token = $this->getctag($path, $user);
789
+		}
745 790
 
746 791
 		// never return current time, as more modifications might happen due to second granularity --> return 1sec less
747 792
 		if ($token >= (int)$GLOBALS['egw_info']['flags']['page_start_time'])
Please login to merge, or discard this patch.
api/src/CalDAV/Principals.php 1 patch
Braces   +116 added lines, -29 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		parent::__construct($app, $caldav);
51 51
 
52
-		if (!isset(self::$resources)) self::$resources = new resources_bo();
52
+		if (!isset(self::$resources))
53
+		{
54
+			self::$resources = new resources_bo();
55
+		}
53 56
 	}
54 57
 
55 58
 	/**
@@ -93,7 +96,10 @@  discard block
 block discarded – undo
93 96
 	{
94 97
 		unset($path);	// not used, but required by function signature
95 98
 
96
-		if (is_null($reports)) $reports = $this->supported_reports;
99
+		if (is_null($reports))
100
+		{
101
+			$reports = $this->supported_reports;
102
+		}
97 103
 
98 104
 		$supported = array();
99 105
 		foreach($reports as $name => $data)
@@ -264,7 +270,10 @@  discard block
 block discarded – undo
264 270
 		$requested_props = $options['other'];
265 271
 		while(($requested_prop = array_shift($requested_props)))
266 272
 		{
267
-			if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue;
273
+			if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1)
274
+			{
275
+				continue;
276
+			}
268 277
 
269 278
 			$prop_ns = $requested_prop['attrs']['namespace'];
270 279
 			$prop_name = $requested_prop['attrs']['name'];
@@ -303,7 +312,10 @@  discard block
 block discarded – undo
303 312
 			// find prop to expand
304 313
 			foreach($prop_files['files'][0]['props'] as $expand_prop)
305 314
 			{
306
-				if ($expand_prop['name'] === $prop_name) break;
315
+				if ($expand_prop['name'] === $prop_name)
316
+				{
317
+					break;
318
+				}
307 319
 			}
308 320
 			if ($expand_prop['name'] !== $prop_name || !is_array($expand_prop['val']) ||
309 321
 				$expand_prop['val'] && $expand_prop['val'][0]['name'] !== 'href')
@@ -319,10 +331,13 @@  discard block
 block discarded – undo
319 331
 			{
320 332
 				if ($prop['name'] == 'property' && $prop['depth'] == 2)
321 333
 				{
322
-					if (!is_array($options2['props']))	// is "all" initially
334
+					if (!is_array($options2['props']))
335
+					{
336
+						// is "all" initially
323 337
 					{
324 338
 						$options2['props'] = array();
325 339
 					}
340
+					}
326 341
 					$options2['props'][] = array(
327 342
 						'name' => $prop['attrs']['name'],
328 343
 						'xmlns' => isset($prop['attrs']['namespace']) ? $prop['attrs']['namespace'] : $prop['xmlns'],
@@ -330,7 +345,10 @@  discard block
 block discarded – undo
330 345
 				}
331 346
 			}
332 347
 			// put back evtl. read top-level property
333
-			if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop);
348
+			if ($prop && $prop['depth'] == 1)
349
+			{
350
+				array_unshift($requested_props, $prop);
351
+			}
334 352
 			$this->caldav->options = $options2;	// also modify global variable
335 353
 
336 354
 			// run regular profind to get requested 2.-level properties for each href
@@ -526,9 +544,12 @@  discard block
 block discarded – undo
526 544
 		// now filter out not matching "files"
527 545
 		foreach($files['files'] as $n => $resource)
528 546
 		{
529
-			if (count(explode('/', $resource['path'])) < 5)	// hack to only return principals, not the collections itself
547
+			if (count(explode('/', $resource['path'])) < 5)
548
+			{
549
+				// hack to only return principals, not the collections itself
530 550
 			{
531 551
 				unset($files['files'][$n]);
552
+			}
532 553
 				continue;
533 554
 			}
534 555
 			// match with $search_props
@@ -538,16 +559,26 @@  discard block
 block discarded – undo
538 559
 				// search resource for $search_prop
539 560
 				foreach($resource['props'] as $prop)
540 561
 				{
541
-					if ($prop['name'] === $search_prop['name']) break;
562
+					if ($prop['name'] === $search_prop['name'])
563
+					{
564
+						break;
565
+					}
542 566
 				}
543
-				if ($prop['name'] === $search_prop['name'])	// search_prop NOT found
567
+				if ($prop['name'] === $search_prop['name'])
568
+				{
569
+					// search_prop NOT found
544 570
 				{
545 571
 					foreach((array)$prop['val'] as $value)
546 572
 					{
547
-						if (is_array($value)) $value = $value['val'];	// eg. href prop
548
-						if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false)	// prop does match
573
+						if (is_array($value)) $value = $value['val'];
574
+				}
575
+				// eg. href prop
576
+						if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false)
577
+						{
578
+							// prop does match
549 579
 						{
550 580
 							++$matches;
581
+						}
551 582
 							//error_log("$matches: $resource[path]: $search_prop[name]=".array2string($prop['name'] !== $search_prop['name'] ? null : $prop['val'])." does match '$search_prop[match]'");
552 583
 							break;
553 584
 						}
@@ -749,7 +780,10 @@  discard block
 block discarded – undo
749 780
 		{
750 781
 			foreach($resource['props']['resourcetype']['val'] as $prop)
751 782
 			{
752
-				if ($prop['name'] == 'principal') continue 2;
783
+				if ($prop['name'] == 'principal')
784
+				{
785
+					continue 2;
786
+				}
753 787
 			}
754 788
 			unset($files['files'][$n]);	// not a principal --> do not return
755 789
 		}
@@ -903,7 +937,11 @@  discard block
 block discarded – undo
903 937
 	{
904 938
 		$addressbooks = array();
905 939
 		$ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
906
-		if (empty($ab_home_set)) $ab_home_set = 'P';	// personal addressbook
940
+		if (empty($ab_home_set))
941
+		{
942
+			$ab_home_set = 'P';
943
+		}
944
+		// personal addressbook
907 945
 		$addressbook_home_set = explode(',', $ab_home_set);
908 946
 		// replace symbolic id's with real nummeric id's
909 947
 		foreach(array(
@@ -917,10 +955,13 @@  discard block
 block discarded – undo
917 955
 				$addressbook_home_set[$key] = $id;
918 956
 			}
919 957
 		}
920
-		if (in_array('O',$addressbook_home_set))	// "all in one" from groupdav.php/addressbook/
958
+		if (in_array('O',$addressbook_home_set))
959
+		{
960
+			// "all in one" from groupdav.php/addressbook/
921 961
 		{
922 962
 			$addressbooks[] = '/';
923 963
 		}
964
+		}
924 965
 		foreach(array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id)
925 966
 		{
926 967
 			if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) &&
@@ -999,7 +1040,10 @@  discard block
 block discarded – undo
999 1040
 	 */
1000 1041
 	static public function url2uid($url, $only_type=null, $cn=null)
1001 1042
 	{
1002
-		if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto');
1043
+		if (!$only_type)
1044
+		{
1045
+			$only_type = array('users', 'groups', 'resources', 'locations', 'mailto');
1046
+		}
1003 1047
 
1004 1048
 		if ($url[0] == '/')
1005 1049
 		{
@@ -1009,7 +1053,10 @@  discard block
 block discarded – undo
1009 1053
 		{
1010 1054
 			list($schema, $rest) = explode(':', $url, 2);
1011 1055
 		}
1012
-		if (empty($rest)) return false;
1056
+		if (empty($rest))
1057
+		{
1058
+			return false;
1059
+		}
1013 1060
 
1014 1061
 		switch(strtolower($schema))
1015 1062
 		{
@@ -1056,9 +1103,12 @@  discard block
 block discarded – undo
1056 1103
 			case 'urn':
1057 1104
 				list($urn_type, $uid) = explode(':', $rest, 2);
1058 1105
 				list($type, $id, $install_id) = explode('-', $uid);
1059
-				if ($type == 'accounts' && empty($id))	// groups have a negative id, eg. "urn:uuid:accounts--1-..."
1106
+				if ($type == 'accounts' && empty($id))
1107
+				{
1108
+					// groups have a negative id, eg. "urn:uuid:accounts--1-..."
1060 1109
 				{
1061 1110
 					list($type, , $id_abs, $install_id) = explode('-', $uid);
1111
+				}
1062 1112
 					$id = -$id_abs;
1063 1113
 				}
1064 1114
 				// own urn
@@ -1072,7 +1122,10 @@  discard block
 block discarded – undo
1072 1122
 					else
1073 1123
 					{
1074 1124
 						static $calendar_bo=null;
1075
-						if (is_null($calendar_bo)) $calendar_bo = new calendar_bo();
1125
+						if (is_null($calendar_bo))
1126
+						{
1127
+							$calendar_bo = new calendar_bo();
1128
+						}
1076 1129
 						foreach($calendar_bo->resources as $letter => $info)
1077 1130
 						{
1078 1131
 							if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location')
@@ -1179,7 +1232,10 @@  discard block
 block discarded – undo
1179 1232
 		{
1180 1233
 			return null;
1181 1234
 		}
1182
-		if (is_null($is_location)) $is_location = self::resource_is_location($resource);
1235
+		if (is_null($is_location))
1236
+		{
1237
+			$is_location = self::resource_is_location($resource);
1238
+		}
1183 1239
 
1184 1240
 		$displayname = Api\Translation::convert($resource['name'],	Api\Translation::charset(), 'utf-8');
1185 1241
 
@@ -1225,7 +1281,10 @@  discard block
 block discarded – undo
1225 1281
 
1226 1282
 		if (!isset($cache[$res_id]))
1227 1283
 		{
1228
-			if (!isset(self::$resources)) self::$resources = new resources_bo();
1284
+			if (!isset(self::$resources))
1285
+			{
1286
+				self::$resources = new resources_bo();
1287
+			}
1229 1288
 
1230 1289
 			if (!($cache[$res_id] = self::$resources->read($res_id)))
1231 1290
 			{
@@ -1262,7 +1321,10 @@  discard block
 block discarded – undo
1262 1321
 	{
1263 1322
 		if (!isset(self::$all_resources))
1264 1323
 		{
1265
-			if (!isset(self::$resources)) self::$resources = new resources_bo($user);
1324
+			if (!isset(self::$resources))
1325
+			{
1326
+				self::$resources = new resources_bo($user);
1327
+			}
1266 1328
 
1267 1329
 			self::$all_resources = array();
1268 1330
 			$query = array(
@@ -1333,9 +1395,15 @@  discard block
 block discarded – undo
1333 1395
 		// required props per WebDAV ACL
1334 1396
 		foreach(array('alternate-URI-set', 'group-membership') as $name)
1335 1397
 		{
1336
-			if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name,'');
1398
+			if (!isset($props[$name]))
1399
+			{
1400
+				$props[$name] = Api\CalDAV::mkprop($name,'');
1401
+			}
1402
+		}
1403
+		if (!$principal_url)
1404
+		{
1405
+			$principal_url = $principal;
1337 1406
 		}
1338
-		if (!$principal_url) $principal_url = $principal;
1339 1407
 
1340 1408
 		$props['principal-URL'] = array(
1341 1409
 			Api\CalDAV::mkprop('href',$this->base_uri.'/principals/'.$principal.'/'));
@@ -1358,7 +1426,11 @@  discard block
 block discarded – undo
1358 1426
 	{
1359 1427
 		list($app,,$what) = explode('-', $type);
1360 1428
 
1361
-		if (true) $proxys = array();	// ignore parameter!
1429
+		if (true)
1430
+		{
1431
+			$proxys = array();
1432
+		}
1433
+		// ignore parameter!
1362 1434
 		list($account_type,$account) = explode('/', $principal);
1363 1435
 
1364 1436
 		switch($account_type)
@@ -1440,16 +1512,22 @@  discard block
 block discarded – undo
1440 1512
 		$set = array();
1441 1513
 		foreach($accounts as $account_id => $account_lid)
1442 1514
 		{
1443
-			if ($this->accounts->visible($account_lid))	// only add visible accounts, gives error in iCal otherwise
1515
+			if ($this->accounts->visible($account_lid))
1516
+			{
1517
+				// only add visible accounts, gives error in iCal otherwise
1444 1518
 			{
1445 1519
 				$set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.($account_id < 0 ? 'groups/' : 'users/').$account_lid.'/');
1446 1520
 			}
1521
+			}
1447 1522
 		}
1448 1523
 		if ($app_proxys)
1449 1524
 		{
1450 1525
 			foreach((array)$app_proxys as $app)
1451 1526
 			{
1452
-				if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue;
1527
+				if (!isset($GLOBALS['egw_info']['user']['apps'][$app]))
1528
+				{
1529
+					continue;
1530
+				}
1453 1531
 
1454 1532
 				switch($app)
1455 1533
 				{
@@ -1490,7 +1568,10 @@  discard block
 block discarded – undo
1490 1568
 					if (($rights & (EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) &&	// we only care for these rights
1491 1569
 						($account_id == $account || in_array($account_id, $memberships)))
1492 1570
 					{
1493
-						if (!isset($location_grants[$location])) $location_grants[$location] = 0;
1571
+						if (!isset($location_grants[$location]))
1572
+						{
1573
+							$location_grants[$location] = 0;
1574
+						}
1494 1575
 						$location_grants[$location] |= $rights;
1495 1576
 					}
1496 1577
 				}
@@ -1524,12 +1605,15 @@  discard block
 block discarded – undo
1524 1605
 		{
1525 1606
 			if ($account_id != $account && ($rights & Api\Acl::READ) &&
1526 1607
 				($account_lid = $this->accounts->id2name($account_id)) &&
1527
-				$this->accounts->visible($account_lid))	// only add visible accounts, gives error in iCal otherwise
1608
+				$this->accounts->visible($account_lid))
1609
+			{
1610
+				// only add visible accounts, gives error in iCal otherwise
1528 1611
 			{
1529 1612
 				$set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.
1530 1613
 					($account_id < 0 ? 'groups/' : 'users/').
1531 1614
 					$account_lid.'/'.$app.'-proxy-'.($rights & Api\Acl::EDIT ? 'write' : 'read').'/');
1532 1615
 			}
1616
+			}
1533 1617
 		}
1534 1618
 		return $set;
1535 1619
 	}
@@ -1621,7 +1705,10 @@  discard block
 block discarded – undo
1621 1705
 
1622 1706
 		if ($options['depth'])
1623 1707
 		{
1624
-			if (is_numeric($options['depth'])) --$options['depth'];
1708
+			if (is_numeric($options['depth']))
1709
+			{
1710
+				--$options['depth'];
1711
+			}
1625 1712
 			$files = array_merge($files, $this->propfind_users('','',$options),
1626 1713
 				$this->propfind_groups('','',$options));
1627 1714
 			if ($GLOBALS['egw_info']['user']['apps']['resources'])
Please login to merge, or discard this patch.
api/src/Translation.php 1 patch
Braces   +121 added lines, -31 removed lines patch added patch discarded remove patch
@@ -126,17 +126,23 @@  discard block
 block discarded – undo
126 126
 			}
127 127
 			return $charsets[$lang];
128 128
 		}
129
-		if (self::$system_charset)	// do we have a system-charset ==> return it
129
+		if (self::$system_charset)
130
+		{
131
+			// do we have a system-charset ==> return it
130 132
 		{
131 133
 			$charset = self::$system_charset;
132 134
 		}
135
+		}
133 136
 		else
134 137
 		{
135 138
 			// if no translations are loaded (system-startup) use a default, else lang('charset')
136 139
 			$charset = !self::$lang_arr ? 'utf-8' : strtolower(self::translate('charset'));
137 140
 		}
138 141
 		// in case no charset is set, default to utf-8
139
-		if (empty($charset) || $charset == 'charset') $charset = 'utf-8';
142
+		if (empty($charset) || $charset == 'charset')
143
+		{
144
+			$charset = 'utf-8';
145
+		}
140 146
 
141 147
 		// we need to set our charset as mbstring.internal_encoding if mbstring.func_overlaod > 0
142 148
 		// else we get problems for a charset is different from the default utf-8
@@ -195,8 +201,14 @@  discard block
 block discarded – undo
195 201
 			}
196 202
 			$apps = array('common');
197 203
 			// for eTemplate apps, load etemplate before app itself (allowing app to overwrite etemplate translations)
198
-			if (class_exists('EGroupware\\Api\\Etemplate', false) || class_exists('etemplate', false)) $apps[] = 'etemplate';
199
-			if ($GLOBALS['egw_info']['flags']['currentapp']) $apps[] = $GLOBALS['egw_info']['flags']['currentapp'];
204
+			if (class_exists('EGroupware\\Api\\Etemplate', false) || class_exists('etemplate', false))
205
+			{
206
+				$apps[] = 'etemplate';
207
+			}
208
+			if ($GLOBALS['egw_info']['flags']['currentapp'])
209
+			{
210
+				$apps[] = $GLOBALS['egw_info']['flags']['currentapp'];
211
+			}
200 212
 			// load instance specific translations last, so they can overwrite everything
201 213
 			$apps[] = 'custom';
202 214
 			self::add_app($apps);
@@ -224,7 +236,10 @@  discard block
 block discarded – undo
224 236
 			self::init();
225 237
 		}
226 238
 		$ret = $key;				// save key if we dont find a translation
227
-		if ($not_found) $ret .= $not_found;
239
+		if ($not_found)
240
+		{
241
+			$ret .= $not_found;
242
+		}
228 243
 
229 244
 		if (isset(self::$lang_arr[$key]))
230 245
 		{
@@ -271,9 +286,15 @@  discard block
 block discarded – undo
271 286
 	{
272 287
 		//error_log(__METHOD__."(".array2string($apps).", $lang) count(self::\$lang_arr)=".count(self::$lang_arr));
273 288
 		//$start = microtime(true);
274
-		if (!$lang) $lang = self::$userlang;
289
+		if (!$lang)
290
+		{
291
+			$lang = self::$userlang;
292
+		}
275 293
 		$tree_level = $instance_level = array();
276
-		if (!is_array($apps)) $apps = (array)$apps;
294
+		if (!is_array($apps))
295
+		{
296
+			$apps = (array)$apps;
297
+		}
277 298
 		foreach($apps as $key => $app)
278 299
 		{
279 300
 			if (!isset(self::$loaded_apps[$app]) || self::$loaded_apps[$app] != $lang && $app != 'common')
@@ -293,8 +314,14 @@  discard block
 block discarded – undo
293 314
 			}
294 315
 		}
295 316
 		// load all translations from cache at once
296
-		if ($tree_level) $tree_level = Cache::getTree(__CLASS__, $tree_level);
297
-		if ($instance_level) $instance_level = Cache::getInstance(__CLASS__, $instance_level);
317
+		if ($tree_level)
318
+		{
319
+			$tree_level = Cache::getTree(__CLASS__, $tree_level);
320
+		}
321
+		if ($instance_level)
322
+		{
323
+			$instance_level = Cache::getInstance(__CLASS__, $instance_level);
324
+		}
298 325
 
299 326
 		// merging loaded translations together
300 327
 		$updated_load_via = false;
@@ -361,7 +388,10 @@  discard block
 block discarded – undo
361 388
 	static function &load_app($app,$lang)
362 389
 	{
363 390
 		//$start = microtime(true);
364
-		if (is_null(self::$db)) self::init(false);
391
+		if (is_null(self::$db))
392
+		{
393
+			self::init(false);
394
+		}
365 395
 		$loaded = array();
366 396
 		foreach(self::$db->select(self::LANG_TABLE,'message_id,content',array(
367 397
 			'lang'		=> $lang,
@@ -467,7 +497,10 @@  discard block
 block discarded – undo
467 497
 				$cache['']['en'] = count($en_phrases);
468 498
 				foreach(array_keys(self::get_available_langs()) as $lang)
469 499
 				{
470
-					if ($lang == 'en') continue;
500
+					if ($lang == 'en')
501
+					{
502
+						continue;
503
+					}
471 504
 					$lang_phrases = array_keys(self::load_app_files(null, $lang, 'all-apps'));
472 505
 					$valid_phrases = array_intersect($lang_phrases, $en_phrases);
473 506
 					$cache[''][$lang] = count($valid_phrases);
@@ -484,7 +517,10 @@  discard block
 block discarded – undo
484 517
 						continue;
485 518
 					}
486 519
 					$en_phrases = array_keys(self::load_app_files(null, 'en', $app));
487
-					if (count($en_phrases) <= 2) continue;
520
+					if (count($en_phrases) <= 2)
521
+					{
522
+						continue;
523
+					}
488 524
 					$cache['en'][$app] = count($en_phrases);
489 525
 					$lang_phrases = array_keys(self::load_app_files(null, $_lang, $app));
490 526
 					$valid_phrases = array_intersect($lang_phrases, $en_phrases);
@@ -516,7 +552,10 @@  discard block
 block discarded – undo
516 552
 			// check if cache is NOT invalided by checking if we have a modification time for concerned lang-file
517 553
 			$time = Cache::getTree(__CLASS__, $file=self::get_lang_file($_app, $_lang));
518 554
 			// if we dont have one, cache has been invalidated and we need to load translations
519
-			if (!isset($time)) self::add_app($_app, $_lang);
555
+			if (!isset($time))
556
+			{
557
+				self::add_app($_app, $_lang);
558
+			}
520 559
 
521 560
 			$etag = self::max_lang_time();
522 561
 		}
@@ -568,7 +607,11 @@  discard block
 block discarded – undo
568 607
 		$loaded = array();
569 608
 		foreach($load_app == 'all-apps' ? scandir(EGW_SERVER_ROOT) : (array)$load_app as $app_dir)
570 609
 		{
571
-			if ($load_app == 'all-apps' && $app_dir=='..') continue; // do not try to break out of egw server root
610
+			if ($load_app == 'all-apps' && $app_dir=='..')
611
+			{
612
+				continue;
613
+			}
614
+			// do not try to break out of egw server root
572 615
 			if ($app_dir[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app_dir) ||
573 616
 				!@file_exists($file=self::get_lang_file($app_dir, $lang)) ||
574 617
 				!($f = fopen($file, 'r')))
@@ -587,9 +630,15 @@  discard block
 block discarded – undo
587 630
 			{
588 631
 				$line = explode("\t", trim($read));
589 632
 				++$line_nr;
590
-				if (count($line) != 4) continue;
633
+				if (count($line) != 4)
634
+				{
635
+					continue;
636
+				}
591 637
 				list($l_id,$l_app,$l_lang,$l_translation) = $line;
592
-				if ($l_lang != $lang) continue;
638
+				if ($l_lang != $lang)
639
+				{
640
+					continue;
641
+				}
593 642
 				if (!isset($just_app_file) && $l_app != $app)
594 643
 				{
595 644
 					// check if $l_app contained in file in $app_dir is mentioned in $load_via
@@ -603,8 +652,14 @@  discard block
 block discarded – undo
603 652
 						}
604 653
 						// if not update load_via accordingly and store it as config
605 654
 						//error_log(__METHOD__."() load_via does not contain $l_app => $app_dir");
606
-						if (!isset(self::$load_via[$l_app])) self::$load_via[$l_app] = array($l_app);
607
-						if (!is_array(self::$load_via[$l_app])) self::$load_via[$l_app] = array(self::$load_via[$l_app]);
655
+						if (!isset(self::$load_via[$l_app]))
656
+						{
657
+							self::$load_via[$l_app] = array($l_app);
658
+						}
659
+						if (!is_array(self::$load_via[$l_app]))
660
+						{
661
+							self::$load_via[$l_app] = array(self::$load_via[$l_app]);
662
+						}
608 663
 						self::$load_via[$l_app][] = $app_dir;
609 664
 						$updated_load_via = true;
610 665
 					}
@@ -671,7 +726,10 @@  discard block
 block discarded – undo
671 726
 
672 727
 			if ($translate)
673 728
 			{
674
-				if (is_null(self::$db)) self::init(false);
729
+				if (is_null(self::$db))
730
+				{
731
+					self::init(false);
732
+				}
675 733
 
676 734
 				foreach(self::$langs as $lang => $name)
677 735
 				{
@@ -704,10 +762,13 @@  discard block
 block discarded – undo
704 762
 	 */
705 763
 	static function lang2language($lang)
706 764
 	{
707
-		if (isset(self::$langs[$lang]))	// no need to query the DB
765
+		if (isset(self::$langs[$lang]))
766
+		{
767
+			// no need to query the DB
708 768
 		{
709 769
 			return self::$langs[$lang];
710 770
 		}
771
+		}
711 772
 		return self::$db->select(self::LANGUAGES_TABLE,'lang_name',array('lang_id' => $lang),__LINE__,__FILE__)->fetchColumn();
712 773
 	}
713 774
 
@@ -746,7 +807,10 @@  discard block
 block discarded – undo
746 807
 	 */
747 808
 	static function get_lang_file($app,$lang)
748 809
 	{
749
-		if ($app == 'common') $app = 'phpgwapi';
810
+		if ($app == 'common')
811
+		{
812
+			$app = 'phpgwapi';
813
+		}
750 814
 		return EGW_SERVER_ROOT.'/'.$app.'/'.self::LANG_DIR.'/'.self::LANGFILE_PREFIX.$lang.self::LANGFILE_EXTENSION;
751 815
 	}
752 816
 
@@ -809,9 +873,15 @@  discard block
 block discarded – undo
809 873
 	{
810 874
 		if ($check_to_from)
811 875
 		{
812
-			if ($from) $from = strtolower($from);
876
+			if ($from)
877
+			{
878
+				$from = strtolower($from);
879
+			}
813 880
 
814
-			if ($to) $to = strtolower($to);
881
+			if ($to)
882
+			{
883
+				$to = strtolower($to);
884
+			}
815 885
 
816 886
 			if (!$from)
817 887
 			{
@@ -936,7 +1006,10 @@  discard block
 block discarded – undo
936 1006
 	 */
937 1007
 	static function convert_jsonsafe($_data,$from=False)
938 1008
 	{
939
-		if ($from===false) $from = self::detect_encoding($_data);
1009
+		if ($from===false)
1010
+		{
1011
+			$from = self::detect_encoding($_data);
1012
+		}
940 1013
 
941 1014
 		$data = self::convert($_data, strtolower($from));
942 1015
 
@@ -1035,15 +1108,22 @@  discard block
 block discarded – undo
1035 1108
 	static function get_message_id($translation,$app=null,$lang=null)
1036 1109
 	{
1037 1110
 		$where = array('content '.self::$db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.self::$db->quote($translation));
1038
-		if ($app) $where['app_name'] = $app;
1039
-		if ($lang) $where['lang'] = $lang;
1111
+		if ($app)
1112
+		{
1113
+			$where['app_name'] = $app;
1114
+		}
1115
+		if ($lang)
1116
+		{
1117
+			$where['lang'] = $lang;
1118
+		}
1040 1119
 
1041 1120
 		$id = self::$db->select(self::LANG_TABLE,'message_id',$where,__LINE__,__FILE__)->fetchColumn();
1042 1121
 
1043 1122
 		// Check cache, since most things aren't in the DB anymore
1044 1123
 		if(!$id)
1045 1124
 		{
1046
-			$ids = array_filter(array_keys(self::$lang_arr), function($haystack) use($translation) {
1125
+			$ids = array_filter(array_keys(self::$lang_arr), function($haystack) use($translation)
1126
+			{
1047 1127
 				return stripos(self::$lang_arr[$haystack],$translation) !== false;
1048 1128
 			});
1049 1129
 			$id = array_shift($ids);
@@ -1060,10 +1140,17 @@  discard block
 block discarded – undo
1060 1140
 				}
1061 1141
 
1062 1142
 				// load all translations from cache at once
1063
-				if ($tree_level) $lang_arr = Cache::getTree(__CLASS__, $tree_level);
1064
-				if ($instance_level) $lang_arr = Cache::getInstance(__CLASS__, $instance_level);
1143
+				if ($tree_level)
1144
+				{
1145
+					$lang_arr = Cache::getTree(__CLASS__, $tree_level);
1146
+				}
1147
+				if ($instance_level)
1148
+				{
1149
+					$lang_arr = Cache::getInstance(__CLASS__, $instance_level);
1150
+				}
1065 1151
 				$lang_arr = $lang_arr[$app.':en'];
1066
-				$ids = array_filter(array_keys($lang_arr), function($haystack) use($translation, $lang_arr) {
1152
+				$ids = array_filter(array_keys($lang_arr), function($haystack) use($translation, $lang_arr)
1153
+				{
1067 1154
 					return stripos($lang_arr[$haystack],$translation) !== false;
1068 1155
 				});
1069 1156
 				$id = array_shift($ids);
@@ -1087,7 +1174,10 @@  discard block
 block discarded – undo
1087 1174
 		{
1088 1175
 			$list = array('utf-8', 'iso-8859-1', 'windows-1251'); // list may be extended
1089 1176
 
1090
-			if ($verify) array_unshift($list, $verify);
1177
+			if ($verify)
1178
+			{
1179
+				array_unshift($list, $verify);
1180
+			}
1091 1181
 
1092 1182
 			foreach ($list as $item)
1093 1183
 			{
Please login to merge, or discard this patch.
api/src/Acl.php 1 patch
Braces   +81 added lines, -20 removed lines patch added patch discarded remove patch
@@ -111,7 +111,10 @@  discard block
 block discarded – undo
111 111
 		else
112 112
 		{
113 113
 			$acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true);
114
-			if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups);
114
+			if (is_array($no_groups))
115
+			{
116
+				$acl_acc_list = array_diff($acl_acc_list,$no_groups);
117
+			}
115 118
 			array_unshift($acl_acc_list,$this->account_id);
116 119
 		}
117 120
 
@@ -149,7 +152,10 @@  discard block
 block discarded – undo
149 152
 	 */
150 153
 	function add($appname,$location,$rights)
151 154
 	{
152
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
155
+		if (!$appname)
156
+		{
157
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
158
+		}
153 159
 
154 160
 		$row = array(
155 161
 			'appname'  => $appname,
@@ -171,7 +177,10 @@  discard block
 block discarded – undo
171 177
 	 */
172 178
 	function delete($appname,$location)
173 179
 	{
174
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
180
+		if (!$appname)
181
+		{
182
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
183
+		}
175 184
 
176 185
 		foreach($this->data as $idx => $value)
177 186
 		{
@@ -209,10 +218,13 @@  discard block
 block discarded – undo
209 218
 			}
210 219
 		}
211 220
 		if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] &&
212
-			method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
221
+			method_exists($GLOBALS['egw'],'invalidate_session_cache'))
222
+		{
223
+			// egw object in setup is limited
213 224
 		{
214 225
 			$GLOBALS['egw']->invalidate_session_cache();
215 226
 		}
227
+		}
216 228
 		return $this->data;
217 229
 	}
218 230
 
@@ -240,7 +252,10 @@  discard block
 block discarded – undo
240 252
 		{
241 253
 			$this->read_repository();
242 254
 		}
243
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
255
+		if (!$appname)
256
+		{
257
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
258
+		}
244 259
 
245 260
 		if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny')
246 261
 		{
@@ -289,7 +304,10 @@  discard block
 block discarded – undo
289 304
 	 */
290 305
 	function get_specific_rights($location, $appname = '', $memberships=array())
291 306
 	{
292
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
307
+		if (!$appname)
308
+		{
309
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
310
+		}
293 311
 
294 312
 		if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny')
295 313
 		{
@@ -353,10 +371,13 @@  discard block
 block discarded – undo
353 371
 		),__LINE__,__FILE__);
354 372
 
355 373
 		if ($account_id == $GLOBALS['egw_info']['user']['account_id'] &&
356
-			method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
374
+			method_exists($GLOBALS['egw'],'invalidate_session_cache'))
375
+		{
376
+			// egw object in setup is limited
357 377
 		{
358 378
 			$GLOBALS['egw']->invalidate_session_cache();
359 379
 		}
380
+		}
360 381
 		return True;
361 382
 	}
362 383
 
@@ -387,11 +408,17 @@  discard block
 block discarded – undo
387 408
 				$where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id);
388 409
 			}
389 410
 		}
390
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
411
+		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
412
+		{
413
+			// egw object in setup is limited
391 414
 		{
392 415
 			$GLOBALS['egw']->invalidate_session_cache();
393 416
 		}
394
-		if ($app == '%' || $app == '%%') unset($where['acl_appname']);
417
+		}
418
+		if ($app == '%' || $app == '%%')
419
+		{
420
+			unset($where['acl_appname']);
421
+		}
395 422
 
396 423
 		$this->db->delete(self::TABLE,$where,__LINE__,__FILE__);
397 424
 
@@ -408,7 +435,10 @@  discard block
 block discarded – undo
408 435
 	 */
409 436
 	function get_specific_rights_for_account($account_id,$location,$appname='')
410 437
 	{
411
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
438
+		if (!$appname)
439
+		{
440
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
441
+		}
412 442
 
413 443
 		return $this->db->select(self::TABLE,'acl_rights',array(
414 444
 			'acl_location' => $location,
@@ -426,7 +456,10 @@  discard block
 block discarded – undo
426 456
 	 */
427 457
 	function get_all_rights($location,$appname='')
428 458
 	{
429
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
459
+		if (!$appname)
460
+		{
461
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
462
+		}
430 463
 
431 464
 		$rights = array();
432 465
 		foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array(
@@ -449,7 +482,10 @@  discard block
 block discarded – undo
449 482
 	 */
450 483
 	function get_all_location_rights($account_id,$appname='',$use_memberships=true)
451 484
 	{
452
-		if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp'];
485
+		if (!$appname)
486
+		{
487
+			$appname = $GLOBALS['egw_info']['flags']['currentapp'];
488
+		}
453 489
 
454 490
 		$accounts = array($account_id);
455 491
 		if ($use_memberships && (int)$account_id > 0)
@@ -553,7 +589,10 @@  discard block
 block discarded – undo
553 589
 	 */
554 590
 	function get_ids_for_location($location, $required, $app = '')
555 591
 	{
556
-		if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp'];
592
+		if (!$app)
593
+		{
594
+			$app = $GLOBALS['egw_info']['flags']['currentapp'];
595
+		}
557 596
 
558 597
 		$accounts = false;
559 598
 		foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array(
@@ -577,7 +616,10 @@  discard block
 block discarded – undo
577 616
 	 */
578 617
 	function get_locations_for_app($app='')
579 618
 	{
580
-		if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp'];
619
+		if (!$app)
620
+		{
621
+			$app = $GLOBALS['egw_info']['flags']['currentapp'];
622
+		}
581 623
 
582 624
 		$locations = false;
583 625
 		foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array(
@@ -613,7 +655,10 @@  discard block
 block discarded – undo
613 655
 			$account_id = get_account_id($accountid,$this->account_id);
614 656
 			$cache_accountid[$accountid] = $account_id;
615 657
 		}
616
-		if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true);
658
+		if ($use_memberships && (int)$account_id > 0)
659
+		{
660
+			$memberships = $GLOBALS['egw']->accounts->memberships($account_id, true);
661
+		}
617 662
 		$memberships[] = (int)$account_id;
618 663
 
619 664
 		$apps = array();
@@ -647,15 +692,24 @@  discard block
 block discarded – undo
647 692
 	 */
648 693
 	function get_grants($app='',$enum_group_acls=true,$user=null)
649 694
 	{
650
-		if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp'];
651
-		if (!$user) $user = $this->account_id;
695
+		if (!$app)
696
+		{
697
+			$app = $GLOBALS['egw_info']['flags']['currentapp'];
698
+		}
699
+		if (!$user)
700
+		{
701
+			$user = $this->account_id;
702
+		}
652 703
 
653 704
 		static $cache = array();	// some caching withing the request
654 705
 
655 706
 		$grants =& $cache[$app][$user];
656 707
 		if (!isset($grants))
657 708
 		{
658
-			if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true);
709
+			if ((int)$user > 0)
710
+			{
711
+				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
712
+			}
659 713
 			$memberships[] = $user;
660 714
 
661 715
 			$grants = $accounts = Array();
@@ -680,7 +734,11 @@  discard block
 block discarded – undo
680 734
 					// return the grant for each member of the group (false = also for no longer active users)
681 735
 					foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor)
682 736
 					{
683
-						if (!$grantor) continue;	// can happen if group has no members
737
+						if (!$grantor)
738
+						{
739
+							continue;
740
+						}
741
+						// can happen if group has no members
684 742
 
685 743
 						// Don't allow to override private with group ACL's!
686 744
 						$rights &= ~self::PRIVAT;
@@ -734,7 +792,10 @@  discard block
 block discarded – undo
734 792
 	 */
735 793
 	function get_location_grants($location,$app='')
736 794
 	{
737
-		if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp'];
795
+		if (!$app)
796
+		{
797
+			$app = $GLOBALS['egw_info']['flags']['currentapp'];
798
+		}
738 799
 
739 800
 		$locations = array();
740 801
 		foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array(
Please login to merge, or discard this patch.
api/src/Config.php 1 patch
Braces   +28 added lines, -8 removed lines patch added patch discarded remove patch
@@ -92,16 +92,23 @@  discard block
 block discarded – undo
92 92
 			}
93 93
 			foreach(self::$configs[$this->appname] as $name => $value)
94 94
 			{
95
-				if (!isset($this->config_data[$name]))	// has been deleted
95
+				if (!isset($this->config_data[$name]))
96
+				{
97
+					// has been deleted
96 98
 				{
97 99
 					self::save_value($name, null, $this->appname, false);
100
+				}
98 101
 					//self::$db->delete(self::TABLE,array('config_app'=>$this->appname,'config_name'=>$name),__LINE__,__FILE__);
99 102
 				}
100 103
 			}
101 104
 
102
-			if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
105
+			if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache'))
106
+			{
107
+				// egw object in setup is limited
103 108
 			{
104
-				$GLOBALS['egw']->invalidate_session_cache();	// in case egw_info is cached in the session (phpgwapi is in egw_info[server])
109
+				$GLOBALS['egw']->invalidate_session_cache();
110
+			}
111
+			// in case egw_info is cached in the session (phpgwapi is in egw_info[server])
105 112
 			}
106 113
 			self::$configs[$this->appname] = $this->config_data;
107 114
 
@@ -145,20 +152,30 @@  discard block
 block discarded – undo
145 152
 
146 153
 		if (!isset($value) || $value === '')
147 154
 		{
148
-			if (isset(self::$configs[$app])) unset(self::$configs[$app][$name]);
155
+			if (isset(self::$configs[$app]))
156
+			{
157
+				unset(self::$configs[$app][$name]);
158
+			}
149 159
 			self::$db->delete(self::TABLE,array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
150 160
 		}
151 161
 		else
152 162
 		{
153 163
 			self::$configs[$app][$name] = $value;
154
-			if(is_array($value)) $value = json_encode($value);
164
+			if(is_array($value))
165
+			{
166
+				$value = json_encode($value);
167
+			}
155 168
 			self::$db->insert(self::TABLE,array('config_value'=>$value),array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
156 169
 		}
157 170
 		if ($update_cache)
158 171
 		{
159
-			if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
172
+			if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache'))
173
+			{
174
+				// egw object in setup is limited
160 175
 			{
161
-				$GLOBALS['egw']->invalidate_session_cache();	// in case egw_info is cached in the session (phpgwapi is in egw_info[server])
176
+				$GLOBALS['egw']->invalidate_session_cache();
177
+			}
178
+			// in case egw_info is cached in the session (phpgwapi is in egw_info[server])
162 179
 			}
163 180
 			Cache::setInstance(__CLASS__, 'configs', self::$configs);
164 181
 		}
@@ -278,7 +295,10 @@  discard block
 block discarded – undo
278 295
 		{
279 296
 			foreach($config as $name => $value)
280 297
 			{
281
-				if (strpos($name, 'pass') !== false) continue;
298
+				if (strpos($name, 'pass') !== false)
299
+				{
300
+					continue;
301
+				}
282 302
 
283 303
 				if (in_array($name, $white_list['all']) || isset($white_list[$app]) && in_array($name, $white_list[$app]))
284 304
 				{
Please login to merge, or discard this patch.
api/src/DateTime.php 1 patch
Braces   +76 added lines, -18 removed lines patch added patch discarded remove patch
@@ -95,7 +95,11 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function __construct($time='now',DateTimeZone $tz=null,&$type=null)
97 97
 	{
98
-		if (is_null($tz)) $tz = self::$user_timezone;	// default user timezone
98
+		if (is_null($tz))
99
+		{
100
+			$tz = self::$user_timezone;
101
+		}
102
+		// default user timezone
99 103
 
100 104
 		switch(($type = gettype($time)))
101 105
 		{
@@ -108,7 +112,11 @@  discard block
 block discarded – undo
108 112
 				if (!(is_numeric($time) && ($time > 21000000 || $time < 19000000)))
109 113
 				{
110 114
 					$t_str = $time;
111
-					if (is_numeric($time) && strlen($time) == 8) $t_str .= 'T000000';	// 'Ymd' string used in calendar to represent a date
115
+					if (is_numeric($time) && strlen($time) == 8)
116
+					{
117
+						$t_str .= 'T000000';
118
+					}
119
+					// 'Ymd' string used in calendar to represent a date
112 120
 					// $time ending in a Z (Zulu or UTC time), is unterstood by DateTime class itself
113 121
 					try {
114 122
 						parent::__construct($t_str,$tz);
@@ -116,7 +124,10 @@  discard block
 block discarded – undo
116 124
 					}
117 125
 					catch(Exception $e) {
118 126
 						// if string is nummeric, ignore the exception and treat string as timestamp
119
-						if (!is_numeric($time)) throw $e;
127
+						if (!is_numeric($time))
128
+						{
129
+							throw $e;
130
+						}
120 131
 					}
121 132
 				}
122 133
 				$type = 'integer';
@@ -137,7 +148,9 @@  discard block
 block discarded – undo
137 148
 
138 149
 			case 'array':
139 150
 				parent::__construct('now',$tz);
140
-				if (isset($time['Y']))	// array format used in eTemplate
151
+				if (isset($time['Y']))
152
+				{
153
+					// array format used in eTemplate
141 154
 				{
142 155
 					$time = array(
143 156
 						'year'   => $time['Y'],
@@ -148,13 +161,17 @@  discard block
 block discarded – undo
148 161
 						'second' => $time['s'],
149 162
 					);
150 163
 				}
164
+				}
151 165
 				if (!empty($time['full']) && empty($time['year']))
152 166
 				{
153 167
 					$time['year']  = (int)substr($time['full'],0,4);
154 168
 					$time['month'] = (int)substr($time['full'],4,2);
155 169
 					$time['day']   = (int)substr($time['full'],6,2);
156 170
 				}
157
-				if (isset($time['year'])) $this->setDate((int)$time['year'],(int)$time['month'],isset($time['day']) ? (int)$time['day'] : (int)$time['mday']);
171
+				if (isset($time['year']))
172
+				{
173
+					$this->setDate((int)$time['year'],(int)$time['month'],isset($time['day']) ? (int)$time['day'] : (int)$time['mday']);
174
+				}
158 175
 				$this->setTime((int)$time['hour'],(int)$time['minute'],(int)$time['second']);
159 176
 				break;
160 177
 
@@ -178,7 +195,10 @@  discard block
 block discarded – undo
178 195
 	 */
179 196
 	public function add($interval)
180 197
 	{
181
-		if (is_string($interval)) $interval = DateInterval::createFromDateString($interval);
198
+		if (is_string($interval))
199
+		{
200
+			$interval = DateInterval::createFromDateString($interval);
201
+		}
182 202
 
183 203
 		parent::add($interval);
184 204
 	}
@@ -202,7 +222,10 @@  discard block
 block discarded – undo
202 222
 				$wstart = -($wday ? $wday-1 : 6);
203 223
 				break;
204 224
 		}
205
-		if ($wstart) $this->add($wstart.'days');
225
+		if ($wstart)
226
+		{
227
+			$this->add($wstart.'days');
228
+		}
206 229
 	}
207 230
 
208 231
 	/**
@@ -263,15 +286,27 @@  discard block
 block discarded – undo
263 286
 			}
264 287
 			elseif ($sday || $eday)
265 288
 			{
266
-				if ($sday) $start->add($sday.'days');
267
-				if ($eday) $end->add($eday.'days');
289
+				if ($sday)
290
+				{
291
+					$start->add($sday.'days');
292
+				}
293
+				if ($eday)
294
+				{
295
+					$end->add($eday.'days');
296
+				}
268 297
 			}
269 298
 			elseif ($sweek || $eweek)
270 299
 			{
271 300
 				$start->setWeekstart();
272
-				if ($sweek) $start->add($sweek.'weeks');
301
+				if ($sweek)
302
+				{
303
+					$start->add($sweek.'weeks');
304
+				}
273 305
 				$end->setWeekstart();
274
-				if ($eweek) $end->add($eweek.'weeks');
306
+				if ($eweek)
307
+				{
308
+					$end->add($eweek.'weeks');
309
+				}
275 310
 			}
276 311
 		}
277 312
 		// convert start + end from user to servertime for the filter
@@ -416,7 +451,10 @@  discard block
 block discarded – undo
416 451
 		}
417 452
 		$time->setUser();
418 453
 
419
-		if (is_null($type)) $type = $typeof;
454
+		if (is_null($type))
455
+		{
456
+			$type = $typeof;
457
+		}
420 458
 
421 459
 		//echo "<p>".__METHOD__."($time,$type) = ".print_r($format->format($type),true)."</p>\n";
422 460
 		return $time->format($type);
@@ -446,7 +484,10 @@  discard block
 block discarded – undo
446 484
 		}
447 485
 		$time->setServer();
448 486
 
449
-		if (is_null($type)) $type = $typeof;
487
+		if (is_null($type))
488
+		{
489
+			$type = $typeof;
490
+		}
450 491
 
451 492
 		//echo "<p>".__METHOD__."($time,$type) = ".print_r($format->format($type),true)."</p>\n";
452 493
 		return $time->format($type);
@@ -489,7 +530,10 @@  discard block
 block discarded – undo
489 530
 	public static function setUserPrefs($tz,$dateformat='',$timeformat='')
490 531
 	{
491 532
 		//echo "<p>".__METHOD__."('$tz','$dateformat','$timeformat') ".function_backtrace()."</p>\n";
492
-		if (!empty($dateformat)) self::$user_dateformat = $dateformat;
533
+		if (!empty($dateformat))
534
+		{
535
+			self::$user_dateformat = $dateformat;
536
+		}
493 537
 
494 538
 		switch($timeformat)
495 539
 		{
@@ -527,7 +571,10 @@  discard block
 block discarded – undo
527 571
 	 */
528 572
 	public static function tz_offset_s($time='now')
529 573
 	{
530
-		if (!($time instanceof DateTime)) $time = new DateTime($time);
574
+		if (!($time instanceof DateTime))
575
+		{
576
+			$time = new DateTime($time);
577
+		}
531 578
 
532 579
 		return self::$user_timezone->getOffset($time) - self::$server_timezone->getOffset($time);
533 580
 	}
@@ -635,9 +682,17 @@  discard block
 block discarded – undo
635 682
 		);
636 683
 		foreach(DateTimeZone::listIdentifiers() as $name)
637 684
 		{
638
-			if (in_array($name,$no_vtimezone)) continue;	// do NOT allow to set in EGroupware, as we have not VTIMEZONE component for it
685
+			if (in_array($name,$no_vtimezone))
686
+			{
687
+				continue;
688
+			}
689
+			// do NOT allow to set in EGroupware, as we have not VTIMEZONE component for it
639 690
 			list($continent) = explode('/',$name,2);
640
-			if (!isset($tzs[$continent])) continue;	// old depricated timezones
691
+			if (!isset($tzs[$continent]))
692
+			{
693
+				continue;
694
+			}
695
+			// old depricated timezones
641 696
 			$datetime = new DateTime('now',new DateTimeZone($name));
642 697
 			$tzs[$continent][$name] = str_replace(array('_','/'),array(' ',' / '),$name)."  ".$datetime->format();
643 698
 			unset($datetime);
@@ -676,10 +731,13 @@  discard block
 block discarded – undo
676 731
 		{
677 732
 			$user_tzs = array_merge(array($tz),$user_tzs);
678 733
 		}
679
-		if (!$user_tzs)	// if we have no user timezones, eg. user set no pref --> use server default
734
+		if (!$user_tzs)
735
+		{
736
+			// if we have no user timezones, eg. user set no pref --> use server default
680 737
 		{
681 738
 			$user_tzs = array($GLOBALS['egw_info']['server']['server_timezone']);
682 739
 		}
740
+		}
683 741
 		if ($extra && !in_array($extra,$user_tzs))
684 742
 		{
685 743
 			$user_tzs = array_merge(array($extra),$user_tzs);
Please login to merge, or discard this patch.
api/src/Categories.php 1 patch
Braces   +208 added lines, -52 removed lines patch added patch discarded remove patch
@@ -122,7 +122,10 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	function __construct($accountid='',$app_name = '')
124 124
 	{
125
-		if (!$app_name) $app_name = $GLOBALS['egw_info']['flags']['currentapp'];
125
+		if (!$app_name)
126
+		{
127
+			$app_name = $GLOBALS['egw_info']['flags']['currentapp'];
128
+		}
126 129
 
127 130
 		if ($accountid === self::GLOBAL_ACCOUNT ||
128 131
 			$accountid < 0 && $GLOBALS['egw']->accounts->exists($accountid) == 2)
@@ -138,10 +141,13 @@  discard block
 block discarded – undo
138 141
 		$this->app_name		= $app_name;
139 142
 		$this->db			= $GLOBALS['egw']->db;
140 143
 
141
-		if (is_null(self::$cache))	// should not be necessary, as cache is load and restored by egw object
144
+		if (is_null(self::$cache))
145
+		{
146
+			// should not be necessary, as cache is load and restored by egw object
142 147
 		{
143 148
 			self::init_cache();
144 149
 		}
150
+		}
145 151
 		if (is_null(self::$global_marker))
146 152
 		{
147 153
 			// as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8
@@ -189,7 +195,9 @@  discard block
 block discarded – undo
189 195
 		$cats = array();
190 196
 		foreach(self::$cache as $cat)
191 197
 		{
192
-			if ($filter) foreach($filter as $col => $val)
198
+			if ($filter)
199
+			{
200
+				foreach($filter as $col => $val)
193 201
 			{
194 202
 				if (!is_array($val) && $val[0] === '!')
195 203
 				{
@@ -197,10 +205,14 @@  discard block
 block discarded – undo
197 205
 					if (($col == 'name' || $col == 'description') && is_string($cat[$col]))
198 206
 					{
199 207
 						if ($cat[$col] == substr($val,1) || trim($cat[$col]) == substr($val,1)) continue 2;
208
+			}
200 209
 					}
201 210
 					else
202 211
 					{
203
-						if ($cat[$col] == substr($val,1)) continue 2;
212
+						if ($cat[$col] == substr($val,1))
213
+						{
214
+							continue 2;
215
+						}
204 216
 					}
205 217
 				}
206 218
 				elseif (is_array($val))
@@ -208,11 +220,17 @@  discard block
 block discarded – undo
208 220
 					// also match against trimmed database entry on name and description fields
209 221
 					if (($col == 'name' || $col == 'description') && is_string($cat[$col]))
210 222
 					{
211
-						if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) continue 2;
223
+						if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val))
224
+						{
225
+							continue 2;
226
+						}
212 227
 					}
213 228
 					else
214 229
 					{
215
-						if (!in_array($cat[$col],$val)) continue 2;
230
+						if (!in_array($cat[$col],$val))
231
+						{
232
+							continue 2;
233
+						}
216 234
 					}
217 235
 				}
218 236
 				else
@@ -220,16 +238,25 @@  discard block
 block discarded – undo
220 238
 					// also match against trimmed database entry on name and description fields
221 239
 					if (($col == 'name' || $col == 'description') && is_string($cat[$col]))
222 240
 					{
223
-						if ($cat[$col] != $val && trim($cat[$col]) != $val) continue 2;
241
+						if ($cat[$col] != $val && trim($cat[$col]) != $val)
242
+						{
243
+							continue 2;
244
+						}
224 245
 					}
225 246
 					else
226 247
 					{
227
-						if ($cat[$col] != $val) continue 2;
248
+						if ($cat[$col] != $val)
249
+						{
250
+							continue 2;
251
+						}
228 252
 					}
229 253
 				}
230 254
 			}
231 255
 			// check if certain parent required
232
-			if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) continue;
256
+			if ($parent_id && !in_array($cat['parent'],(array)$parent_id))
257
+			{
258
+				continue;
259
+			}
233 260
 
234 261
 			// return global categories just if $globals is set
235 262
 			if (!$globals && $cat['appname'] == self::GLOBAL_APPNAME)
@@ -247,30 +274,55 @@  discard block
 block discarded – undo
247 274
 			switch ($type)
248 275
 			{
249 276
 				case 'subs':
250
-					if (!$cat['parent']) continue 2;	// 2 for switch AND foreach!
277
+					if (!$cat['parent'])
278
+					{
279
+						continue 2;
280
+					}
281
+					// 2 for switch AND foreach!
251 282
 					break;
252 283
 				case 'mains':
253
-					if ($cat['parent']) continue 2;
284
+					if ($cat['parent'])
285
+					{
286
+						continue 2;
287
+					}
254 288
 					break;
255 289
 				case 'appandmains':
256
-					if ($cat['appname'] != $this->app_name || $cat['parent']) continue 2;
290
+					if ($cat['appname'] != $this->app_name || $cat['parent'])
291
+					{
292
+						continue 2;
293
+					}
257 294
 					break;
258 295
 				case 'appandsubs':
259
-					if ($cat['appname'] != $this->app_name || !$cat['parent']) continue 2;
296
+					if ($cat['appname'] != $this->app_name || !$cat['parent'])
297
+					{
298
+						continue 2;
299
+					}
260 300
 					break;
261 301
 				case 'noglobal':
262
-					if ($cat['appname'] == $this->app_name) continue 2;
302
+					if ($cat['appname'] == $this->app_name)
303
+					{
304
+						continue 2;
305
+					}
263 306
 					break;
264 307
 				case 'noglobalapp':
265
-					if ($cat['appname'] != $this->app_name || $cat['owner'] == (int)$this->account_id) continue 2;
308
+					if ($cat['appname'] != $this->app_name || $cat['owner'] == (int)$this->account_id)
309
+					{
310
+						continue 2;
311
+					}
266 312
 					break;
267 313
 			}
268 314
 
269 315
 			// check name and description for $query
270
-			if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false) continue;
316
+			if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false)
317
+			{
318
+				continue;
319
+			}
271 320
 
272 321
 			// check if last modified since
273
-			if ($lastmod > 0 && $cat['last_mod'] <= $lastmod) continue;
322
+			if ($lastmod > 0 && $cat['last_mod'] <= $lastmod)
323
+			{
324
+				continue;
325
+			}
274 326
 
275 327
 			$cat['data'] = $cat['data'] ? json_php_unserialize($cat['data'], true) : array();
276 328
 
@@ -281,13 +333,23 @@  discard block
 block discarded – undo
281 333
 			//error_log(__METHOD__."($type,$start,$limit,$query,$sort,$order,$globals,parent=$parent_id,$lastmod,$column) account_id=$this->account_id, appname=$this->app_name = FALSE");
282 334
 			return array();
283 335
 		}
284
-		if (!$sort) $sort = 'ASC';
336
+		if (!$sort)
337
+		{
338
+			$sort = 'ASC';
339
+		}
285 340
 		// order the entries if necessary (cache is already ordered in or default order: cat_main, cat_level, cat_name ASC)
286 341
 		if ($this->total_records > 1 && !empty($order) &&
287 342
 			preg_match('/^[a-zA-Z_(), ]+$/',$order) && preg_match('/^(ASC|DESC|asc|desc)$/',$sort))
288 343
 		{
289
-			if (strstr($order,'cat_data') !== false) $order = 'cat_data';	// sitemgr orders by round(cat_data)!
290
-			if (substr($order,0,4) == 'cat_') $order = substr($order,4);
344
+			if (strstr($order,'cat_data') !== false)
345
+			{
346
+				$order = 'cat_data';
347
+			}
348
+			// sitemgr orders by round(cat_data)!
349
+			if (substr($order,0,4) == 'cat_')
350
+			{
351
+				$order = substr($order,4);
352
+			}
291 353
 			$sign = strtoupper($sort) == 'DESC' ? -1 : 1;
292 354
 			usort($cats, function($a, $b) use ($order, $sign)
293 355
 			{
@@ -301,7 +363,10 @@  discard block
 block discarded – undo
301 363
 		// limit the number of returned rows
302 364
 		if ($limit)
303 365
 		{
304
-			if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
366
+			if (!is_int($limit))
367
+			{
368
+				$limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
369
+			}
305 370
 			$cats = array_slice($cats,(int)$start,$limit);
306 371
 		}
307 372
 		// return only a certain column (why not return is as value?)
@@ -334,15 +399,24 @@  discard block
 block discarded – undo
334 399
 	 */
335 400
 	function return_sorted_array($start=0,$limit=True,$query='',$sort='ASC',$order='cat_name',$globals=False, $parent_id=0,$unserialize_data=true,$filter=null)
336 401
 	{
337
-		if (!$sort)  $sort = 'ASC';
338
-		if (!$order) $order = 'cat_name';
402
+		if (!$sort)
403
+		{
404
+			$sort = 'ASC';
405
+		}
406
+		if (!$order)
407
+		{
408
+			$order = 'cat_name';
409
+		}
339 410
 
340 411
 		//error_log(__METHOD__."($start,$limit,$query,$sort,$order,globals=$globals,parent=$parent_id,$unserialize_data) account_id=$this->account_id, appname=$this->app_name: ".function_backtrace());
341 412
 
342 413
 		$parents = $cats = array();
343 414
 
344 415
 		// Cast parent_id to array, but only if there is one
345
-		if($parent_id !== false && $parent_id !== null) $parent_id = (array)$parent_id;
416
+		if($parent_id !== false && $parent_id !== null)
417
+		{
418
+			$parent_id = (array)$parent_id;
419
+		}
346 420
 		if (!($cats = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parent_id,-1,'',$filter,$unserialize_data)))
347 421
 		{
348 422
 			$cats = array();
@@ -352,7 +426,9 @@  discard block
 block discarded – undo
352 426
 			$parents[] = $cat['id'];
353 427
 		}
354 428
 
355
-		if($parent_id || !$cats) // Avoid wiping search results
429
+		if($parent_id || !$cats)
430
+		{
431
+			// Avoid wiping search results
356 432
 		{
357 433
 			// Go find the children
358 434
 			while (count($parents))
@@ -360,6 +436,7 @@  discard block
 block discarded – undo
360 436
 				if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data)))
361 437
 				{
362 438
 					break;
439
+		}
363 440
 				}
364 441
 				$parents = $children = array();
365 442
 				foreach($subs as $cat)
@@ -391,7 +468,10 @@  discard block
 block discarded – undo
391 468
 		// limit the number of returned rows
392 469
 		if ($limit)
393 470
 		{
394
-			if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
471
+			if (!is_int($limit))
472
+			{
473
+				$limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
474
+			}
395 475
 			$cats = array_slice($cats,(int)$start,$limit);
396 476
 		}
397 477
 		reset($cats);	// some old code (eg. sitemgr) relies on the array-pointer!
@@ -410,9 +490,15 @@  discard block
 block discarded – undo
410 490
 	 */
411 491
 	static function read($id)
412 492
 	{
413
-		if (is_null(self::$cache)) self::init_cache();
493
+		if (is_null(self::$cache))
494
+		{
495
+			self::init_cache();
496
+		}
414 497
 
415
-		if (!isset(self::$cache[$id])) return false;
498
+		if (!isset(self::$cache[$id]))
499
+		{
500
+			return false;
501
+		}
416 502
 
417 503
 		$cat = self::$cache[$id];
418 504
 		$cat['data'] = $cat['data'] ? ((($arr=json_php_unserialize($cat['data'], true)) !== false || $cat['data'] === 'b:0;') ?
@@ -475,8 +561,11 @@  discard block
 block discarded – undo
475 561
 	 * @return string truncated commaseparated list of category ids
476 562
 	 */
477 563
 	function check_list($needed, $cat_list)
478
- 	{
479
-		if (empty($cat_list)) return $cat_list;
564
+	{
565
+		if (empty($cat_list))
566
+		{
567
+			return $cat_list;
568
+		}
480 569
 		if (is_array($cat_list))
481 570
 		{
482 571
 			$cat_list = implode(',',$cat_list);
@@ -487,10 +576,13 @@  discard block
 block discarded – undo
487 576
 		{
488 577
 			foreach($cat_arr as $id=>$cat_id)
489 578
 			{
490
-				if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ))	// allow reading all global cats
579
+				if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ))
580
+				{
581
+					// allow reading all global cats
491 582
 				{
492 583
 					unset($cat_arr[$id]);
493 584
 				}
585
+				}
494 586
 			}
495 587
 			$cat_list = implode(',',$cat_arr);
496 588
 		}
@@ -596,9 +688,15 @@  discard block
 block discarded – undo
596 688
 				{
597 689
 					$update = array('cat_level' => $cat['level']-1);
598 690
 
599
-					if ($new_main) $update['cat_main'] = $new_main;
691
+					if ($new_main)
692
+					{
693
+						$update['cat_main'] = $new_main;
694
+					}
600 695
 
601
-					if ($cat['parent'] == $cat_id) $update['cat_parent'] = $new_parent;
696
+					if ($cat['parent'] == $cat_id)
697
+					{
698
+						$update['cat_parent'] = $new_parent;
699
+					}
602 700
 
603 701
 					$this->db->update(self::TABLE,$update,array(
604 702
 						'cat_id' => $cat['id'],
@@ -624,9 +722,13 @@  discard block
 block discarded – undo
624 722
 			'modify_subs' => $modify_subs,
625 723
 			'location'    => 'delete_category'
626 724
 		);
627
-		if($this->is_global($cat_id, true))	// true = application global (otherwise eg. global addressbook categories call all apps)
725
+		if($this->is_global($cat_id, true))
726
+		{
727
+			// true = application global (otherwise eg. global addressbook categories call all apps)
628 728
 		{
629
-			Hooks::process($GLOBALS['hook_values'],False,True);  // called for every app now, not only enabled ones)
729
+			Hooks::process($GLOBALS['hook_values'],False,True);
730
+		}
731
+		// called for every app now, not only enabled ones)
630 732
 		}
631 733
 		else
632 734
 		{
@@ -682,12 +784,22 @@  discard block
 block discarded – undo
682 784
 		// check if we try to move an element down its own subtree, which will fail
683 785
 		foreach ($this->return_sorted_array('',False,'','','',False, $values['id']) as $cat)
684 786
 		{
685
-			if ($cat['id'] == $values['parent']) return lang('Cannot set a category as parent, which is part of this categorys subtree!');
787
+			if ($cat['id'] == $values['parent'])
788
+			{
789
+				return lang('Cannot set a category as parent, which is part of this categorys subtree!');
790
+			}
686 791
 		}
687 792
 		// check if we try to be our own parent
688
-		if ($values['parent']==$values['id']) return lang('Cannot set this cat as its own parent!'); // deny to be our own parent
793
+		if ($values['parent']==$values['id'])
794
+		{
795
+			return lang('Cannot set this cat as its own parent!');
796
+		}
797
+		// deny to be our own parent
689 798
 		// check if parent still exists
690
-		if ((int)$values['parent']>0 && !$this->read($values['parent'])) return lang('Chosen parent category no longer exists');
799
+		if ((int)$values['parent']>0 && !$this->read($values['parent']))
800
+		{
801
+			return lang('Chosen parent category no longer exists');
802
+		}
691 803
 		return true;
692 804
 	}
693 805
 
@@ -704,7 +816,10 @@  discard block
 block discarded – undo
704 816
 		if (isset($values['old_parent']) && (int)$values['old_parent'] != (int)$values['parent'])
705 817
 		{
706 818
 			$ret = $this->check_consistency4update($values);
707
-			if ($ret !== true) throw new Exception\WrongUserinput($ret);
819
+			if ($ret !== true)
820
+			{
821
+				throw new Exception\WrongUserinput($ret);
822
+			}
708 823
 			// everything seems in order -> proceed
709 824
 			$values['level'] = ($values['parent'] ? $this->id2name($values['parent'],'level')+1:0);
710 825
 			$this->adapt_level_in_subtree($values);
@@ -717,7 +832,10 @@  discard block
 block discarded – undo
717 832
 			if ($values['parent'] > 0)
718 833
 			{
719 834
 				$ret = $this->check_consistency4update($values);
720
-				if ($ret !== true) throw new Exception\WrongUserinput($ret);
835
+				if ($ret !== true)
836
+				{
837
+					throw new Exception\WrongUserinput($ret);
838
+				}
721 839
 
722 840
 				// everything seems in order -> proceed
723 841
 				$values['main']  = $this->id2name($values['parent'],'main');
@@ -773,7 +891,10 @@  discard block
 block discarded – undo
773 891
 	{
774 892
 		static $cache = array();	// a litle bit of caching
775 893
 
776
-		if (isset($cache[$cat_name])) return $cache[$cat_name];
894
+		if (isset($cache[$cat_name]))
895
+		{
896
+			return $cache[$cat_name];
897
+		}
777 898
 
778 899
 		if ($strip === true)
779 900
 		{
@@ -826,7 +947,11 @@  discard block
 block discarded – undo
826 947
 	 */
827 948
 	static function is_global($cat,$application_global=false)
828 949
 	{
829
-		if (!is_array($cat) && !($cat = self::read($cat))) return null;	// cat not found
950
+		if (!is_array($cat) && !($cat = self::read($cat)))
951
+		{
952
+			return null;
953
+		}
954
+		// cat not found
830 955
 
831 956
 		$global_owner = false;
832 957
 		foreach(explode(',',$cat['owner']) as $owner)
@@ -848,10 +973,19 @@  discard block
 block discarded – undo
848 973
 	 */
849 974
 	static function id2name($cat_id=0, $item='name')
850 975
 	{
851
-		if(!$cat_id) return '--';
852
-		if (!$item) $item = 'parent';
976
+		if(!$cat_id)
977
+		{
978
+			return '--';
979
+		}
980
+		if (!$item)
981
+		{
982
+			$item = 'parent';
983
+		}
853 984
 
854
-		if (is_null(self::$cache)) self::init_cache();
985
+		if (is_null(self::$cache))
986
+		{
987
+			self::init_cache();
988
+		}
855 989
 
856 990
 		$cat = self::$cache[$cat_id];
857 991
 		if ($item == 'path')
@@ -892,7 +1026,10 @@  discard block
 block discarded – undo
892 1026
 		if ($cat_name)
893 1027
 		{
894 1028
 			$filter['name'] = $cat_name;
895
-			if ($cat_id) $filter['id'] = '!'.(int)$cat_id;
1029
+			if ($cat_id)
1030
+			{
1031
+				$filter['id'] = '!'.(int)$cat_id;
1032
+			}
896 1033
 		}
897 1034
 		elseif ($cat_id)
898 1035
 		{
@@ -921,7 +1058,10 @@  discard block
 block discarded – undo
921 1058
 	{
922 1059
 		$where = array('cat_owner' => $owner);
923 1060
 
924
-		if ($app) $where['cat_appname'] = $app;
1061
+		if ($app)
1062
+		{
1063
+			$where['cat_appname'] = $app;
1064
+		}
925 1065
 
926 1066
 		if ((int)$to)
927 1067
 		{
@@ -967,7 +1107,11 @@  discard block
 block discarded – undo
967 1107
 				false,'ORDER BY cat_main, cat_level, cat_name ASC') as $cat)
968 1108
 			{
969 1109
 				$cat = Db::strip_array_keys($cat,'cat_');
970
-				if ($cat['appname'] == '*update*') continue;	// --> ignore update marker
1110
+				if ($cat['appname'] == '*update*')
1111
+				{
1112
+					continue;
1113
+				}
1114
+				// --> ignore update marker
971 1115
 				$cat['app_name'] = $cat['appname'];
972 1116
 				// backlink children to their parent
973 1117
 				if ($cat['parent'])
@@ -1058,7 +1202,10 @@  discard block
 block discarded – undo
1058 1202
 		// ACL check
1059 1203
 		$cats = $GLOBALS['egw']->categories->check_list(Acl::READ, $_cats);
1060 1204
 
1061
-		if (!$cats) return null;
1205
+		if (!$cats)
1206
+		{
1207
+			return null;
1208
+		}
1062 1209
 
1063 1210
 		if (isset($cat2color[$cats]))
1064 1211
 		{
@@ -1090,7 +1237,10 @@  discard block
 block discarded – undo
1090 1237
 	 */
1091 1238
 	public static function delete_account($account_id, $new_owner=null)
1092 1239
 	{
1093
-		if (is_null(self::$cache)) self::init_cache();
1240
+		if (is_null(self::$cache))
1241
+		{
1242
+			self::init_cache();
1243
+		}
1094 1244
 
1095 1245
 		$deleted = 0;
1096 1246
 		$cat = null;
@@ -1110,7 +1260,10 @@  discard block
 block discarded – undo
1110 1260
 				else
1111 1261
 				{
1112 1262
 					unset($owners[$owner_key]);
1113
-					if ($new_owner && $account_id > 0) $owners[] = $new_owner;
1263
+					if ($new_owner && $account_id > 0)
1264
+					{
1265
+						$owners[] = $new_owner;
1266
+					}
1114 1267
 					$data['owner'] = implode(',', $owners);
1115 1268
 					// app_name have to match cat to update!
1116 1269
 					if (!isset($cat) || $cat->app_name != $data['appname'])
@@ -1132,7 +1285,10 @@  discard block
 block discarded – undo
1132 1285
 	 */
1133 1286
 	public static function delete_orphans()
1134 1287
 	{
1135
-		if (is_null(self::$cache)) self::init_cache();
1288
+		if (is_null(self::$cache))
1289
+		{
1290
+			self::init_cache();
1291
+		}
1136 1292
 
1137 1293
 		$checked = array();
1138 1294
 		$deleted = 0;
Please login to merge, or discard this patch.