moved function to check config options to baseModule

This commit is contained in:
Roland Gruber 2009-10-03 17:48:37 +00:00
parent 7487459885
commit fb91567007
2 changed files with 109 additions and 106 deletions

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 - 2008 Roland Gruber Copyright (C) 2003 - 2009 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -1315,6 +1315,28 @@ abstract class baseModule {
} }
return null; return null;
} }
// helper functions
/**
* Returns if the given configuration option is set.
* This function returns false if the configuration options cannot be read.
*
* @param String $optionName name of the option
* @return boolean true if option is set
*/
protected function isBooleanConfigOptionSet($optionName) {
// abort if configuration is not available
if (!isset($this->moduleSettings) || !is_array($this->moduleSettings)) {
return false;
}
if (isset($this->moduleSettings[$optionName][0]) && ($this->moduleSettings[$optionName][0] == 'true')) {
return true;
}
return false;
}
} }

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 - 2006 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
2005 - 2008 Roland Gruber 2005 - 2009 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -157,31 +157,31 @@ class inetOrgPerson extends baseModule {
'departmentNumber' => _('Department(s)')); 'departmentNumber' => _('Department(s)'));
// profile elements // profile elements
$return['profile_options'] = array(); $return['profile_options'] = array();
if (!$this->configOptionSet('inetOrgPerson_hideLocation')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
$return['profile_options'][] = array( $return['profile_options'][] = array(
array('kind' => 'text', 'text' => _('Location') . ":"), array('kind' => 'text', 'text' => _('Location') . ":"),
array('kind' => 'input', 'name' => 'inetOrgPerson_l', 'type' => 'text', 'size' => '30', 'maxlength' => '255'), array('kind' => 'input', 'name' => 'inetOrgPerson_l', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
array('kind' => 'help', 'value' => 'l')); array('kind' => 'help', 'value' => 'l'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideDepartments')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$return['profile_options'][] = array( $return['profile_options'][] = array(
array('kind' => 'text', 'text' => _('Department(s)') . ":"), array('kind' => 'text', 'text' => _('Department(s)') . ":"),
array('kind' => 'input', 'name' => 'inetOrgPerson_departmentNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '255'), array('kind' => 'input', 'name' => 'inetOrgPerson_departmentNumber', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
array('kind' => 'help', 'value' => 'departmentNumber')); array('kind' => 'help', 'value' => 'departmentNumber'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideState')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
$return['profile_options'][] = array( $return['profile_options'][] = array(
array('kind' => 'text', 'text' => _('State') . ":"), array('kind' => 'text', 'text' => _('State') . ":"),
array('kind' => 'input', 'name' => 'inetOrgPerson_st', 'type' => 'text', 'size' => '30', 'maxlength' => '255'), array('kind' => 'input', 'name' => 'inetOrgPerson_st', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
array('kind' => 'help', 'value' => 'st')); array('kind' => 'help', 'value' => 'st'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideJobTitle')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$return['profile_options'][] = array( $return['profile_options'][] = array(
array('kind' => 'text', 'text' => _('Job title') . ":"), array('kind' => 'text', 'text' => _('Job title') . ":"),
array('kind' => 'input', 'name' => 'inetOrgPerson_title', 'type' => 'text', 'size' => '30', 'maxlength' => '255'), array('kind' => 'input', 'name' => 'inetOrgPerson_title', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
array('kind' => 'help', 'value' => 'title')); array('kind' => 'help', 'value' => 'title'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideEmployeeType')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$return['profile_options'][] = array( $return['profile_options'][] = array(
array('kind' => 'text', 'text' => _('Employee type') . ":"), array('kind' => 'text', 'text' => _('Employee type') . ":"),
array('kind' => 'input', 'name' => 'inetOrgPerson_employeeType', 'type' => 'text', 'size' => '30', 'maxlength' => '255'), array('kind' => 'input', 'name' => 'inetOrgPerson_employeeType', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
@ -296,7 +296,7 @@ class inetOrgPerson extends baseModule {
'required' => true 'required' => true
) )
); );
if (!$this->configOptionSet('inetOrgPerson_hideDescription')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_description', 'name' => 'inetOrgPerson_description',
'description' => _('Description'), 'description' => _('Description'),
@ -304,7 +304,7 @@ class inetOrgPerson extends baseModule {
'example' => _('Temp, contract until december') 'example' => _('Temp, contract until december')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideJobTitle')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_title', 'name' => 'inetOrgPerson_title',
'description' => _('Job title'), 'description' => _('Job title'),
@ -312,7 +312,7 @@ class inetOrgPerson extends baseModule {
'example' => _('President') 'example' => _('President')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideEmployeeType')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_type', 'name' => 'inetOrgPerson_type',
'description' => _('Employee type'), 'description' => _('Employee type'),
@ -320,7 +320,7 @@ class inetOrgPerson extends baseModule {
'example' => _('Temp') 'example' => _('Temp')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideManager')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_manager', 'name' => 'inetOrgPerson_manager',
'description' => _('Manager'), 'description' => _('Manager'),
@ -328,7 +328,7 @@ class inetOrgPerson extends baseModule {
'example' => _('uid=smiller,ou=People,dc=company,dc=com') 'example' => _('uid=smiller,ou=People,dc=company,dc=com')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideBusinessCategory')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_businessCategory', 'name' => 'inetOrgPerson_businessCategory',
'description' => _('Business category'), 'description' => _('Business category'),
@ -336,7 +336,7 @@ class inetOrgPerson extends baseModule {
'example' => _('Administration') 'example' => _('Administration')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideStreet')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_street', 'name' => 'inetOrgPerson_street',
'description' => _('Street'), 'description' => _('Street'),
@ -344,7 +344,7 @@ class inetOrgPerson extends baseModule {
'example' => _('Mystreetname 42') 'example' => _('Mystreetname 42')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalCode')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_postalCode', 'name' => 'inetOrgPerson_postalCode',
'description' => _('Postal code'), 'description' => _('Postal code'),
@ -352,7 +352,7 @@ class inetOrgPerson extends baseModule {
'example' => _('GB-12345') 'example' => _('GB-12345')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_address', 'name' => 'inetOrgPerson_address',
'description' => _('Postal address'), 'description' => _('Postal address'),
@ -360,7 +360,7 @@ class inetOrgPerson extends baseModule {
'example' => _('Mycity') 'example' => _('Mycity')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostOfficeBox')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_postOfficeBox', 'name' => 'inetOrgPerson_postOfficeBox',
'description' => _('Post office box'), 'description' => _('Post office box'),
@ -368,7 +368,7 @@ class inetOrgPerson extends baseModule {
'example' => _('12345') 'example' => _('12345')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_telephone', 'name' => 'inetOrgPerson_telephone',
'description' => _('Telephone number'), 'description' => _('Telephone number'),
@ -376,7 +376,7 @@ class inetOrgPerson extends baseModule {
'example' => _('123-123-1234') 'example' => _('123-123-1234')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_homePhone', 'name' => 'inetOrgPerson_homePhone',
'description' => _('Home telephone number'), 'description' => _('Home telephone number'),
@ -384,7 +384,7 @@ class inetOrgPerson extends baseModule {
'example' => _('123-124-1234') 'example' => _('123-124-1234')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideMobileNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_mobile', 'name' => 'inetOrgPerson_mobile',
'description' => _('Mobile number'), 'description' => _('Mobile number'),
@ -392,7 +392,7 @@ class inetOrgPerson extends baseModule {
'example' => _('123-123-1235') 'example' => _('123-123-1235')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideFaxNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_fax', 'name' => 'inetOrgPerson_fax',
'description' => _('Fax number'), 'description' => _('Fax number'),
@ -400,7 +400,7 @@ class inetOrgPerson extends baseModule {
'example' => _('123-123-1236') 'example' => _('123-123-1236')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideEMailAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_email', 'name' => 'inetOrgPerson_email',
'description' => _('eMail address'), 'description' => _('eMail address'),
@ -408,7 +408,7 @@ class inetOrgPerson extends baseModule {
'example' => _('user@company.com') 'example' => _('user@company.com')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideRoomNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_roomNumber', 'name' => 'inetOrgPerson_roomNumber',
'description' => _('Room number'), 'description' => _('Room number'),
@ -416,7 +416,7 @@ class inetOrgPerson extends baseModule {
'example' => 'A 2.24' 'example' => 'A 2.24'
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideDepartments')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_departmentNumber', 'name' => 'inetOrgPerson_departmentNumber',
'description' => _('Department(s)'), 'description' => _('Department(s)'),
@ -424,7 +424,7 @@ class inetOrgPerson extends baseModule {
'example' => _('Administration') 'example' => _('Administration')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideLocation')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_l', 'name' => 'inetOrgPerson_l',
'description' => _('Location'), 'description' => _('Location'),
@ -432,7 +432,7 @@ class inetOrgPerson extends baseModule {
'example' => _('MyCity') 'example' => _('MyCity')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideState')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_st', 'name' => 'inetOrgPerson_st',
'description' => _('State'), 'description' => _('State'),
@ -440,7 +440,7 @@ class inetOrgPerson extends baseModule {
'example' => _('New York') 'example' => _('New York')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideCarLicense')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_carLicense', 'name' => 'inetOrgPerson_carLicense',
'description' => _('Car license'), 'description' => _('Car license'),
@ -448,7 +448,7 @@ class inetOrgPerson extends baseModule {
'example' => _('yes') 'example' => _('yes')
); );
} }
if (!$this->configOptionSet('inetOrgPerson_hideOfficeName')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
$return['upload_columns'][] = array( $return['upload_columns'][] = array(
'name' => 'inetOrgPerson_physicalDeliveryOfficeName', 'name' => 'inetOrgPerson_physicalDeliveryOfficeName',
'description' => _('Office name'), 'description' => _('Office name'),
@ -494,64 +494,64 @@ class inetOrgPerson extends baseModule {
'givenName', 'givenName',
'sn' 'sn'
); );
if (!$this->configOptionSet('inetOrgPerson_hideDescription')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
$return['PDF_fields'][] = 'description'; $return['PDF_fields'][] = 'description';
} }
if (!$this->configOptionSet('inetOrgPerson_hideStreet')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
$return['PDF_fields'][] = 'street'; $return['PDF_fields'][] = 'street';
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostOfficeBox')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
$return['PDF_fields'][] = 'postOfficeBox'; $return['PDF_fields'][] = 'postOfficeBox';
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalCode')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
$return['PDF_fields'][] = 'postalCode'; $return['PDF_fields'][] = 'postalCode';
} }
if (!$this->configOptionSet('inetOrgPerson_hideLocation')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
$return['PDF_fields'][] = 'location'; $return['PDF_fields'][] = 'location';
} }
if (!$this->configOptionSet('inetOrgPerson_hideState')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
$return['PDF_fields'][] = 'state'; $return['PDF_fields'][] = 'state';
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$return['PDF_fields'][] = 'postalAddress'; $return['PDF_fields'][] = 'postalAddress';
} }
if (!$this->configOptionSet('inetOrgPerson_hideOfficeName')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
$return['PDF_fields'][] = 'officeName'; $return['PDF_fields'][] = 'officeName';
} }
if (!$this->configOptionSet('inetOrgPerson_hideRoomNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
$return['PDF_fields'][] = 'roomNumber'; $return['PDF_fields'][] = 'roomNumber';
} }
if (!$this->configOptionSet('inetOrgPerson_hideTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$return['PDF_fields'][] = 'telephoneNumber'; $return['PDF_fields'][] = 'telephoneNumber';
} }
if (!$this->configOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
$return['PDF_fields'][] = 'homePhone'; $return['PDF_fields'][] = 'homePhone';
} }
if (!$this->configOptionSet('inetOrgPerson_hideMobileNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
$return['PDF_fields'][] = 'mobileTelephoneNumber'; $return['PDF_fields'][] = 'mobileTelephoneNumber';
} }
if (!$this->configOptionSet('inetOrgPerson_hideFaxNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$return['PDF_fields'][] = 'facimilieTelephoneNumber'; $return['PDF_fields'][] = 'facimilieTelephoneNumber';
} }
if (!$this->configOptionSet('inetOrgPerson_hideEMailAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
$return['PDF_fields'][] = 'mail'; $return['PDF_fields'][] = 'mail';
} }
if (!$this->configOptionSet('inetOrgPerson_hideJobTitle')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$return['PDF_fields'][] = 'title'; $return['PDF_fields'][] = 'title';
} }
if (!$this->configOptionSet('inetOrgPerson_hideCarLicense')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
$return['PDF_fields'][] = 'carLicense'; $return['PDF_fields'][] = 'carLicense';
} }
if (!$this->configOptionSet('inetOrgPerson_hideEmployeeType')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$return['PDF_fields'][] = 'employeeType'; $return['PDF_fields'][] = 'employeeType';
} }
if (!$this->configOptionSet('inetOrgPerson_hideBusinessCategory')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$return['PDF_fields'][] = 'businessCategory'; $return['PDF_fields'][] = 'businessCategory';
} }
if (!$this->configOptionSet('inetOrgPerson_hideDepartments')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$return['PDF_fields'][] = 'departmentNumber'; $return['PDF_fields'][] = 'departmentNumber';
} }
if (!$this->configOptionSet('inetOrgPerson_hideManager')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
$return['PDF_fields'][] = 'manager'; $return['PDF_fields'][] = 'manager';
} }
@ -775,76 +775,76 @@ class inetOrgPerson extends baseModule {
} }
} }
// Load and check attributes // Load and check attributes
if (!$this->configOptionSet('inetOrgPerson_hideDescription')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
$this->attributes['description'][0] = $_POST['description']; $this->attributes['description'][0] = $_POST['description'];
} }
$this->attributes['sn'][0] = $_POST['sn']; $this->attributes['sn'][0] = $_POST['sn'];
if ( !get_preg($this->attributes['sn'][0], 'realname')) $errors[] = $this->messages['lastname'][0]; if ( !get_preg($this->attributes['sn'][0], 'realname')) $errors[] = $this->messages['lastname'][0];
$this->attributes['givenName'][0] = $_POST['givenName']; $this->attributes['givenName'][0] = $_POST['givenName'];
if (($this->attributes['givenName'][0] != '') && !get_preg($this->attributes['givenName'][0], 'realname')) $errors[] = $this->messages['givenName'][0]; if (($this->attributes['givenName'][0] != '') && !get_preg($this->attributes['givenName'][0], 'realname')) $errors[] = $this->messages['givenName'][0];
if (!$this->configOptionSet('inetOrgPerson_hideJobTitle')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$this->attributes['title'][0] = $_POST['title']; $this->attributes['title'][0] = $_POST['title'];
if ( !get_preg($this->attributes['title'][0], 'title')) $errors[] = $this->messages['title'][0]; if ( !get_preg($this->attributes['title'][0], 'title')) $errors[] = $this->messages['title'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideEMailAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
$this->attributes['mail'][0] = $_POST['mail']; $this->attributes['mail'][0] = $_POST['mail'];
if (($this->attributes['mail'][0] != '') && !get_preg($this->attributes['mail'][0], 'email')) $errors[] = $this->messages['email'][0]; if (($this->attributes['mail'][0] != '') && !get_preg($this->attributes['mail'][0], 'email')) $errors[] = $this->messages['email'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$this->attributes['telephoneNumber'][0] = $_POST['telephoneNumber']; $this->attributes['telephoneNumber'][0] = $_POST['telephoneNumber'];
if ( !get_preg($this->attributes['telephoneNumber'][0], 'telephone')) $errors[] = $this->messages['telephoneNumber'][0]; if ( !get_preg($this->attributes['telephoneNumber'][0], 'telephone')) $errors[] = $this->messages['telephoneNumber'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideMobileNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
$this->attributes['mobile'][0] = $_POST['mobileTelephoneNumber']; $this->attributes['mobile'][0] = $_POST['mobileTelephoneNumber'];
if ( !get_preg($this->attributes['mobile'][0], 'telephone')) $errors[] = $this->messages['mobileTelephone'][0]; if ( !get_preg($this->attributes['mobile'][0], 'telephone')) $errors[] = $this->messages['mobileTelephone'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideFaxNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$this->attributes['facsimileTelephoneNumber'][0] = $_POST['facsimileTelephoneNumber']; $this->attributes['facsimileTelephoneNumber'][0] = $_POST['facsimileTelephoneNumber'];
if ( !get_preg($this->attributes['facsimileTelephoneNumber'][0], 'telephone')) $errors[] = $this->messages['facsimileNumber'][0]; if ( !get_preg($this->attributes['facsimileTelephoneNumber'][0], 'telephone')) $errors[] = $this->messages['facsimileNumber'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideStreet')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
$this->attributes['street'][0] = $_POST['street']; $this->attributes['street'][0] = $_POST['street'];
if ( !get_preg($this->attributes['street'][0], 'street')) $errors[] = $this->messages['street'][0]; if ( !get_preg($this->attributes['street'][0], 'street')) $errors[] = $this->messages['street'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostOfficeBox')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
$this->attributes['postOfficeBox'][0] = $_POST['postOfficeBox']; $this->attributes['postOfficeBox'][0] = $_POST['postOfficeBox'];
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalCode')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
$this->attributes['postalCode'][0] = $_POST['postalCode']; $this->attributes['postalCode'][0] = $_POST['postalCode'];
if ( !get_preg($this->attributes['postalCode'][0], 'postalCode')) $errors[] = $this->messages['postalCode'][0]; if ( !get_preg($this->attributes['postalCode'][0], 'postalCode')) $errors[] = $this->messages['postalCode'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$this->attributes['postalAddress'][0] = $_POST['postalAddress']; $this->attributes['postalAddress'][0] = $_POST['postalAddress'];
if ( !get_preg($this->attributes['postalAddress'][0], 'postalAddress')) $errors[] = $this->messages['postalAddress'][0]; if ( !get_preg($this->attributes['postalAddress'][0], 'postalAddress')) $errors[] = $this->messages['postalAddress'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideEmployeeType')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$this->attributes['employeeType'][0] = $_POST['employeeType']; $this->attributes['employeeType'][0] = $_POST['employeeType'];
if ( !get_preg($this->attributes['employeeType'][0], 'employeeType')) $errors[] = $this->messages['employeeType'][0]; if ( !get_preg($this->attributes['employeeType'][0], 'employeeType')) $errors[] = $this->messages['employeeType'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
$this->attributes['homePhone'][0] = $_POST['homePhone']; $this->attributes['homePhone'][0] = $_POST['homePhone'];
if ( !get_preg($this->attributes['homePhone'][0], 'telephone')) $errors[] = $this->messages['homePhone'][0]; if ( !get_preg($this->attributes['homePhone'][0], 'telephone')) $errors[] = $this->messages['homePhone'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideRoomNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
$this->attributes['roomNumber'][0] = $_POST['roomNumber']; $this->attributes['roomNumber'][0] = $_POST['roomNumber'];
} }
if (!$this->configOptionSet('inetOrgPerson_hideBusinessCategory')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$this->attributes['businessCategory'][0] = $_POST['businessCategory']; $this->attributes['businessCategory'][0] = $_POST['businessCategory'];
if ( !get_preg($this->attributes['businessCategory'][0], 'businessCategory')) $errors[] = $this->messages['businessCategory'][0]; if ( !get_preg($this->attributes['businessCategory'][0], 'businessCategory')) $errors[] = $this->messages['businessCategory'][0];
} }
if (!$this->configOptionSet('inetOrgPerson_hideLocation')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
$this->attributes['l'][0] = $_POST['l']; $this->attributes['l'][0] = $_POST['l'];
} }
if (!$this->configOptionSet('inetOrgPerson_hideState')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
$this->attributes['st'][0] = $_POST['st']; $this->attributes['st'][0] = $_POST['st'];
} }
if (!$this->configOptionSet('inetOrgPerson_hideCarLicense')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
$this->attributes['carLicense'][0] = $_POST['carLicense']; $this->attributes['carLicense'][0] = $_POST['carLicense'];
} }
if (!$this->configOptionSet('inetOrgPerson_hideOfficeName')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
$this->attributes['physicalDeliveryOfficeName'][0] = $_POST['physicalDeliveryOfficeName']; $this->attributes['physicalDeliveryOfficeName'][0] = $_POST['physicalDeliveryOfficeName'];
} }
if (!$this->configOptionSet('inetOrgPerson_hideDepartments')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
if (isset($_POST['departmentNumber'])) { if (isset($_POST['departmentNumber'])) {
$this->attributes['departmentNumber'] = explode(';', $_POST['departmentNumber']); $this->attributes['departmentNumber'] = explode(';', $_POST['departmentNumber']);
// remove extra spaces // remove extra spaces
@ -856,7 +856,7 @@ class inetOrgPerson extends baseModule {
} }
} }
} }
if (!$this->configOptionSet('inetOrgPerson_hideManager')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
if ($_POST['manager'] != '-') { if ($_POST['manager'] != '-') {
$this->attributes['manager'][0] = $_POST['manager']; $this->attributes['manager'][0] = $_POST['manager'];
} }
@ -972,7 +972,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $cn), 'maxlength' => '255', 'value' => $cn),
array('kind' => 'help', 'value' => 'cn')); array('kind' => 'help', 'value' => 'cn'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideDescription')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDescription')) {
$description = ''; $description = '';
if (isset($this->attributes['description'][0])) $description = $this->attributes['description'][0]; if (isset($this->attributes['description'][0])) $description = $this->attributes['description'][0];
$return[] = array ( $return[] = array (
@ -1006,7 +1006,7 @@ class inetOrgPerson extends baseModule {
$return[] = array(array('kind' => 'text', 'td' => array('colspan' => 3))); $return[] = array(array('kind' => 'text', 'td' => array('colspan' => 3)));
} }
if (!$this->configOptionSet('inetOrgPerson_hideStreet')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet')) {
$street = ''; $street = '';
if (isset($this->attributes['street'][0])) $street = $this->attributes['street'][0]; if (isset($this->attributes['street'][0])) $street = $this->attributes['street'][0];
$return[] = array( $return[] = array(
@ -1015,7 +1015,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $street), 'maxlength' => '255', 'value' => $street),
array('kind' => 'help', 'value' => 'street')); array('kind' => 'help', 'value' => 'street'));
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostOfficeBox')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
$postOffice = ''; $postOffice = '';
if (isset($this->attributes['postOfficeBox'][0])) $postOffice = $this->attributes['postOfficeBox'][0]; if (isset($this->attributes['postOfficeBox'][0])) $postOffice = $this->attributes['postOfficeBox'][0];
$return[] = array( $return[] = array(
@ -1024,7 +1024,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $postOffice), 'maxlength' => '255', 'value' => $postOffice),
array('kind' => 'help', 'value' => 'postOfficeBox')); array('kind' => 'help', 'value' => 'postOfficeBox'));
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalCode')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode')) {
$postalCode = ''; $postalCode = '';
if (isset($this->attributes['postalCode'][0])) $postalCode = $this->attributes['postalCode'][0]; if (isset($this->attributes['postalCode'][0])) $postalCode = $this->attributes['postalCode'][0];
$return[] = array( $return[] = array(
@ -1033,7 +1033,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $postalCode), 'maxlength' => '255', 'value' => $postalCode),
array('kind' => 'help', 'value' => 'postalCode')); array('kind' => 'help', 'value' => 'postalCode'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideLocation')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')) {
$l = ''; $l = '';
if (isset($this->attributes['l'][0])) $l = $this->attributes['l'][0]; if (isset($this->attributes['l'][0])) $l = $this->attributes['l'][0];
$return[] = array( $return[] = array(
@ -1042,7 +1042,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $l), 'maxlength' => '255', 'value' => $l),
array('kind' => 'help', 'value' => 'l')); array('kind' => 'help', 'value' => 'l'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideState')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState')) {
$st = ''; $st = '';
if (isset($this->attributes['st'][0])) $st = $this->attributes['st'][0]; if (isset($this->attributes['st'][0])) $st = $this->attributes['st'][0];
$return[] = array( $return[] = array(
@ -1051,7 +1051,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $st), 'maxlength' => '255', 'value' => $st),
array('kind' => 'help', 'value' => 'st')); array('kind' => 'help', 'value' => 'st'));
} }
if (!$this->configOptionSet('inetOrgPerson_hidePostalAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
$postalAddress = ''; $postalAddress = '';
if (isset($this->attributes['postalAddress'][0])) $postalAddress = $this->attributes['postalAddress'][0]; if (isset($this->attributes['postalAddress'][0])) $postalAddress = $this->attributes['postalAddress'][0];
$return[] = array( $return[] = array(
@ -1060,7 +1060,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $postalAddress), 'maxlength' => '255', 'value' => $postalAddress),
array('kind' => 'help', 'value' => 'postalAddress')); array('kind' => 'help', 'value' => 'postalAddress'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideOfficeName')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
$physicalDeliveryOfficeName = ''; $physicalDeliveryOfficeName = '';
if (isset($this->attributes['physicalDeliveryOfficeName'][0])) $physicalDeliveryOfficeName = $this->attributes['physicalDeliveryOfficeName'][0]; if (isset($this->attributes['physicalDeliveryOfficeName'][0])) $physicalDeliveryOfficeName = $this->attributes['physicalDeliveryOfficeName'][0];
$return[] = array( $return[] = array(
@ -1069,7 +1069,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $physicalDeliveryOfficeName), 'maxlength' => '255', 'value' => $physicalDeliveryOfficeName),
array('kind' => 'help', 'value' => 'physicalDeliveryOfficeName')); array('kind' => 'help', 'value' => 'physicalDeliveryOfficeName'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideRoomNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
$roomNumber = ''; $roomNumber = '';
if (isset($this->attributes['roomNumber'][0])) $roomNumber = $this->attributes['roomNumber'][0]; if (isset($this->attributes['roomNumber'][0])) $roomNumber = $this->attributes['roomNumber'][0];
$return[] = array( $return[] = array(
@ -1081,7 +1081,7 @@ class inetOrgPerson extends baseModule {
$return[] = array(array('kind' => 'text', 'td' => array('colspan' => 3))); $return[] = array(array('kind' => 'text', 'td' => array('colspan' => 3)));
if (!$this->configOptionSet('inetOrgPerson_hideTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
$telephone = ''; $telephone = '';
if (isset($this->attributes['telephoneNumber'][0])) $telephone = $this->attributes['telephoneNumber'][0]; if (isset($this->attributes['telephoneNumber'][0])) $telephone = $this->attributes['telephoneNumber'][0];
$return[] = array( $return[] = array(
@ -1090,7 +1090,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $telephone), 'maxlength' => '255', 'value' => $telephone),
array('kind' => 'help', 'value' => 'telephoneNumber')); array('kind' => 'help', 'value' => 'telephoneNumber'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideHomeTelephoneNumber')) {
$homePhone = ''; $homePhone = '';
if (isset($this->attributes['homePhone'][0])) $homePhone = $this->attributes['homePhone'][0]; if (isset($this->attributes['homePhone'][0])) $homePhone = $this->attributes['homePhone'][0];
$return[] = array( $return[] = array(
@ -1099,7 +1099,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $homePhone), 'maxlength' => '255', 'value' => $homePhone),
array('kind' => 'help', 'value' => 'homePhone')); array('kind' => 'help', 'value' => 'homePhone'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideMobileNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideMobileNumber')) {
$mobile = ''; $mobile = '';
if (isset($this->attributes['mobile'][0])) $mobile = $this->attributes['mobile'][0]; if (isset($this->attributes['mobile'][0])) $mobile = $this->attributes['mobile'][0];
$return[] = array( $return[] = array(
@ -1108,7 +1108,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $mobile), 'maxlength' => '255', 'value' => $mobile),
array('kind' => 'help', 'value' => 'mobileTelephoneNumber')); array('kind' => 'help', 'value' => 'mobileTelephoneNumber'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideFaxNumber')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideFaxNumber')) {
$fax = ''; $fax = '';
if (isset($this->attributes['facsimileTelephoneNumber'][0])) $fax = $this->attributes['facsimileTelephoneNumber'][0]; if (isset($this->attributes['facsimileTelephoneNumber'][0])) $fax = $this->attributes['facsimileTelephoneNumber'][0];
$return[] = array( $return[] = array(
@ -1117,7 +1117,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $fax), 'maxlength' => '255', 'value' => $fax),
array('kind' => 'help', 'value' => 'facsimileTelephoneNumber')); array('kind' => 'help', 'value' => 'facsimileTelephoneNumber'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideEMailAddress')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEMailAddress')) {
$email = ''; $email = '';
if (isset($this->attributes['mail'][0])) $email = $this->attributes['mail'][0]; if (isset($this->attributes['mail'][0])) $email = $this->attributes['mail'][0];
$return[] = array( $return[] = array(
@ -1129,7 +1129,7 @@ class inetOrgPerson extends baseModule {
$return[] = array(array('kind' => 'text', 'td' => array('colspan' => 3))); $return[] = array(array('kind' => 'text', 'td' => array('colspan' => 3)));
if (!$this->configOptionSet('inetOrgPerson_hideJobTitle')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideJobTitle')) {
$title = ''; $title = '';
if (isset($this->attributes['title'][0])) $title = $this->attributes['title'][0]; if (isset($this->attributes['title'][0])) $title = $this->attributes['title'][0];
$return[] = array( $return[] = array(
@ -1138,7 +1138,7 @@ class inetOrgPerson extends baseModule {
'value' => $title), 'value' => $title),
array('kind' => 'help', 'value' => 'title')); array('kind' => 'help', 'value' => 'title'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideCarLicense')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideCarLicense')) {
$carLicense = ''; $carLicense = '';
if (isset($this->attributes['carLicense'][0])) $carLicense = $this->attributes['carLicense'][0]; if (isset($this->attributes['carLicense'][0])) $carLicense = $this->attributes['carLicense'][0];
$return[] = array( $return[] = array(
@ -1147,7 +1147,7 @@ class inetOrgPerson extends baseModule {
'value' => $carLicense), 'value' => $carLicense),
array('kind' => 'help', 'value' => 'carLicense')); array('kind' => 'help', 'value' => 'carLicense'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideEmployeeType')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
$employeeType = ''; $employeeType = '';
if (isset($this->attributes['employeeType'][0])) $employeeType = $this->attributes['employeeType'][0]; if (isset($this->attributes['employeeType'][0])) $employeeType = $this->attributes['employeeType'][0];
$return[] = array( $return[] = array(
@ -1156,7 +1156,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $employeeType), 'maxlength' => '255', 'value' => $employeeType),
array('kind' => 'help', 'value' => 'employeeType')); array('kind' => 'help', 'value' => 'employeeType'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideBusinessCategory')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideBusinessCategory')) {
$businessCategory = ''; $businessCategory = '';
if (isset($this->attributes['businessCategory'][0])) $businessCategory = $this->attributes['businessCategory'][0]; if (isset($this->attributes['businessCategory'][0])) $businessCategory = $this->attributes['businessCategory'][0];
$return[] = array( $return[] = array(
@ -1165,7 +1165,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $businessCategory), 'maxlength' => '255', 'value' => $businessCategory),
array('kind' => 'help', 'value' => 'businessCategory')); array('kind' => 'help', 'value' => 'businessCategory'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideDepartments')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideDepartments')) {
$departmentNumber = ''; $departmentNumber = '';
if (isset($this->attributes['departmentNumber'][0])) $departmentNumber = implode(';', $this->attributes['departmentNumber']); if (isset($this->attributes['departmentNumber'][0])) $departmentNumber = implode(';', $this->attributes['departmentNumber']);
$return[] = array( $return[] = array(
@ -1185,7 +1185,7 @@ class inetOrgPerson extends baseModule {
'maxlength' => '255', 'value' => $hostvalue ), 'maxlength' => '255', 'value' => $hostvalue ),
array('kind' => 'help', 'value' => 'workstations')); array('kind' => 'help', 'value' => 'workstations'));
} }
if (!$this->configOptionSet('inetOrgPerson_hideManager')) { if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hideManager')) {
// get list of existing users for manager attribute // get list of existing users for manager attribute
$dnUsers = $_SESSION['cache']->get_cache('uid', 'inetOrgPerson', 'user'); $dnUsers = $_SESSION['cache']->get_cache('uid', 'inetOrgPerson', 'user');
if (!is_array($dnUsers)) $dnUsers = array(); if (!is_array($dnUsers)) $dnUsers = array();
@ -2042,25 +2042,6 @@ class inetOrgPerson extends baseModule {
return $return; return $return;
} }
/**
* Returns if the given configuration option is set.
* This function returns false if the configuration options cannot be read.
*
* @param String $optionName name of the option
* @return boolean true if option is set
*/
private function configOptionSet($optionName) {
//print_r($this->moduleSettings);die;
// abort if configuration is not available
if (!isset($this->moduleSettings) || !is_array($this->moduleSettings)) {
return false;
}
if (isset($this->moduleSettings[$optionName][0]) && ($this->moduleSettings[$optionName][0] == 'true')) {
return true;
}
return false;
}
} }
?> ?>