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
23/**
24 *   	\file       htdocs/admin/ldap_members.php
25 *		\ingroup    ldap member
26 *		\brief      Page d'administration/configuration du module Ldap adherent
27 */
28
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
32require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
34require_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
39if (!$user->admin)
40  accessforbidden();
41
42$action = GETPOST('action', 'aZ09');
43
44/*
45 * Actions
46 */
47
48if ($action == 'setvalue' && $user->admin)
49{
50	$error = 0;
51
52	$db->begin();
53
54	if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++;
55	if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++;
56	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++;
57	// Members
58	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++;
59	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++;
60	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++;
61	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++;
62	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++;
63	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++;
64	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++;
65	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++;
66	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++;
67	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++;
68	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++;
69	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++;
70	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++;
71	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++;
72	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++;
73	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++;
74	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++;
75	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++;
76	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++;
77	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++;
78	if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++;
79	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++;
80	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++;
81
82	// Subscriptions
83	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++;
84	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++;
85	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++;
86	if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++;
87
88	// This one must be after the others
89	$valkey = '';
90	$key = GETPOST("key");
91	if ($key) $valkey = $conf->global->$key;
92	if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++;
93
94	if (!$error)
95	{
96		$db->commit();
97		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
98	} else {
99		$db->rollback();
100		dol_print_error($db);
101	}
102}
103
104
105
106/*
107 * View
108 */
109
110$form = new Form($db);
111
112llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
113$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
114
115print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
116
117$head = ldap_prepare_head();
118
119// Test si fonction LDAP actives
120if (!function_exists("ldap_connect"))
121{
122	setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
123}
124
125print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
126print '<input type="hidden" name="token" value="'.newToken().'">';
127
128print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1);
129
130
131print $langs->trans("LDAPDescMembers").'<br>';
132print '<br>';
133
134print '<table class="noborder centpercent">';
135
136print '<tr class="liste_titre">';
137print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
138print "</tr>\n";
139
140// DN Pour les adherents
141print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
142print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
143print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
144print '<td>&nbsp;</td>';
145print '</tr>';
146
147// List of object class used to define attributes in structure
148print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
149print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.'">';
150print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
151print '<td>&nbsp;</td>';
152print '</tr>';
153
154// Filter, used to filter search
155print '<tr class="oddeven"><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
156print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_MEMBER_FILTER.'">';
157print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
158print '<td></td>';
159print '</tr>';
160
161print '</table>';
162print '<br>';
163print '<table class="noborder centpercent">';
164
165print '<tr class="liste_titre">';
166print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
167print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
168print '<td class="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
169print "</tr>\n";
170
171// Filtre
172
173// Common name
174print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
175print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
176print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
177print '<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>";
178print '</tr>';
179
180// Name
181print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
182print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
183print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
184print '<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>";
185print '</tr>';
186
187// Firstname
188print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
189print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.'">';
190print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
191print '<td class="right">&nbsp;</td>';
192print '</tr>';
193
194// Login unix
195print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
196print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
197print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
198print '<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>";
199print '</tr>';
200
201// Login samba
202print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
203print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
204print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
205print '<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>";
206print '</tr>';
207
208// Password not crypted
209print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
210print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.'">';
211print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
212print '<td class="right">&nbsp;</td>';
213print '</tr>';
214
215// Password crypted
216print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
217print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.'">';
218print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
219print '<td class="right">&nbsp;</td>';
220print '</tr>';
221
222// Mail
223print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
224print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
225print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
226print '<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>";
227print '</tr>';
228
229// Phone pro
230print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
231print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.'">';
232print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
233print '<td class="right">&nbsp;</td>';
234print '</tr>';
235
236// Phone perso
237
238print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
239print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.'">';
240print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
241print '<td class="right">&nbsp;</td>';
242print '</tr>';
243
244// Mobile
245print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
246print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.'">';
247print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
248print '<td class="right">&nbsp;</td>';
249print '</tr>';
250
251// Skype
252print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldSkype").'</td><td>';
253print '<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_MEMBER_FIELD_SKYPE.'">';
254print '</td><td>'.$langs->trans("LDAPFieldSkypeExample").'</td>';
255print '<td class="right">&nbsp;</td>';
256print '</tr>';
257
258// Fax
259print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
260print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.'">';
261print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
262print '<td class="right">&nbsp;</td>';
263print '</tr>';
264
265// Company
266print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
267print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_MEMBER_FIELD_COMPANY.'">';
268print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
269print '<td class="right">&nbsp;</td>';
270print '</tr>';
271
272// Address
273print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
274print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.'">';
275print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
276print '<td class="right">&nbsp;</td>';
277print '</tr>';
278
279// ZIP
280print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
281print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.'">';
282print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
283print '<td class="right">&nbsp;</td>';
284print '</tr>';
285
286// TOWN
287print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
288print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.'">';
289print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
290print '<td class="right">&nbsp;</td>';
291print '</tr>';
292
293// COUNTRY
294print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
295print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.'">';
296print '</td><td>&nbsp;</td>';
297print '<td class="right">&nbsp;</td>';
298print '</tr>';
299
300// Description
301print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
302print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.'">';
303print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
304print '<td class="right">&nbsp;</td>';
305print '</tr>';
306
307// Public Note
308print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldNotePublic").'</td><td>';
309print '<input size="25" type="text" name="fieldnotepublic" value="'.$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC.'">';
310print '</td><td>'.$langs->trans("LDAPFieldNotePublicExample").'</td>';
311print '<td class="right">&nbsp;</td>';
312print '</tr>';
313
314// Birthday
315
316print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
317print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.'">';
318print '</td><td>&nbsp;</td>';
319print '<td class="right">&nbsp;</td>';
320print '</tr>';
321
322// Status
323print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
324print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.'">';
325print '</td><td>&nbsp;</td>';
326print '<td class="right">&nbsp;</td>';
327print '</tr>';
328
329// First subscription date
330
331print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
332print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.'">';
333print '</td><td>&nbsp;</td>';
334print '<td class="right">&nbsp;</td>';
335print '</tr>';
336
337// First subscription amount
338print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
339print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.'">';
340print '</td><td>&nbsp;</td>';
341print '<td class="right">&nbsp;</td>';
342print '</tr>';
343
344// Last subscription date
345print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
346print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.'">';
347print '</td><td>&nbsp;</td>';
348print '<td class="right">&nbsp;</td>';
349print '</tr>';
350
351// Last subscription amount
352print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
353print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.'">';
354print '</td><td>&nbsp;</td>';
355print '<td class="right">&nbsp;</td>';
356print '</tr>';
357
358// End last subscriptions
359print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
360print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.'">';
361print '</td><td>&nbsp;</td>';
362print '<td class="right">&nbsp;</td>';
363print '</tr>';
364
365print '</table>';
366
367print info_admin($langs->trans("LDAPDescValues"));
368
369print dol_get_fiche_end();
370
371print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
372
373print '</form>';
374
375
376
377/*
378 * Test de la connexion
379 */
380if (!empty($conf->global->LDAP_MEMBER_ACTIVE))
381{
382	$butlabel = $langs->trans("LDAPTestSynchroMember");
383	$testlabel = 'testmember';
384	$key = $conf->global->LDAP_KEY_MEMBERS;
385	$dn = $conf->global->LDAP_MEMBER_DN;
386	$objectclass = $conf->global->LDAP_MEMBER_OBJECT_CLASS;
387
388	show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
389}
390
391if (function_exists("ldap_connect"))
392{
393	if ($_GET["action"] == 'testmember')
394	{
395		// Creation objet
396		$object = new Adherent($db);
397		$object->initAsSpecimen();
398
399		// Test synchro
400		$ldap = new Ldap();
401		$result = $ldap->connect_bind();
402
403		if ($result > 0)
404		{
405			$info = $object->_load_ldap_info();
406			$dn = $object->_load_ldap_dn($info);
407
408			$result1 = $ldap->delete($dn); // To be sure to delete existing records
409			$result2 = $ldap->add($dn, $info, $user); // Now the test
410			$result3 = $ldap->delete($dn); // Clean what we did
411
412			if ($result2 > 0)
413			{
414				print img_picto('', 'info').' ';
415				print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
416			} else {
417				print img_picto('', 'error').' ';
418				print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
419				print ': '.$ldap->error;
420				print '</font><br>';
421				print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
422			}
423
424			print "<br>\n";
425			print "LDAP input file used for test:<br><br>\n";
426			print nl2br($ldap->dump_content($dn, $info));
427			print "\n<br>";
428		} else {
429			print img_picto('', 'error').' ';
430			print '<font class="error">'.$langs->trans("LDAPSynchroKO");
431			print ': '.$ldap->error;
432			print '</font><br>';
433			print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
434		}
435	}
436}
437
438// End of page
439llxFooter();
440$db->close();
441