Completed
Push — 16.1 ( c01321...500e21 )
by Ralf
30:59 queued 17:12
created
api/src/Contacts/Ldap.php 1 patch
Braces   +93 added lines, -24 removed lines patch added patch discarded remove patch
@@ -327,9 +327,12 @@  discard block
 block discarded – undo
327 327
 			$this->ds = Api\Ldap::factory();
328 328
 		}
329 329
 		// if ldap is NOT the contact repository, we only do accounts and need to use the account-data
330
-		elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap')	// not (ldap or sql-ldap)
330
+		elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap')
331
+		{
332
+			// not (ldap or sql-ldap)
331 333
 		{
332 334
 			$this->ldap_config['ldap_contact_host'] = $this->ldap_config['ldap_host'];
335
+		}
333 336
 			$this->allContactsDN = $this->ldap_config['ldap_context'];
334 337
 			$this->ds = Api\Ldap::factory();
335 338
 		}
@@ -413,7 +416,10 @@  discard block
 block discarded – undo
413 416
 		}
414 417
 		else
415 418
 		{
416
-			if (is_array($contact_id)) $contact_id = isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid'];
419
+			if (is_array($contact_id))
420
+			{
421
+				$contact_id = isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid'];
422
+			}
417 423
 			$filter = $this->id_filter($contact_id);
418 424
 		}
