Completed
Push — 17.1 ( 8c3b94...29ee37 )
by Ralf
20:39 queued 11:58
created
api/src/Json/Exception.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,4 +20,6 @@
 block discarded – undo
20 20
  *
21 21
  * As you get this only by an error in the code or during development, the message does not need to be translated
22 22
  */
23
-class Exception extends Api\Exception\WrongParameter { }
23
+class Exception extends Api\Exception\WrongParameter
24
+{
25
+}
Please login to merge, or discard this patch.
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/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/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/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.
api/src/Link/Storage.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -302,7 +302,10 @@
 block discarded – undo
302 302
 			}
303 303
 			if ($owner)
304 304
 			{
305
-				if ($app) $where = array($where);
305
+				if ($app)
306
+				{
307
+					$where = array($where);
308
+				}
306 309
 				$where['link_owner'] = $owner;
307 310
 			}
308 311
 		}
Please login to merge, or discard this patch.
api/src/loader/common.php 1 patch
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 {
48 48
 	static $func_overload = null;
49 49
 
50
-	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
50
+	if (is_null($func_overload))
51
+	{
52
+		$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
53
+	}
51 54
 
52 55
 	return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
53 56
 }
@@ -64,7 +67,10 @@  discard block
 block discarded – undo
64 67
 {
65 68
 	static $func_overload = null;
66 69
 
67
-	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
70
+	if (is_null($func_overload))
71
+	{
72
+		$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
73
+	}
68 74
 
69 75
 	if (is_null($len))
70 76
 	{
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 			{
131 137
 				$personal = str_replace('\\', '', substr($personal, 1, -1));
132 138
 			}
133
-			if (empty($host)) $host = $default_host;
139
+			if (empty($host))
140
+			{
141
+				$host = $default_host;
142
+			}
134 143
 
135 144
 			$addresses[] = (object)array_diff(array(
136 145
 				'mailbox'  => $mailbox,
@@ -153,13 +162,19 @@  discard block
 block discarded – undo
153 162
 	 */
154 163
 	function imap_rfc822_write_address($mailbox, $host, $personal)
155 164
 	{
156
-		if (is_array($personal))  $personal = implode(' ', $personal);
165
+		if (is_array($personal))
166
+		{
167
+			$personal = implode(' ', $personal);
168
+		}
157 169
 
158 170
 		//if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal))	// that's how I read the rfc(2)822
159
-		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))	// but quoting is never wrong, so quote more then necessary
171
+		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))
172
+		{
173
+			// but quoting is never wrong, so quote more then necessary
160 174
 		{
161 175
 			$personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"';
162 176
 		}
177
+		}
163 178
 		return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : '');
164 179
 	}
165 180
 }
@@ -366,7 +381,9 @@  discard block
 block discarded – undo
366 381
 	return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']);
367 382
 }
368 383
 
369
-if (!function_exists('lang') || defined('NO_LANG'))	// setup declares an own version
384
+if (!function_exists('lang') || defined('NO_LANG'))
385
+{
386
+	// setup declares an own version
370 387
 {
371 388
 	/**
372 389
 	 * function to handle multilanguage support
@@ -380,6 +397,7 @@  discard block
 block discarded – undo
380 397
 		if(!is_array($vars))
381 398
 		{
382 399
 			$vars = func_get_args();
400
+}
383 401
 			array_shift($vars);	// remove $key
384 402
 		}
385 403
 		return Api\Translation::translate($key,$vars);
Please login to merge, or discard this patch.