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