dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
34require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array('admin', 'errors'));
48
49if (!$user->admin) {
51}
52
53$action = GETPOST('action', 'aZ09');
54
55/*
56 * Actions
57 */
58
59if ($action == 'setvalue' && $user->admin) {
60 $error = 0;
61
62 $db->begin();
63
64 if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) {
65 $error++;
66 }
67 if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
68 $error++;
69 }
70 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) {
71 $error++;
72 }
73 // Members
74 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
75 $error++;
76 }
77 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) {
78 $error++;
79 }
80 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) {
81 $error++;
82 }
83 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) {
84 $error++;
85 }
86 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) {
87 $error++;
88 }
89 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) {
90 $error++;
91 }
92 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) {
93 $error++;
94 }
95 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) {
96 $error++;
97 }
98 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) {
99 $error++;
100 }
101 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) {
102 $error++;
103 }
104 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) {
105 $error++;
106 }
107 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) {
108 $error++;
109 }
110 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) {
111 $error++;
112 }
113 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) {
114 $error++;
115 }
116 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) {
117 $error++;
118 }
119 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) {
120 $error++;
121 }
122 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) {
123 $error++;
124 }
125 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) {
126 $error++;
127 }
128 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) {
129 $error++;
130 }
131 if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) {
132 $error++;
133 }
134 if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) {
135 $error++;
136 }
137 if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) {
138 $error++;
139 }
140
141 // Subscriptions
142 if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
143 $error++;
144 }
145 if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
146 $error++;
147 }
148 if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
149 $error++;
150 }
151 if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
152 $error++;
153 }
154
155 // This one must be after the others
156 $valkey = '';
157 $key = GETPOST("key");
158 if ($key) {
159 $valkey = getDolGlobalString($key);
160 }
161 if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) {
162 $error++;
163 }
164
165 if (!$error) {
166 $db->commit();
167 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
168 } else {
169 $db->rollback();
170 dol_print_error($db);
171 }
172}
173
174
175
176/*
177 * View
178 */
179
180$form = new Form($db);
181
182llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP', '', 0, 0, '', '', '', 'mod-admin page-ldap_members');
183$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
184
185print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
186
187$head = ldap_prepare_head();
188
189// Test si function LDAP actives
190if (!function_exists("ldap_connect")) {
191 setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
192}
193
194print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue&token='.newToken().'">';
195print '<input type="hidden" name="token" value="'.newToken().'">';
196
197print dol_get_fiche_head($head, 'members', '', -1);
198
199
200print '<span class="opacitymedium">'.$langs->trans("LDAPDescMembers").'</span><br>';
201print '<br>';
202
203print '<table class="noborder centpercent">';
204
205print '<tr class="liste_titre">';
206print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
207print "</tr>\n";
208
209// DN Pour les adherents
210print '<!-- LDAP_MEMBER_DN -->';
211print '<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
212print '<input size="48" type="text" name="user" value="' . getDolGlobalString('LDAP_MEMBER_DN').'">';
213print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
214print '<td>&nbsp;</td>';
215print '</tr>';
216
217// List of object class used to define attributes in structure
218print '<!-- LDAP_MEMBER_OBJECT_CLASS -->';
219print '<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
220print '<input size="48" type="text" name="objectclass" value="' . getDolGlobalString('LDAP_MEMBER_OBJECT_CLASS').'">';
221print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
222print '<td>&nbsp;</td>';
223print '</tr>';
224
225// Filter, used to filter search
226print '<!-- LDAP_MEMBER_FILTER -->';
227print '<tr class="oddeven"><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
228print '<input size="48" type="text" name="filterconnection" value="' . getDolGlobalString('LDAP_MEMBER_FILTER').'">';
229print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
230print '<td></td>';
231print '</tr>';
232
233print '</table>';
234print '<br>';
235print '<table class="noborder centpercent">';
236
237print '<tr class="liste_titre">';
238print '<td>'.$langs->trans("LDAPDolibarrMapping").'</td>';
239print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
240print '<td class="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
241print "</tr>\n";
242
243// Filtre
244
245// Common name
246print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
247print '<input size="25" type="text" name="fieldfullname" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_FULLNAME').'">';
248print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
249print '<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>";
250print '</tr>';
251
252// Name
253print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
254print '<input size="25" type="text" name="fieldname" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_NAME').'">';
255print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
256print '<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>";
257print '</tr>';
258
259// Firstname
260print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
261print '<input size="25" type="text" name="fieldfirstname" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_FIRSTNAME').'">';
262print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
263print '<td class="right">&nbsp;</td>';
264print '</tr>';
265
266// Login unix
267print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
268print '<input size="25" type="text" name="fieldlogin" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_LOGIN').'">';
269print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
270print '<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>";
271print '</tr>';
272
273// Login samba
274print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
275print '<input size="25" type="text" name="fieldloginsamba" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_LOGIN_SAMBA').'">';
276print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
277print '<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>";
278print '</tr>';
279
280// Password not encrypted
281print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
282print '<input size="25" type="text" name="fieldpassword" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD').'">';
283print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
284print '<td class="right">&nbsp;</td>';
285print '</tr>';
286
287// Password encrypted
288print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
289print '<input size="25" type="text" name="fieldpasswordcrypted" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_PASSWORD_CRYPTED').'">';
290print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
291print '<td class="right">&nbsp;</td>';
292print '</tr>';
293
294// Mail
295print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
296print '<input size="25" type="text" name="fieldmail" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_MAIL').'">';
297print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
298print '<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>";
299print '</tr>';
300
301// Phone pro
302print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
303print '<input size="25" type="text" name="fieldphone" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_PHONE').'">';
304print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
305print '<td class="right">&nbsp;</td>';
306print '</tr>';
307
308// Phone perso
309
310print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
311print '<input size="25" type="text" name="fieldphoneperso" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_PHONE_PERSO').'">';
312print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
313print '<td class="right">&nbsp;</td>';
314print '</tr>';
315
316// Mobile
317print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
318print '<input size="25" type="text" name="fieldmobile" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_MOBILE').'">';
319print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
320print '<td class="right">&nbsp;</td>';
321print '</tr>';
322
323// Fax
324print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
325print '<input size="25" type="text" name="fieldfax" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_FAX').'">';
326print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
327print '<td class="right">&nbsp;</td>';
328print '</tr>';
329
330// Company
331print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
332print '<input size="25" type="text" name="fieldcompany" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_COMPANY').'">';
333print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
334print '<td class="right">&nbsp;</td>';
335print '</tr>';
336
337// Address
338print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
339print '<input size="25" type="text" name="fieldaddress" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_ADDRESS').'">';
340print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
341print '<td class="right">&nbsp;</td>';
342print '</tr>';
343
344// ZIP
345print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
346print '<input size="25" type="text" name="fieldzip" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_ZIP').'">';
347print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
348print '<td class="right">&nbsp;</td>';
349print '</tr>';
350
351// TOWN
352print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
353print '<input size="25" type="text" name="fieldtown" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_TOWN').'">';
354print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
355print '<td class="right">&nbsp;</td>';
356print '</tr>';
357
358// COUNTRY
359print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
360print '<input size="25" type="text" name="fieldcountry" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_COUNTRY').'">';
361print '</td><td>&nbsp;</td>';
362print '<td class="right">&nbsp;</td>';
363print '</tr>';
364
365// Description
366print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
367print '<input size="25" type="text" name="fielddescription" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_DESCRIPTION').'">';
368print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
369print '<td class="right">&nbsp;</td>';
370print '</tr>';
371
372// Public Note
373print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldNotePublic").'</td><td>';
374print '<input size="25" type="text" name="fieldnotepublic" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_NOTE_PUBLIC').'">';
375print '</td><td>'.$langs->trans("LDAPFieldNotePublicExample").'</td>';
376print '<td class="right">&nbsp;</td>';
377print '</tr>';
378
379// Birthday
380
381print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
382print '<input size="25" type="text" name="fieldbirthdate" value="' . getDolGlobalString('LDAP_MEMBER_FIELD_BIRTHDATE').'">';
383print '</td><td>&nbsp;</td>';
384print '<td class="right">&nbsp;</td>';
385print '</tr>';
386
387// Status
388print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
389print '<input size="25" type="text" name="fieldstatus" value="' . getDolGlobalString('LDAP_FIELD_MEMBER_STATUS').'">';
390print '</td><td>&nbsp;</td>';
391print '<td class="right">&nbsp;</td>';
392print '</tr>';
393
394// First subscription date
395
396print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
397print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="' . getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE').'">';
398print '</td><td>&nbsp;</td>';
399print '<td class="right">&nbsp;</td>';
400print '</tr>';
401
402// First subscription amount
403print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
404print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="' . getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT').'">';
405print '</td><td>&nbsp;</td>';
406print '<td class="right">&nbsp;</td>';
407print '</tr>';
408
409// Last subscription date
410print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
411print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="' . getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE').'">';
412print '</td><td>&nbsp;</td>';
413print '<td class="right">&nbsp;</td>';
414print '</tr>';
415
416// Last subscription amount
417print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
418print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="' . getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT').'">';
419print '</td><td>&nbsp;</td>';
420print '<td class="right">&nbsp;</td>';
421print '</tr>';
422
423// End last subscriptions
424print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
425print '<input size="25" type="text" name="fieldendlastsubscription" value="' . getDolGlobalString('LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION').'">';
426print '</td><td>&nbsp;</td>';
427print '<td class="right">&nbsp;</td>';
428print '</tr>';
429
430print '</table>';
431
432print info_admin($langs->trans("LDAPDescValues"));
433
434print dol_get_fiche_end();
435
436print $form->buttonsSaveCancel("Modify", '');
437
438print '</form>';
439
440
441
442/*
443 * Test the connection
444 */
445if (getDolGlobalString('LDAP_MEMBER_ACTIVE')) {
446 $butlabel = $langs->trans("LDAPTestSynchroMember");
447 $testlabel = 'testmember';
448 $key = getDolGlobalString('LDAP_KEY_MEMBERS');
449 $dn = getDolGlobalString('LDAP_MEMBER_DN');
450 $objectclass = getDolGlobalString('LDAP_MEMBER_OBJECT_CLASS');
451
452 show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
453}
454
455if (function_exists("ldap_connect")) {
456 if ($action == 'testmember') {
457 // Create object
458 $object = new Adherent($db);
459 $object->initAsSpecimen();
460
461 // Test synchro
462 $ldap = new Ldap();
463 $result = $ldap->connectBind();
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->dumpContent($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
499llxFooter();
500$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
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
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.