Hi,

Since we use the 'registeredAddress' attribute I had to add it to LAM.
Since the attribute is very similar to 'postalAddress', I simply copied
everything regarding the 'postalAddress' and changed to 'registeredAddress'.

I also changed the 'printHelpLink' (lib/modules.inc), 'displayHelp'
(templates/help.php) and  get_help (lib/baseModule.inc) functions  so
that the LDAP attribute name is shown in 'tooltip' and in help.

Both patches are attached. If this could or should be done in a
different, better way, I'm open to suggestions.


  Best regards, Danilo

diff -Nur ldap-account-manager-3.5.0-orig//lib/account.inc 
ldap-account-manager-3.5.0/lib/account.inc
--- ldap-account-manager-3.5.0-orig//lib/account.inc    2011-08-09 
19:18:59.000000000 +0200
+++ ldap-account-manager-3.5.0/lib/account.inc  2011-11-02 15:46:01.505449966 
+0100
@@ -422,6 +422,9 @@
                case "postalAddress":   // Allow all but \, <, >, =, ?
                                        $pregexpr = '/^[^\\\<>=\\?]*$/';
                                        break;
+               case "registeredAddress":       // Allow all but \, <, >, =, ?
+                                       $pregexpr = '/^[^\\\<>=\\?]*$/';
+                                       break;
                case "postalCode":      // Allow all but \, <, >, =, ?
                case "street":
                case "title":
