Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
api/src/Mail/Smime/PassphraseMissing.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 PassphraseMissing extends Api\Exception\AssertionFailed { }
23
+class PassphraseMissing extends Api\Exception\AssertionFailed
24
+{
25
+}
Please login to merge, or discard this patch.
api/src/Cache.php 2 patches
Spacing   +71 added lines, -73 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @var array
84 84
 	 */
85
-	static $default_provider;	// = array('EGroupware\Api\Cache\Files');// array('EGroupware\Api\Cache\Memcache','localhost');
85
+	static $default_provider; // = array('EGroupware\Api\Cache\Files');// array('EGroupware\Api\Cache\Memcache','localhost');
86 86
 
87 87
 	/**
88 88
 	 * Maximum expiration time, if set unlimited expiration (=0) or bigger expiration times are replaced with that time
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
109 109
 	 * @return boolean true if data could be stored, false otherwise incl. key already existed
110 110
 	 */
111
-	static public function addCache($level,$app,$location,$data,$expiration=0)
111
+	static public function addCache($level, $app, $location, $data, $expiration = 0)
112 112
 	{
113 113
 		//error_log(__METHOD__."('$level','$app','$location',".array2string($data).",$expiration)");
114
-		switch($level)
114
+		switch ($level)
115 115
 		{
116 116
 			case self::SESSION:
117 117
 			case self::REQUEST:
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 				{
130 130
 					$expiration = self::$max_expiration;
131 131
 				}
132
-				return $provider->add(self::keys($level,$app,$location),$data,$expiration);
132
+				return $provider->add(self::keys($level, $app, $location), $data, $expiration);
133 133
 		}
134 134
 		throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
135 135
 	}
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
145 145
 	 * @return boolean true if data could be stored, false otherwise
146 146
 	 */
147
-	static public function setCache($level,$app,$location,$data,$expiration=0)
147
+	static public function setCache($level, $app, $location, $data, $expiration = 0)
148 148
 	{
149 149
 		//error_log(__METHOD__."('$level','$app','$location',".array2string($data).",$expiration)");
150
-		switch($level)
150
+		switch ($level)
151 151
 		{
152 152
 			case self::SESSION:
153 153
 			case self::REQUEST:
154
-				return call_user_func(array(__CLASS__,'set'.$level),$app,$location,$data,$expiration);
154
+				return call_user_func(array(__CLASS__, 'set'.$level), $app, $location, $data, $expiration);
155 155
 
156 156
 			case self::INSTANCE:
157 157
 			case self::TREE:
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				{
166 166
 					$expiration = self::$max_expiration;
167 167
 				}
168
-				return $provider->set(self::keys($level,$app,$location),$data,$expiration);
168
+				return $provider->set(self::keys($level, $app, $location), $data, $expiration);
169 169
 		}
170 170
 		throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
171 171
 	}
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 	 * @return mixed NULL if data not found in cache (and no callback specified) or
183 183
 	 * 	if $location is an array: location => data pairs for existing location-data, non-existing is not returned
184 184
 	 */
185
-	static public function getCache($level,$app,$location,$callback=null,array $callback_params=array(),$expiration=0)
185
+	static public function getCache($level, $app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
186 186
 	{
187
-		switch($level)
187
+		switch ($level)
188 188
 		{
189 189
 			case self::SESSION:
190 190
 			case self::REQUEST:
191
-				foreach((array)$location as $l)
191
+				foreach ((array)$location as $l)
192 192
 				{
193
-					$data[$l] = call_user_func(array(__CLASS__,'get'.$level),$app,$l,$callback,$callback_params,$expiration);
193
+					$data[$l] = call_user_func(array(__CLASS__, 'get'.$level), $app, $l, $callback, $callback_params, $expiration);
194 194
 				}
195 195
 				return is_array($location) ? $data : $data[$l];
196 196
 
@@ -210,34 +210,34 @@  discard block
 block discarded – undo
210 210
 						}
211 211
 						if (is_a($provider, 'EGroupware\Api\Cache\ProviderMultiple'))
212 212
 						{
213
-							$data = $provider->mget($keys=self::keys($level,$app,$location));
213
+							$data = $provider->mget($keys = self::keys($level, $app, $location));
214 214
 						}
215 215
 						else	// default implementation calls get multiple times
216 216
 						{
217 217
 							$data = array();
218
-							foreach($location as $l)
218
+							foreach ($location as $l)
219 219
 							{
220
-								$data[$l] = $provider->get($keys=self::keys($level,$app,$l));
220
+								$data[$l] = $provider->get($keys = self::keys($level, $app, $l));
221 221
 								if (!isset($data[$l])) unset($data[$l]);
222 222
 							}
223 223
 						}
224 224
 					}
225 225
 					else
226 226
 					{
227
-						$data = $provider->get($keys=self::keys($level,$app,$location));
227
+						$data = $provider->get($keys = self::keys($level, $app, $location));
228 228
 						if (is_null($data) && !is_null($callback))
229 229
 						{
230
-							$data = call_user_func_array($callback,$callback_params);
230
+							$data = call_user_func_array($callback, $callback_params);
231 231
 							// limit expiration to configured maximum time
232 232
 							if (isset(self::$max_expiration) && (!$expiration || $expiration > self::$max_expiration))
233 233
 							{
234 234
 								$expiration = self::$max_expiration;
235 235
 							}
236
-							$provider->set($keys,$data,$expiration);
236
+							$provider->set($keys, $data, $expiration);
237 237
 						}
238 238
 					}
239 239
 				}
