2003-12-12 00:52:35 +00:00
< ? php
/*
$Id $
This code is part of LDAP Account Manager ( http :// www . sourceforge . net / projects / lam )
Copyright ( C ) 2003 Tilo Lutz
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
/**
* This class contains all account LDAP attributes
* and funtioncs required to deal with inetOrgPerson .
*
* @ package modules
2003-12-12 00:52:35 +00:00
*/
2004-06-08 18:54:37 +00:00
class inetOrgPerson extends baseModule {
2004-06-13 19:58:58 +00:00
2004-06-24 09:51:12 +00:00
/**
* Creates a new inetOrgPerson object .
*/
function inetOrgPerson ( $scope ) {
2004-09-26 13:48:52 +00:00
// call parent constructor
parent :: baseModule ( $scope );
2004-06-24 09:51:12 +00:00
}
2004-09-26 13:48:52 +00:00
/** this functin fills the error message array with messages
**/
function load_Messages () {
$this -> messages [ 'host' ][ 0 ] = array ( 'ERROR' , _ ( 'Unix workstations' ), _ ( 'Unix workstations is invalid.' ));
2004-10-11 18:06:53 +00:00
$this -> messages [ 'givenName' ][ 0 ] = array ( 'ERROR' , _ ( 'Given name' ), _ ( 'Given name contains invalid characters!' ));
$this -> messages [ 'givenName' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_lastName' ), _ ( 'Given name contains invalid characters!' ));
$this -> messages [ 'surname' ][ 0 ] = array ( 'ERROR' , _ ( 'Surname' ), _ ( 'Surname contains invalid characters!' ));
$this -> messages [ 'surname' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_firstName' ), _ ( 'Surname contains invalid characters!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'telephoneNumber' ][ 0 ] = array ( 'ERROR' , _ ( 'Telephone number' ), _ ( 'Please enter a valid telephone number!' ));
2004-10-11 18:06:53 +00:00
$this -> messages [ 'telephoneNumber' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_telephone' ), _ ( 'Please enter a valid telephone number!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'mobileTelephone' ][ 0 ] = array ( 'ERROR' , _ ( 'Mobile number' ), _ ( 'Please enter a valid mobile number!' ));
2004-10-11 18:06:53 +00:00
$this -> messages [ 'mobileTelephone' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_mobile' ), _ ( 'Please enter a valid mobile number!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'facsimileNumber' ][ 0 ] = array ( 'ERROR' , _ ( 'Fax number' ), _ ( 'Please enter a valid fax number!' ));
2004-10-11 18:06:53 +00:00
$this -> messages [ 'facsimileNumber' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_fax' ), _ ( 'Please enter a valid fax number!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'email' ][ 0 ] = array ( 'ERROR' , _ ( 'eMail address' ), _ ( 'Please enter a valid eMail address!' ));
2004-10-11 18:06:53 +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-11 18:06:53 +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-11 18:06:53 +00:00
$this -> messages [ 'postalAddress' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_address' ), _ ( 'Please enter a valid postal 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-11 18:06:53 +00:00
$this -> messages [ 'postalCode' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_postalCode' ), _ ( 'Please enter a valid postal code!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'title' ][ 0 ] = array ( 'ERROR' , _ ( 'Title' ), _ ( 'Please enter a valid title!' ));
2004-10-11 18:06:53 +00:00
$this -> messages [ 'title' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_title' ), _ ( 'Please enter a valid 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-11 18:06:53 +00:00
$this -> messages [ 'employeeType' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s: inetOrgPerson_type' ), _ ( 'Please enter a valid employee type!' ));
2004-09-26 13:48:52 +00:00
}
2004-06-13 19:58:58 +00:00
/**
* Returns meta data that is interpreted by parent class
*
* @ return array array with meta data
*/
function get_metaData () {
$return = array ();
// manages user accounts
$return [ " account_types " ] = array ( " user " );
2004-06-14 16:05:36 +00:00
// alias name
$return [ " alias " ] = _ ( 'Personal' );
2004-10-06 18:17:22 +00:00
// RDN attribute
$return [ " RDN " ] = array ( " cn " => " low " );
2004-06-20 17:32:02 +00:00
// module dependencies
$return [ 'dependencies' ] = array ( 'depends' => array ( 'posixAccount' ), 'conflicts' => array ( 'account' ));
2004-07-01 15:54:33 +00:00
// profile elements
$return [ 'profile_options' ] = array (
array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Job title' ) . " : " ),
1 => array ( 'kind' => 'input' , 'name' => 'inetOrgPerson_title' , 'type' => 'text' , 'size' => '30' , 'maxlength' => '255' ),
2 => array ( 'kind' => 'help' , 'value' => 'TODO' )),
array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Employee type' ) . " : " ),
1 => array ( 'kind' => 'input' , 'name' => 'inetOrgPerson_employeeType' , 'type' => 'text' , 'size' => '30' , 'maxlength' => '255' ),
2 => array ( 'kind' => 'help' , 'value' => 'TODO' ))
);
// profile checks
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'inetOrgPerson_title' ] = array (
'type' => 'ext_preg' ,
'regex' => 'title' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'title' ][ 0 ]);
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'inetOrgPerson_employeeType' ] = array (
'type' => 'ext_preg' ,
'regex' => 'employeeType' ,
'error_message' => $this -> messages [ 'employeeType' ][ 0 ]);
2004-10-11 18:06:53 +00:00
$return [ 'upload_columns' ] = array (
array (
2004-10-15 14:52:02 +00:00
'name' => 'inetOrgPerson_cn' ,
'description' => _ ( 'Common name' ),
'help' => 'cn' ,
'example' => _ ( 'Steve Miller' ),
'default' => '<i><inetOrgPerson_firstName> <inetOrgPerson_lastName></i>'
),
array (
2004-10-11 18:06:53 +00:00
'name' => 'inetOrgPerson_firstName' ,
'description' => _ ( 'First Name' ),
'help' => 'givenName' ,
'example' => _ ( 'Steve' )
),
array (
'name' => 'inetOrgPerson_lastName' ,
'description' => _ ( 'Last Name' ),
'help' => 'sn' ,
'example' => _ ( 'Miller' ),
'required' => true
),
array (
'name' => 'inetOrgPerson_description' ,
'description' => _ ( 'Desription' ),
'help' => 'description' ,
'example' => _ ( 'Temp, contract until december' )
),
array (
'name' => 'inetOrgPerson_title' ,
'description' => _ ( 'Job title' ),
'help' => 'title' ,
'example' => _ ( 'President' )
),
array (
'name' => 'inetOrgPerson_type' ,
'description' => _ ( 'Employee type' ),
'help' => 'employeeType' ,
'example' => _ ( 'Worker' )
),
array (
'name' => 'inetOrgPerson_street' ,
'description' => _ ( 'Street' ),
'help' => 'street' ,
'example' => _ ( 'Mystreetname 42' )
),
array (
'name' => 'inetOrgPerson_postalCode' ,
'description' => _ ( 'Postal code' ),
'help' => 'postalCode' ,
'example' => _ ( '12345' )
),
array (
'name' => 'inetOrgPerson_address' ,
'description' => _ ( 'Postal address' ),
'help' => 'postalAddress' ,
'example' => _ ( 'Mycity' )
),
array (
'name' => 'inetOrgPerson_telephone' ,
'description' => _ ( 'Telephone number' ),
'help' => 'telephoneNumber' ,
'example' => _ ( '123-123-1234' )
),
array (
'name' => 'inetOrgPerson_mobile' ,
'description' => _ ( 'Mobile number' ),
'help' => 'mobileTelephoneNumber' ,
'example' => _ ( '123-123-1234' )
),
array (
'name' => 'inetOrgPerson_fax' ,
'description' => _ ( 'Fax number' ),
'help' => 'facsimileTelephoneNumber' ,
'example' => _ ( '123-123-1234' )
),
array (
'name' => 'inetOrgPerson_email' ,
'description' => _ ( 'eMail address' ),
'help' => 'mail' ,
'example' => _ ( 'user@company.com' )
)
);
// TODO unix workstations for upload
2004-08-17 15:16:17 +00:00
// available PDF fields
$return [ 'PDF_fields' ] = array ( 'description' ,
'host' ,
'title' ,
'givenName' ,
'sn' ,
'employeeType' ,
'street' ,
'postalCode' ,
'postalAddress' ,
'telephoneNumber' ,
'mobileTelephoneNumber' ,
'facimilieTelefonNumber' ,
'mail' );
2004-09-08 17:39:06 +00:00
// help Entries
$return [ 'help' ] = array ( 'description' => array ( " ext " => " FALSE " , " Headline " => _ ( " Gecos " ), " Text " => _ ( " Host description. If left empty host name will be used. " )),
'title' => array ( " ext " => " FALSE " , " Headline " => _ ( " Title " ), " Text " => _ ( " Title of user, Mr., Ms., ... " )),
'givenName' => array ( " ext " => " FALSE " , " Headline " => _ ( " Given name " ), " Text " => _ ( " Given name of user. Only letters, - and spaces are allowed. " )),
'sn' => array ( " ext " => " FALSE " , " Headline " => _ ( " Surname " ), " Text " => _ ( " Surname of user. Only letters, - and spaces are allowed. " )),
'employeeType' => array ( " ext " => " FALSE " , " Headline " => _ ( " Employee type " ), " Text " => _ ( " Employee type: worker, student, nurse, ... " )),
'street' => array ( " ext " => " FALSE " , " Headline " => _ ( " Street " ), " Text " => _ ( " Street " )),
'postalCode' => array ( " ext " => " FALSE " , " Headline " => _ ( " Postal code " ), " Text " => _ ( " Postal code " )),
'postalAddress' => array ( " ext " => " FALSE " , " Headline " => _ ( " Postal address " ), " Text " => _ ( " Postal address, city " )),
'telephoneNumber' => array ( " ext " => " FALSE " , " Headline " => _ ( " Telephone number " ), " Text " => _ ( " Telephone number " )),
'mobileTelephoneNumber' => array ( " ext " => " FALSE " , " Headline " => _ ( " Mobile number " ), " Text " => _ ( " Mobile number " )),
'facsimileTelephoneNumber' => array ( " ext " => " FALSE " , " Headline " => _ ( " Fax number " ), " Text " => _ ( " Fax number " )),
'mail' => array ( " ext " => " FALSE " , " Headline " => _ ( " eMail address " ), " Text " => _ ( " eMail address " )));
2004-08-17 15:16:17 +00:00
2004-06-13 19:58:58 +00:00
return $return ;
}
2004-07-02 12:09:06 +00:00
/**
* Initializes the module in its accountContainer
*
* @ param string $base the name of account_container in session
*/
2004-06-08 18:54:37 +00:00
function init ( $base ) {
2004-09-01 20:53:06 +00:00
// call parent init
parent :: init ( $base );
2003-12-12 00:52:35 +00:00
}
2003-12-27 11:21:00 +00:00
/* This function returns true if all required attributes from other
* modules are set . This is required to prevent undefined states
*/
2003-12-20 19:24:01 +00:00
function module_ready () {
return true ;
}
2004-02-09 18:11:01 +00:00
/* This functions return true
* if all needed settings are done
*/
function module_complete () {
if ( ! $this -> module_ready ()) return false ;
if ( $this -> attributes [ 'sn' ][ 0 ] == '' ) return false ;
if ( $this -> attributes [ 'givenName' ][ 0 ] == '' ) return false ;
return true ;
}
2003-12-27 11:21:00 +00:00
/* This function returns a list of all html - pages in module
* This is usefull for mass upload and pdf - files
* because lam can walk trough all pages itself and do some
* error checkings
*/
function pages () {
return array ( 'attributes' );
}
2003-12-12 00:52:35 +00:00
/* This function loads all attributes into the object
* $attr is an array as it ' s retured from ldap_get_attributes
*/
function load_attributes ( $attr ) {
2004-09-26 13:48:52 +00:00
$this -> load_ldap_attributes ( $attr );
2003-12-12 18:21:15 +00:00
return 0 ;
2003-12-12 00:52:35 +00:00
}
2003-12-27 11:21:00 +00:00
/* This function returns an array with 4 entries :
* array ( DN1 ( 'add' => array ( $attr ), 'remove' => array ( $attr ), 'modify' => array ( $attr ), 'lamdaemon' => array ( cmds )), DN2 .... )
2003-12-12 00:52:35 +00:00
* 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
* add are attributes which have to be added to ldap entry
* remove are attributes which have to be removed from ldap entry
2003-12-27 11:21:00 +00:00
* lamdaemon are lamdaemon commands to modify homedir , quotas , ...
2003-12-12 00:52:35 +00:00
*/
function save_attributes () {
2003-12-27 11:21:00 +00:00
// Get easy attributes
2003-12-20 19:24:01 +00:00
$return = $_SESSION [ $this -> base ] -> save_module_attributes ( $this -> attributes , $this -> orig );
2003-12-27 11:21:00 +00:00
// unset password. First we hanlde userPassword with posixAccount, second we hanlde it completly separat
// because it en/decrypted in session
2003-12-20 21:42:52 +00:00
if ( isset ( $return [ $_SESSION [ $this -> base ] -> dn ][ 'modify' ][ 'userPassword' ]))
unset ( $return [ $_SESSION [ $this -> base ] -> dn ][ 'modify' ][ 'userPassword' ]);
2003-12-27 11:21:00 +00:00
// Return attributes
2003-12-15 15:11:44 +00:00
return $return ;
2003-12-12 00:52:35 +00:00
}
2003-12-30 15:36:30 +00:00
/* Write variables into object and do some regexp checks
2003-12-12 00:52:35 +00:00
*/
2003-12-30 15:36:30 +00:00
function delete_attributes ( $post ) {
2004-01-10 11:47:48 +00:00
return 0 ;
2003-12-30 15:36:30 +00:00
}
2004-10-16 19:51:36 +00:00
function proccess_attributes ( $post ) {
2003-12-30 15:36:30 +00:00
// Load attributes
$this -> attributes [ 'description' ][ 0 ] = $post [ 'description' ];
$this -> attributes [ 'sn' ][ 0 ] = $post [ 'sn' ];
$this -> attributes [ 'givenName' ][ 0 ] = $post [ 'givenName' ];
$this -> attributes [ 'title' ][ 0 ] = $post [ 'title' ];
$this -> attributes [ 'mail' ][ 0 ] = $post [ 'mail' ];
$this -> attributes [ 'telephoneNumber' ][ 0 ] = $post [ 'telephoneNumber' ];
$this -> attributes [ 'mobileTelephoneNumber' ][ 0 ] = $post [ 'mobileTelephoneNumber' ];
$this -> attributes [ 'facsimileTelephoneNumber' ][ 0 ] = $post [ 'facsimileTelephoneNumber' ];
$this -> attributes [ 'street' ][ 0 ] = $post [ 'street' ];
$this -> attributes [ 'postalCode' ][ 0 ] = $post [ 'postalCode' ];
$this -> attributes [ 'postalAddress' ][ 0 ] = $post [ 'postalAddress' ];
$this -> attributes [ 'employeeType' ][ 0 ] = $post [ 'employeeType' ];
// handle host-attribute in on epice because it's not set by default
if ( isset ( $this -> attributes [ 'host' ])) {
$host = $post [ 'host' ];
2004-09-26 13:48:52 +00:00
if ( ! get_preg ( $host , 'unixhost' ))
2004-10-16 19:51:36 +00:00
$triggered_messages [ 'host' ][] = $this -> messages [ 'host' ][ 0 ];
2003-12-30 15:36:30 +00:00
$hosts = explode ( " " , $host );
$this -> attributes [ 'host' ] = array ();
foreach ( $hosts as $host )
if ( $host != " " ) $this -> attributes [ 'host' ][] = $host ;
}
// Do some regex-checks and return error if attributes are set to wrong values
2004-10-16 19:51:36 +00:00
if ( ! get_preg ( $this -> attributes [ 'givenName' ][ 0 ], 'realname' )) $triggered_messages [ 'givenName' ][] = $this -> messages [ 'givenName' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'sn' ][ 0 ], 'realname' )) $triggered_messages [ 'sn' ][] = $this -> messages [ 'surname' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'telephoneNumber' ][ 0 ], 'telephone' )) $triggered_messages [ 'telephoneNumber' ][] = $this -> messages [ 'telephoneNumber' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'mobileTelephoneNumber' ][ 0 ], 'telephone' )) $triggered_messages [ 'mobileTelephoneNumber' ][] = $this -> messages [ 'mobileTelephone' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'facsimileTelephoneNumber' ][ 0 ], 'telephone' )) $triggered_messages [ 'facsimileTelephoneNumber' ][] = $this -> messages [ 'facsimileNumber' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'mail' ][ 0 ], 'email' )) $triggered_messages [ 'mail' ][] = $this -> messages [ 'email' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'street' ][ 0 ], 'street' )) $triggered_messages [ 'street' ][] = $this -> messages [ 'street' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'postalAddress' ][ 0 ], 'postalAddress' )) $triggered_messages [ 'postalAdress' ][] = $this -> messages [ 'postalAddress' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'personal_postalCode' ][ 0 ], 'postalCode' )) $triggered_messages [ 'personal_postalCode' ][] = $this -> messages [ 'postalCode' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'title' ][ 0 ], 'title' )) $triggered_messages [ 'title' ][] = $this -> messages [ 'title' ][ 0 ];
if ( ! get_preg ( $this -> attributes [ 'employeeType' ][ 0 ], 'employeeType' )) $triggered_messages [ 'employeeType' ][] = $this -> messages [ 'employeeType' ][ 0 ];
2003-12-30 15:36:30 +00:00
// Return error-messages
2004-10-16 19:51:36 +00:00
if ( is_array ( $triggered_messages )) return $triggered_messages ;
2003-12-30 15:36:30 +00:00
return 0 ;
2003-12-12 00:52:35 +00:00
}
/* This function will create the html - page
* to show a page with all attributes .
* It will output a complete html - table
*/
2004-10-16 19:51:36 +00:00
function display_html_attributes ( $post ) {
2004-01-18 12:52:52 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Description' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'description' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'description' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'description' ));
2003-12-20 19:24:01 +00:00
if ( isset ( $this -> attributes [ 'host' ])) {
if ( is_array ( $this -> attributes [ 'host' ]))
2004-01-18 12:52:52 +00:00
foreach ( $this -> attributes [ 'host' ] as $host ) $hostvalue .= $host . " " ;
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Unix workstations' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'host' , 'type' => 'text' , 'size' => '20' ,
'maxlength' => '255' , 'value' => $hostvalues ),
2 => array ( 'kind' => 'help' , 'value' => 'host' ));
2003-12-20 19:24:01 +00:00
}
2004-07-01 15:54:33 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Job title' ) ),
2004-01-18 12:52:52 +00:00
1 => array ( 'kind' => 'input' , 'name' => 'title' , 'type' => 'text' , 'size' => '10' ,
2004-07-01 15:54:33 +00:00
'value' => $this -> attributes [ 'title' ][ 0 ] ),
2004-01-18 12:52:52 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'title' ));
2004-10-16 19:51:36 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'First name' ) . '*' ),
1 => array ( 'kind' => 'input' , 'name' => 'givenName' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'givenName' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'givenName' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Last name' ) . '*' ),
1 => array ( 'kind' => 'input' , 'name' => 'sn' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'sn' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'sn' ));
2004-01-18 12:52:52 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Employee type' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'employeeType' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'employeeType' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'employeeType' ));
2004-10-16 19:51:36 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Street' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'street' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'street' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'street' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Postal code' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'postalCode' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'postalCode' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'postalCode' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Postal address' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'postalAddress' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'postalAddress' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'postalAddress' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Telephone number' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'telephoneNumber' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'telephoneNumber' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'telephoneNumber' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Mobile number' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'mobileTelephoneNumber' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'mobileTelephoneNumber' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'mobileTelephoneNumber' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Fax number' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'facsimileTelephoneNumber' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'facsimileTelephoneNumber' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'facsimileTelephoneNumber' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'eMail address' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'mail' , 'type' => 'text' , 'size' => '30' ,
'maxlength' => '255' , 'value' => $this -> attributes [ 'mail' ][ 0 ] ),
2 => array ( 'kind' => 'help' , 'value' => 'mail' ));
2004-01-18 12:52:52 +00:00
return $return ;
2003-12-12 00:52:35 +00:00
}
2004-10-16 19:51:36 +00:00
function display_html_delete ( $post ) {
2003-12-30 15:36:30 +00:00
return 0 ;
}
2004-03-09 12:03:39 +00:00
2004-08-17 15:16:17 +00:00
/*
* ( non - PHPDoc )
* @ see baseModule #get_pdfEntries
*/
2004-05-29 19:20:28 +00:00
function get_pdfEntries ( $account_type = " user " ) {
return array ( 'inetOrgPerson_description' => array ( '<block><key>' . _ ( 'Description' ) . '</key><value>' . $this -> attributes [ 'description' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_host' => array ( '<block><key>' . _ ( 'Unix workstations' ) . '</key><value>' . $this -> attributes [ 'host' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_title' => array ( '<block><key>' . _ ( 'Title' ) . '</key><value>' . $this -> attributes [ 'title' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_givenName' => array ( '<block><key>' . _ ( 'First name' ) . '</key><value>' . $this -> attributes [ 'givenName' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_sn' => array ( '<block><key>' . _ ( 'Last name' ) . '</key><value>' . $this -> attributes [ 'sn' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_employeeType' => array ( '<block><key>' . _ ( 'Employee type' ) . '</key><value>' . $this -> attributes [ 'employeeType' ][ 0 ]),
'inetOrgPerson_street' => array ( '<block><key>' . _ ( 'Street' ) . '</key><value>' . $this -> attributes [ 'street' ] . '</value></block>' ),
'inetOrgPerson_postalCode' => array ( '<block><key>' . _ ( 'Postal code' ) . '</key><value>' . $this -> attributes [ 'postalCode' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_postalAddress' => array ( '<block><key>' . _ ( 'Postal address' ) . '</key><value>' . $this -> attributes [ 'postalAddress' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_telephoneNumber' => array ( '<block><key>' . _ ( 'Telephone number' ) . '</key><value>' . $this -> attributes [ 'telephoneNumber' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_mobileTelephoneNumber' => array ( '<block><key>' . _ ( 'Mobile number' ) . '</key><value>' . $this -> attributes [ 'mobileTelephoneNumber' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_facimileTelefonNumber' => array ( '<block><key>' . _ ( 'Fax number' ) . '</key><value>' . $this -> attributes [ 'facsimileTelephoneNumber' ][ 0 ] . '</value></block>' ),
'inetOrgPerson_mail' => array ( '<block><key>' . _ ( 'eMail address' ) . '</key><value>' . $this -> attributes [ 'mail' ][ 0 ] . '</value></block>' ));
2004-05-24 21:39:57 +00:00
}
2004-03-14 17:33:05 +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 $partialAccounts list of hash arrays ( name => value ) which are later added to LDAP
* @ param array $ids list of IDs for column position ( e . g . " posixAccount_uid " => 5 )
* @ return array list of error messages if any
*/
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts ) {
2004-10-16 19:51:36 +00:00
$triggered_messages = array ();
2004-10-11 18:06:53 +00:00
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
if ( ! in_array ( " inetOrgPerson " , $partialAccounts [ $i ][ 'objectClass' ])) $partialAccounts [ $i ][ 'objectClass' ][] = " inetOrgPerson " ;
// last name
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_lastName' ]], 'realname' )) {
$partialAccounts [ $i ][ 'sn' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_lastName' ]];
}
else {
$errMsg = $this -> messages [ 'surname' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// first name
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_firstName' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_firstName' ]], 'realname' )) {
$partialAccounts [ $i ][ 'givenName' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_firstName' ]];
}
else {
$errMsg = $this -> messages [ 'givenName' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// description
if ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_description' ]] != " " ) {
$partialAccounts [ $i ][ 'description' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_description' ]];
}
else {
if ( $partialAccounts [ $i ][ 'givenName' ] != " " ) {
$partialAccounts [ $i ][ 'description' ] = $partialAccounts [ $i ][ 'givenName' ] . " " . $partialAccounts [ $i ][ 'sn' ];
}
else {
$partialAccounts [ $i ][ 'description' ] = $partialAccounts [ $i ][ 'sn' ];
}
}
// title
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_title' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_title' ]], 'title' )) {
$partialAccounts [ $i ][ 'title' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_title' ]];
}
else {
$errMsg = $this -> messages [ 'title' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// employee type
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_type' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_type' ]], 'employeeType' )) {
$partialAccounts [ $i ][ 'employeeType' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_type' ]];
}
else {
$errMsg = $this -> messages [ 'employeeType' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// street
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_street' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_street' ]], 'street' )) {
$partialAccounts [ $i ][ 'street' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_street' ]];
}
else {
$errMsg = $this -> messages [ 'street' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// postal code
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_postalCode' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_postalCode' ]], 'postalCode' )) {
$partialAccounts [ $i ][ 'postalCode' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_postalCode' ]];
}
else {
$errMsg = $this -> messages [ 'postalCode' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// postal address
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_address' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_address' ]], 'postalAddress' )) {
$partialAccounts [ $i ][ 'postalAddress' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_address' ]];
}
else {
$errMsg = $this -> messages [ 'postalAddress' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// telephone
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_telephone' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_telephone' ]], 'telephone' )) {
$partialAccounts [ $i ][ 'telephoneNumber' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_telephone' ]];
}
else {
$errMsg = $this -> messages [ 'telephone' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// mobile
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_mobile' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_mobile' ]], 'telephone' )) {
$partialAccounts [ $i ][ 'mobiletelephoneNumber' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_mobile' ]];
}
else {
$errMsg = $this -> messages [ 'mobileTelephone' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// facsimile
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_fax' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_fax' ]], 'telephone' )) {
$partialAccounts [ $i ][ 'facsimileTelephoneNumber' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_fax' ]];
}
else {
$errMsg = $this -> messages [ 'facsimileNumber' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
// eMail
if (( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_email' ]] != " " ) && get_preg ( $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_email' ]], 'email' )) {
$partialAccounts [ $i ][ 'mail' ] = $rawAccounts [ $i ][ $ids [ 'inetOrgPerson_email' ]];
}
else {
$errMsg = $this -> messages [ 'email' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +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 [ 'email' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2004-10-16 19:51:36 +00:00
$triggered_messages [] = $errMsg ;
2004-10-11 18:06:53 +00:00
}
}
else {
if ( $partialAccounts [ $i ][ 'givenName' ] != " " ) {
$partialAccounts [ $i ][ 'cn' ] = $partialAccounts [ $i ][ 'givenName' ] . " " . $partialAccounts [ $i ][ 'sn' ];
}
else {
$partialAccounts [ $i ][ 'cn' ] = $partialAccounts [ $i ][ 'sn' ];
}
}
}
2004-10-16 19:51:36 +00:00
return $triggered_messages ;
2004-10-11 18:06:53 +00:00
}
2004-03-09 12:03:39 +00:00
}
2003-12-12 00:52:35 +00:00
?>