Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
api/src/Etemplate/Request/Files.php 1 patch
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,12 +77,18 @@  discard block
 block discarded – undo
77 77
 		{
78 78
 			self::$directory = $GLOBALS['egw_info']['server']['temp_dir'];
79 79
 		}
80
-		if (!$id) $id = self::request_id();
80
+		if (!$id)
81
+		{
82
+			$id = self::request_id();
83
+		}
81 84
 
82 85
 		$this->id = $id;
83 86
 
84 87
 		// hack to quiten IDE Warning for not calling parent::__construct, which we can not!
85
-		if (false) parent::__construct();
88
+		if (false)
89
+		{
90
+			parent::__construct();
91
+		}
86 92
 	}
87 93
 
88 94
 	/**
@@ -114,7 +120,10 @@  discard block
 block discarded – undo
114 120
 				return false;
115 121
 			}
116 122
 			$request->data = unserialize(file_get_contents($filename));
117
-			if ($request->data === false) error_log("Error unserializing '$filename' to read the etemplate request data!");
123
+			if ($request->data === false)
124
+			{
125
+				error_log("Error unserializing '$filename' to read the etemplate request data!");
126
+			}
118 127
 		}
119 128
 		//error_log(__METHOD__."(id=$id");
120 129
 		return $request;
Please login to merge, or discard this patch.
api/src/Etemplate/Request/Cache.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,10 @@
 block discarded – undo
78 78
 		//error_log(__METHOD__."($_id) this->id=$this->id");
79 79
 
80 80
 		// hack to quiten IDE Warning for not calling parent::__construct, which we can not!
81
-		if (false) parent::__construct();
81
+		if (false)
82
+		{
83
+			parent::__construct();
84
+		}
82 85
 	}
83 86
 
84 87
 	/**
Please login to merge, or discard this patch.
api/src/MimeMagic.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,10 @@
 block discarded – undo
106 106
 	public static function mime2ext($_type)
107 107
 	{
108 108
 		$type = strtolower($_type);
109
-		if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type];
109
+		if (isset(self::$mime_alias_map[$type]))
110
+		{
111
+			$type = self::$mime_alias_map[$type];
112
+		}
110 113
 		$key = array_search($type, self::$mime_extension_map);
111 114
 		if (empty($type) || $key === false)
112 115
 		{
Please login to merge, or discard this patch.
api/src/Cache.php 1 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
 					}
@@ -371,7 +374,10 @@  discard block
 block discarded – undo
371 374
 		unset($expiration);	// not used, but required by function signature
372 375
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
373 376
 		{
374
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
377
+			if (Session::ERROR_LOG_DEBUG)
378
+			{
379
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
380
+			}
375 381
 			return false;	// can no longer store something in the session, eg. because commit_session() was called
376 382
 		}
377 383
 		$_SESSION[Session::EGW_APPSESSION_VAR][$app][$location] = $data;
@@ -396,7 +402,10 @@  discard block
 block discarded – undo
396 402
 		unset($expiration);	// not used, but required by function signature
397 403
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
398 404
 		{
399
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
405
+			if (Session::ERROR_LOG_DEBUG)
406
+			{
407
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
408
+			}
400 409
 			return null;	// can no longer store something in the session, eg. because commit_session() was called
401 410
 		}
402 411
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]) && !is_null($callback))
@@ -417,7 +426,10 @@  discard block
 block discarded – undo
417 426
 	{
418 427
 		if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED]))
419 428
 		{
420
-			if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!');
429
+			if (Session::ERROR_LOG_DEBUG)
430
+			{
431
+				error_log(__METHOD__.' called after session was encrypted --> ignored!');
432
+			}
421 433
 			return false;	// can no longer store something in the session, eg. because commit_session() was called
422 434
 		}
423 435
 		if (!isset($_SESSION[Session::EGW_APPSESSION_VAR][$app][$location]))
@@ -504,7 +516,10 @@  discard block
 block discarded – undo
504 516
 	{
505 517
 		static $providers = array();
506 518
 
507
-		if ($level != self::TREE) $level = self::INSTANCE;
519
+		if ($level != self::TREE)
520
+		{
521
+			$level = self::INSTANCE;
522
+		}
508 523
 
509 524
 		if (!isset($providers[$level]))
510 525
 		{
@@ -515,10 +530,13 @@  discard block
 block discarded – undo
515 530
 			}
516 531
 			if (!isset($params))
517 532
 			{
518
-				if ($level == self::TREE)	// if no tree level provider use the instance level one
533
+				if ($level == self::TREE)
534
+				{
535
+					// if no tree level provider use the instance level one
519 536
 				{
520 537
 					$providers[$level] = self::get_provider(self::INSTANCE);
521 538
 				}
539
+				}
522 540
 				else
523 541
 				{
524 542
 					$providers[$level] = false;	// no provider specified
@@ -532,7 +550,10 @@  discard block
 block discarded – undo
532 550
 			}
533 551
 			else
534 552
 			{
535
-				if (!is_array($params)) $params = (array)$params;
553
+				if (!is_array($params))
554
+				{
555
+					$params = (array)$params;
556
+				}
536 557
 
537 558
 				$class = array_shift($params);
538 559
 				if (!class_exists($class))
@@ -553,7 +574,10 @@  discard block
 block discarded – undo
553 574
 					}
554 575
 				}
555 576
 			}
556
-			if (!$providers[$level] && $log_not_found) error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
577
+			if (!$providers[$level] && $log_not_found)
578
+			{
579
+				error_log(__METHOD__."($level) no provider found ($reason)!".function_backtrace());
580
+			}
557 581
 		}
558 582
 		//error_log(__METHOD__."($level) = ".array2string($providers[$level]).', cache_provider='.array2string($GLOBALS['egw_info']['server']['cache_provider_'.strtolower($level)]));
559 583
 		return $providers[$level];
@@ -589,7 +613,11 @@  discard block
 block discarded – undo
589 613
 				}
590 614
 				catch(Db\Exception $e)
591 615
 				{
592
-					if ($throw) error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());//.function_backtrace());
616
+					if ($throw)
617
+					{
618
+						error_log(__METHOD__."('$name', $throw) cound NOT query value: ".$e->getMessage());
619
+					}
620
+					//.function_backtrace());
593 621
 				}
594 622
 			}
595 623
 			if (!$GLOBALS['egw_info']['server'][$name] && $throw)
@@ -697,7 +725,10 @@  discard block
 block discarded – undo
697 725
 				if ($level !== $GLOBALS['egw_info']['server']['install_id'])
698 726
 				{
699 727
 					$level_key = self::getTree(__CLASS__, $level);
700
-					if (!isset($level_key)) $level_key = self::generate_instance_key($level);
728
+					if (!isset($level_key))
729
+					{
730
+						$level_key = self::generate_instance_key($level);
731
+					}
701 732
 					break;
702 733
 				}
703 734
 				// fall-through for current instance
@@ -706,7 +737,10 @@  discard block
 block discarded – undo
706 737
 				{
707 738
 					self::$instance_key = self::getTree(__CLASS__, self::get_system_config('install_id'));
708 739
 					//error_log(__METHOD__."('$level',...) instance_key read from tree-cache=".array2string(self::$instance_key));
709
-					if (!isset(self::$instance_key)) self::$instance_key = self::generate_instance_key();
740
+					if (!isset(self::$instance_key))
741
+					{
742
+						self::$instance_key = self::generate_instance_key();
743
+					}
710 744
 				}
711 745
 				$level_key = self::$instance_key;
712 746
 				break;
@@ -715,7 +749,10 @@  discard block
 block discarded – undo
715 749
 		if (isset($app))
716 750
 		{
717 751
 			$keys[] = $app;
718
-			if (isset($location)) $keys[] = $location;
752
+			if (isset($location))
753
+			{
754
+				$keys[] = $location;
755
+			}
719 756
 		}
720 757
 		return $keys;
721 758
 	}
Please login to merge, or discard this patch.
api/src/Accounts/Ads.php 1 patch
Braces   +234 added lines, -78 removed lines patch added patch discarded remove patch
@@ -136,12 +136,21 @@  discard block
 block discarded – undo
136 136
 	public static function get_adldap(array &$config=null)
137 137
 	{
138 138
 		static $adldap = array();
139
-		if (!$config) $config =& $GLOBALS['egw_info']['server'];
139
+		if (!$config)
140
+		{
141
+			$config =& $GLOBALS['egw_info']['server'];
142
+		}
140 143
 
141 144
 		if (!isset($adldap[$config['ads_domain']]))
142 145
 		{
143
-			if (empty($config['ads_host'])) throw new Api\Exception("Required ADS host name(s) missing!");
144
-			if (empty($config['ads_domain'])) throw new Api\Exception("Required ADS domain missing!");
146
+			if (empty($config['ads_host']))
147
+			{
148
+				throw new Api\Exception("Required ADS host name(s) missing!");
149
+			}
150
+			if (empty($config['ads_domain']))
151
+			{
152
+				throw new Api\Exception("Required ADS domain missing!");
153
+			}
145 154
 
146 155
 			$base_dn_parts = array();
147 156
 			foreach(explode('.', $config['ads_domain']) as $dc)
@@ -160,7 +169,10 @@  discard block
 block discarded – undo
160 169
 				'charset' => Api\Translation::charset(),
161 170
 			);
162 171
 			$adldap[$config['ads_domain']] = new adLDAP($options);
163
-			if (self::$debug) error_log(__METHOD__."() new adLDAP(".array2string($options).") returned ".array2string($adldap[$config['ads_domain']]).' '.function_backtrace());
172
+			if (self::$debug)
173
+			{
174
+				error_log(__METHOD__."() new adLDAP(".array2string($options).") returned ".array2string($adldap[$config['ads_domain']]).' '.function_backtrace());
175
+			}
164 176
 		}
165 177
 		//else error_log(__METHOD__."() returning cached adLDAP ".array2string($adldap[$config['ads_domain']]).' '.function_backtrace());
166 178
 		return $adldap[$config['ads_domain']];
@@ -241,7 +253,10 @@  discard block
 block discarded – undo
241 253
 			throw new Api\Exception\WrongUserinput("Wrong or not configured ADS context '$context' (baseDN='$base')!");
242 254
 		}
243 255
 		$container = $matches[1];
244
-		if (self::$debug) error_log(__METHOD__."() context='$context', base='$base' returning ".array2string($container));
256
+		if (self::$debug)
257
+		{
258
+			error_log(__METHOD__."() context='$context', base='$base' returning ".array2string($container));
259
+		}
245 260
 		return $container;
246 261
 	}
247 262
 
@@ -334,10 +349,16 @@  discard block
 block discarded – undo
334 349
 	 */
