Author Topic: Adding fields to Contact objects  (Read 3375 times)

markc

  • Freshman
  • *
  • Posts: 47
    • View Profile
Adding fields to Contact objects
« on: March 17, 2010, 05:07:50 pm »
Hello,

I'm trying to add a second and third line to each address of my contact objects (e.g. w_address2, h_address3).

Based on comments on this thread -> http://forums.fengoffice.com/index.php?topic=619.0 I have added my fields to the mysql db, added them to the columns array, added getters and setters based on existing fields, and now I'm looking for errata. I just don't think adding a few lines to print functions is going to do it in this case.

Through a series of piped greps I've got the list of files that mention w_address (excluding other languages, for now):
Code: [Select]
/usr/share/fengoffice/language/en_us/fields.php:        'field Contacts w_address' => 'Work address',
/usr/share/fengoffice/language/en_us/project_interface.php:     'field w_address' => 'Work address',
/usr/share/fengoffice/public/install/installation/templates/sql/mysql_schema.php:       `w_address` varchar(200) <?php echo $default_collation ?> default NULL,
/usr/share/fengoffice/application/views/contact/edit_contact.php:                                       <td><?php echo text_field('contact[w_address]'array_var($contact_data'w_address'), array('id' => $genid.'profileFormWAddress''tabindex' => '75''maxlength' => 200)) ?></td>
/usr/share/fengoffice/application/controllers/ContactController.class.php:                      'w_address'=> $contact->getWAddress(),
/usr/share/fengoffice/application/controllers/ContactController.class.php:              $comp['address'] = array_var($contact_data, 'w_address');
/usr/share/fengoffice/application/controllers/ContactController.class.php:              if (isset($checked['w_address']) && $checked['w_address']) $contact_data['w_address'] = array_var($fields, $position['w_address']);
/usr/share/fengoffice/application/controllers/ContactController.class.php:              if (isset($checked['w_address']) && $checked['w_address'] == 'checked') $str .= self::build_csv_field($contact->getWAddress());
/usr/share/fengoffice/application/controllers/ContactController.class.php:                    $block_data["w_address"] = $addr[0];
/usr/share/fengoffice/application/models/contacts/Contacts.class.php:                   'contact[w_address]' => lang('address'),
/usr/share/fengoffice/application/models/contacts/Contact.class.php:    protected $searchable_columns = array('email', 'email2', 'email3', 'firstname', 'w_address', 'h_address', 'o_address');
/usr/share/fengoffice/application/models/contacts/Contact.class.php:            'w_address' => array('w_address', 'w_city', 'w_state', 'w_zipcode', 'w_country'),
/usr/share/fengoffice/application/models/contacts/Contact.class.php:            } else if($column_name == 'w_address') {
/usr/share/fengoffice/application/models/contacts/base/BaseContacts.class.php:     'w_address' => DATA_TYPE_STRING,
/usr/share/fengoffice/application/models/contacts/base/BaseContact.class.php:    * Return value of 'w_address' field
/usr/share/fengoffice/application/models/contacts/base/BaseContact.class.php:      return $this->getColumnValue('w_address');
/usr/share/fengoffice/application/models/contacts/base/BaseContact.class.php:    * Set value of 'w_address' field
/usr/share/fengoffice/application/models/contacts/base/BaseContact.class.php:      return $this->setColumnValue('w_address', $value);

You would think that I could just update them all, such as the 'get all address fields' type functions and it would all be dandy (assuming I'm updating h_address and etc. fields, too). However if you notice...those lines include things like '$addr[0]' which I see has references in:
Code: [Select]
/usr/share/fengoffice/environment/classes/mail/MailUtilities.class.php:                                 $name = $address != trim($addr[0]) ? trim($addr[0]) : "";
/usr/share/fengoffice/environment/classes/mail/MailUtilities.class.php:                                 $address = trim($addr[0]);
/usr/share/fengoffice/application/functions.php:                        if ($addr[0] == '"') {
/usr/share/fengoffice/application/controllers/ContactController.class.php:                    $block_data["h_address"] = $addr[0];
/usr/share/fengoffice/application/controllers/ContactController.class.php:                    $block_data["w_address"] = $addr[0];
/usr/share/fengoffice/application/controllers/ContactController.class.php:                    $block_data["o_address"] = $addr[0];

If someone wants to clarify for me to the last detail what to do that would be fantastic...but more realistically I'm curious if I'm close to the end of the trail or if this 'method' I'm using is going to drag me upside down through the source for the next two weeks.  ;D
« Last Edit: March 17, 2010, 05:10:32 pm by markc »

markc

  • Freshman
  • *
  • Posts: 47
    • View Profile
Re: Adding fields to Contact objects
« Reply #1 on: March 24, 2010, 12:45:05 pm »
Well, the lack of input is a little daunting...but so far this is going well.

Almost all of the work including getters and setters, mysql additions, etc is as simple as adding code for a second and third line wherever you see h_address and w_address and etc.

I have also added this line to the previous list of places that need editing:
/usr/share/fengoffice/language/en_us/general.php:    'address2' => 'Address 2',

...which, that lang entry is actually used for companies...but the original 'address' one seems to be in use for both contacts and companies so I'm adding an address3 and letting contacts and companies use them. I might even go back later and actually add the third line to the companies object.

The rest of the work consists of places where fields are statically mapped like I mentioned with places that have $addr[0]. Most of the code I've found for this so far seems to be related to the vcard import and export. Much to my delight the vcard spec allows for three (or maybe four...I need to re-read it) lines of address info, so I don't think I will have much left to do once I update the regex and field mapping for import and the print statements for export.