Author Topic: Patch to add 2nd and 3rd street lines to all addresses (for v2.2.4.1)  (Read 6971 times)

markc

  • Freshman
  • *
  • Posts: 47
    • View Profile
General
The attached patch adds 2nd and 3rd street/address lines to all addresses of Contacts and Companies, which are supported or partially supported in things like Thunderbird, gmail, Outlook, and the vcard RFC. The patch is for FengOffice 2.2.4.1, and was recently (FINALLY!) rewritten from a 2.2.1 patch version that itself was a major redo from a patch to 1.7.5. The patch should be fairly comprehensive. It updates the address "display cards", their edit pages, the "quick create company" div from the user edit/add page, the import/export routines use the extra fields if present, and etc., etc. I even tried to match indention styles as not all files are the same, and I added the appropriate code for the 2nd and 3rd address lines even in places where the original code was commented out or only there for demonstration (that is, I left it commented, but updated it anyway).

Database changes:
The patch requires adding two fields: street2 and street3 to the table contact_addresses, both of which should have identical attributes to the existing street field in that table. I've included changes to ../public/install/installation/templates/sql/mysql_schema.php so if you apply the patch to the source tree BEFORE running the install you won't have to manually add these fields. However if you have good backups, know what you're doing, and understand that I take no responsibility... you technically can patch an existing 2.2.4.1 install and add the fields to the DB and be all set. Existing records will look no different regarding the street2 and street3 fields than they would for any other field that only had some records of a certain type set (like if phone was set and phone2 wasn't...perfectly normal).

Lang changes:
There was already an address2 field for other reasons so the only addition is:
Code: [Select]
'address3' => 'Address 3',As before I've only added it to en_us, but this time around it finally occurred to me that updating other languages can be done fairly accurately by comparing their existing address/address2 or email/email2/email3 lines and apply the same semantics for address3. I may still do this and post an update with the change.

Upgrading: (basically, no guarantees)
This patch is intended as something that might be merged to the official code, so I can't support it for anyone who uses it individually. If you decide to anyway though, this might help:

-You can't upgrade from any prior version to 2.2.4.1 using a tree that has this patch because I only made additions to the install schema, not the upgrade schema or migration scripts.
-Once you're up and going with a new or existing 2.2.4.1 install though, future upgrades are usually a matter of removing the patch, running the stock upgrade, and then re-applying (possibly a slightly modified version of) the patch. Usually only minor changes are needed to make it apply cleanly to a newer minor release. It wasn't as problematic in the late 1.X days, but even my 2.2.1 version wouldn't apply cleanly to 2.2.4.1. This may change again as 2.X continues to mature.

I may post updated versions when minor changes in the official code make it necessary, but I must point out that this is the first version of it I've posted since the one for 1.7.5 (so again, no guarantees). This was because going to 2.X the devs abstracted the addresses table away from the Contact and Company objects which, although it is a very, very awesome improvement and was well done by them, it made updating this patch rather daunting (and I've still got to update one more patch before I can move from 1.7.5).

Please let me know if you try this and find a bug.

...

Code: [Select]
luser@host:/var/www/fengoffice$ sudo patch -p1 < /home/luser/source/2241/addr2and3.patch
patching file application/controllers/ContactController.class.php
patching file application/models/contact_addresses/ContactAddress.class.php
patching file application/models/contact_addresses/base/BaseContactAddress.class.php
patching file application/models/contact_addresses/base/BaseContactAddresses.class.php
patching file application/models/contacts/Contact.class.php
patching file application/models/contacts/Contacts.class.php
patching file application/views/contact/add_company.php
patching file application/views/contact/card_content.php
patching file application/views/contact/company_card.php
patching file application/views/contact/company_content.php
patching file application/views/contact/edit_contact.php
patching file language/en_us/fields.php
patching file language/en_us/general.php
patching file public/assets/javascript/og/modules/addContactForm.js
patching file public/install/installation/templates/sql/mysql_schema.php
luser@host:/var/www/fengoffice$
« Last Edit: April 07, 2013, 07:07:04 am by markc »

markc

  • Freshman
  • *
  • Posts: 47
    • View Profile
Re: Patch to add 2nd and 3rd street lines to all addresses (for v2.2.4.1)
« Reply #1 on: April 07, 2013, 06:57:11 am »
The forum said the upload directory was full, and it also says I'm not allowed to post links, so here is a link to the patch with reversed starting slashes:

http:\\images.whattheit.com/addr2and3.patch

edit: and oddly, I just pasted that mangled url into firefox and IE and they both take it just fine!
« Last Edit: April 07, 2013, 06:59:45 am by markc »