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