335 350
 	public function read($account_id)
336 351
 	{
337
-		if (!(int)$account_id) return false;
352
+		if (!(int)$account_id)
353
+		{
354
+			return false;
355
+		}
338 356
 
339 357
 		$ret = $account_id < 0 ? $this->_read_group($account_id) : $this->_read_user($account_id);
340
-		if (self::$debug) error_log(__METHOD__."($account_id) returning ".array2string($ret));
358
+		if (self::$debug)
359
+		{
360
+			error_log(__METHOD__."($account_id) returning ".array2string($ret));
361
+		}
341 362
 		return $ret;
342 363
 	}
343 364
 
@@ -370,7 +391,10 @@  discard block
 block discarded – undo
370 391
 		}
371 392
 		$ret = $is_group ? $this->_save_group($data, $old) : $this->_save_user($data, $old);
372 393
 
373
-		if (self::$debug) error_log(__METHOD__.'('.array2string($data).') returning '.array2string($ret));
394
+		if (self::$debug)
395
+		{
396
+			error_log(__METHOD__.'('.array2string($data).') returning '.array2string($ret));
397
+		}
374 398
 		return $ret;
375 399
 	}
376 400
 
@@ -400,7 +424,10 @@  discard block
 block discarded – undo
400 424
 		{
401 425
 			$ret = $this->adldap->user()->delete($account_lid);
402 426
 		}
403
-		if (self::$debug) error_log(__METHOD__."($account_id) account_lid='$account_lid' returning ".array2string($ret));
427
+		if (self::$debug)
428
+		{
429
+			error_log(__METHOD__."($account_id) account_lid='$account_lid' returning ".array2string($ret));
430
+		}
404 431
 		return $ret;
405 432
 	}
406 433
 
@@ -562,11 +589,17 @@  discard block
 block discarded – undo
562 589
 	protected static function _when2ts($_when)
563 590
 	{
564 591
 		static $utc=null;
565
-		if (!isset($utc)) $utc = new \DateTimeZone('UTC');
592
+		if (!isset($utc))
593
+		{
594
+			$utc = new \DateTimeZone('UTC');
595
+		}
566 596
 
567 597
 		list($when) = explode('.', $_when);	// remove .0Z not understood by createFromFormat
568 598
 		$datetime = Api\DateTime::createFromFormat(self::WHEN_FORMAT, $when, $utc);
569
-		if (Api\DateTime::$server_timezone) $datetime->setTimezone(Api\DateTime::$server_timezone);
599
+		if (Api\DateTime::$server_timezone)
600
+		{
601
+			$datetime->setTimezone(Api\DateTime::$server_timezone);
602
+		}
570 603
 
571 604
 		return $datetime->getTimestamp();
572 605
 	}
@@ -583,12 +616,15 @@  discard block
 block discarded – undo
