LDAPAccountManager/lam/lib/modules/inetOrgPerson.inc

4318 lines
183 KiB
PHP
Raw Normal View History

2003-12-12 00:52:35 +00:00
<?php
2017-03-21 18:26:31 +00:00
use \LAM\TYPES\TypeManager;
2018-08-19 17:13:16 +00:00
use LAM\ImageUtils\ImageManipulationFactory;
2018-08-25 17:39:47 +00:00
use LAM\PDF\PDFImage;
2003-12-12 00:52:35 +00:00
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
2006-03-03 17:30:35 +00:00
Copyright (C) 2003 - 2006 Tilo Lutz
2020-01-19 17:12:03 +00:00
2005 - 2020 Roland Gruber
2003-12-12 00:52:35 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
2020-03-02 15:44:15 +00:00
* Manages the attributes of object class inetOrgPerson.
*
* @package modules
* @author Tilo Lutz
* @author Roland Gruber
* @author Michael Duergner
2003-12-12 00:52:35 +00:00
*/
/**
2007-06-24 17:54:23 +00:00
* This module manages LDAP attributes of the object class inetOrgPerson (e.g. name and address).
*
* @package modules
2003-12-12 00:52:35 +00:00
*/
2009-10-10 12:47:40 +00:00
class inetOrgPerson extends baseModule implements passwordService {
2012-07-15 12:05:47 +00:00
/** clear text password */
private $clearTextPassword = null;
2013-03-24 15:25:01 +00:00
/** cache for departments */
private $departmentCache = null;
/** organization cache */
private $oCache = null;
/** organizational unit cache */
private $ouCache = null;
/** title cache */
private $titleCache = null;
/** employee type cache */
private $employeeTypeCache = null;
/** business category cache */
private $businessCategoryCache = null;
2014-02-06 18:43:06 +00:00
/** cache for email duplication checks */
private $emailCheckCache = array();
/** session variable for existing user certificates in self service */
const SESS_CERTIFICATES_LIST = 'inetOrgPerson_certificatesList';
2018-05-16 16:00:54 +00:00
/** session variable for existing user certificates in self service */
const SESS_PHOTO = 'inetOrgPerson_jpegPhoto';
/**
* This function fills the message array.
**/
function load_Messages() {
$this->messages['givenName'][0] = array('ERROR', _('First name'), _('First name contains invalid characters!'));
2013-04-06 15:01:19 +00:00
$this->messages['givenName'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_firstName', _('First name contains invalid characters!'));
2006-07-23 15:06:49 +00:00
$this->messages['lastname'][0] = array('ERROR', _('Last name'), _('Last name contains invalid characters or is empty!'));
2013-04-06 15:01:19 +00:00
$this->messages['lastname'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_lastName', _('Last name contains invalid characters or is empty!'));
$this->messages['telephoneNumber'][0] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
2004-10-23 11:11:31 +00:00
$this->messages['telephoneNumber'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_telephone', _('Please enter a valid telephone number!'));
$this->messages['homePhone'][0] = array('ERROR', _('Home telephone number'), _('Please enter a valid telephone number!'));
$this->messages['homePhone'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_homePhone', _('Please enter a valid telephone number!'));
2013-11-02 10:25:08 +00:00
$this->messages['mobile'][0] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
2004-10-23 11:11:31 +00:00
$this->messages['mobileTelephone'][1] = array('ERROR', _('Account %s:') . " inetOrgPerson_mobile", _('Please enter a valid mobile number!'));
2013-11-02 10:25:08 +00:00
$this->messages['facsimileTelephoneNumber'][0] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
2004-10-23 11:11:31 +00:00
$this->messages['facsimileNumber'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_fax', _('Please enter a valid fax number!'));
2014-07-27 11:10:42 +00:00
$this->messages['pager'][0] = array('ERROR', _('Pager'), _('Please enter a valid telephone number!'));
$this->messages['pager'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_pager', _('Please enter a valid telephone number!'));
2013-11-02 10:25:08 +00:00
$this->messages['mail'][0] = array('ERROR', _('Email address'), _('Please enter a valid email address!'));
2014-02-06 18:43:06 +00:00
$this->messages['mail'][1] = array('WARN', _('Email address'), _('Email "%s" already in use.'));
2018-05-22 17:55:49 +00:00
$this->messages['mail'][2] = array('WARN', _('Account %s:') . ' inetOrgPerson_email', _('Email "%s" already in use.'));
2010-04-02 11:39:09 +00:00
$this->messages['email'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_email', _('Please enter a valid email address!'));
$this->messages['street'][0] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
2004-10-23 11:11:31 +00:00
$this->messages['street'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_street', _('Please enter a valid street name!'));
$this->messages['postalAddress'][0] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
2004-10-23 11:11:31 +00:00
$this->messages['postalAddress'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_address', _('Please enter a valid postal address!'));
2011-11-03 18:31:33 +00:00
$this->messages['registeredAddress'][0] = array('ERROR', _('Registered address'), _('Please enter a valid registered address.'));
$this->messages['registeredAddress'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_registeredAddress', _('Please enter a valid registered address.'));
$this->messages['postalCode'][0] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
2004-10-23 11:11:31 +00:00
$this->messages['postalCode'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_postalCode', _('Please enter a valid postal code!'));
2004-11-07 12:56:55 +00:00
$this->messages['title'][0] = array('ERROR', _('Job title'), _('Please enter a valid job title!'));
$this->messages['title'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_title', _('Please enter a valid job title!'));
$this->messages['employeeType'][0] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
2004-10-23 11:11:31 +00:00
$this->messages['employeeType'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_type', _('Please enter a valid employee type!'));
$this->messages['cn'][0] = array('ERROR', _('Common name'), _('Please enter a valid common name!'));
$this->messages['cn'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_cn', _('Please enter a valid common name!'));
$this->messages['uid'][0] = array('ERROR', _('User name'), _('User name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
2005-07-02 12:05:33 +00:00
$this->messages['uid'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_userName', _('User name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
2018-08-12 07:41:36 +00:00
$this->messages['uid'][3] = array('WARN', _('Account %s:') . ' inetOrgPerson_userName', _('User name already exists!'));
2005-07-02 12:05:33 +00:00
$this->messages['manager'][0] = array('ERROR', _('Account %s:') . ' inetOrgPerson_manager', _('This is not a valid DN!'));
2013-01-28 21:15:55 +00:00
$this->messages['file'][0] = array('ERROR', _('No file selected.'));
2013-11-01 14:14:47 +00:00
$this->messages['file'][2] = array('ERROR', _('Unable to process this file.'));
2013-12-26 16:08:55 +00:00
$this->messages['file'][3] = array('ERROR', _('File is too large. Maximum allowed size is %s kB.'));
$this->messages['businessCategory'][0] = array('ERROR', _('Business category'), _('Please enter a valid business category!'));
$this->messages['businessCategory'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_businessCategory', _('Please enter a valid business category!'));
2013-01-13 10:40:47 +00:00
$this->messages['userPassword'][0] = array('ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are:') . ' a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ §°!');
2013-04-28 10:21:45 +00:00
$this->messages['sendPasswordMail'][0] = array('ERROR', _('Account %s:') . ' inetOrgPerson_sendPasswordMail', _('This value can only be "true" or "false".'));
2006-08-13 12:58:19 +00:00
}
/**
* Returns true if this module can manage accounts of the current type, otherwise false.
*
* @return boolean true if module fits
*/
public function can_manage() {
return in_array($this->get_scope(), array('user'));
}
2004-06-13 19:58:58 +00:00
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*
2008-02-03 14:28:28 +00:00
* @see baseModule::get_metaData()
2004-06-13 19:58:58 +00:00
*/
function get_metaData() {
$return = array();
2007-11-19 18:42:03 +00:00
// icon
$return['icon'] = 'uid.png';
2004-06-14 16:05:36 +00:00
// alias name
$return["alias"] = _('Personal');
// this is a base module
$return["is_base"] = true;
2004-10-06 18:17:22 +00:00
// RDN attribute
$return["RDN"] = array("cn" => "normal", 'uid' => 'low');
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=inetOrgPerson)");
2004-06-20 17:32:02 +00:00
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('inetOrgPerson');
2006-05-01 16:13:10 +00:00
// LDAP aliases
$return['LDAPaliases'] = array('commonName' => 'cn', 'surname' => 'sn', 'streetAddress' => 'street',
'fax' => 'facsimileTelephoneNumber', 'gn' => 'givenName', 'userid' => 'uid', 'rfc822Mailbox' => 'mail',
2012-10-14 08:32:26 +00:00
'mobileTelephoneNumber' => 'mobile', 'organizationName' => 'o', 'organizationalUnitName' => 'ou');
2006-05-13 08:55:31 +00:00
// managed attributes
2014-04-21 19:21:47 +00:00
$return['attributes'] = array('uid', 'employeeType', 'givenName', 'jpegPhoto', 'mail', 'manager', 'mobile',
'title', 'telephoneNumber', 'facsimileTelephoneNumber', 'street', 'postOfficeBox', 'postalCode', 'postalAddress',
2014-07-27 11:10:42 +00:00
'sn', 'userPassword', 'description', 'homePhone', 'pager', 'roomNumber', 'businessCategory', 'l', 'st',
'physicalDeliveryOfficeName', 'carLicense', 'departmentNumber', 'o', 'employeeNumber', 'initials',
2016-06-19 09:41:47 +00:00
'registeredAddress', 'labeledURI', 'ou', 'userCertificate;binary', 'INFO.userPasswordClearText');
// self service search attributes
$return['selfServiceSearchAttributes'] = array('uid', 'mail', 'cn', 'surname', 'givenName', 'employeeNumber');
2006-07-16 17:15:37 +00:00
// self service field settings
$return['selfServiceFieldSettings'] = array('firstName' => _('First name'), 'lastName' => _('Last name'),
2010-04-02 11:39:09 +00:00
'mail' => _('Email address'), 'telephoneNumber' => _('Telephone number'), 'mobile' => _('Mobile number'),
2011-11-03 18:31:33 +00:00
'faxNumber' => _('Fax number'), 'street' => _('Street'), 'postalAddress' => _('Postal address'), 'registeredAddress' => _('Registered address'),
'postalCode' => _('Postal code'), 'postOfficeBox' => _('Post office box'), 'jpegPhoto' => _('Photo'),
2014-07-27 11:10:42 +00:00
'homePhone' => _('Home telephone number'), 'pager' => _('Pager'), 'roomNumber' => _('Room number'), 'carLicense' => _('Car license'),
2009-02-15 12:54:37 +00:00
'location' => _('Location'), 'state' => _('State'), 'officeName' => _('Office name'), 'businessCategory' => _('Business category'),
2013-01-28 21:15:55 +00:00
'departmentNumber' => _('Department'), 'initials' => _('Initials'), 'title' => _('Job title'), 'labeledURI' => _('Web site'),
2017-05-13 09:10:38 +00:00
'userCertificate' => _('User certificates'), 'o' => _('Organisation'), 'ou' => _('Organisational unit'), 'description' => _('Description'),
2020-01-19 17:12:03 +00:00
'uid' => _('User name'), 'displayName' => _('Display name'));
2012-08-18 15:55:43 +00:00
// possible self service read-only fields
2014-07-27 11:10:42 +00:00
$return['selfServiceReadOnlyFields'] = array('firstName', 'lastName', 'mail', 'telephoneNumber', 'mobile', 'faxNumber', 'pager', 'street',
2012-08-18 15:55:43 +00:00
'postalAddress', 'registeredAddress', 'postalCode', 'postOfficeBox', 'jpegPhoto', 'homePhone', 'roomNumber', 'carLicense',
'location', 'state', 'officeName', 'businessCategory', 'departmentNumber', 'initials', 'title', 'labeledURI', 'userCertificate',
2020-01-19 17:12:03 +00:00
'o', 'ou', 'description', 'uid', 'displayName');
// profile checks and mappings
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
$return['profile_mappings']['inetOrgPerson_initials'] = 'initials';
}
2012-09-14 10:35:21 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
$return['profile_mappings']['inetOrgPerson_description'] = 'description';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$return['profile_checks']['inetOrgPerson_title'] = array(
'type' => 'ext_preg',
'regex' => 'title',
'error_message' => $this->messages['title'][0]);
$return['profile_mappings']['inetOrgPerson_title'] = 'title';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$return['profile_checks']['inetOrgPerson_employeeType'] = array(
'type' => 'ext_preg',
'regex' => 'employeeType',
'error_message' => $this->messages['employeeType'][0]);
$return['profile_mappings']['inetOrgPerson_employeeType'] = 'employeeType';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$return['profile_checks']['inetOrgPerson_businessCategory'] = array(
'type' => 'ext_preg',
'regex' => 'businessCategory',
'error_message' => $this->messages['businessCategory'][0]);
$return['profile_mappings']['inetOrgPerson_businessCategory'] = 'businessCategory';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
$return['profile_checks']['inetOrgPerson_street'] = array(
'type' => 'ext_preg',
'regex' => 'street',
'error_message' => $this->messages['street'][0]);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
$return['profile_checks']['inetOrgPerson_postalCode'] = array(
'type' => 'ext_preg',
'regex' => 'postalCode',
'error_message' => $this->messages['postalCode'][0]);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$return['profile_checks']['inetOrgPerson_postalAddress'] = array(
'type' => 'ext_preg',
'regex' => 'postalAddress',
'error_message' => $this->messages['postalAddress'][0]);
$return['profile_mappings']['inetOrgPerson_postalAddress'] = 'postalAddress';
}
2011-11-03 18:31:33 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
$return['profile_checks']['inetOrgPerson_registeredAddress'] = array(
'type' => 'ext_preg',
'regex' => 'postalAddress',
'error_message' => $this->messages['registeredAddress'][0]);
$return['profile_mappings']['inetOrgPerson_registeredAddress'] = 'registeredAddress';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
$return['profile_mappings']['inetOrgPerson_physicalDeliveryOfficeName'] = 'physicalDeliveryOfficeName';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
$return['profile_mappings']['inetOrgPerson_roomNumber'] = 'roomNumber';
}
2005-01-16 12:41:38 +00:00
// upload fields
2004-10-11 18:06:53 +00:00
$return['upload_columns'] = array(
2009-10-03 15:46:26 +00:00
array(
'name' => 'inetOrgPerson_firstName',
'description' => _('First name'),
'help' => 'givenName',
'example' => _('Steve')
),
array(
'name' => 'inetOrgPerson_lastName',
'description' => _('Last name'),
'help' => 'sn',
'example' => _('Miller'),
'required' => true
)
2004-10-11 18:06:53 +00:00
);
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_initials',
'description' => _('Initials'),
'help' => 'initials',
'example' => 'A.B.'
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_description',
'description' => _('Description'),
'help' => 'description',
2013-08-20 18:56:52 +00:00
'example' => _('Temp, contract till December')
2009-10-03 15:46:26 +00:00
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_title',
'description' => _('Job title'),
'help' => 'titleList',
2009-10-03 15:46:26 +00:00
'example' => _('President')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_employeeNumber',
'description' => _('Employee number'),
'help' => 'employeeNumber',
'example' => '123456'
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_type',
'description' => _('Employee type'),
'help' => 'employeeType',
'example' => _('Temp')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_manager',
'description' => _('Manager'),
2011-12-20 20:40:51 +00:00
'help' => 'managerList',
2009-10-03 15:46:26 +00:00
'example' => _('uid=smiller,ou=People,dc=company,dc=com')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_businessCategory',
'description' => _('Business category'),
'help' => 'businessCategoryList',
2009-10-03 15:46:26 +00:00
'example' => _('Administration')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_street',
'description' => _('Street'),
'help' => 'streetList',
2009-10-03 15:46:26 +00:00
'example' => _('Mystreetname 42')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_postalCode',
'description' => _('Postal code'),
'help' => 'postalCodeList',
2009-10-03 15:46:26 +00:00
'example' => _('GB-12345')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_address',
'description' => _('Postal address'),
'help' => 'postalAddress',
2013-12-07 16:49:23 +00:00
'example' => _('MyCity')
2009-10-03 15:46:26 +00:00
);
}
2011-11-03 18:31:33 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_registeredAddress',
'description' => _('Registered address'),
'help' => 'registeredAddress',
2013-12-07 16:49:23 +00:00
'example' => _('MyCity')
2011-11-03 18:31:33 +00:00
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_postOfficeBox',
'description' => _('Post office box'),
'help' => 'postOfficeBoxList',
2009-10-03 15:46:26 +00:00
'example' => _('12345')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_telephone',
'description' => _('Telephone number'),
'help' => 'telephoneNumberList',
2009-10-03 15:46:26 +00:00
'example' => _('123-123-1234')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_homePhone',
'description' => _('Home telephone number'),
'help' => 'homePhoneList',
2009-10-03 15:46:26 +00:00
'example' => _('123-124-1234')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_mobile',
'description' => _('Mobile number'),
'help' => 'mobileTelephoneNumberList',
2009-10-03 15:46:26 +00:00
'example' => _('123-123-1235')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_fax',
'description' => _('Fax number'),
'help' => 'facsimileTelephoneNumberList',
2009-10-03 15:46:26 +00:00
'example' => _('123-123-1236')
);
}
2014-07-27 11:10:42 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_pager',
'description' => _('Pager'),
'help' => 'pagerList',
'example' => _('123-123-1236')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_email',
2010-04-02 11:39:09 +00:00
'description' => _('Email address'),
'help' => 'mailList',
2009-10-03 15:46:26 +00:00
'example' => _('user@company.com')
);
2013-04-28 10:21:45 +00:00
if (isLAMProVersion()) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_sendPasswordMail',
'description' => _('Send password via mail'),
'help' => 'mailPassword',
'values' => 'true, false',
'default' => 'false',
'example' => 'false'
);
}
2009-10-03 15:46:26 +00:00
}
2011-12-11 13:36:34 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_labeledURI',
'description' => _('Web site'),
'help' => 'labeledURIList',
'example' => _('http://www.company.com')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_roomNumber',
'description' => _('Room number'),
'help' => 'roomNumber',
'example' => 'A 2.24'
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_departmentNumber',
'description' => _('Department'),
'help' => 'departmentNumberList',
2009-10-03 15:46:26 +00:00
'example' => _('Administration')
);
}
2012-10-14 08:32:26 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_ou',
'description' => _('Organisational unit'),
'help' => 'ouList',
'example' => _('Administration')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) {
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_o',
'description' => _('Organisation'),
'help' => 'oList',
'example' => _('YourCompany')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_l',
'description' => _('Location'),
'help' => 'lList',
2009-10-03 15:46:26 +00:00
'example' => _('MyCity')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_st',
'description' => _('State'),
'help' => 'stList',
2009-10-03 15:46:26 +00:00
'example' => _('New York')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_carLicense',
'description' => _('Car license'),
'help' => 'carLicense',
'example' => _('yes')
);
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
2009-10-03 15:46:26 +00:00
$return['upload_columns'][] = array(
'name' => 'inetOrgPerson_physicalDeliveryOfficeName',
'description' => _('Office name'),
'help' => 'physicalDeliveryOfficeNameList',
'example' => _('YourCompany')
2009-10-03 15:46:26 +00:00
);
}
// available PDF fields
2004-10-30 16:46:06 +00:00
$return['PDF_fields'] = array(
2010-04-05 12:38:23 +00:00
'givenName' => _('First name'),
'sn' => _('Last name')
2004-10-30 16:46:06 +00:00
);
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['description'] = _('Description');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['street'] = _('Street');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['postOfficeBox'] = _('Post office box');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['postalCode'] = _('Postal code');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['location'] = _('Location');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['state'] = _('State');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['postalAddress'] = _('Postal address');
2009-10-03 15:46:26 +00:00
}
2011-11-03 18:31:33 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
$return['PDF_fields']['registeredAddress'] = _('Registered address');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['officeName'] = _('Office name');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['roomNumber'] = _('Room number');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['telephoneNumber'] = _('Telephone number');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['homePhone'] = _('Home telephone number');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['mobileTelephoneNumber'] = _('Mobile number');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
2011-01-09 16:20:21 +00:00
$return['PDF_fields']['facsimileTelephoneNumber'] = _('Fax number');
2009-10-03 15:46:26 +00:00
}
2014-07-27 11:10:42 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) {
$return['PDF_fields']['pager'] = _('Pager');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['mail'] = _('Email address');
2009-10-03 15:46:26 +00:00
}
2011-12-11 13:36:34 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
$return['PDF_fields']['labeledURI'] = _('Web site');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['title'] = _('Job title');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['carLicense'] = _('Car license');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['employeeType'] = _('Employee type');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['businessCategory'] = _('Business category');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$return['PDF_fields']['departmentNumber'] = _('Department');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
2010-04-05 12:38:23 +00:00
$return['PDF_fields']['manager'] = _('Manager');
2009-10-03 15:46:26 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) {
$return['PDF_fields']['o'] = _('Organisation');
}
2012-10-14 08:32:26 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) {
$return['PDF_fields']['ou'] = _('Organisational unit');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) {
$return['PDF_fields']['employeeNumber'] = _('Employee number');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
$return['PDF_fields']['initials'] = _('Initials');
}
2018-08-25 17:39:47 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) {
$return['PDF_fields']['jpegPhoto'] = _('Photo');
}
// help Entries
$return['help'] = array (
2009-10-03 15:46:26 +00:00
'description' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Description"), 'attr' => 'description',
2009-10-03 15:46:26 +00:00
"Text" => _("User description. If left empty sur- and give name will be used.")
),
'title' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Job title"), 'attr' => 'title',
2009-10-03 15:46:26 +00:00
"Text" => _("Job title of user: President, department manager, ...")
),
'titleList' => array (
"Headline" => _("Job title"), 'attr' => 'title',
"Text" => _("Job title of user: President, department manager, ...") . ' ' . _("Multiple values are separated by semicolon.")
),
2009-10-03 15:46:26 +00:00
'givenName' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("First name"), 'attr' => 'givenName',
2009-10-03 15:46:26 +00:00
"Text" => _("First name of user. Only letters, - and spaces are allowed.")
),
'sn' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Last name"), 'attr' => 'sn',
2009-10-03 15:46:26 +00:00
"Text" => _("Last name of user. Only letters, - and spaces are allowed.")
),
'employeeType' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Employee type"), 'attr' => 'employeeType',
2009-10-03 15:46:26 +00:00
"Text" => _("Employee type: Contractor, Employee, Intern, Temp, External, ...")
),
'manager' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Manager"), 'attr' => 'manager',
2009-10-03 15:46:26 +00:00
"Text" => _("This is the LDAP DN of the user's manager. Use this property to represent hierarchies in your company.")
),
2011-12-20 20:40:51 +00:00
'managerList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Manager"), 'attr' => 'manager',
2011-12-20 20:40:51 +00:00
"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.")
),
2009-10-03 15:46:26 +00:00
'street' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Street"), 'attr' => 'street',
"Text" => _("The street name of the user's address.")
),
'streetList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Street"), 'attr' => 'street',
"Text" => _("The street name of the user's address.") . ' ' . _("Multiple values are separated by semicolon.")
2009-10-03 15:46:26 +00:00
),
'postOfficeBox' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Post office box"), 'attr' => 'postOfficeBox',
"Text" => _("The post office box of the user's address.")
),
'postOfficeBoxList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Post office box"), 'attr' => 'postOfficeBox',
"Text" => _("The post office box of the user's address.") . ' ' . _("Multiple values are separated by semicolon.")
2009-10-03 15:46:26 +00:00
),
'postalCode' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Postal code"), 'attr' => 'postalCode',
"Text" => _("The postal code of the user's address.")
),
'postalCodeList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Postal code"), 'attr' => 'postalCode',
"Text" => _("The postal code of the user's address.") . ' ' . _("Multiple values are separated by semicolon.")
2009-10-03 15:46:26 +00:00
),
'postalAddress' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Postal address"), 'attr' => 'postalAddress',
2009-10-03 15:46:26 +00:00
"Text" => _("Postal address, city")
),
2011-11-03 18:31:33 +00:00
'registeredAddress' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Registered address"), 'attr' => 'registeredAddress',
2011-11-03 18:31:33 +00:00
"Text" => _("Registered address, city")
),
2009-10-03 15:46:26 +00:00
'telephoneNumber' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Telephone number"), 'attr' => 'telephoneNumber',
"Text" => _("The user's telephone number.")
),
'telephoneNumberList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Telephone number"), 'attr' => 'telephoneNumber',
"Text" => _("The user's telephone number.") . ' ' . _('Multiple values are separated by semicolon.')
2009-10-03 15:46:26 +00:00
),
2013-11-02 10:25:08 +00:00
'mobile' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Mobile number"), 'attr' => 'mobile',
"Text" => _("The user's mobile number.")
),
'mobileTelephoneNumberList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Mobile number"), 'attr' => 'mobile',
"Text" => _("The user's mobile number.") . ' ' . _('Multiple values are separated by semicolon.')
2009-10-03 15:46:26 +00:00
),
'facsimileTelephoneNumber' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Fax number"), 'attr' => 'facsimileTelephoneNumber',
"Text" => _("The user's fax number.")
),
'facsimileTelephoneNumberList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Fax number"), 'attr' => 'facsimileTelephoneNumber',
"Text" => _("The user's fax number.") . ' ' . _('Multiple values are separated by semicolon.')
2009-10-03 15:46:26 +00:00
),
2014-07-27 11:10:42 +00:00
'pager' => array (
"Headline" => _('Pager'), 'attr' => 'pager',
"Text" => _("The user's pager number.")
),
'pagerList' => array (
"Headline" => _('Pager'), 'attr' => 'pager',
"Text" => _("The user's pager number.") . ' ' . _('Multiple values are separated by semicolon.')
),
2009-10-03 15:46:26 +00:00
'mail' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Email address"), 'attr' => 'mail',
2016-11-19 18:20:44 +00:00
"Text" => _("The user's email address.")
),
'mailList' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Email address"), 'attr' => 'mail',
"Text" => _("The user's email address.") . ' ' . _('Multiple values are separated by semicolon.')
2009-10-03 15:46:26 +00:00
),
2013-04-28 10:21:45 +00:00
"mailPassword" => array (
"Headline" => _("Send password via mail"),
"Text" => _("Sends the password to the user via mail. Please edit your LAM server profile to setup the mail settings.")),
2011-12-11 13:36:34 +00:00
'labeledURI' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Web site"), 'attr' => 'labeledURI',
2011-12-12 18:10:54 +00:00
"Text" => _("The user's web site (e.g. http://www.company.com).")
2011-12-11 13:36:34 +00:00
),
'labeledURIList' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Web site"), 'attr' => 'labeledURI',
2011-12-12 18:10:54 +00:00
"Text" => _("The user's web site (e.g. http://www.company.com).") . ' ' . _('Multiple values are separated by semicolon.')
2011-12-11 13:36:34 +00:00
),
2009-10-03 15:46:26 +00:00
'cn' => array (
2012-01-31 19:32:25 +00:00
"Headline" => _("Common name"), 'attr' => 'cn',
2009-10-03 15:46:26 +00:00
"Text" => _("This is the natural name of the user. If empty, the first and last name is used.")
),
2020-01-19 17:12:03 +00:00
'displayName' => array (
"Headline" => _("Display name"), 'attr' => 'displayName',
"Text" => _("This is the user's preferred name to be used when displaying entries.")
),
2009-10-03 15:46:26 +00:00
'uid' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("User name"), 'attr' => 'uid',
2012-02-18 13:48:08 +00:00
"Text" => _("User name of the user who should be created. Valid characters are: a-z,A-Z,0-9, @.-_.")
2009-10-03 15:46:26 +00:00
),
'photoUpload' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Add photo"), 'attr' => 'jpegPhoto',
2009-10-03 15:46:26 +00:00
"Text" => _("Please select an image file to upload. It must be in JPG format (.jpg/.jpeg).")
),
'homePhone' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Home telephone number"), 'attr' => 'homePhone',
"Text" => _("The user's private telephone number.")
),
'homePhoneList' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Home telephone number"), 'attr' => 'homePhone',
"Text" => _("The user's private telephone number.") . ' ' . _('Multiple values are separated by semicolon.')
2009-10-03 15:46:26 +00:00
),
'roomNumber' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Room number"), 'attr' => 'roomNumber',
2009-10-03 15:46:26 +00:00
"Text" => _("The room number of the employee's office.")
),
'businessCategory' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Business category"), 'attr' => 'businessCategory',
2020-02-24 19:08:28 +00:00
"Text" => _("Business category (e.g. Administration, IT-Services, Management, ...)")
2009-10-03 15:46:26 +00:00
),
'businessCategoryList' => array(
"Headline" => _("Business category"), 'attr' => 'businessCategory',
2020-02-24 19:08:28 +00:00
"Text" => _("Business category (e.g. Administration, IT-Services, Management, ...)") . '. ' . _("Multiple values are separated by semicolon.")
),
2009-10-03 15:46:26 +00:00
'l' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Location"), 'attr' => 'l',
"Text" => _("This describes the location of the user.")
),
'lList' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Location"), 'attr' => 'l',
"Text" => _("This describes the location of the user.") . ' ' . _("Multiple values are separated by semicolon.")
2009-10-03 15:46:26 +00:00
),
'st' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("State"), 'attr' => 'st',
"Text" => _("The state where the user resides or works.")
),
'stList' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("State"), 'attr' => 'st',
"Text" => _("The state where the user resides or works.") . ' ' . _("Multiple values are separated by semicolon.")
2009-10-03 15:46:26 +00:00
),
'carLicense' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Car license"), 'attr' => 'carLicense',
2009-10-03 15:46:26 +00:00
"Text" => _("This can be used to specify if the user has a car license.")
),
'physicalDeliveryOfficeName' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Office name"), 'attr' => 'physicalDeliveryOfficeName',
2009-10-03 15:46:26 +00:00
"Text" => _("The office name of the user (e.g. YourCompany, Human Resources).")
),
'physicalDeliveryOfficeNameList' => array(
"Headline" => _("Office name"), 'attr' => 'physicalDeliveryOfficeName',
"Text" => _("The office name of the user (e.g. YourCompany, Human Resources).") . ' ' . _("Multiple values are separated by semicolon.")
),
2009-10-03 15:46:26 +00:00
'departmentNumber' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Department"), 'attr' => 'departmentNumber',
"Text" => _("Here you can enter the user's department.")
),
'departmentNumberList' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Department"), 'attr' => 'departmentNumber',
"Text" => _("Here you can enter the user's department.") . ' ' . _("Multiple values are separated by semicolon.")
2009-10-03 15:46:26 +00:00
),
'hiddenOptions' => array(
"Headline" => _("Hidden options"),
"Text" => _("The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields.")
2009-11-12 19:48:53 +00:00
),
'pwdHash' => array(
"Headline" => _("Password hash type"),
2012-08-26 17:54:31 +00:00
"Text" => _("LAM supports CRYPT, CRYPT-SHA512, SHA, SSHA, MD5 and SMD5 to generate the hash value of passwords. SSHA and CRYPT are the most common but CRYPT does not support passwords greater than 8 letters. We do not recommend to use plain text passwords.")
2016-01-02 12:16:14 +00:00
. ' ' . _('K5KEY is only needed if you use Kerberos with smbk5pwd.')
),
2012-10-14 08:32:26 +00:00
'ou' => array(
"Headline" => _("Organisational unit"), 'attr' => 'ou',
"Text" => _("The user's organisational unit.")
),
'ouList' => array(
"Headline" => _("Organisational unit"), 'attr' => 'ou',
"Text" => _("The user's organisational unit.") . ' ' . _('Multiple values are separated by semicolon.')
),
'o' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Organisation"), 'attr' => 'o',
"Text" => _("The user's organisation name.")
),
'oList' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Organisation"), 'attr' => 'o',
"Text" => _("The user's organisation name.") . ' ' . _('Multiple values are separated by semicolon.')
),
'employeeNumber' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Employee number"), 'attr' => 'employeeNumber',
"Text" => _("The user's unique employee number.")
),
'initials' => array(
2012-01-31 19:32:25 +00:00
"Headline" => _("Initials"), 'attr' => 'initials',
"Text" => _("The initials of the user's first names.") . ' ' . _('Multiple values are separated by semicolon.')
),
'userPassword' => array(
"Headline" => _("Password"),
"Text" => _("Please enter the password which you want to set for this account.")
),
2013-01-28 21:15:55 +00:00
'userCertificate' => array(
"Headline" => _('User certificates'),
"Text" => _('These are the user\'s certificates.')
),
'crop' => array(
"Headline" => _('Image cropping'),
"Text" => _('Uploaded images will be cropped to these maximum values.')
),
2015-05-23 12:10:55 +00:00
'addAddressbook' => array(
"Headline" => _('Add addressbook (ou=addressbook)'),
"Text" => _('Adds an "ou=addressbook" subentry to each user.')
),
2004-10-30 16:46:06 +00:00
);
2004-06-13 19:58:58 +00:00
return $return;
}
2017-04-23 18:46:58 +00:00
/**
* {@inheritDoc}
* @see baseModule::getManagedAttributes()
*/
public function getManagedAttributes($typeId) {
$attrs = parent::getManagedAttributes($typeId);
if (!$this->isUnixActive()) {
$attrs[] = 'cn';
}
2020-01-19 17:12:03 +00:00
if (!$this->isSamba3Active()) {
$attrs[] = 'displayName';
}
2017-04-23 18:46:58 +00:00
return $attrs;
}
/**
* This functions return true if all needed settings are done.
*
* @return boolean true, if all is ok
*/
function module_complete() {
2007-10-03 18:02:10 +00:00
if (!$this->getAccountContainer()->isNewAccount) {
2005-08-26 08:53:16 +00:00
// check if account is based on our object class
2007-10-03 18:02:10 +00:00
$objectClasses = $this->getAccountContainer()->attributes_orig['objectClass'];
2005-08-26 08:53:16 +00:00
if (is_array($objectClasses) && !in_array('inetOrgPerson', $objectClasses)) {
return true;
}
}
2006-05-01 16:13:10 +00:00
if (!isset($this->attributes['sn'][0]) || ($this->attributes['sn'][0] == '')) return false;
2016-06-19 09:41:47 +00:00
if (!$this->isUnixActive()) {
2011-03-26 12:47:30 +00:00
if (($this->getAccountContainer()->rdn == 'uid') && !isset($this->attributes['uid'][0])) {
return false;
}
}
return true;
2006-08-13 12:58:19 +00:00
}
2005-08-26 08:53:16 +00:00
/**
* Controls if the module button the account page is visible and activated.
*
* @return string status ("enabled", "disabled", "hidden")
*/
function getButtonStatus() {
2007-10-03 18:02:10 +00:00
if (!$this->getAccountContainer()->isNewAccount) {
2005-08-26 08:53:16 +00:00
// check if account is based on our object class
2007-10-03 18:02:10 +00:00
$objectClasses = $this->getAccountContainer()->attributes_orig['objectClass'];
2005-08-26 08:53:16 +00:00
if (is_array($objectClasses) && !in_array('inetOrgPerson', $objectClasses)) {
return "disabled";
}
}
return "enabled";
}
2007-11-03 14:17:19 +00:00
/**
* Returns a list of modifications which have to be made to the LDAP account.
*
* @return array list of modifications
* <br>This function returns an array with 3 entries:
* <br>array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
* <br>DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid)
* <br>"add" are attributes which have to be added to LDAP entry
* <br>"remove" are attributes which have to be removed from LDAP entry
* <br>"modify" are attributes which have to been modified in LDAP entry
2011-02-26 13:14:10 +00:00
* <br>"info" are values with informational value (e.g. to be used later by pre/postModify actions)
2003-12-12 00:52:35 +00:00
*/
function save_attributes() {
2005-08-26 08:53:16 +00:00
// skip saving if account is based on another structural object class
2007-10-03 18:02:10 +00:00
if (!$this->getAccountContainer()->isNewAccount && !in_array('inetOrgPerson', $this->getAccountContainer()->attributes_orig['objectClass'])) {
2005-08-26 08:53:16 +00:00
return array();
}
2007-10-03 18:02:10 +00:00
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
2011-11-03 18:31:33 +00:00
// postalAddress, registeredAddress, facsimileTelephoneNumber and jpegPhoto need special removing
if (isset($return[$this->getAccountContainer()->dn_orig]['remove']['postalAddress'])) {
$return[$this->getAccountContainer()->dn_orig]['modify']['postalAddress'] = $this->attributes['postalAddress'];
unset($return[$this->getAccountContainer()->dn_orig]['remove']['postalAddress']);
}
2011-11-03 18:31:33 +00:00
if (isset($return[$this->getAccountContainer()->dn_orig]['remove']['registeredAddress'])) {
$return[$this->getAccountContainer()->dn_orig]['modify']['registeredAddress'] = $this->attributes['registeredAddress'];
unset($return[$this->getAccountContainer()->dn_orig]['remove']['registeredAddress']);
}
if (isset($return[$this->getAccountContainer()->dn_orig]['remove']['facsimileTelephoneNumber'])) {
$return[$this->getAccountContainer()->dn_orig]['modify']['facsimileTelephoneNumber'] = $this->attributes['facsimileTelephoneNumber'];
unset($return[$this->getAccountContainer()->dn_orig]['remove']['facsimileTelephoneNumber']);
}
2012-05-20 09:33:24 +00:00
if (isset($return[$this->getAccountContainer()->dn_orig]['add']['facsimileTelephoneNumber'])
&& isset($this->orig['facsimileTelephoneNumber']) && (sizeof($this->orig['facsimileTelephoneNumber']) > 0)) {
$return[$this->getAccountContainer()->dn_orig]['modify']['facsimileTelephoneNumber'] = $this->attributes['facsimileTelephoneNumber'];
unset($return[$this->getAccountContainer()->dn_orig]['add']['facsimileTelephoneNumber']);
}
if (isset($return[$this->getAccountContainer()->dn_orig]['remove']['jpegPhoto'])) {
$return[$this->getAccountContainer()->dn_orig]['modify']['jpegPhoto'] = array();
unset($return[$this->getAccountContainer()->dn_orig]['remove']['jpegPhoto']);
2005-12-05 14:45:01 +00:00
}
// add information about clear text password
if ($this->clearTextPassword != null) {
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordClearText'][0] = $this->clearTextPassword;
}
// password status change
if (!$this->isUnixActive()) {
2017-03-21 18:26:31 +00:00
$pwdOrig = empty($this->orig['userPassword'][0]) ? '' : $this->orig['userPassword'][0];
$pwdNew = empty($this->attributes['userPassword'][0]) ? '' : $this->attributes['userPassword'][0];
if ((pwd_is_enabled($pwdOrig) && pwd_is_enabled($pwdNew)) || (!pwd_is_enabled($pwdOrig) && !pwd_is_enabled($pwdNew))) {
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'unchanged';
}
2017-03-21 18:26:31 +00:00
elseif (pwd_is_enabled($pwdOrig)) {
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'locked';
}
else {
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordStatusChange'][0] = 'unlocked';
}
}
return $return;
}
2015-05-23 12:10:55 +00:00
/**
* Runs the postmodify actions.
*
2015-05-23 12:10:55 +00:00
* @see baseModule::postModifyActions()
*
* @param boolean $newAccount
* @param array $attributes LDAP attributes of this entry
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/
public function postModifyActions($newAccount, $attributes) {
$messages = array();
2018-07-07 15:40:44 +00:00
// set exop password
$messages = array_merge($messages, $this->setExopPassword($this->moduleSettings));
2015-05-23 12:10:55 +00:00
// add address book
2015-06-17 19:41:48 +00:00
$accountContainer = $this->getAccountContainer();
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook') && !empty($accountContainer)) {
$dn = 'ou=addressbook,' . $accountContainer->finalDN;
2015-05-23 12:10:55 +00:00
$result = ldapGetDN($dn);
if (empty($result)) {
$attrs = array(
'objectClass' => array('organizationalUnit'),
'ou' => 'addressbook'
);
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs);
if (!$success) {
2019-07-31 19:19:42 +00:00
logNewMessage(LOG_ERR, 'Unable to add addressbook for user ' . $accountContainer->finalDN . ' (' . ldap_error($_SESSION['ldap']->server()) . ').');
2015-05-23 12:10:55 +00:00
$messages[] = array('ERROR', sprintf(_("Was unable to create DN: %s."), htmlspecialchars($dn)), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
}
else {
2019-07-31 19:19:42 +00:00
logNewMessage(LOG_NOTICE, 'Added addressbook for user ' . $accountContainer->finalDN);
2015-05-23 12:10:55 +00:00
}
}
}
return $messages;
}
2003-12-30 15:36:30 +00:00
2018-07-07 15:40:44 +00:00
/**
* Sets the password via ldap_exop if configured.
*
* @param array $settings settings
* @return array error message parameters if any
*/
private function setExopPassword($settings) {
if (!empty($this->clearTextPassword) && !empty($settings['posixAccount_pwdHash'][0])
&& ($settings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) {
$success = ldap_exop_passwd($_SESSION['ldap']->server(), $this->getAccountContainer()->finalDN, null, $this->clearTextPassword);
if (!$success) {
return array(array('ERROR', _('Unable to set password'), getExtendedLDAPErrorMessage($_SESSION['ldap']->server())));
2018-07-07 15:40:44 +00:00
}
}
return array();
}
/**
* Processes user input of the primary module page.
* It checks if all input values are correct and updates the associated LDAP attributes.
*
* @return array list of info/error messages
*/
2006-08-13 12:58:19 +00:00
function process_attributes() {
2006-05-20 16:32:02 +00:00
$errors = array();
2016-11-19 18:20:44 +00:00
$keysToReplace = array('mail', 'description', 'postalAddress', 'cn',
'registeredAddress', 'labeledURI');
if ($this->isUnixActive()) {
$keysToReplace[] = 'uid';
}
$this->getAccountContainer()->replaceWildcardsInPOST($keysToReplace);
// add parent object classes
if ($this->getAccountContainer()->isNewAccount) {
if (!in_array('organizationalPerson', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'organizationalPerson';
}
if (!in_array('person', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'person';
}
}
// load and check attributes
// description
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription') && !$this->isAdminReadOnly('description')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('description', $errors);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// last name
if (!$this->isAdminReadOnly('sn')) {
$this->attributes['sn'][0] = trim($_POST['sn']);
if (!get_preg($this->attributes['sn'][0], 'realname')) $errors[] = $this->messages['lastname'][0];
}
// first name
if (!$this->isAdminReadOnly('givenName')) {
$this->attributes['givenName'][0] = trim($_POST['givenName']);
if (($this->attributes['givenName'][0] != '') && !get_preg($this->attributes['givenName'][0], 'realname')) $errors[] = $this->messages['givenName'][0];
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle') && !$this->isAdminReadOnly('title')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('title', $errors, 'title');
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress') && !$this->isAdminReadOnly('mail')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('mail', $errors, 'email');
if (!empty($this->attributes['mail'])) {
foreach ($this->attributes['mail'] as &$mail) {
2014-02-06 18:43:06 +00:00
if (empty($this->orig['mail']) || !in_array($mail, $this->orig['mail'])) {
if ($this->emailExists($mail)) {
$msg = $this->messages['mail'][1];
$msg[] = array(htmlspecialchars($mail));
$errors[] = $msg;
}
}
}
}
2009-10-03 17:29:10 +00:00
}
2020-01-19 17:12:03 +00:00
if (!$this->isSamba3Active() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) {
$this->attributes['displayName'][0] = $_POST['displayName'];
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber') && !$this->isAdminReadOnly('telephoneNumber')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('telephoneNumber', $errors, 'telephone');
2009-02-15 12:54:37 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber') && !$this->isAdminReadOnly('mobile')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('mobile', $errors, 'telephone');
2005-07-02 12:05:33 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber') && !$this->isAdminReadOnly('facsimileTelephoneNumber')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('facsimileTelephoneNumber', $errors, 'telephone');
}
2014-07-27 11:10:42 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true) && !$this->isAdminReadOnly('pager')) {
$this->processMultiValueInputTextField('pager', $errors, 'telephone');
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber') && !$this->isAdminReadOnly('homePhone')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('homePhone', $errors, 'telephone');
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') && !$this->isAdminReadOnly('street')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('street', $errors, 'street');
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox') && !$this->isAdminReadOnly('postOfficeBox')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('postOfficeBox', $errors);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') && !$this->isAdminReadOnly('postalCode')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('postalCode', $errors, 'postalCode');
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress') && !$this->isAdminReadOnly('postalAddress')) {
$addressCounter = 0;
while (isset($_POST['postalAddress' . $addressCounter])) {
$this->attributes['postalAddress'][$addressCounter] = implode('$', preg_split('/[\r][\n]/', $_POST['postalAddress' . $addressCounter]));
if (!get_preg($this->attributes['postalAddress'][$addressCounter], 'postalAddress')) $errors[] = $this->messages['postalAddress'][0];
if ($this->attributes['postalAddress'][$addressCounter] == '') {
unset($this->attributes['postalAddress'][$addressCounter]);
}
$addressCounter++;
}
if (isset($_POST['addPostalAddress'])) {
$this->attributes['postalAddress'][] = '';
}
$this->attributes['postalAddress'] = array_values($this->attributes['postalAddress']);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI') && !$this->isAdminReadOnly('labeledURI')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('labeledURI', $errors);
2011-12-11 13:36:34 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress') && !$this->isAdminReadOnly('registeredAddress')) {
2011-11-03 18:31:33 +00:00
$addressCounter = 0;
while (isset($_POST['registeredAddress' . $addressCounter])) {
$this->attributes['registeredAddress'][$addressCounter] = implode('$', preg_split('/[\r][\n]/', $_POST['registeredAddress' . $addressCounter]));
if (!get_preg($this->attributes['registeredAddress'][$addressCounter], 'postalAddress')) $errors[] = $this->messages['registeredAddress'][0];
if ($this->attributes['registeredAddress'][$addressCounter] == '') {
unset($this->attributes['registeredAddress'][$addressCounter]);
}
$addressCounter++;
}
if (isset($_POST['addRegisteredAddress'])) {
$this->attributes['registeredAddress'][] = '';
}
$this->attributes['registeredAddress'] = array_values($this->attributes['registeredAddress']);
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType') && !$this->isAdminReadOnly('employeeType')) {
2009-10-03 17:29:10 +00:00
$this->attributes['employeeType'][0] = $_POST['employeeType'];
if (!get_preg($this->attributes['employeeType'][0], 'employeeType')) $errors[] = $this->messages['employeeType'][0];
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber') && !$this->isAdminReadOnly('roomNumber')) {
2009-10-03 17:29:10 +00:00
$this->attributes['roomNumber'][0] = $_POST['roomNumber'];
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation') && !$this->isAdminReadOnly('l')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('l', $errors);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') && !$this->isAdminReadOnly('st')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('st', $errors);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense') && !$this->isAdminReadOnly('carLicense')) {
2009-10-03 17:29:10 +00:00
$this->attributes['carLicense'][0] = $_POST['carLicense'];
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName') && !$this->isAdminReadOnly('physicalDeliveryOfficeName')) {
2013-11-01 18:59:55 +00:00
$this->processMultiValueInputTextField('physicalDeliveryOfficeName', $errors);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory') && !$this->isAdminReadOnly('businessCategory')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('businessCategory', $errors, 'businessCategory');
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments') && !$this->isAdminReadOnly('departmentNumber')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('departmentNumber', $errors);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber') && !$this->isAdminReadOnly('employeeNumber')) {
$this->attributes['employeeNumber'][0] = $_POST['employeeNumber'];
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu') && !$this->isAdminReadOnly('ou')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('ou', $errors);
2012-10-14 08:32:26 +00:00
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO') && !$this->isAdminReadOnly('o')) {
2013-11-02 10:25:08 +00:00
$this->processMultiValueInputTextField('o', $errors);
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials') && !$this->isAdminReadOnly('initials')) {
$this->attributes['initials'] = preg_split('/;[ ]*/', $_POST['initials']);
}
2014-04-21 19:21:47 +00:00
if (!$this->isUnixActive()) {
// uid
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID') && !$this->isAdminReadOnly('uid')) {
2013-11-01 18:59:55 +00:00
if (isset($_POST['uid']) && ($_POST['uid'] != '')) {
if (!get_preg($_POST['uid'], 'username')) {
$errors[] = $this->messages['uid'][0];
}
else {
2013-11-01 18:59:55 +00:00
$this->attributes['uid'][0] = $_POST['uid'];
}
2007-07-21 09:47:48 +00:00
}
elseif (isset($this->attributes['uid'][0])) {
unset($this->attributes['uid'][0]);
2007-07-21 09:47:48 +00:00
}
}
// cn
2014-01-06 14:29:09 +00:00
if (!$this->isAdminReadOnly('cn')) {
2014-04-21 19:21:47 +00:00
$this->processMultiValueInputTextField('cn', $errors, 'cn');
if (empty($this->attributes['cn'][0])) {
2014-01-06 14:29:09 +00:00
if ($_POST['givenName'] != '') {
$this->attributes['cn'][0] = $_POST['givenName'] . " " . $_POST['sn'];
}
else {
$this->attributes['cn'][0] = $_POST['sn'];
}
}
}
2014-01-06 14:29:09 +00:00
if (!$this->isAdminReadOnly('userPassword')) {
if (isset($_POST['lockPassword'])) {
$this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]);
}
if (isset($_POST['unlockPassword'])) {
$this->attributes['userPassword'][0] = pwd_enable($this->attributes['userPassword'][0]);
}
if (isset($_POST['removePassword'])) {
unset($this->attributes['userPassword']);
}
2015-02-11 16:57:38 +00:00
// set SASL password for new and renamed users
if (!empty($this->attributes['uid'][0]) && !empty($this->moduleSettings['posixAccount_pwdHash'][0])
&& ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL')
&& ($this->getAccountContainer()->isNewAccount || ($this->attributes['uid'][0] != $this->orig['uid'][0]))) {
$this->attributes['userPassword'][0] = '{SASL}' . $this->attributes['uid'][0];
}
2016-01-02 12:16:14 +00:00
// set K5KEY password for new users
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'K5KEY')) {
$this->attributes[$this->getPasswordAttrName()][0] = pwd_hash('x', true, $this->moduleSettings['posixAccount_pwdHash'][0]);
}
2011-04-25 17:57:04 +00:00
}
}
2014-01-06 14:29:09 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto') && isset($_POST['delPhoto']) && !$this->isAdminReadOnly('jpegPhoto')) {
2008-04-24 18:50:02 +00:00
$this->attributes['jpegPhoto'] = array();
}
2003-12-30 15:36:30 +00:00
// Return error-messages
2006-05-20 16:32:02 +00:00
return $errors;
2006-01-23 19:26:16 +00:00
}
2003-12-12 00:52:35 +00:00
2007-06-24 17:54:23 +00:00
/**
* Returns the HTML meta data for the main account page.
*
2007-06-24 17:54:23 +00:00
* @return array HTML meta data
*/
2006-08-13 12:58:19 +00:00
function display_html_attributes() {
2013-03-24 15:25:01 +00:00
$this->initCache();
2019-09-01 08:52:03 +00:00
$container = new htmlResponsiveRow();
2019-09-02 16:05:25 +00:00
$fieldContainer = new htmlResponsiveRow();
2019-10-23 16:56:54 +00:00
$fieldTabletColumns = $this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto') ? 12 : 8;
$container->add($fieldContainer, 12, 12, $fieldTabletColumns);
2014-01-06 14:29:09 +00:00
// uid
2014-04-21 19:21:47 +00:00
if (!$this->isUnixActive() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('uid')) {
$this->addSimpleReadOnlyField($fieldContainer, 'uid', _('User name'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'uid', _('User name'));
}
2013-11-01 18:59:55 +00:00
}
2014-01-06 14:29:09 +00:00
// first name
if ($this->isAdminReadOnly('givenName')) {
$this->addSimpleReadOnlyField($fieldContainer, 'givenName', _('First name'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'givenName', _('First name'));
}
// last name
if ($this->isAdminReadOnly('sn')) {
$this->addSimpleReadOnlyField($fieldContainer, 'sn', _('Last name'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'sn', _('Last name'), true);
}
// initials
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('initials')) {
$this->addSimpleReadOnlyField($fieldContainer, 'initials', _('Initials'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'initials', _('Initials'));
}
}
2014-01-06 14:29:09 +00:00
// common name
2014-04-21 19:21:47 +00:00
if (!$this->isUnixActive()) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('cn')) {
$this->addSimpleReadOnlyField($fieldContainer, 'cn', _('Common name'));
}
else {
2014-04-21 19:21:47 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'cn', _('Common name'), true);
2014-01-06 14:29:09 +00:00
}
}
2020-01-19 17:12:03 +00:00
// display name
if (!$this->isSamba3Active() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) {
$this->addSimpleInputTextField($fieldContainer, 'displayName', _('Display name'));
}
// description
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('description')) {
$this->addSimpleReadOnlyField($fieldContainer, 'description', _('Description'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'description', _('Description'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
2010-06-12 19:37:51 +00:00
2011-04-30 09:12:32 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')
2011-11-03 18:31:33 +00:00
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
2019-09-02 16:05:25 +00:00
$fieldContainer->add(new htmlSubTitle(_('Address')), 12);
2011-04-30 09:12:32 +00:00
}
2010-06-12 19:37:51 +00:00
2014-01-06 14:29:09 +00:00
// street
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('street')) {
$this->addSimpleReadOnlyField($fieldContainer, 'street', _('Street'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'street', _('Street'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// post office box
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('postOfficeBox')) {
$this->addSimpleReadOnlyField($fieldContainer, 'postOfficeBox', _('Post office box'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'postOfficeBox', _('Post office box'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// postal code
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('postalCode')) {
$this->addSimpleReadOnlyField($fieldContainer, 'postalCode', _('Postal code'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'postalCode', _('Postal code'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// location
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('l')) {
$this->addSimpleReadOnlyField($fieldContainer, 'l', _('Location'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'l', _('Location'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// state
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('st')) {
$this->addSimpleReadOnlyField($fieldContainer, 'st', _('State'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'st', _('State'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// postal address
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$postalAddresses = array();
2011-05-10 18:23:37 +00:00
if (isset($this->attributes['postalAddress'][0])) {
for ($i = 0; $i < sizeof($this->attributes['postalAddress']); $i++) {
$postalAddresses[] = implode("\r\n", explode('$', $this->attributes['postalAddress'][$i]));
}
2011-05-10 18:23:37 +00:00
}
if (sizeof($postalAddresses) == 0) {
$postalAddresses[] = '';
}
$addressLabel = new htmlOutputText(_('Postal address'));
$addressLabel->alignment = htmlElement::ALIGN_TOP;
2019-09-02 16:05:25 +00:00
$fieldContainer->addLabel($addressLabel);
$addressContainer = new htmlGroup();
for ($i = 0; $i < sizeof($postalAddresses); $i++) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('postalAddress')) {
$val = str_replace("\r\n", '<br>', htmlspecialchars($postalAddresses[$i]));
$addressContainer->addElement(new htmlOutputText($val, false));
if ($i < (sizeof($postalAddresses) - 1)) {
$addressContainer->addElement(new htmlOutputText('<br>', false));
}
}
else {
2014-01-06 14:29:09 +00:00
$addressContainer->addElement(new htmlInputTextarea('postalAddress' . $i, $postalAddresses[$i], 30, 3));
if ($i < (sizeof($postalAddresses) - 1)) {
$addressContainer->addElement(new htmlOutputText('<br>', false));
}
else {
$addressContainer->addElement(new htmlButton('addPostalAddress', 'add.png', true));
2019-09-02 16:05:25 +00:00
$addressHelp = new htmlHelpLink('postalAddress');
$addressContainer->addElement($addressHelp);
2014-01-06 14:29:09 +00:00
}
}
}
2019-09-02 16:05:25 +00:00
$fieldContainer->addField($addressContainer);
2009-10-03 17:29:10 +00:00
}
2014-01-06 14:29:09 +00:00
// registered address
2011-11-03 18:31:33 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
$registeredAddresses = array();
if (isset($this->attributes['registeredAddress'][0])) {
for ($i = 0; $i < sizeof($this->attributes['registeredAddress']); $i++) {
$registeredAddresses[] = implode("\r\n", explode('$', $this->attributes['registeredAddress'][$i]));
}
}
if (sizeof($registeredAddresses) == 0) {
$registeredAddresses[] = '';
}
$registeredAddressLabel = new htmlOutputText(_('Registered address'));
$registeredAddressLabel->alignment = htmlElement::ALIGN_TOP;
2019-09-02 16:05:25 +00:00
$fieldContainer->addLabel($registeredAddressLabel);
2011-11-03 18:31:33 +00:00
$registeredAddressContainer = new htmlGroup();
for ($i = 0; $i < sizeof($registeredAddresses); $i++) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('registeredAddress')) {
$val = str_replace("\r\n", '<br>', htmlspecialchars($registeredAddresses[$i]));
$registeredAddressContainer->addElement(new htmlOutputText($val, false));
if ($i < (sizeof($registeredAddresses) - 1)) {
$registeredAddressContainer->addElement(new htmlOutputText('<br>', false));
}
2011-11-03 18:31:33 +00:00
}
else {
2014-01-06 14:29:09 +00:00
$registeredAddressContainer->addElement(new htmlInputTextarea('registeredAddress' . $i, $registeredAddresses[$i], 30, 3));
if ($i < (sizeof($registeredAddresses) - 1)) {
$registeredAddressContainer->addElement(new htmlOutputText('<br>', false));
}
else {
$registeredAddressContainer->addElement(new htmlButton('addRegisteredAddress', 'add.png', true));
2019-09-02 16:05:25 +00:00
$registeredAddressHelp = new htmlHelpLink('registeredAddress');
$registeredAddressContainer->addElement($registeredAddressHelp);
2014-01-06 14:29:09 +00:00
}
2011-11-03 18:31:33 +00:00
}
}
2019-09-02 16:05:25 +00:00
$fieldContainer->addField($registeredAddressContainer);
2011-11-03 18:31:33 +00:00
}
2014-01-06 14:29:09 +00:00
// office name
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('physicalDeliveryOfficeName')) {
$this->addSimpleReadOnlyField($fieldContainer, 'physicalDeliveryOfficeName', _('Office name'));
}
2013-11-01 18:59:55 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'physicalDeliveryOfficeName', _('Office name'));
2013-11-01 18:59:55 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('roomNumber')) {
$this->addSimpleReadOnlyField($fieldContainer, 'roomNumber', _('Room number'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'roomNumber', _('Room number'));
}
2009-10-03 17:29:10 +00:00
}
2011-04-30 09:12:32 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')
2011-12-11 13:36:34 +00:00
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
2019-09-02 16:05:25 +00:00
$fieldContainer->add(new htmlSubTitle(_('Contact data')), 12);
2011-04-30 09:12:32 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('telephoneNumber')) {
$this->addSimpleReadOnlyField($fieldContainer, 'telephoneNumber', _('Telephone number'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'telephoneNumber', _('Telephone number'));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('homePhone')) {
$this->addSimpleReadOnlyField($fieldContainer, 'homePhone', _('Home telephone number'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'homePhone', _('Home telephone number'));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('mobile')) {
$this->addSimpleReadOnlyField($fieldContainer, 'mobile', _('Mobile number'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'mobile', _('Mobile number'));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('facsimileTelephoneNumber')) {
$this->addSimpleReadOnlyField($fieldContainer, 'facsimileTelephoneNumber', _('Fax number'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'facsimileTelephoneNumber', _('Fax number'));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
2014-07-27 11:10:42 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePager', true)) {
if ($this->isAdminReadOnly('pager')) {
$this->addSimpleReadOnlyField($fieldContainer, 'pager', _('Pager'));
}
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'pager', _('Pager'));
2014-07-27 11:10:42 +00:00
}
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('mail')) {
$this->addSimpleReadOnlyField($fieldContainer, 'mail', _('Email address'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'mail', _('Email address'));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
2011-12-11 13:36:34 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('labeledURI')) {
$this->addSimpleReadOnlyField($fieldContainer, 'labeledURI', _('Web site'));
2011-12-11 13:36:34 +00:00
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'labeledURI', _('Web site'));
2013-11-02 10:25:08 +00:00
}
2011-12-11 13:36:34 +00:00
}
2011-04-30 09:12:32 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')
2013-01-28 21:15:55 +00:00
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments') || !$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')
|| !$this->isBooleanConfigOptionSet('inetOrgPerson_hideuserCertificate')) {
2019-09-02 16:05:25 +00:00
$fieldContainer->add(new htmlSubTitle(_('Work details')), 12);
2011-04-30 09:12:32 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('title')) {
$this->addSimpleReadOnlyField($fieldContainer, 'title', _('Job title'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'title', _('Job title'), false, null, false, array_slice($this->titleCache, 0, 300));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('carLicense')) {
$this->addSimpleReadOnlyField($fieldContainer, 'carLicense', _('Car license'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'carLicense', _('Car license'));
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeNumber')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('employeeNumber')) {
$this->addSimpleReadOnlyField($fieldContainer, 'employeeNumber', _('Employee number'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'employeeNumber', _('Employee number'));
}
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('employeeType')) {
$this->addSimpleReadOnlyField($fieldContainer, 'employeeType', _('Employee type'));
}
else {
2014-09-21 18:09:44 +00:00
$this->addSimpleInputTextField($fieldContainer, 'employeeType', _('Employee type'), false, null, false, array_slice($this->employeeTypeCache, 0, 300));
2014-01-06 14:29:09 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('businessCategory')) {
$this->addSimpleReadOnlyField($fieldContainer, 'businessCategory', _('Business category'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'businessCategory', _('Business category'), false, null, false, array_slice($this->businessCategoryCache, 0, 300));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('departmentNumber')) {
$this->addSimpleReadOnlyField($fieldContainer, 'departmentNumber', _('Department'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'departmentNumber', _('Department'), false, null, false, array_slice($this->departmentCache, 0, 300));
2013-11-02 10:25:08 +00:00
}
2009-10-03 17:29:10 +00:00
}
2012-10-14 08:32:26 +00:00
// organisational unit
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('ou')) {
$this->addSimpleReadOnlyField($fieldContainer, 'ou', _('Organisational unit'));
2012-10-14 08:32:26 +00:00
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'ou', _('Organisational unit'), false, null, false, array_slice($this->ouCache, 0, 300));
2013-11-02 10:25:08 +00:00
}
2012-10-14 08:32:26 +00:00
}
// organisation
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) {
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('o')) {
$this->addSimpleReadOnlyField($fieldContainer, 'o', _('Organisation'));
}
2013-11-02 10:25:08 +00:00
else {
2019-09-01 08:52:03 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'o', _('Organisation'), false, null, false, array_slice($this->oCache, 0, 300));
2013-11-02 10:25:08 +00:00
}
}
2013-01-28 21:15:55 +00:00
// user certificates
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideuserCertificate')) {
2019-09-02 16:05:25 +00:00
$fieldContainer->addVerticalSpacer('0.5rem');
$fieldContainer->addLabel(new htmlOutputText(_('User certificates')));
2013-01-28 21:15:55 +00:00
$userCertificateGroup = new htmlGroup();
$userCertificateCount = 0;
if (isset($this->attributes['userCertificate;binary'])) {
$userCertificateCount = sizeof($this->attributes['userCertificate;binary']);
}
$userCertificateGroup->addElement(new htmlOutputText($userCertificateCount));
$userCertificateGroup->addElement(new htmlSpacer('10px', null));
2014-01-06 14:29:09 +00:00
if (!$this->isAdminReadOnly('manager')) {
$userCertificateGroup->addElement(new htmlAccountPageButton(get_class($this), 'userCertificate', 'manage', _('Manage')));
2019-09-02 16:05:25 +00:00
$userCertificateGroup->addElement(new htmlHelpLink('userCertificate'));
2014-01-06 14:29:09 +00:00
}
2019-09-02 16:05:25 +00:00
$fieldContainer->addField($userCertificateGroup);
2013-01-28 21:15:55 +00:00
}
2011-12-20 20:40:51 +00:00
// manager
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
2019-09-02 16:05:25 +00:00
$fieldContainer->addVerticalSpacer('0.5rem');
$fieldContainer->addLabel(new htmlOutputText(_('Manager')));
if (!$this->isAdminReadOnly('manager')) {
$managerButtonGroup = new htmlGroup();
$managerButtonGroup->addElement(new htmlAccountPageButton(get_class($this), 'manager', 'change', _("Change")));
$managerButtonGroup->addElement(new htmlHelpLink('manager'));
$fieldContainer->addField($managerButtonGroup);
2014-01-06 14:29:09 +00:00
}
2009-10-03 17:29:10 +00:00
if (isset($this->attributes['manager'][0])) {
2011-12-20 20:40:51 +00:00
$managerList = array();
for ($i = 0; $i < sizeof($this->attributes['manager']); $i++) {
$managerList[] = $this->attributes['manager'][$i];
}
usort($managerList, 'compareDN');
$managers = new htmlTable();
2013-03-12 20:06:16 +00:00
$managers->alignment = htmlElement::ALIGN_RIGHT;
$managers->colspan = 3;
2011-12-20 20:40:51 +00:00
for ($i = 0; $i < sizeof($managerList); $i++) {
2013-03-12 20:06:16 +00:00
$manager = new htmlOutputText(getAbstractDN($managerList[$i]));
$manager->alignment = htmlElement::ALIGN_RIGHT;
$managers->addElement($manager, true);
2011-12-20 20:40:51 +00:00
}
2019-09-02 16:05:25 +00:00
$fieldContainer->addLabel(new htmlOutputText('&nbsp;', false));
$fieldContainer->addField($managers);
2009-10-03 17:29:10 +00:00
}
2005-07-02 12:05:33 +00:00
}
2011-04-25 17:57:04 +00:00
// password buttons
2014-04-21 19:21:47 +00:00
if (!$this->isUnixActive() && checkIfWriteAccessIsAllowed($this->get_scope()) && isset($this->attributes['userPassword'][0]) && !$this->isAdminReadOnly('userPassword')) {
2019-09-02 16:05:25 +00:00
$fieldContainer->add(new htmlSubTitle(_('Password')), 12);
2019-09-27 18:09:47 +00:00
$pwdContainer = new htmlGroup();
2011-04-25 17:57:04 +00:00
if (pwd_is_enabled($this->attributes['userPassword'][0])) {
$pwdContainer->addElement(new htmlButton('lockPassword', _('Lock password')));
}
else {
$pwdContainer->addElement(new htmlButton('unlockPassword', _('Unlock password')));
}
2019-09-27 18:09:47 +00:00
$pwdContainer->addElement(new htmlSpacer('0.5rem', null));
2011-04-25 17:57:04 +00:00
$pwdContainer->addElement(new htmlButton('removePassword', _('Remove password')));
2019-09-27 18:09:47 +00:00
$fieldContainer->add($pwdContainer, 12, 12, 12, 'text-center');
2011-04-25 17:57:04 +00:00
}
2005-12-05 14:45:01 +00:00
// photo
2013-12-26 16:08:55 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) {
$imageContainer = new htmlTable();
2019-09-02 16:05:25 +00:00
$imageContainer->setCSSClasses(array('div-center'));
2013-12-26 16:08:55 +00:00
$imageContainer->alignment = htmlElement::ALIGN_TOP;
$photoFile = '../../graphics/userDefault.png';
$noPhoto = true;
if (isset($this->attributes['jpegPhoto'][0])) {
$jpeg_filename = 'jpg' . getRandomNumber() . '.jpg';
$outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $this->attributes['jpegPhoto'][0]);
fclose ($outjpeg);
$photoFile = '../../tmp/' . $jpeg_filename;
$noPhoto = false;
}
2014-10-25 13:13:44 +00:00
$img = new htmlImage($photoFile);
$img->setCSSClasses(array('photo'));
2018-10-28 16:18:47 +00:00
$img->enableLightbox();
2014-10-25 13:13:44 +00:00
$imageContainer->addElement($img, true);
2014-01-06 14:29:09 +00:00
if (!$this->isAdminReadOnly('jpegPhoto')) {
if ($noPhoto) {
$imageContainer->addElement(new htmlAccountPageButton(get_class($this), 'photo', 'open', _('Add photo')));
}
else {
$imageContainer->addElement(new htmlButton('delPhoto', _('Delete photo')));
}
2013-12-26 16:08:55 +00:00
}
2019-10-23 16:56:54 +00:00
$container->add($imageContainer, 12, 12, 4);
2005-12-05 14:45:01 +00:00
}
return $container;
}
2005-12-05 14:45:01 +00:00
/**
* Sets a new photo.
2018-05-12 08:43:32 +00:00
*
* @return array list of error messages if any
2005-12-05 14:45:01 +00:00
*/
2018-05-12 08:43:32 +00:00
public function process_photo() {
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_back'])) {
2011-12-08 19:17:37 +00:00
return array();
}
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('jpegPhoto')) {
2018-05-12 08:43:32 +00:00
return array();
}
2020-07-22 11:28:17 +00:00
if (isset($_POST['form_subpage_' . get_class($this) . '_photo_upload']) || isset($_POST['webcamData'])) {
2018-05-12 08:43:32 +00:00
return $this->uploadPhoto();
}
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_crop'])) {
$messages = array();
try {
2018-08-19 17:13:16 +00:00
include_once dirname(__FILE__) . '/../imageutils.inc';
$imageManipulator = ImageManipulationFactory::getImageManipulator($this->attributes['jpegPhoto'][0]);
$imageManipulator->crop($_POST['croppingDataX'], $_POST['croppingDataY'], $_POST['croppingDataWidth'], $_POST['croppingDataHeight']);
$this->attributes['jpegPhoto'][0] = $imageManipulator->getImageData();
2018-05-12 08:43:32 +00:00
}
catch (Exception $e) {
$msg = $this->messages['file'][2];
$msg[] = htmlspecialchars($e->getMessage());
$messages[] = $msg;
}
2014-01-06 14:29:09 +00:00
return $messages;
}
2018-05-12 08:43:32 +00:00
}
/**
* Uploads the photo file.
*
* @return array error messages if any
*/
private function uploadPhoto() {
$messages = array();
2020-07-22 11:28:17 +00:00
if ((empty($_FILES['photoFile']) || ($_FILES['photoFile']['size'] <= 0)) && empty($_POST['webcamData'])) {
$messages[] = $this->messages['file'][0];
return $messages;
}
if (!empty($_FILES['photoFile']['tmp_name'])) {
2005-12-05 14:45:01 +00:00
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
2018-05-16 16:00:54 +00:00
$data = fread($handle, 100000000);
2020-07-24 18:49:04 +00:00
fclose($handle);
2013-12-26 16:08:55 +00:00
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]))) {
$errMsg = $this->messages['file'][3];
$errMsg[] = null;
$errMsg[] = array($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]);
return array($errMsg);
}
2005-12-05 14:45:01 +00:00
}
2020-07-22 11:28:17 +00:00
elseif (isset($_POST['webcamData'])) {
$data = $_POST['webcamData'];
$data = str_replace('data:image/png;base64,', '', $data);
$data = base64_decode($data);
}
// convert to JPG
try {
include_once dirname(__FILE__) . '/../imageutils.inc';
$imageManipulator = ImageManipulationFactory::getImageManipulator($data);
// resize if maximum values specified
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0])) {
$maxWidth = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $imageManipulator->getWidth() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0];
$maxHeight = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $imageManipulator->getHeight() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0];
$imageManipulator->thumbnail($maxWidth, $maxHeight);
}
$imageManipulator->convertToJpeg();
$data = $imageManipulator->getImageData();
}
catch (Exception $e) {
$msg = $this->messages['file'][2];
$msg[] = htmlspecialchars($e->getMessage());
$messages[] = $msg;
return $messages;
2005-12-05 14:45:01 +00:00
}
2020-07-22 11:28:17 +00:00
$this->attributes['jpegPhoto'][0] = $data;
2005-12-05 14:45:01 +00:00
return $messages;
}
/**
* Displays the photo upload page.
*
* @return array meta HTML code
*/
2018-05-12 08:43:32 +00:00
public function display_html_photo() {
2019-09-01 08:52:03 +00:00
$container = new htmlResponsiveRow();
2018-05-12 08:43:32 +00:00
if (empty($this->attributes['jpegPhoto'][0])) {
2019-09-01 08:52:03 +00:00
$container->add(new htmlSubTitle(_('Upload image')), 12);
2018-05-12 08:43:32 +00:00
$label = _('Photo file');
2019-09-01 08:52:03 +00:00
$container->add(new htmlResponsiveInputFileUpload('photoFile', $label, 'photoUpload'), 12);
2020-07-22 06:23:49 +00:00
$container->addVerticalSpacer('0.5rem');
$container->addLabel(new htmlOutputText('&nbsp;', false));
$container->addField(new htmlAccountPageButton(get_class($this), 'photo', 'upload', _('Upload')));
2019-09-01 08:52:03 +00:00
$container->addVerticalSpacer('1rem');
2020-07-22 06:23:49 +00:00
$webcamContent = new htmlResponsiveRow();
2020-07-24 08:06:22 +00:00
$webcamContent->add(new htmlSubTitle(_('Use webcam')), 12);
2020-07-22 11:28:17 +00:00
$errorMessage = new htmlStatusMessage('ERROR', '');
$errorMessage->setCSSClasses(array('hidden', 'lam-webcam-message'));
$webcamContent->add($errorMessage, 12);
$captureButton = new htmlButton('lam-webcam-capture', _('Start capture'));
2020-07-24 08:06:22 +00:00
$captureButton->setOnClick('window.lam.tools.webcam.capture(event);');
2020-07-22 11:28:17 +00:00
$webcamContent->add($captureButton, 12, 12, 12, 'text-center');
$video = new htmlVideo('lam-webcam-video');
$video->setCSSClasses(array('hidden'));
$webcamContent->add($video, 12, 12, 12, 'text-center');
$webcamContent->addVerticalSpacer('0.5rem');
$webcamUploadButton = new htmlButton('uploadWebcam', _('Upload'));
$webcamUploadButton->setCSSClasses(array('btn-lam-webcam-upload', 'hidden'));
2020-07-24 08:06:22 +00:00
$webcamUploadButton->setOnClick('window.lam.tools.webcam.upload();');
2020-07-22 11:28:17 +00:00
$webcamContent->add($webcamUploadButton, 12, 12, 12, 'text-center');
$canvas = new htmlCanvas('lam-webcam-canvas');
$canvas->setCSSClasses(array('hidden'));
$webcamContent->add($canvas, 12);
2020-07-22 06:23:49 +00:00
$webcamDiv = new htmlDiv('lam_webcam_div', $webcamContent, array('hidden'));
$container->add($webcamDiv, 12);
$container->addVerticalSpacer('1rem');
$container->add(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')), 12);
2018-05-12 08:43:32 +00:00
}
else {
2019-09-01 08:52:03 +00:00
$container->add(new htmlSubTitle(_('Crop image')), 12);
2018-05-12 08:43:32 +00:00
$jpeg_filename = 'jpg' . getRandomNumber() . '.jpg';
$outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $this->attributes['jpegPhoto'][0]);
fclose ($outjpeg);
$photoFile = '../../tmp/' . $jpeg_filename;
$img = new htmlImage($photoFile);
$img->setCSSClasses(array('photo'));
$img->enableCropping();
2019-09-01 08:52:03 +00:00
$container->add($img, 12);
$container->addVerticalSpacer('1rem');
$doneButton = new htmlAccountPageButton(get_class($this), 'attributes', 'crop', _('Done'));
$container->add($doneButton, 12);
2018-05-12 08:43:32 +00:00
}
2010-06-21 16:23:44 +00:00
return $container;
2005-12-05 14:45:01 +00:00
}
2011-12-20 20:40:51 +00:00
/**
* This function will create the meta HTML code to show a page to change the manager attribute.
*
2011-12-20 20:40:51 +00:00
* @return htmlElement HTML meta data
*/
function display_html_manager() {
2019-09-01 08:52:03 +00:00
$return = new htmlResponsiveRow();
2011-12-20 20:40:51 +00:00
if (!isset($this->attributes['manager'])) {
$this->attributes['manager'] = array();
}
// show list of possible new managers
if (isset($_POST['form_subpage_' . get_class($this) . '_manager_select'])) {
$options = array();
$filter = get_ldap_filter('user');
2012-07-22 10:38:24 +00:00
$entries = searchLDAPByFilter('(|' . $filter . '(objectclass=organizationalRole))', array('dn'), array('user'));
2011-12-20 20:40:51 +00:00
for ($i = 0; $i < sizeof($entries); $i++) {
$entries[$i] = $entries[$i]['dn'];
}
// sort by DN
usort($entries, 'compareDN');
for ($i = 0; $i < sizeof($entries); $i++) {
if (!isset($this->attributes['manager']) || !in_array($entries[$i], $this->attributes['manager'])) {
$options[getAbstractDN($entries[$i])] = $entries[$i];
}
}
$size = 20;
2019-09-01 08:52:03 +00:00
if (sizeof($options) < 20) {
$size = sizeof($options);
}
2011-12-20 20:40:51 +00:00
$managerSelect = new htmlSelect('manager', $options, array(), $size);
$managerSelect->setHasDescriptiveElements(true);
$managerSelect->setMultiSelect(true);
$managerSelect->setRightToLeftTextDirection(true);
$managerSelect->setSortElements(false);
$managerSelect->setTransformSingleSelect(false);
2019-09-01 08:52:03 +00:00
$return->add($managerSelect, 12);
$return->addVerticalSpacer('1rem');
$return->addLabel(new htmlAccountPageButton(get_class($this), 'manager', 'addManagers', _('Add')));
$return->addField(new htmlAccountPageButton(get_class($this), 'manager', 'cancel', _('Cancel')));
2011-12-20 20:40:51 +00:00
return $return;
}
// show existing managers
$managerTemp = array();
if (isset($this->attributes['manager'])) {
$managerTemp = $this->attributes['manager'];
}
// sort by DN
usort($managerTemp, 'compareDN');
$managers = array();
for ($i = 0; $i < sizeof($managerTemp); $i++) {
$managers[getAbstractDN($managerTemp[$i])] = $managerTemp[$i];
}
$size = 20;
if (sizeof($this->attributes['manager']) < 20) {
$size = sizeof($this->attributes['manager']);
}
if (sizeof($managers) > 0) {
$managerSelect = new htmlSelect('manager', $managers, array(), $size);
$managerSelect->setHasDescriptiveElements(true);
$managerSelect->setMultiSelect(true);
$managerSelect->setRightToLeftTextDirection(true);
$managerSelect->setSortElements(false);
$managerSelect->setTransformSingleSelect(false);
2019-09-01 08:52:03 +00:00
$return->add($managerSelect, 12);
$return->addVerticalSpacer('0.5rem');
2011-12-20 20:40:51 +00:00
$removeButton = new htmlAccountPageButton(get_class($this), 'manager', 'remove', _('Remove selected entries'));
2019-09-01 08:52:03 +00:00
$return->add($removeButton, 12, 12, 12, 'text-center');
$return->addVerticalSpacer('1rem');
$return->add(new htmlHorizontalLine(), 12);
}
$return->addVerticalSpacer('1rem');
$return->addLabel(new htmlAccountPageButton(get_class($this), 'manager', 'select', _('Add entries')));
$return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'managerBack', _('Back')));
2011-12-20 20:40:51 +00:00
return $return;
}
/**
* Processes user input of the manager page.
* It checks if all input values are correct and updates the associated LDAP attributes.
*
* @return array list of info/error messages
*/
function process_manager() {
$return = array();
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('manager')) {
return $return;
}
2011-12-20 20:40:51 +00:00
if (isset($_POST['form_subpage_' . get_class($this) . '_manager_remove']) && isset($_POST['manager'])) {
$managers = array_flip($this->attributes['manager']);
for ($i = 0; $i < sizeof($_POST['manager']); $i++) {
if (isset($managers[$_POST['manager'][$i]])) {
unset($managers[$_POST['manager'][$i]]);
}
}
$this->attributes['manager'] = array_values(array_flip($managers));
}
elseif (isset($_POST['form_subpage_' . get_class($this) . '_manager_addManagers']) && isset($_POST['manager'])) {
for ($i = 0; $i < sizeof($_POST['manager']); $i++) {
$this->attributes['manager'][] = $_POST['manager'][$i];
$this->attributes['manager'] = array_unique($this->attributes['manager']);
}
}
return $return;
}
2005-12-05 14:45:01 +00:00
2013-01-28 21:15:55 +00:00
/**
* Displays the certificate upload page.
*
* @return array meta HTML code
*/
function display_html_userCertificate() {
2019-09-01 08:52:03 +00:00
$container = new htmlResponsiveRow();
2013-01-28 21:15:55 +00:00
if (isset($this->attributes['userCertificate;binary'])) {
$table = new htmlTable();
$table->colspan = 10;
for ($i = 0; $i < sizeof($this->attributes['userCertificate;binary']); $i++) {
2013-07-21 11:34:31 +00:00
$filename = 'userCertificate' . getRandomNumber() . '.der';
$pathOut = dirname(__FILE__) . '/../../tmp/' . $filename;
$out = @fopen($pathOut, "wb");
@chmod($pathOut, 0640);
2013-01-28 21:15:55 +00:00
fwrite($out, $this->attributes['userCertificate;binary'][$i]);
fclose ($out);
$path = '../../tmp/' . $filename;
$link = new htmlLink('', $path, '../../graphics/save.png');
$link->setTargetWindow('_blank');
$table->addElement($link);
$deleteButton = new htmlAccountPageButton(get_class($this), 'userCertificate', 'delete_' . $i, 'delete.png', true);
$deleteButton->setIconClass('deleteButton');
$table->addElement($deleteButton);
if (function_exists('openssl_x509_parse')) {
$pem = @chunk_split(@base64_encode($this->attributes['userCertificate;binary'][$i]), 64, "\n");
if (!empty($pem)) {
$pem = "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n";
$pemData = @openssl_x509_parse($pem);
$data = array();
if (isset($pemData['serialNumber'])) {
$data[] = $pemData['serialNumber'];
}
if (isset($pemData['name'])) {
$data[] = $pemData['name'];
}
if (sizeof($data) > 0) {
$table->addElement(new htmlOutputText(implode(': ', $data)));
}
}
}
$table->addNewLine();
}
2019-09-01 08:52:03 +00:00
$container->add($table, 12);
$container->addVerticalSpacer('2rem');
2013-01-28 21:15:55 +00:00
}
2019-09-01 08:52:03 +00:00
$container->add(new htmlResponsiveInputFileUpload('userCertificateUpload', _('New user certificate')), 12, 6);
2013-01-28 21:15:55 +00:00
$uploadButton = new htmlAccountPageButton(get_class($this), 'userCertificate', 'submit', _('Upload'));
$uploadButton->setIconClass('upButton');
2019-09-01 08:52:03 +00:00
$container->add($uploadButton, 12, 6);
$container->addVerticalSpacer('2rem');
$container->add(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')), 12);
2013-01-28 21:15:55 +00:00
return $container;
}
2013-01-28 21:15:55 +00:00
/**
* Sets a new certificate or deletes old ones.
2014-01-06 14:29:09 +00:00
*
* @return array list of info/error messages
2013-01-28 21:15:55 +00:00
*/
function process_userCertificate() {
$messages = array();
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('userCertificate')) {
return $messages;
}
2013-01-28 21:15:55 +00:00
if (isset($_POST['form_subpage_' . get_class($this) . '_userCertificate_submit'])) {
if ($_FILES['userCertificateUpload'] && ($_FILES['userCertificateUpload']['size'] > 0)) {
$handle = fopen($_FILES['userCertificateUpload']['tmp_name'], "r");
$data = fread($handle, 10000000);
fclose($handle);
if (strpos($data, '-----BEGIN CERTIFICATE-----') === 0) {
$pemData = str_replace("\r", '', $data);
$pemData = explode("\n", $pemData);
array_shift($pemData);
$last = array_pop($pemData);
while (($last != '-----END CERTIFICATE-----') && sizeof($pemData) > 2) {
$last = array_pop($pemData);
}
$pemData = implode('', $pemData);
$data = base64_decode($pemData);
}
$this->attributes['userCertificate;binary'][] = $data;
}
else {
$messages[] = $this->messages['file'][0];
}
}
elseif (isset($this->attributes['userCertificate;binary'])) {
for ($i = 0; $i < sizeof($this->attributes['userCertificate;binary']); $i++) {
if (isset($_POST['form_subpage_' . get_class($this) . '_userCertificate_delete_' . $i])) {
unset($this->attributes['userCertificate;binary'][$i]);
$this->attributes['userCertificate;binary'] = array_values($this->attributes['userCertificate;binary']);
break;
}
}
}
return $messages;
}
2017-04-23 18:46:58 +00:00
/**
* {@inheritDoc}
* @see baseModule::get_pdfFields()
*/
public function get_pdfFields($typeId) {
$fields = parent::get_pdfFields($typeId);
$typeManager = new TypeManager();
$modules = $typeManager->getConfiguredType($typeId)->getModules();
if (!$this->isUnixActive($modules)) {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) {
$fields['uid'] = _('User name');
}
$fields['cn'] = _('Common name');
$fields['userPassword'] = _('Password');
}
2020-01-19 17:12:03 +00:00
if (!$this->isSamba3Active($modules)) {
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) {
$fields['displayName'] = _('Display name');
}
}
2017-04-23 18:46:58 +00:00
return $fields;
}
/**
2017-02-19 08:14:11 +00:00
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
2015-01-07 17:16:35 +00:00
*/
2017-04-01 07:57:03 +00:00
function get_pdfEntries($pdfKeys, $typeId) {
2013-05-04 18:22:07 +00:00
$return = array();
$this->addSimplePDFField($return, 'description', _('Description'));
$this->addSimplePDFField($return, 'title', _('Job title'));
$this->addSimplePDFField($return, 'givenName', _('First name'));
$this->addSimplePDFField($return, 'sn', _('Last name'));
$this->addSimplePDFField($return, 'manager', _('Manager'));
$this->addSimplePDFField($return, 'street', _('Street'));
$this->addSimplePDFField($return, 'postOfficeBox', _('Post office box'));
$this->addSimplePDFField($return, 'postalCode', _('Postal code'));
if (!empty($this->attributes['postalAddress'])) {
$this->addPDFKeyValue($return, 'postalAddress', _('Postal address'), str_replace('$', "\n", implode("\n\n", $this->attributes['postalAddress'])));
}
2013-05-04 18:22:07 +00:00
$this->addSimplePDFField($return, 'registeredAddress', _('Registered address'));
$this->addSimplePDFField($return, 'telephoneNumber', _('Telephone number'));
$this->addSimplePDFField($return, 'homePhone', _('Home telephone number'));
$this->addSimplePDFField($return, 'mobileTelephoneNumber', _('Mobile number'), 'mobile');
2014-07-27 11:10:42 +00:00
$this->addSimplePDFField($return, 'pager', _('Pager'));
2013-05-04 18:22:07 +00:00
$this->addSimplePDFField($return, 'mail', _('Email address'));
$this->addSimplePDFField($return, 'cn', _('Common name'));
$this->addSimplePDFField($return, 'facsimileTelephoneNumber', _('Fax number'));
$this->addSimplePDFField($return, 'roomNumber', _('Room number'));
$this->addSimplePDFField($return, 'businessCategory', _('Business category'));
$this->addSimplePDFField($return, 'uid', _('User name'));
$this->addSimplePDFField($return, 'carLicense', _('Car license'));
$this->addSimplePDFField($return, 'state', _('State'), 'st');
$this->addSimplePDFField($return, 'officeName', _('Office name'), 'physicalDeliveryOfficeName');
$this->addSimplePDFField($return, 'employeeType', _('Employee type'));
$this->addSimplePDFField($return, 'location', _('Location'), 'l');
$this->addSimplePDFField($return, 'employeeNumber', _('Employee number'));
$this->addSimplePDFField($return, 'ou', _('Organisational unit'));
$this->addSimplePDFField($return, 'o', _('Organisation'));
$this->addSimplePDFField($return, 'initials', _('Initials'));
$this->addSimplePDFField($return, 'labeledURI', _('Web site'));
$this->addSimplePDFField($return, 'departmentNumber', _('Department'));
2020-01-19 17:12:03 +00:00
$this->addSimplePDFField($return, 'displayName', _('Display name'));
2016-06-19 09:41:47 +00:00
if (isset($this->clearTextPassword)) {
$this->addPDFKeyValue($return, 'userPassword', _('Password'), $this->clearTextPassword);
}
else if (isset($this->attributes['INFO.userPasswordClearText'])) {
$this->addPDFKeyValue($return, 'userPassword', _('Password'), $this->attributes['INFO.userPasswordClearText']);
}
2018-08-25 17:39:47 +00:00
$this->addPDFImage($return, 'jpegPhoto');
2009-02-15 12:54:37 +00:00
return $return;
}
2017-04-23 18:46:58 +00:00
/**
* {@inheritDoc}
* @see baseModule::get_profileOptions()
*/
public function get_profileOptions($typeId) {
$typeManager = new TypeManager();
$modules = $typeManager->getConfiguredType($typeId)->getModules();
$profileElements = array();
if (!$this->isUnixActive($modules)) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Common name'), 'inetOrgPerson_cn', null, 'cn');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Initials'), 'inetOrgPerson_initials', null, 'initials');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Description'), 'inetOrgPerson_description', null, 'description');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Street'), 'inetOrgPerson_street', null, 'streetList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Post office box'), 'inetOrgPerson_postOfficeBox', null, 'postOfficeBoxList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Postal code'), 'inetOrgPerson_postalCode', null, 'postalCodeList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Location'), 'inetOrgPerson_l', null, 'lList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('State'), 'inetOrgPerson_st', null, 'stList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Postal address'), 'inetOrgPerson_postalAddress', null, 'postalAddress');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Registered address'), 'inetOrgPerson_registeredAddress', null, 'registeredAddress');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Office name'), 'inetOrgPerson_physicalDeliveryOfficeName', null, 'physicalDeliveryOfficeName');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Room number'), 'inetOrgPerson_roomNumber', null, 'roomNumber');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Telephone number'), 'inetOrgPerson_telephoneNumber', null, 'telephoneNumberList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Fax number'), 'inetOrgPerson_facsimileTelephoneNumber', null, 'facsimileTelephoneNumberList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Email address'), 'inetOrgPerson_mail', null, 'mailList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Web site'), 'inetOrgPerson_labeledURI', null, 'labeledURIList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Department'), 'inetOrgPerson_departmentNumber', null, 'departmentNumberList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Organisational unit'), 'inetOrgPerson_ou', null, 'ouList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Organisation'), 'inetOrgPerson_o', null, 'oList');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Job title'), 'inetOrgPerson_title', null, 'title');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Employee type'), 'inetOrgPerson_employeeType', null, 'employeeType');
2017-04-23 18:46:58 +00:00
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
2018-05-19 11:26:35 +00:00
$profileElements[] = new htmlResponsiveInputField(_('Business category'), 'inetOrgPerson_businessCategory', null, 'businessCategory');
2017-04-23 18:46:58 +00:00
}
if (sizeof($profileElements) > 0) {
2018-05-19 11:26:35 +00:00
$profileContainer = new htmlResponsiveRow();
2017-04-23 18:46:58 +00:00
for ($i = 0; $i < sizeof($profileElements); $i++) {
2018-05-19 11:26:35 +00:00
$profileContainer->add($profileElements[$i], 12);
2017-04-23 18:46:58 +00:00
}
return $profileContainer;
}
return null;
}
2009-02-15 12:54:37 +00:00
/**
* Loads the values of an account profile into internal variables.
*
* @param array $profile hash array with profile values (identifier => value)
*/
function load_profile($profile) {
// profile mappings in meta data
parent::load_profile($profile);
2017-04-23 18:46:58 +00:00
if (!$this->isUnixActive() && !empty($profile['inetOrgPerson_cn'][0])) {
$this->attributes['cn'][0] = $profile['inetOrgPerson_cn'][0];
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
// departments
if (isset($profile['inetOrgPerson_departmentNumber'][0]) && $profile['inetOrgPerson_departmentNumber'][0] != '') {
$departments = explode(';', $profile['inetOrgPerson_departmentNumber'][0]);
// remove extra spaces and set attributes
$this->attributes['departmentNumber'] = array_map('trim', $departments);
}
2009-02-15 12:54:37 +00:00
}
2012-10-14 08:32:26 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu') && isset($profile['inetOrgPerson_ou'][0])) {
$oList = preg_split('/;[ ]*/', $profile['inetOrgPerson_ou'][0]);
$this->attributes['ou'] = $oList;
}
2011-05-07 08:05:25 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO') && isset($profile['inetOrgPerson_o'][0])) {
$oList = preg_split('/;[ ]*/', $profile['inetOrgPerson_o'][0]);
$this->attributes['o'] = $oList;
}
2011-05-07 08:05:25 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress') && isset($profile['inetOrgPerson_mail'][0])) {
$mailList = preg_split('/;[ ]*/', $profile['inetOrgPerson_mail'][0]);
$this->attributes['mail'] = $mailList;
}
2011-12-11 13:36:34 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI') && isset($profile['inetOrgPerson_labeledURI'][0])) {
$labeledURIList = preg_split('/;[ ]*/', $profile['inetOrgPerson_labeledURI'][0]);
$this->attributes['labeledURI'] = $labeledURIList;
}
2011-05-07 08:05:25 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber') && isset($profile['inetOrgPerson_telephoneNumber'][0])) {
$telephoneNumberList = preg_split('/;[ ]*/', $profile['inetOrgPerson_telephoneNumber'][0]);
$this->attributes['telephoneNumber'] = $telephoneNumberList;
}
2011-05-07 08:05:25 +00:00
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber') && isset($profile['inetOrgPerson_facsimileTelephoneNumber'][0])) {
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', $profile['inetOrgPerson_facsimileTelephoneNumber'][0]);
$this->attributes['facsimileTelephoneNumber'] = $facsimileTelephoneNumberList;
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') && isset($profile['inetOrgPerson_street'][0])) {
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_street'][0]);
$this->attributes['street'] = $list;
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox') && isset($profile['inetOrgPerson_postOfficeBox'][0])) {
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_postOfficeBox'][0]);
$this->attributes['postOfficeBox'] = $list;
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') && isset($profile['inetOrgPerson_postalCode'][0])) {
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_postalCode'][0]);
$this->attributes['postalCode'] = $list;
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation') && isset($profile['inetOrgPerson_l'][0])) {
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_l'][0]);
$this->attributes['l'] = $list;
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') && isset($profile['inetOrgPerson_st'][0])) {
$list = preg_split('/;[ ]*/', $profile['inetOrgPerson_st'][0]);
$this->attributes['st'] = $list;
}
}
/**
2017-03-30 18:39:24 +00:00
* {@inheritDoc}
*/
2017-03-30 18:39:24 +00:00
function check_profileOptions($options, $typeId) {
$messages = parent::check_profileOptions($options, $typeId);
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$telephoneNumberList = preg_split('/;[ ]*/', $options['inetOrgPerson_telephoneNumber'][0]);
for ($i = 0; $i < sizeof($telephoneNumberList); $i++) {
if (!get_preg($telephoneNumberList[$i], 'telephone')) {
$messages[] = $this->messages['telephoneNumber'][0];
break;
}
}
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', $options['inetOrgPerson_facsimileTelephoneNumber'][0]);
for ($i = 0; $i < sizeof($facsimileTelephoneNumberList); $i++) {
if (!get_preg($facsimileTelephoneNumberList[$i], 'telephone')) {
2013-11-02 10:25:08 +00:00
$messages[] = $this->messages['facsimileTelephoneNumber'][0];
break;
}
}
}
return $messages;
}
2004-03-14 17:33:05 +00:00
/**
2017-05-01 18:02:44 +00:00
* {@inheritDoc}
* @see baseModule::getManagedAttributes()
*/
2017-05-20 08:55:26 +00:00
function get_uploadColumns($selectedModules, &$type) {
$return = parent::get_uploadColumns($selectedModules, $type);
// cn and uid for upload (only if posixAccount is not selected)
2017-04-23 18:46:58 +00:00
if (!$this->isUnixActive($selectedModules)) {
$return[] = array(
'name' => 'inetOrgPerson_cn',
'description' => _('Common name'),
'help' => 'cn',
'example' => _('Steve Miller'),
2010-12-05 13:29:53 +00:00
'default' => '{inetOrgPerson_firstName} {inetOrgPerson_lastName}'
);
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) {
$return[] = array(
'name' => 'inetOrgPerson_userName',
'description' => _('User name'),
'help' => 'uid',
'example' => _('smiller'),
'unique' => true,
'required' => false
);
}
$return[] = array(
'name' => 'inetOrgPerson_userPassword',
'description' => _('Password'),
'help' => 'userPassword',
'example' => _('secret'),
);
}
2020-01-19 17:12:03 +00:00
if (!$this->isSamba3Active() && !$this->isBooleanConfigOptionSet('inetOrgPerson_hidedisplayName', true)) {
$return[] = array(
'name' => 'inetOrgPerson_displayName',
'description' => _('Display name'),
'help' => 'displayName',
'example' => _('Steve Miller'),
);
}
return $return;
}
2004-10-11 18:06:53 +00:00
/**
2017-05-20 09:46:49 +00:00
* {@inheritDoc}
* @see baseModule::build_uploadAccounts()
*/
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) {
2006-05-20 16:32:02 +00:00
$errors = array();
2010-08-09 17:38:49 +00:00
// get list of existing users
2011-05-21 10:58:22 +00:00
$existingUsers = searchLDAPByAttribute('uid', '*', 'inetOrgPerson', array('uid'), array('user'));
2010-08-09 17:38:49 +00:00
for ($e = 0; $e < sizeof($existingUsers); $e++) {
$existingUsers[$e] = $existingUsers[$e]['uid'][0];
}
2018-05-22 17:55:49 +00:00
$existingMails = searchLDAPByAttribute('mail', '*', 'inetOrgPerson', array('mail'), array('user'));
for ($e = 0; $e < sizeof($existingMails); $e++) {
$existingMails[$e] = $existingMails[$e]['mail'][0];
}
2004-10-11 18:06:53 +00:00
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!in_array("inetOrgPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetOrgPerson";
// last name
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_lastName']], 'realname')) {
$partialAccounts[$i]['sn'] = trim($rawAccounts[$i][$ids['inetOrgPerson_lastName']]);
2004-10-11 18:06:53 +00:00
}
else {
$errMsg = $this->messages['lastname'][1];
2004-10-11 18:06:53 +00:00
array_push($errMsg, array($i));
2006-05-20 16:32:02 +00:00
$errors[] = $errMsg;
2004-10-11 18:06:53 +00:00
}
// first name
2005-06-07 18:19:48 +00:00
if ($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") {
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_firstName']], 'realname')) {
$partialAccounts[$i]['givenName'] = trim($rawAccounts[$i][$ids['inetOrgPerson_firstName']]);
2005-06-07 18:19:48 +00:00
}
else {
$errMsg = $this->messages['givenName'][1];
array_push($errMsg, array($i));
2006-05-20 16:32:02 +00:00
$errors[] = $errMsg;
2005-06-07 18:19:48 +00:00
}
2004-10-11 18:06:53 +00:00
}
2017-04-23 18:46:58 +00:00
if (!$this->isUnixActive($selectedModules)) {
// uid
if (isset($ids['inetOrgPerson_userName']) && !empty($rawAccounts[$i][$ids['inetOrgPerson_userName']])) {
if (in_array($rawAccounts[$i][$ids['inetOrgPerson_userName']], $existingUsers)) {
$errMsg = $this->messages['uid'][3];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
2018-08-12 07:41:36 +00:00
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_userName']], 'username')) {
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['inetOrgPerson_userName']];
}
else {
$errMsg = $this->messages['uid'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
}
// initials
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_initials']) && ($rawAccounts[$i][$ids['inetOrgPerson_initials']] != "")) {
$partialAccounts[$i]['initials'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_initials']]);
}
2020-01-19 17:12:03 +00:00
// display name
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_displayName', 'displayName');
2004-10-11 18:06:53 +00:00
// description
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_description', 'description');
2004-10-11 18:06:53 +00:00
// title
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_title', 'title', 'title', $this->messages['title'][1], $errors, '/;[ ]*/');
// employee number
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_employeeNumber', 'employeeNumber');
2004-10-11 18:06:53 +00:00
// employee type
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_type', 'employeeType',
'employeeType', $this->messages['employeeType'][1], $errors);
// business category
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_businessCategory', 'businessCategory', 'businessCategory', $this->messages['businessCategory'][1], $errors, '/;[ ]*/');
2005-07-02 12:05:33 +00:00
// manager
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_manager', 'manager', 'dn', $this->messages['manager'][0], $errors, '/;[ ]*/');
2004-10-11 18:06:53 +00:00
// street
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_street', 'street', 'street', $this->messages['street'][1], $errors, '/;[ ]*/');
2005-07-02 12:05:33 +00:00
// post office box
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_postOfficeBox']) && ($rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']] != "")) {
$partialAccounts[$i]['postOfficeBox'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']]);
2005-07-02 12:05:33 +00:00
}
// room number
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_roomNumber', 'roomNumber');
2009-02-15 12:54:37 +00:00
// departments
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_departmentNumber']) && ($rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']] != "")) {
2009-02-15 12:54:37 +00:00
$partialAccounts[$i]['departmentNumber'] = explode(';', $rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']]);
// remove extra spaces
$partialAccounts[$i]['departmentNumber'] = array_map('trim', $partialAccounts[$i]['departmentNumber']);
}
2012-10-14 08:32:26 +00:00
// organisational unit
if (isset($ids['inetOrgPerson_ou']) && ($rawAccounts[$i][$ids['inetOrgPerson_ou']] != "")) {
$partialAccounts[$i]['ou'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_ou']]);
}
// organisation
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_o']) && ($rawAccounts[$i][$ids['inetOrgPerson_o']] != "")) {
$partialAccounts[$i]['o'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_o']]);
}
// location
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_l']) && ($rawAccounts[$i][$ids['inetOrgPerson_l']] != "")) {
$partialAccounts[$i]['l'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_l']]);
}
// state
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_st']) && ($rawAccounts[$i][$ids['inetOrgPerson_st']] != "")) {
$partialAccounts[$i]['st'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_st']]);
}
// physicalDeliveryOfficeName
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_physicalDeliveryOfficeName']) && ($rawAccounts[$i][$ids['inetOrgPerson_physicalDeliveryOfficeName']] != "")) {
$partialAccounts[$i]['physicalDeliveryOfficeName'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_physicalDeliveryOfficeName']]);
}
// carLicense
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_carLicense', 'carLicense');
2004-10-11 18:06:53 +00:00
// postal code
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_postalCode', 'postalCode', 'postalCode', $this->messages['postalCode'][1], $errors, '/;[ ]*/');
2004-10-11 18:06:53 +00:00
// postal address
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_address', 'postalAddress',
'postalAddress',$this->messages['postalAddress'][1] , $errors);
2011-11-03 18:31:33 +00:00
// registered address
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_registeredAddress', 'registeredAddress',
'postalAddress',$this->messages['registeredAddress'][1] , $errors);
2004-10-11 18:06:53 +00:00
// telephone
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_telephone', 'telephoneNumber', 'telephone', $this->messages['telephoneNumber'][1], $errors, '/;[ ]*/');
// home telephone
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_homePhone', 'homePhone', 'telephone', $this->messages['homePhone'][1], $errors, '/;[ ]*/');
2004-10-11 18:06:53 +00:00
// mobile
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_mobile', 'mobile', 'telephone', $this->messages['mobileTelephone'][1], $errors, '/;[ ]*/');
2004-10-11 18:06:53 +00:00
// facsimile
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_fax', 'facsimileTelephoneNumber', 'telephone', $this->messages['facsimileNumber'][1], $errors, '/;[ ]*/');
2014-07-27 11:10:42 +00:00
// pager
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_pager', 'pager', 'telephone', $this->messages['pager'][1], $errors, '/;[ ]*/');
2004-10-11 18:06:53 +00:00
// eMail
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_email']) && ($rawAccounts[$i][$ids['inetOrgPerson_email']] != "")) {
$mailList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_email']]));
$partialAccounts[$i]['mail'] = $mailList;
for ($x = 0; $x < sizeof($mailList); $x++) {
if (!get_preg($mailList[$x], 'email')) {
$errMsg = $this->messages['email'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
break;
}
2018-05-22 17:55:49 +00:00
elseif (in_array($mailList[$x], $existingMails)) {
$errMsg = $this->messages['mail'][2];
array_push($errMsg, array($i, $mailList[$x]));
$errors[] = $errMsg;
}
2005-06-07 18:19:48 +00:00
}
2004-10-11 18:06:53 +00:00
}
2013-04-28 10:21:45 +00:00
if (isLAMProVersion() && isset($ids['inetOrgPerson_sendPasswordMail']) && ($rawAccounts[$i][$ids['inetOrgPerson_sendPasswordMail']] != "")) {
if (!in_array($rawAccounts[$i][$ids['inetOrgPerson_sendPasswordMail']], array('true', 'false'))) {
$errMsg = $this->messages['sendPasswordMail'][0];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
2011-12-11 13:36:34 +00:00
// labeledURI
2012-05-20 13:19:59 +00:00
if (isset($ids['inetOrgPerson_labeledURI']) && ($rawAccounts[$i][$ids['inetOrgPerson_labeledURI']] != "")) {
$partialAccounts[$i]['labeledURI'] = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_labeledURI']]));
2011-12-11 13:36:34 +00:00
}
2017-04-23 18:46:58 +00:00
if (!$this->isUnixActive($selectedModules)) {
// cn
if ($rawAccounts[$i][$ids['inetOrgPerson_cn']] != "") {
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_cn']], 'cn')) {
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['inetOrgPerson_cn']];
}
else {
$errMsg = $this->messages['cn'][1];
array_push($errMsg, array($i));
2006-05-20 16:32:02 +00:00
$errors[] = $errMsg;
}
2004-10-11 18:06:53 +00:00
}
else {
if ($partialAccounts[$i]['givenName'] != "") {
$partialAccounts[$i]['cn'] = $partialAccounts[$i]['givenName'] . " " . $partialAccounts[$i]['sn'];
}
else {
$partialAccounts[$i]['cn'] = $partialAccounts[$i]['sn'];
}
2004-10-11 18:06:53 +00:00
}
// password
2018-07-07 15:40:44 +00:00
// delay exop passwords
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) {
// changed in post action
}
2015-02-11 16:57:38 +00:00
// set SASL password
2018-07-07 15:40:44 +00:00
elseif (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL')) {
2015-02-11 16:57:38 +00:00
$partialAccounts[$i]['userPassword'] = '{SASL}' . $partialAccounts[$i]['uid'];
}
2016-01-02 12:16:14 +00:00
// set K5KEY password
elseif (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'K5KEY')) {
$partialAccounts[$i]['userPassword'] = pwd_hash('x', true, $this->moduleSettings['posixAccount_pwdHash'][0]);
}
2015-02-11 16:57:38 +00:00
// set normal password
else {
if (($rawAccounts[$i][$ids['inetOrgPerson_userPassword']] != "") && (get_preg($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], 'password'))) {
$partialAccounts[$i]['userPassword'] = pwd_hash($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], true, $this->moduleSettings['posixAccount_pwdHash'][0]);
$partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccounts[$i][$ids['inetOrgPerson_userPassword']]; // for custom scripts etc.
}
elseif ($rawAccounts[$i][$ids['inetOrgPerson_userPassword']] != "") {
$errMsg = $this->messages['userPassword'][0];
$errMsg[2] = str_replace('%', '%%', $errMsg[2]); // double "%" because of later sprintf
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
2005-06-06 19:24:48 +00:00
}
2004-10-11 18:06:53 +00:00
}
2006-05-20 16:32:02 +00:00
return $errors;
2004-10-11 18:06:53 +00:00
}
2013-04-28 10:21:45 +00:00
/**
2017-05-10 17:23:28 +00:00
* {@inheritDoc}
* @see baseModule::doUploadPostActions()
*/
2017-09-02 11:03:36 +00:00
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts, $selectedModules, $type) {
if (!checkIfWriteAccessIsAllowed($this->get_scope())) {
2013-04-28 10:21:45 +00:00
die();
}
if (!isset($temp['counter'])) {
$temp['counter'] = 0;
}
$errors = array();
2015-05-23 12:10:55 +00:00
$dataSize = sizeof($data);
if (($temp['counter'] < $dataSize) && !in_array($temp['counter'], $failed)) {
// mail sending is LAM Pro only
if (isLAMProVersion()
&& isset($ids['inetOrgPerson_email'])
&& ($data[$temp['counter']][$ids['inetOrgPerson_email']] != "")) {
if (isset($ids['inetOrgPerson_sendPasswordMail']) && ($data[$temp['counter']][$ids['inetOrgPerson_sendPasswordMail']] == "true")
&& isset($accounts[$temp['counter']]['INFO.userPasswordClearText'])) {
$mailMessages = sendPasswordMail($accounts[$temp['counter']]['INFO.userPasswordClearText'], $accounts[$temp['counter']]);
for ($i = 0; $i < sizeof($mailMessages); $i++) {
if ($mailMessages[$i][0] == 'ERROR') {
$errors[] = $mailMessages[$i];
}
2013-04-28 10:21:45 +00:00
}
}
}
2015-05-23 12:10:55 +00:00
// add addressbook entry
if ($this->isBooleanConfigOptionSet('inetOrgPerson_addAddressbook')) {
$attrs = array(
'objectClass' => array('organizationalUnit'),
'ou' => 'addressbook'
);
$dn = 'ou=addressbook,' . $accounts[$temp['counter']]['dn'];
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs);
if (!$success) {
logNewMessage(LOG_ERR, 'Unable to add addressbook for user ' . $accounts[$temp['counter']]['dn'] . ' (' . ldap_error($_SESSION['ldap']->server()) . ').');
$messages[] = array('ERROR', sprintf(_("Was unable to create DN: %s."), htmlspecialchars($dn)), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
}
else {
logNewMessage(LOG_NOTICE, 'Added addressbook for user ' . $accounts[$temp['counter']]['dn']);
}
}
2018-07-07 15:40:44 +00:00
// set password via exop
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) {
if (isset($ids['inetOrgPerson_userPassword']) && !empty($data[$temp['counter']][$ids['inetOrgPerson_userPassword']])) {
$dn = $accounts[$temp['counter']]['dn'];
$password = $data[$temp['counter']][$ids['inetOrgPerson_userPassword']];
$success = ldap_exop_passwd($_SESSION['ldap']->server(), $dn, null, $password);
if (!$success) {
$errors[] = array(
"ERROR",
_('Unable to set password'),
$dn . '<br>' . getDefaultLDAPErrorString($_SESSION['ldap']->server()),
array($temp['groups'][$temp['counter']])
);
}
}
}
2013-04-28 10:21:45 +00:00
}
$temp['counter']++;
2015-05-23 12:10:55 +00:00
if ($temp['counter'] < $dataSize) {
2013-04-28 10:21:45 +00:00
return array (
'status' => 'inProgress',
2014-09-21 18:09:44 +00:00
'progress' => ($temp['counter'] * 100) / $dataSize,
2013-04-28 10:21:45 +00:00
'errors' => $errors
);
}
else {
return array (
'status' => 'finished',
'progress' => 100,
'errors' => $errors
);
}
}
/**
* Returns a list of self service configuration settings.
*
* @param selfServiceProfile $profile currently edited profile
* @return htmlElement meta HTML object
*/
public function getSelfServiceSettings($profile) {
2017-12-17 10:44:49 +00:00
$container = new htmlResponsiveRow();
$container->add(new htmlSubTitle(_('Photo')), 12);
2018-05-12 07:39:29 +00:00
$container->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, array('crop', get_class($this))), 12);
$container->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, array('crop', get_class($this))), 12);
2017-12-17 10:44:49 +00:00
$container->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), 12);
return $container;
}
/**
* Checks if the self service settings are valid.
*
* If the input data is invalid the return value is an array that contains arrays
* to build StatusMessages (message type, message head, message text). If no errors
2020-03-04 11:07:56 +00:00
* occurred the function returns an empty array.
*
* @param array $options hash array (option name => value) that contains the input. The option values are all arrays containing one or more elements.
* @param selfServiceProfile $profile self service profile
* @return array error messages
*/
public function checkSelfServiceSettings(&$options, &$profile) {
$errors = array();
if (!empty($options['inetOrgPerson_jpegPhoto_maxWidth'][0]) && !is_numeric($options['inetOrgPerson_jpegPhoto_maxWidth'][0])) {
$errors[] = array('ERROR', _('Please enter a number.'), _('Maximum width (px)'));
}
if (!empty($options['inetOrgPerson_jpegPhoto_maxHeight'][0]) && !is_numeric($options['inetOrgPerson_jpegPhoto_maxHeight'][0])) {
$errors[] = array('ERROR', _('Please enter a number.'), _('Maximum height (px)'));
}
if (!empty($options['inetOrgPerson_jpegPhoto_maxSize'][0]) && !is_numeric($options['inetOrgPerson_jpegPhoto_maxSize'][0])) {
$errors[] = array('ERROR', _('Please enter a number.'), _('Maximum file size (kB)'));
}
return $errors;
}
2006-07-23 15:06:49 +00:00
/**
* Returns the meta HTML code for each input field.
* format: array(<field1> => array(<META HTML>), ...)
* It is not possible to display help links.
*
* @param array $fields list of active fields
2011-08-20 17:59:36 +00:00
* @param array $attributes attributes of LDAP account
* @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
2012-08-18 15:55:43 +00:00
* @param array $readOnlyFields list of read-only fields
2015-08-09 09:00:38 +00:00
* @return array list of meta HTML elements (field name => htmlResponsiveRow)
2006-07-23 15:06:49 +00:00
*/
2012-08-18 15:55:43 +00:00
function getSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {
2006-07-23 15:06:49 +00:00
$return = array();
if ($passwordChangeOnly) {
return $return; // no fields as long no LDAP content can be read
}
2006-07-23 15:06:49 +00:00
if (in_array('firstName', $fields)) {
$firstName = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['givenName'][0])) {
$firstName = $attributes['givenName'][0];
}
2012-08-18 15:55:43 +00:00
$firstNameField = new htmlInputField('inetOrgPerson_firstName', $firstName);
if (in_array('firstName', $readOnlyFields)) {
$firstNameField = new htmlOutputText($firstName);
}
2015-08-09 09:00:38 +00:00
$return['firstName'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('firstName', _('First name'))), $firstNameField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('lastName', $fields)) {
$lastName = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['sn'][0])) {
$lastName = $attributes['sn'][0];
}
2012-08-18 15:55:43 +00:00
$lastNameField = new htmlInputField('inetOrgPerson_lastName', $lastName);
if (in_array('lastName', $readOnlyFields)) {
$lastNameField = new htmlOutputText($lastName);
}
2015-08-09 09:00:38 +00:00
$return['lastName'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('lastName', _('Last name'))), $lastNameField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('mail', $fields)) {
$mail = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['mail'][0])) {
$mail = $attributes['mail'][0];
}
2012-08-18 15:55:43 +00:00
$mailField = new htmlInputField('inetOrgPerson_mail', $mail);
if (in_array('mail', $readOnlyFields)) {
$mailField = new htmlOutputText($mail);
}
2015-08-09 09:00:38 +00:00
$return['mail'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('mail', _('Email address'))), $mailField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
2011-12-11 13:36:34 +00:00
if (in_array('labeledURI', $fields)) {
$labeledURI = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['labeledURI'][0])) {
$labeledURI = implode('; ', $attributes['labeledURI']);
}
2012-08-18 15:55:43 +00:00
$labeledURIField = new htmlInputField('inetOrgPerson_labeledURI', $labeledURI);
if (in_array('labeledURI', $readOnlyFields)) {
$labeledURIField = new htmlOutputText($labeledURI);
}
2015-08-09 09:00:38 +00:00
$return['labeledURI'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('labeledURI', _('Web site'))), $labeledURIField
2015-08-09 09:00:38 +00:00
);
2011-12-11 13:36:34 +00:00
}
2006-07-23 15:06:49 +00:00
if (in_array('telephoneNumber', $fields)) {
$telephoneNumber = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['telephoneNumber'][0])) {
$telephoneNumber = $attributes['telephoneNumber'][0];
}
2012-08-18 15:55:43 +00:00
$telephoneNumberField = new htmlInputField('inetOrgPerson_telephoneNumber', $telephoneNumber);
if (in_array('telephoneNumber', $readOnlyFields)) {
$telephoneNumberField = new htmlOutputText($telephoneNumber);
}
2015-08-09 09:00:38 +00:00
$return['telephoneNumber'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('telephoneNumber', _('Telephone number'))), $telephoneNumberField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('homePhone', $fields)) {
$homePhone = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['homePhone'][0])) {
$homePhone = $attributes['homePhone'][0];
}
2012-08-18 15:55:43 +00:00
$homePhoneField = new htmlInputField('inetOrgPerson_homePhone', $homePhone);
if (in_array('homePhone', $readOnlyFields)) {
$homePhoneField = new htmlOutputText($homePhone);
}
2015-08-09 09:00:38 +00:00
$return['homePhone'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('homePhone', _('Home telephone number'))), $homePhoneField
2015-08-09 09:00:38 +00:00
);
}
2006-07-23 15:06:49 +00:00
if (in_array('mobile', $fields)) {
$mobile = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['mobile'][0])) {
$mobile = $attributes['mobile'][0];
}
2012-08-18 15:55:43 +00:00
$mobileField = new htmlInputField('inetOrgPerson_mobile', $mobile);
if (in_array('mobile', $readOnlyFields)) {
$mobileField = new htmlOutputText($mobile);
}
2015-08-09 09:00:38 +00:00
$return['mobile'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('mobile', _('Mobile telephone number'))), $mobileField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('faxNumber', $fields)) {
$faxNumber = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['facsimileTelephoneNumber'][0])) {
$faxNumber = $attributes['facsimileTelephoneNumber'][0];
}
2012-08-18 15:55:43 +00:00
$faxNumberField = new htmlInputField('inetOrgPerson_faxNumber', $faxNumber);
if (in_array('faxNumber', $readOnlyFields)) {
$faxNumberField = new htmlOutputText($faxNumber);
}
2015-08-09 09:00:38 +00:00
$return['faxNumber'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('faxNumber', _('Fax number'))), $faxNumberField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
2014-07-27 11:10:42 +00:00
if (in_array('pager', $fields)) {
$pager = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['pager'][0])) {
$pager = $attributes['pager'][0];
}
2014-07-27 11:10:42 +00:00
$pagerField = new htmlInputField('inetOrgPerson_pager', $pager);
if (in_array('pager', $readOnlyFields)) {
$pagerField = new htmlOutputText($pager);
}
2015-08-09 09:00:38 +00:00
$return['pager'] = new htmlResponsiveRow(
2014-07-27 11:10:42 +00:00
new htmlOutputText($this->getSelfServiceLabel('pager', _('Pager'))), $pagerField
2015-08-09 09:00:38 +00:00
);
2014-07-27 11:10:42 +00:00
}
2006-07-23 15:06:49 +00:00
if (in_array('street', $fields)) {
$street = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['street'][0])) {
$street = $attributes['street'][0];
}
2012-08-18 15:55:43 +00:00
$streetField = new htmlInputField('inetOrgPerson_street', $street);
if (in_array('street', $readOnlyFields)) {
$streetField = new htmlOutputText($street);
}
2015-08-09 09:00:38 +00:00
$return['street'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('street', _('Street'))), $streetField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('postalAddress', $fields)) {
$postalAddress = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['postalAddress'][0])) {
$postalAddress = $attributes['postalAddress'][0];
}
2012-08-18 15:55:43 +00:00
$postalAddressField = new htmlInputField('inetOrgPerson_postalAddress', $postalAddress);
if (in_array('postalAddress', $readOnlyFields)) {
$postalAddressField = new htmlOutputText($postalAddress);
}
2015-08-09 09:00:38 +00:00
$return['postalAddress'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('postalAddress', _('Postal address'))), $postalAddressField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
2011-11-03 18:31:33 +00:00
if (in_array('registeredAddress', $fields)) {
$registeredAddress = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['registeredAddress'][0])) {
$registeredAddress = $attributes['registeredAddress'][0];
}
2012-08-18 15:55:43 +00:00
$registeredAddressField = new htmlInputField('inetOrgPerson_registeredAddress', $registeredAddress);
if (in_array('registeredAddress', $readOnlyFields)) {
$registeredAddressField = new htmlOutputText($registeredAddress);
}
2015-08-09 09:00:38 +00:00
$return['registeredAddress'] = new htmlResponsiveRow(
2012-08-18 15:55:43 +00:00
new htmlOutputText(_('Registered address')), $registeredAddressField
2015-08-09 09:00:38 +00:00
);
2011-11-03 18:31:33 +00:00
}
2006-07-23 15:06:49 +00:00
if (in_array('postalCode', $fields)) {
$postalCode = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['postalCode'][0])) {
$postalCode = $attributes['postalCode'][0];
}
2012-08-18 15:55:43 +00:00
$postalCodeField = new htmlInputField('inetOrgPerson_postalCode', $postalCode);
if (in_array('postalCode', $readOnlyFields)) {
$postalCodeField = new htmlOutputText($postalCode);
}
2015-08-09 09:00:38 +00:00
$return['postalCode'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('postalCode', _('Postal code'))), $postalCodeField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('postOfficeBox', $fields)) {
$postOfficeBox = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['postOfficeBox'][0])) {
$postOfficeBox = $attributes['postOfficeBox'][0];
}
2012-08-18 15:55:43 +00:00
$postOfficeBoxField = new htmlInputField('inetOrgPerson_postOfficeBox', $postOfficeBox);
if (in_array('postOfficeBox', $readOnlyFields)) {
$postOfficeBoxField = new htmlOutputText($postOfficeBox);
}
2015-08-09 09:00:38 +00:00
$return['postOfficeBox'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('postOfficeBox', _('Post office box'))), $postOfficeBoxField
2015-08-09 09:00:38 +00:00
);
2006-07-23 15:06:49 +00:00
}
if (in_array('roomNumber', $fields)) {
$roomNumber = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['roomNumber'][0])) {
$roomNumber = $attributes['roomNumber'][0];
}
2012-08-18 15:55:43 +00:00
$roomNumberField = new htmlInputField('inetOrgPerson_roomNumber', $roomNumber);
if (in_array('roomNumber', $readOnlyFields)) {
$roomNumberField = new htmlOutputText($roomNumber);
}
2015-08-09 09:00:38 +00:00
$return['roomNumber'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('roomNumber', _('Room number'))), $roomNumberField
2015-08-09 09:00:38 +00:00
);
}
if (in_array('location', $fields)) {
$l = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['l'][0])) {
$l = $attributes['l'][0];
}
2012-08-18 15:55:43 +00:00
$lField = new htmlInputField('inetOrgPerson_location', $l);
if (in_array('location', $readOnlyFields)) {
$lField = new htmlOutputText($l);
}
2015-08-09 09:00:38 +00:00
$return['location'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('location', _('Location'))), $lField
2015-08-09 09:00:38 +00:00
);
}
if (in_array('state', $fields)) {
$st = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['st'][0])) {
$st = $attributes['st'][0];
}
2012-08-18 15:55:43 +00:00
$stField = new htmlInputField('inetOrgPerson_state', $st);
if (in_array('state', $readOnlyFields)) {
$stField = new htmlOutputText($st);
}
2015-08-09 09:00:38 +00:00
$return['state'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('state', _('State'))), $stField
2015-08-09 09:00:38 +00:00
);
}
if (in_array('carLicense', $fields)) {
$carLicense = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['carLicense'][0])) {
$carLicense = $attributes['carLicense'][0];
}
2012-08-18 15:55:43 +00:00
$carLicenseField = new htmlInputField('inetOrgPerson_carLicense', $carLicense);
if (in_array('carLicense', $readOnlyFields)) {
$carLicenseField = new htmlOutputText($carLicense);
}
2015-08-09 09:00:38 +00:00
$return['carLicense'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('carLicense', _('Car license'))), $carLicenseField
2015-08-09 09:00:38 +00:00
);
}
if (in_array('officeName', $fields)) {
$physicalDeliveryOfficeName = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['physicalDeliveryOfficeName'][0])) {
$physicalDeliveryOfficeName = $attributes['physicalDeliveryOfficeName'][0];
}
2012-08-18 15:55:43 +00:00
$physicalDeliveryOfficeNameField = new htmlInputField('inetOrgPerson_officeName', $physicalDeliveryOfficeName);
if (in_array('officeName', $readOnlyFields)) {
$physicalDeliveryOfficeNameField = new htmlOutputText($physicalDeliveryOfficeName);
}
2015-08-09 09:00:38 +00:00
$return['officeName'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('officeName', _('Office name'))), $physicalDeliveryOfficeNameField
2015-08-09 09:00:38 +00:00
);
}
2009-02-08 18:15:21 +00:00
if (in_array('businessCategory', $fields)) {
$businessCategory = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['businessCategory'][0])) {
$businessCategory = $attributes['businessCategory'][0];
}
2012-08-18 15:55:43 +00:00
$businessCategoryField = new htmlInputField('inetOrgPerson_businessCategory', $businessCategory);
if (in_array('businessCategory', $readOnlyFields)) {
$businessCategoryField = new htmlOutputText($businessCategory);
}
2015-08-09 09:00:38 +00:00
$return['businessCategory'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('businessCategory', _('Business category'))), $businessCategoryField
2015-08-09 09:00:38 +00:00
);
2009-02-08 18:15:21 +00:00
}
2007-02-18 18:37:15 +00:00
if (in_array('jpegPhoto', $fields)) {
2018-05-16 16:00:54 +00:00
$_SESSION[self::SESS_PHOTO] = null;
2007-02-18 18:37:15 +00:00
if (isset($attributes['jpegPhoto'][0])) {
2018-05-16 16:00:54 +00:00
$_SESSION[self::SESS_PHOTO] = $attributes['jpegPhoto'][0];
}
$readOnlyPhoto = in_array('jpegPhoto', $readOnlyFields);
if (!empty($attributes['jpegPhoto'][0]) || !$readOnlyPhoto) {
$photoSub = new htmlDiv('inetOrgPersonPhotoUploadContent', $this->getSelfServicePhoto($readOnlyPhoto, false));
$photoRow = new htmlResponsiveRow();
$photoRow->add($this->getSelfServicePhotoJS($readOnlyPhoto), 0);
$photoRow->addLabel(new htmlOutputText($this->getSelfServiceLabel('jpegPhoto', _('Photo'))));
$photoRow->addField(new htmlDiv('jpegPhotoDiv', $photoSub));
$return['jpegPhoto'] = $photoRow;
2007-02-18 18:37:15 +00:00
}
}
2009-02-15 12:54:37 +00:00
if (in_array('departmentNumber', $fields)) {
$departmentNumber = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['departmentNumber'][0])) {
$departmentNumber = implode('; ', $attributes['departmentNumber']);
}
2012-08-18 15:55:43 +00:00
$departmentNumberField = new htmlInputField('inetOrgPerson_departmentNumber', $departmentNumber);
if (in_array('departmentNumber', $readOnlyFields)) {
$departmentNumberField = new htmlOutputText($departmentNumber);
}
2015-08-09 09:00:38 +00:00
$return['departmentNumber'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('departmentNumber', _('Department'))), $departmentNumberField
2015-08-09 09:00:38 +00:00
);
2009-02-15 12:54:37 +00:00
}
if (in_array('initials', $fields)) {
$initials = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['initials'][0])) {
$initials = implode('; ', $attributes['initials']);
}
2012-08-18 15:55:43 +00:00
$initialsField = new htmlInputField('inetOrgPerson_initials', $initials);
if (in_array('initials', $readOnlyFields)) {
$initialsField = new htmlOutputText($initials);
}
2015-08-09 09:00:38 +00:00
$return['initials'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('initials', _('Initials'))), $initialsField
2015-08-09 09:00:38 +00:00
);
}
2011-05-22 14:22:00 +00:00
if (in_array('title', $fields)) {
$title = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['title'][0])) {
$title = $attributes['title'][0];
}
2012-08-18 15:55:43 +00:00
$titleField = new htmlInputField('inetOrgPerson_title', $title);
if (in_array('title', $readOnlyFields)) {
$titleField = new htmlOutputText($title);
}
2015-08-09 09:00:38 +00:00
$return['title'] = new htmlResponsiveRow(
2013-11-30 15:02:06 +00:00
new htmlOutputText($this->getSelfServiceLabel('title', _('Job title'))), $titleField
2015-08-09 09:00:38 +00:00
);
2011-05-22 14:22:00 +00:00
}
if (in_array('userCertificate', $fields)) {
$userCertificates = array();
if (isset($attributes['userCertificate'][0])) {
$userCertificates = $attributes['userCertificate'];
}
elseif (isset($attributes['userCertificate;binary'][0])) {
$userCertificates = $attributes['userCertificate;binary'];
}
$_SESSION[self::SESS_CERTIFICATES_LIST] = $userCertificates;
2015-08-09 13:18:04 +00:00
$certTable = new htmlResponsiveRow();
$certTable->add(new htmlDiv('userCertificateDiv', $this->getSelfServiceUserCertificates()), 12);
// JavaScript functions
2015-08-09 13:18:04 +00:00
$certTable->add($this->getSelfServiceUserCertificatesJSBlock(), 12);
// upload button
$uploadButtons = new htmlGroup();
$uploadButtons->addElement(new htmlDiv('inetOrgPersonCertUploadId', new htmlOutputText('')), true);
$certUpload = new htmlJavaScript('inetOrgPersonUploadCert(\'inetOrgPersonCertUploadId\');');
$uploadButtons->addElement($certUpload);
2015-08-09 13:18:04 +00:00
$certTable->add($uploadButtons, 12);
// upload status
$uploadStatus = new htmlDiv('inetOrgPerson_upload_status_cert', new htmlOutputText(''));
$uploadStatus->setCSSClasses(array('qq-upload-list'));
2015-08-09 13:18:04 +00:00
$certTable->add($uploadStatus, 12);
2013-11-30 15:02:06 +00:00
$certLabel = new htmlOutputText($this->getSelfServiceLabel('userCertificate', _('User certificates')));
2015-08-09 09:00:38 +00:00
$return['userCertificate'] = new htmlResponsiveRow($certLabel, $certTable);
}
2017-05-13 09:10:38 +00:00
// o
if (in_array('o', $fields)) {
$o = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['o'][0])) {
$o = $attributes['o'][0];
}
2017-05-13 09:10:38 +00:00
if (in_array('o', $readOnlyFields)) {
$oField = new htmlOutputText(getAbstractDN($o));
}
else {
$filter = '(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer)(objectClass=container))';
$suffix = $_SESSION['selfServiceProfile']->LDAPSuffix;
$foundOs = searchLDAPPaged($_SESSION['ldapHandle'], $suffix, $filter, array('dn'), false, 0);
$oList = array();
foreach ($foundOs as $foundO) {
$oList[] = $foundO['dn'];
}
if (!empty($attributes['o'][0]) && !in_array($attributes['o'][0], $oList)) {
$oList[] = $attributes['o'][0];
usort($oList, 'compareDN');
}
$oSelectionList = array('' => '');
foreach ($oList as $singleOU) {
$oSelectionList[getAbstractDN($singleOU)] = $singleOU;
}
$oSelectionListSelected = array();
if (!empty($attributes['o'][0])) {
$oSelectionListSelected[] = $attributes['o'][0];
}
$oField = new htmlSelect('inetOrgPerson_o', $oSelectionList, $oSelectionListSelected);
$oField->setHasDescriptiveElements(true);
$oField->setRightToLeftTextDirection(true);
$oField->setSortElements(false);
}
$return['o'] = new htmlResponsiveRow(
new htmlOutputText($this->getSelfServiceLabel('o', _('Organisation'))), $oField
);
}
// ou
if (in_array('ou', $fields)) {
$ou = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['ou'][0])) {
$ou = $attributes['ou'][0];
}
if (in_array('ou', $readOnlyFields)) {
$ouField = new htmlOutputText(getAbstractDN($ou));
}
else {
2017-05-13 09:10:38 +00:00
$filter = '(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer)(objectClass=container))';
$suffix = $_SESSION['selfServiceProfile']->LDAPSuffix;
$foundOus = searchLDAPPaged($_SESSION['ldapHandle'], $suffix, $filter, array('dn'), false, 0);
$ouList = array();
foreach ($foundOus as $foundOu) {
$ouList[] = $foundOu['dn'];
}
if (!empty($attributes['ou'][0]) && !in_array($attributes['ou'][0], $ouList)) {
$ouList[] = $attributes['ou'][0];
usort($ouList, 'compareDN');
}
$ouSelectionList = array('' => '');
foreach ($ouList as $singleOU) {
$ouSelectionList[getAbstractDN($singleOU)] = $singleOU;
}
$ouSelectionListSelected = array();
if (!empty($attributes['ou'][0])) {
$ouSelectionListSelected[] = $attributes['ou'][0];
}
$ouField = new htmlSelect('inetOrgPerson_ou', $ouSelectionList, $ouSelectionListSelected);
$ouField->setHasDescriptiveElements(true);
$ouField->setRightToLeftTextDirection(true);
$ouField->setSortElements(false);
}
2015-08-09 09:00:38 +00:00
$return['ou'] = new htmlResponsiveRow(
new htmlOutputText($this->getSelfServiceLabel('ou', _('Organisational unit'))), $ouField
2015-08-09 09:00:38 +00:00
);
}
// description
if (in_array('description', $fields)) {
$description = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['description'][0])) {
$description = $attributes['description'][0];
}
$descriptionField = new htmlInputField('inetOrgPerson_description', $description);
if (in_array('description', $readOnlyFields)) {
$descriptionField = new htmlOutputText($description);
}
2015-08-09 09:00:38 +00:00
$return['description'] = new htmlResponsiveRow(
new htmlOutputText($this->getSelfServiceLabel('description', _('Description'))), $descriptionField
2015-08-09 09:00:38 +00:00
);
}
// uid
if (in_array('uid', $fields)) {
$uid = '';
2020-01-19 17:12:03 +00:00
if (isset($attributes['uid'][0])) {
$uid = $attributes['uid'][0];
}
$uidField = new htmlInputField('inetOrgPerson_uid', $uid);
if (in_array('uid', $readOnlyFields)) {
$uidField = new htmlOutputText($uid);
}
2015-08-09 09:00:38 +00:00
$return['uid'] = new htmlResponsiveRow(
new htmlOutputText($this->getSelfServiceLabel('uid', _('User name'))), $uidField
2015-08-09 09:00:38 +00:00
);
}
2020-01-19 17:12:03 +00:00
if (in_array('displayName', $fields)) {
$displayName = '';
if (isset($attributes['displayName'][0])) {
$displayName = $attributes['displayName'][0];
}
$displayNameField = new htmlInputField('inetOrgPerson_displayName', $displayName);
if (in_array('displayName', $readOnlyFields)) {
$displayNameField = new htmlOutputText($displayName);
}
$return['displayName'] = new htmlResponsiveRow(
new htmlOutputText($this->getSelfServiceLabel('displayName', _('Display name'))), $displayNameField
);
}
2006-07-23 15:06:49 +00:00
return $return;
}
2018-05-16 16:00:54 +00:00
/**
* Renders the photo area for self service.
*
* @param boolean $readOnly content is read-only
* @param boolean $crop enable cropping
* @return htmlResponsiveRow content
*/
private function getSelfServicePhoto($readOnly, $crop) {
$photo = $_SESSION[self::SESS_PHOTO];
$row = new htmlResponsiveRow();
if (!empty($photo)) {
$jpeg_filename = 'jpegPhoto' . getRandomNumber() . '.jpg';
$outjpeg = fopen(realpath('../../') . '/tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $photo);
fclose ($outjpeg);
$photoFile = '../../tmp/' . $jpeg_filename;
$img = new htmlImage($photoFile);
$img->setCSSClasses(array('photo'));
if ($crop) {
$img->enableCropping();
}
$row->add($img, 12);
if (!$readOnly) {
$row->addVerticalSpacer('0.5rem');
$deleteButton = new htmlLink(_('Delete'), '#', '../../graphics/delete.png', true);
$deleteButton->setOnClick('inetOrgPersonDeletePhoto(); return false;');
$row->add($deleteButton, 12);
}
$row->addVerticalSpacer('0.5rem');
}
// upload button
$row->add(new htmlDiv('inetOrgPersonPhotoUploadId', new htmlOutputText('')), 12);
$row->add(new htmlJavaScript('inetOrgPersonUploadPhoto(\'inetOrgPersonPhotoUploadId\');'), 0);
$uploadStatus = new htmlDiv('inetOrgPersonPhotoUploadStatus', new htmlOutputText(''));
$uploadStatus->setCSSClasses(array('qq-upload-list'));
$row->add($uploadStatus, 12);
2020-07-24 08:06:22 +00:00
// webcam button
$webcamContent = new htmlResponsiveRow();
$webcamContent->addVerticalSpacer('0.5rem');
$errorMessage = new htmlStatusMessage('ERROR', '');
$errorMessage->setCSSClasses(array('hidden', 'lam-webcam-message'));
$webcamContent->add($errorMessage, 12);
$webcamContent->addVerticalSpacer('0.5rem');
$captureButton = new htmlLink(_('Use webcam'), '#', '../../graphics/webcam.png', true);
$captureButton->setId('btn_lam-webcam-capture');
$captureButton->setOnClick('window.lam.tools.webcam.capture(event);');
$webcamContent->add($captureButton, 12, 12, 12);
$video = new htmlVideo('lam-webcam-video');
$video->setCSSClasses(array('hidden'));
$webcamContent->add($video, 12, 12, 12, 'text-center');
$webcamContent->addVerticalSpacer('1rem');
$webcamUploadButton = new htmlLink(_('Upload'), '#', '../../graphics/up.gif', true);
$webcamUploadButton->setId('btn-lam-webcam-upload');
$webcamUploadButton->setCSSClasses(array('btn-lam-webcam-upload', 'hidden'));
$webcamUploadButton->setOnClick('window.lam.tools.webcam.uploadSelfService(event, "' . getSecurityTokenName()
. '", "' . getSecurityTokenValue() . '", "inetOrgPerson", "user", "' . _('File upload failed!') . '", "inetOrgPersonPhotoUploadContent");');
$webcamContent->add($webcamUploadButton, 12, 12, 12);
$canvas = new htmlCanvas('lam-webcam-canvas');
$canvas->setCSSClasses(array('hidden'));
$webcamContent->add($canvas, 12);
$webcamDiv = new htmlDiv('lam_webcam_div', $webcamContent, array('hidden'));
$webcamContent->addVerticalSpacer('1rem');
$row->add($webcamDiv, 12);
2018-05-16 16:00:54 +00:00
return $row;
}
/**
* Returns the Java Script functions to manage the photo.
*
* @param boolean $readOnly content is read-only
* @return htmlJavaScript JS block
*/
private static function getSelfServicePhotoJS($readOnly) {
if ($readOnly) {
return new htmlGroup();
}
$content = '
function inetOrgPersonUploadPhoto(elementID) {
var uploadStatus = document.getElementById(\'inetOrgPersonPhotoUploadStatus\');
var params = { action: \'ajaxPhotoUpload\' };
params["' . getSecurityTokenName() . '"] = "' . getSecurityTokenValue() . '";
var uploader = new qq.FineUploader({
element: document.getElementById(elementID),
listElement: uploadStatus,
request: {
endpoint: \'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user'
. '&' . getSecurityTokenName() . '=' . getSecurityTokenValue() . '\',
forceMultipart: true,
params: params
},
multiple: false,
callbacks: {
onComplete: function(id, fileName, data) {
if (data.success) {
if (data.html) {
jQuery(\'#inetOrgPersonPhotoUploadContent\').html(data.html);
2020-07-24 08:06:22 +00:00
window.lam.tools.webcam.init();
2018-05-16 16:00:54 +00:00
}
}
else {
alert(data.error);
}
}
}
});
}
function inetOrgPersonDeletePhoto(id) {
var actionJSON = {
"action": "deletePhoto",
"id": id
};
var data = {jsonInput: actionJSON};
data["' . getSecurityTokenName() . '"] = "' . getSecurityTokenValue() . '";
jQuery.post(\'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user\',
data, function(data) {inetOrgPersonDeletePhotoHandleReply(data);}, \'json\');
}
function inetOrgPersonDeletePhotoHandleReply(data) {
if (data.errorsOccured == "false") {
jQuery(\'#inetOrgPersonPhotoUploadContent\').html(data.html);
2020-07-24 08:06:22 +00:00
window.lam.tools.webcam.init();
2018-05-16 16:00:54 +00:00
}
else {
alert(data.errormessage);
}
}
';
return new htmlJavaScript($content);
}
/**
* Returns the meta HTML code to display the certificate area.
* This also includes the file upload.
*
* @return htmlTable certificate content
*/
private function getSelfServiceUserCertificates() {
$userCertificates = $_SESSION[self::SESS_CERTIFICATES_LIST];
2015-08-09 13:18:04 +00:00
$content = new htmlGroup();
if (sizeof($userCertificates) > 0) {
2015-08-09 13:18:04 +00:00
$certTable = new htmlResponsiveRow();
for ($i = 0; $i < sizeof($userCertificates); $i++) {
2015-08-09 13:18:04 +00:00
$group = new htmlGroup();
2013-07-21 11:34:31 +00:00
$filename = 'userCertificate' . getRandomNumber() . '.der';
$out = @fopen(dirname(__FILE__) . '/../../tmp/' . $filename, "wb");
fwrite($out, $userCertificates[$i]);
fclose ($out);
$path = '../../tmp/' . $filename;
if (function_exists('openssl_x509_parse')) {
$pem = @chunk_split(@base64_encode($userCertificates[$i]), 64, "\n");
if (!empty($pem)) {
$pem = "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n";
$pemData = @openssl_x509_parse($pem);
$data = array();
if (isset($pemData['serialNumber'])) {
$data[] = $pemData['serialNumber'];
}
if (isset($pemData['name'])) {
$data[] = $pemData['name'];
}
if (sizeof($data) > 0) {
2015-08-09 13:18:04 +00:00
$group->addElement(new htmlOutputText(implode(': ', $data)));
$group->addElement(new htmlSpacer('5px', null));
}
}
}
2015-08-09 09:00:38 +00:00
$saveLink = new htmlLink('', $path, '../../graphics/save.png');
$saveLink->setTitle(_('Save'));
$saveLink->setTargetWindow('_blank');
2015-08-09 13:18:04 +00:00
$group->addElement($saveLink);
2015-08-09 09:00:38 +00:00
$delLink = new htmlLink('', '#', '../../graphics/del.png');
$delLink->setTitle(_('Delete'));
$delLink->setOnClick('inetOrgPersonDeleteCertificate(' . $i . '); return false;');
2015-08-09 13:18:04 +00:00
$group->addElement($delLink);
$certTable->add($group, 12);
}
2015-08-09 13:18:04 +00:00
$content->addElement($certTable);
}
return $content;
}
/**
* Returns the Java Script functions to manage the certificates.
*
* @return htmlJavaScript JS block
*/
private static function getSelfServiceUserCertificatesJSBlock() {
$content = '
function inetOrgPersonDeleteCertificate(id) {
var actionJSON = {
2018-05-16 16:00:54 +00:00
"action": "deleteCert",
"id": id
};
var data = {jsonInput: actionJSON};
data["' . getSecurityTokenName() . '"] = "' . getSecurityTokenValue() . '";
jQuery.post(\'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user\',
data, function(data) {inetOrgPersonDeleteCertificateHandleReply(data);}, \'json\');
}
function inetOrgPersonDeleteCertificateHandleReply(data) {
if (data.errorsOccured == "false") {
jQuery(\'#userCertificateDiv\').html(data.html);
}
else {
alert(data.errormessage);
}
}
function inetOrgPersonUploadCert(elementID) {
var uploadStatus = document.getElementById(\'inetOrgPerson_upload_status_cert\');
var params = { action: \'ajaxCertUpload\' };
params["' . getSecurityTokenName() . '"] = "' . getSecurityTokenValue() . '";
var uploader = new qq.FineUploader({
element: document.getElementById(elementID),
listElement: uploadStatus,
request: {
2015-05-14 09:18:45 +00:00
endpoint: \'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user'
. '&' . getSecurityTokenName() . '=' . getSecurityTokenValue() . '\',
forceMultipart: true,
params: params
},
multiple: false,
callbacks: {
onComplete: function(id, fileName, data) {
if (data.success) {
if (data.html) {
jQuery(\'#userCertificateDiv\').html(data.html);
}
}
else {
alert(data.error);
}
}
}
});
}
';
return new htmlJavaScript($content);
}
2006-07-23 15:06:49 +00:00
/**
2011-02-26 13:14:10 +00:00
* Checks if all input values are correct and returns the LDAP attributes which should be changed.
* <br>Return values:
* <br>messages: array of parameters to create status messages
* <br>add: array of attributes to add
* <br>del: array of attributes to remove
* <br>mod: array of attributes to modify
* <br>info: array of values with informational value (e.g. to be used later by pre/postModify actions)
*
2011-02-26 13:14:10 +00:00
* Calling this method does not require the existence of an enclosing {@link accountContainer}.
2006-07-23 15:06:49 +00:00
*
* @param string $fields input fields
* @param array $attributes LDAP attributes
* @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
2012-08-18 15:55:43 +00:00
* @param array $readOnlyFields list of read-only fields
2011-02-26 13:14:10 +00:00
* @return array messages and attributes (array('messages' => array(), 'add' => array('mail' => array('test@test.com')), 'del' => array(), 'mod' => array(), 'info' => array()))
2006-07-23 15:06:49 +00:00
*/
2012-08-18 15:55:43 +00:00
function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {
2011-02-26 13:14:10 +00:00
$return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array(), 'info' => array());
if ($passwordChangeOnly) {
return $return; // skip processing if only a password change is done
}
2006-07-23 15:06:49 +00:00
$attributeNames = array(); // list of attributes which should be checked for modification
$attributesNew = $attributes;
// first name
2012-08-18 15:55:43 +00:00
if (in_array('firstName', $fields) && !in_array('firstName', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'givenName';
if (isset($_POST['inetOrgPerson_firstName']) && ($_POST['inetOrgPerson_firstName'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_firstName'], 'realname')) {
$return['messages'][] = $this->messages['givenName'][0];
}
else {
$attributesNew['givenName'][0] = $_POST['inetOrgPerson_firstName'];
}
}
elseif (isset($attributes['givenName'])) {
unset($attributesNew['givenName']);
2006-07-23 15:06:49 +00:00
}
}
// last name
2012-08-18 15:55:43 +00:00
if (in_array('lastName', $fields) && !in_array('lastName', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'sn';
if (isset($_POST['inetOrgPerson_lastName']) && ($_POST['inetOrgPerson_lastName'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_lastName'], 'realname')) {
$return['messages'][] = $this->messages['lastname'][0];
}
else {
$attributesNew['sn'][0] = $_POST['inetOrgPerson_lastName'];
}
2006-07-23 15:06:49 +00:00
}
else {
// last name is required attribute
$return['messages'][] = $this->messages['lastname'][0];
}
}
// email
2012-08-18 15:55:43 +00:00
if (in_array('mail', $fields) && !in_array('mail', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'mail';
if (isset($_POST['inetOrgPerson_mail']) && ($_POST['inetOrgPerson_mail'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_mail'], 'email')) {
$return['messages'][] = $this->messages['email'][0];
}
else {
$attributesNew['mail'][0] = $_POST['inetOrgPerson_mail'];
}
}
elseif (isset($attributes['mail'])) {
unset($attributesNew['mail']);
2006-07-23 15:06:49 +00:00
}
}
2011-12-11 13:36:34 +00:00
// labeledURI
2012-08-18 15:55:43 +00:00
if (in_array('labeledURI', $fields) && !in_array('labeledURI', $readOnlyFields)) {
2011-12-11 13:36:34 +00:00
$attributeNames[] = 'labeledURI';
if (isset($_POST['inetOrgPerson_labeledURI']) && ($_POST['inetOrgPerson_labeledURI'] != '')) {
$attributesNew['labeledURI'] = preg_split('/;[ ]*/', $_POST['inetOrgPerson_labeledURI']);
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['labeledURI'])) {
unset($attributesNew['labeledURI']);
}
2011-12-11 13:36:34 +00:00
}
2006-07-23 15:06:49 +00:00
// telephone number
2012-08-18 15:55:43 +00:00
if (in_array('telephoneNumber', $fields) && !in_array('telephoneNumber', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'telephoneNumber';
if (isset($_POST['inetOrgPerson_telephoneNumber']) && ($_POST['inetOrgPerson_telephoneNumber'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_telephoneNumber'], 'telephone')) {
$return['messages'][] = $this->messages['telephoneNumber'][0];
}
else {
$attributesNew['telephoneNumber'][0] = $_POST['inetOrgPerson_telephoneNumber'];
}
}
elseif (isset($attributes['telephoneNumber'])) {
unset($attributesNew['telephoneNumber']);
2006-07-23 15:06:49 +00:00
}
}
// home telephone number
2012-08-18 15:55:43 +00:00
if (in_array('homePhone', $fields) && !in_array('homePhone', $readOnlyFields)) {
$attributeNames[] = 'homePhone';
if (isset($_POST['inetOrgPerson_homePhone']) && ($_POST['inetOrgPerson_homePhone'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_homePhone'], 'telephone')) {
$return['messages'][] = $this->messages['homePhone'][0];
}
else {
$attributesNew['homePhone'][0] = $_POST['inetOrgPerson_homePhone'];
}
}
elseif (isset($attributes['homePhone'])) {
unset($attributesNew['homePhone']);
}
}
2006-07-23 15:06:49 +00:00
// fax number
2012-08-18 15:55:43 +00:00
if (in_array('faxNumber', $fields) && !in_array('faxNumber', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'facsimileTelephoneNumber';
if (isset($_POST['inetOrgPerson_faxNumber']) && ($_POST['inetOrgPerson_faxNumber'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_faxNumber'], 'telephone')) {
$return['messages'][] = $this->messages['facsimileNumber'][0];
}
else {
$attributesNew['facsimileTelephoneNumber'][0] = $_POST['inetOrgPerson_faxNumber'];
}
}
elseif (isset($attributes['facsimileTelephoneNumber'])) {
$attributesNew['facsimileTelephoneNumber'] = array();
2006-07-23 15:06:49 +00:00
}
}
// mobile telephone number
2012-08-18 15:55:43 +00:00
if (in_array('mobile', $fields) && !in_array('mobile', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'mobile';
if (isset($_POST['inetOrgPerson_mobile']) && ($_POST['inetOrgPerson_mobile'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_mobile'], 'telephone')) {
$return['messages'][] = $this->messages['mobileTelephone'][0];
}
else {
$attributesNew['mobile'][0] = $_POST['inetOrgPerson_mobile'];
}
}
elseif (isset($attributes['mobile'])) {
unset($attributesNew['mobile']);
2006-07-23 15:06:49 +00:00
}
}
2014-07-27 11:10:42 +00:00
// pager
if (in_array('pager', $fields) && !in_array('pager', $readOnlyFields)) {
$attributeNames[] = 'pager';
if (isset($_POST['inetOrgPerson_pager']) && ($_POST['inetOrgPerson_pager'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_pager'], 'telephone')) {
$return['messages'][] = $this->messages['pager'][0];
}
else {
$attributesNew['pager'][0] = $_POST['inetOrgPerson_pager'];
}
}
elseif (isset($attributes['pager'])) {
unset($attributesNew['pager']);
2014-07-27 11:10:42 +00:00
}
}
2006-07-23 15:06:49 +00:00
// street
2012-08-18 15:55:43 +00:00
if (in_array('street', $fields) && !in_array('street', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'street';
if (isset($_POST['inetOrgPerson_street']) && ($_POST['inetOrgPerson_street'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_street'], 'street')) {
$return['messages'][] = $this->messages['street'][0];
}
else {
$attributesNew['street'][0] = $_POST['inetOrgPerson_street'];
}
}
elseif (isset($attributes['street'])) {
unset($attributesNew['street']);
2006-07-23 15:06:49 +00:00
}
}
// postal address
2012-08-18 15:55:43 +00:00
if (in_array('postalAddress', $fields) && !in_array('postalAddress', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'postalAddress';
if (isset($_POST['inetOrgPerson_postalAddress']) && ($_POST['inetOrgPerson_postalAddress'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_postalAddress'], 'postalAddress')) {
$return['messages'][] = $this->messages['postalAddress'][0];
}
else {
$attributesNew['postalAddress'][0] = $_POST['inetOrgPerson_postalAddress'];
}
}
elseif (isset($attributes['postalAddress'])) {
$attributesNew['postalAddress'] = array();
2006-07-23 15:06:49 +00:00
}
}
2011-11-03 18:31:33 +00:00
// registered address
2012-08-18 15:55:43 +00:00
if (in_array('registeredAddress', $fields) && !in_array('registeredAddress', $readOnlyFields)) {
2011-11-03 18:31:33 +00:00
$attributeNames[] = 'registeredAddress';
if (isset($_POST['inetOrgPerson_registeredAddress']) && ($_POST['inetOrgPerson_registeredAddress'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_registeredAddress'], 'postalAddress')) {
$return['messages'][] = $this->messages['registeredAddress'][0];
}
else {
$attributesNew['registeredAddress'][0] = $_POST['inetOrgPerson_registeredAddress'];
}
}
elseif (isset($attributes['registeredAddress'])) {
$attributesNew['registeredAddress'] = array();
2011-11-03 18:31:33 +00:00
}
}
2006-07-23 15:06:49 +00:00
// postal code
2012-08-18 15:55:43 +00:00
if (in_array('postalCode', $fields) && !in_array('postalCode', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'postalCode';
if (isset($_POST['inetOrgPerson_postalCode']) && ($_POST['inetOrgPerson_postalCode'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_postalCode'], 'postalCode')) {
$return['messages'][] = $this->messages['postalCode'][0];
}
else {
$attributesNew['postalCode'][0] = $_POST['inetOrgPerson_postalCode'];
}
}
elseif (isset($attributes['postalCode'])) {
unset($attributesNew['postalCode']);
2006-07-23 15:06:49 +00:00
}
}
// post office box
2012-08-18 15:55:43 +00:00
if (in_array('postOfficeBox', $fields) && !in_array('postOfficeBox', $readOnlyFields)) {
2006-07-23 15:06:49 +00:00
$attributeNames[] = 'postOfficeBox';
if (isset($_POST['inetOrgPerson_postOfficeBox']) && ($_POST['inetOrgPerson_postOfficeBox'] != '')) {
$attributesNew['postOfficeBox'][0] = $_POST['inetOrgPerson_postOfficeBox'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['postOfficeBox'])) {
unset($attributesNew['postOfficeBox']);
}
2006-07-23 15:06:49 +00:00
}
// room number
2012-08-18 15:55:43 +00:00
if (in_array('roomNumber', $fields) && !in_array('roomNumber', $readOnlyFields)) {
$attributeNames[] = 'roomNumber';
if (isset($_POST['inetOrgPerson_roomNumber']) && ($_POST['inetOrgPerson_roomNumber'] != '')) {
$attributesNew['roomNumber'][0] = $_POST['inetOrgPerson_roomNumber'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['roomNumber'])) {
unset($attributesNew['roomNumber']);
}
}
// l
2012-08-18 15:55:43 +00:00
if (in_array('location', $fields) && !in_array('location', $readOnlyFields)) {
$attributeNames[] = 'l';
if (isset($_POST['inetOrgPerson_location']) && ($_POST['inetOrgPerson_location'] != '')) {
$attributesNew['l'][0] = $_POST['inetOrgPerson_location'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['l'])) {
unset($attributesNew['l']);
}
}
// st
2012-08-18 15:55:43 +00:00
if (in_array('state', $fields) && !in_array('state', $readOnlyFields)) {
$attributeNames[] = 'st';
if (isset($_POST['inetOrgPerson_state']) && ($_POST['inetOrgPerson_state'] != '')) {
$attributesNew['st'][0] = $_POST['inetOrgPerson_state'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['st'])) {
unset($attributesNew['st']);
}
}
// car license
2012-08-18 15:55:43 +00:00
if (in_array('carLicense', $fields) && !in_array('carLicense', $readOnlyFields)) {
$attributeNames[] = 'carLicense';
if (isset($_POST['inetOrgPerson_carLicense']) && ($_POST['inetOrgPerson_carLicense'] != '')) {
$attributesNew['carLicense'][0] = $_POST['inetOrgPerson_carLicense'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['carLicense'])) {
unset($attributesNew['carLicense']);
}
}
// office name
2012-08-18 15:55:43 +00:00
if (in_array('officeName', $fields) && !in_array('officeName', $readOnlyFields)) {
$attributeNames[] = 'physicalDeliveryOfficeName';
if (isset($_POST['inetOrgPerson_officeName']) && ($_POST['inetOrgPerson_officeName'] != '')) {
$attributesNew['physicalDeliveryOfficeName'][0] = $_POST['inetOrgPerson_officeName'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['physicalDeliveryOfficeName'])) {
unset($attributesNew['physicalDeliveryOfficeName']);
}
}
2009-02-08 18:15:21 +00:00
// business category
2012-08-18 15:55:43 +00:00
if (in_array('businessCategory', $fields) && !in_array('businessCategory', $readOnlyFields)) {
2009-02-08 18:15:21 +00:00
$attributeNames[] = 'businessCategory';
if (isset($_POST['inetOrgPerson_businessCategory']) && ($_POST['inetOrgPerson_businessCategory'] != '')) {
if (!get_preg($_POST['inetOrgPerson_businessCategory'], 'businessCategory')) {
$return['messages'][] = $this->messages['businessCategory'][0];
}
else {
$attributesNew['businessCategory'][0] = $_POST['inetOrgPerson_businessCategory'];
}
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['businessCategory'])) {
unset($attributesNew['businessCategory']);
}
2009-02-08 18:15:21 +00:00
}
2007-02-18 18:37:15 +00:00
// photo
2012-08-18 15:55:43 +00:00
if (in_array('jpegPhoto', $fields) && !in_array('jpegPhoto', $readOnlyFields)) {
2018-05-16 16:00:54 +00:00
$data = $_SESSION[self::SESS_PHOTO];
// remove photo
2018-05-16 16:00:54 +00:00
if (!empty($attributes['jpegPhoto'][0]) && empty($data)) {
$return['mod']['jpegPhoto'] = array();
2007-02-18 18:37:15 +00:00
}
// set/replace photo
2018-05-16 16:00:54 +00:00
elseif (!empty($data) && (empty($attributes['jpegPhoto'][0]) || ($data != $attributes['jpegPhoto'][0]))) {
$moduleSettings = $this->selfServiceSettings->moduleSettings;
2018-05-16 16:00:54 +00:00
try {
2018-08-19 17:13:16 +00:00
include_once dirname(__FILE__) . '/../imageutils.inc';
$imageManipulator = ImageManipulationFactory::getImageManipulator($data);
$imageManipulator->crop($_POST['croppingDataX'], $_POST['croppingDataY'], $_POST['croppingDataWidth'], $_POST['croppingDataHeight']);
$data = $imageManipulator->getImageData();
2018-05-16 16:00:54 +00:00
$data = inetOrgPerson::resizeAndConvertImage($data, $moduleSettings);
if (!empty($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && ($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0] < (strlen($data) / 1024))) {
$msg = $this->messages['file'][3];
$msg[] = null;
$msg[] = htmlspecialchars($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]);
2018-05-12 07:39:29 +00:00
$return['messages'][] = $msg;
}
2018-05-16 16:00:54 +00:00
else {
if (!empty($attributes['jpegPhoto'][0])) {
$return['mod']['jpegPhoto'][0] = $data;
}
else {
$return['add']['jpegPhoto'][0] = $data;
}
}
2007-02-18 18:37:15 +00:00
}
2018-05-16 16:00:54 +00:00
catch (Exception $e) {
$msg = $this->messages['file'][2];
$msg[] = htmlspecialchars($e->getMessage());
$return['messages'][] = $msg;
}
2007-02-18 18:37:15 +00:00
}
}
2009-02-15 12:54:37 +00:00
// departments
2012-08-18 15:55:43 +00:00
if (in_array('departmentNumber', $fields) && !in_array('departmentNumber', $readOnlyFields)) {
2009-02-15 12:54:37 +00:00
$attributeNames[] = 'departmentNumber';
if (isset($_POST['inetOrgPerson_departmentNumber']) && ($_POST['inetOrgPerson_departmentNumber'] != '')) {
$attributesNew['departmentNumber'] = preg_split('/;[ ]*/', $_POST['inetOrgPerson_departmentNumber']);
2009-02-15 12:54:37 +00:00
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['departmentNumber'])) {
unset($attributesNew['departmentNumber']);
}
2009-02-15 12:54:37 +00:00
}
// initials
2012-08-18 15:55:43 +00:00
if (in_array('initials', $fields) && !in_array('initials', $readOnlyFields)) {
$attributeNames[] = 'initials';
if (isset($_POST['inetOrgPerson_initials']) && ($_POST['inetOrgPerson_initials'] != '')) {
$attributesNew['initials'] = preg_split('/;[ ]*/', $_POST['inetOrgPerson_initials']);
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['initials'])) {
unset($attributesNew['initials']);
}
}
2011-05-22 14:22:00 +00:00
// title
2012-08-18 15:55:43 +00:00
if (in_array('title', $fields) && !in_array('title', $readOnlyFields)) {
2011-05-22 14:22:00 +00:00
$attributeNames[] = 'title';
if (isset($_POST['inetOrgPerson_title']) && ($_POST['inetOrgPerson_title'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_title'], 'title')) {
$return['messages'][] = $this->messages['title'][0];
}
else {
$attributesNew['title'][0] = $_POST['inetOrgPerson_title'];
}
}
elseif (isset($attributes['title'])) {
unset($attributesNew['title']);
2011-05-22 14:22:00 +00:00
}
}
// user certificates
if (in_array('userCertificate', $fields)) {
$userCertificates = $_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST];
$userCertificatesAttrName = 'userCertificate;binary';
if (isset($attributes['userCertificate'])) {
$userCertificatesAttrName = 'userCertificate';
}
$attributeNames[] = $userCertificatesAttrName;
if (sizeof($userCertificates) > 0) {
$attributesNew[$userCertificatesAttrName] = $userCertificates;
}
elseif (isset($attributesNew[$userCertificatesAttrName])) {
unset($attributesNew[$userCertificatesAttrName]);
}
}
// description
if (in_array('description', $fields) && !in_array('description', $readOnlyFields)) {
$attributeNames[] = 'description';
if (!empty($_POST['inetOrgPerson_description'])) {
$attributesNew['description'][0] = $_POST['inetOrgPerson_description'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['description'])) {
unset($attributesNew['description']);
}
}
// ou
if (in_array('ou', $fields) && !in_array('ou', $readOnlyFields)) {
$attributeNames[] = 'ou';
if (!empty($_POST['inetOrgPerson_ou'])) {
$attributesNew['ou'][0] = $_POST['inetOrgPerson_ou'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['ou'])) {
unset($attributesNew['ou']);
}
}
2017-05-13 09:10:38 +00:00
// o
if (in_array('o', $fields) && !in_array('o', $readOnlyFields)) {
$attributeNames[] = 'o';
if (!empty($_POST['inetOrgPerson_o'])) {
$attributesNew['o'][0] = $_POST['inetOrgPerson_o'];
}
2020-01-19 17:12:03 +00:00
elseif (isset($attributes['o'])) {
unset($attributesNew['o']);
}
2017-05-13 09:10:38 +00:00
}
// uid
if (in_array('uid', $fields) && !in_array('uid', $readOnlyFields)) {
$attributeNames[] = 'uid';
if (isset($_POST['inetOrgPerson_uid']) && ($_POST['inetOrgPerson_uid'] != '')) {
2020-01-19 17:12:03 +00:00
if (!get_preg($_POST['inetOrgPerson_uid'], 'username')) {
$return['messages'][] = $this->messages['uid'][0];
}
else {
$attributesNew['uid'][0] = $_POST['inetOrgPerson_uid'];
}
}
elseif (isset($attributes['uid'])) {
unset($attributesNew['uid']);
}
}
// display name
if (in_array('displayName', $fields) && !in_array('displayName', $readOnlyFields)) {
$attributeNames[] = 'displayName';
if (!empty($_POST['inetOrgPerson_displayName'])) {
$attributesNew['displayName'][0] = $_POST['inetOrgPerson_displayName'];
}
elseif (isset($attributes['displayName'])) {
unset($attributesNew['displayName']);
}
}
2006-07-23 15:06:49 +00:00
// find differences
for ($i = 0; $i < sizeof($attributeNames); $i++) {
$attrName = $attributeNames[$i];
if (isset($attributes[$attrName]) && !isset($attributesNew[$attrName])) $return['del'][$attrName] = $attributes[$attrName];
elseif (!isset($attributes[$attrName]) && isset($attributesNew[$attrName])) $return['add'][$attrName] = $attributesNew[$attrName];
else {
2010-06-16 17:22:47 +00:00
if (isset($attributes[$attrName])) {
for ($a = 0; $a < sizeof($attributes[$attrName]); $a++) {
if (!in_array($attributes[$attrName][$a], $attributesNew[$attrName])) {
$return['mod'][$attrName] = $attributesNew[$attrName];
break;
}
2006-07-23 15:06:49 +00:00
}
}
2010-06-16 17:22:47 +00:00
if (isset($attributesNew[$attrName])) {
for ($a = 0; $a < sizeof($attributesNew[$attrName]); $a++) {
if (!in_array($attributesNew[$attrName][$a], $attributes[$attrName])) {
$return['mod'][$attrName] = $attributesNew[$attrName];
break;
}
2009-02-15 12:54:37 +00:00
}
}
2006-07-23 15:06:49 +00:00
}
}
return $return;
}
/**
* Resizes the given image data to the settings provided.
*
* @param array $data binary image data
* @param array $settings settings
* @return array binary image data
*/
private static function resizeAndConvertImage($data, $settings) {
2018-08-19 17:13:16 +00:00
include_once dirname(__FILE__) . '/../imageutils.inc';
$imageManipulator = ImageManipulationFactory::getImageManipulator($data);
2018-05-12 07:39:29 +00:00
// resize if maximum values specified
if (!empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0])) {
2018-08-19 17:13:16 +00:00
$maxWidth = empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $imageManipulator->getWidth() : $settings['inetOrgPerson_jpegPhoto_maxWidth'][0];
$maxHeight = empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $imageManipulator->getHeight() : $settings['inetOrgPerson_jpegPhoto_maxHeight'][0];
$imageManipulator->thumbnail($maxWidth, $maxHeight);
2018-05-12 07:39:29 +00:00
}
2018-08-19 17:13:16 +00:00
$imageManipulator->convertToJpeg();
2020-03-19 19:26:49 +00:00
return $imageManipulator->getImageData();
}
/**
* Manages AJAX requests.
* This function may be called with or without an account container.
*/
public function handleAjaxRequest() {
// AJAX uploads are non-JSON
if (isset($_GET['action']) && ($_GET['action'] == 'ajaxCertUpload')) {
2018-05-16 16:00:54 +00:00
$this->ajaxUploadCert();
return;
}
if (isset($_GET['action']) && ($_GET['action'] == 'ajaxPhotoUpload')) {
$this->ajaxUploadPhoto();
return;
}
$jsonInput = $_POST['jsonInput'];
$jsonReturn = self::invalidAjaxRequest();
if (isset($jsonInput['action'])) {
2018-05-16 16:00:54 +00:00
if ($jsonInput['action'] == 'deleteCert') {
$jsonReturn = $this->ajaxDeleteSelfServiceUserCertificate($jsonInput);
}
2018-05-16 16:00:54 +00:00
elseif ($jsonInput['action'] == 'deletePhoto') {
$jsonReturn = $this->ajaxDeleteSelfServicePhoto($jsonInput);
}
}
echo json_encode($jsonReturn);
}
/**
2018-05-16 16:00:54 +00:00
* Handles an AJAX certificate file upload and prints the JSON result.
*/
2018-05-16 16:00:54 +00:00
private function ajaxUploadCert() {
$result = array('success' => true);
if (!isset($_FILES['qqfile']) || ($_FILES['qqfile']['size'] < 100)) {
$result = array('error' => _('No file received.'));
}
else {
$handle = fopen($_FILES['qqfile']['tmp_name'], "r");
$data = fread($handle, 100000000);
fclose($handle);
if (strpos($data, '-----BEGIN CERTIFICATE-----') === 0) {
$pemData = str_replace("\r", '', $data);
$pemData = explode("\n", $pemData);
array_shift($pemData);
$last = array_pop($pemData);
while (($last != '-----END CERTIFICATE-----') && sizeof($pemData) > 2) {
$last = array_pop($pemData);
}
$pemData = implode('', $pemData);
$data = base64_decode($pemData);
}
$_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST][] = $data;
ob_start();
$contentElement = $this->getSelfServiceUserCertificates();
ob_end_clean();
ob_start();
$tabindex = 999;
parseHtml(null, $contentElement, array(), true, $tabindex, $this->get_scope());
$content = ob_get_contents();
ob_end_clean();
$result['html'] = $content;
}
echo json_encode($result);
}
2018-05-16 16:00:54 +00:00
/**
* Handles an AJAX photo file upload and prints the JSON result.
*/
private function ajaxUploadPhoto() {
$result = array('success' => true);
2020-07-24 08:06:22 +00:00
if ((!isset($_FILES['qqfile']) || ($_FILES['qqfile']['size'] < 100)) && empty($_POST['webcamData'])) {
2018-05-16 16:00:54 +00:00
$result = array('error' => _('No file received.'));
}
else {
2020-07-24 08:06:22 +00:00
if (empty($_POST['webcamData'])) {
$handle = fopen($_FILES['qqfile']['tmp_name'], "r");
$data = fread($handle, 100000000);
fclose($handle);
}
else {
$data = $_POST['webcamData'];
$data = str_replace('data:image/png;base64,', '', $data);
$data = base64_decode($data);
}
2018-05-16 16:00:54 +00:00
try {
2018-08-19 17:13:16 +00:00
include_once dirname(__FILE__) . '/../imageutils.inc';
$imageManipulator = ImageManipulationFactory::getImageManipulator($data);
$imageManipulator->convertToJpeg();
$data = $imageManipulator->getImageData();
2018-05-16 16:00:54 +00:00
}
catch (Exception $e) {
$result = array('success' => false, 'error' => htmlspecialchars($e->getMessage()));
echo json_encode($result);
return;
}
$_SESSION[inetOrgPerson::SESS_PHOTO] = $data;
ob_start();
$contentElement = $this->getSelfServicePhoto(false, true);
ob_end_clean();
ob_start();
$tabindex = 999;
parseHtml(null, $contentElement, array(), true, $tabindex, $this->get_scope());
$content = ob_get_contents();
ob_end_clean();
$result['html'] = $content;
}
echo json_encode($result);
}
/**
* Manages the deletion of a photo.
*
* @param array $data JSON data
*/
private function ajaxDeleteSelfServicePhoto($data) {
$_SESSION[self::SESS_PHOTO] = null;
ob_start();
$contentElement = $this->getSelfServicePhoto(false, false);
ob_end_clean();
ob_start();
$tabindex = 999;
parseHtml(null, $contentElement, array(), true, $tabindex, $this->get_scope());
$content = ob_get_contents();
ob_end_clean();
return array(
'errorsOccured' => 'false',
'html' => $content,
);
}
/**
* Manages the deletion of a certificate.
*
* @param array $data JSON data
*/
private function ajaxDeleteSelfServiceUserCertificate($data) {
if (!isset($data['id'])) {
return self::invalidAjaxRequest();
}
$index = $data['id'];
if (array_key_exists($index, $_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST])) {
unset($_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST][$index]);
$_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST] = array_values($_SESSION[inetOrgPerson::SESS_CERTIFICATES_LIST]);
}
ob_start();
$contentElement = $this->getSelfServiceUserCertificates();
ob_end_clean();
ob_start();
$tabindex = 999;
parseHtml(null, $contentElement, array(), true, $tabindex, $this->get_scope());
$content = ob_get_contents();
ob_end_clean();
return array(
'errorsOccured' => 'false',
'html' => $content,
);
}
/**
* Invalid AJAX request received.
*
* @param String $message error message
*/
public static function invalidAjaxRequest($message = null) {
if ($message == null) {
$message = _('Invalid request');
}
return array('errorsOccured' => 'true', 'errormessage' => $message);
}
2009-10-10 12:47:40 +00:00
/**
* This method specifies if a module manages password attributes.
* @see passwordService::managesPasswordAttributes
*
* @return boolean true if this module manages password attributes
*/
public function managesPasswordAttributes() {
2016-06-19 09:41:47 +00:00
if (!$this->isUnixActive()) {
2014-01-06 14:29:09 +00:00
return !$this->isAdminReadOnly('userPassword');
2009-10-10 12:47:40 +00:00
}
return false;
}
/**
* Specifies if this module supports to force that a user must change his password on next login.
*
* @return boolean force password change supported
*/
public function supportsForcePasswordChange() {
return false;
}
2009-10-10 12:47:40 +00:00
/**
* This function is called whenever the password should be changed. Account modules
* must change their password attributes only if the modules list contains their module name.
*
* @param String $password new password
* @param $modules list of modules for which the password should be changed
* @param boolean $forcePasswordChange force the user to change his password at next login
2009-10-10 12:47:40 +00:00
* @return array list of error messages if any as parameter array for StatusMessage
2020-02-24 19:08:28 +00:00
* e.g. return array(array('ERROR', 'Password change failed.'))
2009-10-10 12:47:40 +00:00
* @see passwordService::passwordChangeRequested
*/
public function passwordChangeRequested($password, $modules, $forcePasswordChange) {
2009-10-10 12:47:40 +00:00
if (!in_array(get_class($this), $modules)) {
return array();
}
2014-04-17 19:26:08 +00:00
// check password strength
$user = empty($this->attributes['uid'][0]) ? null : $this->attributes['uid'][0];
$additionalAttrs = array();
if (!empty($this->attributes['sn'][0])) {
$additionalAttrs[] = $this->attributes['sn'][0];
}
if (!empty($this->attributes['givenName'][0])) {
$additionalAttrs[] = $this->attributes['givenName'][0];
}
$checkResult = checkPasswordStrength($password, $user, $additionalAttrs);
if ($checkResult !== true) {
return array(array('ERROR', $checkResult));
}
// set new password
$this->clearTextPassword = $password;
2015-02-11 16:57:38 +00:00
// set SASL password
if (!empty($this->attributes['uid'][0]) && !empty($this->moduleSettings['posixAccount_pwdHash'][0])
&& ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL')) {
$this->attributes['userPassword'][0] = '{SASL}' . $this->attributes['uid'][0];
}
2018-07-07 15:40:44 +00:00
// delay on ldap_exop
elseif (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'LDAP_EXOP')) {
logNewMessage(LOG_DEBUG, 'Setting password in post action, exop');
}
2015-02-11 16:57:38 +00:00
// set normal password
else {
$this->attributes['userPassword'][0] = pwd_hash($password, true, $this->moduleSettings['posixAccount_pwdHash'][0]);
}
2009-10-10 12:47:40 +00:00
return array();
}
2013-03-24 15:25:01 +00:00
/**
* Loads cached data from LDAP such as departmets etc.
*/
private function initCache() {
if ($this->departmentCache != null) {
return;
}
$attrs = array();
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$attrs[] = 'departmentNumber';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) {
$attrs[] = 'ou';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) {
$attrs[] = 'o';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$attrs[] = 'title';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$attrs[] = 'employeeType';
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$attrs[] = 'businessCategory';
}
$departments = array();
$ous = array();
$os = array();
$titles = array();
$employeeTypes = array();
$businessCategories = array();
if (sizeof($attrs) > 0) {
$result = searchLDAPByFilter('(objectClass=inetOrgPerson)', $attrs, array($this->get_scope()));
foreach ($result as $attributes) {
if (isset($attributes['departmentnumber'])) {
2014-09-21 18:09:44 +00:00
foreach ($attributes['departmentnumber'] as $val) {
$departments[] = $val;
}
2013-03-24 15:25:01 +00:00
}
if (isset($attributes['ou'])) {
2014-09-21 18:09:44 +00:00
foreach ($attributes['ou'] as $val) {
$ous[] = $val;
}
2013-03-24 15:25:01 +00:00
}
if (isset($attributes['o'])) {
2014-09-21 18:09:44 +00:00
foreach ($attributes['o'] as $val) {
$os[] = $val;
}
2013-03-24 15:25:01 +00:00
}
if (isset($attributes['title'])) {
2014-09-21 18:09:44 +00:00
foreach ($attributes['title'] as $val) {
$titles[] = $val;
}
2013-03-24 15:25:01 +00:00
}
if (isset($attributes['employeetype'])) {
2014-09-21 18:09:44 +00:00
foreach ($attributes['employeetype'] as $val) {
$employeeTypes[] = $val;
}
2013-03-24 15:25:01 +00:00
}
if (isset($attributes['businesscategory'])) {
2014-09-21 18:09:44 +00:00
foreach ($attributes['businesscategory'] as $val) {
$businessCategories[] = $val;
}
2013-03-24 15:25:01 +00:00
}
}
}
$this->departmentCache = array_values(array_unique($departments));
$this->oCache = array_values(array_unique($os));
$this->ouCache = array_values(array_unique($ous));
$this->titleCache = array_values(array_unique($titles));
$this->employeeTypeCache = array_values(array_unique($employeeTypes));
$this->businessCategoryCache = array_values(array_unique($businessCategories));
}
2014-01-06 14:29:09 +00:00
/**
* Returns if the attribute is read-only in admin interface.
*
2014-01-06 14:29:09 +00:00
* @param String $attrName attribute name
* @return boolean attribute is read-only
*/
private function isAdminReadOnly($attrName) {
// for new accounts all fields can be edited
if ($this->getAccountContainer()->isNewAccount) {
return false;
}
return $this->isBooleanConfigOptionSet('inetOrgPerson_readOnly_' . $attrName);
}
2014-01-25 14:14:46 +00:00
/**
2017-11-25 10:39:34 +00:00
* {@inheritDoc}
* @see baseModule::get_configOptions()
*/
2014-01-25 14:14:46 +00:00
public function get_configOptions($scopes, $allScopes) {
2017-11-25 16:40:31 +00:00
$configContainer = new htmlResponsiveRow();
2014-01-25 14:14:46 +00:00
if (isset($_SESSION['conf_config'])) {
// add password hash type if posixAccount is inactive
2017-03-21 18:26:31 +00:00
$unixModuleFound = false;
$typeManager = new TypeManager($_SESSION['conf_config']);
$types = $typeManager->getConfiguredTypesForScopes(array('user', 'group'));
foreach ($types as $type) {
$modules = $type->getModules();
if (in_array('posixAccount', $modules) || in_array('posixGroup', $modules)) {
$unixModuleFound = true;
break;
}
2014-01-25 14:14:46 +00:00
}
2017-03-21 18:26:31 +00:00
if (!$unixModuleFound) {
2014-01-25 14:14:46 +00:00
$optionsSelected = array('SSHA');
2017-11-25 16:40:31 +00:00
$hashOption = new htmlResponsiveSelect('posixAccount_pwdHash', getSupportedHashTypes(), $optionsSelected, _("Password hash type"), 'pwdHash');
$configContainer->add($hashOption, 12);
2014-01-25 14:14:46 +00:00
}
}
2017-11-25 16:40:31 +00:00
$configContainerHead = new htmlGroup();
2014-01-25 14:14:46 +00:00
$configContainerHead->addElement(new htmlOutputText(_('Hidden options')));
$configContainerHead->addElement(new htmlHelpLink('hiddenOptions'));
2017-11-25 16:40:31 +00:00
$configContainer->add($configContainerHead, 12);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideDescription', false, _('Description'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideStreet', false, _('Street'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePostOfficeBox', false, _('Post office box'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePostalCode', false, _('Postal code'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideLocation', false, _('Location'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideState', false, _('State'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePostalAddress', false, _('Postal address'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideRegisteredAddress', false, _('Registered address'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideOfficeName', false, _('Office name'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideRoomNumber', false, _('Room number'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideTelephoneNumber', false, _('Telephone number'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideHomeTelephoneNumber', false, _('Home telephone number'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideMobileNumber', false, _('Mobile number'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideFaxNumber', false, _('Fax number'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidePager', true, _('Pager'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideEMailAddress', false, _('Email address'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideJobTitle', false, _('Job title'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideCarLicense', false, _('Car license'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideEmployeeType', false, _('Employee type'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideBusinessCategory', false, _('Business category'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideDepartments', false, _('Department'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideManager', false, _('Manager'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideOu', false, _('Organisational unit'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideO', false, _('Organisation'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideEmployeeNumber', false, _('Employee number'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideInitials', false, _('Initials'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideLabeledURI', false, _('Web site'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideuserCertificate', false, _('User certificates'), null, true), 12, 4);
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidejpegPhoto', false, _('Photo'), null, true), 12, 4);
2014-01-25 14:14:46 +00:00
if (isset($_SESSION['conf_config'])) {
2020-01-19 17:12:03 +00:00
$confActiveUserModules = $_SESSION['conf_config']->get_AccountModules('user');
if (!in_array('sambaSamAccount', $confActiveUserModules)) {
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hidedisplayName', true, _('Display name'), null, true), 12, 4);
}
2014-01-25 14:14:46 +00:00
// option to hide uid
2020-01-19 17:12:03 +00:00
if (!in_array('posixAccount', $confActiveUserModules)) {
2017-11-25 16:40:31 +00:00
$configContainer->add(new htmlResponsiveInputCheckbox('inetOrgPerson_hideUID', false, _('User name'), null, true), 12, 4);
}
else {
$configContainer->add(new htmlOutputText(''), 0, 4);
2014-01-25 14:14:46 +00:00
}
}
2017-11-25 16:40:31 +00:00
$configContainer->addVerticalSpacer('1rem');
$advancedOptions = new htmlResponsiveRow();
$advancedOptions->add(new htmlResponsiveInputCheckbox('inetOrgPerson_addAddressbook', false, _('Add addressbook (ou=addressbook)'), 'addAddressbook'), 12);
$advancedOptions->add(new htmlSubTitle(_('Read-only fields')), 12);
2014-01-25 14:14:46 +00:00
$readOnlyOptions = array(
_('Description') => 'inetOrgPerson_readOnly_description', _('Street') => 'inetOrgPerson_readOnly_street',
_('First name') => 'inetOrgPerson_readOnly_givenName', _('Last name') => 'inetOrgPerson_readOnly_sn',
_('Post office box') => 'inetOrgPerson_readOnly_postOfficeBox', _('Postal code') => 'inetOrgPerson_readOnly_postalCode',
_('Location') => 'inetOrgPerson_readOnly_l', _('State') => 'inetOrgPerson_readOnly_st',
_('Postal address') => 'inetOrgPerson_readOnly_postalAddress', _('Registered address') => 'inetOrgPerson_readOnly_registeredAddress',
_('Office name') => 'inetOrgPerson_readOnly_physicalDeliveryOfficeName', _('Room number') => 'inetOrgPerson_readOnly_roomNumber',
_('Telephone number') => 'inetOrgPerson_readOnly_telephoneNumber', _('Home telephone number') => 'inetOrgPerson_readOnly_homePhone',
_('Mobile number') => 'inetOrgPerson_readOnly_mobile', _('Fax number') => 'inetOrgPerson_readOnly_facsimileTelephoneNumber',
2014-07-27 11:10:42 +00:00
_('Pager') => 'inetOrgPerson_readOnly_pager', _('Email address') => 'inetOrgPerson_readOnly_mail',
_('Web site') => 'inetOrgPerson_readOnly_labeledURI', _('Job title') => 'inetOrgPerson_readOnly_title',
_('Car license') => 'inetOrgPerson_readOnly_carLicense', _('Employee type') => 'inetOrgPerson_readOnly_employeeType',
_('Business category') => 'inetOrgPerson_readOnly_businessCategory',
2014-01-25 14:14:46 +00:00
_('Department') => 'inetOrgPerson_readOnly_departmentNumber', _('Manager') => 'inetOrgPerson_readOnly_manager',
_('Organisation') => 'inetOrgPerson_readOnly_o', _('Organisational unit') => 'inetOrgPerson_readOnly_ou',
_('Employee number') => 'inetOrgPerson_readOnly_employeeNumber', _('Initials') => 'inetOrgPerson_readOnly_initials',
_('Photo') => 'inetOrgPerson_readOnly_jpegPhoto', _('Password') => 'inetOrgPerson_readOnly_userPassword'
);
if (isset($_SESSION['conf_config'])) {
$readOnlyOptions[_('User name')] = 'inetOrgPerson_readOnly_uid';
$readOnlyOptions[_('Common name')] = 'inetOrgPerson_readOnly_cn';
}
ksort($readOnlyOptions);
foreach ($readOnlyOptions as $label => $id) {
2017-11-25 16:40:31 +00:00
$advancedOptions->add(new htmlResponsiveInputCheckbox($id, false, $label, null, true), 12, 4);
2014-01-25 14:14:46 +00:00
}
2017-11-25 16:40:31 +00:00
$advancedOptions->add(new htmlSubTitle(_('Photo')), 12);
2018-05-12 07:39:29 +00:00
$advancedOptions->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, 'crop'), 12);
$advancedOptions->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, 'crop'), 12);
2017-11-25 16:40:31 +00:00
$advancedOptions->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), 12);
2014-01-25 14:14:46 +00:00
$advancedOptionsAccordion = new htmlAccordion('inetOrgPersonAdvancedOptions', array(_('Advanced options') => $advancedOptions), false);
2017-11-25 16:40:31 +00:00
$configContainer->add($advancedOptionsAccordion, 12);
return $configContainer;
2014-01-25 14:14:46 +00:00
}
2009-10-10 12:47:40 +00:00
2014-02-06 18:43:06 +00:00
/**
* Checks if the given email address already exists in LDAP.
*
2014-02-06 18:43:06 +00:00
* @param String $mail email address
* @return boolean true if already exists
*/
private function emailExists($mail) {
if (empty($mail)) {
return false;
}
if (isset($this->emailCheckCache[$mail])) {
return $this->emailCheckCache[$mail];
}
$result = searchLDAPByAttribute('mail', $mail, 'inetOrgPerson', array('dn'), array('user'));
$this->emailCheckCache[$mail] = (sizeof($result) > 0);
return $this->emailCheckCache[$mail];
}
2014-04-21 19:21:47 +00:00
/**
* Returns if the Unix module is also active.
*
2017-04-23 18:46:58 +00:00
* @param string[] $modules active account mdules
2014-04-21 19:21:47 +00:00
* @return boolean Unix is active
*/
2017-04-23 18:46:58 +00:00
private function isUnixActive($modules = null) {
if (!empty($modules)) {
return in_array('posixAccount', $modules);
}
if ($this->getAccountContainer() == null) {
2014-04-21 19:21:47 +00:00
return false;
}
2017-04-23 18:46:58 +00:00
$modules = $this->getAccountContainer()->get_type()->getModules();
2014-04-21 19:21:47 +00:00
return in_array('posixAccount', $modules);
}
2020-01-19 17:12:03 +00:00
/**
* Returns if the Samba 3 module is also active.
*
* @param string[] $modules active account mdules
* @return boolean Samba 3 is active
*/
private function isSamba3Active($modules = null) {
if (!empty($modules)) {
return in_array('sambaSamAccount', $modules);
}
if ($this->getAccountContainer() == null) {
return false;
}
$modules = $this->getAccountContainer()->get_type()->getModules();
return in_array('sambaSamAccount', $modules);
}
2016-11-19 18:20:44 +00:00
/**
2017-06-05 07:39:29 +00:00
* {@inheritdoc}
2016-11-19 18:20:44 +00:00
*/
public function getWildCardReplacements() {
$replacements = array();
// first name
if (!empty($_POST['givenName'])) {
$replacements['firstname'] = $_POST['givenName'];
}
elseif (!empty($this->attributes['givenName'][0])) {
$replacements['firstname'] = $this->attributes['givenName'][0];
}
// last name
if (!empty($_POST['sn'])) {
$replacements['lastname'] = $_POST['sn'];
}
elseif (!empty($this->attributes['sn'][0])) {
$replacements['lastname'] = $this->attributes['sn'][0];
}
// user name
if (!$this->isUnixActive()) {
if (!empty($_POST['uid'])) {
$replacements['user'] = $_POST['uid'];
}
elseif (!empty($this->attributes['uid'][0])) {
$replacements['user'] = $this->attributes['uid'][0];
}
}
// cn
if (!empty($_POST['cn_0'])) {
$replacements['commonname'] = $_POST['cn_0'];
}
elseif (!empty($this->attributes['cn'][0])) {
$replacements['commonname'] = $this->attributes['cn'][0];
}
// mail
if (!empty($_POST['mail_0'])) {
$replacements['email'] = $_POST['mail_0'];
}
elseif (!empty($this->attributes['mail'][0])) {
$replacements['email'] = $this->attributes['mail'][0];
}
return $replacements;
}
}
2003-12-12 00:52:35 +00:00
?>