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