583 616
 	{
584 617
 		//error_log(__METHOD__.'('.array2string($data).', old='.array2string($old).')');
585 618
 
586
-		if (!$old)	// new entry
619
+		if (!$old)
620
+		{
621
+			// new entry
587 622
 		{
588 623
 			static $new2adldap = array(
589 624
 				'account_lid'       => 'group_name',
590 625
 				'account_description' => 'description',
591 626
 			);
627
+		}
592 628
 			$attributes = array();
593 629
 			foreach($new2adldap as $egw => $adldap)
594 630
 			{
@@ -668,7 +704,9 @@  discard block
 block discarded – undo
668 704
 			$data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
669 705
 		}
670 706
 
671
-		if (($new_entry = !$old))	// new entry
707
+		if (($new_entry = !$old))
708
+		{
709
+			// new entry
672 710
 		{
673 711
 			static $new2adldap = array(
674 712
 				'account_lid'       => 'username',
@@ -679,6 +717,7 @@  discard block
 block discarded – undo
679 717
 				'account_passwd'    => 'password',
680 718
 				'account_status'    => 'enabled',
681 719
 			);
720
+		}
682 721
 			$attributes = array();
683 722
 			foreach($new2adldap as $egw => $adldap)
684 723
 			{
@@ -687,7 +726,10 @@  discard block
 block discarded – undo
687 726
 				{
688 727
 					continue;	// do not try to set password, if no SSL or TLS, whole user creation will fail
689 728
 				}
690
-				if (isset($data[$egw])) $attributes[$adldap] = $data[$egw];
729
+				if (isset($data[$egw]))
730
+				{
731
+					$attributes[$adldap] = $data[$egw];
732
+				}
691 733
 			}
692 734
 			$attributes['enabled'] = !isset($data['account_status']) || $data['account_status'] === 'A';
693 735
 			$attributes['container'] = $this->_get_container();
@@ -773,7 +815,11 @@  discard block
 block discarded – undo
773 815
 							self::convertUnixTimeToWindowsTime($data[$egw]);
774 816
 						break;
775 817
 					case 'account_status':
776
-						if ($new_entry && empty($data['account_passwd'])) continue;	// cant active new account without passwd!
818
+						if ($new_entry && empty($data['account_passwd']))
819
+						{
820
+							continue;
821
+						}
822
+						// cant active new account without passwd!
777 823
 						$attributes[$adldap] = $data[$egw] == 'A';
778 824
 						break;
779 825
 					case 'account_lastpwd_change':
@@ -853,8 +899,14 @@  discard block
 block discarded – undo
853 899
 		}
854 900
 		// if it's a limited query, check if the unlimited query is cached
855 901
 		$start = $param['start'];
856
-		if (!($maxmatchs = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])) $maxmatchs = 15;
857
-		if (!($offset = $param['offset'])) $offset = $maxmatchs;
902
+		if (!($maxmatchs = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']))
903
+		{
904
+			$maxmatchs = 15;
905
+		}
906
+		if (!($offset = $param['offset']))
907
+		{
908
+			$offset = $maxmatchs;
909
+		}
858 910
 		unset($param['start']);
859 911
 		unset($param['offset']);
860 912
 		$unl_serial = serialize($param);
@@ -1051,7 +1103,10 @@  discard block
 block discarded – undo
1051 1103
 			$attrs ? $attrs : self::$default_attributes);
1052 1104
 		if (!$sri)
1053 1105
 		{
1054
-			if (self::$debug) error_log(__METHOD__.'('.array2string($attr_filter).", '$account_type') ldap_search($ds, '$context', '$filter') returned ".array2string($sri).' trying to reconnect ...');
1106
+			if (self::$debug)
1107
+			{
1108
+				error_log(__METHOD__.'('.array2string($attr_filter).", '$account_type') ldap_search($ds, '$context', '$filter') returned ".array2string($sri).' trying to reconnect ...');
1109
+			}
1055 1110
 			$sri = ldap_search($ds=$this->ldap_connection(true), $context=$this->ads_context(), $filter,
1056 1111
 				$attrs ? $attrs : self::$default_attributes);
1057 1112
 		}
@@ -1060,7 +1115,10 @@  discard block
 block discarded – undo
1060 1115
 		{
1061 1116
 			foreach($allValues as $key => $data)
1062 1117
 			{
1063
-				if ($key === 'count') continue;
1118
+				if ($key === 'count')
1119
+				{
1120
+					continue;
1121
+				}
1064 1122
 
1065 1123
 				if ($account_type && !($account_type == 'u' && $data['samaccounttype'][0] == adLDAP::ADLDAP_NORMAL_ACCOUNT ||
1066 1124
 					$account_type == 'g' && $data['samaccounttype'][0] == adLDAP::ADLDAP_SECURITY_GLOBAL_GROUP))
@@ -1078,7 +1136,10 @@  discard block
 block discarded – undo
1078 1136
 					$attrs ? $data : Api\Translation::convert($data['samaccountname'][0], 'utf-8');
1079 1137
 			}
1080 1138
 		}
1081
-		else if (self::$debug) error_log(__METHOD__.'('.array2string($attr_filter).", '$account_type') ldap_search($ds, '$context', '$filter')=$sri allValues=".array2string($allValues));
1139
+		else if (self::$debug)
1140
+		{
1141
+			error_log(__METHOD__.'('.array2string($attr_filter).", '$account_type') ldap_search($ds, '$context', '$filter')=$sri allValues=".array2string($allValues));
1142
+		}
1082 1143
 
1083 1144
 		//error_log(__METHOD__.'('.array2string($attr_filter).", '$account_type') ldap_search($ds, '$context', '$filter') returning ".array2string($accounts).' '.function_backtrace());
1084 1145
 		return $accounts;
@@ -1115,7 +1176,10 @@  discard block
 block discarded – undo
1115 1176
 				break;
1116 1177
 			}
1117 1178
 		}
1118
-		if (self::$debug) error_log(__METHOD__."('$name', '$which', '$account_type') returning ".array2string($ret));
1179
+		if (self::$debug)
1180
+		{
1181
+			error_log(__METHOD__."('$name', '$which', '$account_type') returning ".array2string($ret));
1182
+		}
1119 1183
 		return $ret;
1120 1184
 	}
1121 1185
 
@@ -1157,7 +1221,10 @@  discard block
 block discarded – undo
1157 1221
 	 */
1158 1222
 	function memberships($account_id)
1159 1223
 	{
1160
-		if (!($data = $this->frontend->read($account_id)) || $data['account_id'] <= 0) return false;
1224
+		if (!($data = $this->frontend->read($account_id)) || $data['account_id'] <= 0)
1225
+		{
1226
+			return false;
1227
+		}
1161 1228
 
1162 1229
 		return $data['memberships'];
1163 1230
 	}
@@ -1172,7 +1239,10 @@  discard block
 block discarded – undo
1172 1239
 	 */
1173 1240
 	function members($gid)
1174 1241
 	{
1175
-		if (!($data = $this->frontend->read($gid)) || $data['account_id'] >= 0) return false;
1242
+		if (!($data = $this->frontend->read($gid)) || $data['account_id'] >= 0)
1243
+		{
1244
+			return false;
1245
+		}
1176 1246
 
1177 1247
 		return $data['members'];
1178 1248
 	}
@@ -1186,7 +1256,10 @@  discard block
 block discarded – undo
1186 1256
 	 */
1187 1257
 	function set_memberships($groups,$account_id)
1188 1258
 	{
1189
-		if (!($account = $this->id2name($account_id))) return;
1259
+		if (!($account = $this->id2name($account_id)))
1260
+		{
1261
+			return;
1262
+		}
1190 1263
 		$current = array_keys($this->memberships($account_id));
1191 1264
 
1192 1265
 		$changed = 0;
@@ -1203,7 +1276,10 @@  discard block
 block discarded – undo
1203 1276
 				$changed += (int)$ok;
1204 1277
 			}
