@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->isAllowed($input->getOption('force')); |
87 | 87 | $this->confirmUserIsMapped($uid); |
88 | 88 | $exists = $this->backend->userExistsOnLDAP($uid); |
89 | - if($exists === true) { |
|
89 | + if ($exists === true) { |
|
90 | 90 | $output->writeln('The user is still available on LDAP.'); |
91 | 91 | return; |
92 | 92 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | $this->dui->markUser($uid); |
95 | 95 | $output->writeln('The user does not exists on LDAP anymore.'); |
96 | 96 | $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "' |
97 | - . $uid . '"'); |
|
97 | + . $uid.'"'); |
|
98 | 98 | } catch (\Exception $e) { |
99 | - $output->writeln('<error>' . $e->getMessage(). '</error>'); |
|
99 | + $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @return true |
122 | 122 | */ |
123 | 123 | protected function isAllowed($force) { |
124 | - if($this->helper->haveDisabledConfigurations() && !$force) { |
|
124 | + if ($this->helper->haveDisabledConfigurations() && !$force) { |
|
125 | 125 | throw new \Exception('Cannot check user existence, because ' |
126 | 126 | . 'disabled LDAP configurations are present.'); |
127 | 127 | } |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | * @throws \InvalidArgumentException |
88 | 88 | */ |
89 | 89 | protected function validateOffsetAndLimit($offset, $limit) { |
90 | - if($limit < 0) { |
|
90 | + if ($limit < 0) { |
|
91 | 91 | throw new \InvalidArgumentException('limit must be 0 or greater'); |
92 | 92 | } |
93 | - if($offset < 0) { |
|
93 | + if ($offset < 0) { |
|
94 | 94 | throw new \InvalidArgumentException('offset must be 0 or greater'); |
95 | 95 | } |
96 | - if($limit === 0 && $offset !== 0) { |
|
96 | + if ($limit === 0 && $offset !== 0) { |
|
97 | 97 | throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0'); |
98 | 98 | } |
99 | - if($offset > 0 && ($offset % $limit !== 0)) { |
|
99 | + if ($offset > 0 && ($offset % $limit !== 0)) { |
|
100 | 100 | throw new \InvalidArgumentException('offset must be a multiple of limit'); |
101 | 101 | } |
102 | 102 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $limit = intval($input->getOption('limit')); |
111 | 111 | $this->validateOffsetAndLimit($offset, $limit); |
112 | 112 | |
113 | - if($input->getOption('group')) { |
|
113 | + if ($input->getOption('group')) { |
|
114 | 114 | $proxy = new Group_Proxy($configPrefixes, $ldapWrapper); |
115 | 115 | $getMethod = 'getGroups'; |
116 | 116 | $printID = false; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset); |
124 | - foreach($result as $id => $name) { |
|
125 | - $line = $name . ($printID ? ' ('.$id.')' : ''); |
|
124 | + foreach ($result as $id => $name) { |
|
125 | + $line = $name.($printID ? ' ('.$id.')' : ''); |
|
126 | 126 | $output->writeln($line); |
127 | 127 | } |
128 | 128 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | $success = $this->helper->deleteServerConfiguration($configPrefix); |
64 | 64 | |
65 | - if($success) { |
|
65 | + if ($success) { |
|
66 | 66 | $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
67 | 67 | } else { |
68 | 68 | $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
@@ -71,7 +71,7 @@ |
||
71 | 71 | 'Dir', 'Sharer')); |
72 | 72 | $rows = array(); |
73 | 73 | $resultSet = $this->dui->getUsers(); |
74 | - foreach($resultSet as $user) { |
|
74 | + foreach ($resultSet as $user) { |
|
75 | 75 | $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
76 | 76 | $lastLogin = ($user->getLastLogin() > 0) ? |
77 | 77 | $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
@@ -62,7 +62,7 @@ |
||
62 | 62 | // assign default values |
63 | 63 | $config = new Configuration('', false); |
64 | 64 | $defaults = $config->getDefaults(); |
65 | - foreach($defaults as $key => $default) { |
|
65 | + foreach ($defaults as $key => $default) { |
|
66 | 66 | $parameters[$key.'_default'] = $default; |
67 | 67 | } |
68 | 68 |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig) { |
44 | 44 | parent::__construct($ldap); |
45 | - foreach($serverConfigPrefixes as $configPrefix) { |
|
45 | + foreach ($serverConfigPrefixes as $configPrefix) { |
|
46 | 46 | $this->backends[$configPrefix] = |
47 | 47 | new User_LDAP($this->getAccess($configPrefix), $ocConfig); |
48 | - if(is_null($this->refBackend)) { |
|
48 | + if (is_null($this->refBackend)) { |
|
49 | 49 | $this->refBackend = &$this->backends[$configPrefix]; |
50 | 50 | } |
51 | 51 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected function walkBackends($uid, $method, $parameters) { |
62 | 62 | $cacheKey = $this->getUserCacheKey($uid); |
63 | - foreach($this->backends as $configPrefix => $backend) { |
|
63 | + foreach ($this->backends as $configPrefix => $backend) { |
|
64 | 64 | $instance = $backend; |
65 | - if(!method_exists($instance, $method) |
|
65 | + if (!method_exists($instance, $method) |
|
66 | 66 | && method_exists($this->getAccess($configPrefix), $method)) { |
67 | 67 | $instance = $this->getAccess($configPrefix); |
68 | 68 | } |
69 | - if($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
69 | + if ($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
70 | 70 | $this->writeToCache($cacheKey, $configPrefix); |
71 | 71 | return $result; |
72 | 72 | } |
@@ -86,22 +86,22 @@ discard block |
||
86 | 86 | $cacheKey = $this->getUserCacheKey($uid); |
87 | 87 | $prefix = $this->getFromCache($cacheKey); |
88 | 88 | //in case the uid has been found in the past, try this stored connection first |
89 | - if(!is_null($prefix)) { |
|
90 | - if(isset($this->backends[$prefix])) { |
|
89 | + if (!is_null($prefix)) { |
|
90 | + if (isset($this->backends[$prefix])) { |
|
91 | 91 | $instance = $this->backends[$prefix]; |
92 | - if(!method_exists($instance, $method) |
|
92 | + if (!method_exists($instance, $method) |
|
93 | 93 | && method_exists($this->getAccess($prefix), $method)) { |
94 | 94 | $instance = $this->getAccess($prefix); |
95 | 95 | } |
96 | 96 | $result = call_user_func_array(array($instance, $method), $parameters); |
97 | - if($result === $passOnWhen) { |
|
97 | + if ($result === $passOnWhen) { |
|
98 | 98 | //not found here, reset cache to null if user vanished |
99 | 99 | //because sometimes methods return false with a reason |
100 | 100 | $userExists = call_user_func_array( |
101 | 101 | array($this->backends[$prefix], 'userExists'), |
102 | 102 | array($uid) |
103 | 103 | ); |
104 | - if(!$userExists) { |
|
104 | + if (!$userExists) { |
|
105 | 105 | $this->writeToCache($cacheKey, null); |
106 | 106 | } |
107 | 107 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function getUsers($search = '', $limit = 10, $offset = 0) { |
144 | 144 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
145 | 145 | $users = array(); |
146 | - foreach($this->backends as $backend) { |
|
146 | + foreach ($this->backends as $backend) { |
|
147 | 147 | $backendUsers = $backend->getUsers($search, $limit, $offset); |
148 | 148 | if (is_array($backendUsers)) { |
149 | 149 | $users = array_merge($users, $backendUsers); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @return string|false |
192 | 192 | */ |
193 | 193 | public function loginName2UserName($loginName) { |
194 | - $id = 'LOGINNAME,' . $loginName; |
|
194 | + $id = 'LOGINNAME,'.$loginName; |
|
195 | 195 | return $this->handleRequest($id, 'loginName2UserName', array($loginName)); |
196 | 196 | } |
197 | 197 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return string|false with the username |
203 | 203 | */ |
204 | 204 | public function dn2UserName($dn) { |
205 | - $id = 'DN,' . $dn; |
|
205 | + $id = 'DN,'.$dn; |
|
206 | 206 | return $this->handleRequest($id, 'dn2UserName', array($dn)); |
207 | 207 | } |
208 | 208 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
244 | 244 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
245 | 245 | $users = array(); |
246 | - foreach($this->backends as $backend) { |
|
246 | + foreach ($this->backends as $backend) { |
|
247 | 247 | $backendUsers = $backend->getDisplayNames($search, $limit, $offset); |
248 | 248 | if (is_array($backendUsers)) { |
249 | 249 | $users = $users + $backendUsers; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function countUsers() { |
289 | 289 | $users = false; |
290 | - foreach($this->backends as $backend) { |
|
290 | + foreach ($this->backends as $backend) { |
|
291 | 291 | $backendUsers = $backend->countUsers(); |
292 | 292 | if ($backendUsers !== false) { |
293 | 293 | $users += $backendUsers; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->logger = $serverContainer->getLogger(); |
48 | 48 | $this->helper = $helper; |
49 | 49 | $this->deletedUsersIndex = $deletedUsersIndex; |
50 | - foreach ($serverContainer->getUserManager()->getBackends() as $backend){ |
|
50 | + foreach ($serverContainer->getUserManager()->getBackends() as $backend) { |
|
51 | 51 | $this->logger->debug('instance '.get_class($backend).' backend.', ['app' => 'user_ldap']); |
52 | 52 | if ($backend instanceof IUserLDAP) { |
53 | 53 | $this->backend = $backend; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * @throws \Exception if translation was unsuccessful |
65 | 65 | */ |
66 | 66 | public function getUserDN($uid) { |
67 | - if(!$this->backend->userExists($uid)){ |
|
67 | + if (!$this->backend->userExists($uid)) { |
|
68 | 68 | throw new \Exception('User id not found in LDAP'); |
69 | 69 | } |
70 | 70 | $result = $this->backend->getLDAPAccess($uid)->username2dn($uid); |
71 | - if(!$result){ |
|
71 | + if (!$result) { |
|
72 | 72 | throw new \Exception('Translation to LDAP DN unsuccessful'); |
73 | 73 | } |
74 | 74 | return $result; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function getUserName($dn) { |
85 | 85 | $result = $this->backend->dn2UserName($dn); |
86 | - if(!$result){ |
|
86 | + if (!$result) { |
|
87 | 87 | throw new \Exception('Translation to internal user name unsuccessful'); |
88 | 88 | } |
89 | 89 | return $result; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @throws \Exception if user id was not found in LDAP |
116 | 116 | */ |
117 | 117 | public function getLDAPConnection($uid) { |
118 | - if(!$this->backend->userExists($uid)){ |
|
118 | + if (!$this->backend->userExists($uid)) { |
|
119 | 119 | throw new \Exception('User id not found in LDAP'); |
120 | 120 | } |
121 | 121 | return $this->backend->getNewLDAPConnection($uid); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @throws \Exception if user id was not found in LDAP |
129 | 129 | */ |
130 | 130 | public function getLDAPBaseUsers($uid) { |
131 | - if(!$this->backend->userExists($uid)){ |
|
131 | + if (!$this->backend->userExists($uid)) { |
|
132 | 132 | throw new \Exception('User id not found in LDAP'); |
133 | 133 | } |
134 | 134 | return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_users']; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @throws \Exception if user id was not found in LDAP |
142 | 142 | */ |
143 | 143 | public function getLDAPBaseGroups($uid) { |
144 | - if(!$this->backend->userExists($uid)){ |
|
144 | + if (!$this->backend->userExists($uid)) { |
|
145 | 145 | throw new \Exception('User id not found in LDAP'); |
146 | 146 | } |
147 | 147 | return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_groups']; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @throws \Exception if user id was not found in LDAP |
154 | 154 | */ |
155 | 155 | public function clearCache($uid) { |
156 | - if(!$this->backend->userExists($uid)){ |
|
156 | + if (!$this->backend->userExists($uid)) { |
|
157 | 157 | throw new \Exception('User id not found in LDAP'); |
158 | 158 | } |
159 | 159 | $this->backend->getLDAPAccess($uid)->getConnection()->clearCache(); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * |
23 | 23 | */ |
24 | 24 | $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doSet'); |
25 | -if($state === 'doSet') { |
|
25 | +if ($state === 'doSet') { |
|
26 | 26 | OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); |
27 | 27 | } |
28 | 28 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
32 | 32 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
33 | 33 | $ocConfig = \OC::$server->getConfig(); |
34 | -if(count($configPrefixes) === 1) { |
|
34 | +if (count($configPrefixes) === 1) { |
|
35 | 35 | $dbc = \OC::$server->getDatabaseConnection(); |
36 | 36 | $userManager = new OCA\User_LDAP\User\Manager($ocConfig, |
37 | 37 | new OCA\User_LDAP\FilesystemHelper(), |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | $ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc)); |
49 | 49 | $userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig); |
50 | 50 | $groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess); |
51 | -} else if(count($configPrefixes) > 1) { |
|
51 | +} else if (count($configPrefixes) > 1) { |
|
52 | 52 | $userBackend = new OCA\User_LDAP\User_Proxy( |
53 | 53 | $configPrefixes, $ldapWrapper, $ocConfig |
54 | 54 | ); |
55 | - $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
55 | + $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
56 | 56 | } |
57 | 57 | |
58 | -if(count($configPrefixes) > 0) { |
|
58 | +if (count($configPrefixes) > 0) { |
|
59 | 59 | // register user backend |
60 | 60 | OC_User::useBackend($userBackend); |
61 | 61 | OC_Group::useBackend($groupBackend); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'loginName2UserName' |
69 | 69 | ); |
70 | 70 | |
71 | -if(OCP\App::isEnabled('user_webdavauth')) { |
|
71 | +if (OCP\App::isEnabled('user_webdavauth')) { |
|
72 | 72 | OCP\Util::writeLog('user_ldap', |
73 | 73 | 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour', |
74 | 74 | OCP\Util::WARN); |