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