Commit c3b1f0289f88b6aa382ad14d7784c0952523bce9
1 parent
9cfb4997
Exists in
master
and in
3 other branches
Version: 2.4.3.11
Bugfixes et refactoring getMailFromLDAP & getLoginFromLdap Version majeure en cours (2.5): https://projects.irap.omp.eu/versions/99 ROADMAP: https://projects.irap.omp.eu/projects/labinvent/roadmap
Showing
5 changed files
with
63 additions
and
45 deletions
Show diff stats
README-LABINVENT.md
... | ... | @@ -50,17 +50,10 @@ Logiciel testé et validé sur les configurations suivantes : |
50 | 50 | |
51 | 51 | VERSION ACTUELLE |
52 | 52 | |
53 | -Date: 13/06/2016 | |
54 | -Version: 2.4.3.10 | |
55 | - | |
56 | -!!! Modification BD !!! | |
57 | - | |
58 | -Ajout de tous les attributs faisant partie des demandes de la version 2.04 dans la base de données | |
59 | -+ Ajout de ces attributs dans les modèles et les fixtures. | |
60 | - | |
61 | - | |
62 | -Demande (terminé) : https://projects.irap.omp.eu/issues/3799 | |
53 | +Date: 14/06/2016 | |
54 | +Version: 2.4.3.11 | |
63 | 55 | |
56 | +Bugfixes et refactoring getMailFromLDAP & getLoginFromLdap | |
64 | 57 | |
65 | 58 | Version majeure en cours (2.5): https://projects.irap.omp.eu/versions/99 |
66 | 59 | ... | ... |
src/Controller/UsersController.php
... | ... | @@ -182,47 +182,25 @@ class UsersController extends AppController |
182 | 182 | // called from Javascript (Ajax) |
183 | 183 | public function getLdapLogin($userName) { |
184 | 184 | |
185 | - $ldapConnection = TableRegistry::get('LdapConnections'); | |
186 | - $u = $ldapConnection->getAllLdapUsers(); | |
187 | - | |
188 | - for($i = 0; $i < $ldapConnection->getNbUsers(); $i++) { | |
189 | - | |
190 | - //if (!empty($u[$i][$this->request->session()->read('authType')][0])) { | |
191 | - if ($userName == $u[$i]['givenname'][0].' '.$u[$i]['sn'][0]) { | |
192 | - $this->set ( 'login', $u[$i][$this->request->session()->read('authType')][0] ); | |
193 | - } | |
194 | - //} | |
185 | + $u = TableRegistry::get('LdapConnections')->getListLoginUsers(); | |
186 | + | |
187 | + if(isset($u[$userName])) { | |
188 | + $this->set ('login', $u[$userName]); | |
195 | 189 | } |
196 | - | |
190 | + | |
197 | 191 | $this->viewBuilder()->layout = 'ajax'; |
198 | 192 | } |
199 | 193 | |
200 | 194 | // called from Javascript (Ajax) |
201 | 195 | public function getLdapEmail($userName) { |
202 | - $ldapConnection = TableRegistry::get('LdapConnections'); | |
203 | - $u = $ldapConnection->getAllLdapUsers(); | |
204 | 196 | |
205 | - if (isset($u[0]['mailperso'])) { | |
206 | - $typeMail = 'mailperso'; | |
197 | + $u = TableRegistry::get('LdapConnections')->getListEmailUsers(); | |
198 | + | |
199 | + if(isset($u[$userName])) { | |
200 | + $this->set ('email', $u[$userName]); | |
207 | 201 | } |
208 | 202 | else { |
209 | - $typeMail = 'mail'; | |
210 | - } | |
211 | - | |
212 | - for($i = 0; $i < $ldapConnection->getNbUsers(); $i++) { | |
213 | - | |
214 | - //if (!empty($u[$i][$this->request->session()->read('authType')][0])) { | |
215 | - | |
216 | - if ($userName == $u[$i]['givenname'][0].' '.$u[$i]['sn'][0]) { | |
217 | - if (isset($u[$i][$typeMail][0]) && filter_var($u[$i][$typeMail][0], FILTER_VALIDATE_EMAIL)) { | |
218 | - $this->set ('email', $u[$i][$typeMail][0] ); | |
219 | - } else { | |
220 | - $this->set ('email', ' '); | |
221 | - } | |
222 | - } | |
223 | - //} | |
224 | - | |
225 | - | |
203 | + $this->set ('email', ' '); | |
226 | 204 | } |
227 | 205 | |
228 | 206 | $this->viewBuilder()->layout = 'ajax'; | ... | ... |
src/Model/Table/LdapConnectionsTable.php
... | ... | @@ -147,7 +147,7 @@ class LdapConnectionsTable extends AppTable { |
147 | 147 | if ($this->USE_LDAP) { |
148 | 148 | $ldapConnection = ldap_connect($this->host, $this->port); |
149 | 149 | ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); |
150 | - $results = ldap_search($ldapConnection, $this->baseDn, $this->authenticationType . '=' . $userName); | |
150 | + $results = ldap_search($ldapConnection, $this->baseDn, '('.$this->authenticationType . '=' . $userName.')'); | |
151 | 151 | return ldap_get_entries($ldapConnection, $results); |
152 | 152 | } |
153 | 153 | else return array($this->getFakeLdapUser($userName)); |
... | ... | @@ -192,6 +192,53 @@ class LdapConnectionsTable extends AppTable { |
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
195 | + * Return a list of login ofUsers with key = username & value = login | |
196 | + */ | |
197 | + public function getListLoginUsers() { | |
198 | + $u = $this->getAllLdapUsers(); | |
199 | + $utilisateurs= []; | |
200 | + | |
201 | + if($this->USE_LDAP) { | |
202 | + for($i = 0; $i < $u['count']; $i++) { | |
203 | + $utilisateurs[$u[$i]['givenname'][0].' '.$u[$i]['sn'][0]] = $u[$i][$this->authenticationType][0]; | |
204 | + } | |
205 | + } | |
206 | + else { | |
207 | + for($i = 0; $i < sizeof($u)-1; $i++) { | |
208 | + $utilisateurs[$u[$i]['givenname'][0].' '.$u[$i]['sn'][0]] = $u[$i][$this->authenticationType][0]; | |
209 | + } | |
210 | + } | |
211 | + | |
212 | + return $utilisateurs; | |
213 | + } | |
214 | + | |
215 | + /** | |
216 | + * Return a list of mail of Users with key = username & value = mail | |
217 | + */ | |
218 | + public function getListEmailUsers() { | |
219 | + $u = $this->getAllLdapUsers(); | |
220 | + $utilisateurs= []; | |
221 | + | |
222 | + if($this->USE_LDAP) { | |
223 | + for($i = 0; $i < $u['count']; $i++) { | |
224 | + if(isset($u[$i]['mail'][0])) { | |
225 | + $utilisateurs[$u[$i]['givenname'][0].' '.$u[$i]['sn'][0]] = $u[$i]['mail'][0]; | |
226 | + } | |
227 | + else { | |
228 | + $utilisateurs[$u[$i]['givenname'][0].' '.$u[$i]['sn'][0]] = 'N/A'; | |
229 | + } | |
230 | + } | |
231 | + } | |
232 | + else { | |
233 | + for($i = 0; $i < sizeof($u)-1; $i++) { | |
234 | + $utilisateurs[$u[$i]['givenname'][0].' '.$u[$i]['sn'][0]] = $u[$i]['mail'][0]; | |
235 | + } | |
236 | + } | |
237 | + | |
238 | + return $utilisateurs; | |
239 | + } | |
240 | + | |
241 | + /** | |
195 | 242 | * Return size of list users |
196 | 243 | */ |
197 | 244 | public function getNbUsers() { | ... | ... |
src/Template/Layout/default.ctp
... | ... | @@ -94,7 +94,7 @@ $cakeDescription = 'Labinvent 2.0'; |
94 | 94 | </i></td> |
95 | 95 | <td id="version"> |
96 | 96 | <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) --> |
97 | - <font color="black">VERSION 2.4.3.10 (13/06/2016)</font> | |
97 | + <font color="black">VERSION 2.4.3.11 (14/06/2016)</font> | |
98 | 98 | </td> |
99 | 99 | </tr> |
100 | 100 | </table> | ... | ... |
src/Template/Materiels/index.ctp
... | ... | @@ -189,7 +189,7 @@ if (isset ( $STATUS )) { |
189 | 189 | 'confirm' => 'Êtes-vous sur de vouloir faire une demande d\'archive '.$materiel->designation.' ?']); |
190 | 190 | |
191 | 191 | } |
192 | - else if (h($materiel->status) == 'TOBEARCHIVED' && $role != 'Responsable'){ | |
192 | + else if (h($materiel->status) == 'TOBEARCHIVED' && !in_array($role, ['Responsable', 'Super Administrateur'])){ | |
193 | 193 | echo $this->Html->link('<i class="icon-inbox"></i>', |
194 | 194 | ['action' => 'statusArchived', $materiel->id], |
195 | 195 | ['title' => 'Sortir de l\'inventaire', 'style' => 'margin: 0 2px', 'escape' => false, | ... | ... |