Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - markc

Pages: [1]
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, 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 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 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 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 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

Feng Office 2 / Quick question on search in FO 2.x
« on: August 30, 2012, 01:13:06 pm »
Has there been any increase in the number of fields that can be searched for Contacts or other objects? I looked at some bits of the code and didn't see much new, but some of the new stuff may not be in the same places as before

In our 1.7.5 install I managed to add the Contacts object's 'Department' field in the code and in the 'searchable_objects' table so we could search on that field. I need to add some others but I think we'll be upgrading to 2.x before too long so I don't want to go through the trouble if 2.x is better in this regard.

I don't need a detailed list or anything, just a general idea if there are a lot of new searchable fields in 2.x (or if the schema of the search index in 2.x has changed enough that I should wait).

Community Contributions / vcard improvement (by itself!)
« on: August 01, 2011, 05:55:22 pm »
First off, thanks to everyone who works on FO. The new 'getting started' screen looks particularly great, among other things.

Some time back I made some improvements to the vcard import/export that were merged into the FO code. They helped but unfortunately, even today (even on the Sky demo) you cannot export, delete, and then re-import a contact without losing data!

If you try this procedure:
-Create new contact
-Fill in most of the addresses and phone numbers and other fields
-Export vcard
-Trash and delete the contact
-Import the vcard you just exported

...that will result in over half of the contact's phone numbers disappearing (and those that survive are in the wrong order). Also, the Middlename and Department fields disappear as well.

This is just what the software does to natively exported vcards; you don't even want to know what happens when the vcard is 3rd party, and includes newline-folded address lines or QP encoded strings. (Outlook vcards have both)

The attached patch fixes all but one of these problems (the folded lines in 3rd party vcards remain an issue). However, it enables you to export a vcard and re-import it without losing data, including many of the fields that are not in the vcard spec like 'Department'. Even that part is done according to spec though, because it is exported with an 'X-' to signify a custom field. It also does a much better job with importing 3rd party vcards and it can now handle QP encoded strings.

This is NOT the version of the patch that adds fields to Contact objects, which I had posted before. That one modified a lot of code and other stuff including the MySQL schema and lang strings.

This version only modifies 2 functions in ./application/controllers/ContactController.class.php so it should be infinitely easier to evaluate. It doesn't touch the schema or lang stuff or any other code. This one I'm attaching is updated for v1.7.5 (but read the install note below!).

If you find any bugs or have any questions please let me know.

Thank you,

Somewhere around v1.7.3 the file ContactController.class.php (along with most of the rest of the php code files) changed from using unix line endings to using dos line endings. The attached patch file uses unix line endings and the 'patch' binary (at least the one I have) will not apply it successfully unless you change the line endings in the target file. (I do ':set ff=unix' in vim or 'flip -u')

Once that is done I'm using something along the lines of:
# cd /example/path/to/fengoffice
# sudo patch -p1 --dry-run < /example/path/to/vcard_ups_for_v175.patch

How To's / No "Getting Started" when I double-click Overview button.
« on: July 29, 2011, 04:54:22 pm »
I have a test feng site and a production feng site which are both @ v1.7.5.

On the test site (which was a recent clean install), I get the "Getting Started" page and I can Close it. It says to double-click Overview to get it back. This works.

On the production site (which was manually upgraded from 1.7.2) no one gets the "Getting Started" page even though it is set as the default user preference (enable). When I double click Overview it just says 'Loading...' for a second and then nothing happens.

What I know so far:
-It is the same in Firefox and IE for both FO admins and regular users.
-I do not get an error in-browser (even if I turn on debug) and I get nothing in ./cache/log.php.
-There is no difference in behavior if "./application/views/dashboard/widget_getting_started.php" is chmod 000 or 777 so I put it back to what it was (644).
-If that same file is missing I do get major errors when I double-click Overview.
-The entire fengoffice install is owned by the same user running apache.

Any ideas?

Thank you in advance for any assistance,

Applications / Search within Contact's Department field
« on: September 27, 2010, 12:40:03 pm »
I've tried to make it so that the search box will search within the Department field of my Contact objects but it hasn't been working.

I remember adding the name of the field to $searchable_columns in /application/models/contacts/Contact.class.php but I don't think it worked. It has been a bit now so I don't remember if I tried anything else.

Any ideas?

Thank you,

Community Contributions / New version of previous vcard submission
« on: July 27, 2010, 07:33:21 pm »
See here for background:

