2003-12-12 00:52:35 +00:00
< ? php
/*
$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
2015-01-07 17:16:35 +00:00
2005 - 2015 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
*/
2004-07-02 12:09:06 +00:00
/**
* 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
*/
2004-07-02 12:09:06 +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 ) .
2004-07-02 12:09:06 +00:00
*
* @ package modules
2003-12-12 00:52:35 +00:00
*/
2009-10-10 12:47:40 +00:00
class inetOrgPerson extends baseModule implements passwordService {
2015-07-12 12:41:47 +00:00
2010-11-21 14:43:09 +00:00
/** caches the list of possible managers */
private $cachedManagers = null ;
2012-07-15 12:05:47 +00:00
/** clear text password */
2011-05-16 17:32:32 +00:00
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 ();
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
/** session variable for existing user certificates in self service */
const SESS_CERTIFICATES_LIST = 'inetOrgPerson_certificatesList' ;
2015-07-12 12:41:47 +00:00
2004-06-24 09:51:12 +00:00
/**
2005-08-15 18:36:56 +00:00
* This function fills the message array .
2004-09-26 13:48:52 +00:00
**/
function load_Messages () {
2004-10-28 15:14:54 +00:00
$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!' ));
2004-09-26 13:48:52 +00:00
$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!' ));
2007-06-11 18:19:05 +00:00
$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!' ));
2004-09-26 13:48:52 +00:00
$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!' ));
2004-09-26 13:48:52 +00:00
$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.' ));
2004-09-26 13:48:52 +00:00
$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!' ));
2004-09-26 13:48:52 +00:00
$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!' ));
2005-06-19 09:38:44 +00:00
$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.' ));
2007-06-11 18:19:05 +00:00
$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
}
2014-04-20 13:00:42 +00:00
/**
* Returns true if this module can manage accounts of the current type , otherwise false .
2015-07-12 12:41:47 +00:00
*
2014-04-20 13:00:42 +00:00
* @ 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
2015-07-12 12:41:47 +00:00
*
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' );
2005-01-10 10:41:38 +00:00
// this is a base module
$return [ " is_base " ] = true ;
2004-10-06 18:17:22 +00:00
// RDN attribute
2007-07-03 15:43:52 +00:00
$return [ " RDN " ] = array ( " cn " => " normal " , 'uid' => 'low' );
2005-06-19 09:38:44 +00:00
// LDAP filter
$return [ " ldap_filter " ] = array ( 'or' => " (objectClass=inetOrgPerson) " );
2004-06-20 17:32:02 +00:00
// module dependencies
2005-06-19 09:38:44 +00:00
$return [ 'dependencies' ] = array ( 'depends' => array (), 'conflicts' => array ());
2006-04-05 15:48:27 +00:00
// 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' ,
2007-12-29 11:02:57 +00:00
'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' ,
'registeredAddress' , 'labeledURI' , 'ou' , 'userCertificate;binary' );
2014-04-21 19:21:47 +00:00
if ( ! $this -> isUnixActive ()) {
$return [ 'attributes' ][] = 'cn' ;
}
2006-06-28 15:13:57 +00:00
// self service search attributes
2011-08-20 16:27:53 +00:00
$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' ),
2007-06-11 18:19:05 +00:00
'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' ),
2014-05-03 09:33:44 +00:00
'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' ,
2014-05-03 09:33:44 +00:00
'location' , 'state' , 'officeName' , 'businessCategory' , 'departmentNumber' , 'initials' , 'title' , 'labeledURI' , 'userCertificate' ,
'ou' , 'description' , 'uid' );
2004-07-01 15:54:33 +00:00
// profile elements
2010-06-12 19:37:51 +00:00
$profileElements = array ();
2012-09-13 15:29:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideInitials' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Initials' ), 'inetOrgPerson_initials' , null , 'initials' );
}
2012-09-14 10:35:21 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideDescription' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Description' ), 'inetOrgPerson_description' , null , 'description' );
}
2011-02-19 15:06:11 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideStreet' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Street' ), 'inetOrgPerson_street' , null , 'streetList' );
2011-02-19 15:06:11 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostOfficeBox' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Post office box' ), 'inetOrgPerson_postOfficeBox' , null , 'postOfficeBoxList' );
2011-02-19 15:06:11 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostalCode' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Postal code' ), 'inetOrgPerson_postalCode' , null , 'postalCodeList' );
2011-02-19 15:06:11 +00:00
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideLocation' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Location' ), 'inetOrgPerson_l' , null , 'lList' );
2009-10-03 15:46:26 +00:00
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideState' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'State' ), 'inetOrgPerson_st' , null , 'stList' );
2009-10-03 15:46:26 +00:00
}
2011-02-19 15:06:11 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostalAddress' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Postal address' ), 'inetOrgPerson_postalAddress' , null , 'postalAddress' );
}
2011-11-03 18:31:33 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideRegisteredAddress' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Registered address' ), 'inetOrgPerson_registeredAddress' , null , 'registeredAddress' );
}
2012-09-13 15:29:51 +00:00
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' );
}
2011-02-19 15:06:11 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideTelephoneNumber' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Telephone number' ), 'inetOrgPerson_telephoneNumber' , null , 'telephoneNumberList' );
2011-02-19 15:06:11 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideFaxNumber' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Fax number' ), 'inetOrgPerson_facsimileTelephoneNumber' , null , 'facsimileTelephoneNumberList' );
2011-02-19 15:06:11 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideEMailAddress' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Email address' ), 'inetOrgPerson_mail' , null , 'mailList' );
2011-02-19 15:06:11 +00:00
}
2011-12-11 13:36:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideLabeledURI' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Web site' ), 'inetOrgPerson_labeledURI' , null , 'labeledURIList' );
}
2011-02-19 15:06:11 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideDepartments' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Department' ), 'inetOrgPerson_departmentNumber' , null , 'departmentNumberList' );
2011-02-19 15:06:11 +00:00
}
2012-10-14 08:32:26 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideOu' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Organisational unit' ), 'inetOrgPerson_ou' , null , 'ouList' );
}
2011-05-01 11:58:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideO' )) {
2012-01-06 17:34:39 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Organisation' ), 'inetOrgPerson_o' , null , 'oList' );
2011-05-01 11:58:34 +00:00
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideJobTitle' )) {
2010-06-12 19:37:51 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Job title' ), 'inetOrgPerson_title' , null , 'title' );
2009-10-03 15:46:26 +00:00
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideEmployeeType' )) {
2010-06-12 19:37:51 +00:00
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Employee type' ), 'inetOrgPerson_employeeType' , null , 'employeeType' );
}
2013-03-04 19:21:16 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideBusinessCategory' )) {
$profileElements [] = new htmlTableExtendedInputField ( _ ( 'Business category' ), 'inetOrgPerson_businessCategory' , null , 'businessCategory' );
}
2010-06-12 19:37:51 +00:00
if ( sizeof ( $profileElements ) > 0 ) {
$profileContainer = new htmlTable ();
for ( $i = 0 ; $i < sizeof ( $profileElements ); $i ++ ) {
$profileContainer -> addElement ( $profileElements [ $i ]);
2010-09-30 18:58:44 +00:00
$profileContainer -> addNewLine ();
2010-06-12 19:37:51 +00:00
}
$return [ 'profile_options' ] = $profileContainer ;
2009-10-03 15:46:26 +00:00
}
2011-02-19 15:06:11 +00:00
// profile checks and mappings
2012-09-13 15:29:51 +00:00
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' ;
}
2009-10-03 18:13:38 +00:00
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' ;
}
2013-03-04 19:21:16 +00:00
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' ;
}
2011-02-19 15:06:11 +00:00
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' ;
}
2012-09-13 15:29:51 +00:00
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
);
2011-05-01 11:58:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideInitials' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_initials' ,
'description' => _ ( 'Initials' ),
'help' => 'initials' ,
'example' => 'A.B.'
);
}
2009-10-03 17:48:37 +00:00
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
);
}
2009-10-03 17:48:37 +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' ),
2013-02-17 19:58:23 +00:00
'help' => 'titleList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( 'President' )
);
}
2011-05-01 11:58:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideEmployeeNumber' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_employeeNumber' ,
'description' => _ ( 'Employee number' ),
'help' => 'employeeNumber' ,
'example' => '123456'
);
}
2009-10-03 17:48:37 +00:00
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' )
);
}
2009-10-03 17:48:37 +00:00
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' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideBusinessCategory' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_businessCategory' ,
'description' => _ ( 'Business category' ),
2013-02-17 19:58:23 +00:00
'help' => 'businessCategoryList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( 'Administration' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideStreet' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_street' ,
'description' => _ ( 'Street' ),
2012-01-06 17:34:39 +00:00
'help' => 'streetList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( 'Mystreetname 42' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostalCode' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_postalCode' ,
'description' => _ ( 'Postal code' ),
2012-01-06 17:34:39 +00:00
'help' => 'postalCodeList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( 'GB-12345' )
);
}
2009-10-03 17:48:37 +00:00
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
);
}
2009-10-03 17:48:37 +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' ),
2012-01-06 17:34:39 +00:00
'help' => 'postOfficeBoxList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( '12345' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideTelephoneNumber' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_telephone' ,
'description' => _ ( 'Telephone number' ),
2012-01-06 17:34:39 +00:00
'help' => 'telephoneNumberList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( '123-123-1234' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideHomeTelephoneNumber' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_homePhone' ,
'description' => _ ( 'Home telephone number' ),
2012-01-06 17:34:39 +00:00
'help' => 'homePhoneList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( '123-124-1234' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideMobileNumber' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_mobile' ,
'description' => _ ( 'Mobile number' ),
2012-01-06 17:34:39 +00:00
'help' => 'mobileTelephoneNumberList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( '123-123-1235' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideFaxNumber' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_fax' ,
'description' => _ ( 'Fax number' ),
2012-01-06 17:34:39 +00:00
'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' )
);
}
2009-10-03 17:48:37 +00:00
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' ),
2012-01-06 17:34:39 +00:00
'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' )
);
}
2009-10-03 17:48:37 +00:00
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'
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideDepartments' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_departmentNumber' ,
2012-01-06 17:34:39 +00:00
'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' )
);
}
2011-05-01 11:58:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideO' )) {
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_o' ,
'description' => _ ( 'Organisation' ),
2012-01-06 17:34:39 +00:00
'help' => 'oList' ,
2011-05-01 11:58:34 +00:00
'example' => _ ( 'YourCompany' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideLocation' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_l' ,
'description' => _ ( 'Location' ),
2012-01-06 17:34:39 +00:00
'help' => 'lList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( 'MyCity' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideState' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_st' ,
'description' => _ ( 'State' ),
2012-01-06 17:34:39 +00:00
'help' => 'stList' ,
2009-10-03 15:46:26 +00:00
'example' => _ ( 'New York' )
);
}
2009-10-03 17:48:37 +00:00
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' )
);
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideOfficeName' )) {
2009-10-03 15:46:26 +00:00
$return [ 'upload_columns' ][] = array (
'name' => 'inetOrgPerson_physicalDeliveryOfficeName' ,
'description' => _ ( 'Office name' ),
2012-03-20 20:30:35 +00:00
'help' => 'physicalDeliveryOfficeNameList' ,
'example' => _ ( 'YourCompany' )
2009-10-03 15:46:26 +00:00
);
}
2004-08-17 15:16:17 +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
);
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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' );
}
2009-10-03 17:48:37 +00:00
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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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' );
}
2009-10-03 17:48:37 +00:00
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' );
}
2009-10-03 17:48:37 +00:00
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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +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
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideDepartments' )) {
2012-01-06 17:34:39 +00:00
$return [ 'PDF_fields' ][ 'departmentNumber' ] = _ ( 'Department' );
2009-10-03 15:46:26 +00:00
}
2009-10-03 17:48:37 +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
}
2011-05-01 11:58:34 +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' );
}
2011-05-01 11:58:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideEmployeeNumber' )) {
$return [ 'PDF_fields' ][ 'employeeNumber' ] = _ ( 'Employee number' );
}
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideInitials' )) {
$return [ 'PDF_fields' ][ 'initials' ] = _ ( 'Initials' );
}
2015-07-12 12:41:47 +00:00
2014-10-25 19:17:53 +00:00
if ( isLoggedIn ()) {
2005-06-19 09:38:44 +00:00
$modules = $_SESSION [ 'config' ] -> get_AccountModules ( $this -> get_scope ());
if ( ! in_array ( 'posixAccount' , $modules )) {
2013-03-10 19:53:48 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideUID' )) {
$return [ 'PDF_fields' ][ 'uid' ] = _ ( 'User name' );
}
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'cn' ] = _ ( 'Common name' );
2005-06-19 09:38:44 +00:00
}
}
2004-09-08 17:39:06 +00:00
// help Entries
2004-10-28 15:14:54 +00:00
$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, ... " )
),
2013-02-17 19:58:23 +00:00
'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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The street name of the user's address. " )
),
'streetList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Street " ), 'attr' => 'street' ,
2011-10-08 19:28:38 +00:00
" 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' ,
2012-01-06 17:34:39 +00:00
" 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' ,
2011-10-08 19:28:38 +00:00
" 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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The postal code of the user's address. " )
),
'postalCodeList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Postal code " ), 'attr' => 'postalCode' ,
2011-10-08 19:28:38 +00:00
" 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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The user's telephone number. " )
),
'telephoneNumberList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Telephone number " ), 'attr' => 'telephoneNumber' ,
2011-04-30 16:50:08 +00:00
" 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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The user's mobile number. " )
),
'mobileTelephoneNumberList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Mobile number " ), 'attr' => 'mobile' ,
2011-04-30 16:50:08 +00:00
" 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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The user's fax number. " )
),
'facsimileTelephoneNumberList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Fax number " ), 'attr' => 'facsimileTelephoneNumber' ,
2011-04-30 16:50:08 +00:00
" 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' ,
2013-12-28 10:48:54 +00:00
" Text " => _ ( " The user's email address. " ) . ' ' . _ ( 'You can use "$user", "$firstname" and "$lastname" as wildcards for user name, first and last name.' )
2012-01-06 17:34:39 +00:00
),
'mailList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Email address " ), 'attr' => 'mail' ,
2011-04-30 16:50:08 +00:00
" Text " => _ ( " The user's email address. " ) . ' ' . _ ( 'Multiple values are separated by semicolon.' )
2013-12-28 10:48:54 +00:00
. ' ' . _ ( 'You can use "$user", "$firstname" and "$lastname" as wildcards for user name, first and last name.' )
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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The user's private telephone number. " )
),
'homePhoneList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Home telephone number " ), 'attr' => 'homePhone' ,
2011-04-30 16:50:08 +00:00
" 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, ...) " )
),
2013-02-17 19:58:23 +00:00
'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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " This describes the location of the user. " )
),
'lList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Location " ), 'attr' => 'l' ,
2011-10-14 18:37:03 +00:00
" 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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The state where the user resides or works. " )
),
'stList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " State " ), 'attr' => 'st' ,
2011-10-14 18:37:03 +00:00
" 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). " )
),
2012-03-20 20:30:35 +00:00
'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' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " Here you can enter the user's department. " )
),
'departmentNumberList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Department " ), 'attr' => 'departmentNumber' ,
2012-01-06 17:34:39 +00:00
" 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. " )
2011-05-01 11:58:34 +00:00
),
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.' )
),
2011-05-01 11:58:34 +00:00
'o' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Organisation " ), 'attr' => 'o' ,
2012-01-06 17:34:39 +00:00
" Text " => _ ( " The user's organisation name. " )
),
'oList' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Organisation " ), 'attr' => 'o' ,
2011-05-01 11:58:34 +00:00
" 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' ,
2011-05-01 11:58:34 +00:00
" Text " => _ ( " The user's unique employee number. " )
),
'initials' => array (
2012-01-31 19:32:25 +00:00
" Headline " => _ ( " Initials " ), 'attr' => 'initials' ,
2011-05-01 11:58:34 +00:00
" Text " => _ ( " The initials of the user's first names. " ) . ' ' . _ ( 'Multiple values are separated by semicolon.' )
),
2012-10-07 10:57:51 +00:00
'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.' )
),
2015-01-23 20:51:15 +00:00
'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 ;
}
2005-08-15 18:36:56 +00:00
/**
* This functions return true if all needed settings are done .
*
* @ return boolean true , if all is ok
2004-02-09 18:11:01 +00:00
*/
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 ;
2011-03-26 12:47:30 +00:00
$modules = $_SESSION [ 'config' ] -> get_AccountModules ( $this -> get_scope ());
if ( ! in_array ( 'posixAccount' , $modules )) {
if (( $this -> getAccountContainer () -> rdn == 'uid' ) && ! isset ( $this -> attributes [ 'uid' ][ 0 ])) {
return false ;
}
}
2004-02-09 18:11:01 +00:00
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 ();
}
2013-12-28 10:48:54 +00:00
// replace $user in email
if ( ! empty ( $this -> attributes [ 'mail' ][ 0 ])) {
$user = null ;
if ( $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) != null ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$user = $attrs [ 'uid' ][ 0 ];
}
elseif ( ! empty ( $this -> attributes [ 'uid' ][ 0 ])) {
$user = $this -> attributes [ 'uid' ][ 0 ];
}
if ( ! empty ( $user )) {
foreach ( $this -> attributes [ 'mail' ] as & $mail ) {
$mail = str_replace ( '$user' , $user , $mail );
}
}
}
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
2011-10-15 09:46:13 +00:00
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' ]);
2005-11-12 10:18:54 +00:00
}
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' ]);
}
2011-10-15 09:46:13 +00:00
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' ]);
2005-11-12 10:18:54 +00:00
}
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' ]);
}
2011-10-15 09:46:13 +00:00
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
}
2011-05-16 17:32:32 +00:00
// add information about clear text password
if ( $this -> clearTextPassword != null ) {
2011-10-15 09:46:13 +00:00
$return [ $this -> getAccountContainer () -> dn_orig ][ 'info' ][ 'userPasswordClearText' ][ 0 ] = $this -> clearTextPassword ;
2011-05-16 17:32:32 +00:00
}
2005-08-16 12:04:09 +00:00
return $return ;
2005-08-15 18:36:56 +00:00
}
2015-07-12 12:41:47 +00:00
2015-05-23 12:10:55 +00:00
/**
* Runs the postmodify actions .
2015-07-12 12:41:47 +00:00
*
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
2005-09-07 12:58:34 +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 ();
2013-12-28 10:48:54 +00:00
$replacements = array ( '$lastname' => 'sn' , '$firstname' => 'givenName' );
2007-11-14 09:12:27 +00:00
// 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' ;
}
}
2012-01-03 19:31:29 +00:00
// 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' );
2013-12-28 10:48:54 +00:00
if ( ! empty ( $this -> attributes [ 'mail' ])) {
foreach ( $this -> attributes [ 'mail' ] as & $mail ) {
foreach ( $replacements as $wildcard => $key ) {
if ( ! empty ( $this -> attributes [ $key ][ 0 ])) {
$mail = str_replace ( $wildcard , $this -> attributes [ $key ][ 0 ], $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 ;
}
}
2015-07-12 12:41:47 +00:00
}
2013-12-28 10:48:54 +00:00
}
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' );
2011-04-30 16:50:08 +00:00
}
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' )) {
2011-10-14 18:37:03 +00:00
$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' ];
2011-04-30 16:50:08 +00:00
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' );
2013-02-17 19:58:23 +00:00
}
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' )) {
2011-05-01 11:58:34 +00:00
$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 );
2011-05-01 11:58:34 +00:00
}
2014-01-06 14:29:09 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideInitials' ) && ! $this -> isAdminReadOnly ( 'initials' )) {
2011-05-01 11:58:34 +00:00
$this -> attributes [ 'initials' ] = preg_split ( '/;[ ]*/' , $_POST [ 'initials' ]);
}
2015-07-12 12:41:47 +00:00
2014-04-21 19:21:47 +00:00
if ( ! $this -> isUnixActive ()) {
2005-06-19 09:38:44 +00:00
// 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' )) {
2013-03-10 19:53:48 +00:00
$errors [] = $this -> messages [ 'uid' ][ 0 ];
}
else {
2013-11-01 18:59:55 +00:00
$this -> attributes [ 'uid' ][ 0 ] = $_POST [ 'uid' ];
2013-03-10 19:53:48 +00:00
}
2007-07-21 09:47:48 +00:00
}
2013-03-10 19:53:48 +00:00
elseif ( isset ( $this -> attributes [ 'uid' ][ 0 ])) {
unset ( $this -> attributes [ 'uid' ][ 0 ]);
2007-07-21 09:47:48 +00:00
}
2005-06-19 09:38:44 +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' ];
}
2005-06-19 09:38:44 +00:00
}
}
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 ];
}
2011-04-25 17:57:04 +00:00
}
2005-06-19 09:38:44 +00:00
}
2015-07-12 12:41:47 +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 .
2015-07-12 12:41:47 +00:00
*
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
2011-05-01 11:58:34 +00:00
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' ;
}
2011-05-01 11:58:34 +00:00
}
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' ;
}
2005-06-19 09:38:44 +00:00
}
2012-01-03 19:31:29 +00:00
// description
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideDescription' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'description' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'description' , _ ( 'Description' ));
2012-01-03 19:31:29 +00:00
}
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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideStreet' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'street' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'street' , _ ( 'Street' ));
2012-01-06 17:34:39 +00:00
}
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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostOfficeBox' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'postOfficeBox' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'postOfficeBox' , _ ( 'Post office box' ));
2012-01-06 17:34:39 +00:00
}
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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostalCode' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'postalCode' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'postalCode' , _ ( 'Postal code' ));
2012-01-06 17:34:39 +00:00
}
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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideLocation' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'l' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'l' , _ ( 'Location' ));
2012-01-06 17:34:39 +00:00
}
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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideState' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'st' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'st' , _ ( 'State' ));
2012-01-06 17:34:39 +00:00
}
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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hidePostalAddress' )) {
2011-10-14 18:37:03 +00:00
$postalAddresses = array ();
2011-05-10 18:23:37 +00:00
if ( isset ( $this -> attributes [ 'postalAddress' ][ 0 ])) {
2011-10-14 18:37:03 +00:00
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
}
2011-10-14 18:37:03 +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 ));
}
2011-10-14 18:37:03 +00:00
}
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 ));
}
2011-10-14 18:37:03 +00:00
}
}
$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
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideOfficeName' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'physicalDeliveryOfficeName' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'physicalDeliveryOfficeName' , _ ( 'Office name' ));
2012-03-20 20:30:35 +00:00
}
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
}
2009-10-03 17:48:37 +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
}
2008-02-09 18:01:29 +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 );
}
2015-07-12 12:41:47 +00:00
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideTelephoneNumber' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'telephoneNumber' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'telephoneNumber' , _ ( 'Telephone number' ));
2012-01-06 17:34:39 +00:00
}
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
}
2009-10-03 17:48:37 +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' ));
2012-01-06 17:34:39 +00:00
}
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
}
2009-10-03 17:48:37 +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' ));
2012-01-06 17:34:39 +00:00
}
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
}
2009-10-03 17:48:37 +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' ));
2012-01-06 17:34:39 +00:00
}
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 );
}
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideEMailAddress' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'mail' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'mail' , _ ( 'Email address' ));
2012-01-06 17:34:39 +00:00
}
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
}
2015-07-12 12:41:47 +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 );
}
2015-07-12 12:41:47 +00:00
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideJobTitle' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'title' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'title' , _ ( 'Job title' ));
2013-02-17 19:58:23 +00:00
}
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
}
2009-10-03 17:48:37 +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
}
2011-05-01 11:58:34 +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' ;
}
2011-05-01 11:58:34 +00:00
}
2009-10-03 17:48:37 +00:00
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
}
2009-10-03 17:48:37 +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-02-17 19:58:23 +00:00
}
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
}
2009-10-03 17:48:37 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideDepartments' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'departmentNumber' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'departmentNumber' , _ ( 'Department' ));
2012-01-06 17:34:39 +00:00
}
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
2011-05-01 11:58:34 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideO' )) {
2014-01-06 14:29:09 +00:00
if ( $this -> isAdminReadOnly ( 'o' )) {
$this -> addSimpleReadOnlyField ( $fieldContainer , 'o' , _ ( 'Organisation' ));
2012-01-06 17:34:39 +00:00
}
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
}
2011-05-01 11:58:34 +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
2009-10-03 17:48:37 +00:00
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 ));
2015-07-12 12:41:47 +00:00
return $container ;
2005-08-15 18:36:56 +00:00
}
2004-03-09 12:03:39 +00:00
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
}
2015-07-12 12:41:47 +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 .
2015-07-12 12:41:47 +00:00
*
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 ( ' ' , false ), true );
}
$return -> addElement ( new htmlOutputText ( ' ' , 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' ;
2013-08-10 12:43:01 +00:00
$pathOut = dirname ( __FILE__ ) . '/../../tmp/' . $filename ;
$out = @ fopen ( $pathOut , " wb " );
2015-06-18 18:16:00 +00:00
@ 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 ;
}
2015-07-12 12:41:47 +00:00
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 ;
}
2005-10-09 18:05:32 +00:00
/**
2015-01-07 17:16:35 +00:00
* Returns a list of possible PDF entries for this account .
*
* @ param array $pdfKeys list of PDF keys that are included in document
* @ return list of PDF entries ( array ( < PDF key > => < PDF lines > ))
*/
function get_pdfEntries ( $pdfKeys ) {
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' ));
2009-02-15 12:54:37 +00:00
return $return ;
}
2015-07-12 12:41:47 +00:00
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 );
2009-10-03 18:13:38 +00:00
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 ])) {
2011-05-01 11:58:34 +00:00
$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 ])) {
2011-04-30 16:50:08 +00:00
$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 ])) {
2011-04-30 16:50:08 +00:00
$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 ])) {
2011-04-30 16:50:08 +00:00
$facsimileTelephoneNumberList = preg_split ( '/;[ ]*/' , $profile [ 'inetOrgPerson_facsimileTelephoneNumber' ][ 0 ]);
$this -> attributes [ 'facsimileTelephoneNumber' ] = $facsimileTelephoneNumberList ;
}
2011-10-08 19:28:38 +00:00
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 ;
}
2011-10-14 18:37:03 +00:00
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 ;
}
2011-04-30 16:50:08 +00:00
}
2015-07-12 12:41:47 +00:00
2011-04-30 16:50:08 +00:00
/**
* Checks input values of account profiles .
*
* @ param array $options a hash array ( name => value ) containing the options
* @ return array list of error messages ( array ( type , title , text )) to generate StatusMessages , if any
*/
function check_profileOptions ( $options ) {
$messages = parent :: check_profileOptions ( $options );
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 ];
2011-04-30 16:50:08 +00:00
break ;
}
}
}
return $messages ;
2004-05-24 21:39:57 +00:00
}
2004-03-14 17:33:05 +00:00
2010-02-15 20:21:44 +00:00
/**
* Returns an array containing all input columns for the file upload .
*
* Syntax :
* < br > array (
* < br > string : name , // fixed non-translated name which is used as column name (should be of format: <module name>_<column name>)
* < br > string : description , // short descriptive name
* < br > string : help , // help ID
* < br > string : example , // example value
* < br > boolean : required // true, if user must set a value for this column
* < br > )
*
* @ param array $selectedModules list of selected account modules
* @ return array column list
*/
function get_uploadColumns ( $selectedModules ) {
$return = parent :: get_uploadColumns ( $selectedModules );
// cn and uid for upload (only if posixAccount is not selected)
if ( ! in_array ( 'posixAccount' , $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}'
2010-02-15 20:21:44 +00:00
);
2013-03-10 19:53:48 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'inetOrgPerson_hideUID' )) {
$return [] = array (
'name' => 'inetOrgPerson_userName' ,
'description' => _ ( 'User name' ),
'help' => 'uid' ,
'example' => _ ( 'smiller' ),
'unique' => true ,
'required' => false
);
}
2012-10-07 10:57:51 +00:00
$return [] = array (
'name' => 'inetOrgPerson_userPassword' ,
'description' => _ ( 'Password' ),
'help' => 'userPassword' ,
'example' => _ ( 'secret' ),
);
2010-02-15 20:21:44 +00:00
}
return $return ;
}
2015-07-12 12:41:47 +00:00
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
2010-02-15 20:21:44 +00:00
* @ param array $selectedModules list of selected account modules
2004-10-11 18:06:53 +00:00
* @ return array list of error messages if any
*/
2010-02-15 20:21:44 +00:00
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts , $selectedModules ) {
2006-05-20 16:32:02 +00:00
$errors = array ();
2013-12-28 10:48:54 +00:00
$replacements = 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' )) {
2013-05-25 12:47:07 +00:00
$partialAccounts [ $i ][ 'sn' ] = trim ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_lastName' ]]);
2013-12-28 10:48:54 +00:00
$replacements [ '$lastname' ] = $partialAccounts [ $i ][ 'sn' ];
2004-10-11 18:06:53 +00:00
}
else {
2004-10-28 15:14:54 +00:00
$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' )) {
2013-05-25 12:47:07 +00:00
$partialAccounts [ $i ][ 'givenName' ] = trim ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_firstName' ]]);
2013-12-28 10:48:54 +00:00
$replacements [ '$firstname' ] = $partialAccounts [ $i ][ 'givenName' ];
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
}
2013-12-28 10:48:54 +00:00
if ( ! in_array ( 'posixAccount' , $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' ]];
$replacements [ '$user' ] = $partialAccounts [ $i ][ 'uid' ];
}
else {
$errMsg = $this -> messages [ 'uid' ][ 1 ];
array_push ( $errMsg , array ( $i ));
$errors [] = $errMsg ;
}
}
}
2011-05-01 11:58:34 +00:00
// initials
2012-05-20 13:19:59 +00:00
if ( isset ( $ids [ 'inetOrgPerson_initials' ]) && ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_initials' ]] != " " )) {
2011-05-01 11:58:34 +00:00
$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
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_title' , 'title' , 'title' , $this -> messages [ 'title' ][ 1 ], $errors , '/;[ ]*/' );
2011-05-01 11:58:34 +00:00
// 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 );
2007-06-11 18:19:05 +00:00
// business category
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_businessCategory' , 'businessCategory' , 'businessCategory' , $this -> messages [ 'businessCategory' ][ 1 ], $errors , '/;[ ]*/' );
2005-07-02 12:05:33 +00:00
// manager
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_manager' , 'manager' , 'dn' , $this -> messages [ 'manager' ][ 0 ], $errors , '/;[ ]*/' );
2004-10-11 18:06:53 +00:00
// street
2015-07-12 12:41:47 +00:00
$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' ]] != " " )) {
2011-10-08 19:28:38 +00:00
$partialAccounts [ $i ][ 'postOfficeBox' ] = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_postOfficeBox' ]]);
2005-07-02 12:05:33 +00:00
}
2007-06-11 18:19:05 +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' ]]);
}
2011-05-01 11:58:34 +00:00
// organisation
2012-05-20 13:19:59 +00:00
if ( isset ( $ids [ 'inetOrgPerson_o' ]) && ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_o' ]] != " " )) {
2011-05-01 11:58:34 +00:00
$partialAccounts [ $i ][ 'o' ] = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_o' ]]);
}
2008-02-09 18:01:29 +00:00
// location
2012-05-20 13:19:59 +00:00
if ( isset ( $ids [ 'inetOrgPerson_l' ]) && ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_l' ]] != " " )) {
2011-10-14 18:37:03 +00:00
$partialAccounts [ $i ][ 'l' ] = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_l' ]]);
2008-02-09 18:01:29 +00:00
}
// state
2012-05-20 13:19:59 +00:00
if ( isset ( $ids [ 'inetOrgPerson_st' ]) && ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_st' ]] != " " )) {
2011-10-14 18:37:03 +00:00
$partialAccounts [ $i ][ 'st' ] = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_st' ]]);
2008-02-09 18:01:29 +00:00
}
// physicalDeliveryOfficeName
2012-05-20 13:19:59 +00:00
if ( isset ( $ids [ 'inetOrgPerson_physicalDeliveryOfficeName' ]) && ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_physicalDeliveryOfficeName' ]] != " " )) {
2012-03-20 20:30:35 +00:00
$partialAccounts [ $i ][ 'physicalDeliveryOfficeName' ] = preg_split ( '/;[ ]*/' , $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_physicalDeliveryOfficeName' ]]);
2008-02-09 18:01:29 +00:00
}
// 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
2015-07-12 12:41:47 +00:00
$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
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_telephone' , 'telephoneNumber' , 'telephone' , $this -> messages [ 'telephoneNumber' ][ 1 ], $errors , '/;[ ]*/' );
2007-06-11 18:19:05 +00:00
// home telephone
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_homePhone' , 'homePhone' , 'telephone' , $this -> messages [ 'homePhone' ][ 1 ], $errors , '/;[ ]*/' );
2004-10-11 18:06:53 +00:00
// mobile
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_mobile' , 'mobile' , 'telephone' , $this -> messages [ 'mobileTelephone' ][ 1 ], $errors , '/;[ ]*/' );
2004-10-11 18:06:53 +00:00
// facsimile
2015-07-12 12:41:47 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'inetOrgPerson_fax' , 'facsimileTelephoneNumber' , 'telephone' , $this -> messages [ 'facsimileNumber' ][ 1 ], $errors , '/;[ ]*/' );
2014-07-27 11:10:42 +00:00
// pager
2015-07-12 12:41:47 +00:00
$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' ]] != " " )) {
2013-12-28 10:48:54 +00:00
foreach ( $replacements as $wildcard => $value ) {
$rawAccounts [ $i ][ $ids [ 'inetOrgPerson_email' ]] = str_replace ( $wildcard , $value , $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_email' ]]);
}
2013-05-25 12:47:07 +00:00
$mailList = preg_split ( '/;[ ]*/' , trim ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_email' ]]));
2011-04-30 16:50:08 +00:00
$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' ]] != " " )) {
2013-05-25 12:47:07 +00:00
$partialAccounts [ $i ][ 'labeledURI' ] = preg_split ( '/;[ ]*/' , trim ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_labeledURI' ]]));
2011-12-11 13:36:34 +00:00
}
2010-02-15 20:21:44 +00:00
if ( ! in_array ( 'posixAccount' , $selectedModules )) {
2005-06-19 09:38:44 +00:00
// 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 ;
2005-06-19 09:38:44 +00:00
}
2004-10-11 18:06:53 +00:00
}
else {
2005-06-19 09:38:44 +00:00
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
}
2012-10-07 10:57:51 +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' ];
2012-10-07 10:57:51 +00:00
}
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 ;
}
2012-10-07 10:57:51 +00:00
}
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 ) {
2014-01-15 20:48:52 +00:00
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
);
}
}
2015-07-12 12:41:47 +00:00
2015-01-23 20:51:15 +00:00
/**
* 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 ;
}
2015-07-12 12:41:47 +00:00
2015-01-23 20:51:15 +00:00
/**
* Checks if the self service settings are valid .
2015-07-12 12:41:47 +00:00
*
2015-01-23 20:51:15 +00:00
* 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
2012-02-08 17:55:00 +00:00
* @ 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
2012-05-10 19:29:51 +00:00
* @ return array list of meta HTML elements ( field name => htmlTableRow )
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 ();
2012-02-08 17:55:00 +00:00
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 );
}
2010-06-21 16:23:44 +00:00
$return [ 'firstName' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'firstName' , _ ( 'First name' ))), $firstNameField
2010-06-21 16:23:44 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'lastName' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'lastName' , _ ( 'Last name' ))), $lastNameField
2010-07-03 12:31:55 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'mail' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'mail' , _ ( 'Email address' ))), $mailField
2010-07-03 12:31:55 +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 );
}
2011-12-11 13:36:34 +00:00
$return [ 'labeledURI' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'labeledURI' , _ ( 'Web site' ))), $labeledURIField
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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'telephoneNumber' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'telephoneNumber' , _ ( 'Telephone number' ))), $telephoneNumberField
2010-07-03 12:31:55 +00:00
));
2006-07-23 15:06:49 +00:00
}
2007-06-11 18:19:05 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'homePhone' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'homePhone' , _ ( 'Home telephone number' ))), $homePhoneField
2010-07-03 12:31:55 +00:00
));
2007-06-11 18:19:05 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'mobile' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'mobile' , _ ( 'Mobile telephone number' ))), $mobileField
2010-07-03 12:31:55 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'faxNumber' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'faxNumber' , _ ( 'Fax number' ))), $faxNumberField
2010-07-03 12:31:55 +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 );
}
$return [ 'pager' ] = new htmlTableRow ( array (
new htmlOutputText ( $this -> getSelfServiceLabel ( 'pager' , _ ( 'Pager' ))), $pagerField
));
}
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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'street' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'street' , _ ( 'Street' ))), $streetField
2010-07-03 12:31:55 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'postalAddress' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'postalAddress' , _ ( 'Postal address' ))), $postalAddressField
2010-07-03 12:31:55 +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 );
}
2011-11-03 18:31:33 +00:00
$return [ 'registeredAddress' ] = new htmlTableRow ( array (
2012-08-18 15:55:43 +00:00
new htmlOutputText ( _ ( 'Registered address' )), $registeredAddressField
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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'postalCode' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'postalCode' , _ ( 'Postal code' ))), $postalCodeField
2010-07-03 12:31:55 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'postOfficeBox' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'postOfficeBox' , _ ( 'Post office box' ))), $postOfficeBoxField
2010-07-03 12:31:55 +00:00
));
2006-07-23 15:06:49 +00:00
}
2007-06-11 18:19:05 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'roomNumber' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'roomNumber' , _ ( 'Room number' ))), $roomNumberField
2010-07-03 12:31:55 +00:00
));
2007-06-11 18:19:05 +00:00
}
2008-02-09 18:01:29 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'location' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'location' , _ ( 'Location' ))), $lField
2010-07-03 12:31:55 +00:00
));
2008-02-09 18:01:29 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'state' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'state' , _ ( 'State' ))), $stField
2010-07-03 12:31:55 +00:00
));
2008-02-09 18:01:29 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'carLicense' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'carLicense' , _ ( 'Car license' ))), $carLicenseField
2010-07-03 12:31:55 +00:00
));
2008-02-09 18:01:29 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'officeName' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'officeName' , _ ( 'Office name' ))), $physicalDeliveryOfficeNameField
2010-07-03 12:31:55 +00:00
));
2008-02-09 18:01:29 +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 );
}
2010-07-03 12:31:55 +00:00
$return [ 'businessCategory' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'businessCategory' , _ ( 'Business category' ))), $businessCategoryField
2010-07-03 12:31:55 +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 ();
$photoSubSub -> addElement ( new htmlTableExtendedInputCheckbox ( 'removeReplacePhoto' , false , _ ( 'Remove/replace photo' ), null , false ));
2015-01-23 20:51:15 +00:00
$photoSubSub -> addElement ( new htmlInputFileUpload ( 'photoFile' ));
2012-08-18 15:55:43 +00:00
$photoSub -> addElement ( $photoSubSub );
}
2013-11-30 15:02:06 +00:00
$photoRowCells = array ( new htmlOutputText ( $this -> getSelfServiceLabel ( 'jpegPhoto' , _ ( 'Photo' ))), $photoSub );
2010-07-03 12:31:55 +00:00
$photoRow = new htmlTableRow ( $photoRowCells );
$return [ 'jpegPhoto' ] = $photoRow ;
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' )));
2015-01-23 20:51:15 +00:00
$photoSub -> addElement ( new htmlHiddenInput ( 'addPhoto' , 'true' ));
2013-11-30 15:02:06 +00:00
$photoRowCells = array ( new htmlOutputText ( $this -> getSelfServiceLabel ( 'jpegPhoto' , _ ( 'Photo' ))), $photoSub );
2010-07-03 12:31:55 +00:00
$photoRow = new htmlTableRow ( $photoRowCells );
$return [ 'jpegPhoto' ] = $photoRow ;
2007-02-18 18:37:15 +00:00
}
}
2009-02-15 12:54:37 +00:00
if ( in_array ( 'departmentNumber' , $fields )) {
$departmentNumber = '' ;
2011-05-01 11:58:34 +00:00
if ( isset ( $attributes [ 'departmentNumber' ][ 0 ])) $departmentNumber = implode ( '; ' , $attributes [ 'departmentNumber' ]);
2012-08-18 15:55:43 +00:00
$departmentNumberField = new htmlInputField ( 'inetOrgPerson_departmentNumber' , $departmentNumber );
if ( in_array ( 'departmentNumber' , $readOnlyFields )) {
$departmentNumberField = new htmlOutputText ( $departmentNumber );
}
2010-07-03 12:31:55 +00:00
$return [ 'departmentNumber' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'departmentNumber' , _ ( 'Department' ))), $departmentNumberField
2010-07-03 12:31:55 +00:00
));
2009-02-15 12:54:37 +00:00
}
2011-05-01 11:58:34 +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 );
}
2011-05-01 11:58:34 +00:00
$return [ 'initials' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'initials' , _ ( 'Initials' ))), $initialsField
2011-05-01 11:58:34 +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 );
}
2011-05-22 14:22:00 +00:00
$return [ 'title' ] = new htmlTableRow ( array (
2013-11-30 15:02:06 +00:00
new htmlOutputText ( $this -> getSelfServiceLabel ( 'title' , _ ( 'Job title' ))), $titleField
2011-05-22 14:22:00 +00:00
));
}
2013-03-30 14:22:11 +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 ;
$certTable = new htmlTable ();
$certTable -> addElement ( new htmlDiv ( 'userCertificateDiv' , $this -> getSelfServiceUserCertificates ()), true );
// JavaScript functions
$certTable -> addElement ( $this -> getSelfServiceUserCertificatesJSBlock (), true );
// upload button
$uploadButtons = new htmlGroup ();
$uploadButtons -> addElement ( new htmlDiv ( 'inetOrgPersonCertUploadId' , new htmlOutputText ( '' )), true );
$certUpload = new htmlJavaScript ( 'inetOrgPersonUploadCert(\'inetOrgPersonCertUploadId\');' );
$uploadButtons -> addElement ( $certUpload );
$certTable -> addElement ( $uploadButtons , true );
// upload status
$uploadStatus = new htmlDiv ( 'inetOrgPerson_upload_status_cert' , new htmlOutputText ( '' ));
$uploadStatus -> setCSSClasses ( array ( 'qq-upload-list' ));
$uploadStatus -> colspan = 7 ;
$certTable -> addElement ( $uploadStatus , true );
2013-11-30 15:02:06 +00:00
$certLabel = new htmlOutputText ( $this -> getSelfServiceLabel ( 'userCertificate' , _ ( 'User certificates' )));
2013-03-30 14:22:11 +00:00
$certLabel -> alignment = htmlElement :: ALIGN_TOP ;
$userCertificatesCells = array ( $certLabel , $certTable );
$userCertificatesRow = new htmlTableRow ( $userCertificatesCells );
$return [ 'userCertificate' ] = $userCertificatesRow ;
}
2014-05-03 09:33:44 +00:00
// 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 ();
$ouList = $userObj -> getSuffixList ();
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 );
}
$return [ 'ou' ] = new htmlTableRow ( array (
new htmlOutputText ( $this -> getSelfServiceLabel ( 'ou' , _ ( 'Organisational unit' ))), $ouField
));
}
// 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 );
}
$return [ 'description' ] = new htmlTableRow ( array (
new htmlOutputText ( $this -> getSelfServiceLabel ( 'description' , _ ( 'Description' ))), $descriptionField
));
}
// 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 );
}
$return [ 'uid' ] = new htmlTableRow ( array (
new htmlOutputText ( $this -> getSelfServiceLabel ( 'uid' , _ ( 'User name' ))), $uidField
));
}
2006-07-23 15:06:49 +00:00
return $return ;
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
/**
* Returns the meta HTML code to display the certificate area .
* This also includes the file upload .
2015-07-12 12:41:47 +00:00
*
2013-03-30 14:22:11 +00:00
* @ return htmlTable certificate content
*/
2013-08-15 19:06:10 +00:00
private function getSelfServiceUserCertificates () {
2013-03-30 14:22:11 +00:00
$userCertificates = $_SESSION [ self :: SESS_CERTIFICATES_LIST ];
$content = new htmlTable ();
if ( sizeof ( $userCertificates ) > 0 ) {
$certTable = new htmlTable ();
for ( $i = 0 ; $i < sizeof ( $userCertificates ); $i ++ ) {
2013-07-21 11:34:31 +00:00
$filename = 'userCertificate' . getRandomNumber () . '.der' ;
2013-03-30 14:22:11 +00:00
$out = @ fopen ( dirname ( __FILE__ ) . '/../../tmp/' . $filename , " wb " );
fwrite ( $out , $userCertificates [ $i ]);
fclose ( $out );
$path = '../../tmp/' . $filename ;
$saveLink = new htmlLink ( '' , $path , '../../graphics/save.png' );
$saveLink -> setTitle ( _ ( 'Save' ));
$saveLink -> setTargetWindow ( '_blank' );
$certTable -> addElement ( $saveLink );
$delLink = new htmlLink ( '' , '#' , '../../graphics/del.png' );
$delLink -> setTitle ( _ ( 'Delete' ));
2013-08-15 19:06:10 +00:00
$delLink -> setOnClick ( 'inetOrgPersonDeleteCertificate(' . $i . '); return false;' );
2013-03-30 14:22:11 +00:00
$certTable -> addElement ( $delLink );
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 ) {
$certTable -> addElement ( new htmlOutputText ( implode ( ': ' , $data )));
}
}
}
$certTable -> addNewLine ();
}
$content -> addElement ( $certTable , true );
}
return $content ;
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
/**
* Returns the Java Script functions to manage the certificates .
2015-07-12 12:41:47 +00:00
*
2013-03-30 14:22:11 +00:00
* @ 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\ ' );
2013-03-30 14:22:11 +00:00
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
function inetOrgPersonDeleteCertificateHandleReply ( data ) {
if ( data . errorsOccured == " false " ) {
jQuery ( \ ' #userCertificateDiv\').html(data.html);
}
else {
alert ( data . errormessage );
}
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
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 () . ' \ ' ,
2013-03-30 14:22:11 +00:00
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 );
}
}
}
2015-07-12 12:41:47 +00:00
});
2013-03-30 14:22:11 +00:00
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
' ;
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 )
2015-07-12 12:41:47 +00:00
*
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
2012-02-08 17:55:00 +00:00
* @ 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 ());
2012-02-08 17:55:00 +00:00
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' ]);
}
2007-06-11 18:19:05 +00:00
// home telephone number
2012-08-18 15:55:43 +00:00
if ( in_array ( 'homePhone' , $fields ) && ! in_array ( 'homePhone' , $readOnlyFields )) {
2007-06-11 18:19:05 +00:00
$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' ]);
}
2007-06-11 18:19:05 +00:00
// room number
2012-08-18 15:55:43 +00:00
if ( in_array ( 'roomNumber' , $fields ) && ! in_array ( 'roomNumber' , $readOnlyFields )) {
2007-06-11 18:19:05 +00:00
$attributeNames [] = 'roomNumber' ;
if ( isset ( $_POST [ 'inetOrgPerson_roomNumber' ]) && ( $_POST [ 'inetOrgPerson_roomNumber' ] != '' )) {
$attributesNew [ 'roomNumber' ][ 0 ] = $_POST [ 'inetOrgPerson_roomNumber' ];
}
elseif ( isset ( $attributes [ 'roomNumber' ])) unset ( $attributesNew [ 'roomNumber' ]);
}
2008-02-09 18:01:29 +00:00
// l
2012-08-18 15:55:43 +00:00
if ( in_array ( 'location' , $fields ) && ! in_array ( 'location' , $readOnlyFields )) {
2008-02-09 18:01:29 +00:00
$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 )) {
2008-02-09 18:01:29 +00:00
$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 )) {
2008-02-09 18:01:29 +00:00
$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 )) {
2008-02-09 18:01:29 +00:00
$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 )) {
2015-01-23 20:51:15 +00:00
// 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
}
2015-01-23 20:51: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 {
2015-01-23 20:51:15 +00:00
$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' ] != '' )) {
2011-05-01 11:58:34 +00:00
$attributesNew [ 'departmentNumber' ] = preg_split ( '/;[ ]*/' , $_POST [ 'inetOrgPerson_departmentNumber' ]);
2009-02-15 12:54:37 +00:00
}
elseif ( isset ( $attributes [ 'departmentNumber' ])) unset ( $attributesNew [ 'departmentNumber' ]);
}
2011-05-01 11:58:34 +00:00
// initials
2012-08-18 15:55:43 +00:00
if ( in_array ( 'initials' , $fields ) && ! in_array ( 'initials' , $readOnlyFields )) {
2011-05-01 11:58:34 +00:00
$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' ]);
}
2013-03-30 14:22:11 +00:00
// user certificates
if ( in_array ( 'userCertificate' , $fields )) {
$userCertificates = $_SESSION [ inetOrgPerson :: SESS_CERTIFICATES_LIST ];
$userCertificatesAttrName = 'userCertificate;binary' ;
if ( isset ( $attributes [ 'userCertificate' ])) {
$userCertificatesAttrName = 'userCertificate' ;
}
$attributeNames [] = $userCertificatesAttrName ;
if ( sizeof ( $userCertificates ) > 0 ) {
$attributesNew [ $userCertificatesAttrName ] = $userCertificates ;
}
elseif ( isset ( $attributesNew [ $userCertificatesAttrName ])) {
unset ( $attributesNew [ $userCertificatesAttrName ]);
}
}
2014-05-03 09:33:44 +00:00
// 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 ;
}
2015-07-12 12:41:47 +00:00
2015-01-23 20:51:15 +00:00
/**
* Resizes the given image data to the settings provided .
2015-07-12 12:41:47 +00:00
*
2015-01-23 20:51:15 +00:00
* @ 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 ;
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
/**
* 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 );
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
/**
* 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 .
2015-07-12 12:41:47 +00:00
*
2013-03-30 14:22:11 +00:00
* @ 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 ,
);
}
2015-07-12 12:41:47 +00:00
2013-03-30 14:22:11 +00:00
/**
* Invalid AJAX request received .
2015-07-12 12:41:47 +00:00
*
2013-03-30 14:22:11 +00:00
* @ 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 () {
$modules = $_SESSION [ 'config' ] -> get_AccountModules ( $this -> get_scope ());
if ( ! in_array ( 'posixAccount' , $modules )) {
2014-01-06 14:29:09 +00:00
return ! $this -> isAdminReadOnly ( 'userPassword' );
2009-10-10 12:47:40 +00:00
}
return false ;
}
2012-01-15 19:34:14 +00:00
/**
* Specifies if this module supports to force that a user must change his password on next login .
2015-07-12 12:41:47 +00:00
*
2012-01-15 19:34:14 +00:00
* @ return boolean force password change supported
*/
public function supportsForcePasswordChange () {
return false ;
}
2015-07-12 12:41:47 +00:00
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
2012-01-15 19:34:14 +00:00
* @ 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
*/
2012-01-15 19:34:14 +00:00
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
2011-05-16 17:32:32 +00:00
$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 ();
}
2015-07-12 12:41:47 +00:00
2010-11-21 14:43:09 +00:00
/**
* Returns a list of possible managers .
*
* @ return array list of format array ( abstract DN => DN )
*/
private function getManagers () {
if ( $this -> cachedManagers != null ) {
return $this -> cachedManagers ;
}
$dnUsers = searchLDAPByAttribute ( null , null , 'inetOrgPerson' , array ( 'dn' ), array ( 'user' ));
for ( $i = 0 ; $i < sizeof ( $dnUsers ); $i ++ ) {
$dnUsers [ $i ] = $dnUsers [ $i ][ 'dn' ];
}
2011-04-25 17:57:04 +00:00
usort ( $dnUsers , 'compareDN' );
2010-11-21 14:43:09 +00:00
array_unshift ( $dnUsers , '-' );
$this -> cachedManagers = array ();
for ( $i = 0 ; $i < sizeof ( $dnUsers ); $i ++ ) {
$this -> cachedManagers [ getAbstractDN ( $dnUsers [ $i ])] = $dnUsers [ $i ];
}
2015-07-12 12:41:47 +00:00
return $this -> cachedManagers ;
2010-11-21 14:43:09 +00:00
}
2015-07-12 12:41:47 +00:00
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 ));
}
2015-07-12 12:41:47 +00:00
2014-01-06 14:29:09 +00:00
/**
* Returns if the attribute is read - only in admin interface .
2015-07-12 12:41:47 +00:00
*
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 );
}
2015-07-12 12:41:47 +00:00
2014-01-06 14:29:09 +00:00
/**
* Adds a simple read - only field to the given container .
2015-07-12 12:41:47 +00:00
*
2014-01-06 14:29:09 +00:00
* @ param htmlTable $container parent container
* @ param String $attrName attribute name
* @ param String $label field label
*/
private function addSimpleReadOnlyField ( & $container , $attrName , $label ) {
$val = '' ;
if ( ! empty ( $this -> attributes [ $attrName ][ 0 ])) {
$values = $this -> attributes [ $attrName ];
array_map ( 'htmlspecialchars' , $values );
$val = implode ( '<br>' , $values );
}
$labelBox = new htmlOutputText ( $label );
if ( ! empty ( $this -> attributes [ $attrName ]) && ( sizeof ( $this -> attributes [ $attrName ]) > 1 )) {
$labelBox -> alignment = htmlElement :: ALIGN_TOP ;
}
$container -> addElement ( $labelBox );
$container -> addElement ( new htmlOutputText ( $val , false ), true );
}
2015-07-12 12:41:47 +00:00
2014-01-25 14:14:46 +00:00
/**
* Returns a list of configuration options .
2015-07-12 12:41:47 +00:00
*
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
2015-07-12 12:41:47 +00:00
*
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
$confActiveUnixModules = $_SESSION [ 'conf_config' ] -> get_AccountModules ( 'user' );
if ( in_array ( 'host' , $_SESSION [ 'conf_config' ] -> get_ActiveTypes ())) {
$confActiveUnixModules = array_merge ( $confActiveUnixModules , $_SESSION [ 'conf_config' ] -> get_AccountModules ( 'host' ));
}
if ( in_array ( 'group' , $_SESSION [ 'conf_config' ] -> get_ActiveTypes ())) {
$confActiveUnixModules = array_merge ( $confActiveUnixModules , $_SESSION [ 'conf_config' ] -> get_AccountModules ( 'group' ));
}
if ( ! in_array ( 'posixAccount' , $confActiveUnixModules ) && ! in_array ( 'posixGroup' , $confActiveUnixModules )) {
$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 ;
2015-01-23 20:51:15 +00:00
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 .
2015-07-12 12:41:47 +00:00
*
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 ];
}
2015-07-12 12:41:47 +00:00
2014-04-21 19:21:47 +00:00
/**
* Returns if the Unix module is also active .
2015-07-12 12:41:47 +00:00
*
2014-04-21 19:21:47 +00:00
* @ return boolean Unix is active
*/
private function isUnixActive () {
if ( ! isset ( $_SESSION [ 'config' ])) {
return false ;
}
$modules = $_SESSION [ 'config' ] -> get_AccountModules ( $this -> get_scope ());
return in_array ( 'posixAccount' , $modules );
}
2015-07-12 12:41:47 +00:00
2004-03-09 12:03:39 +00:00
}
2003-12-12 00:52:35 +00:00
?>