dolibarr  9.0.0
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 <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 // Load translation files required by the page
37 $langs->loadLangs(array('admin', '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?restore_lastsearch_values=1">'.$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 print '<table class="noborder" width="100%">';
137 
138 print '<tr class="liste_titre">';
139 print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
140 print "</tr>\n";
141 
142 // DN Pour les adherents
143 print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
144 print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
145 print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
146 print '<td>&nbsp;</td>';
147 print '</tr>';
148 
149 // List of object class used to define attributes in structure
150 print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
151 print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.'">';
152 print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
153 print '<td>&nbsp;</td>';
154 print '</tr>';
155 
156 // Filter, used to filter search
157 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
158 print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_MEMBER_FILTER.'">';
159 print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
160 print '<td></td>';
161 print '</tr>';
162 
163 print '</table>';
164 print '<br>';
165 print '<table class="noborder" width="100%">';
166 
167 print '<tr class="liste_titre">';
168 print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
169 print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
170 print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
171 print "</tr>\n";
172 
173 // Filtre
174 
175 // Common name
176 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
177 print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
178 print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
179 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>";
180 print '</tr>';
181 
182 // Name
183 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
184 print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
185 print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
186 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>";
187 print '</tr>';
188 
189 // Firstname
190 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
191 print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.'">';
192 print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
193 print '<td align="right">&nbsp;</td>';
194 print '</tr>';
195 
196 // Login unix
197 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
198 print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
199 print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
200 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>";
201 print '</tr>';
202 
203 // Login samba
204 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
205 print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
206 print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
207 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>";
208 print '</tr>';
209 
210 // Password not crypted
211 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
212 print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.'">';
213 print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
214 print '<td align="right">&nbsp;</td>';
215 print '</tr>';
216 
217 // Password crypted
218 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
219 print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.'">';
220 print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
221 print '<td align="right">&nbsp;</td>';
222 print '</tr>';
223 
224 // Mail
225 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
226 print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
227 print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
228 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>";
229 print '</tr>';
230 
231 // Phone pro
232 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
233 print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.'">';
234 print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
235 print '<td align="right">&nbsp;</td>';
236 print '</tr>';
237 
238 // Phone perso
239 
240 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
241 print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.'">';
242 print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
243 print '<td align="right">&nbsp;</td>';
244 print '</tr>';
245 
246 // Mobile
247 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
248 print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.'">';
249 print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
250 print '<td align="right">&nbsp;</td>';
251 print '</tr>';
252 
253 // Skype
254 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldSkype").'</td><td>';
255 print '<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_MEMBER_FIELD_SKYPE.'">';
256 print '</td><td>'.$langs->trans("LDAPFieldSkypeExample").'</td>';
257 print '<td align="right">&nbsp;</td>';
258 print '</tr>';
259 
260 // Fax
261 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
262 print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.'">';
263 print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
264 print '<td align="right">&nbsp;</td>';
265 print '</tr>';
266 
267 // Company
268 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
269 print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_MEMBER_FIELD_COMPANY.'">';
270 print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
271 print '<td align="right">&nbsp;</td>';
272 print '</tr>';
273 
274 // Address
275 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
276 print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.'">';
277 print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
278 print '<td align="right">&nbsp;</td>';
279 print '</tr>';
280 
281 // ZIP
282 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
283 print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.'">';
284 print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
285 print '<td align="right">&nbsp;</td>';
286 print '</tr>';
287 
288 // TOWN
289 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
290 print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.'">';
291 print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
292 print '<td align="right">&nbsp;</td>';
293 print '</tr>';
294 
295 // COUNTRY
296 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
297 print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.'">';
298 print '</td><td>&nbsp;</td>';
299 print '<td align="right">&nbsp;</td>';
300 print '</tr>';
301 
302 // Description
303 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
304 print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.'">';
305 print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
306 print '<td align="right">&nbsp;</td>';
307 print '</tr>';
308 
309 // Public Note
310 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldNotePublic").'</td><td>';
311 print '<input size="25" type="text" name="fieldnotepublic" value="'.$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC.'">';
312 print '</td><td>'.$langs->trans("LDAPFieldNotePublicExample").'</td>';
313 print '<td align="right">&nbsp;</td>';
314 print '</tr>';
315 
316 // Birthday
317 
318 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
319 print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.'">';
320 print '</td><td>&nbsp;</td>';
321 print '<td align="right">&nbsp;</td>';
322 print '</tr>';
323 
324 // Status
325 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
326 print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.'">';
327 print '</td><td>&nbsp;</td>';
328 print '<td align="right">&nbsp;</td>';
329 print '</tr>';
330 
331 // First subscription date
332 
333 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
334 print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.'">';
335 print '</td><td>&nbsp;</td>';
336 print '<td align="right">&nbsp;</td>';
337 print '</tr>';
338 
339 // First subscription amount
340 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
341 print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.'">';
342 print '</td><td>&nbsp;</td>';
343 print '<td align="right">&nbsp;</td>';
344 print '</tr>';
345 
346 // Last subscription date
347 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
348 print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.'">';
349 print '</td><td>&nbsp;</td>';
350 print '<td align="right">&nbsp;</td>';
351 print '</tr>';
352 
353 // Last subscription amount
354 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
355 print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.'">';
356 print '</td><td>&nbsp;</td>';
357 print '<td align="right">&nbsp;</td>';
358 print '</tr>';
359 
360 // End last subscriptions
361 print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
362 print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.'">';
363 print '</td><td>&nbsp;</td>';
364 print '<td align="right">&nbsp;</td>';
365 print '</tr>';
366 
367 print '</table>';
368 
369 print info_admin($langs->trans("LDAPDescValues"));
370 
371 dol_fiche_end();
372 
373 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
374 
375 print '</form>';
376 
377 
378 
379 /*
380  * Test de la connexion
381  */
382 if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
383 {
384  $butlabel=$langs->trans("LDAPTestSynchroMember");
385  $testlabel='testmember';
386  $key=$conf->global->LDAP_KEY_MEMBERS;
387  $dn=$conf->global->LDAP_MEMBER_DN;
388  $objectclass=$conf->global->LDAP_MEMBER_OBJECT_CLASS;
389 
390  show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
391 }
392 
393 if (function_exists("ldap_connect"))
394 {
395  if ($_GET["action"] == 'testmember')
396  {
397  // Creation objet
398  $object=new Adherent($db);
399  $object->initAsSpecimen();
400 
401  // Test synchro
402  $ldap=new Ldap();
403  $result=$ldap->connect_bind();
404 
405  if ($result > 0)
406  {
407  $info=$object->_load_ldap_info();
408  $dn=$object->_load_ldap_dn($info);
409 
410  $result1=$ldap->delete($dn); // To be sure to delete existing records
411  $result2=$ldap->add($dn,$info,$user); // Now the test
412  $result3=$ldap->delete($dn); // Clean what we did
413 
414  if ($result2 > 0)
415  {
416  print img_picto('','info').' ';
417  print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
418  }
419  else
420  {
421  print img_picto('','error').' ';
422  print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
423  print ': '.$ldap->error;
424  print '</font><br>';
425  print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
426  }
427 
428  print "<br>\n";
429  print "LDAP input file used for test:<br><br>\n";
430  print nl2br($ldap->dump_content($dn,$info));
431  print "\n<br>";
432  }
433  else
434  {
435  print img_picto('','error').' ';
436  print '<font class="error">'.$langs->trans("LDAPSynchroKO");
437  print ': '.$ldap->error;
438  print '</font><br>';
439  print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
440  }
441  }
442 }
443 
444 // End of page
445 llxFooter();
446 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:510
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
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', $morecss='')
Show information for admin users or standard users.
dol_fiche_end($notab=0)
Show tab footer of a card.
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:44
Class to manage LDAP features.
Definition: ldap.class.php:30
ldap_prepare_head()
Initialize the array of tabs for customer invoice.
Definition: ldap.lib.php:31
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.