1205 1278
 		}
1206
-		if (self::$debug) error_log(__METHOD__.'('.array2string($groups).", $account_id) current=".array2string($current)." returning $changed");
1279
+		if (self::$debug)
1280
+		{
1281
+			error_log(__METHOD__.'('.array2string($groups).", $account_id) current=".array2string($current)." returning $changed");
1282
+		}
1207 1283
 		return $changed;
1208 1284
 	}
1209 1285
 
@@ -1216,7 +1292,10 @@  discard block
 block discarded – undo
1216 1292
 	 */
1217 1293
 	function set_members($users, $gid)
1218 1294
 	{
1219
-		if (!($group = $this->id2name($gid))) return;
1295
+		if (!($group = $this->id2name($gid)))
1296
+		{
1297
+			return;
1298
+		}
1220 1299
 		$current = array_keys($this->members($gid));
1221 1300
 
1222 1301
 		$changed = 0;
@@ -1233,7 +1312,10 @@  discard block
 block discarded – undo
1233 1312
 				$changed += (int)$ok;
1234 1313
 			}
1235 1314
 		}
1236
-		if (self::$debug) error_log(__METHOD__.'('.array2string($users).", $gid) current=".array2string($current)." returning $changed");
1315
+		if (self::$debug)
1316
+		{
1317
+			error_log(__METHOD__.'('.array2string($users).", $gid) current=".array2string($current)." returning $changed");
1318
+		}
1237 1319
 		return $changed;
1238 1320
 	}
1239 1321
 }
@@ -1287,8 +1369,10 @@  discard block
 block discarded – undo
1287 1369
 	 *
1288 1370
 	 * @return adLDAPUsers
1289 1371
 	 */
1290
-	public function user() {
1291
-		if (!$this->userClass) {
1372
+	public function user()
1373
+	{
1374
+		if (!$this->userClass)
1375
+		{
1292 1376
 			$this->userClass = new adLDAPUsers($this);
1293 1377
 		}
1294 1378
 		return $this->userClass;
@@ -1299,8 +1383,10 @@  discard block
 block discarded – undo
1299 1383
     *
1300 1384
     * @return adLDAPGroups
1301 1385
     */
1302
-    public function group() {
1303
-        if (!$this->groupClass) {
1386
+    public function group()
1387
+    {
1388
+        if (!$this->groupClass)
1389
+        {
1304 1390
             $this->groupClass = new adLDAPGroups($this);
1305 1391
         }
1306 1392
         return $this->groupClass;
@@ -1311,8 +1397,10 @@  discard block
 block discarded – undo
1311 1397
     *
1312 1398
     * @return adLDAPUtils
1313 1399
     */
1314
-    public function utilities() {
1315
-        if (!$this->utilClass) {
1400
+    public function utilities()
1401
+    {
1402
+        if (!$this->utilClass)
1403
+        {
1316 1404
             $this->utilClass = new adLDAPUtils($this);
1317 1405
         }
1318 1406
         return $this->utilClass;
@@ -1340,18 +1428,32 @@  discard block
 block discarded – undo
1340 1428
 	public function create($attributes)
1341 1429
 	{
1342 1430
 		// Check for compulsory fields
1343
-		if (!array_key_exists("username", $attributes)){ return "Missing compulsory field [username]"; }
1344
-		if (!array_key_exists("firstname", $attributes)){ return "Missing compulsory field [firstname]"; }
1345
-		if (!array_key_exists("surname", $attributes)){ return "Missing compulsory field [surname]"; }
1346
-		if (!array_key_exists("email", $attributes)){ return "Missing compulsory field [email]"; }
1347
-		if (!array_key_exists("container", $attributes)){ return "Missing compulsory field [container]"; }
1348
-		if (empty($attributes["container"])){ return "Container attribute must be an array or string."; }
1349
-
1350
-		if (array_key_exists("password",$attributes) && (!$this->adldap->getUseSSL() && !$this->adldap->getUseTLS())){
1431
+		if (!array_key_exists("username", $attributes))
1432
+		{
1433
+return "Missing compulsory field [username]"; }
1434
+		if (!array_key_exists("firstname", $attributes))
1435
+		{
1436
+return "Missing compulsory field [firstname]"; }
1437
+		if (!array_key_exists("surname", $attributes))
1438
+		{
1439
+return "Missing compulsory field [surname]"; }
1440
+		if (!array_key_exists("email", $attributes))
1441
+		{
1442
+return "Missing compulsory field [email]"; }
1443
+		if (!array_key_exists("container", $attributes))
1444
+		{
1445
+return "Missing compulsory field [container]"; }
1446
+		if (empty($attributes["container"]))
1447
+		{
1448
+return "Container attribute must be an array or string."; }
1449
+
1450
+		if (array_key_exists("password",$attributes) && (!$this->adldap->getUseSSL() && !$this->adldap->getUseTLS()))
1451
+		{
1351 1452
 			throw new adLDAPException('SSL must be configured on your webserver and enabled in the class to set passwords.');
1352 1453
 		}
1353 1454
 
1354
-		if (!array_key_exists("display_name", $attributes)) {
1455
+		if (!array_key_exists("display_name", $attributes))
1456
+		{
1355 1457
 			$attributes["display_name"] = $attributes["firstname"] . " " . $attributes["surname"];
1356 1458
 		}
1357 1459
 
@@ -1373,7 +1475,8 @@  discard block
 block discarded – undo
1373 1475
 		$add["userAccountControl"][0] = $this->accountControl($control_options);
1374 1476
 
1375 1477
 		// Determine the container
1376
-		if (is_array($attributes['container'])) {
1478
+		if (is_array($attributes['container']))
1479
+		{
1377 1480
 			$attributes["container"] = array_reverse($attributes["container"]);
1378 1481
 			$attributes["container"] = "OU=" . implode(",OU=",$attributes["container"]);
1379 1482
 		}
@@ -1382,7 +1485,8 @@  discard block
 block discarded – undo
1382 1485
 
1383 1486
 		// Add the entry
1384 1487
 		$result = ldap_add($ds=$this->adldap->getLdapConnection(), $dn="CN=" . $add["cn"][0] . "," . $attributes["container"] . "," . $this->adldap->getBaseDn(), $add);
1385
-		if ($result != true) {
1488
+		if ($result != true)
1489
+		{
1386 1490
 			error_log(__METHOD__."(".array2string($attributes).") ldap_add($ds, '$dn', ".array2string($add).") returned ".array2string($result)." ldap_error()=".ldap_error($ds));
1387 1491
 			return false;
1388 1492
 		}
@@ -1390,7 +1494,10 @@  discard block
 block discarded – undo
1390 1494
 		// now password can be added to still disabled account
1391 1495
 		if (array_key_exists("password",$attributes))
1392 1496
 		{
1393
-			if (!$this->setPassword($dn, $attributes['password'])) return false;
1497
+			if (!$this->setPassword($dn, $attributes['password']))
1498
+			{
1499
+				return false;
1500
+			}
1394 1501
 
1395 1502
 			// now account can be enabled
1396 1503
 			if ($attributes["enabled"])
@@ -1398,7 +1505,10 @@  discard block
 block discarded – undo
1398 1505
 				$control_options = array("NORMAL_ACCOUNT");
1399 1506
 				$mod = array("userAccountControl" => $this->accountControl($control_options));
1400 1507
 				$result = ldap_modify($ds, $dn, $mod);
1401
-				if (!$result) error_log(__METHOD__."(".array2string($attributes).") ldap_modify($ds, '$dn', ".array2string($mod).") returned ".array2string($result)." ldap_error()=".ldap_error($ds));
1508
+				if (!$result)
1509
+				{
1510
+					error_log(__METHOD__."(".array2string($attributes).") ldap_modify($ds, '$dn', ".array2string($mod).") returned ".array2string($result)." ldap_error()=".ldap_error($ds));
1511
+				}
1402 1512
 			}
1403 1513
 		}
1404 1514
 
@@ -1421,7 +1531,9 @@  discard block
 block discarded – undo
1421 1531
             return mb_convert_encoding($password, 'UTF-16LE', $this->adldap->charset);
1422 1532
         }
1423 1533
         $encoded="";
1424
-        for ($i=0; $i <strlen($password); $i++){ $encoded.="{$password{$i}}\000"; }
1534
+        for ($i=0; $i <strlen($password); $i++)
1535
+        {
1536
+$encoded.="{$password{$i}}\000"; }
1425 1537
         return $encoded;
1426 1538
     }
1427 1539
 
@@ -1441,7 +1553,10 @@  discard block
 block discarded – undo
1441 1553
     	$result = ldap_mod_replace($ds=$this->adldap->getLdapConnection(), $dn, array(
1442 1554
     		'unicodePwd' => $this->encodePassword($password),
1443 1555
     	));
1444
-    	if (!$result) error_log(__METHOD__."('$dn', '$password') ldap_mod_replace($ds, '$dn', \$password) returned FALSE: ".ldap_error($ds));
1556
+    	if (!$result)
1557
+    	{
1558
+    		error_log(__METHOD__."('$dn', '$password') ldap_mod_replace($ds, '$dn', \$password) returned FALSE: ".ldap_error($ds));
1559
+    	}
1445 1560
     	return $result;
1446 1561
     }
1447 1562
 
@@ -1468,26 +1583,36 @@  discard block
 block discarded – undo
1468 1583
     */
1469 1584
     public function password($username, $password, $isGUID = false, $old_password=null)
1470 1585
     {
1471
-        if ($username === NULL) { return false; }
1472
-        if ($password === NULL) { return false; }
1473
-        if (!$this->adldap->getLdapBind()) { return false; }
1474
-        if (!$this->adldap->getUseSSL() && !$this->adldap->getUseTLS()) {
1586
+        if ($username === NULL)
1587
+        {
1588
+return false; }
1589
+        if ($password === NULL)
1590
+        {
1591
+return false; }
1592
+        if (!$this->adldap->getLdapBind())
1593
+        {
1594
+return false; }
1595
+        if (!$this->adldap->getUseSSL() && !$this->adldap->getUseTLS())
1596
+        {
1475 1597
             throw new adLDAPException('SSL must be configured on your webserver and enabled in the class to set passwords.');
1476 1598
         }
1477 1599
 
1478 1600
         $userDn = $this->dn($username, $isGUID);
1479
-        if ($userDn === false) {
1601
+        if ($userDn === false)
1602
+        {
1480 1603
             return false;
1481 1604
         }
1482 1605
 
1483 1606
         $add=array();
1484 1607
 
1485
-		if (empty($old_password) || !function_exists('ldap_modify_batch')) {
1608
+		if (empty($old_password) || !function_exists('ldap_modify_batch'))
1609
+		{
1486 1610
 			$add["unicodePwd"][0] = $this->encodePassword($password);
1487 1611
 
1488 1612
 			$result = @ldap_mod_replace($this->adldap->getLdapConnection(), $userDn, $add);
1489 1613
 		}
1490
-		else {
1614
+		else
1615
+		{
1491 1616
 			$mods = array(
1492 1617
 				array(
1493 1618
 					"attrib"  => "unicodePwd",
@@ -1502,16 +1627,20 @@  discard block
 block discarded – undo
1502 1627
 			);
1503 1628
 			$result = ldap_modify_batch($this->adldap->getLdapConnection(), $userDn, $mods);
1504 1629
 		}
1505
-        if ($result === false){
1630
+        if ($result === false)
1631
+        {
1506 1632
             $err = ldap_errno($this->adldap->getLdapConnection());
1507
-            if ($err) {
1633
+            if ($err)
1634
+            {
1508 1635
                 $msg = 'Error ' . $err . ': ' . ldap_err2str($err) . '.';
1509
-                if($err == 53) {
1636
+                if($err == 53)
1637
+                {
1510 1638
                     $msg .= ' Your password might not match the password policy.';
1511 1639
                 }
1512 1640
                 throw new adLDAPException($msg);
1513 1641
             }
1514
-            else {
1642
+            else
1643
+            {
1515 1644
                 return false;
1516 1645
             }
1517 1646
         }
@@ -1529,14 +1658,18 @@  discard block
 block discarded – undo
1529 1658
     */
1530 1659
     public function modify($username, $attributes, $isGUID = false)
1531 1660
     {
1532
-        if ($username === NULL) { return "Missing compulsory field [username]"; }
1533
-        if (array_key_exists("password", $attributes) && !$this->adldap->getUseSSL() && !$this->adldap->getUseTLS()) {
1661
+        if ($username === NULL)
1662
+        {
1663
+return "Missing compulsory field [username]"; }
1664
+        if (array_key_exists("password", $attributes) && !$this->adldap->getUseSSL() && !$this->adldap->getUseTLS())
1665
+        {
1534 1666
             throw new adLDAPException('SSL/TLS must be configured on your webserver and enabled in the class to set passwords.');
1535 1667
         }
1536 1668
 
1537 1669
         // Find the dn of the user
1538 1670
         $userDn = $this->dn($username, $isGUID);
1539
-        if ($userDn === false) {
1671
+        if ($userDn === false)
1672
+        {
1540 1673
             return false;
1541 1674
         }
1542 1675
 
@@ -1544,16 +1677,20 @@  discard block
 block discarded – undo
1544 1677
         $mod = $this->adldap->adldap_schema($attributes);
1545 1678
 
1546 1679
         // Check to see if this is an enabled status update
1547
-        if (!$mod && !array_key_exists("enabled", $attributes)){
1680
+        if (!$mod && !array_key_exists("enabled", $attributes))
1681
+        {
1548 1682
             return false;
1549 1683
         }
1550 1684
 
1551 1685
         // Set the account control attribute (only if specified)
1552
-        if (array_key_exists("enabled", $attributes)){
1553
-            if ($attributes["enabled"]){
1686
+        if (array_key_exists("enabled", $attributes))
1687
+        {
1688
+            if ($attributes["enabled"])
1689
+            {
1554 1690
                 $controlOptions = array("NORMAL_ACCOUNT");
1555 1691
             }
1556
-            else {
1692
+            else
1693
+            {
1557 1694
                 $controlOptions = array("NORMAL_ACCOUNT", "ACCOUNTDISABLE");
1558 1695
             }
1559 1696
             $mod["userAccountControl"][0] = $this->accountControl($controlOptions);
@@ -1565,14 +1702,18 @@  discard block
 block discarded – undo
1565 1702
 		{
1566 1703
 	        // Do the update
1567 1704
 	        $result = @ldap_modify($ds=$this->adldap->getLdapConnection(), $userDn, $mod);
1568
-	        if ($result == false) {
1569
-				if (isset($mod['unicodePwd'])) $mod['unicodePwd'] = '***';
1705
+	        if ($result == false)
1706
+	        {
1707
+				if (isset($mod['unicodePwd']))
1708
+				{
1709
+					$mod['unicodePwd'] = '***';
1710
+				}
1570 1711
 				error_log(__METHOD__."(".array2string($attributes).") ldap_modify($ds, '$userDn', ".array2string($mod).") returned ".array2string($result)." ldap_error()=".ldap_error($ds));
1571 1712
 	        	return false;
1572 1713
 	        }
1573 1714
 		}
1574 1715
         if (array_key_exists("password",$attributes) && !$this->setPassword($userDn, $attributes['password']))
1575
-		{
1716
+        {
1576 1717
 			return false;
1577 1718
 		}
1578 1719
 		return true;
@@ -1594,10 +1735,18 @@  discard block
 block discarded – undo
1594 1735
 	 */
1595 1736
 	public function create($attributes)
1596 1737
 	{
1597
-		if (!is_array($attributes)){ return "Attributes must be an array"; }
1598
-		if (!array_key_exists("group_name", $attributes)){ return "Missing compulsory field [group_name]"; }
1599
-		if (!array_key_exists("container", $attributes)){ return "Missing compulsory field [container]"; }
1600
-		if (empty($attributes["container"])){ return "Container attribute must be an array or string."; }
1738
+		if (!is_array($attributes))
1739
+		{
1740
+return "Attributes must be an array"; }
1741
+		if (!array_key_exists("group_name", $attributes))
1742
+		{
1743
+return "Missing compulsory field [group_name]"; }
1744
+		if (!array_key_exists("container", $attributes))
1745
+		{
1746
+return "Missing compulsory field [container]"; }
1747
+		if (empty($attributes["container"]))
1748
+		{
1749
+return "Container attribute must be an array or string."; }
1601 1750
 
1602 1751
 		//$member_array = array();
1603 1752
 		//$member_array[0] = "cn=user1,cn=Users,dc=yourdomain,dc=com";
@@ -1607,16 +1756,21 @@  discard block
 block discarded – undo
1607 1756
 		$add["cn"] = $attributes["group_name"];
1608 1757
 		$add["samaccountname"] = $attributes["group_name"];
1609 1758
 		$add["objectClass"] = "Group";
1610
-		if (!empty($attributes["description"])) $add["description"] = $attributes["description"];
1759
+		if (!empty($attributes["description"]))
1760
+		{
1761
+			$add["description"] = $attributes["description"];
1762
+		}
1611 1763
 		//$add["member"] = $member_array; UNTESTED
1612 1764
 
1613 1765
 		// Determine the container
1614
-		if (is_array($attributes['container'])) {
1766
+		if (is_array($attributes['container']))
1767
+		{
1615 1768
 			$attributes["container"] = array_reverse($attributes["container"]);
1616 1769
 			$attributes["container"] = "OU=" . implode(",OU=",$attributes["container"]);
1617 1770
 		}
1618 1771
 		$result = ldap_add($this->adldap->getLdapConnection(), "CN=" . $add["cn"] . "," . $attributes["container"] . "," . $this->adldap->getBaseDn(), $add);
1619
-		if ($result != true) {
1772
+		if ($result != true)
1773
+		{
1620 1774
 			return false;
1621 1775
 		}
1622 1776
 		return true;
@@ -1646,10 +1800,12 @@  discard block
 block discarded – undo
1646 1800
     * @author Port by Andreas Gohr <[email protected]>
1647 1801
     * @return string
1648 1802
     */
1649
-    public function ldapSlashes($str){
1803
+    public function ldapSlashes($str)
1804
+    {
1650 1805
         return preg_replace_callback(
1651 1806
       		'/([\x00-\x1F\*\(\)\\\\])/',
1652
-        	function ($matches) {
1807
+        	function ($matches)
1808
+        	{
1653 1809
             	return "\\".join("", unpack("H2", $matches[1]));
1654 1810
         	},
1655 1811
         	$str
Please login to merge, or discard this patch.
api/src/Accounts/Sql.php 1 patch
Braces   +94 added lines, -23 removed lines patch added patch discarded remove patch
@@ -122,7 +122,10 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	function read($account_id)
124 124
 	{
125
-		if (!(int)$account_id) return false;
125
+		if (!(int)$account_id)
126
+		{
127
+			return false;
128
+		}
126 129
 
127 130
 		if ($account_id > 0)
128 131
 		{
@@ -152,11 +155,14 @@  discard block
 block discarded – undo
152 155
 			unset($e);
153 156
 		}
154 157
 
155
-		if (!$rs)	// handle not (yet) existing mailaccounts table
158
+		if (!$rs)
159
+		{
160
+			// handle not (yet) existing mailaccounts table
156 161
 		{
157 162
 			$rs = $this->db->select($this->table, $this->table.'.*',
158 163
 				$this->table.'.account_id='.abs($account_id), __LINE__, __FILE__);
159 164
 		}
165
+		}
160 166
 		if (!$rs || !($data = $rs->fetch()))
161 167
 		{
162 168
 			return false;
@@ -166,7 +172,10 @@  discard block
 block discarded – undo
166 172
 			$data['account_id'] = -$data['account_id'];
167 173
 			$data['mailAllowed'] = true;
168 174
 		}
169
-		if (!$data['account_firstname']) $data['account_firstname'] = $data['account_lid'];
175
+		if (!$data['account_firstname'])
176
+		{
177
+			$data['account_firstname'] = $data['account_lid'];
178
+		}
170 179
 		if (!$data['account_lastname'])
171 180
 		{
172 181
 			$data['account_lastname'] = $data['account_type'] == 'g' ? 'Group' : 'User';
@@ -177,7 +186,10 @@  discard block
 block discarded – undo
177 186
 				$data['account_lastname'] = lang($data['account_lastname']);
178 187
 			}
179 188
 		}
180
-		if (!$data['account_fullname']) $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
189
+		if (!$data['account_fullname'])
190
+		{
191
+			$data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
192
+		}
181 193
 
182 194
 		return $data;
183 195
 	}
@@ -199,31 +211,57 @@  discard block
 block discarded – undo
199 211
 		{
200 212
 			// if password it's not already entcrypted, do so now
201 213
 			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
202
-				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))	// md5 hash
214
+				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))
215
+			{
216
+				// md5 hash
203 217
 			{
204 218
 				$data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']);
205 219
 			}
220
+			}
206 221
 			$to_write['account_pwd'] = $data['account_passwd'];
207 222
 			$to_write['account_lastpwd_change'] = time();
208 223
 		}
209
-		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0;
224
+		if ($data['mustchangepassword'] == 1)
225
+		{
226
+			$to_write['account_lastpwd_change']=0;
227
+		}
210 228
 		if (!(int)$data['account_id'] || !$this->id2name($data['account_id']))
211 229
 		{
212
-			if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1;
230
+			if ($to_write['account_id'] < 0)
231
+			{
232
+				$to_write['account_id'] *= -1;
233
+			}
213 234
 
214
-			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = '';	// is NOT NULL!
215
-			if (!isset($to_write['account_status'])) $to_write['account_status'] = '';	// is NOT NULL!
235
+			if (!isset($to_write['account_pwd']))
236
+			{
237
+				$to_write['account_pwd'] = '';
238
+			}
239
+			// is NOT NULL!
240
+			if (!isset($to_write['account_status']))
241
+			{
242
+				$to_write['account_status'] = '';
243
+			}
244
+			// is NOT NULL!
216 245
 
217 246
 			// postgres requires the auto-id field to be unset!
218
-			if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']);
247
+			if (isset($to_write['account_id']) && !$to_write['account_id'])
248
+			{
249
+				unset($to_write['account_id']);
250
+			}
219 251
 
220 252
 			if (!in_array($to_write['account_type'],array('u','g')) ||
221
-				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false;
253
+				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__))
254
+			{
255
+				return false;
256
+			}
222 257
 
223 258
 			if (!(int)$data['account_id'])
224 259
 			{
225 260
 				$data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id');
226
-				if ($data['account_type'] == 'g') $data['account_id'] *= -1;
261
+				if ($data['account_type'] == 'g')
262
+				{
263
+					$data['account_id'] *= -1;
264
+				}
227 265
 			}
228 266
 		}
229 267
 		else	// update of existing account
@@ -276,7 +314,10 @@  discard block
 block discarded – undo
276 314
 	 */
277 315
 	function delete($account_id)
278 316
 	{
279
-		if (!(int)$account_id) return false;
317
+		if (!(int)$account_id)
318
+		{
319
+			return false;
320
+		}
280 321
 
281 322
 		$contact_id = $this->id2name($account_id,'person_id');
282 323
 
@@ -286,7 +327,10 @@  discard block
 block discarded – undo
286 327
 		}
287 328
 		if ($contact_id)
288 329
 		{
289
-			if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
330
+			if (!isset($this->contacts))
331
+			{
332
+				$this->contacts = new Api\Contacts();
333
+			}
290 334
 			$this->contacts->delete($contact_id,false);	// false = allow to delete accounts (!)
291 335
 		}
292 336
 		return true;
@@ -300,7 +344,10 @@  discard block
 block discarded – undo
300 344
 	 */
301 345
 	function memberships($account_id)
302 346
 	{
303
-		if (!(int)$account_id) return false;
347
+		if (!(int)$account_id)
348
+		{
349
+			return false;
350
+		}
304 351
 
305 352
 		$memberships = array();
306 353
 		if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
@@ -321,7 +368,10 @@  discard block
 block discarded – undo
321 368
 	 */
322 369
 	function set_memberships($groups,$account_id)
323 370
 	{
324
-		if (!(int)$account_id) return;
371
+		if (!(int)$account_id)
372
+		{
373
+			return;
374
+		}
325 375
 
326 376
 		$acl = new Api\Acl($account_id);
327 377
 		$acl->read_repository();
@@ -342,7 +392,10 @@  discard block
 block discarded – undo
342 392
 	 */
343 393
 	function members($account_id)
344 394
 	{
345
-		if (!is_numeric($account_id)) $account_id = $this->name2id($account_id);
395
+		if (!is_numeric($account_id))
396
+		{
397
+			$account_id = $this->name2id($account_id);
398
+		}
346 399
 
347 400
 		$members = array();
348 401
 		foreach($this->db->select($this->table, 'account_id,account_lid',
@@ -418,7 +471,10 @@  discard block
 block discarded – undo
418 471
 		{
419 472
 			$order .= ($order?',':'').'account_lid';
420 473
 		}
421
-		if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
474
+		if ($param['sort'])
475
+		{
476
+			$order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
477
+		}
422 478
 
423 479
 		$search_cols = array('account_lid','n_family','n_given','email');
424 480
 		$join = $this->contacts_join;
@@ -455,7 +511,10 @@  discard block
 block discarded – undo
455 511
 				{
456 512
 					unset($name);
457 513
 					$members = array_unique(array_merge($members, array_keys((array)$this->members($grp))));
458
-					if ($param['type'] == 'groupmembers+memberships') $members[] = abs($grp);
514
+					if ($param['type'] == 'groupmembers+memberships')
515
+					{
516
+						$members[] = abs($grp);
517
+					}
459 518
 				}
460 519
 				$filter['account_id'] = $members;
461 520
 				break;
@@ -474,9 +533,12 @@  discard block
 block discarded – undo
474 533
 		// fix ambigous account_id (used in accounts and contacts table)
475 534
 		if (array_key_exists('account_id', $filter))
476 535
 		{
477
-			if (!$filter['account_id'])	// eg. group without members (would give SQL error)
536
+			if (!$filter['account_id'])
537
+			{
538
+				// eg. group without members (would give SQL error)
478 539
 			{
479 540
 				$this->total = 0;
541
+			}
480 542
 				return array();
481 543
 			}
482 544
 			$filter[] = $this->db->expression($this->table, $this->table.'.', array(
@@ -528,7 +590,10 @@  discard block
 block discarded – undo
528 590
 					break;
529 591
 			}
530 592
 		}
531
-		if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
593
+		if (!isset($this->contacts))
594
+		{
595
+			$this->contacts = new Api\Contacts();
596
+		}
532 597
 
533 598
 		$accounts = array();
534 599
 		foreach((array) $this->contacts->search($criteria,
@@ -578,7 +643,10 @@  discard block
 block discarded – undo
578 643
 	 */
579 644
 	function name2id($name,$which='account_lid',$account_type=null)
580 645
 	{
581
-		if ($account_type === 'g' && $which != 'account_lid') return false;
646
+		if ($account_type === 'g' && $which != 'account_lid')
647
+		{
648
+			return false;
649
+		}
582 650
 
583 651
 		$where = array();
584 652
 		$cols = 'account_id';
@@ -601,9 +669,12 @@  discard block
 block discarded – undo
601 669
 				$cols .= ',account_type';
602 670
 				$where[$which] = $name;
603 671
 				// check if we need to treat username case-insensitive
604
-				if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username'])	// = is case sensitiv eg. on postgres, but not on mysql!
672
+				if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username'])
673
+				{
674
+					// = is case sensitiv eg. on postgres, but not on mysql!
605 675
 				{
606 676
 					$where[] = 'account_lid '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote($where['account_lid']);
677
+				}
607 678
 					unset($where['account_lid']);
608 679
 				}
609 680
 		}
Please login to merge, or discard this patch.
api/src/Cache/Memcache.php 1 patch
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,11 @@
 block discarded – undo
59 59
 		check_load_extension('memcache',true);
60 60
 		$this->memcache = new \Memcache();
61 61
 
62
-		if (!$params) $params = array('localhost');	// some reasonable default
62
+		if (!$params)
63
+		{
64
+			$params = array('localhost');
65
+		}
66
+		// some reasonable default
63 67
 
64 68
 		$ok = false;
65 69
 		foreach($params as $host_port)
Please login to merge, or discard this patch.
api/src/Cache/Base.php 1 patch
Braces   +52 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,18 +49,27 @@  discard block
 block discarded – undo
49 49
 				$get_before_set = $this->get(array($level,__CLASS__,$location));
50 50
 				if (!is_null($get_before_set))
51 51
 				{
52
-					if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
52
+					if ($verbose)
53
+					{
54
+						echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
55
+					}
53 56
 					++$failed;
54 57
 				}
55 58
 				if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true)
56 59
 				{
57
-					if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n";
60
+					if ($verbose)
61
+					{
62
+						echo "$label: set returned ".array2string($set)." !== TRUE\n";
63
+					}
58 64
 					++$failed;
59 65
 				}
60 66
 				$get_after_set = $this->get(array($level,__CLASS__,$location));
61 67
 				if ($get_after_set !== $data)
62 68
 				{
63
-					if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
69
+					if ($verbose)
70
+					{
71
+						echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
72
+					}
64 73
 					++$failed;
65 74
 				}
66 75
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
@@ -68,25 +77,37 @@  discard block
 block discarded – undo
68 77
 					$mget_after_set = $this->mget(array($level,__CLASS__,array($location)));
69 78
 					if ($mget_after_set[$location] !== $data)
70 79
 					{
71
-						if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
80
+						if ($verbose)
81
+						{
82
+							echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
83
+						}
72 84
 						++$failed;
73 85
 					}
74 86
 				}
75 87
 				$add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data');
76 88
 				if ($add_after_set !== false)
77 89
 				{
78
-					if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n";
90
+					if ($verbose)
91
+					{
92
+						echo "$label: add_after_set=".array2string($add_after_set)."\n";
93
+					}
79 94
 					++$failed;
80 95
 				}
81 96
 				if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true)
82 97
 				{
83
-					if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
98
+					if ($verbose)
99
+					{
100
+						echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
101
+					}
84 102
 					++$failed;
85 103
 				}
86 104
 				$get_after_delete = $this->get(array($level,__CLASS__,$location));
87 105
 				if (!is_null($get_after_delete))
88 106
 				{
89
-					if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
107
+					if ($verbose)
108
+					{
109
+						echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
110
+					}
90 111
 					++$failed;
91 112
 				}
92 113
 				// prepare for mget of everything
@@ -96,18 +117,27 @@  discard block
 block discarded – undo
96 117
 					$mget_after_delete = $this->mget(array($level,__CLASS__,array($location)));
97 118
 					if (isset($mget_after_delete[$location]))
98 119
 					{
99
-						if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
120
+						if ($verbose)
121
+						{
122
+							echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
123
+						}
100 124
 						++$failed;
101 125
 					}
102 126
 				}
103
-				elseif (!is_null($data))	// emulation can NOT distinquish between null and not set
127
+				elseif (!is_null($data))
128
+				{
129
+					// emulation can NOT distinquish between null and not set
104 130
 				{
105 131
 					$locations[$location] = $data;
106 132
 				}
133
+				}
107 134
 				$add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10);
108 135
 				if ($add_after_delete !== true)
109 136
 				{
110
-					if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
137
+					if ($verbose)
138
+					{
139
+						echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
140
+					}
111 141
 					++$failed;
112 142
 				}
113 143
 				else
@@ -115,7 +145,10 @@  discard block
 block discarded – undo
115 145
 					$get_after_add = $this->get(array($level,__CLASS__,$location));
116 146
 					if ($get_after_add !== $data)
117 147
 					{
118
-						if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
148
+						if ($verbose)
149
+						{
150
+							echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
151
+						}
119 152
 						++$failed;
120 153
 					}
121 154
 				}
@@ -136,12 +169,18 @@  discard block
 block discarded – undo
136 169
 			}*/
137 170
 				if ($mget !== $locations)
138 171
 				{
139
-					if ($verbose) echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n";
172
+					if ($verbose)
173
+					{
174
+						echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n";
175
+					}
140 176
 					++$failed;
141 177
 				}
142 178
 				if ($mget_bogus !== $locations)
143 179
 				{
144
-					if ($verbose) echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n";
180
+					if ($verbose)
181
+					{
182
+						echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n";
183
+					}
145 184
 					++$failed;
146 185
 				}
147 186
 			}
Please login to merge, or discard this patch.
api/src/Cache/Files.php 1 patch
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,7 +50,10 @@  discard block
 block discarded – undo
50 50
 		else
51 51
 		{
52 52
 			$this->base_path = Api\Cache::get_system_config('temp_dir', false);
53
-			if (isset($this->base_path)) $this->base_path .= '/egw_cache';
53
+			if (isset($this->base_path))
54
+			{
55
+				$this->base_path .= '/egw_cache';
56
+			}
54 57
 		}
55 58
 		if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path,0700,true))
56 59
 		{
@@ -86,7 +89,10 @@  discard block
 block discarded – undo
86 89
 		{
87 90
 			flock($ret, LOCK_EX);
88 91
 			$ok = fwrite($ret, serialize($data));
89
-			if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration);
92
+			if ((int)$expiration > 0)
93
+			{
94
+				file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration);
95
+			}
90 96
 			flock($ret, LOCK_UN);
91 97
 			fclose($ret);
92 98
 			$ret = $ok !== false;
@@ -106,7 +112,10 @@  discard block
 block discarded – undo
106 112
 	{
107 113
 		if (($ret = @file_put_contents($fname=$this->filename($keys,true),serialize($data),LOCK_EX) > 0))
108 114
 		{
109
-			if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration);
115
+			if ((int)$expiration > 0)
116
+			{
117
+				file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration);
118
+			}
110 119
 		}
111 120
 		return $ret;
112 121
 	}
@@ -182,17 +191,26 @@  discard block
 block discarded – undo
182 191
 		}
183 192
 		foreach(scandir($path) as $file)
184 193
 		{
185
-			if ($file == '.' || $file == '..') continue;
194
+			if ($file == '.' || $file == '..')
195
+			{
196
+				continue;
197
+			}
186 198
 
187 199
 			$file = $path.'/'.$file;
188 200
 
189 201
 			if (is_dir($file))
190 202
 			{
191
-				if (!self::rm_recursive($file)) return false;
203
+				if (!self::rm_recursive($file))
204
+				{
205
+					return false;
206
+				}
192 207
 			}
193 208
 			else
194 209
 			{
195
-				if (!unlink($file)) return false;
210
+				if (!unlink($file))
211
+				{
212
+					return false;
213
+				}
196 214
 			}
197 215
 		}
198 216
 		return rmdir($path);
Please login to merge, or discard this patch.