diff -Nur ldap-account-manager-3.5.0-orig//lib/modules/inetOrgPerson.inc 
ldap-account-manager-3.5.0/lib/modules/inetOrgPerson.inc
--- ldap-account-manager-3.5.0-orig//lib/modules/inetOrgPerson.inc      
2011-08-09 19:18:59.000000000 +0200
+++ ldap-account-manager-3.5.0/lib/modules/inetOrgPerson.inc    2011-11-02 
16:00:11.281451774 +0100
@@ -63,6 +63,8 @@
                $this->messages['street'][1] = array('ERROR', _('Account %s:') 
. ' inetOrgPerson_street', _('Please enter a valid street name!'));
                $this->messages['postalAddress'][0] = array('ERROR', _('Postal 
address'), _('Please enter a valid postal address!'));
                $this->messages['postalAddress'][1] = array('ERROR', _('Account 
%s:') . ' inetOrgPerson_address', _('Please enter a valid postal address!'));
+               $this->messages['registeredAddress'][0] = array('ERROR', 
_('Registered address'), _('Please enter a valid address!'));
+               $this->messages['registeredAddress'][1] = array('ERROR', 
_('Account %s:') . ' inetOrgPerson_registeredaddress', _('Please enter a valid 
address!'));
                $this->messages['postalCode'][0] = array('ERROR', _('Postal 
code'), _('Please enter a valid postal code!'));
                $this->messages['postalCode'][1] = array('ERROR', _('Account 
%s:') . ' inetOrgPerson_postalCode', _('Please enter a valid postal code!'));
                $this->messages['title'][0] = array('ERROR', _('Job title'), 
_('Please enter a valid job title!'));
@@ -111,7 +113,7 @@
                        'mobileTelephoneNumber' => 'mobile', 'organizationName' 
=> 'o');
                // managed attributes
                $return['attributes'] = array('uid', 'cn', 'employeeType', 
'givenName', 'jpegPhoto', 'mail', 'manager', 'mobile',
-                       'title', 'telephoneNumber', 'facsimileTelephoneNumber', 
'street', 'postOfficeBox', 'postalCode', 'postalAddress',
+                       'title', 'telephoneNumber', 'facsimileTelephoneNumber', 
'street', 'postOfficeBox', 'postalCode', 'postalAddress', 'registeredAddress',
                        'sn', 'userPassword', 'description', 'homePhone', 
'roomNumber', 'businessCategory', 'l', 'st', 'physicalDeliveryOfficeName',
                        'carLicense', 'departmentNumber', 'o', 
'employeeNumber', 'initials');
                // self service search attributes
@@ -119,7 +121,7 @@
                // self service field settings
                $return['selfServiceFieldSettings'] = array('firstName' => 
_('First name'), 'lastName' => _('Last name'),
                        'mail' => _('Email address'), 'telephoneNumber' => 
_('Telephone number'), 'mobile' => _('Mobile number'),
-                       'faxNumber' => _('Fax number'), 'street' => 
_('Street'), 'postalAddress' => _('Postal address'),
+                       'faxNumber' => _('Fax number'), 'street' => 
_('Street'), 'postalAddress' => _('Postal address'), 'registeredAddress' => 
_('Registered address'),
                        'postalCode' => _('Postal code'), 'postOfficeBox' => 
_('Post office box'), 'jpegPhoto' => _('Photo'),
                        'homePhone' => _('Home telephone number'), 'roomNumber' 
=> _('Room number'), 'carLicense' => _('Car license'),
                        'location' => _('Location'), 'state' => _('State'), 
'officeName' => _('Office name'), 'businessCategory' => _('Business category'),
@@ -144,6 +146,9 @@
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
                        $profileElements[] = new 
htmlTableExtendedInputField(_('Postal address'), 'inetOrgPerson_postalAddress', 
null, 'postalAddress');
                }
+               if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
+                       $profileElements[] = new 
htmlTableExtendedInputField(_('Registered address'), 
'inetOrgPerson_registeredAddress', null, 'registeredAddress');
+               }
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideTelephoneNumber')) {
                        $profileElements[] = new 
htmlTableExtendedInputField(_('Telephone number'), 
'inetOrgPerson_telephoneNumber', null, 'telephoneNumber');
                }
@@ -215,6 +220,13 @@
                                'error_message' => 
$this->messages['postalAddress'][0]);
                        
$return['profile_mappings']['inetOrgPerson_postalAddress'] = 'postalAddress';
                }
+               if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
+                       
$return['profile_checks']['inetOrgPerson_registeredAddress'] = array(
+                               'type' => 'ext_preg',
+                               'regex' => 'registeredAddress',
+                               'error_message' => 
$this->messages['registeredAddress'][0]);
+                       
$return['profile_mappings']['inetOrgPerson_registeredAddress'] = 
'registeredAddress';
+               }
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
                        
$return['profile_mappings']['inetOrgPerson_postOfficeBox'] = 'postOfficeBox';
                }
@@ -239,6 +251,8 @@
                $configContainerOptions->addElement(new htmlOutputText(' '));
                $configContainerOptions->addElement(new 
htmlTableExtendedInputCheckbox('inetOrgPerson_hidePostalAddress', false, 
_('Postal address'), null, false));
                $configContainerOptions->addElement(new htmlOutputText(' '));
+               $configContainerOptions->addElement(new 
htmlTableExtendedInputCheckbox('inetOrgPerson_hideRegisteredAddress', false, 
_('Registered address'), null, false));
+               $configContainerOptions->addElement(new htmlOutputText(' '));
                $configContainerOptions->addElement(new 
htmlTableExtendedInputCheckbox('inetOrgPerson_hideOfficeName', false, _('Office 
name'), null, false));
                $configContainerOptions->addNewLine();
                $configContainerOptions->addElement(new 
htmlTableExtendedInputCheckbox('inetOrgPerson_hideRoomNumber', false, _('Room 
number'), null, false));
@@ -379,6 +393,14 @@
                                'example' => _('Mycity')
                        );
                }
+               if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
+                       $return['upload_columns'][] = array(
+                               'name' => 'inetOrgPerson_address',
+                               'description' => _('Registered address'),
+                               'help' => 'registeredAddress',
+                               'example' => _('Mycity')
+                       );
+               }
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')) {
                        $return['upload_columns'][] = array(
                                'name' => 'inetOrgPerson_postOfficeBox',
@@ -509,6 +531,9 @@
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')) {
                        $return['PDF_fields']['postalAddress'] = _('Postal 
address');
                }
+               if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
+                       $return['PDF_fields']['registeredAddress'] = 
_('Registered address');
+               }
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
                        $return['PDF_fields']['officeName'] = _('Office name');
                }
@@ -607,6 +632,10 @@
                                "Headline" => _("Postal address"),
                                "Text" => _("Postal address, city")
                        ),
+                       'registeredAddress' => array (
+                               "Headline" => _("Registered address"),
+                               "Text" => _("Registered address, city")
+                       ),
                        'telephoneNumber' => array (
                                "Headline" => _("Telephone number"),
                                "Text" => _("The user's telephone number.") . ' 
' . _('Multiple values are separated by semicolon.')
@@ -749,11 +778,15 @@
                        return array();
                }
                $return = 
$this->getAccountContainer()->save_module_attributes($this->attributes, 
$this->orig);
-               // postalAddress, facsimileTelephoneNumber and jpegPhoto need 
special removing
+               // registeredAddress, postalAddress, facsimileTelephoneNumber 
and jpegPhoto need special removing
                if 
(isset($return[$this->getAccountContainer()->dn]['remove']['postalAddress'])) {
                        
$return[$this->getAccountContainer()->dn]['modify']['postalAddress'] = array();
                        
unset($return[$this->getAccountContainer()->dn]['remove']['postalAddress']);
                }
+               if 
(isset($return[$this->getAccountContainer()->dn]['remove']['registeredAddress']))
 {
+                       
$return[$this->getAccountContainer()->dn]['modify']['registeredAddress'] = 
array();
+                       
unset($return[$this->getAccountContainer()->dn]['remove']['registeredAddress']);
+               }
                if 
(isset($return[$this->getAccountContainer()->dn]['remove']['facsimileTelephoneNumber']))
 {
                        
$return[$this->getAccountContainer()->dn]['modify']['facsimileTelephoneNumber'] 
= array();
                        
unset($return[$this->getAccountContainer()->dn]['remove']['facsimileTelephoneNumber']);
@@ -858,6 +891,10 @@
                        $this->attributes['postalAddress'][0] = implode('$', 
preg_split('/[\r][\n]/', $_POST['postalAddress']));
                        if (!get_preg($this->attributes['postalAddress'][0], 
'postalAddress')) $errors[] = $this->messages['postalAddress'][0];
                }
+               if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
+                       $this->attributes['registeredAddress'][0] = 
implode('$', preg_split('/[\r][\n]/', $_POST['registeredAddress']));
+                       if 
(!get_preg($this->attributes['registeredAddress'][0], 'registeredAddress')) 
$errors[] = $this->messages['registeredAddress'][0];
+               }
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideEmployeeType')) {
                        $this->attributes['employeeType'][0] = 
$_POST['employeeType'];
                        if (!get_preg($this->attributes['employeeType'][0], 
'employeeType')) $errors[] = $this->messages['employeeType'][0];
@@ -1003,7 +1040,8 @@
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideStreet') || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostOfficeBox')
                                || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalCode') || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideLocation')
                                || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideState') || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hidePostalAddress')
