diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc index d0096e48bbf4fec93e6445ece3fa72e2592746fd..a4d781cefc4d1a7f44df1da435b7d90979f14921 100644 --- a/plugins/admin/departments/class_department.inc +++ b/plugins/admin/departments/class_department.inc @@ -99,7 +99,7 @@ class department extends simplePlugin new StringAttribute( _('Country'), _('Country'), 'co', FALSE ), - new TextAreaAttribute( + new PostalAddressAttribute( _('Address'), sprintf(_('A postal address for this %s'), $name), 'postalAddress', FALSE ), diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 94e19333ee717186f3eb623e1de8fc85fe47bf93..da7b9f2482565b02085c9f2ed3aca0ee4766edb4 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -233,6 +233,42 @@ class UserPasswordAttribute extends CompositeAttribute } } +class PostalAddressAttribute extends TextAreaAttribute +{ + function inputValue ($ldapValue) + { + $string = $ldapValue; + $offset = 0; + $lastslash = NULL; + while (preg_match('/[\\\$]/', $string, $m, PREG_OFFSET_CAPTURE, $offset)) { + $offset = $m[0][1] + 1; + if ($m[0][0] == '\\') { + if ($lastslash == $m[0][1] - 1) { + $string = substr_replace($string, '\\', $m[0][1] - 1, 2); + $offset = $m[0][1]; + $lastslash = NULL; + } else { + $lastslash = $m[0][1]; + } + } elseif ($m[0][0] == '$') { + if ($lastslash == $m[0][1] - 1) { + $string = substr_replace($string, '$', $m[0][1] - 1, 2); + $offset = $m[0][1]; + } else { + $string = substr_replace($string, "\n", $m[0][1], 1); + $offset = $m[0][1]; + } + } + } + return $string; + } + + function computeLdapValue () + { + return preg_replace("/\n/", '$', addcslashes($this->getValue(), '$\\')); + } +} + class user extends simplePlugin { var $objectclasses = array('inetOrgPerson','organizationalPerson','person'); @@ -308,7 +344,7 @@ class user extends simplePlugin _('State'), _('State'), 'st', FALSE ), - new TextAreaAttribute ( + new PostalAddressAttribute ( _('Address'), _('Business postal address'), 'postalAddress', FALSE ), @@ -366,7 +402,7 @@ class user extends simplePlugin _('Display name'), _('Name this user should appear as. Used by Exchange.'), 'displayName', FALSE ), - new TextAreaAttribute ( + new PostalAddressAttribute ( _('Home address'), _('Home postal address'), 'homePostalAddress', FALSE ),