419 425
 		$rows = $this->_searchLDAP($this->allContactsDN,
@@ -517,7 +523,10 @@  discard block
 block discarded – undo
517 523
 		// add for all supported objectclasses the objectclass and it's attributes
518 524
 		foreach($this->schema2egw as $objectclass => $mapping)
519 525
 		{
520
-			if(!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue;
526
+			if(!$this->ldapServerInfo->supportsObjectClass($objectclass))
527
+			{
528
+				continue;
529
+			}
521 530
 
522 531
 			if($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses))
523 532
 			{
@@ -535,7 +544,10 @@  discard block
 block discarded – undo
535 544
 			}
536 545
 			foreach($mapping as $egwFieldName => $ldapFieldName)
537 546
 			{
538
-				if (is_int($egwFieldName)) continue;
547
+				if (is_int($egwFieldName))
548
+				{
549
+					continue;
550
+				}
539 551
 				if(!empty($data[$egwFieldName]))
540 552
 				{
541 553
 					// dont convert the (binary) jpegPhoto!
@@ -671,7 +683,10 @@  discard block
 block discarded – undo
671 683
 	function delete($keys=null)
672 684
 	{
673 685
 		// single entry
674
-		if($keys[$this->contacts_id]) $keys = array( 0 => $keys);
686
+		if($keys[$this->contacts_id])
687
+		{
688
+			$keys = array( 0 => $keys);
689
+		}
675 690
 
676 691
 		if(!is_array($keys))
677 692
 		{
@@ -760,7 +775,10 @@  discard block
 block discarded – undo
760 775
 
761 776
 		if((int)$filter['owner'])
762 777
 		{
763
-			if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false;
778
+			if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner'])))
779
+			{
780
+				return false;
781
+			}
764 782
 
765 783
 			$searchDN = 'cn='. Api\Ldap::quote(strtolower($accountName)) .',';
766 784
 
@@ -856,7 +874,10 @@  discard block
 block discarded – undo
856 874
 			$sort = 'ASC';
857 875
 			foreach(explode(',',$order_by) as $o)
858 876
 			{
859
-				if (substr($o,0,8) == 'contact_') $o = substr($o,8);
877
+				if (substr($o,0,8) == 'contact_')
878
+				{
879
+					$o = substr($o,8);
880
+				}
860 881
 				if (substr($o,-4) == ' ASC')
861 882
 				{
862 883
 					$sort = 'ASC';
@@ -884,7 +905,10 @@  discard block
 block discarded – undo
884 905
 					{
885 906
 						$strc = strcmp($b[$f], $a[$f]);
886 907
 					}
887
-					if ($strc) return $strc;
908
+					if ($strc)
909
+					{
910
+						return $strc;
911
+					}
888 912
 				}
889 913
 				return 0;
890 914
 			});
@@ -913,12 +937,18 @@  discard block
 block discarded – undo
913 937
 	 */
914 938
 	function _colFilter($filter)
915 939
 	{
916
-		if (!is_array($filter)) return '';
940
+		if (!is_array($filter))
941
+		{
942
+			return '';
943
+		}
917 944
 
918 945
 		$filters = '';
919 946
 		foreach($filter as $key => $value)
920 947
 		{
921
-			if ($key != 'cat_id' && $key != 'account_id' && !$value) continue;
948
+			if ($key != 'cat_id' && $key != 'account_id' && !$value)
949
+			{
950
+				continue;
951
+			}
922 952
 
923 953
 			switch((string) $key)
924 954
 			{
@@ -950,19 +980,28 @@  discard block
 block discarded – undo
950 980
 							$GLOBALS['egw']->categories = new Api\Categories();
951 981
 						}
952 982
 						$cats = $GLOBALS['egw']->categories->return_all_children((int)$value);
953
-						if (count($cats) > 1) $filters .= '(|';
983
+						if (count($cats) > 1)
984
+						{
985
+							$filters .= '(|';
986
+						}
954 987
 						foreach($cats as $cat)
955 988
 						{
956 989
 							$catName = Api\Translation::convert(
957 990
 								$GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8');
958 991
 							$filters .= '(category='.Api\Ldap::quote($catName).')';
959 992
 						}
960
-						if (count($cats) > 1) $filters .= ')';
993
+						if (count($cats) > 1)
994
+						{
995
+							$filters .= ')';
996
+						}
961 997
 					}
962 998
 					break;
963 999
 
964 1000
 				case 'carddav_name':
965
-					if (!is_array($value)) $value = array($value);
1001
+					if (!is_array($value))
1002
+					{
1003
+						$value = array($value);
1004
+					}
966 1005
 					foreach($value as &$v)
967 1006
 					{
968 1007
 						$v = basename($v, '.vcf');
@@ -996,7 +1035,10 @@  discard block
 block discarded – undo
996 1035
 					elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/",$value,$matches))
997 1036
 					{
998 1037
 						list(,$name,$value) = $matches;
999
-						if (strpos($name,'.') !== false) list(,$name) = explode('.',$name);
1038
+						if (strpos($name,'.') !== false)
1039
+						{
1040
+							list(,$name) = explode('.',$name);
1041
+						}
1000 1042
 						foreach($this->schema2egw as $mapping)
1001 1043
 						{
1002 1044
 							if (isset($mapping[$name]))
@@ -1069,13 +1111,20 @@  discard block
 block discarded – undo
1069 1111
 		{
1070 1112
 			$result = @ldap_list($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit);
1071 1113
 		}
1072
-		if(!$result || !$entries = ldap_get_entries($this->ds, $result)) return array();
1114
+		if(!$result || !$entries = ldap_get_entries($this->ds, $result))
1115
+		{
1116
+			return array();
1117
+		}
1073 1118
 		//error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype) result of $entries[count]");
1074 1119
 
1075 1120
 		$this->total = $entries['count'];
1076 1121
 		foreach($entries as $i => $entry)
1077 1122
 		{
1078
-			if (!is_int($i)) continue;	// eg. count
1123
+			if (!is_int($i))
1124
+			{
1125
+				continue;
1126
+			}
1127
+			// eg. count
1079 1128
 
1080 1129
 			$contact = array(
1081 1130
 				'id'  => $entry['uid'][0] ? $entry['uid'][0] : $entry['entryuuid'][0],
@@ -1295,11 +1344,17 @@  discard block
 block discarded – undo
1295 1344
 			$contact['cat_id'] = array();
1296 1345
 			foreach($data['category'] as $iii => $cat)
1297 1346
 			{
1298
-				if (!is_int($iii)) continue;
1347
+				if (!is_int($iii))
1348
+				{
1349
+					continue;
1350
+				}
1299 1351
 
1300 1352
 				$contact['cat_id'][] = $GLOBALS['egw']->categories->name2id($cat);
1301 1353
 			}
1302
-			if ($contact['cat_id']) $contact['cat_id'] = implode(',',$contact['cat_id']);
1354
+			if ($contact['cat_id'])
1355
+			{
1356
+				$contact['cat_id'] = implode(',',$contact['cat_id']);
1357
+			}
1303 1358
 		}
1304 1359
 		if ($data['primaryphone'])
1305 1360
 		{
@@ -1354,7 +1409,10 @@  discard block
 block discarded – undo
1354 1409
 	{
1355 1410
 		unset($contact);	// not used, but required by function signature
1356 1411
 		static $shadowExpireNow=null;
1357
-		if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time()-date('Z'))/86400);
1412
+		if (!isset($shadowExpireNow))
1413
+		{
1414
+			$shadowExpireNow = floor((time()-date('Z'))/86400);
1415
+		}
1358 1416
 
1359 1417
 		// exclude expired or deactivated accounts
1360 1418
 		if (isset($data['shadowexpire']) && $data['shadowexpire'][0] <= $shadowExpireNow)
@@ -1399,9 +1457,13 @@  discard block
 block discarded – undo
1399 1457
 		elseif ($data['adr_one_countryname'])
1400 1458
 		{
1401 1459
 			$ldapContact['c'] = Api\Country::country_code($data['adr_one_countryname']);
1402
-			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)	// Bad countryname when "custom" selected!
1460
+			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)
1461
+			{
1462
+				// Bad countryname when "custom" selected!
1403 1463
 			{
1404
-				$ldapContact['c'] = array(); // should return error...
1464
+				$ldapContact['c'] = array();
1465
+			}
1466
+			// should return error...
1405 1467
 			}
1406 1468
 		}
1407 1469
 		elseif ($isUpdate)
@@ -1440,14 +1502,21 @@  discard block
 block discarded – undo
1440 1502
 		if ($data['adr_one_countrycode'])
1441 1503
 		{
1442 1504
 			$ldapContact['c'] = $data['adr_one_countrycode'];
1443
-			if ($isUpdate) $ldapContact['co'] = array();
1505
+			if ($isUpdate)
1506
+			{
1507
+				$ldapContact['co'] = array();
1508
+			}
1444 1509
 		}
1445 1510
 		elseif ($data['adr_one_countryname'])
1446 1511
 		{
1447 1512
 			$ldapContact['c'] = Api\Country::country_code($data['adr_one_countryname']);
1448
-			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)	// Bad countryname when "custom" selected!
1513
+			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)
1449 1514
 			{
1450
-				$ldapContact['c'] = array(); // should return error...
1515
+				// Bad countryname when "custom" selected!
1516
+			{
1517
+				$ldapContact['c'] = array();
1518
+			}
1519
+			// should return error...
1451 1520
 			}
1452 1521
 		}
1453 1522
 		elseif ($isUpdate)
Please login to merge, or discard this patch.