diff --git a/contrib/openldap/core-fd-conf.schema b/contrib/openldap/core-fd-conf.schema index 643b38305c3a3e582a7155157edbbfbe229bdc8c..fa23ae862dcbe4325bdafedeb6d946de4dd5964b 100644 --- a/contrib/openldap/core-fd-conf.schema +++ b/contrib/openldap/core-fd-conf.schema @@ -142,6 +142,19 @@ attributetype ( 1.3.6.1.4.1.38414.8.12.19 NAME 'fdRestrictRoleMembers' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) +attributetype ( 1.3.6.1.4.1.38414.8.12.20 NAME 'fdSplitPostalAddress' + DESC 'FusionDirectory - Expose street, postOfficeBox and postalCode fields instead of postalAddress' + EQUALITY booleanMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 + SINGLE-VALUE ) + +attributetype ( 1.3.6.1.4.1.38414.8.12.21 NAME 'fdPostalAddressPattern' + DESC 'FusionDirectory - When using separate address fields, you can use a pattern to fill postalAddress field' + EQUALITY caseExactIA5Match + SUBSTR caseExactIA5SubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 + SINGLE-VALUE) + # Password attributetype ( 1.3.6.1.4.1.38414.8.13.1 NAME 'fdPasswordDefaultHash' @@ -518,7 +531,7 @@ objectclass ( 1.3.6.1.4.1.38414.8.2.1 NAME 'fusionDirectoryConf' fdStrictNamingRules $ fdMinId $ fdUidNumberBase $ fdGidNumberBase $ fdUserRDN $ fdGroupRDN $ fdIdAllocationMethod $ fdGidNumberPoolMin $ fdUidNumberPoolMin $ fdGidNumberPoolMax $ fdUidNumberPoolMax $ - fdAclRoleRDN $ fdCnPattern $ fdRestrictRoleMembers $ + fdAclRoleRDN $ fdCnPattern $ fdRestrictRoleMembers $ fdSplitPostalAddress $ fdPostalAddressPattern $ fdPasswordDefaultHash $ fdPasswordMinLength $ fdPasswordMinDiffer $ fdHandleExpiredAccounts $ fdSaslRealm $ fdSaslExop $ fdForcePasswordDefaultHash $ diff --git a/include/class_pluglist.inc b/include/class_pluglist.inc index 4adcad5ab2813481a284d14b3fa46a5d65bcc36b..8cc9dcc5c83f3717ff1443940a3daaf924b49e38 100644 --- a/include/class_pluglist.inc +++ b/include/class_pluglist.inc @@ -149,7 +149,7 @@ class pluglist { $this->info[$depend]['plDepending'] = array($cname); } } else { - trigger_error("$cname depends off the inexisting plugin $depend"); + trigger_error("$cname depends of the inexisting plugin $depend"); } } } diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc index 8b29b79fd6669cd1b297a2becd3f7ed74609d864..0ae86f7bca522c118c805847e491a4fb68837e8d 100644 --- a/plugins/config/class_configInLdap.inc +++ b/plugins/config/class_configInLdap.inc @@ -377,6 +377,14 @@ class configInLdap extends simplePlugin _('Restrict role members'), _('When enabled only users from the same branch or members of groups from the same branch can be added to a role.'), 'fdRestrictRoleMembers' ), + new BooleanAttribute ( + _('Separate address fields'), _('Expose street, postOfficeBox and postalCode fields instead of postalAddress.'), + 'fdSplitPostalAddress' + ), + new PostalAddressAttribute ( + _('Postal address pattern'), _('When using separate address fields, you can use a pattern to fill postalAddress field.'), + 'fdPostalAddressPattern' + ), ) ), 'debug' => array( diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 91110edbb462d8f23bc5ba37c523551edaac99cb..245a7cb61deaf21d38b6fe82e67ceb6a7bc549b8 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -300,8 +300,9 @@ class user extends simplePlugin // The main function : information about attributes static function getAttributesInfo () { + global $config; $languages = array_merge(array('' => ''), get_languages(TRUE)); - return array( + $attributesInfo = array( 'perso' => array( 'name' => _('Personal information'), 'icon' => 'geticon.php?context=types&icon=user&size=16', @@ -445,6 +446,25 @@ class user extends simplePlugin ) ), ); + if ($config->get_cfg_value('SplitPostalAddress') == 'TRUE') { + $attributesInfo['contact']['attrs'][2]->setVisible(FALSE); + array_splice($attributesInfo['contact']['attrs'], 3, 0, array( + new StringAttribute ( + _('Street'), _('Street part of the address'), + 'street', FALSE + ), + new StringAttribute ( + _('Post office box'), _('Post office box'), + 'postOfficeBox', FALSE + ), + new IntAttribute ( + _('Postal code'), _('Postal code'), + 'postalCode', FALSE, + 0, FALSE + ), + )); + } + return $attributesInfo; } function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) @@ -478,6 +498,11 @@ class user extends simplePlugin { global $config; $pattern = $config->get_cfg_value('CnPattern', '%givenName% %sn%'); + $this->attributesAccess['cn']->setValue($this->applyPattern($pattern)); + } + + private function applyPattern ($pattern) + { $fields = templateHandling::listFields($pattern); $attrs = array(); foreach ($fields as $field) { @@ -496,7 +521,8 @@ class user extends simplePlugin } trigger_error('Could not find field '.$field.' in any tab!'); } - $this->attributesAccess['cn']->setValue(templateHandling::parseString($pattern, $attrs)); + + return templateHandling::parseString($pattern, $attrs); } function compute_dn() @@ -520,6 +546,19 @@ class user extends simplePlugin return parent::execute(); } + protected function prepare_save () + { + global $config; + if ($config->get_cfg_value('SplitPostalAddress') == 'TRUE') { + $pattern = $config->get_cfg_value('PostalAddressPattern', ''); + if (!empty($pattern)) { + $this->postalAddress = $this->applyPattern($this->attributesAccess['postalAddress']->inputValue($pattern)); + } + } + + return parent::prepare_save(); + } + function ldap_save() { $errors = parent::ldap_save();