-                               || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName') || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')) {
+                               || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName') || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRoomNumber')
+                               || 
!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
                        $fieldContainer->addElement(new 
htmlSubTitle(_('Address')), true);
                }
 
@@ -1039,6 +1077,13 @@
                        }
                        $fieldContainer->addElement(new 
htmlTableExtendedInputTextarea('postalAddress', $postalAddress, 30, 3, 
_('Postal address'), 'postalAddress'), true);
                }
+               if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideRegisteredAddress')) {
+                       $registeredAddress = '';
+                       if (isset($this->attributes['registeredAddress'][0])) {
+                               $registeredAddress = implode("\r\n", 
explode('$', $this->attributes['registeredAddress'][0]));
+                       }
+                       $fieldContainer->addElement(new 
htmlTableExtendedInputTextarea('registeredAddress', $registeredAddress, 30, 3, 
_('Registered address'), 'registeredAddress'), true);
+               }
                if 
(!$this->isBooleanConfigOptionSet('inetOrgPerson_hideOfficeName')) {
                        $physicalDeliveryOfficeName = '';
                        if 
(isset($this->attributes['physicalDeliveryOfficeName'][0])) 
$physicalDeliveryOfficeName = 
$this->attributes['physicalDeliveryOfficeName'][0];
@@ -1241,6 +1286,10 @@
                if (isset($this->attributes['postalAddress'][0])) {
                        $postalAddress = $this->attributes['postalAddress'][0];
                }
+               $registeredAddress = '';
+               if (isset($this->attributes['registeredAddress'][0])) {
+                       $postalAddress = 
$this->attributes['registeredAddress'][0];
+               }
                $telephoneNumber = '';
                if (isset($this->attributes['telephoneNumber'][0])) {
                        $telephoneNumber = implode(', ', 
$this->attributes['telephoneNumber']);
@@ -1317,6 +1366,7 @@
                        get_class($this) . '_postOfficeBox' => 
array('<block><key>' . _('Post office box') . '</key><value>' . $postOfficeBox 
. '</value></block>'),
                        get_class($this) . '_postalCode' => 
array('<block><key>' . _('Postal code') . '</key><value>' . $postalCode . 
'</value></block>'),
                        get_class($this) . '_postalAddress' => 
array('<block><key>' . _('Postal address') . '</key><value>' . $postalAddress . 
'</value></block>'),
+                       get_class($this) . '_registeredAddress' => 
array('<block><key>' . _('Registered address') . '</key><value>' . 
$registeredAddress . '</value></block>'),
                        get_class($this) . '_telephoneNumber' => 
array('<block><key>' . _('Telephone number') . '</key><value>' . 
$telephoneNumber . '</value></block>'),
                        get_class($this) . '_homePhone' => array('<block><key>' 
. _('Home telephone number') . '</key><value>' . $homePhone . 
'</value></block>'),
                        get_class($this) . '_mobileTelephoneNumber' => 
array('<block><key>' . _('Mobile number') . '</key><value>' . $mobile . 
'</value></block>'),
@@ -1610,6 +1660,17 @@
                                        $errors[] = $errMsg;
                                }
                        }
