CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Email Amender
Pages: [1]

Author Topic: Email Amender  (Read 606 times)

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Email Amender
February 16, 2014, 09:13:14 am
Hi guys,

I've written a brand new extension: the Email Amender.

This passively corrects common spelling errors in email addresses. .cpm instead of .com, hotmai instead of hotmail, etc.

It also lets you maintain your own lists of corrections through a handy interface - nothing is hardcoded here.

It's far smarter than just a search and replace - hotmai@hotmai.hotmai.com will be corrected to hotmai@hotmai.hotmail.com.

It needs someone to review and sign off on it - any takers?

https://civicrm.org/extensions/email-amender

Thanks,
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Email Amender
February 17, 2014, 11:34:59 am
Looks pretty cool! I haven't had a chance to test it, but a few low-level suggestions/comments from skimming the code:

 * In https://github.com/JohnFF/Email-Amender/blob/master/emailamender.php#L26 , the function create_activity_type_if_doesnt_exist should be prefixed (eg "emailamender_create_activity_type_if_doesnt_exist()" or "_emailamender_create_activity_type_if_doesnt_exist()").

 * In https://github.com/JohnFF/Email-Amender/blob/master/templates/CRM/Emailamender/Page/EmailAmenderSettings.js , it adds several functions to the global namespace. This probably works now but can produce conflicts when scaled to lots of extensions. It's generally better practice to put JS inside a closure or the CRM object, e.g.

Code: [Select]
// Example 1: Putting myFunc in a closure
cj(function($) {
  var myFunc = function(...) { ...}

  $('.my-selector').whatever(...);
});

// Example 2: Putting myFunc in CRM
var CRM = CRM || {};
CRM.EmailAmender = CRM.EmailAmender || {};
CRM.EmailAmender.myFunc = function(...) { ... }

 * The install/uninstall does some work to manage "settings". For future reference, hook_civicrm_alterSettingsFolders ( http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders ) provides a way to declaratively define settings (using files like https://github.com/civicrm/civicrm-core/blob/master/settings/Core.setting.php ). This has the upshot of integrating better with the Settings API and CiviConfigure. Of course, if you've already tested the current setup process, then it's probably better to stick with your current code. But next time you need to declare some settings, give it a try.

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Re: Email Amender
February 18, 2014, 01:27:35 pm
Thanks Totten!
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Email Amender

This forum was archived on 2017-11-26.