240
-				catch(Exception $e) {
240
+				catch (Exception $e) {
241 241
 					unset($e);
242 242
 					$data = null;
243 243
 				}
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 	 * @param string $location location name for data
255 255
 	 * @return boolean true if data was set, false if not (like isset())
256 256
 	 */
257
-	static public function unsetCache($level,$app,$location)
257
+	static public function unsetCache($level, $app, $location)
258 258
 	{
259
-		switch($level)
259
+		switch ($level)
260 260
 		{
261 261
 			case self::SESSION:
262 262
 			case self::REQUEST:
263
-				return call_user_func(array(__CLASS__,'unset'.$level),$app,$location);
263
+				return call_user_func(array(__CLASS__, 'unset'.$level), $app, $location);
264 264
 
265 265
 			case self::INSTANCE:
266 266
 			case self::TREE:
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				{
270 270
 					return false;
271 271
 				}
272
-				return $provider->delete(self::keys($level,$app,$location));
272
+				return $provider->delete(self::keys($level, $app, $location));
273 273
 		}
274 274
 		throw new Exception\WrongParameter(__METHOD__."() unknown level '$level'!");
275 275
 	}
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
284 284
 	 * @return boolean true if data could be stored, false otherwise
285 285
 	 */
286
-	static public function setTree($app,$location,$data,$expiration=0)
286
+	static public function setTree($app, $location, $data, $expiration = 0)
287 287
 	{
288 288
 		//error_log(__METHOD__."('$app','$location',".array2string($data).",$expiration)");
289
-		return self::setCache(self::TREE,$app,$location,$data,$expiration);
289
+		return self::setCache(self::TREE, $app, $location, $data, $expiration);
290 290
 	}
291 291
 
292 292
 	/**
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
300 300
 	 * @return mixed NULL if data not found in cache (and no callback specified)
301 301
 	 */
302
-	static public function getTree($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
302
+	static public function getTree($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
303 303
 	{
304
-		return self::getCache(self::TREE,$app,$location,$callback,$callback_params,$expiration);
304
+		return self::getCache(self::TREE, $app, $location, $callback, $callback_params, $expiration);
305 305
 	}
306 306
 
307 307
 	/**
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 * @param string $location location name for data
312 312
 	 * @return boolean true if data was set, false if not (like isset())
313 313
 	 */
314
-	static public function unsetTree($app,$location)
314
+	static public function unsetTree($app, $location)
315 315
 	{
316
-		return self::unsetCache(self::TREE,$app,$location);
316
+		return self::unsetCache(self::TREE, $app, $location);
317 317
 	}
318 318
 
319 319
 	/**
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
326 326
 	 * @return boolean true if data could be stored, false otherwise
327 327
 	 */
328
-	static public function setInstance($app,$location,$data,$expiration=0)
328
+	static public function setInstance($app, $location, $data, $expiration = 0)
329 329
 	{
330
-		return self::setCache(self::INSTANCE,$app,$location,$data,$expiration);
330
+		return self::setCache(self::INSTANCE, $app, $location, $data, $expiration);
331 331
 	}
332 332
 
333 333
 	/**
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
341 341
 	 * @return mixed NULL if data not found in cache (and no callback specified)
342 342
 	 */
343
-	static public function getInstance($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
343
+	static public function getInstance($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
344 344
 	{
345
-		return self::getCache(self::INSTANCE,$app,$location,$callback,$callback_params,$expiration);
345
+		return self::getCache(self::INSTANCE, $app, $location, $callback, $callback_params, $expiration);
346 346
 	}
347 347
 
348 348
 	/**
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 	 * @param string $location location name for data
353 353
 	 * @return boolean true if data was set, false if not (like isset())
354 354
 	 */
355
-	static public function unsetInstance($app,$location)
355
+	static public function unsetInstance($app, $location)
356 356
 	{
357
-		return self::unsetCache(self::INSTANCE,$app,$location);
357
+		return self::unsetCache(self::INSTANCE, $app, $location);
358 358
 	}
359 359
 
360 360
 	/**
@@ -371,18 +371,18 @@  discard block
 block discarded – undo
371 371
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
372 372
 	 * @return boolean true if data could be stored, false otherwise
373 373
 	 */
374
-	static public function setSession($app,$location,$data,$expiration=0)
374
+	static public function setSession($app, $location, $data, $expiration = 0)
375 375
 	{
376 376
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
377 377
 		{
378 378
 			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
379
-			return false;	// can no longer store something in the session, eg. because commit_session() was called
379
+			return false; // can no longer store something in the session, eg. because commit_session() was called
380 380
 		}
381 381
 		$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = $data;
382 382
 
383 383
 		if ($expiration > 0)
384 384
 		{
385
-			$_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location] = time()+$expiration;
385
+			$_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location] = time() + $expiration;
386 386
 		}
387 387
 
388 388
 		return true;
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 	 * @param int $expiration =0 expiration time in seconds, default 0 = never
401 401
 	 * @return mixed NULL if data not found in cache (and no callback specified)
402 402
 	 */
403
-	static public function &getSession($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
403
+	static public function &getSession($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
404 404
 	{
405 405
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
406 406
 		{
407 407
 			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
408
-			return null;	// can no longer store something in the session, eg. because commit_session() was called
408
+			return null; // can no longer store something in the session, eg. because commit_session() was called
409 409
 		}
410 410
 		// check if entry is expired and clean it up in that case
411 411
 		if (isset($_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location]) &&
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		}
417 417
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]) && !is_null($callback))
418 418
 		{
419
-			$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = call_user_func_array($callback,$callback_params);
419
+			$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = call_user_func_array($callback, $callback_params);
420 420
 		}
421 421
 		return $_SESSION[Session::EGW_APPSESSION_VAR][$app][$location];
422 422
 	}
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
 	 * @param string $location location name for data
429 429
 	 * @return boolean true if data was set, false if not (like isset())
430 430
 	 */
431
-	static public function unsetSession($app,$location)
431
+	static public function unsetSession($app, $location)
432 432
 	{
433 433
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
434 434
 		{
435 435
 			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
436
-			return false;	// can no longer store something in the session, eg. because commit_session() was called
436
+			return false; // can no longer store something in the session, eg. because commit_session() was called
437 437
 		}
438 438
 		// check if entry is expired and clean it up in that case
439 439
 		if (isset($_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location]) &&
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	 * @param int $expiration =0 expiration time is NOT used for REQUEST!
468 468
 	 * @return boolean true if data could be stored, false otherwise
469 469
 	 */
470
-	static public function setRequest($app,$location,$data,$expiration=0)
470
+	static public function setRequest($app, $location, $data, $expiration = 0)
471 471
 	{
472
-		unset($expiration);	// not used, but required by function signature
472
+		unset($expiration); // not used, but required by function signature
473 473
 		self::$request_cache[$app][$location] = $data;
474 474
 
475 475
 		return true;
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 	 * @param int $expiration =0 expiration time is NOT used for REQUEST!
486 486
 	 * @return mixed NULL if data not found in cache (and no callback specified)
487 487
 	 */
488
-	static public function getRequest($app,$location,$callback=null,array $callback_params=array(),$expiration=0)
488
+	static public function getRequest($app, $location, $callback = null, array $callback_params = array(), $expiration = 0)
489 489
 	{
490
-		unset($expiration);	// not used, but required by function signature
490
+		unset($expiration); // not used, but required by function signature
491 491
 		if (!isset(self::$request_cache[$app][$location]) && !is_null($callback))
492 492
 		{
493
-			self::$request_cache[$app][$location] = call_user_func_array($callback,$callback_params);
493
+			self::$request_cache[$app][$location] = call_user_func_array($callback, $callback_params);
494 494
 		}
495 495
 		return self::$request_cache[$app][$location];
496 496
 	}
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	 * @param string $location location name for data
503 503
 	 * @return boolean true if data was set, false if not (like isset())
504 504
 	 */
505
-	static public function unsetRequest($app,$location)
505
+	static public function unsetRequest($app, $location)
506 506
 	{
507 507
 		if (!isset(self::$request_cache[$app][$location]))
508 508
 		{
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 	 * @param boolean $log_not_found =true false do not log if no provider found, used eg. to supress error via unsetCache during installation
523 523
 	 * @return Api\Cache\Provider
524 524
 	 */
525
-	static protected function get_provider($level, $log_not_found=true)
525
+	static protected function get_provider($level, $log_not_found = true)
526 526
 	{
527 527
 		static $providers = array();
528 528
 
@@ -543,13 +543,13 @@  discard block
 block discarded – undo
543 543
 				}
544 544
 				else
545 545
 				{
546
-					$providers[$level] = false;	// no provider specified
546
+					$providers[$level] = false; // no provider specified
547 547
 					$reason = 'no provider specified';
548 548
 				}
549 549
 			}
550 550
 			elseif (!$params)
551 551
 			{
552
-					$providers[$level] = false;	// cache for $level disabled
552
+					$providers[$level] = false; // cache for $level disabled
553 553
 					$reason = "cache for $level disabled";
554 554
 			}
555 555
 			else
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 				$class = array_shift($params);
560 560
 				if (!class_exists($class))
561 561
 				{
562
-					$providers[$level] = false;	// provider class not found
562
+					$providers[$level] = false; // provider class not found
563 563
 					$reason = "provider $class not found";
564 564
 				}
565 565
 				else
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 					{
569 569
 						$providers[$level] = new $class($params);
570 570
 					}
571
-					catch(Exception $e)
571
+					catch (Exception $e)
572 572
 					{
573
-						$providers[$level] = false;	// eg. could not open connection to backend
573
+						$providers[$level] = false; // eg. could not open connection to backend
574 574
 						$reason = "error instanciating provider $class: ".$e->getMessage();
575 575
 					}
576 576
 				}
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 * @param string $level
588 588
 	 * @return string class-name of provider
589 589
 	 */
590
-	public static function getProvider($level=self::INSTANCE)
590
+	public static function getProvider($level = self::INSTANCE)
591 591
 	{
592 592
 		$provider = self::get_provider($level);
593 593
 
@@ -601,35 +601,35 @@  discard block
 block discarded – undo
601 601
 	 * @param boolean $throw =true throw an exception, if we can't retriev the value
602 602
 	 * @return string|boolean string with config or false if not found and !$throw
603 603
 	 */
604
-	static public function get_system_config($name,$throw=true)
604
+	static public function get_system_config($name, $throw = true)
605 605
 	{
606
-		if(!isset($GLOBALS['egw_info']['server'][$name]))
606
+		if (!isset($GLOBALS['egw_info']['server'][$name]))
607 607
 		{
608 608
 			if (isset($GLOBALS['egw_setup']) && isset($GLOBALS['egw_setup']->db) || $GLOBALS['egw']->db)
609 609
 			{
610 610
 				$db = $GLOBALS['egw']->db ? $GLOBALS['egw']->db : $GLOBALS['egw_setup']->db;
611 611
 
612 612
 				try {
613
-					if (($rs = $db->select(Config::TABLE,'config_value',array(
613
+					if (($rs = $db->select(Config::TABLE, 'config_value', array(
614 614
 						'config_app'	=> 'phpgwapi',
615 615
 						'config_name'	=> $name,
616
-					),__LINE__,__FILE__)))
616
+					), __LINE__, __FILE__)))
617 617
 					{
618 618
 						$GLOBALS['egw_info']['server'][$name] = $rs->fetchColumn();
619 619
 					}
620 620
 					else
621 621
 					{
622
-						error_log(__METHOD__."('$name', $throw) config value NOT found!");//.function_backtrace());
622
+						error_log(__METHOD__."('$name', $throw) config value NOT found!"); //.function_backtrace());
623 623
 					}
624 624
 				}
625
-				catch(Db\Exception $e)
625
+				catch (Db\Exception $e)
626 626
 				{
627
-					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace());
627
+					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage()); //.function_backtrace());
628 628
 				}
629 629
 			}
630 630
 			if (!$GLOBALS['egw_info']['server'][$name] && $throw)
631 631
 			{
632
-				throw new Exception (__METHOD__."($name) \$GLOBALS['egw_info']['server']['$name'] is NOT set!");
632
+				throw new Exception(__METHOD__."($name) \$GLOBALS['egw_info']['server']['$name'] is NOT set!");
633 633
 			}
634 634
 		}
635 635
 		return $GLOBALS['egw_info']['server'][$name];
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	 * @param string $level =self::INSTANCE
642 642
 	 * @param string $app =null app-name or "all" to empty complete cache
643 643
 	 */
644
-	static public function flush($level=self::INSTANCE, $app=null)
644
+	static public function flush($level = self::INSTANCE, $app = null)
645 645
 	{
646 646
 		$ret = true;
647 647
 		if (!($provider = self::get_provider($level)))
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 	 * @param string $install_id =null default use install_id of current instance
689 689
 	 * @return string new key also stored in self::$instance_key
690 690
 	 */
691
-	static public function generate_instance_key($install_id=null)
691
+	static public function generate_instance_key($install_id = null)
692 692
 	{
693 693
 		if (!isset($install_id))
694 694
 		{
@@ -710,18 +710,18 @@  discard block
 block discarded – undo
710 710
 	 * @param string $location =null
711 711
 	 * @return array
712 712
 	 */
713
-	static public function keys($level, $app=null, $location=null)
713
+	static public function keys($level, $app = null, $location = null)
714 714
 	{
715 715
 		static $tree_key = null;
716 716
 
717
-		switch($level)
717
+		switch ($level)
718 718
 		{
719 719
 			case self::TREE:
720 720
 				if (!isset($tree_key))
721 721
 				{
722
-					$tree_key = $level.'-'.str_replace(array(':','/','\\'),'-', self::$egw_server_root);
722
+					$tree_key = $level.'-'.str_replace(array(':', '/', '\\'), '-', self::$egw_server_root);
723 723
 					// add charset to key, if not utf-8 (as everything we store depends on charset!)
724
-					if (($charset = self::get_system_config('system_charset',false)) && $charset != 'utf-8')
724
+					if (($charset = self::get_system_config('system_charset', false)) && $charset != 'utf-8')
725 725
 					{
726 726
 						$tree_key .= '-'.$charset;
727 727
 					}
@@ -769,9 +769,7 @@  discard block
 block discarded – undo
769 769
 if (is_null(Cache::$default_provider))
770 770
 {
771 771
 	Cache::$default_provider =
772
-		function_exists('apcu_fetch') && Cache\Apcu::available() ? 'EGroupware\Api\Cache\Apcu' :
773
-			(function_exists('apc_fetch') && Cache\Apc::available() ? 'EGroupware\Api\Cache\Apc' :
774
-				'EGroupware\Api\Cache\Files');
772
+		function_exists('apcu_fetch') && Cache\Apcu::available() ? 'EGroupware\Api\Cache\Apcu' : (function_exists('apc_fetch') && Cache\Apc::available() ? 'EGroupware\Api\Cache\Apc' : 'EGroupware\Api\Cache\Files');
775 773
 }
776 774
 
777 775
 //error_log('Cache::$default_provider='.array2string(Cache::$default_provider));
Please login to merge, or discard this patch.
Braces   +49 added lines, -12 removed lines patch added patch discarded remove patch
@@ -218,7 +218,10 @@  discard block
 block discarded – undo
218 218
 							foreach($location as $l)
219 219
 							{
220 220
 								$data[$l] = $provider->get($keys=self::keys($level,$app,$l));
221
-								if (!isset($data[$l])) unset($data[$l]);
221
+								if (!isset($data[$l]))
222
+								{
223
+									unset($data[$l]);
224
+								}
222 225
 							}
223 226
 						}
224 227
 					}
@@ -375,7 +378,10 @@  discard block
 block discarded – undo
375 378
 	{
376 379
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
377 380
 		{
378
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
381
+			if (Session::ERROR_LOG_DEBUG)
382
+			{
383
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
384
+			}
379 385
 			return false;	// can no longer store something in the session, eg. because commit_session() was called
380 386
 		}
381 387
 		$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = $data;
@@ -404,7 +410,10 @@  discard block
 block discarded – undo
404 410
 	{
405 411
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
406 412
 		{
407
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
413
+			if (Session::ERROR_LOG_DEBUG)
414
+			{
415
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
416
+			}
408 417
 			return null;	// can no longer store something in the session, eg. because commit_session() was called
409 418
 		}
410 419
 		// check if entry is expired and clean it up in that case
@@ -432,7 +441,10 @@  discard block
 block discarded – undo
432 441
 	{
433 442
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
434 443
 		{
435
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
444
+			if (Session::ERROR_LOG_DEBUG)
445
+			{
446
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
447
+			}
436 448
 			return false;	// can no longer store something in the session, eg. because commit_session() was called
437 449
 		}
438 450
 		// check if entry is expired and clean it up in that case
@@ -526,7 +538,10 @@  discard block
 block discarded – undo
526 538
 	{
527 539
 		static $providers = array();
528 540
 
529
-		if ($level != self::TREE) $level = self::INSTANCE;
541
+		if ($level != self::TREE)
542
+		{
543
+			$level = self::INSTANCE;
544
+		}
530 545
 
531 546
 		if (!isset($providers[$level]))
532 547
 		{
@@ -537,10 +552,13 @@  discard block
 block discarded – undo
537 552
 			}
538 553
 			if (!isset($params))
539 554
 			{
540
-				if ($level == self::TREE)	// if no tree level provider use the instance level one
555
+				if ($level == self::TREE)
556
+				{
557
+					// if no tree level provider use the instance level one
541 558
 				{
542 559
 					$providers[$level] = self::get_provider(self::INSTANCE);
543 560
 				}
561
+				}
544 562
 				else
545 563
 				{
546 564
 					$providers[$level] = false;	// no provider specified
@@ -554,7 +572,10 @@  discard block
 block discarded – undo
554 572
 			}
555 573
 			else
556 574
 			{
557
-				if (!is_array($params)) $params = (array)$params;
575
+				if (!is_array($params))
576
+				{
577
+					$params = (array)$params;
578
+				}
558 579
 
559 580
 				$class = array_shift($params);
560 581
 				if (!class_exists($class))
@@ -575,7 +596,10 @@  discard block
 block discarded – undo
575 596
 					}
576 597
 				}
577 598
 			}
578
-			if (!$providers[$level] && $log_not_found) error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
599
+			if (!$providers[$level] && $log_not_found)
600
+			{
601
+				error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
602
+			}
579 603
 		}
580 604
 		//error_log(__METHOD__."($level) = ".array2string($providers[$level]).', cache_provider='.array2string($GLOBALS['egw_info']['server']['cache_provider_'.strtolower($level)]));
581 605
 		return $providers[$level];
@@ -624,7 +648,11 @@  discard block
 block discarded – undo
624 648
 				}
625 649
 				catch(Db\Exception $e)
626 650
 				{
627
-					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace());
651
+					if ($throw)
652
+					{
653
+						error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());
654
+					}
655
+					//.function_backtrace());
628 656
 				}
629 657
 			}
630 658
 			if (!$GLOBALS['egw_info']['server'][$name] && $throw)
@@ -732,7 +760,10 @@  discard block
 block discarded – undo
732 760
 				if ($level !== $GLOBALS['egw_info']['server']['install_id'])
733 761
 				{
734 762
 					$level_key = self::getTree(__CLASS__, $level);
735
-					if (!isset($level_key)) $level_key = self::generate_instance_key($level);
763
+					if (!isset($level_key))
764
+					{
765
+						$level_key = self::generate_instance_key($level);
766
+					}
736 767
 					break;
737 768
 				}
738 769
 				// fall-through for current instance
@@ -741,7 +772,10 @@  discard block
 block discarded – undo
741 772
 				{
742 773
 					self::$instance_key = self::getTree(__CLASS__, self::get_system_config('install_id'));
743 774
 					//error_log(__METHOD__."('$level',...) instance_key read from tree-cache=".array2string(self::$instance_key));
744
-					if (!isset(self::$instance_key)) self::$instance_key = self::generate_instance_key();
775
+					if (!isset(self::$instance_key))
776
+					{
777
+						self::$instance_key = self::generate_instance_key();
778
+					}
745 779
 				}
746 780
 				$level_key = self::$instance_key;
747 781
 				break;
@@ -750,7 +784,10 @@  discard block
 block discarded – undo
750 784
 		if (isset($app))
751 785
 		{
752 786
 			$keys[] = $app;
753
-			if (isset($location)) $keys[] = $location;
787
+			if (isset($location))
788
+			{
789
+				$keys[] = $location;
790
+			}
754 791
 		}
755 792
 		return $keys;
756 793
 	}
Please login to merge, or discard this patch.
doc/phpunit_bootstrap.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
 // backward compatibility with PHPunit 5.7
19 19
 if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase'))
20 20
 {
21
-    class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
22
-    class_alias('\PHPUnit_Framework_ExpectationFailedException', '\PHPUnit\Framework\ExpectationFailedException');
21
+	class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
22
+	class_alias('\PHPUnit_Framework_ExpectationFailedException', '\PHPUnit\Framework\ExpectationFailedException');
23 23
 }
24 24
 
25 25
 // Needed to let Cache work
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 $GLOBALS['egw_info']['server']['install_id'] = 'PHPUnit test';
27 27
 
28 28
 // Symlink api/src/fixtures/apps/* to root
29
-foreach(scandir($path=__DIR__.'/../api/tests/fixtures/apps') as $app)
29
+foreach (scandir($path = __DIR__.'/../api/tests/fixtures/apps') as $app)
30 30
 {
31 31
 	if (is_dir($path.'/'.$app) && @file_exists($path.'/'.$app.'/setup/setup.inc.php')/* &&
32 32
 		readlink(__DIR__.'/../'.$app) !== 'api/tests/fixtures/apps/'.$app*/)
Please login to merge, or discard this patch.
api/src/Etemplate.php 4 patches
Braces   +81 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,14 +47,24 @@  discard block
 block discarded – undo
47 47
 	function __construct($name='',$load_via='')
48 48
 	{
49 49
 		// we do NOT call parent consturctor, as we only want to enherit it's (static) methods
50
-		if (false) parent::__construct ($name);	// satisfy IDE, as we dont call parent constructor
50
+		if (false)
51
+		{
52
+			parent::__construct ($name);
53
+		}
54
+		// satisfy IDE, as we dont call parent constructor
51 55
 
52 56
 		$this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']);
53 57
 
54
-		if ($name) $this->read($name,$template='default','default',0,'',$load_via);
58
+		if ($name)
59
+		{
60
+			$this->read($name,$template='default','default',0,'',$load_via);
61
+		}
55 62
 
56 63
 		// generate new etemplate request object, if not already existing
57
-		if(!isset(self::$request)) self::$request = Etemplate\Request::read();
64
+		if(!isset(self::$request))
65
+		{
66
+			self::$request = Etemplate\Request::read();
67
+		}
58 68
 	}
59 69
 
60 70
 	/**
@@ -111,7 +121,10 @@  discard block
 block discarded – undo
111 121
 
112 122
 		foreach($hook_data as $extras)
113 123
 		{
114
-			if (!$extras) continue;
124
+			if (!$extras)
125
+			{
126
+				continue;
127
+			}
115 128
 
116 129
 			foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
117 130
 			{
@@ -136,7 +149,10 @@  discard block
 block discarded – undo
136 149
 		// Include the etemplate2 javascript code
137 150
 		Framework::includeJS('etemplate', 'etemplate2', 'api');
138 151
 
139
-		if (!$this->rel_path) throw new Exception\AssertionFailed("No (valid) template '$this->name' found!");
152
+		if (!$this->rel_path)
153
+		{
154
+			throw new Exception\AssertionFailed("No (valid) template '$this->name' found!");
155
+		}
140 156
 
141 157
 		if ($output_mode == 4)
142 158
 		{
@@ -151,14 +167,23 @@  discard block
 block discarded – undo
151 167
 		self::$request->preserv = $preserv ? $preserv : array();
152 168
 		self::$request->method = $method;
153 169
 		self::$request->ignore_validation = $ignore_validation;
154
-		if (self::$request->output_mode == -1) self::$request->output_mode = 0;
170
+		if (self::$request->output_mode == -1)
171
+		{
172
+			self::$request->output_mode = 0;
173
+		}
155 174
 		self::$request->template = $this->as_array();
156 175
 
157
-		if (empty($this->name)) throw new Exception\AssertionFailed("Template  name is not set '$this->name' !");
176
+		if (empty($this->name))
177
+		{
178
+			throw new Exception\AssertionFailed("Template  name is not set '$this->name' !");
179
+		}
158 180
 		// instanciate template to fill self::$request->sel_options for select-* widgets
159 181
 		// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
160 182
 		$template = self::instance($this->name, $this->template_set, $this->version, $this->laod_via);
161
-		if (!$template) throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
183
+		if (!$template)
184
+		{
185
+			throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
186
+		}
162 187
 		$this->children = array($template);
163 188
 		$template->run('beforeSendToClient', array('', array('cont'=>$content)));
164 189
 
@@ -203,10 +228,13 @@  discard block
 block discarded – undo
203 228
 			'data' => $data,
204 229
 			'DOMNodeID' => $dom_id,
205 230
 		);
206
-		if (self::$response)	// call is within an ajax event / form submit
231
+		if (self::$response)
232
+		{
233
+			// call is within an ajax event / form submit
207 234
 		{
208 235
 			//error_log("Ajax " . __LINE__);
209 236
 			self::$response->generic('et2_load', $load_array+Framework::get_extra());
237
+		}
210 238
 			Framework::clear_extra();	// to not send/set it twice for multiple etemplates (eg. CRM view)
211 239
 		}
212 240
 		else	// first call
@@ -269,7 +297,10 @@  discard block
 block discarded – undo
269 297
 				echo $GLOBALS['egw']->framework->footer();
270 298
 			}
271 299
 			ob_flush();
272
-			if ($output_mode == 1)	return $form;
300
+			if ($output_mode == 1)
301
+			{
302
+				return $form;
303
+			}
273 304
 		}
274 305
 		self::$request = null;
275 306
 	}
@@ -284,7 +315,10 @@  discard block
 block discarded – undo
284 315
 	{
285 316
 		foreach($sel_options as &$options)
286 317
 		{
287
-			if (!is_array($options)||empty($options)) continue;
318
+			if (!is_array($options)||empty($options))
319
+			{
320
+				continue;
321
+			}
288 322
 			foreach($options as $key => $value)
289 323
 			{
290 324
 				if (is_numeric($key) && (!is_array($value) || !isset($value['value'])))
@@ -325,7 +359,10 @@  discard block
 block discarded – undo
325 359
 
326 360
 		// Set current app for validation
327 361
 		list($app) = explode('.',self::$request->method);
328
-		if(!$app) list($app) = explode('::',self::$request->method);
362
+		if(!$app)
363
+		{
364
+			list($app) = explode('::',self::$request->method);
365
+		}
329 366
 		if($app)
330 367
 		{
331 368
 			Translation::add_app($app);
@@ -356,7 +393,10 @@  discard block
 block discarded – undo
356 393
 			'location_name'   => $template->id,
357 394
 		) + self::complete_array_merge(self::$request->preserv, $validated)) as $extras)
358 395
 		{
359
-			if (!$extras) continue;
396
+			if (!$extras)
397
+			{
398
+				continue;
399
+			}
360 400
 
361 401
 			foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
362 402
 			{
@@ -394,10 +434,15 @@  discard block
 block discarded – undo
394 434
 		{
395 435
 			foreach($hook_data as $extras)
396 436
 			{
397
-				if (!$extras) continue;
437
+				if (!$extras)
438
+				{
439
+					continue;
440
+				}
398 441
 
399
-				foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
400
-					if ($extra['data'] && is_array($extra['data'])) {
442
+				foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
443
+				{
444
+					if ($extra['data'] && is_array($extra['data']))
445
+					{
401 446
 						$content = array_merge($content, $extra['data']);
402 447
 					}
403 448
 				}
@@ -436,7 +481,10 @@  discard block
 block discarded – undo
436 481
 	 */
437 482
 	static public function process_exec()
438 483
 	{
439
-		if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']);
484
+		if (get_magic_quotes_gpc())
485
+		{
486
+			$_POST['value'] = stripslashes($_POST['value']);
487
+		}
440 488
 		$content = json_decode($_POST['value'],true);
441 489
 		//error_log(__METHOD__."(".array2string($content).")");
442 490
 
@@ -599,16 +647,22 @@  discard block
 block discarded – undo
599 647
 	{
600 648
 		if (is_array($new))
601 649
 		{
602
-			if (!is_array($old)) $old = (array) $old;
650
+			if (!is_array($old))
651
+			{
652
+				$old = (array) $old;
653
+			}
603 654
 
604 655
 			foreach($new as $k => $v)
605 656
 			{
606 657
 				if (!is_array($v) || !isset($old[$k]) || 	// no array or a new array
607 658
 					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1])	|| // or no associative array, eg. selecting multiple accounts
608
-					is_array($v) && count($v) == 0)			// Empty array replacing non-empty
659
+					is_array($v) && count($v) == 0)
660
+				{
661
+					// Empty array replacing non-empty
609 662
 				{
610 663
 					$old[$k] = $v;
611 664
 				}
665
+				}
612 666
 				else
613 667
 				{
614 668
 					$old[$k] = self::complete_array_merge($old[$k],$v);
@@ -661,10 +715,16 @@  discard block
 block discarded – undo
661 715
 		if (is_null($dec_separator))
662 716
 		{
663 717
 			$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
664
-			if (empty($dec_separator)) $dec_separator = '.';
718
+			if (empty($dec_separator))
719
+			{
720
+				$dec_separator = '.';
721
+			}
665 722
 			$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
666 723
 		}
667
-		if ((string)$number === '') return '';
724
+		if ((string)$number === '')
725
+		{
726
+			return '';
727
+		}
668 728
 
669 729
 		return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : '');
670 730
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@
 block discarded – undo
158 158
 		// instanciate template to fill self::$request->sel_options for select-* widgets
159 159
 		// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
160 160
 		$template = self::instance($this->name, $this->template_set, $this->version, $this->laod_via);
161
-		if (!$template) throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
161
+		if (!$template) throw new Exception\AssertionFailed("template $this->name not instanciable! Maybe you forgot to rename template id.");
162 162
 		$this->children = array($template);
163 163
 		$template->run('beforeSendToClient', array('', array('cont'=>$content)));
164 164
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	 *
580 580
 	 * @param string $name cell-name
581 581
 	 * @param string $attr attribute-name
582
-	 * @param mixed $val if not NULL sets attribute else returns it
582
+	 * @param boolean|string $val if not NULL sets attribute else returns it
583 583
 	 * @return reference to attribute
584 584
 	 * @deprecated use setElementAttribute($name, $attr, $val)
585 585
 	 */
@@ -638,7 +638,6 @@  discard block
 block discarded – undo
638 638
 	/**
639 639
 	 * Deep copy array to make sure there are no references
640 640
 	 *
641
-	 * @param Array $array
642 641
 	 * @return Array
643 642
 	 */
644 643
 	public static function deep_copy($source)
Please login to merge, or discard this patch.
Spacing   +62 added lines, -63 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @public boolean
31 31
 	 */
32
-	public $sitemgr=false;
32
+	public $sitemgr = false;
33 33
 
34 34
 	/**
35 35
 	 * Tell egw framework it's ok to call this
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	 * @param string $name of etemplate or array with name and other keys
45 45
 	 * @param string|array $load_via with keys of other etemplate to load in order to get $name
46 46
 	 */
47
-	function __construct($name='',$load_via='')
47
+	function __construct($name = '', $load_via = '')
48 48
 	{
49 49
 		// we do NOT call parent consturctor, as we only want to enherit it's (static) methods
50
-		if (false) parent::__construct ($name);	// satisfy IDE, as we dont call parent constructor
50
+		if (false) parent::__construct($name); // satisfy IDE, as we dont call parent constructor
51 51
 
52 52
 		$this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']);
53 53
 
54
-		if ($name) $this->read($name,$template='default','default',0,'',$load_via);
54
+		if ($name) $this->read($name, $template = 'default', 'default', 0, '', $load_via);
55 55
 
56 56
 		// generate new etemplate request object, if not already existing
57
-		if(!isset(self::$request)) self::$request = Etemplate\Request::read();
57
+		if (!isset(self::$request)) self::$request = Etemplate\Request::read();
58 58
 	}
59 59
 
60 60
 	/**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param string|array $params url or array with get-params incl. menuaction
67 67
 	 */
68
-	static function location($params='')
68
+	static function location($params = '')
69 69
 	{
70 70
 		Framework::redirect_link(is_array($params) ? '/index.php' : $params,
71 71
 			is_array($params) ? $params : '');
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param array $changes change made in the last call if looping, only used internaly by process_exec
101 101
 	 * @return string html for $output_mode == 1, else nothing
102 102
 	 */
103
-	function exec($method,array $content,array $sel_options=null,array $readonlys=null,array $preserv=null,$output_mode=0,$ignore_validation='',array $changes=null)
103
+	function exec($method, array $content, array $sel_options = null, array $readonlys = null, array $preserv = null, $output_mode = 0, $ignore_validation = '', array $changes = null)
104 104
 	{
105 105
 		$hook_data = Hooks::process(
106 106
 			array('hook_location'   => 'etemplate2_before_exec') +
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 			$content
110 110
 		);
111 111
 
112
-		foreach($hook_data as $extras)
112
+		foreach ($hook_data as $extras)
113 113
 		{
114 114
 			if (!$extras) continue;
115 115
 
116
-			foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
116
+			foreach (isset($extras[0]) ? $extras : array($extras) as $extra)
117 117
 			{
118 118
 				if ($extra['data'] && is_array($extra['data']))
119 119
 				{
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			$output_mode = 0;
149 149
 			self::$response = Json\Response::get();
150 150
 		}
151
-		self::$request->output_mode = $output_mode;	// let extensions "know" they are run eg. in a popup
151
+		self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup
152 152
 		self::$request->content = self::$cont = $content;
153 153
 		self::$request->changes = $changes;
154 154
 		self::$request->sel_options = is_array($sel_options) ? self::fix_sel_options($sel_options) : array();
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 
173 173
 		// compile required translations translations
174 174
 		$currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
175
-		$langRequire = array('common' => array(), 'etemplate' => array());	// keep that order
176
-		foreach(Translation::$loaded_apps as $l_app => $lang)
175
+		$langRequire = array('common' => array(), 'etemplate' => array()); // keep that order
176
+		foreach (Translation::$loaded_apps as $l_app => $lang)
177 177
 		{
178 178
 			if (!in_array($l_app, array($currentapp, 'custom')))
179 179
 			{
180 180
 				$langRequire[$l_app] = array('app' => $l_app, 'lang' => $lang, 'etag' => Translation::etag($l_app, $lang));
181 181
 			}
182 182
 		}
183
-		foreach(array($currentapp, 'custom') as $l_app)
183
+		foreach (array($currentapp, 'custom') as $l_app)
184 184
 		{
185 185
 			if (isset(Translation::$loaded_apps[$l_app]))
186 186
 			{
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			'currentapp' => $currentapp,
201 201
 		);
202 202
 
203
-		if($data['content']['nm']['rows'] && is_array($data['content']['nm']['rows']))
203
+		if ($data['content']['nm']['rows'] && is_array($data['content']['nm']['rows']))
204 204
 		{
205 205
 			// Deep copy rows so we don't lose them when request is set to null
206 206
 			// (some content by reference)
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		}
209 209
 
210 210
 		// Info required to load the etemplate client-side
211
-		$dom_id = str_replace('.','-',$this->dom_id);
211
+		$dom_id = str_replace('.', '-', $this->dom_id);
212 212
 		$load_array = array(
213 213
 			'name' => $this->name,
214 214
 			'url' => self::rel2url($this->rel_path),
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 		if (self::$response)	// call is within an ajax event / form submit
219 219
 		{
220 220
 			//error_log("Ajax " . __LINE__);
221
-			self::$response->generic('et2_load', $load_array+Framework::get_extra());
222
-			Framework::clear_extra();	// to not send/set it twice for multiple etemplates (eg. CRM view)
221
+			self::$response->generic('et2_load', $load_array + Framework::get_extra());
222
+			Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view)
223 223
 		}
224 224
 		else	// first call
225 225
 		{
226 226
 			// check if application of template has a app.js file --> load it
227
-			list($app) = explode('.',$this->name);
227
+			list($app) = explode('.', $this->name);
228 228
 			if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js'))
229 229
 			{
230
-				Framework::includeJS('.','app',$app,true);
230
+				Framework::includeJS('.', 'app', $app, true);
231 231
 			}
232 232
 			// Category styles
233 233
 			Categories::css($app);
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 				$content = '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container"></form>'."\n".
246 246
 					'<iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;visibility:hidden;"></iframe>';
247 247
 				$GLOBALS['egw']->framework->response->generic("data", array($content));
248
-				$GLOBALS['egw']->framework->response->generic('et2_load',$load_array+Framework::get_extra());
249
-				Framework::clear_extra();	// to not send/set it twice for multiple etemplates (eg. CRM view)
248
+				$GLOBALS['egw']->framework->response->generic('et2_load', $load_array + Framework::get_extra());
249
+				Framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view)
250 250
 
251 251
 				// Really important to run this or weird things happen
252 252
 				// See https://help.egroupware.org/t/nextmatch-wert-im-header-ausgeben/73412/11
253
-				self::$request=null;
253
+				self::$request = null;
254 254
 				return;
255 255
 			}
256 256
 			// let framework know, if we are a popup or not ('popup' not true, which is allways used by index.php!)
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				echo '<div id="popupMainDiv" class="popupMainDiv">'."\n";
269 269
 			}
270 270
 			// Send any accumulated json responses - after flush to avoid sending the buffer as a response
271
-			if(Json\Response::isJSONResponse())
271
+			if (Json\Response::isJSONResponse())
272 272
 			{
273 273
 				$load_array['response'] = Json\Response::get()->returnResult();
274 274
 			}
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	static protected function fix_sel_options(array $sel_options)
299 299
 	{
300
-		foreach($sel_options as &$options)
300
+		foreach ($sel_options as &$options)
301 301
 		{
302
-			if (!is_array($options)||empty($options)) continue;
303
-			foreach($options as $key => $value)
302
+			if (!is_array($options) || empty($options)) continue;
303
+			foreach ($options as $key => $value)
304 304
 			{
305 305
 				if (is_numeric($key) && (!is_array($value) || !isset($value['value'])))
306 306
 				{
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 		$GLOBALS['egw']->session->set_action('Etemplate: '.self::$request->method);
340 340
 
341 341
 		// Set current app for validation
342
-		list($app) = explode('.',self::$request->method);
343
-		if(!$app) list($app) = explode('::',self::$request->method);
344
-		if($app)
342
+		list($app) = explode('.', self::$request->method);
343
+		if (!$app) list($app) = explode('::', self::$request->method);
344
+		if ($app)
345 345
 		{
346 346
 			Translation::add_app($app);
347 347
 			$GLOBALS['egw_info']['flags']['currentapp'] = $app;
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		$expand = array(
351 351
 			'cont' => &self::$request->content,
352 352
 		);
353
-		$template->run('validate', array('', $expand, $_content, &$validated), true);	// $respect_disabled=true: do NOT validate disabled widgets and children
353
+		$template->run('validate', array('', $expand, $_content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children
354 354
 
355 355
 		if ($no_validation)
356 356
 		{
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		// tell request call to remove request, if it is not modified eg. by call to exec in callback
367 367
 		self::$request->remove_if_not_modified();
368 368
 
369
-		foreach(Hooks::process(array(
369
+		foreach (Hooks::process(array(
370 370
 			'hook_location'   => 'etemplate2_before_process',
371 371
 			'location_name'   => $template->id,
372 372
 		) + self::complete_array_merge(self::$request->preserv, $validated)) as $extras)
373 373
 		{
374 374
 			if (!$extras) continue;
375 375
 
376
-			foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
376
+			foreach (isset($extras[0]) ? $extras : array($extras) as $extra)
377 377
 			{
378 378
 				if ($extra['data'] && is_array($extra['data']))
379 379
 				{
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 
385 385
 		//error_log(__METHOD__."(,".array2string($content).')');
386 386
 		//error_log(' validated='.array2string($validated));
387
-		if(is_callable(self::$request->method))
387
+		if (is_callable(self::$request->method))
388 388
 		{
389
-			call_user_func(self::$request->method,self::complete_array_merge(self::$request->preserv, $validated));
389
+			call_user_func(self::$request->method, self::complete_array_merge(self::$request->preserv, $validated));
390 390
 		}
391 391
 		else
392 392
 		{
@@ -394,8 +394,7 @@  discard block
 block discarded – undo
394 394
 			$content = ExecMethod(self::$request->method, self::complete_array_merge(self::$request->preserv, $validated));
395 395
 		}
396 396
 
397
-		$tcontent = is_array($content) ? $content :
398
-			self::complete_array_merge(self::$request->preserv, $validated);
397
+		$tcontent = is_array($content) ? $content : self::complete_array_merge(self::$request->preserv, $validated);
399 398
 
400 399
 		$hook_data = Hooks::process(
401 400
 			array(
@@ -407,11 +406,11 @@  discard block
 block discarded – undo
407 406
 
408 407
 		if (is_array($content))
409 408
 		{
410
-			foreach($hook_data as $extras)
409
+			foreach ($hook_data as $extras)
411 410
 			{
412 411
 				if (!$extras) continue;
413 412
 
414
-				foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
413
+				foreach (isset($extras[0]) ? $extras : array($extras) as $extra) {
415 414
 					if ($extra['data'] && is_array($extra['data'])) {
416 415
 						$content = array_merge($content, $extra['data']);
417 416
 					}
@@ -423,7 +422,7 @@  discard block
 block discarded – undo
423 422
 		if (isset($GLOBALS['egw_info']['flags']['java_script']))
424 423
 		{
425 424
 			// Strip out any script tags
426
-			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']);
425
+			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']);
427 426
 			self::$response->script($GLOBALS['egw_info']['flags']['java_script']);
428 427
 			//error_log($app .' added javascript to $GLOBALS[egw_info][flags][java_script] - use Json\Response->script() instead.');
429 428
 		}
@@ -452,7 +451,7 @@  discard block
 block discarded – undo
452 451
 	static public function process_exec()
453 452
 	{
454 453
 		if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']);
455
-		$content = json_decode($_POST['value'],true);
454
+		$content = json_decode($_POST['value'], true);
456 455
 		//error_log(__METHOD__."(".array2string($content).")");
457 456
 
458 457
 		self::$request = Etemplate\Request::read($_POST['etemplate_exec_id']);
@@ -466,7 +465,7 @@  discard block
 block discarded – undo
466 465
 		$expand = array(
467 466
 			'cont' => &self::$request->content,
468 467
 		);
469
-		$template->run('validate', array('', $expand, $content, &$validated), true);	// $respect_disabled=true: do NOT validate disabled widgets and children
468
+		$template->run('validate', array('', $expand, $content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children
470 469
 		if (self::validation_errors(self::$request->ignore_validation))
471 470
 		{
472 471
 			error_log(__METHOD__."(,".array2string($content).') validation_errors='.array2string(self::$validation_errors));
@@ -502,7 +501,7 @@  discard block
 block discarded – undo
502 501
 	 *
503 502
 	 * @ToDo supported customized templates stored in DB
504 503
 	 */
505
-	public function read($name,$template_set=null,$lang='default',$group=0,$version='',$load_via='')
504
+	public function read($name, $template_set = null, $lang = 'default', $group = 0, $version = '', $load_via = '')
506 505
 	{
507 506
 
508 507
 		// For mobile experience try to load custom mobile templates
@@ -511,9 +510,9 @@  discard block
 block discarded – undo
511 510
 			$template_set = "mobile";
512 511
 		}
513 512
 
514
-		unset($lang); unset($group);	// not used, but in old signature
515
-		$this->rel_path = self::relPath($this->name=$name, $this->template_set=$template_set,
516
-			$this->version=$version, $this->laod_via = $load_via);
513
+		unset($lang); unset($group); // not used, but in old signature
514
+		$this->rel_path = self::relPath($this->name = $name, $this->template_set = $template_set,
515
+			$this->version = $version, $this->laod_via = $load_via);
517 516
 		//error_log(__METHOD__."('$name', '$template_set', '$lang', $group, '$version', '$load_via') rel_path=".array2string($this->rel_path));
518 517
 
519 518
 		$this->dom_id = $name;
@@ -568,7 +567,7 @@  discard block
 block discarded – undo
568 567
 	 * @return mixed reference to attribute, usually NULL
569 568
 	 * @deprecated use getElementAttribute($name, $attr)
570 569
 	 */
571
-	public function &get_cell_attribute($name,$attr)
570
+	public function &get_cell_attribute($name, $attr)
572 571
 	{
573 572
 		return self::getElementAttribute($name, $attr);
574 573
 	}
@@ -582,7 +581,7 @@  discard block
 block discarded – undo
582 581
 	 * @return reference to attribute
583 582
 	 * @deprecated use setElementAttribute($name, $attr, $val)
584 583
 	 */
585
-	public function &set_cell_attribute($name,$attr,$val)
584
+	public function &set_cell_attribute($name, $attr, $val)
586 585
 	{
587 586
 		return self::setElementAttribute($name, $attr, $val);
588 587
 	}
@@ -595,7 +594,7 @@  discard block
 block discarded – undo
595 594
 	 * @return reference to attribute
596 595
 	 * @deprecated use disableElement($name, $disabled=true)
597 596
 	 */
598
-	public function disable_cells($name,$disabled=True)
597
+	public function disable_cells($name, $disabled = True)
599 598
 	{
600 599
 		return self::disableElement($name, $disabled);
601 600
 	}
@@ -611,23 +610,23 @@  discard block
 block discarded – undo
611 610
 	 * @param array $new
612 611
 	 * @return array the merged array
613 612
 	 */
614
-	public static function complete_array_merge($old,$new)
613
+	public static function complete_array_merge($old, $new)
615 614
 	{
616 615
 		if (is_array($new))
617 616
 		{
618
-			if (!is_array($old)) $old = (array) $old;
617
+			if (!is_array($old)) $old = (array)$old;
619 618
 
620
-			foreach($new as $k => $v)
619
+			foreach ($new as $k => $v)
621 620
 			{
622
-				if (!is_array($v) || !isset($old[$k]) || 	// no array or a new array
623
-					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1])	|| // or no associative array, eg. selecting multiple accounts
621
+				if (!is_array($v) || !isset($old[$k]) || // no array or a new array
622
+					isset($v[0]) && !is_array($v[0]) && isset($v[count($v) - 1]) || // or no associative array, eg. selecting multiple accounts
624 623
 					is_array($v) && count($v) == 0)			// Empty array replacing non-empty
625 624
 				{
626 625
 					$old[$k] = $v;
627 626
 				}
628 627
 				else
629 628
 				{
630
-					$old[$k] = self::complete_array_merge($old[$k],$v);
629
+					$old[$k] = self::complete_array_merge($old[$k], $v);
631 630
 				}
632 631
 			}
633 632
 		}
@@ -669,7 +668,7 @@  discard block
 block discarded – undo
669 668
 	 *
670 669
 	 * @param array $content =null
671 670
 	 */
672
-	public function debug(array $content=null)
671
+	public function debug(array $content = null)
673 672
 	{
674 673
 		$GLOBALS['egw']->framework->render(print_r($content, true));
675 674
 	}
@@ -683,11 +682,11 @@  discard block
 block discarded – undo
683 682
 	 * @param int &$max_upload=null on return max. upload size in byte
684 683
 	 * @return string
685 684
 	 */
686
-	static function max_upload_size_message(&$max_upload=null)
685
+	static function max_upload_size_message(&$max_upload = null)
687 686
 	{
688 687
 		$upload_max_filesize = ini_get('upload_max_filesize');
689 688
 		$post_max_size = ini_get('post_max_size');
690
-		$max_upload = min(self::km2int($upload_max_filesize),self::km2int($post_max_size)-2800);
689
+		$max_upload = min(self::km2int($upload_max_filesize), self::km2int($post_max_size) - 2800);
691 690
 
692 691
 		return lang('Maximum size for uploads').': '.Vfs::hsize($max_upload).
693 692
 			" (php.ini: upload_max_filesize=$upload_max_filesize, post_max_size=$post_max_size)";
@@ -701,9 +700,9 @@  discard block
 block discarded – undo
701 700
 	 * @param boolean $readonly =true
702 701
 	 * @return string
703 702
 	 */
704
-	static public function number_format($number,$num_decimal_places=2,$readonly=true)
703
+	static public function number_format($number, $num_decimal_places = 2, $readonly = true)
705 704
 	{
706
-		static $dec_separator=null,$thousands_separator=null;
705
+		static $dec_separator = null, $thousands_separator = null;
707 706
 		if (is_null($dec_separator))
708 707
 		{
709 708
 			$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
@@ -712,7 +711,7 @@  discard block
 block discarded – undo
712 711
 		}
713 712
 		if ((string)$number === '') return '';
714 713
 
715
-		return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : '');
714
+		return number_format(str_replace(' ', '', $number), $num_decimal_places, $dec_separator, $readonly ? $thousands_separator : '');
716 715
 	}
717 716
 
718 717
 	/**
@@ -725,13 +724,13 @@  discard block
 block discarded – undo
725 724
 	{
726 725
 		if (!is_numeric($size))
727 726
 		{
728
-			switch(strtolower(substr($size,-1)))
727
+			switch (strtolower(substr($size, -1)))
729 728
 			{
730 729
 				case 'm':
731
-					$size = 1024*1024*(int)$size;
730
+					$size = 1024 * 1024 * (int)$size;
732 731
 					break;
733 732
 				case 'k':
734
-					$size = 1024*(int)$size;
733
+					$size = 1024 * (int)$size;
735 734
 					break;
736 735
 			}
737 736
 		}
Please login to merge, or discard this patch.
admin/inc/class.admin_egw_acl_record.inc.php 2 patches
Braces   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -35,11 +35,15 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string $_identifier
37 37
 	 */
38
-	public function __construct( $_identifier='' ) {
39
-		if(is_array($_identifier)) {
38
+	public function __construct( $_identifier='' )
39
+	{
40
+		if(is_array($_identifier))
41
+		{
40 42
 			$this->identifier = $_identifier['id'];
41 43
 			$this->set_record($_identifier);
42
-		} else {
44
+		}
45
+		else
46
+		{
43 47
 			$this->identifier = $_identifier;
44 48
 			//$GLOBALS['egw']->acl->read($this->identifier);
45 49
 		}
@@ -50,7 +54,8 @@  discard block
 block discarded – undo
50 54
 	 *
51 55
 	 * @param string $_attribute_name
52 56
 	 */
53
-	public function __get($_attribute_name) {
57
+	public function __get($_attribute_name)
58
+	{
54 59
 		return $this->record[$_attribute_name];
55 60
 	}
56 61
 
@@ -60,7 +65,8 @@  discard block
 block discarded – undo
60 65
 	 * @param string $_attribute_name
61 66
 	 * @param data $data
62 67
 	 */
63
-	public function __set($_attribute_name, $data) {
68
+	public function __set($_attribute_name, $data)
69
+	{
64 70
 		$this->record[$_attribute_name] = $data;
65 71
 	}
66 72
 
@@ -72,7 +78,8 @@  discard block
 block discarded – undo
72 78
 	 *
73 79
 	 * @return array complete record as associative array
74 80
 	 */
75
-	public function get_record_array() {
81
+	public function get_record_array()
82
+	{
76 83
 		return $this->record;
77 84
 	}
78 85
 
@@ -81,7 +88,8 @@  discard block
 block discarded – undo
81 88
 	 *
82 89
 	 *@return string title
83 90
 	 */
84
-	public function get_title() {
91
+	public function get_title()
92
+	{
85 93
 		return Api\Accounts::username($this->identifier);
86 94
 	}
87 95
 
@@ -91,7 +99,8 @@  discard block
 block discarded – undo
91 99
 	 * @todo add some checks
92 100
 	 * @return void
93 101
 	 */
94
-	public function set_record(array $_record) {
102
+	public function set_record(array $_record)
103
+	{
95 104
 		$this->record = $_record;
96 105
 	}
97 106
 
@@ -100,7 +109,8 @@  discard block
 block discarded – undo
100 109
 	 *
101 110
 	 * @return string identifier of current record
102 111
 	 */
103
-	public function get_identifier() {
112
+	public function get_identifier()
113
+	{
104 114
 		return $this->identifier;
105 115
 	}
106 116
 
@@ -110,7 +120,8 @@  discard block
 block discarded – undo
110 120
 	 *
111 121
 	 * @return string Full URL of an icon, or appname/icon_name
112 122
 	 */
113
-	public function get_icon() {
123
+	public function get_icon()
124
+	{
114 125
 		return 'access';
115 126
 	}
116 127
 
@@ -119,7 +130,8 @@  discard block
 block discarded – undo
119 130
 	 *
120 131
 	 * @return string identifier
121 132
 	 */
122
-	public function save ( $_dst_identifier ) {
133
+	public function save ( $_dst_identifier )
134
+	{
123 135
 		unset($_dst_identifier);	// not used, but require by function signature
124 136
 	}
125 137
 
@@ -129,7 +141,8 @@  discard block
 block discarded – undo
129 141
 	 * @param string $_dst_identifier
130 142
 	 * @return string dst_identifier
131 143
 	 */
132
-	public function copy ( $_dst_identifier ) {
144
+	public function copy ( $_dst_identifier )
145
+	{
133 146
 		unset($_dst_identifier);	// not used, but require by function signature
134 147
 	}
135 148
 
@@ -140,7 +153,8 @@  discard block
 block discarded – undo
140 153
 	 * @param string $_dst_identifier
141 154
 	 * @return string dst_identifier
142 155
 	 */
143
-	public function move ( $_dst_identifier ) {
156
+	public function move ( $_dst_identifier )
157
+	{
144 158
 		unset($_dst_identifier);	// not used, but require by function signature
145 159
 	}
146 160
 
@@ -148,7 +162,8 @@  discard block
 block discarded – undo
148 162
 	 * delets current record from backend
149 163
 	 *
150 164
 	 */
151
-	public function delete () {
165
+	public function delete ()
166
+	{
152 167
 
153 168
 	}
154 169
 
@@ -156,7 +171,8 @@  discard block
 block discarded – undo
156 171
 	 * destructor
157 172
 	 *
158 173
 	 */
159
-	public function __destruct() {
174
+	public function __destruct()
175
+	{
160 176
 		unset ($this->record);
161 177
 	}
162 178
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	static $types = array(
27 27
 		'select' => array('acl_appname'),
28 28
 		'select-account' => array('acl_account', 'acl_location'),
29
-		'select-bool' => array('acl_run', 'acl1', 'acl2','acl4','acl8','acl16','acl64','acl128','acl256'),
29
+		'select-bool' => array('acl_run', 'acl1', 'acl2', 'acl4', 'acl8', 'acl16', 'acl64', 'acl128', 'acl256'),
30 30
 	);
31 31
 
32 32
 	/**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string $_identifier
37 37
 	 */
38
-	public function __construct( $_identifier='' ) {
39
-		if(is_array($_identifier)) {
38
+	public function __construct($_identifier = '') {
39
+		if (is_array($_identifier)) {
40 40
 			$this->identifier = $_identifier['id'];
41 41
 			$this->set_record($_identifier);
42 42
 		} else {
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return string identifier
121 121
 	 */
122
-	public function save ( $_dst_identifier ) {
123
-		unset($_dst_identifier);	// not used, but require by function signature
122
+	public function save($_dst_identifier) {
123
+		unset($_dst_identifier); // not used, but require by function signature
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 * @param string $_dst_identifier
130 130
 	 * @return string dst_identifier
131 131
 	 */
132
-	public function copy ( $_dst_identifier ) {
133
-		unset($_dst_identifier);	// not used, but require by function signature
132
+	public function copy($_dst_identifier) {
133
+		unset($_dst_identifier); // not used, but require by function signature
134 134
 	}
135 135
 
136 136
 	/**
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 	 * @param string $_dst_identifier
141 141
 	 * @return string dst_identifier
142 142
 	 */
143
-	public function move ( $_dst_identifier ) {
144
-		unset($_dst_identifier);	// not used, but require by function signature
143
+	public function move($_dst_identifier) {
144
+		unset($_dst_identifier); // not used, but require by function signature
145 145
 	}
146 146
 
147 147
 	/**
148 148
 	 * delets current record from backend
149 149
 	 *
150 150
 	 */
151
-	public function delete () {
151
+	public function delete() {
152 152
 
153 153
 	}
154 154
 
Please login to merge, or discard this patch.
admin/inc/class.admin_export_acl_csv.inc.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,10 @@
 block discarded – undo
99 99
 				// Implode arrays, so they don't say 'Array'
100 100
 				foreach($record->get_record_array() as $key => $value)
101 101
 				{
102
-					if(is_array($value)) $record->$key = implode(',', $value);
102
+					if(is_array($value))
103
+					{
104
+						$record->$key = implode(',', $value);
105
+					}
103 106
 				}
104 107
  			}
105 108
 			$record->all_acls = implode(',', $all_acls);
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param egw_record $_definition
25 25
 	 */
26
-	public function export( $_stream, importexport_definition $_definition)
26
+	public function export($_stream, importexport_definition $_definition)
27 27
 	{
28 28
 		$options = $_definition->plugin_options;
29 29
 
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 				'location' => 'acl_rights'
37 37
 			))
38 38
 		);
39
-		if($_definition->filter['acl_location'])
39
+		if ($_definition->filter['acl_location'])
40 40
 		{
41 41
 			$query['col_filter']['acl_location'] = $_definition->filter['acl_location'];
42 42
 		}
43 43
 
44 44
 		// ACL queries only go by one account at a time, so we collect for all
45
-		if($_definition->filter['acl_account'])
45
+		if ($_definition->filter['acl_account'])
46 46
 		{
47 47
 			$accounts = array_flip($_definition->filter['acl_account']);
48 48
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			);
55 55
 			$accounts = $GLOBALS['egw']->accounts->search($account_query);
56 56
 		}
57
-		foreach($accounts as $account_id => $account_data)
57
+		foreach ($accounts as $account_id => $account_data)
58 58
 		{
59 59
 			$this->get_account_acl($account_id, $options['mapping']['acl_run'], $query, $selection);
60 60
 		}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		$lookups = array(
67 67
 			'acl_appname' => Select::app_options('installed')
68 68
 		);
69
-		if($selection['sel_options'])
69
+		if ($selection['sel_options'])
70 70
 		{
71 71
 			$lookups += $selection['sel_options'];
72 72
 			unset($selection['sel_options']);
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
 			$record = new admin_egw_acl_record($_record);
80 80
 			// Add in field for all ACLs
81 81
 			$all_acls = array();
82
-			foreach($record->get_record_array() as $key => $value)
82
+			foreach ($record->get_record_array() as $key => $value)
83 83
 			{
84
-				if(strpos($key, '_') === FALSE && !in_array($key, array('id')))
84
+				if (strpos($key, '_') === FALSE && !in_array($key, array('id')))
85 85
 				{
86 86
 					$all_acls[] = $value;
87 87
 				}
88 88
 			}
89 89
 
90
-			if($options['convert'])
90
+			if ($options['convert'])
91 91
 			{
92 92
 				importexport_export_csv::convert($record, admin_egw_acl_record::$types, 'admin', $lookups);
93 93
 			}
94 94
 			else
95 95
 			{
96 96
 				// Implode arrays, so they don't say 'Array'
97
-				foreach($record->get_record_array() as $key => $value)
97
+				foreach ($record->get_record_array() as $key => $value)
98 98
 				{
99
-					if(is_array($value)) $record->$key = implode(',', $value);
99
+					if (is_array($value)) $record->$key = implode(',', $value);
100 100
 				}
101 101
  			}
102 102
 			$record->all_acls = implode(',', $all_acls);
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 		$selection = array_merge($selection, $account_acl);
125 125
 
126 126
 		$run = array();
127
-		if($run_rights)
127
+		if ($run_rights)
128 128
 		{
129 129
 			$query['filter'] = 'run';
130 130
 			admin_acl::get_rows($query, $run);
131
-			foreach($run as &$run_row)
131
+			foreach ($run as &$run_row)
132 132
 			{
133 133
 				$run_row['acl_run'] = true;
134 134
 				unset($run_row['acl_location']);
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * Exports records as defined in $_definition
25 25
 	 *
26
-	 * @param egw_record $_definition
26
+	 * @param importexport_definition $_definition
27 27
 	 */
28 28
 	public function export( $_stream, importexport_definition $_definition)
29 29
 	{
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param $definition Specific definition
146 146
 	 *
147
-	 * @return array (
147
+	 * @return boolean (
148 148
 	 * 		name 		=> string,
149 149
 	 * 		content		=> array,
150 150
 	 * 		sel_options	=> array,
Please login to merge, or discard this patch.
admin/inc/class.admin_wizard_export_acl_csv.inc.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@
 block discarded – undo
14 14
 
15 15
 class admin_wizard_export_acl_csv extends importexport_wizard_basic_export_csv
16 16
 {
17
-	public function __construct() {
17
+	public function __construct()
18
+	{
18 19
 		parent::__construct();
19 20
 
20 21
 		// Field mapping
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 			'acl4'              => lang('Edit'),
29 29
 			'acl8'              => lang('Delete'),
30 30
 			'acl16'             => lang('Private'),
31
-			'acl64'             => lang('Custom') .' 1',
32
-			'acl128'            => lang('Custom') .' 2',
33
-			'acl256'            => lang('Custom') .' 3',
31
+			'acl64'             => lang('Custom').' 1',
32
+			'acl128'            => lang('Custom').' 2',
33
+			'acl256'            => lang('Custom').' 3',
34 34
 		);
35 35
 
36 36
 		// Custom fields - not possible for ACL
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	{
46 46
 		$result = parent::wizard_step30($content, $sel_options, $readonlys, $preserv);
47 47
 		unset($this->export_fields['all_custom_fields']);
48
-		foreach($content['fields'] as $field_id => $field)
48
+		foreach ($content['fields'] as $field_id => $field)
49 49
 		{
50
-			if($field['field'] == 'all_custom_fields')
50
+			if ($field['field'] == 'all_custom_fields')
51 51
 			{
52 52
 				unset($content['fields'][$field_id]);
53 53
 			}
Please login to merge, or discard this patch.
api/src/Contacts/Storage.php 4 patches
Doc Comments   +1 added lines, -10 removed lines patch added patch discarded remove patch
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	 * @param array|string $criteria array of key and data cols, OR string to search over all standard search fields
626 626
 	 * @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return
627 627
 	 * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
628
-	 * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
628
+	 * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
629 629
 	 * @param string $wildcard ='' appended befor and after each criteria
630 630
 	 * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
631 631
 	 * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
@@ -833,13 +833,6 @@  discard block
 block discarded – undo
833 833
 	 * Find contacts that appear to be duplicates
834 834
 	 *
835 835
 	 * @param Array $param
836
-	 * @param string $param[org_view] 'org_name', 'org_name,adr_one_location', 'org_name,org_unit' how to group
837
-	 * @param int $param[owner] addressbook to search
838
-	 * @param string $param[search] search pattern for org_name
839
-	 * @param string $param[searchletter] letter the org_name need to start with
840
-	 * @param int $param[start]
841
-	 * @param int $param[num_rows]
842
-	 * @param string $param[sort] ASC or DESC
843 836
 	 *
844 837
 	 * @return array of arrays
845 838
 	 */
@@ -932,8 +925,6 @@  discard block
 block discarded – undo
932 925
 	 * delete / move all contacts of an addressbook
933 926
 	 *
934 927
 	 * @param array $data
935
-	 * @param int $data['account_id'] owner to change
936
-	 * @param int $data['new_owner']  new owner or 0 for delete
937 928
 	 */
938 929
 	function deleteaccount($data)
939 930
 	{
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
 	var $extra_table = 'egw_addressbook_extra';
45 45
 
46 46
 	/**
47
-	* @var string
48
-	*/
47
+	 * @var string
48
+	 */
49 49
 	var $extra_id = 'contact_id';
50 50
 
51 51
 	/**
52
-	* @var string
53
-	*/
52
+	 * @var string
53
+	 */
54 54
 	var $extra_owner = 'contact_owner';
55 55
 
56 56
 	/**
57
-	* @var string
58
-	*/
57
+	 * @var string
58
+	 */
59 59
 	var $extra_key = 'contact_name';
60 60
 
61 61
 	/**
62
-	* @var string
63
-	*/
62
+	 * @var string
63
+	 */
64 64
 	var $extra_value = 'contact_value';
65 65
 
66 66
 	/**
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 	var $distributionlist_view ='(SELECT contact_id, egw_addressbook_lists.list_id as list_id, egw_addressbook_lists.list_name as list_name, egw_addressbook_lists.list_owner as list_owner FROM egw_addressbook_lists, egw_addressbook2list where egw_addressbook_lists.list_id=egw_addressbook2list.list_id) d_view ';
72 72
 	var $distributionlist_tabledef = array();
73 73
 	/**
74
-	* @var string
75
-	*/
74
+	 * @var string
75
+	 */
76 76
 	var $distri_id = 'contact_id';
77 77
 
78 78
 	/**
79
-	* @var string
80
-	*/
79
+	 * @var string
80
+	 */
81 81
 	var $distri_owner = 'list_owner';
82 82
 
83 83
 	/**
84
-	* @var string
85
-	*/
84
+	 * @var string
85
+	 */
86 86
 	var $distri_key = 'list_id';
87 87
 
88 88
 	/**
89
-	* @var string
90
-	*/
89
+	 * @var string
90
+	 */
91 91
 	var $distri_value = 'list_name';
92 92
 
93 93
 	/**
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 	);
194 194
 
195 195
 	/**
196
-	* Special content type to indicate a deleted addressbook
197
-	*
198
-	* @var String;
199
-	*/
196
+	 * Special content type to indicate a deleted addressbook
197
+	 *
198
+	 * @var String;
199
+	 */
200 200
 	const DELETED_TYPE = 'D';
201 201
 
202 202
 	/**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 			$this->distributionlist_tabledef = array('fd' => array(
302 302
 					$this->distri_id => $tda2list['fd'][$this->distri_id],
303 303
 					$this->distri_owner => $tdlists['fd'][$this->distri_owner],
304
-        	    	$this->distri_key => $tdlists['fd'][$this->distri_key],
304
+					$this->distri_key => $tdlists['fd'][$this->distri_key],
305 305
 					$this->distri_value => $tdlists['fd'][$this->distri_value],
306 306
 				), 'pk' => array(), 'fk' => array(), 'ix' => array(), 'uc' => array(),
307 307
 			);
@@ -502,12 +502,12 @@  discard block
 block discarded – undo
502 502
 	}
503 503
 
504 504
 	/**
505
-	* deletes contact entry including custom fields
506
-	*
507
-	* @param mixed $contact array with id or just the id
508
-	* @param int $check_etag =null
509
-	* @return boolean|int true on success or false on failiure, 0 if etag does not match
510
-	*/
505
+	 * deletes contact entry including custom fields
506
+	 *
507
+	 * @param mixed $contact array with id or just the id
508
+	 * @param int $check_etag =null
509
+	 * @return boolean|int true on success or false on failiure, 0 if etag does not match
510
+	 */
511 511
 	function delete($contact,$check_etag=null)
512 512
 	{
513 513
 		if (is_array($contact)) $contact = $contact['id'];
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 	}
544 544
 
545 545
 	/**
546
-	* saves contact data including custom fields
547
-	*
548
-	* @param array &$contact contact data from etemplate::exec
549
-	* @return bool false on success, errornumber on failure
550
-	*/
546
+	 * saves contact data including custom fields
547
+	 *
548
+	 * @param array &$contact contact data from etemplate::exec
549
+	 * @return bool false on success, errornumber on failure
550
+	 */
551 551
 	function save(&$contact)
552 552
 	{
553 553
 		// save mainfields
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 *
601 601
 	 * @param int|string $contact_id contact_id or 'a'.account_id
602 602
 	 * @return array|boolean data if row could be retrived else False
603
-	*/
603
+	 */
604 604
 	function read($contact_id)
605 605
 	{
606 606
 		if (empty($contact_id))
@@ -930,10 +930,10 @@  discard block
 block discarded – undo
930 930
 	}
931 931
 
932 932
  	/**
933
-	 * gets all contact fields from database
934
-	 *
935
-	 * @return array of (internal) field-names
936
-	 */
933
+ 	 * gets all contact fields from database
934
+ 	 *
935
+ 	 * @return array of (internal) field-names
936
+ 	 */
937 937
 	function get_contact_columns()
938 938
 	{
939 939
 		$fields = $this->get_fields('all');
Please login to merge, or discard this patch.
Spacing   +145 added lines, -146 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @var string
70 70
 	 */
71
-	var $distributionlist_view ='(SELECT contact_id, egw_addressbook_lists.list_id as list_id, egw_addressbook_lists.list_name as list_name, egw_addressbook_lists.list_owner as list_owner FROM egw_addressbook_lists, egw_addressbook2list where egw_addressbook_lists.list_id=egw_addressbook2list.list_id) d_view ';
71
+	var $distributionlist_view = '(SELECT contact_id, egw_addressbook_lists.list_id as list_id, egw_addressbook_lists.list_name as list_name, egw_addressbook_lists.list_owner as list_owner FROM egw_addressbook_lists, egw_addressbook2list where egw_addressbook_lists.list_id=egw_addressbook2list.list_id) d_view ';
72 72
 	var $distributionlist_tabledef = array();
73 73
 	/**
74 74
 	* @var string
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 	 * In SQL we can search all columns, though a view make on real sense
123 123
 	 */
124 124
 	var $sql_cols_not_to_search = array(
125
-		'jpegphoto','owner','tid','private','cat_id','etag',
126
-		'modified','modifier','creator','created','tz','account_id',
127
-		'uid','carddav_name','freebusy_uri','calendar_uri',
128
-		'geo','pubkey',
125
+		'jpegphoto', 'owner', 'tid', 'private', 'cat_id', 'etag',
126
+		'modified', 'modifier', 'creator', 'created', 'tz', 'account_id',
127
+		'uid', 'carddav_name', 'freebusy_uri', 'calendar_uri',
128
+		'geo', 'pubkey',
129 129
 	);
130 130
 	/**
131 131
 	 * columns to search, if we search for a single pattern
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	const FILES_DIRECTORY = '.files';
166 166
 	const FILES_PHOTO = '.files/photo.jpeg';
167 167
 	const FILES_PGP_PUBKEY = '.files/pgp-pubkey.asc';
168
-	const FILES_SMIME_PUBKEY =  '.files/smime-pubkey.crt';
168
+	const FILES_SMIME_PUBKEY = '.files/smime-pubkey.crt';
169 169
 
170 170
 	/**
171 171
 	 * Constant for bit-field "contact_files" storing what files are available
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 	 * @param string $contact_app ='addressbook' used for acl->get_grants()
239 239
 	 * @param Api\Db $db =null
240 240
 	 */
241
-	function __construct($contact_app='addressbook',Api\Db $db=null)
241
+	function __construct($contact_app = 'addressbook', Api\Db $db = null)
242 242
 	{
243
-		$this->db     = is_null($db) ? $GLOBALS['egw']->db : $db;
243
+		$this->db = is_null($db) ? $GLOBALS['egw']->db : $db;
244 244
 
245 245
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
246
-		$this->memberships = $GLOBALS['egw']->accounts->memberships($this->user,true);
246
+		$this->memberships = $GLOBALS['egw']->accounts->memberships($this->user, true);
247 247
 
248 248
 		// account backend used
249 249
 		if ($GLOBALS['egw_info']['server']['account_repository'])
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		}
257 257
 		$this->customfields = Api\Storage\Customfields::get('addressbook');
258 258
 		// contacts backend (contacts in LDAP require accounts in LDAP!)
259
-		if($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' && $this->account_repository == 'ldap')
259
+		if ($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' && $this->account_repository == 'ldap')
260 260
 		{
261 261
 			$this->contact_repository = 'ldap';
262 262
 			$this->somain = new Ldap();
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 			$this->somain = new Sql($db);
272 272
 
273 273
 			// remove some columns, absolutly not necessary to search in sql
274
-			$this->columns_to_search = array_diff(array_values($this->somain->db_cols),$this->sql_cols_not_to_search);
274
+			$this->columns_to_search = array_diff(array_values($this->somain->db_cols), $this->sql_cols_not_to_search);
275 275
 		}
276 276
 		if ($this->user)
277 277
 		{
278
-			$this->grants = $this->get_grants($this->user,$contact_app);
278
+			$this->grants = $this->get_grants($this->user, $contact_app);
279 279
 		}
280 280
 		if ($this->account_repository != 'sql' && $this->contact_repository == 'sql')
281 281
 		{
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		}
293 293
 		if ($this->contact_repository == 'sql' || $this->contact_repository == 'sql-ldap')
294 294
 		{
295
-			$tda2list = $this->db->get_table_definitions('api','egw_addressbook2list');
296
-			$tdlists = $this->db->get_table_definitions('api','egw_addressbook_lists');
295
+			$tda2list = $this->db->get_table_definitions('api', 'egw_addressbook2list');
296
+			$tdlists = $this->db->get_table_definitions('api', 'egw_addressbook_lists');
297 297
 			$this->distributionlist_tabledef = array('fd' => array(
298 298
 					$this->distri_id => $tda2list['fd'][$this->distri_id],
299 299
 					$this->distri_owner => $tdlists['fd'][$this->distri_owner],
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 			);
304 304
 		}
305 305
 		// ToDo: it should be the other way arround, the backend should set the grants it uses
306
-		$this->somain->grants =& $this->grants;
306
+		$this->somain->grants = & $this->grants;
307 307
 
308
-		if($this->somain instanceof Sql)
308
+		if ($this->somain instanceof Sql)
309 309
 		{
310
-			$this->soextra =& $this->somain;
310
+			$this->soextra = & $this->somain;
311 311
 		}
312 312
 		else
313 313
 		{
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
 		// Add in deleted type, if holding deleted contacts
329 329
 		$config = Api\Config::read('phpgwapi');
330
-		if($config['history'])
330
+		if ($config['history'])
331 331
 		{
332 332
 			$this->content_types[self::DELETED_TYPE] = array(
333 333
 				'name'	=>	lang('Deleted'),
@@ -346,18 +346,18 @@  discard block
 block discarded – undo
346 346
 	 * @param string $contact_app ='addressbook'
347 347
 	 * @return array
348 348
 	 */
349
-	function get_grants($user, $contact_app='addressbook', $preferences=null)
349
+	function get_grants($user, $contact_app = 'addressbook', $preferences = null)
350 350
 	{
351 351
 		if (!isset($preferences)) $preferences = $GLOBALS['egw_info']['user']['preferences'];
352 352
 
353 353
 		if ($user)
354 354
 		{
355 355
 			// contacts backend (contacts in LDAP require accounts in LDAP!)
356
-			if($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' && $this->account_repository == 'ldap')
356
+			if ($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' && $this->account_repository == 'ldap')
357 357
 			{
358 358
 				// static grants from ldap: all rights for the own personal addressbook and the group ones of the meberships
359 359
 				$grants = array($user => ~0);
360
-				foreach($GLOBALS['egw']->accounts->memberships($user,true) as $gid)
360
+				foreach ($GLOBALS['egw']->accounts->memberships($user, true) as $gid)
361 361
 				{
362 362
 					$grants[$gid] = ~0;
363 363
 				}
@@ -366,22 +366,22 @@  discard block
 block discarded – undo
366 366
 			{
367 367
 				// group grants are now grants for the group addressbook and NOT grants for all its members,
368 368
 				// therefor the param false!
369
-				$grants = $GLOBALS['egw']->acl->get_grants($contact_app,false,$user);
369
+				$grants = $GLOBALS['egw']->acl->get_grants($contact_app, false, $user);
370 370
 			}
371 371
 			// add grants for accounts: if account_selection not in ('none','groupmembers'): everyone has read access,
372 372
 			// if he has not set the hide_accounts preference
373 373
 			// ToDo: be more specific for 'groupmembers', they should be able to see the groupmembers
374
-			if (!in_array($preferences['common']['account_selection'], array('none','groupmembers')))
374
+			if (!in_array($preferences['common']['account_selection'], array('none', 'groupmembers')))
375 375
 			{
376 376
 				$grants[0] = Api\Acl::READ;
377 377
 			}
378 378
 			// add account grants for admins (only for current user!)
379 379
 			if ($user == $this->user && $this->is_admin())	// admin rights can be limited by ACL!
380 380
 			{
381
-				$grants[0] = Api\Acl::READ;	// admins always have read-access
382
-				if (!$GLOBALS['egw']->acl->check('account_access',16,'admin')) $grants[0] |= Api\Acl::EDIT;
383
-				if (!$GLOBALS['egw']->acl->check('account_access',4,'admin'))  $grants[0] |= Api\Acl::ADD;
384
-				if (!$GLOBALS['egw']->acl->check('account_access',32,'admin')) $grants[0] |= Api\Acl::DELETE;
381
+				$grants[0] = Api\Acl::READ; // admins always have read-access
382
+				if (!$GLOBALS['egw']->acl->check('account_access', 16, 'admin')) $grants[0] |= Api\Acl::EDIT;
383
+				if (!$GLOBALS['egw']->acl->check('account_access', 4, 'admin'))  $grants[0] |= Api\Acl::ADD;
384
+				if (!$GLOBALS['egw']->acl->check('account_access', 32, 'admin')) $grants[0] |= Api\Acl::DELETE;
385 385
 			}
386 386
 			// allow certain groups to edit contact-data of accounts
387 387
 			if (self::allow_account_edit($user))
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
 	 * @param array $contact =null for future use, where admins might not be admins for all accounts
406 406
 	 * @return boolean
407 407
 	 */
408
-	function is_admin($contact=null)
408
+	function is_admin($contact = null)
409 409
 	{
410
-		unset($contact);	// not (yet) used
410
+		unset($contact); // not (yet) used
411 411
 
412
-		return isset($GLOBALS['egw_info']['user']['apps']['admin']) && !$GLOBALS['egw']->acl->check('account_access',16,'admin');
412
+		return isset($GLOBALS['egw_info']['user']['apps']['admin']) && !$GLOBALS['egw']->acl->check('account_access', 16, 'admin');
413 413
 	}
414 414
 
415 415
 	/**
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 * @param int $user =null default $this->user
419 419
 	 * @return boolean
420 420
 	 */
421
-	function allow_account_edit($user=null)
421
+	function allow_account_edit($user = null)
422 422
 	{
423 423
 		return $GLOBALS['egw_info']['server']['allow_account_edit'] &&
424 424
 			array_intersect($GLOBALS['egw_info']['server']['allow_account_edit'],
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
 	 * @param array $field_names =null custom fields to read, default all
433 433
 	 * @return array id => name => value
434 434
 	 */
435
-	function read_customfields($ids,$field_names=null)
435
+	function read_customfields($ids, $field_names = null)
436 436
 	{
437
-		return $this->soextra->read_customfields($ids,$field_names);
437
+		return $this->soextra->read_customfields($ids, $field_names);
438 438
 	}
439 439
 
440 440
 	/**
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
 	 * @param int|array $ids
444 444
 	 * @return array id => name => value
445 445
 	 */
446
-	function read_distributionlist($ids, $dl_allowed=array())
446
+	function read_distributionlist($ids, $dl_allowed = array())
447 447
 	{
448 448
 		if ($this->contact_repository == 'ldap')
449 449
 		{
450
-			return array();	// ldap does not support distributionlists
450
+			return array(); // ldap does not support distributionlists
451 451
 		}
452
-		foreach($ids as $key => $id)
452
+		foreach ($ids as $key => $id)
453 453
 		{
454 454
 			if (!is_numeric($id)) unset($ids[$key]);
455 455
 		}
456
-		if (!$ids) return array();	// nothing to do, eg. all these contacts are in ldap
456
+		if (!$ids) return array(); // nothing to do, eg. all these contacts are in ldap
457 457
 		$fields = array();
458
-		$filter[$this->distri_id]=$ids;
459
-		if (count($dl_allowed)) $filter[$this->distri_key]=$dl_allowed;
460
-		$distri_view = str_replace(') d_view',' and '.$this->distri_id.' in ('.implode(',',$ids).')) d_view',$this->distributionlist_view);
458
+		$filter[$this->distri_id] = $ids;
459
+		if (count($dl_allowed)) $filter[$this->distri_key] = $dl_allowed;
460
+		$distri_view = str_replace(') d_view', ' and '.$this->distri_id.' in ('.implode(',', $ids).')) d_view', $this->distributionlist_view);
461 461
 		#_debug_array($this->distributionlist_tabledef);
462
-		foreach($this->db->select($distri_view, '*', $filter, __LINE__, __FILE__,
462
+		foreach ($this->db->select($distri_view, '*', $filter, __LINE__, __FILE__,
463 463
 			false, 'ORDER BY '.$this->distri_id, false, 0, '', $this->distributionlist_tabledef) as $row)
464 464
 		{
465
-			if ((isset($row[$this->distri_id])&&strlen($row[$this->distri_value])>0))
465
+			if ((isset($row[$this->distri_id]) && strlen($row[$this->distri_value]) > 0))
466 466
 			{
467 467
 				$fields[$row[$this->distri_id]][$row[$this->distri_key]] = $row[$this->distri_value].' ('.
468 468
 					Api\Accounts::username($row[$this->distri_owner]).')';
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	* @param int $check_etag =null
505 505
 	* @return boolean|int true on success or false on failiure, 0 if etag does not match
506 506
 	*/
507
-	function delete($contact,$check_etag=null)
507
+	function delete($contact, $check_etag = null)
508 508
 	{
509 509
 		if (is_array($contact)) $contact = $contact['id'];
510 510
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 		if ($this->somain->delete($where))
516 516
 		{
517 517
 			// delete customfields, can return 0 if there are no customfields
518
-			if(!($this->somain instanceof Sql))
518
+			if (!($this->somain instanceof Sql))
519 519
 			{
520 520
 				$this->soextra->delete_customfields(array($this->extra_id => $contact));
521 521
 			}
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 			}
536 536
 			return true;
537 537
 		}
538
-		return $check_etag ? 0 : false;		// if etag given, we return 0 on failure, thought it could also mean the whole contact does not exist
538
+		return $check_etag ? 0 : false; // if etag given, we return 0 on failure, thought it could also mean the whole contact does not exist
539 539
 	}
540 540
 
541 541
 	/**
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 				}
587 587
 			}
588 588
 		}
589
-		if($error_nr) return $error_nr;
589
+		if ($error_nr) return $error_nr;
590 590
 
591
-		return false;	// no error
591
+		return false; // no error
592 592
 	}
593 593
 
594 594
 	/**
@@ -601,20 +601,20 @@  discard block
 block discarded – undo
601 601
 	{
602 602
 		if (empty($contact_id))
603 603
 		{
604
-			return false;	// no need to pass to backend, will fail anyway
604
+			return false; // no need to pass to backend, will fail anyway
605 605
 		}
606
-		if (!is_array($contact_id) && substr($contact_id,0,8) == 'account:')
606
+		if (!is_array($contact_id) && substr($contact_id, 0, 8) == 'account:')
607 607
 		{
608
-			$contact_id = array('account_id' => (int) substr($contact_id,8));
608
+			$contact_id = array('account_id' => (int)substr($contact_id, 8));
609 609
 		}
610 610
 		// read main data
611
-		$backend =& $this->get_backend($contact_id);
611
+		$backend = & $this->get_backend($contact_id);
612 612
 		if (!($contact = $backend->read($contact_id)))
613 613
 		{
614 614
 			return $contact;
615 615
 		}
616
-		$dl_list=$this->read_distributionlist(array($contact['id']));
617
-		if (count($dl_list)) $contact['distrib_lists']=implode("\n",$dl_list[$contact['id']]);
616
+		$dl_list = $this->read_distributionlist(array($contact['id']));
617
+		if (count($dl_list)) $contact['distrib_lists'] = implode("\n", $dl_list[$contact['id']]);
618 618
 		return $this->db2data($contact);
619 619
 	}
620 620
 
@@ -637,18 +637,18 @@  discard block
 block discarded – undo
637 637
 	 * @param boolean $ignore_acl =false true: no acl check
638 638
 	 * @return array of matching rows (the row is an array of the cols) or False
639 639
 	 */
640
-	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='', $ignore_acl=false)
640
+	function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $ignore_acl = false)
641 641
 	{
642 642
 		//error_log(__METHOD__.'('.array2string($criteria,true).','.array2string($only_keys).",'$order_by','$extra_cols','$wildcard','$empty','$op',".array2string($start).','.array2string($filter,true).",'$join')");
643 643
 
644 644
 		// Handle 'None' country option
645
-		if(is_array($filter) && $filter['adr_one_countrycode'] == '-custom-')
645
+		if (is_array($filter) && $filter['adr_one_countrycode'] == '-custom-')
646 646
 		{
647 647
 			$filter[] = 'adr_one_countrycode IS NULL';
648 648
 			unset($filter['adr_one_countrycode']);
649 649
 		}
650 650
 		// Hide deleted items unless type is specifically deleted
651
-		if(!is_array($filter)) $filter = $filter ? (array) $filter : array();
651
+		if (!is_array($filter)) $filter = $filter ? (array)$filter : array();
652 652
 
653 653
 		if (isset($filter['cols_to_search']))
654 654
 		{
@@ -657,22 +657,22 @@  discard block
 block discarded – undo
657 657
 		}
658 658
 
659 659
 		// if no tid set or tid==='' do NOT return deleted entries ($tid === null returns all entries incl. deleted)
660
-		if(!array_key_exists('tid', $filter) || $filter['tid'] === '')
660
+		if (!array_key_exists('tid', $filter) || $filter['tid'] === '')
661 661
 		{
662
-			if ($join && strpos($join,'RIGHT JOIN') !== false)	// used eg. to search for groups
662
+			if ($join && strpos($join, 'RIGHT JOIN') !== false)	// used eg. to search for groups
663 663
 			{
664
-				$filter[] = '(contact_tid != \'' . self::DELETED_TYPE . '\' OR contact_tid IS NULL)';
664
+				$filter[] = '(contact_tid != \''.self::DELETED_TYPE.'\' OR contact_tid IS NULL)';
665 665
 			}
666 666
 			else
667 667
 			{
668
-				$filter[] = 'contact_tid != \'' . self::DELETED_TYPE . '\'';
668
+				$filter[] = 'contact_tid != \''.self::DELETED_TYPE.'\'';
669 669
 			}
670 670
 		}
671
-		elseif(is_null($filter['tid']))
671
+		elseif (is_null($filter['tid']))
672 672
 		{
673
-			unset($filter['tid']);	// return all entries incl. deleted
673
+			unset($filter['tid']); // return all entries incl. deleted
674 674
 		}
675
-		$backend = $this->get_backend(null,$filter['owner']);
675
+		$backend = $this->get_backend(null, $filter['owner']);
676 676
 		// single string to search for --> create so_sql conformant search criterial for the standard search columns
677 677
 		if ($criteria && !is_array($criteria))
678 678
 		{
@@ -693,34 +693,34 @@  discard block
 block discarded – undo
693 693
 			{
694 694
 				$cols = $this->account_cols_to_search;
695 695
 			}
696
-			if($backend instanceof Sql)
696
+			if ($backend instanceof Sql)
697 697
 			{
698 698
 				// Keep a string, let the parent handle it
699 699
 				$criteria = $search;
700 700
 
701
-				foreach($cols as $key => &$col)
701
+				foreach ($cols as $key => &$col)
702 702
 				{
703
-					if($col != Sql::EXTRA_VALUE &&
703
+					if ($col != Sql::EXTRA_VALUE &&
704 704
 						$col != Sql::EXTRA_TABLE.'.'.Sql::EXTRA_VALUE &&
705 705
 						!array_key_exists($col, $backend->db_cols))
706 706
 					{
707
-						if(!($col = array_search($col, $backend->db_cols)))
707
+						if (!($col = array_search($col, $backend->db_cols)))
708 708
 						{
709 709
 							// Can't search this column, it will error if we try
710 710
 							unset($cols[$key]);
711 711
 						}
712 712
 					}
713
-					if ($col=='contact_id') $col='egw_addressbook.contact_id';
713
+					if ($col == 'contact_id') $col = 'egw_addressbook.contact_id';
714 714
 				}
715 715
 
716 716
 				$backend->columns_to_search = $cols;
717 717
 			}
718 718
 			else
719 719
 			{
720
-				foreach($cols as $col)
720
+				foreach ($cols as $col)
721 721
 				{
722 722
 					// remove from LDAP backend not understood use-AND-syntax
723
-					$criteria[$col] = str_replace(' +',' ',$search);
723
+					$criteria[$col] = str_replace(' +', ' ', $search);
724 724
 				}
725 725
 			}
726 726
 		}
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 
745 745
 		if ($rows)
746 746
 		{
747
-			foreach($rows as $n => $row)
747
+			foreach ($rows as $n => $row)
748 748
 			{
749 749
 				$rows[$n] = $this->db2data($row);
750 750
 			}
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	 */
768 768
 	function organisations($param)
769 769
 	{
770
-		if (!method_exists($this->somain,'organisations'))
770
+		if (!method_exists($this->somain, 'organisations'))
771 771
 		{
772 772
 			$this->total = 0;
773 773
 			return false;
@@ -776,16 +776,16 @@  discard block
 block discarded – undo
776 776
 		{
777 777
 			$search = $param['search'];
778 778
 			$param['search'] = array();
779
-			if($this->somain instanceof Sql)
779
+			if ($this->somain instanceof Sql)
780 780
 			{
781 781
 				// Keep the string, let the parent deal with it
782 782
 				$param['search'] = $search;
783 783
 			}
784 784
 			else
785 785
 			{
786
-				foreach($this->columns_to_search as $col)
786
+				foreach ($this->columns_to_search as $col)
787 787
 				{
788
-					if ($col != 'contact_value') $param['search'][$col] = $search;	// we dont search the customfields
788
+					if ($col != 'contact_value') $param['search'][$col] = $search; // we dont search the customfields
789 789
 				}
790 790
 			}
791 791
 		}
@@ -793,13 +793,13 @@  discard block
 block discarded – undo
793 793
 		{
794 794
 			$param['search'] = $this->data2db($param['search']);
795 795
 		}
796
-		if(!array_key_exists('tid', $param['col_filter']) || $param['col_filter']['tid'] === '')
796
+		if (!array_key_exists('tid', $param['col_filter']) || $param['col_filter']['tid'] === '')
797 797
 		{
798
-			$param['col_filter'][] = 'contact_tid != \'' . self::DELETED_TYPE . '\'';
798
+			$param['col_filter'][] = 'contact_tid != \''.self::DELETED_TYPE.'\'';
799 799
 		}
800
-		elseif(is_null($param['col_filter']['tid']))
800
+		elseif (is_null($param['col_filter']['tid']))
801 801
 		{
802
-			unset($param['col_filter']['tid']);	// return all entries incl. deleted
802
+			unset($param['col_filter']['tid']); // return all entries incl. deleted
803 803
 		}
804 804
 
805 805
 		$rows = $this->somain->organisations($param);
@@ -807,11 +807,11 @@  discard block
 block discarded – undo
807 807
 
808 808
 		if (!$rows) return array();
809 809
 
810
-		foreach($rows as $n => $row)
810
+		foreach ($rows as $n => $row)
811 811
 		{
812
-			if (strpos($row['org_name'],'&')!==false) $row['org_name'] = str_replace('&','*AND*',$row['org_name']);
812
+			if (strpos($row['org_name'], '&') !== false) $row['org_name'] = str_replace('&', '*AND*', $row['org_name']);
813 813
 			$rows[$n]['id'] = 'org_name:'.$row['org_name'];
814
-			foreach(array(
814
+			foreach (array(
815 815
 				'org_unit' => lang('departments'),
816 816
 				'adr_one_locality' => lang('locations'),
817 817
 			) as $by => $by_label)
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 				}
823 823
 				else
824 824
 				{
825
-					if (strpos($row[$by],'&')!==false) $row[$by] = str_replace('&','*AND*',$row[$by]);
825
+					if (strpos($row[$by], '&') !== false) $row[$by] = str_replace('&', '*AND*', $row[$by]);
826 826
 					$rows[$n]['id'] .= '|||'.$by.':'.$row[$by];
827 827
 				}
828 828
 			}
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 	 */
847 847
 	public function duplicates($param)
848 848
 	{
849
-		if (!method_exists($this->somain,'duplicates'))
849
+		if (!method_exists($this->somain, 'duplicates'))
850 850
 		{
851 851
 			$this->total = 0;
852 852
 			return false;
@@ -855,14 +855,14 @@  discard block
 block discarded – undo
855 855
 		{
856 856
 			$search = $param['search'];
857 857
 			$param['search'] = array();
858
-			if($this->somain instanceof Sql)
858
+			if ($this->somain instanceof Sql)
859 859
 			{
860 860
 				// Keep the string, let the parent deal with it
861 861
 				$param['search'] = $search;
862 862
 			}
863 863
 			else
864 864
 			{
865
-				foreach($this->columns_to_search as $col)
865
+				foreach ($this->columns_to_search as $col)
866 866
 				{
867 867
 					// we don't search the customfields
868 868
 					if ($col != 'contact_value') $param['search'][$col] = $search;
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
 		{
874 874
 			$param['search'] = $this->data2db($param['search']);
875 875
 		}
876
-		if(!array_key_exists('tid', $param['col_filter']) || $param['col_filter']['tid'] === '')
876
+		if (!array_key_exists('tid', $param['col_filter']) || $param['col_filter']['tid'] === '')
877 877
 		{
878
-			$param['col_filter'][] = $this->somain->table_name.'.contact_tid != \'' . self::DELETED_TYPE . '\'';
878
+			$param['col_filter'][] = $this->somain->table_name.'.contact_tid != \''.self::DELETED_TYPE.'\'';
879 879
 		}
880
-		elseif(is_null($param['col_filter']['tid']))
880
+		elseif (is_null($param['col_filter']['tid']))
881 881
 		{
882 882
 			// return all entries including deleted
883 883
 			unset($param['col_filter']['tid']);
884 884
 		}
885
-		if(array_key_exists('filter', $param) && $param['filter'] != '')
885
+		if (array_key_exists('filter', $param) && $param['filter'] != '')
886 886
 		{
887 887
 			$param['owner'] = $param['filter'];
888 888
 			unset($param['filter']);
889 889
 		}
890
-		if(array_key_exists('owner', $param['col_filter']) && $param['col_filter']['owner'] != '')
890
+		if (array_key_exists('owner', $param['col_filter']) && $param['col_filter']['owner'] != '')
891 891
 		{
892 892
 			$param['owner'] = $param['col_filter']['owner'];
893 893
 			unset($param['col_filter']['owner']);
@@ -899,13 +899,13 @@  discard block
 block discarded – undo
899 899
 
900 900
 		if (!$rows) return array();
901 901
 
902
-		foreach($rows as $n => $row)
902
+		foreach ($rows as $n => $row)
903 903
 		{
904 904
 			$rows[$n]['id'] = 'duplicate:';
905
-			foreach(array_keys(static::$duplicate_fields) as $by)
905
+			foreach (array_keys(static::$duplicate_fields) as $by)
906 906
 			{
907
-				if (strpos($row[$by],'&')!==false) $row[$by] = str_replace('&','*AND*',$row[$by]);
908
-				if($row[$by])
907
+				if (strpos($row[$by], '&') !== false) $row[$by] = str_replace('&', '*AND*', $row[$by]);
908
+				if ($row[$by])
909 909
 				{
910 910
 					$rows[$n]['id'] .= '|||'.$by.':'.$row[$by];
911 911
 				}
@@ -939,11 +939,11 @@  discard block
 block discarded – undo
939 939
 	function deleteaccount($data)
940 940
 	{
941 941
 		$account_id = $data['account_id'];
942
-		$new_owner =  $data['new_owner'];
942
+		$new_owner = $data['new_owner'];
943 943
 
944 944
 		if (!$new_owner)
945 945
 		{
946
-			$this->somain->delete(array('owner' => $account_id));	// so_sql_cf::delete() takes care of cfs too
946
+			$this->somain->delete(array('owner' => $account_id)); // so_sql_cf::delete() takes care of cfs too
947 947
 
948 948
 			if (method_exists($this->somain, 'get_lists') &&
949 949
 				($lists = $this->somain->get_lists($account_id)))
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 		}
954 954
 		else
955 955
 		{
956
-			$this->somain->change_owner($account_id,$new_owner);
956
+			$this->somain->change_owner($account_id, $new_owner);
957 957
 		}
958 958
 	}
959 959
 
@@ -964,16 +964,15 @@  discard block
 block discarded – undo
964 964
 	 * @param int $owner =null account_id of owner or 0 for accounts
965 965
 	 * @return Sql|Ldap|Ads|Univention
966 966
 	 */
967
-	function get_backend($keys=null,$owner=null)
967
+	function get_backend($keys = null, $owner = null)
968 968
 	{
969 969
 		if ($owner === '') $owner = null;
970 970
 
971
-		$contact_id = !is_array($keys) ? $keys :
972
-			(isset($keys['id']) ? $keys['id'] : $keys['contact_id']);
971
+		$contact_id = !is_array($keys) ? $keys : (isset($keys['id']) ? $keys['id'] : $keys['contact_id']);
973 972
 
974 973
 		if ($this->contact_repository != $this->account_repository && is_object($this->so_accounts) &&
975 974
 			(!is_null($owner) && !$owner || is_array($keys) && $keys['account_id'] || !is_null($contact_id) &&
976
-			($this->contact_repository == 'sql' && (!is_numeric($contact_id) && !is_array($contact_id) )||
975
+			($this->contact_repository == 'sql' && (!is_numeric($contact_id) && !is_array($contact_id)) ||
977 976
 			 $this->contact_repository == 'ldap' && is_numeric($contact_id))))
978 977
 		{
979 978
 			return $this->so_accounts;
@@ -989,20 +988,20 @@  discard block
 block discarded – undo
989 988
 	 * @param int $owner =null account_id of owner or 0 for accounts
990 989
 	 * @return array with eGW contact field names
991 990
 	 */
992
-	function get_fields($type='all',$contact_id=null,$owner=null)
991
+	function get_fields($type = 'all', $contact_id = null, $owner = null)
993 992
 	{
994
-		$def = $this->db->get_table_definitions('api','egw_addressbook');
993
+		$def = $this->db->get_table_definitions('api', 'egw_addressbook');
995 994
 
996 995
 		$all_fields = array();
997
-		foreach(array_keys($def['fd']) as $field)
996
+		foreach (array_keys($def['fd']) as $field)
998 997
 		{
999
-			$all_fields[] = substr($field,0,8) == 'contact_' ? substr($field,8) : $field;
998
+			$all_fields[] = substr($field, 0, 8) == 'contact_' ? substr($field, 8) : $field;
1000 999
 		}
1001 1000
 		if ($type == 'all')
1002 1001
 		{
1003 1002
 			return $all_fields;
1004 1003
 		}
1005
-		$backend = $this->get_backend($contact_id,$owner);
1004
+		$backend = $this->get_backend($contact_id, $owner);
1006 1005
 
1007 1006
 		$supported_fields = method_exists($backend, 'supported_fields') ? $backend->supported_fields() : $all_fields;
1008 1007
 
@@ -1010,7 +1009,7 @@  discard block
 block discarded – undo
1010 1009
 		{
1011 1010
 			return $supported_fields;
1012 1011
 		}
1013
-		return array_diff($all_fields,$supported_fields);
1012
+		return array_diff($all_fields, $supported_fields);
1014 1013
 	}
1015 1014
 
1016 1015
 	/**
@@ -1026,7 +1025,7 @@  discard block
 block discarded – undo
1026 1025
 	function migrate2ldap($type)
1027 1026
 	{
1028 1027
 		//error_log(__METHOD__."(".array2string($type).")");
1029
-		$sql_contacts  = new Sql();
1028
+		$sql_contacts = new Sql();
1030 1029
 		if ($type == 'accounts-back-ads')
1031 1030
 		{
1032 1031
 			$ldap_contacts = new Ads();
@@ -1049,10 +1048,10 @@  discard block
 block discarded – undo
1049 1048
 			$filter = count($do) == 2 ? null :
1050 1049
 				array($do[0] == 'contacts' ? 'contact_owner != 0' : 'contact_owner = 0');
1051 1050
 
1052
-			while (($contacts = $sql_contacts->search(false,false,'n_family,n_given','','',false,'AND',
1053
-				array($start,$num),$filter)))
1051
+			while (($contacts = $sql_contacts->search(false, false, 'n_family,n_given', '', '', false, 'AND',
1052
+				array($start, $num), $filter)))
1054 1053
 			{
1055
-				foreach($contacts as $contact)
1054
+				foreach ($contacts as $contact)
1056 1055
 				{
1057 1056
 					if ($contact['account_id']) $contact['id'] = $GLOBALS['egw']->accounts->id2name($contact['account_id']);
1058 1057
 
@@ -1073,12 +1072,12 @@  discard block
 block discarded – undo
1073 1072
 			}
1074 1073
 		}
1075 1074
 		// direction LDAP --> SQL: either "sql" (contacts and accounts) or "accounts-back" (only accounts)
1076
-		if (($do = array_intersect(array('accounts-back','sql'), $type)))
1075
+		if (($do = array_intersect(array('accounts-back', 'sql'), $type)))
1077 1076
 		{
1078 1077
 			//error_log(__METHOD__."(".array2string($type).") do=".array2string($type));
1079 1078
 			$filter = in_array('sql', $do) ? null : array('owner' => 0);
1080 1079
 
1081
-			foreach($ldap_contacts->search(false,false,'n_family,n_given','','',false,'AND',
1080
+			foreach ($ldap_contacts->search(false, false, 'n_family,n_given', '', '', false, 'AND',
1082 1081
 				false, $filter) as $contact)
1083 1082
 			{
1084 1083
 				//error_log(__METHOD__."(".array2string($type).") do=".array2string($type)." migrating ".array2string($contact));
@@ -1087,7 +1086,7 @@  discard block
 block discarded – undo
1087 1086
 					$contact = $ldap_contacts->read($contact['id']);
1088 1087
 				}
1089 1088
 				$old_contact_id = $contact['id'];
1090
-				unset($contact['id']);	// ldap uid/account_lid
1089
+				unset($contact['id']); // ldap uid/account_lid
1091 1090
 				if ($contact['account_id'] && ($old = $sql_contacts->read(array('account_id' => $contact['account_id']))))
1092 1091
 				{
1093 1092
 					$contact['id'] = $old['id'];
@@ -1099,24 +1098,24 @@  discard block
 block discarded – undo
1099 1098
 				{
1100 1099
 					echo '<p style="margin: 0px;">'.$n.': '.$contact['n_fn'].
1101 1100
 						($contact['org_name'] ? ' ('.$contact['org_name'].')' : '')." --> SQL (".
1102
-						($contact['owner']?lang('User'):lang('Contact')).")<br>\n";
1101
+						($contact['owner'] ?lang('User') : lang('Contact')).")<br>\n";
1103 1102
 
1104 1103
 					$new_contact_id = $sql_contacts->data['id'];
1105
-					echo "&nbsp;&nbsp;&nbsp;&nbsp;" . $old_contact_id . " --> " . $new_contact_id . " / ";
1104
+					echo "&nbsp;&nbsp;&nbsp;&nbsp;".$old_contact_id." --> ".$new_contact_id." / ";
1106 1105
 
1107
-					$this->db->update('egw_links',array(
1106
+					$this->db->update('egw_links', array(
1108 1107
 						'link_id1' => $new_contact_id,
1109
-					),array(
1108
+					), array(
1110 1109
 						'link_app1' => 'addressbook',
1111 1110
 						'link_id1' => $old_contact_id
1112
-					),__LINE__,__FILE__);
1111
+					), __LINE__, __FILE__);
1113 1112
 
1114
-					$this->db->update('egw_links',array(
1113
+					$this->db->update('egw_links', array(
1115 1114
 						'link_id2' => $new_contact_id,
1116
-					),array(
1115
+					), array(
1117 1116
 						'link_app2' => 'addressbook',
1118 1117
 						'link_id2' => $old_contact_id
1119
-					),__LINE__,__FILE__);
1118
+					), __LINE__, __FILE__);
1120 1119
 					echo "</p>\n";
1121 1120
 				}
1122 1121
 				else
@@ -1136,25 +1135,25 @@  discard block
 block discarded – undo
1136 1135
 	 * @param string $extra_labels =null first labels if given (already translated)
1137 1136
 	 * @return array with id => label pairs or false if backend does not support lists
1138 1137
 	 */
1139
-	function get_lists($required=Api\Acl::READ,$extra_labels=null)
1138
+	function get_lists($required = Api\Acl::READ, $extra_labels = null)
1140 1139
 	{
1141 1140
 		$lists = is_array($extra_labels) ? $extra_labels : array();
1142 1141
 
1143
-		if (method_exists($this->somain,'get_lists'))
1142
+		if (method_exists($this->somain, 'get_lists'))
1144 1143
 		{
1145 1144
 			$uids = array();
1146
-			foreach($this->grants as $uid => $rights)
1145
+			foreach ($this->grants as $uid => $rights)
1147 1146
 			{
1148 1147
 				// only requests groups / list in accounts addressbook for read
1149 1148
 				if (!$uid && $required != Api\Acl::READ) continue;
1150 1149
 
1151
-				if (($rights & $required) == $required)
1150
+				if (($rights&$required) == $required)
1152 1151
 				{
1153 1152
 					$uids[] = $uid;
1154 1153
 				}
1155 1154
 			}
1156 1155
 
1157
-			foreach($this->somain->get_lists($uids) as $list_id => $data)
1156
+			foreach ($this->somain->get_lists($uids) as $list_id => $data)
1158 1157
 			{
1159 1158
 				$lists[$list_id] = $data['list_name'];
1160 1159
 				if ($data['list_owner'] != $this->user)
@@ -1169,7 +1168,7 @@  discard block
 block discarded – undo
1169 1168
 		if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1' &&
1170 1169
 				$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_groups_as_lists'] == '0')
1171 1170
 		{
1172
-			foreach($GLOBALS['egw']->accounts->search(array(
1171
+			foreach ($GLOBALS['egw']->accounts->search(array(
1173 1172
 				'type' => 'groups'
1174 1173
 			)) as $account_id => $group)
1175 1174
 			{
@@ -1188,12 +1187,12 @@  discard block
 block discarded – undo
1188 1187
 	 * @param boolean $limit_in_ab =false if true only return members from the same owners addressbook
1189 1188
 	 * @return array with list_id => array(list_id,list_name,list_owner,...) pairs
1190 1189
 	 */
1191
-	function read_lists($keys,$member_attr=null,$limit_in_ab=false)
1190
+	function read_lists($keys, $member_attr = null, $limit_in_ab = false)
1192 1191
 	{
1193 1192
 		$backend = (string)$limit_in_ab === '0' && $this->so_accounts ? $this->so_accounts : $this->somain;
1194 1193
 		if (!method_exists($backend, 'get_lists')) return false;
1195 1194
 
1196
-		return $backend->get_lists($keys,null,$member_attr,$limit_in_ab);
1195
+		return $backend->get_lists($keys, null, $member_attr, $limit_in_ab);
1197 1196
 	}
1198 1197
 
1199 1198
 	/**
@@ -1205,12 +1204,12 @@  discard block
 block discarded – undo
1205 1204
 	 * @param array &$data=array() values for keys 'list_uid', 'list_carddav_name', 'list_name'
1206 1205
 	 * @return int|boolean integer list_id or false on error
1207 1206
 	 */
1208
-	function add_list($keys,$owner,$contacts=array(),array &$data=array())
1207
+	function add_list($keys, $owner, $contacts = array(), array &$data = array())
1209 1208
 	{
1210 1209
 		$backend = (string)$owner === '0' && $this->so_accounts ? $this->so_accounts : $this->somain;
1211 1210
 		if (!method_exists($backend, 'add_list')) return false;
1212 1211
 
1213
-		return $backend->add_list($keys,$owner,$contacts,$data);
1212
+		return $backend->add_list($keys, $owner, $contacts, $data);
1214 1213
 	}
1215 1214
 
1216 1215
 	/**
@@ -1221,11 +1220,11 @@  discard block
 block discarded – undo
1221 1220
 	 * @param array $existing =null array of existing contact-id(s) of list, to not reread it, eg. array()
1222 1221
 	 * @return false on error
1223 1222
 	 */
1224
-	function add2list($contact,$list,array $existing=null)
1223
+	function add2list($contact, $list, array $existing = null)
1225 1224
 	{
1226
-		if (!method_exists($this->somain,'add2list')) return false;
1225
+		if (!method_exists($this->somain, 'add2list')) return false;
1227 1226
 
1228
-		return $this->somain->add2list($contact,$list,$existing);
1227
+		return $this->somain->add2list($contact, $list, $existing);
1229 1228
 	}
1230 1229
 
1231 1230
 	/**
@@ -1235,11 +1234,11 @@  discard block
 block discarded – undo
1235 1234
 	 * @param int $list =null list-id or null to remove from all lists
1236 1235
 	 * @return false on error
1237 1236
 	 */
1238
-	function remove_from_list($contact,$list=null)
1237
+	function remove_from_list($contact, $list = null)
1239 1238
 	{
1240
-		if (!method_exists($this->somain,'remove_from_list')) return false;
1239
+		if (!method_exists($this->somain, 'remove_from_list')) return false;
1241 1240
 
1242
-		return $this->somain->remove_from_list($contact,$list);
1241
+		return $this->somain->remove_from_list($contact, $list);
1243 1242
 	}
1244 1243
 
1245 1244
 	/**
@@ -1250,7 +1249,7 @@  discard block
 block discarded – undo
1250 1249
 	 */
1251 1250
 	function delete_list($list)
1252 1251
 	{
1253
-		if (!method_exists($this->somain,'delete_list')) return false;
1252
+		if (!method_exists($this->somain, 'delete_list')) return false;
1254 1253
 
1255 1254
 		return $this->somain->delete_list($list);
1256 1255
 	}
@@ -1263,7 +1262,7 @@  discard block
 block discarded – undo
1263 1262
 	 */
1264 1263
 	function read_list($list)
1265 1264
 	{
1266
-		if (!method_exists($this->somain,'read_list')) return false;
1265
+		if (!method_exists($this->somain, 'read_list')) return false;
1267 1266
 
1268 1267
 		return $this->somain->read_list($list);
1269 1268
 	}
@@ -1274,11 +1273,11 @@  discard block
 block discarded – undo
1274 1273
 	 * @param int|string $owner ='' addressbook (eg. 0 = accounts), default '' = "all" addressbook (uses the main backend)
1275 1274
 	 * @return boolean
1276 1275
 	 */
1277
-	function lists_available($owner='')
1276
+	function lists_available($owner = '')
1278 1277
 	{
1279
-		$backend =& $this->get_backend(null,$owner);
1278
+		$backend = & $this->get_backend(null, $owner);
1280 1279
 
1281
-		return method_exists($backend,'read_list');
1280
+		return method_exists($backend, 'read_list');
1282 1281
 	}
1283 1282
 
1284 1283
 	/**
@@ -1287,9 +1286,9 @@  discard block
 block discarded – undo
1287 1286
 	 * @param int|array $owner =null null for all lists user has access too
1288 1287
 	 * @return int
1289 1288
 	 */
1290
-	function lists_ctag($owner=null)
1289
+	function lists_ctag($owner = null)
1291 1290
 	{
1292
-		if (!method_exists($this->somain,'lists_ctag')) return 0;
1291
+		if (!method_exists($this->somain, 'lists_ctag')) return 0;
1293 1292
 
1294 1293
 		return $this->somain->lists_ctag($owner);
1295 1294
 	}
Please login to merge, or discard this patch.
Braces   +140 added lines, -35 removed lines patch added patch discarded remove patch
@@ -348,7 +348,10 @@  discard block
 block discarded – undo
348 348
 	 */
349 349
 	function get_grants($user, $contact_app='addressbook', $preferences=null)
350 350
 	{
351
-		if (!isset($preferences)) $preferences = $GLOBALS['egw_info']['user']['preferences'];
351
+		if (!isset($preferences))
352
+		{
353
+			$preferences = $GLOBALS['egw_info']['user']['preferences'];
354
+		}
352 355
 
353 356
 		if ($user)
354 357
 		{
@@ -376,12 +379,25 @@  discard block
 block discarded – undo
376 379
 				$grants[0] = Api\Acl::READ;
377 380
 			}
378 381
 			// add account grants for admins (only for current user!)
379
-			if ($user == $this->user && $this->is_admin())	// admin rights can be limited by ACL!
382
+			if ($user == $this->user && $this->is_admin())
383
+			{
384
+				// admin rights can be limited by ACL!
380 385
 			{
381
-				$grants[0] = Api\Acl::READ;	// admins always have read-access
382
-				if (!$GLOBALS['egw']->acl->check('account_access',16,'admin')) $grants[0] |= Api\Acl::EDIT;
383
-				if (!$GLOBALS['egw']->acl->check('account_access',4,'admin'))  $grants[0] |= Api\Acl::ADD;
384
-				if (!$GLOBALS['egw']->acl->check('account_access',32,'admin')) $grants[0] |= Api\Acl::DELETE;
386
+				$grants[0] = Api\Acl::READ;
387
+			}
388
+			// admins always have read-access
389
+				if (!$GLOBALS['egw']->acl->check('account_access',16,'admin'))
390
+				{
391
+					$grants[0] |= Api\Acl::EDIT;
392
+				}
393
+				if (!$GLOBALS['egw']->acl->check('account_access',4,'admin'))
394
+				{
395
+					$grants[0] |= Api\Acl::ADD;
396
+				}
397
+				if (!$GLOBALS['egw']->acl->check('account_access',32,'admin'))
398
+				{
399
+					$grants[0] |= Api\Acl::DELETE;
400
+				}
385 401
 			}
386 402
 			// allow certain groups to edit contact-data of accounts
387 403
 			if (self::allow_account_edit($user))
@@ -451,12 +467,22 @@  discard block
 block discarded – undo
451 467
 		}
452 468
 		foreach($ids as $key => $id)
453 469
 		{
454
-			if (!is_numeric($id)) unset($ids[$key]);
470
+			if (!is_numeric($id))
471
+			{
472
+				unset($ids[$key]);
473
+			}
474
+		}
475
+		if (!$ids)
476
+		{
477
+			return array();
455 478
 		}
456
-		if (!$ids) return array();	// nothing to do, eg. all these contacts are in ldap
479
+		// nothing to do, eg. all these contacts are in ldap
457 480
 		$fields = array();
458 481
 		$filter[$this->distri_id]=$ids;
459
-		if (count($dl_allowed)) $filter[$this->distri_key]=$dl_allowed;
482
+		if (count($dl_allowed))
483
+		{
484
+			$filter[$this->distri_key]=$dl_allowed;
485
+		}
460 486
 		$distri_view = str_replace(') d_view',' and '.$this->distri_id.' in ('.implode(',',$ids).')) d_view',$this->distributionlist_view);
461 487
 		#_debug_array($this->distributionlist_tabledef);
462 488
 		foreach($this->db->select($distri_view, '*', $filter, __LINE__, __FILE__,
@@ -506,10 +532,16 @@  discard block
 block discarded – undo
506 532
 	*/
507 533
 	function delete($contact,$check_etag=null)
508 534
 	{
509
-		if (is_array($contact)) $contact = $contact['id'];
535
+		if (is_array($contact))
536
+		{
537
+			$contact = $contact['id'];
538
+		}
510 539
 
511 540
 		$where = array('id' => $contact);
512
-		if ($check_etag) $where['etag'] = $check_etag;
541
+		if ($check_etag)
542
+		{
543
+			$where['etag'] = $check_etag;
544
+		}
513 545
 
514 546
 		// delete mainfields
515 547
 		if ($this->somain->delete($where))
@@ -586,7 +618,10 @@  discard block
 block discarded – undo
586 618
 				}
587 619
 			}
588 620
 		}
589
-		if($error_nr) return $error_nr;
621
+		if($error_nr)
622
+		{
623
+			return $error_nr;
624
+		}
590 625
 
591 626
 		return false;	// no error
592 627
 	}
@@ -614,7 +649,10 @@  discard block
 block discarded – undo
614 649
 			return $contact;
615 650
 		}
616 651
 		$dl_list=$this->read_distributionlist(array($contact['id']));
617
-		if (count($dl_list)) $contact['distrib_lists']=implode("\n",$dl_list[$contact['id']]);
652
+		if (count($dl_list))
653
+		{
654
+			$contact['distrib_lists']=implode("\n",$dl_list[$contact['id']]);
655
+		}
618 656
 		return $this->db2data($contact);
619 657
 	}
620 658
 
@@ -648,7 +686,10 @@  discard block
 block discarded – undo
648 686
 			unset($filter['adr_one_countrycode']);
649 687
 		}
650 688
 		// Hide deleted items unless type is specifically deleted
651
-		if(!is_array($filter)) $filter = $filter ? (array) $filter : array();
689
+		if(!is_array($filter))
690
+		{
691
+			$filter = $filter ? (array) $filter : array();
692
+		}
652 693
 
653 694
 		if (isset($filter['cols_to_search']))
654 695
 		{
@@ -659,10 +700,13 @@  discard block
 block discarded – undo
659 700
 		// if no tid set or tid==='' do NOT return deleted entries ($tid === null returns all entries incl. deleted)
660 701
 		if(!array_key_exists('tid', $filter) || $filter['tid'] === '')
661 702
 		{
662
-			if ($join && strpos($join,'RIGHT JOIN') !== false)	// used eg. to search for groups
703
+			if ($join && strpos($join,'RIGHT JOIN') !== false)
704
+			{
705
+				// used eg. to search for groups
663 706
 			{
664 707
 				$filter[] = '(contact_tid != \'' . self::DELETED_TYPE . '\' OR contact_tid IS NULL)';
665 708
 			}
709
+			}
666 710
 			else
667 711
 			{
668 712
 				$filter[] = 'contact_tid != \'' . self::DELETED_TYPE . '\'';
@@ -710,7 +754,10 @@  discard block
 block discarded – undo
710 754
 							unset($cols[$key]);
711 755
 						}
712 756
 					}
713
-					if ($col=='contact_id') $col='egw_addressbook.contact_id';
757
+					if ($col=='contact_id')
758
+					{
759
+						$col='egw_addressbook.contact_id';
760
+					}
714 761
 				}
715 762
 
716 763
 				$backend->columns_to_search = $cols;
@@ -785,7 +832,11 @@  discard block
 block discarded – undo
785 832
 			{
786 833
 				foreach($this->columns_to_search as $col)
787 834
 				{
788
-					if ($col != 'contact_value') $param['search'][$col] = $search;	// we dont search the customfields
835
+					if ($col != 'contact_value')
836
+					{
837
+						$param['search'][$col] = $search;
838
+					}
839
+					// we dont search the customfields
789 840
 				}
790 841
 			}
791 842
 		}
@@ -805,11 +856,17 @@  discard block
 block discarded – undo
805 856
 		$rows = $this->somain->organisations($param);
806 857
 		$this->total = $this->somain->total;
807 858
 
808
-		if (!$rows) return array();
859
+		if (!$rows)
860
+		{
861
+			return array();
862
+		}
809 863
 
810 864
 		foreach($rows as $n => $row)
811 865
 		{
812
-			if (strpos($row['org_name'],'&')!==false) $row['org_name'] = str_replace('&','*AND*',$row['org_name']);
866
+			if (strpos($row['org_name'],'&')!==false)
867
+			{
868
+				$row['org_name'] = str_replace('&','*AND*',$row['org_name']);
869
+			}
813 870
 			$rows[$n]['id'] = 'org_name:'.$row['org_name'];
814 871
 			foreach(array(
815 872
 				'org_unit' => lang('departments'),
@@ -822,7 +879,10 @@  discard block
 block discarded – undo
822 879
 				}
823 880
 				else
824 881
 				{
825
-					if (strpos($row[$by],'&')!==false) $row[$by] = str_replace('&','*AND*',$row[$by]);
882
+					if (strpos($row[$by],'&')!==false)
883
+					{
884
+						$row[$by] = str_replace('&','*AND*',$row[$by]);
885
+					}
826 886
 					$rows[$n]['id'] .= '|||'.$by.':'.$row[$by];
827 887
 				}
828 888
 			}
@@ -865,7 +925,10 @@  discard block
 block discarded – undo
865 925
 				foreach($this->columns_to_search as $col)
866 926
 				{
867 927
 					// we don't search the customfields
868
-					if ($col != 'contact_value') $param['search'][$col] = $search;
928
+					if ($col != 'contact_value')
929
+					{
930
+						$param['search'][$col] = $search;
931
+					}
869 932
 				}
870 933
 			}
871 934
 		}
@@ -897,14 +960,20 @@  discard block
 block discarded – undo
897 960
 		$rows = $this->somain->duplicates($param);
898 961
 		$this->total = $this->somain->total;
899 962
 
900
-		if (!$rows) return array();
963
+		if (!$rows)
964
+		{
965
+			return array();
966
+		}
901 967
 
902 968
 		foreach($rows as $n => $row)
903 969
 		{
904 970
 			$rows[$n]['id'] = 'duplicate:';
905 971
 			foreach(array_keys(static::$duplicate_fields) as $by)
906 972
 			{
907
-				if (strpos($row[$by],'&')!==false) $row[$by] = str_replace('&','*AND*',$row[$by]);
973
+				if (strpos($row[$by],'&')!==false)
974
+				{
975
+					$row[$by] = str_replace('&','*AND*',$row[$by]);
976
+				}
908 977
 				if($row[$by])
909 978
 				{
910 979
 					$rows[$n]['id'] .= '|||'.$by.':'.$row[$by];
@@ -966,7 +1035,10 @@  discard block
 block discarded – undo
966 1035
 	 */
967 1036
 	function get_backend($keys=null,$owner=null)
968 1037
 	{
969
-		if ($owner === '') $owner = null;
1038
+		if ($owner === '')
1039
+		{
1040
+			$owner = null;
1041
+		}
970 1042
 
971 1043
 		$contact_id = !is_array($keys) ? $keys :
972 1044
 			(isset($keys['id']) ? $keys['id'] : $keys['contact_id']);
@@ -1038,7 +1110,10 @@  discard block
 block discarded – undo
1038 1110
 			$ldap_contacts = new Ldap(null, $ds);
1039 1111
 		}
1040 1112
 
1041
-		if (!is_array($type)) $type = explode(',', $type);
1113
+		if (!is_array($type))
1114
+		{
1115
+			$type = explode(',', $type);
1116
+		}
1042 1117
 
1043 1118
 		$start = $n = 0;
1044 1119
 		$num = 100;
@@ -1054,7 +1129,10 @@  discard block
 block discarded – undo
1054 1129
 			{
1055 1130
 				foreach($contacts as $contact)
1056 1131
 				{
1057
-					if ($contact['account_id']) $contact['id'] = $GLOBALS['egw']->accounts->id2name($contact['account_id']);
1132
+					if ($contact['account_id'])
1133
+					{
1134
+						$contact['id'] = $GLOBALS['egw']->accounts->id2name($contact['account_id']);
1135
+					}
1058 1136
 
1059 1137
 					$ldap_contacts->data = $contact;
1060 1138
 					$n++;
@@ -1082,10 +1160,13 @@  discard block
 block discarded – undo
1082 1160
 				false, $filter) as $contact)
1083 1161
 			{
1084 1162
 				//error_log(__METHOD__."(".array2string($type).") do=".array2string($type)." migrating ".array2string($contact));
1085
-				if ($contact['jpegphoto'])	// photo is NOT read by LDAP backend on search, need to do an extra read
1163
+				if ($contact['jpegphoto'])
1164
+				{
1165
+					// photo is NOT read by LDAP backend on search, need to do an extra read
1086 1166
 				{
1087 1167
 					$contact = $ldap_contacts->read($contact['id']);
1088 1168
 				}
1169
+				}
1089 1170
 				$old_contact_id = $contact['id'];
1090 1171
 				unset($contact['id']);	// ldap uid/account_lid
1091 1172
 				if ($contact['account_id'] && ($old = $sql_contacts->read(array('account_id' => $contact['account_id']))))
@@ -1146,7 +1227,10 @@  discard block
 block discarded – undo
1146 1227
 			foreach($this->grants as $uid => $rights)
1147 1228
 			{
1148 1229
 				// only requests groups / list in accounts addressbook for read
1149
-				if (!$uid && $required != Api\Acl::READ) continue;
1230
+				if (!$uid && $required != Api\Acl::READ)
1231
+				{
1232
+					continue;
1233
+				}
1150 1234
 
1151 1235
 				if (($rights & $required) == $required)
1152 1236
 				{
@@ -1191,7 +1275,10 @@  discard block
 block discarded – undo
1191 1275
 	function read_lists($keys,$member_attr=null,$limit_in_ab=false)
1192 1276
 	{
1193 1277
 		$backend = (string)$limit_in_ab === '0' && $this->so_accounts ? $this->so_accounts : $this->somain;
1194
-		if (!method_exists($backend, 'get_lists')) return false;
1278
+		if (!method_exists($backend, 'get_lists'))
1279
+		{
1280
+			return false;
1281
+		}
1195 1282
 
1196 1283
 		return $backend->get_lists($keys,null,$member_attr,$limit_in_ab);
1197 1284
 	}
@@ -1208,7 +1295,10 @@  discard block
 block discarded – undo
1208 1295
 	function add_list($keys,$owner,$contacts=array(),array &$data=array())
1209 1296
 	{
1210 1297
 		$backend = (string)$owner === '0' && $this->so_accounts ? $this->so_accounts : $this->somain;
1211
-		if (!method_exists($backend, 'add_list')) return false;
1298
+		if (!method_exists($backend, 'add_list'))
1299
+		{
1300
+			return false;
1301
+		}
1212 1302
 
1213 1303
 		return $backend->add_list($keys,$owner,$contacts,$data);
1214 1304
 	}
@@ -1223,7 +1313,10 @@  discard block
 block discarded – undo
1223 1313
 	 */
1224 1314
 	function add2list($contact,$list,array $existing=null)
1225 1315
 	{
1226
-		if (!method_exists($this->somain,'add2list')) return false;
1316
+		if (!method_exists($this->somain,'add2list'))
1317
+		{
1318
+			return false;
1319
+		}
1227 1320
 
1228 1321
 		return $this->somain->add2list($contact,$list,$existing);
1229 1322
 	}
@@ -1237,7 +1330,10 @@  discard block
 block discarded – undo
1237 1330
 	 */
1238 1331
 	function remove_from_list($contact,$list=null)
1239 1332
 	{
1240
-		if (!method_exists($this->somain,'remove_from_list')) return false;
1333
+		if (!method_exists($this->somain,'remove_from_list'))
1334
+		{
1335
+			return false;
1336
+		}
1241 1337
 
1242 1338
 		return $this->somain->remove_from_list($contact,$list);
1243 1339
 	}
@@ -1250,7 +1346,10 @@  discard block
 block discarded – undo
1250 1346
 	 */
1251 1347
 	function delete_list($list)
1252 1348
 	{
1253
-		if (!method_exists($this->somain,'delete_list')) return false;
1349
+		if (!method_exists($this->somain,'delete_list'))
1350
+		{
1351
+			return false;
1352
+		}
1254 1353
 
1255 1354
 		return $this->somain->delete_list($list);
1256 1355
 	}
@@ -1263,7 +1362,10 @@  discard block
 block discarded – undo
1263 1362
 	 */
1264 1363
 	function read_list($list)
1265 1364
 	{
1266
-		if (!method_exists($this->somain,'read_list')) return false;
1365
+		if (!method_exists($this->somain,'read_list'))
1366
+		{
1367
+			return false;
1368
+		}
1267 1369
 
1268 1370
 		return $this->somain->read_list($list);
1269 1371
 	}
@@ -1289,7 +1391,10 @@  discard block
 block discarded – undo
1289 1391
 	 */
1290 1392
 	function lists_ctag($owner=null)
1291 1393
 	{
1292
-		if (!method_exists($this->somain,'lists_ctag')) return 0;
1394
+		if (!method_exists($this->somain,'lists_ctag'))
1395
+		{
1396
+			return 0;
1397
+		}
1293 1398
 
1294 1399
 		return $this->somain->lists_ctag($owner);
1295 1400
 	}
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php 2 patches
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,11 +46,13 @@  discard block
 block discarded – undo
46 46
 				'title' => $cat['description'],
47 47
 			);
48 48
 		}
49
-		if(count($cat_list) > 0) {
49
+		if(count($cat_list) > 0)
50
+		{
50 51
 			$this->mapping_fields[lang('Categories')] = $cat_list;
51 52
 		}
52 53
 
53
-		foreach($bocontacts->customfields as $name => $data) {
54
+		foreach($bocontacts->customfields as $name => $data)
55
+		{
54 56
 			$this->mapping_fields['#'.$name] = $data['label'];
55 57
 		}
56 58
 		unset($this->mapping_fields['jpegphoto']);        // can't cvs import that
@@ -75,7 +77,8 @@  discard block
 block discarded – undo
75 77
 
76 78
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
77 79
 	{
78
-		if($content['field_mapping'][0] == lang('Categories')) {
80
+		if($content['field_mapping'][0] == lang('Categories'))
81
+		{
79 82
 			unset($content['field_mapping'][0]);
80 83
 		}
81 84
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
@@ -86,7 +89,10 @@  discard block
 block discarded – undo
86 89
 
87 90
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
88 91
 	{
89
-		if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
92
+		if($this->debug)
93
+		{
94
+			error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
95
+		}
90 96
 		unset($content['no_owner_map']);
91 97
 		// return from step60
92 98
 		if ($content['step'] == 'wizard_step60')
@@ -108,13 +114,16 @@  discard block
 block discarded – undo
108 114
 		{
109 115
 			$content['msg'] = $this->steps['wizard_step60'];
110 116
 			$content['step'] = 'wizard_step60';
111
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
117
+			if(!array_key_exists($content['contact_owner']) && $content['plugin_options'])
118
+			{
112 119
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
113 120
 			}
114
-			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
121
+			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options'])
122
+			{
115 123
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
116 124
 			}
117
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
125
+			if(!array_key_exists($content['change_owner']) && $content['plugin_options'])
126
+			{
118 127
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
119 128
 			}
120 129
 
@@ -124,7 +133,8 @@  discard block
 block discarded – undo
124 133
 			{
125 134
 				$sel_options['contact_owner'][$content['contact_owner']] = lang("'%1' is not allowed ('%2')!", $content['contact_owner'], implode(',',array_keys($sel_options['contact_owner'])));
126 135
 			}
127
-			if(!in_array('owner', $content['field_mapping'])) {
136
+			if(!in_array('owner', $content['field_mapping']))
137
+			{
128 138
 				$content['no_owner_map'] = true;
129 139
 			}
130 140
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		$bocontacts = new Api\Contacts();
32 32
 		$this->mapping_fields = $bocontacts->contact_fields;
33 33
 
34
-		$categories = new Api\Categories('','addressbook');
34
+		$categories = new Api\Categories('', 'addressbook');
35 35
 		$cat_list = array();
36
-		foreach((array)$categories->return_sorted_array(0,False,'','','',true,0,true) as $cat)
36
+		foreach ((array)$categories->return_sorted_array(0, False, '', '', '', true, 0, true) as $cat)
37 37
 		{
38
-			$s = str_repeat('&nbsp;',$cat['level']) . stripslashes($cat['name']);
38
+			$s = str_repeat('&nbsp;', $cat['level']).stripslashes($cat['name']);
39 39
 
40 40
 			if (Api\Categories::is_global($cat))
41 41
 			{
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 				'title' => $cat['description'],
47 47
 			);
48 48
 		}
49
-		if(count($cat_list) > 0) {
49
+		if (count($cat_list) > 0) {
50 50
 			$this->mapping_fields[lang('Categories')] = $cat_list;
51 51
 		}
52 52
 
53
-		foreach($bocontacts->customfields as $name => $data) {
53
+		foreach ($bocontacts->customfields as $name => $data) {
54 54
 			$this->mapping_fields['#'.$name] = $data['label'];
55 55
 		}
56
-		unset($this->mapping_fields['jpegphoto']);        // can't cvs import that
56
+		unset($this->mapping_fields['jpegphoto']); // can't cvs import that
57 57
 
58 58
 		// Add in special handled fields
59 59
 		$this->mapping_fields[lang('Special')] = addressbook_import_contacts_csv::$special_fields;
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
 
76 76
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
77 77
 	{
78
-		if($content['field_mapping'][0] == lang('Categories')) {
78
+		if ($content['field_mapping'][0] == lang('Categories')) {
79 79
 			unset($content['field_mapping'][0]);
80 80
 		}
81 81
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
82
-		$content['msg'] .= "\n*" . lang('Contact ID cannot be changed by import');
82
+		$content['msg'] .= "\n*".lang('Contact ID cannot be changed by import');
83 83
 
84 84
 		return $result;
85 85
 	}
86 86
 
87 87
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
88 88
 	{
89
-		if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
89
+		if ($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content, true));
90 90
 		unset($content['no_owner_map']);
91 91
 		// return from step60
92 92
 		if ($content['step'] == 'wizard_step60')
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 			switch (array_search('pressed', $content['button']))
95 95
 			{
96 96
 				case 'next':
97
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
97
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
98 98
 				case 'previous' :
99
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
99
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
100 100
 				case 'finish':
101 101
 					return 'wizard_finish';
102 102
 				default :
103
-					return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
103
+					return $this->wizard_step60($content, $sel_options, $readonlys, $preserv);
104 104
 			}
105 105
 		}
106 106
 		// init step60
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 		{
109 109
 			$content['msg'] = $this->steps['wizard_step60'];
110 110
 			$content['step'] = 'wizard_step60';
111
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
111
+			if (!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
112 112
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
113 113
 			}
114
-			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
114
+			if (!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
115 115
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
116 116
 			}
117
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
117
+			if (!array_key_exists($content['change_owner']) && $content['plugin_options']) {
118 118
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
119 119
 			}
120 120
 
121 121
 			$bocontacts = new Api\Contacts();
122 122
 			$sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD);
123
-			if(!array_key_exists($content['contact_owner'], $sel_options['contact_owner']))
123
+			if (!array_key_exists($content['contact_owner'], $sel_options['contact_owner']))
124 124
 			{
125
-				$sel_options['contact_owner'][$content['contact_owner']] = lang("'%1' is not allowed ('%2')!", $content['contact_owner'], implode(',',array_keys($sel_options['contact_owner'])));
125
+				$sel_options['contact_owner'][$content['contact_owner']] = lang("'%1' is not allowed ('%2')!", $content['contact_owner'], implode(',', array_keys($sel_options['contact_owner'])));
126 126
 			}
127
-			if(!in_array('owner', $content['field_mapping'])) {
127
+			if (!in_array('owner', $content['field_mapping'])) {
128 128
 				$content['no_owner_map'] = true;
129 129
 			}
130 130
 
Please login to merge, or discard this patch.