dolibarr  16.0.5
ldap_members.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
4  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
7  * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('admin', 'errors'));
38 
39 if (!$user->admin) {
41 }
42 
43 $action = GETPOST('action', 'aZ09');
44 
45 /*
46  * Actions
47  */
48 
49 if ($action == 'setvalue' && $user->admin) {
50  $error = 0;
51 
52  $db->begin();
53 
54  if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) {
55  $error++;
56  }
57  if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
58  $error++;
59  }
60  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) {
61  $error++;
62  }
63  // Members
64  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
65  $error++;
66  }
67  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) {
68  $error++;
69  }
70  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) {
71  $error++;
72  }
73  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) {
74  $error++;
75  }
76  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) {
77  $error++;
78  }
79  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) {
80  $error++;
81  }
82  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) {
83  $error++;
84  }
85  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) {
86  $error++;
87  }
88  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) {
89  $error++;
90  }
91  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) {
92  $error++;
93  }
94  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) {
95  $error++;
96  }
97  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) {
98  $error++;
99  }
100  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) {
101  $error++;
102  }
103  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) {
104  $error++;
105  }
106  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) {
107  $error++;
108  }
109  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) {
110  $error++;
111  }
112  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) {
113  $error++;
114  }
115  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) {
116  $error++;
117  }
118  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) {
119  $error++;
120  }
121  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) {
122  $error++;
123  }
124  if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) {
125  $error++;
126  }
127  if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) {
128  $error++;
129  }
130  if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) {
131  $error++;
132  }
133 
134  // Subscriptions
135  if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
136  $error++;
137  }
138  if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
139  $error++;
140  }
141  if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
142  $error++;
143  }
144  if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
145  $error++;
146  }
147 
148  // This one must be after the others
149  $valkey = '';
150  $key = GETPOST("key");
151  if ($key) {
152  $valkey = $conf->global->$key;
153  }
154  if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) {
155  $error++;
156  }
157 
158  if (!$error) {
159  $db->commit();
160  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
161  } else {
162  $db->rollback();
163  dol_print_error($db);
164  }
165 }
166 
167 
168 
169 /*
170  * View
171  */
172 
173 $form = new Form($db);
174 
175 llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
176 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
177 
178 print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
179 
180 $head = ldap_prepare_head();
181 
182 // Test si fonction LDAP actives
183 if (!function_exists("ldap_connect")) {
184  setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
185 }
186 
187 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue&token='.newToken().'">';
188 print '<input type="hidden" name="token" value="'.newToken().'">';
189 
190 print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1);
191 
192 
193 print '<span class="opacitymedium">'.$langs->trans("LDAPDescMembers").'</span><br>';
194 print '<br>';
195 
196 print '<table class="noborder centpercent">';
197 
198 print '<tr class="liste_titre">';
199 print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
200 print "</tr>\n";
201 
202 // DN Pour les adherents
203 print '<!-- LDAP_MEMBER_DN -->';
204 print '<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
205 print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
206 print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
207 print '<td>&nbsp;</td>';
208 print '</tr>';
209 
210 // List of object class used to define attributes in structure
211 print '<!-- LDAP_MEMBER_OBJECT_CLASS -->';
212 print '<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
213 print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.'">';
214 print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
215 print '<td>&nbsp;</td>';
216 print '</tr>';
217 
218 // Filter, used to filter search
219 print '<!-- LDAP_MEMBER_FILTER -->';
220 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
221 print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_MEMBER_FILTER.'">';
222 print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
223 print '<td></td>';
224 print '</tr>';
225 
226 print '</table>';
227 print '<br>';
228 print '<table class="noborder centpercent">';
229 
230 print '<tr class="liste_titre">';
231 print '<td>'.$langs->trans("LDAPDolibarrMapping").'</td>';
232 print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
233 print '<td class="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
234 print "</tr>\n";
235 
236 // Filtre
237 
238 // Common name
239 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
240 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
241 print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
242 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_FULLNAME) ? ' checked' : '')."></td>";
243 print '</tr>';
244 
245 // Name
246 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
247 print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
248 print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
249 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_NAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_NAME) ? ' checked' : '')."></td>";
250 print '</tr>';
251 
252 // Firstname
253 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
254 print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.'">';
255 print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
256 print '<td class="right">&nbsp;</td>';
257 print '</tr>';
258 
259 // Login unix
260 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
261 print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
262 print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
263 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN) ? ' checked' : '')."></td>";
264 print '</tr>';
265 
266 // Login samba
267 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
268 print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
269 print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
270 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA) ? ' checked' : '')."></td>";
271 print '</tr>';
272 
273 // Password not crypted
274 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
275 print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.'">';
276 print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
277 print '<td class="right">&nbsp;</td>';
278 print '</tr>';
279 
280 // Password crypted
281 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
282 print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.'">';
283 print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
284 print '<td class="right">&nbsp;</td>';
285 print '</tr>';
286 
287 // Mail
288 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
289 print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
290 print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
291 print '<td class="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_MAIL"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS == $conf->global->LDAP_MEMBER_FIELD_MAIL) ? ' checked' : '')."></td>";
292 print '</tr>';
293 
294 // Phone pro
295 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
296 print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.'">';
297 print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
298 print '<td class="right">&nbsp;</td>';
299 print '</tr>';
300 
301 // Phone perso
302 
303 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
304 print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.'">';
305 print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
306 print '<td class="right">&nbsp;</td>';
307 print '</tr>';
308 
309 // Mobile
310 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
311 print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.'">';
312 print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
313 print '<td class="right">&nbsp;</td>';
314 print '</tr>';
315 
316 // Skype
317 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldSkype").'</td><td>';
318 print '<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_MEMBER_FIELD_SKYPE.'">';
319 print '</td><td>'.$langs->trans("LDAPFieldSkypeExample").'</td>';
320 print '<td class="right">&nbsp;</td>';
321 print '</tr>';
322 
323 // Fax
324 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
325 print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.'">';
326 print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
327 print '<td class="right">&nbsp;</td>';
328 print '</tr>';
329 
330 // Company
331 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
332 print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_MEMBER_FIELD_COMPANY.'">';
333 print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
334 print '<td class="right">&nbsp;</td>';
335 print '</tr>';
336 
337 // Address
338 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
339 print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.'">';
340 print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
341 print '<td class="right">&nbsp;</td>';
342 print '</tr>';
343 
344 // ZIP
345 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
346 print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.'">';
347 print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
348 print '<td class="right">&nbsp;</td>';
349 print '</tr>';
350 
351 // TOWN
352 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
353 print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.'">';
354 print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
355 print '<td class="right">&nbsp;</td>';
356 print '</tr>';
357 
358 // COUNTRY
359 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
360 print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.'">';
361 print '</td><td>&nbsp;</td>';
362 print '<td class="right">&nbsp;</td>';
363 print '</tr>';
364 
365 // Description
366 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
367 print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.'">';
368 print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
369 print '<td class="right">&nbsp;</td>';
370 print '</tr>';
371 
372 // Public Note
373 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldNotePublic").'</td><td>';
374 print '<input size="25" type="text" name="fieldnotepublic" value="'.$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC.'">';
375 print '</td><td>'.$langs->trans("LDAPFieldNotePublicExample").'</td>';
376 print '<td class="right">&nbsp;</td>';
377 print '</tr>';
378 
379 // Birthday
380 
381 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
382 print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.'">';
383 print '</td><td>&nbsp;</td>';
384 print '<td class="right">&nbsp;</td>';
385 print '</tr>';
386 
387 // Status
388 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
389 print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.'">';
390 print '</td><td>&nbsp;</td>';
391 print '<td class="right">&nbsp;</td>';
392 print '</tr>';
393 
394 // First subscription date
395 
396 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
397 print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.'">';
398 print '</td><td>&nbsp;</td>';
399 print '<td class="right">&nbsp;</td>';
400 print '</tr>';
401 
402 // First subscription amount
403 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
404 print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.'">';
405 print '</td><td>&nbsp;</td>';
406 print '<td class="right">&nbsp;</td>';
407 print '</tr>';
408 
409 // Last subscription date
410 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
411 print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.'">';
412 print '</td><td>&nbsp;</td>';
413 print '<td class="right">&nbsp;</td>';
414 print '</tr>';
415 
416 // Last subscription amount
417 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
418 print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.'">';
419 print '</td><td>&nbsp;</td>';
420 print '<td class="right">&nbsp;</td>';
421 print '</tr>';
422 
423 // End last subscriptions
424 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
425 print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.'">';
426 print '</td><td>&nbsp;</td>';
427 print '<td class="right">&nbsp;</td>';
428 print '</tr>';
429 
430 print '</table>';
431 
432 print info_admin($langs->trans("LDAPDescValues"));
433 
434 print dol_get_fiche_end();
435 
436 print $form->buttonsSaveCancel("Modify", '');
437 
438 print '</form>';
439 
440 
441 
442 /*
443  * Test de la connexion
444  */
445 if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) {
446  $butlabel = $langs->trans("LDAPTestSynchroMember");
447  $testlabel = 'testmember';
448  $key = $conf->global->LDAP_KEY_MEMBERS;
449  $dn = $conf->global->LDAP_MEMBER_DN;
450  $objectclass = $conf->global->LDAP_MEMBER_OBJECT_CLASS;
451 
452  show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
453 }
454 
455 if (function_exists("ldap_connect")) {
456  if ($_GET["action"] == 'testmember') {
457  // Creation objet
458  $object = new Adherent($db);
459  $object->initAsSpecimen();
460 
461  // Test synchro
462  $ldap = new Ldap();
463  $result = $ldap->connect_bind();
464 
465  if ($result > 0) {
466  $info = $object->_load_ldap_info();
467  $dn = $object->_load_ldap_dn($info);
468 
469  $result1 = $ldap->delete($dn); // To be sure to delete existing records
470  $result2 = $ldap->add($dn, $info, $user); // Now the test
471  $result3 = $ldap->delete($dn); // Clean what we did
472 
473  if ($result2 > 0) {
474  print img_picto('', 'info').' ';
475  print '<span class="ok">'.$langs->trans("LDAPSynchroOK").'</span><br>';
476  } else {
477  print img_picto('', 'error').' ';
478  print '<span class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
479  print ': '.$ldap->error;
480  print '</span><br>';
481  print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
482  }
483 
484  print "<br>\n";
485  print "LDAP input file used for test:<br><br>\n";
486  print nl2br($ldap->dump_content($dn, $info));
487  print "\n<br>";
488  } else {
489  print img_picto('', 'error').' ';
490  print '<span class="error">'.$langs->trans("LDAPSynchroKO");
491  print ': '.$ldap->error;
492  print '</span><br>';
493  print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
494  }
495  }
496 }
497 
498 // End of page
499 llxFooter();
500 $db->close();
Ldap
Class to manage LDAP features.
Definition: ldap.class.php:34
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
ldap_prepare_head
ldap_prepare_head()
Initialize the array of tabs for customer invoice.
Definition: ldap.lib.php:31
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
show_ldap_test_button
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
Show button test LDAP synchro.
Definition: ldap.lib.php:102