I've done a re-write of the previous version. I also have a version of the patch that adds a second and third address line to each address (see ) and because I also have several versions for 1.6.2 and 1.7 in various states of completion...the scope is getting a bit beyond me. I'm not quite as sure about this version because I can't as easily visualize all versions of my entire code. It has gotten a bit big to keep my head wrapped around, but I think I'm just imagining problems at this point. I'm an IT guy, not a coder!  :)

However! I'm pleased to say that the code works great for us; much better than the last one (which went into 1.7). Some examples of the improvement is that it can classify phone numbers better, it understands parameters better ( "TYPE=HOME,WORK;" and "TYPE=HOME;TYPE=WORK" come out looking the same! ), and for contacts that are already in FO it can usually do a lossless export and reimport including FO only fields. It tags those FO only fields as custom in the export and the importer knows where to look. AFAIK the way it does this is within the vcard spec.

It is commented out for a later version, but this code was also close to being able to handle strings that are have their own delimiter escaped within a field. The regex matches odd or even numbers of backslashes to tell preg_match_all() whether to break to the next field or print the backslashes and the delimiter literally. Didn't quite get that part working.

I'm going to attach four versions of "v2 final", if you will. At one point each one was thoroughly tested and I THINK I've kept them cleanly applying to their various code-bases. You might be able to apply them and use them in production straight-out, but I'm only using the last one from here on out.

Since my patch list has been growing it is my hope that the vcard part will get committed, and that maybe even the devs will see value in having two more address lines in the contacts object (since vcard supports it and that support is already working in that version of this patch). It'd let me juggle less but I suppose I'll live if I have to keep updating these patches myself to your new versions. :)

Same patch instructions as the last version. I think that is about it. Let me know if you have any questions.

Hope these help,

1. vcard v2 for 1.6.2
2. vcard v2 for 1.6.2 w/ address line 2/3 expansion
3. vcard v2 for 1.7
4. vcard v2 for 1.7 w/ address line 2/3 expansion    <(in production!)

On 1.6.1 and 1.6.2 if I go to Administration -> Add User and select Create contact with user data when creating the user, the contact that is created will have the users email address listed for both email1 and email2.

This is because during this code block around line 740 of ../application/functions.php:
Code: [Select]
       $contact = $user->getContact();
        if ($contact instanceof Contact) {
                // update contact data with data entered for this user
                // make user's email the contact's main email address
                if ($contact->getEmail2() == $user->getEmail()) {
                } else if ($contact->getEmail3() == $user->getEmail()) {
                } else if ($contact->getEmail2() == "") {
                } else {

the software is trying to change the order that the addresses are listed so that it can set the contact's address to be the same as the user's address. However, the code fails to check whether the user and contact already have the same address, resulting in Email1 (previously created during the create_user function) getting moved to Email2, and a duplicate Email1 being put in its place.

I believe the patch I've attached resolves the issue by skipping the entire block of code if $contact->getEmail and $user->getEmail are already the same.

As always though...please let me know if I'm over-looking something horribly obvious.


P.S. I haven't used the patch program much in the past so this may be helpful info... In my own environment, a cd into the root of fengoffice before "patch -p1 < ...path_to_patch_file..." seems to resolve the issue.

I do not believe this to be causing a bug, and parts of it could be intentional, but it appears to be a copy/paste that wasn't fleshed out.

I'm sure there are bigger problems but I thought I'd make mention of it here...since I found no previous mention when searching for the function names.



getFullOtherAddress's comment says that is gets the full work address,

         * Returns the full work address
         * @return string
        function getFullOtherAddress()
                $line1 = $this->getOAddress();

getFullHomeAddress has no comment over it at all.

Also, even though these functions (I'm assuming) are the same except for the type of address they are retrieving, they differ in how they initialize some of their lines.

How To's / Adding fields to Contact objects
« on: March 17, 2010, 05:07:50 pm »

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 -> 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

Older versions / "Error: The file does not exists" Contact import failure
« on: January 22, 2010, 06:51:25 pm »

I wanted to share that I was having a similar issue to the one in this thread:
"unable to import contacts"

I was doing this from my Windows 7 machine, and tried opening up the NTFS permissions on the file wide open. I also tried running my browser as admin. I edited ./fengoffice/php.ini to look like:
Code: [Select]
max_execution_time = 300
post_max_size = 10M
upload_max_filesize = 10M
memory_limit = 64M try and see if it was failing during upload. I also temporarily set ./fenoffice/upload/ to permissions 777.

None of these things helped. What fixed it was to cut my import file into two pieces. It turns out that my file was 2.23mb and anything under ~2mb would proceed fine. Anything bigger would fail with the error "The file does not exists."

I hope this is helpful.

Thank you,

fengoffice 1.6.1
ubuntu server 8.04 LTS x86

Pages: [1]