@@ -64,7 +64,7 @@ |
||
64 | 64 | * |
65 | 65 | * @param string $user_dn The user DN for which to infer the rules |
66 | 66 | * @param array $ownerships The owned groups for the user DN |
67 | - * @return array The roles of the given user |
|
67 | + * @return string[] The roles of the given user |
|
68 | 68 | */ |
69 | 69 | private function getRoles($user_dn, $ownerships) |
70 | 70 | { |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Symfony\Component\Security\Core\User\UserInterface; |
7 | 7 | use Symfony\Component\Security\Core\User\UserProviderInterface; |
8 | 8 | use Zend\Ldap\Exception\LdapException; |
9 | -use Zend\Ldap\Ldap; |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * This class maps a requested user to its LDAP entry. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * Returns all groups (OUs) with their common names |
42 | 42 | * |
43 | 43 | * @param array $fields A list of fields we want to return from the search |
44 | - * @return bool|\Zend\Ldap\Collection |
|
44 | + * @return Collection |
|
45 | 45 | * @throws LdapException |
46 | 46 | */ |
47 | 47 | public function getGroups($fields = ['cn']) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * Retrieve the members of the given group |
157 | 157 | * |
158 | 158 | * @param string $group_ou OU of the group |
159 | - * @return bool|Collection |
|
159 | + * @return Collection |
|
160 | 160 | */ |
161 | 161 | public function getOwners($group_ou) |
162 | 162 | { |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * Retrieves all members for the given group CN |
168 | 168 | * |
169 | 169 | * @param string $group_ou The common name of the group for which we want to retrieve the members |
170 | - * @param array $fields A list of fields we want to return from the search |
|
171 | - * @return bool|\Zend\Ldap\Collection |
|
170 | + * @param string[] $fields A list of fields we want to return from the search |
|
171 | + * @return Collection |
|
172 | 172 | * @throws LdapException |
173 | 173 | */ |
174 | 174 | public function getMembers($group_ou, $fields = ['member']) |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * Returns the groups owned by the user with the given dn |
226 | 226 | * |
227 | 227 | * @param string $user_dn The user DN for which we want to check |
228 | - * @return bool|Collection The groups owned by the user |
|
228 | + * @return Collection The groups owned by the user |
|
229 | 229 | */ |
230 | 230 | public function getOwnedGroups($user_dn) |
231 | 231 | { |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * Retrieves all memberships for the given DN |
237 | 237 | * |
238 | 238 | * @param string $user_dn The DN for which to get the memberships |
239 | - * @param array $fields A list of fields we want to return from the search |
|
239 | + * @param string[] $fields A list of fields we want to return from the search |
|
240 | 240 | * @param string $attribute The attribute which we use for filtering |
241 | - * @return bool|\Zend\Ldap\Collection |
|
241 | + * @return Collection |
|
242 | 242 | * @throws LdapException |
243 | 243 | */ |
244 | 244 | public function getMemberships($user_dn, $fields = ['cn'], $attribute = 'member') |
@@ -32,7 +32,8 @@ discard block |
||
32 | 32 | * @param $subtrees |
33 | 33 | * @throws LdapException |
34 | 34 | */ |
35 | - public function __construct($options, $subtrees) { |
|
35 | + public function __construct($options, $subtrees) |
|
36 | + { |
|
36 | 37 | parent::__construct($options); |
37 | 38 | $this->subtrees = $subtrees; |
38 | 39 | } |
@@ -200,10 +201,11 @@ discard block |
||
200 | 201 | ['dn', 'uid', 'cn', 'displayName', $attribute], |
201 | 202 | 'dn' |
202 | 203 | ); |
203 | - if ($results->count() > 0) |
|
204 | - return $results->getFirst(); |
|
205 | - else |
|
206 | - return false; |
|
204 | + if ($results->count() > 0) { |
|
205 | + return $results->getFirst(); |
|
206 | + } else { |
|
207 | + return false; |
|
208 | + } |
|
207 | 209 | } |
208 | 210 | |
209 | 211 | /** |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $this->attributes = $attributes; |
56 | 56 | $this->roles = $roles; |
57 | 57 | $this->memberships = $memberships; |
58 | - $this->ownerships = array_map(function($group) { |
|
58 | + $this->ownerships = array_map(function ($group) { |
|
59 | 59 | return $group['ou'][0]; |
60 | 60 | }, $ownerships); |
61 | 61 | } |
@@ -85,7 +85,9 @@ discard block |
||
85 | 85 | $ownedGroups = $app['ldap']->getOwnedGroups($user->getAttributes()['dn'])->toArray(); |
86 | 86 | |
87 | 87 | $selGroup = $request->request->get('ou'); |
88 | - if (!isset($selGroup)) $selGroup = $ownedGroups[0]['ou'][0]; |
|
88 | + if (!isset($selGroup)) { |
|
89 | + $selGroup = $ownedGroups[0]['ou'][0]; |
|
90 | + } |
|
89 | 91 | $selGroupDN = sprintf('ou=%s,%s', $selGroup, $app['config']['ldap.subtrees']['groups']); |
90 | 92 | |
91 | 93 | foreach ($ownedGroups as $og) { |
@@ -151,9 +153,10 @@ discard block |
||
151 | 153 | private function retrieveGuestByMail($mail) |
152 | 154 | { |
153 | 155 | $info = $this->app['ldap']->getMemberByMail($mail, 'mail'); |
154 | - if (is_array($info)) |
|
155 | - return $info['dn']; |
|
156 | - else |
|
157 | - return false; |
|
156 | + if (is_array($info)) { |
|
157 | + return $info['dn']; |
|
158 | + } else { |
|
159 | + return false; |
|
160 | + } |
|
158 | 161 | } |
159 | 162 | } |
160 | 163 | \ No newline at end of file |
@@ -66,7 +66,8 @@ discard block |
||
66 | 66 | $groupDN = sprintf('ou=%s,%s', $groupOU, $app['config']['ldap.subtrees']['groups']); |
67 | 67 | $groupAttr = $app['ldap']->getEntry($groupDN, ['cn', 'owner']); |
68 | 68 | |
69 | - switch ($action) { |
|
69 | + switch ($action) |
|
70 | + { |
|
70 | 71 | case 'quit': |
71 | 72 | try { |
72 | 73 | if (in_array($userDN, $groupAttr['owner'])) { |
@@ -113,15 +114,23 @@ discard block |
||
113 | 114 | $groupList = []; |
114 | 115 | foreach ($groups as $g) { |
115 | 116 | $roles = []; |
116 | - if (isset($g['owner']) && in_array($userDN, $g['owner'])) $roles[] = 'owner'; |
|
117 | - if (isset($g['member']) && in_array($userDN, $g['member'])) $roles[] = 'member'; |
|
118 | - if (isset($g['pending']) && in_array($userDN, $g['pending'])) $roles[] = 'pending'; |
|
117 | + if (isset($g['owner']) && in_array($userDN, $g['owner'])) { |
|
118 | + $roles[] = 'owner'; |
|
119 | + } |
|
120 | + if (isset($g['member']) && in_array($userDN, $g['member'])) { |
|
121 | + $roles[] = 'member'; |
|
122 | + } |
|
123 | + if (isset($g['pending']) && in_array($userDN, $g['pending'])) { |
|
124 | + $roles[] = 'pending'; |
|
125 | + } |
|
119 | 126 | |
120 | 127 | $owners = []; |
121 | 128 | if (isset($g['owner'])) { |
122 | 129 | for ($j = 0; $j < count($g['owner']); $j++) { |
123 | 130 | $o = $app['ldap']->getEntry($g['owner'][$j], ['cn', 'mail']); |
124 | - if (isset($o)) $owners[] = $o; |
|
131 | + if (isset($o)) { |
|
132 | + $owners[] = $o; |
|
133 | + } |
|
125 | 134 | } |
126 | 135 | } |
127 | 136 | |
@@ -156,7 +165,9 @@ discard block |
||
156 | 165 | return new \Symfony\Component\HttpFoundation\RedirectResponse('/members/Benutzerdaten'); |
157 | 166 | } |
158 | 167 | |
159 | - if (!isset($selGroup)) $selGroup = $ownedGroups[0]['ou'][0]; |
|
168 | + if (!isset($selGroup)) { |
|
169 | + $selGroup = $ownedGroups[0]['ou'][0]; |
|
170 | + } |
|
160 | 171 | $selGroupDN = sprintf('ou=%s,%s', $selGroup, $app['config']['ldap.subtrees']['groups']); |
161 | 172 | |
162 | 173 | $action = $request->request->get('manage-action'); |
@@ -179,7 +190,8 @@ discard block |
||
179 | 190 | |
180 | 191 | $groupAttr = $app['ldap']->getEntry($selGroupDN, ['owner']); |
181 | 192 | |
182 | - switch ($action) { |
|
193 | + switch ($action) |
|
194 | + { |
|
183 | 195 | case 'activate': |
184 | 196 | try { |
185 | 197 | $app['ldap']->activateMember($userID); |
@@ -232,11 +244,19 @@ discard block |
||
232 | 244 | $memberList = []; |
233 | 245 | foreach ($allUsers as $u) { |
234 | 246 | $roles = []; |
235 | - if (isset($groupAttr['owner']) && in_array($u['dn'], $groupAttr['owner'])) $roles[] = 'owner'; |
|
236 | - if (isset($groupAttr['member']) && in_array($u['dn'], $groupAttr['member'])) $roles[] = 'member'; |
|
237 | - if (isset($groupAttr['pending']) && in_array($u['dn'], $groupAttr['pending'])) $roles[] = 'pending'; |
|
247 | + if (isset($groupAttr['owner']) && in_array($u['dn'], $groupAttr['owner'])) { |
|
248 | + $roles[] = 'owner'; |
|
249 | + } |
|
250 | + if (isset($groupAttr['member']) && in_array($u['dn'], $groupAttr['member'])) { |
|
251 | + $roles[] = 'member'; |
|
252 | + } |
|
253 | + if (isset($groupAttr['pending']) && in_array($u['dn'], $groupAttr['pending'])) { |
|
254 | + $roles[] = 'pending'; |
|
255 | + } |
|
238 | 256 | // we handle inactive members like the other cases, the UI is just so similar |
239 | - if (strstr($u['dn'], 'ou=inactive')) $roles[] = 'inactive'; |
|
257 | + if (strstr($u['dn'], 'ou=inactive')) { |
|
258 | + $roles[] = 'inactive'; |
|
259 | + } |
|
240 | 260 | |
241 | 261 | $listentry = array( |
242 | 262 | 'name' => $u['cn'][0], |