4

I'm wrestling with where and how to best make modifications to the CiviMail new mailing form, built with Angular. There are several other questions addressing this in part, but none address my needs completely.

The customization is pretty simple: include the logged in user's email as an option in the From Address selector and set it as the default.

What I've found is that:

1) I can't simply modify the from address list using the optionValues() hook. There are some oddities with from_email_addresses passed to that hook -- not all of the values are passed for modification. And because the select2 widget in the angular form is set to filter on is_active, any values I add via the hook are ignored (the hook only let's me work with the basic option list; I have no access to other record metadata).

2) Even if I use a php override of the CRM/Mailing/Info.php file and alter the from address values passed to angular, the default value is being set in some mystery way that I've not been able to find. Altering the is_default value and weight so that my desired option is the default has no impact.

3) In general, it seems very difficult to target angular forms via a hook in order to inject js. Maybe I'm missing something obvious, but the pageRun() hook doesn't seem to give me enough to be able to condition the injection of js adequately.

Any tips would be much appreciated.

  • Have a look here civicrm.stackexchange.com/a/12061 and here civicrm.stackexchange.com/a/11543 you can hook into angular declaring a 'fake/empty' module and loading it via hook_civicrm_angularModules, then you can target CiviMail's angular Directives, Services, Controllers, etc and change their behaviour when crmMailing bootstraps – Andrei Dec 19 '16 at 22:58
1

What about modifying the option list itself? So pick a hook that fires whenever the new mailing page is loaded (hook pageRun or something) and use the api to check if the current user's email is an option in that list. If not, add it

That gets you halfway there... not sure about setting it as the default. I suppose if you made it the default every time the hook fires, then it would temporarily be the default for whoever is composing a mailing.

  • per my observation 3 above, there's no clear way to target the mailing form via pageRun(). the object passed to the hook has elements generic to all angular pages -- I don't see any way to filter by the mailing page. – lcdservices Dec 19 '16 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.