dolibarr 19.0.3
html.formldap.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Regis Houssin <regis.houssin@inodbox.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
23require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
24
29{
33 public $db;
34
38 public $error = '';
39
43 public $errors = array();
44
45
51 public function __construct($db)
52 {
53 global $langs, $form;
54
55 if (!is_object($form)) {
56 $form = new Form($this->db);
57 }
58
59 $langs->loadLangs(array("admin", "ldap"));
60
61 $this->db = $db;
62 }
63
72 public function selectLdapPasswordHashType($selected = 'md5', $htmlname = 'ldaphashtype', $showempty = 0)
73 {
74 global $form;
75
76 if (empty($selected)) {
77 $selected = 'md5';
78 }
79 if (empty($htmlname)) {
80 $htmlname = 'ldaphashtype';
81 }
82
83 $arraylist = array(
84 //"pbkdf2sha256" => "PBKDF2_SHA256",
85 "ssha512" => "SSHA-512",
86 "ssha384" => "SSHA-384",
87 "ssha256" => "SSHA-256",
88 "ssha" => "SSHA",
89 "sha512" => "SHA-512",
90 "sha384" => "SHA-384",
91 "sha256" => "SHA-256",
92 "sha" => "SHA",
93 "md5" => "MD5",
94 "smd5" => "SMD5",
95 //"cryptmd5" => "CRYPT-MD5",
96 //"cryptsha512" => "CRYPT-SHA512",
97 //"cryptsha384" => "CRYPT-SHA384",
98 //"cryptsha256" => "CRYPT-SHA256",
99 "crypt" => "CRYPT",
100 "clear" => "CLEAR"
101 );
102
103 return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
104 }
105
116 public function selectLdapDnSynchroActive($selected = 0, $htmlname = 'activesynchro', $exclude = array(), $scriptonly = 0, $showempty = 0)
117 {
118 global $langs, $form;
119
120 if (empty($selected)) {
121 $selected = Ldap::SYNCHRO_NONE;
122 }
123 if (empty($htmlname)) {
124 $htmlname = 'activesynchro';
125 }
126
127 $dolibarr2ldaplabel = $langs->trans("DolibarrToLDAP") . (($scriptonly == 1 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPExportScriptOnly").")" : "");
128 $ldap2dolibarrlabel = $langs->trans("LDAPToDolibarr") . (($scriptonly == 2 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPImportScriptOnly").")" : "");
129
130 $arraylist = array(
131 Ldap::SYNCHRO_NONE => $langs->trans("No"),
132 Ldap::SYNCHRO_DOLIBARR_TO_LDAP => $dolibarr2ldaplabel,
133 Ldap::SYNCHRO_LDAP_TO_DOLIBARR => $ldap2dolibarrlabel
134 );
135
136 if (is_array($exclude) && !empty($exclude)) {
137 foreach ($exclude as $value) {
138 if (array_key_exists($value, $arraylist)) {
139 unset($arraylist[$value]);
140 }
141 }
142 }
143
144 return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
145 }
146
155 public function selectLdapServerType($selected = 'openldap', $htmlname = 'type', $showempty = 0)
156 {
157 global $form;
158
159 if (empty($selected)) {
160 $selected = 'openldap';
161 }
162 if (empty($htmlname)) {
163 $htmlname = 'type';
164 }
165
166 $arraylist = array(
167 'activedirectory' => 'Active Directory',
168 'openldap' => 'OpenLdap',
169 'egroupware' => 'Egroupware'
170 );
171
172 return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
173 }
174
183 public function selectLdapServerProtocolVersion($selected = '3', $htmlname = 'ldapprotocolversion', $showempty = 0)
184 {
185 global $form;
186
187 if (empty($selected)) {
188 $selected = '3';
189 }
190 if (empty($htmlname)) {
191 $htmlname = 'ldapprotocolversion';
192 }
193
194 $arraylist = array(
195 '3' => 'Version 3',
196 '2' => 'Version 2'
197 );
198
199 return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
200 }
201}
Class to manage generation of HTML components Only common components must be here.
Class to manage generation of HTML components for ldap module.
selectLdapServerType($selected='openldap', $htmlname='type', $showempty=0)
Return list of ldap server types.
__construct($db)
Constructor.
selectLdapServerProtocolVersion($selected='3', $htmlname='ldapprotocolversion', $showempty=0)
Return list of ldap server protocol version.
selectLdapPasswordHashType($selected='md5', $htmlname='ldaphashtype', $showempty=0)
Return list of types of hash.
selectLdapDnSynchroActive($selected=0, $htmlname='activesynchro', $exclude=array(), $scriptonly=0, $showempty=0)
Return list of type of synchronization.
const SYNCHRO_NONE
No Ldap synchronization.
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
const SYNCHRO_DOLIBARR_TO_LDAP
Dolibarr to Ldap synchronization.