29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ldap.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
36 $langs->loadLangs(array(
"admin",
"errors"));
42 $action =
GETPOST(
'action',
'aZ09');
48 if ($action ==
'setvalue' && $user->admin) {
66 if (!
dolibarr_set_const($db,
'LDAP_CONTACT_FIELD_FIRSTNAME',
GETPOST(
"fieldfirstname"),
'chaine', 0,
'', $conf->entity)) {
78 if (!
dolibarr_set_const($db,
'LDAP_CONTACT_FIELD_HOMEPHONE',
GETPOST(
"fieldhomephone"),
'chaine', 0,
'', $conf->entity)) {
107 $valkey = $conf->global->$key;
109 if (!
dolibarr_set_const($db,
'LDAP_KEY_CONTACTS', $valkey,
'chaine', 0,
'', $conf->entity)) {
130 llxHeader(
'', $langs->trans(
"LDAPSetup"),
'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP');
131 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
133 print
load_fiche_titre($langs->trans(
"LDAPSetup"), $linkback,
'title_setup');
138 if (!function_exists(
"ldap_connect")) {
139 setEventMessages($langs->trans(
"LDAPFunctionsNotAvailableOnPHP"), null,
'errors');
145 print
'<span class="opacitymedium">'.$langs->trans(
"LDAPDescContact").
'</span><br>';
148 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.
newToken().
'">';
149 print
'<input type="hidden" name="token" value="'.newToken().
'">';
151 print
'<table class="noborder centpercent">';
153 print
'<tr class="liste_titre">';
154 print
'<td colspan="4">'.$langs->trans(
"LDAPSynchronizeContacts").
'</td>';
158 print
'<!-- LDAP_CONTACT_DN -->';
159 print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactDn").
'</span></td><td>';
160 print
'<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.
'">';
161 print
'</td><td>'.$langs->trans(
"LDAPContactDnExample").
'</td>';
162 print
'<td> </td>';
166 print
'<!-- LDAP_CONTACT_OBJECT_CLASS -->';
167 print
'<tr class="oddeven"><td><span class="fieldrequired">'.$langs->trans(
"LDAPContactObjectClassList").
'</span></td><td>';
168 print
'<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_CONTACT_OBJECT_CLASS.
'">';
169 print
'</td><td>'.$langs->trans(
"LDAPContactObjectClassListExample").
'</td>';
170 print
'<td> </td>';
175 print
'<table class="noborder centpercent">';
177 print
'<tr class="liste_titre">';
178 print
'<td>'.$langs->trans(
"LDAPDolibarrMapping").
'</td>';
179 print
'<td colspan="2">'.$langs->trans(
"LDAPLdapMapping").
'</td>';
180 print
'<td class="right">'.$langs->trans(
"LDAPNamingAttribute").
'</td>';
184 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFullname").
'</td><td>';
185 print
'<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_CONTACT_FIELD_FULLNAME.
'">';
186 print
'</td><td>'.$langs->trans(
"LDAPFieldFullnameExample").
'</td>';
187 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FULLNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FULLNAME ?
' checked' :
'').
"></td>";
191 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldName").
'</td><td>';
192 print
'<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_CONTACT_FIELD_NAME.
'">';
193 print
'</td><td>'.$langs->trans(
"LDAPFieldNameExample").
'</td>';
194 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_NAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_NAME ?
' checked' :
'').
"></td>";
198 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFirstName").
'</td><td>';
199 print
'<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME.
'">';
200 print
'</td><td>'.$langs->trans(
"LDAPFieldFirstNameExample").
'</td>';
201 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FIRSTNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FIRSTNAME ?
' checked' :
'').
"></td>";
205 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCompany").
'</td><td>';
206 print
'<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_CONTACT_FIELD_COMPANY.
'">';
207 print
'</td><td>'.$langs->trans(
"LDAPFieldCompanyExample").
'</td>';
208 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COMPANY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COMPANY ?
' checked' :
'').
"></td>";
212 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMail").
'</td><td>';
213 print
'<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_CONTACT_FIELD_MAIL.
'">';
214 print
'</td><td>'.$langs->trans(
"LDAPFieldMailExample").
'</td>';
215 print
'<td class="right"><input type="radio" name="key" value=">LDAP_CONTACT_FIELD_MAIL"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MAIL ?
' checked' :
'').
"></td>";
219 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldPhone").
'</td><td>';
220 print
'<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_CONTACT_FIELD_PHONE.
'">';
221 print
'</td><td>'.$langs->trans(
"LDAPFieldPhoneExample").
'</td>';
222 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_PHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_PHONE ?
' checked' :
'').
"></td>";
226 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldHomePhone").
'</td><td>';
227 print
'<input size="25" type="text" name="fieldhomephone" value="'.$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE.
'">';
228 print
'</td><td>'.$langs->trans(
"LDAPFieldHomePhoneExample").
'</td>';
229 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_HOMEPHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_HOMEPHONE ?
' checked' :
'').
"></td>";
233 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldMobile").
'</td><td>';
234 print
'<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_CONTACT_FIELD_MOBILE.
'">';
235 print
'</td><td>'.$langs->trans(
"LDAPFieldMobileExample").
'</td>';
236 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_MOBILE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_MOBILE ?
' checked' :
'').
"></td>";
240 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldSkype").
'</td><td>';
241 print
'<input size="25" type="text" name="fieldskype" value="'.$conf->global->LDAP_CONTACT_FIELD_SKYPE.
'">';
242 print
'</td><td>'.$langs->trans(
"LDAPFieldSkypeExample").
'</td>';
243 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_SKYPE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_SKYPE ?
' checked' :
'').
"></td>";
247 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldFax").
'</td><td>';
248 print
'<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_CONTACT_FIELD_FAX.
'">';
249 print
'</td><td>'.$langs->trans(
"LDAPFieldFaxExample").
'</td>';
250 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FAX"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_FAX ?
' checked' :
'').
"></td>";
254 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldAddress").
'</td><td>';
255 print
'<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_CONTACT_FIELD_ADDRESS.
'">';
256 print
'</td><td>'.$langs->trans(
"LDAPFieldAddressExample").
'</td>';
257 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ADDRESS"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ADDRESS ?
' checked' :
'').
"></td>";
261 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldZip").
'</td><td>';
262 print
'<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_CONTACT_FIELD_ZIP.
'">';
263 print
'</td><td>'.$langs->trans(
"LDAPFieldZipExample").
'</td>';
264 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ZIP"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_ZIP ?
' checked' :
'').
"></td>";
268 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldTown").
'</td><td>';
269 print
'<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_CONTACT_FIELD_TOWN.
'">';
270 print
'</td><td>'.$langs->trans(
"LDAPFieldTownExample").
'</td>';
271 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_TOWN"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_TOWN ?
' checked' :
'').
"></td>";
275 print
'<tr class="oddeven"><td>'.$langs->trans(
"LDAPFieldCountry").
'</td><td>';
276 print
'<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_CONTACT_FIELD_COUNTRY.
'">';
277 print
'</td><td> </td>';
278 print
'<td class="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COUNTRY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS == $conf->global->LDAP_CONTACT_FIELD_COUNTRY ?
' checked' :
'').
"></td>";
283 print
info_admin($langs->trans(
"LDAPDescValues"));
287 print
$form->buttonsSaveCancel(
"Modify",
'');
295 $butlabel = $langs->trans(
"LDAPTestSynchroContact");
297 $key = $conf->global->LDAP_KEY_CONTACTS;
298 $dn = $conf->global->LDAP_CONTACT_DN;
299 $objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS;
304 if (function_exists(
"ldap_connect")) {
305 if ($_GET[
"action"] ==
'test') {
308 $object->initAsSpecimen();
312 $result = $ldap->connect_bind();
315 $info = $object->_load_ldap_info();
316 $dn = $object->_load_ldap_dn($info);
318 $result1 = $ldap->delete($dn);
319 $result2 = $ldap->add($dn, $info, $user);
320 $result3 = $ldap->delete($dn);
324 print
'<span class="ok">'.$langs->trans(
"LDAPSynchroOK").
'</span><br>';
327 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKOMayBePermissions");
328 print
': '.$ldap->error;
330 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
334 print
"LDAP input file used for test:<br><br>\n";
335 print nl2br($ldap->dump_content($dn, $info));
339 print
'<span class="error">'.$langs->trans(
"LDAPSynchroKO");
340 print
': '.$ldap->error;
342 print $langs->trans(
"ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).
'<br>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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).
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
Show button test LDAP synchro.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class to manage LDAP features.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
ldap_prepare_head()
Initialize the array of tabs for customer invoice.