+                       // registered address
+                       if ($rawAccounts[$i][$ids['inetOrgPerson_address']] != 
"") {
+                               if 
(get_preg($rawAccounts[$i][$ids['inetOrgPerson_address']], 
'registeredAddress')) {
+                                       
$partialAccounts[$i]['registeredAddress'] = 
$rawAccounts[$i][$ids['inetOrgPerson_address']];
+                               }
+                               else {
+                                       $errMsg = 
$this->messages['registeredAddress'][1];
+                                       array_push($errMsg, array($i));
+                                       $errors[] = $errMsg;
+                               }
+                       }
                        // telephone
                        if ($rawAccounts[$i][$ids['inetOrgPerson_telephone']] 
!= "") {
                                $telephoneList = preg_split('/;[ ]*/', 
$rawAccounts[$i][$ids['inetOrgPerson_telephone']]);
@@ -1788,6 +1849,13 @@
                                new htmlTableExtendedInputField(_('Postal 
address'), 'inetOrgPerson_postalAddress', $postalAddress)
                        ));
                }
+               if (in_array('registeredAddress', $fields)) {
+                       $registeredAddress = '';
+                       if (isset($attributes['registeredAddress'][0])) 
$registeredAddress = $attributes['registeredAddress'][0];
+                       $return['registeredAddress'] = new htmlTableRow(array(
+                               new htmlTableExtendedInputField(_('Postal 
address'), 'inetOrgPerson_registeredAddress', $registeredAddress)
+                       ));
+               }
                if (in_array('postalCode', $fields)) {
                        $postalCode = '';
                        if (isset($attributes['postalCode'][0])) $postalCode = 
$attributes['postalCode'][0];
@@ -1996,6 +2064,15 @@
                        }
                        elseif (isset($attributes['postalAddress'])) 
$attributesNew['postalAddress'] = array();
                }
+               // registered address
+               if (in_array('registeredAddress', $fields)) {
+                       $attributeNames[] = 'registeredAddress';
+                       if (isset($_POST['inetOrgPerson_registeredAddress']) && 
($_POST['inetOrgPerson_registeredAddress'] != '')) {
+                               if 
(!get_preg($_POST['inetOrgPerson_registeredAddress'], 'registeredAddress')) 
$return['messages'][] = $this->messages['registeredAddress'][0];
+                               else $attributesNew['registeredAddress'][0] = 
$_POST['inetOrgPerson_registeredAddress'];
+                       }
+                       elseif (isset($attributes['registeredAddress'])) 
$attributesNew['registeredAddress'] = array();
+               }
                // postal code
                if (in_array('postalCode', $fields)) {
                        $attributeNames[] = 'postalCode';

diff -Nur ldap-account-manager-3.5.0-orig/lib/baseModule.inc 
ldap-account-manager-3.5.0/lib/baseModule.inc
--- ldap-account-manager-3.5.0-orig/lib/baseModule.inc  2011-08-09 
19:18:59.000000000 +0200
+++ ldap-account-manager-3.5.0/lib/baseModule.inc       2011-11-03 
14:34:05.545452341 +0100
@@ -915,6 +915,7 @@
         */
        public function get_help($id) {
                if(isset($this->meta['help'][$id])) {
+                       $this->meta['help'][$id]["ID"]=$id;
                        return $this->meta['help'][$id];
                }
                elseif(isset($this->meta['help'][$this->scope][$id])) {
diff -Nur ldap-account-manager-3.5.0-orig/lib/modules.inc 
ldap-account-manager-3.5.0/lib/modules.inc
--- ldap-account-manager-3.5.0-orig/lib/modules.inc     2011-08-09 
19:18:59.000000000 +0200
+++ ldap-account-manager-3.5.0/lib/modules.inc  2011-11-03 15:38:07.045453086 
+0100
@@ -608,7 +608,11 @@
 function printHelpLink($entry, $number, $module='', $scope='') {
        $helpPath = "../";
        if (is_file("./help.php")) $helpPath = "";
-       $title = $entry['Headline'];
+       if (isset($entry['ID'])) {
+               $title = $entry['Headline'] . " (" . $entry['ID'] . ")";
+       } else {
+               $title = $entry['Headline'];
+       }
        $message = $entry['Text'];
        // replace special characters
        $message = str_replace(array("'", '"', "\n"), array("\\'", '&quot;', 
''), $message);
diff -Nur ldap-account-manager-3.5.0-orig/templates/help.php 
ldap-account-manager-3.5.0/templates/help.php
--- ldap-account-manager-3.5.0-orig/templates/help.php  2011-08-09 
19:18:59.000000000 +0200
+++ ldap-account-manager-3.5.0/templates/help.php       2011-11-03 
14:22:40.265451356 +0100
@@ -83,7 +83,7 @@
  */
 function displayHelp($helpEntry,$helpVariables) {
        echoHTMLHead();
-       echo "          <h1 class=\"help\">" . $helpEntry['Headline'] . 
"</h1>\n";
+       echo "          <h1 class=\"help\">" . $helpEntry['Headline'] . " (" . 
$helpEntry['ID'] . ")" . "</h1>\n";
        $format = "             <p class=\"help\">" . $helpEntry['Text'] . 
"</p>\n";
        array_unshift($helpVariables,$format);
        call_user_func_array("printf",$helpVariables);

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Lam-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lam-public

Reply via email to