LDAPAccountManager/lam/lib/modules/inetOrgPerson.inc

3847 lines
172 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;
2003-12-12 00:52:35 +00:00
/*
$Id$
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
2017-01-07 18:10:33 +00:00
2005 - 2017 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
*/
/**
* Manages the atrributes 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';
/**
* 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.'));
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 .-_ !'));
$this->messages['uid'][3] = array('ERROR', _('Account %s:') . ' inetOrgPerson_userName', _('User name already exists!'));
$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'][1] = array('ERROR', _('Please upload a .jpg/.jpeg file.'));
$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'),
'userCertificate' => _('User certificates'), 'ou' => _('Organisational unit'), 'description' => _('Description'), 'uid' => _('User 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',
'ou', 'description', 'uid');
// 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');
}
// 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.")
),
'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',
2009-10-03 15:46:26 +00:00
"Text" => _("Business category (e.g. Administration, IT-Services, Manangement, ...)")
),
'businessCategoryList' => array(
"Headline" => _("Business category"), 'attr' => 'businessCategory',
"Text" => _("Business category (e.g. Administration, IT-Services, Manangement, ...)") . '. ' . _("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';
}
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();
// 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)) {
$ldapUser = $_SESSION['ldap']->decrypt_login();
$ldapUser = $ldapUser[0];
$attrs = array(
'objectClass' => array('organizationalUnit'),
'ou' => 'addressbook'
);
$success = @ldap_add($_SESSION['ldap']->server(), $dn, $attrs);
if (!$success) {
2015-06-17 19:41:48 +00:00
logNewMessage(LOG_ERR, '[' . $ldapUser .'] 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 {
2015-06-17 19:41:48 +00:00
logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Added addressbook for user ' . $accountContainer->finalDN);
2015-05-23 12:10:55 +00:00
}
}
}
return $messages;
}
2003-12-30 15:36:30 +00:00
/**
* 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
}
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();
2013-03-24 10:02:49 +00:00
$equalWidthElements = array();
2010-06-12 19:37:51 +00:00
$container = new htmlTable();
$fieldContainer = new htmlTable();
$container->addElement($fieldContainer);
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'));
$equalWidthElements[] = 'uid';
}
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'));
$equalWidthElements[] = 'givenName';
}
// last name
if ($this->isAdminReadOnly('sn')) {
$this->addSimpleReadOnlyField($fieldContainer, 'sn', _('Last name'));
}
else {
$this->addSimpleInputTextField($fieldContainer, 'sn', _('Last name'), true);
$equalWidthElements[] = 'sn';
}
// 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'));
$equalWidthElements[] = '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
$equalWidthElements[] = 'cn';
}
}
// 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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'description', _('Description'), false, null, false, null, null, $equalWidthElements);
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')) {
2011-04-30 09:12:32 +00:00
$fieldContainer->addElement(new htmlSubTitle(_('Address')), true);
}
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'street', _('Street'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'postOfficeBox', _('Post office box'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'postalCode', _('Postal code'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'l', _('Location'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'st', _('State'), false, null, false, null, null, $equalWidthElements);
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;
$fieldContainer->addElement($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));
$equalWidthElements[] = 'postalAddress' . $i;
if ($i < (sizeof($postalAddresses) - 1)) {
$addressContainer->addElement(new htmlOutputText('<br>', false));
}
else {
$addressContainer->addElement(new htmlButton('addPostalAddress', 'add.png', true));
}
}
}
$fieldContainer->addElement($addressContainer);
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('postalAddress')) {
$fieldContainer->addNewLine();
}
else {
$addressHelp = new htmlHelpLink('postalAddress');
$addressHelp->alignment = htmlElement::ALIGN_TOP;
$fieldContainer->addElement($addressHelp, true);
}
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;
$fieldContainer->addElement($registeredAddressLabel);
$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));
$equalWidthElements[] = 'registeredAddress' . $i;
if ($i < (sizeof($registeredAddresses) - 1)) {
$registeredAddressContainer->addElement(new htmlOutputText('<br>', false));
}
else {
$registeredAddressContainer->addElement(new htmlButton('addRegisteredAddress', 'add.png', true));
}
2011-11-03 18:31:33 +00:00
}
}
$fieldContainer->addElement($registeredAddressContainer);
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('registeredAddress')) {
$fieldContainer->addNewLine();
}
else {
$registeredAddressHelp = new htmlHelpLink('registeredAddress');
$registeredAddressHelp->alignment = htmlElement::ALIGN_TOP;
$fieldContainer->addElement($registeredAddressHelp, true);
}
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'physicalDeliveryOfficeName', _('Office name'), false, null, false, null, null, $equalWidthElements);
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'));
$equalWidthElements[] = 'roomNumber';
}
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')) {
2011-04-30 09:12:32 +00:00
$fieldContainer->addElement(new htmlSubTitle(_('Contact data')), true);
}
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'telephoneNumber', _('Telephone number'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'homePhone', _('Home telephone number'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'mobile', _('Mobile number'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'facsimileTelephoneNumber', _('Fax number'), false, null, false, null, null, $equalWidthElements);
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 {
$this->addMultiValueInputTextField($fieldContainer, 'pager', _('Pager'), false, null, false, null, null, $equalWidthElements);
}
}
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'mail', _('Email address'), false, null, false, null, null, $equalWidthElements);
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 {
2014-01-06 14:29:09 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'labeledURI', _('Web site'), false, null, false, null, null, $equalWidthElements);
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')) {
2011-04-30 09:12:32 +00:00
$fieldContainer->addElement(new htmlSubTitle(_('Work details')), true);
}
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 {
2014-09-21 18:09:44 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'title', _('Job title'), false, null, false, array_slice($this->titleCache, 0, 300), null, $equalWidthElements);
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'));
$equalWidthElements[] = 'carLicense';
}
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'));
$equalWidthElements[] = 'employeeNumber';
}
}
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
$equalWidthElements[] = 'employeeType';
}
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 {
2014-09-21 18:09:44 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'businessCategory', _('Business category'), false, null, false, array_slice($this->businessCategoryCache, 0, 300), null, $equalWidthElements);
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 {
2014-09-21 18:09:44 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'departmentNumber', _('Department'), false, null, false, array_slice($this->departmentCache, 0, 300), null, $equalWidthElements);
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 {
2014-09-21 18:09:44 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'ou', _('Organisational unit'), false, null, false, array_slice($this->ouCache, 0, 300), null, $equalWidthElements);
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 {
2014-09-21 18:09:44 +00:00
$this->addMultiValueInputTextField($fieldContainer, 'o', _('Organisation'), false, null, false, array_slice($this->oCache, 0, 300), null, $equalWidthElements);
2013-11-02 10:25:08 +00:00
}
}
2013-01-28 21:15:55 +00:00
// user certificates
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideuserCertificate')) {
$fieldContainer->addElement(new htmlOutputText(_('User certificates')));
$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')));
}
2013-01-28 21:15:55 +00:00
$fieldContainer->addElement($userCertificateGroup);
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('manager')) {
$fieldContainer->addNewLine();
}
else {
$fieldContainer->addElement(new htmlHelpLink('userCertificate'), true);
}
2013-01-28 21:15:55 +00:00
}
2011-12-20 20:40:51 +00:00
// manager
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
2011-12-20 20:40:51 +00:00
$fieldContainer->addElement(new htmlOutputText(_('Manager')));
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('manager')) {
$fieldContainer->addNewLine();
}
else {
$fieldContainer->addElement(new htmlAccountPageButton(get_class($this), 'manager', 'change', _("Change")));
$fieldContainer->addElement(new htmlHelpLink('manager'), true);
}
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
}
$fieldContainer->addElement(new htmlOutputText(''));
$fieldContainer->addElement($managers, true);
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')) {
2011-04-30 09:12:32 +00:00
$fieldContainer->addElement(new htmlSubTitle(_('Password')), true);
2011-04-25 17:57:04 +00:00
$pwdContainer = new htmlTable();
if (pwd_is_enabled($this->attributes['userPassword'][0])) {
$pwdContainer->addElement(new htmlButton('lockPassword', _('Lock password')));
}
else {
$pwdContainer->addElement(new htmlButton('unlockPassword', _('Unlock password')));
}
$pwdContainer->addElement(new htmlButton('removePassword', _('Remove password')));
$pwdContainer->colspan = 2;
$fieldContainer->addElement($pwdContainer);
}
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();
$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'));
$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
}
$container->addElement(new htmlSpacer('50px', null));
$container->addElement($imageContainer, false);
2005-12-05 14:45:01 +00:00
}
2013-03-24 10:02:49 +00:00
$container->addElement(new htmlEqualWidth($equalWidthElements));
return $container;
}
2005-12-05 14:45:01 +00:00
/**
* Sets a new photo.
*/
2006-08-13 12:58:19 +00:00
function process_photo() {
2011-12-08 19:17:37 +00:00
if (!isset($_POST['form_subpage_' . get_class($this) . '_attributes_submit'])) {
return array();
}
2005-12-05 14:45:01 +00:00
$messages = array();
2014-01-06 14:29:09 +00:00
if ($this->isAdminReadOnly('jpegPhoto')) {
return $messages;
}
2005-12-05 14:45:01 +00:00
if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) {
2013-11-01 14:14:47 +00:00
$name = $_FILES['photoFile']['name'];
$extension = strtolower(substr($name, strpos($name, '.') + 1));
2014-01-18 17:25:08 +00:00
if (!extension_loaded('imagick') && !($extension == 'jpg') && !($extension == 'jpeg')) {
2013-11-01 14:14:47 +00:00
$messages[] = $this->messages['file'][1];
return $messages;
}
2005-12-05 14:45:01 +00:00
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
2013-11-01 14:14:47 +00:00
$data = fread($handle, 10000000);
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
fclose($handle);
2013-11-01 14:14:47 +00:00
if (extension_loaded('imagick')) {
// convert to JPG if imagick extension is available
$image = new Imagick();
try {
$image->readImageBlob($data);
2013-12-26 16:08:55 +00:00
// 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]) ? $image->getimagewidth() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0];
$maxHeight = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0];
$image->thumbnailimage($maxWidth, $maxHeight, true);
}
2013-11-01 14:14:47 +00:00
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageFormat('jpeg');
$data = $image->getimageblob();
}
catch (Exception $e) {
$msg = $this->messages['file'][2];
$msg[] = htmlspecialchars($e->getMessage());
$messages[] = $msg;
return $messages;
}
}
2005-12-05 14:45:01 +00:00
$this->attributes['jpegPhoto'][0] = $data;
}
else {
2013-01-28 21:15:55 +00:00
$messages[] = $this->messages['file'][0];
2005-12-05 14:45:01 +00:00
}
return $messages;
}
/**
* Displays the photo upload page.
*
* @return array meta HTML code
*/
2006-08-13 12:58:19 +00:00
function display_html_photo() {
2010-06-21 16:23:44 +00:00
$container = new htmlTable();
2013-11-01 14:22:13 +00:00
$label = _('Photo file (JPG format)');
if (extension_loaded('imagick')) {
$label = _('Photo file');
}
$container->addElement(new htmlTableExtendedInputFileUpload('photoFile', $label, 'photoUpload'), true);
2010-06-21 16:23:44 +00:00
$buttonContainer = new htmlTable();
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Add photo')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')));
$container->addElement($buttonContainer);
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() {
$return = new htmlTable();
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;
if (sizeof($options) < 20) $size = sizeof($options);
$managerSelect = new htmlSelect('manager', $options, array(), $size);
$managerSelect->setHasDescriptiveElements(true);
$managerSelect->setMultiSelect(true);
$managerSelect->setRightToLeftTextDirection(true);
$managerSelect->setSortElements(false);
$managerSelect->setTransformSingleSelect(false);
$return->addElement($managerSelect, true);
$buttonTable = new htmlTable();
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'manager', 'addManagers', _('Add')));
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'manager', 'cancel', _('Cancel')));
$return->addElement($buttonTable);
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);
$return->addElement($managerSelect, true);
$removeButton = new htmlAccountPageButton(get_class($this), 'manager', 'remove', _('Remove selected entries'));
$removeButton->colspan = 3;
$return->addElement($removeButton, true);
$return->addElement(new htmlOutputText('&nbsp;', false), true);
}
$return->addElement(new htmlOutputText('&nbsp;', false), true);
$buttonTable = new htmlTable();
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'manager', 'select', _('Add entries')));
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'managerBack', _('Back')));
$return->addElement($buttonTable);
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() {
$container = new htmlTable();
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();
}
$container->addElement($table, true);
$container->addElement(new htmlSpacer(null, '20px'), true);
}
$newGroup = new htmlGroup();
$newGroup->addElement(new htmlOutputText(_('New user certificate')));
$newGroup->addElement(new htmlSpacer('1px', null));
$newGroup->addElement(new htmlInputFileUpload('userCertificateUpload'));
$newGroup->addElement(new htmlSpacer('1px', null));
$uploadButton = new htmlAccountPageButton(get_class($this), 'userCertificate', 'submit', _('Upload'));
$uploadButton->setIconClass('upButton');
$newGroup->addElement($uploadButton);
$container->addElement($newGroup, true);
$container->addElement(new htmlSpacer(null, '10px'), true);
$container->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')));
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');
}
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'));
$this->addSimplePDFField($return, 'postalAddress', _('Postal address'));
$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'));
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']);
}
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)) {
$profileElements[] = new htmlTableExtendedInputField(_('Common name'), 'inetOrgPerson_cn', null, 'cn');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideInitials')) {
$profileElements[] = new htmlTableExtendedInputField(_('Initials'), 'inetOrgPerson_initials', null, 'initials');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
$profileElements[] = new htmlTableExtendedInputField(_('Description'), 'inetOrgPerson_description', null, 'description');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
$profileElements[] = new htmlTableExtendedInputField(_('Street'), 'inetOrgPerson_street', null, 'streetList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
$profileElements[] = new htmlTableExtendedInputField(_('Post office box'), 'inetOrgPerson_postOfficeBox', null, 'postOfficeBoxList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
$profileElements[] = new htmlTableExtendedInputField(_('Postal code'), 'inetOrgPerson_postalCode', null, 'postalCodeList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
$profileElements[] = new htmlTableExtendedInputField(_('Location'), 'inetOrgPerson_l', null, 'lList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
$profileElements[] = new htmlTableExtendedInputField(_('State'), 'inetOrgPerson_st', null, 'stList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$profileElements[] = new htmlTableExtendedInputField(_('Postal address'), 'inetOrgPerson_postalAddress', null, 'postalAddress');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
$profileElements[] = new htmlTableExtendedInputField(_('Registered address'), 'inetOrgPerson_registeredAddress', null, 'registeredAddress');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
$profileElements[] = new htmlTableExtendedInputField(_('Office name'), 'inetOrgPerson_physicalDeliveryOfficeName', null, 'physicalDeliveryOfficeName');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
$profileElements[] = new htmlTableExtendedInputField(_('Room number'), 'inetOrgPerson_roomNumber', null, 'roomNumber');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$profileElements[] = new htmlTableExtendedInputField(_('Telephone number'), 'inetOrgPerson_telephoneNumber', null, 'telephoneNumberList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$profileElements[] = new htmlTableExtendedInputField(_('Fax number'), 'inetOrgPerson_facsimileTelephoneNumber', null, 'facsimileTelephoneNumberList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
$profileElements[] = new htmlTableExtendedInputField(_('Email address'), 'inetOrgPerson_mail', null, 'mailList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLabeledURI')) {
$profileElements[] = new htmlTableExtendedInputField(_('Web site'), 'inetOrgPerson_labeledURI', null, 'labeledURIList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$profileElements[] = new htmlTableExtendedInputField(_('Department'), 'inetOrgPerson_departmentNumber', null, 'departmentNumberList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOu')) {
$profileElements[] = new htmlTableExtendedInputField(_('Organisational unit'), 'inetOrgPerson_ou', null, 'ouList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideO')) {
$profileElements[] = new htmlTableExtendedInputField(_('Organisation'), 'inetOrgPerson_o', null, 'oList');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$profileElements[] = new htmlTableExtendedInputField(_('Job title'), 'inetOrgPerson_title', null, 'title');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$profileElements[] = new htmlTableExtendedInputField(_('Employee type'), 'inetOrgPerson_employeeType', null, 'employeeType');
}
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$profileElements[] = new htmlTableExtendedInputField(_('Business category'), 'inetOrgPerson_businessCategory', null, 'businessCategory');
}
if (sizeof($profileElements) > 0) {
$profileContainer = new htmlTable();
for ($i = 0; $i < sizeof($profileElements); $i++) {
$profileContainer->addElement($profileElements[$i]);
$profileContainer->addNewLine();
}
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()
*/
function get_uploadColumns($selectedModules) {
$return = parent::get_uploadColumns($selectedModules);
// 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'),
);
}
return $return;
}
2004-10-11 18:06:53 +00:00
/**
* In this function the LDAP account is built up.
*
* @param array $rawAccounts list of hash arrays (name => value) from user input
* @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5)
2012-07-15 12:05:47 +00:00
* @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
* @param array $selectedModules list of selected account modules
2004-10-11 18:06:53 +00:00
* @return array list of error messages if any
*/
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
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];
}
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;
}
elseif (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']]);
}
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;
}
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
2015-02-11 16:57:38 +00:00
// set SASL password
if (!empty($this->moduleSettings['posixAccount_pwdHash'][0]) && ($this->moduleSettings['posixAccount_pwdHash'][0] === 'SASL')) {
$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
/**
* This function executes one post upload action.
*
* @param array $data array containing one account in each element
* @param array $ids array(<column_name> => <column number>)
* @param array $failed list of accounts which were not created successfully
* @param array $temp variable to store temporary data between two post actions
* @param array $accounts list of LDAP entries
* @return array current status
* <br> array (
* <br> 'status' => 'finished' | 'inProgress'
* <br> 'progress' => 0..100
* <br> 'errors' => array (<array of parameters for StatusMessage>)
* <br> )
*/
function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts) {
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']);
}
}
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) {
$container = new htmlTable();
$container->addElement(new htmlSubTitle(_('Photo')), true);
$photoTable = new htmlTable();
$photoTable->colspan = 2;
if (extension_loaded('imagick')) {
$photoTable->addElement(new htmlTableExtendedInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth'));
$photoTable->addElement(new htmlHelpLink('crop', get_class($this)), true);
$photoTable->addElement(new htmlTableExtendedInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight'));
$photoTable->addElement(new htmlHelpLink('crop', get_class($this)), true);
}
$photoTable->addElement(new htmlTableExtendedInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), true);
$container->addElement($photoTable, true);
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
* occured 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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
if (isset($attributes['pager'][0])) $pager = $attributes['pager'][0];
$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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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 = '';
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)) {
if (isset($attributes['jpegPhoto'][0])) {
$jpeg_filename = 'jpegPhoto' . session_id() . '.jpg';
$outjpeg = fopen(realpath('../../') . '/tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $attributes['jpegPhoto'][0]);
fclose ($outjpeg);
$photoFile = '../../tmp/' . $jpeg_filename;
2010-07-03 12:31:55 +00:00
$photoSub = new htmlTable();
2014-10-25 13:13:44 +00:00
$img = new htmlImage($photoFile);
$img->setCSSClasses(array('photo'));
$photoSub->addElement($img, true);
2012-08-18 15:55:43 +00:00
if (!in_array('jpegPhoto', $readOnlyFields)) {
$photoSubSub = new htmlTable();
2015-08-09 09:00:38 +00:00
$upload = new htmlInputFileUpload('photoFile');
$upload->colspan = 2;
$photoSubSub->addElement($upload, true);
2012-08-18 15:55:43 +00:00
$photoSubSub->addElement(new htmlTableExtendedInputCheckbox('removeReplacePhoto', false, _('Remove/replace photo'), null, false));
$photoSub->addElement($photoSubSub);
}
2015-08-09 09:00:38 +00:00
$return['jpegPhoto'] = new htmlResponsiveRow(new htmlOutputText($this->getSelfServiceLabel('jpegPhoto', _('Photo'))), $photoSub);
2007-02-18 18:37:15 +00:00
}
2012-08-18 15:55:43 +00:00
elseif (!in_array('jpegPhoto', $readOnlyFields)) {
2010-07-03 12:31:55 +00:00
$photoSub = new htmlTable();
$photoSub->addElement(new htmlTableExtendedInputFileUpload('photoFile', _('Add photo')));
$photoSub->addElement(new htmlHiddenInput('addPhoto', 'true'));
2015-08-09 09:00:38 +00:00
$return['jpegPhoto'] = new htmlResponsiveRow(new htmlOutputText($this->getSelfServiceLabel('jpegPhoto', _('Photo'))), $photoSub);
2007-02-18 18:37:15 +00:00
}
}
2009-02-15 12:54:37 +00:00
if (in_array('departmentNumber', $fields)) {
$departmentNumber = '';
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 = '';
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 = '';
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'));
$uploadStatus->colspan = 7;
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);
}
// ou
if (in_array('ou', $fields)) {
$ou = '';
if (isset($attributes['ou'][0])) $ou = $attributes['ou'][0];
if (in_array('ou', $readOnlyFields)) {
$ouField = new htmlOutputText(getAbstractDN($ou));
}
else {
$userObj = new user();
$filter = $userObj->getSuffixFilter();
$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 = '';
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 = '';
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
);
}
2006-07-23 15:06:49 +00:00
return $return;
}
/**
* 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 = {
"action": "delete",
"id": id
};
2015-05-14 09:18:45 +00:00
jQuery.post(\'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user'
. '&' . getSecurityTokenName() . '=' . getSecurityTokenValue()
. '\', {jsonInput: actionJSON}, 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 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: {
action: \'ajaxCertUpload\'
}
},
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'] != '')) {
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']);
}
// 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'] != '')) {
if (!get_preg($_POST['inetOrgPerson_lastName'], 'realname')) $return['messages'][] = $this->messages['lastname'][0];
else $attributesNew['sn'][0] = $_POST['inetOrgPerson_lastName'];
}
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'] != '')) {
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']);
}
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']);
}
elseif (isset($attributes['labeledURI'])) unset($attributesNew['labeledURI']);
}
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'] != '')) {
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']);
}
// 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'] != '')) {
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'] != '')) {
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();
}
// 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'] != '')) {
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']);
}
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'] != '')) {
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']);
}
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'] != '')) {
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']);
}
// 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'] != '')) {
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();
}
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'] != '')) {
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();
}
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'] != '')) {
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']);
}
// 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'];
}
elseif (isset($attributes['postOfficeBox'])) unset($attributesNew['postOfficeBox']);
}
// 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'];
}
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'];
}
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'];
}
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'];
}
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'];
}
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'];
}
}
elseif (isset($attributes['businessCategory'])) unset($attributesNew['businessCategory']);
}
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)) {
// remove photo
if (isset($_POST['removeReplacePhoto']) && ($_POST['removeReplacePhoto'] == 'on')
&& (empty($_FILES['replacePhotoFile']) || ($_FILES['replacePhotoFile']['size'] == 0))) {
$return['mod']['jpegPhoto'] = array();
2007-02-18 18:37:15 +00:00
}
// set/replace photo
if (isset($_FILES['photoFile']) && ($_FILES['photoFile']['size'] > 0)) {
$moduleSettings = $this->selfServiceSettings->moduleSettings;
if (!empty($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && ($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0] < ($_FILES['photoFile']['size'] / 1024))) {
$msg = $this->messages['file'][3];
$msg[] = null;
$msg[] = htmlspecialchars($moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]);
$return['messages'][] = $msg;
2007-02-18 18:37:15 +00:00
}
else {
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
$data = fread($handle, 100000000);
fclose($handle);
if (extension_loaded('imagick')) {
try {
$data = inetOrgPerson::resizeAndConvertImage($data, $moduleSettings);
}
catch (Exception $e) {
$msg = $this->messages['file'][2];
$msg[] = htmlspecialchars($e->getMessage());
$return['messages'][] = $msg;
}
}
if (isset($_POST['removeReplacePhoto']) && ($_POST['removeReplacePhoto'] == 'on')) {
$return['mod']['jpegPhoto'][0] = $data;
}
elseif (isset($_POST['addPhoto'])) {
$return['add']['jpegPhoto'][0] = $data;
}
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
}
elseif (isset($attributes['departmentNumber'])) unset($attributesNew['departmentNumber']);
}
// 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']);
}
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'] != '')) {
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']);
}
// 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'];
}
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'];
}
elseif (isset($attributes['ou'])) unset($attributesNew['ou']);
}
// uid
if (in_array('uid', $fields) && !in_array('uid', $readOnlyFields)) {
$attributeNames[] = 'uid';
if (isset($_POST['inetOrgPerson_uid']) && ($_POST['inetOrgPerson_uid'] != '')) {
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']);
}
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) {
if (extension_loaded('imagick')) {
// convert to JPG if imagick extension is available
$image = new Imagick();
$image->readImageBlob($data);
// resize if maximum values specified
if (!empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0])) {
$maxWidth = empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $settings['inetOrgPerson_jpegPhoto_maxWidth'][0];
$maxHeight = empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $settings['inetOrgPerson_jpegPhoto_maxHeight'][0];
$image->thumbnailimage($maxWidth, $maxHeight, true);
}
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageFormat('jpeg');
$data = $image->getimageblob();
}
return $data;
}
/**
* 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')) {
$this->ajaxUpload();
return;
}
$jsonInput = $_POST['jsonInput'];
$jsonReturn = self::invalidAjaxRequest();
if (isset($jsonInput['action'])) {
if ($jsonInput['action'] == 'delete') {
$jsonReturn = $this->ajaxDeleteSelfServiceUserCertificate($jsonInput);
}
}
echo json_encode($jsonReturn);
}
/**
* Handles an AJAX file upload and prints the JSON result.
*/
private function ajaxUpload() {
$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);
}
/**
* 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
* e.g. return arrray(array('ERROR', 'Password change failed.'))
* @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];
}
// 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
/**
* Returns a list of configuration options.
*
2014-01-25 14:14:46 +00:00
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br>
* The field names are used as keywords to load and save settings.
* We recommend to use the module name as prefix for them (e.g. posixAccount_homeDirectory) to avoid naming conflicts.
*
* @param array $scopes account types (user, group, host)
* @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
* @return mixed htmlElement or array of htmlElement
*
2014-01-25 14:14:46 +00:00
* @see htmlElement
*/
public function get_configOptions($scopes, $allScopes) {
$return = parent::get_configOptions($scopes, $allScopes);
// configuration settings
$configContainer = new htmlTable();
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');
$hashOption = new htmlTable();
$hashOption->addElement(new htmlTableExtendedSelect('posixAccount_pwdHash', getSupportedHashTypes(), $optionsSelected, _("Password hash type"), 'pwdHash'));
$configContainer->addElement($hashOption, true);
}
}
$configContainerHead = new htmlTable();
$configContainerHead->addElement(new htmlOutputText(_('Hidden options')));
$configContainerHead->addElement(new htmlHelpLink('hiddenOptions'));
$configContainerOptions = new htmlTable();
$configContainer->addElement($configContainerHead, true);
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideDescription', false, _('Description'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideStreet', false, _('Street'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hidePostOfficeBox', false, _('Post office box'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hidePostalCode', false, _('Postal code'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideLocation', false, _('Location'), null, false));
$configContainerOptions->addNewLine();
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideState', false, _('State'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hidePostalAddress', false, _('Postal address'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideRegisteredAddress', false, _('Registered address'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideOfficeName', false, _('Office name'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideRoomNumber', false, _('Room number'), null, false));
$configContainerOptions->addNewLine();
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideTelephoneNumber', false, _('Telephone number'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideHomeTelephoneNumber', false, _('Home telephone number'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideMobileNumber', false, _('Mobile number'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideFaxNumber', false, _('Fax number'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
2014-07-27 11:10:42 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hidePager', true, _('Pager'), null, false));
2014-01-25 14:14:46 +00:00
$configContainerOptions->addNewLine();
2014-07-27 11:10:42 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideEMailAddress', false, _('Email address'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
2014-01-25 14:14:46 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideJobTitle', false, _('Job title'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideCarLicense', false, _('Car license'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideEmployeeType', false, _('Employee type'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideBusinessCategory', false, _('Business category'), null, false));
$configContainerOptions->addNewLine();
2014-07-27 11:10:42 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideDepartments', false, _('Department'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
2014-01-25 14:14:46 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideManager', false, _('Manager'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideOu', false, _('Organisational unit'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideO', false, _('Organisation'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideEmployeeNumber', false, _('Employee number'), null, false));
$configContainerOptions->addNewLine();
2014-07-27 11:10:42 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideInitials', false, _('Initials'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
2014-01-25 14:14:46 +00:00
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideLabeledURI', false, _('Web site'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideuserCertificate', false, _('User certificates'), null, false));
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hidejpegPhoto', false, _('Photo'), null, false));
if (isset($_SESSION['conf_config'])) {
$confActiveUnixUserModules = $_SESSION['conf_config']->get_AccountModules('user');
// option to hide uid
if (!in_array('posixAccount', $confActiveUnixUserModules)) {
$configContainerOptions->addElement(new htmlOutputText(' '));
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideUID', false, _('User name'), null, false));
}
}
$configContainer->addElement($configContainerOptions, true);
$advancedOptions = new htmlTable();
2015-05-23 12:10:55 +00:00
$addressbookTable = new htmlTable();
$addressbookTable->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_addAddressbook', false, _('Add addressbook (ou=addressbook)'), 'addAddressbook'));
$advancedOptions->addElement($addressbookTable, true);
2014-01-25 14:14:46 +00:00
$advancedOptions->addElement(new htmlSubTitle(_('Read-only fields')), true);
$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'])) {
$confActiveUnixUserModules = $_SESSION['conf_config']->get_AccountModules('user');
$readOnlyOptions[_('User name')] = 'inetOrgPerson_readOnly_uid';
$readOnlyOptions[_('Common name')] = 'inetOrgPerson_readOnly_cn';
}
ksort($readOnlyOptions);
$readOnlyCounter = 0;
$readOnlyOptionsTable = new htmlTable();
$readOnlyOptionsTable->colspan = 5;
foreach ($readOnlyOptions as $label => $id) {
$readOnlyOptionsTable->addElement(new htmlTableExtendedInputCheckbox($id, false, $label, null, false));
$readOnlyCounter++;
if (($readOnlyCounter % 5) == 0) {
$readOnlyOptionsTable->addNewLine();
}
}
$advancedOptions->addElement($readOnlyOptionsTable, true);
$advancedOptions->addElement(new htmlSubTitle(_('Photo')), true);
$photoTable = new htmlTable();
$photoTable->colspan = 2;
if (extension_loaded('imagick')) {
$photoTable->addElement(new htmlTableExtendedInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, 'crop'), true);
$photoTable->addElement(new htmlTableExtendedInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, 'crop'), true);
}
2014-01-25 14:14:46 +00:00
$photoTable->addElement(new htmlTableExtendedInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), true);
$advancedOptions->addElement($photoTable, true);
$advancedOptionsAccordion = new htmlAccordion('inetOrgPersonAdvancedOptions', array(_('Advanced options') => $advancedOptions), false);
$advancedOptionsAccordion->colspan = 5;
$configContainer->addElement($advancedOptionsAccordion);
$return[] = $configContainer;
return $return;
}
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);
}
2016-11-19 18:20:44 +00:00
/**
* Returns a list of wildcards that can be replaced in input fileds.
* E.g. "$firstname$" is replaced with "givenName" attribute value.
*
* @return array replacements as wildcard => value
*/
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
?>