ldap_members.php 20 KB

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