mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-10 11:31:26 +01:00
NEW add html.formldap.class.php
This commit is contained in:
@@ -158,13 +158,13 @@ print dol_get_fiche_end();
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a></div>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,13 +124,13 @@ print dol_get_fiche_end();
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) {
|
||||
if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) {
|
||||
if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ if (empty($reshook)) {
|
||||
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("'LDAP_PASSWORD_HASH_TYPE'", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
|
||||
if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("LDAP_PASSWORD_HASH_TYPE", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@@ -150,13 +150,9 @@ print "</tr>\n";
|
||||
// Synchro utilisateurs/groupes active
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnSynchroActive").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['0'] = $langs->trans("No");
|
||||
$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr");
|
||||
$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP");
|
||||
print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE);
|
||||
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_SYNCHRO_ACTIVE'), 'activesynchro');
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPDnSynchroActiveExample").'</span>';
|
||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && empty($conf->global->LDAP_USER_DN)) {
|
||||
print '<br><span class="error">'.$langs->trans("LDAPSetupNotComplete").'</span>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
@@ -164,32 +160,21 @@ print '</td></tr>';
|
||||
// Synchro contact active
|
||||
if (!empty($conf->societe->enabled)) {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['0'] = $langs->trans("No");
|
||||
$arraylist['1'] = $langs->trans("DolibarrToLDAP");
|
||||
print $form->selectarray('activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE);
|
||||
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_CONTACT_ACTIVE'), 'activecontact', array(Ldap::SYNCHRO_LDAP_TO_DOLIBARR));
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPDnContactActiveExample").'</span></td></tr>';
|
||||
}
|
||||
|
||||
// Synchro member active
|
||||
if (!empty($conf->adherent->enabled)) {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['0'] = $langs->trans("No");
|
||||
$arraylist['1'] = $langs->trans("DolibarrToLDAP");
|
||||
$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
|
||||
print $form->selectarray('activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE);
|
||||
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_ACTIVE'), 'activemembers', array(), 2);
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPDnMemberActiveExample").'</span></td></tr>';
|
||||
}
|
||||
|
||||
// Synchro member type active
|
||||
if (!empty($conf->adherent->enabled)) {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberTypeActive").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['0'] = $langs->trans("No");
|
||||
$arraylist['1'] = $langs->trans("DolibarrToLDAP");
|
||||
$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
|
||||
print $form->selectarray('activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE);
|
||||
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE'), 'activememberstypes', array(), 2);
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPDnMemberTypeActiveExample").'</span></td></tr>';
|
||||
}
|
||||
|
||||
@@ -206,53 +191,39 @@ print "</tr>\n";
|
||||
|
||||
// Type
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Type").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['activedirectory'] = 'Active Directory';
|
||||
$arraylist['openldap'] = 'OpenLdap';
|
||||
$arraylist['egroupware'] = 'Egroupware';
|
||||
print $form->selectarray('type', $arraylist, $conf->global->LDAP_SERVER_TYPE);
|
||||
print $formldap->selectLdapServerType(getDolGlobalString('LDAP_SERVER_TYPE'), 'type');
|
||||
print '</td><td> </td></tr>';
|
||||
|
||||
// Version
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Version").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['3'] = 'Version 3';
|
||||
$arraylist['2'] = 'Version 2';
|
||||
print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION);
|
||||
print $formldap->selectLdapServerProtocolVersion(getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION'), 'LDAP_SERVER_PROTOCOLVERSION');
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPServerProtocolVersion").'</span></td></tr>';
|
||||
|
||||
// Serveur primaire
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("LDAPPrimaryServer").'</td><td>';
|
||||
print '<input class="minwidth200" type="text" name="host" value="'.$conf->global->LDAP_SERVER_HOST.'">';
|
||||
print '<input class="minwidth200" type="text" name="host" value="'.getDolGlobalString('LDAP_SERVER_HOST').'">';
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPServerExample").'</span></td></tr>';
|
||||
|
||||
// Serveur secondaire
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("LDAPSecondaryServer").'</td><td>';
|
||||
print '<input class="minwidth200" type="text" name="slave" value="'.$conf->global->LDAP_SERVER_HOST_SLAVE.'">';
|
||||
print '<input class="minwidth200" type="text" name="slave" value="'.getDolGlobalString('LDAP_SERVER_HOST_SLAVE').'">';
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPServerExample").'</span></td></tr>';
|
||||
|
||||
// Port
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerPort").'</td><td>';
|
||||
if (!empty($conf->global->LDAP_SERVER_PORT)) {
|
||||
print '<input class="width75" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.'">';
|
||||
} else {
|
||||
print '<input class="width75" type="text" name="port" value="389">';
|
||||
}
|
||||
print '<input class="width75" type="text" name="port" value="'.getDolGlobalString('LDAP_SERVER_PORT', '389').'">';
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPServerPortExample").'</span></td></tr>';
|
||||
|
||||
// DNserver
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerDn").'</td><td>';
|
||||
print '<input class="minwidth300" type="text" name="dn" value="'.$conf->global->LDAP_SERVER_DN.'">';
|
||||
print '<input class="minwidth300" type="text" name="dn" value="'.getDolGlobalString('LDAP_SERVER_DN').'">';
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPServerDnExample").'</span></td></tr>';
|
||||
|
||||
// Utiliser TLS
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPServerUseTLS").'</td><td>';
|
||||
$arraylist = array();
|
||||
$arraylist['0'] = $langs->trans("No");
|
||||
$arraylist['1'] = $langs->trans("Yes");
|
||||
print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS);
|
||||
print $form->selectyesno('usetls', getDolGlobalInt('LDAP_SERVER_USE_TLS'), 1);
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans("LDAPServerUseTLSExample").'</span></td></tr>';
|
||||
|
||||
// Password hash type
|
||||
@@ -267,7 +238,7 @@ print "</tr>\n";
|
||||
// DNAdmin
|
||||
print '<!-- LDAP_ADMIN_DN -->';
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("LDAPAdminDn").'</td><td>';
|
||||
print '<input class="minwidth300" type="text" name="admin" value="'.$conf->global->LDAP_ADMIN_DN.'">';
|
||||
print '<input class="minwidth300" type="text" name="admin" value="'.getDolGlobalString('LDAP_ADMIN_DN').'">';
|
||||
print '</td><td class="maxwidthhalf"><span class="opacitymedium">'.$langs->trans("LDAPAdminDnExample").'</span></td></tr>';
|
||||
|
||||
// Pass
|
||||
@@ -276,7 +247,7 @@ print '<tr class="oddeven"><td>'.$langs->trans("LDAPPassword").'</td><td>';
|
||||
if (!empty($conf->global->LDAP_ADMIN_PASS)) {
|
||||
print '<input class="minwidth150" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">'; // je le met en visible pour test
|
||||
} else {
|
||||
print '<input class="minwidth150" type="text" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';
|
||||
print '<input class="minwidth150" type="text" name="pass" value="">';
|
||||
}
|
||||
print '</td><td><span class="opacitymedium">'.$langs->trans('Password').' (ex: secret)</span></td></tr>';
|
||||
|
||||
@@ -306,17 +277,17 @@ if (function_exists("ldap_connect")) {
|
||||
if ($result > 0) {
|
||||
// Test ldap connect and bind
|
||||
print img_picto('', 'info').' ';
|
||||
print '<span class="ok">'.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).'</span>';
|
||||
print '<span class="ok">'.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).'</span>';
|
||||
print '<br>';
|
||||
|
||||
if (!empty($conf->global->LDAP_ADMIN_DN) && !empty($conf->global->LDAP_ADMIN_PASS)) {
|
||||
if ($result == 2) {
|
||||
print img_picto('', 'info').' ';
|
||||
print '<span class="ok">'.$langs->trans("LDAPBindOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).'</span>';
|
||||
print '<span class="ok">'.$langs->trans("LDAPBindOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).'</span>';
|
||||
print '<br>';
|
||||
} else {
|
||||
print img_picto('', 'error').' ';
|
||||
print '<span class="error">'.$langs->trans("LDAPBindKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).'</span>';
|
||||
print '<span class="error">'.$langs->trans("LDAPBindKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).'</span>';
|
||||
print '<br>';
|
||||
print $langs->trans("Error").' '.$ldap->error;
|
||||
print '<br>';
|
||||
@@ -342,7 +313,7 @@ if (function_exists("ldap_connect")) {
|
||||
$ldap->unbind();
|
||||
} else {
|
||||
print img_picto('', 'error').' ';
|
||||
print '<span class="error">'.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).'</span>';
|
||||
print '<span class="error">'.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).'</span>';
|
||||
print '<br>';
|
||||
print $langs->trans("Error").' '.$ldap->error;
|
||||
print '<br>';
|
||||
|
||||
@@ -218,7 +218,7 @@ print '</form>';
|
||||
/*
|
||||
* Test de la connexion
|
||||
*/
|
||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$butlabel = $langs->trans("LDAPTestSynchroGroup");
|
||||
$testlabel = 'testgroup';
|
||||
$key = $conf->global->LDAP_KEY_GROUPS;
|
||||
@@ -226,7 +226,7 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
$objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
|
||||
|
||||
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
|
||||
} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
|
||||
} elseif (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
|
||||
$butlabel = $langs->trans("LDAPTestSearch");
|
||||
$testlabel = 'testsearchgroup';
|
||||
$key = $conf->global->LDAP_KEY_GROUPS;
|
||||
|
||||
@@ -188,7 +188,7 @@ print '</form>';
|
||||
/*
|
||||
* Test de la connexion
|
||||
*/
|
||||
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$butlabel = $langs->trans("LDAPTestSynchroMemberType");
|
||||
$testlabel = 'testmembertype';
|
||||
$key = $conf->global->LDAP_KEY_MEMBERS_TYPES;
|
||||
|
||||
@@ -405,7 +405,7 @@ print '</form>';
|
||||
/*
|
||||
* Test de la connexion
|
||||
*/
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') {
|
||||
if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$butlabel = $langs->trans("LDAPTestSynchroUser");
|
||||
$testlabel = 'testuser';
|
||||
$key = getDolGlobalString('LDAP_KEY_USERS');
|
||||
@@ -413,7 +413,7 @@ if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') {
|
||||
$objectclass = getDolGlobalString('LDAP_USER_OBJECT_CLASS');
|
||||
|
||||
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
|
||||
} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'ldap2dolibarr') {
|
||||
} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
|
||||
$butlabel = $langs->trans("LDAPTestSearch");
|
||||
$testlabel = 'testsearchuser';
|
||||
$key = getDolGlobalString('LDAP_KEY_USERS');
|
||||
|
||||
@@ -136,13 +136,13 @@ print dol_get_fiche_end();
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') {
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') {
|
||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -845,6 +845,23 @@ class Conf
|
||||
}
|
||||
}
|
||||
|
||||
// For backward compatibility
|
||||
if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) {
|
||||
if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
$this->global->LDAP_SYNCHRO_ACTIVE = 1;
|
||||
} else if ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
|
||||
$this->global->LDAP_SYNCHRO_ACTIVE = 2;
|
||||
}
|
||||
}
|
||||
// For backward compatibility
|
||||
if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') {
|
||||
$this->global->LDAP_MEMBER_ACTIVE = 2;
|
||||
}
|
||||
// For backward compatibility
|
||||
if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') {
|
||||
$this->global->LDAP_MEMBER_TYPE_ACTIVE = 2;
|
||||
}
|
||||
|
||||
if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
|
||||
$this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
|
||||
}
|
||||
|
||||
196
htdocs/core/class/html.formldap.class.php
Normal file
196
htdocs/core/class/html.formldap.class.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/* Copyright (C) 2021 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/html.formldap.class.php
|
||||
* \ingroup core
|
||||
* \brief File of class with ldap html predefined components
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||
|
||||
/**
|
||||
* Class to manage generation of HTML components for ldap module
|
||||
*/
|
||||
class FormLdap
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Array of error strings
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $langs, $form;
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($this->db);
|
||||
}
|
||||
|
||||
$langs->loadLangs(array("admin", "ldap"));
|
||||
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of types of hash
|
||||
*
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in form
|
||||
* @param int $showempty Add an empty field
|
||||
* @return string HTML select string
|
||||
*/
|
||||
public function selectLdapPasswordHashType($selected = 'md5', $htmlname = 'ldaphashtype', $showempty = 0)
|
||||
{
|
||||
global $form;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = 'md5';
|
||||
}
|
||||
if (empty($htmlname)) {
|
||||
$htmlname = 'ldaphashtype';
|
||||
}
|
||||
|
||||
$arraylist = array(
|
||||
"pbkdf2sha256" => "PBKDF2_SHA256",
|
||||
"ssha512" => "SSHA512",
|
||||
"ssha256" => "SSHA256",
|
||||
"ssha" => "SSHA",
|
||||
"sha" => "SHA",
|
||||
"md5" => "MD5",
|
||||
"smd5" => "SMD5",
|
||||
"cryptmd5" => "CRYPT-MD5",
|
||||
"cryptsha512" => "CRYPT-SHA512",
|
||||
"cryptsha256" => "CRYPT-SHA256",
|
||||
"crypt" => "CRYPT",
|
||||
"clear" => "CLEAR"
|
||||
);
|
||||
|
||||
return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of type of synchronization
|
||||
*
|
||||
* @param int $selected Preselected type
|
||||
* @param string $htmlname Name of field in form
|
||||
* @param array $exclude Exclude values from the list
|
||||
* @param int $scriptonly Add warning if synchro only work with a script (0 = disable, 1 = Dolibarr2ldap, 2 = ldap2dolibarr, 3 = all)
|
||||
* @param int $showempty Add an empty field
|
||||
* @return string HTML select string
|
||||
*/
|
||||
public function selectLdapDnSynchroActive($selected = 0, $htmlname = 'activesynchro', $exclude = array(), $scriptonly = 0, $showempty = 0)
|
||||
{
|
||||
global $langs, $form;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = Ldap::SYNCHRO_NONE;
|
||||
}
|
||||
if (empty($htmlname)) {
|
||||
$htmlname = 'activesynchro';
|
||||
}
|
||||
|
||||
$dolibarr2ldaplabel = $langs->trans("DolibarrToLDAP") . (($scriptonly == 1 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPExportScriptOnly").")" : "");
|
||||
$ldap2dolibarrlabel = $langs->trans("LDAPToDolibarr") . (($scriptonly == 2 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPImportScriptOnly").")" : "");
|
||||
|
||||
$arraylist = array(
|
||||
Ldap::SYNCHRO_NONE => $langs->trans("No"),
|
||||
Ldap::SYNCHRO_DOLIBARR_TO_LDAP => $dolibarr2ldaplabel,
|
||||
Ldap::SYNCHRO_LDAP_TO_DOLIBARR => $ldap2dolibarrlabel
|
||||
);
|
||||
|
||||
if (is_array($exclude) && !empty($exclude)) {
|
||||
foreach($exclude as $value) {
|
||||
if (array_key_exists($value, $arraylist)) {
|
||||
unset($arraylist[$value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of ldap server types
|
||||
*
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in form
|
||||
* @param int $showempty Add an empty field
|
||||
* @return string HTML select string
|
||||
*/
|
||||
public function selectLdapServerType($selected = 'openldap', $htmlname = 'type', $showempty = 0)
|
||||
{
|
||||
global $form;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = 'openldap';
|
||||
}
|
||||
if (empty($htmlname)) {
|
||||
$htmlname = 'type';
|
||||
}
|
||||
|
||||
$arraylist = array(
|
||||
'activedirectory' => 'Active Directory',
|
||||
'openldap' => 'OpenLdap',
|
||||
'egroupware' => 'Egroupware'
|
||||
);
|
||||
|
||||
return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of ldap server protocol version
|
||||
*
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in form
|
||||
* @param int $showempty Add an empty field
|
||||
* @return string HTML select string
|
||||
*/
|
||||
public function selectLdapServerProtocolVersion($selected = '3', $htmlname = 'ldapprotocolversion', $showempty = 0)
|
||||
{
|
||||
global $form;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = '3';
|
||||
}
|
||||
if (empty($htmlname)) {
|
||||
$htmlname = 'ldapprotocolversion';
|
||||
}
|
||||
|
||||
$arraylist = array(
|
||||
'3' => 'Version 3',
|
||||
'2' => 'Version 2'
|
||||
);
|
||||
|
||||
return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,21 @@ class Ldap
|
||||
*/
|
||||
public $result;
|
||||
|
||||
/**
|
||||
* No Ldap synchronization
|
||||
*/
|
||||
const SYNCHRO_NONE = 0;
|
||||
|
||||
/**
|
||||
* Dolibarr to Ldap synchronization
|
||||
*/
|
||||
const SYNCHRO_DOLIBARR_TO_LDAP = 1;
|
||||
|
||||
/**
|
||||
* Ldap to Dolibarr synchronization
|
||||
*/
|
||||
const SYNCHRO_LDAP_TO_DOLIBARR = 2;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -230,7 +245,7 @@ class Ldap
|
||||
dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING);
|
||||
$this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection);
|
||||
$connected = 0;
|
||||
$this->close();
|
||||
$this->unbind();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +294,7 @@ class Ldap
|
||||
}
|
||||
|
||||
if (!$connected) {
|
||||
$this->close();
|
||||
$this->unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
|
||||
}
|
||||
|
||||
// ldap2dolibarr synchronisation
|
||||
if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { // ldap2dolibarr synchronisation
|
||||
if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { // ldap2dolibarr synchronization
|
||||
dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
|
||||
|
||||
// On charge les attributs du user ldap
|
||||
|
||||
@@ -81,7 +81,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
// Users
|
||||
if ($action == 'USER_CREATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -98,7 +98,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'USER_MODIFY') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -177,7 +177,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'USER_NEW_PASSWORD') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -212,7 +212,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
} elseif ($action == 'USER_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -229,7 +229,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
/*} elseif ($action == 'USER_SETINGROUP') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -263,7 +263,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'USER_REMOVEFROMGROUP') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -298,7 +298,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
} elseif ($action == 'USERGROUP_CREATE') {
|
||||
// Groupes
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -320,7 +320,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'USERGROUP_MODIFY') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -353,7 +353,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'USERGROUP_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -439,7 +439,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
} elseif ($action == 'MEMBER_CREATE') {
|
||||
// Members
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -450,7 +450,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
$result = $ldap->add($dn, $info, $user);
|
||||
|
||||
// For member type
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
if ($object->typeid > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
||||
$membertype = new AdherentType($this->db);
|
||||
@@ -482,7 +482,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_VALIDATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If status field is setup to be synchronized
|
||||
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
|
||||
$ldap = new Ldap();
|
||||
@@ -503,7 +503,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_SUBSCRIPTION') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If subscriptions fields are setup to be synchronized
|
||||
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
|
||||
|| $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
|
||||
@@ -528,7 +528,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_MODIFY') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -557,7 +557,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
|
||||
|
||||
// For member type
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
||||
|
||||
/*
|
||||
@@ -616,7 +616,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_NEW_PASSWORD') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If password field is setup to be synchronized
|
||||
if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
|
||||
$ldap = new Ldap();
|
||||
@@ -637,7 +637,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_RESILIATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
// If status field is setup to be synchronized
|
||||
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
|
||||
$ldap = new Ldap();
|
||||
@@ -658,7 +658,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -669,7 +669,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
$result = $ldap->delete($dn);
|
||||
|
||||
// For member type
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
if ($object->typeid > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
||||
|
||||
@@ -706,7 +706,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
} elseif ($action == 'MEMBER_TYPE_CREATE') {
|
||||
// Members types
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -728,7 +728,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_TYPE_MODIFY') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -765,7 +765,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
||||
}
|
||||
} elseif ($action == 'MEMBER_TYPE_DELETE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
|
||||
@@ -27,3 +27,5 @@ ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and
|
||||
PasswordOfUserInLDAP=Password of user in LDAP
|
||||
LDAPPasswordHashType=Password hash type
|
||||
LDAPPasswordHashTypeExample=Type of password hash used on the server
|
||||
SupportedForLDAPExportScriptOnly=Only supported by an ldap export script
|
||||
SupportedForLDAPImportScriptOnly=Only supported by an ldap import script
|
||||
@@ -731,7 +731,7 @@ if ($action == 'create' || $action == 'adduserldap') {
|
||||
print "<br>";
|
||||
|
||||
|
||||
if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) {
|
||||
if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) {
|
||||
// Show form to add an account from LDAP if sync LDAP -> Dolibarr is set
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
|
||||
@@ -147,13 +147,13 @@ print dol_get_fiche_end();
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -153,13 +153,13 @@ print dol_get_fiche_end();
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||
}
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
|
||||
if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user