ldap_members.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  4. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  5. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  7. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \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. // Load translation files required by the page
  34. $langs->loadLangs(array('admin', 'errors'));
  35. if (!$user->admin) {
  36. accessforbidden();
  37. }
  38. $action = GETPOST('action', 'aZ09');
  39. /*
  40. * Actions
  41. */
  42. if ($action == 'setvalue' && $user->admin) {
  43. $error = 0;
  44. $db->begin();
  45. if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) {
  46. $error++;
  47. }
  48. if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) {
  49. $error++;
  50. }
  51. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) {
  52. $error++;
  53. }
  54. // Members
  55. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) {
  56. $error++;
  57. }
  58. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) {
  59. $error++;
  60. }
  61. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) {
  62. $error++;
  63. }
  64. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) {
  65. $error++;
  66. }
  67. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) {
  68. $error++;
  69. }
  70. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) {
  71. $error++;
  72. }
  73. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) {
  74. $error++;
  75. }
  76. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) {
  77. $error++;
  78. }
  79. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) {
  80. $error++;
  81. }
  82. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) {
  83. $error++;
  84. }
  85. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) {
  86. $error++;
  87. }
  88. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) {
  89. $error++;
  90. }
  91. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) {
  92. $error++;
  93. }
  94. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) {
  95. $error++;
  96. }
  97. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) {
  98. $error++;
  99. }
  100. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) {
  101. $error++;
  102. }
  103. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) {
  104. $error++;
  105. }
  106. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) {
  107. $error++;
  108. }
  109. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) {
  110. $error++;
  111. }
  112. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) {
  113. $error++;
  114. }
  115. if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) {
  116. $error++;
  117. }
  118. if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) {
  119. $error++;
  120. }
  121. if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) {
  122. $error++;
  123. }
  124. // Subscriptions
  125. if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
  126. $error++;
  127. }
  128. if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
  129. $error++;
  130. }
  131. if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) {
  132. $error++;
  133. }
  134. if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) {
  135. $error++;
  136. }
  137. // This one must be after the others
  138. $valkey = '';
  139. $key = GETPOST("key");
  140. if ($key) {
  141. $valkey = $conf->global->$key;
  142. }
  143. if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) {
  144. $error++;
  145. }
  146. if (!$error) {
  147. $db->commit();
  148. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  149. } else {
  150. $db->rollback();
  151. dol_print_error($db);
  152. }
  153. }
  154. /*
  155. * View
  156. */
  157. $form = new Form($db);
  158. llxHeader('', $langs->trans("LDAPSetup"), 'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
  159. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  160. print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup');
  161. $head = ldap_prepare_head();
  162. // Test si fonction LDAP actives
  163. if (!function_exists("ldap_connect")) {
  164. setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
  165. }
  166. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue&token='.newToken().'">';
  167. print '<input type="hidden" name="token" value="'.newToken().'">';
  168. print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1);
  169. print '<span class="opacitymedium">'.$langs->trans("LDAPDescMembers").'</span><br>';
  170. print '<br>';
  171. print '<table class="noborder centpercent">';
  172. print '<tr class="liste_titre">';
  173. print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
  174. print "</tr>\n";
  175. // DN Pour les adherents
  176. print '<!-- LDAP_MEMBER_DN -->';
  177. print '<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
  178. print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
  179. print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
  180. print '<td>&nbsp;</td>';
  181. print '</tr>';
  182. // List of object class used to define attributes in structure
  183. print '<!-- LDAP_MEMBER_OBJECT_CLASS -->';
  184. print '<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
  185. print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.'">';
  186. print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
  187. print '<td>&nbsp;</td>';
  188. print '</tr>';
  189. // Filter, used to filter search
  190. print '<!-- LDAP_MEMBER_FILTER -->';
  191. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
  192. print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_MEMBER_FILTER.'">';
  193. print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
  194. print '<td></td>';
  195. print '</tr>';
  196. print '</table>';
  197. print '<br>';
  198. print '<table class="noborder centpercent">';
  199. print '<tr class="liste_titre">';
  200. print '<td>'.$langs->trans("LDAPDolibarrMapping").'</td>';
  201. print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
  202. print '<td class="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
  203. print "</tr>\n";
  204. // Filtre
  205. // Common name
  206. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
  207. print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
  208. print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
  209. 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>";
  210. print '</tr>';
  211. // Name
  212. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
  213. print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
  214. print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
  215. 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>";
  216. print '</tr>';
  217. // Firstname
  218. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
  219. print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.'">';
  220. print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
  221. print '<td class="right">&nbsp;</td>';
  222. print '</tr>';
  223. // Login unix
  224. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
  225. print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
  226. print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
  227. 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>";
  228. print '</tr>';
  229. // Login samba
  230. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
  231. print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
  232. print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
  233. 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>";
  234. print '</tr>';
  235. // Password not crypted
  236. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
  237. print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.'">';
  238. print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
  239. print '<td class="right">&nbsp;</td>';
  240. print '</tr>';
  241. // Password crypted
  242. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
  243. print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.'">';
  244. print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
  245. print '<td class="right">&nbsp;</td>';
  246. print '</tr>';
  247. // Mail
  248. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
  249. print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
  250. print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
  251. 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>";
  252. print '</tr>';
  253. // Phone pro
  254. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
  255. print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.'">';
  256. print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
  257. print '<td class="right">&nbsp;</td>';
  258. print '</tr>';
  259. // Phone perso
  260. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
  261. print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.'">';
  262. print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
  263. print '<td class="right">&nbsp;</td>';
  264. print '</tr>';
  265. // Mobile
  266. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
  267. print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.'">';
  268. print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
  269. print '<td class="right">&nbsp;</td>';
  270. print '</tr>';
  271. // Skype
  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 class="right">&nbsp;</td>';
  276. print '</tr>';
  277. // Fax
  278. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
  279. print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.'">';
  280. print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
  281. print '<td class="right">&nbsp;</td>';
  282. print '</tr>';
  283. // Company
  284. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
  285. print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_MEMBER_FIELD_COMPANY.'">';
  286. print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
  287. print '<td class="right">&nbsp;</td>';
  288. print '</tr>';
  289. // Address
  290. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
  291. print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.'">';
  292. print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
  293. print '<td class="right">&nbsp;</td>';
  294. print '</tr>';
  295. // ZIP
  296. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
  297. print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.'">';
  298. print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
  299. print '<td class="right">&nbsp;</td>';
  300. print '</tr>';
  301. // TOWN
  302. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
  303. print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.'">';
  304. print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
  305. print '<td class="right">&nbsp;</td>';
  306. print '</tr>';
  307. // COUNTRY
  308. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
  309. print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.'">';
  310. print '</td><td>&nbsp;</td>';
  311. print '<td class="right">&nbsp;</td>';
  312. print '</tr>';
  313. // Description
  314. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
  315. print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.'">';
  316. print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
  317. print '<td class="right">&nbsp;</td>';
  318. print '</tr>';
  319. // Public Note
  320. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldNotePublic").'</td><td>';
  321. print '<input size="25" type="text" name="fieldnotepublic" value="'.$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC.'">';
  322. print '</td><td>'.$langs->trans("LDAPFieldNotePublicExample").'</td>';
  323. print '<td class="right">&nbsp;</td>';
  324. print '</tr>';
  325. // Birthday
  326. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
  327. print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.'">';
  328. print '</td><td>&nbsp;</td>';
  329. print '<td class="right">&nbsp;</td>';
  330. print '</tr>';
  331. // Status
  332. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
  333. print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.'">';
  334. print '</td><td>&nbsp;</td>';
  335. print '<td class="right">&nbsp;</td>';
  336. print '</tr>';
  337. // First subscription date
  338. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
  339. print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.'">';
  340. print '</td><td>&nbsp;</td>';
  341. print '<td class="right">&nbsp;</td>';
  342. print '</tr>';
  343. // First subscription amount
  344. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
  345. print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.'">';
  346. print '</td><td>&nbsp;</td>';
  347. print '<td class="right">&nbsp;</td>';
  348. print '</tr>';
  349. // Last subscription date
  350. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
  351. print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.'">';
  352. print '</td><td>&nbsp;</td>';
  353. print '<td class="right">&nbsp;</td>';
  354. print '</tr>';
  355. // Last subscription amount
  356. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
  357. print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.'">';
  358. print '</td><td>&nbsp;</td>';
  359. print '<td class="right">&nbsp;</td>';
  360. print '</tr>';
  361. // End last subscriptions
  362. print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
  363. print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.'">';
  364. print '</td><td>&nbsp;</td>';
  365. print '<td class="right">&nbsp;</td>';
  366. print '</tr>';
  367. print '</table>';
  368. print info_admin($langs->trans("LDAPDescValues"));
  369. print dol_get_fiche_end();
  370. print $form->buttonsSaveCancel("Modify", '');
  371. print '</form>';
  372. /*
  373. * Test de la connexion
  374. */
  375. if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) {
  376. $butlabel = $langs->trans("LDAPTestSynchroMember");
  377. $testlabel = 'testmember';
  378. $key = $conf->global->LDAP_KEY_MEMBERS;
  379. $dn = $conf->global->LDAP_MEMBER_DN;
  380. $objectclass = $conf->global->LDAP_MEMBER_OBJECT_CLASS;
  381. show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
  382. }
  383. if (function_exists("ldap_connect")) {
  384. if ($_GET["action"] == 'testmember') {
  385. // Creation objet
  386. $object = new Adherent($db);
  387. $object->initAsSpecimen();
  388. // Test synchro
  389. $ldap = new Ldap();
  390. $result = $ldap->connect_bind();
  391. if ($result > 0) {
  392. $info = $object->_load_ldap_info();
  393. $dn = $object->_load_ldap_dn($info);
  394. $result1 = $ldap->delete($dn); // To be sure to delete existing records
  395. $result2 = $ldap->add($dn, $info, $user); // Now the test
  396. $result3 = $ldap->delete($dn); // Clean what we did
  397. if ($result2 > 0) {
  398. print img_picto('', 'info').' ';
  399. print '<span class="ok">'.$langs->trans("LDAPSynchroOK").'</span><br>';
  400. } else {
  401. print img_picto('', 'error').' ';
  402. print '<span class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
  403. print ': '.$ldap->error;
  404. print '</span><br>';
  405. print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
  406. }
  407. print "<br>\n";
  408. print "LDAP input file used for test:<br><br>\n";
  409. print nl2br($ldap->dump_content($dn, $info));
  410. print "\n<br>";
  411. } else {
  412. print img_picto('', 'error').' ';
  413. print '<span class="error">'.$langs->trans("LDAPSynchroKO");
  414. print ': '.$ldap->error;
  415. print '</span><br>';
  416. print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
  417. }
  418. }
  419. }
  420. // End of page
  421. llxFooter();
  422. $db->close();