Commit 669e221b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5361 Added an option to use separate fields for postalAddress

parent c6cfecd4
......@@ -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 $
......
......@@ -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");
}
}
}
......
......@@ -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(
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment