| 1 |
<?php |
| 2 |
|
| 3 |
use LAM\TYPES\TypeManager; |
| 4 |
use LAM\ImageUtils\ImageManipulationFactory; |
| 5 |
use LAM\TYPES\ConfiguredType; |
| 6 |
|
| 7 |
/* |
| 8 |
|
| 9 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 10 |
Copyright (C) 2003 - 2006 Tilo Lutz |
| 11 |
2005 - 2026 Roland Gruber |
| 12 |
|
| 13 |
This program is free software; you can redistribute it and/or modify |
| 14 |
it under the terms of the GNU General Public License as published by |
| 15 |
the Free Software Foundation; either version 2 of the License, or |
| 16 |
(at your option) any later version. |
| 17 |
|
| 18 |
This program is distributed in the hope that it will be useful, |
| 19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
GNU General Public License for more details. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License |
| 24 |
along with this program; if not, write to the Free Software |
| 25 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 |
*/ |
| 27 |
|
| 28 |
/** |
| 29 |
* Manages the attributes of object class inetOrgPerson. |
| 30 |
* |
| 31 |
* @package modules |
| 32 |
* @author Tilo Lutz |
| 33 |
* @author Roland Gruber |
| 34 |
* @author Michael Duergner |
| 35 |
*/ |
| 36 |
|
| 37 |
/** |
| 38 |
* This module manages LDAP attributes of the object class inetOrgPerson (e.g. name and address). |
| 39 |
* |
| 40 |
* @package modules |
| 41 |
*/ |
| 42 |
class inetOrgPerson extends baseModule implements passwordService, AccountStatusProvider { |
| 43 |
|
| 44 |
/** |
| 45 |
* ID for locked password status. |
| 46 |
*/ |
| 47 |
private const STATUS_PASSWORD_LOCKED = "INETORG_PERSON_PASSWORD_LOCKED"; |
| 48 |
|
| 49 |
/** @var string|null $clearTextPassword clear text password */ |
| 50 |
private ?string $clearTextPassword = null; |
| 51 |
/** @var string[]|null $departmentCache cache for departments */ |
| 52 |
private ?array $departmentCache = null; |
| 53 |
/** @var string[]|null $oCache organization cache */ |
| 54 |
private ?array $oCache = null; |
| 55 |
/** @var string[]|null $ouCache organizational unit cache */ |
| 56 |
private ?array $ouCache = null; |
| 57 |
/** @var string[]|null $titleCache title cache */ |
| 58 |
private ?array $titleCache = null; |
| 59 |
/** @var string[]|null $employeeTypeCache employee type cache */ |
| 60 |
private ?array $employeeTypeCache = null; |
| 61 |
/** @var string[]|null $businessCategoryCache business category cache */ |
| 62 |
private ?array $businessCategoryCache = null; |
| 63 |
|
| 64 |
/** @var array<string, bool> $emailCheckCache email cache */ |
| 65 |
private array $emailCheckCache = []; |
| 66 |
|
| 67 |
/** session variable for existing user certificates in self-service */ |
| 68 |
const SESS_CERTIFICATES_LIST = 'inetOrgPerson_certificatesList'; |
| 69 |
/** session variable for existing user certificates in self-service */ |
| 70 |
const SESS_PHOTO = 'inetOrgPerson_jpegPhoto'; |
| 71 |
|
| 72 |
/** |
| 73 |
* {@inheritDoc} |
| 74 |
*/ |
| 75 |
protected function load_Messages(): void { |
| 76 |
$this->messages['givenName'][0] = ['ERROR', _('First name'), _('First name contains invalid characters!')]; |
| 77 |
$this->messages['givenName'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_firstName', _('First name contains invalid characters!')]; |
| 78 |
$this->messages['lastname'][0] = ['ERROR', _('Last name'), _('Last name contains invalid characters or is empty!')]; |
| 79 |
$this->messages['lastname'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_lastName', _('Last name contains invalid characters or is empty!')]; |
| 80 |
$this->messages['telephoneNumber'][0] = ['ERROR', _('Telephone number'), _('Please enter a valid telephone number!')]; |
| 81 |
$this->messages['telephoneNumber'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_telephone', _('Please enter a valid telephone number!')]; |
| 82 |
$this->messages['homePhone'][0] = ['ERROR', _('Home telephone number'), _('Please enter a valid telephone number!')]; |
| 83 |
$this->messages['homePhone'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_homePhone', _('Please enter a valid telephone number!')]; |
| 84 |
$this->messages['mobile'][0] = ['ERROR', _('Mobile number'), _('Please enter a valid mobile number!')]; |
| 85 |
$this->messages['mobileTelephone'][1] = ['ERROR', _('Account %s:') . " inetOrgPerson_mobile", _('Please enter a valid mobile number!')]; |
| 86 |
$this->messages['facsimileTelephoneNumber'][0] = ['ERROR', _('Fax number'), _('Please enter a valid fax number!')]; |
| 87 |
$this->messages['facsimileNumber'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_fax', _('Please enter a valid fax number!')]; |
| 88 |
$this->messages['pager'][0] = ['ERROR', _('Pager'), _('Please enter a valid telephone number!')]; |
| 89 |
$this->messages['pager'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_pager', _('Please enter a valid telephone number!')]; |
| 90 |
$this->messages['mail'][0] = ['ERROR', _('Email address'), _('Please enter a valid email address!')]; |
| 91 |
$this->messages['mail'][1] = ['WARN', _('Email address'), _('Email "%s" already in use.')]; |
| 92 |
$this->messages['mail'][2] = ['WARN', _('Account %s:') . ' inetOrgPerson_email', _('Email "%s" already in use.')]; |
| 93 |
$this->messages['email'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_email', _('Please enter a valid email address!')]; |
| 94 |
$this->messages['street'][0] = ['ERROR', _('Street'), _('Please enter a valid street name!')]; |
| 95 |
$this->messages['street'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_street', _('Please enter a valid street name!')]; |
| 96 |
$this->messages['postalAddress'][0] = ['ERROR', _('Postal address'), _('Please enter a valid postal address!')]; |
| 97 |
$this->messages['postalAddress'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_address', _('Please enter a valid postal address!')]; |
| 98 |
$this->messages['registeredAddress'][0] = ['ERROR', _('Registered address'), _('Please enter a valid registered address.')]; |
| 99 |
$this->messages['registeredAddress'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_registeredAddress', _('Please enter a valid registered address.')]; |
| 100 |
$this->messages['postalCode'][0] = ['ERROR', _('Postal code'), _('Please enter a valid postal code!')]; |
| 101 |
$this->messages['postalCode'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_postalCode', _('Please enter a valid postal code!')]; |
| 102 |
$this->messages['title'][0] = ['ERROR', _('Job title'), _('Please enter a valid job title!')]; |
| 103 |
$this->messages['title'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_title', _('Please enter a valid job title!')]; |
| 104 |
$this->messages['employeeType'][0] = ['ERROR', _('Employee type'), _('Please enter a valid employee type!')]; |
| 105 |
$this->messages['employeeType'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_type', _('Please enter a valid employee type!')]; |
| 106 |
$this->messages['cn'][0] = ['ERROR', _('Common name'), _('Please enter a valid common name!')]; |
| 107 |
$this->messages['cn'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_cn', _('Please enter a valid common name!')]; |
| 108 |
$this->messages['uid'][0] = ['ERROR', _('User name'), _('User name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')]; |
| 109 |
$this->messages['uid'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_userName', _('User name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')]; |
| 110 |
$this->messages['uid'][3] = ['WARN', _('Account %s:') . ' inetOrgPerson_userName', _('User name already exists!')]; |
| 111 |
$this->messages['manager'][0] = ['ERROR', _('Account %s:') . ' inetOrgPerson_manager', _('This is not a valid DN!')]; |
| 112 |
$this->messages['file'][0] = ['ERROR', _('No file selected.')]; |
| 113 |
$this->messages['file'][2] = ['ERROR', _('Unable to process this file.')]; |
| 114 |
$this->messages['file'][3] = ['ERROR', _('File is too large. Maximum allowed size is %s kB.')]; |
| 115 |
$this->messages['businessCategory'][0] = ['ERROR', _('Business category'), _('Please enter a valid business category!')]; |
| 116 |
$this->messages['businessCategory'][1] = ['ERROR', _('Account %s:') . ' inetOrgPerson_businessCategory', _('Please enter a valid business category!')]; |
| 117 |
$this->messages['userPassword'][0] = ['ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are:') . ' a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ §°!']; |
| 118 |
$this->messages['passwordDisabled'][0] = ['ERROR', _('Account %s:') . ' inetOrgPerson_passwordDisabled', _('This value can only be "true" or "false".')]; |
| 119 |
$this->messages['sendPasswordMail'][0] = ['ERROR', _('Account %s:') . ' inetOrgPerson_sendPasswordMail', _('This value can only be "true" or "false".')]; |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* {@inheritDoc} |
| 124 |
*/ |
| 125 |
public function can_manage(): bool { |
| 126 |
return $this->get_scope() === 'user'; |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* {@inheritDoc} |
| 131 |
*/ |
| 132 |
public function get_metaData(): array { |
| 133 |
$return = []; |
| 134 |
// icon |
| 135 |
$return['icon'] = 'user.svg'; |
| 136 |
// alias name |
| 137 |
$return["alias"] = _('Personal'); |
| 138 |
// this is a base module |
| 139 |
$return["is_base"] = true; |
| 140 |
// RDN attribute |
| 141 |
$return["RDN"] = ["cn" => "normal", 'uid' => 'low']; |
| 142 |
// LDAP filter |
| 143 |
$return["ldap_filter"] = ['or' => "(objectClass=inetOrgPerson)"]; |
| 144 |
// module dependencies |
| 145 |
$return['dependencies'] = ['depends' => [], 'conflicts' => []]; |
| 146 |
// managed object classes |
| 147 |
$return['objectClasses'] = ['inetOrgPerson']; |
| 148 |
// LDAP aliases |
| 149 |
$return['LDAPaliases'] = ['commonName' => 'cn', 'surname' => 'sn', 'streetAddress' => 'street', |
| 150 |
'fax' => 'facsimileTelephoneNumber', 'gn' => 'givenName', 'userid' => 'uid', 'rfc822mailbox' => 'mail', |
| 151 |
'mobileTelephoneNumber' => 'mobile', 'organizationName' => 'o', 'organizationalUnitName' => 'ou']; |
| 152 |
// managed attributes |
| 153 |
$return['attributes'] = ['uid', 'employeeType', 'givenName', 'jpegPhoto', 'mail', 'manager', 'mobile', |
| 154 |
'title', 'telephoneNumber', 'facsimileTelephoneNumber', 'street', 'postOfficeBox', 'postalCode', 'postalAddress', |
| 155 |
'sn', 'userpassword', 'description', 'homePhone', 'pager', 'roomNumber', 'businessCategory', 'l', 'st', |
| 156 |
'physicalDeliveryOfficeName', 'carLicense', 'departmentNumber', 'o', 'employeeNumber', 'initials', |
| 157 |
'registeredAddress', 'labeledURI', 'ou', 'userCertificate;binary', 'INFO.userPasswordClearText']; |
| 158 |
// self-service search attributes |
| 159 |
$return['selfServiceSearchAttributes'] = ['uid', 'mail', 'cn', 'surname', 'givenName', 'employeeNumber']; |
| 160 |
// self-service field settings |
| 161 |
$return['selfServiceFieldSettings'] = ['firstName' => _('First name'), 'lastName' => _('Last name'), |
| 162 |
'mail' => _('Email address'), 'telephoneNumber' => _('Telephone number'), 'mobile' => _('Mobile number'), |
| 163 |
'faxNumber' => _('Fax number'), 'street' => _('Street'), 'postalAddress' => _('Postal address'), 'registeredAddress' => _('Registered address'), |
| 164 |
'postalCode' => _('Postal code'), 'postOfficeBox' => _('Post office box'), 'jpegPhoto' => _('Photo'), |
| 165 |
'homePhone' => _('Home telephone number'), 'pager' => _('Pager'), 'roomNumber' => _('Room number'), 'carLicense' => _('Car license'), |
| 166 |
'location' => _('Location'), 'state' => _('State'), 'officeName' => _('Office name'), 'businessCategory' => _('Business category'), |
| 167 |
'departmentNumber' => _('Department'), 'initials' => _('Initials'), 'title' => _('Job title'), 'labeledURI' => _('Web site'), |
| 168 |
'userCertificate' => _('User certificates'), 'o' => _('Organisation'), 'ou' => _('Organisational unit'), 'description' => _('Description'), |
| 169 |
'uid' => _('User name'), 'displayName' => _('Display name')]; |
| 170 |
// possible self-service read-only fields |
| 171 |
$return['selfServiceReadOnlyFields'] = ['firstName', 'lastName', 'mail', 'telephoneNumber', 'mobile', 'faxNumber', 'pager', 'street', |
| 172 |
'postalAddress', 'registeredAddress', 'postalCode', 'postOfficeBox', 'jpegPhoto', 'homePhone', 'roomNumber', 'carLicense', |
| 173 |
'location', 'state', 'officeName', 'businessCategory', 'departmentNumber', 'initials', 'title', 'labeledURI', 'userCertificate', |
| 174 |
'o', 'ou', 'description', 'uid', 'displayName']; |
| 175 |
// profile checks and mappings |
| 176 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) { |
| 177 |
$return['profile_mappings']['inetOrgPerson_initials'] = 'initials'; |
| 178 |
} |
| 179 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { |
| 180 |
$return['profile_mappings']['inetOrgPerson_description'] = 'description'; |
| 181 |
} |
| 182 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 183 |
$return['profile_checks']['inetOrgPerson_title'] = [ |
| 184 |
'type' => 'ext_preg', |
| 185 |
'regex' => 'title', |
| 186 |
'error_message' => $this->messages['title'][0]]; |
| 187 |
$return['profile_mappings']['inetOrgPerson_title'] = 'title'; |
| 188 |
} |
| 189 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 190 |
$return['profile_checks']['inetOrgPerson_employeeType'] = [ |
| 191 |
'type' => 'ext_preg', |
| 192 |
'regex' => 'employeeType', |
| 193 |
'error_message' => $this->messages['employeeType'][0]]; |
| 194 |
$return['profile_mappings']['inetOrgPerson_employeeType'] = 'employeeType'; |
| 195 |
} |
| 196 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 197 |
$return['profile_checks']['inetOrgPerson_businessCategory'] = [ |
| 198 |
'type' => 'ext_preg', |
| 199 |
'regex' => 'businessCategory', |
| 200 |
'error_message' => $this->messages['businessCategory'][0]]; |
| 201 |
$return['profile_mappings']['inetOrgPerson_businessCategory'] = 'businessCategory'; |
| 202 |
} |
| 203 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) { |
| 204 |
$return['profile_checks']['inetOrgPerson_street'] = [ |
| 205 |
'type' => 'ext_preg', |
| 206 |
'regex' => 'street', |
| 207 |
'error_message' => $this->messages['street'][0]]; |
| 208 |
} |
| 209 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) { |
| 210 |
$return['profile_checks']['inetOrgPerson_postalCode'] = [ |
| 211 |
'type' => 'ext_preg', |
| 212 |
'regex' => 'postalCode', |
| 213 |
'error_message' => $this->messages['postalCode'][0]]; |
| 214 |
} |
| 215 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) { |
| 216 |
$return['profile_checks']['inetOrgPerson_postalAddress'] = [ |
| 217 |
'type' => 'ext_preg', |
| 218 |
'regex' => 'postalAddress', |
| 219 |
'error_message' => $this->messages['postalAddress'][0]]; |
| 220 |
$return['profile_mappings']['inetOrgPerson_postalAddress'] = 'postalAddress'; |
| 221 |
} |
| 222 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 223 |
$return['profile_checks']['inetOrgPerson_registeredAddress'] = [ |
| 224 |
'type' => 'ext_preg', |
| 225 |
'regex' => 'postalAddress', |
| 226 |
'error_message' => $this->messages['registeredAddress'][0]]; |
| 227 |
$return['profile_mappings']['inetOrgPerson_registeredAddress'] = 'registeredAddress'; |
| 228 |
} |
| 229 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) { |
| 230 |
$return['profile_mappings']['inetOrgPerson_physicalDeliveryOfficeName'] = 'physicalDeliveryOfficeName'; |
| 231 |
} |
| 232 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) { |
| 233 |
$return['profile_mappings']['inetOrgPerson_roomNumber'] = 'roomNumber'; |
| 234 |
} |
| 235 |
// upload fields |
| 236 |
$return['upload_columns'] = [ |
| 237 |
[ |
| 238 |
'name' => 'inetOrgPerson_firstName', |
| 239 |
'description' => _('First name'), |
| 240 |
'help' => 'givenName', |
| 241 |
'example' => _('Steve') |
| 242 |
], |
| 243 |
[ |
| 244 |
'name' => 'inetOrgPerson_lastName', |
| 245 |
'description' => _('Last name'), |
| 246 |
'help' => 'sn', |
| 247 |
'example' => _('Miller'), |
| 248 |
'required' => true |
| 249 |
] |
| 250 |
]; |
| 251 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) { |
| 252 |
$return['upload_columns'][] = [ |
| 253 |
'name' => 'inetOrgPerson_initials', |
| 254 |
'description' => _('Initials'), |
| 255 |
'help' => 'initials', |
| 256 |
'example' => 'A.B.' |
| 257 |
]; |
| 258 |
} |
| 259 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { |
| 260 |
$return['upload_columns'][] = [ |
| 261 |
'name' => 'inetOrgPerson_description', |
| 262 |
'description' => _('Description'), |
| 263 |
'help' => 'descriptionList', |
| 264 |
'example' => _('Temp, contract till December') |
| 265 |
]; |
| 266 |
} |
| 267 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 268 |
$return['upload_columns'][] = [ |
| 269 |
'name' => 'inetOrgPerson_title', |
| 270 |
'description' => _('Job title'), |
| 271 |
'help' => 'titleList', |
| 272 |
'example' => _('President') |
| 273 |
]; |
| 274 |
} |
| 275 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) { |
| 276 |
$return['upload_columns'][] = [ |
| 277 |
'name' => 'inetOrgPerson_employeeNumber', |
| 278 |
'description' => _('Employee number'), |
| 279 |
'help' => 'employeeNumber', |
| 280 |
'example' => '123456' |
| 281 |
]; |
| 282 |
} |
| 283 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 284 |
$return['upload_columns'][] = [ |
| 285 |
'name' => 'inetOrgPerson_type', |
| 286 |
'description' => _('Employee type'), |
| 287 |
'help' => 'employeeType', |
| 288 |
'example' => _('Temp') |
| 289 |
]; |
| 290 |
} |
| 291 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) { |
| 292 |
$return['upload_columns'][] = [ |
| 293 |
'name' => 'inetOrgPerson_manager', |
| 294 |
'description' => _('Manager'), |
| 295 |
'help' => 'managerList', |
| 296 |
'example' => _('uid=smiller,ou=People,dc=company,dc=com') |
| 297 |
]; |
| 298 |
} |
| 299 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 300 |
$return['upload_columns'][] = [ |
| 301 |
'name' => 'inetOrgPerson_businessCategory', |
| 302 |
'description' => _('Business category'), |
| 303 |
'help' => 'businessCategoryList', |
| 304 |
'example' => _('Administration') |
| 305 |
]; |
| 306 |
} |
| 307 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) { |
| 308 |
$return['upload_columns'][] = [ |
| 309 |
'name' => 'inetOrgPerson_street', |
| 310 |
'description' => _('Street'), |
| 311 |
'help' => 'streetList', |
| 312 |
'example' => _('Mystreetname 42') |
| 313 |
]; |
| 314 |
} |
| 315 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) { |
| 316 |
$return['upload_columns'][] = [ |
| 317 |
'name' => 'inetOrgPerson_postalCode', |
| 318 |
'description' => _('Postal code'), |
| 319 |
'help' => 'postalCodeList', |
| 320 |
'example' => _('GB-12345') |
| 321 |
]; |
| 322 |
} |
| 323 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) { |
| 324 |
$return['upload_columns'][] = [ |
| 325 |
'name' => 'inetOrgPerson_address', |
| 326 |
'description' => _('Postal address'), |
| 327 |
'help' => 'postalAddress', |
| 328 |
'example' => _('MyCity') |
| 329 |
]; |
| 330 |
} |
| 331 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 332 |
$return['upload_columns'][] = [ |
| 333 |
'name' => 'inetOrgPerson_registeredAddress', |
| 334 |
'description' => _('Registered address'), |
| 335 |
'help' => 'registeredAddress', |
| 336 |
'example' => _('MyCity') |
| 337 |
]; |
| 338 |
} |
| 339 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) { |
| 340 |
$return['upload_columns'][] = [ |
| 341 |
'name' => 'inetOrgPerson_postOfficeBox', |
| 342 |
'description' => _('Post office box'), |
| 343 |
'help' => 'postOfficeBoxList', |
| 344 |
'example' => _('12345') |
| 345 |
]; |
| 346 |
} |
| 347 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { |
| 348 |
$return['upload_columns'][] = [ |
| 349 |
'name' => 'inetOrgPerson_telephone', |
| 350 |
'description' => _('Telephone number'), |
| 351 |
'help' => 'telephoneNumberList', |
| 352 |
'example' => _('123-123-1234') |
| 353 |
]; |
| 354 |
} |
| 355 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { |
| 356 |
$return['upload_columns'][] = [ |
| 357 |
'name' => 'inetOrgPerson_homePhone', |
| 358 |
'description' => _('Home telephone number'), |
| 359 |
'help' => 'homePhoneList', |
| 360 |
'example' => _('123-124-1234') |
| 361 |
]; |
| 362 |
} |
| 363 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) { |
| 364 |
$return['upload_columns'][] = [ |
| 365 |
'name' => 'inetOrgPerson_mobile', |
| 366 |
'description' => _('Mobile number'), |
| 367 |
'help' => 'mobileTelephoneNumberList', |
| 368 |
'example' => _('123-123-1235') |
| 369 |
]; |
| 370 |
} |
| 371 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) { |
| 372 |
$return['upload_columns'][] = [ |
| 373 |
'name' => 'inetOrgPerson_fax', |
| 374 |
'description' => _('Fax number'), |
| 375 |
'help' => 'facsimileTelephoneNumberList', |
| 376 |
'example' => _('123-123-1236') |
| 377 |
]; |
| 378 |
} |
| 379 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) { |
| 380 |
$return['upload_columns'][] = [ |
| 381 |
'name' => 'inetOrgPerson_pager', |
| 382 |
'description' => _('Pager'), |
| 383 |
'help' => 'pagerList', |
| 384 |
'example' => _('123-123-1236') |
| 385 |
]; |
| 386 |
} |
| 387 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) { |
| 388 |
$return['upload_columns'][] = [ |
| 389 |
'name' => 'inetOrgPerson_email', |
| 390 |
'description' => _('Email address'), |
| 391 |
'help' => 'mailList', |
| 392 |
'example' => _('[email protected]') |
| 393 |
]; |
| 394 |
if (isLAMProVersion()) { |
| 395 |
$return['upload_columns'][] = [ |
| 396 |
'name' => 'inetOrgPerson_sendPasswordMail', |
| 397 |
'description' => _('Send password via mail'), |
| 398 |
'help' => 'mailPassword', |
| 399 |
'values' => 'true, false', |
| 400 |
'default' => 'false', |
| 401 |
'example' => 'false' |
| 402 |
]; |
| 403 |
} |
| 404 |
} |
| 405 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) { |
| 406 |
$return['upload_columns'][] = [ |
| 407 |
'name' => 'inetOrgPerson_labeledURI', |
| 408 |
'description' => _('Web site'), |
| 409 |
'help' => 'labeledURIList', |
| 410 |
'example' => _('https://www.company.com') |
| 411 |
]; |
| 412 |
} |
| 413 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) { |
| 414 |
$return['upload_columns'][] = [ |
| 415 |
'name' => 'inetOrgPerson_roomNumber', |
| 416 |
'description' => _('Room number'), |
| 417 |
'help' => 'roomNumber', |
| 418 |
'example' => 'A 2.24' |
| 419 |
]; |
| 420 |
} |
| 421 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) { |
| 422 |
$return['upload_columns'][] = [ |
| 423 |
'name' => 'inetOrgPerson_departmentNumber', |
| 424 |
'description' => _('Department'), |
| 425 |
'help' => 'departmentNumberList', |
| 426 |
'example' => _('Administration') |
| 427 |
]; |
| 428 |
} |
| 429 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) { |
| 430 |
$return['upload_columns'][] = [ |
| 431 |
'name' => 'inetOrgPerson_ou', |
| 432 |
'description' => _('Organisational unit'), |
| 433 |
'help' => 'ouList', |
| 434 |
'example' => _('Administration') |
| 435 |
]; |
| 436 |
} |
| 437 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) { |
| 438 |
$return['upload_columns'][] = [ |
| 439 |
'name' => 'inetOrgPerson_o', |
| 440 |
'description' => _('Organisation'), |
| 441 |
'help' => 'oList', |
| 442 |
'example' => _('YourCompany') |
| 443 |
]; |
| 444 |
} |
| 445 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) { |
| 446 |
$return['upload_columns'][] = [ |
| 447 |
'name' => 'inetOrgPerson_l', |
| 448 |
'description' => _('Location'), |
| 449 |
'help' => 'lList', |
| 450 |
'example' => _('MyCity') |
| 451 |
]; |
| 452 |
} |
| 453 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) { |
| 454 |
$return['upload_columns'][] = [ |
| 455 |
'name' => 'inetOrgPerson_st', |
| 456 |
'description' => _('State'), |
| 457 |
'help' => 'stList', |
| 458 |
'example' => _('New York') |
| 459 |
]; |
| 460 |
} |
| 461 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) { |
| 462 |
$return['upload_columns'][] = [ |
| 463 |
'name' => 'inetOrgPerson_carLicense', |
| 464 |
'description' => _('Car license'), |
| 465 |
'help' => 'carLicense', |
| 466 |
'example' => _('yes') |
| 467 |
]; |
| 468 |
} |
| 469 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) { |
| 470 |
$return['upload_columns'][] = [ |
| 471 |
'name' => 'inetOrgPerson_physicalDeliveryOfficeName', |
| 472 |
'description' => _('Office name'), |
| 473 |
'help' => 'physicalDeliveryOfficeNameList', |
| 474 |
'example' => _('YourCompany') |
| 475 |
]; |
| 476 |
} |
| 477 |
// available PDF fields |
| 478 |
$return['PDF_fields'] = [ |
| 479 |
'givenName' => _('First name'), |
| 480 |
'sn' => _('Last name') |
| 481 |
]; |
| 482 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { |
| 483 |
$return['PDF_fields']['description'] = _('Description'); |
| 484 |
} |
| 485 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) { |
| 486 |
$return['PDF_fields']['street'] = _('Street'); |
| 487 |
} |
| 488 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) { |
| 489 |
$return['PDF_fields']['postOfficeBox'] = _('Post office box'); |
| 490 |
} |
| 491 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) { |
| 492 |
$return['PDF_fields']['postalCode'] = _('Postal code'); |
| 493 |
} |
| 494 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) { |
| 495 |
$return['PDF_fields']['location'] = _('Location'); |
| 496 |
} |
| 497 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) { |
| 498 |
$return['PDF_fields']['state'] = _('State'); |
| 499 |
} |
| 500 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) { |
| 501 |
$return['PDF_fields']['postalAddress'] = _('Postal address'); |
| 502 |
} |
| 503 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 504 |
$return['PDF_fields']['registeredAddress'] = _('Registered address'); |
| 505 |
} |
| 506 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) { |
| 507 |
$return['PDF_fields']['officeName'] = _('Office name'); |
| 508 |
} |
| 509 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) { |
| 510 |
$return['PDF_fields']['roomNumber'] = _('Room number'); |
| 511 |
} |
| 512 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { |
| 513 |
$return['PDF_fields']['telephoneNumber'] = _('Telephone number'); |
| 514 |
} |
| 515 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { |
| 516 |
$return['PDF_fields']['homePhone'] = _('Home telephone number'); |
| 517 |
} |
| 518 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) { |
| 519 |
$return['PDF_fields']['mobileTelephoneNumber'] = _('Mobile number'); |
| 520 |
} |
| 521 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) { |
| 522 |
$return['PDF_fields']['facsimileTelephoneNumber'] = _('Fax number'); |
| 523 |
} |
| 524 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) { |
| 525 |
$return['PDF_fields']['pager'] = _('Pager'); |
| 526 |
} |
| 527 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) { |
| 528 |
$return['PDF_fields']['mail'] = _('Email address'); |
| 529 |
} |
| 530 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) { |
| 531 |
$return['PDF_fields']['labeledURI'] = _('Web site'); |
| 532 |
} |
| 533 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 534 |
$return['PDF_fields']['title'] = _('Job title'); |
| 535 |
} |
| 536 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) { |
| 537 |
$return['PDF_fields']['carLicense'] = _('Car license'); |
| 538 |
} |
| 539 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 540 |
$return['PDF_fields']['employeeType'] = _('Employee type'); |
| 541 |
} |
| 542 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 543 |
$return['PDF_fields']['businessCategory'] = _('Business category'); |
| 544 |
} |
| 545 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) { |
| 546 |
$return['PDF_fields']['departmentNumber'] = _('Department'); |
| 547 |
} |
| 548 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) { |
| 549 |
$return['PDF_fields']['manager'] = _('Manager'); |
| 550 |
} |
| 551 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) { |
| 552 |
$return['PDF_fields']['o'] = _('Organisation'); |
| 553 |
} |
| 554 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) { |
| 555 |
$return['PDF_fields']['ou'] = _('Organisational unit'); |
| 556 |
} |
| 557 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) { |
| 558 |
$return['PDF_fields']['employeeNumber'] = _('Employee number'); |
| 559 |
} |
| 560 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) { |
| 561 |
$return['PDF_fields']['initials'] = _('Initials'); |
| 562 |
} |
| 563 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) { |
| 564 |
$return['PDF_fields']['jpegPhoto'] = _('Photo'); |
| 565 |
} |
| 566 |
// help Entries |
| 567 |
$return['help'] = [ |
| 568 |
'description' => [ |
| 569 |
"Headline" => _("Description"), 'attr' => 'description', |
| 570 |
"Text" => _("User description. If left empty surname and given name will be used.") |
| 571 |
], |
| 572 |
'descriptionList' => [ |
| 573 |
"Headline" => _("Description"), 'attr' => 'description', |
| 574 |
"Text" => _("User description. If left empty surname and given name will be used.") . ' ' . _("Multiple values are separated by semicolon.") |
| 575 |
], |
| 576 |
'title' => [ |
| 577 |
"Headline" => _("Job title"), 'attr' => 'title', |
| 578 |
"Text" => _("Job title of user: President, department manager, ...") |
| 579 |
], |
| 580 |
'titleList' => [ |
| 581 |
"Headline" => _("Job title"), 'attr' => 'title', |
| 582 |
"Text" => _("Job title of user: President, department manager, ...") . ' ' . _("Multiple values are separated by semicolon.") |
| 583 |
], |
| 584 |
'givenName' => [ |
| 585 |
"Headline" => _("First name"), 'attr' => 'givenName', |
| 586 |
"Text" => _("First name of user. Only letters, - and spaces are allowed.") |
| 587 |
], |
| 588 |
'sn' => [ |
| 589 |
"Headline" => _("Last name"), 'attr' => 'sn', |
| 590 |
"Text" => _("Last name of user. Only letters, - and spaces are allowed.") |
| 591 |
], |
| 592 |
'employeeType' => [ |
| 593 |
"Headline" => _("Employee type"), 'attr' => 'employeeType', |
| 594 |
"Text" => _("Employee type: Contractor, Employee, Intern, Temp, External, ...") |
| 595 |
], |
| 596 |
'manager' => [ |
| 597 |
"Headline" => _("Manager"), 'attr' => 'manager', |
| 598 |
"Text" => _("This is the LDAP DN of the user's manager. Use this property to represent hierarchies in your company.") |
| 599 |
], |
| 600 |
'managerList' => [ |
| 601 |
"Headline" => _("Manager"), 'attr' => 'manager', |
| 602 |
"Text" => _("This is the LDAP DN of the user's manager. Use this property to represent hierarchies in your company.") . ' ' . _("Multiple values are separated by semicolon.") |
| 603 |
], |
| 604 |
'street' => [ |
| 605 |
"Headline" => _("Street"), 'attr' => 'street', |
| 606 |
"Text" => _("The street name of the user's address.") |
| 607 |
], |
| 608 |
'streetList' => [ |
| 609 |
"Headline" => _("Street"), 'attr' => 'street', |
| 610 |
"Text" => _("The street name of the user's address.") . ' ' . _("Multiple values are separated by semicolon.") |
| 611 |
], |
| 612 |
'postOfficeBox' => [ |
| 613 |
"Headline" => _("Post office box"), 'attr' => 'postOfficeBox', |
| 614 |
"Text" => _("The post office box of the user's address.") |
| 615 |
], |
| 616 |
'postOfficeBoxList' => [ |
| 617 |
"Headline" => _("Post office box"), 'attr' => 'postOfficeBox', |
| 618 |
"Text" => _("The post office box of the user's address.") . ' ' . _("Multiple values are separated by semicolon.") |
| 619 |
], |
| 620 |
'postalCode' => [ |
| 621 |
"Headline" => _("Postal code"), 'attr' => 'postalCode', |
| 622 |
"Text" => _("The postal code of the user's address.") |
| 623 |
], |
| 624 |
'postalCodeList' => [ |
| 625 |
"Headline" => _("Postal code"), 'attr' => 'postalCode', |
| 626 |
"Text" => _("The postal code of the user's address.") . ' ' . _("Multiple values are separated by semicolon.") |
| 627 |
], |
| 628 |
'postalAddress' => [ |
| 629 |
"Headline" => _("Postal address"), 'attr' => 'postalAddress', |
| 630 |
"Text" => _("Postal address, city") |
| 631 |
], |
| 632 |
'registeredAddress' => [ |
| 633 |
"Headline" => _("Registered address"), 'attr' => 'registeredAddress', |
| 634 |
"Text" => _("Registered address, city") |
| 635 |
], |
| 636 |
'telephoneNumber' => [ |
| 637 |
"Headline" => _("Telephone number"), 'attr' => 'telephoneNumber', |
| 638 |
"Text" => _("The user's telephone number.") |
| 639 |
], |
| 640 |
'telephoneNumberList' => [ |
| 641 |
"Headline" => _("Telephone number"), 'attr' => 'telephoneNumber', |
| 642 |
"Text" => _("The user's telephone number.") . ' ' . _('Multiple values are separated by semicolon.') |
| 643 |
], |
| 644 |
'mobile' => [ |
| 645 |
"Headline" => _("Mobile number"), 'attr' => 'mobile', |
| 646 |
"Text" => _("The user's mobile number.") |
| 647 |
], |
| 648 |
'mobileTelephoneNumberList' => [ |
| 649 |
"Headline" => _("Mobile number"), 'attr' => 'mobile', |
| 650 |
"Text" => _("The user's mobile number.") . ' ' . _('Multiple values are separated by semicolon.') |
| 651 |
], |
| 652 |
'facsimileTelephoneNumber' => [ |
| 653 |
"Headline" => _("Fax number"), 'attr' => 'facsimileTelephoneNumber', |
| 654 |
"Text" => _("The user's fax number.") |
| 655 |
], |
| 656 |
'facsimileTelephoneNumberList' => [ |
| 657 |
"Headline" => _("Fax number"), 'attr' => 'facsimileTelephoneNumber', |
| 658 |
"Text" => _("The user's fax number.") . ' ' . _('Multiple values are separated by semicolon.') |
| 659 |
], |
| 660 |
'pager' => [ |
| 661 |
"Headline" => _('Pager'), 'attr' => 'pager', |
| 662 |
"Text" => _("The user's pager number.") |
| 663 |
], |
| 664 |
'pagerList' => [ |
| 665 |
"Headline" => _('Pager'), 'attr' => 'pager', |
| 666 |
"Text" => _("The user's pager number.") . ' ' . _('Multiple values are separated by semicolon.') |
| 667 |
], |
| 668 |
'mail' => [ |
| 669 |
"Headline" => _("Email address"), 'attr' => 'mail', |
| 670 |
"Text" => _("The user's email address.") |
| 671 |
], |
| 672 |
'mailList' => [ |
| 673 |
"Headline" => _("Email address"), 'attr' => 'mail', |
| 674 |
"Text" => _("The user's email address.") . ' ' . _('Multiple values are separated by semicolon.') |
| 675 |
], |
| 676 |
"mailPassword" => [ |
| 677 |
"Headline" => _("Send password via mail"), |
| 678 |
"Text" => _("Sends the password to the user via mail. Please edit your LAM server profile to setup the mail settings.")], |
| 679 |
'labeledURI' => [ |
| 680 |
"Headline" => _("Web site"), 'attr' => 'labeledURI', |
| 681 |
"Text" => _("The user's web site (e.g. https://www.company.com).") |
| 682 |
], |
| 683 |
'labeledURIList' => [ |
| 684 |
"Headline" => _("Web site"), 'attr' => 'labeledURI', |
| 685 |
"Text" => _("The user's web site (e.g. https://www.company.com).") . ' ' . _('Multiple values are separated by semicolon.') |
| 686 |
], |
| 687 |
'cn' => [ |
| 688 |
"Headline" => _("Common name"), 'attr' => 'cn', |
| 689 |
"Text" => _("This is the natural name of the user. If empty, the first and last name is used.") |
| 690 |
], |
| 691 |
'displayName' => [ |
| 692 |
"Headline" => _("Display name"), 'attr' => 'displayName', |
| 693 |
"Text" => _("This is the user's preferred name to be used when displaying entries.") |
| 694 |
], |
| 695 |
'uid' => [ |
| 696 |
"Headline" => _("User name"), 'attr' => 'uid', |
| 697 |
"Text" => _("User name of the user who should be created. Valid characters are: a-z,A-Z,0-9, @.-_.") |
| 698 |
], |
| 699 |
'photoUpload' => [ |
| 700 |
"Headline" => _("Add photo"), 'attr' => 'jpegPhoto', |
| 701 |
"Text" => _("Please select an image file to upload. It must be in JPG format (.jpg/.jpeg).") |
| 702 |
], |
| 703 |
'homePhone' => [ |
| 704 |
"Headline" => _("Home telephone number"), 'attr' => 'homePhone', |
| 705 |
"Text" => _("The user's private telephone number.") |
| 706 |
], |
| 707 |
'homePhoneList' => [ |
| 708 |
"Headline" => _("Home telephone number"), 'attr' => 'homePhone', |
| 709 |
"Text" => _("The user's private telephone number.") . ' ' . _('Multiple values are separated by semicolon.') |
| 710 |
], |
| 711 |
'roomNumber' => [ |
| 712 |
"Headline" => _("Room number"), 'attr' => 'roomNumber', |
| 713 |
"Text" => _("The room number of the employee's office.") |
| 714 |
], |
| 715 |
'businessCategory' => [ |
| 716 |
"Headline" => _("Business category"), 'attr' => 'businessCategory', |
| 717 |
"Text" => _("Business category (e.g. Administration, IT-Services, Management, ...)") |
| 718 |
], |
| 719 |
'businessCategoryList' => [ |
| 720 |
"Headline" => _("Business category"), 'attr' => 'businessCategory', |
| 721 |
"Text" => _("Business category (e.g. Administration, IT-Services, Management, ...)") . '. ' . _("Multiple values are separated by semicolon.") |
| 722 |
], |
| 723 |
'l' => [ |
| 724 |
"Headline" => _("Location"), 'attr' => 'l', |
| 725 |
"Text" => _("This describes the location of the user.") |
| 726 |
], |
| 727 |
'lList' => [ |
| 728 |
"Headline" => _("Location"), 'attr' => 'l', |
| 729 |
"Text" => _("This describes the location of the user.") . ' ' . _("Multiple values are separated by semicolon.") |
| 730 |
], |
| 731 |
'st' => [ |
| 732 |
"Headline" => _("State"), 'attr' => 'st', |
| 733 |
"Text" => _("The state where the user resides or works.") |
| 734 |
], |
| 735 |
'stList' => [ |
| 736 |
"Headline" => _("State"), 'attr' => 'st', |
| 737 |
"Text" => _("The state where the user resides or works.") . ' ' . _("Multiple values are separated by semicolon.") |
| 738 |
], |
| 739 |
'carLicense' => [ |
| 740 |
"Headline" => _("Car license"), 'attr' => 'carLicense', |
| 741 |
"Text" => _("This can be used to specify if the user has a car license.") |
| 742 |
], |
| 743 |
'physicalDeliveryOfficeName' => [ |
| 744 |
"Headline" => _("Office name"), 'attr' => 'physicalDeliveryOfficeName', |
| 745 |
"Text" => _("The office name of the user (e.g. YourCompany, Human Resources).") |
| 746 |
], |
| 747 |
'physicalDeliveryOfficeNameList' => [ |
| 748 |
"Headline" => _("Office name"), 'attr' => 'physicalDeliveryOfficeName', |
| 749 |
"Text" => _("The office name of the user (e.g. YourCompany, Human Resources).") . ' ' . _("Multiple values are separated by semicolon.") |
| 750 |
], |
| 751 |
'departmentNumber' => [ |
| 752 |
"Headline" => _("Department"), 'attr' => 'departmentNumber', |
| 753 |
"Text" => _("Here you can enter the user's department.") |
| 754 |
], |
| 755 |
'departmentNumberList' => [ |
| 756 |
"Headline" => _("Department"), 'attr' => 'departmentNumber', |
| 757 |
"Text" => _("Here you can enter the user's department.") . ' ' . _("Multiple values are separated by semicolon.") |
| 758 |
], |
| 759 |
'hiddenOptions' => [ |
| 760 |
"Headline" => _("Hidden options"), |
| 761 |
"Text" => _("The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields.") |
| 762 |
], |
| 763 |
'pwdHash' => [ |
| 764 |
"Headline" => _("Password hash type"), |
| 765 |
"Text" => _("LAM supports a large number of possibilities to generate the hash value of passwords. CRYPT-SHA512 and SSHA are the most common. We do not recommend to use plain text passwords unless passwords are hashed server-side.") |
| 766 |
. ' ' . _('K5KEY is only needed if you use Kerberos with smbk5pwd.') |
| 767 |
], |
| 768 |
'ou' => [ |
| 769 |
"Headline" => _("Organisational unit"), 'attr' => 'ou', |
| 770 |
"Text" => _("The user's organisational unit.") |
| 771 |
], |
| 772 |
'ouList' => [ |
| 773 |
"Headline" => _("Organisational unit"), 'attr' => 'ou', |
| 774 |
"Text" => _("The user's organisational unit.") . ' ' . _('Multiple values are separated by semicolon.') |
| 775 |
], |
| 776 |
'o' => [ |
| 777 |
"Headline" => _("Organisation"), 'attr' => 'o', |
| 778 |
"Text" => _("The user's organisation name.") |
| 779 |
], |
| 780 |
'oList' => [ |
| 781 |
"Headline" => _("Organisation"), 'attr' => 'o', |
| 782 |
"Text" => _("The user's organisation name.") . ' ' . _('Multiple values are separated by semicolon.') |
| 783 |
], |
| 784 |
'employeeNumber' => [ |
| 785 |
"Headline" => _("Employee number"), 'attr' => 'employeeNumber', |
| 786 |
"Text" => _("The user's unique employee number.") |
| 787 |
], |
| 788 |
'initials' => [ |
| 789 |
"Headline" => _("Initials"), 'attr' => 'initials', |
| 790 |
"Text" => _("The initials of the user's first names.") . ' ' . _('Multiple values are separated by semicolon.') |
| 791 |
], |
| 792 |
'userPassword' => [ |
| 793 |
"Headline" => _("Password"), |
| 794 |
"Text" => _("Please enter the password which you want to set for this account.") |
| 795 |
], |
| 796 |
'userPassword_lock' => [ |
| 797 |
"Headline" => _("Lock password"), |
| 798 |
"Text" => _("If checked then the password will be deactivated by putting a \"!\" before the encrypted password.") |
| 799 |
], |
| 800 |
'userCertificate' => [ |
| 801 |
"Headline" => _('User certificates'), |
| 802 |
"Text" => _('These are the user\'s certificates.') |
| 803 |
], |
| 804 |
'crop' => [ |
| 805 |
"Headline" => _('Image cropping'), |
| 806 |
"Text" => _('Uploaded images will be cropped to these maximum values.') |
| 807 |
], |
| 808 |
'addAddressbook' => [ |
| 809 |
"Headline" => _('Add addressbook (ou=addressbook)'), |
| 810 |
"Text" => _('Adds an "ou=addressbook" subentry to each user.') |
| 811 |
], |
| 812 |
'filter' => [ |
| 813 |
"Headline" => _("Filter"), |
| 814 |
"Text" => _("Here you can enter a filter value. Only entries which contain the filter text will be shown.") |
| 815 |
. ' ' . _('Possible wildcards are: "*" = any character, "^" = line start, "$" = line end') |
| 816 |
], |
| 817 |
]; |
| 818 |
return $return; |
| 819 |
} |
| 820 |
|
| 821 |
/** |
| 822 |
* {@inheritDoc} |
| 823 |
*/ |
| 824 |
public function getManagedAttributes(string $typeId): array { |
| 825 |
$attrs = parent::getManagedAttributes($typeId); |
| 826 |
if (!$this->isUnixActive()) { |
| 827 |
$attrs[] = 'cn'; |
| 828 |
} |
| 829 |
if (!$this->isSamba3Active()) { |
| 830 |
$attrs[] = 'displayName'; |
| 831 |
} |
| 832 |
return $attrs; |
| 833 |
} |
| 834 |
|
| 835 |
/** |
| 836 |
* {@inheritDoc} |
| 837 |
*/ |
| 838 |
public function module_complete(): bool { |
| 839 |
if (!$this->getAccountContainer()->isNewAccount) { |
| 840 |
// check if account is based on our object class |
| 841 |
$objectClasses = $this->getAccountContainer()->attributes_orig['objectClass']; |
| 842 |
if (is_array($objectClasses) && !in_array('inetOrgPerson', $objectClasses)) { |
| 843 |
return true; |
| 844 |
} |
| 845 |
} |
| 846 |
if (!isset($this->attributes['sn'][0]) || ($this->attributes['sn'][0] == '')) { |
| 847 |
return false; |
| 848 |
} |
| 849 |
return $this->isUnixActive() |
| 850 |
|| ($this->getAccountContainer()->rdn !== 'uid') |
| 851 |
|| isset($this->attributes['uid'][0]); |
| 852 |
} |
| 853 |
|
| 854 |
/** |
| 855 |
* {@inheritDoc} |
| 856 |
*/ |
| 857 |
public function getButtonStatus(): string { |
| 858 |
if (!$this->getAccountContainer()->isNewAccount) { |
| 859 |
// check if account is based on our object class |
| 860 |
$objectClasses = $this->getAccountContainer()->attributes_orig['objectClass']; |
| 861 |
if (is_array($objectClasses) && !in_array('inetOrgPerson', $objectClasses)) { |
| 862 |
return "disabled"; |
| 863 |
} |
| 864 |
} |
| 865 |
return "enabled"; |
| 866 |
} |
| 867 |
|
| 868 |
/** |
| 869 |
* {@inheritDoc} |
| 870 |
*/ |
| 871 |
public function save_attributes(): array { |
| 872 |
// skip saving if account is based on another structural object class |
| 873 |
if (!$this->getAccountContainer()->isNewAccount && !in_array('inetOrgPerson', $this->getAccountContainer()->attributes_orig['objectClass'])) { |
| 874 |
return []; |
| 875 |
} |
| 876 |
$return = parent::save_attributes(); |
| 877 |
// add information about clear text password |
| 878 |
if ($this->clearTextPassword != null) { |
| 879 |
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordClearText'][0] = $this->clearTextPassword; |
| 880 |
} |
| 881 |
// password status change |
| 882 |
if (!$this->isUnixActive()) { |
| 883 |
$pwdOrig = empty($this->orig['userpassword'][0]) ? '' : $this->orig['userpassword'][0]; |
| 884 |
$pwdNew = empty($this->attributes['userpassword'][0]) ? '' : $this->attributes['userpassword'][0]; |
| 885 |
if ((pwd_is_enabled($pwdOrig) && pwd_is_enabled($pwdNew)) || (!pwd_is_enabled($pwdOrig) && !pwd_is_enabled($pwdNew))) { |
| 886 |
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'unchanged'; |
| 887 |
} |
| 888 |
elseif (pwd_is_enabled($pwdOrig)) { |
| 889 |
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'locked'; |
| 890 |
} |
| 891 |
else { |
| 892 |
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'unlocked'; |
| 893 |
} |
| 894 |
} |
| 895 |
return $return; |
| 896 |
} |
| 897 |
|
| 898 |
/** |
| 899 |
* {@inheritDoc} |
| 900 |
*/ |
| 901 |
public function postModifyActions(bool $newAccount, array $attributes): array { |
| 902 |
$messages = []; |
| 903 |
// set exop password |
| 904 |
$messages = array_merge($messages, $this->setExopPassword($this->moduleSettings)); |
| 905 |
// add address book |
| 906 |
$accountContainer = $this->getAccountContainer(); |
| 907 |
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook') |
| 908 |
&& !empty($accountContainer) |
| 909 |
&& !empty($accountContainer->finalDN)) { |
| 910 |
$dn = 'ou=addressbook,' . $accountContainer->finalDN; |
| 911 |
$result = ldapGetDN($dn); |
| 912 |
if (empty($result)) { |
| 913 |
$attrs = [ |
| 914 |
'objectClass' => ['organizationalUnit'], |
| 915 |
'ou' => 'addressbook' |
| 916 |
]; |
| 917 |
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs); |
| 918 |
if (!$success) { |
| 919 |
logNewMessage(LOG_ERR, 'Unable to add addressbook for user ' . $accountContainer->finalDN . ' (' . ldap_error($_SESSION['ldap']->server()) . ').'); |
| 920 |
$messages[] = ['ERROR', sprintf(_("Was unable to create DN: %s."), htmlspecialchars($dn)), getDefaultLDAPErrorString($_SESSION['ldap']->server())]; |
| 921 |
} |
| 922 |
else { |
| 923 |
logNewMessage(LOG_NOTICE, 'Added addressbook for user ' . $accountContainer->finalDN); |
| 924 |
} |
| 925 |
} |
| 926 |
} |
| 927 |
return $messages; |
| 928 |
} |
| 929 |
|
| 930 |
/** |
| 931 |
* Sets the password via ldap_exop if configured. |
| 932 |
* |
| 933 |
* @param array<string, string[]> $settings settings |
| 934 |
* @return array<string|string[]>[] error message parameters if any |
| 935 |
*/ |
| 936 |
private function setExopPassword($settings): array { |
| 937 |
if (!empty($this->clearTextPassword) && !empty($settings['posixAccount_pwdHash'][0]) |
| 938 |
&& ($settings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) { |
| 939 |
$success = ldap_exop_passwd($_SESSION['ldap']->server(), $this->getAccountContainer()->finalDN, '', $this->clearTextPassword); |
| 940 |
if (!$success) { |
| 941 |
return [['ERROR', _('Unable to set password'), getExtendedLDAPErrorMessage($_SESSION['ldap']->server())]]; |
| 942 |
} |
| 943 |
} |
| 944 |
return []; |
| 945 |
} |
| 946 |
|
| 947 |
/** |
| 948 |
* {@inheritDoc} |
| 949 |
*/ |
| 950 |
public function process_attributes(): array { |
| 951 |
$errors = []; |
| 952 |
$this->getAccountContainer()->replaceWildcardsInPOST($this->getWildcardTargetAttributeNames()); |
| 953 |
// add parent object classes |
| 954 |
if ($this->getAccountContainer()->isNewAccount) { |
| 955 |
if (!in_array('organizationalPerson', $this->attributes['objectClass'])) { |
| 956 |
$this->attributes['objectClass'][] = 'organizationalPerson'; |
| 957 |
} |
| 958 |
if (!in_array('person', $this->attributes['objectClass'])) { |
| 959 |
$this->attributes['objectClass'][] = 'person'; |
| 960 |
} |
| 961 |
} |
| 962 |
// load and check attributes |
| 963 |
// description |
| 964 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription') && !$this->isAdminReadOnly('description')) { |
| 965 |
$this->processMultiValueInputTextField('description', $errors); |
| 966 |
} |
| 967 |
// last name |
| 968 |
if (!$this->isAdminReadOnly('sn')) { |
| 969 |
$this->attributes['sn'][0] = trim($_POST['sn']); |
| 970 |
if (!get_preg($this->attributes['sn'][0], 'realname')) { |
| 971 |
$errors[] = $this->messages['lastname'][0]; |
| 972 |
} |
| 973 |
} |
| 974 |
// first name |
| 975 |
if (!$this->isAdminReadOnly('givenName')) { |
| 976 |
$this->attributes['givenName'][0] = trim($_POST['givenName']); |
| 977 |
if (($this->attributes['givenName'][0] !== '') && !get_preg($this->attributes['givenName'][0], 'realname')) { |
| 978 |
$errors[] = $this->messages['givenName'][0]; |
| 979 |
} |
| 980 |
} |
| 981 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle') && !$this->isAdminReadOnly('title')) { |
| 982 |
$this->processMultiValueInputTextField('title', $errors, 'title'); |
| 983 |
} |
| 984 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress') && !$this->isAdminReadOnly('mail')) { |
| 985 |
$this->processMultiValueInputTextField('mail', $errors, 'email'); |
| 986 |
if (!empty($this->attributes['mail'])) { |
| 987 |
foreach ($this->attributes['mail'] as &$mail) { |
| 988 |
if ((empty($this->orig['mail']) || !in_array($mail, $this->orig['mail'])) && $this->emailExists($mail)) { |
| 989 |
$msg = $this->messages['mail'][1]; |
| 990 |
$msg[] = [htmlspecialchars($mail)]; |
| 991 |
$errors[] = $msg; |
| 992 |
} |
| 993 |
} |
| 994 |
} |
| 995 |
} |
| 996 |
if (!$this->isSamba3Active() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) { |
| 997 |
$this->attributes['displayName'][0] = $_POST['displayName']; |
| 998 |
} |
| 999 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber') && !$this->isAdminReadOnly('telephoneNumber')) { |
| 1000 |
$this->processMultiValueInputTextField('telephoneNumber', $errors, 'telephone'); |
| 1001 |
} |
| 1002 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber') && !$this->isAdminReadOnly('mobile')) { |
| 1003 |
$this->processMultiValueInputTextField('mobile', $errors, 'telephone'); |
| 1004 |
} |
| 1005 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber') && !$this->isAdminReadOnly('facsimileTelephoneNumber')) { |
| 1006 |
$this->processMultiValueInputTextField('facsimileTelephoneNumber', $errors, 'telephone'); |
| 1007 |
} |
| 1008 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true) && !$this->isAdminReadOnly('pager')) { |
| 1009 |
$this->processMultiValueInputTextField('pager', $errors, 'telephone'); |
| 1010 |
} |
| 1011 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber') && !$this->isAdminReadOnly('homePhone')) { |
| 1012 |
$this->processMultiValueInputTextField('homePhone', $errors, 'telephone'); |
| 1013 |
} |
| 1014 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') && !$this->isAdminReadOnly('street')) { |
| 1015 |
$this->processMultiValueInputTextField('street', $errors, 'street'); |
| 1016 |
} |
| 1017 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox') && !$this->isAdminReadOnly('postOfficeBox')) { |
| 1018 |
$this->processMultiValueInputTextField('postOfficeBox', $errors); |
| 1019 |
} |
| 1020 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') && !$this->isAdminReadOnly('postalCode')) { |
| 1021 |
$this->processMultiValueInputTextField('postalCode', $errors, 'postalCode'); |
| 1022 |
} |
| 1023 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress') && !$this->isAdminReadOnly('postalAddress')) { |
| 1024 |
$addressCounter = 0; |
| 1025 |
while (isset($_POST['postalAddress' . $addressCounter])) { |
| 1026 |
$this->attributes['postalAddress'][$addressCounter] = implode('$', preg_split('/[\r][\n]/', $_POST['postalAddress' . $addressCounter])); |
| 1027 |
if (!get_preg($this->attributes['postalAddress'][$addressCounter], 'postalAddress')) { |
| 1028 |
$errors[] = $this->messages['postalAddress'][0]; |
| 1029 |
} |
| 1030 |
if ($this->attributes['postalAddress'][$addressCounter] === '') { |
| 1031 |
unset($this->attributes['postalAddress'][$addressCounter]); |
| 1032 |
} |
| 1033 |
$addressCounter++; |
| 1034 |
} |
| 1035 |
if (isset($_POST['addPostalAddress'])) { |
| 1036 |
$this->attributes['postalAddress'][] = ''; |
| 1037 |
} |
| 1038 |
$this->attributes['postalAddress'] = array_values($this->attributes['postalAddress']); |
| 1039 |
} |
| 1040 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI') && !$this->isAdminReadOnly('labeledURI')) { |
| 1041 |
$this->processMultiValueInputTextField('labeledURI', $errors); |
| 1042 |
} |
| 1043 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress') && !$this->isAdminReadOnly('registeredAddress')) { |
| 1044 |
$addressCounter = 0; |
| 1045 |
while (isset($_POST['registeredAddress' . $addressCounter])) { |
| 1046 |
$this->attributes['registeredAddress'][$addressCounter] = implode('$', preg_split('/[\r][\n]/', $_POST['registeredAddress' . $addressCounter])); |
| 1047 |
if (!get_preg($this->attributes['registeredAddress'][$addressCounter], 'postalAddress')) { |
| 1048 |
$errors[] = $this->messages['registeredAddress'][0]; |
| 1049 |
} |
| 1050 |
if ($this->attributes['registeredAddress'][$addressCounter] === '') { |
| 1051 |
unset($this->attributes['registeredAddress'][$addressCounter]); |
| 1052 |
} |
| 1053 |
$addressCounter++; |
| 1054 |
} |
| 1055 |
if (isset($_POST['addRegisteredAddress'])) { |
| 1056 |
$this->attributes['registeredAddress'][] = ''; |
| 1057 |
} |
| 1058 |
$this->attributes['registeredAddress'] = array_values($this->attributes['registeredAddress']); |
| 1059 |
} |
| 1060 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType') && !$this->isAdminReadOnly('employeeType')) { |
| 1061 |
$this->attributes['employeeType'][0] = $_POST['employeeType']; |
| 1062 |
if (!get_preg($this->attributes['employeeType'][0], 'employeeType')) { |
| 1063 |
$errors[] = $this->messages['employeeType'][0]; |
| 1064 |
} |
| 1065 |
} |
| 1066 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber') && !$this->isAdminReadOnly('roomNumber')) { |
| 1067 |
$this->attributes['roomNumber'][0] = $_POST['roomNumber']; |
| 1068 |
} |
| 1069 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation') && !$this->isAdminReadOnly('l')) { |
| 1070 |
$this->processMultiValueInputTextField('l', $errors); |
| 1071 |
} |
| 1072 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') && !$this->isAdminReadOnly('st')) { |
| 1073 |
$this->processMultiValueInputTextField('st', $errors); |
| 1074 |
} |
| 1075 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense') && !$this->isAdminReadOnly('carLicense')) { |
| 1076 |
$this->attributes['carLicense'][0] = $_POST['carLicense']; |
| 1077 |
} |
| 1078 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName') && !$this->isAdminReadOnly('physicalDeliveryOfficeName')) { |
| 1079 |
$this->processMultiValueInputTextField('physicalDeliveryOfficeName', $errors); |
| 1080 |
} |
| 1081 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory') && !$this->isAdminReadOnly('businessCategory')) { |
| 1082 |
$this->processMultiValueInputTextField('businessCategory', $errors, 'businessCategory'); |
| 1083 |
} |
| 1084 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments') && !$this->isAdminReadOnly('departmentNumber')) { |
| 1085 |
$this->processMultiValueInputTextField('departmentNumber', $errors); |
| 1086 |
} |
| 1087 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber') && !$this->isAdminReadOnly('employeeNumber')) { |
| 1088 |
$this->attributes['employeeNumber'][0] = $_POST['employeeNumber']; |
| 1089 |
} |
| 1090 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu') && !$this->isAdminReadOnly('ou')) { |
| 1091 |
$this->processMultiValueInputTextField('ou', $errors); |
| 1092 |
} |
| 1093 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO') && !$this->isAdminReadOnly('o')) { |
| 1094 |
$this->processMultiValueInputTextField('o', $errors); |
| 1095 |
} |
| 1096 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials') && !$this->isAdminReadOnly('initials')) { |
| 1097 |
$this->attributes['initials'] = preg_split('/;[ ]*/', $_POST['initials']); |
| 1098 |
} |
| 1099 |
|
| 1100 |
if (!$this->isUnixActive()) { |
| 1101 |
// uid |
| 1102 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID') && !$this->isAdminReadOnly('uid')) { |
| 1103 |
if (isset($_POST['uid']) && ($_POST['uid'] != '')) { |
| 1104 |
if (!get_preg($_POST['uid'], 'username')) { |
| 1105 |
$errors[] = $this->messages['uid'][0]; |
| 1106 |
} |
| 1107 |
else { |
| 1108 |
$this->attributes['uid'][0] = $_POST['uid']; |
| 1109 |
} |
| 1110 |
} |
| 1111 |
elseif (isset($this->attributes['uid'][0])) { |
| 1112 |
unset($this->attributes['uid'][0]); |
| 1113 |
} |
| 1114 |
} |
| 1115 |
// cn |
| 1116 |
if (!$this->isAdminReadOnly('cn')) { |
| 1117 |
$this->processMultiValueInputTextField('cn', $errors, 'cn'); |
| 1118 |
if (empty($this->attributes['cn'][0])) { |
| 1119 |
$this->attributes['cn'][0] = ($_POST['givenName'] != '') ? $_POST['givenName'] . " " . $_POST['sn'] : $_POST['sn']; |
| 1120 |
} |
| 1121 |
} |
| 1122 |
if (!$this->isAdminReadOnly('userPassword')) { |
| 1123 |
if (isset($_POST['lockPassword'])) { |
| 1124 |
$this->attributes['userpassword'][0] = pwd_disable($this->attributes['userpassword'][0]); |
| 1125 |
} |
| 1126 |
if (isset($_POST['unlockPassword'])) { |
| 1127 |
$this->attributes['userpassword'][0] = pwd_enable($this->attributes['userpassword'][0]); |
| 1128 |
} |
| 1129 |
if (isset($_POST['removePassword'])) { |
| 1130 |
unset($this->attributes['userpassword']); |
| 1131 |
} |
| 1132 |
// set SASL password for new and renamed users |
| 1133 |
if (!empty($this->attributes['uid'][0]) && !empty($this->moduleSettings['posixAccount_pwdHash'][0]) |
| 1134 |
&& ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL') |
| 1135 |
&& ($this->getAccountContainer()->isNewAccount || ($this->attributes['uid'][0] != $this->orig['uid'][0]))) { |
| 1136 |
$this->attributes['userpassword'][0] = '{SASL}' . $this->attributes['uid'][0]; |
| 1137 |
} |
| 1138 |
// set K5KEY password for new users |
| 1139 |
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'K5KEY')) { |
| 1140 |
$this->attributes['userpassword'][0] = pwd_hash('x', true, $this->moduleSettings['posixAccount_pwdHash'][0]); |
| 1141 |
} |
| 1142 |
} |
| 1143 |
} |
| 1144 |
|
| 1145 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto') && isset($_POST['delPhoto']) && !$this->isAdminReadOnly('jpegPhoto')) { |
| 1146 |
$this->attributes['jpegPhoto'] = []; |
| 1147 |
} |
| 1148 |
// Return error-messages |
| 1149 |
return $errors; |
| 1150 |
} |
| 1151 |
|
| 1152 |
/** |
| 1153 |
* {@inheritDoc} |
| 1154 |
*/ |
| 1155 |
public function display_html_attributes(): htmlElement|array { |
| 1156 |
$this->initCache(); |
| 1157 |
$this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes); |
| 1158 |
$container = new htmlResponsiveRow(); |
| 1159 |
$fieldContainer = new htmlResponsiveRow(); |
| 1160 |
$fieldTabletColumns = $this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto') ? 12 : 8; |
| 1161 |
$container->add($fieldContainer, 12, 12, $fieldTabletColumns); |
| 1162 |
// uid |
| 1163 |
if (!$this->isUnixActive() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) { |
| 1164 |
if ($this->isAdminReadOnly('uid')) { |
| 1165 |
$this->addSimpleReadOnlyField($fieldContainer, 'uid', _('User name')); |
| 1166 |
} |
| 1167 |
else { |
| 1168 |
$this->addSimpleInputTextField($fieldContainer, 'uid', _('User name')); |
| 1169 |
} |
| 1170 |
} |
| 1171 |
// first name |
| 1172 |
if ($this->isAdminReadOnly('givenName')) { |
| 1173 |
$this->addSimpleReadOnlyField($fieldContainer, 'givenName', _('First name')); |
| 1174 |
} |
| 1175 |
else { |
| 1176 |
$this->addSimpleInputTextField($fieldContainer, 'givenName', _('First name')); |
| 1177 |
} |
| 1178 |
// last name |
| 1179 |
if ($this->isAdminReadOnly('sn')) { |
| 1180 |
$this->addSimpleReadOnlyField($fieldContainer, 'sn', _('Last name')); |
| 1181 |
} |
| 1182 |
else { |
| 1183 |
$this->addSimpleInputTextField($fieldContainer, 'sn', _('Last name'), true); |
| 1184 |
} |
| 1185 |
// initials |
| 1186 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) { |
| 1187 |
if ($this->isAdminReadOnly('initials')) { |
| 1188 |
$this->addSimpleReadOnlyField($fieldContainer, 'initials', _('Initials')); |
| 1189 |
} |
| 1190 |
else { |
| 1191 |
$this->addSimpleInputTextField($fieldContainer, 'initials', _('Initials')); |
| 1192 |
} |
| 1193 |
} |
| 1194 |
// common name |
| 1195 |
if (!$this->isUnixActive()) { |
| 1196 |
if ($this->isAdminReadOnly('cn')) { |
| 1197 |
$this->addSimpleReadOnlyField($fieldContainer, 'cn', _('Common name')); |
| 1198 |
} |
| 1199 |
else { |
| 1200 |
$this->addMultiValueInputTextField($fieldContainer, 'cn', _('Common name'), true); |
| 1201 |
} |
| 1202 |
} |
| 1203 |
// display name |
| 1204 |
if (!$this->isSamba3Active() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) { |
| 1205 |
$this->addSimpleInputTextField($fieldContainer, 'displayName', _('Display name')); |
| 1206 |
} |
| 1207 |
// description |
| 1208 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { |
| 1209 |
if ($this->isAdminReadOnly('description')) { |
| 1210 |
$this->addSimpleReadOnlyField($fieldContainer, 'description', _('Description')); |
| 1211 |
} |
| 1212 |
else { |
| 1213 |
$this->addMultiValueInputTextField($fieldContainer, 'description', _('Description')); |
| 1214 |
} |
| 1215 |
} |
| 1216 |
|
| 1217 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox') |
| 1218 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation') |
| 1219 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress') |
| 1220 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber') |
| 1221 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 1222 |
$fieldContainer->add(new htmlSubTitle(_('Address'))); |
| 1223 |
} |
| 1224 |
|
| 1225 |
// street |
| 1226 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) { |
| 1227 |
if ($this->isAdminReadOnly('street')) { |
| 1228 |
$this->addSimpleReadOnlyField($fieldContainer, 'street', _('Street')); |
| 1229 |
} |
| 1230 |
else { |
| 1231 |
$this->addMultiValueInputTextField($fieldContainer, 'street', _('Street')); |
| 1232 |
} |
| 1233 |
} |
| 1234 |
// post office box |
| 1235 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) { |
| 1236 |
if ($this->isAdminReadOnly('postOfficeBox')) { |
| 1237 |
$this->addSimpleReadOnlyField($fieldContainer, 'postOfficeBox', _('Post office box')); |
| 1238 |
} |
| 1239 |
else { |
| 1240 |
$this->addMultiValueInputTextField($fieldContainer, 'postOfficeBox', _('Post office box')); |
| 1241 |
} |
| 1242 |
} |
| 1243 |
// postal code |
| 1244 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) { |
| 1245 |
if ($this->isAdminReadOnly('postalCode')) { |
| 1246 |
$this->addSimpleReadOnlyField($fieldContainer, 'postalCode', _('Postal code')); |
| 1247 |
} |
| 1248 |
else { |
| 1249 |
$this->addMultiValueInputTextField($fieldContainer, 'postalCode', _('Postal code')); |
| 1250 |
} |
| 1251 |
} |
| 1252 |
// location |
| 1253 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) { |
| 1254 |
if ($this->isAdminReadOnly('l')) { |
| 1255 |
$this->addSimpleReadOnlyField($fieldContainer, 'l', _('Location')); |
| 1256 |
} |
| 1257 |
else { |
| 1258 |
$this->addMultiValueInputTextField($fieldContainer, 'l', _('Location')); |
| 1259 |
} |
| 1260 |
} |
| 1261 |
// state |
| 1262 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) { |
| 1263 |
if ($this->isAdminReadOnly('st')) { |
| 1264 |
$this->addSimpleReadOnlyField($fieldContainer, 'st', _('State')); |
| 1265 |
} |
| 1266 |
else { |
| 1267 |
$this->addMultiValueInputTextField($fieldContainer, 'st', _('State')); |
| 1268 |
} |
| 1269 |
} |
| 1270 |
// postal address |
| 1271 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) { |
| 1272 |
$postalAddresses = []; |
| 1273 |
if (isset($this->attributes['postalAddress'][0])) { |
| 1274 |
for ($i = 0; $i < count($this->attributes['postalAddress']); $i++) { |
| 1275 |
$postalAddresses[] = implode("\r\n", explode('$', $this->attributes['postalAddress'][$i])); |
| 1276 |
} |
| 1277 |
} |
| 1278 |
if (count($postalAddresses) === 0) { |
| 1279 |
$postalAddresses[] = ''; |
| 1280 |
} |
| 1281 |
$addressLabel = new htmlOutputText(_('Postal address')); |
| 1282 |
$addressLabel->alignment = htmlElement::ALIGN_TOP; |
| 1283 |
$fieldContainer->addLabel($addressLabel); |
| 1284 |
$addressContainer = new htmlGroup(); |
| 1285 |
for ($i = 0; $i < count($postalAddresses); $i++) { |
| 1286 |
if ($this->isAdminReadOnly('postalAddress')) { |
| 1287 |
$val = str_replace("\r\n", '<br>', htmlspecialchars($postalAddresses[$i])); |
| 1288 |
$addressContainer->addElement(new htmlOutputText($val, false)); |
| 1289 |
if ($i < (count($postalAddresses) - 1)) { |
| 1290 |
$addressContainer->addElement(new htmlLineBreak()); |
| 1291 |
} |
| 1292 |
} |
| 1293 |
else { |
| 1294 |
$postalAddressTextarea = new htmlInputTextarea('postalAddress' . $i, $postalAddresses[$i], 30, 3); |
| 1295 |
$postalAddressTextarea->setAccessibilityLabel(_('Postal address')); |
| 1296 |
$addressContainer->addElement($postalAddressTextarea); |
| 1297 |
if ($i < (count($postalAddresses) - 1)) { |
| 1298 |
$addressContainer->addElement(new htmlLineBreak()); |
| 1299 |
} |
| 1300 |
else { |
| 1301 |
$addButton = new htmlButton('addPostalAddress', 'add.svg', true); |
| 1302 |
$addButton->setTitle(_('Add')); |
| 1303 |
$addressContainer->addElement($addButton); |
| 1304 |
$addressHelp = new htmlHelpLink('postalAddress'); |
| 1305 |
$addressContainer->addElement($addressHelp); |
| 1306 |
} |
| 1307 |
} |
| 1308 |
} |
| 1309 |
$fieldContainer->addField($addressContainer); |
| 1310 |
} |
| 1311 |
// registered address |
| 1312 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 1313 |
$registeredAddresses = []; |
| 1314 |
if (isset($this->attributes['registeredAddress'][0])) { |
| 1315 |
for ($i = 0; $i < count($this->attributes['registeredAddress']); $i++) { |
| 1316 |
$registeredAddresses[] = implode("\r\n", explode('$', $this->attributes['registeredAddress'][$i])); |
| 1317 |
} |
| 1318 |
} |
| 1319 |
if (count($registeredAddresses) === 0) { |
| 1320 |
$registeredAddresses[] = ''; |
| 1321 |
} |
| 1322 |
$registeredAddressLabel = new htmlOutputText(_('Registered address')); |
| 1323 |
$registeredAddressLabel->alignment = htmlElement::ALIGN_TOP; |
| 1324 |
$fieldContainer->addLabel($registeredAddressLabel); |
| 1325 |
$registeredAddressContainer = new htmlGroup(); |
| 1326 |
for ($i = 0; $i < count($registeredAddresses); $i++) { |
| 1327 |
if ($this->isAdminReadOnly('registeredAddress')) { |
| 1328 |
$val = str_replace("\r\n", '<br>', htmlspecialchars($registeredAddresses[$i])); |
| 1329 |
$registeredAddressContainer->addElement(new htmlOutputText($val, false)); |
| 1330 |
if ($i < (count($registeredAddresses) - 1)) { |
| 1331 |
$registeredAddressContainer->addElement(new htmlLineBreak()); |
| 1332 |
} |
| 1333 |
} |
| 1334 |
else { |
| 1335 |
$registeredAddressTextarea = new htmlInputTextarea('registeredAddress' . $i, $registeredAddresses[$i], 30, 3); |
| 1336 |
$registeredAddressTextarea->setAccessibilityLabel(_('Registered address')); |
| 1337 |
$registeredAddressContainer->addElement($registeredAddressTextarea); |
| 1338 |
if ($i < (count($registeredAddresses) - 1)) { |
| 1339 |
$registeredAddressContainer->addElement(new htmlLineBreak()); |
| 1340 |
} |
| 1341 |
else { |
| 1342 |
$addButton = new htmlButton('addRegisteredAddress', 'add.svg', true); |
| 1343 |
$addButton->setTitle(_('Add')); |
| 1344 |
$registeredAddressContainer->addElement($addButton); |
| 1345 |
$registeredAddressHelp = new htmlHelpLink('registeredAddress'); |
| 1346 |
$registeredAddressContainer->addElement($registeredAddressHelp); |
| 1347 |
} |
| 1348 |
} |
| 1349 |
} |
| 1350 |
$fieldContainer->addField($registeredAddressContainer); |
| 1351 |
} |
| 1352 |
// office name |
| 1353 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) { |
| 1354 |
if ($this->isAdminReadOnly('physicalDeliveryOfficeName')) { |
| 1355 |
$this->addSimpleReadOnlyField($fieldContainer, 'physicalDeliveryOfficeName', _('Office name')); |
| 1356 |
} |
| 1357 |
else { |
| 1358 |
$this->addMultiValueInputTextField($fieldContainer, 'physicalDeliveryOfficeName', _('Office name')); |
| 1359 |
} |
| 1360 |
} |
| 1361 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) { |
| 1362 |
if ($this->isAdminReadOnly('roomNumber')) { |
| 1363 |
$this->addSimpleReadOnlyField($fieldContainer, 'roomNumber', _('Room number')); |
| 1364 |
} |
| 1365 |
else { |
| 1366 |
$this->addSimpleInputTextField($fieldContainer, 'roomNumber', _('Room number')); |
| 1367 |
} |
| 1368 |
} |
| 1369 |
|
| 1370 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber') |
| 1371 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber') |
| 1372 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) { |
| 1373 |
$fieldContainer->add(new htmlSubTitle(_('Contact data'))); |
| 1374 |
} |
| 1375 |
|
| 1376 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { |
| 1377 |
if ($this->isAdminReadOnly('telephoneNumber')) { |
| 1378 |
$this->addSimpleReadOnlyField($fieldContainer, 'telephoneNumber', _('Telephone number')); |
| 1379 |
} |
| 1380 |
else { |
| 1381 |
$this->addMultiValueInputTextField($fieldContainer, 'telephoneNumber', _('Telephone number')); |
| 1382 |
} |
| 1383 |
} |
| 1384 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { |
| 1385 |
if ($this->isAdminReadOnly('homePhone')) { |
| 1386 |
$this->addSimpleReadOnlyField($fieldContainer, 'homePhone', _('Home telephone number')); |
| 1387 |
} |
| 1388 |
else { |
| 1389 |
$this->addMultiValueInputTextField($fieldContainer, 'homePhone', _('Home telephone number')); |
| 1390 |
} |
| 1391 |
} |
| 1392 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) { |
| 1393 |
if ($this->isAdminReadOnly('mobile')) { |
| 1394 |
$this->addSimpleReadOnlyField($fieldContainer, 'mobile', _('Mobile number')); |
| 1395 |
} |
| 1396 |
else { |
| 1397 |
$this->addMultiValueInputTextField($fieldContainer, 'mobile', _('Mobile number')); |
| 1398 |
} |
| 1399 |
} |
| 1400 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) { |
| 1401 |
if ($this->isAdminReadOnly('facsimileTelephoneNumber')) { |
| 1402 |
$this->addSimpleReadOnlyField($fieldContainer, 'facsimileTelephoneNumber', _('Fax number')); |
| 1403 |
} |
| 1404 |
else { |
| 1405 |
$this->addMultiValueInputTextField($fieldContainer, 'facsimileTelephoneNumber', _('Fax number')); |
| 1406 |
} |
| 1407 |
} |
| 1408 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) { |
| 1409 |
if ($this->isAdminReadOnly('pager')) { |
| 1410 |
$this->addSimpleReadOnlyField($fieldContainer, 'pager', _('Pager')); |
| 1411 |
} |
| 1412 |
else { |
| 1413 |
$this->addMultiValueInputTextField($fieldContainer, 'pager', _('Pager')); |
| 1414 |
} |
| 1415 |
} |
| 1416 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) { |
| 1417 |
if ($this->isAdminReadOnly('mail')) { |
| 1418 |
$this->addSimpleReadOnlyField($fieldContainer, 'mail', _('Email address')); |
| 1419 |
} |
| 1420 |
else { |
| 1421 |
$this->addMultiValueInputTextField($fieldContainer, 'mail', _('Email address')); |
| 1422 |
} |
| 1423 |
} |
| 1424 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) { |
| 1425 |
if ($this->isAdminReadOnly('labeledURI')) { |
| 1426 |
$this->addSimpleReadOnlyField($fieldContainer, 'labeledURI', _('Web site')); |
| 1427 |
} |
| 1428 |
else { |
| 1429 |
$this->addMultiValueInputTextField($fieldContainer, 'labeledURI', _('Web site')); |
| 1430 |
} |
| 1431 |
} |
| 1432 |
|
| 1433 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense') |
| 1434 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory') |
| 1435 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager') |
| 1436 |
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideuserCertificate')) { |
| 1437 |
$fieldContainer->add(new htmlSubTitle(_('Work details'))); |
| 1438 |
} |
| 1439 |
|
| 1440 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 1441 |
if ($this->isAdminReadOnly('title')) { |
| 1442 |
$this->addSimpleReadOnlyField($fieldContainer, 'title', _('Job title')); |
| 1443 |
} |
| 1444 |
else { |
| 1445 |
$this->addMultiValueInputTextField($fieldContainer, 'title', _('Job title'), false, null, false, array_slice($this->titleCache, 0, 300)); |
| 1446 |
} |
| 1447 |
} |
| 1448 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) { |
| 1449 |
if ($this->isAdminReadOnly('carLicense')) { |
| 1450 |
$this->addSimpleReadOnlyField($fieldContainer, 'carLicense', _('Car license')); |
| 1451 |
} |
| 1452 |
else { |
| 1453 |
$this->addSimpleInputTextField($fieldContainer, 'carLicense', _('Car license')); |
| 1454 |
} |
| 1455 |
} |
| 1456 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) { |
| 1457 |
if ($this->isAdminReadOnly('employeeNumber')) { |
| 1458 |
$this->addSimpleReadOnlyField($fieldContainer, 'employeeNumber', _('Employee number')); |
| 1459 |
} |
| 1460 |
else { |
| 1461 |
$this->addSimpleInputTextField($fieldContainer, 'employeeNumber', _('Employee number')); |
| 1462 |
} |
| 1463 |
} |
| 1464 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 1465 |
if ($this->isAdminReadOnly('employeeType')) { |
| 1466 |
$this->addSimpleReadOnlyField($fieldContainer, 'employeeType', _('Employee type')); |
| 1467 |
} |
| 1468 |
else { |
| 1469 |
$this->addSimpleInputTextField($fieldContainer, 'employeeType', _('Employee type'), false, null, false, array_slice($this->employeeTypeCache, 0, 300)); |
| 1470 |
} |
| 1471 |
} |
| 1472 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 1473 |
if ($this->isAdminReadOnly('businessCategory')) { |
| 1474 |
$this->addSimpleReadOnlyField($fieldContainer, 'businessCategory', _('Business category')); |
| 1475 |
} |
| 1476 |
else { |
| 1477 |
$this->addMultiValueInputTextField($fieldContainer, 'businessCategory', _('Business category'), false, null, false, array_slice($this->businessCategoryCache, 0, 300)); |
| 1478 |
} |
| 1479 |
} |
| 1480 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) { |
| 1481 |
if ($this->isAdminReadOnly('departmentNumber')) { |
| 1482 |
$this->addSimpleReadOnlyField($fieldContainer, 'departmentNumber', _('Department')); |
| 1483 |
} |
| 1484 |
else { |
| 1485 |
$this->addMultiValueInputTextField($fieldContainer, 'departmentNumber', _('Department'), false, null, false, array_slice($this->departmentCache, 0, 300)); |
| 1486 |
} |
| 1487 |
} |
| 1488 |
// organisational unit |
| 1489 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) { |
| 1490 |
if ($this->isAdminReadOnly('ou')) { |
| 1491 |
$this->addSimpleReadOnlyField($fieldContainer, 'ou', _('Organisational unit')); |
| 1492 |
} |
| 1493 |
else { |
| 1494 |
$this->addMultiValueInputTextField($fieldContainer, 'ou', _('Organisational unit'), false, null, false, array_slice($this->ouCache, 0, 300)); |
| 1495 |
} |
| 1496 |
} |
| 1497 |
// organisation |
| 1498 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) { |
| 1499 |
if ($this->isAdminReadOnly('o')) { |
| 1500 |
$this->addSimpleReadOnlyField($fieldContainer, 'o', _('Organisation')); |
| 1501 |
} |
| 1502 |
else { |
| 1503 |
$this->addMultiValueInputTextField($fieldContainer, 'o', _('Organisation'), false, null, false, array_slice($this->oCache, 0, 300)); |
| 1504 |
} |
| 1505 |
} |
| 1506 |
// user certificates |
| 1507 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideuserCertificate')) { |
| 1508 |
$fieldContainer->addVerticalSpacer('0.5rem'); |
| 1509 |
$fieldContainer->addLabel(new htmlOutputText(_('User certificates'))); |
| 1510 |
$userCertificateGroup = new htmlGroup(); |
| 1511 |
$userCertificateCount = 0; |
| 1512 |
if (isset($this->attributes['userCertificate;binary'])) { |
| 1513 |
$userCertificateCount = count($this->attributes['userCertificate;binary']); |
| 1514 |
} |
| 1515 |
$userCertificateGroup->addElement(new htmlOutputText((string) $userCertificateCount)); |
| 1516 |
$userCertificateGroup->addElement(new htmlSpacer('10px', null)); |
| 1517 |
if (!$this->isAdminReadOnly('manager')) { |
| 1518 |
$userCertificateGroup->addElement(new htmlAccountPageButton(static::class, 'userCertificate', 'manage', _('Manage'))); |
| 1519 |
$userCertificateGroup->addElement(new htmlHelpLink('userCertificate')); |
| 1520 |
} |
| 1521 |
$fieldContainer->addField($userCertificateGroup); |
| 1522 |
} |
| 1523 |
// manager |
| 1524 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) { |
| 1525 |
$fieldContainer->addVerticalSpacer('0.5rem'); |
| 1526 |
$fieldContainer->addLabel(new htmlOutputText(_('Manager'))); |
| 1527 |
if (!$this->isAdminReadOnly('manager')) { |
| 1528 |
$managerButtonGroup = new htmlGroup(); |
| 1529 |
$managerButtonGroup->addElement(new htmlAccountPageButton(static::class, 'manager', 'change', _("Change"))); |
| 1530 |
$managerButtonGroup->addElement(new htmlHelpLink('manager')); |
| 1531 |
$fieldContainer->addField($managerButtonGroup); |
| 1532 |
} |
| 1533 |
if (isset($this->attributes['manager'][0])) { |
| 1534 |
$managerList = []; |
| 1535 |
for ($i = 0; $i < count($this->attributes['manager']); $i++) { |
| 1536 |
$managerList[] = $this->attributes['manager'][$i]; |
| 1537 |
} |
| 1538 |
usort($managerList, compareDN(...)); |
| 1539 |
$managers = new htmlTable(); |
| 1540 |
$managers->alignment = htmlElement::ALIGN_RIGHT; |
| 1541 |
$managers->colspan = 3; |
| 1542 |
for ($i = 0; $i < count($managerList); $i++) { |
| 1543 |
$manager = new htmlOutputText(getAbstractDN($managerList[$i])); |
| 1544 |
$manager->alignment = htmlElement::ALIGN_RIGHT; |
| 1545 |
$managers->addElement($manager, true); |
| 1546 |
} |
| 1547 |
$fieldContainer->addLabel(new htmlOutputText(' ', false)); |
| 1548 |
$fieldContainer->addField($managers); |
| 1549 |
} |
| 1550 |
} |
| 1551 |
// password buttons |
| 1552 |
if (!$this->isUnixActive() && checkIfWriteAccessIsAllowed($this->get_scope()) && isset($this->attributes['userpassword'][0]) && !$this->isAdminReadOnly('userPassword')) { |
| 1553 |
$fieldContainer->add(new htmlSubTitle(_('Password'))); |
| 1554 |
$pwdContainer = new htmlGroup(); |
| 1555 |
if (pwd_is_enabled($this->attributes['userpassword'][0])) { |
| 1556 |
$pwdContainer->addElement(new htmlButton('lockPassword', _('Lock password'))); |
| 1557 |
} |
| 1558 |
else { |
| 1559 |
$pwdContainer->addElement(new htmlButton('unlockPassword', _('Unlock password'))); |
| 1560 |
} |
| 1561 |
$pwdContainer->addElement(new htmlSpacer('0.5rem', null)); |
| 1562 |
$pwdContainer->addElement(new htmlButton('removePassword', _('Remove password'))); |
| 1563 |
$fieldContainer->add($pwdContainer, 12, 12, 12, 'text-center'); |
| 1564 |
} |
| 1565 |
// photo |
| 1566 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) { |
| 1567 |
$imageContainer = new htmlTable(); |
| 1568 |
$imageContainer->setCSSClasses(['div-center']); |
| 1569 |
$imageContainer->alignment = htmlElement::ALIGN_TOP; |
| 1570 |
$photoFile = '../../graphics/user.svg'; |
| 1571 |
$noPhoto = true; |
| 1572 |
if (isset($this->attributes['jpegPhoto'][0])) { |
| 1573 |
try { |
| 1574 |
$temporaryFilesManager = new LamTemporaryFilesManager(); |
| 1575 |
$jpeg_filename = $temporaryFilesManager->registerTemporaryFile('.jpg'); |
| 1576 |
$handle = $temporaryFilesManager->openTemporaryFileForWrite($jpeg_filename); |
| 1577 |
fwrite($handle, $this->attributes['jpegPhoto'][0]); |
| 1578 |
fclose($handle); |
| 1579 |
$photoFile = $temporaryFilesManager->getResourceLink($jpeg_filename); |
| 1580 |
} |
| 1581 |
catch (LAMException $e) { |
| 1582 |
logNewMessage(LOG_ERR, $e->getTitle()); |
| 1583 |
} |
| 1584 |
$noPhoto = false; |
| 1585 |
} |
| 1586 |
$img = new htmlImage($photoFile); |
| 1587 |
$img->setCSSClasses(['photo']); |
| 1588 |
$img->enableLightbox(); |
| 1589 |
$imageContainer->addElement($img, true); |
| 1590 |
if (!$this->isAdminReadOnly('jpegPhoto')) { |
| 1591 |
if ($noPhoto) { |
| 1592 |
$imageContainer->addElement(new htmlAccountPageButton(static::class, 'photo', 'open', _('Add photo'))); |
| 1593 |
} |
| 1594 |
else { |
| 1595 |
$imageContainer->addElement(new htmlButton('delPhoto', _('Delete photo'))); |
| 1596 |
} |
| 1597 |
} |
| 1598 |
$container->add($imageContainer, 12, 12, 4); |
| 1599 |
} |
| 1600 |
return $container; |
| 1601 |
} |
| 1602 |
|
| 1603 |
/** |
| 1604 |
* Sets a new photo. |
| 1605 |
* |
| 1606 |
* @return array<string|string[]>[] list of error messages if any |
| 1607 |
*/ |
| 1608 |
public function process_photo(): array { |
| 1609 |
if (isset($_POST['form_subpage_' . static::class . '_attributes_back'])) { |
| 1610 |
return []; |
| 1611 |
} |
| 1612 |
if ($this->isAdminReadOnly('jpegPhoto')) { |
| 1613 |
return []; |
| 1614 |
} |
| 1615 |
if (isset($_POST['form_subpage_' . static::class . '_photo_upload']) || isset($_POST['webcamData'])) { |
| 1616 |
return $this->uploadPhoto(); |
| 1617 |
} |
| 1618 |
if (isset($_POST['form_subpage_' . static::class . '_attributes_crop'])) { |
| 1619 |
$messages = []; |
| 1620 |
try { |
| 1621 |
include_once __DIR__ . '/../imageutils.inc'; |
| 1622 |
$imageManipulator = ImageManipulationFactory::getImageManipulator($this->attributes['jpegPhoto'][0]); |
| 1623 |
$scaleFactor = $imageManipulator->getWidth() / intval($_POST['croppingDataWidth']); |
| 1624 |
$imageManipulator->crop( |
| 1625 |
(int) round(intval($_POST['croppingDataX']) * $scaleFactor), |
| 1626 |
(int) round(intval($_POST['croppingDataY']) * $scaleFactor), |
| 1627 |
(int) round($_POST['croppingDataSelectionWidth'] * $scaleFactor), |
| 1628 |
(int) round($_POST['croppingDataSelectionHeight'] * $scaleFactor) |
| 1629 |
); |
| 1630 |
$this->attributes['jpegPhoto'][0] = $imageManipulator->getImageData(); |
| 1631 |
} |
| 1632 |
catch (Exception $e) { |
| 1633 |
$msg = $this->messages['file'][2]; |
| 1634 |
$msg[] = htmlspecialchars($e->getMessage()); |
| 1635 |
$messages[] = $msg; |
| 1636 |
} |
| 1637 |
return $messages; |
| 1638 |
} |
| 1639 |
return []; |
| 1640 |
} |
| 1641 |
|
| 1642 |
/** |
| 1643 |
* Uploads the photo file. |
| 1644 |
* |
| 1645 |
* @return array<string|string[]>[] error messages if any |
| 1646 |
*/ |
| 1647 |
private function uploadPhoto(): array { |
| 1648 |
$messages = []; |
| 1649 |
if ((empty($_FILES['photoFile']) || ($_FILES['photoFile']['size'] <= 0)) && empty($_POST['webcamData'])) { |
| 1650 |
$messages[] = $this->messages['file'][0]; |
| 1651 |
return $messages; |
| 1652 |
} |
| 1653 |
if (!empty($_FILES['photoFile']['tmp_name'])) { |
| 1654 |
$handle = fopen($_FILES['photoFile']['tmp_name'], "r"); |
| 1655 |
$data = fread($handle, 100000000); |
| 1656 |
fclose($handle); |
| 1657 |
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) |
| 1658 |
&& (strlen($data) > (1024 * intval($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0])))) { |
| 1659 |
$errMsg = $this->messages['file'][3]; |
| 1660 |
$errMsg[] = null; |
| 1661 |
$errMsg[] = [$this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]]; |
| 1662 |
return [$errMsg]; |
| 1663 |
} |
| 1664 |
} |
| 1665 |
elseif (isset($_POST['webcamData'])) { |
| 1666 |
$data = $_POST['webcamData']; |
| 1667 |
$data = str_replace('data:image/png;base64,', '', $data); |
| 1668 |
$data = base64_decode($data); |
| 1669 |
} |
| 1670 |
else { |
| 1671 |
return $messages; |
| 1672 |
} |
| 1673 |
// convert to JPG |
| 1674 |
try { |
| 1675 |
include_once __DIR__ . '/../imageutils.inc'; |
| 1676 |
$imageManipulator = ImageManipulationFactory::getImageManipulator($data); |
| 1677 |
// resize if maximum values specified |
| 1678 |
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0])) { |
| 1679 |
$maxWidth = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $imageManipulator->getWidth() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]; |
| 1680 |
$maxHeight = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $imageManipulator->getHeight() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]; |
| 1681 |
$imageManipulator->thumbnail($maxWidth, $maxHeight); |
| 1682 |
} |
| 1683 |
$imageManipulator->convertToJpeg(); |
| 1684 |
$data = $imageManipulator->getImageData(); |
| 1685 |
} |
| 1686 |
catch (Exception $e) { |
| 1687 |
$msg = $this->messages['file'][2]; |
| 1688 |
$msg[] = htmlspecialchars($e->getMessage()); |
| 1689 |
$messages[] = $msg; |
| 1690 |
return $messages; |
| 1691 |
} |
| 1692 |
$this->attributes['jpegPhoto'][0] = $data; |
| 1693 |
return $messages; |
| 1694 |
} |
| 1695 |
|
| 1696 |
/** |
| 1697 |
* Displays the photo upload page. |
| 1698 |
* |
| 1699 |
* @return htmlElement meta HTML code |
| 1700 |
*/ |
| 1701 |
public function display_html_photo(): htmlElement { |
| 1702 |
$container = new htmlResponsiveRow(); |
| 1703 |
if (empty($this->attributes['jpegPhoto'][0])) { |
| 1704 |
$container->add(new htmlSubTitle(_('Upload image'))); |
| 1705 |
$label = _('Photo file'); |
| 1706 |
$container->add(new htmlResponsiveInputFileUpload('photoFile', $label, 'photoUpload')); |
| 1707 |
$container->addVerticalSpacer('0.5rem'); |
| 1708 |
$container->addLabel(new htmlOutputText(' ', false)); |
| 1709 |
$container->addField(new htmlAccountPageButton(static::class, 'photo', 'upload', _('Upload'))); |
| 1710 |
$container->addVerticalSpacer('1rem'); |
| 1711 |
$webcamContent = new htmlResponsiveRow(); |
| 1712 |
$webcamContent->add(new htmlSubTitle(_('Use webcam'))); |
| 1713 |
$errorMessage = new htmlStatusMessage('ERROR', ''); |
| 1714 |
$errorMessage->setCSSClasses(['hidden', 'lam-webcam-message']); |
| 1715 |
$webcamContent->add($errorMessage); |
| 1716 |
$captureButton = new htmlButton('lam-webcam-capture', _('Start capture')); |
| 1717 |
$captureButton->setOnClick('window.lam.tools.webcam.capture(event);'); |
| 1718 |
$webcamContent->add($captureButton, 12, 12, 12, 'text-center'); |
| 1719 |
$video = new htmlVideo('lam-webcam-video'); |
| 1720 |
$video->setCSSClasses(['hidden']); |
| 1721 |
$webcamContent->add($video, 12, 12, 12, 'text-center'); |
| 1722 |
$webcamContent->addVerticalSpacer('0.5rem'); |
| 1723 |
$webcamUploadButton = new htmlButton('uploadWebcam', _('Upload')); |
| 1724 |
$webcamUploadButton->setCSSClasses(['btn-lam-webcam-upload', 'hidden']); |
| 1725 |
$webcamUploadButton->setOnClick('window.lam.tools.webcam.upload();'); |
| 1726 |
$webcamContent->add($webcamUploadButton, 12, 12, 12, 'text-center'); |
| 1727 |
$canvas = new htmlCanvas('lam-webcam-canvas'); |
| 1728 |
$canvas->setCSSClasses(['hidden']); |
| 1729 |
$webcamContent->add($canvas); |
| 1730 |
$webcamDiv = new htmlDiv('lam_webcam_div', $webcamContent, ['hidden']); |
| 1731 |
$container->add($webcamDiv); |
| 1732 |
$container->addVerticalSpacer('1rem'); |
| 1733 |
$container->add(new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back'))); |
| 1734 |
} |
| 1735 |
else { |
| 1736 |
$container->add(new htmlSubTitle(_('Crop image'))); |
| 1737 |
try { |
| 1738 |
$tempFilesManager = new LamTemporaryFilesManager(); |
| 1739 |
$jpeg_filename = $tempFilesManager->registerTemporaryFile('.jpg'); |
| 1740 |
$handle = $tempFilesManager->openTemporaryFileForWrite($jpeg_filename); |
| 1741 |
fwrite($handle, $this->attributes['jpegPhoto'][0]); |
| 1742 |
fclose($handle); |
| 1743 |
$photoFile = $tempFilesManager->getResourceLink($jpeg_filename); |
| 1744 |
$img = new htmlImage($photoFile); |
| 1745 |
$img->setCSSClasses(['photo']); |
| 1746 |
$img->enableCropping(); |
| 1747 |
$container->add($img); |
| 1748 |
} |
| 1749 |
catch (LAMException $e) { |
| 1750 |
logNewMessage(LOG_ERR, $e->getTitle()); |
| 1751 |
} |
| 1752 |
$container->addVerticalSpacer('1rem'); |
| 1753 |
$doneButton = new htmlAccountPageButton(static::class, 'attributes', 'crop', _('Done')); |
| 1754 |
$container->add($doneButton); |
| 1755 |
} |
| 1756 |
return $container; |
| 1757 |
} |
| 1758 |
|
| 1759 |
/** |
| 1760 |
* This function will create the meta HTML code to show a page to change the manager attribute. |
| 1761 |
* |
| 1762 |
* @return htmlElement HTML meta data |
| 1763 |
*/ |
| 1764 |
public function display_html_manager(): htmlElement { |
| 1765 |
$return = new htmlResponsiveRow(); |
| 1766 |
if (!isset($this->attributes['manager'])) { |
| 1767 |
$this->attributes['manager'] = []; |
| 1768 |
} |
| 1769 |
// show list of possible new managers |
| 1770 |
if (isset($_POST['form_subpage_' . static::class . '_manager_select'])) { |
| 1771 |
$return->add(new htmlSubTitle(_('Add entries'))); |
| 1772 |
$options = []; |
| 1773 |
$filter = get_ldap_filter('user'); |
| 1774 |
$entries = searchLDAPByFilter('(|' . $filter . '(objectclass=organizationalRole))', ['dn'], ['user']); |
| 1775 |
for ($i = 0; $i < count($entries); $i++) { |
| 1776 |
$entries[$i] = $entries[$i]['dn']; |
| 1777 |
} |
| 1778 |
// sort by DN |
| 1779 |
usort($entries, compareDN(...)); |
| 1780 |
for ($i = 0; $i < count($entries); $i++) { |
| 1781 |
if (!in_array($entries[$i], $this->attributes['manager'])) { |
| 1782 |
$options[getAbstractDN($entries[$i])] = $entries[$i]; |
| 1783 |
} |
| 1784 |
} |
| 1785 |
$size = 20; |
| 1786 |
if (count($options) < 20) { |
| 1787 |
$size = count($options); |
| 1788 |
} |
| 1789 |
$managerSelect = new htmlSelect('manager', $options, [], $size); |
| 1790 |
$managerSelect->setHasDescriptiveElements(true); |
| 1791 |
$managerSelect->setMultiSelect(true); |
| 1792 |
$managerSelect->setRightToLeftTextDirection(true); |
| 1793 |
$managerSelect->setSortElements(false); |
| 1794 |
$managerSelect->setTransformSingleSelect(false); |
| 1795 |
$return->add($managerSelect); |
| 1796 |
$filterGroup = new htmlGroup(); |
| 1797 |
$filterGroup->addElement(new htmlOutputText(_('Filter'))); |
| 1798 |
$filterInput = new htmlInputField('filter'); |
| 1799 |
$filterInput->filterSelectBox('manager'); |
| 1800 |
$filterInput->setCSSClasses(['max-width-10']); |
| 1801 |
$filterGroup->addElement($filterInput); |
| 1802 |
$filterGroup->addElement(new htmlHelpLink('filter')); |
| 1803 |
$return->add($filterGroup); |
| 1804 |
$return->addVerticalSpacer('1rem'); |
| 1805 |
$return->addLabel(new htmlAccountPageButton(static::class, 'manager', 'addManagers', _('Add'))); |
| 1806 |
$return->addField(new htmlAccountPageButton(static::class, 'manager', 'cancel', _('Cancel'))); |
| 1807 |
return $return; |
| 1808 |
} |
| 1809 |
$return->add(new htmlSubTitle(_('Manager'))); |
| 1810 |
// show existing managers |
| 1811 |
$managerTemp = $this->attributes['manager']; |
| 1812 |
// sort by DN |
| 1813 |
usort($managerTemp, compareDN(...)); |
| 1814 |
$managers = []; |
| 1815 |
for ($i = 0; $i < count($managerTemp); $i++) { |
| 1816 |
$managers[getAbstractDN($managerTemp[$i])] = $managerTemp[$i]; |
| 1817 |
} |
| 1818 |
$size = 20; |
| 1819 |
if (count($this->attributes['manager']) < 20) { |
| 1820 |
$size = count($this->attributes['manager']); |
| 1821 |
} |
| 1822 |
if ($managers !== []) { |
| 1823 |
$managerSelect = new htmlSelect('manager', $managers, [], $size); |
| 1824 |
$managerSelect->setHasDescriptiveElements(true); |
| 1825 |
$managerSelect->setMultiSelect(true); |
| 1826 |
$managerSelect->setRightToLeftTextDirection(true); |
| 1827 |
$managerSelect->setSortElements(false); |
| 1828 |
$managerSelect->setTransformSingleSelect(false); |
| 1829 |
$return->add($managerSelect); |
| 1830 |
$return->addVerticalSpacer('0.5rem'); |
| 1831 |
$removeButton = new htmlAccountPageButton(static::class, 'manager', 'remove', _('Remove selected entries')); |
| 1832 |
$return->add($removeButton, 12, 12, 12, 'text-center'); |
| 1833 |
$return->addVerticalSpacer('1rem'); |
| 1834 |
$return->add(new htmlHorizontalLine()); |
| 1835 |
} |
| 1836 |
$return->addVerticalSpacer('1rem'); |
| 1837 |
$return->addLabel(new htmlAccountPageButton(static::class, 'manager', 'select', _('Add entries'))); |
| 1838 |
$return->addField(new htmlAccountPageButton(static::class, 'attributes', 'managerBack', _('Back'))); |
| 1839 |
return $return; |
| 1840 |
} |
| 1841 |
|
| 1842 |
/** |
| 1843 |
* Processes user input of the manager page. |
| 1844 |
* It checks if all input values are correct and updates the associated LDAP attributes. |
| 1845 |
* |
| 1846 |
* @return array<string|string[]>[] list of info/error messages |
| 1847 |
*/ |
| 1848 |
public function process_manager(): array { |
| 1849 |
$return = []; |
| 1850 |
if ($this->isAdminReadOnly('manager')) { |
| 1851 |
return $return; |
| 1852 |
} |
| 1853 |
if (isset($_POST['form_subpage_' . static::class . '_manager_remove']) && isset($_POST['manager'])) { |
| 1854 |
$managers = array_flip($this->attributes['manager']); |
| 1855 |
for ($i = 0; $i < count($_POST['manager']); $i++) { |
| 1856 |
if (isset($managers[$_POST['manager'][$i]])) { |
| 1857 |
unset($managers[$_POST['manager'][$i]]); |
| 1858 |
} |
| 1859 |
} |
| 1860 |
$this->attributes['manager'] = array_values(array_flip($managers)); |
| 1861 |
} |
| 1862 |
elseif (isset($_POST['form_subpage_' . static::class . '_manager_addManagers']) && isset($_POST['manager'])) { |
| 1863 |
for ($i = 0; $i < count($_POST['manager']); $i++) { |
| 1864 |
$this->attributes['manager'][] = $_POST['manager'][$i]; |
| 1865 |
$this->attributes['manager'] = array_unique($this->attributes['manager']); |
| 1866 |
} |
| 1867 |
} |
| 1868 |
return $return; |
| 1869 |
} |
| 1870 |
|
| 1871 |
/** |
| 1872 |
* Displays the certificate upload page. |
| 1873 |
* |
| 1874 |
* @return htmlElement meta HTML code |
| 1875 |
*/ |
| 1876 |
public function display_html_userCertificate(): htmlElement { |
| 1877 |
$container = new htmlResponsiveRow(); |
| 1878 |
if (isset($this->attributes['userCertificate;binary'])) { |
| 1879 |
$table = new htmlTable(); |
| 1880 |
$table->colspan = 10; |
| 1881 |
$temFilesManager = new LamTemporaryFilesManager(); |
| 1882 |
for ($i = 0; $i < count($this->attributes['userCertificate;binary']); $i++) { |
| 1883 |
$filename = $temFilesManager->registerTemporaryFile('.der'); |
| 1884 |
$out = $temFilesManager->openTemporaryFileForWrite($filename); |
| 1885 |
fwrite($out, $this->attributes['userCertificate;binary'][$i]); |
| 1886 |
fclose($out); |
| 1887 |
$path = $temFilesManager->getDownloadLink($filename); |
| 1888 |
$link = new htmlLink('', $path, '../../graphics/save.svg'); |
| 1889 |
$link->setTargetWindow('_blank'); |
| 1890 |
$link->setCSSClasses(['icon']); |
| 1891 |
$table->addElement($link); |
| 1892 |
$deleteButton = new htmlAccountPageButton(static::class, 'userCertificate', 'delete_' . $i, 'del.svg', true); |
| 1893 |
$table->addElement($deleteButton); |
| 1894 |
$pem = @chunk_split(@base64_encode($this->attributes['userCertificate;binary'][$i]), 64, "\n"); |
| 1895 |
if (!empty($pem)) { |
| 1896 |
$pem = "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n"; |
| 1897 |
$pemData = @openssl_x509_parse($pem); |
| 1898 |
$data = []; |
| 1899 |
if (isset($pemData['serialNumber'])) { |
| 1900 |
$data[] = $pemData['serialNumber']; |
| 1901 |
} |
| 1902 |
if (isset($pemData['name'])) { |
| 1903 |
$data[] = $pemData['name']; |
| 1904 |
} |
| 1905 |
if ($data !== []) { |
| 1906 |
$table->addElement(new htmlOutputText(implode(': ', $data))); |
| 1907 |
} |
| 1908 |
} |
| 1909 |
$table->addNewLine(); |
| 1910 |
} |
| 1911 |
$container->add($table); |
| 1912 |
$container->addVerticalSpacer('2rem'); |
| 1913 |
} |
| 1914 |
$container->add(new htmlResponsiveInputFileUpload('userCertificateUpload', _('New user certificate')), 12, 6); |
| 1915 |
|
| 1916 |
$uploadButton = new htmlAccountPageButton(static::class, 'userCertificate', 'submit', _('Upload')); |
| 1917 |
$container->add($uploadButton, 12, 6); |
| 1918 |
$container->addVerticalSpacer('2rem'); |
| 1919 |
$container->add(new htmlAccountPageButton(static::class, 'attributes', 'back', _('Back'))); |
| 1920 |
return $container; |
| 1921 |
} |
| 1922 |
|
| 1923 |
/** |
| 1924 |
* Sets a new certificate or deletes old ones. |
| 1925 |
* |
| 1926 |
* @return array<string|string[]>[] list of info/error messages |
| 1927 |
*/ |
| 1928 |
public function process_userCertificate(): array { |
| 1929 |
$messages = []; |
| 1930 |
if ($this->isAdminReadOnly('userCertificate')) { |
| 1931 |
return $messages; |
| 1932 |
} |
| 1933 |
if (isset($_POST['form_subpage_' . static::class . '_userCertificate_submit'])) { |
| 1934 |
if ($_FILES['userCertificateUpload'] && ($_FILES['userCertificateUpload']['size'] > 0)) { |
| 1935 |
$handle = fopen($_FILES['userCertificateUpload']['tmp_name'], "r"); |
| 1936 |
$data = fread($handle, 10000000); |
| 1937 |
fclose($handle); |
| 1938 |
if (str_starts_with($data, '-----BEGIN CERTIFICATE-----')) { |
| 1939 |
$pemData = str_replace("\r", '', $data); |
| 1940 |
$pemData = explode("\n", $pemData); |
| 1941 |
array_shift($pemData); |
| 1942 |
$last = array_pop($pemData); |
| 1943 |
while (($last != '-----END CERTIFICATE-----') && (count($pemData) > 2)) { |
| 1944 |
$last = array_pop($pemData); |
| 1945 |
} |
| 1946 |
$pemData = implode('', $pemData); |
| 1947 |
$data = base64_decode($pemData); |
| 1948 |
} |
| 1949 |
$this->attributes['userCertificate;binary'][] = $data; |
| 1950 |
} |
| 1951 |
else { |
| 1952 |
$messages[] = $this->messages['file'][0]; |
| 1953 |
} |
| 1954 |
} |
| 1955 |
elseif (isset($this->attributes['userCertificate;binary'])) { |
| 1956 |
for ($i = 0; $i < count($this->attributes['userCertificate;binary']); $i++) { |
| 1957 |
if (isset($_POST['form_subpage_' . static::class . '_userCertificate_delete_' . $i])) { |
| 1958 |
unset($this->attributes['userCertificate;binary'][$i]); |
| 1959 |
$this->attributes['userCertificate;binary'] = array_values($this->attributes['userCertificate;binary']); |
| 1960 |
break; |
| 1961 |
} |
| 1962 |
} |
| 1963 |
} |
| 1964 |
return $messages; |
| 1965 |
} |
| 1966 |
|
| 1967 |
/** |
| 1968 |
* {@inheritDoc} |
| 1969 |
*/ |
| 1970 |
public function get_pdfFields(string $typeId): array { |
| 1971 |
$fields = parent::get_pdfFields($typeId); |
| 1972 |
$typeManager = new TypeManager(); |
| 1973 |
$modules = $typeManager->getConfiguredType($typeId)->getModules(); |
| 1974 |
if (!$this->isUnixActive($modules)) { |
| 1975 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) { |
| 1976 |
$fields['uid'] = _('User name'); |
| 1977 |
} |
| 1978 |
$fields['cn'] = _('Common name'); |
| 1979 |
$fields['userPassword'] = _('Password'); |
| 1980 |
} |
| 1981 |
if (!$this->isSamba3Active($modules) |
| 1982 |
&& !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) { |
| 1983 |
$fields['displayName'] = _('Display name'); |
| 1984 |
} |
| 1985 |
return $fields; |
| 1986 |
} |
| 1987 |
|
| 1988 |
/** |
| 1989 |
* {@inheritDoc} |
| 1990 |
*/ |
| 1991 |
public function get_pdfEntries(array $pdfKeys, string $typeId): array { |
| 1992 |
$return = []; |
| 1993 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { |
| 1994 |
$this->addSimplePDFField($return, 'description', _('Description')); |
| 1995 |
} |
| 1996 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 1997 |
$this->addSimplePDFField($return, 'title', _('Job title')); |
| 1998 |
} |
| 1999 |
$this->addSimplePDFField($return, 'givenName', _('First name')); |
| 2000 |
$this->addSimplePDFField($return, 'sn', _('Last name')); |
| 2001 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) { |
| 2002 |
$this->addSimplePDFField($return, 'manager', _('Manager')); |
| 2003 |
} |
| 2004 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) { |
| 2005 |
$this->addSimplePDFField($return, 'street', _('Street')); |
| 2006 |
} |
| 2007 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) { |
| 2008 |
$this->addSimplePDFField($return, 'postOfficeBox', _('Post office box')); |
| 2009 |
} |
| 2010 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) { |
| 2011 |
$this->addSimplePDFField($return, 'postalCode', _('Postal code')); |
| 2012 |
} |
| 2013 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress') |
| 2014 |
&& !empty($this->attributes['postalAddress'])) { |
| 2015 |
$this->addPDFKeyValue($return, 'postalAddress', _('Postal address'), str_replace('$', "\n", implode("\n\n", $this->attributes['postalAddress']))); |
| 2016 |
} |
| 2017 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 2018 |
$this->addSimplePDFField($return, 'registeredAddress', _('Registered address')); |
| 2019 |
} |
| 2020 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { |
| 2021 |
$this->addSimplePDFField($return, 'telephoneNumber', _('Telephone number')); |
| 2022 |
} |
| 2023 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { |
| 2024 |
$this->addSimplePDFField($return, 'homePhone', _('Home telephone number')); |
| 2025 |
} |
| 2026 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) { |
| 2027 |
$this->addSimplePDFField($return, 'mobileTelephoneNumber', _('Mobile number'), 'mobile'); |
| 2028 |
} |
| 2029 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) { |
| 2030 |
$this->addSimplePDFField($return, 'pager', _('Pager')); |
| 2031 |
} |
| 2032 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) { |
| 2033 |
$this->addSimplePDFField($return, 'mail', _('Email address')); |
| 2034 |
} |
| 2035 |
$this->addSimplePDFField($return, 'cn', _('Common name')); |
| 2036 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) { |
| 2037 |
$this->addSimplePDFField($return, 'facsimileTelephoneNumber', _('Fax number')); |
| 2038 |
} |
| 2039 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) { |
| 2040 |
$this->addSimplePDFField($return, 'roomNumber', _('Room number')); |
| 2041 |
} |
| 2042 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 2043 |
$this->addSimplePDFField($return, 'businessCategory', _('Business category')); |
| 2044 |
} |
| 2045 |
$this->addSimplePDFField($return, 'uid', _('User name')); |
| 2046 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) { |
| 2047 |
$this->addSimplePDFField($return, 'carLicense', _('Car license')); |
| 2048 |
} |
| 2049 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) { |
| 2050 |
$this->addSimplePDFField($return, 'state', _('State'), 'st'); |
| 2051 |
} |
| 2052 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) { |
| 2053 |
$this->addSimplePDFField($return, 'officeName', _('Office name'), 'physicalDeliveryOfficeName'); |
| 2054 |
} |
| 2055 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 2056 |
$this->addSimplePDFField($return, 'employeeType', _('Employee type')); |
| 2057 |
} |
| 2058 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) { |
| 2059 |
$this->addSimplePDFField($return, 'location', _('Location'), 'l'); |
| 2060 |
} |
| 2061 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) { |
| 2062 |
$this->addSimplePDFField($return, 'employeeNumber', _('Employee number')); |
| 2063 |
} |
| 2064 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) { |
| 2065 |
$this->addSimplePDFField($return, 'ou', _('Organisational unit')); |
| 2066 |
} |
| 2067 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) { |
| 2068 |
$this->addSimplePDFField($return, 'o', _('Organisation')); |
| 2069 |
} |
| 2070 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) { |
| 2071 |
$this->addSimplePDFField($return, 'initials', _('Initials')); |
| 2072 |
} |
| 2073 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) { |
| 2074 |
$this->addSimplePDFField($return, 'labeledURI', _('Web site')); |
| 2075 |
} |
| 2076 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) { |
| 2077 |
$this->addSimplePDFField($return, 'departmentNumber', _('Department')); |
| 2078 |
} |
| 2079 |
$this->addSimplePDFField($return, 'displayName', _('Display name')); |
| 2080 |
if ($this->clearTextPassword !== null) { |
| 2081 |
$this->addPDFKeyValue($return, 'userPassword', _('Password'), $this->clearTextPassword); |
| 2082 |
} |
| 2083 |
elseif (isset($this->attributes['INFO.userPasswordClearText'])) { |
| 2084 |
$this->addPDFKeyValue($return, 'userPassword', _('Password'), $this->attributes['INFO.userPasswordClearText']); |
| 2085 |
} |
| 2086 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) { |
| 2087 |
$this->addPDFImage($return, 'jpegPhoto'); |
| 2088 |
} |
| 2089 |
return $return; |
| 2090 |
} |
| 2091 |
|
| 2092 |
/** |
| 2093 |
* {@inheritDoc} |
| 2094 |
*/ |
| 2095 |
public function get_profileOptions(string $typeId): ?htmlResponsiveRow { |
| 2096 |
$typeManager = new TypeManager(); |
| 2097 |
$modules = $typeManager->getConfiguredType($typeId)->getModules(); |
| 2098 |
$profileElements = []; |
| 2099 |
if (!$this->isUnixActive($modules)) { |
| 2100 |
$profileElements[] = new htmlResponsiveInputField(_('User name'), 'inetOrgPerson_uid', null, 'uid'); |
| 2101 |
} |
| 2102 |
if (!$this->isUnixActive($modules)) { |
| 2103 |
$profileElements[] = new htmlResponsiveInputField(_('Common name'), 'inetOrgPerson_cn', null, 'cn'); |
| 2104 |
} |
| 2105 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) { |
| 2106 |
$profileElements[] = new htmlResponsiveInputField(_('Initials'), 'inetOrgPerson_initials', null, 'initials'); |
| 2107 |
} |
| 2108 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) { |
| 2109 |
$profileElements[] = new htmlResponsiveInputField(_('Description'), 'inetOrgPerson_description', null, 'description'); |
| 2110 |
} |
| 2111 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) { |
| 2112 |
$profileElements[] = new htmlResponsiveInputField(_('Street'), 'inetOrgPerson_street', null, 'streetList'); |
| 2113 |
} |
| 2114 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) { |
| 2115 |
$profileElements[] = new htmlResponsiveInputField(_('Post office box'), 'inetOrgPerson_postOfficeBox', null, 'postOfficeBoxList'); |
| 2116 |
} |
| 2117 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) { |
| 2118 |
$profileElements[] = new htmlResponsiveInputField(_('Postal code'), 'inetOrgPerson_postalCode', null, 'postalCodeList'); |
| 2119 |
} |
| 2120 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) { |
| 2121 |
$profileElements[] = new htmlResponsiveInputField(_('Location'), 'inetOrgPerson_l', null, 'lList'); |
| 2122 |
} |
| 2123 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) { |
| 2124 |
$profileElements[] = new htmlResponsiveInputField(_('State'), 'inetOrgPerson_st', null, 'stList'); |
| 2125 |
} |
| 2126 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) { |
| 2127 |
$profileElements[] = new htmlResponsiveInputField(_('Postal address'), 'inetOrgPerson_postalAddress', null, 'postalAddress'); |
| 2128 |
} |
| 2129 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) { |
| 2130 |
$profileElements[] = new htmlResponsiveInputField(_('Registered address'), 'inetOrgPerson_registeredAddress', null, 'registeredAddress'); |
| 2131 |
} |
| 2132 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) { |
| 2133 |
$profileElements[] = new htmlResponsiveInputField(_('Office name'), 'inetOrgPerson_physicalDeliveryOfficeName', null, 'physicalDeliveryOfficeName'); |
| 2134 |
} |
| 2135 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) { |
| 2136 |
$profileElements[] = new htmlResponsiveInputField(_('Room number'), 'inetOrgPerson_roomNumber', null, 'roomNumber'); |
| 2137 |
} |
| 2138 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { |
| 2139 |
$profileElements[] = new htmlResponsiveInputField(_('Telephone number'), 'inetOrgPerson_telephoneNumber', null, 'telephoneNumberList'); |
| 2140 |
} |
| 2141 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) { |
| 2142 |
$profileElements[] = new htmlResponsiveInputField(_('Fax number'), 'inetOrgPerson_facsimileTelephoneNumber', null, 'facsimileTelephoneNumberList'); |
| 2143 |
} |
| 2144 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) { |
| 2145 |
$profileElements[] = new htmlResponsiveInputField(_('Email address'), 'inetOrgPerson_mail', null, 'mailList'); |
| 2146 |
} |
| 2147 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) { |
| 2148 |
$profileElements[] = new htmlResponsiveInputField(_('Web site'), 'inetOrgPerson_labeledURI', null, 'labeledURIList'); |
| 2149 |
} |
| 2150 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) { |
| 2151 |
$profileElements[] = new htmlResponsiveInputField(_('Department'), 'inetOrgPerson_departmentNumber', null, 'departmentNumberList'); |
| 2152 |
} |
| 2153 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) { |
| 2154 |
$profileElements[] = new htmlResponsiveInputField(_('Organisational unit'), 'inetOrgPerson_ou', null, 'ouList'); |
| 2155 |
} |
| 2156 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) { |
| 2157 |
$profileElements[] = new htmlResponsiveInputField(_('Organisation'), 'inetOrgPerson_o', null, 'oList'); |
| 2158 |
} |
| 2159 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 2160 |
$profileElements[] = new htmlResponsiveInputField(_('Job title'), 'inetOrgPerson_title', null, 'title'); |
| 2161 |
} |
| 2162 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 2163 |
$profileElements[] = new htmlResponsiveInputField(_('Employee type'), 'inetOrgPerson_employeeType', null, 'employeeType'); |
| 2164 |
} |
| 2165 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 2166 |
$profileElements[] = new htmlResponsiveInputField(_('Business category'), 'inetOrgPerson_businessCategory', null, 'businessCategory'); |
| 2167 |
} |
| 2168 |
if ($profileElements !== []) { |
| 2169 |
$profileContainer = new htmlResponsiveRow(); |
| 2170 |
for ($i = 0; $i < count($profileElements); $i++) { |
| 2171 |
$profileContainer->add($profileElements[$i]); |
| 2172 |
} |
| 2173 |
return $profileContainer; |
| 2174 |
} |
| 2175 |
return null; |
| 2176 |
} |
| 2177 |
|
| 2178 |
/** |
| 2179 |
* {@inheritDoc} |
| 2180 |
*/ |
| 2181 |
public function load_profile(array $profile): void { |
| 2182 |
// profile mappings in meta data |
| 2183 |
parent::load_profile($profile); |
| 2184 |
if (!$this->isUnixActive() && !empty($profile['inetOrgPerson_uid'][0])) { |
| 2185 |
$this->attributes['uid'][0] = $profile['inetOrgPerson_uid'][0]; |
| 2186 |
} |
| 2187 |
if (!$this->isUnixActive() && !empty($profile['inetOrgPerson_cn'][0])) { |
| 2188 |
$this->attributes['cn'][0] = $profile['inetOrgPerson_cn'][0]; |
| 2189 |
} |
| 2190 |
// departments |
| 2191 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments') |
| 2192 |
&& isset($profile['inetOrgPerson_departmentNumber'][0]) |
| 2193 |
&& ($profile['inetOrgPerson_departmentNumber'][0] != '')) { |
| 2194 |
$departments = explode(';', $profile['inetOrgPerson_departmentNumber'][0]); |
| 2195 |
// remove extra spaces and set attributes |
| 2196 |
$this->attributes['departmentNumber'] = array_map(trim(...), $departments); |
| 2197 |
} |
| 2198 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu') && isset($profile['inetOrgPerson_ou'][0])) { |
| 2199 |
$oList = preg_split('/;[ ]*/', $profile['inetOrgPerson_ou'][0]); |
| 2200 |
$this->attributes['ou'] = $oList; |
| 2201 |
} |
| 2202 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO') && isset($profile['inetOrgPerson_o'][0])) { |
| 2203 |
$oList = preg_split('/;[ ]*/', $profile['inetOrgPerson_o'][0]); |
| 2204 |
$this->attributes['o'] = $oList; |
| 2205 |
} |
| 2206 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress') && isset($profile['inetOrgPerson_mail'][0])) { |
| 2207 |
$mailList = preg_split('/;[ ]*/', $profile['inetOrgPerson_mail'][0]); |
| 2208 |
$this->attributes['mail'] = $mailList; |
| 2209 |
} |
| 2210 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI') && isset($profile['inetOrgPerson_labeledURI'][0])) { |
| 2211 |
$labeledURIList = preg_split('/;[ ]*/', $profile['inetOrgPerson_labeledURI'][0]); |
| 2212 |
$this->attributes['labeledURI'] = $labeledURIList; |
| 2213 |
} |
| 2214 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber') && isset($profile['inetOrgPerson_telephoneNumber'][0])) { |
| 2215 |
$telephoneNumberList = preg_split('/;[ ]*/', $profile['inetOrgPerson_telephoneNumber'][0]); |
| 2216 |
$this->attributes['telephoneNumber'] = $telephoneNumberList; |
| 2217 |
} |
| 2218 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber') && isset($profile['inetOrgPerson_facsimileTelephoneNumber'][0])) { |
| 2219 |
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', $profile['inetOrgPerson_facsimileTelephoneNumber'][0]); |
| 2220 |
$this->attributes['facsimileTelephoneNumber'] = $facsimileTelephoneNumberList; |
| 2221 |
} |
| 2222 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') && isset($profile['inetOrgPerson_street'][0])) { |
| 2223 |
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_street'][0]); |
| 2224 |
$this->attributes['street'] = $list; |
| 2225 |
} |
| 2226 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox') && isset($profile['inetOrgPerson_postOfficeBox'][0])) { |
| 2227 |
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_postOfficeBox'][0]); |
| 2228 |
$this->attributes['postOfficeBox'] = $list; |
| 2229 |
} |
| 2230 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') && isset($profile['inetOrgPerson_postalCode'][0])) { |
| 2231 |
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_postalCode'][0]); |
| 2232 |
$this->attributes['postalCode'] = $list; |
| 2233 |
} |
| 2234 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation') && isset($profile['inetOrgPerson_l'][0])) { |
| 2235 |
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_l'][0]); |
| 2236 |
$this->attributes['l'] = $list; |
| 2237 |
} |
| 2238 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') && isset($profile['inetOrgPerson_st'][0])) { |
| 2239 |
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_st'][0]); |
| 2240 |
$this->attributes['st'] = $list; |
| 2241 |
} |
| 2242 |
} |
| 2243 |
|
| 2244 |
/** |
| 2245 |
* {@inheritDoc} |
| 2246 |
*/ |
| 2247 |
public function check_profileOptions(array $options, string $typeId): array { |
| 2248 |
$messages = parent::check_profileOptions($options, $typeId); |
| 2249 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) { |
| 2250 |
$telephoneNumberList = preg_split('/;[ ]*/', $options['inetOrgPerson_telephoneNumber'][0]); |
| 2251 |
for ($i = 0; $i < count($telephoneNumberList); $i++) { |
| 2252 |
if (!get_preg($telephoneNumberList[$i], 'telephone')) { |
| 2253 |
$messages[] = $this->messages['telephoneNumber'][0]; |
| 2254 |
break; |
| 2255 |
} |
| 2256 |
} |
| 2257 |
} |
| 2258 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) { |
| 2259 |
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', $options['inetOrgPerson_facsimileTelephoneNumber'][0]); |
| 2260 |
for ($i = 0; $i < count($facsimileTelephoneNumberList); $i++) { |
| 2261 |
if (!get_preg($facsimileTelephoneNumberList[$i], 'telephone')) { |
| 2262 |
$messages[] = $this->messages['facsimileTelephoneNumber'][0]; |
| 2263 |
break; |
| 2264 |
} |
| 2265 |
} |
| 2266 |
} |
| 2267 |
return $messages; |
| 2268 |
} |
| 2269 |
|
| 2270 |
/** |
| 2271 |
* {@inheritDoc} |
| 2272 |
*/ |
| 2273 |
public function get_uploadColumns(array $selectedModules, ConfiguredType $type): array { |
| 2274 |
$return = parent::get_uploadColumns($selectedModules, $type); |
| 2275 |
// cn and uid for upload (only if posixAccount is not selected) |
| 2276 |
if (!$this->isUnixActive($selectedModules)) { |
| 2277 |
$return[] = [ |
| 2278 |
'name' => 'inetOrgPerson_cn', |
| 2279 |
'description' => _('Common name'), |
| 2280 |
'help' => 'cn', |
| 2281 |
'example' => _('Steve Miller'), |
| 2282 |
'default' => '{inetOrgPerson_firstName} {inetOrgPerson_lastName}' |
| 2283 |
]; |
| 2284 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) { |
| 2285 |
$return[] = [ |
| 2286 |
'name' => 'inetOrgPerson_userName', |
| 2287 |
'description' => _('User name'), |
| 2288 |
'help' => 'uid', |
| 2289 |
'example' => _('smiller'), |
| 2290 |
'unique' => true, |
| 2291 |
'required' => false |
| 2292 |
]; |
| 2293 |
} |
| 2294 |
$return[] = [ |
| 2295 |
'name' => 'inetOrgPerson_userPassword', |
| 2296 |
'description' => _('Password'), |
| 2297 |
'help' => 'userPassword', |
| 2298 |
'example' => _('secret'), |
| 2299 |
]; |
| 2300 |
$return[] = [ |
| 2301 |
'name' => 'inetOrgPerson_passwordDisabled', |
| 2302 |
'description' => _('Lock password'), |
| 2303 |
'help' => 'userPassword_lock', |
| 2304 |
'example' => 'false', |
| 2305 |
'values' => 'true, false', |
| 2306 |
'default' => 'false' |
| 2307 |
]; |
| 2308 |
} |
| 2309 |
if (!$this->isSamba3Active() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) { |
| 2310 |
$return[] = [ |
| 2311 |
'name' => 'inetOrgPerson_displayName', |
| 2312 |
'description' => _('Display name'), |
| 2313 |
'help' => 'displayName', |
| 2314 |
'example' => _('Steve Miller'), |
| 2315 |
]; |
| 2316 |
} |
| 2317 |
return $return; |
| 2318 |
} |
| 2319 |
|
| 2320 |
/** |
| 2321 |
* {@inheritDoc} |
| 2322 |
*/ |
| 2323 |
public function build_uploadAccounts(array $rawAccounts, array $ids, array &$partialAccounts, array $selectedModules, ConfiguredType &$type): array { |
| 2324 |
$errors = []; |
| 2325 |
// get list of existing users |
| 2326 |
$existingUsers = searchLDAPByAttribute('uid', '*', 'inetOrgPerson', ['uid'], ['user']); |
| 2327 |
for ($e = 0; $e < count($existingUsers); $e++) { |
| 2328 |
$existingUsers[$e] = $existingUsers[$e]['uid'][0]; |
| 2329 |
} |
| 2330 |
$existingMails = searchLDAPByAttribute('mail', '*', 'inetOrgPerson', ['mail'], ['user']); |
| 2331 |
for ($e = 0; $e < count($existingMails); $e++) { |
| 2332 |
$existingMails[$e] = $existingMails[$e]['mail'][0]; |
| 2333 |
} |
| 2334 |
for ($i = 0; $i < count($rawAccounts); $i++) { |
| 2335 |
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) { |
| 2336 |
$partialAccounts[$i]['objectClass'][] = "inetOrgPerson"; |
| 2337 |
} |
| 2338 |
// last name |
| 2339 |
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_lastName']], 'realname')) { |
| 2340 |
$partialAccounts[$i]['sn'] = trim($rawAccounts[$i][$ids['inetOrgPerson_lastName']]); |
| 2341 |
} |
| 2342 |
else { |
| 2343 |
$errMsg = $this->messages['lastname'][1]; |
| 2344 |
$errMsg[] = [$i]; |
| 2345 |
$errors[] = $errMsg; |
| 2346 |
} |
| 2347 |
// first name |
| 2348 |
if ($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") { |
| 2349 |
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_firstName']], 'realname')) { |
| 2350 |
$partialAccounts[$i]['givenName'] = trim($rawAccounts[$i][$ids['inetOrgPerson_firstName']]); |
| 2351 |
} |
| 2352 |
else { |
| 2353 |
$errMsg = $this->messages['givenName'][1]; |
| 2354 |
$errMsg[] = [$i]; |
| 2355 |
$errors[] = $errMsg; |
| 2356 |
} |
| 2357 |
} |
| 2358 |
// uid |
| 2359 |
if (!$this->isUnixActive($selectedModules) |
| 2360 |
&& isset($ids['inetOrgPerson_userName']) |
| 2361 |
&& !empty($rawAccounts[$i][$ids['inetOrgPerson_userName']])) { |
| 2362 |
if (in_array($rawAccounts[$i][$ids['inetOrgPerson_userName']], $existingUsers)) { |
| 2363 |
$errMsg = $this->messages['uid'][3]; |
| 2364 |
$errMsg[] = [$i]; |
| 2365 |
$errors[] = $errMsg; |
| 2366 |
} |
| 2367 |
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_userName']], 'username')) { |
| 2368 |
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['inetOrgPerson_userName']]; |
| 2369 |
} |
| 2370 |
else { |
| 2371 |
$errMsg = $this->messages['uid'][1]; |
| 2372 |
$errMsg[] = [$i]; |
| 2373 |
$errors[] = $errMsg; |
| 2374 |
} |
| 2375 |
} |
| 2376 |
// initials |
| 2377 |
if (isset($ids['inetOrgPerson_initials']) && ($rawAccounts[$i][$ids['inetOrgPerson_initials']] != "")) { |
| 2378 |
$partialAccounts[$i]['initials'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_initials']]); |
| 2379 |
} |
| 2380 |
// display name |
| 2381 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_displayName', 'displayName'); |
| 2382 |
// description |
| 2383 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_description', |
| 2384 |
'description', null, [], $errors, '/;[ ]*/'); |
| 2385 |
// title |
| 2386 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_title', |
| 2387 |
'title', 'title', $this->messages['title'][1], $errors, '/;[ ]*/'); |
| 2388 |
// employee number |
| 2389 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_employeeNumber', 'employeeNumber'); |
| 2390 |
// employee type |
| 2391 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_type', 'employeeType', |
| 2392 |
'employeeType', $this->messages['employeeType'][1], $errors); |
| 2393 |
// business category |
| 2394 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_businessCategory', |
| 2395 |
'businessCategory', 'businessCategory', $this->messages['businessCategory'][1], $errors, '/;[ ]*/'); |
| 2396 |
// manager |
| 2397 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_manager', |
| 2398 |
'manager', 'dn', $this->messages['manager'][0], $errors, '/;[ ]*/'); |
| 2399 |
// street |
| 2400 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_street', |
| 2401 |
'street', 'street', $this->messages['street'][1], $errors, '/;[ ]*/'); |
| 2402 |
// post office box |
| 2403 |
if (isset($ids['inetOrgPerson_postOfficeBox']) && ($rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']] != "")) { |
| 2404 |
$partialAccounts[$i]['postOfficeBox'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']]); |
| 2405 |
} |
| 2406 |
// room number |
| 2407 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_roomNumber', 'roomNumber'); |
| 2408 |
// departments |
| 2409 |
if (isset($ids['inetOrgPerson_departmentNumber']) && ($rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']] != "")) { |
| 2410 |
$partialAccounts[$i]['departmentNumber'] = explode(';', $rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']]); |
| 2411 |
// remove extra spaces |
| 2412 |
$partialAccounts[$i]['departmentNumber'] = array_map(trim(...), $partialAccounts[$i]['departmentNumber']); |
| 2413 |
} |
| 2414 |
// organisational unit |
| 2415 |
if (isset($ids['inetOrgPerson_ou']) && ($rawAccounts[$i][$ids['inetOrgPerson_ou']] != "")) { |
| 2416 |
$partialAccounts[$i]['ou'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_ou']]); |
| 2417 |
} |
| 2418 |
// organisation |
| 2419 |
if (isset($ids['inetOrgPerson_o']) && ($rawAccounts[$i][$ids['inetOrgPerson_o']] != "")) { |
| 2420 |
$partialAccounts[$i]['o'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_o']]); |
| 2421 |
} |
| 2422 |
// location |
| 2423 |
if (isset($ids['inetOrgPerson_l']) && ($rawAccounts[$i][$ids['inetOrgPerson_l']] != "")) { |
| 2424 |
$partialAccounts[$i]['l'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_l']]); |
| 2425 |
} |
| 2426 |
// state |
| 2427 |
if (isset($ids['inetOrgPerson_st']) && ($rawAccounts[$i][$ids['inetOrgPerson_st']] != "")) { |
| 2428 |
$partialAccounts[$i]['st'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_st']]); |
| 2429 |
} |
| 2430 |
// physicalDeliveryOfficeName |
| 2431 |
if (isset($ids['inetOrgPerson_physicalDeliveryOfficeName']) && ($rawAccounts[$i][$ids['inetOrgPerson_physicalDeliveryOfficeName']] != "")) { |
| 2432 |
$partialAccounts[$i]['physicalDeliveryOfficeName'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_physicalDeliveryOfficeName']]); |
| 2433 |
} |
| 2434 |
// carLicense |
| 2435 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_carLicense', 'carLicense'); |
| 2436 |
// postal code |
| 2437 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_postalCode', 'postalCode', 'postalCode', $this->messages['postalCode'][1], $errors, '/;[ ]*/'); |
| 2438 |
// postal address |
| 2439 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_address', 'postalAddress', |
| 2440 |
'postalAddress', $this->messages['postalAddress'][1], $errors); |
| 2441 |
// registered address |
| 2442 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_registeredAddress', 'registeredAddress', |
| 2443 |
'postalAddress', $this->messages['registeredAddress'][1], $errors); |
| 2444 |
// telephone |
| 2445 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_telephone', 'telephoneNumber', 'telephone', $this->messages['telephoneNumber'][1], $errors, '/;[ ]*/'); |
| 2446 |
// home telephone |
| 2447 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_homePhone', 'homePhone', 'telephone', $this->messages['homePhone'][1], $errors, '/;[ ]*/'); |
| 2448 |
// mobile |
| 2449 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_mobile', 'mobile', 'telephone', $this->messages['mobileTelephone'][1], $errors, '/;[ ]*/'); |
| 2450 |
// facsimile |
| 2451 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_fax', 'facsimileTelephoneNumber', 'telephone', $this->messages['facsimileNumber'][1], $errors, '/;[ ]*/'); |
| 2452 |
// pager |
| 2453 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_pager', 'pager', 'telephone', $this->messages['pager'][1], $errors, '/;[ ]*/'); |
| 2454 |
// eMail |
| 2455 |
if (isset($ids['inetOrgPerson_email']) && ($rawAccounts[$i][$ids['inetOrgPerson_email']] != "")) { |
| 2456 |
$mailList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_email']])); |
| 2457 |
$partialAccounts[$i]['mail'] = $mailList; |
| 2458 |
for ($x = 0; $x < count($mailList); $x++) { |
| 2459 |
if (!get_preg($mailList[$x], 'email')) { |
| 2460 |
$errMsg = $this->messages['email'][1]; |
| 2461 |
$errMsg[] = [$i]; |
| 2462 |
$errors[] = $errMsg; |
| 2463 |
break; |
| 2464 |
} |
| 2465 |
elseif (in_array($mailList[$x], $existingMails)) { |
| 2466 |
$errMsg = $this->messages['mail'][2]; |
| 2467 |
$errMsg[] = [$i, $mailList[$x]]; |
| 2468 |
$errors[] = $errMsg; |
| 2469 |
} |
| 2470 |
} |
| 2471 |
} |
| 2472 |
if (isLAMProVersion() && isset($ids['inetOrgPerson_sendPasswordMail']) |
| 2473 |
&& ($rawAccounts[$i][$ids['inetOrgPerson_sendPasswordMail']] != "") |
| 2474 |
&& !in_array($rawAccounts[$i][$ids['inetOrgPerson_sendPasswordMail']], ['true', 'false'])) { |
| 2475 |
$errMsg = $this->messages['sendPasswordMail'][0]; |
| 2476 |
$errMsg[] = [$i]; |
| 2477 |
$errors[] = $errMsg; |
| 2478 |
} |
| 2479 |
// labeledURI |
| 2480 |
if (isset($ids['inetOrgPerson_labeledURI']) && ($rawAccounts[$i][$ids['inetOrgPerson_labeledURI']] != "")) { |
| 2481 |
$partialAccounts[$i]['labeledURI'] = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_labeledURI']])); |
| 2482 |
} |
| 2483 |
if (!$this->isUnixActive($selectedModules)) { |
| 2484 |
// cn |
| 2485 |
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") { |
| 2486 |
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_cn']], 'cn')) { |
| 2487 |
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['inetOrgPerson_cn']]; |
| 2488 |
} |
| 2489 |
else { |
| 2490 |
$errMsg = $this->messages['cn'][1]; |
| 2491 |
$errMsg[] = [$i]; |
| 2492 |
$errors[] = $errMsg; |
| 2493 |
} |
| 2494 |
} |
| 2495 |
elseif ($partialAccounts[$i]['givenName'] != "") { |
| 2496 |
$partialAccounts[$i]['cn'] = $partialAccounts[$i]['givenName'] . " " . $partialAccounts[$i]['sn']; |
| 2497 |
} |
| 2498 |
else { |
| 2499 |
$partialAccounts[$i]['cn'] = $partialAccounts[$i]['sn']; |
| 2500 |
} |
| 2501 |
// password |
| 2502 |
$pwd_enabled = true; |
| 2503 |
// password enabled/disabled |
| 2504 |
if (empty($rawAccounts[$i][$ids['inetOrgPerson_passwordDisabled']])) { |
| 2505 |
$pwd_enabled = true; |
| 2506 |
} |
| 2507 |
elseif (in_array($rawAccounts[$i][$ids['inetOrgPerson_passwordDisabled']], ['true', 'false'])) { |
| 2508 |
if ($rawAccounts[$i][$ids['inetOrgPerson_passwordDisabled']] == 'true') { |
| 2509 |
$pwd_enabled = false; |
| 2510 |
} |
| 2511 |
} |
| 2512 |
else { |
| 2513 |
$errMsg = $this->messages['passwordDisabled'][0]; |
| 2514 |
$errMsg[] = [$i]; |
| 2515 |
$errors[] = $errMsg; |
| 2516 |
} |
| 2517 |
// delay exop passwords |
| 2518 |
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) { |
| 2519 |
// changed in post action |
| 2520 |
} |
| 2521 |
// set SASL password |
| 2522 |
elseif (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL')) { |
| 2523 |
$partialAccounts[$i]['userpassword'] = '{SASL}' . $partialAccounts[$i]['uid']; |
| 2524 |
} |
| 2525 |
// set K5KEY password |
| 2526 |
elseif (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'K5KEY')) { |
| 2527 |
$partialAccounts[$i]['userpassword'] = pwd_hash('x', true, $this->moduleSettings['posixAccount_pwdHash'][0]); |
| 2528 |
} |
| 2529 |
elseif ($rawAccounts[$i][$ids['inetOrgPerson_userPassword']] != "") { |
| 2530 |
$userNames = []; |
| 2531 |
if (isset($ids['inetOrgPerson_userName']) && !empty($rawAccounts[$i][$ids['inetOrgPerson_userName']])) { |
| 2532 |
$userNames[] = $rawAccounts[$i][$ids['inetOrgPerson_userName']]; |
| 2533 |
} |
| 2534 |
$strengthResult = checkPasswordStrength($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], $userNames, []); |
| 2535 |
if (!$strengthResult->isValid()) { |
| 2536 |
$errors[] = ['ERROR', _('Account %s:') . ' inetOrgPerson_userPassword', $strengthResult->getTextMessage(), [$i]]; |
| 2537 |
} |
| 2538 |
elseif (!get_preg($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], 'password')) { |
| 2539 |
$errMsg = $this->messages['userPassword'][0]; |
| 2540 |
$errMsg[2] = str_replace('%', '%%', $errMsg[2]); // double "%" because of later sprintf |
| 2541 |
$errMsg[] = [$i]; |
| 2542 |
$errors[] = $errMsg; |
| 2543 |
} |
| 2544 |
else { |
| 2545 |
$partialAccounts[$i]['userpassword'] = pwd_hash($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], $pwd_enabled, $this->moduleSettings['posixAccount_pwdHash'][0]); |
| 2546 |
// for custom scripts etc. |
| 2547 |
$partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccounts[$i][$ids['inetOrgPerson_userPassword']]; |
| 2548 |
} |
| 2549 |
} |
| 2550 |
} |
| 2551 |
} |
| 2552 |
return $errors; |
| 2553 |
} |
| 2554 |
|
| 2555 |
/** |
| 2556 |
* {@inheritDoc} |
| 2557 |
*/ |
| 2558 |
public function doUploadPostActions(array &$data, array $ids, array $failed, array &$temp, array &$accounts, |
| 2559 |
array $selectedModules, ConfiguredType $type): array { |
| 2560 |
if (!checkIfWriteAccessIsAllowed($this->get_scope())) { |
| 2561 |
die(); |
| 2562 |
} |
| 2563 |
if (!isset($temp['counter'])) { |
| 2564 |
$temp['counter'] = 0; |
| 2565 |
} |
| 2566 |
$errors = []; |
| 2567 |
$dataSize = count($data); |
| 2568 |
if (($temp['counter'] < $dataSize) && !in_array($temp['counter'], $failed)) { |
| 2569 |
// mail sending is LAM Pro only |
| 2570 |
if (isLAMProVersion() |
| 2571 |
&& isset($ids['inetOrgPerson_email']) |
| 2572 |
&& ($data[$temp['counter']][$ids['inetOrgPerson_email']] != "") |
| 2573 |
&& isset($ids['inetOrgPerson_sendPasswordMail']) |
| 2574 |
&& ($data[$temp['counter']][$ids['inetOrgPerson_sendPasswordMail']] == "true") |
| 2575 |
&& isset($accounts[$temp['counter']]['INFO.userPasswordClearText'])) { |
| 2576 |
$mailMessages = sendPasswordMail($accounts[$temp['counter']]['INFO.userPasswordClearText'], $accounts[$temp['counter']]); |
| 2577 |
for ($i = 0; $i < count($mailMessages); $i++) { |
| 2578 |
if ($mailMessages[$i][0] == 'ERROR') { |
| 2579 |
$errors[] = $mailMessages[$i]; |
| 2580 |
} |
| 2581 |
} |
| 2582 |
} |
| 2583 |
// add addressbook entry |
| 2584 |
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook')) { |
| 2585 |
$attrs = [ |
| 2586 |
'objectClass' => ['organizationalUnit'], |
| 2587 |
'ou' => 'addressbook' |
| 2588 |
]; |
| 2589 |
$dn = 'ou=addressbook,' . $accounts[$temp['counter']]['dn']; |
| 2590 |
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs); |
| 2591 |
if (!$success) { |
| 2592 |
logNewMessage(LOG_ERR, 'Unable to add addressbook for user ' . $accounts[$temp['counter']]['dn'] . ' (' . ldap_error($_SESSION['ldap']->server()) . ').'); |
| 2593 |
$errors[] = ['ERROR', sprintf(_("Was unable to create DN: %s."), htmlspecialchars($dn)), getDefaultLDAPErrorString($_SESSION['ldap']->server())]; |
| 2594 |
} |
| 2595 |
else { |
| 2596 |
logNewMessage(LOG_NOTICE, 'Added addressbook for user ' . $accounts[$temp['counter']]['dn']); |
| 2597 |
} |
| 2598 |
} |
| 2599 |
// set password via exop |
| 2600 |
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) |
| 2601 |
&& ($this->moduleSettings['posixAccount_pwdHash'][0] === 'LDAP_EXOP') |
| 2602 |
&& isset($ids['inetOrgPerson_userPassword']) |
| 2603 |
&& !empty($data[$temp['counter']][$ids['inetOrgPerson_userPassword']])) { |
| 2604 |
$dn = $accounts[$temp['counter']]['dn']; |
| 2605 |
$password = $data[$temp['counter']][$ids['inetOrgPerson_userPassword']]; |
| 2606 |
$success = ldap_exop_passwd($_SESSION['ldap']->server(), $dn, '', $password); |
| 2607 |
if (!$success) { |
| 2608 |
$errors[] = [ |
| 2609 |
"ERROR", |
| 2610 |
_('Unable to set password'), |
| 2611 |
$dn . '<br>' . getDefaultLDAPErrorString($_SESSION['ldap']->server()), |
| 2612 |
[$temp['groups'][$temp['counter']]] |
| 2613 |
]; |
| 2614 |
} |
| 2615 |
} |
| 2616 |
} |
| 2617 |
$temp['counter']++; |
| 2618 |
if ($temp['counter'] < $dataSize) { |
| 2619 |
return [ |
| 2620 |
'status' => 'inProgress', |
| 2621 |
'progress' => ($temp['counter'] * 100) / $dataSize, |
| 2622 |
'errors' => $errors |
| 2623 |
]; |
| 2624 |
} |
| 2625 |
else { |
| 2626 |
return [ |
| 2627 |
'status' => 'finished', |
| 2628 |
'progress' => 100, |
| 2629 |
'errors' => $errors |
| 2630 |
]; |
| 2631 |
} |
| 2632 |
} |
| 2633 |
|
| 2634 |
|
| 2635 |
/** |
| 2636 |
* {@inheritDoc} |
| 2637 |
*/ |
| 2638 |
public function getSelfServiceSettings(selfServiceProfile $profile): ?htmlElement { |
| 2639 |
$container = new htmlResponsiveRow(); |
| 2640 |
$container->add(new htmlSubTitle(_('Photo'))); |
| 2641 |
$container->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, ['crop', static::class])); |
| 2642 |
$container->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, ['crop', static::class])); |
| 2643 |
$container->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize')); |
| 2644 |
return $container; |
| 2645 |
} |
| 2646 |
|
| 2647 |
/** |
| 2648 |
* {@inheritDoc} |
| 2649 |
*/ |
| 2650 |
public function checkSelfServiceSettings(array &$options, selfServiceProfile &$profile): array { |
| 2651 |
$errors = []; |
| 2652 |
if (!empty($options['inetOrgPerson_jpegPhoto_maxWidth'][0]) && !is_numeric($options['inetOrgPerson_jpegPhoto_maxWidth'][0])) { |
| 2653 |
$errors[] = ['ERROR', _('Please enter a number.'), _('Maximum width (px)')]; |
| 2654 |
} |
| 2655 |
if (!empty($options['inetOrgPerson_jpegPhoto_maxHeight'][0]) && !is_numeric($options['inetOrgPerson_jpegPhoto_maxHeight'][0])) { |
| 2656 |
$errors[] = ['ERROR', _('Please enter a number.'), _('Maximum height (px)')]; |
| 2657 |
} |
| 2658 |
if (!empty($options['inetOrgPerson_jpegPhoto_maxSize'][0]) && !is_numeric($options['inetOrgPerson_jpegPhoto_maxSize'][0])) { |
| 2659 |
$errors[] = ['ERROR', _('Please enter a number.'), _('Maximum file size (kB)')]; |
| 2660 |
} |
| 2661 |
return $errors; |
| 2662 |
} |
| 2663 |
|
| 2664 |
/** |
| 2665 |
* {@inheritDoc} |
| 2666 |
*/ |
| 2667 |
public function getSelfServiceOptions(array $fields, array $attributes, bool $passwordChangeOnly, array $readOnlyFields): array { |
| 2668 |
$return = []; |
| 2669 |
if ($passwordChangeOnly) { |
| 2670 |
return $return; // no fields as long no LDAP content can be read |
| 2671 |
} |
| 2672 |
$this->addSimpleSelfServiceTextField($return, 'firstName', _('First name'), $fields, |
| 2673 |
$attributes, $readOnlyFields, false, false, 'givenName'); |
| 2674 |
$this->addSimpleSelfServiceTextField($return, 'lastName', _('Last name'), $fields, |
| 2675 |
$attributes, $readOnlyFields, true, false, 'sn'); |
| 2676 |
$this->addMultiValueSelfServiceTextField($return, 'mail', _('Email address'), $fields, |
| 2677 |
$attributes, $readOnlyFields); |
| 2678 |
$this->addMultiValueSelfServiceTextField($return, 'labeledURI', _('Web site'), $fields, |
| 2679 |
$attributes, $readOnlyFields, false, false, 'labeledURI'); |
| 2680 |
$this->addMultiValueSelfServiceTextField($return, 'telephoneNumber', _('Telephone number'), $fields, |
| 2681 |
$attributes, $readOnlyFields, false, false, 'telephoneNumber'); |
| 2682 |
$this->addMultiValueSelfServiceTextField($return, 'homePhone', _('Home telephone number'), $fields, |
| 2683 |
$attributes, $readOnlyFields, false, false, 'homePhone'); |
| 2684 |
$this->addMultiValueSelfServiceTextField($return, 'mobile', _('Mobile telephone number'), $fields, |
| 2685 |
$attributes, $readOnlyFields); |
| 2686 |
$this->addMultiValueSelfServiceTextField($return, 'faxNumber', _('Fax number'), $fields, |
| 2687 |
$attributes, $readOnlyFields, false, false, 'facsimileTelephoneNumber'); |
| 2688 |
$this->addMultiValueSelfServiceTextField($return, 'pager', _('Pager'), $fields, |
| 2689 |
$attributes, $readOnlyFields); |
| 2690 |
$this->addMultiValueSelfServiceTextField($return, 'street', _('Street'), $fields, |
| 2691 |
$attributes, $readOnlyFields); |
| 2692 |
$this->addMultiValueSelfServiceTextField($return, 'postalAddress', _('Postal address'), $fields, |
| 2693 |
$attributes, $readOnlyFields, false, true, 'postalAddress'); |
| 2694 |
$this->addMultiValueSelfServiceTextField($return, 'registeredAddress', _('Registered address'), $fields, |
| 2695 |
$attributes, $readOnlyFields, false, true, 'registeredAddress'); |
| 2696 |
$this->addMultiValueSelfServiceTextField($return, 'postalCode', _('Postal code'), $fields, |
| 2697 |
$attributes, $readOnlyFields, false, false, 'postalCode'); |
| 2698 |
$this->addMultiValueSelfServiceTextField($return, 'postOfficeBox', _('Post office box'), $fields, |
| 2699 |
$attributes, $readOnlyFields, false, false, 'postOfficeBox'); |
| 2700 |
$this->addSimpleSelfServiceTextField($return, 'roomNumber', _('Room number'), $fields, |
| 2701 |
$attributes, $readOnlyFields, false, false, 'roomNumber'); |
| 2702 |
$this->addMultiValueSelfServiceTextField($return, 'location', _('Location'), $fields, |
| 2703 |
$attributes, $readOnlyFields, false, false, 'l'); |
| 2704 |
$this->addMultiValueSelfServiceTextField($return, 'state', _('State'), $fields, |
| 2705 |
$attributes, $readOnlyFields, false, false, 'st'); |
| 2706 |
$this->addSimpleSelfServiceTextField($return, 'carLicense', _('Car license'), $fields, |
| 2707 |
$attributes, $readOnlyFields, false, false, 'carLicense'); |
| 2708 |
$this->addMultiValueSelfServiceTextField($return, 'officeName', _('Office name'), $fields, |
| 2709 |
$attributes, $readOnlyFields, false, false, 'physicalDeliveryOfficeName'); |
| 2710 |
$this->addMultiValueSelfServiceTextField($return, 'businessCategory', _('Business category'), $fields, |
| 2711 |
$attributes, $readOnlyFields, false, false, 'businessCategory'); |
| 2712 |
|
| 2713 |
if (in_array('jpegPhoto', $fields)) { |
| 2714 |
$_SESSION[self::SESS_PHOTO] = null; |
| 2715 |
if (isset($attributes['jpegPhoto'][0])) { |
| 2716 |
$_SESSION[self::SESS_PHOTO] = $attributes['jpegPhoto'][0]; |
| 2717 |
} |
| 2718 |
$readOnlyPhoto = in_array('jpegPhoto', $readOnlyFields); |
| 2719 |
if (!empty($attributes['jpegPhoto'][0]) || !$readOnlyPhoto) { |
| 2720 |
$photoSub = new htmlDiv('inetOrgPersonPhotoUploadContent', $this->getSelfServicePhoto($readOnlyPhoto, false)); |
| 2721 |
$photoRow = new htmlResponsiveRow(); |
| 2722 |
$photoRow->add($this->getSelfServicePhotoJS($readOnlyPhoto), 0); |
| 2723 |
$photoRow->addLabel(new htmlOutputText($this->getSelfServiceLabel('jpegPhoto', _('Photo')))); |
| 2724 |
$photoRow->addField(new htmlDiv('jpegPhotoDiv', $photoSub)); |
| 2725 |
$return['jpegPhoto'] = $photoRow; |
| 2726 |
} |
| 2727 |
} |
| 2728 |
|
| 2729 |
$this->addMultiValueSelfServiceTextField($return, 'departmentNumber', _('Department'), $fields, |
| 2730 |
$attributes, $readOnlyFields, false, false, 'departmentNumber'); |
| 2731 |
$this->addSimpleSelfServiceTextField($return, 'initials', _('Initials'), $fields, |
| 2732 |
$attributes, $readOnlyFields); |
| 2733 |
$this->addMultiValueSelfServiceTextField($return, 'title', _('Job title'), $fields, |
| 2734 |
$attributes, $readOnlyFields); |
| 2735 |
|
| 2736 |
if (in_array('userCertificate', $fields)) { |
| 2737 |
$userCertificates = []; |
| 2738 |
if (isset($attributes['userCertificate'][0])) { |
| 2739 |
$userCertificates = $attributes['userCertificate']; |
| 2740 |
} |
| 2741 |
elseif (isset($attributes['userCertificate;binary'][0])) { |
| 2742 |
$userCertificates = $attributes['userCertificate;binary']; |
| 2743 |
} |
| 2744 |
$_SESSION[self::SESS_CERTIFICATES_LIST] = $userCertificates; |
| 2745 |
$certTable = new htmlResponsiveRow(); |
| 2746 |
$certTable->add(new htmlDiv('userCertificateDiv', $this->getSelfServiceUserCertificates())); |
| 2747 |
// JavaScript functions |
| 2748 |
$certTable->add($this->getSelfServiceUserCertificatesJSBlock()); |
| 2749 |
// upload button |
| 2750 |
$uploadButtonGroup = new htmlGroup(); |
| 2751 |
$uploadLabel = new htmlLabel('inetOrgPersonCertificate_file', _('Upload a file')); |
| 2752 |
$uploadButtonGroup->addElement($uploadLabel); |
| 2753 |
$uploadInput = new htmlInputFileUpload('inetOrgPersonCertificate_file'); |
| 2754 |
$uploadInput->setOnChange('inetOrgPersonUploadCert();'); |
| 2755 |
$uploadButtonGroup->addElement($uploadInput); |
| 2756 |
$certLabel = new htmlOutputText($this->getSelfServiceLabel('userCertificate', _('User certificates'))); |
| 2757 |
$certTable->add(new htmlDiv('inetOrgPersonCertUploadId', $uploadButtonGroup, ['lam-upload-button'])); |
| 2758 |
$return['userCertificate'] = new htmlResponsiveRow($certLabel, $certTable); |
| 2759 |
} |
| 2760 |
// o |
| 2761 |
if (in_array('o', $fields)) { |
| 2762 |
$o = ''; |
| 2763 |
if (isset($attributes['o'][0])) { |
| 2764 |
$o = $attributes['o'][0]; |
| 2765 |
} |
| 2766 |
if (in_array('o', $readOnlyFields)) { |
| 2767 |
$oField = new htmlOutputText(getAbstractDN($o)); |
| 2768 |
} |
| 2769 |
else { |
| 2770 |
$filter = '(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer)(objectClass=container))'; |
| 2771 |
$suffix = $_SESSION['selfServiceProfile']->LDAPSuffix; |
| 2772 |
$foundOs = searchLDAPPaged($_SESSION['ldapHandle']->getServer(), $suffix, $filter, ['dn'], 0, 0); |
| 2773 |
$oList = []; |
| 2774 |
foreach ($foundOs as $foundO) { |
| 2775 |
$oList[] = $foundO['dn']; |
| 2776 |
} |
| 2777 |
if (!empty($attributes['o'][0]) && !in_array($attributes['o'][0], $oList)) { |
| 2778 |
$oList[] = $attributes['o'][0]; |
| 2779 |
usort($oList, compareDN(...)); |
| 2780 |
} |
| 2781 |
$oSelectionList = ['' => '']; |
| 2782 |
foreach ($oList as $singleOU) { |
| 2783 |
$oSelectionList[getAbstractDN($singleOU)] = $singleOU; |
| 2784 |
} |
| 2785 |
$oSelectionListSelected = []; |
| 2786 |
if (!empty($attributes['o'][0])) { |
| 2787 |
$oSelectionListSelected[] = $attributes['o'][0]; |
| 2788 |
} |
| 2789 |
$oField = new htmlSelect('inetOrgPerson_o', $oSelectionList, $oSelectionListSelected); |
| 2790 |
$oField->setHasDescriptiveElements(true); |
| 2791 |
$oField->setRightToLeftTextDirection(true); |
| 2792 |
$oField->setSortElements(false); |
| 2793 |
} |
| 2794 |
$return['o'] = new htmlResponsiveRow( |
| 2795 |
new htmlLabel('inetOrgPerson_o', $this->getSelfServiceLabel('o', _('Organisation'))), $oField |
| 2796 |
); |
| 2797 |
} |
| 2798 |
// ou |
| 2799 |
if (in_array('ou', $fields)) { |
| 2800 |
$ou = ''; |
| 2801 |
if (isset($attributes['ou'][0])) { |
| 2802 |
$ou = $attributes['ou'][0]; |
| 2803 |
} |
| 2804 |
if (in_array('ou', $readOnlyFields)) { |
| 2805 |
$ouField = new htmlOutputText(getAbstractDN($ou)); |
| 2806 |
} |
| 2807 |
else { |
| 2808 |
$filter = '(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer)(objectClass=container))'; |
| 2809 |
$suffix = $_SESSION['selfServiceProfile']->LDAPSuffix; |
| 2810 |
$foundOus = searchLDAPPaged($_SESSION['ldapHandle']->getServer(), $suffix, $filter, ['dn'], 0, 0); |
| 2811 |
$ouList = []; |
| 2812 |
foreach ($foundOus as $foundOu) { |
| 2813 |
$ouList[] = $foundOu['dn']; |
| 2814 |
} |
| 2815 |
if (!empty($attributes['ou'][0]) && !in_array($attributes['ou'][0], $ouList)) { |
| 2816 |
$ouList[] = $attributes['ou'][0]; |
| 2817 |
usort($ouList, compareDN(...)); |
| 2818 |
} |
| 2819 |
$ouSelectionList = ['' => '']; |
| 2820 |
foreach ($ouList as $singleOU) { |
| 2821 |
$ouSelectionList[getAbstractDN($singleOU)] = $singleOU; |
| 2822 |
} |
| 2823 |
$ouSelectionListSelected = []; |
| 2824 |
if (!empty($attributes['ou'][0])) { |
| 2825 |
$ouSelectionListSelected[] = $attributes['ou'][0]; |
| 2826 |
} |
| 2827 |
$ouField = new htmlSelect('inetOrgPerson_ou', $ouSelectionList, $ouSelectionListSelected); |
| 2828 |
$ouField->setHasDescriptiveElements(true); |
| 2829 |
$ouField->setRightToLeftTextDirection(true); |
| 2830 |
$ouField->setSortElements(false); |
| 2831 |
} |
| 2832 |
$return['ou'] = new htmlResponsiveRow( |
| 2833 |
new htmlLabel('inetOrgPerson_ou', $this->getSelfServiceLabel('ou', _('Organisational unit'))), $ouField |
| 2834 |
); |
| 2835 |
} |
| 2836 |
|
| 2837 |
$this->addMultiValueSelfServiceTextField($return, 'description', _('Description'), $fields, |
| 2838 |
$attributes, $readOnlyFields); |
| 2839 |
$this->addSimpleSelfServiceTextField($return, 'uid', _('User name'), $fields, |
| 2840 |
$attributes, $readOnlyFields); |
| 2841 |
$this->addSimpleSelfServiceTextField($return, 'displayName', _('Display name'), $fields, |
| 2842 |
$attributes, $readOnlyFields, false, false, 'displayName'); |
| 2843 |
return $return; |
| 2844 |
} |
| 2845 |
|
| 2846 |
/** |
| 2847 |
* Renders the photo area for self-service. |
| 2848 |
* |
| 2849 |
* @param boolean $readOnly content is read-only |
| 2850 |
* @param boolean $crop enable cropping |
| 2851 |
* @return htmlResponsiveRow content |
| 2852 |
* @throws LAMException error displaying page |
| 2853 |
*/ |
| 2854 |
private function getSelfServicePhoto($readOnly, $crop) { |
| 2855 |
$photo = $_SESSION[self::SESS_PHOTO]; |
| 2856 |
$row = new htmlResponsiveRow(); |
| 2857 |
if (!empty($photo)) { |
| 2858 |
$tempFilesManager = new LamTemporaryFilesManager(); |
| 2859 |
$fileName = $tempFilesManager->registerTemporaryFile('.jpg'); |
| 2860 |
$handle = $tempFilesManager->openTemporaryFileForWrite($fileName); |
| 2861 |
fwrite($handle, $photo); |
| 2862 |
fclose($handle); |
| 2863 |
$photoFile = $tempFilesManager->getResourceLink($fileName); |
| 2864 |
$img = new htmlImage($photoFile, null, null, $this->getSelfServiceLabel('jpegPhoto', _('Photo'))); |
| 2865 |
$img->setCSSClasses(['photo']); |
| 2866 |
if ($crop) { |
| 2867 |
$img->enableCropping(); |
| 2868 |
} |
| 2869 |
$row->add($img); |
| 2870 |
if (!$readOnly) { |
| 2871 |
$row->addVerticalSpacer('0.5rem'); |
| 2872 |
$deleteButton = new htmlLink(_('Delete'), '#', '../../graphics/del.svg'); |
| 2873 |
$deleteButton->setOnClick('inetOrgPersonDeletePhoto(); return false;'); |
| 2874 |
$row->add($deleteButton); |
| 2875 |
} |
| 2876 |
$row->addVerticalSpacer('0.5rem'); |
| 2877 |
} |
| 2878 |
if (!$readOnly) { |
| 2879 |
// upload button |
| 2880 |
$uploadButtonGroup = new htmlGroup(); |
| 2881 |
$uploadLabel = new htmlLabel('inetOrgPersonPhoto_file', _('Upload a file')); |
| 2882 |
$uploadButtonGroup->addElement($uploadLabel); |
| 2883 |
$uploadInput = new htmlInputFileUpload('inetOrgPersonPhoto_file'); |
| 2884 |
$uploadInput->setOnChange('inetOrgPersonUploadPhoto();'); |
| 2885 |
$uploadButtonGroup->addElement($uploadInput); |
| 2886 |
$row->add(new htmlDiv('inetOrgPersonPhotoUploadId', $uploadButtonGroup, ['lam-upload-button'])); |
| 2887 |
// webcam button |
| 2888 |
$webcamContent = new htmlResponsiveRow(); |
| 2889 |
$webcamContent->addVerticalSpacer('0.5rem'); |
| 2890 |
$errorMessage = new htmlStatusMessage('ERROR', ''); |
| 2891 |
$errorMessage->setCSSClasses(['hidden', 'lam-webcam-message']); |
| 2892 |
$webcamContent->add($errorMessage); |
| 2893 |
$webcamContent->addVerticalSpacer('0.5rem'); |
| 2894 |
$captureButton = new htmlLink(_('Use webcam'), '#', '../../graphics/webcam.png'); |
| 2895 |
$captureButton->setId('btn_lam-webcam-capture'); |
| 2896 |
$captureButton->setOnClick('window.lam.tools.webcam.capture(event);'); |
| 2897 |
$webcamContent->add($captureButton, 12, 12, 12); |
| 2898 |
$video = new htmlVideo('lam-webcam-video'); |
| 2899 |
$video->setCSSClasses(['hidden']); |
| 2900 |
$webcamContent->add($video, 12, 12, 12, 'text-center'); |
| 2901 |
$webcamContent->addVerticalSpacer('1rem'); |
| 2902 |
$webcamUploadButton = new htmlLink(_('Upload'), '#', '../../graphics/upload.svg'); |
| 2903 |
$webcamUploadButton->setId('btn-lam-webcam-upload'); |
| 2904 |
$webcamUploadButton->setCSSClasses(['btn-lam-webcam-upload', 'hidden']); |
| 2905 |
$webcamUploadButton->setOnClick('window.lam.tools.webcam.uploadSelfService(event, "' . getSecurityTokenName() |
| 2906 |
. '", "' . getSecurityTokenValue() . '", "inetOrgPerson", "user", "' . _('File upload failed!') . '", "inetOrgPersonPhotoUploadContent");'); |
| 2907 |
$webcamContent->add($webcamUploadButton, 12, 12, 12); |
| 2908 |
$canvas = new htmlCanvas('lam-webcam-canvas'); |
| 2909 |
$canvas->setCSSClasses(['hidden']); |
| 2910 |
$webcamContent->add($canvas); |
| 2911 |
$webcamDiv = new htmlDiv('lam_webcam_div', $webcamContent, ['hidden']); |
| 2912 |
$webcamContent->addVerticalSpacer('1rem'); |
| 2913 |
$row->add($webcamDiv); |
| 2914 |
} |
| 2915 |
return $row; |
| 2916 |
} |
| 2917 |
|
| 2918 |
/** |
| 2919 |
* Returns the JavaScript functions to manage the photo. |
| 2920 |
* |
| 2921 |
* @param boolean $readOnly content is read-only |
| 2922 |
* @return htmlElement JS block |
| 2923 |
*/ |
| 2924 |
private function getSelfServicePhotoJS($readOnly) { |
| 2925 |
if ($readOnly) { |
| 2926 |
return new htmlGroup(); |
| 2927 |
} |
| 2928 |
$content = ' |
| 2929 |
function inetOrgPersonUploadPhoto() { |
| 2930 |
let params = new FormData(); |
| 2931 |
params.append("action", "ajaxPhotoUpload"); |
| 2932 |
params.append("' . getSecurityTokenName() . '", "' . getSecurityTokenValue() . '"); |
| 2933 |
let reader = new FileReader(); |
| 2934 |
reader.onload = function () { |
| 2935 |
const content = reader.result; |
| 2936 |
params.append("file", btoa(content)); |
| 2937 |
fetch("../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user", { |
| 2938 |
method: "POST", |
| 2939 |
body: params |
| 2940 |
}) |
| 2941 |
.then(async response => { |
| 2942 |
const data = await response.json(); |
| 2943 |
if (data.success) { |
| 2944 |
if (data.html) { |
| 2945 |
document.getElementById(\'inetOrgPersonPhotoUploadContent\').innerHTML = data.html; |
| 2946 |
window.lam.tools.webcam.init(); |
| 2947 |
window.lam.html.initCropping(); |
| 2948 |
} |
| 2949 |
} |
| 2950 |
else if (data.error) { |
| 2951 |
window.lam.dialog.showInfo(data.error, "' . _('Ok') . '"); |
| 2952 |
} |
| 2953 |
else if (data.errormessage) { |
| 2954 |
window.lam.dialog.showInfo(data.errormessage, "' . _('Ok') . '"); |
| 2955 |
} |
| 2956 |
}); |
| 2957 |
}; |
| 2958 |
const fileInput = document.getElementById("inetOrgPersonPhoto_file"); |
| 2959 |
reader.readAsBinaryString(fileInput.files[0]); |
| 2960 |
} |
| 2961 |
|
| 2962 |
function inetOrgPersonDeletePhoto(id) { |
| 2963 |
var actionJSON = { |
| 2964 |
"action": "deletePhoto", |
| 2965 |
"id": id |
| 2966 |
}; |
| 2967 |
let data = new FormData(); |
| 2968 |
data.append("jsonInput", JSON.stringify(actionJSON)); |
| 2969 |
data.append("' . getSecurityTokenName() . '", "' . getSecurityTokenValue() . '"); |
| 2970 |
fetch("../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user", { |
| 2971 |
method: "POST", |
| 2972 |
body: data |
| 2973 |
}) |
| 2974 |
.then(async response => { |
| 2975 |
const data = await response.json(); |
| 2976 |
inetOrgPersonDeletePhotoHandleReply(data); |
| 2977 |
}); |
| 2978 |
} |
| 2979 |
|
| 2980 |
function inetOrgPersonDeletePhotoHandleReply(data) { |
| 2981 |
if (data.errorsOccurred == "false") { |
| 2982 |
document.getElementById(\'inetOrgPersonPhotoUploadContent\').innerHTML = data.html; |
| 2983 |
window.lam.tools.webcam.init(); |
| 2984 |
} |
| 2985 |
else { |
| 2986 |
window.lam.dialog.showInfo(data.errormessage, "' . _('Ok') . '"); |
| 2987 |
} |
| 2988 |
} |
| 2989 |
|
| 2990 |
'; |
| 2991 |
return new htmlJavaScript($content); |
| 2992 |
} |
| 2993 |
|
| 2994 |
|
| 2995 |
/** |
| 2996 |
* Returns the meta HTML code to display the certificate area. |
| 2997 |
* This also includes the file upload. |
| 2998 |
* |
| 2999 |
* @return htmlGroup certificate content |
| 3000 |
* @throws LAMException |
| 3001 |
*/ |
| 3002 |
private function getSelfServiceUserCertificates() { |
| 3003 |
$userCertificates = $_SESSION[self::SESS_CERTIFICATES_LIST]; |
| 3004 |
$content = new htmlGroup(); |
| 3005 |
if (count($userCertificates) > 0) { |
| 3006 |
$certTable = new htmlResponsiveRow(); |
| 3007 |
$tempFilesManager = new LamTemporaryFilesManager(); |
| 3008 |
for ($i = 0; $i < count($userCertificates); $i++) { |
| 3009 |
$group = new htmlGroup(); |
| 3010 |
$filename = $tempFilesManager->registerTemporaryFile('.der', 'userCertificate_'); |
| 3011 |
$out = $tempFilesManager->openTemporaryFileForWrite($filename); |
| 3012 |
fwrite($out, $userCertificates[$i]); |
| 3013 |
fclose($out); |
| 3014 |
$pem = @chunk_split(@base64_encode($userCertificates[$i]), 64, "\n"); |
| 3015 |
if (!empty($pem)) { |
| 3016 |
$pem = "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n"; |
| 3017 |
$pemData = @openssl_x509_parse($pem); |
| 3018 |
$data = []; |
| 3019 |
if (isset($pemData['serialNumber'])) { |
| 3020 |
$data[] = $pemData['serialNumber']; |
| 3021 |
} |
| 3022 |
if (isset($pemData['name'])) { |
| 3023 |
$data[] = $pemData['name']; |
| 3024 |
} |
| 3025 |
if ($data !== []) { |
| 3026 |
$group->addElement(new htmlOutputText(implode(': ', $data))); |
| 3027 |
$group->addElement(new htmlSpacer('5px', null)); |
| 3028 |
} |
| 3029 |
} |
| 3030 |
$saveLink = new htmlLink('', $tempFilesManager->getDownloadLink($filename), '../../graphics/save.svg'); |
| 3031 |
$saveLink->setTitle(_('Save')); |
| 3032 |
$saveLink->setTargetWindow('_blank'); |
| 3033 |
$saveLink->setCSSClasses(['icon']); |
| 3034 |
$group->addElement($saveLink); |
| 3035 |
$delLink = new htmlLink('', '#', '../../graphics/del.svg'); |
| 3036 |
$delLink->setTitle(_('Delete')); |
| 3037 |
$delLink->setOnClick('inetOrgPersonDeleteCertificate(' . $i . '); return false;'); |
| 3038 |
$delLink->setCSSClasses(['icon']); |
| 3039 |
$group->addElement($delLink); |
| 3040 |
$certTable->add($group); |
| 3041 |
} |
| 3042 |
$content->addElement($certTable); |
| 3043 |
} |
| 3044 |
return $content; |
| 3045 |
} |
| 3046 |
|
| 3047 |
/** |
| 3048 |
* Returns the Java Script functions to manage the certificates. |
| 3049 |
* |
| 3050 |
* @return htmlJavaScript JS block |
| 3051 |
*/ |
| 3052 |
private function getSelfServiceUserCertificatesJSBlock() { |
| 3053 |
$content = ' |
| 3054 |
function inetOrgPersonDeleteCertificate(id) { |
| 3055 |
var actionJSON = { |
| 3056 |
"action": "deleteCert", |
| 3057 |
"id": id |
| 3058 |
}; |
| 3059 |
let data = new FormData(); |
| 3060 |
data.append("jsonInput", JSON.stringify(actionJSON)); |
| 3061 |
data.append("' . getSecurityTokenName() . '", "' . getSecurityTokenValue() . '"); |
| 3062 |
fetch(\'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user\', { |
| 3063 |
method: "POST", |
| 3064 |
body: data |
| 3065 |
}) |
| 3066 |
.then(async response => { |
| 3067 |
const jsonData = await response.json(); |
| 3068 |
inetOrgPersonDeleteCertificateHandleReply(jsonData); |
| 3069 |
}); |
| 3070 |
} |
| 3071 |
|
| 3072 |
function inetOrgPersonDeleteCertificateHandleReply(data) { |
| 3073 |
if (data.errorsOccurred == "false") { |
| 3074 |
document.getElementById(\'userCertificateDiv\').innerHTML = data.html; |
| 3075 |
} |
| 3076 |
else { |
| 3077 |
alert(data.errormessage); |
| 3078 |
} |
| 3079 |
} |
| 3080 |
|
| 3081 |
function inetOrgPersonUploadCert() { |
| 3082 |
let data = new FormData(); |
| 3083 |
data.append("action", \'ajaxCertUpload\'); |
| 3084 |
data.append("' . getSecurityTokenName() . '", "' . getSecurityTokenValue() . '"); |
| 3085 |
let reader = new FileReader(); |
| 3086 |
reader.onload = function () { |
| 3087 |
const content = reader.result; |
| 3088 |
data.append("file", btoa(content)); |
| 3089 |
fetch(\'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user\', { |
| 3090 |
method: "POST", |
| 3091 |
body: data |
| 3092 |
}) |
| 3093 |
.then(async response => { |
| 3094 |
const jsonData = await response.json(); |
| 3095 |
if (jsonData.success) { |
| 3096 |
if (jsonData.html) { |
| 3097 |
document.getElementById(\'userCertificateDiv\').innerHTML = jsonData.html; |
| 3098 |
} |
| 3099 |
} |
| 3100 |
else if (jsonData.error) { |
| 3101 |
window.lam.dialog.showInfo(jsonData.error, "' . _('Ok') . '"); |
| 3102 |
} |
| 3103 |
else if (jsonData.errormessage) { |
| 3104 |
window.lam.dialog.showInfo(jsonData.errormessage, "' . _('Ok') . '"); |
| 3105 |
} |
| 3106 |
}); |
| 3107 |
}; |
| 3108 |
const fileInput = document.getElementById("inetOrgPersonCertificate_file"); |
| 3109 |
reader.readAsBinaryString(fileInput.files[0]); |
| 3110 |
} |
| 3111 |
|
| 3112 |
'; |
| 3113 |
return new htmlJavaScript($content); |
| 3114 |
} |
| 3115 |
|
| 3116 |
/** |
| 3117 |
* {@inheritDoc} |
| 3118 |
*/ |
| 3119 |
public function checkSelfServiceOptions(array $fields, array $attributes, bool $passwordChangeOnly, array $readOnlyFields): array { |
| 3120 |
$return = ['messages' => [], 'add' => [], 'del' => [], 'mod' => [], 'info' => []]; |
| 3121 |
if ($passwordChangeOnly) { |
| 3122 |
return $return; // skip processing if only a password change is done |
| 3123 |
} |
| 3124 |
$attributeNames = []; // list of attributes which should be checked for modification |
| 3125 |
$attributesNew = $attributes; |
| 3126 |
$this->checkSimpleSelfServiceTextField($return, 'firstName', $attributes, $fields, |
| 3127 |
$readOnlyFields, 'realname', $this->messages['givenName'][0], null, |
| 3128 |
'givenName'); |
| 3129 |
$this->checkSimpleSelfServiceTextField($return, 'lastName', $attributes, $fields, |
| 3130 |
$readOnlyFields, 'realname', $this->messages['lastname'][0], $this->messages['lastname'][0], |
| 3131 |
'sn'); |
| 3132 |
$this->checkMultiValueSelfServiceTextField($return, 'mail', $attributes, $fields, |
| 3133 |
$readOnlyFields, 'email', $this->messages['mail'][0]); |
| 3134 |
$this->checkMultiValueSelfServiceTextField($return, 'labeledURI', $attributes, $fields, |
| 3135 |
$readOnlyFields, null, null, null, 'labeledURI'); |
| 3136 |
$this->checkMultiValueSelfServiceTextField($return, 'telephoneNumber', $attributes, $fields, |
| 3137 |
$readOnlyFields, 'telephone', $this->messages['telephoneNumber'][0], null, |
| 3138 |
'telephoneNumber'); |
| 3139 |
$this->checkMultiValueSelfServiceTextField($return, 'homePhone', $attributes, $fields, |
| 3140 |
$readOnlyFields, 'telephone', $this->messages['homePhone'][0], null, |
| 3141 |
'homePhone'); |
| 3142 |
$this->checkMultiValueSelfServiceTextField($return, 'faxNumber', $attributes, $fields, |
| 3143 |
$readOnlyFields, 'telephone', $this->messages['facsimileTelephoneNumber'][0], null, |
| 3144 |
'facsimileTelephoneNumber'); |
| 3145 |
$this->checkMultiValueSelfServiceTextField($return, 'mobile', $attributes, $fields, |
| 3146 |
$readOnlyFields, 'telephone', $this->messages['mobile'][0]); |
| 3147 |
$this->checkMultiValueSelfServiceTextField($return, 'pager', $attributes, $fields, |
| 3148 |
$readOnlyFields, 'telephone', $this->messages['pager'][0]); |
| 3149 |
$this->checkMultiValueSelfServiceTextField($return, 'street', $attributes, $fields, |
| 3150 |
$readOnlyFields, 'street', $this->messages['street'][0]); |
| 3151 |
$this->checkMultiValueSelfServiceTextField($return, 'postalAddress', $attributes, $fields, |
| 3152 |
$readOnlyFields, 'postalAddress', $this->messages['postalAddress'][0], null, |
| 3153 |
'postalAddress'); |
| 3154 |
$this->checkMultiValueSelfServiceTextField($return, 'registeredAddress', $attributes, $fields, |
| 3155 |
$readOnlyFields, 'postalAddress', $this->messages['registeredAddress'][0], null, |
| 3156 |
'registeredAddress'); |
| 3157 |
$this->checkMultiValueSelfServiceTextField($return, 'postalCode', $attributes, $fields, |
| 3158 |
$readOnlyFields, 'postalCode', $this->messages['postalCode'][0], null, |
| 3159 |
'postalCode'); |
| 3160 |
$this->checkMultiValueSelfServiceTextField($return, 'postOfficeBox', $attributes, $fields, |
| 3161 |
$readOnlyFields, null, null, null, |
| 3162 |
'postOfficeBox'); |
| 3163 |
$this->checkSimpleSelfServiceTextField($return, 'roomNumber', $attributes, $fields, |
| 3164 |
$readOnlyFields, null, null, null, |
| 3165 |
'roomNumber'); |
| 3166 |
$this->checkMultiValueSelfServiceTextField($return, 'location', $attributes, $fields, |
| 3167 |
$readOnlyFields, null, null, null, |
| 3168 |
'l'); |
| 3169 |
$this->checkMultiValueSelfServiceTextField($return, 'state', $attributes, $fields, |
| 3170 |
$readOnlyFields, null, null, null, |
| 3171 |
'st'); |
| 3172 |
$this->checkSimpleSelfServiceTextField($return, 'carLicense', $attributes, $fields, |
| 3173 |
$readOnlyFields, null, null, null, |
| 3174 |
'carLicense'); |
| 3175 |
$this->checkMultiValueSelfServiceTextField($return, 'officeName', $attributes, $fields, |
| 3176 |
$readOnlyFields, null, null, null, |
| 3177 |
'physicalDeliveryOfficeName'); |
| 3178 |
$this->checkMultiValueSelfServiceTextField($return, 'businessCategory', $attributes, $fields, |
| 3179 |
$readOnlyFields, 'businessCategory', $this->messages['businessCategory'][0], null, |
| 3180 |
'businessCategory'); |
| 3181 |
|
| 3182 |
// photo |
| 3183 |
if (in_array('jpegPhoto', $fields) && !in_array('jpegPhoto', $readOnlyFields)) { |
| 3184 |
$data = $_SESSION[self::SESS_PHOTO]; |
| 3185 |
// remove photo |
| 3186 |
if (!empty($attributes['jpegPhoto'][0]) && empty($data)) { |
| 3187 |
$return['mod']['jpegPhoto'] = []; |
| 3188 |
} |
| 3189 |
// set/replace photo |
| 3190 |
elseif (!empty($data) && (empty($attributes['jpegPhoto'][0]) || ($data != $attributes['jpegPhoto'][0]))) { |
| 3191 |
$moduleSettings = $this->selfServiceSettings->moduleSettings; |
| 3192 |
try { |
| 3193 |
include_once __DIR__ . '/../imageutils.inc'; |
| 3194 |
$imageManipulator = ImageManipulationFactory::getImageManipulator($data); |
| 3195 |
$scaleFactor = $imageManipulator->getWidth() / intval($_POST['croppingDataWidth']); |
| 3196 |
$imageManipulator->crop( |
| 3197 |
(int) round(intval($_POST['croppingDataX']) * $scaleFactor), |
| 3198 |
(int) round(intval($_POST['croppingDataY']) * $scaleFactor), |
| 3199 |
(int) round($_POST['croppingDataSelectionWidth'] * $scaleFactor), |
| 3200 |
(int) round($_POST['croppingDataSelectionHeight'] * $scaleFactor) |
| 3201 |
); |
| 3202 |
$data = $imageManipulator->getImageData(); |
| 3203 |
$data = $this->resizeAndConvertImage($data, $moduleSettings); |
| 3204 |
if (!empty($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && ($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0] < (strlen($data) / 1024))) { |
| 3205 |
$msg = $this->messages['file'][3]; |
| 3206 |
$msg[] = null; |
| 3207 |
$msg[] = htmlspecialchars($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]); |
| 3208 |
$return['messages'][] = $msg; |
| 3209 |
} |
| 3210 |
elseif (!empty($attributes['jpegPhoto'][0])) { |
| 3211 |
$return['mod']['jpegPhoto'][0] = $data; |
| 3212 |
} |
| 3213 |
else { |
| 3214 |
$return['add']['jpegPhoto'][0] = $data; |
| 3215 |
} |
| 3216 |
} |
| 3217 |
catch (Exception $e) { |
| 3218 |
$msg = $this->messages['file'][2]; |
| 3219 |
$msg[] = htmlspecialchars($e->getMessage()); |
| 3220 |
$return['messages'][] = $msg; |
| 3221 |
} |
| 3222 |
} |
| 3223 |
} |
| 3224 |
|
| 3225 |
$this->checkMultiValueSelfServiceTextField($return, 'departmentNumber', $attributes, $fields, |
| 3226 |
$readOnlyFields, null, null, null, |
| 3227 |
'departmentNumber'); |
| 3228 |
$this->checkSimpleSelfServiceTextField($return, 'initials', $attributes, $fields, |
| 3229 |
$readOnlyFields); |
| 3230 |
$this->checkMultiValueSelfServiceTextField($return, 'title', $attributes, $fields, |
| 3231 |
$readOnlyFields, 'title', $this->messages['title'][0]); |
| 3232 |
|
| 3233 |
// user certificates |
| 3234 |
if (in_array('userCertificate', $fields)) { |
| 3235 |
$userCertificates = $_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST]; |
| 3236 |
$userCertificatesAttrName = 'userCertificate;binary'; |
| 3237 |
if (isset($attributes['userCertificate'])) { |
| 3238 |
$userCertificatesAttrName = 'userCertificate'; |
| 3239 |
} |
| 3240 |
$attributeNames[] = $userCertificatesAttrName; |
| 3241 |
if (count($userCertificates) > 0) { |
| 3242 |
$attributesNew[$userCertificatesAttrName] = $userCertificates; |
| 3243 |
} |
| 3244 |
elseif (isset($attributesNew[$userCertificatesAttrName])) { |
| 3245 |
unset($attributesNew[$userCertificatesAttrName]); |
| 3246 |
} |
| 3247 |
} |
| 3248 |
// ou |
| 3249 |
if (in_array('ou', $fields) && !in_array('ou', $readOnlyFields)) { |
| 3250 |
$attributeNames[] = 'ou'; |
| 3251 |
if (!empty($_POST['inetOrgPerson_ou'])) { |
| 3252 |
$attributesNew['ou'][0] = $_POST['inetOrgPerson_ou']; |
| 3253 |
} |
| 3254 |
elseif (isset($attributes['ou'])) { |
| 3255 |
unset($attributesNew['ou']); |
| 3256 |
} |
| 3257 |
} |
| 3258 |
// o |
| 3259 |
if (in_array('o', $fields) && !in_array('o', $readOnlyFields)) { |
| 3260 |
$attributeNames[] = 'o'; |
| 3261 |
if (!empty($_POST['inetOrgPerson_o'])) { |
| 3262 |
$attributesNew['o'][0] = $_POST['inetOrgPerson_o']; |
| 3263 |
} |
| 3264 |
elseif (isset($attributes['o'])) { |
| 3265 |
unset($attributesNew['o']); |
| 3266 |
} |
| 3267 |
} |
| 3268 |
|
| 3269 |
$this->checkMultiValueSelfServiceTextField($return, 'description', $attributes, $fields, |
| 3270 |
$readOnlyFields); |
| 3271 |
$this->checkSimpleSelfServiceTextField($return, 'uid', $attributes, $fields, |
| 3272 |
$readOnlyFields, 'username', $this->messages['uid'][0]); |
| 3273 |
$this->checkSimpleSelfServiceTextField($return, 'displayName', $attributes, $fields, |
| 3274 |
$readOnlyFields, null, null, null, 'displayName'); |
| 3275 |
|
| 3276 |
// find differences |
| 3277 |
for ($i = 0; $i < count($attributeNames); $i++) { |
| 3278 |
$attrName = $attributeNames[$i]; |
| 3279 |
if (isset($attributes[$attrName]) && !isset($attributesNew[$attrName])) { |
| 3280 |
$return['del'][$attrName] = $attributes[$attrName]; |
| 3281 |
} |
| 3282 |
elseif (!isset($attributes[$attrName]) && isset($attributesNew[$attrName])) { |
| 3283 |
$return['add'][$attrName] = $attributesNew[$attrName]; |
| 3284 |
} |
| 3285 |
else { |
| 3286 |
if (isset($attributes[$attrName])) { |
| 3287 |
for ($a = 0; $a < count($attributes[$attrName]); $a++) { |
| 3288 |
if (!in_array($attributes[$attrName][$a], $attributesNew[$attrName])) { |
| 3289 |
$return['mod'][$attrName] = $attributesNew[$attrName]; |
| 3290 |
break; |
| 3291 |
} |
| 3292 |
} |
| 3293 |
} |
| 3294 |
if (isset($attributesNew[$attrName])) { |
| 3295 |
for ($a = 0; $a < count($attributesNew[$attrName]); $a++) { |
| 3296 |
if (!in_array($attributesNew[$attrName][$a], $attributes[$attrName])) { |
| 3297 |
$return['mod'][$attrName] = $attributesNew[$attrName]; |
| 3298 |
break; |
| 3299 |
} |
| 3300 |
} |
| 3301 |
} |
| 3302 |
} |
| 3303 |
} |
| 3304 |
return $return; |
| 3305 |
} |
| 3306 |
|
| 3307 |
/** |
| 3308 |
* Resizes the given image data to the settings provided. |
| 3309 |
* |
| 3310 |
* @param string $data binary image data |
| 3311 |
* @param array<string, string[]> $settings settings |
| 3312 |
* @return string binary image data |
| 3313 |
*/ |
| 3314 |
private function resizeAndConvertImage($data, $settings): string { |
| 3315 |
include_once __DIR__ . '/../imageutils.inc'; |
| 3316 |
$imageManipulator = ImageManipulationFactory::getImageManipulator($data); |
| 3317 |
// resize if maximum values specified |
| 3318 |
if (!empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0])) { |
| 3319 |
$maxWidth = empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $imageManipulator->getWidth() : $settings['inetOrgPerson_jpegPhoto_maxWidth'][0]; |
| 3320 |
$maxHeight = empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $imageManipulator->getHeight() : $settings['inetOrgPerson_jpegPhoto_maxHeight'][0]; |
| 3321 |
$imageManipulator->thumbnail($maxWidth, $maxHeight); |
| 3322 |
} |
| 3323 |
$imageManipulator->convertToJpeg(); |
| 3324 |
return $imageManipulator->getImageData(); |
| 3325 |
} |
| 3326 |
|
| 3327 |
/** |
| 3328 |
* {@inheritDoc} |
| 3329 |
*/ |
| 3330 |
public function handleAjaxRequest(): void { |
| 3331 |
// AJAX uploads are non-JSON |
| 3332 |
if (isset($_POST['action']) && ($_POST['action'] == 'ajaxCertUpload')) { |
| 3333 |
$this->ajaxUploadCert(); |
| 3334 |
return; |
| 3335 |
} |
| 3336 |
if ((isset($_POST['action']) && ($_POST['action'] == 'ajaxPhotoUpload')) |
| 3337 |
|| (isset($_GET['action']) && ($_GET['action'] == 'ajaxPhotoUpload'))) { |
| 3338 |
$this->ajaxUploadPhoto(); |
| 3339 |
return; |
| 3340 |
} |
| 3341 |
$jsonInput = json_decode($_POST['jsonInput'], true); |
| 3342 |
$jsonReturn = self::invalidAjaxRequest(); |
| 3343 |
if (isset($jsonInput['action'])) { |
| 3344 |
if ($jsonInput['action'] == 'deleteCert') { |
| 3345 |
$jsonReturn = $this->ajaxDeleteSelfServiceUserCertificate($jsonInput); |
| 3346 |
} |
| 3347 |
elseif ($jsonInput['action'] == 'deletePhoto') { |
| 3348 |
$jsonReturn = $this->ajaxDeleteSelfServicePhoto(); |
| 3349 |
} |
| 3350 |
} |
| 3351 |
echo json_encode($jsonReturn); |
| 3352 |
} |
| 3353 |
|
| 3354 |
/** |
| 3355 |
* Handles an AJAX certificate file upload and prints the JSON result. |
| 3356 |
*/ |
| 3357 |
private function ajaxUploadCert(): void { |
| 3358 |
$result = ['success' => true]; |
| 3359 |
if (!isset($_POST['file']) || (strlen($_POST['file']) < 100)) { |
| 3360 |
$result = ['error' => _('No file received.')]; |
| 3361 |
} |
| 3362 |
else { |
| 3363 |
$data = base64_decode($_POST['file']); |
| 3364 |
if (str_starts_with($data, '-----BEGIN CERTIFICATE-----')) { |
| 3365 |
$pemData = str_replace("\r", '', $data); |
| 3366 |
$pemData = explode("\n", $pemData); |
| 3367 |
array_shift($pemData); |
| 3368 |
$last = array_pop($pemData); |
| 3369 |
while (($last != '-----END CERTIFICATE-----') && count($pemData) > 2) { |
| 3370 |
$last = array_pop($pemData); |
| 3371 |
} |
| 3372 |
$pemData = implode('', $pemData); |
| 3373 |
$data = base64_decode($pemData); |
| 3374 |
} |
| 3375 |
$_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST][] = $data; |
| 3376 |
$_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST] = array_unique($_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST]); |
| 3377 |
ob_start(); |
| 3378 |
$contentElement = $this->getSelfServiceUserCertificates(); |
| 3379 |
ob_end_clean(); |
| 3380 |
ob_start(); |
| 3381 |
parseHtml(null, $contentElement, [], true); |
| 3382 |
$content = ob_get_contents(); |
| 3383 |
ob_end_clean(); |
| 3384 |
$result['html'] = $content; |
| 3385 |
} |
| 3386 |
echo json_encode($result); |
| 3387 |
} |
| 3388 |
|
| 3389 |
/** |
| 3390 |
* Handles an AJAX photo file upload and prints the JSON result. |
| 3391 |
*/ |
| 3392 |
private function ajaxUploadPhoto(): void { |
| 3393 |
$result = ['success' => true]; |
| 3394 |
if ((!isset($_POST['file']) || (strlen($_POST['file']) < 100)) && empty($_POST['webcamData'])) { |
| 3395 |
$result = ['error' => _('No file received.')]; |
| 3396 |
} |
| 3397 |
else { |
| 3398 |
if (empty($_POST['webcamData'])) { |
| 3399 |
$data = base64_decode($_POST['file']); |
| 3400 |
} |
| 3401 |
else { |
| 3402 |
$data = $_POST['webcamData']; |
| 3403 |
$data = str_replace('data:image/png;base64,', '', $data); |
| 3404 |
$data = base64_decode($data); |
| 3405 |
} |
| 3406 |
try { |
| 3407 |
include_once __DIR__ . '/../imageutils.inc'; |
| 3408 |
$imageManipulator = ImageManipulationFactory::getImageManipulator($data); |
| 3409 |
$imageManipulator->convertToJpeg(); |
| 3410 |
$data = $imageManipulator->getImageData(); |
| 3411 |
} |
| 3412 |
catch (Exception $e) { |
| 3413 |
$result = ['success' => false, 'error' => htmlspecialchars($e->getMessage())]; |
| 3414 |
echo json_encode($result); |
| 3415 |
return; |
| 3416 |
} |
| 3417 |
$_SESSION[inetOrgPerson::SESS_PHOTO] = $data; |
| 3418 |
ob_start(); |
| 3419 |
$contentElement = $this->getSelfServicePhoto(false, true); |
| 3420 |
ob_end_clean(); |
| 3421 |
ob_start(); |
| 3422 |
parseHtml(null, $contentElement, [], true); |
| 3423 |
$content = ob_get_contents(); |
| 3424 |
ob_end_clean(); |
| 3425 |
$result['html'] = $content; |
| 3426 |
} |
| 3427 |
echo json_encode($result); |
| 3428 |
} |
| 3429 |
|
| 3430 |
/** |
| 3431 |
* Manages the deletion of a photo. |
| 3432 |
* |
| 3433 |
* @return array<string, string> response |
| 3434 |
*/ |
| 3435 |
private function ajaxDeleteSelfServicePhoto(): array { |
| 3436 |
$_SESSION[self::SESS_PHOTO] = null; |
| 3437 |
ob_start(); |
| 3438 |
$contentElement = $this->getSelfServicePhoto(false, false); |
| 3439 |
ob_end_clean(); |
| 3440 |
ob_start(); |
| 3441 |
parseHtml(null, $contentElement, [], true); |
| 3442 |
$content = ob_get_contents(); |
| 3443 |
ob_end_clean(); |
| 3444 |
return [ |
| 3445 |
'errorsOccurred' => 'false', |
| 3446 |
'html' => $content, |
| 3447 |
]; |
| 3448 |
} |
| 3449 |
|
| 3450 |
/** |
| 3451 |
* Manages the deletion of a certificate. |
| 3452 |
* |
| 3453 |
* @param array<string, string> $data JSON data |
| 3454 |
* @return array<string, string> response |
| 3455 |
*/ |
| 3456 |
private function ajaxDeleteSelfServiceUserCertificate($data): array { |
| 3457 |
if (!isset($data['id'])) { |
| 3458 |
return self::invalidAjaxRequest(); |
| 3459 |
} |
| 3460 |
$index = $data['id']; |
| 3461 |
if (array_key_exists($index, $_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST])) { |
| 3462 |
unset($_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST][$index]); |
| 3463 |
$_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST] = array_values($_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST]); |
| 3464 |
} |
| 3465 |
ob_start(); |
| 3466 |
$contentElement = $this->getSelfServiceUserCertificates(); |
| 3467 |
ob_end_clean(); |
| 3468 |
ob_start(); |
| 3469 |
parseHtml(null, $contentElement, [], true); |
| 3470 |
$content = ob_get_contents(); |
| 3471 |
ob_end_clean(); |
| 3472 |
return [ |
| 3473 |
'errorsOccurred' => 'false', |
| 3474 |
'html' => $content, |
| 3475 |
]; |
| 3476 |
} |
| 3477 |
|
| 3478 |
/** |
| 3479 |
* Invalid AJAX request received. |
| 3480 |
* |
| 3481 |
* @param string|null $message error message |
| 3482 |
* @return array<string, string|null> response |
| 3483 |
*/ |
| 3484 |
public static function invalidAjaxRequest($message = null): array { |
| 3485 |
if ($message == null) { |
| 3486 |
$message = _('Invalid request'); |
| 3487 |
} |
| 3488 |
return ['errorsOccurred' => 'true', 'errormessage' => $message]; |
| 3489 |
} |
| 3490 |
|
| 3491 |
/** |
| 3492 |
* {@inheritDoc} |
| 3493 |
*/ |
| 3494 |
public function managesPasswordAttributes(): bool { |
| 3495 |
if (!$this->isUnixActive()) { |
| 3496 |
return !$this->isAdminReadOnly('userPassword'); |
| 3497 |
} |
| 3498 |
return false; |
| 3499 |
} |
| 3500 |
|
| 3501 |
/** |
| 3502 |
* {@inheritDoc} |
| 3503 |
*/ |
| 3504 |
public function supportsForcePasswordChange(): bool { |
| 3505 |
return false; |
| 3506 |
} |
| 3507 |
|
| 3508 |
/** |
| 3509 |
* {@inheritDoc} |
| 3510 |
*/ |
| 3511 |
public function passwordChangeRequested(string $password, array $modules, bool $forcePasswordChange): array { |
| 3512 |
if (!in_array(static::class, $modules)) { |
| 3513 |
return []; |
| 3514 |
} |
| 3515 |
// check password strength |
| 3516 |
$user = empty($this->attributes['uid'][0]) ? null : $this->attributes['uid'][0]; |
| 3517 |
$additionalAttrs = []; |
| 3518 |
if (!empty($this->attributes['sn'][0])) { |
| 3519 |
$additionalAttrs[] = $this->attributes['sn'][0]; |
| 3520 |
} |
| 3521 |
if (!empty($this->attributes['givenName'][0])) { |
| 3522 |
$additionalAttrs[] = $this->attributes['givenName'][0]; |
| 3523 |
} |
| 3524 |
$checkResult = checkPasswordStrength($password, $user, $additionalAttrs); |
| 3525 |
if (!$checkResult->isValid()) { |
| 3526 |
return [['ERROR', $checkResult->getTextMessage()]]; |
| 3527 |
} |
| 3528 |
// set new password |
| 3529 |
$this->clearTextPassword = $password; |
| 3530 |
// set SASL password |
| 3531 |
if (!empty($this->attributes['uid'][0]) && !empty($this->moduleSettings['posixAccount_pwdHash'][0]) |
| 3532 |
&& ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL')) { |
| 3533 |
$this->attributes['userpassword'][0] = '{SASL}' . $this->attributes['uid'][0]; |
| 3534 |
} |
| 3535 |
// delay on ldap_exop |
| 3536 |
elseif (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) { |
| 3537 |
logNewMessage(LOG_DEBUG, 'Setting password in post action, exop'); |
| 3538 |
} |
| 3539 |
// set normal password |
| 3540 |
else { |
| 3541 |
$this->attributes['userpassword'][0] = pwd_hash($password, true, $this->moduleSettings['posixAccount_pwdHash'][0]); |
| 3542 |
} |
| 3543 |
return []; |
| 3544 |
} |
| 3545 |
|
| 3546 |
/** |
| 3547 |
* Loads cached data from LDAP such as departmets etc. |
| 3548 |
*/ |
| 3549 |
private function initCache(): void { |
| 3550 |
if ($this->departmentCache !== null) { |
| 3551 |
return; |
| 3552 |
} |
| 3553 |
$attrs = []; |
| 3554 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) { |
| 3555 |
$attrs[] = 'departmentNumber'; |
| 3556 |
} |
| 3557 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) { |
| 3558 |
$attrs[] = 'ou'; |
| 3559 |
} |
| 3560 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) { |
| 3561 |
$attrs[] = 'o'; |
| 3562 |
} |
| 3563 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) { |
| 3564 |
$attrs[] = 'title'; |
| 3565 |
} |
| 3566 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) { |
| 3567 |
$attrs[] = 'employeeType'; |
| 3568 |
} |
| 3569 |
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) { |
| 3570 |
$attrs[] = 'businessCategory'; |
| 3571 |
} |
| 3572 |
$departments = []; |
| 3573 |
$ous = []; |
| 3574 |
$os = []; |
| 3575 |
$titles = []; |
| 3576 |
$employeeTypes = []; |
| 3577 |
$businessCategories = []; |
| 3578 |
if ($attrs !== []) { |
| 3579 |
$result = searchLDAPByFilter('(objectClass=inetOrgPerson)', $attrs, [$this->get_scope()]); |
| 3580 |
foreach ($result as $attributes) { |
| 3581 |
if (isset($attributes['departmentnumber'])) { |
| 3582 |
foreach ($attributes['departmentnumber'] as $val) { |
| 3583 |
$departments[] = $val; |
| 3584 |
} |
| 3585 |
} |
| 3586 |
if (isset($attributes['ou'])) { |
| 3587 |
foreach ($attributes['ou'] as $val) { |
| 3588 |
$ous[] = $val; |
| 3589 |
} |
| 3590 |
} |
| 3591 |
if (isset($attributes['o'])) { |
| 3592 |
foreach ($attributes['o'] as $val) { |
| 3593 |
$os[] = $val; |
| 3594 |
} |
| 3595 |
} |
| 3596 |
if (isset($attributes['title'])) { |
| 3597 |
foreach ($attributes['title'] as $val) { |
| 3598 |
$titles[] = $val; |
| 3599 |
} |
| 3600 |
} |
| 3601 |
if (isset($attributes['employeetype'])) { |
| 3602 |
foreach ($attributes['employeetype'] as $val) { |
| 3603 |
$employeeTypes[] = $val; |
| 3604 |
} |
| 3605 |
} |
| 3606 |
if (isset($attributes['businesscategory'])) { |
| 3607 |
foreach ($attributes['businesscategory'] as $val) { |
| 3608 |
$businessCategories[] = $val; |
| 3609 |
} |
| 3610 |
} |
| 3611 |
} |
| 3612 |
} |
| 3613 |
$this->departmentCache = array_values(array_unique($departments)); |
| 3614 |
$this->oCache = array_values(array_unique($os)); |
| 3615 |
$this->ouCache = array_values(array_unique($ous)); |
| 3616 |
$this->titleCache = array_values(array_unique($titles)); |
| 3617 |
$this->employeeTypeCache = array_values(array_unique($employeeTypes)); |
| 3618 |
$this->businessCategoryCache = array_values(array_unique($businessCategories)); |
| 3619 |
} |
| 3620 |
|
| 3621 |
/** |
| 3622 |
* Returns if the attribute is read-only in admin interface. |
| 3623 |
* |
| 3624 |
* @param String $attrName attribute name |
| 3625 |
* @return boolean attribute is read-only |
| 3626 |
*/ |
| 3627 |
private function isAdminReadOnly($attrName) { |
| 3628 |
// for new accounts all fields can be edited |
| 3629 |
if ($this->getAccountContainer()->isNewAccount) { |
| 3630 |
return false; |
| 3631 |
} |
| 3632 |
return $this->isBooleanConfigOptionSet('inetOrgPerson_readOnly_' . $attrName); |
| 3633 |
} |
| 3634 |
|
| 3635 |
/** |
| 3636 |
* {@inheritDoc} |
| 3637 |
*/ |
| 3638 |
public function get_configOptions(array $scopes, array $allScopes): htmlElement|array { |
| 3639 |
$configContainer = new htmlResponsiveRow(); |
| 3640 |
if (isset($_SESSION['conf_config'])) { |
| 3641 |
// add password hash type if posixAccount is inactive |
| 3642 |
$unixModuleFound = false; |
| 3643 |
$typeManager = new TypeManager($_SESSION['conf_config']); |
| 3644 |
$types = $typeManager->getConfiguredTypesForScopes(['user', 'group']); |
| 3645 |
foreach ($types as $type) { |
| 3646 |
$modules = $type->getModules(); |
| 3647 |
if (in_array('posixAccount', $modules) || in_array('posixGroup', $modules)) { |
| 3648 |
$unixModuleFound = true; |
| 3649 |
break; |
| 3650 |
} |
| 3651 |
} |
| 3652 |
if (!$unixModuleFound) { |
| 3653 |
$optionsSelected = ['CRYPT-SHA512']; |
| 3654 |
$hashOption = new htmlResponsiveSelect('posixAccount_pwdHash', getSupportedHashTypes(), $optionsSelected, _("Password hash type"), 'pwdHash'); |
| 3655 |
$configContainer->add($hashOption); |
| 3656 |
} |
| 3657 |
} |
| 3658 |
$configContainerHead = new htmlGroup(); |
| 3659 |
$configContainerHead->addElement(new htmlOutputText(_('Hidden options'))); |
| 3660 |
$configContainerHead->addElement(new htmlHelpLink('hiddenOptions')); |
| 3661 |
$configContainer->add($configContainerHead); |
| 3662 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideDescription', false, _('Description'), null, true), 12, 4); |
| 3663 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideStreet', false, _('Street'), null, true), 12, 4); |
| 3664 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePostOfficeBox', false, _('Post office box'), null, true), 12, 4); |
| 3665 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePostalCode', false, _('Postal code'), null, true), 12, 4); |
| 3666 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideLocation', false, _('Location'), null, true), 12, 4); |
| 3667 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideState', false, _('State'), null, true), 12, 4); |
| 3668 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePostalAddress', false, _('Postal address'), null, true), 12, 4); |
| 3669 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideRegisteredAddress', false, _('Registered address'), null, true), 12, 4); |
| 3670 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideOfficeName', false, _('Office name'), null, true), 12, 4); |
| 3671 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideRoomNumber', false, _('Room number'), null, true), 12, 4); |
| 3672 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideTelephoneNumber', false, _('Telephone number'), null, true), 12, 4); |
| 3673 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideHomeTelephoneNumber', false, _('Home telephone number'), null, true), 12, 4); |
| 3674 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideMobileNumber', false, _('Mobile number'), null, true), 12, 4); |
| 3675 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideFaxNumber', false, _('Fax number'), null, true), 12, 4); |
| 3676 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePager', true, _('Pager'), null, true), 12, 4); |
| 3677 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideEMailAddress', false, _('Email address'), null, true), 12, 4); |
| 3678 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideJobTitle', false, _('Job title'), null, true), 12, 4); |
| 3679 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideCarLicense', false, _('Car license'), null, true), 12, 4); |
| 3680 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideEmployeeType', false, _('Employee type'), null, true), 12, 4); |
| 3681 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideBusinessCategory', false, _('Business category'), null, true), 12, 4); |
| 3682 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideDepartments', false, _('Department'), null, true), 12, 4); |
| 3683 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideManager', false, _('Manager'), null, true), 12, 4); |
| 3684 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideOu', false, _('Organisational unit'), null, true), 12, 4); |
| 3685 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideO', false, _('Organisation'), null, true), 12, 4); |
| 3686 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideEmployeeNumber', false, _('Employee number'), null, true), 12, 4); |
| 3687 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideInitials', false, _('Initials'), null, true), 12, 4); |
| 3688 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideLabeledURI', false, _('Web site'), null, true), 12, 4); |
| 3689 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideuserCertificate', false, _('User certificates'), null, true), 12, 4); |
| 3690 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidejpegPhoto', false, _('Photo'), null, true), 12, 4); |
| 3691 |
if (isset($_SESSION['conf_config'])) { |
| 3692 |
$confActiveUserModules = $_SESSION['conf_config']->get_AccountModules('user'); |
| 3693 |
if (!in_array('sambaSamAccount', $confActiveUserModules)) { |
| 3694 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidedisplayName', true, _('Display name'), null, true), 12, 4); |
| 3695 |
} |
| 3696 |
// option to hide uid |
| 3697 |
if (!in_array('posixAccount', $confActiveUserModules)) { |
| 3698 |
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideUID', false, _('User name'), null, true), 12, 4); |
| 3699 |
} |
| 3700 |
else { |
| 3701 |
$configContainer->add(new htmlOutputText(''), 0, 4); |
| 3702 |
} |
| 3703 |
} |
| 3704 |
$configContainer->addVerticalSpacer('1rem'); |
| 3705 |
$advancedOptions = new htmlResponsiveRow(); |
| 3706 |
$advancedOptions->add(new htmlResponsiveInputCheckbox('inetOrgPerson_addAddressbook', false, _('Add addressbook (ou=addressbook)'), 'addAddressbook')); |
| 3707 |
$advancedOptions->add(new htmlSubTitle(_('Read-only fields'))); |
| 3708 |
$readOnlyOptions = [ |
| 3709 |
_('Description') => 'inetOrgPerson_readOnly_description', _('Street') => 'inetOrgPerson_readOnly_street', |
| 3710 |
_('First name') => 'inetOrgPerson_readOnly_givenName', _('Last name') => 'inetOrgPerson_readOnly_sn', |
| 3711 |
_('Post office box') => 'inetOrgPerson_readOnly_postOfficeBox', _('Postal code') => 'inetOrgPerson_readOnly_postalCode', |
| 3712 |
_('Location') => 'inetOrgPerson_readOnly_l', _('State') => 'inetOrgPerson_readOnly_st', |
| 3713 |
_('Postal address') => 'inetOrgPerson_readOnly_postalAddress', _('Registered address') => 'inetOrgPerson_readOnly_registeredAddress', |
| 3714 |
_('Office name') => 'inetOrgPerson_readOnly_physicalDeliveryOfficeName', _('Room number') => 'inetOrgPerson_readOnly_roomNumber', |
| 3715 |
_('Telephone number') => 'inetOrgPerson_readOnly_telephoneNumber', _('Home telephone number') => 'inetOrgPerson_readOnly_homePhone', |
| 3716 |
_('Mobile number') => 'inetOrgPerson_readOnly_mobile', _('Fax number') => 'inetOrgPerson_readOnly_facsimileTelephoneNumber', |
| 3717 |
_('Pager') => 'inetOrgPerson_readOnly_pager', _('Email address') => 'inetOrgPerson_readOnly_mail', |
| 3718 |
_('Web site') => 'inetOrgPerson_readOnly_labeledURI', _('Job title') => 'inetOrgPerson_readOnly_title', |
| 3719 |
_('Car license') => 'inetOrgPerson_readOnly_carLicense', _('Employee type') => 'inetOrgPerson_readOnly_employeeType', |
| 3720 |
_('Business category') => 'inetOrgPerson_readOnly_businessCategory', |
| 3721 |
_('Department') => 'inetOrgPerson_readOnly_departmentNumber', _('Manager') => 'inetOrgPerson_readOnly_manager', |
| 3722 |
_('Organisation') => 'inetOrgPerson_readOnly_o', _('Organisational unit') => 'inetOrgPerson_readOnly_ou', |
| 3723 |
_('Employee number') => 'inetOrgPerson_readOnly_employeeNumber', _('Initials') => 'inetOrgPerson_readOnly_initials', |
| 3724 |
_('Photo') => 'inetOrgPerson_readOnly_jpegPhoto', _('Password') => 'inetOrgPerson_readOnly_userPassword' |
| 3725 |
]; |
| 3726 |
if (isset($_SESSION['conf_config'])) { |
| 3727 |
$readOnlyOptions[_('User name')] = 'inetOrgPerson_readOnly_uid'; |
| 3728 |
$readOnlyOptions[_('Common name')] = 'inetOrgPerson_readOnly_cn'; |
| 3729 |
} |
| 3730 |
ksort($readOnlyOptions); |
| 3731 |
foreach ($readOnlyOptions as $label => $id) { |
| 3732 |
$advancedOptions->add(new htmlResponsiveInputCheckbox($id, false, $label, null, true), 12, 4); |
| 3733 |
} |
| 3734 |
$advancedOptions->add(new htmlSubTitle(_('Photo'))); |
| 3735 |
$advancedOptions->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, 'crop')); |
| 3736 |
$advancedOptions->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, 'crop')); |
| 3737 |
$advancedOptions->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize')); |
| 3738 |
$advancedOptionsAccordion = new htmlAccordion('inetOrgPersonAdvancedOptions', [_('Advanced options') => $advancedOptions], false); |
| 3739 |
$configContainer->add($advancedOptionsAccordion); |
| 3740 |
return $configContainer; |
| 3741 |
} |
| 3742 |
|
| 3743 |
/** |
| 3744 |
* Checks if the given email address already exists in LDAP. |
| 3745 |
* |
| 3746 |
* @param string $mail email address |
| 3747 |
* @return bool true if already exists |
| 3748 |
*/ |
| 3749 |
private function emailExists(string $mail): bool { |
| 3750 |
if (empty($mail)) { |
| 3751 |
return false; |
| 3752 |
} |
| 3753 |
if (isset($this->emailCheckCache[$mail])) { |
| 3754 |
return $this->emailCheckCache[$mail]; |
| 3755 |
} |
| 3756 |
$result = searchLDAPByAttribute('mail', $mail, 'inetOrgPerson', ['dn'], ['user']); |
| 3757 |
$this->emailCheckCache[$mail] = (count($result) > 0); |
| 3758 |
return $this->emailCheckCache[$mail]; |
| 3759 |
} |
| 3760 |
|
| 3761 |
/** |
| 3762 |
* Returns if the Unix module is also active. |
| 3763 |
* |
| 3764 |
* @param string[] $modules active account modules |
| 3765 |
* @return boolean Unix is active |
| 3766 |
*/ |
| 3767 |
private function isUnixActive($modules = null) { |
| 3768 |
if (!empty($modules)) { |
| 3769 |
return in_array('posixAccount', $modules); |
| 3770 |
} |
| 3771 |
if ($this->getAccountContainer() == null) { |
| 3772 |
return false; |
| 3773 |
} |
| 3774 |
$modules = $this->getAccountContainer()->get_type()->getModules(); |
| 3775 |
return in_array('posixAccount', $modules); |
| 3776 |
} |
| 3777 |
|
| 3778 |
/** |
| 3779 |
* Returns if the Samba 3 module is also active. |
| 3780 |
* |
| 3781 |
* @param string[] $modules active account modules |
| 3782 |
* @return boolean Samba 3 is active |
| 3783 |
*/ |
| 3784 |
private function isSamba3Active($modules = null) { |
| 3785 |
if (!empty($modules)) { |
| 3786 |
return in_array('sambaSamAccount', $modules); |
| 3787 |
} |
| 3788 |
if ($this->getAccountContainer() == null) { |
| 3789 |
return false; |
| 3790 |
} |
| 3791 |
$modules = $this->getAccountContainer()->get_type()->getModules(); |
| 3792 |
return in_array('sambaSamAccount', $modules); |
| 3793 |
} |
| 3794 |
|
| 3795 |
/** |
| 3796 |
* {@inheritdoc} |
| 3797 |
*/ |
| 3798 |
public function getWildcardTargetAttributeNames(): array { |
| 3799 |
$attributeNames = ['mail', 'description', 'postalAddress', 'uid', 'cn', |
| 3800 |
'registeredAddress', 'labeledURI']; |
| 3801 |
if ($this->isUnixActive()) { |
| 3802 |
$attributeNames[] = 'uid'; |
| 3803 |
} |
| 3804 |
return $attributeNames; |
| 3805 |
} |
| 3806 |
|
| 3807 |
/** |
| 3808 |
* {@inheritdoc} |
| 3809 |
*/ |
| 3810 |
public function getWildCardReplacements(): array { |
| 3811 |
$replacements = []; |
| 3812 |
// first name |
| 3813 |
if (!empty($_POST['givenName'])) { |
| 3814 |
$replacements['firstname'] = $_POST['givenName']; |
| 3815 |
} |
| 3816 |
elseif (!empty($this->attributes['givenName'][0])) { |
| 3817 |
$replacements['firstname'] = $this->attributes['givenName'][0]; |
| 3818 |
} |
| 3819 |
// last name |
| 3820 |
if (!empty($_POST['sn'])) { |
| 3821 |
$replacements['lastname'] = $_POST['sn']; |
| 3822 |
} |
| 3823 |
elseif (!empty($this->attributes['sn'][0])) { |
| 3824 |
$replacements['lastname'] = $this->attributes['sn'][0]; |
| 3825 |
} |
| 3826 |
// user name |
| 3827 |
if (!$this->isUnixActive()) { |
| 3828 |
if (!empty($_POST['uid'])) { |
| 3829 |
$replacements['user'] = $_POST['uid']; |
| 3830 |
} |
| 3831 |
elseif (!empty($this->attributes['uid'][0])) { |
| 3832 |
$replacements['user'] = $this->attributes['uid'][0]; |
| 3833 |
} |
| 3834 |
} |
| 3835 |
// cn |
| 3836 |
if (!empty($_POST['cn_0'])) { |
| 3837 |
$replacements['commonname'] = $_POST['cn_0']; |
| 3838 |
} |
| 3839 |
elseif (!empty($this->attributes['cn'][0])) { |
| 3840 |
$replacements['commonname'] = $this->attributes['cn'][0]; |
| 3841 |
} |
| 3842 |
// mail |
| 3843 |
if (!empty($_POST['mail_0'])) { |
| 3844 |
$replacements['email'] = $_POST['mail_0']; |
| 3845 |
} |
| 3846 |
elseif (!empty($this->attributes['mail'][0])) { |
| 3847 |
$replacements['email'] = $this->attributes['mail'][0]; |
| 3848 |
} |
| 3849 |
return $replacements; |
| 3850 |
} |
| 3851 |
|
| 3852 |
/** |
| 3853 |
* Returns if the password of the current account is locked. |
| 3854 |
* |
| 3855 |
* @param array<string, string[]|string>|null $attributes LDAP attribute data |
| 3856 |
* @return bool password is locked |
| 3857 |
*/ |
| 3858 |
public function isLocked(?array $attributes = null): bool { |
| 3859 |
if ($attributes === null) { |
| 3860 |
$attributes = array_change_key_case($this->attributes); |
| 3861 |
} |
| 3862 |
return isset($attributes['userpassword'][0]) |
| 3863 |
&& !pwd_is_enabled($attributes['userpassword'][0]); |
| 3864 |
} |
| 3865 |
|
| 3866 |
/** |
| 3867 |
* @inheritDoc |
| 3868 |
*/ |
| 3869 |
public function supportsPasswordQuickChangePage(): bool { |
| 3870 |
return true; |
| 3871 |
} |
| 3872 |
|
| 3873 |
/** |
| 3874 |
* @inheritDoc |
| 3875 |
*/ |
| 3876 |
public function addPasswordQuickChangeAccountDetails(htmlResponsiveRow $row): void { |
| 3877 |
if (!$this->isUnixActive() && !empty($this->attributes['uid'][0])) { |
| 3878 |
$row->addLabel(new htmlOutputText(_('User name'))); |
| 3879 |
$row->addField(new htmlOutputText($this->attributes['uid'][0])); |
| 3880 |
} |
| 3881 |
$nameParts = []; |
| 3882 |
if (isset($this->attributes['givenName'][0])) { |
| 3883 |
$nameParts[] = $this->attributes['givenName'][0]; |
| 3884 |
} |
| 3885 |
if (isset($this->attributes['sn'][0])) { |
| 3886 |
$nameParts[] = $this->attributes['sn'][0]; |
| 3887 |
} |
| 3888 |
if (!empty($nameParts)) { |
| 3889 |
$row->addLabel(new htmlOutputText(_('Full name'))); |
| 3890 |
$row->addField(new htmlOutputText(implode(' ', $nameParts))); |
| 3891 |
} |
| 3892 |
if (!empty($this->attributes['mail'][0])) { |
| 3893 |
$row->addLabel(new htmlOutputText(_('Email address'))); |
| 3894 |
$row->addField(new htmlOutputText($this->attributes['mail'][0])); |
| 3895 |
} |
| 3896 |
if (!empty($this->attributes['telephoneNumber'][0])) { |
| 3897 |
$row->addLabel(new htmlOutputText(_('Telephone number'))); |
| 3898 |
$row->addField(new htmlOutputText($this->attributes['telephoneNumber'][0])); |
| 3899 |
} |
| 3900 |
if (!empty($this->attributes['mobile'][0])) { |
| 3901 |
$row->addLabel(new htmlOutputText(_('Mobile number'))); |
| 3902 |
$row->addField(new htmlOutputText($this->attributes['mobile'][0])); |
| 3903 |
} |
| 3904 |
} |
| 3905 |
|
| 3906 |
/** |
| 3907 |
* @inheritDoc |
| 3908 |
*/ |
| 3909 |
public function getPasswordQuickChangeOptions(bool $forcePasswordChangeByDefault): array { |
| 3910 |
if ($this->isUnixActive() && in_array_ignore_case('posixAccount', $this->attributes['objectClass'])) { |
| 3911 |
return []; |
| 3912 |
} |
| 3913 |
if (!in_array_ignore_case('inetOrgPerson', $this->attributes['objectClass'])) { |
| 3914 |
return []; |
| 3915 |
} |
| 3916 |
return [ |
| 3917 |
new PasswordQuickChangeOption('updateUnixPwd', _('Change password')) |
| 3918 |
]; |
| 3919 |
} |
| 3920 |
|
| 3921 |
/** |
| 3922 |
* @inheritDoc |
| 3923 |
*/ |
| 3924 |
public function getPasswordQuickChangeChanges(string $password): array { |
| 3925 |
if ($this->isUnixActive() && in_array_ignore_case('posixAccount', $this->attributes['objectClass'])) { |
| 3926 |
return []; |
| 3927 |
} |
| 3928 |
if (!in_array_ignore_case('inetOrgPerson', $this->attributes['objectClass'])) { |
| 3929 |
return []; |
| 3930 |
} |
| 3931 |
$attrs = []; |
| 3932 |
if (isset($_POST['updateUnixPwd'])) { |
| 3933 |
$hashType = $this->moduleSettings['posixAccount_pwdHash'][0]; |
| 3934 |
if ($hashType === 'LDAP_EXOP') { |
| 3935 |
$this->clearTextPassword = $password; |
| 3936 |
} |
| 3937 |
else { |
| 3938 |
$attrs['userpassword'][0] = pwd_hash($password, true, $hashType); |
| 3939 |
} |
| 3940 |
} |
| 3941 |
return $attrs; |
| 3942 |
} |
| 3943 |
|
| 3944 |
/** |
| 3945 |
* @inheritDoc |
| 3946 |
*/ |
| 3947 |
public function getPasswordQuickChangePasswordStrengthUserName(): ?string { |
| 3948 |
return $this->attributes['uid'][0] ?? null; |
| 3949 |
} |
| 3950 |
|
| 3951 |
/** |
| 3952 |
* @inheritDoc |
| 3953 |
*/ |
| 3954 |
public function getPasswordQuickChangePasswordStrengthAttributes(): array { |
| 3955 |
$values = []; |
| 3956 |
if (isset($this->attributes['sn'][0])) { |
| 3957 |
$values[] = $this->attributes['sn'][0]; |
| 3958 |
} |
| 3959 |
if (isset($this->attributes['givenName'][0])) { |
| 3960 |
$values[] = $this->attributes['givenName'][0]; |
| 3961 |
} |
| 3962 |
return $values; |
| 3963 |
} |
| 3964 |
|
| 3965 |
/** |
| 3966 |
* @inheritDoc |
| 3967 |
*/ |
| 3968 |
public function getPasswordQuickChangeIsPasswordInHistory(string $password): bool { |
| 3969 |
return false; |
| 3970 |
} |
| 3971 |
|
| 3972 |
/** |
| 3973 |
* @inheritDoc |
| 3974 |
*/ |
| 3975 |
public function getAccountStatusDetails(ConfiguredType $type, ?array &$attributes): array { |
| 3976 |
if ($this->isUnixActive($type->getModules())) { |
| 3977 |
return []; |
| 3978 |
} |
| 3979 |
if ($attributes === null) { |
| 3980 |
$attributes = $this->attributes; |
| 3981 |
} |
| 3982 |
$details = []; |
| 3983 |
if (self::isLocked($attributes)) { |
| 3984 |
$details[] = AccountStatusDetails::newLocked(_('Personal'), self::STATUS_PASSWORD_LOCKED); |
| 3985 |
} |
| 3986 |
return $details; |
| 3987 |
} |
| 3988 |
|
| 3989 |
/** |
| 3990 |
* @inheritDoc |
| 3991 |
*/ |
| 3992 |
public function getAccountStatusRequiredAttributes(ConfiguredType $type): array { |
| 3993 |
if ($this->isUnixActive($type->getModules())) { |
| 3994 |
return []; |
| 3995 |
} |
| 3996 |
return ['userpassword']; |
| 3997 |
} |
| 3998 |
|
| 3999 |
/** |
| 4000 |
* @inheritDoc |
| 4001 |
*/ |
| 4002 |
public function getAccountStatusPossibleLockOptions(ConfiguredType $type, ?array &$attributes): array { |
| 4003 |
if ($this->isUnixActive($type->getModules())) { |
| 4004 |
return []; |
| 4005 |
} |
| 4006 |
if ($attributes === null) { |
| 4007 |
$attributes = $this->attributes; |
| 4008 |
} |
| 4009 |
$options = []; |
| 4010 |
if (!self::isLocked($attributes) && isset($attributes['userpassword'][0]) && pwd_is_lockable($attributes['userpassword'][0])) { |
| 4011 |
$options[] = AccountStatusDetails::newLocked(_('Personal'), self::STATUS_PASSWORD_LOCKED); |
| 4012 |
} |
| 4013 |
return $options; |
| 4014 |
} |
| 4015 |
|
| 4016 |
/** |
| 4017 |
* @inheritDoc |
| 4018 |
*/ |
| 4019 |
public function accountStatusPerformLock(ConfiguredType $type, ?array &$attributes, array $lockIds): void { |
| 4020 |
if ($this->isUnixActive($type->getModules())) { |
| 4021 |
return; |
| 4022 |
} |
| 4023 |
if ($attributes === null) { |
| 4024 |
$attributes = &$this->attributes; |
| 4025 |
} |
| 4026 |
if (in_array(self::STATUS_PASSWORD_LOCKED, $lockIds)) { |
| 4027 |
$attributes['userpassword'][0] = pwd_disable($attributes['userpassword'][0]); |
| 4028 |
} |
| 4029 |
} |
| 4030 |
|
| 4031 |
/** |
| 4032 |
* @inheritDoc |
| 4033 |
*/ |
| 4034 |
public function accountStatusPerformUnlock(ConfiguredType $type, ?array &$attributes, array $lockIds): void { |
| 4035 |
if ($this->isUnixActive($type->getModules())) { |
| 4036 |
return; |
| 4037 |
} |
| 4038 |
if ($attributes === null) { |
| 4039 |
$attributes = &$this->attributes; |
| 4040 |
} |
| 4041 |
if (in_array(self::STATUS_PASSWORD_LOCKED, $lockIds)) { |
| 4042 |
$attributes['userpassword'][0] = pwd_enable($attributes['userpassword'][0]); |
| 4043 |
} |
| 4044 |
} |
| 4045 |
|
| 4046 |
/** |
| 4047 |
* @inheritDoc |
| 4048 |
*/ |
| 4049 |
public function getListAttributeDescriptions(ConfiguredType $type): array { |
| 4050 |
return [ |
| 4051 |
'givenname' => _('First name'), |
| 4052 |
'sn' => _('Last name'), |
| 4053 |
'description' => _('Description'), |
| 4054 |
'street' => _('Street'), |
| 4055 |
'postofficebox' => _('Post office box'), |
| 4056 |
'postalcode' => _('Postal code'), |
| 4057 |
'l' => _('Location'), |
| 4058 |
'st' => _('State'), |
| 4059 |
'postaladdress' => _('Postal address'), |
| 4060 |
'registeredaddress' => _('Registered address'), |
| 4061 |
'officename' => _('Office name'), |
| 4062 |
'roomnumber' => _('Room number'), |
| 4063 |
'telephonenumber' => _('Telephone number'), |
| 4064 |
'homephone' => _('Home telephone number'), |
| 4065 |
'mobiletelephonenumber' => _('Mobile number'), |
| 4066 |
'pager' => _('Pager'), |
| 4067 |
'mail' => _('Email address'), |
| 4068 |
'labeleduri' => _('Web site'), |
| 4069 |
'title' => _('Job title'), |
| 4070 |
'carlicense' => _('Car license'), |
| 4071 |
'facsimiletelephonenumber' => _('Fax number'), |
| 4072 |
'employeetype' => _('Employee type'), |
| 4073 |
'businesscategory' => _('Business category'), |
| 4074 |
'departmentnumber' => _('Department'), |
| 4075 |
'manager' => _('Manager'), |
| 4076 |
'o' => _('Organisation'), |
| 4077 |
'ou' => _('Organisational unit'), |
| 4078 |
'employeenumber' => _('Employee number'), |
| 4079 |
'initials' => _('Initials'), |
| 4080 |
'jpegphoto' => _('Photo'), |
| 4081 |
]; |
| 4082 |
} |
| 4083 |
|
| 4084 |
/** |
| 4085 |
* @inheritDoc |
| 4086 |
*/ |
| 4087 |
public function getListRenderFunction(string $attributeName, ConfiguredType $type): ?callable { |
| 4088 |
if (($attributeName === 'mail') || ($attributeName === 'rfc822mailbox')) { |
| 4089 |
return function(array $entry, string $attribute): htmlElement { |
| 4090 |
$group = new htmlGroup(); |
| 4091 |
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] != '')) { |
| 4092 |
for ($i = 0; $i < count($entry[$attribute]); $i++) { |
| 4093 |
if ($i > 0) { |
| 4094 |
$group->addElement(new htmlOutputText(", ")); |
| 4095 |
} |
| 4096 |
$group->addElement(new htmlLink($entry[$attribute][$i], "mailto:" . $entry[$attribute][$i])); |
| 4097 |
} |
| 4098 |
} |
| 4099 |
return $group; |
| 4100 |
}; |
| 4101 |
} |
| 4102 |
elseif ($attributeName === 'jpegphoto') { |
| 4103 |
return function(array $entry, string $attribute): htmlElement { |
| 4104 |
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) { |
| 4105 |
if (strlen($entry[$attribute][0]) < 100) { |
| 4106 |
// looks like we have read broken binary data, reread photo |
| 4107 |
$result = @ldap_read($_SESSION['ldap']->server(), $entry['dn'], $attribute . "=*", [$attribute], 0, 0, 0, LDAP_DEREF_NEVER); |
| 4108 |
if ($result) { |
| 4109 |
$tempEntry = @ldap_first_entry($_SESSION['ldap']->server(), $result); |
| 4110 |
if ($tempEntry) { |
| 4111 |
$binData = ldap_get_values_len($_SESSION['ldap']->server(), $tempEntry, $attribute); |
| 4112 |
$entry[$attribute] = $binData; |
| 4113 |
} |
| 4114 |
} |
| 4115 |
} |
| 4116 |
$tempFilesManager = new LamTemporaryFilesManager(); |
| 4117 |
$fileName = $tempFilesManager->registerTemporaryFile('.jpg'); |
| 4118 |
$handle = $tempFilesManager->openTemporaryFileForWrite($fileName); |
| 4119 |
fwrite($handle, $entry[$attribute][0]); |
| 4120 |
fclose($handle); |
| 4121 |
$photoFile = $tempFilesManager->getResourceLink($fileName); |
| 4122 |
$image = new htmlImage($photoFile); |
| 4123 |
$image->enableLightbox(); |
| 4124 |
$image->setCSSClasses(['thumbnail']); |
| 4125 |
return $image; |
| 4126 |
} |
| 4127 |
return new htmlGroup(); |
| 4128 |
}; |
| 4129 |
} |
| 4130 |
return null; |
| 4131 |
} |
| 4132 |
|
| 4133 |
} |