Completed
Pull Request — stable10 (#6492)
by Morris
11:41
created
apps/user_ldap/ajax/testConfiguration.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 			try {
67 67
 				$ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', array('dn'));
68 68
 			} catch (\Exception $e) {
69
-				if($e->getCode() === 1) {
69
+				if ($e->getCode() === 1) {
70 70
 					OCP\JSON::error(array('message' => $l->t('The configuration is invalid: anonymous bind is not allowed.')));
71 71
 					exit;
72 72
 				}
Please login to merge, or discard this patch.
apps/user_ldap/ajax/setConfiguration.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@
 block discarded – undo
30 30
 OCP\JSON::checkAppEnabled('user_ldap');
31 31
 OCP\JSON::callCheck();
32 32
 
33
-$prefix = (string)$_POST['ldap_serverconfig_chooser'];
33
+$prefix = (string) $_POST['ldap_serverconfig_chooser'];
34 34
 
35 35
 // Checkboxes are not submitted, when they are unchecked. Set them manually.
36 36
 // only legacy checkboxes (Advanced and Expert tab) need to be handled here,
37 37
 // the Wizard-like tabs handle it on their own
38 38
 $chkboxes = array('ldap_configuration_active', 'ldap_override_main_server',
39 39
 				  'ldap_turn_off_cert_check');
40
-foreach($chkboxes as $boxid) {
41
-	if(!isset($_POST[$boxid])) {
40
+foreach ($chkboxes as $boxid) {
41
+	if (!isset($_POST[$boxid])) {
42 42
 		$_POST[$boxid] = 0;
43 43
 	}
44 44
 }
Please login to merge, or discard this patch.
apps/user_ldap/ajax/wizard.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
 
33 33
 $l = \OC::$server->getL10N('user_ldap');
34 34
 
35
-if(!isset($_POST['action'])) {
35
+if (!isset($_POST['action'])) {
36 36
 	\OCP\JSON::error(array('message' => $l->t('No action specified')));
37 37
 }
38
-$action = (string)$_POST['action'];
38
+$action = (string) $_POST['action'];
39 39
 
40 40
 
41
-if(!isset($_POST['ldap_serverconfig_chooser'])) {
41
+if (!isset($_POST['ldap_serverconfig_chooser'])) {
42 42
 	\OCP\JSON::error(array('message' => $l->t('No configuration specified')));
43 43
 }
44
-$prefix = (string)$_POST['ldap_serverconfig_chooser'];
44
+$prefix = (string) $_POST['ldap_serverconfig_chooser'];
45 45
 
46 46
 $ldapWrapper = new \OCA\User_LDAP\LDAP();
47 47
 $configuration = new \OCA\User_LDAP\Configuration($prefix);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 $wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access);
68 68
 
69
-switch($action) {
69
+switch ($action) {
70 70
 	case 'guessPortAndTLS':
71 71
 	case 'guessBaseDN':
72 72
 	case 'detectEmailAttribute':
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	case 'countInBaseDN':
86 86
 		try {
87 87
 			$result = $wizard->$action();
88
-			if($result !== false) {
88
+			if ($result !== false) {
89 89
 				OCP\JSON::success($result->getResultArray());
90 90
 				exit;
91 91
 			}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		try {
102 102
 			$loginName = $_POST['ldap_test_loginname'];
103 103
 			$result = $wizard->$action($loginName);
104
-			if($result !== false) {
104
+			if ($result !== false) {
105 105
 				OCP\JSON::success($result->getResultArray());
106 106
 				exit;
107 107
 			}
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
 	case 'save':
118 118
 		$key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false;
119 119
 		$val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null;
120
-		if($key === false || is_null($val)) {
120
+		if ($key === false || is_null($val)) {
121 121
 			\OCP\JSON::error(array('message' => $l->t('No data specified')));
122 122
 			exit;
123 123
 		}
124 124
 		$cfg = array($key => $val);
125 125
 		$setParameters = array();
126 126
 		$configuration->setConfiguration($cfg, $setParameters);
127
-		if(!in_array($key, $setParameters)) {
127
+		if (!in_array($key, $setParameters)) {
128 128
 			\OCP\JSON::error(array('message' => $l->t($key.
129 129
 				' Could not set configuration %s', $setParameters[0])));
130 130
 			exit;
Please login to merge, or discard this patch.
apps/user_ldap/ajax/getNewServerConfigPrefix.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@
 block discarded – undo
32 32
 sort($serverConnections);
33 33
 $lk = array_pop($serverConnections);
34 34
 $ln = intval(str_replace('s', '', $lk));
35
-$nk = 's'.str_pad($ln+1, 2, '0', STR_PAD_LEFT);
35
+$nk = 's'.str_pad($ln + 1, 2, '0', STR_PAD_LEFT);
36 36
 
37 37
 $resultData = array('configPrefix' => $nk);
38 38
 
39 39
 $newConfig = new \OCA\User_LDAP\Configuration($nk, false);
40
-if(isset($_POST['copyConfig'])) {
40
+if (isset($_POST['copyConfig'])) {
41 41
 	$originalConfig = new \OCA\User_LDAP\Configuration($_POST['copyConfig']);
42 42
 	$newConfig->setConfiguration($originalConfig->getConfiguration());
43 43
 } else {
Please login to merge, or discard this patch.
apps/user_ldap/lib/Group_Proxy.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap) {
38 38
 		parent::__construct($ldap);
39
-		foreach($serverConfigPrefixes as $configPrefix) {
39
+		foreach ($serverConfigPrefixes as $configPrefix) {
40 40
 			$this->backends[$configPrefix] =
41 41
 				new \OCA\User_LDAP\Group_LDAP($this->getAccess($configPrefix));
42
-			if(is_null($this->refBackend)) {
42
+			if (is_null($this->refBackend)) {
43 43
 				$this->refBackend = &$this->backends[$configPrefix];
44 44
 			}
45 45
 		}
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	protected function walkBackends($gid, $method, $parameters) {
56 56
 		$cacheKey = $this->getGroupCacheKey($gid);
57
-		foreach($this->backends as $configPrefix => $backend) {
58
-			if($result = call_user_func_array(array($backend, $method), $parameters)) {
57
+		foreach ($this->backends as $configPrefix => $backend) {
58
+			if ($result = call_user_func_array(array($backend, $method), $parameters)) {
59 59
 				$this->writeToCache($cacheKey, $configPrefix);
60 60
 				return $result;
61 61
 			}
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
 	 * @return mixed, the result of the method or false
73 73
 	 */
74 74
 	protected function callOnLastSeenOn($gid, $method, $parameters, $passOnWhen) {
75
-		$cacheKey = $this->getGroupCacheKey($gid);;
75
+		$cacheKey = $this->getGroupCacheKey($gid); ;
76 76
 		$prefix = $this->getFromCache($cacheKey);
77 77
 		//in case the uid has been found in the past, try this stored connection first
78
-		if(!is_null($prefix)) {
79
-			if(isset($this->backends[$prefix])) {
78
+		if (!is_null($prefix)) {
79
+			if (isset($this->backends[$prefix])) {
80 80
 				$result = call_user_func_array(array($this->backends[$prefix], $method), $parameters);
81
-				if($result === $passOnWhen) {
81
+				if ($result === $passOnWhen) {
82 82
 					//not found here, reset cache to null if group vanished
83 83
 					//because sometimes methods return false with a reason
84 84
 					$groupExists = call_user_func_array(
85 85
 						array($this->backends[$prefix], 'groupExists'),
86 86
 						array($gid)
87 87
 					);
88
-					if(!$groupExists) {
88
+					if (!$groupExists) {
89 89
 						$this->writeToCache($cacheKey, null);
90 90
 					}
91 91
 				}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	public function getUserGroups($uid) {
119 119
 		$groups = array();
120 120
 
121
-		foreach($this->backends as $backend) {
121
+		foreach ($this->backends as $backend) {
122 122
 			$backendGroups = $backend->getUserGroups($uid);
123 123
 			if (is_array($backendGroups)) {
124 124
 				$groups = array_merge($groups, $backendGroups);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
136 136
 		$users = array();
137 137
 
138
-		foreach($this->backends as $backend) {
138
+		foreach ($this->backends as $backend) {
139 139
 			$backendUsers = $backend->usersInGroup($gid, $search, $limit, $offset);
140 140
 			if (is_array($backendUsers)) {
141 141
 				$users = array_merge($users, $backendUsers);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	public function getGroups($search = '', $limit = -1, $offset = 0) {
166 166
 		$groups = array();
167 167
 
168
-		foreach($this->backends as $backend) {
168
+		foreach ($this->backends as $backend) {
169 169
 			$backendGroups = $backend->getGroups($search, $limit, $offset);
170 170
 			if (is_array($backendGroups)) {
171 171
 				$groups = array_merge($groups, $backendGroups);
Please login to merge, or discard this patch.
apps/user_ldap/lib/User/DeletedUsersIndex.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			'user_ldap', 'isDeleted', '1');
72 72
 
73 73
 		$userObjects = array();
74
-		foreach($deletedUsers as $user) {
74
+		foreach ($deletedUsers as $user) {
75 75
 			$userObjects[] = new OfflineUser($user, $this->config, $this->db, $this->mapping);
76 76
 		}
77 77
 		$this->deletedUsers = $userObjects;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @return \OCA\User_LDAP\User\OfflineUser[]
85 85
 	 */
86 86
 	public function getUsers() {
87
-		if(is_array($this->deletedUsers)) {
87
+		if (is_array($this->deletedUsers)) {
88 88
 			return $this->deletedUsers;
89 89
 		}
90 90
 		return $this->fetchDeletedUsers();
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 	 * @return bool
96 96
 	 */
97 97
 	public function hasUsers() {
98
-		if($this->deletedUsers === false) {
98
+		if ($this->deletedUsers === false) {
99 99
 			$this->fetchDeletedUsers();
100 100
 		}
101
-		if(is_array($this->deletedUsers) && count($this->deletedUsers) > 0) {
101
+		if (is_array($this->deletedUsers) && count($this->deletedUsers) > 0) {
102 102
 			return true;
103 103
 		}
104 104
 		return false;
Please login to merge, or discard this patch.
apps/user_ldap/lib/User/Manager.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return null
131 131
 	 */
132 132
 	private function checkAccess() {
133
-		if(is_null($this->access)) {
133
+		if (is_null($this->access)) {
134 134
 			throw new \Exception('LDAP Access instance must be set first');
135 135
 		}
136 136
 	}
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 			$this->access->getConnection()->ldapUserDisplayName,
151 151
 			$this->access->getConnection()->ldapUserDisplayName2,
152 152
 		);
153
-		foreach($possible as $attr) {
154
-			if(!is_null($attr)) {
153
+		foreach ($possible as $attr) {
154
+			if (!is_null($attr)) {
155 155
 				$attributes[] = $attr;
156 156
 			}
157 157
 		}
158 158
 
159 159
 		$homeRule = $this->access->getConnection()->homeFolderNamingRule;
160
-		if(strpos($homeRule, 'attr:') === 0) {
160
+		if (strpos($homeRule, 'attr:') === 0) {
161 161
 			$attributes[] = substr($homeRule, strlen('attr:'));
162 162
 		}
163 163
 
164
-		if(!$minimal) {
164
+		if (!$minimal) {
165 165
 			// attributes that are not really important but may come with big
166 166
 			// payload.
167 167
 			$attributes = array_merge($attributes, array(
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	protected function createInstancyByUserName($id) {
206 206
 		//most likely a uid. Check whether it is a deleted user
207
-		if($this->isDeletedUser($id)) {
207
+		if ($this->isDeletedUser($id)) {
208 208
 			return $this->getDeletedUser($id);
209 209
 		}
210 210
 		$dn = $this->access->username2dn($id);
211
-		if($dn !== false) {
211
+		if ($dn !== false) {
212 212
 			return $this->createAndCache($dn, $id);
213 213
 		}
214 214
 		return null;
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function get($id) {
224 224
 		$this->checkAccess();
225
-		if(isset($this->usersByDN[$id])) {
225
+		if (isset($this->usersByDN[$id])) {
226 226
 			return $this->usersByDN[$id];
227
-		} else if(isset($this->usersByUid[$id])) {
227
+		} else if (isset($this->usersByUid[$id])) {
228 228
 			return $this->usersByUid[$id];
229 229
 		}
230 230
 
231
-		if($this->access->stringResemblesDN($id) ) {
231
+		if ($this->access->stringResemblesDN($id)) {
232 232
 			$uid = $this->access->dn2username($id);
233
-			if($uid !== false) {
233
+			if ($uid !== false) {
234 234
 				return $this->createAndCache($id, $uid);
235 235
 			}
236 236
 		}
Please login to merge, or discard this patch.
apps/user_ldap/lib/User/OfflineUser.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
 	 * reads the user details
180 180
 	 */
181 181
 	protected function fetchDetails() {
182
-		$properties = array (
182
+		$properties = array(
183 183
 			'displayName' => 'user_ldap',
184 184
 			'uid'         => 'user_ldap',
185 185
 			'homePath'    => 'user_ldap',
186 186
 			'email'       => 'settings',
187 187
 			'lastLogin'   => 'login'
188 188
 		);
189
-		foreach($properties as $property => $app) {
189
+		foreach ($properties as $property => $app) {
190 190
 			$this->$property = $this->config->getUserValue($this->ocName, $app, $property, '');
191 191
 		}
192 192
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		', 1);
210 210
 		$query->execute(array($this->ocName));
211 211
 		$sResult = $query->fetchColumn(0);
212
-		if(intval($sResult) === 1) {
212
+		if (intval($sResult) === 1) {
213 213
 			$this->hasActiveShares = true;
214 214
 			return;
215 215
 		}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		', 1);
222 222
 		$query->execute(array($this->ocName));
223 223
 		$sResult = $query->fetchColumn(0);
224
-		if(intval($sResult) === 1) {
224
+		if (intval($sResult) === 1) {
225 225
 			$this->hasActiveShares = true;
226 226
 			return;
227 227
 		}
Please login to merge, or discard this patch.
apps/user_ldap/lib/WizardResult.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param array|string $values
53 53
 	 */
54 54
 	public function addOptions($key, $values) {
55
-		if(!is_array($values)) {
55
+		if (!is_array($values)) {
56 56
 			$values = array($values);
57 57
 		}
58 58
 		$this->options[$key] = $values;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	public function getResultArray() {
72 72
 		$result = array();
73 73
 		$result['changes'] = $this->changes;
74
-		if(count($this->options) > 0) {
74
+		if (count($this->options) > 0) {
75 75
 			$result['options'] = $this->options;
76 76
 		}
77 77
 		return $result;
Please login to merge, or discard this patch.