ldap_members.php 19 KB

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